<?php
session_start();
if( $_SESSION["user"] == "" || $_SESSION["passwd"] == "" ) {
   $_SESSION["login_section"] = "workflow";
   header("Location: indexWorkflow.php");
}


$_SESSION["login_section"] = "workflow";
$_SESSION["module"] = "Dashboard";
$admin = $_SESSION["admin"];
$operador = $_SESSION["operador"];
$include_search = false;
 
$width = "80%";

include_once('db_config.php');
ini_set('max_execution_time', 120);

if( $admin == "" ) $admin = false;
if( $operador == "" ) $operador = "Test";
$admin = true;
$readonly = $_SESSION["readonly"];

include 'workflowHeader.php'; 
include('fusion/fusioncharts.php');
?>
<style>
/*nav ul a {
  color: white !important;
} */

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

.modal {
 overflow-y:inherit;
 }
tbody {
   padding: 0;
   margin:0;
   border-size:0;
}


/* Menu y Pagina Oscura */
body {
 background-color: #2a323e !important;
}
#content {
 background-color: #2a323e !important;
}

.dashboard {
   background-color: #2a323e ;
}

.nav-wrapper {
   background-color: #2a323e !important;
}


.nav-item {
  color: white !important;
}

.menu-item:hover {
   color: white !important;
}

.menu-item {
   color: black !important;
}

/* Menu y Pagina Oscura */

#hideAll
{
   position: fixed;
   left: 0px; 
   right: 0px; 
   top: 0px; 
   bottom: 0px; 
   background-color: white;
   z-index: 99; /* Higher than anything else in the document */
}
.dropdown-content li > a, .dropdown-content li > span {
//   width:200px !important;
   font-size: 14px !important;
}
nav ul a {
  color: white !important;
}


</style>
   <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<?php


$corte = 0;
$baja_velocidad = 0;
$otros = 0;
$totales = 0;
$conectados = 0;
$cortes = 0;

