<?php
declare(strict_types=0);
// session_start();
// echo '<meta http-equiv="refresh" content="5">';
foreach($_GET  as $key => $value){${$key}=trim($value);$_PARAMS[$key]=${$key};}  
foreach($_POST as $key => $value){${$key}=trim($value);$_PARAMS[$key]=${$key};}
include_once('lib_main.php');

echo '<div id="filtros" noprint style="background-color:;">';

$zid='plvh';
$zlabel='Placa';
$ztodo=1;
$zvalue=$plvh;
$ztabla='plvh';
$zsize=1.5;
$zwidth=6;
$zonchange='{fn_consulta(event);}';
include('ele_input.php');

$zobj=1;
include('ele_break.php');


$zid='btn_consul'; 
$zlabel='Consultar';
$zalign='right';
$zonclick='{fn_consulta(event);}';
$zsize=1.5;
include('ele_button.php');

echo '</div>';

$zobj=2;     
include('ele_break.php');
     


echo '<div id="main2" style="font-size:'.$fsize.'px;" >';


if(!empty($plvh))
{
     
     $modu='vtas';
     $docu='FC10';

     set_hora2grg($modu,$docu,$ptov);
     
     $sql_plvh='select * from '.$modu.'1 left join '.$modu.'2 on idnum1=idnum2 ';
     $sql_plvh.='left join item0 on item=item_codigo ';
     $sql_plvh.='left join plvh0 on plvh=plvh_codigo ';
     $sql_plvh=calc_fields($modu,$sql_plvh);
     $sql_plvh.='where ifnull(status,"")not in ("O","X")';
     $sql_plvh.='and plvh="'.$plvh.'" ';
     $sql_plvh.='and fecha>="'.date('Y-m-d',strtotime('-2 day')).'" ';
     $sql_plvh.='order by idnum1 desc limit 1';
     $res_plvh=msql_query($sql_plvh,$link_data);
     
     $aso_plvh=msql_fetch_assoc($res_plvh);
     
     
//      var_dump2($aso_plvh);
     
// $zobj=2;     
// include('ele_break.php');
     
     $zid='ticket';
     $zlabel='🧾 Ticket';
     $zreado=1;
     $zvalue=$aso_plvh['numero'];
//      $ztype='date';
     $zsize=1.5;
     $zwidth=6;
     include('ele_input.php');

// $zobj=1;     
// include('ele_break.php');
     
     $zid='fecha';
     $zlabel='Fecha';
     $zreado=1;
     $zvalue=$aso_plvh['fecha'];
     $ztype='date';
     $zsize=1.5;
//      $zwidth=5;
     include('ele_input.php');

$zobj=1;     
include('ele_break.php');
     
     $uniclock=uni_clock(substr($aso_plvh['hora1'],0,5));
     $zid='entra';
     $zlabel=$uniclock.' Entrada';
     $zreado=1;
     $zvalue=$aso_plvh['hora1'];
//      $ztype='time';
     $zsize=1.5;
     $zwidth=5;
     include('ele_input.php');

// $zobj=1;     
// include('ele_break.php');
     
     $uniclock=uni_clock(substr($aso_plvh['hora2'],0,5));
     $zid='sale';
     $zlabel=$uniclock.' Salida';
     $zreado=1;
     $zvalue=$aso_plvh['hora2'];
//      $zhide=1;
//      if($aso_plvh['stfin']==1){$zhide=0;}
     if($aso_plvh['stfin']!=1){$zvalue="--:--";}
     $zsize=1.5;
     $zwidth=5;
     include('ele_input.php');

$zobj=1;     
include('ele_break.php');
     
//      ⌚
     $zid='tiempo';
     $zlabel='⏲ Tiempo';
     $zreado=1;
     $zvalue=$aso_plvh['hora12'];
     $zsize=1.5;
     $zwidth=5;
     include('ele_input.php');

// $zobj=1;     
// include('ele_break.php');
     
     $zid='tarifa';
     $zlabel='💲 Tarifa';
     $zreado=1;
     $zvalue=number_format($aso_plvh['item_pvp1'],2);
     $zsize=1.5;
     $zclass='numeric-dec';
     $zwidth=5;
     include('ele_input.php');

$zobj=1;     
include('ele_break.php');
     
     $zid='total';
     $zlabel='💲 Total ';
     $zreado=1;
     $zvalue=number_format($aso_plvh['total'],2);
     $zsize=1.5;
     $zclass='numeric-dec';
     $zwidth=5;
     $zalign='right';
     include('ele_input.php');
     
//      var_dump2($aso_plvh);


     
if($aso_plvh['stfin']!=1)
{
     
     
     
$zobj=2;     
include('ele_break.php');
     
     
     $zid='enti';
     $zlabel='🪪 Facturar a: ';
//      $zreado=1;
     $zvalue=$aso_plvh['enti'];
     if($aso_plvh['fecha']==date('Y-m-d'))
     {
     $zsave=1;
     $zsavet='plvh';
     $zsavec=$aso_plvh['plvh_enti'];
     $zsavef='enti';
     }
     $zsize=1.5;
//      $ztabla='enti';
     if(strlen($zvalue)>=10){$zreado=1;}
     if(substr($zvalue,0,2)=='99'){$zreado=0;}
     include('ele_input.php');
     
$zobj=1;     
include('ele_break.php');
     
     $zid='wsapp';
     $zlabel='📱 WhatsApp';
     $zvalue=$aso_plvh['plvh_wsapp'];
     $ztype='number';
     if($aso_plvh['fecha']==date('Y-m-d'))
     {
     $zsave=1;
     $zsavet='plvh';
     $zsavec=$aso_plvh['plvh'];
     $zsavef='wsapp';
     }
     if(strlen($zvalue)>=10){$zreado=1;}
//      if(empty($numero)){$zreado=1; }  
     $zsize=1.5;
     include('ele_input.php');
}
     
     
}


echo '</div>';


?>


<script>
function fn_consulta(event)
{
     var xhref='',dataget;
     xhref=xhref+'?scri=<?php echo basename(__FILE__,'.php');?>';
     dataget=new_FormData('filtros','get');
     xhref=xhref+dataget;
//      alert(xhref);
     document.getElementById("main2").innerHTML='Espere...';
     location.href=xhref;
}
</script>
