Primary changes return type from ResultSet to int for those requests that only return a record count. Also corrected a few other minor issues.

This commit is contained in:
Steve Ireland
2023-03-15 21:25:52 -04:00
parent 80b893a332
commit c5180ab614
16 changed files with 32 additions and 27 deletions

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}
/**

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -46,7 +46,7 @@ $(document).ready(function()
<?php
}
?>
<button class='btn btn-info btn-sm pull-right modal-dlg' data-btn-submit='<?php echo lang('Common.submit') ?>' data-href='<?php echo esc(site_url("$controller_name/view"), 'url') ?>'
<button class='btn btn-info btn-sm pull-right modal-dlg' data-btn-submit='<?php echo lang('Common.submit') ?>' data-href='<?php echo site_url("$controller_name/view") ?>'
title='<?php echo lang("$controller_name.new") ?>'>
<span class="glyphicon glyphicon-user">&nbsp</span><?php echo lang("$controller_name.new") ?>
</button>