Code refactoring

This commit is contained in:
FrancescoUK
2018-06-16 21:05:15 +01:00
committed by jekkos
parent 957dc5de16
commit 683ef75162
25 changed files with 745 additions and 744 deletions

View File

@@ -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'
}));
});
</script>

View File

@@ -134,9 +134,9 @@ $(document).ready(function()
{
$("a.fileinput-exists").click(function() {
$.ajax({
type: "GET",
url: "<?php echo site_url("$controller_name/remove_logo"); ?>",
dataType: "json"
type: 'GET',
url: '<?php echo site_url("$controller_name/remove_logo"); ?>',
dataType: 'json'
})
});

View File

@@ -207,7 +207,7 @@ $(document).ready(function()
enable_disable_invoice_enable();
enable_disable_work_order_enable();
},
dataType:'json'
dataType: 'json'
});
}
}));

View File

@@ -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: '<?php echo $this->lang->line('config_number_locale_required') ?>',
number_locale: '<?php echo $this->lang->line('config_number_locale_invalid') ?>'
required: "<?php echo $this->lang->line('config_number_locale_required') ?>",
number_locale: "<?php echo $this->lang->line('config_number_locale_invalid') ?>"
}
},
errorLabelContainer: "#locale_error_message_box"
errorLabelContainer: '#locale_error_message_box'
}));
});
</script>

View File

@@ -60,7 +60,8 @@ $(document).ready(function()
$('#mailchimp_list_id').append(new Option(text, val));
});
$('#mailchimp_list_id').prop('selectedIndex', 0);
}, 'json'
},
'json'
);
});

View File

