<?php

include("../../DMMYSQLG.php");
$fechaIni =  DateTime::createFromFormat('d/m/Y', $_POST["fechaIni"]);
$fechaFin =  DateTime::createFromFormat('d/m/Y', $_POST["fechaFin"]);
$fechaIni2 = $fechaIni->format('Y-m-d');
$fechaFin2 = $fechaFin->format('Y-m-d');
$status = $_POST["status"];

$datos = mysqli_query($con ,"SELECT id,fecha_sol,status,supervisor,fdepartamento.np_desc1 , dxopemaex.nomb FROM pedidosH 
inner join fdepartamento on proyecto = fdepartamento.nparte1
inner join dxopemaex on solicitante = dxopemaex.oper WHERE fecha_sol BETWEEN '$fechaIni2' AND '$fechaFin2' AND status = $status order by fecha_sol DESC");

while ($iteam = mysqli_fetch_assoc($datos)) {
            if ($iteam['status'] == 3) {
                $statusP = "DEVUELTO PARCIAL";
                $color = 'yellow';
            }if ($iteam['status'] == 2) {
                $statusP = "DEVUELTO";
                $color = 'green';
            }if ($iteam['status'] == 1) {
                $statusP = "PESTADOS";
                $color = 'red';
            }

            echo "<tr>";
            echo "<td> <div align='center' style='color:#000'>" . $iteam["id"] . "&nbsp;</div></td>";
            echo "<td> <div align='center' style='color:#000'>" . $iteam["fecha_sol"] . "&nbsp;</div></td>";
            echo "<td> <div align='center' style='color:#000'>" . $iteam["nomb"] . "&nbsp;</div></td>";
            echo "<td> <div align='center' style='color:#000'>" . $iteam["np_desc1"] . "&nbsp;</div></td>";
            echo "<td> <div align='center' style='color:#000'>" . $iteam["supervisor"] . "&nbsp;</div></td>";
            echo "<td bgcolor='$color'> <div align='center' style='color:#000'>" .  $statusP . "&nbsp;</div></td>";
            echo "<td> <div align='center' style='color:#000'><button class='pedido' value='" . $iteam["id"] . "' type='button' >detalle</button></div></td>";
            echo "</tr>";
        }
