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/Customer.php
<?php
class Customer extends Person{
	
	/*public function mob_exists($mobile){

		$this->db->from('customers');
		$this->db->where('custmobile', $mobile);
		$query = $this->db->get();
		if($query->num_rows() == 1){
			$info = $query->row();
			$cust_id = $info->custid;
       return $cust_id;
		}else{
			return false;
		}
	}*/
	
	public function exists($customer_id){
		$this->db->from('customers');
		$this->db->where('status', 1);
		$this->db->where('custid', $customer_id);
		return ($this->db->get()->num_rows() == 1);
	}
	
	public function search($search, $rows = 0, $limit_from = 0, $sort = 'cust_name', $order = 'asc'){
		$this->db->from('customers');
		$this->db->group_start();
			$this->db->like('custfname', $search);
			$this->db->or_like('custmobile', $search);
			$this->db->or_like('custemail', $search);
			$this->db->or_like('custaddress', $search);
		$this->db->group_end();
		$this->db->order_by('custid','desc');
		$this->db->where('status',1);
		if($rows > 0){
			$this->db->limit($rows, $limit_from);
		}
		return $this->db->get();
	}

	public function get_found_rows($search){
		$this->db->from('customers');
		$this->db->like('custfname', $search);
		$this->db->or_like('custmobile', $search);
		$this->db->or_like('custemail', $search);
		$this->db->or_like('custaddress', $search);
		$this->db->where('status',1);
		return $this->db->get()->num_rows();
	}
	public function get_info($customer_id){

		$this->db->from('customers');
		$this->db->where('customers.custid', $customer_id);
		$this->db->where('status', 1);
		$query = $this->db->get();
		
		if($query->num_rows() == 1){
			return $query->row();
		}else{
			$person_obj = parent::get_info(-1);
			foreach($this->db->list_fields('customers') as $field){
				$person_obj->$field = '';
			}
			return $person_obj;
		}
	}

	public function save_customer(&$customer_data, $customer_id = FALSE){
		if(!$customer_id || !$this->exists($customer_id, TRUE)){
			if($this->db->insert('customers', $customer_data)){
				$customer_data['custid'] = $this->db->insert_id();
				return TRUE;
			}
			return FALSE;
		}
		$this->db->where('custid', $customer_id);
		return $this->db->update('customers', $customer_data);
	}

	/*public function lead_save_customer($customer_data, $mobile){
		if(!$this->mob_exists($mobile)){
			$this->db->insert('customers', $customer_data);
			return $this->db->insert_id();
		}else{
			$this->db->where('custmobile', $mobile);
			$this->db->update('customers', $customer_data);
			return $this->mob_exists($mobile);
		}
	}*/

	public function delete_list($customer_ids){
		$this->db->where_in('custid', $customer_ids);
		return $this->db->update('customers', array('status' => 0));
 	}

	public function get_all($rows = 0, $limit_from = 0){
		$this->db->from('customers');
		$this->db->join('people', 'customers.person_id = people.person_id');
		$this->db->where('customers.status', 1);
		$this->db->order_by('cust_name', 'asc');
		if($rows > 0){
			$this->db->limit($rows, $limit_from);
		}
		return $this->db->get();
	}

	public function get_multiple_info($customer_ids){
		$this->db->from('customers');
		$this->db->where_in('customers.custid', $customer_ids);
		return $this->db->get()->result_array();
	}
	public function check_login_exist($custloginid){
		$this->db->from('customers');
		$this->db->where('customers.status', 1);
		$this->db->like('custloginid', $custloginid);
		return $this->db->get()->num_rows();
	}	
}
?>