@@ -1,113 +1,113 @@
<?php echo form_open('config/save_tax/', array('id' => 'tax_config_form', 'class' => 'form-horizontal')); ?>
<div id="config_wrapper">
<fieldset id="config_info">
<div id="required_fields_message"><?php echo $this->lang->line('common_fields_required_message'); ?></div>
<ul id="tax_error_message_box" class="error_message_box"></ul>
<div id="config_wrapper">
<fieldset id="config_info">
<div id="required_fields_message"><?php echo $this->lang->line('common_fields_required_message'); ?></div>
<ul id="tax_error_message_box" class="error_message_box"></ul>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_tax_included'), 'tax_included', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-2'>
<div class='col-xs-2'>
<?php echo form_checkbox(array(
'name' => 'tax_included',
'id' => 'tax_included',
'value' => 'tax_included',
'checked'=>$this->config->item('tax_included'))); ?>
</div>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_default_tax_rate_1'), 'default_tax_1_rate', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-2'>
<div class='col-xs-2'>
<?php echo form_input(array(
'name' => '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'))); ?>
</div>
<div class="col-xs-1 input-group">
</div>
<div class="col-xs-1 input-group">
<?php echo form_input(array(
'name' => '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')))); ?>
<span class="input-group-addon input-sm">%</span>
</div>
</div>
<span class="input-group-addon input-sm">%</span>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_default_tax_rate_2'), 'default_tax_2_rate', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-2'>
<div class='col-xs-2'>
<?php echo form_input(array(
'name' => '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'))); ?>
</div>
<div class="col-xs-1 input-group">
</div>
<div class="col-xs-1 input-group">
<?php echo form_input(array(
'name' => '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')))); ?>
<span class="input-group-addon input-sm">%</span>
</div>
</div>
<span class="input-group-addon input-sm">%</span>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_customer_sales_tax_support'), 'customer_sales_tax_support', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-2'>
<div class='col-xs-2'>
<?php echo form_checkbox(array(
'name' => 'customer_sales_tax_support',
'id' => 'customer_sales_tax_support',
'value' => 'customer_sales_tax_support',
'checked'=>$this->config->item('customer_sales_tax_support'))); ?>
</div>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('config_default_origin_tax_code'), 'default_origin_tax_code', array('class' => 'control-label col-xs-2')); ?>
<div class='col-xs-2'>
<div class='col-xs-2'>
<?php echo form_dropdown('default_origin_tax_code', $tax_codes, $this->config->item('default_origin_tax_code'), array('class' => 'form-control input-sm')); ?>
</div>
</div>
</div>
</div>
<div id="tax_categories">
<div id="tax_categories">
<?php $this->load->view('partial/tax_categories', array('tax_categories' => $tax_categories)); ?>
</div>
<?php echo form_submit(array(
'name' => 'submit_tax',
'id' => 'submit_tax',
'value' => $this->lang->line('common_submit'),
'class' => 'btn btn-primary btn-sm pull-right')); ?>
</fieldset>
</div>
<?php echo form_submit(array(
'name' => 'submit_tax',
'id' => 'submit_tax',
'value' => $this->lang->line('common_submit'),
'class' => 'btn btn-primary btn-sm pull-right')); ?>
</fieldset>
</div>
<?php echo form_close(); ?>
<script type="text/javascript">
//validation and submit handling
$(document).ready(function()
{
var enable_disable_customer_sales_tax_support = (function() {
var customer_sales_tax_support = $("#customer_sales_tax_support").is(":checked");
// $("input[name*='tax_category']:not(input[name=customer_sales_tax_support])").prop("disabled", !customer_sales_tax_support);
$("input[name*='tax_category']").prop("disabled", !customer_sales_tax_support);
$("input[name*='tax_group_sequence']").prop("disabled", !customer_sales_tax_support);
$("select[name='default_origin_tax_code']").prop("disabled", !customer_sales_tax_support);
if(customer_sales_tax_support)
{
$(".add_tax_category, .remove_tax_category").show();
}
else
{
$(".add_tax_category, .remove_tax_category").hide();
}
var enable_disable_customer_sales_tax_support = (function() {
var customer_sales_tax_support = $("#customer_sales_tax_support").is(":checked");
// $("input[name*='tax_category']:not(input[name=customer_sales_tax_support])").prop("disabled", !customer_sales_tax_support);
$("input[name*='tax_category']").prop("disabled", !customer_sales_tax_support);
$("input[name*='tax_group_sequence']").prop("disabled", !customer_sales_tax_support);
$("select[name='default_origin_tax_code']").prop("disabled", !customer_sales_tax_support);
if(customer_sales_tax_support)
{
$(".add_tax_category, .remove_tax_category").show();
}
else
{
$(".add_tax_category, .remove_tax_category").hide();
}
return arguments.callee;
})();
return arguments.callee;
})();
$("#customer_sales_tax_support").change(enable_disable_customer_sales_tax_support);
$("#customer_sales_tax_support").change(enable_disable_customer_sales_tax_support);
var category_count = <?php echo sizeof($tax_categories); ?>;
@@ -124,114 +124,112 @@ $(document).ready(function()
};
var add_tax_category = function() {
var id = $(this).parent().find('input').attr('id');
id = id.replace(/.*?_(\d+)$/g, "$1");
var previous_id = 'tax_category_' + id;
var previous_id_next = 'tax_group_sequence_' + id;
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
var new_block_id = 'tax_category_' + ++id;
var new_block_id_next = 'tax_group_sequence_' + id;
$(new_block).find('label').html("<?php echo $this->lang->line('config_tax_category'); ?> " + ++category_count).attr('for', new_block_id).attr('class', 'control-label col-xs-2');
$(new_block).find("input[id='"+previous_id+"']").attr('id', new_block_id).removeAttr('disabled').attr('name', new_block_id).attr('class', 'form-control input-sm').val('');
$(new_block).find("input[id='"+previous_id_next+"']").attr('id', new_block_id_next).removeAttr('disabled').attr('name', new_block_id_next).attr('class', 'form-control input-sm').val('');
hide_show_remove();
};
var add_tax_category = function() {
var id = $(this).parent().find('input').attr('id');
id = id.replace(/.*?_(\d+)$/g, "$1");
var previous_id = 'tax_category_' + id;
var previous_id_next = 'tax_group_sequence_' + id;
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
var new_block_id = 'tax_category_' + ++id;
var new_block_id_next = 'tax_group_sequence_' + id;
$(new_block).find('label').html("<?php echo $this->lang->line('config_tax_category'); ?> " + ++category_count).attr('for', new_block_id).attr('class', 'control-label col-xs-2');
$(new_block).find("input[id='"+previous_id+"']").attr('id', new_block_id).removeAttr('disabled').attr('name', new_block_id).attr('class', 'form-control input-sm').val('');
$(new_block).find("input[id='"+previous_id_next+"']").attr('id', new_block_id_next).removeAttr('disabled').attr('name', new_block_id_next).attr('class', 'form-control input-sm').val('');
hide_show_remove();
};
var remove_tax_category = function() {
$(this).parent().remove();
hide_show_remove();
};
var remove_tax_category = function() {
$(this).parent().remove();
hide_show_remove();
};
var init_add_remove_categories = function() {
$('.add_tax_category').click(add_tax_category);
$('.remove_tax_category').click(remove_tax_category);
hide_show_remove();
// set back disabled state
enable_disable_customer_sales_tax_support();
};
init_add_remove_categories();
var init_add_remove_categories = function() {
$('.add_tax_category').click(add_tax_category);
$('.remove_tax_category').click(remove_tax_category);
hide_show_remove();
// set back disabled state
enable_disable_customer_sales_tax_support();
};
init_add_remove_categories();
var duplicate_found = false;
// run validator once for all fields
$.validator.addMethod('tax_category' , function(value, element) {
var value_count = 0;
$("input[name*='tax_category']:not(input[name=customer_sales_tax_support])").each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});
return value_count < 2;
}, "<?php echo $this->lang->line('config_tax_category_duplicate'); ?>");
var duplicate_found = false;
// run validator once for all fields
$.validator.addMethod('tax_category' , function(value, element) {
var value_count = 0;
$("input[name*='tax_category']:not(input[name=customer_sales_tax_support])").each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});
return value_count < 2;
}, "<?php echo $this->lang->line('config_tax_category_duplicate'); ?>");
$.validator.addMethod('valid_chars', function(value, element) {
return value.indexOf('_') === -1;
}, "<?php echo $this->lang->line('config_tax_category_invalid_chars'); ?>");
$.validator.addMethod('valid_chars', function(value, element) {
return value.indexOf('_') === -1;
}, "<?php echo $this->lang->line('config_tax_category_invalid_chars'); ?>");
$('#tax_config_form').validate($.extend(form_support.handler, {
submitHandler: function(form) {
$(form).ajaxSubmit({
beforeSerialize: function(arr, $form, options) {
$("input[name*='tax_category']:not(input[name=customer_sales_tax_support])").prop("disabled", false);
return true;
},
success: function(response) {
$.notify({ message: response.message }, { type: response.success ? 'success' : 'danger'});
$("#tax_categories").load('<?php echo site_url("config/ajax_tax_categories"); ?>', init_add_remove_categories);
},
dataType: 'json'
});
},
$('#tax_config_form').validate($.extend(form_support.handler, {
submitHandler: function(form) {
$(form).ajaxSubmit({
beforeSerialize: function(arr, $form, options) {
$("input[name*='tax_category']:not(input[name=customer_sales_tax_support])").prop("disabled", false);
return true;
},
success: function(response) {
$.notify({ message: response.message }, { type: response.success ? 'success' : 'danger'});
$("#tax_categories").load('<?php echo site_url("config/ajax_tax_categories"); ?>', init_add_remove_categories);
},
dataType: 'json'
});
},
errorLabelContainer: "#category_error_message_box",
errorLabelContainer: "#category_error_message_box",
rules:
{
default_tax_1_rate:
{
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
default_tax2_rate:
{
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
<?php
$i = 0;
foreach($tax_categories as $tax_category=>$category)
{
?>
<?php echo 'tax_category_' . ++$i ?>:
{
required: true,
tax_category: true,
valid_chars: true
},
<?php
}
?>
},
messages:
{
default_tax_1_rate:
{
number: "<?php echo $this->lang->line('config_default_tax_rate_number'); ?>"
},
<?php
$i = 0;
foreach($tax_categories as $tax_category=>$category)
rules:
{
?>
<?php echo 'tax_category_' . ++$i ?>: "<?php echo $this->lang->line('config_tax_category_required'); ?>",
<?php
default_tax_1_rate:
{
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
default_tax2_rate:
{
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
},
<?php
$i = 0;
foreach($tax_categories as $tax_category=>$category)
{
?>
<?php echo 'tax_category_' . ++$i ?>:
{
required: true,
tax_category: true,
valid_chars: true
},
<?php
}
?>
},
messages:
{
default_tax_1_rate:
{
number: "<?php echo $this->lang->line('config_default_tax_rate_number'); ?>"
},
<?php
$i = 0;
foreach($tax_categories as $tax_category=>$category)
{
?>
<?php echo 'tax_category_' . ++$i ?>: "<?php echo $this->lang->line('config_tax_category_required'); ?>",
<?php
}
?>
}
?>
}
}));
}));
});
</script>

View File

@@ -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: '<?php echo site_url("taxes/suggest_sales_tax_codes"); ?>',
$('#sales_tax_code_name').autocomplete({
source: "<?php echo site_url('taxes/suggest_sales_tax_codes'); ?>",
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('<?php echo site_url($controller_name); ?>', response);
table_support.handle_submit("<?php echo site_url($controller_name); ?>", response);
},
dataType: 'json'
});
},
errorLabelContainer: '#error_message_box',
rules:
{
first_name: 'required',
@@ -458,10 +459,10 @@ $(document).ready(function()
{
remote:
{
url: "<?php echo site_url($controller_name . '/ajax_check_email')?>",
url: "<?php echo site_url($controller_name . '/ajax_check_email') ?>",
type: 'POST',
data: {
'person_id': '<?php echo $person_info->person_id; ?>'
'person_id': "<?php echo $person_info->person_id; ?>"
// email is posted by default
}
}
@@ -470,10 +471,10 @@ $(document).ready(function()
{
remote:
{
url: "<?php echo site_url($controller_name . '/ajax_check_account_number')?>",
url: "<?php echo site_url($controller_name . '/ajax_check_account_number') ?>",
type: 'POST',
data: {
'person_id': '<?php echo $person_info->person_id; ?>'
'person_id': "<?php echo $person_info->person_id; ?>"
// account_number is posted by default
}
}

View File

@@ -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: "<?php echo $this->lang->line('common_import_full_path'); ?>"

View File

@@ -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;
}, '<?php echo $this->lang->line('employees_subpermission_required'); ?>');
}, "<?php echo $this->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('<?php echo site_url('employees'); ?>', response);
table_support.handle_submit("<?php echo site_url($controller_name); ?>", 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:
{
<?php
if($person_info->person_id == "")
if($person_info->person_id == '')
{
?>
required:true,
required: true,
<?php
}
?>
@@ -225,10 +226,11 @@ $(document).ready(function()
},
repeat_password:
{
equalTo: "#password"
equalTo: '#password'
},
email: "email"
email: 'email'
},
messages:
{
first_name: "<?php echo $this->lang->line('common_first_name_required'); ?>",
@@ -238,14 +240,13 @@ $(document).ready(function()
required: "<?php echo $this->lang->line('employees_username_required'); ?>",
minlength: "<?php echo $this->lang->line('employees_username_minlength'); ?>"
},
password:
{
<?php
if($person_info->person_id == "")
{
?>
required:"<?php echo $this->lang->line('employees_password_required'); ?>",
required: "<?php echo $this->lang->line('employees_password_required'); ?>",
<?php
}
?>

View File

@@ -172,22 +172,9 @@ $(document).ready(function()
todayBtn: true,
todayHighlight: true,
bootcssVer: 3,
language: '<?php echo current_language_code(); ?>'
language: "<?php echo current_language_code(); ?>"
});
var submit_form = function()
{
$(this).ajaxSubmit(
{
success: function(response)
{
dialog_support.hide();
table_support.handle_submit('<?php echo site_url('expenses'); ?>', response);
},
dataType: 'json'
});
};
var amount_validator = function(field) {
return {
url: "<?php echo site_url($controller_name . '/ajax_check_amount')?>",
@@ -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("<?php echo site_url($controller_name); ?>", 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: '<?php echo $this->lang->line('expenses_category_required'); ?>',
category: "<?php echo $this->lang->line('expenses_category_required'); ?>",
date:
{
required: '<?php echo $this->lang->line('expenses_date_required'); ?>'
required: "<?php echo $this->lang->line('expenses_date_required'); ?>"
},
amount:
{
required: '<?php echo $this->lang->line('expenses_amount_required'); ?>',
remote: '<?php echo $this->lang->line('expenses_amount_number'); ?>'
required: "<?php echo $this->lang->line('expenses_amount_required'); ?>",
remote: "<?php echo $this->lang->line('expenses_amount_number'); ?>"
},
tax_amount:
{
remote: '<?php echo $this->lang->line('expenses_tax_amount_number'); ?>'
remote: "<?php echo $this->lang->line('expenses_tax_amount_number'); ?>"
}
}
}, form_support.error));

View File

@@ -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('<?php echo site_url('expenses_categories'); ?>', 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("<?php echo site_url($controller_name); ?>", response);
},
dataType: 'json'
});
},
errorLabelContainer: '#error_message_box',
rules:
{
category_name: 'required'
},
messages:
{
category_name: '<?php echo $this->lang->line('category_name_required'); ?>'
category_name: "<?php echo $this->lang->line('category_name_required'); ?>"
}
}, form_support.error));
});

