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

$query = mysqli_query($conection, "SELECT * FROM proveedor
WHERE estatus = 1 ORDER BY idproveedor");

mysqli_close($conection);

$docu = "proveedores.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 = 6>Lista de proveedores</th>';
echo '</tr>';
echo '<tr><th>ID</th><th>RUC</th><th>PROVEEDOR</th><th>CONTACTO</th><th>TELEFONO</th><th>DIRECCION</th></tr>';

while ($data = mysqli_fetch_array($query)) {
    $formato = 'Y-m-d H:i:s';
    $fecha = DateTime::createFromFormat($formato, $data["date_add"]);

    echo '<tr>';
    echo '<td>' . $data["idproveedor"] . '</td>';
    echo '<td>' . $data["ruc"] . '</td>';
    echo '<td>' . $data["proveedor"] . '</td>';
    echo '<td>' . $data["contacto"] . '</td>';
    echo '<td>' . $data["telefono"] . '</td>';
    echo '<td>' . $data["direccion"] . '</td>';
    echo '</tr>';
}

echo '</table>';
