CI4 bugfixes

- Added session variable instantiation where needed.
- Added tabular helper to autoload
- removed tabular helper reference where no longer needed.
- Remove esc() references where it was causing display problems.
- Remove excess whitespace on blank line
- Remove unecessary using reference
- Make parameters for dinner table functions nullable
This commit is contained in:
objecttothis
2023-03-01 01:41:43 +04:00
committed by jekkos
parent 145930ce5b
commit 8d80f5a261
14 changed files with 45 additions and 50 deletions

View File

@@ -204,6 +204,7 @@ class Autoload extends AutoloadConfig
*/
public $helpers = [
'form',
'cookie'
'cookie',
'tabular'
];
}

View File

@@ -8,9 +8,9 @@ require_once('Secure_Controller.php');
/**
* Attributes controls the custom attributes assigned to items
*
*
* @property attribute attribute
*
*
*/
class Attributes extends Secure_Controller
{
@@ -23,7 +23,6 @@ class Attributes extends Secure_Controller
public function getIndex(): void
{
helper('tabular');
$data['table_headers'] = get_attribute_definition_manage_table_headers();
echo view('attributes/manage', $data);

View File

@@ -34,7 +34,6 @@ class Customers extends Persons
public function __construct()
{
parent::__construct('customers');
helper('tabular');
$this->mailchimp_lib = new Mailchimp_lib();
$this->customer = model('Customer');

View File

@@ -21,7 +21,6 @@ class Expenses extends Secure_Controller
public function getIndex(): void
{
helper('tabular');
$data['table_headers'] = get_expenses_manage_table_headers();
// filters that will be loaded in the multiselect dropdown

View File

@@ -18,7 +18,6 @@ class Expenses_categories extends Secure_Controller //TODO: Is this class ever u
public function getIndex(): void
{
helper('tabular');
$data['table_headers'] = get_expense_category_manage_table_headers();
echo view('expenses_categories/manage', $data);

View File

@@ -18,7 +18,6 @@ class Giftcards extends Secure_Controller
public function getIndex(): void
{
helper('tabular');
$data['table_headers'] = get_giftcards_manage_table_headers();
echo view('giftcards/manage', $data);

View File

@@ -28,7 +28,7 @@ class Item_kits extends Secure_Controller
$this->item_kit = model('Item_kit');
$this->item_kit_items = model('Item_kit_items');
}
/**
* Add the total cost and retail price to a passed item_kit retrieving the data from each singular item part of the kit
*/
@@ -63,10 +63,9 @@ class Item_kits extends Secure_Controller
return $item_kit;
}
public function getIndex(): void
{
helper('tabular');
$data['table_headers'] = get_item_kits_manage_table_headers();
echo view('item_kits/manage', $data);
@@ -111,7 +110,7 @@ class Item_kits extends Secure_Controller
echo json_encode(get_item_kit_data_row($item_kit));
}
public function view(int $item_kit_id = -1): void //TODO: Replace -1 with a constant
{
$info = $this->item_kit->get_info($item_kit_id);
@@ -150,7 +149,7 @@ class Item_kits extends Secure_Controller
echo view("item_kits/form", $data);
}
public function save(int $item_kit_id = -1): void //TODO: Replace -1 with a constant
{
$item_kit_data = [
@@ -163,7 +162,7 @@ class Item_kits extends Secure_Controller
'print_option' => $this->request->getPost('print_option', FILTER_SANITIZE_NUMBER_INT),
'description' => $this->request->getPost('description', FILTER_SANITIZE_STRING)
];
if($this->item_kit->save_value($item_kit_data, $item_kit_id))
{
$new_item = FALSE;
@@ -218,7 +217,7 @@ class Item_kits extends Secure_Controller
]);
}
}
public function delete(): void
{
$item_kits_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_STRING);
@@ -241,7 +240,7 @@ class Item_kits extends Secure_Controller
$exists = $this->item_kit->item_number_exists($this->request->getPost('item_kit_number', FILTER_SANITIZE_STRING), $this->request->getPost('item_kit_id', FILTER_SANITIZE_NUMBER_INT));
echo !$exists ? 'true' : 'false';
}
public function generate_barcodes(string $item_kit_ids): void
{
$this->barcode_lib = new Barcode_lib();
@@ -249,10 +248,10 @@ class Item_kits extends Secure_Controller
$item_kit_ids = explode(':', $item_kit_ids);
foreach($item_kit_ids as $item_kid_id)
{
{
// calculate the total cost and retail price of the Kit, so it can be added to the barcode text at the bottom
$item_kit = $this->_add_totals_to_item_kit($this->item_kit->get_info($item_kid_id));
$item_kid_id = 'KIT '. urldecode($item_kid_id);
$result[] = [

View File

@@ -62,7 +62,6 @@ class Items extends Secure_Controller
public function getIndex(): void
{
helper('tabular');
$this->session->set('allow_temp_items', 0);
$data['table_headers'] = get_items_manage_table_headers();

View File

@@ -18,7 +18,6 @@ abstract class Persons extends Secure_Controller
public function getIndex(): void
{
helper('tabular');
$data['table_headers'] = get_people_manage_table_headers();
echo view('people/manage', $data);

View File

@@ -49,12 +49,14 @@ class Sales extends Secure_Controller
helper('file');
$this->session = session();
$this->barcode_lib = new Barcode_lib();
$this->email_lib = new Email_lib();
$this->sale_lib = new Sale_lib();
$this->tax_lib = new Tax_lib();
$this->token_lib = new Token_lib();
$this->config = config('OSPOS')->settings;
$this->stock_location = model('Stock_location');
}
public function getIndex(): void
@@ -570,7 +572,7 @@ class Sales extends Secure_Controller
if(!$this->validate([]))
{
$this->sale_lib->edit_item($line, $description, $serialnumber, $quantity, $discount, $discount_type, $price, $discounted_total);
$this->sale_lib->empty_payments();
}
else
@@ -1286,7 +1288,7 @@ class Sales extends Secure_Controller
$data['selected_employee_name'] = $employee_info->first_name . ' ' . $employee_info->last_name;
$data['sale_info'] = $sale_info;
$balance_due = round($sale_info['amount_due'] - $sale_info['amount_tendered'] + $sale_info['cash_refund'], totals_decimals(), PHP_ROUND_HALF_UP);
if(!$this->sale_lib->reset_cash_rounding() && $balance_due < 0)
{
$balance_due = 0;

View File

@@ -14,7 +14,6 @@ use App\Models\Sale;
use CodeIgniter\Session\Session;
use App\Models\Stock_location;
use ReflectionException;
use App\Libraries\Tax_lib;
/**
* Sale library
@@ -39,7 +38,7 @@ class Sale_lib
{
public function __construct()
{
$this->session = Session();
$this->session = session();
$this->attribute = model('Attribute');
$this->customer = model('Customer');
@@ -700,10 +699,10 @@ class Sale_lib
public function get_mode(): string
{
if(!$this->session->get('sales_mode'))
{
$this->set_mode('sale');
}
if(!$this->session->get('sales_mode'))
{
$this->set_mode('sale');
}
return $this->session->get('sales_mode');
}
@@ -717,7 +716,7 @@ class Sale_lib
$this->session->remove('sales_mode');
}
public function get_dinner_table(): int
public function get_dinner_table(): ?int
{
if(!$this->session->get('dinner_table'))
{
@@ -1441,7 +1440,7 @@ class Sale_lib
return $total;
}
public function get_empty_tables(int $current_dinner_table_id): array
public function get_empty_tables(?int $current_dinner_table_id): array
{
return $this->dinner_table->get_empty_tables($current_dinner_table_id);
}

View File

@@ -46,7 +46,7 @@ class Dinner_table extends Model
/**
* Get empty tables
*/
public function get_empty_tables(int $current_dinner_table_id): array
public function get_empty_tables(?int $current_dinner_table_id): array
{
$builder = $this->db->table('dinner_tables');
$builder->where('status', 0);

View File

@@ -32,4 +32,4 @@ abstract class Report extends Model
// Returns key=>value pairing of summary data for the report
public abstract function getSummaryData(array $inputs): array;
}
}

View File

@@ -2,6 +2,7 @@
/**
* @var bool $logo_exists
* @var string $controller_name
* @var array $config
*/
?>
<?php echo form_open('config/save_info/', ['id' => 'info_config_form', 'enctype' => 'multipart/form-data', 'class' => 'form-horizontal']) ?>
@@ -10,7 +11,7 @@
<div id="required_fields_message"><?php echo lang('Common.fields_required_message') ?></div>
<ul id="info_error_message_box" class="error_message_box"></ul>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label(lang('Config.company'), 'company', ['class' => 'control-label col-xs-2 required']) ?>
<div class="col-xs-6">
<div class="input-group">
@@ -19,20 +20,20 @@
'name' => 'company',
'id' => 'company',
'class' => 'form-control input-sm required',
'value' => esc($config['company'], 'attr')
'value' => $config['company']
]) ?>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label(lang('Config.company_logo'), 'company_logo', ['class' => 'control-label col-xs-2']) ?>
<div class='col-xs-6'>
<div class="fileinput <?php echo $logo_exists ? 'fileinput-exists' : 'fileinput-new' ?>" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 200px; height: 200px;"></div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 200px;">
<img data-src="holder.js/100%x100%" alt="<?php echo lang('Config.company_logo') ?>"
src="<?php if($logo_exists) echo esc(base_url('uploads/' . $config['company_logo']), 'url'); else echo '' ?>"
src="<?php if($logo_exists) echo base_url('uploads/' . $config['company_logo']); else echo '' ?>"
style="max-height: 100%; max-width: 100%;">
</div>
<div>
@@ -47,19 +48,19 @@
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label(lang('Config.address'), 'address', ['class' => 'control-label col-xs-2 required']) ?>
<div class='col-xs-6'>
<?php echo form_textarea ([
'name' => 'address',
'id' => 'address',
'class' => 'form-control input-sm required',
'value'=> esc($config['address'], 'attr')
'value'=> $config['address'], 'attr'
]) ?>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label(lang('Config.website'), 'website', ['class' => 'control-label col-xs-2']) ?>
<div class="col-xs-6">
<div class="input-group">
@@ -68,13 +69,13 @@
'name' => 'website',
'id' => 'website',
'class' => 'form-control input-sm',
'value'=> esc($config['website'], 'url')
'value'=> $config['website']
]) ?>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label(lang('Common.email'), 'email', ['class' => 'control-label col-xs-2']) ?>
<div class="col-xs-6">
<div class="input-group">
@@ -84,13 +85,13 @@
'id' => 'email',
'type' => 'email',
'class' => 'form-control input-sm',
'value'=> esc($config['email'], 'attr')
'value'=> $config['email']
]) ?>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label(lang('Config.phone'), 'phone', ['class' => 'control-label col-xs-2 required']) ?>
<div class="col-xs-6">
<div class="input-group">
@@ -99,13 +100,13 @@
'name' => 'phone',
'id' => 'phone',
'class' => 'form-control input-sm required',
'value'=> esc($config['phone'], 'attr')
'value'=> $config['phone']
]) ?>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label(lang('Config.fax'), 'fax', ['class' => 'control-label col-xs-2']) ?>
<div class="col-xs-6">
<div class="input-group">
@@ -114,20 +115,20 @@
'name' => 'fax',
'id' => 'fax',
'class' => 'form-control input-sm',
'value'=> esc($config['fax'], 'attr')
'value'=> $config['fax']
]) ?>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label(lang('Common.return_policy'), 'return_policy', ['class' => 'control-label col-xs-2 required']) ?>
<div class='col-xs-6'>
<?php echo form_textarea ([
'name' => 'return_policy',
'id' => 'return_policy',
'class' => 'form-control input-sm required',
'value' => esc($config['return_policy'], 'attr')
'value' => $config['return_policy']
]) ?>
</div>
</div>
@@ -148,7 +149,7 @@ $(document).ready(function()
$("a.fileinput-exists").click(function() {
$.ajax({
type: 'POST',
url: '<?php echo esc(site_url("$controller_name/remove_logo"), 'url'); ?>',
url: '<?php echo site_url("$controller_name/remove_logo"); ?>',
dataType: 'json'
})
});
@@ -166,7 +167,7 @@ $(document).ready(function()
return_policy: "required"
},
messages:
messages:
{
company: "<?php echo lang('Config.company_required') ?>",
address: "<?php echo lang('Config.address_required') ?>",