View File

@@ -72,8 +72,8 @@ $(document).ready(function()
$("input[name='person_name']").val(ui.item.label);
};
var autocompleter = $('#person_name').autocomplete({
source: '<?php echo site_url("customers/suggest"); ?>',
$('#person_name').autocomplete({
source: "<?php echo site_url('customers/suggest'); ?>",
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('<?php echo site_url($controller_name); ?>', response);
},
error: function(jqXHR, textStatus, errorThrown)
{
table_support.handle_submit('<?php echo site_url($controller_name); ?>', {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("<?php echo site_url($controller_name); ?>", response);
},
error: function(jqXHR, textStatus, errorThrown)
{
table_support.handle_submit("<?php echo site_url($controller_name); ?>", {message: errorThrown});
},
dataType: 'json'
});
},
errorLabelContainer: '#error_message_box',
rules:
{
<?php
if($this->config->item('giftcard_number') == "series")
if($this->config->item('giftcard_number') == 'series')
{
?>
giftcard_number:
@@ -136,17 +132,18 @@ $(document).ready(function()
}
}
},
messages:
{
<?php
if($this->config->item('giftcard_number') == "series")
if($this->config->item('giftcard_number') == 'series')
{
?>
giftcard_number:
{
required: "<?php echo $this->lang->line('giftcards_number_required'); ?>",
number: "<?php echo $this->lang->line('giftcards_number'); ?>"
},
giftcard_number:
{
required: "<?php echo $this->lang->line('giftcards_number_required'); ?>",
number: "<?php echo $this->lang->line('giftcards_number'); ?>"
},
<?php
}
?>

View File

@@ -81,17 +81,17 @@ $(document).ready(function()
}, '<?php echo $this->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:

View File

@@ -16,107 +16,107 @@
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('item_kits_find_kit_item'), 'item_name', array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-8'>
<div class="input-group input-group-sm">
<?php echo form_input(array(
'name'=>'item_name',
'id'=>'item_name',
'class'=>'form-control input-sm',
'size'=>'50',
'value'=>$selected_kit_item)
); ?>
<?php echo form_hidden('kit_item_id', $selected_kit_item_id);?>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('item_kits_find_kit_item'), 'item_name', array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-8'>
<div class="input-group input-group-sm">
<?php echo form_input(array(
'name'=>'item_name',
'id'=>'item_name',
'class'=>'form-control input-sm',
'size'=>'50',
'value'=>$selected_kit_item)
); ?>
<?php echo form_hidden('kit_item_id', $selected_kit_item_id);?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('item_kits_discount_percent'), 'kit_discount_percent', array('class' => 'control-label col-xs-3')); ?>
<div class='col-xs-3'>
<div class="input-group input-group-sm">
<?php echo form_input(array(
'name'=>'kit_discount_percent',
'size'=>'5',
'maxlength'=>'5',
'id'=>'kit_discount_percent',
'class'=>'form-control input-sm',
'value'=>$item_kit_info->kit_discount_percent)
);?>
<span class="input-group-addon input-sm"><b>%</b></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('item_kits_discount_percent'), 'kit_discount_percent', array('class' => 'control-label col-xs-3')); ?>
<div class='col-xs-3'>
<div class="input-group input-group-sm">
<?php echo form_input(array(
'name'=>'kit_discount_percent',
'size'=>'5',
'maxlength'=>'5',
'id'=>'kit_discount_percent',
'class'=>'form-control input-sm',
'value'=>$item_kit_info->kit_discount_percent)
);?>
<span class="input-group-addon input-sm"><b>%</b></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->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')); ?>
<div class="col-xs-8">
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'price_option',
'type'=>'radio',
'id'=>'price_option',
'value'=>0,
'checked'=>$item_kit_info->price_option == PRICE_ALL)
); ?> <?php echo $this->lang->line('item_kits_kit_and_components'); ?>
</label>
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'price_option',
'type'=>'radio',
'id'=>'price_option',
'value'=>1,
'checked'=>$item_kit_info->price_option == PRICE_KIT)
); ?> <?php echo $this->lang->line('item_kits_kit_only'); ?>
</label>
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'price_option',
'type'=>'radio',
'id'=>'price_option',
'value'=>2,
'checked'=>$item_kit_info->price_option == PRICE_KIT_ITEMS)
); ?> <?php echo $this->lang->line('item_kits_kit_and_stock'); ?>
</label>
<div class="form-group form-group-sm">
<?php echo form_label($this->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')); ?>
<div class="col-xs-8">
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'price_option',
'type'=>'radio',
'id'=>'price_option',
'value'=>0,
'checked'=>$item_kit_info->price_option == PRICE_ALL)
); ?> <?php echo $this->lang->line('item_kits_kit_and_components'); ?>
</label>
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'price_option',
'type'=>'radio',
'id'=>'price_option',
'value'=>1,
'checked'=>$item_kit_info->price_option == PRICE_KIT)
); ?> <?php echo $this->lang->line('item_kits_kit_only'); ?>
</label>
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'price_option',
'type'=>'radio',
'id'=>'price_option',
'value'=>2,
'checked'=>$item_kit_info->price_option == PRICE_KIT_ITEMS)
); ?> <?php echo $this->lang->line('item_kits_kit_and_stock'); ?>
</label>
</div>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<?php echo form_label($this->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')); ?>
<div class="col-xs-8">
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'print_option',
'type'=>'radio',
'id'=>'print_option',
'value'=>0,
'checked'=>$item_kit_info->print_option == PRINT_ALL)
); ?> <?php echo $this->lang->line('item_kits_all'); ?>
</label>
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'print_option',
'type'=>'radio',
'id'=>'print_option',
'value'=>1,
'checked'=>$item_kit_info->print_option == PRINT_PRICED)
); ?> <?php echo $this->lang->line('item_kits_priced_only'); ?>
</label>
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'print_option',
'type'=>'radio',
'id'=>'print_option',
'value'=>2,
'checked'=>$item_kit_info->print_option == PRINT_KIT)
); ?> <?php echo $this->lang->line('item_kits_kit_only'); ?>
</label>
<div class="form-group form-group-sm">
<?php echo form_label($this->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')); ?>
<div class="col-xs-8">
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'print_option',
'type'=>'radio',
'id'=>'print_option',
'value'=>0,
'checked'=>$item_kit_info->print_option == PRINT_ALL)
); ?> <?php echo $this->lang->line('item_kits_all'); ?>
</label>
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'print_option',
'type'=>'radio',
'id'=>'print_option',
'value'=>1,
'checked'=>$item_kit_info->print_option == PRINT_PRICED)
); ?> <?php echo $this->lang->line('item_kits_priced_only'); ?>
</label>
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'print_option',
'type'=>'radio',
'id'=>'print_option',
'value'=>2,
'checked'=>$item_kit_info->print_option == PRINT_KIT)
); ?> <?php echo $this->lang->line('item_kits_kit_only'); ?>
</label>
</div>
</div>
</div>
</div>
<div class="form-group form-group-sm">
@@ -146,7 +146,7 @@
<thead>
<tr>
<th width="10%"><?php echo $this->lang->line('common_delete'); ?></th>
<th width="10%"><?php echo $this->lang->line('item_kits_sequence'); ?></th>
<th width="10%"><?php echo $this->lang->line('item_kits_sequence'); ?></th>
<th width="60%"><?php echo $this->lang->line('item_kits_item'); ?></th>
<th width="20%"><?php echo $this->lang->line('item_kits_quantity'); ?></th>
</tr>
@@ -158,9 +158,9 @@
?>
<tr>
<td><a href='#' onclick='return delete_item_kit_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td>
<td><input class='quantity form-control input-sm' id='item_seq_<?php echo $item_kit_item['item_id'] ?>' name=item_kit_seq[<?php echo $item_kit_item['item_id'] ?>] value='<?php echo to_quantity_decimals($item_kit_item['kit_sequence']) ?>'/></td>
<td><input class='quantity form-control input-sm' id='item_seq_<?php echo $item_kit_item['item_id'] ?>" name=item_kit_seq[<?php echo $item_kit_item['item_id'] ?>] value="<?php echo to_quantity_decimals($item_kit_item['kit_sequence']) ?>"/></td>
<td><?php echo $item_kit_item['name']; ?></td>
<td><input class='quantity form-control input-sm' id='item_qty_<?php echo $item_kit_item['item_id'] ?>' name=item_kit_qty[<?php echo $item_kit_item['item_id'] ?>] value='<?php echo to_quantity_decimals($item_kit_item['quantity']) ?>'/></td>
<td><input class='quantity form-control input-sm' id='item_qty_<?php echo $item_kit_item['item_id'] ?>" name=item_kit_qty[<?php echo $item_kit_item['item_id'] ?>] value="<?php echo to_quantity_decimals($item_kit_item['quantity']) ?>"/></td>
</tr>
<?php
}
@@ -176,80 +176,80 @@
//validation and submit handling
$(document).ready(function()
{
$("#item").autocomplete({
source: "<?php echo site_url('items/suggest'); ?>",
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("<tr>" +
"<td><a href='#' onclick='return delete_item_kit_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td>" +
"<td><input class='quantity form-control input-sm' id='item_seq_" + ui.item.value + "' name=item_kit_seq[" + ui.item.value + "] value='0'/></td>" +
"<td>" + ui.item.label + "</td>" +
"<td><input class='quantity form-control input-sm' id='item_qty_" + ui.item.value + "' name=item_kit_qty[" + ui.item.value + "] value='1'/></td>" +
"</tr>");
}
$("#item").val("");
return false;
}
});
$("#item").autocomplete({
source: '<?php echo site_url("items/suggest"); ?>',
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("<tr>" +
"<td><a href='#' onclick='return delete_item_kit_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td>" +
"<td><input class='quantity form-control input-sm' id='item_seq_" + ui.item.value + "' name=item_kit_seq[" + ui.item.value + "] value='0'/></td>" +
"<td>" + ui.item.label + "</td>" +
"<td><input class='quantity form-control input-sm' id='item_qty_" + ui.item.value + "' name=item_kit_qty[" + ui.item.value + "] value='1'/></td>" +
"</tr>");
}
$("#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: '<?php echo site_url("items/suggest_kits"); ?>',
minChars: 0,
delay: 15,
cacheLength: 1,
appendTo: '.modal-content',
select: fill_value,
focus: fill_value
});
$('#item_name').autocomplete({
source: "<?php echo site_url('items/suggest_kits'); ?>",
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('<?php echo site_url('item_kits'); ?>', response);
},
dataType:'json'
});
},
$('#item_kit_form').validate($.extend({
submitHandler: function(form) {
$(form).ajaxSubmit({
success: function(response)
{
dialog_support.hide();
table_support.handle_submit("<?php echo site_url($controller_name); ?>", response);
},
dataType: 'json'
});
},
rules:
{
name:"required",
category:"required"
},
errorLabelContainer: '#error_message_box',
messages:
{
name:"<?php echo $this->lang->line('items_name_required'); ?>",
category:"<?php echo $this->lang->line('items_category_required'); ?>"
}
}, form_support.error));
rules:
{
name: 'required',
category: 'required'
},
messages:
{
name: "<?php echo $this->lang->line('items_name_required'); ?>",
category: "<?php echo $this->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;
}
</script>

