<?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 ped.*,user.nomb,user.apa,proy.np_desc1 from pedido as ped
                                                left join dxopemaex as user on ped.solicitante=user.oper
                                                inner join fdepartamento as proy on ped.proyecto=proy.nparte1
                                                where  fecha_sol between '$fechaIni2' and '$fechaFin2'  AND proy.t1='ACTIVO' AND ped.status = $status order by fecha_sol DESC");
 
while ($fila = mysqli_fetch_assoc($datos)) {

    if ($fila['status'] == 3) {
        $statusP = "SURTIDO PARCIAL";
        $color = 'yellow';
    }if ($fila['status'] == 2) {
        $statusP = "SURTIDO";
        $color = 'green';
    }if ($fila['status'] == 1) {
        $statusP = "POR SURTIR";
        $color = 'red';
    }

    echo "<tr>";
    echo "<td> <div align='center' style='color:#000'>" . $fila['id'] . "&nbsp;</div></td>";
    echo "<td> <div align='center' style='color:#000'>" . $fila['fecha_sol'] . "&nbsp;</div></td>";
    echo "<td> <div align='center' style='color:#000'>" . $fila['nomb'] . "  " . $fila['apa'] . "&nbsp;</div></td>";
    echo "<td> <div align='center' style='color:#000'>" . $fila['np_desc1'] . "&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='" . $fila['id'] . "' type='button' >detalle</button></div></td>";
    echo "</tr>";
}
