Файловый менеджер - Редактировать - /home/d46091/invoice.ecogenix.in/sales_excel_report.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 $selectedIds = array_filter($_POST['selected_ids'], fn($id) => is_numeric($id)); $selectedIdsList = implode(',', array_map('intval', $selectedIds)); if (empty($selectedIdsList)) { die('Invalid selection.'); } // Fetch records $query = "SELECT * FROM `road_challans` WHERE id IN ($selectedIdsList) ORDER BY `id` DESC"; $result = $conn->query($query); // Excel headers header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename=sales_report_" . date("Ymd_His") . ".xls"); header("Pragma: no-cache"); header("Expires: 0"); // Output table 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>Unloaded Date</th> <th>Quantity Unloaded</th> <th>Rate</th> <th>Value</th> <th>CGST</th> <th>SGST</th> <th>IGST</th> <th>Total</th> </tr> </thead> <tbody>"; if ($result && $result->num_rows > 0) { $index = 1; while ($row = $result->fetch_assoc()) { $date_of_unloading = !empty($row['date_of_unloading']) ? new DateTime($row['date_of_unloading']) : null; $unloading_date = $date_of_unloading ? $date_of_unloading->format('Y-m-d') : 'N/A'; $cgst = $row['cgst'] !== '' && $row['cgst'] !== null ? $row['cgst'] : 'NULL'; $sgst = $row['sgst'] !== '' && $row['sgst'] !== null ? $row['sgst'] : 'NULL'; $igst = $row['igst'] !== '' && $row['igst'] !== null ? $row['igst'] : 'NULL'; echo "<tr> <td>{$index}</td> <td>" . htmlspecialchars((string)($row['consignorName'] ?? '')) . "</td> <td>" . htmlspecialchars((string)($row['name'] ?? '')) . "</td> <td>" . htmlspecialchars((string)($row['challan_no'] ?? '')) . "</td> <td>" . htmlspecialchars((string)($row['date'] ?? '')) . "</td> <td>{$unloading_date}</td> <td>" . htmlspecialchars((string)($row['quantity_billed'] ?? '')) . "</td> <td>" . htmlspecialchars((string)($row['rate'] ?? '')) . "</td> <td>" . htmlspecialchars((string)($row['amount'] ?? '')) . "</td> <td>{$cgst}</td> <td>{$sgst}</td> <td>{$igst}</td> <td>" . htmlspecialchars((string)($row['finalAmount'] ?? '')) . "</td> </tr>"; $index++; } } else { echo "<tr><td colspan='13'>No matching data found.</td></tr>"; } echo "</tbody></table>";
| ver. 1.4 |
Github
|
.
| PHP 8.1.32 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка