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/sbltt/application/models/Rate_model.php
<?php
class Rate_model extends CI_Model
{
	public function search($search,$rows = 0,$limit_from= 0,$sort='rate_id',$order='asc'){
		$this->db->from('rate');
		$this->db->join('trip_type', 'trip_type.trip_type_id = rate.rate_trip_type','left');
		$this->db->join('veh_type', 'veh_type.veh_type_id = rate.rate_vehicle_type','left');
		$this->db->join('vendor', 'vendor.vendor_id = rate.rate_vendor','left');
		$this->db->where('rate.status',1);
		$this->db->group_start();
		$this->db->like('rate_id',$search);
		$this->db->or_like('trip_type_name',$search);
		$this->db->or_like('veh_type',$search);
		$this->db->or_like('upto_km',$search);
		$this->db->or_like('upto_amt',$search);
		$this->db->or_like('extra_km_amt',$search);
		$this->db->group_end();
		$this->db->order_by('rate_id',$order);
		if($rows>0)
		{
			$this->db->limit($rows, $limit_from);
		}
		return $this->db->get();
	}
	
	public function get_found_rows($search){
		$this->db->from('rate');
		$this->db->where('status',1);
		return $this->db->get()->num_rows();
	}
	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_trip_type() {
	   $this->db->from('trip_type');
	   $this->db->where('status', 1);
	   $this->db->order_by('trip_type_name', 'asc');
	   return $this->db->get();
	}
	public function get_vendor() {
	   $this->db->from('vendor');
	   $this->db->where('status', 1);
	   $this->db->order_by('vendor_name', 'asc');
	   return $this->db->get();
	}
	public function get_info($rate_id){
		$this->db->from('rate');
		$this->db->where('rate_id',$rate_id);
		$a=$this->db->get();
		if($a->num_rows() === 1){
			return $a->row();		
		}else{
			foreach ($this->db->list_fields('rate') as $field){
				$PersonObj->field= '';
			}
			return $PersonObj;
		}
	}

	public function exists($rate_id){
		$this->db->from('rate');
		$this->db->where('rate_id', $rate_id);
		return ($this->db->get()->num_rows() == 1);
	}

	/*
	Inserts or updates a rate
	*/
	public function save_rate(&$rate_data, $rate_id = FALSE){

		if(!$rate_id || !$this->exists($rate_id, TRUE))
		{
			if($this->db->insert('rate', $rate_data))
			{
				$rate_data['rate_id'] = $this->db->insert_id();

				return TRUE;
			}

			return FALSE;
		}

		$this->db->where('rate_id', $rate_id);

		return $this->db->update('rate', $rate_data);

}

	public function delete_list($rate_id){
		$this->db->where_in('rate_id',$rate_id);
		return $this->db->update('rate',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('rate');
		$this->db->where_in('rate_id', $cat_ids);
		return $this->db->get()->result_array();
	}
}
?>