//   echo "<div style='display:hidden;' id='hideAll'>&nbsp;</div>";
   echo "<div id='content'>";
   echo "<div class='container' style='width:" . $width . ";' >";

   // Tareas Completadas ultimos 30 dias
   $sql = "select sql_no_cache count(id) as completadas from ag_tareas where ag_tareas.estado = 'Completada' and ( tipo = 1 or tipo = 7 or tipo = 21) and fecha >= date_sub( curdate(), interval 30 day )";
   $result = $conn->query($sql);
   if ($result->num_rows > 0) {
      if( $row = $result->fetch_assoc() ) {
         $completadas = $row["completadas"];
      }
      if( $result ) mysql_free_result( $result );
   }

   // Tareas Pendientes
   $sql = "select sql_no_cache count(id) as pendientes from ag_tareas where ag_tareas.estado = 'Pendiente' and ( tipo = 1 or tipo = 7 )";
   $result = $conn->query($sql);
   if ($result->num_rows > 0) {
      if( $row = $result->fetch_assoc() ) {
         $pendientes = $row["pendientes"];
      }
      if( $result ) mysql_free_result( $result );
   }

   // Retiros
   $sql = "select sql_no_cache count(id) as retiros  from ag_tareas where ag_tareas.estado = 'Pendiente' and tipo = 9";
   $result = $conn->query($sql);
   if ($result->num_rows > 0) {
      if( $row = $result->fetch_assoc() ) {
         $retiros = $row["retiros"];
      }
      if( $result ) mysql_free_result( $result );
   }

   // Atrasadas mas de 15 dias
   $sql = "select sql_no_cache count(id) as atrasadas from ag_tareas where ag_tareas.estado = 'Pendiente' and fecha <= date_sub( curdate(), interval 15 day )";
   $result = $conn->query($sql);
   if ($result->num_rows > 0) {
      if( $row = $result->fetch_assoc() ) {
         $atrasadas = $row["atrasadas"];
      }
      if( $result ) mysql_free_result( $result );
   }

  // Pedidos Pendientes Facibles para Coordinar
   $sql = "select sql_no_cache count(id) as coordinar from ag_pedidos where (factibilidad = '1' or factibilidad = '4') and estado = 'Pedido'";
   $result = $conn->query($sql);
   if ($result->num_rows > 0) {
      if( $row = $result->fetch_assoc() ) {
         $coordinar = $row["coordinar"];
      }
      if( $result ) mysql_free_result( $result );
   }

   // Pedidos Pendientes de Factibilidad
   $sql = "select sql_no_cache count(id) as factibilidad from ag_pedidos where factibilidad = '0' and estado = 'Pedido'";
   $result = $conn->query($sql);
   if ($result->num_rows > 0) {
      if( $row = $result->fetch_assoc() ) {
         $factibilidad = $row["factibilidad"];
      }
      if( $result ) mysql_free_result( $result );
   }


   // Reclamos Ultimos 30 dias
   $sql = "select sql_no_cache sum( case when causal_reclamo = 1 then 1 else 0 end ) as corte, sum( case when causal_reclamo = 2 then 1 else 0 end ) as baja_velocidad, sum( case when causal_reclamo > 2 then 1 else 0 end ) as otros  from tickets where fecha_reclamo >= date_sub(now(), interval 30 day)";
   $result = $conn->query($sql);
   if ($result->num_rows > 0) {
      if( $row = $result->fetch_assoc() ) {

         $corte = $row["corte"];
         $baja_velocidad = $row["baja_velocidad"];
         $otros = $row["otros"];
      }
      if( $result ) mysql_free_result( $result );
   }

   // Clientes Conectados
   $sql = "select sql_no_cache count(radacctid) as total from radacct where acctstoptime is NULL or acctstoptime =''";
   $result = $conn->query($sql);
   if ($result->num_rows > 0) {
      if( $row = $result->fetch_assoc()) {
         $conectados = $row["total"];
      }
      if( $result ) mysql_free_result( $result );
   }

   // Clientes Totales
   $sql = "select sql_no_cache count(id) as total from ag_users where situacion >= 1 and situacion <= 4 and estado = 'Instalado' and username <> ''";
   $sql = "select sql_no_cache count(id) as total from ag_users where situacion >= 1 and situacion <= 3 and estado = 'Instalado' and username <> ''";
   $result = $conn->query($sql);
   if ($result->num_rows > 0) {
      if( $row = $result->fetch_assoc()) {
         $totales = $row["total"];
      }
      if( $result ) mysql_free_result( $result );
   }

   // Clientes Morosos
   $sql = sprintf( "select sql_no_cache count(id) as total from ag_cortes where activo = 1" );
   $result = $conn->query($sql);
   if ($result->num_rows > 0) {
      if( $row = $result->fetch_assoc()) {
         $cortes = $row["total"];
      }
      if( $result ) mysql_free_result( $result );
   }


   // Consumo del Dia
   $sql = "select sql_no_cache date(acctstarttime) as fecha, sum(acctoutputoctets) as download, sum(acctinputoctets) as upload from radacct where date(acctstarttime) >= date_sub( Now() , interval 1 day )";
   $sql = "select sql_no_cache date(acctstarttime) as fecha, sum(acctoutputoctets) as download, sum(acctinputoctets) as upload from radacct where date(acctstarttime) >= date_sub( Now() , interval 1 day )";
   $result = $conn->query($sql);
   if ($result->num_rows > 0) {
      if( $row = $result->fetch_assoc() ) {
         $dn = $row["download"];
         $up = $row["upload"];
         $fecha = $row["fecha"];
      }
      if( $result ) mysql_free_result( $result );
   }

   $size_dn = $dn / (1024 * 1024 * 1024 * 1024);
   $size_up = $up / (1024 * 1024 * 1024 * 1024);

   echo "<div style='height:35px;'></div>";

   echo "<table style='width:100%;'>";
      echo "<tr style='border-style:none !important;'>";
         echo "<td style='width:100%; padding:0; margin:0; padding-right:3px; padding-bottom:3px;'>";
            echo "<div style=' height:500px;' id='chart-container'></div>";
         echo "</td>";
     echo "</tr>";
   echo "</table>";
   echo "<div style='height:5px;'></div>";

   echo "<table style='width:100%;'>";
     echo "<tr style='border-style:none !important;'>";
     echo "<td style='width:60%; padding:0; margin:0; padding-right:3px; padding-bottom:3px;' >";
         echo "<div id='reclamos'></div>";

         $xmlData = "<chart caption=\"Reclamos (Ultimos 30 dias)\" theme=\"candy\" showLabels=\"0\" use3DLighting=\"1\" pieSliceDepth=\"15\" ";
         $xmlData .= "showLegend=\"1\" manageLabelOverflow=\"1\" legendItemFontSize=\"10\" >";

         $sql = "select sql_no_cache diagnostico_reclamo, count(id_ticket) as cantidad from tickets where fecha_reclamo >= date_sub(now(), interval 30 day) group by diagnostico_reclamo";
         $result = $conn->query($sql);
         $first = 0;
         if ($result->num_rows > 0) {
            while( $row = $result->fetch_assoc() ) {

               $diagnostico = $row["diagnostico_reclamo"];
               $cantidad[$diagnostico] = $row["cantidad"];
               $cantidad = $row["cantidad"];

               switch( $diagnostico ) {
                  case '0': $text = "S/D";               break;
//                  case '0': $text = "No se detectaron problemas";               break;
                  case '1':  $text = "Cable/Ficha cortada";                     break; 
                  case '2':
                  case '3':  $text = "Trafo/ONU/Antena";                        break; 
                  case '4':  $text = "Perdida de configuracion";                break; 
                  case '7':  $text = "Baja se&ntilde;al";                       break; 
                  case '9':  $text = "Problema en nodo";                        break; 
                  case '10': $text = "Corte Fibra";                             break; 
                  case '11': $text = "Moroso";                                  break; 
                  case '12': $text = "No se detectaron problemas";              break;
                  case '13': $text = "Atribuido al cliente";                    break; 
                  case '14': $text = "Modem desconectado";                      break; 
                  case '16':
                  case '17': $text = "Corte de Luz";                            break; 
                  case '18': $text = "Mantenimiento";                           break; 
                  default:   $text = $diagnostico;                              break;  
               }
               $solucion[$diagnostico] = $text;
               $text = substr( $text, 0, 26 );
               
               if( $cantidad > 0 )  {
//                  if( $diagnostico == "12" ) $xmlData .= "<set label=\"" . $text . "\" value=\"" . $cantidad . "\" isSliced=\"1\" />"; 
                  if( $diagnostico == "112" ) $xmlData .= "<set label=\"" . $text . "\" value=\"" . $cantidad . "\" isSliced=\"1\" />"; 
                  else $xmlData .= "<set label=\"" . $text . "\" value=\"" . $cantidad . "\" />"; 
               }
//               echo "set label=\"" . $text . "\" value=\"" . $cantidad . "\"</br/>"; 
            }
            $xmlData .= "</chart>";
            if( $result ) mysql_free_result( $result );
         }
         $Chart = new FusionCharts("doughnut3d", "myreclamos" , "100%", "350", "reclamos", "xml", $xmlData);
         $Chart->render();
     echo "</td>";

     echo "<td style='width:40%; padding:0; margin:0; padding-right:3px; padding-bottom:3px;'>";
         echo "<div id='chart_tareas'></div>";
     echo "</td>";
     echo "</tr>";
   echo "</table>";

   if( $readonly == false ) {
   echo "<table style='width:100%;'>";
      echo "<tr style='border-style:none !important;'>";
         echo "<td style='width:61%; padding:0; margin:0; padding-right:3px; padding-bottom:3px;'>";
            echo "<div id='trafico'></div>";
         echo "</td>";
         echo "<td style='width:40%; padding:0; margin:0; padding-right:3px; padding-bottom:3px;'>";
            echo "<div id='clientes'></div>";
         echo "</td>";
     echo "</tr>";
   echo "</table>";
   }


   // Instalaciones mes a mes
   echo "<table style='width:98%; padding:0;'>";
     echo "<tr style='border-style:none !important;'>";
     echo "<td style='width:100%; padding:0; margin:0; padding-top:1px; padding-bottom:3px;'>";
         echo "<div id='instalaciones_php'></div>";

         $sql = "select sql_no_cache count(id) as cantidad, instalacion from ag_users where estado ='Instalado' and situacion < 5 and instalacion > date_sub(now(), interval 1 year ) group by concat( year(instalacion),month(instalacion) ) order by instalacion";
         $result = $conn->query($sql);

         $xmlData = "<chart caption=\"Instalaciones Mensuales\" yaxisname=\"Cantidad\" theme=\"ocean\" bgcolor=\"#262a33\" xAxisNameFontColor=\"#c0c0c0\" yAxisNameFontColor=\"#c0c0c0\" ";
         $xmlData .= "xAxisNameFontSize=\"15\" yAxisNameFontSize=\"15\" divlineisdashed=\"1\" divlinedashlen=\"1\" divlinegaplen=\"1\" ";
         $xmlData .= "showLabels=\"1\" labelFontColor=\"#ffffff\" captionFontColor=\"#ffffff\" captionFont=\"Roboto\" captionFontSize=\"16\" captionFontBold=\"0\" ";
         $xmlData .= "showValues=\"1\" placeValuesInside=\"1\" valueFontColor=\"#ffffff\" baseFontColor=\"#ffffff\" canvasBgColor=\"#262a33\" ";
         $xmlData .= ">";
         $categories = "<categories>";
         $dataset1 = "<dataset seriesname=\"Instalaciones\">";
         $dataset2 = "";
