diff --git a/app/Controllers/Item_kits.php b/app/Controllers/Item_kits.php index d84b54c3a..64ff433e2 100644 --- a/app/Controllers/Item_kits.php +++ b/app/Controllers/Item_kits.php @@ -153,14 +153,14 @@ class Item_kits extends Secure_Controller public function postSave(int $item_kit_id = NEW_ENTRY): void { $item_kit_data = [ - 'name' => $this->request->getPost('name', FILTER_SANITIZE_FULL_SPECIAL_CHARS), - 'item_kit_number' => $this->request->getPost('item_kit_number', FILTER_SANITIZE_FULL_SPECIAL_CHARS), - 'item_id' => $this->request->getPost('kit_item_id', FILTER_SANITIZE_NUMBER_INT), - 'kit_discount' => $this->request->getPost('kit_discount', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), - 'kit_discount_type' => $this->request->getPost('kit_discount_type') == NULL ? PERCENT : $this->request->getPost('kit_discount_type', FILTER_SANITIZE_NUMBER_INT), - 'price_option' => $this->request->getPost('price_option', FILTER_SANITIZE_NUMBER_INT), - 'print_option' => $this->request->getPost('print_option', FILTER_SANITIZE_NUMBER_INT), - 'description' => $this->request->getPost('description', FILTER_SANITIZE_FULL_SPECIAL_CHARS) + 'name' => $this->request->getPost('name'), + 'item_kit_number' => $this->request->getPost('item_kit_number'), + 'item_id' => empty($this->request->getPost('kit_item_id')) ? NULL : intval($this->request->getPost('kit_item_id')), + 'kit_discount' => parse_decimals($this->request->getPost('kit_discount')), + 'kit_discount_type' => $this->request->getPost('kit_discount_type') === NULL ? PERCENT : intval($this->request->getPost('kit_discount_type')), + 'price_option' => $this->request->getPost('price_option') === NULL ? PRICE_ALL : intval($this->request->getPost('price_option')), + 'print_option' => $this->request->getPost('print_option') === NULL ? PRINT_ALL : intval($this->request->getPost('print_option')), + 'description' => $this->request->getPost('description') ]; if($this->item_kit->save_value($item_kit_data, $item_kit_id)) @@ -173,22 +173,29 @@ class Item_kits extends Secure_Controller $new_item = TRUE; } - if($this->request->getPost('item_kit_qty', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) != NULL) + $item_kit_items_array = $this->request->getPost('item_kit_qty') === NULL ? NULL : $this->request->getPost('item_kit_qty'); + + if($item_kit_items_array != NULL) { $item_kit_items = []; - foreach($this->request->getPost('item_kit_qty', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) as $item_id => $quantity) + foreach($item_kit_items_array as $item_id => $item_kit_qty) { - $seq = $this->request->getPost("item_kit_seq[$item_id]", FILTER_SANITIZE_NUMBER_INT); $item_kit_items[] = [ 'item_id' => $item_id, - 'quantity' => $quantity, - 'kit_sequence' => $seq + 'quantity' => $item_kit_qty === NULL ? 0 : parse_quantity($item_kit_qty), + 'kit_sequence' => $this->request->getPost("item_kit_seq[$item_id]") === NULL ? 0 : intval($this->request->getPost("item_kit_seq[$item_id]")) ]; } - } - $success = $this->item_kit_items->save_value($item_kit_items, $item_kit_id); + if (!empty($item_kit_items)) + { + $success = $this->item_kit_items->save_value($item_kit_items, $item_kit_id); + } + else + { + $success = TRUE; + } if($new_item) { @@ -235,7 +242,7 @@ class Item_kits extends Secure_Controller } } - public function check_item_number(): void + public function postCheckItemNumber(): void { $exists = $this->item_kit->item_number_exists($this->request->getPost('item_kit_number', FILTER_SANITIZE_FULL_SPECIAL_CHARS), $this->request->getPost('item_kit_id', FILTER_SANITIZE_NUMBER_INT)); echo !$exists ? 'true' : 'false'; diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php index 72bd5a981..a5f17d615 100644 --- a/app/Controllers/Items.php +++ b/app/Controllers/Items.php @@ -187,9 +187,9 @@ class Items extends Secure_Controller echo json_encode($suggestions); } - public function suggest(): void + public function getSuggest(): void { - $suggestions = $this->item->get_search_suggestions($this->request->getPostGet('term'), ['search_custom' => FALSE, 'is_deleted' => FALSE], TRUE); + $suggestions = $this->item->get_search_suggestions($this->request->getGet('term'), ['search_custom' => FALSE, 'is_deleted' => FALSE], TRUE); echo json_encode($suggestions); } @@ -201,9 +201,9 @@ class Items extends Secure_Controller echo json_encode($suggestions); } - public function suggest_kits(): void + public function getSuggestKits(): void { - $suggestions = $this->item->get_kit_search_suggestions($this->request->getPostGet('term'), ['search_custom' => FALSE, 'is_deleted' => FALSE], TRUE); + $suggestions = $this->item->get_kit_search_suggestions($this->request->getGet('term'), ['search_custom' => FALSE, 'is_deleted' => FALSE], TRUE); echo json_encode($suggestions); } diff --git a/app/Controllers/Reports.php b/app/Controllers/Reports.php index c0259b303..564299ddc 100644 --- a/app/Controllers/Reports.php +++ b/app/Controllers/Reports.php @@ -80,6 +80,11 @@ class Reports extends Secure_Controller helper('report'); } + public function index(): void + { + $this->getIndex(); + } + //Initial Report listing screen public function getIndex(): void { @@ -1662,7 +1667,7 @@ class Reports extends Secure_Controller return $sale_type_options; } - public function detailed_sales(string $start_date, string $end_date, string $sale_type, string $location_id = 'all'): void + public function getDetailed_sales(string $start_date, string $end_date, string $sale_type, string $location_id = 'all'): void { $this->clearCache(); diff --git a/app/Helpers/locale_helper.php b/app/Helpers/locale_helper.php index 133de9ae0..42c1a9630 100644 --- a/app/Helpers/locale_helper.php +++ b/app/Helpers/locale_helper.php @@ -384,7 +384,7 @@ function to_decimals(?float $number, string $decimals = NULL, int $type = Number if(empty($config['thousands_separator'])) { - $fmt->setAttribute(NumberFormatter::GROUPING_SEPARATOR_SYMBOL, ''); + $fmt->setTextAttribute(NumberFormatter::GROUPING_SEPARATOR_SYMBOL, ''); } $fmt->setSymbol(NumberFormatter::CURRENCY_SYMBOL, $config['currency_symbol']); diff --git a/app/Helpers/report_helper.php b/app/Helpers/report_helper.php index 10f12adab..36dce1202 100644 --- a/app/Helpers/report_helper.php +++ b/app/Helpers/report_helper.php @@ -14,7 +14,7 @@ use App\Models\Employee; */ function show_report_if_allowed(string $report_prefix, string $report_name, int $person_id, string $permission_id = ''): void { - $permission_id = empty($permission_id) ? 'reports_' . $report_name : $permission_id; //TODO: Use String Interpolation here. + $permission_id = empty($permission_id) ? $report_name : $permission_id; //TODO: Use String Interpolation here. $employee = model(Employee::class); if($employee->has_grant($permission_id, $person_id)) @@ -25,9 +25,14 @@ function show_report_if_allowed(string $report_prefix, string $report_name, int function show_report(string $report_prefix, string $report_name, string $lang_key = ''): void { - $lang_key = empty($lang_key) ? $report_name : $lang_key; - $report_label = lang($lang_key); - $report_prefix = empty($report_prefix) ? '' : $report_prefix . '.'; + if(empty($lang_key)) + { + $lang_key = str_replace('reports_','', $report_name); + $report_label = lang('Reports.' . $lang_key); + } + $report_label = lang('Reports.' . $lang_key); + + $report_prefix = empty($report_prefix) ? '' : $report_prefix . '_'; // no summary nor detailed reports for receivings if(!empty($report_label) && $report_label != $lang_key . ' (TBD)') //TODO: String Interpolation. Also !== diff --git a/app/Libraries/Token_lib.php b/app/Libraries/Token_lib.php index 689eb6c22..f44f20abb 100644 --- a/app/Libraries/Token_lib.php +++ b/app/Libraries/Token_lib.php @@ -2,7 +2,7 @@ namespace app\Libraries; -use App\Models\tokens\Token; +use App\Models\Tokens\Token; /** * Token library diff --git a/app/Views/item_kits/form.php b/app/Views/item_kits/form.php index bf117cc32..1d2c9f5f3 100644 --- a/app/Views/item_kits/form.php +++ b/app/Views/item_kits/form.php @@ -49,7 +49,7 @@ 'id' => 'item_name', 'class' => 'form-control input-sm', 'size' => '50', - 'value' => esc($selected_kit_item) + 'value' => $selected_kit_item ]) ?> @@ -253,7 +253,7 @@ $(document).ready(function() $('#item_name').autocomplete({ - source: "", + source: "", minChars: 0, delay: 15, cacheLength: 1, diff --git a/app/Views/reports/date_input.php b/app/Views/reports/date_input.php index 77682f547..ff6d13836 100644 --- a/app/Views/reports/date_input.php +++ b/app/Views/reports/date_input.php @@ -111,7 +111,7 @@ $(document).ready(function() $("#generate_report").click(function() - { + { window.location = [window.location, start_date, end_date, $("#input_type").val() || 0, $("#location_id").val() || 'all', $("#discount_type_id").val() || 0 ].join("/"); }); });