<?php
session_start();
if( $_SESSION["user"] == "" || $_SESSION["passwd"] == "" ) {
   mysqli_close($conn);
//   header("Location: traficoIndex.php");
}

if(isset($_SESSION['screen_width']) AND isset($_SESSION['screen_height'])){
   $screen_width =  $_SESSION['screen_width'];
   $screen_height =  $_SESSION['screen_height']; 
} else if(isset($_REQUEST['width']) AND isset($_REQUEST['height'])) {
    $_SESSION['screen_width'] = $_REQUEST['width'];
    $_SESSION['screen_height'] = $_REQUEST['height'];
    header('Location: ' . $_SERVER['PHP_SELF']);
} else {
    echo '<script type="text/javascript">window.location = "' . $_SERVER['PHP_SELF'] . '?width="+screen.width+"&height="+screen.height;</script>';
}

include_once('db_config_hosting.php');
ini_set('max_execution_time', 240);

$page = $_SERVER['PHP_SELF'];
$sec = "30";
header("Refresh: $sec; url=$page");

$Year     = isset($_POST['year']) ? $_POST["year"]  : "";
$Month  = isset($_POST['month']) ? $_POST['month'] : "";
$Fecha = "";
$Total_Llamados = 0;
$Total_Minutos = 0;
$Importe_Total = 0;
$Total_Dia_Llamados = 0;
$Total_Dia_Minutos = 0;
$Importe_Dia_Total = 0;

$YS2015 = "";
$YS2016 = "";
$YS2017 = "";
$YS2018 = "";
$YS2019 = "";
$YS2020 = "";
$YS2021 = "";
$width = "85%";

$url = "http://10.0.65.11/event_cli.php";

if( empty($Year) ) {        
   if( $_SESSION["Year"] != "" ) $Year = $_SESSION["Year"];
   else {
      $Year = date("Y");
   }
}

if( empty($Month) ) {       
   if( $_SESSION["Month"] != "" ) $Month = $_SESSION["Month"];
   else {
     $Month = date("n");
   }
}

$_SESSION["Year"] = $Year;
$_SESSION["Month"] = $Month;

$informes = $_SESSION["informes"];


$sm = array("", "", "", "", "", "", "", "", "", "", "", "");
$sm[$Month-1] = "selected";

if( $Year == "2015")  $YS2015 = "selected";
if( $Year == "2016")  $YS2016 = "selected";
if( $Year == "2017")  $YS2017 = "selected";
if( $Year == "2018")  $YS2018 = "selected";
if( $Year == "2019")  $YS2019 = "selected";
if( $Year == "2020")  $YS2020 = "selected";
if( $Year == "2021")  $YS2021 = "selected";
$admin = false;
$Movistar = 0.9225;
$Movistar = 1.476; 
$Personal = 1.476;
$Personal_New = 1.575;
$Claro =  0.738;
$Nextel = 1.107;
include 'traficoHeader.php'; 

function cnvSegundosHoras($tiempo_en_segundos) {

   $dias = floor($tiempo_en_segundos / 86400 );
   $tiempo_en_segundos -= ( $dias * 86400 );

   $horas = floor($tiempo_en_segundos / 3600);
   $minutos = floor(($tiempo_en_segundos - ($horas * 3600)) / 60);
   $segundos = $tiempo_en_segundos - ($horas * 3600) - ($minutos * 60);

   /*
   if( $dias > 30 ) {
       $meses = floor( $dias / 30 );
       $dias = $dias - ( $meses * 30 );
       $meses .= "m";
   }
   else $meses = "";
   */
   $meses = "";

//   if( $horas > 0 )
      return( sprintf("%s %dd %dh %02d&apos; %02d\"", $meses, $dias, $horas, $minutos, $segundos ) ); 
//   return( sprintf("%d:%02d", $minutos, $segundos) ); 
}
?>
<style>

.tabs {
  height: 40px !important;
}