//         $dataset2 = "<dataset seriesname=\"Subida\">";

         if ($result->num_rows > 0) {
    		   while($row = $result->fetch_assoc()) {

               $fecha = date("m-Y", strtotime( $row["instalacion"] ) );
               $categories .= "<category label=\"$fecha\" />";
               $cantidad = $row["cantidad"];

//               $xmlData .= "<set label=\"$fecha\" value=\"$size_dn\" />";
               $dataset1 .= "<set value=\"$cantidad\" />";
//               $dataset2 .= "<set value=\"$size_up\" />";
            }
         }               
         $categories .= "</categories>";
         $dataset1 .= "</dataset>";
//         $dataset2 .= "</dataset>";
         $xmlData .= "$categories$dataset1$dataset2</chart>";
//         $Chart = new FusionCharts("mscolumn3d", "mytrafico" , "100%", "350", "trafico_php", "xml", $xmlData);
         $Chart = new FusionCharts("stackedcolumn3d", "myInstalaciones" , "100%", "350", "instalaciones_php", "xml", $xmlData);

         $Chart->render();

     echo "</td>";
     echo "</tr>";
   echo "</table>";

   // PHP Chart
   echo "<table style='width:99%; padding:0;'>";
     echo "<tr style='border-style:none !important;'>";
     echo "<td style='width:100%; padding:0; margin:0; padding-top:1px; padding-bottom:3px;'>";
         echo "<div id='trafico_php'></div>";

         $sql = "select sql_no_cache date(acctstarttime) as fecha, sum(acctoutputoctets) as download, sum(acctinputoctets) as upload from radacct where date(acctstarttime) >= date_sub( Now() , interval 15 day ) group by date(acctstarttime) ";
         $result = $conn->query($sql);

         $xmlData = "<chart caption=\"Trafico en Terabytes (Ultimos 15 dias)\" yaxisname=\"Trafico (en TB)\" theme=\"ocean\" bgcolor=\"#262a33\" xAxisNameFontColor=\"#c0c0c0\" yAxisNameFontColor=\"#c0c0c0\" ";
         $xmlData .= "xAxisNameFontSize=\"15\" yAxisNameFontSize=\"15\" divlineisdashed=\"1\" divlinedashlen=\"1\" divlinegaplen=\"1\" ";
         $xmlData .= "showLabels=\"1\" labelFontColor=\"#ffffff\" captionFontColor=\"#ffffff\" captionFont=\"Roboto\" captionFontSize=\"16\" captionFontBold=\"0\" ";
         $xmlData .= "showValues=\"1\" placeValuesInside=\"1\" numberSuffix=\"TB\" valueFontColor=\"#ffffff\" baseFontColor=\"#ffffff\" canvasBgColor=\"#262a33\" ";
         $xmlData .= ">";
         $categories = "<categories>";
         $dataset1 = "<dataset seriesname=\"Bajada\">";
         $dataset2 = "<dataset seriesname=\"Subida\">";

         if ($result->num_rows > 0) {
    		   while($row = $result->fetch_assoc()) {

               $fecha = date("d-m", strtotime( $row["fecha"] ) );
               $categories .= "<category label=\"$fecha\" />";
               $dn = $row["download"];
               $up = $row["upload"];
               $size_dn = $dn / (1024 * 1024 * 1024 * 1024);
               $size_up = $up / (1024 * 1024 * 1024 * 1024);

//               $xmlData .= "<set label=\"$fecha\" value=\"$size_dn\" />";
               $dataset1 .= "<set value=\"$size_dn\" />";
               $dataset2 .= "<set value=\"$size_up\" />";
            }
         }               
         $categories .= "</categories>";
         $dataset1 .= "</dataset>";
         $dataset2 .= "</dataset>";
         $xmlData .= "$categories$dataset1$dataset2</chart>";
