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');
$dia_form = date("Y-m-d");
if (isset($_POST['depart'])) {$depart=$_POST['depart'];}else{$depart="GERAL";}
if (isset($_POST['empresa'])) {$empresa=$_POST['empresa'];}else{$empresa="GERAL";}
if (isset($_POST['dia'])) {
$dia = $_POST['dia'];
$dia_form = substr($dia, 0,10);
}else{$dia="não";}
if ($empresa==$depart){$cab='GERAL';}else{$cab=$empresa.' - '.$depart;}
$sex['M']='o';
$sex['F']='a';
$sex['']='o(a)';
$sex['null']='o(a)';
$hoje = date("d-m-Y H:i");
$agora = date("Y-m-d H:i");
if ($dia==='não'){$arq='upload/funcionario.json';}else{$hoje=substr($dia, 8,2).'-'.substr($dia, 5,2).'-'.substr($dia, 0,4).' 21:00';$arq='upload/copias/'.$dia;}
$matriz = file_get_contents($arq);
$pessoa=json_decode($matriz, true);
$p=count($pessoa);
require_once("../jornada-comprovante/comprova07.php");
foreach ($jotform as $pis => $value1) {
foreach ($pessoa as $key => $value) {
if($value['Pis']==$pis){
foreach ($value1 as $hora => $val) {
if($pessoa[$key]['aponta1']==''){
$pessoa[$key]['aponta1']=$hora;$pessoa[$key]['cor1']='jotform';
}else{
if($pessoa[$key]['aponta2']==''){
$pessoa[$key]['aponta2']=$hora;$pessoa[$key]['cor2']='jotform';
}else{
if($pessoa[$key]['aponta3']==''){
$pessoa[$key]['aponta3']=$hora;$pessoa[$key]['cor3']='jotform';
}else{
if($pessoa[$key]['aponta4']==''){
$pessoa[$key]['aponta4']=$hora;$pessoa[$key]['cor4']='jotform';
}
}
}
}
}
}
}
}
?>
<!DOCTYPE html>
<html lang='pt-br'>
<head>
<meta charset='utf-8'/>
<meta http-equiv="pragma" content="no-cache">
<meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'>
<title>Controle de Acesso</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">
<style>
jotform {
color: black;
background-color: #A9D0F5;
padding: 2px;
font-size: 105%;
}
rastreador {
color: black;
background-color: #A9F5BC;
padding: 2px;
font-size: 105%;
}
ponto {
color: black;
padding: 2px;
font-size: 105%;
}
cab1 {
color: black;
background-color: #A9D0F5;
padding: 2px;
font-size: 150%;
}
cab2 {
color: black;
background-color: #A9F5BC;
padding: 2px;
font-size: 150%;
}
cab3 {
color: black;
padding: 2px;
font-size: 200%;
}
cab4 {
color: black;
padding: 2px;
font-size: 300%;
}
</style>
</head>
<table>
<thead>
<tr>
<th width="20%" align="center"><cab1>JotForm</cab1></th>
<th width="60%" align="center" rowspan="2"><cab4>Controle de Ponto <?php echo $cab;?></cab4></th>
<th width="20%" align="center"><cab3><?php echo substr($hoje, 0,10);?></cab3></th>
</tr>
<tr>
<th lign="center"><cab2>Rastreador</cab2></th>
<th align="center"><cab3><?php echo substr($hoje, 11,5);?></cab3></th>
</tr>
</table>
</thead>
<table class="blue">
<col width="4%" />
<col width="44%" />
<col width="13%" />
<col width="13%" />
<col width="13%" />
<col width="13%" />
<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
$r=0;
for($y=0;$y<$p;$y++)
{
if (($pessoa[$y]['Departamento']==$depart or $depart=="GERAL") and (strpos($pessoa[$y]['Empresa'],$empresa)==true or $empresa=="GERAL"))
{
$legenda1[$y]=$legenda2[$y]=$legenda3[$y]=$legenda4[$y]='';
$cor1[$y]=$cor2[$y]='black';$cor4[$y]="red";$cor3[$y]="blue";
if($pessoa[$y]['Coment']<>'SEM' and $pessoa[$y]['Coment']<>'')
{
$legenda1[$y]=$legenda2[$y]=$legenda3[$y]=$legenda4[$y]=$pessoa[$y]['Coment'];
$cor1[$y]=$cor2[$y]=$cor3[$y]=$cor4[$y]="red";
}
else
{
if($pessoa[$y]['aponta1']!==""){
$chega = new DateTime($pessoa[$y]['hora1']);
$chegou = new DateTime($pessoa[$y]['aponta1']);
if ($chega == $chegou){$legenda1[$y]='';}
else
{
$diff_chega = $chega->diff($chegou);$legenda1[$y]=' <strong>→</strong> '.$diff_chega->format('%H:%I');
if($diff_chega->format('%R')=='-'){$cor1[$y]="blue";}
if($diff_chega->format('%R')=='+'){$cor1[$y]="red";}
}
}else{
if(strtotime($pessoa[$y]['hora1'])<=strtotime($agora)){$legenda1[$y]='Está atrasad'.$sex[$pessoa[$y]['Sexo']];}
continue;
}
if($pessoa[$y]['aponta3']!==""){
$alm = 60;
$alm_ini=new DateTime($pessoa[$y]['aponta2']);
$alm_fim=new DateTime($pessoa[$y]['aponta3']);
$diff_alm = $alm_fim->diff($alm_ini);
$hora_alm = ((abs($diff_alm->h) * 60) + abs($diff_alm->i))-$alm;
$horx = abs((int)($hora_alm/60)); //horas inteiras trabalhadas
$minx = abs($hora_alm % 60); //minutos trabalhados
$dat=date("H:i",strtotime($horx.':'.$minx));
$legenda3[$y]=' <strong>→</strong> '.$dat;
if($hora_alm>=1){$cor3[$y]="red";}else{if($hora_alm==0){$legenda3[$y]='';}}
}else{
$legenda3[$y]='';if ($pessoa[$y]['aponta4']==""){continue;}
}
if($pessoa[$y]['aponta4']!==""){
$entrada = new DateTime($pessoa[$y]['aponta1']);
$saida = new DateTime($pessoa[$y]['aponta4']);
$diff_trabalhada = $entrada->diff($saida);
$horas_totais = ($diff_trabalhada->h * 60) + $diff_trabalhada->i; //quantidade de minutos entre a entrada e saída
if ($pessoa[$y]['aponta2']!=="" and $pessoa[$y]['aponta3']!==""){
$saida_intervalo = new DateTime($pessoa[$y]['aponta2']);
$volta_intervalo = new DateTime($pessoa[$y]['aponta3']);
$diff_intervalo = $saida_intervalo->diff($volta_intervalo);
$horas_intervalo = ($diff_intervalo->h * 60) + $diff_intervalo->i; //quantidade de minutos do intervalo
}else{
$horas_intervalo = 0;
}
$horas_trabalhadas = abs($horas_totais - $horas_intervalo);
//echo $pessoa[$y]['Pis'].'a1-->'.$pessoa[$y]['aponta1'].'a2-->'.$pessoa[$y]['aponta2'].'a3-->'.$pessoa[$y]['aponta3'].'a4-->'.$pessoa[$y]['aponta4'].'-->'.$horas_trabalhadas.'-->'.$horas_totais.'-->'.$horas_intervalo.'<br>';
$horas = (int)($horas_trabalhadas/60); //horas inteiras trabalhadas
$minutos = $horas_trabalhadas % 60; //minutos trabalhados
$jor = 528;
$jor_ini=new DateTime('2022-02-08 00:00');
$jor_fim=new DateTime('2022-02-08 '.$horas.':'.$minutos);
$diff_extra = $jor_fim->diff($jor_ini);
$horas_extra = ((abs($diff_extra->h) * 60) + abs($diff_extra->i))-$jor;
$horasx = abs((int)($horas_extra/60)); //horas inteiras trabalhadas
$minutosx = abs($horas_extra % 60); //minutos trabalhados
$dat=date("H:i",strtotime($horasx.':'.$minutosx));
$legenda4[$y]=' <strong>→</strong> '.$dat;
if($horas_extra>=1){$cor4[$y]="blue";}else{if($horas_extra==0){$legenda4[$y]='';}}
}
}
}
}
$r=0;
for($y=0;$y<$p;$y++){
if (($pessoa[$y]['Departamento']==$depart or $depart=="GERAL") and (strpos($pessoa[$y]['Empresa'],$empresa)==true or $empresa=="GERAL"))
{ $r++;
if(!isset($pessoa[$y]['cor1'])){$fun1='ponto';}else{$fun1='jotform';}
if(!isset($pessoa[$y]['cor2'])){$fun2='ponto';}else{$fun2='jotform';}
if(!isset($pessoa[$y]['cor3'])){$fun3='ponto';}else{$fun3='jotform';}
if(!isset($pessoa[$y]['cor4'])){$fun4='ponto';}else{$fun4='jotform';}
echo "
<tr>
<td>".$r."</td>
<td style='text-align: left;'> ".$pessoa[$y]['Nome']."</td>
<td><".$fun1.">".substr($pessoa[$y]['aponta1'],11,5)."</".$fun1."><span style='color:".$cor1[$y]."'>".$legenda1[$y]."</td>
<td><".$fun2.">".substr($pessoa[$y]['aponta2'],11,5)."</".$fun2."><span style='color:".$cor2[$y]."'>".$legenda2[$y]."</td>
<td><".$fun3.">".substr($pessoa[$y]['aponta3'],11,5)."</".$fun3."><span style='color:".$cor3[$y]."'>".$legenda3[$y]."</td>
<td><".$fun4.">".substr($pessoa[$y]['aponta4'],11,5)."</".$fun4."><span style='color:".$cor4[$y]."'>".$legenda4[$y]."</span></td>
</tr>";
}
}
echo "
</tbody>
</table>
<form method='GET' action='index.php'>
<div align='center'>
<button type='submit' class='btn btn-primary'>Voltar</button>
</div>
</form>
";
?>