mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-05 14:24:05 -04:00
Add group operator to giftcard query
This commit is contained in:
@@ -187,18 +187,18 @@ class Giftcard extends CI_Model
|
||||
$suggestions[]=$row->giftcard_number;
|
||||
}
|
||||
|
||||
$this->db->from('customers');
|
||||
$this->db->join('people', 'customers.person_id=people.person_id', 'left');
|
||||
$this->db->from('customers');
|
||||
$this->db->join('people', 'customers.person_id=people.person_id', 'left');
|
||||
$this->db->like('first_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('last_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('CONCAT(first_name, " ", last_name)', $this->db->escape_like_str($search));
|
||||
$this->db->where('deleted', 0);
|
||||
$this->db->order_by('last_name', 'asc');
|
||||
$by_name = $this->db->get();
|
||||
$this->db->where('deleted', 0);
|
||||
$this->db->order_by('last_name', 'asc');
|
||||
$by_name = $this->db->get();
|
||||
|
||||
foreach($by_name->result() as $row)
|
||||
{
|
||||
$suggestions[]=$row->first_name.' '.$row->last_name;
|
||||
foreach($by_name->result() as $row)
|
||||
{
|
||||
$suggestions[]=$row->first_name.' '.$row->last_name;
|
||||
}
|
||||
|
||||
//only return $limit suggestions
|
||||
@@ -209,59 +209,61 @@ class Giftcard extends CI_Model
|
||||
|
||||
return $suggestions;
|
||||
}
|
||||
|
||||
/*
|
||||
Get search suggestions to find customers
|
||||
*/
|
||||
function get_person_search_suggestions($search,$limit=25)
|
||||
{
|
||||
$suggestions = array();
|
||||
|
||||
$this->db->select('person_id');
|
||||
|
||||
/*
|
||||
Get search suggestions to find customers
|
||||
*/
|
||||
function get_person_search_suggestions($search,$limit=25)
|
||||
{
|
||||
$suggestions = array();
|
||||
|
||||
$this->db->select('person_id');
|
||||
$this->db->from('people');
|
||||
$this->db->like('person_id', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('first_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('last_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('CONCAT(first_name, " ", last_name)', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('email', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('phone_number', $this->db->escape_like_str($search));
|
||||
$this->db->order_by('person_id', 'asc');
|
||||
$by_person_id = $this->db->get();
|
||||
|
||||
foreach($by_person_id->result() as $row)
|
||||
{
|
||||
$suggestions[]=$row->person_id;
|
||||
}
|
||||
|
||||
//only return $limit suggestions
|
||||
if(count($suggestions > $limit))
|
||||
{
|
||||
$suggestions = array_slice($suggestions, 0,$limit);
|
||||
$this->db->like('person_id', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('first_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('last_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('CONCAT(first_name, " ", last_name)', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('email', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('phone_number', $this->db->escape_like_str($search));
|
||||
$this->db->order_by('person_id', 'asc');
|
||||
$by_person_id = $this->db->get();
|
||||
|
||||
foreach($by_person_id->result() as $row)
|
||||
{
|
||||
$suggestions[]=$row->person_id;
|
||||
}
|
||||
|
||||
return $suggestions;
|
||||
|
||||
//only return $limit suggestions
|
||||
if(count($suggestions > $limit))
|
||||
{
|
||||
$suggestions = array_slice($suggestions, 0,$limit);
|
||||
}
|
||||
|
||||
return $suggestions;
|
||||
}
|
||||
|
||||
/*
|
||||
Preform a search on giftcards
|
||||
*/
|
||||
function search($search, $rows = 0, $limit_from = 0)
|
||||
{
|
||||
$this->db->from('giftcards');
|
||||
{
|
||||
$this->db->from('giftcards');
|
||||
$this->db->join('people', 'giftcards.person_id=people.person_id', 'left');
|
||||
$this->db->like('first_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('last_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('CONCAT(first_name, " ", last_name)', $this->db->escape_like_str($search));
|
||||
$this->db->like('first_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_group_start();
|
||||
$this->db->or_like('last_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('CONCAT(first_name, " ", last_name)', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('giftcard_number', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('giftcards.person_id', $this->db->escape_like_str($search));
|
||||
$this->db->where('deleted', 0);
|
||||
$this->db->group_end();
|
||||
$this->db->where('giftcards.deleted', 0);
|
||||
$this->db->order_by('giftcard_number', 'asc');
|
||||
|
||||
if ($rows > 0)
|
||||
{
|
||||
$this->db->limit($rows, $limit_from);
|
||||
}
|
||||
|
||||
|
||||
return $this->db->get();
|
||||
}
|
||||
|
||||
@@ -270,12 +272,13 @@ class Giftcard extends CI_Model
|
||||
$this->db->from('giftcards');
|
||||
$this->db->join('people', 'giftcards.person_id=people.person_id', 'left');
|
||||
$this->db->like('first_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_group_start();
|
||||
$this->db->or_like('last_name', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('CONCAT(first_name, " ", last_name)', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('giftcard_number', $this->db->escape_like_str($search));
|
||||
$this->db->or_like('giftcards.person_id', $this->db->escape_like_str($search));
|
||||
$this->db->where('deleted', 0);
|
||||
|
||||
$this->db->group_end();
|
||||
$this->db->where('giftcards.deleted', 0);
|
||||
return $this->db->get()->num_rows();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user