.tabs.tabs-transparent {
  background-color: transparent;
}

.tabs.tabs-transparent .tab a,
.tabs.tabs-transparent .tab.disabled a,
.tabs.tabs-transparent .tab.disabled a:hover {
  color: rgba(255, 255, 255, 0.7);
}

.tabs.tabs-transparent .tab a:hover,
.tabs.tabs-transparent .tab a.active {
  color: #fff;
}

.tabs.tabs-transparent .indicator {
  background-color: #fff;
}

.tabs.tabs-fixed-width {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
}

.tabs.tabs-fixed-width .tab {
  -webkit-box-flex: 1;
  -webkit-flex-grow: 1;
      -ms-flex-positive: 1;
          flex-grow: 1;
}

.tabs .tab {
  line-height: 40px !important;
  height: 40px !important;
/*  text-transform: uppercase; */
  text-transform: none !important;
}

.tabs .tab a {
  color: #16a2d6 !important;
  -webkit-transition: color .28s ease, background-color .28s ease;
  transition: color .28s ease, background-color .28s ease;
}

.tabs .tab a:focus, .tabs .tab a:focus.active {
  background-color: rgba(22, 162, 214, 0.9) !important; 
  color: white !important;
  outline: none;
}

.tabs .tab a:hover, .tabs .tab a.active {
  color: #16a2d6 !important;
}

.tab a.active {
  color: white !important;
}

.tabs .tab.disabled a,
.tabs .tab.disabled a:hover {
  color: #16a2d6 !important;
}

.tabs .indicator {
  position: absolute;
  bottom: 0;
  height: 2px;
  background-color: #16a2d6;
  will-change: left, right;
}

.active {
   border: none !important;
}

.card {
-webkit-box-shadow: 0px 12px 15px -5px rgba(0,0,0,0.59); 
box-shadow: 0px 12px 15px -5px rgba(0,0,0,0.59);

}

th, td {
   padding: 0px;
}

.dropdown-content {
  overflow-x: hidden;
}

th, td {
   font-size: 11pt;
   font-weight: normal;
}

td {
   line-height:2.5em;
}

thead {
   border-bottom: none !important;
}

th {
   margin-bottom: 20px !important;
   text-decoration: underline;
   color: blue;
/*
   padding-bottom: 10px !important;
   border-width: 1px !important;
   border-bottom: solid !important;
   border-color: red !important;
   */
}

.select-wrapper input.select-dropdown {
   color: black;
   font-size:11pt;
}

.select-dropdown.dropdown-content li.selected,
.select-dropdown.dropdown-content li.selected:hover {
    background-color: rgba(0, 0, 0, 0.03);
    color: #666666;
    padding: 10px 16px !important;
}

.select-dropdown.dropdown-content li:hover {
    background-color: #16a2d6 !important;
    color: white!important;
    line-height: 16px !important;
}

.dropdown-content li {
    padding: 10px 16px !important;
}

.dropdown-content li > a, .dropdown-content li > span {
    color: inherit;
}


.dropdown-content li:focus,
.dropdown-content li > a, .dropdown-content li > span {
  font-size: 14px;
 //  color: black !important;
  color: #444444;
  display: block;
  line-height: 16px !important;
  padding: 10px 16px;
  margin: 0 0;
}

.tfecha:hover, .tllamados:hover,
.tminutos:hover, .tpromedio:hover,
.tsep:hover, .timporte:hover, tsva:hover {
   cursor: pointer;
}
.myDisabled {
   color: #666666 !important;
}

