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/Company_codes.php
<?php
class Company_codes extends CI_Model
{
	/*
	Gets Vendor Name
	*/
	public function get_vendor()
	{
		$this->db->from('vendor');
		$this->db->order_by('vendorcompanyname','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();
	}
	/*
	On change category to vendor
	*/
	public function get_ven($c)
	{
		$this->db->select('vendor_id,vendorcompanyname');
		$this->db->from('vendor');
		$this->db->where('category_id',$c);
		return $this->db->get()->result_array();	 
	}

	/*
	Save Company code
	*/
	public function save_code($code_data,$company_code_id= FALSE)
	{
		if($company_code_id === -1){
			$this->db->insert('code',$code_data);
			$code_data['code_id'] = $this->db->insert_id();
			return $code_data['code_id'];
		}else{
			$this->db->where('code_id',$company_code_id);
			return $this->db->update('code',$code_data);
		}
	}

	/*
	To check Company Code Exists
	*/
	public function exist($company_codes)
	{
		$this->db->from('code');
		$this->db->where('company_code',$company_codes);
		return $this->db->get()->num_rows();
	}

	public function exists($company_codes)
	{
		$this->db->from('code');
		$this->db->where('code_id',$company_codes);
		return $this->db->get()->num_rows();
	}
	
	/*
	Search Company Codes
	*/
	public function search($search,$rows = 0,$limit_from= 0,$sort='id',$order='asc')
	{
		
		$this->db->select('*');
		$this->db->from('code AS A');// I use aliasing make joins easier
		$this->db->join('category AS C', 'A.category_id = C.cat_id', 'INNER');
		$this->db->join('vendor AS B', 'B.vendor_id = A.vendorcompanyname', 'INNER');
		$this->db->where('A.status',1);
		$this->db->group_start();
		$this->db->like('code_id',$search);
		$this->db->or_like('cat_name',$search);
		$this->db->or_like('B.vendorcompanyname',$search);
		$this->db->or_like('company_code',$search);
		$this->db->group_end();
		$this->db->order_by('code_id',$order);
		if($rows>0)
		{
			$this->db->limit($rows, $limit_from);
		}
		return $this->db->get();
	}
	/*
	Get Found Rows
	*/
	public function get_found_rows($search)
	{

		$this->db->select('*');
		$this->db->from('code AS A');// I use aliasing make joins easier
		$this->db->join('category AS C', 'A.category_id = C.cat_id', 'INNER');
		$this->db->join('vendor AS B', 'B.vendor_id = A.vendorcompanyname', 'INNER');
		$this->db->where('A.status',1);
		return $this->db->get()->num_rows();
		
	}
	/*
	Get Company COdes
	*/
	public function get_info($code_id)
	{
		$this->db->from('code');
		$this->db->where('code_id', $code_id);
		$query = $this->db->get();
		if($query->num_rows() == 1)
		{
			return $query->row();
		}
		else
		{
			foreach($this->db->list_fields('code') as $field)
			{
				$person_obj->$field = '';
			}
			return $person_obj;
		}
	}
	/*
	Delete Company codes
	*/
	public function delete_list($code_id)
	{
		$this->db->where_in('code_id',$code_id);
		return $this->db->update('code',array('code.status'=>0));
	}
	public function get_multiple_info($code_ids)
	{
		$this->db->from('code');
		$this->db->where_in('code_id', $code_ids);
		return $this->db->get()->result_array();
	}
	
}