OwlCyberSecurity - MANAGER
Edit File: booking.php
<?php require_once './config/config.php'; require_once './includes/auth_validate.php'; // Fetch all bookings with JOINs to get related data $db = getDbInstance(); // Join bookings with customers, vehicles, and drivers $db->join('customers c', 'b.customer_id = c.customer_id', 'LEFT'); $db->join('vehicles v', 'b.vehicle_id = v.vehicle_id', 'LEFT'); $db->join('drivers d', 'b.driver_id = d.driver_id', 'LEFT'); // Order by booking_date in descending order $db->orderBy('b.booking_date', 'DESC'); // Select columns from all tables with aliases // IMPORTANT: 'tour_date' has been replaced by 'start_tour_date' and 'end_tour_date' // 'num_vehicles' has also been added. $bookings = $db->get('bookings b', null, ' b.booking_id, b.booking_date, b.start_tour_date, /* New column */ b.end_tour_date, /* New column */ b.tour_name, b.rate_per_day, b.num_vehicles, /* New column */ b.no_of_days, b.total_amount, b.advance, b.finalization_date, c.full_name, c.father_name, c.mobile_no, c.cnic, v.transport_type, v.vehicle_number AS vehicle_no, /* Alias for consistency with form */ d.driver_name '); require_once 'includes/header.php'; ?> <!-- Font Awesome CDN for icons --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <style> table { font-size: 12px; } th, td { text-align: center; padding: 8px; } .table-responsive { max-height: 400px; /* Keeps scrollability */ overflow-y: auto; } .btn { font-size: 14px; padding: 5px 10px; } .btn i { margin-right: 5px; font-size: 10px; } </style> <div id="page-wrapper"> <div class="row"> <div class="col-lg-12"> <h2 class="page-header">Bookings List</h2> </div> </div> <?php include('./includes/flash_messages.php'); ?> <div class="table-responsive"> <table class="table table-bordered table-striped"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Father Name</th> <!-- Corrected "Last name" to "Father Name" as per customer schema --> <th>Mobile No</th> <th>CNIC</th> <th>Booking Date</th> <th>Start Tour Date</th> <!-- Updated Header --> <th>End Tour Date</th> <!-- New Header --> <th>Tour Name</th> <th>Rate Per Day (PKR)</th> <th>Number of Vehicles</th> <!-- New Header --> <th>No of Days</th> <th>Transport Type</th> <th>Total Amount (PKR)</th> <th>Advance Payment (PKR)</th> <th>Vehicle No</th> <th>Driver Name</th> <th>Finalization Date</th> <th>Actions</th> </tr> </thead> <tbody> <?php if ($bookings): ?> <?php foreach ($bookings as $row): ?> <tr> <td><?php echo htmlspecialchars($row['booking_id']); ?></td> <td><?php echo htmlspecialchars($row['full_name']); ?></td> <td><?php echo htmlspecialchars($row['father_name']); ?></td> <td><?php echo htmlspecialchars($row['mobile_no']); ?></td> <td><?php echo htmlspecialchars($row['cnic']); ?></td> <td><?php echo htmlspecialchars($row['booking_date']); ?></td> <td><?php echo htmlspecialchars($row['start_tour_date']); ?></td> <!-- Display New Column --> <td><?php echo htmlspecialchars($row['end_tour_date']); ?></td> <!-- Display New Column --> <td><?php echo htmlspecialchars($row['tour_name']); ?></td> <td><?php echo htmlspecialchars($row['rate_per_day']); ?></td> <td><?php echo htmlspecialchars($row['num_vehicles']); ?></td> <!-- Display New Column --> <td><?php echo htmlspecialchars($row['no_of_days']); ?></td> <td><?php echo htmlspecialchars($row['transport_type']); ?></td> <td><?php echo htmlspecialchars($row['total_amount']); ?></td> <td><?php echo htmlspecialchars($row['advance']); ?></td> <td><?php echo htmlspecialchars($row['vehicle_no']); ?></td> <td><?php echo htmlspecialchars($row['driver_name']); ?></td> <td><?php echo htmlspecialchars($row['finalization_date']); ?></td> <td> <a href="content.php?page=generate_pdf&id=<?php echo $row['booking_id']; ?>" class="btn btn-sm btn-success"> <i class="fas fa-file-pdf"></i> </a> <!-- You might also want to add an edit and delete button here if they exist --> <!-- <a href="content.php?page=edit_booking&booking_id=<?php echo $row['booking_id']; ?>" class="btn btn-sm btn-primary"> <i class="fas fa-edit"></i> </a> <a href="delete_booking.php?booking_id=<?php echo $row['booking_id']; ?>" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure you want to delete this booking?');"> <i class="fas fa-trash"></i> </a> --> </td> </tr> <?php endforeach; ?> <?php else: ?> <tr> <td colspan="19">No bookings found.</td> </tr> <?php endif; ?> </tbody> </table> </div> </div> <?php include_once 'includes/footer.php'; ?>