Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
APPSST
/
Admin
/
excel
:
ENTREGAS.PHP.bak
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php session_start(); header("Cache-control: private"); // Arregla IE 6 //*******Datos de Conexion Base de Datos************ include("../bd/conexion.php"); $conexion = new mysqli($host, $user, $pw, $bd); if ($conexion->connect_error) { die("Error de conexión: " . $conexion->connect_error); } // Configurar headers para Excel header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=Entregas_ST.xls"); header("Pragma: no-cache"); header("Expires: 0"); // Obtener parámetros del formulario $cedula = isset($_POST["cedula"]) ? $_POST["cedula"] : ""; $fecha_inicio = isset($_POST["fechaXls1"]) ? $_POST["fechaXls1"] : ""; $fecha_fin = isset($_POST["fechaXls2"]) ? $_POST["fechaXls2"] : ""; // Construir condición WHERE $conditions = array("1=1"); // Condición base siempre verdadera if (!empty($cedula)) { $conditions[] = "cedula = '".$conexion->real_escape_string($cedula)."'"; } if (!empty($fecha_inicio) && !empty($fecha_fin)) { $conditions[] = "fEntrega BETWEEN '".$conexion->real_escape_string($fecha_inicio)."' AND '".$conexion->real_escape_string($fecha_fin)."'"; } $where_clause = implode(" AND ", $conditions); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Reporte de Entregas ST</title> </head> <body> <center> <table border="1"> <tr> <th>ID</th> <th>Cédula</th> <th>Nombre</th> <th>Centro de Costo</th> <th>Cargo</th> <th>Fecha Entrega</th> <th>Tipo Entrega</th> <th>Estado</th> <th>Tipo Devolutivo</th> <th>Código EPP</th> <th>EPP</th> <th>Cantidad</th> <th>Entregó</th> </tr> <?php // Consulta principal a la tabla entregasst $query = "SELECT * FROM entregasst WHERE $where_clause ORDER BY fEntrega DESC"; $result = $conexion->query($query); if (!$result) { echo "<tr><td colspan='14'>Error en la consulta: " . $conexion->error . "</td></tr>"; } elseif ($result->num_rows == 0) { echo "<tr><td colspan='14'>No se encontraron registros con los filtros aplicados</td></tr>"; } else { while ($row = $result->fetch_assoc()) { echo "<tr>"; echo "<td>".htmlspecialchars($row['ID'])."</td>"; echo "<td>".htmlspecialchars($row['cedula'])."</td>"; echo "<td>".htmlspecialchars($row['nombre'])."</td>"; echo "<td>".htmlspecialchars($row['ccosto'])."</td>"; echo "<td>".htmlspecialchars($row['cargo'])."</td>"; echo "<td>".htmlspecialchars($row['fEntrega'])."</td>"; echo "<td>".htmlspecialchars($row['tpEntrega'])."</td>"; echo "<td>".htmlspecialchars($row['tpEstado'])."</td>"; echo "<td>".htmlspecialchars($row['tpDevolutivo'])."</td>"; echo "<td>".htmlspecialchars($row['codigo'])."</td>"; echo "<td>".htmlspecialchars($row['epp'])."</td>"; echo "<td>".htmlspecialchars($row['cantidad'])."</td>"; echo "<td>".htmlspecialchars($row['entrego'])."</td>"; echo "</tr>"; } } ?> </table> </center> </body> </html> <?php $conexion->close(); ?>