For #3730. This adds a migration script to preload required configuration values.

This commit is contained in:
Steve Ireland
2023-04-12 22:17:07 -04:00
parent 6ffca6cfad
commit 3668f3cb86
6 changed files with 37 additions and 10 deletions

View File

@@ -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')
{

View File

@@ -0,0 +1,27 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class Migration_add_missing_config extends Migration
{
public function up(): void
{
$image_values = [
['key' => '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.
}
}

View File

@@ -93,7 +93,7 @@
<?php echo form_radio ([
'name' => 'barcode_content',
'value' => 'id',
'checked' => @$config['barcode_content' === 'id']
'checked' => $config['barcode_content' == 'id']
]) ?>
<?php echo lang('Config.barcode_id') ?>
</label>
@@ -101,7 +101,7 @@
<?php echo form_radio ([
'name' => 'barcode_content',
'value' => 'number',
'checked' => @$config['barcode_content'] === 'number']) ?>
'checked' => $config['barcode_content'] == 'number']) ?>
<?php echo lang('Config.barcode_number') ?>
</label>
&nbsp

View File

@@ -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'])
]) ?>
</div>
</div>
@@ -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'])
]) ?>
</div>
</div>
@@ -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'])
]) ?>
</div>
</div>

View File

@@ -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']
) ?>
</div>
@@ -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
]) ?>
</div>
</div>
@@ -428,7 +428,7 @@
'name' => 'category_dropdown',
'id' => 'category_dropdown',
'value' => 'category_dropdown',
'checked' => @$config['category_dropdown'] == 1
'checked' => $config['category_dropdown'] == 1
]) ?>
</div>
</div>

View File

@@ -62,7 +62,7 @@
<div class="input-group">
<span class="input-group-addon input-sm"><span class="glyphicon glyphicon-tag"></span></span>
<?php
if(@$config['category_dropdown'])
if($config['category_dropdown'])
{
echo form_dropdown('category', esc($categories), $selected_category, ['class' => 'form-control']);
}