TransWar File Browser

Path: C:\

<?php
session_start();
date_default_timezone_set('America/Sao_Paulo');
$dateadded = date("d/m/Y  --  G:i"); 
$hoje = date("d/m/Y"); 
ini_set('max_execution_time',259200); 
include_once("API02.php");
$grupo='17';$ds_grupo="CRODA";
if ($grupo<>"nulo"){$logo='grupo_'.$grupo.'.png';} else {if($empresa<>"nulo"){$logo='empresa_'.$empresa.'.png';} else{$logo='logo.png';}}
$inicio   = $_SESSION['inicio'];
$json     = $_SESSION['json']; 
$entregaA  = $_SESSION['entregaA'];
$entregaB  = $_SESSION['entregaB'];
$rawData  = json_decode($json, true); // Isto irá tornar o JSON em array
$alerta1A  = json_decode($entregaA, true);// Isto irá tornar o JSON em array
$alerta1B  = json_decode($entregaB, true);// Isto irá tornar o JSON em array
$div1A=$div1B='';$al='';$pe='';$fr='';
$aaA=count($alerta1A['rows']);
$aaB=count($alerta1B['rows']);
foreach ($alerta1A['rows'] as $lin) {
  if ($lin['c'][2]['v']==107 and $lin['c'][3]['v']<>0){$div1A='<img src="images/atenção.png" width="30" height="30" class="alerta"></img>&nbsp;&nbsp;Entrega na porta há mais de 1 hora!';}
}
$matriz = file_get_contents('upload/matriz.json');
$principal=json_decode($matriz, true);
$oc=count($principal);
$x2=$x3=$x4=$x5=$x6=$x7=0;
for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='red')
    { $x2++;$red[$x2]=intval($principal[$x]['id']);}
  if($principal[$x]['cor']=='green')
    { $x3++;$green[$x3]=intval($principal[$x]['id']);}
  if($principal[$x]['cor']=='Peru')
    { $x4++;$peru[$x4]=intval($principal[$x]['id']);}
  if($principal[$x]['cor']=='blue')
    { $x5++;$blue[$x5]=intval($principal[$x]['id']);}
  if($principal[$x]['cor']=='Gold')
    { $x6++;$gold[$x6]=intval($principal[$x]['id']);}
  if($principal[$x]['cor']=='Grey')
    { $x7++;$grey[$x7]=intval($principal[$x]['id']);}
}
$tot_red=$tot_red2=$tot_green=$tot_green2=$tot_peru=$tot_peru2=$tot_blue=$tot_blue2=$tot_gold=$tot_gold2=$tot_grey=$tot_grey2=0;
for ($q=0; $q < $aaA; $q++)
{ if ($alerta1A['rows'][$q]['c'][1]['v']<>0)
  { for ($x=1;$x<=$x2;$x++)
    { if($red[$x]==intval($alerta1A['rows'][$q]['c'][2]['v']))
      { $tot_red=$tot_red+$alerta1A['rows'][$q]['c'][1]['v'];}
    }
    for ($x=1;$x<=$x3;$x++)
    { if($green[$x]==intval($alerta1A['rows'][$q]['c'][2]['v']))
      { $tot_green=$tot_green+$alerta1A['rows'][$q]['c'][1]['v'];}
    }
    for ($x=1;$x<=$x4;$x++)
    { if($peru[$x]==intval($alerta1A['rows'][$q]['c'][2]['v']))
      { $tot_peru=$tot_peru+$alerta1A['rows'][$q]['c'][1]['v'];}
    }
    for ($x=1;$x<=$x5;$x++)
    { if($blue[$x]==intval($alerta1A['rows'][$q]['c'][2]['v']))
      { $tot_blue=$tot_blue+$alerta1A['rows'][$q]['c'][1]['v'];}
    }
    for ($x=1;$x<=$x6;$x++)
    { if($gold[$x]==intval($alerta1A['rows'][$q]['c'][2]['v']))
      { $tot_gold=$tot_gold+$alerta1A['rows'][$q]['c'][1]['v'];}
    }
    for ($x=1;$x<=$x7;$x++)
    { if($grey[$x]==intval($alerta1A['rows'][$q]['c'][2]['v']))
      { $tot_grey=$tot_grey+$alerta1A['rows'][$q]['c'][1]['v'];}
    }
  }
} 
for ($q=0; $q < $aaB; $q++)
{ if ($alerta1B['rows'][$q]['c'][1]['v']<>0)
  { for ($x=1;$x<=$x2;$x++)
    { if($red[$x]==intval($alerta1B['rows'][$q]['c'][2]['v']))
      { $tot_red2=$tot_red2+$alerta1B['rows'][$q]['c'][1]['v'];}
    }
    for ($x=1;$x<=$x3;$x++)
    { if($green[$x]==intval($alerta1B['rows'][$q]['c'][2]['v']))
      { $tot_green2=$tot_green2+$alerta1B['rows'][$q]['c'][1]['v'];}
    }
    for ($x=1;$x<=$x4;$x++)
    { if($peru[$x]==intval($alerta1B['rows'][$q]['c'][2]['v']))
      { $tot_peru2=$tot_peru2+$alerta1B['rows'][$q]['c'][1]['v'];}
    }
    for ($x=1;$x<=$x5;$x++)
    { if($blue[$x]==intval($alerta1B['rows'][$q]['c'][2]['v']))
      { $tot_blue2=$tot_blue2+$alerta1B['rows'][$q]['c'][1]['v'];}
    }
    for ($x=1;$x<=$x6;$x++)
    { if($gold[$x]==intval($alerta1B['rows'][$q]['c'][2]['v']))
      { $tot_gold2=$tot_gold2+$alerta1B['rows'][$q]['c'][1]['v'];}
    }
    for ($x=1;$x<=$x7;$x++)
    { if($grey[$x]==intval($alerta1B['rows'][$q]['c'][2]['v']))
      { $tot_grey2=$tot_grey2+$alerta1B['rows'][$q]['c'][1]['v'];}
    }
  }
} 
$slices1="slices: {";$data1="[['Tôpico', 'Fatia'],";$ix=0;
if ($tot_red<>0){$data1=$data1."['NÃO REALIZADO',".$tot_red."],";$slices1=$slices1.$ix.":{color:'red'},";$ix++;}
if ($tot_green<>0){$data1=$data1."['SERVIÇO REALIZADO',".$tot_green."],";$slices1=$slices1.$ix.":{color:'green'},";$ix++;}
if ($tot_peru<>0){$data1=$data1."['PROCESSO INICIADO',".$tot_peru."],";$slices1=$slices1.$ix.":{color:'Peru'},";$ix++;}
if ($tot_blue<>0){$data1=$data1."['CHEGADA NO LOCAL',".$tot_blue."],";$slices1=$slices1.$ix.":{color:'blue'},";$ix++;}
if ($tot_gold<>0){$data1=$data1."['EM ROTA DE ENTREGA',".$tot_gold."],";$slices1=$slices1.$ix.":{color:'Gold'},";$ix++;}
if ($tot_grey<>0){$data1=$data1."['OUTROS',".$tot_grey."],";$slices1=$slices1.$ix.":{color:'Grey'},";}
$data1=$data1.']';
$slices1=$slices1.'}';
$slices2="slices: {";$data2="[['Tôpico', 'Fatia'],";$ix=0;
if ($tot_red2<>0){$data2=$data2."['NÃO REALIZADO',".$tot_red2."],";$slices2=$slices2.$ix.":{color:'red'},";$ix++;}
if ($tot_green2<>0){$data2=$data2."['SERVIÇO REALIZADO',".$tot_green2."],";$slices2=$slices2.$ix.":{color:'green'},";$ix++;}
if ($tot_peru2<>0){$data2=$data2."['PROCESSO INICIADO',".$tot_peru2."],";$slices2=$slices2.$ix.":{color:'Peru'},";$ix++;}
if ($tot_blue2<>0){$data2=$data2."['CHEGADA NO LOCAL',".$tot_blue2."],";$slices2=$slices2.$ix.":{color:'blue'},";$ix++;}
if ($tot_gold2<>0){$data2=$data2."['EM ROTA DE ENTREGA',".$tot_gold2."],";$slices2=$slices2.$ix.":{color:'Gold'},";$ix++;}
if ($tot_grey2<>0){$data2=$data2."['OUTROS',".$tot_grey2."],";$slices2=$slices2.$ix.":{color:'Grey'},";}
$data2=$data2.']';
$slices2=$slices2.'}';
?>
<!DOCTYPE html>
<html lang='pt-br'>
  <head>
    <meta charset="utf-8"/>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
    <title>Situação Atual Entrega</title>
    <link rel="icon" type="image/png" href="images/favicon.ico">
    <link href="css/estilo.css" rel="stylesheet" type="text/css" />
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="css/redmond/jquery-ui-1.10.1.custom.css" />
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/bootstrap-theme.min.css" rel="stylesheet">
    <link href="css/theme.css" rel="stylesheet">
    <link href="css/signin.css" rel="stylesheet">
    <script src='js/jquery-3.3.1.min.js'></script>
    <script src='js/jquery-ui.js' type='text/javascript'></script>
    <script src="js/ui.datepicker-pt-BR.js"></script>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <!--Load the AJAX API-->
    <script type="text/javascript">
        function selectAuto() {
          var serializeDados = $('#form_um').serialize();
          var topping = 'Tudo';
          $.ajax({
            url: "API05.php?Topico="+topping,
            dataType: "html",
            type: 'POST',
            data: serializeDados,
            success: function(data, textStatus) {
            $('#aqui1').html(data);  
            },
          });
        }
    
      // Load the Visualization API and the piechart package.
      google.charts.load('current', {'packages':['corechart']});
        
      // Set a callback to run when the Google Visualization API is loaded.
      google.charts.setOnLoadCallback(drawChart1);
        
      google.charts.setOnLoadCallback(drawChart2);

      function drawChart1() {
        var serializeDados1 = $('#form_um').serialize();
              
          // Create our data table out of JSON data loaded from server.
        var data = new google.visualization.arrayToDataTable(<?php  echo $data1; ?>);
        var options = { titleTextStyle: { fontName: 'Arial',
                                          fontSize: 18,
                                          bold: true,
                                          italic: true,
                                          // The color of the text.
                                          color: '#871b47',
                                          // The color of the text outline.
                                          auraColor: '#d799ae',
                                          // The transparency of the text.
                                          opacity: 0.8
                                        },
                        title:'ENTREGAS: CRODA p/ CLIENTE',
                        backgroundColor:'#E6E6E6',
                        width:515,
                        height:350,
                        is3D: true,
                        tooltip:{trigger:'both'},
                        <?php  echo $slices1; ?>
                      };

        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.PieChart(document.getElementById('chart_entrega'));

        function selectHandler1() {
          var selectedItem1 = chart.getSelection()[0];
          if (selectedItem1) {
            var topping1 = data.getValue(selectedItem1.row, 0);
            $.ajax({
                url: "API05_A.php?Topico="+topping1,
                dataType: "html",
                type: 'POST',
                data: serializeDados1,
                success: function(data, textStatus) {
                $('#aqui1').html(data);  
                },
            });
            }
        }

        google.visualization.events.addListener(chart, 'select', selectHandler1);    
        chart.draw(data, options);
      }

        
      function drawChart2() {
        var serializeDados2 = $('#form_um').serialize();
              
          // Create our data table out of JSON data loaded from server.
        var data = new google.visualization.arrayToDataTable(<?php  echo $data2; ?>);
        var options = { titleTextStyle: { fontName: 'Arial',
                                          fontSize: 18,
                                          bold: true,
                                          italic: true,
                                          // The color of the text.
                                          color: '#871b47',
                                          // The color of the text outline.
                                          auraColor: '#d799ae',
                                          // The transparency of the text.
                                          opacity: 0.8
                                        },
                        title:'ENTREGAS: CLIENTES p/ CRODA',
                        backgroundColor:'#E6E6E6',
                        width:515,
                        height:350,
                        is3D: true,
                        tooltip:{trigger:'both'},
                        <?php  echo $slices2; ?>
                      };

        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.PieChart(document.getElementById('chart_coleta'));

        function selectHandler2() {
          document.getElementById('aqui2').style.display = 'none';
          document.getElementById('aqui1').style.display = 'block';
          var selectedItem2 = chart.getSelection()[0];
          if (selectedItem2) {
            var topping2 = data.getValue(selectedItem2.row, 0);
            $.ajax({
                url: "API05_B.php?Topico="+topping2,
                dataType: "html",
                type: 'POST',
                data: serializeDados2,
                success: function(data, textStatus) {
                $('#aqui1').html(data);  
                },
            });
            }
        }

        google.visualization.events.addListener(chart, 'select', selectHandler2);    
        chart.draw(data, options);
      }
    </script>
  </head>
