real_escape_string($_GET['from_date']); $to_date = $conn->real_escape_string($_GET['to_date']); $search_conditions[] = "DATE(date) BETWEEN '$from_date' AND '$to_date'"; } elseif (!empty($_GET['from_date'])) { $from_date = $conn->real_escape_string($_GET['from_date']); $search_conditions[] = "DATE(date) >= '$from_date'"; } elseif (!empty($_GET['to_date'])) { $to_date = $conn->real_escape_string($_GET['to_date']); $search_conditions[] = "DATE(date) <= '$to_date'"; } // Handle challan_no if (!empty($_GET['challan_no'])) { $challan_no = $conn->real_escape_string($_GET['challan_no']); $search_conditions[] = "challan_no LIKE '%$challan_no%'"; } if (!empty($search_conditions)) { $where_sql = " WHERE " . implode(" AND ", $search_conditions); } $query = "SELECT * FROM `road_challans` $where_sql ORDER BY `id` DESC"; $result = $conn->query($query); ?>

Sales Report

num_rows > 0) { $index = 1; while ($row = $result->fetch_assoc()) { // Handle nulls safely $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'] !== null ? htmlspecialchars((string)$row['cgst']) : '0'; $sgst = $row['sgst'] !== null ? htmlspecialchars((string)$row['sgst']) : '0'; $igst = $row['igst'] !== null ? htmlspecialchars((string)$row['igst']) : '0'; echo ""; $index++; } } else { echo ''; } ?>
Select All # Seller Company Purchaser Company Challan No. Challan Date Unloaded Date Quantity Unloaded Rate Value CGST SGST IGST Total Action
" . $index . " " . htmlspecialchars((string)($row['consignorName'] ?? '')) . " " . htmlspecialchars((string)($row['name'] ?? '')) . " " . htmlspecialchars((string)($row['challan_no'] ?? '')) . " " . htmlspecialchars((string)($row['date'] ?? '')) . " " . $unloading_date . " " . htmlspecialchars((string)($row['quantity_billed'] ?? '')) . " " . htmlspecialchars((string)($row['rate'] ?? '')) . " " . htmlspecialchars((string)($row['amount'] ?? '')) . " " . $cgst . " " . $sgst . " " . $igst . " " . htmlspecialchars((string)($row['finalAmount'] ?? '')) . " View
No records found.