diff --git a/app/Controllers/Customers.php b/app/Controllers/Customers.php index 004f8026a..08e830e11 100644 --- a/app/Controllers/Customers.php +++ b/app/Controllers/Customers.php @@ -35,7 +35,7 @@ class Customers extends Persons { parent::__construct('customers'); $this->mailchimp_lib = new Mailchimp_lib(); - + $this->customer_rewards = model('Customer_rewards'); $this->customer = model('Customer'); $this->tax_code = model('Tax_code'); $this->config = config('OSPOS')->settings; @@ -91,7 +91,7 @@ class Customers extends Persons /* Returns customer table data rows. This will be called with AJAX. */ - public function getSearch(): void + public function getSearch() { $search = $this->request->getGet('search', FILTER_SANITIZE_STRING); $limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT); @@ -187,7 +187,7 @@ class Customers extends Persons $data['packages'] = $packages; $data['selected_package'] = $info->package_id; - if($$this->config['use_destination_based_tax']) //TODO: This can be shortened for ternary notation + if($this->config['use_destination_based_tax']) //TODO: This can be shortened for ternary notation { $data['use_destination_based_tax'] = TRUE; } diff --git a/app/Models/Cashup.php b/app/Models/Cashup.php index 1348a9358..54cdb8e4d 100644 --- a/app/Models/Cashup.php +++ b/app/Models/Cashup.php @@ -71,7 +71,7 @@ class Cashup extends Model /** * Gets rows */ - public function get_found_rows(string $search, array $filters): ResultInterface + public function get_found_rows(string $search, array $filters): int { return $this->search($search, $filters, 0, 0, 'cashup_id', 'asc', TRUE); } diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 75a745730..d38e81ab9 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -110,7 +110,7 @@ class Customer extends Person //append those fields to base parent object, we have a complete empty object foreach($this->db->getFieldNames('customers') as $field) { - $person_obj->$field = ''; + $person_obj->$field = null; } return $person_obj; @@ -398,9 +398,11 @@ class Customer extends Person /** * Gets rows */ - public function get_found_rows(string $search): ResultInterface + public function get_found_rows(string $search): int { - return $this->search($search, 0, 0, 'last_name', 'asc', TRUE); + $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/Employee.php b/app/Models/Employee.php index 3ec17c729..ba4f0bb21 100644 --- a/app/Models/Employee.php +++ b/app/Models/Employee.php @@ -327,7 +327,7 @@ class Employee extends Person /** * Gets rows */ - public function get_found_rows(string $search): ResultInterface + public function get_found_rows(string $search): int { return $this->search($search, 0, 0, 'last_name', 'asc', TRUE); } diff --git a/app/Models/Expense.php b/app/Models/Expense.php index a2319db67..d1474d21a 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -79,7 +79,7 @@ class Expense extends Model /** * Gets rows */ - public function get_found_rows(string $search, array $filters): ResultInterface + public function get_found_rows(string $search, array $filters): int { return $this->search($search, $filters, 0, 0, 'expense_id', 'asc', TRUE); } diff --git a/app/Models/Expense_category.php b/app/Models/Expense_category.php index 951e8301a..d753850d3 100644 --- a/app/Models/Expense_category.php +++ b/app/Models/Expense_category.php @@ -144,7 +144,7 @@ class Expense_category extends Model /** * Gets rows */ - public function get_found_rows(string $search): ResultInterface + public function get_found_rows(string $search): int { return $this->search($search, 0, 0, 'category_name', 'asc', TRUE); } diff --git a/app/Models/Giftcard.php b/app/Models/Giftcard.php index e0d40c71b..f4e8bbfdf 100644 --- a/app/Models/Giftcard.php +++ b/app/Models/Giftcard.php @@ -225,7 +225,7 @@ class Giftcard extends Model /** * Gets gift cards */ - public function get_found_rows(string $search): ResultInterface + public function get_found_rows(string $search): int { return $this->search($search, 0, 0, 'giftcard_number', 'asc', TRUE); } diff --git a/app/Models/Item.php b/app/Models/Item.php index 900e485e6..bee8b3aed 100644 --- a/app/Models/Item.php +++ b/app/Models/Item.php @@ -112,7 +112,7 @@ class Item extends Model /** * Get number of rows */ - public function get_found_rows(string $search, array $filters): ResultInterface + public function get_found_rows(string $search, array $filters): int { return $this->search($search, $filters, 0, 0, 'items.name', 'asc', TRUE); } diff --git a/app/Models/Item_kit.php b/app/Models/Item_kit.php index 8ed7d2ac3..b02e5bb60 100644 --- a/app/Models/Item_kit.php +++ b/app/Models/Item_kit.php @@ -249,7 +249,7 @@ class Item_kit extends Model /** * Gets rows */ - public function get_found_rows(string $search): ResultInterface + public function get_found_rows(string $search): int { return $this->search($search, 0, 0, 'name', 'asc', TRUE); } diff --git a/app/Models/Sale.php b/app/Models/Sale.php index c696e5c78..9b823ac2b 100644 --- a/app/Models/Sale.php +++ b/app/Models/Sale.php @@ -118,7 +118,7 @@ class Sale extends Model /** * Get number of rows for the takings (sales/manage) view */ - public function get_found_rows(string $search, array $filters): ResultInterface + public function get_found_rows(string $search, array $filters): int { return $this->search($search, $filters, 0, 0, 'sales.sale_time', 'desc', TRUE); } diff --git a/app/Models/Supplier.php b/app/Models/Supplier.php index ddc67a873..af1d1907d 100644 --- a/app/Models/Supplier.php +++ b/app/Models/Supplier.php @@ -255,7 +255,7 @@ class Supplier extends Person /** * Gets rows */ - public function get_found_rows(string $search): ResultInterface + public function get_found_rows(string $search): int { return $this->search($search, 0, 0, 'last_name', 'asc', TRUE); } diff --git a/app/Models/Tax.php b/app/Models/Tax.php index 61cbd9de4..4402dc851 100644 --- a/app/Models/Tax.php +++ b/app/Models/Tax.php @@ -212,7 +212,7 @@ class Tax extends Model /** * Gets tax_codes */ - public function get_found_rows(string $search): ResultInterface + public function get_found_rows(string $search): int { return $this->search($search, 0, 0, 'tax_code_name', 'asc', TRUE); } diff --git a/app/Models/Tax_category.php b/app/Models/Tax_category.php index 59c540372..16373f84c 100644 --- a/app/Models/Tax_category.php +++ b/app/Models/Tax_category.php @@ -200,7 +200,7 @@ class Tax_category extends Model /** * Gets rows */ - public function get_found_rows(string $search): ResultInterface + public function get_found_rows(string $search): int { return $this->search($search, 0, 0, 'tax_category', 'asc', TRUE); } diff --git a/app/Models/Tax_code.php b/app/Models/Tax_code.php index a085cd949..fffed6eb9 100644 --- a/app/Models/Tax_code.php +++ b/app/Models/Tax_code.php @@ -48,15 +48,18 @@ class Tax_code extends Model /** * Gets information about the particular record */ - public function get_info(int $tax_code_id): object + public function get_info(?int $tax_code_id): object { - $builder = $this->db->table('tax_codes'); + if($tax_code_id != null) + { + $builder = $this->db->table('tax_codes'); - $builder->where('tax_code_id', $tax_code_id); - $builder->where('deleted', 0); - $query = $builder->get(); + $builder->where('tax_code_id', $tax_code_id); + $builder->where('deleted', 0); + $query = $builder->get(); + } - if($query->getNumRows() == 1) //TODO: === + if($tax_code_id != null && $query->getNumRows() === 1) { return $query->getRow(); } @@ -68,7 +71,7 @@ class Tax_code extends Model //Get all the fields from the table foreach($this->db->getFieldNames('tax_codes') as $field) { - $tax_code_obj->$field = ''; + $tax_code_obj->$field = null; } return $tax_code_obj; } @@ -191,7 +194,7 @@ class Tax_code extends Model /** * Gets rows */ - public function get_found_rows(string $search): ResultInterface + public function get_found_rows(string $search): int { return $this->search($search, 0, 0, 'tax_code_name', 'asc', TRUE); } diff --git a/app/Models/Tax_jurisdiction.php b/app/Models/Tax_jurisdiction.php index bba962c69..e33c43ffe 100644 --- a/app/Models/Tax_jurisdiction.php +++ b/app/Models/Tax_jurisdiction.php @@ -205,7 +205,7 @@ class Tax_jurisdiction extends Model /** * Gets rows */ - public function get_found_rows(string $search): ResultInterface + public function get_found_rows(string $search): int { return $this->search($search, 0, 0, 'jurisdiction_name', 'asc', TRUE); } diff --git a/app/Views/people/manage.php b/app/Views/people/manage.php index 0d2a999b8..a9d70014d 100644 --- a/app/Views/people/manage.php +++ b/app/Views/people/manage.php @@ -46,7 +46,7 @@ $(document).ready(function() -