<?php 
class Vehicle_model extends CI_Model {
	
	public function _consruct(){
		parent::_construct();
 	}

 	function addVehicle($vehicle_data = array()){
 		if(empty($vehicle_data)){
 			return 0;
 		}
 		$status = $this->db->insert('customer_vehicle',$vehicle_data);
 		return ($status)?$this->db->insert_id():'0';
 	}

 	function changeStatus($vehicle_id = '', $action = '0'){
 		if(empty($vehicle_id)){
 			return 0;
 		}
 		if($action == 3){
			$status = $this->db->delete('customer_vehicle',array('customer_veh_id'=>$vehicle_id));
 		} else {
 			$status = $this->db->update('customer_vehicle',array('status'=>$action),
 														   array('customer_veh_id'=>$vehicle_id));
 		}
 		return $status;
 	}

    function getCustVechiles($searchData = array()){
        if(empty($searchData)){
        	return 0;
        }
        $cond = array();

        $cond['status'] = 1;
        if(isset($searchData['customer_id']) && !empty($searchData['customer_id'])){
        	$cond['customer_id'] = $searchData['customer_id'];
        }
		$vehData = $this->db->get_where('customer_vehicle',$cond);
		
		if(!empty($vehData)){
			return $vehData->result();
		}
		return 0;
    }

    function changeCustomerCarStatus($customer_id = '', $customer_veh_id = '', $status = ''){
    	if(empty($customer_id) || empty($customer_veh_id) || $status == ''){
    		return 0;
    	}

    	$upStatus = $this->db->update('customer_vehicle',
    								array('status'=>$status),
    								array('customer_id'=>$customer_id,'customer_veh_id'=>$customer_veh_id));

    	return $upStatus;
    }
}
?>