TransWar File Browser

Path: C:\

<?php
ini_set ( 'memory_limit' , '1536M' ) ;
date_default_timezone_set('America/Fortaleza');
$dateadded = date("d/m/Y  --  G:i"); 
$fim=$hoje = date("d/m/Y"); 
$lines = $_POST['result']; 
$linha = json_decode($_POST['result'], true); // Isto irá tornar o JSON em array
if (isset($_GET['Topico'])) {$topico=$_GET['Topico'];}else {$topico='vazio';}
if (isset($_POST['inicio'])) {$inicio=$_POST['inicio'];} else {$inicio=$hoje;}
$matriz = file_get_contents('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++;}
}
if($topico=='NÃO REALIZADO'){$by=$x2;$id=$red;}else{if($topico=='SERVIÇO REALIZADO'){$by=$x3;$id=$green;}else{if($topico=='PROCESSO INICIADO'){$by=$x4;$id=$peru;}else{if($topico=='CHEGADA NO LOCAL'){$by=$x5;$id=$blue;}else{if($topico=='EM ROTA DE ENTREGA'){$by=$x6;$id=$gold;}else{if($topico=='OUTROS'){$by=$x7;$id=$grey;}}}}}}
$ano1=substr($fim, 6);
$mes1=substr($fim, 3,-5);
$dia1=substr($fim, 0,-8);
$data3=$ano1.$mes1.$dia1;
$lin=count($linha);
$ant=$linha[1][9];$start[$ant]=1;
$nf='n';
for ($q=0; $q <= 150; $q++) { $tot[$q]=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')
  { 
    if ($ind==32)
    { $nf='s';
      if ($linha[$q][35]>=$data3)
      {
        $reg[$ind][]=$q;for($i=1;$i<$by;$i++){if($ind==$id[$i]){$top[$topico][]=$q;}}
      }
    }
    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')
          {
            $reg[$ind][]=$q;for($i=1;$i<$by;$i++){if($ind==$id[$i]){$top[$topico][]=$q;}}
          }
          else
          { 
            $nf='n';
          }
        }
      }
      else
      { if ($nf=='n')
        {
          $reg[$ind][]=$q;for($i=1;$i<$by;$i++){if($ind==$id[$i]){$top[$topico][]=$q;}}
        }
        else
        { 
          $nf='n';
        }
      }
    }
  }
}
if ($linha[$lin][9]<>$ant)
{ $start[$linha[$lin][9]]=$lin;
  $stop[$ant]=$lin-1;
  $stop[$linha[$lin][9]]=$lin;
}
else
{
  $stop[$ant]=$lin;
}
//$lin=count($reg[$topico]);$bg1=0;
$lin=count($top[$topico]);$bg1=0;
echo '
    <script src="js/sorttable.js"></script>
  <script type="text/javascript">
    function Detalhe(){
      window.open("about:blank","Historico","toolbar=no, status=no, menubar=no, scrollbars=no, resizable=no, width=800, height=400, top=50, left=20");
      document.formDetalhe.submit();
    }
  </script>
  <style>
    @keyframes neon{
      from {
        filter:drop-shadow(0 0 0 var(--cor-neon));
        }
      to {
        filter:drop-shadow(0 0 30px var(--cor-neon));
        }
      }
    td {
        animation: neon 1s alternate infinite ease-in-out;
      }
    .alerta{color:red;
        --cor-neon: #FFFF00;
      }
    .ok{
        --cor-neon: #00FF00;
      }
    table.blue {
      table-layout:fixed; 
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 10px; 
      }
    table.blue td {
      overflow: hidden;word-wrap: break-word;
      }
    th {
      text-align:left;
      padding:0px 0;
      }
    thead {
      color:white;
      background:#6D7EA0;
      }
      tr#linha:hover {
      background: #F3F781;
    }
  </style>
  <table width="100%" align="center" cellpadding="1" cellspacing="1" bgcolor="#F3F3F3">
    <tr>
      <td align="center" style="color:red; size=3;font-weight: bold;">SITUAÇÃO DAS ENTREGAS: (&nbsp;<span style="color:blue">'.$topico.'</span><span style="color:red">&nbsp;)</span></td>
    </tr>
  </table>
  <table class="sortable blue" width="100%" align="center" cellpadding="1" cellspacing="1" bgcolor="#F3F3F3">
    <col width="20%" />
    <col width="23%" />
    <col width="15%" />
    <col width="9%" />
    <col width="6%" />
    <col width="7%" />
    <col width="5%" />
    <col width="15%" />
      <tr height="31">
      <td><b title="Click para ordenar por essa coluna.">&nbsp;&nbsp;REMETENTE</b></td>
      <td><b title="Click para ordenar por essa coluna.">&nbsp;&nbsp;DESTINATÁRIO</b></td>
      <td><b title="Click para ordenar por essa coluna.">&nbsp;CIDADE DESTINO</b></td>
      <td><b title="Click para ordenar por essa coluna.">MANIFESTO</b></td>
      <td><b title="Click para ordenar por essa coluna.">&nbsp;&nbsp;CTe</b></td>
      <td><b title="Click para ordenar por essa coluna.">&nbsp;&nbsp;DATA</b></td>
      <td><b title="Click para ordenar por essa coluna.">HORA</b></td>
      <td><b>&nbsp;&nbsp;N. F.</b></td>
      </tr>
';
    for ($q=0; $q < $lin; $q++) 
    { if ($bg1 == 1) { $bg="#BDBDBD";$bg1=0;} else {$bg="#ffffff";$bg1=1;}
      $class='';$style='';
      if ($linha[$top[$topico][$q]][25]==107){$colL=strtotime('now')-strtotime($linha[$top[$topico][$q]][35].' '.$linha[$top[$topico][$q]][28]);if($colL>=3600){$class='alerta';$style='background-color: yellow;';}}
      if ($linha[$top[$topico][$q]][15]<>''){$destinatario=$linha[$top[$topico][$q]][15];$cidade=$linha[$top[$topico][$q]][18];}else{$destinatario=$linha[$top[$topico][$q]][20];$cidade=$linha[$top[$topico][$q]][23];}
echo '
    <tr id="linha" bgcolor="'. $bg.'">
        <td>'.$linha[$top[$topico][$q]][14].'</td>
        <td>'.$destinatario.'</td>
        <td>'.$cidade.'</td>
        <td>&nbsp;&nbsp;'.$linha[$top[$topico][$q]][1].'</td>
        <td>'.$linha[$top[$topico][$q]][12].'</td>
        <td>'.$linha[$top[$topico][$q]][27].'</td>
        <td class="'.$class.'" align="center" style="'.$style.'">'.$linha[$top[$topico][$q]][28].'</td>
        <td>
          <form  method="post"  name="formDetalhe" action="API05_detalhe.php"  target="Historico">    
            <input id="result" name="result" type="hidden" value="'.htmlentities($lines, ENT_QUOTES, "UTF-8").'"/>
            <input id="start" name="start" type="hidden" value="'.$start[$linha[$top[$topico][$q]][9]].'"/> 
            <input id="stop" name="stop" type="hidden" value="'.$stop[$linha[$top[$topico][$q]][9]].'"/> 
            <input type="submit"onclick="javascript:Detalhe();" title="Click para ver Histórico." value="'.$linha[$top[$topico][$q]][9].'">
          </form>
        </td>
    </tr>
    ';
    }
echo '
  </table>
';
?>