From 3668f3cb8644869ea683749cdd3125fd7ecc75b1 Mon Sep 17 00:00:00 2001 From: Steve Ireland Date: Wed, 12 Apr 2023 22:17:07 -0400 Subject: [PATCH] For #3730. This adds a migration script to preload required configuration values. --- app/Controllers/Items.php | 2 +- .../20230412000000_add_missing_config.php | 27 +++++++++++++++++++ app/Views/configs/barcode_config.php | 4 +-- app/Views/configs/email_config.php | 6 ++--- app/Views/configs/general_config.php | 6 ++--- app/Views/items/form.php | 2 +- 6 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 app/Database/Migrations/20230412000000_add_missing_config.php diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php index 793cb8817..f9652de7d 100644 --- a/app/Controllers/Items.php +++ b/app/Controllers/Items.php @@ -288,7 +288,7 @@ class Items extends Secure_Controller $use_destination_based_tax = (boolean)$this->config['use_destination_based_tax']; $data['include_hsn'] = $this->config['include_hsn'] === '1'; - $data['category_dropdown'] = @$this->config['category_dropdown']; + $data['category_dropdown'] = $this->config['category_dropdown']; if($data['category_dropdown'] === '1') { diff --git a/app/Database/Migrations/20230412000000_add_missing_config.php b/app/Database/Migrations/20230412000000_add_missing_config.php new file mode 100644 index 000000000..dfbd40b50 --- /dev/null +++ b/app/Database/Migrations/20230412000000_add_missing_config.php @@ -0,0 +1,27 @@ + 'category_dropdown', 'value' => ''], + ['key' => 'smtp_host', 'value' => ''], + ['key' => 'smtp_user', 'value' => ''], + ['key' => 'smtp_pass', 'value' => ''], + ['key' => 'login_form', 'value' => ''], + ['key' => 'receiving_calculate_average_price', 'value' => ''] + ]; + + $this->db->table('app_config')->ignore(true)->insertBatch($image_values); + } + + public function down(): void + { + // no need to remove necessary config values. + } +} diff --git a/app/Views/configs/barcode_config.php b/app/Views/configs/barcode_config.php index d3b32ad0f..707d94dd0 100644 --- a/app/Views/configs/barcode_config.php +++ b/app/Views/configs/barcode_config.php @@ -93,7 +93,7 @@ 'barcode_content', 'value' => 'id', - 'checked' => @$config['barcode_content' === 'id'] + 'checked' => $config['barcode_content' == 'id'] ]) ?> @@ -101,7 +101,7 @@ 'barcode_content', 'value' => 'number', - 'checked' => @$config['barcode_content'] === 'number']) ?> + 'checked' => $config['barcode_content'] == 'number']) ?>   diff --git a/app/Views/configs/email_config.php b/app/Views/configs/email_config.php index 362bb0346..2ec482bba 100644 --- a/app/Views/configs/email_config.php +++ b/app/Views/configs/email_config.php @@ -38,7 +38,7 @@ 'name' => 'smtp_host', 'id' => 'smtp_host', 'class' => 'form-control input-sm', - 'value' => esc(@$config['smtp_host']) + 'value' => esc($config['smtp_host']) ]) ?> @@ -90,7 +90,7 @@ 'name' => 'smtp_user', 'id' => 'smtp_user', 'class' => 'form-control input-sm', - 'value' => esc(@$config['smtp_user']) + 'value' => esc($config['smtp_user']) ]) ?> @@ -105,7 +105,7 @@ 'name' => 'smtp_pass', 'id' => 'smtp_pass', 'class' => 'form-control input-sm', - 'value' => esc(@$config['smtp_pass']) + 'value' => esc($config['smtp_pass']) ]) ?> diff --git a/app/Views/configs/general_config.php b/app/Views/configs/general_config.php index 3dd79da52..dc273f00a 100644 --- a/app/Views/configs/general_config.php +++ b/app/Views/configs/general_config.php @@ -38,7 +38,7 @@ 'floating_labels' => lang('Config.floating_labels'), 'input_groups' => lang('Config.input_groups') ], - esc(@$config['login_form']), + esc($config['login_form']), ['class' => 'form-control input-sm'] ) ?> @@ -127,7 +127,7 @@ 'name' => 'receiving_calculate_average_price', 'id' => 'receiving_calculate_average_price', 'value' => 'receiving_calculate_average_price', - 'checked' => @$config['receiving_calculate_average_price'] == 1 + 'checked' => $config['receiving_calculate_average_price'] == 1 ]) ?> @@ -428,7 +428,7 @@ 'name' => 'category_dropdown', 'id' => 'category_dropdown', 'value' => 'category_dropdown', - 'checked' => @$config['category_dropdown'] == 1 + 'checked' => $config['category_dropdown'] == 1 ]) ?> diff --git a/app/Views/items/form.php b/app/Views/items/form.php index 612c4fc77..96ef017d8 100644 --- a/app/Views/items/form.php +++ b/app/Views/items/form.php @@ -62,7 +62,7 @@
'form-control']); }