label.active {
   color: #930000 !important;
}
</style>
<?php
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_URL,"http://10.0.65.11/event_cli.php");
            curl_setopt ($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, "option=uptime");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $uptime = curl_exec($ch);
            curl_close($ch);

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_URL,"http://10.0.65.11/event_cli.php");
            curl_setopt ($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, "option=status");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = curl_exec($ch);
            curl_close($ch);

            $obj = json_decode( $response );
            $status = $obj->{'response'};

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_URL,"http://10.0.65.11/event_cli.php");
            curl_setopt ($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, "option=status_detener");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $status_detener = curl_exec($ch);
            curl_close($ch);

            if( $status_detener == 1 ) $checked="checked";
            else $checked="";

            /* --- Cpu Usage  --- */
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_URL,"http://10.0.65.11/event_cli.php");
            curl_setopt ($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, "option=get_cpu_status");
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $cpu = curl_exec($ch);
            curl_close($ch);
         
            $obj = json_decode( $cpu );
            $cpu_avg = $obj->{'cpu'};
            $cpu_percent = $obj->{'percent'};
            $cpu_avg_5 = $obj->{'cpu_5'};
            $cpu_percent_5 = $obj->{'percent_5'};
            $cpu_avg_15 = $obj->{'cpu_15'};
            $cpu_percent_15 = $obj->{'percent_15'};


            $start_time = date( "d/m/Y H:i:s", time() - intval( $uptime ) );

            echo "<div class='card white' style='margin:0px;'>"; 
               echo "<div class='card-content black-text' style='border-top:none; !important'>"; 

                  echo "<div class='row' style='padding-left:20px;'>";
                     echo "<div class='input-field col s2'>";
                     echo "<label>";
                        echo "<input id='detener' type='checkbox' $checked/>";
                        echo "<span>Detener Llamados</span>";
                     echo "</label>";
                     echo "</div>";
                     echo "<div class='input-field col s2'>";
                     echo "<label>";
                        echo "<input id='desconectar' type='checkbox' />";
                        echo "<span>Forzar Desconexi&oacute;n</span>";
                     echo "</label>";
                     echo "</div>";
                     echo "<div class='input-field col s2'>";
                     echo "<label>";
                        echo "<input id='clean' type='checkbox' />";
                        echo "<span>Borrar Pantalla</span>";
                     echo "</label>";
                     echo "</div>";
                     echo "<div class='input-field col s2'>";
                     echo "<label>";
                        echo "<input id='hup' type='checkbox'/>";
                        echo "<span>Hangup Todos</span>";
                     echo "</label>";
                     echo "</div>";
                     echo "<div class='input-field col s2'></div>";
                     echo "<div class='input-field col s2'>";
                     echo "<button id='actualizar' onclick='Opciones(this);' class='btn waves-effect waves-light btn col s3 right-align' style='margin-top:10px; width:120px; height:33px; line-height:33px; padding-top:0px; text-transform:none;'>Actualizar</button>";
                     echo "</div>";
                  echo "</div>";

                  echo "<div style='height:40px;'></div>";
                  echo "<div class='row' style='padding-left:20px;'>";
                     echo "<div class='input-field col s1'>";
                        echo "<div>Estado</div>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='start' type='text' disabled class='myDisabled' value='" . $start_time . "' placeholder=''>";
                         echo "<label for='start'>Hora Activaci&oacute;n</label>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='uptime' type='text' disabled class='myDisabled' value='" . cnvSegundosHoras($uptime) . "' placeholder=''>";
                         echo "<label for='uptime'>Uptime</label>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='status' type='text' disabled class='myDisabled' value='" . $status->{'systemStatus'} . "' placeholder=''>";
                         echo "<label for='status'>Estado</label>";
                     echo "</div>";

                  echo "</div>";

                  echo "<div class='row' style='padding-left:20px;'>";
                     echo "<div class='input-field col s1'>";
                        echo "<div>Llamadas</div>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='activas' type='text' disabled class='myDisabled' value='" . $status->{'sessions'}->{'count'}->{'active'} . "' placeholder=''>";
                         echo "<label for='activas'>Activas</label>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='pico' type='text' disabled class='myDisabled' value='" . $status->{'sessions'}->{'count'}->{'peak'} . "' placeholder=''>";
                         echo "<label for='pico'>Pico</label>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='totales' type='text' disabled class='myDisabled' value='" . $status->{'sessions'}->{'count'}->{'total'} . "' placeholder=''>";
                         echo "<label for='totales'>Totales</label>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='maximas' type='text' disabled class='myDisabled' value='" . $status->{'sessions'}->{'count'}->{'limit'} . "' placeholder=''>";
                         echo "<label for='maximas'>M&aacute;ximas</label>";
                     echo "</div>";
                  echo "</div>";

                  echo "<div class='row' style='padding-left:20px;'>";
                     echo "<div class='input-field col s1'>";
                        echo "<div>Sesiones</div>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='actuales' type='text' disabled class='myDisabled' value='" . $status->{'sessions'}->{'rate'}->{'current'} . "' placeholder=''>";
                         echo "<label for='actuales'>Actuales</label>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='spico' type='text' disabled class='myDisabled' value='" . $status->{'sessions'}->{'rate'}->{'peak'} . "' placeholder=''>";
                         echo "<label for='spico'>Pico</label>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='smaximas' type='text' disabled class='myDisabled' value='" . $status->{'sessions'}->{'rate'}->{'max'} . "' placeholder=''>";
                         echo "<label for='smaximas'>M&aacute;ximas</label>";
                     echo "</div>";
                  echo "</div>";

                  echo "<div class='row' style='padding-left:20px;'>";
                     echo "<div class='input-field col s1'>";
                        echo "<div>Sistema</div>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='idlecpu' type='text' disabled class='myDisabled' value='" . $status->{'idleCPU'}->{'used'} . "' placeholder=''>";
                         echo "<label for='idlecpu'>Idle CPU</label>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='maxcpu' type='text' disabled class='myDisabled' value='" . $status->{'idleCPU'}->{'allowed'} . "' placeholder=''>";
                         echo "<label for='maxcpu'>Max CPU</label>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='stack' type='text' disabled class='myDisabled' value='" . $status->{'stackSizeKB'}->{'current'} . "KB / " . $status->{'stackSizeKB'}->{'max'} . "KB' placeholder=''>";
                         echo "<label for='stack'>Stack</label>";
                     echo "</div>";

                  echo "</div>";


                  echo "<div class='row' style='padding-left:20px;'>";
                     echo "<div class='input-field col s1'>";
                        echo "<div>CPU</div>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='idlecpu' type='text' disabled class='myDisabled' value='" . $cpu_percent . "%' placeholder=''>";
                         echo "<label for='idlecpu'>Ultimo Minuto</label>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='maxcpu' type='text' disabled class='myDisabled' value='" . $cpu_percent_5 . "%' placeholder=''>";
                         echo "<label for='maxcpu'>Ultimos 5 Minutos</label>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>";
                         echo "<input id='stack' type='text' disabled class='myDisabled' value='" . $cpu_percent_15 . "%' placeholder=''>";
                         echo "<label for='stack'>Ultimos 15 Minutos</label>";
                     echo "</div>";


                  echo "</div>";


