MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/allyindian_com/backend/application/models/Vehicle_model.php
<?php
class Vehicle_model extends CI_Model
{
	public function search($search,$rows = 0,$limit_from= 0,$sort='vehicle_id',$order='asc'){
		$this->db->from('vehicle');
		$this->db->join('veh_type', 'veh_type.veh_type_id = vehicle.vehicle_type','left');
		$this->db->where('vehicle.status',1);
		$this->db->group_start();
			$this->db->like('vehicle_id',$search);
			$this->db->or_like('vehicle_no',$search);
			$this->db->or_like('veh_type.veh_type',$search);
		$this->db->group_end();
		$this->db->order_by('vehicle_id',$order);
		if($rows>0)
		{
			$this->db->limit($rows, $limit_from);
		}
		return $this->db->get();
	}
	
	public function get_found_rows($search){
		$this->db->from('vehicle');
		$this->db->where('status',1);
		return $this->db->get()->num_rows();
	}

	public function get_info($vehicle_id)	
	{
		$this->db->from('vehicle');
		$this->db->where('vehicle_id',$vehicle_id);
		$a=$this->db->get();
		if($a->num_rows() === 1){
			return $a->row();
		
		}else{
			foreach ($this->db->list_fields('vehicle') as $field)
			{
				$PersonObj->field= '';
			}
			return $PersonObj;
		}
	}

	

	public function exists($vehicle_id){
		$this->db->from('vehicle');
		$this->db->where('vehicle_id', $vehicle_id);
		return ($this->db->get()->num_rows() == 1);
	}
	/*Gets all of state*/
	public function get_state() {
	   $this->db->from('state');
	   $this->db->order_by('state_name', 'asc');
	   return $this->db->get();
	}
	public function get_vehicle_type() {
	   $this->db->from('veh_type');
	   $this->db->where('status', 1);
	   $this->db->order_by('veh_type', 'asc');
	   return $this->db->get();
	}	
	public function get_vehicle_data($vehicle_id){
		$this->db->from('vehicle');
		$this->db->where('vehicle_id', $vehicle_id);
		return $this->db->get()->result_array();
	}			
	/* Inserts or updates a vehicle */
	public function save_vehicle(&$vehicle_data, $vehicle_id = FALSE){
		if(!$vehicle_id || !$this->exists($vehicle_id, TRUE)){
			if($this->db->insert('vehicle', $vehicle_data)){
				$vehicle_data['vehicle_id'] = $this->db->insert_id();
				return TRUE;
			}
			return FALSE;
		}
		$this->db->where('vehicle_id', $vehicle_id);
		return $this->db->update('vehicle', $vehicle_data);
	}

	// Add / Updated Vehicle Seat layout
	public function add_seats($vehicle_id,$lower,$upper){
		$this->db->where('vehicle_id', $vehicle_id);
		$update_seat = $this->db->update('vehicle', array('vehicle_lower'=>$lower,'vehicle_upper'=>$upper));
		// if($update_seat){
		// 	$seats = $lower;
		// 	if($upper){
		// 		$seats = $lower.",".$upper;
		// 	}
		// 	$this->db->where('vehicleid', $vehicle_id);
		// 	$update_seatmap = $this->db->update('vehicletrips', array('seatmap'=>$seats));
		// }
		if($update_seat){
			return $this->get_vehicle_data($vehicle_id);
		}		
	}

	public function delete_list($vehicle_id){
		$this->db->where_in('vehicle_id',$vehicle_id);
		return $this->db->update('vehicle',array('status'=>0,'deleted_by'=>$this->session->userdata('emp_id'),'deleted_date'=>date('Y-m-d h:i:s')));
	}
	public function get_multiple_info($cat_ids){
		$this->db->from('vehicle');
		$this->db->where_in('vehicle_id', $cat_ids);
		return $this->db->get()->result_array();
	}	
}
?>