<?php
require '../conexion.php';

$query = mysqli_query($conection, "SELECT f.nofactura,f.fecha,f.totalfactura,f.codcliente,f.estatus,
                                                     u.nombre as vendedor,
                                                     cl.nombre as cliente
                                              FROM factura f
                                              INNER JOIN usuario u
                                              ON f.usuario = u.idusuario
                                              INNER JOIN cliente cl
                                              ON f.codcliente = cl.idcliente
                                              WHERE f.estatus != 10
                                              ORDER BY f.fecha ASC ");
mysqli_close($conection);

$docu = "cotizaciones.xls";
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename=' . $docu);
header('Pragma: no-cache');
header('Expires: 0');
echo '<table border = 1>';
echo '<tr>';
echo '<th colspan = 5>Lista de cotizaciones</th>';
echo '</tr>';
echo '<tr><th>NRO. COTIZACION</th><th>FECHA - HORA</th><th>CLIENTE</th><th>VENDEDOR</th><th>TOTAL COTIZACION</th></tr>';


while ($data = mysqli_fetch_array($query)) {

    echo '<tr>';
    echo '<td>'. 'No 2024-0' . $data["nofactura"] . '</td>';
    echo '<td>' . $data["fecha"] . '</td>';
    echo '<td>' . $data["cliente"] . '</td>';
    echo '<td>' . $data["vendedor"] . '</td>';
    echo '<td>' . 'S/.' . $data["totalfactura"] . '</td>';
    echo '</tr>';
}

echo '</table>'; 