File: /home/cafsindia/crm_cafsindia_com/application/models/Branch.php
<?php
class branch extends CI_Model
{
public function GetInfo($BranchId)
{
$this->db->from('branches');
$this->db->where('branch_id',$BranchId);
$a=$this->db->get();
if($a->num_rows() === 1)
{
return $a->row();
}
else
{
foreach ($this->db->list_fields('branches') as $field)
{
$PersonObj->field= '';
}
return $PersonObj;
}
}
public function exist($BranchId)
{
//print_r($BranchId);
$this->db->from('branches');
$a=array('branch_code'=>$BranchId['branch_code'],'branch_name'=>$BranchId['branch_name']);
$this->db->where($a);
return $this->db->get()->num_rows();
}
public function SaveCode(&$BranchData,$BranchIds= FALSE)
{
if(!$this->exists($BranchIds,'True')||!$BranchIds)
{
if($this->db->insert('branches',$BranchData))
{
$BranchData['branch_id']=$this->db->insert_id();
return true;
}
return False;
}
$this->db->where('branch_id',$BranchIds);
return $this->db->update('branches',$BranchData);
}
public function exists($BranchId)
{
$this->db->from('branches');
$this->db->where('branch_id',$BranchId);
return $this->db->get()->num_rows();
}
public function search($search,$rows = 0,$limit_from= 0,$sort='id',$order='asc')
{
$this->db->select('*');
$this->db->from('branches');
$this->db->where('status',1);
$this->db->group_start();
$this->db->like('branch_id',$search);
$this->db->or_like('branch_name',$search);
$this->db->or_like('branch_code',$search);
$this->db->group_end();
$this->db->order_by('branch_id',$order);
if($rows>0)
{
$this->db->limit($rows, $limit_from);
}
return $this->db->get();
}
public function GetFoundRows($search)
{
$this->db->select('*');
$this->db->from('branches');
$this->db->where('status',1);
return $this->db->get()->num_rows();
}
public function delete_list($code_id)
{
$this->db->where_in('branch_id',$code_id);
return $this->db->update('branches',array('status'=>0));
}
public function GetMultipleInfo($code_ids)
{
$this->db->from('branches');
$this->db->where_in('branch_id', $code_ids);
return $this->db->get()->result_array();
}
}
?>