diff --git a/application/language/en-GB/config_lang.php b/application/language/en-GB/config_lang.php index 1457f97a7..6c3b896a8 100644 --- a/application/language/en-GB/config_lang.php +++ b/application/language/en-GB/config_lang.php @@ -233,6 +233,10 @@ $lang["config_stock_location"] = "Stock location"; $lang["config_stock_location_duplicate"] = "Please use an unique location name"; $lang["config_stock_location_invalid_chars"] = "The stock location name cannot contain '_'"; $lang["config_stock_location_required"] = "Stock location is a required field"; +$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_table"] = "Table"; $lang["config_table_configuration"] = "Table Configuration"; $lang["config_takings_printer"] = "Takings Printer"; diff --git a/application/language/en-US/config_lang.php b/application/language/en-US/config_lang.php index 15d996f81..718770fbe 100644 --- a/application/language/en-US/config_lang.php +++ b/application/language/en-US/config_lang.php @@ -234,6 +234,10 @@ $lang["config_stock_location"] = "Stock location"; $lang["config_stock_location_duplicate"] = "Stock Location must be unique."; $lang["config_stock_location_invalid_chars"] = "Stock Location can not contain '_'."; $lang["config_stock_location_required"] = "Stock location is a required field."; +$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_table"] = "Table"; $lang["config_table_configuration"] = "Table Configuration"; $lang["config_takings_printer"] = "Receipt Printer"; diff --git a/application/models/Item.php b/application/models/Item.php index f8eb442a7..231d4af4c 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)); } } } @@ -539,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 @@ -548,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 @@ -560,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) @@ -593,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 @@ -602,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; @@ -630,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)); } } } 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_suggestions_layout'), 'suggestions_layout', array('class' => 'control-label col-xs-2')); ?> +
+
+ +
+ $this->lang->line('items_name'), + 'item_number' => $this->lang->line('items_number_information'), + 'unit_price' => $this->lang->line('items_unit_price') + ), + $this->config->item('suggestions_first_column'), array('class' => 'form-control input-sm')); ?> +
+ +
+ $this->lang->line('config_none'), + 'name' => $this->lang->line('items_name'), + 'item_number' => $this->lang->line('items_number_information'), + 'unit_price' => $this->lang->line('items_unit_price') + ), + $this->config->item('suggestions_second_column'), array('class' => 'form-control input-sm')); ?> +
+ +
+ $this->lang->line('config_none'), + 'name' => $this->lang->line('items_name'), + 'item_number' => $this->lang->line('items_number_information'), + 'unit_price' => $this->lang->line('items_unit_price') + ), + $this->config->item('suggestions_third_column'), array('class' => 'form-control input-sm')); ?> +
+
+
+
+
lang->line('config_giftcard_number'), 'giftcard_number', array('class' => 'control-label col-xs-2')); ?>
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', ''); diff --git a/database/database.sql b/database/database.sql index e1b042b6f..747ad05f1 100644 --- a/database/database.sql +++ b/database/database.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', ''); diff --git a/database/migrate_phppos_dist.sql b/database/migrate_phppos_dist.sql index f12db0ca2..8ea7b4c53 100644 --- a/database/migrate_phppos_dist.sql +++ b/database/migrate_phppos_dist.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', ''); 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', '');