mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-25 00:44:03 -04:00
Add SHOW_IN_SEARCH flag to separate attribute search from visibility
Phase 2 implementation: - Add SHOW_IN_SEARCH constant (value 8) to Attribute model - Update Items controller to include searchable attributes when search_custom filter is enabled - Add language strings for the new visibility flag - Update Attributes controller to include new flag in form This allows attributes to be searchable even if they are not displayed in the items table, addressing issue #2919. Fixes #2919
This commit is contained in:
@@ -246,7 +246,7 @@ class Attributes extends Secure_Controller
|
||||
$data['definition_group'][''] = lang('Common.none_selected_text');
|
||||
$data['definition_info'] = $info;
|
||||
|
||||
$show_all = Attribute::SHOW_IN_ITEMS | Attribute::SHOW_IN_RECEIVINGS | Attribute::SHOW_IN_SALES;
|
||||
$show_all = Attribute::SHOW_IN_ITEMS | Attribute::SHOW_IN_RECEIVINGS | Attribute::SHOW_IN_SALES | Attribute::SHOW_IN_SEARCH;
|
||||
$data['definition_flags'] = $this->get_attributes($show_all);
|
||||
$selected_flags = $info->definition_flags === '' ? $show_all : $info->definition_flags;
|
||||
$data['selected_definition_flags'] = $this->get_attributes($selected_flags);
|
||||
|
||||
@@ -129,6 +129,13 @@ class Items extends Secure_Controller
|
||||
// Check if any filter is set in the multiselect dropdown
|
||||
$request_filters = array_fill_keys($this->request->getGet('filters', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? [], true);
|
||||
$filters = array_merge($filters, $request_filters);
|
||||
|
||||
// When search_custom is enabled, include attributes that are searchable but may not be visible in table
|
||||
if (!empty($filters['search_custom'])) {
|
||||
$searchable_definitions = $this->attribute->get_definitions_by_flags(Attribute::SHOW_IN_ITEMS | Attribute::SHOW_IN_SEARCH);
|
||||
$filters['definition_ids'] = array_keys($searchable_definitions);
|
||||
}
|
||||
|
||||
$items = $this->item->search($search, $filters, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->item->get_found_rows($search, $filters);
|
||||
$data_rows = [];
|
||||
|
||||
@@ -30,5 +30,7 @@ return [
|
||||
"show_in_receivings_visibility" => "Receivings",
|
||||
"show_in_sales" => "Show in sales",
|
||||
"show_in_sales_visibility" => "Sales",
|
||||
"show_in_search" => "Show in search",
|
||||
"show_in_search_visibility" => "Search",
|
||||
"update" => "Update Attribute",
|
||||
];
|
||||
|
||||
@@ -30,5 +30,7 @@ return [
|
||||
"show_in_receivings_visibility" => "Receivings",
|
||||
"show_in_sales" => "Show in sales",
|
||||
"show_in_sales_visibility" => "Sales",
|
||||
"show_in_search" => "Show in search",
|
||||
"show_in_search_visibility" => "Search",
|
||||
"update" => "Update Attribute",
|
||||
];
|
||||
|
||||
@@ -38,9 +38,10 @@ class Attribute extends Model
|
||||
'attribute_decimal'
|
||||
];
|
||||
|
||||
public const SHOW_IN_ITEMS = 1; // TODO: These need to be moved to constants.php
|
||||
public const SHOW_IN_ITEMS = 1;
|
||||
public const SHOW_IN_SALES = 2;
|
||||
public const SHOW_IN_RECEIVINGS = 4;
|
||||
public const SHOW_IN_SEARCH = 8;
|
||||
public function deleteDropdownAttributeValue(string $attribute_value, int $definition_id): bool
|
||||
{
|
||||
$attribute_id = $this->getAttributeIdByValue($attribute_value);
|
||||
|
||||
Reference in New Issue
Block a user