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); ?>

Delivery Lead Time Report

num_rows > 0) { $index = 1; while ($row = $result->fetch_assoc()) { // Validate and create DateTime objects safely $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 values $days_to_reach = $days_to_unload = $total_days = 'N/A'; $unloading_date = $unloading_time = 'N/A'; if ($date && $date_of_reach) { $days_to_reach = $date->diff($date_of_reach)->days . ' day(s)'; } if ($date_of_reach && $date_of_unloading) { $days_to_unload = $date_of_reach->diff($date_of_unloading)->days . ' day(s)'; } if ($date && $date_of_unloading) { $total_days = $date->diff($date_of_unloading)->days . ' day(s)'; } if ($date_of_unloading) { $unloading_date = $date_of_unloading->format('Y-m-d'); $unloading_time = $date_of_unloading->format('H:i:s'); } echo ""; $index++; } } else { echo ''; } ?>
Select All # Seller Company Purchaser Company Challan No. Challan Date Reach Date Unloaded Date Despatch To Reach Time Reach To Unload Time Dispatch To Unload Time Action
{$index} {$row['consignorName']} {$row['name']} {$row['challan_no']} {$row['date']} {$row['date_of_reach']} {$unloading_date} {$unloading_time} {$days_to_reach} {$days_to_unload} {$total_days} View
No records found.