/*
         $lines = json_decode( $line );
         print_r( $lines );
         $obj = $lines->{'response'};
         $sessions = $obj->{'sessions'};

         echo "System Status             : " . $obj->{'systemStatus'} . "\n\n";
         echo "Totales                   : " . $obj->{'sessions'}->{'count'}->{'total'} . "\n";
         echo "Activas                   : " . $obj->{'sessions'}->{'count'}->{'active'} . "\n";
         echo "Pico                      : " . $obj->{'sessions'}->{'count'}->{'peak'} . "\n";
         echo "Limite                    : " . $obj->{'sessions'}->{'count'}->{'limit'} . "\n";

         echo "Sesiones Maximas x Segundo: " . $obj->{'sessions'}->{'rate'}->{'max'} . "\n";
         echo "Sesiones Maximas Pico     : " . $obj->{'sessions'}->{'rate'}->{'peak'} . "\n";
         echo "Sesiones Actuals          : " . $obj->{'sessions'}->{'rate'}->{'current'} . "\n";


         echo " Idle CPU                 : " . $obj->{'idleCPU'}->{'used'} . "\n";
         echo "  Max CPU                 : " . $obj->{'idleCPU'}->{'allowed'} . "\n";

         echo "Stack Size Actual         : " . $obj->{'stackSizeKB'}->{'current'} . "Kb\n";
         echo "Stack Size Max            :    " . $obj->{'stackSizeKB'}->{'max'} . "Kb\n";
*/

                  echo "<div style='height:50px;'></div>";
                  /*
                  echo "<div class='row' style='padding-left:20px;'>";
                      echo "<div class='input-field col s3 m3'>";
                         echo "<select id='informes' name='informe'  onchange='onChange(this)'>";
                         echo "<option value= '1'>Detalle de Llamados</option>";
                         echo "<option value= '2'>Detalle</option>";
                         echo "</select>"; 
                        echo "<label>Informe</label>";
                     echo "</div>"; 

                     echo "<div id='field_desde' class='input-field col s2'>";
                     echo "<label for='desde'>Desde</label>";
                     echo "<input id='desde' type='text' class='datepicker' value='" . $D1 . "' onChange='onChange(this);'>";
                     echo "</div>";

                     echo "<div id='field_hasta' class='input-field col s2'>";
                     echo "<label for='hasta'>Hasta</label>";
                     echo "<input id='hasta' type='text' class='datepicker' value='" . $H1 . "' onChange='onChange(this);'>";
                     echo "</div>";

                     echo "<div class='input-field col s2'>&nbsp;</div>";

                     echo "<div class='input-field col s2 right-align' style='float:right;'>";
                     echo "<button id='visualizar' onclick='Opciones(this);' class='btn waves-effect waves-light btn col s3 right-align' style='margin-top:10px; width:120px; height:33px; line-height:33px; text-transform:none;'>Visualizar</button>";
                     echo "</div>";
                  echo "</div>"; 
                  */

                 echo "</div>";
               echo "</div>";
            echo "</div>";
         echo "</div>";
      echo "</div>";

