Merge pull request #1739 from odiea/master

Add Company search to Customer and Sales
This commit is contained in:
FrancescoUK
2017-12-02 16:10:08 +00:00
committed by GitHub

View File

@@ -256,13 +256,14 @@ class Customer extends Person
{
$this->db->or_like('email', $search);
$this->db->or_like('phone_number', $search);
$this->db->or_like('company_name', $search);
}
$this->db->group_end();
$this->db->where('deleted', 0);
$this->db->order_by('last_name', 'asc');
foreach($this->db->get()->result() as $row)
{
$suggestions[] = array('value' => $row->person_id, 'label' => $row->first_name . ' ' . $row->last_name . (!empty($row->phone_number) ? ' [' . $row->phone_number . ']' : ''));
$suggestions[] = array('value' => $row->person_id, 'label' => $row->first_name . ' ' . $row->last_name . (!empty($row->company_name) ? ' [' . $row->company_name . ']' : ''). (!empty($row->phone_number) ? ' [' . $row->phone_number . ']' : ''));
}
if(!$unique)
@@ -296,6 +297,15 @@ class Customer extends Person
{
$suggestions[] = array('value' => $row->person_id, 'label' => $row->account_number);
}
$this->db->from('customers');
$this->db->join('people', 'customers.person_id = people.person_id');
$this->db->where('deleted', 0);
$this->db->like('company_name', $search);
$this->db->order_by('company_name', 'asc');
foreach($this->db->get()->result() as $row)
{
$suggestions[] = array('value' => $row->person_id, 'label' => $row->company_name);
}
}
//only return $limit suggestions
@@ -320,6 +330,7 @@ class Customer extends Person
$this->db->or_like('email', $search);
$this->db->or_like('phone_number', $search);
$this->db->or_like('account_number', $search);
$this->db->or_like('company_name', $search);
$this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
$this->db->group_end();
$this->db->where('deleted', 0);
@@ -340,6 +351,7 @@ class Customer extends Person
$this->db->or_like('email', $search);
$this->db->or_like('phone_number', $search);
$this->db->or_like('account_number', $search);
$this->db->or_like('company_name', $search);
$this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
$this->db->group_end();
$this->db->where('deleted', 0);