Welcome Guest, Not a member yet? Register   Sign In
Custom Rental Diary
#1

[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>
   &lt;?php foreach($dates as $date) {?&gt;
     <td>&lt;?=$date?&gt;</td>
   &lt;?php }?&gt;
</tr>
    </thead>
    <tbody>
      &lt;?php foreach($vehicles as $vehicle) { ?&gt;
<tr>
  <td>&lt;?=$vehicle->registration;?&gt;</td>
    &lt;?php foreach($dates as $date) {?&gt;
        <td>&lt;!--WHAT TO DO HERE!!!!!!!--&gt;</td>
      &lt;?php }?&gt;
   </tr>
&lt;?php }?&gt;
    </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.


Messages In This Thread
Custom Rental Diary - by El Forum - 05-13-2012, 01:11 AM
Custom Rental Diary - by El Forum - 05-13-2012, 03:09 AM
Custom Rental Diary - by El Forum - 05-14-2012, 03:05 AM
Custom Rental Diary - by El Forum - 05-14-2012, 04:52 AM
Custom Rental Diary - by El Forum - 05-14-2012, 05:21 AM
Custom Rental Diary - by El Forum - 05-14-2012, 06:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB