File: /home/cafsindia/crm_cafsindia_com/application/models/RM_Amc_model.php
<?php
class amc_model extends Person
{
public function exists($amc_id){
$this->db->from('amc');
$this->db->where('id', $amc_id);
return $this->db->get()->num_rows();
}
public function duplicate($amc_data){
$data=$this->db->get_where('amc',array('amc'=>$amc_data['amc'],'fund_id'=>$amc_data['fund_id'],'status'=>0));
return $data->num_rows();
}
public function search($search, $rows = 0, $limit_from = 0, $sort = 'amc.id', $order = 'asc'){
$this->db->from('amc');
$this->db->join('fund_name', 'fund_name.fund_id = amc.fund_id');
$this->db->where('amc.status', 0);
$this->db->group_start();
$this->db->like('amc', $search);
$this->db->or_like('fund_name.fund_name', $search);
$this->db->group_end();
$this->db->order_by($sort, $order);
if($rows > 0)
{
$this->db->limit($rows, $limit_from);
}
return $this->db->get();
}
public function get_found_rows($search){
$this->db->from('amc');
$this->db->join('fund_name','amc.fund_id=fund_name.fund_id');
$this->db->where('amc.status', 0);
return $this->db->get()->num_rows();
}
public function get_fund() {
$this->db->from('fund_name');
$this->db->order_by('fund_name', 'asc');
$this->db->where('status', 0);
return $this->db->get();
}
public function get_info($amc_id){
$this->db->from('amc');
$this->db->where('id', $amc_id);
$query = $this->db->get();
if($query->num_rows() == 1)
{
return $query->row();
}
else
{
foreach($this->db->list_fields('amc') as $field)
{
$person_obj->$field = '';
}
return $person_obj;
}
}
public function save_amc(&$amc_data, $amc_id = FALSE){
$this->db->trans_start();
if(!$amc_id || !$this->exists($amc_id)){
$success = $this->db->insert('amc', $amc_data);
}else{
$this->db->where('id', $amc_id);
$success = $this->db->update('amc', $amc_data);
}
$this->db->trans_complete();
$success &= $this->db->trans_status();
return TRUE;
}
public function delete_list($customer_ids){
$this->db->where_in('id', $customer_ids);
return $this->db->update('amc', array('status' => 1));
}
public function GetMultipleInfo($fund_ids)
{
$this->db->from('amc');
$this->db->where_in('id', $fund_ids);
return $this->db->get()->result_array();
}
// public function get_search_suggestions($search, $unique = TRUE, $limit = 25){
// $suggestions = array();
// $this->db->from('amc');
// $this->db->join('fund_name', 'amc.fund_id = fund_name.fund_id');
// $this->db->group_start();
// $this->db->like('amc', $search);
// $this->db->or_like('fund_name.fund_name', $search);
// $this->db->group_end();
// $this->db->where('status', 0);
// $this->db->order_by('amc', 'asc');
// foreach($this->db->get()->result() as $row)
// {
// $suggestions[] = array('value' => $row->id, 'label' => $row->amc.' '.$row->fund_id);
// }
// if(!$unique)
// {
// $this->db->from('amc');
// $this->db->join('fund_name', 'amc.fund_id = fund_name.fund_id');
// $this->db->where('status', 0);
// $this->db->order_by('amc', 'asc');
// foreach($this->db->get()->result() as $row)
// {
// $suggestions[] = array('value' => $row->id, 'label' => $row->amc);
// }
// $this->db->from('amc');
// $this->db->join('fund_name', 'amc.fund_id = fund_name.fund_id');
// $this->db->where('status', 0);
// // $this->db->where('amc.op_id',$this->session->userdata('shop_id'));
// $this->db->like('amc', $search);
// $this->db->order_by('fund_id', 'asc');
// foreach($this->db->get()->result() as $row)
// {
// $suggestions[] = array('value' => $row->person_id, 'label' => $row->phone_number);
// }
// $this->db->from('amc');
// $this->db->join('fund_name', 'amc.fund_id = fund_name.fund_id');
// $this->db->where('status', 0);
// }
// if(count($suggestions > $limit))
// {
// $suggestions = array_slice($suggestions, 0, $limit);
// }
// return $suggestions;
// }
}
?>