Files
6e273a2fb1 refactor: Replace var with let/const in JavaScript files (#4503)
* refactor: Replace var with let/const in JavaScript files

- Replace var with let for variables that are reassigned
- Replace var with const for variables that are never reassigned
- Modernize manage_tables.js and nominatim.autocomplete.js
- Skip third-party libraries (imgpreview.full.jquery.js, clipboard.min.js)

Closes #4491

* refactor: Replace var with let/const in inline JavaScript

- Fixed CodeRabbit review: changed enable_actions and load_success
  from const to let in manage_tables.js (they are reassigned in init)
- Replaced all var declarations in inline JavaScript in Views with
  let (for reassigned) or const (for never reassigned)
- Modernized 48 additional files with inline JavaScript

* refactor: Replace var with let/const in remaining JS files

- Modernized gulpfile.js: 3 var declarations replaced
- Modernized app/Views/errors/html/debug.js: all var declarations replaced
- Used const for never-reassigned, let for reassigned variables

* fix: Replace remaining var declarations in Views

- Changed var  to const in sales/register.php
- Changed var  to const in configs/receipt_config.php

These were missed in the initial pass.

* fix: Replace remaining var declarations in gulpfile.js

- Converted 12 remaining var declarations to const
- All variables are function-scoped and never reassigned
- Complete coverage for this file now

* fix: Address CodeRabbit review comments

- items/manage.php: Remove duplicate let declaration for start_date
  (partial/daterangepicker already declares it)
- header_js.php: Escape CSRF hash in JavaScript context
- tax_jurisdictions.php: Fix mismatched selector (remove_tax_jurisdictions
  -> remove_tax_jurisdiction)

* style(views): Replace var with let/const and fix comment casing

- Convert var to let in items/manage.php for JS modernization
- Capitalize \"Submit\" in validation comments across tax view files

Signed-off-by: Travis Garrison <travis@chiraqbookstore.com>

---------

Signed-off-by: Travis Garrison <travis@chiraqbookstore.com>
Co-authored-by: Ollama <ollama@steganos.dev>
Co-authored-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
Co-authored-by: Travis Garrison <travis@chiraqbookstore.com>
2026-08-06 12:15:45 +04:00

242 lines
9.7 KiB
PHP

<?php
/**
* @var array $suppliers
* @var array $allow_alt_description_choices
* @var array $serialization_choices
* @var string $controller_name
* @var array $config
*/
?>
<div id="required_fields_message"><?= lang('Items.edit_fields_you_want_to_update') ?></div>
<ul id="error_message_box" class="error_message_box"></ul>
<?= form_open('items/bulkUpdate/', ['id' => 'item_form', 'class' => 'form-horizontal']) ?>
<fieldset id="bulk_item_basic_info">
<div class="form-group form-group-sm">
<?= form_label(lang('Items.name'), 'name', ['class' => 'control-label col-xs-3']) ?>
<div class="col-xs-8">
<?= form_input([
'name' => 'name',
'id' => 'name',
'class' => 'form-control input-sm'
]) ?>
</div>
</div>
<div class="form-group form-group-sm">
<?= form_label(lang('Items.category'), 'category', ['class' => 'control-label col-xs-3']) ?>
<div class="col-xs-8">
<div class="input-group">
<span class="input-group-addon input-sm"><span class="glyphicon glyphicon-tag"></span></span>
<?= form_input([
'name' => 'category',
'id' => 'category',
'class' => 'form-control input-sm'
]) ?>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<?= form_label(lang('Items.supplier'), 'supplier', ['class' => 'control-label col-xs-3']) ?>
<div class="col-xs-8">
<?= form_dropdown('supplier_id', $suppliers, '', ['class' => 'form-control']) ?>
</div>
</div>
<div class="form-group form-group-sm">
<?= form_label(lang('Items.cost_price'), 'cost_price', ['class' => 'control-label col-xs-3']) ?>
<div class="col-xs-4">
<div class="input-group input-group-sm">
<?php if (!is_right_side_currency_symbol()): ?>
<span class="input-group-addon input-sm"><b><?= esc($config['currency_symbol']) ?></b></span>
<?php endif; ?>
<?= form_input([
'name' => 'cost_price',
'id' => 'cost_price',
'class' => 'form-control input-sm'
]) ?>
<?php if (is_right_side_currency_symbol()): ?>
<span class="input-group-addon input-sm"><b><?= esc($config['currency_symbol']) ?></b></span>
<?php endif; ?>
</div>
</div>
</div>
<div class="form-group form-group">
<?= form_label(lang('Items.unit_price'), 'unit_price', ['class' => 'control-label col-xs-3']) ?>
<div class="col-xs-4">
<div class="input-group input-group-sm">
<?php if (!is_right_side_currency_symbol()): ?>
<span class="input-group-addon input-sm"><b><?= esc($config['currency_symbol']) ?></b></span>
<?php endif; ?>
<?= form_input([
'name' => 'unit_price',
'id' => 'unit_price',
'class' => 'form-control input-sm'
]) ?>
<?php if (is_right_side_currency_symbol()): ?>
<span class="input-group-addon input-sm"><b><?= esc($config['currency_symbol']) ?></b></span>
<?php endif; ?>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<?= form_label(lang('Items.tax_1'), 'tax_percent_1', ['class' => 'control-label col-xs-3']) ?>
<div class="col-xs-4">
<?= form_input([
'name' => 'tax_names[]',
'id' => 'tax_name_1',
'class' => 'form-control input-sm',
'value' => $config['default_tax_1_name']
]) ?>
</div>
<div class="col-xs-4">
<div class="input-group input-group-sm">
<?= form_input([
'name' => 'tax_percents[]',
'id' => 'tax_percent_name_1',
'class' => 'form-control input-sm',
'value' => to_tax_decimals($config['default_tax_1_rate'])
]) ?>
<span class="input-group input-group-addon"><b>%</b></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<?= form_label(lang('Items.tax_2'), 'tax_percent_2', ['class' => 'control-label col-xs-3']) ?>
<div class="col-xs-4">
<?= form_input([
'name' => 'tax_names[]',
'id' => 'tax_name_2',
'class' => 'form-control input-sm',
'value' => $config['default_tax_2_name']
]) ?>
</div>
<div class="col-xs-4">
<div class="input-group input-group-sm">
<?= form_input([
'name' => 'tax_percents[]',
'id' => 'tax_percent_name_2',
'class' => 'form-control input-sm',
'value' => to_tax_decimals($config['default_tax_2_rate'])
]) ?>
<span class="input-group input-group-addon"><b>%</b></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<?= form_label(lang('Items.reorder_level'), 'reorder_level', ['class' => 'control-label col-xs-3']) ?>
<div class="col-xs-4">
<?= form_input([
'name' => 'reorder_level',
'id' => 'reorder_level',
'class' => 'form-control input-sm'
]) ?>
</div>
</div>
<div class="form-group form-group-sm">
<?= form_label(lang('Items.description'), 'description', ['class' => 'control-label col-xs-3']) ?>
<div class="col-xs-8">
<?= form_textarea([
'name' => 'description',
'id' => 'description',
'class' => 'form-control input-sm'
]) ?>
</div>
</div>
<div class="form-group form-group-sm">
<?= form_label(lang('Items.allow_alt_description'), 'allow_alt_description', ['class' => 'control-label col-xs-3']) ?>
<div class="col-xs-8">
<?= form_dropdown('allow_alt_description', $allow_alt_description_choices, '', ['class' => 'form-control']) ?>
</div>
</div>
<div class="form-group form-group-sm">
<?= form_label(lang('Items.is_serialized'), 'is_serialized', ['class' => 'control-label col-xs-3']) ?>
<div class="col-xs-8">
<?= form_dropdown('is_serialized', $serialization_choices, '', ['class' => 'form-control']) ?>
</div>
</div>
</fieldset>
<?= form_close() ?>
<script type="text/javascript">
// Validation and submit handling
$(document).ready(function() {
$('#category').autocomplete({
source: "<?= 'items/suggestCategory' ?>",
appendTo: '.modal-content',
delay: 10
});
let confirm_message = false;
$('#tax_percent_name_2, #tax_name_2').prop('disabled', true),
$('#tax_percent_name_1, #tax_name_1').blur(function() {
const disabled = !($('#tax_percent_name_1').val() + $('#tax_name_1').val());
$('#tax_percent_name_2, #tax_name_2').prop('disabled', disabled);
confirm_message = disabled ? '' : "<?= lang('Items.confirm_bulk_edit_wipe_taxes') ?>";
});
$('#item_form').validate($.extend({
submitHandler: function(form) {
if (!confirm_message || confirm(confirm_message)) {
$(form).ajaxSubmit({
beforeSubmit: function(arr, $form, options) {
arr.push({
name: 'item_ids',
value: table_support.selected_ids().join(":")
});
},
success: function(response) {
dialog_support.hide();
table_support.handle_submit("<?= esc($controller_name) ?>", response);
},
dataType: 'json'
});
}
},
errorLabelContainer: '#error_message_box',
rules: {
unit_price: {
number: true
},
tax_percent: {
number: true
},
quantity: {
number: true
},
reorder_level: {
number: true
}
},
messages: {
unit_price: {
number: "<?= lang('Items.unit_price_number') ?>"
},
tax_percent: {
number: "<?= lang('Items.tax_percent_number') ?>"
},
quantity: {
number: "<?= lang('Items.quantity_number') ?>"
},
reorder_level: {
number: "<?= lang('Items.reorder_level_number') ?>"
}
}
}, form_support.error));
});
</script>