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/crm_cafsindia_com/application/models/Incentive_model.php
<?php
class incentive_model extends CI_Model
{

	public function search($search,$rows = 0,$limit_from= 0,$sort='grade_id',$order='asc'){
		$this->db->from('incentives');
		$this->db->join('role', 'role.role_id = incentives.role');
		$this->db->join('category', 'category.cat_id = incentives.category');
		$this->db->join('grade', 'grade.grade_id = incentives.grade');
		$this->db->where('incentives.deleted',0);
		$this->db->group_start();
		$this->db->like('incentive_id',$search);
		$this->db->or_like('role',$search);
		$this->db->or_like('category',$search);
		$this->db->or_like('incentives.grade',$search);
		$this->db->group_end();
		$this->db->order_by('incentive_id',$order);
		if($rows>0)
		{
			$this->db->limit($rows, $limit_from);
		}
		return $this->db->get();
	}

	public function get_found_rows($search){
		$this->db->from('incentives');
		$this->db->where('deleted',0);
		return $this->db->get()->num_rows();
	}

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

	public function get_role() {
	   $this->db->from('role');
	   $this->db->order_by('role_name', 'asc');
	   return $this->db->get();
	}

	public function get_grade() {
	   $this->db->from('grade');
	   $this->db->order_by('grade', 'asc');
	   return $this->db->get();
	}

	/*
	Gets Category
	*/
	public function get_category() {
	   $this->db->from('category');
	   $this->db->order_by('cat_name', 'asc');
	   return $this->db->get();
	}

	public function save_incentive($incentiveData,$incentive_id= FALSE){

		if($incentive_id === -1){
		$this->db->insert('incentives',$incentiveData);
		$incentiveData['incentive_id']=$this->db->insert_id();
		return true;
		}else{
			$this->db->where('incentive_id',$incentive_id);
			$incentiveData['updated_by'] =  $this->session->userdata('emp_id');
			$incentiveData['updated_date'] = date('Y-m-d h:i:s');
			return $this->db->update('incentives',$incentiveData);
		}		
	}
				

	public function delete_list($incentive_delete){		
		$this->db->where_in('incentive_id',$incentive_delete);
		return $this->db->update('incentives',array('deleted'=>1,'deleted_by'=>$this->session->userdata('emp_id'),'deleted_date'=>date('Y-m-d h:i:s')));
	}

	public function get_multiple_info($incentive_ids){
		$this->db->from('incentives');
		$this->db->where_in('incentive_id', $incentive_ids);
		return $this->db->get()->result_array();
	}
}
?>