[eluser]ridley1012[/eluser]
Hi I have quite a specific requirement in terms of a diary for a rental system, I need to be able to select a date range which then builds a table and lists all vehicles, then cross reference the dates and vehicles with the database to check if the vehicles are available or booked out. so far I have a function to return the date range as an array. I then have the following model function
Code:
function get_all_vehicles()
{
$this->db->select('*');
$this->db->join('types', 'types.type_index = vehicles.type_index');
$query = $this->db->get_where('vehicles', array('sold' => 'No'));
return $query->result();
}
my controller is as follows
Code:
public function diary()
{
$this->load->model('vehicle_model', 'vehicles', TRUE);
$data['page'] = $this->page;
$data['vehicles'] = $this->vehicles->get_all_vehicles();
$data['dates'] = $this->get_date_range('2011-12-01', '2011-12-06');
$data['title'] = "Administration Panel - Rental Diary";
$this->load->model('rentals_model', 'rentals', TRUE);
$this->load->view('templates/admin/header', $data);
$this->load->view('templates/admin/sidebar');
$this->load->view('admin/diary');
$this->load->view('templates/admin/footer');
}
and then this is currently the view to display it
Code:
<table id="diary">
<thead>
<tr>
<td><strong>VEHICLE REG</strong></td>
<?php foreach($dates as $date) {?>
<td><?=$date?></td>
<?php }?>
</tr>
</thead>
<tbody>
<?php foreach($vehicles as $vehicle) { ?>
<tr>
<td><?=$vehicle->registration;?></td>
<?php foreach($dates as $date) {?>
<td><!--WHAT TO DO HERE!!!!!!!--></td>
<?php }?>
</tr>
<?php }?>
</tbody>
</table>
the problem I have is checking the availibility for each vehicle on each date, I know it would be easy enough to do by calling information from the database within the view file but I want to stick with the MVC format. Any help/suggestions would be greatly appreciated.