Файловый менеджер - Редактировать - /home/d46091/invoice.ecogenix.in/export_delivery_lt.php
Назад
<?php require_once('includes/connection.php'); // Check for selected IDs if (!isset($_POST['selected_ids']) || !is_array($_POST['selected_ids']) || empty($_POST['selected_ids'])) { die('No records selected for export.'); } // Sanitize IDs (allow only integers) $selectedIds = array_filter($_POST['selected_ids'], fn($id) => is_numeric($id)); $selectedIdsList = implode(',', array_map('intval', $selectedIds)); if (empty($selectedIdsList)) { die('Invalid selection.'); } // Fetch only selected records $query = "SELECT * FROM `road_challans` WHERE id IN ($selectedIdsList) ORDER BY `id` DESC"; $result = $conn->query($query); // Set headers for Excel file download header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=delivery_lead_time_" . date("Ymd_His") . ".xls"); header("Pragma: no-cache"); header("Expires: 0"); // Begin table output echo "<table border='1'>"; echo "<thead> <tr> <th>Sl No.</th> <th>Seller Company</th> <th>Purchaser Company</th> <th>Challan No.</th> <th>Challan Date</th> <th>Reach Date</th> <th>Unloaded Date</th> <th>Unloaded Time</th> <th>Despatch To Reach Time (Days)</th> <th>Reach To Unload Time (Days)</th> <th>Dispatch To Unload Time (Days)</th> </tr> </thead> <tbody>"; if ($result && $result->num_rows > 0) { $index = 1; while ($row = $result->fetch_assoc()) { // Safely create DateTime objects $date = !empty($row['d_vehicle_date']) ? new DateTime($row['d_vehicle_date']) : null; $date_of_reach = !empty($row['date_of_reach']) ? new DateTime($row['date_of_reach']) : null; $date_of_unloading = !empty($row['date_of_unloading']) ? new DateTime($row['date_of_unloading']) : null; // Initialize difference values $days_to_reach = $days_to_unload = $total_days = 'N/A'; if ($date && $date_of_reach) { $days_to_reach = $date->diff($date_of_reach)->days; } if ($date_of_reach && $date_of_unloading) { $days_to_unload = $date_of_reach->diff($date_of_unloading)->days; } if ($date && $date_of_unloading) { $total_days = $date->diff($date_of_unloading)->days; } // Format unloaded date and time $unloaded_date = $date_of_unloading ? $date_of_unloading->format('Y-m-d') : 'N/A'; $unloaded_time = $date_of_unloading ? $date_of_unloading->format('H:i:s') : ''; echo "<tr> <td>{$index}</td> <td>" . htmlspecialchars($row['consignorName'] ?? '') . "</td> <td>" . htmlspecialchars($row['name'] ?? '') . "</td> <td>" . htmlspecialchars($row['challan_no'] ?? '') . "</td> <td>" . htmlspecialchars($row['date'] ?? '') . "</td> <td>" . htmlspecialchars($row['date_of_reach'] ?? '') . "</td> <td>{$unloaded_date}</td> <td>{$unloaded_time}</td> <td>{$days_to_reach}</td> <td>{$days_to_unload}</td> <td>{$total_days}</td> </tr>"; $index++; } } else { echo "<tr><td colspan='11'>No matching data found.</td></tr>"; } echo "</tbody></table>";
| ver. 1.4 |
Github
|
.
| PHP 8.1.32 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка