mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-16 12:57:32 -04:00
Add item search for category + suppliers (#328)
This commit is contained in:
@@ -41,7 +41,7 @@ class Giftcards extends Secure_area implements iData_controller
|
||||
*/
|
||||
function suggest()
|
||||
{
|
||||
$suggestions = $this->Giftcard->get_search_suggestions($this->input->post('term'), $this->input->post('limit'));
|
||||
$suggestions = $this->Giftcard->get_search_suggestions($this->input->post('term'));
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ class Items extends Secure_area implements iData_controller
|
||||
$suggestions = $this->Item->get_search_suggestions($this->input->post_get('term'), array(
|
||||
'search_custom' => $this->input->post('search_custom'),
|
||||
'is_deleted' => !empty($this->input->post('is_deleted'))),
|
||||
FALSE, $this->input->post('limit'));
|
||||
FALSE);
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
|
||||
@@ -210,38 +210,6 @@ 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');
|
||||
$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[]=array('label' => $row->person_id);
|
||||
}
|
||||
|
||||
//only return $limit suggestions
|
||||
if(count($suggestions > $limit))
|
||||
{
|
||||
$suggestions = array_slice($suggestions, 0,$limit);
|
||||
}
|
||||
|
||||
return $suggestions;
|
||||
}
|
||||
|
||||
/*
|
||||
Preform a search on giftcards
|
||||
*/
|
||||
|
||||
@@ -263,7 +263,7 @@ class Item extends CI_Model
|
||||
return $this->db->update('items', array('deleted' => 1));
|
||||
}
|
||||
|
||||
public function get_search_suggestions($search, $filters = array("is_deleted"), $unique = FALSE, $limit=25)
|
||||
public function get_search_suggestions($search, $filters = array("is_deleted" => 0), $unique = FALSE, $limit=25)
|
||||
{
|
||||
$suggestions = array();
|
||||
|
||||
@@ -291,6 +291,18 @@ class Item extends CI_Model
|
||||
|
||||
if (!$unique)
|
||||
{
|
||||
$this->db->select('category');
|
||||
$this->db->from('items');
|
||||
$this->db->where('deleted', $filters['is_deleted']);
|
||||
$this->db->distinct();
|
||||
$this->db->like('category', $search);
|
||||
$this->db->order_by('category', 'asc');
|
||||
$by_category = $this->db->get();
|
||||
foreach($by_category->result() as $row)
|
||||
{
|
||||
$suggestions[] = array('label' => $row->category);
|
||||
}
|
||||
|
||||
$this->db->select('company_name');
|
||||
$this->db->from('suppliers');
|
||||
$this->db->like('company_name', $search);
|
||||
@@ -301,7 +313,7 @@ class Item extends CI_Model
|
||||
$by_company_name = $this->db->get();
|
||||
foreach($by_company_name->result() as $row)
|
||||
{
|
||||
$suggestions[] = array('value' => $row->item_id, 'label' => $row->company_name);
|
||||
$suggestions[] = array('label' => $row->company_name);
|
||||
}
|
||||
|
||||
//Search by description
|
||||
|
||||
Reference in New Issue
Block a user