From 683ef75162624e7e65e72827ed149343ac5cc4e1 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Sat, 16 Jun 2018 21:05:15 +0100 Subject: [PATCH] Code refactoring --- application/views/configs/email_config.php | 22 +- application/views/configs/info_config.php | 6 +- application/views/configs/invoice_config.php | 2 +- application/views/configs/locale_config.php | 7 +- .../views/configs/mailchimp_config.php | 3 +- application/views/configs/tax_config.php | 308 ++++++++-------- application/views/customers/form.php | 21 +- .../views/customers/form_excel_import.php | 12 +- application/views/employees/form.php | 57 +-- application/views/expenses/form.php | 48 ++- .../views/expenses_categories/form.php | 34 +- application/views/giftcards/form.php | 57 ++- .../views/home/form_change_password.php | 11 +- application/views/item_kits/form.php | 331 +++++++++--------- application/views/items/form.php | 30 +- application/views/items/form_bulk.php | 37 +- application/views/items/form_excel_import.php | 10 +- application/views/items/form_inventory.php | 36 +- application/views/messages/form_sms.php | 30 +- application/views/partial/header_js.php | 8 +- application/views/receivings/form.php | 42 +-- application/views/sales/form.php | 43 ++- application/views/sales/register.php | 84 ++--- application/views/suppliers/form.php | 33 +- application/views/taxes/form.php | 217 ++++++------ 25 files changed, 745 insertions(+), 744 deletions(-) diff --git a/application/views/configs/email_config.php b/application/views/configs/email_config.php index a1519f4f8..a066e2466 100644 --- a/application/views/configs/email_config.php +++ b/application/views/configs/email_config.php @@ -116,29 +116,29 @@ $(document).ready(function() { var check_protocol = function() { - if($("#protocol").val() == 'sendmail') + if($('#protocol').val() == 'sendmail') { - $("#mailpath").prop('disabled', false); - $("#smtp_host, #smtp_user, #smtp_pass, #smtp_port, #smtp_timeout, #smtp_crypto").prop('disabled', true); + $('#mailpath').prop('disabled', false); + $('#smtp_host, #smtp_user, #smtp_pass, #smtp_port, #smtp_timeout, #smtp_crypto').prop('disabled', true); } - else if($("#protocol").val() == 'smtp') + else if($('#protocol').val() == 'smtp') { - $("#smtp_host, #smtp_user, #smtp_pass, #smtp_port, #smtp_timeout, #smtp_crypto").prop('disabled', false); - $("#mailpath").prop('disabled', true); + $('#smtp_host, #smtp_user, #smtp_pass, #smtp_port, #smtp_timeout, #smtp_crypto').prop('disabled', false); + $('#mailpath').prop('disabled', true); } else { - $("#mailpath, #smtp_host, #smtp_user, #smtp_pass, #smtp_port, #smtp_timeout, #smtp_crypto").prop('disabled', true); + $('#mailpath, #smtp_host, #smtp_user, #smtp_pass, #smtp_port, #smtp_timeout, #smtp_crypto').prop('disabled', true); } }; - $("#protocol").change(check_protocol).ready(check_protocol); + $('#protocol').change(check_protocol).ready(check_protocol); $('#email_config_form').validate($.extend(form_support.handler, { submitHandler: function(form) { $(form).ajaxSubmit({ beforeSerialize: function(arr, $form, options) { - $("#mailpath, #smtp_host, #smtp_user, #smtp_pass, #smtp_port, #smtp_timeout, #smtp_crypto").prop("disabled", false); + $('#mailpath, #smtp_host, #smtp_user, #smtp_pass, #smtp_port, #smtp_timeout, #smtp_crypto').prop('disabled', false); return true; }, success: function(response) { @@ -146,11 +146,11 @@ $(document).ready(function() // set back disabled state check_protocol(); }, - dataType:'json' + dataType: 'json' }); }, - errorLabelContainer: "#email_error_message_box" + errorLabelContainer: '#email_error_message_box' })); }); diff --git a/application/views/configs/info_config.php b/application/views/configs/info_config.php index 6b42fc667..016f14872 100644 --- a/application/views/configs/info_config.php +++ b/application/views/configs/info_config.php @@ -134,9 +134,9 @@ $(document).ready(function() { $("a.fileinput-exists").click(function() { $.ajax({ - type: "GET", - url: "", - dataType: "json" + type: 'GET', + url: '', + dataType: 'json' }) }); diff --git a/application/views/configs/invoice_config.php b/application/views/configs/invoice_config.php index 04ea971b6..3d719e217 100644 --- a/application/views/configs/invoice_config.php +++ b/application/views/configs/invoice_config.php @@ -207,7 +207,7 @@ $(document).ready(function() enable_disable_invoice_enable(); enable_disable_work_order_enable(); }, - dataType:'json' + dataType: 'json' }); } })); diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index 1e98d6829..a01bf07eb 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -243,7 +243,6 @@ $(document).ready(function() }); $('#locale_config_form').validate($.extend(form_support.handler, { - rules: { number_locale: @@ -271,12 +270,12 @@ $(document).ready(function() messages: { number_locale: { - required: 'lang->line('config_number_locale_required') ?>', - number_locale: 'lang->line('config_number_locale_invalid') ?>' + required: "lang->line('config_number_locale_required') ?>", + number_locale: "lang->line('config_number_locale_invalid') ?>" } }, - errorLabelContainer: "#locale_error_message_box" + errorLabelContainer: '#locale_error_message_box' })); }); diff --git a/application/views/configs/mailchimp_config.php b/application/views/configs/mailchimp_config.php index 6be5ebd6d..e7e1fdf08 100644 --- a/application/views/configs/mailchimp_config.php +++ b/application/views/configs/mailchimp_config.php @@ -60,7 +60,8 @@ $(document).ready(function() $('#mailchimp_list_id').append(new Option(text, val)); }); $('#mailchimp_list_id').prop('selectedIndex', 0); - }, 'json' + }, + 'json' ); }); diff --git a/application/views/configs/tax_config.php b/application/views/configs/tax_config.php index 86250aad1..39f87bf64 100644 --- a/application/views/configs/tax_config.php +++ b/application/views/configs/tax_config.php @@ -1,113 +1,113 @@ 'tax_config_form', 'class' => 'form-horizontal')); ?> -
-
-
lang->line('common_fields_required_message'); ?>
-
    +
    +
    +
    lang->line('common_fields_required_message'); ?>
    +
      -
      +
      lang->line('config_tax_included'), 'tax_included', array('class' => 'control-label col-xs-2')); ?> -
      +
      'tax_included', 'id' => 'tax_included', 'value' => 'tax_included', 'checked'=>$this->config->item('tax_included'))); ?> -
      -
      +
      +
      -
      +
      lang->line('config_default_tax_rate_1'), 'default_tax_1_rate', array('class' => 'control-label col-xs-2')); ?> -
      +
      'default_tax_1_name', 'id' => 'default_tax_1_name', 'class' => 'form-control input-sm', 'value'=>$this->config->item('default_tax_1_name')!==FALSE ? $this->config->item('default_tax_1_name') : $this->lang->line('items_sales_tax_1'))); ?> -
      -
      +
      +
      'default_tax_1_rate', 'id' => 'default_tax_1_rate', 'class' => 'form-control input-sm', 'value'=> to_tax_decimals($this->config->item('default_tax_1_rate')))); ?> - % -
      -
      + % +
      +
      -
      +
      lang->line('config_default_tax_rate_2'), 'default_tax_2_rate', array('class' => 'control-label col-xs-2')); ?> -
      +
      'default_tax_2_name', 'id' => 'default_tax_2_name', 'class' => 'form-control input-sm', 'value'=>$this->config->item('default_tax_2_name')!==FALSE ? $this->config->item('default_tax_2_name') : $this->lang->line('items_sales_tax_2'))); ?> -
      -
      +
      +
      'default_tax_2_rate', 'id' => 'default_tax_2_rate', 'class' => 'form-control input-sm', 'value'=> to_tax_decimals($this->config->item('default_tax_2_rate')))); ?> - % -
      -
      + % +
      +
      -
      +
      lang->line('config_customer_sales_tax_support'), 'customer_sales_tax_support', array('class' => 'control-label col-xs-2')); ?> -
      +
      'customer_sales_tax_support', 'id' => 'customer_sales_tax_support', 'value' => 'customer_sales_tax_support', 'checked'=>$this->config->item('customer_sales_tax_support'))); ?> -
      -
      +
      +
      -
      +
      lang->line('config_default_origin_tax_code'), 'default_origin_tax_code', array('class' => 'control-label col-xs-2')); ?> -
      +
      config->item('default_origin_tax_code'), array('class' => 'form-control input-sm')); ?> -
      -
      +
      +
      -
      +
      load->view('partial/tax_categories', array('tax_categories' => $tax_categories)); ?>
      - - 'submit_tax', - 'id' => 'submit_tax', - 'value' => $this->lang->line('common_submit'), - 'class' => 'btn btn-primary btn-sm pull-right')); ?> -
      -
      + + 'submit_tax', + 'id' => 'submit_tax', + 'value' => $this->lang->line('common_submit'), + 'class' => 'btn btn-primary btn-sm pull-right')); ?> +
      +
      diff --git a/application/views/customers/form.php b/application/views/customers/form.php index 43c3a1e3b..13600af9c 100644 --- a/application/views/customers/form.php +++ b/application/views/customers/form.php @@ -416,7 +416,7 @@ $(document).ready(function() { $("input[name='sales_tax_code_name']").change(function() { if( ! $("input[name='sales_tax_code_name']").val() ) { - $("input[name='sales_tax_code']").val(''); + $("input[name='sales_tax_code']").val(''); } }); @@ -426,8 +426,8 @@ $(document).ready(function() $("input[name='sales_tax_code_name']").val(ui.item.label); }; - $("#sales_tax_code_name").autocomplete({ - source: '', + $('#sales_tax_code_name').autocomplete({ + source: "", minChars: 0, delay: 15, cacheLength: 1, @@ -437,18 +437,19 @@ $(document).ready(function() }); $('#customer_form').validate($.extend({ - submitHandler: function(form) - { + submitHandler: function(form) { $(form).ajaxSubmit({ success: function(response) { dialog_support.hide(); - table_support.handle_submit('', response); + table_support.handle_submit("", response); }, dataType: 'json' }); }, + errorLabelContainer: '#error_message_box', + rules: { first_name: 'required', @@ -458,10 +459,10 @@ $(document).ready(function() { remote: { - url: "", + url: "", type: 'POST', data: { - 'person_id': 'person_id; ?>' + 'person_id': "person_id; ?>" // email is posted by default } } @@ -470,10 +471,10 @@ $(document).ready(function() { remote: { - url: "", + url: "", type: 'POST', data: { - 'person_id': 'person_id; ?>' + 'person_id': "person_id; ?>" // account_number is posted by default } } diff --git a/application/views/customers/form_excel_import.php b/application/views/customers/form_excel_import.php index 5cdad9b6a..7de76791b 100644 --- a/application/views/customers/form_excel_import.php +++ b/application/views/customers/form_excel_import.php @@ -25,9 +25,9 @@ $(document).ready(function() { $('#excel_form').validate($.extend({ - submitHandler:function(form) { + submitHandler: function(form) { $(form).ajaxSubmit({ - success:function(response) + success: function(response) { dialog_support.hide(); $.notify(response.message, { type: response.success ? 'success' : 'danger'} ); @@ -35,12 +35,14 @@ $(document).ready(function() dataType: 'json' }); }, - errorLabelContainer: "#error_message_box", - wrapper: "li", + + errorLabelContainer: '#error_message_box', + rules: { - file_path: "required" + file_path: 'required' }, + messages: { file_path: "lang->line('common_import_full_path'); ?>" diff --git a/application/views/employees/form.php b/application/views/employees/form.php index d7872f747..9a00fc5cf 100644 --- a/application/views/employees/form.php +++ b/application/views/employees/form.php @@ -157,67 +157,68 @@ $(document).ready(function() { $.validator.setDefaults({ ignore: [] }); - $.validator.addMethod("module", function (value, element) { - var result = $("#permission_list input").is(":checked"); - $(".module").each(function(index, element) + $.validator.addMethod('module', function (value, element) { + var result = $('#permission_list input').is(':checked'); + $('.module').each(function(index, element) { var parent = $(element).parent(); - var checked = $(element).is(":checked"); - if ($("ul", parent).length > 0 && result) + var checked = $(element).is(':checked'); + if($('ul', parent).length > 0 && result) { - result &= !checked || (checked && $("ul > li > input:checked", parent).length > 0); + result &= !checked || (checked && $('ul > li > input:checked', parent).length > 0); } }); return result; - }, 'lang->line('employees_subpermission_required'); ?>'); + }, "lang->line('employees_subpermission_required'); ?>"); - $("ul#permission_list > li > input.module").each(function() + $('ul#permission_list > li > input.module').each(function() { var $this = $(this); - $("ul > li > input,select", $this.parent()).each(function() + $('ul > li > input,select', $this.parent()).each(function() { var $that = $(this); var updateInputs = function (checked) { - $that.prop("disabled", !checked); - !checked && $that.prop("checked", false); + $that.prop('disabled', !checked); + !checked && $that.prop('checked', false); } $this.change(function() { - updateInputs($this.is(":checked")); + updateInputs($this.is(':checked')); }); - updateInputs($this.is(":checked")); + updateInputs($this.is(':checked')); }); }); $('#employee_form').validate($.extend({ - submitHandler:function(form) - { + submitHandler: function(form) { $(form).ajaxSubmit({ - success:function(response) + success: function(response) { dialog_support.hide(); - table_support.handle_submit('', response); + table_support.handle_submit("", response); }, - dataType:'json' + dataType: 'json' }); }, + + errorLabelContainer: '#error_message_box', + rules: { - first_name: "required", - last_name: "required", + first_name: 'required', + last_name: 'required', username: { - required:true, + required: true, minlength: 5 }, - password: { person_id == "") + if($person_info->person_id == '') { ?> - required:true, + required: true, @@ -225,10 +226,11 @@ $(document).ready(function() }, repeat_password: { - equalTo: "#password" + equalTo: '#password' }, - email: "email" + email: 'email' }, + messages: { first_name: "lang->line('common_first_name_required'); ?>", @@ -238,14 +240,13 @@ $(document).ready(function() required: "lang->line('employees_username_required'); ?>", minlength: "lang->line('employees_username_minlength'); ?>" }, - password: { person_id == "") { ?> - required:"lang->line('employees_password_required'); ?>", + required: "lang->line('employees_password_required'); ?>", diff --git a/application/views/expenses/form.php b/application/views/expenses/form.php index 248f9e871..0bf070e57 100644 --- a/application/views/expenses/form.php +++ b/application/views/expenses/form.php @@ -172,22 +172,9 @@ $(document).ready(function() todayBtn: true, todayHighlight: true, bootcssVer: 3, - language: '' + language: "" }); - var submit_form = function() - { - $(this).ajaxSubmit( - { - success: function(response) - { - dialog_support.hide(); - table_support.handle_submit('', response); - }, - dataType: 'json' - }); - }; - var amount_validator = function(field) { return { url: "", @@ -200,12 +187,20 @@ $(document).ready(function() } } - $('#expenses_edit_form').validate($.extend( - { - submitHandler: function(form) - { - submit_form.call(form); + $('#expenses_edit_form').validate($.extend({ + submitHandler: function(form) { + $(form).ajaxSubmit({ + success: function(response) + { + dialog_support.hide(); + table_support.handle_submit("", response); + }, + dataType: 'json' + }); }, + + errorLabelContainer: '#error_message_box', + rules: { category: 'required', @@ -216,29 +211,30 @@ $(document).ready(function() amount: { required: true, - remote: amount_validator("#amount") + remote: amount_validator('#amount') }, tax_amount: { - remote: amount_validator("#tax_amount") + remote: amount_validator('#tax_amount') } }, + messages: { - category: 'lang->line('expenses_category_required'); ?>', + category: "lang->line('expenses_category_required'); ?>", date: { - required: 'lang->line('expenses_date_required'); ?>' + required: "lang->line('expenses_date_required'); ?>" }, amount: { - required: 'lang->line('expenses_amount_required'); ?>', - remote: 'lang->line('expenses_amount_number'); ?>' + required: "lang->line('expenses_amount_required'); ?>", + remote: "lang->line('expenses_amount_number'); ?>" }, tax_amount: { - remote: 'lang->line('expenses_tax_amount_number'); ?>' + remote: "lang->line('expenses_tax_amount_number'); ?>" } } }, form_support.error)); diff --git a/application/views/expenses_categories/form.php b/application/views/expenses_categories/form.php index e9a777938..21997b94f 100644 --- a/application/views/expenses_categories/form.php +++ b/application/views/expenses_categories/form.php @@ -35,32 +35,28 @@ //validation and submit handling $(document).ready(function() { - var submit_form = function() - { - $(this).ajaxSubmit( - { - success: function(response) - { - dialog_support.hide(); - table_support.handle_submit('', response); - }, - dataType: 'json' - }); - }; - - $('#expense_category_edit_form').validate($.extend( - { - submitHandler: function(form) - { - submit_form.call(form); + $('#expense_category_edit_form').validate($.extend({ + submitHandler: function(form) { + $(form).ajaxSubmit({ + success: function(response) + { + dialog_support.hide(); + table_support.handle_submit("", response); + }, + dataType: 'json' + }); }, + + errorLabelContainer: '#error_message_box', + rules: { category_name: 'required' }, + messages: { - category_name: 'lang->line('category_name_required'); ?>' + category_name: "lang->line('category_name_required'); ?>" } }, form_support.error)); }); diff --git a/application/views/giftcards/form.php b/application/views/giftcards/form.php index dc9091918..22285ea3a 100644 --- a/application/views/giftcards/form.php +++ b/application/views/giftcards/form.php @@ -72,8 +72,8 @@ $(document).ready(function() $("input[name='person_name']").val(ui.item.label); }; - var autocompleter = $('#person_name').autocomplete({ - source: '', + $('#person_name').autocomplete({ + source: "", minChars: 0, delay: 15, cacheLength: 1, @@ -81,33 +81,29 @@ $(document).ready(function() select: fill_value, focus: fill_value }); - - // declare submitHandler as an object.. will be reused - var submit_form = function() { - $(this).ajaxSubmit({ - success: function(response) - { - dialog_support.hide(); - table_support.handle_submit('', response); - }, - error: function(jqXHR, textStatus, errorThrown) - { - table_support.handle_submit('', {message: errorThrown}); - }, - dataType: 'json' - }); - }; - $('#giftcard_form').validate($.extend(form_support.handler, - { - submitHandler:function(form) - { - submit_form.call(form) + $('#giftcard_form').validate($.extend({ + submitHandler: function(form) { + $(form).ajaxSubmit({ + success: function(response) + { + dialog_support.hide(); + table_support.handle_submit("", response); + }, + error: function(jqXHR, textStatus, errorThrown) + { + table_support.handle_submit("", {message: errorThrown}); + }, + dataType: 'json' + }); }, + + errorLabelContainer: '#error_message_box', + rules: { config->item('giftcard_number') == "series") + if($this->config->item('giftcard_number') == 'series') { ?> giftcard_number: @@ -136,17 +132,18 @@ $(document).ready(function() } } }, + messages: { config->item('giftcard_number') == "series") + if($this->config->item('giftcard_number') == 'series') { ?> - giftcard_number: - { - required: "lang->line('giftcards_number_required'); ?>", - number: "lang->line('giftcards_number'); ?>" - }, + giftcard_number: + { + required: "lang->line('giftcards_number_required'); ?>", + number: "lang->line('giftcards_number'); ?>" + }, diff --git a/application/views/home/form_change_password.php b/application/views/home/form_change_password.php index 44d51bc04..3602a1b74 100644 --- a/application/views/home/form_change_password.php +++ b/application/views/home/form_change_password.php @@ -81,17 +81,17 @@ $(document).ready(function() }, 'lang->line('employees_password_not_must_match'); ?>'); $('#employee_form').validate($.extend({ - submitHandler:function(form) - { + submitHandler: function(form) { $(form).ajaxSubmit({ - success:function(response) + success: function(response) { dialog_support.hide(); - $.notify(response.message, { type: response.success ? 'success' : 'danger'} ); + $.notify(response.message, {type: response.success ? 'success' : 'danger'}); }, - dataType:'json' + dataType: 'json' }); }, + rules: { current_password: @@ -110,6 +110,7 @@ $(document).ready(function() equalTo: "#password" } }, + messages: { password: diff --git a/application/views/item_kits/form.php b/application/views/item_kits/form.php index 9baebb5a4..a9289e2e9 100644 --- a/application/views/item_kits/form.php +++ b/application/views/item_kits/form.php @@ -16,107 +16,107 @@ -
      - lang->line('item_kits_find_kit_item'), 'item_name', array('class'=>'control-label col-xs-3')); ?> -
      -
      - 'item_name', - 'id'=>'item_name', - 'class'=>'form-control input-sm', - 'size'=>'50', - 'value'=>$selected_kit_item) - ); ?> - +
      + lang->line('item_kits_find_kit_item'), 'item_name', array('class'=>'control-label col-xs-3')); ?> +
      +
      + 'item_name', + 'id'=>'item_name', + 'class'=>'form-control input-sm', + 'size'=>'50', + 'value'=>$selected_kit_item) + ); ?> + -
      -
      -
      +
      +
      +
      -
      - lang->line('item_kits_discount_percent'), 'kit_discount_percent', array('class' => 'control-label col-xs-3')); ?> -
      -
      - 'kit_discount_percent', - 'size'=>'5', - 'maxlength'=>'5', - 'id'=>'kit_discount_percent', - 'class'=>'form-control input-sm', - 'value'=>$item_kit_info->kit_discount_percent) - );?> - % -
      -
      -
      +
      + lang->line('item_kits_discount_percent'), 'kit_discount_percent', array('class' => 'control-label col-xs-3')); ?> +
      +
      + 'kit_discount_percent', + 'size'=>'5', + 'maxlength'=>'5', + 'id'=>'kit_discount_percent', + 'class'=>'form-control input-sm', + 'value'=>$item_kit_info->kit_discount_percent) + );?> + % +
      +
      +
      -
      - lang->line('item_kits_price_option'), 'price_option', !empty($basic_version) ? array('class'=>'required control-label col-xs-3') : array('class'=>'control-label col-xs-3')); ?> -
      - - - +
      + lang->line('item_kits_price_option'), 'price_option', !empty($basic_version) ? array('class'=>'required control-label col-xs-3') : array('class'=>'control-label col-xs-3')); ?> +
      + + + -
      -
      +
      +
      -
      - lang->line('item_kits_print_option'), 'print_option', !empty($basic_version) ? array('class'=>'required control-label col-xs-3') : array('class'=>'control-label col-xs-3')); ?> -
      - - - +
      + lang->line('item_kits_print_option'), 'print_option', !empty($basic_version) ? array('class'=>'required control-label col-xs-3') : array('class'=>'control-label col-xs-3')); ?> +
      + + + -
      -
      +
      +
      @@ -146,7 +146,7 @@ lang->line('common_delete'); ?> - lang->line('item_kits_sequence'); ?> + lang->line('item_kits_sequence'); ?> lang->line('item_kits_item'); ?> lang->line('item_kits_quantity'); ?> @@ -158,9 +158,9 @@ ?> - ' name=item_kit_seq[] value=''/> + " name=item_kit_seq[] value=""/> - ' name=item_kit_qty[] value=''/> + " name=item_kit_qty[] value=""/> ", + minChars:0, + autoFocus: false, + delay:10, + appendTo: ".modal-content", + select: function(e, ui) { + if ($("#item_kit_item_" + ui.item.value).length == 1) + { + $("#item_kit_item_" + ui.item.value).val(parseFloat( $("#item_kit_item_" + ui.item.value).val()) + 1); + } + else + { + $("#item_kit_items").append("" + + "" + + "" + + "" + ui.item.label + "" + + "" + + ""); + } + $("#item").val(""); + return false; + } + }); - $("#item").autocomplete({ - source: '', - minChars:0, - autoFocus: false, - delay:10, - appendTo: ".modal-content", - select: function(e, ui) { - if ($("#item_kit_item_" + ui.item.value).length == 1) - { - $("#item_kit_item_" + ui.item.value).val(parseFloat( $("#item_kit_item_" + ui.item.value).val()) + 1); - } - else - { - $("#item_kit_items").append("" + - "" + - "" + - "" + ui.item.label + "" + - "" + - ""); - } - $("#item").val(""); - return false; - } - }); + $("input[name='item_name']").change(function() { + if( ! $("input[name='item_name']").val() ) { + $("input[name='kit_item_id']").val(''); + } + }); - $("input[name='item_name']").change(function() { - if( ! $("input[name='item_name']").val() ) { - $("input[name='kit_item_id']").val(''); - } - }); - - var fill_value = function(event, ui) { - event.preventDefault(); - $("input[name='kit_item_id']").val(ui.item.value); - $("input[name='item_name']").val(ui.item.label); - }; + var fill_value = function(event, ui) { + event.preventDefault(); + $("input[name='kit_item_id']").val(ui.item.value); + $("input[name='item_name']").val(ui.item.label); + }; - $("#item_name").autocomplete({ - source: '', - minChars: 0, - delay: 15, - cacheLength: 1, - appendTo: '.modal-content', - select: fill_value, - focus: fill_value - }); + $('#item_name').autocomplete({ + source: "", + minChars: 0, + delay: 15, + cacheLength: 1, + appendTo: '.modal-content', + select: fill_value, + focus: fill_value + }); - $('#item_kit_form').validate($.extend({ - submitHandler:function(form) - { - $(form).ajaxSubmit({ - success:function(response) - { - dialog_support.hide(); - table_support.handle_submit('', response); - }, - dataType:'json' - }); - }, + $('#item_kit_form').validate($.extend({ + submitHandler: function(form) { + $(form).ajaxSubmit({ + success: function(response) + { + dialog_support.hide(); + table_support.handle_submit("", response); + }, + dataType: 'json' + }); + }, - rules: - { - name:"required", - category:"required" - }, + errorLabelContainer: '#error_message_box', - messages: - { - name:"lang->line('items_name_required'); ?>", - category:"lang->line('items_category_required'); ?>" - } - }, form_support.error)); + rules: + { + name: 'required', + category: 'required' + }, + + messages: + { + name: "lang->line('items_name_required'); ?>", + category: "lang->line('items_category_required'); ?>" + } + }, form_support.error)); }); function delete_item_kit_row(link) @@ -257,5 +257,4 @@ function delete_item_kit_row(link) $(link).parent().parent().remove(); return false; } - diff --git a/application/views/items/form.php b/application/views/items/form.php index 551b91ce9..a78aca067 100644 --- a/application/views/items/form.php +++ b/application/views/items/form.php @@ -372,26 +372,30 @@ //validation and submit handling $(document).ready(function() { - $("#new").click(function() { + $('#new').click(function() { stay_open = true; - $("#item_form").submit(); + $('#item_form').submit(); }); - $("#submit").click(function() { + $('#submit').click(function() { stay_open = false; }); var no_op = function(event, data, formatted){}; - $("#category").autocomplete({source: "", delay:10, appendTo: '.modal-content'}); + $('#category').autocomplete({ + source: "", + appendTo: '.modal-content', + delay: 10 + }); - $("#custom" + ).autocomplete({ + $('#custom' + ).autocomplete({ source:function (request, response) { $.ajax({ type: 'POST', - url: "", + url: "", dataType: 'json', data: $.extend(request, {field_no: }), success: function(data) { @@ -409,10 +413,10 @@ $(document).ready(function() } ?> - $("a.fileinput-exists").click(function() { + $('a.fileinput-exists').click(function() { $.ajax({ type: 'GET', - url: "item_id"); ?>", + url: "item_id); ?>", dataType: 'json' }) }); @@ -425,7 +429,7 @@ $(document).ready(function() if (stay_open) { // set action of item_form to url without item id, so a new one can be created - $("#item_form").attr("action", ""); + $('#item_form').attr('action', ""); // use a whitelist of fields to minimize unintended side effects $(':text, :password, :file, #description, #item_form').not('.quantity, #reorder_level, #tax_name_1,' + '#tax_percent_name_1, #reference_number, #name, #cost_price, #unit_price, #taxed_cost_price, #taxed_unit_price').val(''); @@ -436,16 +440,18 @@ $(document).ready(function() { dialog_support.hide(); } - table_support.handle_submit('', response, stay_open); + table_support.handle_submit("", response, stay_open); }, dataType: 'json' }); }, + errorLabelContainer: '#error_message_box', + rules: { - name: "required", - category: "required", + name: 'required', + category: 'required', item_number: { required: false, diff --git a/application/views/items/form_bulk.php b/application/views/items/form_bulk.php index 228eeeade..43bd99f10 100644 --- a/application/views/items/form_bulk.php +++ b/application/views/items/form_bulk.php @@ -162,53 +162,60 @@ //validation and submit handling $(document).ready(function() { - $("#category").autocomplete({source: "", appendTo:'.modal-content', delay:10}); + $('#category').autocomplete({ + source: "", + appendTo: '.modal-content', + delay: 10 + }); var 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()); - $("#tax_percent_name_2, #tax_name_2").prop('disabled', disabled); - confirm_message = disabled ? "" : "lang->line('items_confirm_bulk_edit_wipe_taxes') ?>"; + $('#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()); + $('#tax_percent_name_2, #tax_name_2').prop('disabled', disabled); + confirm_message = disabled ? '' : "lang->line('items_confirm_bulk_edit_wipe_taxes') ?>"; }); $('#item_form').validate($.extend({ - submitHandler:function(form) - { + 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) + success: function(response) { dialog_support.hide(); - table_support.handle_submit('', response); + table_support.handle_submit("", response); }, - dataType:'json' + dataType: 'json' }); } }, + + errorLabelContainer: '#error_message_box', + rules: { unit_price: { - number:true + number: true }, tax_percent: { - number:true + number: true }, quantity: { - number:true + number: true }, reorder_level: { - number:true + number: true } }, + messages: { unit_price: diff --git a/application/views/items/form_excel_import.php b/application/views/items/form_excel_import.php index 32e03fa34..229b414b9 100644 --- a/application/views/items/form_excel_import.php +++ b/application/views/items/form_excel_import.php @@ -25,7 +25,7 @@ $(document).ready(function() { $('#excel_form').validate($.extend({ - submitHandler:function(form) { + submitHandler: function(form) { $(form).ajaxSubmit({ success:function(response) { @@ -35,12 +35,14 @@ $(document).ready(function() dataType: 'json' }); }, - errorLabelContainer: "#error_message_box", - wrapper: "li", + + errorLabelContainer: '#error_message_box', + rules: { - file_path: "required" + file_path: 'required' }, + messages: { file_path: "lang->line('common_import_full_path'); ?>" diff --git a/application/views/items/form_inventory.php b/application/views/items/form_inventory.php index 61172bc16..417ae19fa 100644 --- a/application/views/items/form_inventory.php +++ b/application/views/items/form_inventory.php @@ -97,29 +97,29 @@ //validation and submit handling $(document).ready(function() { - $('#item_form').validate({ - submitHandler:function(form) - { + $('#item_form').validate($.extend({ + submitHandler: function(form) { $(form).ajaxSubmit({ - success:function(response) - { - dialog_support.hide(); - table_support.handle_submit('', response); - }, - dataType: 'json' - }); - + success: function(response) + { + dialog_support.hide(); + table_support.handle_submit("", response); + }, + dataType: 'json' + }); }, - errorLabelContainer: "#error_message_box", - wrapper: "li", + + errorLabelContainer: '#error_message_box', + rules: { newquantity: { - required:true, - number:true + required: true, + number: true } }, + messages: { newquantity: @@ -128,12 +128,12 @@ $(document).ready(function() number: "lang->line('items_quantity_number'); ?>" } } - }); + }, form_support.error)); }); function fill_quantity(val) { - var item_quantities = ; - document.getElementById("quantity").value = parseFloat(item_quantities[val]).toFixed(); + var item_quantities = ; + document.getElementById('quantity').value = parseFloat(item_quantities[val]).toFixed(); } diff --git a/application/views/messages/form_sms.php b/application/views/messages/form_sms.php index 43615414d..653d0c400 100644 --- a/application/views/messages/form_sms.php +++ b/application/views/messages/form_sms.php @@ -35,45 +35,49 @@ \ No newline at end of file + diff --git a/application/views/partial/header_js.php b/application/views/partial/header_js.php index b075c2fa5..300c10b31 100644 --- a/application/views/partial/header_js.php +++ b/application/views/partial/header_js.php @@ -12,12 +12,12 @@ } $.notifyDefaults({ placement: { - align: 'config->item('notify_horizontal_position'); ?>', - from: 'config->item('notify_vertical_position'); ?>' + align: "config->item('notify_horizontal_position'); ?>", + from: "config->item('notify_vertical_position'); ?>" }}); var csrf_token = function() { - return Cookies.get('config->item('csrf_cookie_name'); ?>'); + return Cookies.get("config->item('csrf_cookie_name'); ?>"); }; var csrf_form_base = function() { @@ -27,7 +27,7 @@ var ajax = $.ajax; $.ajax = function() { - var args = arguments[0]; + var args = arguments[0]; if (args['type'] && args['type'].toLowerCase() == 'post' && csrf_token()) { if (typeof args['data'] === 'string') diff --git a/application/views/receivings/form.php b/application/views/receivings/form.php index 96bac4713..6c10ab591 100755 --- a/application/views/receivings/form.php +++ b/application/views/receivings/form.php @@ -80,51 +80,39 @@ $(document).ready(function() language: "" }); - var fill_value = function(event, ui) - { + var fill_value = function(event, ui) { event.preventDefault(); $("input[name='supplier_id']").val(ui.item.value); $("input[name='supplier_name']").val(ui.item.label); }; - var autocompleter = $("#supplier_name").autocomplete( - { - source: '', + $('#supplier_name').autocomplete({ + source: "", minChars: 0, delay: 15, cacheLength: 1, appendTo: '.modal-content', select: fill_value, focus: fill_value - }); + }); $('button#delete').click(function() { dialog_support.hide(); - table_support.do_delete('', ); + table_support.do_delete("", ); }); - // declare submitHandler as an object.. will be reused - var submit_form = function() - { - $(this).ajaxSubmit( - { - success:function(response) - { - dialog_support.hide(); - table_support.handle_submit('', response); - }, - dataType:'json' - }); - }; - - $('#receivings_edit_form').validate($.extend( - { - submitHandler : function(form) - { - submit_form.call(form); + $('#receivings_edit_form').validate($.extend({ + submitHandler: function(form) { + $(form).ajaxSubmit({ + success: function(response) + { + dialog_support.hide(); + table_support.handle_submit("", response); + }, + dataType: 'json' + }); } }, form_support.error)); - }); diff --git a/application/views/sales/form.php b/application/views/sales/form.php index 2c2048b60..b882a4e30 100755 --- a/application/views/sales/form.php +++ b/application/views/sales/form.php @@ -98,10 +98,10 @@ $(document).ready(function() $('#send_invoice').click(function(event) { if (confirm("lang->line('sales_invoice_confirm') . ' ' . $sale_info['email'] ?>")) { - $.get('', + $.get("", function(response) { dialog_support.hide(); - table_support.handle_submit('', response); + table_support.handle_submit("", response); }, 'json' ); } @@ -134,7 +134,7 @@ $(document).ready(function() todayBtn: true, todayHighlight: true, bootcssVer: 3, - language: '' + language: "" }); var fill_value = function(event, ui) { @@ -145,7 +145,7 @@ $(document).ready(function() $('#customer_name').autocomplete( { - source: '', + source: "", minChars: 0, delay: 15, cacheLength: 1, @@ -156,33 +156,29 @@ $(document).ready(function() $('button#delete').click(function() { dialog_support.hide(); - table_support.do_delete('', ); + table_support.do_delete("", ); }); $('button#restore').click(function() { dialog_support.hide(); - table_support.do_restore('', ); + table_support.do_restore("", ); }); - var submit_form = function() - { - $(this).ajaxSubmit( - { - success: function(response) - { - dialog_support.hide(); - table_support.handle_submit('', response); - }, - dataType: 'json' - }); - }; - $('#sales_edit_form').validate($.extend( { - submitHandler: function(form) - { - submit_form.call(form); + submitHandler: function(form) { + $(form).ajaxSubmit({ + success: function(response) + { + dialog_support.hide(); + table_support.handle_submit("", response); + }, + dataType: 'json' + }); }, + + errorLabelContainer: '#error_message_box', + rules: { invoice_number: @@ -200,9 +196,10 @@ $(document).ready(function() } } }, + messages: { - invoice_number: 'lang->line("sales_invoice_number_duplicate"); ?>' + invoice_number: "lang->line("sales_invoice_number_duplicate"); ?>" } }, form_support.error)); }); diff --git a/application/views/sales/register.php b/application/views/sales/register.php index da73240c8..7cde592a1 100644 --- a/application/views/sales/register.php +++ b/application/views/sales/register.php @@ -56,8 +56,8 @@ if(isset($success)) ?>
    • -
    • @@ -90,8 +90,8 @@ if(isset($success))
    • -
    • @@ -207,7 +207,7 @@ if(isset($success)) } ?> - lang->line('sales_update')?> > + ").submit();" title=lang->line('sales_update')?> > lang->line('sales_select_customer') . ' ' . $customer_required; ?> 'customer', 'id'=>'customer', 'class'=>'form-control input-sm', 'value'=>$this->lang->line('sales_start_typing_customer_name')));?> - @@ -468,7 +468,7 @@ if(isset($success)) if($pos_mode == '1') { ?> -
       lang->line('sales_complete_sale'); ?>
      +
       lang->line('sales_complete_sale'); ?>
      @@ -495,7 +495,7 @@ if(isset($success)) -
       lang->line('sales_add_payment'); ?>
      +
       lang->line('sales_add_payment'); ?>
      @@ -644,7 +644,7 @@ $(document).ready(function() var item_id = $(this).parents("tr").find("input[name='item_id']").val(); var item_number = $(this).val(); $.ajax({ - url: '', + url: "", method: 'post', data: { "item_id" : item_id, @@ -658,7 +658,7 @@ $(document).ready(function() var item_id = $(this).parents("tr").find("input[name='item_id']").val(); var item_name = $(this).val(); $.ajax({ - url: '', + url: "", method: 'post', data: { "item_id" : item_id, @@ -672,7 +672,7 @@ $(document).ready(function() var item_id = $(this).parents("tr").find("input[name='item_id']").val(); var item_description = $(this).val(); $.ajax({ - url: '', + url: "", method: 'post', data: { "item_id" : item_id, @@ -686,12 +686,12 @@ $(document).ready(function() $('#item').blur(function() { - $(this).val('lang->line('sales_start_typing_item_name'); ?>'); + $(this).val("lang->line('sales_start_typing_item_name'); ?>"); }); $('#item').autocomplete( { - source: '', + source: "", minChars: 0, autoFocus: false, delay: 500, @@ -711,7 +711,7 @@ $(document).ready(function() var clear_fields = function() { - if($(this).val().match('lang->line('sales_start_typing_item_name') . '|' . $this->lang->line('sales_start_typing_customer_name'); ?>')) + if($(this).val().match("lang->line('sales_start_typing_item_name') . '|' . $this->lang->line('sales_start_typing_customer_name'); ?>")) { $(this).val(''); } @@ -724,12 +724,12 @@ $(document).ready(function() $('#customer').blur(function() { - $(this).val('lang->line('sales_start_typing_customer_name'); ?>'); + $(this).val("lang->line('sales_start_typing_customer_name'); ?>"); }); $("#customer").autocomplete( { - source: '', + source: "", minChars: 0, delay: 10, select: function (a, ui) { @@ -747,7 +747,7 @@ $(document).ready(function() $(".giftcard-input").autocomplete( { - source: '', + source: "", minChars: 0, delay: 10, select: function (a, ui) { @@ -758,7 +758,7 @@ $(document).ready(function() $('#comment').keyup(function() { - $.post('', {comment: $('#comment').val()}); + $.post("", {comment: $('#comment').val()}); }); $('#sales_invoice_number').keyup(function() { - $.post('', {sales_invoice_number: $('#sales_invoice_number').val()}); + $.post("", {sales_invoice_number: $('#sales_invoice_number').val()}); }); var enable_invoice_number = function() @@ -782,7 +782,7 @@ $(document).ready(function() $("#sales_invoice_enable").change(function() { var enabled = enable_invoice_number(); - $.post('', {sales_invoice_number_enabled: enabled}); + $.post("", {sales_invoice_number_enabled: enabled}); }); ', {sales_print_after_sale: $(this).is(":checked")}); + $.post("", {sales_print_after_sale: $(this).is(":checked")}); }); $("#price_work_orders").change(function() { - $.post('', {price_work_orders: $(this).is(":checked")}); + $.post("", {price_work_orders: $(this).is(":checked")}); }); $('#email_receipt').change(function() { - $.post('', {email_receipt: $(this).is(":checked")}); + $.post("", {email_receipt: $(this).is(":checked")}); }); $("#finish_sale_button").click(function() { - $('#buttons_form').attr('action', ''); + $('#buttons_form').attr('action', ""); $('#buttons_form').submit(); }); $("#finish_invoice_quote_button").click(function() { - $('#buttons_form').attr('action', ''); + $('#buttons_form').attr('action', ""); $('#buttons_form').submit(); }); $("#suspend_sale_button").click(function() { - $('#buttons_form').attr('action', ''); + $('#buttons_form').attr('action', ""); $('#buttons_form').submit(); }); $("#cancel_sale_button").click(function() { - if(confirm('lang->line("sales_confirm_cancel_sale"); ?>')) + if(confirm("lang->line("sales_confirm_cancel_sale"); ?>")) { - $('#buttons_form').attr('action', ''); + $('#buttons_form').attr('action', ""); $('#buttons_form').submit(); } }); @@ -900,31 +900,31 @@ function check_payment_type() { var cash_rounding = ; - if($("#payment_types").val() == 'lang->line('sales_giftcard'); ?>') + if($("#payment_types").val() == "lang->line('sales_giftcard'); ?>") { - $("#sale_total").html(''); - $("#sale_amount_due").html(''); - $("#amount_tendered_label").html('lang->line('sales_giftcard_number'); ?>'); + $("#sale_total").html(""); + $("#sale_amount_due").html(""); + $("#amount_tendered_label").html("lang->line('sales_giftcard_number'); ?>"); $("#amount_tendered:enabled").val('').focus(); $(".giftcard-input").attr('disabled', false); $(".non-giftcard-input").attr('disabled', true); $(".giftcard-input:enabled").val('').focus(); } - else if($("#payment_types").val() == 'lang->line('sales_cash'); ?>' && cash_rounding) + else if($("#payment_types").val() == "lang->line('sales_cash'); ?>" && cash_rounding) { - $("#sale_total").html(''); - $("#sale_amount_due").html(''); - $("#amount_tendered_label").html('lang->line('sales_amount_tendered'); ?>'); - $("#amount_tendered:enabled").val(''); + $("#sale_total").html(""); + $("#sale_amount_due").html(""); + $("#amount_tendered_label").html("lang->line('sales_amount_tendered'); ?>"); + $("#amount_tendered:enabled").val(""); $(".giftcard-input").attr('disabled', true); $(".non-giftcard-input").attr('disabled', false); } else { - $("#sale_total").html(''); - $("#sale_amount_due").html(''); - $("#amount_tendered_label").html('lang->line('sales_amount_tendered'); ?>'); - $("#amount_tendered:enabled").val(''); + $("#sale_total").html(""); + $("#sale_amount_due").html(""); + $("#amount_tendered_label").html("lang->line('sales_amount_tendered'); ?>"); + $("#amount_tendered:enabled").val(""); $(".giftcard-input").attr('disabled', true); $(".non-giftcard-input").attr('disabled', false); } diff --git a/application/views/suppliers/form.php b/application/views/suppliers/form.php index 2c0206b06..ab610072d 100644 --- a/application/views/suppliers/form.php +++ b/application/views/suppliers/form.php @@ -49,25 +49,27 @@ $(document).ready(function() { $('#supplier_form').validate($.extend({ - submitHandler:function(form) - { + submitHandler: function(form) { $(form).ajaxSubmit({ - success:function(response) - { - dialog_support.hide(); - table_support.handle_submit('', response); - }, - dataType:'json' - }); - + success: function(response) + { + dialog_support.hide(); + table_support.handle_submit("", response); + }, + dataType: 'json' + }); }, + + errorLabelContainer: '#error_message_box', + rules: { - company_name: "required", - first_name: "required", - last_name: "required", - email: "email" + company_name: 'required', + first_name: 'required', + last_name: 'required', + email: 'email' }, + messages: { company_name: "lang->line('suppliers_company_name_required'); ?>", @@ -77,5 +79,4 @@ $(document).ready(function() } }, form_support.error)); }); - - \ No newline at end of file + diff --git a/application/views/taxes/form.php b/application/views/taxes/form.php index 894e5dd73..387157328 100644 --- a/application/views/taxes/form.php +++ b/application/views/taxes/form.php @@ -28,10 +28,10 @@
      -
      +
      lang->line('taxes_tax_code_type'), 'tax_code_type', !empty($basic_version) ? array('class'=>'required control-label col-xs-3') : array('class'=>'control-label col-xs-3')); ?> -
      -
      + +
      +
      -
      +
      lang->line('common_city'), 'city', array('class'=>'control-label col-xs-3')); ?> -
      +
      'city', 'id'=>'city', 'class'=>'form-control input-sm', 'value'=>$city) );?> -
      -
      +
      +
      -
      +
      lang->line('common_state'), 'name', array('class'=>'control-label col-xs-3')); ?> -
      +
      'state', 'id'=>'state', 'class'=>'form-control input-sm', 'value'=>$state) );?> -
      -
      +
      +
      -
      +
      lang->line('taxes_tax_rate'), 'tax_rate', array('class' => 'required control-label col-xs-3')); ?> -
      -
      +
      +
      'tax_rate', 'id'=>'tax_rate', 'class'=>'form-control input-sm', 'value'=>$tax_rate) );?> - % -
      -
      -
      + % +
      +
      +
      -
      +
      lang->line('taxes_rounding_code'), 'rounding_code', array('class' => 'control-label col-xs-3')); ?> -
      +
      'form-control input-sm')); ?> -
      -
      +
      +
      -
      +
      lang->line('taxes_add_exception'), 'add_tax_category', array('class'=>'control-label col-xs-3')); ?> -
      -
      - +
      +
      + 'add_tax_category', 'id'=>'add_tax_category', @@ -119,98 +119,103 @@ 'value'=>$add_tax_category) );?> -
      -
      -
      +
      +
      +
      - - - - - - - - - - +
      lang->line('common_delete'); ?>lang->line('taxes_tax_category'); ?>lang->line('taxes_tax_rate'); ?>lang->line('taxes_rounding_code'); ?>
      + + + + + + + + + - - - - - - + + + + + + - -
      lang->line('common_delete'); ?>lang->line('taxes_tax_category'); ?>lang->line('taxes_tax_rate'); ?>lang->line('taxes_rounding_code'); ?>
      ' name=exception_tax_rate[] value=''/> 'form-control input-sm'));?>
      ' name=exception_tax_rate[] value=""/> 'form-control input-sm'));?>
      + + - +