Compare commits

...

6 Commits

Author SHA1 Message Date
Ollama
0a0f0c7f4c 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)
2026-04-15 14:36:34 +00:00
Ollama
7a7ee4a5f3 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
2026-04-15 13:17:55 +00:00
Ollama
418dbc69e8 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.
2026-04-15 13:02:22 +00:00
Ollama
e177099be1 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
2026-04-15 12:54:24 +00:00
Ollama
513cccad69 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
2026-04-15 12:45:32 +00:00
Ollama
91137a43a2 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
2026-04-15 12:11:51 +00:00
52 changed files with 328 additions and 327 deletions

View File

@@ -102,12 +102,12 @@
<script type="text/javascript">
// Validation and submit handling
$(document).ready(function() {
var values = [];
var definition_id = <?= esc($definition_id, 'js') ?>;
var is_new = definition_id == 0;
const values = [];
const definition_id = <?= esc($definition_id, 'js') ?>;
const is_new = definition_id == 0;
var disable_definition_types = function() {
var definition_type = $("#definition_type option:selected").text();
const disable_definition_types = function() {
const definition_type = $("#definition_type option:selected").text();
if (definition_type == "DATE" || (definition_type == "GROUP" && !is_new) || definition_type == "DECIMAL") {
$('#definition_type').prop("disabled", true);
@@ -121,7 +121,7 @@
}
disable_definition_types();
var disable_category_dropdown = function() {
const disable_category_dropdown = function() {
if (definition_id == -1) {
$('#definition_name').prop("disabled", true);
$('#definition_type').prop("disabled", true);
@@ -131,11 +131,11 @@
}
disable_category_dropdown();
var show_hide_fields = function(event) {
var is_dropdown = $('#definition_type').val() !== '1';
var is_decimal = $('#definition_type').val() !== '2';
var is_no_group = $('#definition_type').val() !== '0';
var is_category_dropdown = definition_id == -1;
const show_hide_fields = function(event) {
const is_dropdown = $('#definition_type').val() !== '1';
const is_decimal = $('#definition_type').val() !== '2';
const is_no_group = $('#definition_type').val() !== '0';
const is_category_dropdown = definition_id == -1;
$('#definition_value, #definition_list_group').parents('.form-group').toggleClass('hidden', is_dropdown);
$('#definition_unit').parents('.form-group').toggleClass('hidden', is_decimal);
@@ -150,12 +150,12 @@
show_hide_fields();
$('.selectpicker').each(function() {
var $selectpicker = $(this);
const $selectpicker = $(this);
$.fn.selectpicker.call($selectpicker, $selectpicker.data());
});
var remove_attribute_value = function() {
var value = $(this).parents("li").text();
const remove_attribute_value = function() {
const value = $(this).parents("li").text();
if (is_new) {
values.splice($.inArray(value, values), 1);
@@ -168,8 +168,8 @@
$(this).parents("li").remove();
};
var add_attribute_value = function(value) {
var is_event = typeof(value) !== 'string';
const add_attribute_value = function(value) {
const is_event = typeof(value) !== 'string';
if ($("#definition_value").val().match(/(\||_)/g) != null) {
return;
@@ -206,7 +206,7 @@
}
});
var definition_values = <?= json_encode(array_values($definition_values)) ?>;
const definition_values = <?= json_encode(array_values($definition_values)) ?>;
$.each(definition_values, function(index, element) {
add_attribute_value(element);
});

View File

@@ -104,7 +104,7 @@
(function() {
<?= view('partial/datepicker_locale', ['format' => dateformat_bootstrap($config['dateformat'])]) ?>
var enable_delete = function() {
const enable_delete = function() {
$('.remove_attribute_btn').click(function() {
$(this).parents('.form-group').remove();
});
@@ -113,7 +113,7 @@
enable_delete();
$("input[name*='attribute_links']").change(function() {
var definition_id = $(this).data('definition-id');
const definition_id = $(this).data('definition-id');
$("input[name='attribute_ids[" + definition_id + "]']").val('');
}).autocomplete({
source: function(request, response) {
@@ -129,11 +129,11 @@
delay: 10
});
var definition_values = function() {
var result = {};
const definition_values = function() {
const result = {};
$("[name*='attribute_links'").each(function() {
var definition_id = $(this).data('definition-id');
var element = $(this);
const definition_id = $(this).data('definition-id');
const element = $(this);
// For checkboxes, use the visible checkbox, not the hidden input
if (element.attr('type') === 'hidden' && element.siblings('input[type="checkbox"]').length > 0) {
@@ -151,9 +151,9 @@
return result;
};
var refresh = function() {
var definition_id = $("#definition_name option:selected").val();
var attribute_values = definition_values();
const refresh = function() {
const definition_id = $("#definition_name option:selected").val();
let attribute_values = definition_values();
attribute_values[definition_id] = '';
$('#attributes').load('<?= "items/attributes/$item_id" ?>', {
'definition_ids': JSON.stringify(attribute_values)

View File

@@ -308,7 +308,7 @@
);
});
var submit_form = function() {
const submit_form = function() {
$(this).ajaxSubmit({
success: function(response) {
dialog_support.hide();

View File

@@ -139,7 +139,7 @@
<script type="text/javascript">
// Validation and submit handling
$(document).ready(function() {
var check_protocol = function() {
const check_protocol = function() {
if ($('#protocol').val() == 'sendmail') {
$('#mailpath').prop('disabled', false);
$('#smtp_host, #smtp_user, #smtp_pass, #smtp_port, #smtp_timeout, #smtp_crypto').prop('disabled', true);

View File

@@ -467,8 +467,8 @@
<script type="text/javascript">
// Validation and submit handling
$(document).ready(function() {
var enable_disable_gcaptcha_enable = (function() {
var gcaptcha_enable = $("#gcaptcha_enable").is(":checked");
const enable_disable_gcaptcha_enable = (function() {
const gcaptcha_enable = $("#gcaptcha_enable").is(":checked");
if (gcaptcha_enable) {
$("#gcaptcha_site_key, #gcaptcha_secret_key").prop("disabled", !gcaptcha_enable).addClass("required");
$("#config_gcaptcha_site_key, #config_gcaptcha_secret_key").addClass("required");

View File

@@ -198,9 +198,9 @@
<script type="text/javascript">
// Validation and submit handling
$(document).ready(function() {
var enable_disable_invoice_enable = (function() {
var invoice_enabled = $("#invoice_enable").is(":checked");
var work_order_enabled = $("#work_order_enable").is(":checked");
const enable_disable_invoice_enable = (function() {
const invoice_enabled = $("#invoice_enable").is(":checked");
const work_order_enabled = $("#work_order_enable").is(":checked");
$("#sales_invoice_format, #recv_invoice_format, #invoice_default_comments, #invoice_email_message, select[name='invoice_type'], #sales_quote_format, select[name='line_sequence'], #last_used_invoice_number, #last_used_quote_number, #quote_default_comments, #work_order_enable, #work_order_format, #last_used_work_order_number").prop("disabled", !invoice_enabled);
if (invoice_enabled) {
$("#work_order_format, #last_used_work_order_number").prop("disabled", !work_order_enabled);
@@ -210,9 +210,9 @@
return arguments.callee;
})();
var enable_disable_work_order_enable = (function() {
var work_order_enabled = $("#work_order_enable").is(":checked");
var invoice_enabled = $("#invoice_enable").is(":checked");
const enable_disable_work_order_enable = (function() {
const work_order_enabled = $("#work_order_enable").is(":checked");
const invoice_enabled = $("#invoice_enable").is(":checked");
if (invoice_enabled) {
$("#work_order_format, #last_used_work_order_number").prop("disabled", !work_order_enabled);
}

View File

@@ -292,7 +292,7 @@
$('span').tooltip();
$('#currency_symbol, #thousands_separator, #currency_code').change(function() {
var data = {
const data = {
number_locale: $('#number_locale').val()
};
data['save_number_locale'] = $("input[name='save_number_locale']").val();
@@ -336,7 +336,7 @@
}
},
dataFilter: function(data) {
var response = JSON.parse(data);
const response = JSON.parse(data);
$("input[name='save_number_locale']").val(response.save_number_locale);
$('#number_locale_example').text(response.number_locale_example);
$('#currency_symbol').val(response.currency_symbol);

View File

@@ -338,9 +338,9 @@
// Validation and submit handling
$(document).ready(function() {
if (window.localStorage && window.jsPrintSetup) {
var printers = (jsPrintSetup.getPrintersList() && jsPrintSetup.getPrintersList().split(',')) || [];
const printers = (jsPrintSetup.getPrintersList() && jsPrintSetup.getPrintersList().split(',')) || [];
$('#receipt_printer, #invoice_printer, #takings_printer').each(function() {
var $this = $(this)
const $this = $(this)
$(printers).each(function(key, value) {
$this.append($('<option>', {
value: value
@@ -360,7 +360,7 @@
});
}
var dialog_confirmed = window.jsPrintSetup;
const dialog_confirmed = window.jsPrintSetup;
$('#receipt_config_form').validate($.extend(form_support.handler, {
submitHandler: function(form) {

View File

@@ -43,8 +43,8 @@
// Validation and submit handling
$(document).ready(function() {
var enable_disable_customer_reward_enable = (function() {
var customer_reward_enable = $("#customer_reward_enable").is(":checked");
const enable_disable_customer_reward_enable = (function() {
const customer_reward_enable = $("#customer_reward_enable").is(":checked");
$("input[name*='customer_reward']:not(input[name=customer_reward_enable])").prop("disabled", !customer_reward_enable);
$("input[name*='reward_points_']:not(input[name=customer_reward_enable])").prop("disabled", !customer_reward_enable);
if (customer_reward_enable) {
@@ -57,9 +57,9 @@
$("#customer_reward_enable").change(enable_disable_customer_reward_enable);
var table_count = <?= sizeof($customer_rewards) ?>;
let table_count = <?= sizeof($customer_rewards) ?>;
var hide_show_remove = function() {
const hide_show_remove = function() {
if ($("input[name*='customer_rewards']:enabled").length > 1) {
$(".remove_customer_rewards").show();
} else {
@@ -67,27 +67,27 @@
}
};
var add_customer_reward = function() {
var id = $(this).parent().find('input').attr('id');
const add_customer_reward = function() {
let id = $(this).parent().find('input').attr('id');
id = id.replace(/.*?_(\d+)$/g, "$1");
var previous_id = 'customer_reward_' + id;
var previous_id_next = 'reward_points_' + id;
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
var new_block_id = 'customer_reward_' + ++id;
var new_block_id_next = 'reward_points_' + id;
const previous_id = 'customer_reward_' + id;
const previous_id_next = 'reward_points_' + id;
const block = $(this).parent().clone(true);
const new_block = block.insertAfter($(this).parent());
const new_block_id = 'customer_reward_' + ++id;
const new_block_id_next = 'reward_points_' + id;
$(new_block).find('label').html("<?= lang('Config.customer_reward') ?> " + ++table_count).attr('for', new_block_id).attr('class', 'control-label col-xs-2');
$(new_block).find("input[id='" + previous_id + "']").attr('id', new_block_id).removeAttr('disabled').attr('name', new_block_id).attr('class', 'form-control input-sm').val('');
$(new_block).find("input[id='" + previous_id_next + "']").attr('id', new_block_id_next).removeAttr('disabled').attr('name', new_block_id_next).attr('class', 'form-control input-sm').val('');
hide_show_remove();
};
var remove_customer_reward = function() {
const remove_customer_reward = function() {
$(this).parent().remove();
hide_show_remove();
};
var init_add_remove_tables = function() {
const init_add_remove_tables = function() {
$('.add_customer_reward').click(add_customer_reward);
$('.remove_customer_reward').click(remove_customer_reward);
hide_show_remove();
@@ -96,10 +96,10 @@
};
init_add_remove_tables();
var duplicate_found = false;
const duplicate_found = false;
// Run validator once for all fields
$.validator.addMethod('customer_reward', function(value, element) {
var value_count = 0;
let value_count = 0;
$("input[name*='customer_reward']:not(input[name=customer_reward_enable])").each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});

View File

@@ -29,9 +29,9 @@
<script type="text/javascript">
// Validation and submit handling
$(document).ready(function() {
var location_count = <?= sizeof($stock_locations) ?>;
let location_count = <?= sizeof($stock_locations) ?>;
var hide_show_remove = function() {
const hide_show_remove = function() {
if ($("input[name*='stock_location']:enabled").length > 1) {
$(".remove_stock_location").show();
} else {
@@ -39,31 +39,31 @@
}
};
var add_stock_location = function() {
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
var new_block_id = 'stock_location[]';
const add_stock_location = function() {
const block = $(this).parent().clone(true);
const new_block = block.insertAfter($(this).parent());
const new_block_id = 'stock_location[]';
$(new_block).find('label').html("<?= lang('Config.stock_location') ?> " + ++location_count).attr('for', new_block_id).attr('class', 'control-label col-xs-2');
$(new_block).find('input').attr('id', new_block_id).removeAttr('disabled').attr('name', new_block_id).attr('class', 'form-control input-sm').val('');
hide_show_remove();
};
var remove_stock_location = function() {
const remove_stock_location = function() {
$(this).parent().remove();
hide_show_remove();
};
var init_add_remove_locations = function() {
const init_add_remove_locations = function() {
$('.add_stock_location').click(add_stock_location);
$('.remove_stock_location').click(remove_stock_location);
hide_show_remove();
};
init_add_remove_locations();
var duplicate_found = false;
const duplicate_found = false;
// Run validator once for all fields
$.validator.addMethod('stock_location', function(value, element) {
var value_count = 0;
let value_count = 0;
$("input[name*='stock_location']").each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});

View File

@@ -198,7 +198,7 @@ use Config\OSPOS;
<div style="text-align: center;">
<a class="copy" data-clipboard-action="copy" data-clipboard-target="#issuetemplate">Copy Info</a> | <a href="https://github.com/opensourcepos/opensourcepos/issues/new" target="_blank"> <?= lang('Config.report_an_issue') ?></a>
<script type="text/javascript">
var clipboard = new ClipboardJS('.copy');
const clipboard = new ClipboardJS('.copy');
clipboard.on('success', function(e) {
document.getSelection().removeAllRanges();

View File

@@ -43,8 +43,8 @@
// Validation and submit handling
$(document).ready(function() {
var enable_disable_dinner_table_enable = (function() {
var dinner_table_enable = $("#dinner_table_enable").is(":checked");
const enable_disable_dinner_table_enable = (function() {
const dinner_table_enable = $("#dinner_table_enable").is(":checked");
$("input[name*='dinner_table']:not(input[name=dinner_table_enable])").prop("disabled", !dinner_table_enable);
if (dinner_table_enable) {
$(".add_dinner_table, .remove_dinner_table").show();
@@ -56,9 +56,9 @@
$("#dinner_table_enable").change(enable_disable_dinner_table_enable);
var table_count = <?= sizeof($dinner_tables) ?>;
let table_count = <?= sizeof($dinner_tables) ?>;
var hide_show_remove = function() {
const hide_show_remove = function() {
if ($("input[name*='dinner_tables']:enabled").length > 1) {
$(".remove_dinner_tables").show();
} else {
@@ -66,23 +66,23 @@
}
};
var add_dinner_table = function() {
var id = $(this).parent().find('input').attr('id');
const add_dinner_table = function() {
let id = $(this).parent().find('input').attr('id');
id = id.replace(/.*?_(\d+)$/g, "$1");
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
var new_block_id = 'dinner_table_' + ++id;
const block = $(this).parent().clone(true);
const new_block = block.insertAfter($(this).parent());
const new_block_id = 'dinner_table_' + ++id;
$(new_block).find('label').html("<?= lang('Config.dinner_table') ?> " + ++table_count).attr('for', new_block_id).attr('class', 'control-label col-xs-2');
$(new_block).find('input').attr('id', new_block_id).removeAttr('disabled').attr('name', new_block_id).attr('class', 'form-control input-sm').val('');
hide_show_remove();
};
var remove_dinner_table = function() {
const remove_dinner_table = function() {
$(this).parent().remove();
hide_show_remove();
};
var init_add_remove_tables = function() {
const init_add_remove_tables = function() {
$('.add_dinner_table').click(add_dinner_table);
$('.remove_dinner_table').click(remove_dinner_table);
hide_show_remove();
@@ -91,10 +91,10 @@
};
init_add_remove_tables();
var duplicate_found = false;
const duplicate_found = false;
// Run validator once for all fields
$.validator.addMethod('dinner_table', function(value, element) {
var value_count = 0;
let value_count = 0;
$("input[name*='dinner_table']:not(input[name=dinner_table_enable])").each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});

View File

@@ -143,8 +143,8 @@
<script type="text/javascript">
// Validation and submit handling
$(document).ready(function() {
var enable_disable_use_destination_based_tax = (function() {
var use_destination_based_tax = $("#use_destination_based_tax").is(":checked");
const enable_disable_use_destination_based_tax = (function() {
const use_destination_based_tax = $("#use_destination_based_tax").is(":checked");
$("select[name='default_tax_code']").prop("disabled", !use_destination_based_tax);
$("select[name='default_tax_category']").prop("disabled", !use_destination_based_tax);
$("select[name='default_tax_jurisdiction']").prop("disabled", !use_destination_based_tax);

View File

@@ -453,7 +453,7 @@
}
});
var fill_value = function(event, ui) {
const fill_value = function(event, ui) {
event.preventDefault();
$("input[name='sales_tax_code_id']").val(ui.item.value);
$("input[name='sales_tax_code_name']").val(ui.item.label);

View File

@@ -167,10 +167,10 @@
});
$.validator.addMethod('module', function(value, element) {
var result = $('#permission_list input').is(':checked');
let result = $('#permission_list input').is(':checked');
$('.module').each(function(index, element) {
var parent = $(element).parent();
var checked = $(element).is(':checked');
const parent = $(element);
const checked = $(element).is(':checked');
if ($('ul', parent).length > 0 && result) {
result &= !checked || (checked && $('ul > li > input:checked', parent).length > 0);
}
@@ -179,10 +179,10 @@
}, "<?= lang('Employees.subpermission_required') ?>");
$('ul#permission_list > li > input.module').each(function() {
var $this = $(this);
const $this = $(this);
$('ul > li > input,select', $this.parent()).each(function() {
var $that = $(this);
var updateInputs = function(checked) {
const $that = $(this);
const updateInputs = function(checked) {
$that.prop('disabled', !checked);
!checked && $that.prop('checked', false);
}

View File

@@ -1,17 +1,17 @@
var tabLinks = new Array();
var contentDivs = new Array();
const tabLinks = new Array();
const contentDivs = new Array();
function init()
{
// Grab the tab links and content divs from the page
var tabListItems = document.getElementById('tabs').childNodes;
const tabListItems = document.getElementById('tabs').childNodes;
console.log(tabListItems);
for (var i = 0; i < tabListItems.length; i ++)
for (let i = 0; i < tabListItems.length; i ++)
{
if (tabListItems[i].nodeName == "LI")
{
var tabLink = getFirstChildWithTagName(tabListItems[i], 'A');
var id = getHash(tabLink.getAttribute('href'));
const tabLink = getFirstChildWithTagName(tabListItems[i], 'A');
const id = getHash(tabLink.getAttribute('href'));
tabLinks[id] = tabLink;
contentDivs[id] = document.getElementById(id);
}
@@ -19,9 +19,9 @@ function init()
// Assign onclick events to the tab links, and
// highlight the first tab
var i = 0;
let i = 0;
for (var id in tabLinks)
for (const id in tabLinks)
{
tabLinks[id].onclick = showTab;
tabLinks[id].onfocus = function () {
@@ -35,26 +35,26 @@ function init()
}
// Hide all content divs except the first
var i = 0;
let j = 0;
for (var id in contentDivs)
for (const id in contentDivs)
{
if (i != 0)
if (j != 0)
{
console.log(contentDivs[id]);
contentDivs[id].className = 'content hide';
}
i ++;
j ++;
}
}
function showTab()
{
var selectedId = getHash(this.getAttribute('href'));
const selectedId = getHash(this.getAttribute('href'));
// Highlight the selected tab, and dim all others.
// Also show the selected content div, and hide all others.
for (var id in contentDivs)
for (const id in contentDivs)
{
if (id == selectedId)
{
@@ -74,7 +74,7 @@ function showTab()
function getFirstChildWithTagName(element, tagName)
{
for (var i = 0; i < element.childNodes.length; i ++)
for (let i = 0; i < element.childNodes.length; i ++)
{
if (element.childNodes[i].nodeName == tagName)
{
@@ -85,28 +85,29 @@ function getFirstChildWithTagName(element, tagName)
function getHash(url)
{
var hashPos = url.lastIndexOf('#');
const hashPos = url.lastIndexOf('#');
return url.substring(hashPos + 1);
}
function toggle(elem)
{
elem = document.getElementById(elem);
let disp;
if (elem.style && elem.style['display'])
{
// Only works with the "style" attr
var disp = elem.style['display'];
disp = elem.style['display'];
}
else if (elem.currentStyle)
{
// For MSIE, naturally
var disp = elem.currentStyle['display'];
disp = elem.currentStyle['display'];
}
else if (window.getComputedStyle)
{
// For most other browsers
var disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display');
disp = document.defaultView.getComputedStyle(elem, null).getPropertyValue('display');
}
// Toggle the state of the "display" style

View File

@@ -78,7 +78,7 @@
!$(this).val() && $(this).val('');
});
var fill_value = function(event, ui) {
const fill_value = function(event, ui) {
event.preventDefault();
$(this).val((ui.item ? ui.item.label : ""));
$("input[name='person_id']").val(ui.item.value);

View File

@@ -235,7 +235,7 @@
}
});
var fill_value = function(event, ui) {
const fill_value = function(event, ui) {
event.preventDefault();
$("input[name='kit_item_id']").val(ui.item.value);
$("input[name='item_name']").val(DOMPurify.sanitize(ui.item.label));

View File

@@ -467,7 +467,7 @@
!$(this).val() && $(this).val('');
});
var fill_tax_category_value = function(event, ui) {
const fill_tax_category_value = function(event, ui) {
event.preventDefault();
$("input[name='tax_category_id']").val(ui.item.value);
$("input[name='tax_category']").val(ui.item.label);
@@ -483,7 +483,7 @@
focus: fill_tax_category_value
});
var fill_low_sell_value = function(event, ui) {
const fill_low_sell_value = function(event, ui) {
event.preventDefault();
$("input[name='low_sell_item_id']").val(ui.item.value);
$("input[name='low_sell_item_name']").val(ui.item.label);
@@ -517,7 +517,7 @@
return value.match(/(\||_)/g) == null;
}, "<?= lang('Attributes.attribute_value_invalid_chars') ?>");
var init_validation = function() {
const init_validation = function() {
$('#item_form').validate($.extend({
submitHandler: function(form, event) { // Event is not used as a parameter here
$(form).ajaxSubmit({

View File

@@ -178,10 +178,10 @@
delay: 10
});
var confirm_message = false;
let confirm_message = false;
$('#tax_percent_name_2, #tax_name_2').prop('disabled', true),
$('#tax_percent_name_1, #tax_name_1').blur(function() {
var disabled = !($('#tax_percent_name_1').val() + $('#tax_name_1').val());
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') ?>";
});

View File

@@ -115,27 +115,27 @@ use App\Models\Inventory;
});
function display_stock(location_id) {
var item_quantities = <?= json_encode(esc($item_quantities, 'raw')) ?>;
const item_quantities = <?= json_encode(esc($item_quantities, 'raw')) ?>;
document.getElementById("quantity").value = parseFloat(item_quantities[location_id]).toFixed(<?= quantity_decimals() ?>);
var inventory_data = <?= json_encode(esc($inventory_array, 'raw')) ?>;
var employee_data = <?= json_encode(esc($employee_name, 'raw')) ?>;
const inventory_data = <?= json_encode(esc($inventory_array, 'raw')) ?>;
const employee_data = <?= json_encode(esc($employee_name, 'raw')) ?>;
var table = document.getElementById("inventory_result");
const table = document.getElementById("inventory_result");
// Remove old query from tbody
var rowCount = table.rows.length;
for (var index = rowCount; index > 0; index--) {
const rowCount = table.rows.length;
for (let index = rowCount; index > 0; index--) {
table.deleteRow(index - 1);
}
// Add new query to tbody
for (var index = 0; index < inventory_data.length; index++) {
var data = inventory_data[index];
for (let index = 0; index < inventory_data.length; index++) {
const data = inventory_data[index];
if (data['trans_location'] == location_id) {
var tr = document.createElement('tr');
const tr = document.createElement('tr');
var td = document.createElement('td');
let td = document.createElement('td');
td.appendChild(document.createTextNode(data['trans_date']));
tr.appendChild(td);

View File

@@ -136,7 +136,7 @@
});
function fill_quantity(val) {
var item_quantities = <?= json_encode(esc($item_quantities, 'raw')) ?>;
const item_quantities = <?= json_encode(esc($item_quantities, 'raw')) ?>;
document.getElementById('quantity').value = parseFloat(item_quantities[val]).toFixed(<?= quantity_decimals() ?>);
}
</script>

View File

@@ -30,7 +30,7 @@ use App\Models\Employee;
// Set the beginning of time as starting date
$('#daterangepicker').data('daterangepicker').setStartDate("<?= date($config['dateformat'], mktime(0, 0, 0, 01, 01, 2010)) ?>");
// Update the hidden inputs with the selected dates before submitting the search data
var start_date = "<?= date('Y-m-d', mktime(0, 0, 0, 01, 01, 2010)) ?>";
start_date = "<?= date('Y-m-d', mktime(0, 0, 0, 01, 01, 2010)) ?>";
// Override dates from server if provided
<?php if (isset($start_date) && $start_date): ?>

View File

@@ -3,7 +3,7 @@ use Config\OSPOS;
$config = config(OSPOS::class)->settings; ?>
var pickerconfig = function(config) {
const pickerconfig = function(config) {
return $.extend({
format: "<?= $this->data["format"] ?? dateformat_bootstrap($config['dateformat']) . ' ' . dateformat_bootstrap($config['timeformat'])?>",
<?php

View File

@@ -6,8 +6,8 @@
<?php if (empty($config['date_or_time_format'])) { ?>
$('#daterangepicker').css("width", "180");
var start_date = "<?= date('Y-m-d') ?>";
var end_date = "<?= date('Y-m-d') ?>";
let start_date = "<?= date('Y-m-d') ?>";
let end_date = "<?= date('Y-m-d') ?>";
$('#daterangepicker').daterangepicker({
"ranges": {
@@ -112,8 +112,8 @@
});
<?php } else { ?>
$('#daterangepicker').css("width", "305");
var start_date = "<?= date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d"), date("Y"))) ?>";
var end_date = "<?= date('Y-m-d H:i:s', mktime(23, 59, 59, date("m"), date("d"), date("Y"))) ?>";
let start_date = "<?= date('Y-m-d H:i:s', mktime(0, 0, 0, date("m"), date("d"), date("Y"))) ?>";
let end_date = "<?= date('Y-m-d H:i:s', mktime(23, 59, 59, date("m"), date("d"), date("Y"))) ?>";
$('#daterangepicker').daterangepicker({
"ranges": {
"<?= lang('Datepicker.today') ?>": [

View File

@@ -6,14 +6,14 @@
<script type="text/javascript">
// Live clock
var clock_tick = function clock_tick() {
const clock_tick = function clock_tick() {
setInterval('update_clock();', 1000);
}
// Start the clock immediately
clock_tick();
var update_clock = function update_clock() {
const update_clock = function update_clock() {
document.getElementById('liveclock').innerHTML = moment().format("<?= dateformat_momentjs($config['dateformat'] . ' ' . $config['timeformat']) ?>");
}
@@ -32,11 +32,11 @@
}
});
var csrf_token = function() {
return "<?= csrf_hash() ?>";
const csrf_token = function() {
return "<?= esc(csrf_hash(), 'js') ?>";
};
var csrf_form_base = function() {
const csrf_form_base = function() {
return {
<?= esc(config('Security')->tokenName, 'js') ?>: function() {
return csrf_token()
@@ -44,14 +44,14 @@
}
};
var setup_csrf_token = function() {
const setup_csrf_token = function() {
$('input[name="<?= esc(config('Security')->tokenName, 'js') ?>"]').val(csrf_token());
};
var ajax = $.ajax;
const ajax = $.ajax;
$.ajax = function() {
var args = arguments[0];
let args = arguments[0];
if (args['type'] && args['type'].toLowerCase() == 'post' && csrf_token()) {
if (typeof args['data'] === 'string') {
args['data'] += '&' + $.param(csrf_form_base());
@@ -80,7 +80,7 @@
});
});
var submit = $.fn.submit;
const submit = $.fn.submit;
$.fn.submit = function() {
setup_csrf_token();

View File

@@ -1,7 +1,7 @@
<script type="text/javascript">
(function(lang, $) {
var lines = {
const lines = {
'common_submit': "<?= lang('Common.submit') ?>",
'common_close': "<?= lang('Common.close') ?>"
};

View File

@@ -29,11 +29,11 @@
jsPrintSetup.setOption('footerStrRight', '');
<?php } ?>
var printers = jsPrintSetup.getPrintersList().split(',');
const printers = jsPrintSetup.getPrintersList().split(',');
// Get right printer here..
for (var index in printers) {
var default_ticket_printer = window.localStorage && localStorage['<?= esc($selected_printer, 'js') ?>'];
var selected_printer = printers[index];
for (const index in printers) {
const default_ticket_printer = window.localStorage && localStorage['<?= esc($selected_printer, 'js') ?>'];
const selected_printer = printers[index];
if (selected_printer == default_ticket_printer) {
// Select Epson label printer
jsPrintSetup.setPrinter(selected_printer);

View File

@@ -18,11 +18,11 @@ $filter_select_id = $options['filter_select_id'] ?? 'filters';
<script type="text/javascript">
$(document).ready(function() {
var additional_params = <?= json_encode($additional_params) ?>;
var filter_select_id = '<?= esc($filter_select_id) ?>';
const additional_params = <?= json_encode($additional_params) ?>;
const filter_select_id = '<?= esc($filter_select_id) ?>';
function update_url() {
var params = new URLSearchParams();
const params = new URLSearchParams();
// Add dates
if (typeof start_date !== 'undefined') {
@@ -33,7 +33,7 @@ $filter_select_id = $options['filter_select_id'] ?? 'filters';
}
// Add filters
var filters = $('#' + filter_select_id).val();
const filters = $('#' + filter_select_id).val();
if (filters) {
filters.forEach(function(filter) {
params.append('filters[]', filter);
@@ -42,9 +42,9 @@ $filter_select_id = $options['filter_select_id'] ?? 'filters';
// Add additional params
additional_params.forEach(function(param) {
var element = $('#' + param);
const element = $('#' + param);
if (element.length) {
var value = element.val();
const value = element.val();
if (Array.isArray(value) && value.length > 0) {
value.forEach(function(v) {
params.append(param + '[]', v);
@@ -56,8 +56,8 @@ $filter_select_id = $options['filter_select_id'] ?? 'filters';
});
// Update URL without page reload
var new_url = window.location.pathname;
var params_str = params.toString();
const new_url = window.location.pathname;
const params_str = params.toString();
if (params_str) {
new_url += '?' + params_str;
}

View File

@@ -26,8 +26,8 @@ function safeRemoveItem(key) {
}
// Load saved column visibility from localStorage
var savedVisibility = JSON.parse(safeGetItem('columnVisibility')) || { cost: false, profit: false };
var visibleColumns = savedVisibility;
const savedVisibility = JSON.parse(safeGetItem('columnVisibility')) || { cost: false, profit: false };
let visibleColumns = savedVisibility;
// Function to save column visibility to localStorage
function saveColumnVisibility(visibility) {
@@ -56,13 +56,13 @@ $('#table').bootstrapTable('refreshOptions', {
});
// Initialize visibility settings from localStorage
var summaryVisibility = JSON.parse(safeGetItem('summaryVisibility')) || { cost: false, profit: false };
let summaryVisibility = JSON.parse(safeGetItem('summaryVisibility')) || { cost: false, profit: false };
// Function to apply visibility for cost and profit rows
function applySummaryVisibility() {
var rows = $('#report_summary .summary_row');
var costRow = rows.eq(rows.length - 2); // Second-to-last row
var profitRow = rows.eq(rows.length - 1); // Last row
const rows = $('#report_summary .summary_row');
const costRow = rows.eq(rows.length - 2); // Second-to-last row
const profitRow = rows.eq(rows.length - 1); // Last row
if (summaryVisibility.cost === false) {
costRow.hide(); // Hide the cost row
@@ -90,7 +90,7 @@ $('#toggleCostProfitButton').click(function () {
applySummaryVisibility();
// Initialize dialog (if editable)
var init_dialog = function () {
const init_dialog = function () {
<?php if (isset($editable)): ?>
table_support.submit_handler('<?php echo site_url("reports/get_detailed_{$editable}_row") ?>');
dialog_support.init("a.modal-dlg");

View File

@@ -18,13 +18,13 @@
pageSize: <?= $config['lines_per_page'] ?>,
uniqueId: 'people.person_id',
enableActions: function() {
var email_disabled = $("td input:checkbox:checked").parents("tr").find("td a[href^='mailto:']").length == 0;
const email_disabled = $("td input:checkbox:checked").parents("tr").find("td a[href^='mailto:']").length == 0;
$("#email").prop('disabled', email_disabled);
}
});
$("#email").click(function(event) {
var recipients = $.map($("tr.selected a[href^='mailto:']"), function(element) {
const recipients = $.map($("tr.selected a[href^='mailto:']"), function(element) {
return $(element).attr('href').replace(/^mailto:/, '');
});
location.href = "mailto:" + recipients.join(",");

View File

@@ -76,7 +76,7 @@
$('#datetime').datetimepicker(pickerconfig);
var fill_value = function(event, ui) {
const fill_value = function(event, ui) {
event.preventDefault();
$("input[name='supplier_id']").val(ui.item.value);
$("input[name='supplier_name']").val(ui.item.label);

View File

@@ -533,7 +533,7 @@ if (isset($success)) {
});
$('[name="discount_toggle"]').change(function() {
var input = $("<input>").attr("type", "hidden").attr("name", "discount_type").val(($(this).prop('checked')) ? 1 : 0);
const input = $("<input>").attr("type", "hidden").attr("name", "discount_type").val(($(this).prop('checked')) ? 1 : 0);
$('#cart_' + $(this).attr('data-line')).append($(input));
$('#cart_' + $(this).attr('data-line')).submit();
});

View File

@@ -11,7 +11,7 @@
<script type="text/javascript">
// Labels and data series
var data = {
const data = {
labels: <?= esc(json_encode($labels_1), 'js') ?>,
series: [{
name: '<?= esc($yaxis_title, 'js') ?>',
@@ -20,7 +20,7 @@
};
// We are setting a few options for our chart and override the defaults
var options = {
const options = {
// Specify a fixed width for the chart as a string (i.e. '100px' or '50%')
width: '100%',
@@ -98,7 +98,7 @@
]
};
var responsiveOptions = [
const responsiveOptions = [
['screen and (min-width: 640px)', {
height: '80%',
chartPadding: {

View File

@@ -11,7 +11,7 @@
<script type="text/javascript">
// Labels and data series
var data = {
const data = {
labels: <?= json_encode(esc($labels_1, 'js')) ?>,
series: [{
name: '<?= esc($yaxis_title, 'js') ?>',
@@ -20,7 +20,7 @@
};
// We are setting a few options for our chart and override the defaults
var options = {
const options = {
// Specify a fixed width for the chart as a string (i.e. '100px' or '50%')
width: '100%',
@@ -101,7 +101,7 @@
]
};
var responsiveOptions = [
const responsiveOptions = [
['screen and (min-width: 640px)', {
height: '80%',
chartPadding: {

View File

@@ -11,7 +11,7 @@
<script type="text/javascript">
// Labels and data series
var data = {
const data = {
labels: <?= json_encode(esc($labels_1, 'js')) ?>,
series: [{
name: '<?= esc($yaxis_title, 'js') ?>',
@@ -20,7 +20,7 @@
};
// We are setting a few options for our chart and override the defaults
var options = {
const options = {
// Specify a fixed width for the chart as a string (i.e. '100px' or '50%')
width: '100%',
@@ -150,7 +150,7 @@
]
};
var responsiveOptions = [
const responsiveOptions = [
['screen and (min-width: 640px)', {
height: '80%',
chartPadding: {
@@ -172,7 +172,7 @@
// If the draw event was triggered from drawing a point on the line chart
if (data.type === 'point') {
// We are creating a new path SVG element that draws a triangle around the point coordinates
var circle = new Chartist.Svg('circle', {
const circle = new Chartist.Svg('circle', {
cx: [data.x],
cy: [data.y],
r: [5],

View File

@@ -9,13 +9,13 @@
<script type="text/javascript">
// Labels and data series
var data = {
const data = {
labels: <?= json_encode(esc($labels_1, 'js')) ?>,
series: <?= json_encode(esc($series_data_1, 'js')) ?>
};
// We are setting a few options for our chart and override the defaults
var options = {
const options = {
// Specify a fixed width for the chart as a string (i.e. '100px' or '50%')
width: '100%',
@@ -53,7 +53,7 @@
})
] };
var responsiveOptions = [
const responsiveOptions = [
['screen and (min-width: 640px)', {
height: '80%',
chartPadding: 20
@@ -72,9 +72,9 @@
// Generate random colours for the pie sliced because Chartist is currently limited to 15 colours
chart.on('draw', function(data) {
if (data.type === 'slice') {
var r = Math.floor(Math.random() * 256);
var g = Math.floor(Math.random() * 256);
var b = Math.floor(Math.random() * 256);
const r = Math.floor(Math.random() * 256);
const g = Math.floor(Math.random() * 256);
const b = Math.floor(Math.random() * 256);
data.element.attr({
style: 'fill: #' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)

View File

@@ -87,7 +87,7 @@ if (isset($error)) {
<?= view('partial/daterangepicker') ?>
$("#generate_report").click(function() {
var specific_input_data = $('#specific_input_data').val();
let specific_input_data = $('#specific_input_data').val();
if (!$(".discount_percent").is(":visible")) {
specific_input_data = $('#discount_fixed').val();
}
@@ -97,7 +97,7 @@ if (isset($error)) {
});
function check_discount_type() {
var discount_type = $("#discount_type_id").val();
const discount_type = $("#discount_type_id").val();
if (discount_type == 1) {
$(".discount_percent").hide();

View File

@@ -39,13 +39,13 @@
$(document).ready(function () {
<?= view('partial/bootstrap_tables_locale') ?>
var details_data = <?= json_encode(esc($details_data)) ?>;
const details_data = <?= json_encode(esc($details_data)) ?>;
<?php if ($config['customer_reward_enable'] && !empty($details_data_rewards)) { ?>
var details_data_rewards = <?= json_encode(esc($details_data_rewards)) ?>;
const details_data_rewards = <?= json_encode(esc($details_data_rewards)) ?>;
<?php } ?>
<?= view('partial/visibility_js') ?>
var init_dialog = function () {
const init_dialog = function () {
<?php if (isset($editable)) { ?>
table_support.submit_handler('<?= esc(site_url("reports/get_detailed_$editable" . '_row')) ?>');
dialog_support.init("a.modal-dlg");

View File

@@ -172,7 +172,7 @@
<?= view('partial/datepicker_locale') ?>
var fill_value_customer = function(event, ui) {
const fill_value_customer = function(event, ui) {
event.preventDefault();
$("input[name='customer_id']").val(ui.item.value);
$("input[name='customer_name']").val(ui.item.label);
@@ -188,7 +188,7 @@
focus: fill_value_customer
});
var fill_value_employee = function(event, ui) {
const fill_value_employee = function(event, ui) {
event.preventDefault();
$("input[name='employee_id']").val(ui.item.value);
$("input[name='employee_name']").val(ui.item.label);

View File

@@ -32,7 +32,7 @@ if (isset($error_message)) {
<?php if (!empty($customer_email)): ?>
<script type="text/javascript">
$(document).ready(function() {
var send_email = function() {
const send_email = function() {
$.get('<?= site_url() . "sales/sendPdf/$sale_id_num" ?>',
function(response) {
$.notify({

View File

@@ -28,7 +28,7 @@ if (isset($error_message)) {
<?php if (!empty($customer_email)): ?>
<script type="text/javascript">
$(document).ready(function() {
var send_email = function() {
const send_email = function() {
$.get('<?= site_url() . esc("/sales/sendPdf/$sale_id_num/quote") ?>',
function(response) {
$.notify({

View File

@@ -21,7 +21,7 @@ if (isset($error_message)) {
<?php if (!empty($customer_email)): ?>
<script type="text/javascript">
$(document).ready(function() {
var send_email = function() {
const send_email = function() {
$.get('<?= site_url() . esc("/sales/sendPdf/$sale_id_num/receipt") ?>',
function(response) {
$.notify({

View File

@@ -585,8 +585,8 @@ helper('url');
});
$("input[name='item_number']").change(function() {
var item_id = $(this).parents('tr').find("input[name='item_id']").val();
var item_number = $(this).val();
const item_id = $(this).parents('tr').find("input[name='item_id']").val();
const item_number = $(this).val();
$.ajax({
url: "<?= site_url('sales/changeItemNumber') ?>",
method: 'post',
@@ -599,8 +599,8 @@ helper('url');
});
$("input[name='name']").change(function() {
var item_id = $(this).parents('tr').find("input[name='item_id']").val();
var item_name = $(this).val();
const item_id = $(this).parents('tr').find("input[name='item_id']").val();
const item_name = $(this).val();
$.ajax({
url: "<?= site_url('sales/changeItemName') ?>",
method: 'post',
@@ -613,8 +613,8 @@ helper('url');
});
$("input[name='item_description']").change(function() {
var item_id = $(this).parents('tr').find("input[name='item_id']").val();
var item_description = $(this).val();
const item_id = $(this).parents('tr').find("input[name='item_id']").val();
const item_description = $(this).val();
$.ajax({
url: "<?= site_url('sales/changeItemDescription') ?>",
method: 'post',
@@ -651,7 +651,7 @@ helper('url');
}
});
var clear_fields = function() {
const clear_fields = function() {
if ($(this).val().match("<?= lang(ucfirst($controller_name) . '.start_typing_item_name') . '|' . lang(ucfirst($controller_name) . '.start_typing_customer_name') ?>")) {
$(this).val('');
}
@@ -787,7 +787,7 @@ helper('url');
$('#customer').val(response.id);
$('#select_customer_form').submit();
} else {
var $stock_location = $("select[name='stock_location']").val();
const $stock_location = $("select[name='stock_location']").val();
$('#item_location').val($stock_location);
$('#item').val(response.id);
if (stay_open) {
@@ -804,14 +804,14 @@ helper('url');
});
$('[name="discount_toggle"]').change(function() {
var input = $('<input>').attr('type', 'hidden').attr('name', 'discount_type').val(($(this).prop('checked')) ? 1 : 0);
const input = $('<input>').attr('type', 'hidden').attr('name', 'discount_type').val(($(this).prop('checked')) ? 1 : 0);
$('#cart_' + $(this).attr('data-line')).append($(input));
$('#cart_' + $(this).attr('data-line')).submit();
});
});
function check_payment_type() {
var cash_mode = <?= json_encode($cash_mode) ?>;
const cash_mode = <?= json_encode($cash_mode) ?>;
if ($("#payment_types").val() == "<?= lang(ucfirst($controller_name) . '.giftcard') ?>") {
$("#sale_total").html("<?= to_currency($total) ?>");

View File

@@ -32,7 +32,7 @@ if (isset($error_message)) {
<?php if (!empty($customer_email)): ?>
<script type="text/javascript">
$(document).ready(function() {
var send_email = function() {
const send_email = function() {
$.get('<?= esc("/sales/sendPdf/$sale_id_num") ?>',
function(response) {
$.notify({

View File

@@ -30,7 +30,7 @@ if (isset($error_message)) {
<?php if (!empty($customer_email)): ?>
<script type="text/javascript">
$(document).ready(function() {
var send_email = function() {
const send_email = function() {
$.get('<?= esc("/sales/sendPdf/$sale_id_num/work_order") ?>',
function(response) {
$.notify({

View File

@@ -27,14 +27,14 @@
<?= form_close() ?>
<script type="text/javascript">
// Validation and submit handling
// Validation and submit Handling
$(document).ready(function() {
var tax_categories_count = <?= sizeof($tax_categories) ?>;
let tax_categories_count = <?= sizeof($tax_categories) ?>;
if (tax_categories_count == 0) {
tax_categories_count = 1;
}
var hide_show_remove_tax_category = function() {
const hide_show_remove_tax_category = function() {
if ($("input[name*='tax_category']:enabled").length > 1) {
$(".remove_tax_category").show();
} else {
@@ -42,15 +42,15 @@
}
};
var add_tax_category = function() {
var id = $(this).parent().find('input').attr('id');
const add_tax_category = function() {
let id = $(this).parent().find('input').attr('id');
id = id.replace(/.*?_(\d+)$/g, "$1");
var previous_tax_category_id = 'tax_category_' + id;
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
const previous_tax_category_id = 'tax_category_' + id;
const block = $(this).parent().clone(true);
const new_block = block.insertAfter($(this).parent());
++tax_categories_count;
var new_tax_category_id = 'tax_category_' + tax_categories_count;
const new_tax_category_id = 'tax_category_' + tax_categories_count;
$(new_block).find('label').html("<?= lang('Taxes.tax_category') ?> " + tax_categories_count).attr('for', new_tax_category_id).attr('class', 'control-label col-xs-2');
$(new_block).find("input[name='tax_category[]']").attr('id', new_tax_category_id).removeAttr('disabled').attr('class', 'form-control input-sm required').val('');
@@ -59,23 +59,23 @@
hide_show_remove_tax_category();
};
var remove_tax_category = function() {
const remove_tax_category = function() {
$(this).parent().remove();
hide_show_remove_tax_category();
};
var init_add_remove_tax_categories = function() {
const init_add_remove_tax_categories = function() {
$('.add_tax_category').click(add_tax_category);
$('.remove_tax_category').click(remove_tax_category);
hide_show_remove_tax_category();
};
init_add_remove_tax_categories();
var duplicate_found = false;
let duplicate_found = false;
// Run validator once for all fields
$.validator.addMethod("check4TaxCategoryDups", function(value, element) {
var value_count = 0;
let value_count = 0;
$('input[name="tax_category[]"]').each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});

View File

@@ -27,14 +27,14 @@
<?= form_close() ?>
<script type="text/javascript">
// Validation and submit handling
// Validation and submit Handling
$(document).ready(function() {
var tax_code_count = <?= sizeof($tax_codes) ?>;
let tax_code_count = <?= sizeof($tax_codes) ?>;
if (tax_code_count == 0) {
tax_code_count = 1;
}
var hide_show_remove_tax_code = function() {
const hide_show_remove_tax_code = function() {
if ($("input[name*='tax_code']:enabled").length > 1) {
$(".remove_tax_code").show();
} else {
@@ -42,14 +42,14 @@
}
};
var add_tax_code = function() {
var id = $(this).parent().find("input[name='tax_code[]']").attr('id');
const add_tax_code = function() {
let id = $(this).parent().find("input[name='tax_code[]']").attr('id');
id = id.replace(/.*?_(\d+)$/g, "$1");
var previous_tax_code_id = 'tax_code_' + id;
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
const previous_tax_code_id = 'tax_code_' + id;
const block = $(this).parent().clone(true);
const new_block = block.insertAfter($(this).parent());
++tax_code_count;
var new_tax_code_id = 'tax_code_' + tax_code_count;
const new_tax_code_id = 'tax_code_' + tax_code_count;
$(new_block).find('label').html("<?= lang('Taxes.tax_code') ?> " + tax_code_count).attr('for', new_tax_code_id).attr('class', 'control-label col-xs-2');
$(new_block).find("input[name='tax_code[]']").attr('id', new_tax_code_id).removeAttr('disabled').attr('class', 'form-control text-uppercase required input-sm').val('');
@@ -61,12 +61,12 @@
hide_show_remove_tax_code();
};
var remove_tax_code = function() {
const remove_tax_code = function() {
$(this).parent().remove();
hide_show_remove_tax_code();
};
var init_add_remove_tax_codes = function() {
const init_add_remove_tax_codes = function() {
$('.add_tax_code').click(add_tax_code);
$('.remove_tax_code').click(remove_tax_code);
hide_show_remove_tax_code();
@@ -75,7 +75,7 @@
// Run validator once for all fields
$.validator.addMethod('check4TaxCodeDups', function(value, element) {
var value_count = 0;
let value_count = 0;
$("input[name='tax_code[]']").each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});

View File

@@ -28,31 +28,31 @@
<?= form_close() ?>
<script type="text/javascript">
// Validation and submit handling
// Validation and submit Handling
$(document).ready(function() {
var tax_jurisdictions_count = <?= sizeof($tax_jurisdictions) ?>;
let tax_jurisdictions_count = <?= sizeof($tax_jurisdictions) ?>;
if (tax_jurisdictions_count == 0) {
tax_jurisdictions_count = 1;
}
var tax_type_options = '<?= esc($tax_type_options, 'js') ?>';
const tax_type_options = '<?= esc($tax_type_options, 'js') ?>';
var hide_show_remove_tax_jurisdiction = function() {
const hide_show_remove_tax_jurisdiction = function() {
if ($("input[name*='tax_jurisdiction']:enabled").length > 1) {
$(".remove_tax_jurisdiction").show();
} else {
$(".remove_tax_jurisdictions").hide();
$(".remove_tax_jurisdiction").hide();
}
};
var add_tax_jurisdiction = function() {
var id = $(this).parent().find('input').attr('id');
const add_tax_jurisdiction = function() {
let id = $(this).parent().find('input').attr('id');
id = id.replace(/.*?_(\d+)$/g, "$1");
var previous_jurisdiction_name_id = 'jurisdiction_name_' + id;
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
const previous_jurisdiction_name_id = 'jurisdiction_name_' + id;
const block = $(this).parent().clone(true);
const new_block = block.insertAfter($(this).parent());
++tax_jurisdictions_count;
var new_jurisdiction_name_id = 'jurisdiction_name_' + tax_jurisdictions_count;
const new_jurisdiction_name_id = 'jurisdiction_name_' + tax_jurisdictions_count;
$(new_block).find('label').html("<?= lang('Taxes.tax_jurisdiction') ?> " + tax_jurisdictions_count).attr('for', new_jurisdiction_name_id).attr('class', 'control-label col-xs-2');
$(new_block).find("input[name='jurisdiction_name[]']").attr('id', new_jurisdiction_name_id).removeAttr('disabled').attr('class', 'form-control required input-sm').val('');
@@ -65,12 +65,12 @@
hide_show_remove_tax_jurisdiction();
};
var remove_tax_jurisdiction = function() {
const remove_tax_jurisdiction = function() {
$(this).parent().remove();
hide_show_remove_tax_jurisdiction();
};
var init_add_remove_tax_jurisdiction = function() {
const init_add_remove_tax_jurisdiction = function() {
$('.add_tax_jurisdiction').click(add_tax_jurisdiction);
$('.remove_tax_jurisdiction').click(remove_tax_jurisdiction);
hide_show_remove_tax_jurisdiction();
@@ -79,7 +79,7 @@
// Run validator once for all fields
$.validator.addMethod('check4TaxJurisdictionDups', function(value, element) {
var value_count = 0;
let value_count = 0;
$("input[name='jurisdiction_name[]']").each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});

View File

@@ -20,8 +20,8 @@ import { Stream } from 'readable-stream'
const {finished, pipeline} = Stream.promises
var prod0js;
var prod1js;
let prod0js;
let prod1js;
// Clear and remove the resources folder
gulp.task('clean', function () {
@@ -102,7 +102,7 @@ gulp.task('copy-bootstrap', function() {
gulp.task('debug-js', function() {
var debugjs = gulp.src(['./node_modules/jquery/dist/jquery.js',
const debugjs = gulp.src(['./node_modules/jquery/dist/jquery.js',
'./node_modules/jquery-form/src/jquery.form.js',
'./node_modules/jquery-validation/dist/jquery.validate.js',
'./node_modules/jquery-ui-dist/jquery-ui.js',
@@ -141,9 +141,9 @@ gulp.task('debug-js', function() {
gulp.task('prod-js', function() {
var prod0js = gulp.src('./node_modules/jquery/dist/jquery.min.js').pipe(rev()).pipe(gulp.dest('public/resources'));
const prod0js = gulp.src('./node_modules/jquery/dist/jquery.min.js').pipe(rev()).pipe(gulp.dest('public/resources'));
var opensourcepos1js = gulp.src(['./node_modules/bootstrap/dist/js/bootstrap.min.js',
const opensourcepos1js = gulp.src(['./node_modules/bootstrap/dist/js/bootstrap.min.js',
'./node_modules/bootstrap-table/dist/bootstrap-table.min.js',
'./node_modules/moment/min/moment.min.js',
'./node_modules/jquery-ui-dist/jquery-ui.min.js',
@@ -174,13 +174,13 @@ gulp.task('prod-js', function() {
'./node_modules/chartist-plugin-barlabels/dist/chartist-plugin-barlabels.min.js',
'./node_modules/tableexport.jquery.plugin/tableExport.min.js'], { allowEmpty: true });
var opensourcepos2js = gulp.src(['./node_modules/bootstrap-daterangepicker/daterangepicker.js',
const opensourcepos2js = gulp.src(['./node_modules/bootstrap-daterangepicker/daterangepicker.js',
'./public/js/imgpreview.full.jquery.js',
'./public/js/manage_tables.js',
'./public/js/nominatim.autocomplete.js']).pipe(uglify());
var prod1js = series(opensourcepos1js, opensourcepos2js).pipe(concat('opensourcepos.min.js'))
const prod1js = series(opensourcepos1js, opensourcepos2js).pipe(concat('opensourcepos.min.js'))
.pipe(rev())
.pipe(gulp.dest('./public/resources/'));
@@ -194,21 +194,21 @@ gulp.task('prod-js', function() {
gulp.task('debug-login-js', function() {
// Match only core jQuery (jquery-HASH.js), exclude jquery plugins (jquery-HASH.form.js, etc) and jquery-ui (jquery-ui-HASH.js)
// Pattern: jquery-[hash].js where hash is alphanumeric - core jQuery only
var loginDebugJs = gulp.src(['./public/resources/js/jquery-*.js', '!./public/resources/js/jquery-*.form.js', '!./public/resources/js/jquery-*.validate.js', '!./public/resources/js/jquery-ui-*.js']);
const loginDebugJs = gulp.src(['./public/resources/js/jquery-*.js', '!./public/resources/js/jquery-*.form.js', '!./public/resources/js/jquery-*.validate.js', '!./public/resources/js/jquery-ui-*.js']);
return gulp.src('./app/Views/login.php').pipe(inject(loginDebugJs, {addRootSlash: false, ignorePath: '/public/', starttag: '<!-- inject:login:debug:js -->'})).pipe(gulp.dest('./app/Views'));
});
// Inject jQuery into login.php (production mode) - reuse the jQuery file already created by prod-js
gulp.task('prod-login-js', function() {
// jQuery prod file is already in resources/jquery-*.min.js from prod-js task
var loginProdJs = gulp.src('./public/resources/jquery-*.min.js');
const loginProdJs = gulp.src('./public/resources/jquery-*.min.js');
return gulp.src('./app/Views/login.php').pipe(inject(loginProdJs, {addRootSlash: false, ignorePath: '/public/', starttag: '<!-- inject:login:prod:js -->'})).pipe(gulp.dest('./app/Views'));
});
gulp.task('debug-css', function() {
var debugcss = gulp.src(['./node_modules/jquery-ui-dist/jquery-ui.css',
const debugcss = gulp.src(['./node_modules/jquery-ui-dist/jquery-ui.css',
'./node_modules/bootstrap3-dialog/dist/css/bootstrap-dialog.css',
'./node_modules/jasny-bootstrap/dist/css/jasny-bootstrap.css',
'./node_modules/bootstrap-datetime-picker/css/bootstrap-datetimepicker.css',
@@ -234,23 +234,23 @@ gulp.task('debug-css', function() {
gulp.task('prod-css', function() {
var opensourcepos1css = gulp.src(['./node_modules/jquery-ui-dist/jquery-ui.min.css',
const opensourcepos1css = gulp.src(['./node_modules/jquery-ui-dist/jquery-ui.min.css',
'./node_modules/bootstrap3-dialog/dist/css/bootstrap-dialog.min.css',
'./node_modules/jasny-bootstrap/dist/css/jasny-bootstrap.min.css',
'./node_modules/bootstrap-datetime-picker/css/bootstrap-datetimepicker.min.css']);
var opensourcepos2css = gulp.src(['./node_modules/bootstrap-daterangepicker/daterangepicker.css',
const opensourcepos2css = gulp.src(['./node_modules/bootstrap-daterangepicker/daterangepicker.css',
'./node_modules/bootstrap-tagsinput-2021/src/bootstrap-tagsinput.css']).pipe(cleanCSS({compatibility: 'ie8'}));
var opensourcepos3css = gulp.src(['./node_modules/bootstrap-select/dist/css/bootstrap-select.min.css',
const opensourcepos3css = gulp.src(['./node_modules/bootstrap-select/dist/css/bootstrap-select.min.css',
'./node_modules/bootstrap-table/dist/bootstrap-table.min.css',
'./node_modules/bootstrap-table/dist/extensions/sticky-header/bootstrap-table-sticky-header.min.css',
'./node_modules/bootstrap-toggle/css/bootstrap-toggle.min.css',
'./node_modules/chartist/dist/chartist.min.css']);
var opensourcepos4css = gulp.src('./node_modules/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.css').pipe(cleanCSS({compatibility: 'ie8'}));
const opensourcepos4css = gulp.src('./node_modules/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.css').pipe(cleanCSS({compatibility: 'ie8'}));
var opensourcepos5css = gulp.src(['./node_modules/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.css',
const opensourcepos5css = gulp.src(['./node_modules/chartist-plugin-tooltips/dist/chartist-plugin-tooltip.css',
'./public/css/bootstrap.autocomplete.css',
'./public/css/invoice.css',
'./public/css/ospos.css',
@@ -261,7 +261,7 @@ gulp.task('prod-css', function() {
'./public/css/reports.css'
]).pipe(cleanCSS({compatibility: 'ie8'}));
var prodcss = series(opensourcepos1css, opensourcepos2css, opensourcepos3css, opensourcepos4css, opensourcepos5css)
const prodcss = series(opensourcepos1css, opensourcepos2css, opensourcepos3css, opensourcepos4css, opensourcepos5css)
.pipe(concat('opensourcepos.min.css')).pipe(rev()).pipe(gulp.dest('public/resources'));

View File

@@ -1,16 +1,16 @@
(function(dialog_support, $) {
var btn_id, dialog_ref;
let btn_id, dialog_ref;
var hide = function() {
const hide = function() {
dialog_ref && dialog_ref.close();
};
var clicked_id = function() {
const clicked_id = function() {
return btn_id;
};
var submit = function(button_id) {
const submit = function(button_id) {
return function(dlog_ref) {
const form = $('form', dlog_ref.$modalBody).first();
const validator = form.data('validator');
@@ -27,31 +27,31 @@
}
};
var button_class = {
const button_class = {
'submit' : 'btn-primary',
'delete' : 'btn-danger'
};
var init = function(selector) {
const init = function(selector) {
var buttons = function(event) {
var buttons = [];
var dialog_class = 'modal-dlg';
const buttons = function(event) {
const buttons = [];
let dialog_class = 'modal-dlg';
$.each($(this).attr('class').split(/\s+/), function(classIndex, className) {
var width_class = className.split("modal-dlg-");
const width_class = className.split("modal-dlg-");
if (width_class && width_class.length > 1) {
dialog_class = className;
}
});
var has_new_btn = "btnNew" in $(this).data();
const has_new_btn = "btnNew" in $(this).data();
$.each($(this).data(), function(name, value) {
var btn_class = name.split("btn");
const btn_class = name.split("btn");
if (btn_class && btn_class.length > 1) {
var btn_name = btn_class[1].toLowerCase();
var is_submit = btn_name == 'submit';
var is_new = btn_name === 'new';
var is_enter = has_new_btn ? is_new: is_submit;
const btn_name = btn_class[1].toLowerCase();
const is_submit = btn_name == 'submit';
const is_new = btn_name === 'new';
const is_enter = has_new_btn ? is_new: is_submit;
buttons.push({
id: btn_name,
label: value,
@@ -78,12 +78,12 @@
$(selector).each(function(index, $element) {
return $(selector).off('click').on('click', function(event) {
var $link = $(event.target);
let $link = $(event.target);
$link = !$link.is("a, button") ? $link.parents("a, button") : $link ;
BootstrapDialog.show($.extend({
title: $link.attr('title'),
message: (function() {
var node = $('<div></div>');
const node = $('<div></div>');
$.get($link.attr('href') || $link.data('href'), function(data) {
node.html(data);
});
@@ -107,34 +107,34 @@
(function(table_support, $) {
var enable_actions = function(callback) {
let enable_actions = function(callback) {
return function() {
var selection_empty = selected_rows().length == 0;
const selection_empty = selected_rows().length == 0;
$("#toolbar button:not(.dropdown-toggle)").attr('disabled', selection_empty);
typeof callback == 'function' && callback();
}
};
var table = function() {
const table = function() {
return $("#table").data('bootstrap.table');
}
var selected_ids = function () {
const selected_ids = function () {
return $.map(table().getSelections(), function (element) {
return element[options.uniqueId || 'id'] !== '-' ? element[options.uniqueId || 'id'] : null;
});
};
var selected_rows = function () {
const selected_rows = function () {
return $("#table td input:checkbox:checked").parents("tr");
};
var row_selector = function(id) {
const row_selector = function(id) {
return "tr[data-uniqueid='" + id + "']";
};
var rows_selector = function(ids) {
var selectors = [];
const rows_selector = function(ids) {
const selectors = [];
ids = ids instanceof Array ? ids : ("" + ids).split(":");
$.each(ids, function(index, element) {
selectors.push(row_selector(element));
@@ -142,22 +142,22 @@
return selectors;;
};
var highlight_row = function (id, color) {
const highlight_row = function (id, color) {
$(rows_selector(id)).each(function(index, element) {
var original = $(element).css('backgroundColor');
const original = $(element).css('backgroundColor');
$(element).find("td").animate({backgroundColor: color || '#e1ffdd'}, "slow", "linear")
.animate({backgroundColor: color || '#e1ffdd'}, 5000)
.animate({backgroundColor: original}, "slow", "linear");
});
};
var do_action = function(action) {
const do_action = function(action) {
return function (url, ids) {
if (confirm($.fn.bootstrapTable.defaults.formatConfirmAction(action))) {
$.post((url || options.resource) + '/' + action, {'ids[]': ids || selected_ids()}, function (response) {
// Delete was successful, remove checkbox rows
if (response.success) {
var selector = ids ? row_selector(ids) : selected_rows();
const selector = ids ? row_selector(ids) : selected_rows();
table().collapseAllRows();
$(selector).each(function (index, element) {
$(this).find("td").animate({backgroundColor: "green"}, 1200, "linear")
@@ -183,7 +183,7 @@
};
};
var load_success = function(callback) {
let load_success = function(callback) {
return function(response) {
typeof options.load_callback == 'function' && options.load_callback();
options.load_callback = undefined;
@@ -192,18 +192,18 @@
}
};
var options;
let options;
var toggle_column_visibility = function() {
const toggle_column_visibility = function() {
if (localStorage[options.employee_id]) {
var user_settings = JSON.parse(localStorage[options.employee_id]);
const user_settings = JSON.parse(localStorage[options.employee_id]);
user_settings[options.resource] && $.each(user_settings[options.resource], function(index, element) {
element ? table().showColumn(index) : table().hideColumn(index);
});
}
};
var init = function (_options) {
const init = function (_options) {
options = _options;
enable_actions = enable_actions(options.enableActions);
load_success = load_success(options.onLoadSuccess);
@@ -244,7 +244,7 @@
enable_actions();
},
onColumnSwitch : function(field, checked) {
var user_settings = localStorage[options.employee_id];
let user_settings = localStorage[options.employee_id];
user_settings = (user_settings && JSON.parse(user_settings)) || {};
user_settings[options.resource] = user_settings[options.resource] || {};
user_settings[options.resource][field] = checked;
@@ -264,36 +264,36 @@
dialog_support.init("button.modal-dlg");
};
var init_delete = function (confirmMessage) {
const init_delete = function (confirmMessage) {
$("#delete").click(function(event) {
do_action("delete")();
});
};
var init_restore = function (confirmMessage) {
const init_restore = function (confirmMessage) {
$("#restore").click(function(event) {
do_action("restore")();
});
};
var refresh = function() {
const refresh = function() {
table().refresh();
}
var submit_handler = function(url) {
const submit_handler = function(url) {
return function (resource, response) {
var id = response.id !== undefined ? response.id.toString() : "";
const id = response.id !== undefined ? response.id.toString() : "";
if (!response.success) {
$.notify(response.message, { type: 'danger' });
} else {
var message = response.message;
var selector = rows_selector(response.id);
var rows = $(selector.join(",")).length;
const message = response.message;
const selector = rows_selector(response.id);
const rows = $(selector.join(",")).length;
if (rows > 0 && rows < 15) {
var ids = id.split(":");
const ids = id.split(":");
$.get([url || resource + '/row', id].join("/"), {}, function (response) {
$.each(selector, function (index, element) {
var id = $(element).data('uniqueid');
const id = $(element).data('uniqueid');
table().updateByUniqueId({id: id, row: response[id] || response});
});
dialog_support.init("a.modal-dlg");
@@ -313,7 +313,7 @@
};
};
var handle_submit = submit_handler();
const handle_submit = submit_handler();
$.extend(table_support, {
submit_handler: function(url) {
@@ -372,4 +372,4 @@ function number_sorter(a, b) {
a = +a.replace(/[^\-0-9]+/g, '');
b = +b.replace(/[^\-0-9]+/g, '');
return a - b;
}
}

View File

@@ -5,14 +5,14 @@
return document.location.protocol + '//' + url;
}
var url = http_s('nominatim.openstreetmap.org/search');
const url = http_s('nominatim.openstreetmap.org/search');
var handle_auto_completion = function(fields) {
const handle_auto_completion = function(fields) {
return function(event, ui) {
var results = ui.item.results;
const results = ui.item.results;
if (results != null && results.length > 0) {
// Handle auto completion
for(var i in fields) {
for(const i in fields) {
$("#" + fields[i]).val(results[i]);
}
return false;
@@ -21,11 +21,11 @@
};
};
var create_parser = function(field_name, parse_format)
const create_parser = function(field_name, parse_format)
{
var parse_field = function(format, address)
const parse_field = function(format, address)
{
var fields = [];
const fields = [];
$.each(format.split("|"), function(key, value)
{
if (address[value] && fields.length < 2 && $.inArray(address[value], fields) === -1)
@@ -38,11 +38,11 @@
return function(data)
{
var parsed = [];
const parsed = [];
$.each(data, function(index, value)
{
var row = [];
var address = value.address;
const row = [];
const address = value.address;
$.each(parse_format, function(key, format)
{
row.push(parse_field(format, address));
@@ -57,12 +57,12 @@
};
};
var init = function(options) {
const init = function(options) {
var default_params = function(id, key, language)
const default_params = function(id, key, language)
{
return function() {
var result = {
const result = {
format: 'json',
limit: 5,
addressdetails: 1,
@@ -75,8 +75,8 @@
};
var unique = function(parsed) {
var filtered = [];
const unique = function(parsed) {
let filtered = [];
$.each(parsed, function(index, element)
{
filtered = $.map(filtered, function(el, ind)
@@ -91,12 +91,12 @@
$.each(options.fields, function(key, value)
{
var handle_field_completion = handle_auto_completion(value.dependencies);
const handle_field_completion = handle_auto_completion(value.dependencies);
$("#" + key).autocomplete({
source: function (request, response) {
var params = default_params(key, value.response && value.response.field, options.language);
var request_params = {};
const params = default_params(key, value.response && value.response.field, options.language);
const request_params = {};
options.extra_params && $.each(options.extra_params, function(key, param) {
request_params[key] = typeof param == "function" ? param() : param;
});
@@ -122,7 +122,7 @@
});
};
var nominatim = {
const nominatim = {
init : init
@@ -130,4 +130,4 @@
window['nominatim'] = nominatim;
})(jQuery);
})(jQuery);