Path: C:\
<?php
session_start();
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");
$inicio = $_SESSION['inicio'];
$json = $_SESSION['json'];
$coleta = $_SESSION['coleta'];
$entrega = $_SESSION['entrega'];
$grupo = $_SESSION['grupo'];
$empresa = $_SESSION['empresa'];
if ($grupo<>"nulo"){$logo='grupo_'.$grupo.'.png';} else {if($empresa<>"nulo"){$logo='empresa_'.$empresa.'.png';} else{$logo='logo.png';}}
$linha = json_decode($json, true); // Isto irá tornar o JSON em array
$matriz = file_get_contents('upload/matriz.json');
$principal=json_decode($matriz, true);
$oc=count($principal);
$x2=1;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='red')
{ $red[$x2]=$principal[$x]['id'];$x2++;}
}
$x3=1;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='green')
{ $green[$x3]=$principal[$x]['id'];$x3++;}
}
$x4=1;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='Peru')
{ $peru[$x4]=$principal[$x]['id'];$x4++;}
}
$x5=1;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='blue')
{ $blue[$x5]=$principal[$x]['id'];$x5++;}
}
$x6=1;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='Gold')
{ $gold[$x6]=$principal[$x]['id'];$x6++;}
}
$x7=1;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']=='Grey')
{ $gray[$x7]=$principal[$x]['id'];$x7++;}
}
$by2=$x2;$id2=$red;$by3=$x3;$id3=$green;$by4=$x4;$id4=$peru;$by5=$x5;$id5=$blue;$by6=$x6;$id6=$gold;$by7=$x7;$id7=$gray;
$top['OUTROS']=array();
$top['NÃO REALIZADO']=array();
$top['PROCESSO INICIADO']=array();
$top['EM ROTA DE ENTREGA']=array();
$top['CHEGADA NO LOCAL']=array();
$top['SERVIÇO REALIZADO']=array();
$lin=count($linha);
$ant=$linha[1][9];$start[$ant]=1;
$nf='n';
for ($q=0; $q <= 150; $q++) { $tot[$q]=0; }
for ($q=0; $q <= 180; $q++) { $LT[$q]=0; }
$atraso1=0;$emdia1=0;
$atraso2=0;$emdia2=0;
for ($q=1; $q <= $lin; $q++)
{ if ($linha[$q][9]<>$ant)
{
$start[$linha[$q][9]]=$q;
$stop[$ant]=$q-1;
$ant=$linha[$q][9];
}
$ind=intval($linha[$q][25]);
if ($ind<>108 and $linha[$q][7]=='ENTREGA')
{ $ck=0;$dt_ent=strtotime($linha[$q][27]);$dt_prev=strtotime($linha[$q][30]);$dt_col=strtotime($linha[$q][37]);
if ($ind==32)
{ $nf='s';
for($i=1;$i<$by3;$i++){if($ind==$id3[$i]){$top['SERVIÇO REALIZADO'][]=$q;}}
if($dt_ent<=$dt_prev){$emdia1++;}else{$atraso1++;}
$g=(($dt_ent-$dt_col)/86400);$LT[$g]++;
}
else
{ if ($q>=2){if ($linha[$q][9]<>$linha[$q-1][9]){$nf='n';}}
if ($q<>$lin)
{ if ($linha[$q][9]<>$linha[$q+1][9])
{ if ($nf=='n')
{
for($i=1;$i<$by2;$i++){ if($ind==$id2[$i]){$top['SERVIÇO REALIZADO'][]=$q; $ck=1;}}
if ($ck==1){$g=$dt_col-$dt_ent;$LT[$g]++;if($dt_ent<=$dt_prev){$emdia1++;}else{$atraso1++;}}
for($i=1;$i<$by3;$i++){if($ind==$id3[$i]){$top['NÃO REALIZADO'][]=$q;$ck=2;}}
for($i=1;$i<$by4;$i++){if($ind==$id4[$i]){$top['PROCESSO INICIADO'][]=$q;$ck=2;}}
for($i=1;$i<$by5;$i++){if($ind==$id5[$i]){$top['EM ROTA DE ENTREGA'][]=$q;$ck=2;}}
for($i=1;$i<$by6;$i++){if($ind==$id6[$i]){$top['CHEGADA NO LOCAL'][]=$q;$ck=2;}}
for($i=1;$i<$by7;$i++){if($ind==$id7[$i]){$top['OUTROS'][]=$q;$ck=2;}}
if ($ck==2){if($dt_ent<=$dt_prev){$emdia2++;}else{$atraso2++;}}
}
else
{
$nf='n';
}
}
}
else
{ if ($nf=='n')
{
for($i=1;$i<$by2;$i++){if($ind==$id2[$i]){$top['SERVIÇO REALIZADO'][]=$q;$ck=1;}}
if ($ck==1){$g=$dt_col-$dt_ent;$LT[$g]++;if($dt_ent<=$dt_prev){$emdia1++;}else{$atraso1++;}}
for($i=1;$i<$by3;$i++){if($ind==$id3[$i]){$top['NÃO REALIZADO'][]=$q;}}
for($i=1;$i<$by4;$i++){if($ind==$id4[$i]){$top['PROCESSO INICIADO'][]=$q;}}
for($i=1;$i<$by5;$i++){if($ind==$id5[$i]){$top['EM ROTA DE ENTREGA'][]=$q;}}
for($i=1;$i<$by6;$i++){if($ind==$id6[$i]){$top['CHEGADA NO LOCAL'][]=$q;}}
for($i=1;$i<$by7;$i++){if($ind==$id7[$i]){$top['OUTROS'][]=$q;}}
if ($ck==0){if($dt_ent<=$dt_prev){$emdia2++;}else{$atraso2++;}}
}
else
{
$nf='n';
}
}
}
}
}
$lin1=count($top['SERVIÇO REALIZADO']);
$data3="[['Tôpico', 'Pedidos', { role: 'annotation' }]";
for ($q=0; $q <= 180; $q++)
{ if($LT[$q]!==0)
{ if($q==0){$sufixo='Mesmo Dia';}else{if($q==1){$sufixo=$q.' dia';}else{$sufixo=$q.' dias';}}
$perc=number_format(($LT[$q]*100)/$lin1,1).'%';
$data3=$data3.",['".$sufixo."',".$LT[$q].",'".$perc."']";
}
}
$data3=$data3."]";
$lin2=count($top['NÃO REALIZADO']);
$lin3=count($top['PROCESSO INICIADO']);
$lin4=count($top['EM ROTA DE ENTREGA']);
$lin5=count($top['CHEGADA NO LOCAL']);
$lin6=count($top['OUTROS']);
$linTotal=$lin1+$lin2+$lin3+$lin4+$lin5+$lin6;
$data1="[['Tôpico', 'Fatia'],['ENTREGUES',".$lin1."],['NÃO ENTREGUES',".($lin2)."],['EM PROCESSO',".($linTotal-$lin1-$lin2)."]]";
$data2="[['PEDIDOS', 'NO PRAZO', 'ATRASADO'],['ENTREGUES',".$emdia1.",".$atraso1."],['EM PROCESSO',".$emdia2.",".$atraso2."]]";
?>
<!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>Indicadores de Entregas</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);
google.charts.setOnLoadCallback(drawChart3);
function drawChart1() {
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.arrayToDataTable(<?php echo $data1; ?>);
var options = { titleTextStyle: { fontName: 'Times-Roman',
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:"EFETIVIDADE",
backgroundColor:'#E6E6E6',
legend: {position: 'left', textStyle: {fontSize: 10}},
pieStartAngle: 75,
width:515,
height:350,
is3D: true,
tooltip:{trigger: 'both'},
};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('EFETIVIDADE'));
chart.draw(data, options);
}
function drawChart2() {
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.arrayToDataTable(<?php echo $data2; ?>);
var options = { titleTextStyle: { fontName: 'Times-Roman',
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:"PERFORMANCE",
vAxis: {title: 'PEDIDOS'},
isStacked: 'percent',
seriesType: 'bars',
vAxis: {
minValue: 0,
ticks: [0, .3, .6, .9, 1]
},
bar: {groupWidth: "90%"},
backgroundColor:'#E6E6E6',
legend: {position: 'right', textStyle: {fontSize: 10}},
'width':515,
'height':350,
};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.ComboChart(document.getElementById('PERFORMANCE'));
chart.draw(data, options);
}
function drawChart3() {
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.arrayToDataTable(<?php echo $data3; ?>);
var options = { titleTextStyle: { fontName: 'Times-Roman',
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:"LEAD-TIME DAS ENTREGAS",
legend: {position: 'none'},
backgroundColor:'#E6E6E6',
'width':515,
'height':350,
hAxis: {
gridlines:{count: 15},
title: 'NÚMERO DE PEDIDOS'
},
vAxis: {
title: 'LEAD-TIME'
},
};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.BarChart(document.getElementById('LEAD-TIME'));
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='center'><strong><?php echo 'Base de Dados a partir de: '.$inicio; ?></strong></td>
<td align='right'> </td>
</tr>
</table>
<table width="100%">
<tr>
<td align="center">
<div id="EFETIVIDADE"></div>
</td>
<td align="center">
<div id="PERFORMANCE"></div>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="center">
<div id="LEAD-TIME"></div>
</td>
<td align="center"><br />
<form method="post" action="main.php" >
<input type="submit" class="button2" value="Sair"/>
</form>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</div>
</div>
</body>
<p class="copyright" align="center">© Copyright 2020 TransWar - Todos os direitos reservados. Versão 1.0</p>
</html>