From 3cb41c9fe31512906807a3bac4e1a0c1df772b09 Mon Sep 17 00:00:00 2001 From: FrancescoUK Date: Sat, 5 Mar 2016 10:20:44 +0000 Subject: [PATCH] fix picture loading widget in Items/form, works but pic extension is not handled so still commented out (#116) --- application/views/items/form.php | 67 ++++++++++++++------------------ 1 file changed, 29 insertions(+), 38 deletions(-) diff --git a/application/views/items/form.php b/application/views/items/form.php index ee6688a2b..b73884315 100644 --- a/application/views/items/form.php +++ b/application/views/items/form.php @@ -47,9 +47,9 @@
- lang->line('items_supplier'), 'supplier', array('class'=>'control-label col-xs-3')); ?> + lang->line('items_supplier'), 'supplier', array('class'=>'required control-label col-xs-3')); ?>
- 'form-control'));?> + 'required form-control'));?>
@@ -196,16 +196,14 @@ - - lang->line('items_image'), 'items_image', array('class'=>'control-label col-xs-3')); ?>
<?php echo $this->lang->line('items_image'); ?>
@@ -220,8 +218,7 @@
-*/ -?> +*/ ?>
lang->line('items_allow_alt_description'), 'allow_alt_description', array('class'=>'control-label col-xs-3')); ?>
@@ -289,13 +286,11 @@ //validation and submit handling $(document).ready(function() { - $("#continue").click(function() - { + $("#continue").click(function() { stay_open = true; }); - $("#submit").click(function() - { + $("#submit").click(function() { stay_open = false; }); @@ -310,37 +305,31 @@ } ?> - $.validator.addMethod("item_number", function(value, element) - { - return JSON.parse($.ajax( - { - type: 'POST', - url: '', - data: {'item_id' : 'item_id; ?>', 'item_number' : $(element).val() }, - success: function(response) - { - success=response.success; - }, - async:false, - dataType: 'json' - }).responseText).success; - + $.validator.addMethod("item_number", function(value, element) { + return JSON.parse($.ajax({ + type: 'POST', + url: '', + data: {'item_id' : 'item_id; ?>', 'item_number' : $(element).val() }, + success: function(response) { + success = response.success; + }, + async: false, + dataType: 'json' + }).responseText).success; }, 'lang->line("items_item_number_duplicate"); ?>'); $('#item_form').validate($.extend({ - submitHandler:function(form, event) - { + submitHandler: function(form, event) { $(form).ajaxSubmit({ - success:function(response) - { + success: function(response) { var stay_open = dialog_support.clicked_id() != 'submit'; - if (stay_open) + if (stay_open) { // set action of item_form to url without item id, so a new one can be created $("#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(''); + $(':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(''); // de-select any checkboxes, radios and drop-down menus $(':input', '#item_form').not('#item_category_id').removeAttr('checked').removeAttr('selected'); } @@ -348,16 +337,19 @@ { dialog_support.hide(); } - post_item_form_submit(response, stay_open); + post_item_form_submit(response, stay_open); }, - dataType:'json' + dataType: 'json' }); }, rules: { name:"required", category:"required", - item_number: { item_number: true }, + item_number: + { + item_number: true + }, cost_price: { required:true, @@ -378,7 +370,6 @@ required:true, number:true } - }, messages: {