Fix Reports and few other minor things

This commit is contained in:
FrancescoUK committed 2017-12-12 20:58:36 +00:00
1 parent 323738210b
commit c96c2a69a6
15 files changed
+269 -216

No files matched your search

+167 -168
View File
@@ -252,7 +252,7 @@
);?>
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('items_image'), 'items_image', array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-8'>
@@ -339,183 +339,182 @@
<?php echo form_close(); ?>
<script type="text/javascript">
//validation and submit handling
$(document).ready(function()
//validation and submit handling
$(document).ready(function()
{
$("#new").click(function() {
stay_open = true;
$("#item_form").submit();
});
$("#submit").click(function() {
stay_open = false;
});
var no_op = function(event, data, formatted){};
$("#category").autocomplete({source: "<?php echo site_url('items/suggest_category');?>",delay:10,appendTo: '.modal-content'});
<?php for ($i = 1; $i <= 10; ++$i)
{
$("#new").click(function() {
stay_open = true;
$("#item_form").submit();
});
$("#submit").click(function() {
stay_open = false;
});
var no_op = function(event, data, formatted){};
$("#category").autocomplete({source: "<?php echo site_url('items/suggest_category');?>",delay:10,appendTo: '.modal-content'});
<?php for ($i = 1; $i <= 10; ++$i)
{
?>
$("#custom"+<?php echo $i; ?>).autocomplete({
source:function (request, response) {
$.ajax({
type: "POST",
url: "<?php echo site_url('items/suggest_custom');?>",
dataType: "json",
data: $.extend(request, $extend(csrf_form_base(), {field_no: <?php echo $i; ?>})),
success: function(data) {
response($.map(data, function(item) {
return {
value: item.label
};
}))
}
});
},
delay:10,
appendTo: '.modal-content'});
<?php
}
?>
$("a.fileinput-exists").click(function() {
$.ajax({
type: "GET",
url: "<?php echo site_url("$controller_name/remove_logo/$item_info->item_id"); ?>",
dataType: "json"
})
});
$('#item_form').validate($.extend({
submitHandler: function(form, event) {
$(form).ajaxSubmit({
success: function(response) {
var stay_open = dialog_support.clicked_id() != 'submit';
if (stay_open)
{
// set action of item_form to url without item id, so a new one can be created
$("#item_form").attr("action", "<?php echo site_url("items/save/")?>");
// 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('');
// de-select any checkboxes, radios and drop-down menus
$(':input', '#item_form').not('#item_category_id').removeAttr('checked').removeAttr('selected');
}
else
{
dialog_support.hide();
}
table_support.handle_submit('<?php echo site_url('items'); ?>', response, stay_open);
},
dataType: 'json'
?>
$("#custom" + <?php echo $i; ?>).autocomplete({
source:function (request, response) {
$.ajax({
type: "POST",
url: "<?php echo site_url('items/suggest_custom');?>",
dataType: "json",
data: $.extend(request, $extend(csrf_form_base(), {field_no: <?php echo $i; ?>})),
success: function(data) {
response($.map(data, function(item) {
return {
value: item.label
};
}))
}
});
},
delay: 10,
appendTo: '.modal-content'});
<?php
}
?>
rules:
{
name:"required",
category:"required",
item_number:
{
required: false,
remote:
$("a.fileinput-exists").click(function() {
$.ajax({
type: "GET",
url: "<?php echo site_url("$controller_name/remove_logo/$item_info->item_id"); ?>",
dataType: "json"
})
});
$('#item_form').validate($.extend({
submitHandler: function(form, event) {
$(form).ajaxSubmit({
success: function(response) {
var stay_open = dialog_support.clicked_id() != 'submit';
if (stay_open)
{
url: "<?php echo site_url($controller_name . '/check_item_number')?>",
type: "post",
data: $.extend(csrf_form_base(),
{
"item_id" : "<?php echo $item_info->item_id; ?>",
"item_number" : function()
{
return $("#item_number").val();
},
})
// set action of item_form to url without item id, so a new one can be created
$("#item_form").attr("action", "<?php echo site_url("items/save/")?>");
// 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('');
// de-select any checkboxes, radios and drop-down menus
$(':input', '#item_form').not('#item_category_id').removeAttr('checked').removeAttr('selected');
}
else
{
dialog_support.hide();
}
table_support.handle_submit('<?php echo site_url('items'); ?>', response, stay_open);
},
cost_price:
dataType: 'json'
});
},
rules:
{
name: "required",
category: "required",
item_number:
{
required: false,
remote:
{
url: "<?php echo site_url($controller_name . '/check_item_number')?>",
type: "post",
data: $.extend(csrf_form_base(),
{
"item_id": "<?php echo $item_info->item_id; ?>",
"item_number": function()
{
return $("#item_number").val();
},
})
}
},
cost_price:
{
required: true,
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
unit_price:
{
required: true,
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
<?php
foreach($stock_locations as $key=>$location_detail)
{
?>
<?php echo 'quantity_' . $key ?>:
{
required: true,
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
unit_price:
{
required:true,
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
<?php
foreach($stock_locations as $key=>$location_detail)
{
?>
<?php echo 'quantity_' . $key ?>:
{
required:true,
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
<?php
}
?>
receiving_quantity:
{
required:true,
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
reorder_level:
{
required:true,
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
tax_percent:
{
required:true,
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
}
},
messages:
{
name:"<?php echo $this->lang->line('items_name_required'); ?>",
item_number: "<?php echo $this->lang->line('items_item_number_duplicate'); ?>",
category:"<?php echo $this->lang->line('items_category_required'); ?>",
cost_price:
{
required:"<?php echo $this->lang->line('items_cost_price_required'); ?>",
number:"<?php echo $this->lang->line('items_cost_price_number'); ?>"
},
unit_price:
{
required:"<?php echo $this->lang->line('items_unit_price_required'); ?>",
number:"<?php echo $this->lang->line('items_unit_price_number'); ?>"
},
<?php
foreach($stock_locations as $key=>$location_detail)
{
?>
<?php echo 'quantity_' . $key ?>:
{
required:"<?php echo $this->lang->line('items_quantity_required'); ?>",
number:"<?php echo $this->lang->line('items_quantity_number'); ?>"
},
<?php
}
?>
receiving_quantity:
{
required:"<?php echo $this->lang->line('items_quantity_required'); ?>",
number:"<?php echo $this->lang->line('items_quantity_number'); ?>"
},
reorder_level:
{
required:"<?php echo $this->lang->line('items_reorder_level_required'); ?>",
number:"<?php echo $this->lang->line('items_reorder_level_number'); ?>"
},
tax_percent:
{
required:"<?php echo $this->lang->line('items_tax_percent_required'); ?>",
number:"<?php echo $this->lang->line('items_tax_percent_number'); ?>"
}
<?php
}
}, form_support.error));
});
</script>
?>
receiving_quantity:
{
required: true,
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
reorder_level:
{
required: true,
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
tax_percent:
{
required: true,
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
}
},
messages:
{
name: "<?php echo $this->lang->line('items_name_required'); ?>",
item_number: "<?php echo $this->lang->line('items_item_number_duplicate'); ?>",
category: "<?php echo $this->lang->line('items_category_required'); ?>",
cost_price:
{
required: "<?php echo $this->lang->line('items_cost_price_required'); ?>",
number: "<?php echo $this->lang->line('items_cost_price_number'); ?>"
},
unit_price:
{
required: "<?php echo $this->lang->line('items_unit_price_required'); ?>",
number: "<?php echo $this->lang->line('items_unit_price_number'); ?>"
},
<?php
foreach($stock_locations as $key=>$location_detail)
{
?>
<?php echo 'quantity_' . $key ?>:
{
required: "<?php echo $this->lang->line('items_quantity_required'); ?>",
number: "<?php echo $this->lang->line('items_quantity_number'); ?>"
},
<?php
}
?>
receiving_quantity:
{
required: "<?php echo $this->lang->line('items_quantity_required'); ?>",
number: "<?php echo $this->lang->line('items_quantity_number'); ?>"
},
reorder_level:
{
required: "<?php echo $this->lang->line('items_reorder_level_required'); ?>",
number: "<?php echo $this->lang->line('items_reorder_level_number'); ?>"
},
tax_percent:
{
required: "<?php echo $this->lang->line('items_tax_percent_required'); ?>",
number: "<?php echo $this->lang->line('items_tax_percent_number'); ?>"
}
}
}, form_support.error));
});
</script>