<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Mod_payment extends CI_Model{

	var $table = "tblpayment";	
	var $payment = "tblreservation";
	
	function add($payment)
	{
		$this->db->insert($this->table,$payment);	
	}
	
	function payment_complete($data,$lastreffnumber)
	{
		$this->db->where("trn_id",$lastreffnumber);
		$this->db->update($this->payment,$data);
	}
	
	
	function getById($id)
	{
		if($id=="")
		{
			redirect("home");		
		}
		$q =$this->db->query("select a.*,(select tblcar.images from tblcar where a.brand_id = tblcar.brandname group by `brandname`) as imagename, (select b.locationname from tbllocation as b where a.pickup_location = b.id) as pickupname,(SELECT c.locationname from tbllocation as c where a.return_location = c.id)as dropOffname,(select tblcar.fullname from tblcar where a.brand_id = tblcar.brandname group by `brandname`)as carname,(select tblservices.typename from tblservices where a.services_id = tblservices.id)as servicename from tblbooking as a where `trn_id`=".$id."");
			
		if($q->num_rows() > 0)
		{
			return $q->row();
		}
		return false;
	}
	
	function payComplete($id)
	{
		$this->db->where("reserve_id",$id);
		$this->db->where("confirm",1);
		$this->db->from($this->table);
		$q = $this->db->get();
		if($q->num_rows() > 0)
		{
			return $q->row();
		}
		return false;	

	}


	
}