//         $Chart = new FusionCharts("mscolumn3d", "mytrafico" , "100%", "350", "trafico_php", "xml", $xmlData);
         $Chart = new FusionCharts("stackedcolumn3d", "mytrafico" , "100%", "350", "trafico_php", "xml", $xmlData);

         $Chart->render();

     echo "</td>";
     echo "</tr>";
   echo "</table>";


   echo "<div style='height:35px;'></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.min.js"></script>
   <script type="text/javascript" src="materialize/1.0.0/js/jquery.dataTables.min.js"></script>


<script>

/*
   $(window).load(function() {  
      console.log( "load" );
      $("#hideAll").css("display","none" );
   });
   */

   $(document).ready(function() {
      $('.sidenav').sidenav();
      $('.dropdown-trigger').dropdown({
         "hover": true,
         "constrainWidth": false,
         "coverTrigger": false
      });

      /*
     setTimeout(function(){ 
         window.location.href = window.location.href;
     }, 60000);
     */
      $("#cover").fadeOut(200);

   });   


   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);
       });
       $(document.body).append(form);
      form.submit();
   };


   function pad_number(d)
   { 
     return (d < 10 ? '0' : '') + d;
   }


   FusionCharts.ready(function(){
//    Reclamos_Last30();
      Bandwidth();
      Pendientes_Proximos15();
      Clientes();
      Trafico();
   });

   function Clientes() {

      var conectados = <?php echo json_encode($conectados); ?>;
      var totales = <?php echo json_encode($totales); ?>;
      var morosos = <?php echo json_encode($cortes); ?>;

      var fusioncharts = new FusionCharts({
      type: 'mscolumn3d',
      renderAt: 'clientes',
      width: '100%',
      height: '350',
      dataFormat: 'json',
      dataSource: {
         "chart": {
               "caption": "Clientes Conectados/Totales",
               "showValues": "1",
               "showShadow": "1",
               "use3DLighting": "1",
               "showHoverEffect": "1",
               "placeValuesInside": "0",
//               "theme": "ocean",
//               "theme": "gammel",
               "theme": "candy",
               "captionFontSize": "16",
               "captionFont": "Roboto",
         },
         "categories": [
            {
               "category": [
                  {
                     "label": ""
                  }
               ]
            }
         ],
         "dataset": [
            {
               "seriesname": "Totales",
               "data": [
                 {
                   "value": totales
                 }
               ]
            },
            {
               "seriesname": "Conectados",
               "data": [
                  {
                     "value": conectados
                  }
               ]
            },
            {
               "seriesname": "Morosos",
               "data": [
                 {
                   "value": morosos
                 }
               ]
            }
         ]
      }
      });
      fusioncharts.render();
   }


   function Reclamos_Last30() {

      var corte = <?php echo json_encode($corte); ?>;
      var baja_velocidad = <?php echo json_encode($baja_velocidad); ?>;
      var otros = <?php echo json_encode($otros); ?>;

      var fusioncharts = new FusionCharts({
//      type: 'mscolumn3d',
      type: 'doughnut3d',
      renderAt: 'reclamos',
      width: '100%',
      height: '350',
      dataFormat: 'json',
      dataSource: {
         "chart": {
               "caption": "Reclamos Ultimos 30 dias",
//               "showValues": "1",
               "showShadow": "1",
               "use3DLighting": "1",
               "showHoverEffect": "1",
//               "theme": "ocean",
//               "theme": "gammel",
               "theme": "candy",
               "captionFontSize": "16",
               "captionFont": "Roboto",
         },
         "data": [
             {
               "label": "Baja Velocidad",
               "value": baja_velocidad
             },
             {
               "label": "Corte Total",
               "value": corte
             },
             {
               "label": "Otros",
               "value": otros
             }
           ]
      }
      });
      fusioncharts.render();
   }


   function Trafico() {

      var v1 = <?php echo json_encode($size_dn); ?>;
      var v2 = <?php echo json_encode($size_up); ?>;

      var fusioncharts = new FusionCharts({
//      type: 'mscolumn3d',
      type: 'doughnut3d',
      renderAt: 'trafico',
      width: '100%',
      height: '350',
      dataFormat: 'json',
      dataSource: {
         "chart": {
//               "caption": "Trafico en Terabytes Ultimas 24 horas",
               "caption": "Trafico en Terabytes del Dia",
               "showValues": "1",
               "showToolTip": "1",
               "numberSuffix": " TB",
               "enableRotation": "1",
               "showShadow": "1",
               "use3DLighting": "1",
               "showHoverEffect": "1",
//               "theme": "ocean",
//               "theme": "gammel",
               "theme": "candy",
               "captionFontSize": "16",
               "captionFont": "Roboto",
         },
         "data": [
             {
               "label": "Bajada",
               "value": v1
             },
             {
               "label": "Subida",
               "value": v2
             }
           ]
      }
      });
      fusioncharts.render();
   }


   function Pendientes_Proximos15() {

      var corte = <?php echo json_encode($corte); ?>;
      var baja_velocidad = <?php echo json_encode($baja_velocidad); ?>;
      var otros = <?php echo json_encode($otros); ?>;
      var pendientes = <?php echo json_encode($pendientes); ?>;
      var completadas = <?php echo json_encode($completadas); ?>;
      var coordinar = <?php echo json_encode($coordinar); ?>;
      var factibilidad = <?php echo json_encode($factibilidad); ?>;

      var fusioncharts = new FusionCharts({
      type: 'mscolumn3d',
      renderAt: 'chart_tareas',
      width: '100%',
      height: '350',
      dataFormat: 'json',
      dataSource: {
         "chart": {
               "caption": "Tareas Ultimos 15 dias",
               "showValues": "1",
               "showShadow": "1",
               "use3DLighting": "1",
               "showHoverEffect": "1",
//               "theme": "ocean",
//               "theme": "gammel",
               "theme": "candy",
               "captionFontSize": "16",
               "captionFont": "Roboto",
         },
         "categories": [
            {
               "category": [
                  {
                     "label": ""
                  }
               ]
            }
         ],
         "dataset": [
            {
               "seriesname": "Pendientes",
               "data": [
                  {
                     "value": pendientes
                  }
               ]
            },
            {
               "seriesname": "Completadas",
               "data": [
                 {
                     "value": completadas
                 }
               ]
            },
            {
               "seriesname": "A Coordinar",
               "data": [
                 {
                     "value": coordinar
                 }
               ]
            },
            {
               "seriesname": "Para Verificar",
               "data": [
                 {
                     "value": factibilidad
                 }
               ]
            }
         ]
      }
      });
      fusioncharts.render();
   }


   function fetchCheckStatus(response) {
      if (response.status >= 200 && response.status < 300) {
         return response;
      }
      const error = new Error(response.statusText);
      error.response = response;
      throw error;
   }

   function loadData(url) {
      const option = {
         method: 'GET',
         headers: new Headers(),
         mode: 'cors',
         cache: 'default',
      };

      return fetch(url, option)
       .then(fetchCheckStatus)
         .then(resp => {
            const contentType = resp.headers.get('Content-Type');
            if (contentType && contentType.indexOf('application/json') !== -1) {
               return resp.json();
            }
            console.log( resp.text() );
            return resp.text();
         })
         .then(data => data)
         .catch(() => {
            console.log('Something went wrong! Please check data/schema files');
         });
   }


   function loadSql(url) {
      var progress = $.Deferred();
      $.post(url,{}, 
          function (data) { 
            return progress.resolve(data);
         }
      );
//    return progress.reject(false);
      return progress.promise();
   }


   function Bandwidth() {

      Promise.all([
//           loadData('https://s3.eu-central-1.amazonaws.com/fusion.store/ft/data/line-chart-with-time-axis-data.json'),
//         loadData('https://s3.eu-central-1.amazonaws.com/fusion.store/ft/schema/line-chart-with-time-axis-schema.json')
//             loadData('http://tareas.escobarnorte.com.ar/data/line-chart-with-time-axis-data.json'),
//           loadData('http://tareas.escobarnorte.com.ar/data/line-chart-with-time-axis-schema.json')
//            loadData('http://tareas.escobarnorte.com.ar/data/data.json'),
            loadSql("workflowBandwithData.php"),
            loadData("http://tareas.escobarnorte.com.ar/data/wanBandwidth.json")
      ]).then(res => {
         const [data, schema] = res; 
      
         console.dir( data );
         console.dir( schema );
         const dataStore = new FusionCharts.DataStore();
         const dataSource = {
            "caption": {
                "text": "Trafico de Bajada/Subida"
            },
            "subcaption": {
               "text": ""
            },
            yAxis: [{
               "plot": {
                  "value": "Bandwidth",
                  "type": "line"
               }
            }],
            "series": "Direction",
            "chart": {}

            /*
            "yaxis": [
               {
                  "title": "Download",
                  "columnname": "Download",
                  "format": {
                     "prefix": ""
                  },
                  "title": ""
               }
            ],
            "chart": {}
            */
         };
         
         dataSource.data = dataStore.createDataTable(data, schema);
      
         new FusionCharts({
            type: "timeseries",
            renderAt: "chart-container",
            width: "100%",
            height: "500",
            dataSource
         }).render();
      
      });
   }

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

