diff --git a/app/Controllers/Config.php b/app/Controllers/Config.php index 8fce2af61..2039b25fd 100644 --- a/app/Controllers/Config.php +++ b/app/Controllers/Config.php @@ -329,7 +329,7 @@ class Config extends Secure_Controller 'company' => $this->request->getPost('company'), 'address' => $this->request->getPost('address'), 'phone' => $this->request->getPost('phone'), - 'email' => $this->request->getPost('email', FILTER_SANITIZE_EMAIL), + 'email' => strtolower($this->request->getPost('email', FILTER_SANITIZE_EMAIL)), 'fax' => $this->request->getPost('fax'), 'website' => $this->request->getPost('website', FILTER_SANITIZE_URL), 'return_policy' => $this->request->getPost('return_policy') diff --git a/app/Controllers/Customers.php b/app/Controllers/Customers.php index 2fbe2ce2c..ef8deef35 100644 --- a/app/Controllers/Customers.php +++ b/app/Controllers/Customers.php @@ -353,7 +353,10 @@ class Customers extends Persons */ public function postCheckEmail(): void { - $exists = $this->customer->check_email_exists(strtolower($this->request->getPost('email')), $this->request->getPost('person_id', FILTER_SANITIZE_NUMBER_INT)); + $email = strtolower($this->request->getPost('email', FILTER_SANITIZE_EMAIL)); + $person_id = $this->request->getPost('person_id', FILTER_SANITIZE_NUMBER_INT); + + $exists = $this->customer->check_email_exists($email, $person_id); echo !$exists ? 'true' : 'false'; } diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php index 59cdbff11..8a05b4797 100644 --- a/app/Controllers/Items.php +++ b/app/Controllers/Items.php @@ -645,6 +645,9 @@ class Items extends Secure_Controller $default_pack_name = lang('Items.default_pack_name'); $cost_price = prepare_decimal($this->request->getPost('cost_price')); + $unit_price = prepare_decimal($this->request->getPost('unit_price')); + $reorder_level = prepare_decimal($this->request->getPost('reorder_level')); + $qty_per_pack = prepare_decimal($this->request->getPost('qty_per_pack')); //Save item data $item_data = [ @@ -656,12 +659,12 @@ class Items extends Secure_Controller 'supplier_id' => empty($this->request->getPost('supplier_id')) ? null : intval($this->request->getPost('supplier_id')), 'item_number' => empty($this->request->getPost('item_number')) ? null : $this->request->getPost('item_number'), 'cost_price' => parse_decimals(filter_var($cost_price, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)), - 'unit_price' => parse_decimals($this->request->getPost('unit_price')), - 'reorder_level' => parse_quantity($this->request->getPost('reorder_level')), + 'unit_price' => parse_decimals(filter_var($unit_price, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)), + 'reorder_level' => parse_quantity(filter_var($reorder_level, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)), 'receiving_quantity' => $receiving_quantity, 'allow_alt_description' => $this->request->getPost('allow_alt_description') != null, 'is_serialized' => $this->request->getPost('is_serialized') != null, - 'qty_per_pack' => $this->request->getPost('qty_per_pack') == null ? 1 : parse_quantity($this->request->getPost('qty_per_pack')), + 'qty_per_pack' => $this->request->getPost('qty_per_pack') == null ? 1 : parse_quantity(filter_var($qty_per_pack, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)), 'pack_name' => $this->request->getPost('pack_name') == null ? $default_pack_name : $this->request->getPost('pack_name'), 'low_sell_item_id' => $this->request->getPost('low_sell_item_id') === null ? $item_id : intval($this->request->getPost('low_sell_item_id')), 'deleted' => $this->request->getPost('is_deleted') != null, @@ -731,7 +734,8 @@ class Items extends Secure_Controller $stock_locations = $this->stock_location->get_undeleted_all()->getResultArray(); foreach($stock_locations as $location) { - $updated_quantity = parse_quantity($this->request->getPost('quantity_' . $location['location_id'])); + $stock_quantity = prepare_decimal($this->request->getPost('quantity_' . $location['location_id'])); + $updated_quantity = parse_quantity(filter_var($stock_quantity, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)); if($item_data['item_type'] == ITEM_TEMP) { @@ -898,13 +902,14 @@ class Items extends Secure_Controller $employee_id = $this->employee->get_logged_in_employee_info()->person_id; $cur_item_info = $this->item->get_info($item_id); $location_id = $this->request->getPost('stock_location'); + $new_quantity = prepare_decimal($this->request->getPost('newquantity')); $inv_data = [ 'trans_date' => date('Y-m-d H:i:s'), 'trans_items' => $item_id, 'trans_user' => $employee_id, 'trans_location' => $location_id, 'trans_comment' => $this->request->getPost('trans_comment'), - 'trans_inventory' => parse_quantity($this->request->getPost('newquantity')) + 'trans_inventory' => parse_quantity(filter_var($new_quantity, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)) ]; $this->inventory->insert($inv_data, false); diff --git a/app/Models/Item.php b/app/Models/Item.php index c2a4b6493..0e29e2b12 100644 --- a/app/Models/Item.php +++ b/app/Models/Item.php @@ -595,17 +595,20 @@ class Item extends Model } /** - * @param $result_row + * @param object $result_row * @return string */ - public function get_search_suggestion_label($result_row): string + public function get_search_suggestion_label(object $result_row): string { $config = config(OSPOS::class)->settings; + $label = ''; $label1 = $config['suggestions_first_column']; $label2 = $config['suggestions_second_column']; $label3 = $config['suggestions_third_column']; + $this->format_result_numbers($result_row); + // If multi_pack enabled then if "name" is part of the search suggestions then append pack if($config['multi_pack_enabled']) { @@ -631,6 +634,24 @@ class Item extends Model return $label; } + /** + * Converts decimal money values to their correct locale format. + * + * @param object $result_row + * @return void + */ + private function format_result_numbers(object &$result_row): void + { + if(isset($result_row->cost_price)) + { + $result_row->cost_price = to_currency_no_money($result_row->cost_price); + } + if(isset($result_row->unit_price)) + { + $result_row->unit_price = to_currency_no_money($result_row->unit_price); + } + } + /** * @param string $label * @param string $item_field_name diff --git a/app/Views/receivings/receiving.php b/app/Views/receivings/receiving.php index 2b87bbff8..d1be22cb7 100644 --- a/app/Views/receivings/receiving.php +++ b/app/Views/receivings/receiving.php @@ -154,9 +154,9 @@ if (isset($success)) ') ?> - +
- +