?>    
   <script type="text/javascript" src="js/jquery.min.js"></script>
   <script type="text/javascript" src="js/jquery.form.js"></script> 
   <script type="text/javascript" src="materialize/1.0.0/js/materialize.js"></script>
   <script type="text/javascript">

   function post(path, parameters) {
      var form = $('<form></form>');

       form.attr("method", "post");
       form.attr("action", path);

       $.each(parameters, function(key, value) {
           var field = $('<input></input>');
           field.attr("type", "hidden");
           field.attr("name", key);
           field.attr("value", value);
           form.append(field);
       });

       // The form needs to be a part of the document in
       // order for us to be able to submit it.
       $(document.body).append(form);
        form.submit();
   };

   function linkDetalle( tr ) {
      var fecha = tr.find('#nfecha')[0].innerHTML;
//     console.log( fecha[0].innerHTML );
      console.log( fecha );
      post("traficoDetalle.php", {dia: fecha }); 
   }

   $(document).ready(function() {

      console.log( "READY!" );
      $('#month').on('change', function() {
         Month = this.value;
         console.log( this.value )
      });   
      $('#year').on('change', function() {
         Year = this.value;
         console.log( this.value )
      });   

      $('select').formSelect();
      $('.datepicker').datepicker({
         selectMonths: true, // Creates a dropdown to control month
         selectYears: 15, // Creates a dropdown of 15 years to control year
         months: [ 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre' ],
         monthsShort: [ 'Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic' ],
         weekdays: [ 'Domingo', 'Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado' ],
         weekdaysShort: [ 'Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab' ],
         weekdaysLetter: [ 'D', 'L', 'M', 'M', 'J', 'V', 'S' ],
         today: 'Hoy',
         clear: 'Borrar',
         cancel: 'Cerrar',
         format: 'dd-mm-yyyy',
         formatSubmit: 'yyyy-mm-dd'
      });


//  $('#detail tr').click(function() {

      $('.tabs').tabs();
      $('#tabs_menu').tabs();
      $('ul.tabs').tabs();

       $('#detail tbody').on('click', 'td.tfecha', function () { linkDetalle( $(this).closest('tr') ) });
       $('#detail tbody').on('click', 'td.tllamados', function () { linkDetalle( $(this).closest('tr') ) });
       $('#detail tbody').on('click', 'td.tminutos', function () { linkDetalle( $(this).closest('tr') ) });
       $('#detail tbody').on('click', 'td.tpromedio', function () { linkDetalle( $(this).closest('tr') ) });
       $('#detail tbody').on('click', 'td.tsep', function () { linkDetalle( $(this).closest('tr') ) });
       $('#detail tbody').on('click', 'td.timporte', function () { linkDetalle( $(this).closest('tr') ) });
       $('#detail tbody').on('click', 'td.sva', function () { linkDetalle( $(this).closest('tr') ) });

      $('#detail tbody').on('click', 'td.tgraph', function () {
         var tr = $(this).closest('tr');
         var fecha = tr.find('#nfecha')[0].innerHTML ;
         post("traficoDiario.php", {dia: fecha }); 
      });



      /*
      $('#detail tbody').on('click', 'tr', function () {
            console.log( "click tr" );
            var tr = $(this).closest('tr');
            console.dir( tr );

            var fecha = tr.find('#tfecha').val();
            console.log( fecha );
             post("traficoDetalle.php", {fecha: fecha }); 
//            post("traficoDetalle.php", {dia: name.substr(2,10) }); 
      });

//      $('#detail').on('click', 'tr', function(e) {
//          post("traficoDetalle.php", {dia: e.currentTarget.cells[0].innerHTML }); 
//      });
*/
  });   


   function onClick(e) {

      switch( e.id ) {
         case "0":
            post("traficoPanel.php", {t:0});
            break;

         case "1":
            post("traficoPanel.php", {t:1});
            break;

         case "2":
            post("traficoPanel.php", {t:2});
//            post("traficoGateways.php", {t:2});
            break;

         case "3":
            post("traficoPanel.php", {t:3});
//            post("traficoGateways.php", {t:2});
            break;

         case "4":
            post("traficoLlamados.php", {t:4});
            break;

         case "6":
            post("traficoOpciones.php", {t:5});
            break;

         case "5":
            post("traficoConference.php", {t:6});
            break;

         case "7":
            post("traficoAni.php", {t:7});
            break;
      }
   }


   function onChange(e) {

      console.dir( e );
      console.log( e.id );
      switch( e.id ) {

         case "informes":
            var tipo = $("#informes").val();

            if( tipo == "1" ) {
               $("#field_desde").css( 'display', '' ); 
               $("#field_hasta").css( 'display', '' ); 
            }
            else {
               $("#field_desde").css( 'display', 'none' ); 
               $("#field_hasta").css( 'display', 'none' ); 
            }
            break;
      }
   }

   function Opciones(e) {
      var url = <?php echo json_encode($url); ?>;

      switch( e.id ) {

         case "actualizar":
            var detener = 0;
            var desconectar = 0;
            var clean = 0;
            var hupall = 0;

            if ($('#clean').is(":checked")) clean = 1;
            if ($('#detener').is(":checked")) detener = 1;
            if ($('#desconectar').is(":checked")) desconectar = 1; 
            if ($('#hup').is(":checked")) hupall = 1; 
               

            $.ajax({
             type: "POST",
             url: url,
                data: { 'option': "actualizar_status", 'detener': detener, 'desconectar': desconectar, 'clean': clean, 'hupall': hupall },
                  success: function(data){
                     console.log( data );
//                     var msg = JSON.parse(data);
                  }
            });
            break;
      }
   }

</script>
</body>
</html>

