mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-11 18:38:08 -04:00
@@ -159,6 +159,12 @@ class Expenses extends Secure_Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function ajax_check_amount()
|
||||
{
|
||||
$parsed_value = parse_decimals(array_pop($this->input->post()));
|
||||
echo json_encode(array('success' => $parsed_value !== FALSE, 'amount' => to_currency_no_money($parsed_value)));
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$expenses_to_delete = $this->input->post('ids');
|
||||
|
||||
@@ -131,7 +131,7 @@ class Giftcards extends Secure_Controller
|
||||
public function ajax_check_number_giftcard()
|
||||
{
|
||||
$parsed_value = parse_decimals($this->input->post('giftcard_amount'));
|
||||
echo json_encode(array('success' => $parsed_value !== FALSE, 'giftcard_amount' => $parsed_value));
|
||||
echo json_encode(array('success' => $parsed_value !== FALSE, 'giftcard_amount' => to_currency_no_money($parsed_value)));
|
||||
}
|
||||
|
||||
public function delete()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
$lang["expenses_add_item"] = "Add Expense";
|
||||
$lang["expenses_amount"] = "Amount";
|
||||
$lang["expenses_tax_amount"] = "Amount";
|
||||
$lang["expenses_amount_number"] = "Amount must be a number";
|
||||
$lang["expenses_amount_required"] = "Expense Amount required";
|
||||
$lang["expenses_by_category"] = "Category";
|
||||
|
||||
@@ -258,7 +258,6 @@ $(document).ready(function()
|
||||
'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);
|
||||
|
||||
@@ -188,6 +188,18 @@ $(document).ready(function()
|
||||
});
|
||||
};
|
||||
|
||||
var amount_validator = function(field) {
|
||||
return {
|
||||
url: "<?php echo site_url($controller_name . '/ajax_check_amount')?>",
|
||||
type: 'POST',
|
||||
dataFilter: function(data) {
|
||||
var response = JSON.parse(data);
|
||||
$(field).val(response.amount);
|
||||
return response.success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('#expenses_edit_form').validate($.extend(
|
||||
{
|
||||
submitHandler: function(form)
|
||||
@@ -204,7 +216,11 @@ $(document).ready(function()
|
||||
amount:
|
||||
{
|
||||
required: true,
|
||||
number: true
|
||||
remote: amount_validator("#amount")
|
||||
},
|
||||
tax_amount:
|
||||
{
|
||||
remote: amount_validator("#tax_amount")
|
||||
}
|
||||
},
|
||||
messages:
|
||||
@@ -218,7 +234,11 @@ $(document).ready(function()
|
||||
amount:
|
||||
{
|
||||
required: '<?php echo $this->lang->line('expenses_amount_required'); ?>',
|
||||
number: '<?php echo $this->lang->line('expenses_amount_number'); ?>'
|
||||
remote: '<?php echo $this->lang->line('expenses_amount_number'); ?>'
|
||||
},
|
||||
tax_amount:
|
||||
{
|
||||
remote: '<?php echo $this->lang->line('expenses_tax_amount_number'); ?>'
|
||||
}
|
||||
}
|
||||
}, form_support.error));
|
||||
|
||||
@@ -129,9 +129,8 @@ $(document).ready(function()
|
||||
'amount': $('#giftcard_amount').val()
|
||||
},
|
||||
dataFilter: function(data) {
|
||||
setup_csrf_token();
|
||||
var response = JSON.parse(data);
|
||||
$('#giftcard_amount').text(response.value);
|
||||
$('#giftcard_amount').val(response.giftcard_amount);
|
||||
return response.success;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,22 +40,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
return ajax.apply(this, arguments);
|
||||
var result = ajax.apply(this, arguments);
|
||||
|
||||
setup_csrf_token();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
var setup_csrf_token = function() {
|
||||
$('input[name="<?php echo $this->security->get_csrf_token_name(); ?>"]').val(csrf_token());
|
||||
};
|
||||
|
||||
setup_csrf_token();
|
||||
|
||||
$.ajaxSetup({
|
||||
dataFilter: function(data) {
|
||||
setup_csrf_token();
|
||||
return data;
|
||||
}
|
||||
});
|
||||
|
||||
var submit = $.fn.submit;
|
||||
|
||||
$.fn.submit = function() {
|
||||
|
||||
Reference in New Issue
Block a user