Path: C:\
<?php
ini_set('max_execution_time',259200);
ini_set ('memory_limit','-1');
date_default_timezone_set('America/Fortaleza');
$dateadded = date("d/m/Y -- G:i");
$fim=$hoje = date("d/m/Y");
if (isset($_POST['grupo'])) {$grupo=$_POST['grupo'];$dsgru=$_POST['dsgru'];} else {if (isset($_GET['grupo'])) {$grupo=$_GET['grupo'];$dsgru=$_GET['dsgru'];} else {$grupo="nulo";$dsgru="TODOS";}}
if (isset($_POST['empresa'])) {$empresa=$_POST['empresa'];} else {if (isset($_GET['empresa'])) {$empresa=$_GET['empresa'];} else {$empresa="nulo";}}
if (isset($_POST['inicio2'])) {$inicio=$_POST['inicio2'];} else {if (isset($_GET['inicio2'])) {$inicio=$_GET['inicio2'];} else {$inicio=$hoje;}}
if ($grupo<>"nulo"){$logo='grupo_'.$grupo.'.png';} else {if($empresa<>"nulo"){$logo='empresa_'.$empresa.'.png';} else{$logo='logo.png';}}
$json = $_POST['result'];
$coleta = $_POST['coleta'];
$entrega = $_POST['entrega'];
$alerta1 = json_decode($_POST['entrega'], true);// Isto irá tornar o JSON em array
$alerta2 = json_decode($_POST['coleta'], true);
$div1='';$div2='';$al='';$pe='';$fr='';
$aa=count($alerta1['rows']);
$bb=count($alerta2['rows']);
foreach ($alerta1['rows'] as $lin) {
if ($lin['c'][2]['v']==107 and $lin['c'][3]['v']<>0){$div1='<img src="images/atenção.png" width="30" height="30" class="alerta"></img> Entrega na porta há mais de 1 hora!';}
}
foreach ($alerta2['rows'] as $lin2) {
if ($lin2['c'][2]['v']==146 and $lin2['c'][3]['v']<>0){$pe='Pendente';}
if ($lin2['c'][2]['v']==149 and $lin2['c'][3]['v']<>0){$al='Alocada';}
if ($al<>''){if ($pe<>''){$fr=' Pendente/Alocada ';}else{$fr=' Alocada ';}}else{if ($pe<>''){$fr=' Pendente ';}else{$fr='';}}
if ($fr<>''){$div2='<img src="images/atenção.png" width="30" height="30" class="alerta"></img> Coleta'.$fr.'na data LIMITE.';}
}
$matriz = file_get_contents('matriz.json');
$principal=json_decode($matriz, true);
$oc=count($principal);
$x2=0;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='red')
{ $x2++;$red[$x2]=$principal[$x]['id'];}
}
$x3=0;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='green')
{ $x3++;$green[$x3]=$principal[$x]['id'];}
}
$x4=0;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='Peru')
{ $x4++;$peru[$x4]=$principal[$x]['id'];}
}
$x5=0;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='blue')
{ $x5++;$blue[$x5]=$principal[$x]['id'];}
}
$x6=0;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='Gold')
{ $x6++;$gold[$x6]=$principal[$x]['id'];}
}
$x7=0;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='Grey')
{ $x7++;$gray[$x7]=$principal[$x]['id'];}
}
$tot_red=0;for ($q=0; $q < $aa; $q++){if ($alerta1['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x2;$x++){if($red[$x]==$alerta1['rows'][$q]['c'][2]['v']){$tot_red=$tot_red+$alerta1['rows'][$q]['c'][1]['v'];}}}}
$tot_green=0;for ($q=0; $q < $aa; $q++){if ($alerta1['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x3;$x++){if($green[$x]==$alerta1['rows'][$q]['c'][2]['v']){$tot_green=$tot_green+$alerta1['rows'][$q]['c'][1]['v'];}}}}
$tot_peru=0;for ($q=0; $q < $aa; $q++){if ($alerta1['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x4;$x++){if($peru[$x]==$alerta1['rows'][$q]['c'][2]['v']){$tot_peru=$tot_peru+$alerta1['rows'][$q]['c'][1]['v'];}}}}
$tot_blue=0;for ($q=0; $q < $aa; $q++){if ($alerta1['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x5;$x++){if($blue[$x]==$alerta1['rows'][$q]['c'][2]['v']){$tot_blue=$tot_blue+$alerta1['rows'][$q]['c'][1]['v'];}}}}
$tot_gold=0;for ($q=0; $q < $aa; $q++){if ($alerta1['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x6;$x++){if($gold[$x]==$alerta1['rows'][$q]['c'][2]['v']){$tot_gold=$tot_gold+$alerta1['rows'][$q]['c'][1]['v'];}}}}
$tot_gray=0;for ($q=0; $q < $aa; $q++){if ($alerta1['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x7;$x++){if($gray[$x]==$alerta1['rows'][$q]['c'][2]['v']){$tot_gray=$tot_gray+$alerta1['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_gray<>0){$data1=$data1."['OUTROS',".$tot_gray."],";$slices1=$slices1.$ix.":{color:'Grey'},";$ix++;}
$data1=$data1.']';
$slices1=$slices1.'}';
$tot_red2=0;for ($q=0; $q < $bb; $q++){if ($alerta2['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x2;$x++){if($red[$x]==$alerta2['rows'][$q]['c'][2]['v']){$tot_red2=$tot_red2+$alerta2['rows'][$q]['c'][1]['v'];}}}}
$tot_green2=0;for ($q=0; $q < $bb; $q++){if ($alerta2['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x3;$x++){if($green[$x]==$alerta2['rows'][$q]['c'][2]['v']){$tot_green2=$tot_green2+$alerta2['rows'][$q]['c'][1]['v'];}}}}
$tot_peru2=0;for ($q=0; $q < $bb; $q++){if ($alerta2['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x4;$x++){if($peru[$x]==$alerta2['rows'][$q]['c'][2]['v']){$tot_peru2=$tot_peru2+$alerta2['rows'][$q]['c'][1]['v'];}}}}
$tot_blue2=0;for ($q=0; $q < $bb; $q++){if ($alerta2['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x5;$x++){if($blue[$x]==$alerta2['rows'][$q]['c'][2]['v']){$tot_blue2=$tot_blue2+$alerta2['rows'][$q]['c'][1]['v'];}}}}
$tot_gold2=0;for ($q=0; $q < $bb; $q++){if ($alerta2['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x6;$x++){if($gold[$x]==$alerta2['rows'][$q]['c'][2]['v']){$tot_gold2=$tot_gold2+$alerta2['rows'][$q]['c'][1]['v'];}}}}
$tot_gray2=0;for ($q=0; $q < $bb; $q++){if ($alerta2['rows'][$q]['c'][1]['v']<>0){
for ($x=1;$x<=$x7;$x++){if($gray[$x]==$alerta2['rows'][$q]['c'][2]['v']){$tot_gray2=$tot_gray2+$alerta2['rows'][$q]['c'][1]['v'];}}}}
$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."['ALOCADO / LIBERADO',".$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 COLETA',".$tot_gold2."],";$slices2=$slices2.$ix.":{color:'Gold'},";$ix++;}
if ($tot_gray2<>0){$data2=$data2."['PENDENTE',".$tot_gray2."],";$slices2=$slices2.$ix.":{color:'Grey'},";$ix++;}
$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</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">
// 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();
var jsonData1 = document.getElementById('entrega').value;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.arrayToDataTable(<?php echo $data1; ?>);
var options = { 'title':'SITUAÇÃO DAS ENTREGAS',
'width':515,
'height':350,
'is3D': true,
tooltip:{trigger:'selection'},
<?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.php?Topico="+topping1,
dataType: "html",
type: 'POST',
data: serializeDados1,
success: function(data, textStatus) {
$('#aqui').html(data);
},
});
}
}
google.visualization.events.addListener(chart, 'select', selectHandler1);
chart.draw(data, options);
}
function drawChart2() {
var serializeDados2 = $('#form_um').serialize();
var jsonData2 = document.getElementById('coleta').value;;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.arrayToDataTable(<?php echo $data2; ?>);
var options = { 'title':'SITUAÇÃO DAS COLETAS',
'width':515,
'height':350,
'is3D': true,
tooltip:{trigger:'selection'},
<?php echo $slices2; ?>
};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_coleta'));
function selectHandler2() {
var selectedItem2 = chart.getSelection()[0];
if (selectedItem2) {
var topping2 = data.getValue(selectedItem2.row, 0);
$.ajax({
url: "API06.php?Topico="+topping2,
dataType: "html",
type: 'POST',
data: serializeDados2,
success: function(data, textStatus) {
$('#aqui').html(data);
},
});
}
}
google.visualization.events.addListener(chart, 'select', selectHandler2);
chart.draw(data, options);
}
</script>
</head>
<body role="document">
<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='coleta' id='coleta' value='<?php echo htmlentities($coleta, 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"> TORRE DE CONTROLE </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> <?php echo $dateadded; ?></td>
<td align="right" colspan="2">Base de Dados a partir de: <?php echo $inicio; ?> </td>
</tr>
</table>
<table width="100%">
<tr>
<td align="center">
<div id="chart_entrega"></div>
</td>
<td align="center">
<form method="post" action="index2.php" >
<input type='hidden' name='result' value='<?php echo htmlentities($json, ENT_QUOTES, 'UTF-8');?>' />
<input type='hidden' name='coleta' value='<?php echo htmlentities($coleta, ENT_QUOTES, 'UTF-8');?>' />
<input type='hidden' name='entrega' value='<?php echo htmlentities($entrega, ENT_QUOTES, 'UTF-8');?>' />
<input type='hidden' name='grupo' id='grupo' value="<?php echo $grupo; ?>" />
<input type='hidden' name='dsgru' id='dsgru' value="<?php echo $dsgru; ?>" />
<input type='hidden' name='empresa' id='empresa' value="<?php echo $empresa; ?>" />
<input type='hidden' name='inicio' id='inicio' value="<?php echo $inicio; ?>" />
<input type="submit" class="button2" value="Sair"/>
</form>
</td>
<td align="center">
<div id="chart_coleta"></div>
</td>
</tr>
<tr>
<td>
<div align="center" style="color: red;"><?php echo $div1; ?></div>
</td>
<td>
<div id="meio"></div>
</td>
<td>
<div align="center" style="color: red;"><?php echo $div2; ?></div>
</td>
</tr>
<tr><td colspan='3'><br /></td></tr>
<tr>
<td colspan='3'>
<div id="aqui"></div>
</td>
</tr>
</table>
</div>
</div>
</body>
<p class="copyright" align="center">© Copyright 2020 TransWar - Todos os direitos reservados. Versão 1.0</p>
</html>