TransWar File Browser

Path: C:\

<?php
session_start();
ini_set ('memory_limit','-1');
date_default_timezone_set('America/Sao_Paulo');
$dateadded = date("d/m/Y  --  G:i"); 
$fim=$hoje = date("d/m/Y"); 
$dtlimite  = date("Ymd"); 
$linha     = json_decode($_SESSION['json'], true); // Isto irá tornar o JSON em array
if (isset($_GET['Topico'])) {$topico=$_GET['Topico'];}else {$topico='Tudo';}
if (isset($_POST['inicio'])) {$inicio=$_POST['inicio'];} else {$inicio=$hoje;}
$matriz    = $_SESSION['matriz'];
$principal = json_decode($matriz, true);
$oc=count($principal);
for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']!=='black')
  {$fundo[$principal[$x]['id']]=$principal[$x]['cor'];}
}
$x0=1;for ($x=0;$x<$oc;$x++)
{ if($principal[$x]['cor']!=='black')
  { $tudo[$x0]=$principal[$x]['id'];$x0++;}
}
$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=='ALOCADO / LIBERADO'){$by=$x4;$id=$peru;}else{if($topico=='CHEGADA NO LOCAL'){$by=$x5;$id=$blue;}else{if($topico=='EM ROTA DE COLETA'){$by=$x6;$id=$gold;}else{if($topico=='PENDENTE'){$by=$x7;$id=$gray;}else{$by=$x0;$id=$tudo;}}}}}}
$ano1=substr($fim, 6);
$mes1=substr($fim, 3,-5);
$dia1=substr($fim, 0,-8);
$data3=$ano1.$mes1.$dia1;
$lin=count($linha);
$ant=$linha[1][12];$start[$ant]=1;
for ($q=0; $q <= 150; $q++) { $tot[$q]=0; } 
for ($q=1; $q <= $lin; $q++) 
{ if ($linha[$q][12]<>$ant)
  { $start[$linha[$q][12]]=$q;
    $stop[$ant]=$q-1;
    $ant=$linha[$q][12];
  }
  $ind=intval($linha[$q][25]);
  if ($ind<>108 and $linha[$q][7]=='COLETA')
  {
    if ($ind==32)
    {
      if ($linha[$q][35]>=$data3)
      { if($linha[$q][26]=='COLETADA (SEM OCORRÊNCIA)'){$linha[$q][26]='SERVIÇO REALIZADO NORMALMENTE';}
      $reg[$ind][]=$q;for($i=1;$i<$by;$i++){if($ind==$id[$i]){$top[$topico][]=$q;}}
      }
    }
    else
    { 
      if ($q<>$lin)
      { if ($linha[$q][12]<>($linha[$q+1][12]))
        { 
            $reg[$ind][]=$q;for($i=1;$i<$by;$i++){if($ind==$id[$i]){$top[$topico][]=$q;}}
        }
      }
      else
      {
        $reg[$ind][]=$q;for($i=1;$i<$by;$i++){if($ind==$id[$i]){$top[$topico][]=$q;}}
      }
    }
  }
}
if ($linha[$lin][12]<>$ant)
{ 
  $start[$linha[$lin][12]]=$lin;
  $stop[$ant]=$lin-1;
  $stop[$linha[$lin][12]]=$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: 9px; 
      }
    table.blue td {
      overflow: hidden;word-wrap: break-word;
      }
    th {
      text-align:left;
      padding:0px 0;
      }
    thead {
      color:white;
      background:#6D7EA0;
      }
    a:hover {
      background-color: yellow;
      }
      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 COLETAS: (&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="7%" />
    <col width="16%" />
    <col width="17%" />
    <col width="12%" />
    <col width="18%" />
    <col width="6%" />
    <col width="4%" />
    <col width="6%" />
    <col width="9%" />
    <col width="5%" />
    <thead>
      <tr height="31">
      <td><b title="Click para ordenar por essa coluna.">&nbsp;&nbsp;DIA COLETA</b></td>
      <td><b title="Click para ordenar por essa coluna.">&nbsp;&nbsp;CLIENTE</b></td>
      <td><b title="Click para ordenar por essa coluna.">&nbsp;&nbsp;LOCAL DA COLETA</b></td>
      <td><b title="Click para ordenar por essa coluna.">&nbsp;CIDADE DA COLETA</b></td>
      <td><b title="Click para ordenar por essa coluna.">&nbsp;&nbsp;OCORRÊNCIA</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 title="Click para ordenar por essa coluna.">&nbsp;&nbsp;&nbsp;&nbsp;LIMITE</b></td>
      <td><b title="Click para ordenar por essa coluna.">&nbsp;&nbsp;N. F.</b></td>
      <td><b>&nbsp;&nbsp;PEDIDO</b></td>
      </tr>
    </thead>
    <tbody>';
    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]==146 or $linha[$top[$topico][$q]][25]==149)
        { $ano4=substr($linha[$top[$topico][$q]][30], 6);
          $mes4=substr($linha[$top[$topico][$q]][30], 3,-5);
          $dia4=substr($linha[$top[$topico][$q]][30], 0,-8);
          $data4=$ano4.$mes4.$dia4;
          if($dtlimite>=$data4){$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];}
      if ($fundo[$linha[$top[$topico][$q]][25]]=='Gold'){$letra='black';}else{$letra='white';;}
echo '
    <tr id="linha" bgcolor="'. $bg.'" >
      <td>&nbsp;&nbsp;'.$linha[$top[$topico][$q]][37].'</td>
      <td>'.$linha[$top[$topico][$q]][14].'</td>
      <td>'.$destinatario.'</td>
      <td>'.$cidade.'</td>
      <td>&nbsp;&nbsp;'.$linha[$top[$topico][$q]][26].'</td>
      <td>'.$linha[$top[$topico][$q]][27].'</td>
      <td>'.$linha[$top[$topico][$q]][28].'</td>
      <td class="'.$class.'" align="center" style="'.$style.'">'.$linha[$top[$topico][$q]][30].'</td>
      <td>'.$linha[$top[$topico][$q]][9].'</td>
        <td>
          <form  method="post"  name="formDetalhe" action="API06_detalhe.php?get=json"  target="Historico">    
            <input id="start" name="start" type="hidden" value="'.$start[$linha[$top[$topico][$q]][12]].'"/> 
            <input id="stop" name="stop" type="hidden" value="'.$stop[$linha[$top[$topico][$q]][12]].'"/> 
            <input type="submit" onclick="javascript:Detalhe();" style="color:'.$letra.' ;background-color: '.$fundo[$linha[$top[$topico][$q]][25]].'" title="Click para ver Histórico." value="'.$linha[$top[$topico][$q]][12].'">
          </form>
        </td>
    </tr>
    ';
    }
echo '
    </tbody>
  </table>
';
?>