View File

@@ -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: "<?php echo site_url('items/suggest_category');?>", delay:10, appendTo: '.modal-content'});
$('#category').autocomplete({
source: "<?php echo site_url('items/suggest_category'); ?>",
appendTo: '.modal-content',
delay: 10
});
<?php for ($i = 1; $i <= 10; ++$i)
{
?>
$("#custom" + <?php echo $i; ?>).autocomplete({
$('#custom' + <?php echo $i; ?>).autocomplete({
source:function (request, response) {
$.ajax({
type: 'POST',
url: "<?php echo site_url('items/suggest_custom');?>",
url: "<?php echo site_url('items/suggest_custom'); ?>",
dataType: 'json',
data: $.extend(request, {field_no: <?php echo $i; ?>}),
success: function(data) {
@@ -409,10 +413,10 @@ $(document).ready(function()
}
?>
$("a.fileinput-exists").click(function() {
$('a.fileinput-exists').click(function() {
$.ajax({
type: 'GET',
url: "<?php echo site_url("$controller_name/remove_logo/$item_info->item_id"); ?>",
url: "<?php echo site_url($controller_name . '/remove_logo/' . $item_info->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", "<?php echo site_url("items/save/")?>");
$('#item_form').attr('action', "<?php echo site_url($controller_name . '/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('');
@@ -436,16 +440,18 @@ $(document).ready(function()
{
dialog_support.hide();
}
table_support.handle_submit('<?php echo site_url('items'); ?>', response, stay_open);
table_support.handle_submit("<?php echo site_url($controller_name); ?>", response, stay_open);
},
dataType: 'json'
});
},
errorLabelContainer: '#error_message_box',
rules:
{
name: "required",
category: "required",
name: 'required',
category: 'required',
item_number:
{
required: false,

View File

@@ -162,53 +162,60 @@
//validation and submit handling
$(document).ready(function()
{
$("#category").autocomplete({source: "<?php echo site_url('items/suggest_category');?>", appendTo:'.modal-content', delay:10});
$('#category').autocomplete({
source: "<?php echo site_url('items/suggest_category');?>",
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 ? "" : "<?php echo $this->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 ? '' : "<?php echo $this->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('<?php echo site_url('items'); ?>', response);
table_support.handle_submit("<?php echo site_url($controller_name); ?>", 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:

View File

@@ -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: "<?php echo $this->lang->line('common_import_full_path'); ?>"

View File

@@ -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('<?php echo site_url('items'); ?>', response);
},
dataType: 'json'
});
success: function(response)
{
dialog_support.hide();
table_support.handle_submit("<?php echo site_url($controller_name); ?>", 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: "<?php echo $this->lang->line('items_quantity_number'); ?>"
}
}
});
}, form_support.error));
});
function fill_quantity(val)
{
var item_quantities = <?php echo json_encode($item_quantities); ?>;
document.getElementById("quantity").value = parseFloat(item_quantities[val]).toFixed(<?php echo quantity_decimals(); ?>);
var item_quantities = <?php echo json_encode($item_quantities); ?>;
document.getElementById('quantity').value = parseFloat(item_quantities[val]).toFixed(<?php echo quantity_decimals(); ?>);
}
</script>

View File

@@ -35,45 +35,49 @@
<?php echo form_close(); ?>
<script type="text/javascript">
//validation and submit handling
$(document).ready(function()
{
$('#send_sms_form').validate($.extend({
submitHandler:function(form)
{
submitHandler: function(form) {
$(form).ajaxSubmit({
success:function(response)
success: function(response)
{
dialog_support.hide();
table_support.handle_submit('<?php echo site_url('messages'); ?>', response);
table_support.handle_submit("<?php echo site_url($controller_name); ?>", response);
},
dataType:'json'
dataType: 'json'
});
},
errorLabelContainer: '#error_message_box',
rules:
{
phone:
{
required:true,
number:true
required: true,
number: true
},
message:
{
required:true,
number:false
required: true,
number: false
}
},
messages:
{
phone:
{
required:"<?php echo $this->lang->line('messages_phone_number_required'); ?>",
number:"<?php echo $this->lang->line('messages_phone'); ?>"
required: "<?php echo $this->lang->line('messages_phone_number_required'); ?>",
number: "<?php echo $this->lang->line('messages_phone'); ?>"
},
message:
{
required:"<?php echo $this->lang->line('messages_message_required'); ?>"
required: "<?php echo $this->lang->line('messages_message_required'); ?>"
}
}
}, form_support.error));
});
</script>
</script>

View File

@@ -12,12 +12,12 @@
}
$.notifyDefaults({ placement: {
align: '<?php echo $this->config->item('notify_horizontal_position'); ?>',
from: '<?php echo $this->config->item('notify_vertical_position'); ?>'
align: "<?php echo $this->config->item('notify_horizontal_position'); ?>",
from: "<?php echo $this->config->item('notify_vertical_position'); ?>"
}});
var csrf_token = function() {
return Cookies.get('<?php echo $this->config->item('csrf_cookie_name'); ?>');
return Cookies.get("<?php echo $this->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')

View File

@@ -80,51 +80,39 @@ $(document).ready(function()
language: "<?php echo current_language_code(); ?>"
});
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: '<?php echo site_url("suppliers/suggest"); ?>',
$('#supplier_name').autocomplete({
source: "<?php echo site_url('suppliers/suggest'); ?>",
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('<?php echo site_url('receivings'); ?>', <?php echo $receiving_info['receiving_id']; ?>);
table_support.do_delete("<?php echo site_url($controller_name); ?>", <?php echo $receiving_info['receiving_id']; ?>);
});
// declare submitHandler as an object.. will be reused
var submit_form = function()
{
$(this).ajaxSubmit(
{
success:function(response)
{
dialog_support.hide();
table_support.handle_submit('<?php echo site_url('receivings'); ?>', 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("<?php echo site_url($controller_name); ?>", response);
},
dataType: 'json'
});
}
}, form_support.error));
});
</script>

View File

@@ -98,10 +98,10 @@ $(document).ready(function()
<?php if(!empty($sale_info['email'])): ?>
$('#send_invoice').click(function(event) {
if (confirm("<?php echo $this->lang->line('sales_invoice_confirm') . ' ' . $sale_info['email'] ?>")) {
$.get('<?php echo site_url() . "/sales/send_pdf/" . $sale_info['sale_id']; ?>',
$.get("<?php echo site_url($controller_name . '/send_pdf/' . $sale_info['sale_id']); ?>",
function(response) {
dialog_support.hide();
table_support.handle_submit('<?php echo site_url('sales'); ?>', response);
table_support.handle_submit("<?php echo site_url('sales'); ?>", response);
}, 'json'
);
}
@@ -134,7 +134,7 @@ $(document).ready(function()
todayBtn: true,
todayHighlight: true,
bootcssVer: 3,
language: '<?php echo current_language_code(); ?>'
language: "<?php echo current_language_code(); ?>"
});
var fill_value = function(event, ui) {
@@ -145,7 +145,7 @@ $(document).ready(function()
$('#customer_name').autocomplete(
{
source: '<?php echo site_url("customers/suggest"); ?>',
source: "<?php echo site_url('customers/suggest'); ?>",
minChars: 0,
delay: 15,
cacheLength: 1,
@@ -156,33 +156,29 @@ $(document).ready(function()
$('button#delete').click(function() {
dialog_support.hide();
table_support.do_delete('<?php echo site_url('sales'); ?>', <?php echo $sale_info['sale_id']; ?>);
table_support.do_delete("<?php echo site_url($controller_name); ?>", <?php echo $sale_info['sale_id']; ?>);
});
$('button#restore').click(function() {
dialog_support.hide();
table_support.do_restore('<?php echo site_url('sales'); ?>', <?php echo $sale_info['sale_id']; ?>);
table_support.do_restore("<?php echo site_url($controller_name); ?>", <?php echo $sale_info['sale_id']; ?>);
});
var submit_form = function()
{
$(this).ajaxSubmit(
{
success: function(response)
{
dialog_support.hide();
table_support.handle_submit('<?php echo site_url('sales'); ?>', 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("<?php echo site_url($controller_name); ?>", response);
},
dataType: 'json'
});
},
errorLabelContainer: '#error_message_box',
rules:
{
invoice_number:
@@ -200,9 +196,10 @@ $(document).ready(function()
}
}
},
messages:
{
invoice_number: '<?php echo $this->lang->line("sales_invoice_number_duplicate"); ?>'
invoice_number: "<?php echo $this->lang->line("sales_invoice_number_duplicate"); ?>"
}
}, form_support.error));
});

View File

@@ -56,8 +56,8 @@ if(isset($success))
?>
<li class="pull-right">
<button class='btn btn-default btn-sm modal-dlg' id='show_suspended_sales_button' data-href='<?php echo site_url($controller_name."/suspended"); ?>'
title='<?php echo $this->lang->line('sales_suspended_sales'); ?>'>
<button class='btn btn-default btn-sm modal-dlg' id='show_suspended_sales_button' data-href="<?php echo site_url($controller_name."/suspended"); ?>"
title="<?php echo $this->lang->line('sales_suspended_sales'); ?>">
<span class="glyphicon glyphicon-align-justify">&nbsp</span><?php echo $this->lang->line('sales_suspended_sales'); ?>
</button>
</li>
@@ -90,8 +90,8 @@ if(isset($success))
<span class="ui-helper-hidden-accessible" role="status"></span>
</li>
<li class="pull-right">
<button id='new_item_button' class='btn btn-info btn-sm pull-right modal-dlg' data-btn-new='<?php echo $this->lang->line('common_new') ?>' data-btn-submit='<?php echo $this->lang->line('common_submit')?>' data-href='<?php echo site_url("items/view"); ?>'
title='<?php echo $this->lang->line($controller_name . '_new_item'); ?>'>
<button id='new_item_button' class='btn btn-info btn-sm pull-right modal-dlg' data-btn-new="<?php echo $this->lang->line('common_new') ?>" data-btn-submit="<?php echo $this->lang->line('common_submit')?>" data-href="<?php echo site_url("items/view"); ?>"
title="<?php echo $this->lang->line($controller_name . '_new_item'); ?>">
<span class="glyphicon glyphicon-tag">&nbsp</span><?php echo $this->lang->line($controller_name. '_new_item'); ?>
</button>
</li>
@@ -207,7 +207,7 @@ if(isset($success))
}
?>
</td>
<td><a href="javascript:document.getElementById('<?php echo 'cart_'.$line ?>').submit();" title=<?php echo $this->lang->line('sales_update')?> ><span class="glyphicon glyphicon-refresh"></span></a></td>
<td><a href="javascript:document.getElementById("<?php echo 'cart_'.$line ?>").submit();" title=<?php echo $this->lang->line('sales_update')?> ><span class="glyphicon glyphicon-refresh"></span></a></td>
</tr>
<tr>
<?php
@@ -386,8 +386,8 @@ if(isset($success))
<label id="customer_label" for="customer" class="control-label" style="margin-bottom: 1em; margin-top: -1em;"><?php echo $this->lang->line('sales_select_customer') . ' ' . $customer_required; ?></label>
<?php echo form_input(array('name'=>'customer', 'id'=>'customer', 'class'=>'form-control input-sm', 'value'=>$this->lang->line('sales_start_typing_customer_name')));?>
<button class='btn btn-info btn-sm modal-dlg' data-btn-submit='<?php echo $this->lang->line('common_submit') ?>' data-href='<?php echo site_url("customers/view"); ?>'
title='<?php echo $this->lang->line($controller_name. '_new_customer'); ?>'>
<button class='btn btn-info btn-sm modal-dlg' data-btn-submit="<?php echo $this->lang->line('common_submit') ?>" data-href="<?php echo site_url("customers/view"); ?>"
title="<?php echo $this->lang->line($controller_name. '_new_customer'); ?>">
<span class="glyphicon glyphicon-user">&nbsp</span><?php echo $this->lang->line($controller_name. '_new_customer'); ?>
</button>
@@ -468,7 +468,7 @@ if(isset($success))
if($pos_mode == '1')
{
?>
<div class='btn btn-sm btn-success pull-right' id='finish_sale_button' tabindex='<?php echo ++$tabindex; ?>'><span class="glyphicon glyphicon-ok">&nbsp</span><?php echo $this->lang->line('sales_complete_sale'); ?></div>
<div class='btn btn-sm btn-success pull-right' id='finish_sale_button' tabindex="<?php echo ++$tabindex; ?>"><span class="glyphicon glyphicon-ok">&nbsp</span><?php echo $this->lang->line('sales_complete_sale'); ?></div>
<?php
}
?>
@@ -495,7 +495,7 @@ if(isset($success))
</table>
<?php echo form_close(); ?>
<div class='btn btn-sm btn-success pull-right' id='add_payment_button' tabindex='<?php echo ++$tabindex; ?>'><span class="glyphicon glyphicon-credit-card">&nbsp</span><?php echo $this->lang->line('sales_add_payment'); ?></div>
<div class='btn btn-sm btn-success pull-right' id='add_payment_button' tabindex="<?php echo ++$tabindex; ?>"><span class="glyphicon glyphicon-credit-card">&nbsp</span><?php echo $this->lang->line('sales_add_payment'); ?></div>
<?php
}
?>
@@ -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: '<?php echo site_url('sales/change_item_number');?>',
url: "<?php echo site_url('sales/change_item_number');?>",
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: '<?php echo site_url('sales/change_item_name');?>',
url: "<?php echo site_url('sales/change_item_name');?>",
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: '<?php echo site_url('sales/change_item_description');?>',
url: "<?php echo site_url('sales/change_item_description');?>",
method: 'post',
data: {
"item_id" : item_id,
@@ -686,12 +686,12 @@ $(document).ready(function()
$('#item').blur(function()
{
$(this).val('<?php echo $this->lang->line('sales_start_typing_item_name'); ?>');
$(this).val("<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
});
$('#item').autocomplete(
{
source: '<?php echo site_url($controller_name."/item_search"); ?>',
source: "<?php echo site_url($controller_name . '/item_search'); ?>",
minChars: 0,
autoFocus: false,
delay: 500,
@@ -711,7 +711,7 @@ $(document).ready(function()
var clear_fields = function()
{
if($(this).val().match('<?php echo $this->lang->line('sales_start_typing_item_name') . '|' . $this->lang->line('sales_start_typing_customer_name'); ?>'))
if($(this).val().match("<?php echo $this->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('<?php echo $this->lang->line('sales_start_typing_customer_name'); ?>');
$(this).val("<?php echo $this->lang->line('sales_start_typing_customer_name'); ?>");
});
$("#customer").autocomplete(
{
source: '<?php echo site_url("customers/suggest"); ?>',
source: "<?php echo site_url("customers/suggest"); ?>",
minChars: 0,
delay: 10,
select: function (a, ui) {
@@ -747,7 +747,7 @@ $(document).ready(function()
$(".giftcard-input").autocomplete(
{
source: '<?php echo site_url("giftcards/suggest"); ?>',
source: "<?php echo site_url("giftcards/suggest"); ?>",
minChars: 0,
delay: 10,
select: function (a, ui) {
@@ -758,7 +758,7 @@ $(document).ready(function()
$('#comment').keyup(function()
{
$.post('<?php echo site_url($controller_name."/set_comment");?>', {comment: $('#comment').val()});
$.post("<?php echo site_url($controller_name."/set_comment");?>", {comment: $('#comment').val()});
});
<?php
@@ -767,7 +767,7 @@ $(document).ready(function()
?>
$('#sales_invoice_number').keyup(function()
{
$.post('<?php echo site_url($controller_name."/set_invoice_number");?>', {sales_invoice_number: $('#sales_invoice_number').val()});
$.post("<?php echo site_url($controller_name."/set_invoice_number");?>", {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('<?php echo site_url($controller_name."/set_invoice_number_enabled");?>', {sales_invoice_number_enabled: enabled});
$.post("<?php echo site_url($controller_name."/set_invoice_number_enabled");?>", {sales_invoice_number_enabled: enabled});
});
<?php
}
@@ -790,42 +790,42 @@ $(document).ready(function()
$("#sales_print_after_sale").change(function()
{
$.post('<?php echo site_url($controller_name."/set_print_after_sale");?>', {sales_print_after_sale: $(this).is(":checked")});
$.post("<?php echo site_url($controller_name."/set_print_after_sale");?>", {sales_print_after_sale: $(this).is(":checked")});
});
$("#price_work_orders").change(function()
{
$.post('<?php echo site_url($controller_name."/set_price_work_orders");?>', {price_work_orders: $(this).is(":checked")});
$.post("<?php echo site_url($controller_name."/set_price_work_orders");?>", {price_work_orders: $(this).is(":checked")});
});
$('#email_receipt').change(function()
{
$.post('<?php echo site_url($controller_name."/set_email_receipt");?>', {email_receipt: $(this).is(":checked")});
$.post("<?php echo site_url($controller_name."/set_email_receipt");?>", {email_receipt: $(this).is(":checked")});
});
$("#finish_sale_button").click(function()
{
$('#buttons_form').attr('action', '<?php echo site_url($controller_name."/complete"); ?>');
$('#buttons_form').attr('action', "<?php echo site_url($controller_name."/complete"); ?>");
$('#buttons_form').submit();
});
$("#finish_invoice_quote_button").click(function()
{
$('#buttons_form').attr('action', '<?php echo site_url($controller_name."/complete"); ?>');
$('#buttons_form').attr('action', "<?php echo site_url($controller_name."/complete"); ?>");
$('#buttons_form').submit();
});
$("#suspend_sale_button").click(function()
{
$('#buttons_form').attr('action', '<?php echo site_url($controller_name."/suspend"); ?>');
$('#buttons_form').attr('action', "<?php echo site_url($controller_name."/suspend"); ?>");
$('#buttons_form').submit();
});
$("#cancel_sale_button").click(function()
{
if(confirm('<?php echo $this->lang->line("sales_confirm_cancel_sale"); ?>'))
if(confirm("<?php echo $this->lang->line("sales_confirm_cancel_sale"); ?>"))
{
$('#buttons_form').attr('action', '<?php echo site_url($controller_name."/cancel"); ?>');
$('#buttons_form').attr('action', "<?php echo site_url($controller_name."/cancel"); ?>");
$('#buttons_form').submit();
}
});
@@ -900,31 +900,31 @@ function check_payment_type()
{
var cash_rounding = <?php echo json_encode($cash_rounding); ?>;
if($("#payment_types").val() == '<?php echo $this->lang->line('sales_giftcard'); ?>')
if($("#payment_types").val() == "<?php echo $this->lang->line('sales_giftcard'); ?>")
{
$("#sale_total").html('<?php echo to_currency($total); ?>');
$("#sale_amount_due").html('<?php echo to_currency($amount_due); ?>');
$("#amount_tendered_label").html('<?php echo $this->lang->line('sales_giftcard_number'); ?>');
$("#sale_total").html("<?php echo to_currency($total); ?>");
$("#sale_amount_due").html("<?php echo to_currency($amount_due); ?>");
$("#amount_tendered_label").html("<?php echo $this->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() == '<?php echo $this->lang->line('sales_cash'); ?>' && cash_rounding)
else if($("#payment_types").val() == "<?php echo $this->lang->line('sales_cash'); ?>" && cash_rounding)
{
$("#sale_total").html('<?php echo to_currency($cash_total); ?>');
$("#sale_amount_due").html('<?php echo to_currency($cash_amount_due); ?>');
$("#amount_tendered_label").html('<?php echo $this->lang->line('sales_amount_tendered'); ?>');
$("#amount_tendered:enabled").val('<?php echo to_currency_no_money($cash_amount_due); ?>');
$("#sale_total").html("<?php echo to_currency($cash_total); ?>");
$("#sale_amount_due").html("<?php echo to_currency($cash_amount_due); ?>");
$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
$("#amount_tendered:enabled").val("<?php echo to_currency_no_money($cash_amount_due); ?>");
$(".giftcard-input").attr('disabled', true);
$(".non-giftcard-input").attr('disabled', false);
}
else
{
$("#sale_total").html('<?php echo to_currency($non_cash_total); ?>');
$("#sale_amount_due").html('<?php echo to_currency($non_cash_amount_due); ?>');
$("#amount_tendered_label").html('<?php echo $this->lang->line('sales_amount_tendered'); ?>');
$("#amount_tendered:enabled").val('<?php echo to_currency_no_money($non_cash_amount_due); ?>');
$("#sale_total").html("<?php echo to_currency($non_cash_total); ?>");
$("#sale_amount_due").html("<?php echo to_currency($non_cash_amount_due); ?>");
$("#amount_tendered_label").html("<?php echo $this->lang->line('sales_amount_tendered'); ?>");
$("#amount_tendered:enabled").val("<?php echo to_currency_no_money($non_cash_amount_due); ?>");
$(".giftcard-input").attr('disabled', true);
$(".non-giftcard-input").attr('disabled', false);
}

View File

@@ -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('<?php echo site_url('suppliers'); ?>', response);
},
dataType:'json'
});
success: function(response)
{
dialog_support.hide();
table_support.handle_submit("<?php echo site_url($controller_name); ?>", 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: "<?php echo $this->lang->line('suppliers_company_name_required'); ?>",
@@ -77,5 +79,4 @@ $(document).ready(function()
}
}, form_support.error));
});
</script>
</script>

View File

@@ -28,10 +28,10 @@
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->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')); ?>
<div class="col-xs-9">
<label class="radio-inline">
<div class="col-xs-9">
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'tax_code_type',
'type'=>'radio',
@@ -39,8 +39,8 @@
'value'=>0,
'checked'=>$tax_code_type == '0')
); ?> <?php echo $this->lang->line('taxes_sales_tax'); ?>
</label>
<label class="radio-inline">
</label>
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'tax_code_type',
'type'=>'radio',
@@ -48,8 +48,8 @@
'value'=>1,
'checked'=>$tax_code_type == '1')
); ?> <?php echo $this->lang->line('taxes_sales_tax_by_invoice'); ?>
</label>
<label class="radio-inline">
</label>
<label class="radio-inline">
<?php echo form_radio(array(
'name'=>'tax_code_type',
'type'=>'radio',
@@ -57,61 +57,61 @@
'value'=>1,
'checked'=>$tax_code_type == '2')
); ?> <?php echo $this->lang->line('taxes_vat_tax'); ?>
</label>
</div>
</div>
</label>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('common_city'), 'city', array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-8'>
<div class='col-xs-8'>
<?php echo form_input(array(
'name'=>'city',
'id'=>'city',
'class'=>'form-control input-sm',
'value'=>$city)
);?>
</div>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('common_state'), 'name', array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-8'>
<div class='col-xs-8'>
<?php echo form_input(array(
'name'=>'state',
'id'=>'state',
'class'=>'form-control input-sm',
'value'=>$state)
);?>
</div>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('taxes_tax_rate'), 'tax_rate', array('class' => 'required control-label col-xs-3')); ?>
<div class='col-xs-4'>
<div class="input-group input-group-sm">
<div class='col-xs-4'>
<div class="input-group input-group-sm">
<?php echo form_input(array(
'name'=>'tax_rate',
'id'=>'tax_rate',
'class'=>'form-control input-sm',
'value'=>$tax_rate)
);?>
<span class="input-group-addon input-sm"><b>%</b></span>
</div>
</div>
</div>
<span class="input-group-addon input-sm"><b>%</b></span>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('taxes_rounding_code'), 'rounding_code', array('class' => 'control-label col-xs-3')); ?>
<div class='col-xs-4'>
<div class='col-xs-4'>
<?php echo form_dropdown('rounding_code', $rounding_options, $rounding_code, array('class' => 'form-control input-sm')); ?>
</div>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<div class="form-group form-group-sm">
<?php echo form_label($this->lang->line('taxes_add_exception'), 'add_tax_category', array('class'=>'control-label col-xs-3')); ?>
<div class='col-xs-8'>
<div class="input-group">
<span class="input-group-addon input-sm"><span class="glyphicon glyphicon-tag"></span></span>
<div class='col-xs-8'>
<div class="input-group">
<span class="input-group-addon input-sm"><span class="glyphicon glyphicon-tag"></span></span>
<?php echo form_input(array(
'name'=>'add_tax_category',
'id'=>'add_tax_category',
@@ -119,98 +119,103 @@
'value'=>$add_tax_category)
);?>
<?php echo form_hidden('rate_tax_category_id', $rate_tax_category_id);?>
</div>
</div>
</div>
</div>
</div>
</div>
<table id="tax_code_rates" class="table table-striped table-hover">
<thead>
<tr>
<th width="10%"><?php echo $this->lang->line('common_delete'); ?></th>
<th width="30%"><?php echo $this->lang->line('taxes_tax_category'); ?></th>
<th width="30%"><?php echo $this->lang->line('taxes_tax_rate'); ?></th>
<th width="30%"><?php echo $this->lang->line('taxes_rounding_code'); ?></th>
</tr>
</thead>
<tbody>
<table id="tax_code_rates" class="table table-striped table-hover">
<thead>
<tr>
<th width="10%"><?php echo $this->lang->line('common_delete'); ?></th>
<th width="30%"><?php echo $this->lang->line('taxes_tax_category'); ?></th>
<th width="30%"><?php echo $this->lang->line('taxes_tax_rate'); ?></th>
<th width="30%"><?php echo $this->lang->line('taxes_rounding_code'); ?></th>
</tr>
</thead>
<tbody>
<?php
foreach($tax_code_rates as $tax_code_rate)
{
?>
<tr>
<td><a href='#' onclick='return delete_tax_code_rate_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td>
<td><?php echo $tax_code_rate['tax_category']; ?></td>
<td><input class='form-control input-sm' id='exception_tax_rate_<?php echo $tax_code_rate['rate_tax_category_id'] ?>' name=exception_tax_rate[<?php echo $tax_code_rate['rate_tax_category_id'] ?>] value='<?php echo $tax_code_rate['tax_rate'] ?>'/></td>
<td><?php echo form_dropdown('exception_rounding_code['.$tax_code_rate['rate_tax_category_id'].']', $rounding_options, $tax_code_rate['rounding_code'], array('class' => 'form-control input-sm'));?></td>
</tr>
<tr>
<td><a href='#' onclick='return delete_tax_code_rate_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td>
<td><?php echo $tax_code_rate['tax_category']; ?></td>
<td><input class='form-control input-sm' id='exception_tax_rate_<?php echo $tax_code_rate['rate_tax_category_id'] ?>' name=exception_tax_rate[<?php echo $tax_code_rate['rate_tax_category_id'] ?>] value="<?php echo $tax_code_rate['tax_rate'] ?>"/></td>
<td><?php echo form_dropdown('exception_rounding_code['.$tax_code_rate['rate_tax_category_id'].']', $rounding_options, $tax_code_rate['rounding_code'], array('class' => 'form-control input-sm'));?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</tbody>
</table>
</fieldset>
</fieldset>
<?php echo form_close(); ?>
<script type="text/javascript">
//validation and submit handling
$(document).ready(function() {
//validation and submit handling
$(document).ready(function()
{
$('#tax_code_form').validate($.extend({
submitHandler: function (form) {
$(form).ajaxSubmit({
success: function (response)
{
dialog_support.hide();
table_support.handle_submit("<?php echo site_url($controller_name); ?>", response);
},
dataType: 'json'
});
$('#tax_code_form').validate($.extend({
submitHandler: function (form) {
$(form).ajaxSubmit({
success: function (response) {
dialog_support.hide();
table_support.handle_submit('<?php echo site_url('taxes'); ?>', response);
},
dataType: 'json'
});
},
},
rules: {
tax_code: "required",
tax_rate: "required"
},
messages: {
tax_code: "<?php echo $this->lang->line('taxes_tax_code_required'); ?>",
tax_rate: "<?php echo $this->lang->line('taxes_tax_rate_required'); ?>"
}
}, form_support.error));
errorLabelContainer: '#error_message_box',
rules:
{
tax_code: 'required',
tax_rate: 'required'
},
$("#add_tax_category").autocomplete({
source: '<?php echo site_url("taxes/suggest_tax_categories"); ?>',
minChars: 0,
autoFocus: false,
delay: 10,
appendTo: ".modal-content",
select: function (e, ui) {
messages:
{
tax_code: "<?php echo $this->lang->line('taxes_tax_code_required'); ?>",
tax_rate: "<?php echo $this->lang->line('taxes_tax_rate_required'); ?>"
}
}, form_support.error));
var rounding_options = "<?php echo $html_rounding_options; ?>";
$('#add_tax_category').autocomplete({
source: "<?php echo site_url($controller_name . '/suggest_tax_categories'); ?>",
minChars: 0,
autoFocus: false,
delay: 10,
appendTo: '.modal-content',
select: function (e, ui) {
if ($("#tax_category_id" + ui.item.value).length == 1) {
$("#tax_category_id" + ui.item.value).val(parseFloat($("#tax_category_id" + ui.item.value).val()) + 1);
} else {
$("#tax_code_rates").append("<tr>" +
"<td><a href='#' onclick='return delete_tax_code_rate_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td>" +
"<td>" + ui.item.label + "</td>" +
"<td><input class='form-control input-sm' id='exception_tax_rate_" + ui.item.value + "' name=exception_tax_rate[" + ui.item.value + "] value=''/></td>" +
"<td><select id='exception_rounding_code_" + ui.item.value + "' class='form-control input-sm' name=exception_rounding_code[" + ui.item.value +
"] aria-invalid='false'>" + rounding_options + "</select></td>" +
"</tr>");
}
$("#add_tax_category").val("");
return false;
}
});
var rounding_options = "<?php echo $html_rounding_options; ?>";
if ($('#tax_category_id' + ui.item.value).length == 1) {
$('#tax_category_id' + ui.item.value).val(parseFloat($('#tax_category_id' + ui.item.value).val()) + 1);
}
else
{
$('#tax_code_rates').append("<tr>" +
"<td><a href='#' onclick='return delete_tax_code_rate_row(this);'><span class='glyphicon glyphicon-trash'></span></a></td>" +
"<td>" + ui.item.label + "</td>" +
"<td><input class='form-control input-sm' id='exception_tax_rate_" + ui.item.value + "' name=exception_tax_rate[" + ui.item.value + "] value=''/></td>" +
"<td><select id='exception_rounding_code_" + ui.item.value + "' class='form-control input-sm' name=exception_rounding_code[" + ui.item.value +
"] aria-invalid='false'>" + rounding_options + "</select></td>" +
"</tr>");
}
$('#add_tax_category').val('');
return false;
}
});
});
});
function delete_tax_code_rate_row(link) {
$(link).parent().parent().remove();
return false;
}
function delete_tax_code_rate_row(link) {
$(link).parent().parent().remove();
return false;
}
</script>