From fea046240720cb1013c8c5ab16a58166b0ea4f70 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Sun, 27 May 2018 21:43:18 +0100 Subject: [PATCH] Remove additional csrf_form_base calls, general tidy up --- application/views/configs/locale_config.php | 22 ++++++++-------- application/views/customers/form.php | 17 ++++++------- application/views/giftcards/form.php | 28 ++++++++++++++------- application/views/items/form.php | 16 ++++++------ application/views/sales/form.php | 17 ++++++------- 5 files changed, 53 insertions(+), 47 deletions(-) diff --git a/application/views/configs/locale_config.php b/application/views/configs/locale_config.php index 910bea5cd..5ac983086 100644 --- a/application/views/configs/locale_config.php +++ b/application/views/configs/locale_config.php @@ -226,17 +226,17 @@ //validation and submit handling $(document).ready(function() { - $("span").tooltip(); + $('span').tooltip(); - $("#currency_symbol, #thousands_separator").change(function() { + $('#currency_symbol, #thousands_separator').change(function() { var field = $(this).attr('id'); - var value = $(this).is(":checkbox") ? $(this).is(":checked") : $(this).val(); - var data = { number_locale: $("#number_locale").val() }; + var value = $(this).is(':checkbox') ? $(this).is(':checked') : $(this).val(); + var data = { number_locale: $('#number_locale').val() }; data[field] = value; $.post("", data, function(response) { - $("#number_locale_example").text(response.number_locale_example); + $('#number_locale_example').text(response.number_locale_example); }, 'json' ); @@ -252,17 +252,17 @@ $(document).ready(function() remote: { url: "", - type: 'post', + type: 'POST', data: { - 'number_locale': $("#number_locale").val(), - 'thousands_separator': $("#thousands_separator").is(":checked") + 'number_locale': $('#number_locale').val(), + 'thousands_separator': $('#thousands_separator').is(':checked') }, dataFilter: function(data) { setup_csrf_token(); var response = JSON.parse(data); - $("#number_locale_example").text(response.number_locale_example); - $("#currency_symbol").val(response.currency_symbol); - $("#thousands_separator").prop('checked', response.thousands_separator); + $('#number_locale_example').text(response.number_locale_example); + $('#currency_symbol').val(response.currency_symbol); + $('#thousands_separator').prop('checked', response.thousands_separator); return response.success; } } diff --git a/application/views/customers/form.php b/application/views/customers/form.php index fe7589ad1..2e11fb942 100644 --- a/application/views/customers/form.php +++ b/application/views/customers/form.php @@ -451,18 +451,17 @@ $(document).ready(function() rules: { - first_name: "required", - last_name: "required", - consent: "required", + first_name: 'required', + last_name: 'required', + consent: 'required', email: { remote: { url: "", - type: "post", - data: - { - "person_id" : "person_id; ?>", + type: 'POST', + data: { + 'person_id': 'person_id; ?>' // email is posted by default } } @@ -472,9 +471,9 @@ $(document).ready(function() remote: { url: "", - type: "post", + type: 'POST', data: { - "person_id" : "person_id; ?>" + 'person_id': 'person_id; ?>' // account_number is posted by default } } diff --git a/application/views/giftcards/form.php b/application/views/giftcards/form.php index adb6d7d46..6004b96e1 100644 --- a/application/views/giftcards/form.php +++ b/application/views/giftcards/form.php @@ -72,7 +72,7 @@ $(document).ready(function() $("input[name='person_name']").val(ui.item.label); }; - var autocompleter = $("#person_name").autocomplete({ + var autocompleter = $('#person_name').autocomplete({ source: '', minChars: 0, delay: 15, @@ -94,7 +94,7 @@ $(document).ready(function() { table_support.handle_submit('', {message: errorThrown}); }, - dataType:'json' + dataType: 'json' }); }; @@ -106,27 +106,32 @@ $(document).ready(function() }, rules: { - config->item('giftcard_number') == "series") { ?> + config->item('giftcard_number') == "series") + { + ?> giftcard_number: { required: true, number: true }, - + giftcard_amount: { required: true, remote: { url: "", - type: 'post', + type: 'POST', data: { - 'amount': $("#giftcard_amount").val() + 'amount': $('#giftcard_amount').val() }, dataFilter: function(data) { setup_csrf_token(); var response = JSON.parse(data); - $("#giftcard_amount").text(response.value); + $('#giftcard_amount').text(response.value); return response.success; } } @@ -134,13 +139,18 @@ $(document).ready(function() }, messages: { - config->item('giftcard_number') == "series"){ ?> + config->item('giftcard_number') == "series") + { + ?> giftcard_number: { required: "lang->line('giftcards_number_required'); ?>", number: "lang->line('giftcards_number'); ?>" }, - + giftcard_amount: { required: "lang->line('giftcards_value_required'); ?>", diff --git a/application/views/items/form.php b/application/views/items/form.php index 7ef0f1a2c..7954003b5 100644 --- a/application/views/items/form.php +++ b/application/views/items/form.php @@ -376,10 +376,10 @@ $(document).ready(function() $("#custom" + ).autocomplete({ source:function (request, response) { $.ajax({ - type: "POST", + type: 'POST', url: "", dataType: "json", - data: $.extend(request, $extend(csrf_form_base(), {field_no: })), + data: $.extend(request, {field_no: }), success: function(data) { response($.map(data, function(item) { return { @@ -438,15 +438,13 @@ $(document).ready(function() remote: { url: "", - type: "post", - data: $.extend(csrf_form_base(), - { + type: 'POST', + data: { "item_id": "item_id; ?>", - "item_number": function() - { + "item_number": function() { return $("#item_number").val(); - }, - }) + } + } } }, cost_price: diff --git a/application/views/sales/form.php b/application/views/sales/form.php index 47242d387..80ec82ba5 100755 --- a/application/views/sales/form.php +++ b/application/views/sales/form.php @@ -96,13 +96,13 @@ $(document).ready(function() { - $("#send_invoice").click(function(event) { + $('#send_invoice').click(function(event) { if (confirm("lang->line('sales_invoice_confirm') . ' ' . $sale_info['email'] ?>")) { $.get('', function(response) { dialog_support.hide(); table_support.handle_submit('', response); - }, "json" + }, 'json' ); } }); @@ -143,7 +143,7 @@ $(document).ready(function() $("input[name='customer_name']").val(ui.item.label); }; - $("#customer_name").autocomplete( + $('#customer_name').autocomplete( { source: '', minChars: 0, @@ -190,14 +190,13 @@ $(document).ready(function() remote: { url: "", - type: "POST", + type: 'POST', data: { - "sale_id" : , - "invoice_number" : function() - { - return $("#invoice_number").val(); + 'sale_id': , + 'invoice_number': function() { + return $('#invoice_number').val(); } - }) + } } } },