diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php index f43858945..08205ebb2 100644 --- a/app/Controllers/Items.php +++ b/app/Controllers/Items.php @@ -492,7 +492,7 @@ class Items extends Secure_Controller echo view('barcodes/barcode_sheet', $data); } - public function attributes(int $item_id = NEW_ITEM): void + public function getAttributes(int $item_id = NEW_ITEM): void { $data['item_id'] = $item_id; $definition_ids = json_decode($this->request->getPost('definition_ids', FILTER_SANITIZE_STRING), TRUE); diff --git a/app/Helpers/locale_helper.php b/app/Helpers/locale_helper.php index 7ee794811..78504f132 100644 --- a/app/Helpers/locale_helper.php +++ b/app/Helpers/locale_helper.php @@ -322,17 +322,17 @@ function to_datetime(int $datetime = DEFAULT_DATETIME): string return date($config['dateformat'] . ' ' . $config['timeformat'], $datetime); } -function to_currency(float $number): string +function to_currency(?float $number): string { return to_decimals($number, 'currency_decimals', NumberFormatter::CURRENCY); } -function to_currency_no_money(float $number): string +function to_currency_no_money(?float $number): string { return to_decimals($number, 'currency_decimals'); } -function to_currency_tax(float $number): string +function to_currency_tax(?float $number): string { $config = config('OSPOS')->settings; @@ -346,8 +346,13 @@ function to_currency_tax(float $number): string } } -function to_tax_decimals(float $number): string +function to_tax_decimals($number): string { + // TODO: When the tax array is empty the value passed in is an empty string, For now I "untyped" it to get past + // the issue because I don't understand why an empty string is being passed in when I know the array is empty. + // It looks like it must be creating a String value on the fly because the form is referring to the index 0 when + // there IS no index[0] row in the table + // taxes that are NULL, '' or 0 don't need to be displayed // NOTE: do not remove this line otherwise the items edit form will show a tax with 0, and it will save it if(empty($number)) @@ -358,18 +363,18 @@ function to_tax_decimals(float $number): string return to_decimals($number, 'tax_decimals'); } -function to_quantity_decimals(float $number): string +function to_quantity_decimals(?float $number): string { return to_decimals($number, 'quantity_decimals'); } -function to_decimals(float $number, string $decimals = NULL, int $type = NumberFormatter::DECIMAL): string +function to_decimals(?float $number, string $decimals = NULL, int $type = NumberFormatter::DECIMAL): string { // ignore empty strings and return // NOTE: do not change it to empty otherwise tables will show a 0 with no decimal nor currency symbol if(!isset($number)) { - return $number; + return ""; } $config = config('OSPOS')->settings; diff --git a/app/Libraries/Item_lib.php b/app/Libraries/Item_lib.php index 44e777138..26f303008 100644 --- a/app/Libraries/Item_lib.php +++ b/app/Libraries/Item_lib.php @@ -33,7 +33,7 @@ class Item_lib return $this->session->get('item_location'); } - public function set_item_location(string $location): void + public function set_item_location(?string $location): void { $this->session->set('item_location',$location); } @@ -42,4 +42,4 @@ class Item_lib { $this->session->remove('item_location'); } -} \ No newline at end of file +} diff --git a/app/Models/Attribute.php b/app/Models/Attribute.php index 8d420e275..6facc3f0c 100644 --- a/app/Models/Attribute.php +++ b/app/Models/Attribute.php @@ -193,7 +193,7 @@ class Attribute extends Model return $this->to_array($results, 'definition_id'); } - public function get_values_by_definitions(array $definition_ids): array + public function get_values_by_definitions(?array $definition_ids): array { if(count($definition_ids ? : [])) { diff --git a/app/Models/Customer.php b/app/Models/Customer.php index d38e81ab9..3d8f8c69d 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -401,7 +401,6 @@ class Customer extends Person public function get_found_rows(string $search): int { $result = $this->search($search, 0, 0, 'last_name', 'asc', TRUE); - log_message('info', '>>>Customer.get_found_rows-' . $result); return $result; } diff --git a/app/Models/Item.php b/app/Models/Item.php index bee8b3aed..55d307d3d 100644 --- a/app/Models/Item.php +++ b/app/Models/Item.php @@ -120,7 +120,7 @@ class Item extends Model /** * Perform a search on items */ - public function search(string $search, array $filters, ?int $rows = 0, ?int $limit_from = 0, ?string $sort = 'items.name', ?string $order = 'asc', ?bool $count_only = FALSE): ResultInterface + public function search(string $search, array $filters, ?int $rows = 0, ?int $limit_from = 0, ?string $sort = 'items.name', ?string $order = 'asc', ?bool $count_only = FALSE) { // Set default values if($rows == null) $rows = 0; @@ -331,7 +331,7 @@ class Item extends Model //Get all the fields from items table foreach($this->db->getFieldNames('items') as $field) { - $item_obj->$field = ''; + $item_obj->$field = null; } return $item_obj;