Path: C:\
<?php
ini_set('max_execution_time',259200);
ini_set ('memory_limit','-1');
error_reporting(E_ALL);
ini_set('display_errors', 'On');
date_default_timezone_set('America/Sao_Paulo');
$depart="ADMINISTRATIVO OPERACIONAL";$depart1="MOTORISTA";$depart2="OPERACIONAL";$depart3="FROTA";
$empresa="CAMPINAS";
$cab=$empresa.' - ';
$hoje = date("d-m-Y H:i");
$agora = date("Ymd H:i");
$matriz = file_get_contents('upload/funcionario.json');
$pessoa=json_decode($matriz, true);
$p=count($pessoa);
?>
<!DOCTYPE html>
<html lang='pt-br'>
<head>
<meta charset='utf-8'/>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv='refresh' CONTENT='300'>
<meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>
<title>Controle de Presença</title>
<link href="../css/bootstrap.min.css" rel="stylesheet">
<script src='../js/jquery-3.2.1.min.js'></script>
<script src='../js/tabelas.js'></script>
<link href="../css/tabelas3.css" rel="stylesheet">
</head>
<table class="blue">
<col width="4%" />
<col width="44%" />
<col width="13%" />
<col width="13%" />
<col width="13%" />
<col width="13%" />
<h1><?php echo "Controle de Presença - ".$cab." - em: ".$hoje;?></h1>
<thead>
<tr>
<th rowspan=2 style='border: 2px solid white;'>Nº</th>
<th rowspan=2 style='border: 2px solid white;'>Funcionário</th>
<th rowspan=2 style='border: 2px solid white;'>Entrada</th>
<th colspan=2 style='border: 2px solid white;'>Almoço</th>
<th rowspan=2 style='border: 2px solid white;'>Saída</th>
</tr>
<tr>
<th style='border: 2px solid white;'>Saiu</th>
<th style='border: 2px solid white;'>Chegou</th>
</tr>
</thead>
<tbody>
<?php
for($y=0;$y<$p;$y++){
$pessoa[$y]['legenda1']=$pessoa[$y]['legenda2']=$pessoa[$y]['legenda3']=$pessoa[$y]['legenda4']='';$pessoa[$y]['sit']='A';
if($pessoa[$y]['Coment']<>'SEM' and $pessoa[$y]['Coment']<>'')
{
$pessoa[$y]['legenda1']=$pessoa[$y]['legenda2']=$pessoa[$y]['legenda3']=$pessoa[$y]['legenda4']=$pessoa[$y]['Coment'];
$pessoa[$y]['cor']='Red';continue;
}
else
{
if($pessoa[$y]['aponta1']!=="")
{$pessoa[$y]['legenda1']='PRESENTE';$pessoa[$y]['cor']='Blue';}
else
{$pessoa[$y]['legenda1']='AUSENTE';$pessoa[$y]['cor']='Red';$pessoa[$y]['sit']='B';continue;}
if($pessoa[$y]['aponta2']!=="")
{$pessoa[$y]['legenda1']='';$pessoa[$y]['legenda2']='ALMOÇANDO';$pessoa[$y]['cor']='DeepPink';}
else
{continue;}
if($pessoa[$y]['aponta3']!=="")
{$pessoa[$y]['legenda2']='';$pessoa[$y]['legenda3']='PRESENTE';$pessoa[$y]['cor']='Blue';}
else
{continue;}
if($pessoa[$y]['aponta4']!=="")
{$pessoa[$y]['legenda3']='';$pessoa[$y]['legenda4']='ENCERROU';$pessoa[$y]['cor']='red';}
else
{continue;}
}
}
function cmp($a, $b) {
if ($a['sit'] == $b['sit']) {
return (strnatcmp($a['Nome'] , $b['Nome']));
}
if ($a['sit'] == 'A') {
return -1;
} elseif ($b['sit'] == 'A') {
return 1;
} else {
return (strnatcmp($a['Nome'] , $b['Nome']));
}
}
usort($pessoa, 'cmp');
$r=0;
for($y=0;$y<$p;$y++){
if (($pessoa[$y]['Departamento']==$depart or $pessoa[$y]['Departamento']==$depart1 or $pessoa[$y]['Departamento']==$depart2 or $pessoa[$y]['Departamento']==$depart3) and (strpos($pessoa[$y]['Empresa'],$empresa)==true))
{ $r++;
echo "
<tr>
<td>".$r."</td>
<td style='text-align: left;'> ".$pessoa[$y]['Nome']."</td>
<td style='color:".$pessoa[$y]['cor'].";'>".$pessoa[$y]['legenda1']."</td>
<td style='color:".$pessoa[$y]['cor'].";'>".$pessoa[$y]['legenda2']."</td>
<td style='color:".$pessoa[$y]['cor'].";'>".$pessoa[$y]['legenda3']."</td>
<td style='color:".$pessoa[$y]['cor'].";'>".$pessoa[$y]['legenda4']."</td>
</tr>";
}
}
echo "
</tbody>
</table>
";
?>