<body role="document" onLoad="selectAuto();">
  <div class="container">   
    <form action="" method="post" id="form_um">    
      <input type='hidden' name='result' value='<?php echo htmlentities($json, ENT_QUOTES, 'UTF-8');?>' />
      <input type='hidden' name='entrega' id='entrega' value='<?php echo htmlentities($entrega, ENT_QUOTES, 'UTF-8');?>' />
      <input id='inicio' name='inicio' type='hidden' value="<?php echo $inicio; ?>" /> 
    </form>
    <div class="container">   
      <table width="100%"> 
        <tr> 
          <td width="30%" align="center">
            <img src="images/logo03.png" width="300" height="88"/>
          </td> 
          <td width="40%" align="center">
            <div class="page-header">
              <h2><span class="label label-primary">&nbsp;&nbsp;TORRE DE CONTROLE&nbsp;&nbsp;</span></h2>
            </div>
          </td>
          <td width="30%" align="center">
            <img src="<?php echo 'images/'.$logo; ?>" width="300" height="88"/>
          </td> 
        </tr> 
        <tr height="30"  background="images/top-menubg.gif" > 
          <td>&nbsp;&nbsp;<?php echo $dateadded; ?></td>
          <td align='center'><strong><?php echo 'Base de Dados a partir de: '.$inicio; ?></strong></td>
          <td align='right'>Usuário:&nbsp;<?php echo utf8_encode($_SESSION['usuarioNome']); ?>&nbsp;&nbsp;</td> 
        </tr> 
      </table>
      <table width="100%">
        <tr>
          <td align="center">
            <div id="chart_entrega"></div>
          </td>
          <td align="center">
            <form method="post" action="main.php" >
              <input type="submit" class="button2" value="Sair"/>
            </form>
            <form method="post" action="" >
              <input type="submit" class="button2" value="Tudo"/>
            </form>
          </td> 
          <td align="center">
            <div id="chart_coleta"></div>
          </td>
        </tr>
        <tr>
          <td>
            <div align="center" style="color: red;"><?php echo $div1A; ?></div>
          </td>
          <td>
            <div id="meio"></div>
          </td>
          <td>
            <div align="center" style="color: red;"><?php echo $div1B; ?></div>
          </td>
        </tr>
        <tr><td colspan='3'><br /></td></tr>
        <tr>
          <td colspan='3'>
            <div id="aqui1"></div>
          </td>
        </tr>
        <tr>
          <td colspan='3'>
            <div id="aqui2"></div>
          </td>
        </tr>
     </table>
    </div>
  </div>
</body>
<p class="copyright" align="center">&copy; Copyright 2020 TransWar - Todos os direitos reservados. Versão 1.0</p> 
</html>