From 07dd8158e55a0098e2f05b7434f4f6637e753b54 Mon Sep 17 00:00:00 2001
From: objecttothis <17935339+objecttothis@users.noreply.github.com>
Date: Mon, 11 Sep 2017 17:04:37 +0400
Subject: [PATCH 1/6] Support for custom search suggestion format
---
database/3.1.1_to_3.2.0.sql | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/database/3.1.1_to_3.2.0.sql b/database/3.1.1_to_3.2.0.sql
index fdbb27ba7..a73e1b86c 100644
--- a/database/3.1.1_to_3.2.0.sql
+++ b/database/3.1.1_to_3.2.0.sql
@@ -73,3 +73,11 @@ INSERT INTO `ospos_grants` (`permission_id`, `person_id`, `menu_group`) VALUES
ALTER TABLE `ospos_employees`
ADD COLUMN `language` VARCHAR(48) DEFAULT NULL,
ADD COLUMN `language_code` VARCHAR(8) DEFAULT NULL;
+
+
+-- Add support for custom search suggestion format
+
+INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
+('suggestions_first_column', 'name'),
+('suggestions_second_column', ''),
+('suggestions_third_column', '');
From aa346cbb3f659701f8ca083a19af9f9a661884c6 Mon Sep 17 00:00:00 2001
From: objecttothis <17935339+objecttothis@users.noreply.github.com>
Date: Mon, 11 Sep 2017 17:07:03 +0400
Subject: [PATCH 2/6] Add support for custom search suggestion format
---
database/tables.sql | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/database/tables.sql b/database/tables.sql
index 58c70eba5..5d60a9bbf 100644
--- a/database/tables.sql
+++ b/database/tables.sql
@@ -114,7 +114,10 @@ INSERT INTO `ospos_app_config` (`key`, `value`) VALUES
('receiving_calculate_average_price', '0'),
('work_order_enable', '0'),
('work_order_format', 'W%y{WSEQ:6}'),
-('last_used_work_order_number', '0');
+('last_used_work_order_number', '0'),
+('suggestions_first_column', 'name'),
+('suggestions_second_column', ''),
+('suggestions_third_column', '');
From cac02eaf967d67dd8ae4d70a8797e515695c91db Mon Sep 17 00:00:00 2001
From: objecttothis <17935339+objecttothis@users.noreply.github.com>
Date: Mon, 11 Sep 2017 17:19:07 +0400
Subject: [PATCH 3/6] Add language strings
---
application/language/en-US/config_lang.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/application/language/en-US/config_lang.php b/application/language/en-US/config_lang.php
index 15d996f81..d1c10eac5 100644
--- a/application/language/en-US/config_lang.php
+++ b/application/language/en-US/config_lang.php
@@ -227,6 +227,10 @@ $lang["config_work_order_format"] = "Work Order Format";
$lang["config_sales_quote_format"] = "Sales Quote Format";
$lang["config_saved_successfully"] = "Configuration save successful.";
$lang["config_saved_unsuccessfully"] = "Configuration save failed.";
+$lang["config_suggestions_first_column"] = "Column 1";
+$lang["config_suggestions_layout"] = "Search Suggestions Layout";
+$lang["config_suggestions_second_column"] = "Column 2";
+$lang["config_suggestions_third_column"] = "Column 3";
$lang["config_show_office_group"] = "Show office icon";
$lang["config_statistics"] = "Send Statistics";
$lang["config_statistics_tooltip"] = "Send statistics for development and feature improvement purposes.";
From 178ba9f70268fac0abb32df64d52e1387ec13f9e Mon Sep 17 00:00:00 2001
From: objecttothis <17935339+objecttothis@users.noreply.github.com>
Date: Tue, 12 Sep 2017 14:53:35 +0400
Subject: [PATCH 4/6] Add option to select custom columns for search
suggestions
---
application/views/configs/general_config.php | 37 ++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/application/views/configs/general_config.php b/application/views/configs/general_config.php
index 86bc5a8c0..4e5ddd043 100644
--- a/application/views/configs/general_config.php
+++ b/application/views/configs/general_config.php
@@ -115,6 +115,43 @@
+
+
lang->line('config_giftcard_number'), 'giftcard_number', array('class' => 'control-label col-xs-2')); ?>
From 6e82602a4711aa7742c8af50ca834bd8172459cf Mon Sep 17 00:00:00 2001
From: objecttothis <17935339+objecttothis@users.noreply.github.com>
Date: Tue, 12 Sep 2017 18:22:52 +0400
Subject: [PATCH 5/6] Allow custom suggestions format
This changes the display of the search suggestions to match the format set by the user in app_config. It does not change the logic of how the search suggestions are gathered.
---
application/models/Item.php | 52 ++++++++++++++++++++++++++++++++-----
1 file changed, 45 insertions(+), 7 deletions(-)
diff --git a/application/models/Item.php b/application/models/Item.php
index f8eb442a7..8ad8142aa 100644
--- a/application/models/Item.php
+++ b/application/models/Item.php
@@ -428,11 +428,49 @@ class Item extends CI_Model
return $success;
}
+ function get_search_suggestion_format(string $seed = NULL)
+ {
+ $seed .= ','.$this->config->item('suggestions_first_column');
+
+ if($this->config->item('suggestions_second_column') !== '')
+ {
+ $seed .= ','.$this->config->item('suggestions_second_column');
+ }
+
+ if($this->config->item('suggestions_third_column') !== '')
+ {
+ $seed .= ','.$this->config->item('suggestions_third_column');
+ }
+
+ return $seed;
+ }
+
+ function get_search_suggestion_label($result_row)
+ {
+ $label1 = $this->config->item('suggestions_first_column');
+ $label2 = $this->config->item('suggestions_second_column');
+ $label3 = $this->config->item('suggestions_third_column');
+
+ $label = $result_row->$label1;
+
+ if($label2 !== '')
+ {
+ $label .= ' | '. $result_row->$label2;
+ }
+
+ if($label3 !== '')
+ {
+ $label .= ' | '. $result_row->$label3;
+ }
+
+ return $label;
+ }
+
public function get_search_suggestions($search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25)
{
$suggestions = array();
- $this->db->select('item_id, name');
+ $this->db->select($this->get_search_suggestion_format('item_id,name'));
$this->db->from('items');
$this->db->where('deleted', $filters['is_deleted']);
$this->db->where("item_type = " . ITEM); // standard, exclude kit items since kits will be picked up later
@@ -440,10 +478,10 @@ class Item extends CI_Model
$this->db->order_by('name', 'asc');
foreach($this->db->get()->result() as $row)
{
- $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
+ $suggestions[] = array('value' => $row->item_id, 'label' => $this->get_search_suggestion_label($row));
}
- $this->db->select('item_id, item_number');
+ $this->db->select($this->get_search_suggestion_format('item_id,item_number'));
$this->db->from('items');
$this->db->where('deleted', $filters['is_deleted']);
$this->db->where("item_type = " . ITEM); // standard, exclude kit items since kits will be picked up later
@@ -451,7 +489,7 @@ class Item extends CI_Model
$this->db->order_by('item_number', 'asc');
foreach($this->db->get()->result() as $row)
{
- $suggestions[] = array('value' => $row->item_id, 'label' => $row->item_number);
+ $suggestions[] = array('value' => $row->item_id, 'label' => $this->get_search_suggestion_label($row));
}
if(!$unique)
@@ -484,7 +522,7 @@ class Item extends CI_Model
}
//Search by description
- $this->db->select('item_id, name, description');
+ $this->db->select($this->get_search_suggestion_format('item_id, name, description'));
$this->db->from('items');
$this->db->where('deleted', $filters['is_deleted']);
$this->db->where("item_type = " . ITEM); // standard, exclude kit items since kits will be picked up later
@@ -492,7 +530,7 @@ class Item extends CI_Model
$this->db->order_by('description', 'asc');
foreach($this->db->get()->result() as $row)
{
- $entry = array('value' => $row->item_id, 'label' => $row->name);
+ $entry = array('value' => $row->item_id, 'label' => $this->get_search_suggestion_label($row));
if(!array_walk($suggestions, function($value, $label) use ($entry) { return $entry['label'] != $label; } ))
{
$suggestions[] = $entry;
@@ -519,7 +557,7 @@ class Item extends CI_Model
$this->db->where("item_type = " . ITEM); // standard, exclude kit items since kits will be picked up later
foreach($this->db->get()->result() as $row)
{
- $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
+ $suggestions[] = array('value' => $row->item_id, 'label' => get_search_suggestion_label($row));
}
}
}
From 67cace93c71cc0c3d6d6ca8a16cf725ff7621f97 Mon Sep 17 00:00:00 2001
From: objecttothis <17935339+objecttothis@users.noreply.github.com>
Date: Tue, 12 Sep 2017 18:33:07 +0400
Subject: [PATCH 6/6] allow custom format in receivings as well
---
application/models/Item.php | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/application/models/Item.php b/application/models/Item.php
index 8ad8142aa..231d4af4c 100644
--- a/application/models/Item.php
+++ b/application/models/Item.php
@@ -577,7 +577,7 @@ class Item extends CI_Model
{
$suggestions = array();
- $this->db->select('item_id, name');
+ $this->db->select($this->get_search_suggestion_format('item_id, name'));
$this->db->from('items');
$this->db->where('deleted', $filters['is_deleted']);
$this->db->where("item_type = " . ITEM); // standard, exclude kit items since kits will be picked up later
@@ -586,10 +586,10 @@ class Item extends CI_Model
$this->db->order_by('name', 'asc');
foreach($this->db->get()->result() as $row)
{
- $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
+ $suggestions[] = array('value' => $row->item_id, 'label' => $this->get_search_suggestion_label($row));
}
- $this->db->select('item_id, item_number');
+ $this->db->select($this->get_search_suggestion_format('item_id, item_number'));
$this->db->from('items');
$this->db->where('deleted', $filters['is_deleted']);
$this->db->where("item_type = " . ITEM); // standard, exclude kit items since kits will be picked up later
@@ -598,7 +598,7 @@ class Item extends CI_Model
$this->db->order_by('item_number', 'asc');
foreach($this->db->get()->result() as $row)
{
- $suggestions[] = array('value' => $row->item_id, 'label' => $row->item_number);
+ $suggestions[] = array('value' => $row->item_id, 'label' => $this->get_search_suggestion_label($row));
}
if(!$unique)
@@ -631,7 +631,7 @@ class Item extends CI_Model
}
//Search by description
- $this->db->select('item_id, name, description');
+ $this->db->select($this->get_search_suggestion_format('item_id, name, description'));
$this->db->from('items');
$this->db->where('deleted', $filters['is_deleted']);
$this->db->where("item_type = " . ITEM); // standard, exclude kit items since kits will be picked up later
@@ -640,7 +640,7 @@ class Item extends CI_Model
$this->db->order_by('description', 'asc');
foreach($this->db->get()->result() as $row)
{
- $entry = array('value' => $row->item_id, 'label' => $row->name);
+ $entry = array('value' => $row->item_id, 'label' => $this->get_search_suggestion_label($row));
if(!array_walk($suggestions, function($value, $label) use ($entry) { return $entry['label'] != $label; } ))
{
$suggestions[] = $entry;
@@ -668,7 +668,7 @@ class Item extends CI_Model
$this->db->where('deleted', $filters['is_deleted']);
foreach($this->db->get()->result() as $row)
{
- $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
+ $suggestions[] = array('value' => $row->item_id, 'label' => $this->get_search_suggestion_label($row));
}
}
}