Файловый менеджер - Редактировать - /home/d46091/invoice.ecogenix.in/export_transit_loss.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=transit_loss_" . 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>Quantity Dispatch</th> <th>Quantity Unloaded</th> <th>Difference (Kgs)</th> </tr> </thead> <tbody>"; if ($result && $result->num_rows > 0) { $index = 1; while ($row = $result->fetch_assoc()) { $qty = is_numeric($row['quantity']) ? (float)$row['quantity'] : 0; $qty_billed = is_numeric($row['quantity_billed']) ? (float)$row['quantity_billed'] : 0; $difference = $qty - $qty_billed; 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['quantity'] ?? '') . "</td> <td>" . htmlspecialchars($row['quantity_billed'] ?? '') . "</td> <td>" . htmlspecialchars((string)$difference) . "</td> </tr>"; $index++; } } else { echo "<tr><td colspan='8'>No matching data found.</td></tr>"; } echo "</tbody></table>";
| ver. 1.4 |
Github
|
.
| PHP 8.1.32 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка