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/Grade_model.php
<?php
class grade_model extends CI_Model
{

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

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

	public function GetInfo($grade_id)	
	{
		$this->db->from('grade');
		$this->db->where('grade_id',$grade_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 save_grade($gradeData,$grade_id= FALSE){
	 if(!$this->exist($gradeData)){
			if($grade_id === -1){
			$this->db->insert('grade',$gradeData);
			$gradeData['grade_id']=$this->db->insert_id();
			return true;
		}else{
			$this->db->where('grade_id',$grade_id);
			$gradeData['updated_by'] =  $this->session->userdata('emp_id');
			$gradeData['updated_date'] = date('Y-m-d h:i:s');
			return $this->db->update('grade',$gradeData);
		}
		}else{
			return FALSE;
	}
		
	}		
	public function exist($gradeData){
		$grade = $gradeData['grade'];
		$this->db->from('grade');
		$this->db->where('grade',$grade);
		$this->db->where('deleted',0);
		return $this->db->get()->num_rows();
	}

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

	public function GetMultipleInfo($grade_ids){
		$this->db->from('grade');
		$this->db->where_in('grade_id', $grade_ids);
		return $this->db->get()->result_array();
	}
}
?>