<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

	class Mod_booking extends CI_Model
	{
		var $table = "tblreservation";
		function __construct()
		{
			parent::__construct();
		}	
		
		function getbooking ()
		{
			$sql="select a.*,(select tblcar.fullname from tblcar where a.car_id = tblcar.id) as brandname,(select b.typename from tblservices as b where a.services_id = b.id) as servicename,(SELECT c.locationname from tbllocation as c where a.pickup_location=c.id)as pick_up_location,(SELECT d.locationname from tbllocation as d where a.return_location=d.id)as drop_off_location from tblreservation as a order by `id` DESC";
			return $this->db->query($sql);
			
		}
		
		function detail($id)
		{
			$sql="select a.*,(select tblcar.fullname from tblcar where a.car_id = tblcar.id) as brandname,(select b.typename from tblservices as b where a.services_id = b.id) as servicename,(SELECT c.locationname from tbllocation as c where a.pickup_location=c.id)as pickup_location,(SELECT d.locationname from tbllocation as d where a.return_location=d.id)as return_location from tblreservation as a WHERE id=".$id."";
			return $this->db->query($sql);
		}
		
		function update($data,$id)
		{
			$this->db->where("id",$id);
			$this->db->update($this->table,$data);
		}
	
		
	}