Fix submit in items, customers and sales (#716)

Add again new button functionality in items (#712)
Bugfixes for csrf tokens (#599)
This commit is contained in:
jekkos
2016-07-04 21:42:02 +02:00
parent 01486fd41e
commit 7b674b2e3f
17 changed files with 83 additions and 102 deletions

View File

@@ -887,7 +887,7 @@ class Reports extends Secure_Controller
'reference' => $report_data['reference'],
'comment' => $report_data['comment'],
'edit' => anchor("receivings/edit/". $report_data['receiving_id'], '<span class="glyphicon glyphicon-edit"></span>',
array('class'=>"modal-dlg print_hide", 'data-btn-delete' => $this->lang->line('common_delete'), 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('receivings_update'))
array('class'=>"modal-dlg print_hide", 'data-btn-submit' => $this->lang->line('common_submit'), 'data-btn-delete' => $this->lang->line('common_delete'), 'title' => $this->lang->line('receivings_update'))
)
));

View File

@@ -283,10 +283,10 @@ function get_item_data_row($item, $controller)
array('class' => 'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title' => $CI->lang->line($controller_name.'_count'))
),
'stock' => anchor($controller_name."/count_details/$item->item_id", '<span class="glyphicon glyphicon-list-alt"></span>',
array('class' => 'modal-dlg', 'title' => $CI->lang->line($controller_name.'_details_count'))
array('class' => 'modal-dlg', 'title' => $CI->lang->line($controller_name.'_details_count'))
),
'edit' => anchor($controller_name."/view/$item->item_id", '<span class="glyphicon glyphicon-edit"></span>',
array('class' => 'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title' => $CI->lang->line($controller_name.'_update'))
array('class' => 'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'data-btn-new' => $CI->lang->line('common_new'), 'title' => $CI->lang->line($controller_name.'_update'))
));
}

View File

@@ -83,6 +83,7 @@ $(document).ready(function()
submitHandler:function(form)
{
$(form).ajaxSubmit({
beforeSerialize: setup_csrf_token(),
success:function(response)
{
dialog_support.hide();
@@ -102,14 +103,14 @@ $(document).ready(function()
{
url: "<?php echo site_url($controller_name . '/check_account_number')?>",
type: "post",
data:
data: $.extend(csrf_form_base(),
{
"person_id" : "<?php echo $person_info->person_id; ?>",
"account_number" : function()
{
return $("#account_number").val();
}
}
})
}
}
},

View File

@@ -283,8 +283,9 @@
//validation and submit handling
$(document).ready(function()
{
$("#continue").click(function() {
$("#new").click(function() {
stay_open = true;
$("#item_form").submit();
});
$("#submit").click(function() {
@@ -303,7 +304,7 @@
type: "POST",
url: "<?php echo site_url('items/suggest_custom');?>",
dataType: "json",
data: $.extend(request, {field_no: <?php echo $i; ?>}),
data: $.extend(request, $extend(csrf_form_base(), {field_no: <?php echo $i; ?>})),
success: function(data) {
response($.map(data, function(item) {
return {
@@ -330,6 +331,7 @@
$('#item_form').validate($.extend({
submitHandler: function(form, event) {
$(form).ajaxSubmit({
beforeSerialize: setup_csrf_token,
success: function(response) {
var stay_open = dialog_support.clicked_id() != 'submit';
if (stay_open)
@@ -363,14 +365,14 @@
{
url: "<?php echo site_url($controller_name . '/check_item_number')?>",
type: "post",
data:
data: $.extend(csrf_form_base(),
{
"item_id" : "<?php echo $item_info->item_id; ?>",
"item_number" : function()
{
return $("#item_number").val();
}
}
},
})
}
},
cost_price:

View File

@@ -55,6 +55,7 @@
<script src="bower_components/chartist-plugin-pointlabels/dist/chartist-plugin-pointlabels.min.js"></script>
<script src="bower_components/chartist-plugin-tooltip/dist/chartist-plugin-tooltip.min.js"></script>
<script src="bower_components/remarkable-bootstrap-notify/bootstrap-notify.js"></script>
<script src="bower_components/js-cookie/src/js.cookie.js"></script>
<!-- endbower -->
<!-- start js template tags -->
<script type="text/javascript" src="js/imgpreview.full.jquery.js"></script>
@@ -68,50 +69,15 @@
<!-- start mincss template tags -->
<link rel="stylesheet" type="text/css" href="dist/bootstrap.min.css?rel=9ed20b1ee8"/>
<link rel="stylesheet" type="text/css" href="dist/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=f8daa2f957"/>
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=80813172ba"/>
<!-- end mincss template tags -->
<!-- start minjs template tags -->
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=75d94393ed"></script>
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=1dbb3c287c"></script>
<!-- end minjs template tags -->
<?php endif; ?>
<?php $this->load->view('partial/lang_lines'); ?>
<script type="text/javascript">
// live clock
var clock_tick = function clock_tick() {
setInterval('update_clock();', 1000);
}
// start the clock immediatly
clock_tick();
var update_clock = function update_clock() {
document.getElementById('liveclock').innerHTML = moment().format("<?php echo dateformat_momentjs($this->config->item('dateformat').' '.$this->config->item('timeformat'))?>");
}
$.notifyDefaults({ placement: {
align: '<?php echo $this->config->item('config_notify_horizontal_position'); ?>',
from: '<?php echo $this->config->item('config_notify_vertical_position'); ?>'
}});
var post = $.post;
$.post = function() {
post.call(this, arguments[0], $.extend(arguments[1], {
<?php echo $this->security->get_csrf_token_name(); ?> : Cookies.get('<?php echo $this->config->item('csrf_cookie_name'); ?>')
}));
};
var setup_csrf = function() {
var csrf_cookie_val = Cookies.get('<?php echo $this->config->item('csrf_cookie_name'); ?>');
$('input[name="<?php echo $this->security->get_csrf_token_name(); ?>"]').val(csrf_cookie_val);
};
setup_csrf();
$(document).ajaxComplete(setup_csrf);
</script>
<?php $this->load->view('partial/header_js'); ?>
<style type="text/css">
html {

View File

@@ -0,0 +1,40 @@
<script type="text/javascript">
// live clock
var clock_tick = function clock_tick() {
setInterval('update_clock();', 1000);
}
// start the clock immediatly
clock_tick();
var update_clock = function update_clock() {
document.getElementById('liveclock').innerHTML = moment().format("<?php echo dateformat_momentjs($this->config->item('dateformat').' '.$this->config->item('timeformat'))?>");
}
$.notifyDefaults({ placement: {
align: '<?php echo $this->config->item('config_notify_horizontal_position'); ?>',
from: '<?php echo $this->config->item('config_notify_vertical_position'); ?>'
}});
var post = $.post;
var csrf_token = function() {
return Cookies.get('<?php echo $this->config->item('csrf_cookie_name'); ?>');
};
var csrf_form_base = function() {
return { <?php echo $this->security->get_csrf_token_name(); ?> : function () { return csrf_token(); } };
};
$.post = function() {
post.call(this, arguments[0], $.extend(arguments[1], csrf_form_base()));
};
var setup_csrf_token = function() {
$('input[name="<?php echo $this->security->get_csrf_token_name(); ?>"]').val(csrf_token());
};
setup_csrf_token();
$(document).ajaxComplete(setup_csrf_token);
</script>

View File

@@ -123,14 +123,6 @@ $(document).ready(function()
submitHandler : function(form)
{
submit_form.call(form);
},
rules:
{
},
messages:
{
}
}, form_support.error));

View File

@@ -493,6 +493,7 @@ $(document).ready(function()
{
if(response.success)
{
setup_csrf_token();
if (resource.match(/suppliers$/))
{
$("#supplier").attr("value",response.id);

View File

@@ -164,6 +164,7 @@ $(document).ready(function()
{
$(this).ajaxSubmit(
{
beforeSerialize: setup_csrf_token(),
success: function(response)
{
dialog_support.hide();
@@ -187,14 +188,14 @@ $(document).ready(function()
{
url: "<?php echo site_url($controller_name . '/check_invoice_number')?>",
type: "POST",
data:
data: $.extend(csrf_form_base(),
{
"sale_id" : <?php echo $sale_info['sale_id']; ?>,
"invoice_number" : function()
{
return $("#invoice_number").val();
}
}
})
}
}
},

View File

@@ -46,7 +46,7 @@ if (isset($success))
?>
<li class="pull-right">
<button class='btn btn-default btn-sm modal-dlg' id='show_suspended_sales_button' data-btn-submit='<?php echo $this->lang->line('common_submit'); ?>', data-href='<?php echo site_url($controller_name."/suspended"); ?>'
<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>
@@ -78,7 +78,7 @@ 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-submit='<?php echo $this->lang->line('common_submit') ?>' data-href='<?php echo site_url("items/view"); ?>'
<button id='new_item_button' class='btn btn-info btn-sm pull-right modal-dlg' data-btn-submit='<?php echo $this->lang->line('common_submit')?>' data-btn-new='<?php echo $this->lang->line('common_new') ?>' 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>
@@ -672,6 +672,7 @@ $(document).ready(function()
table_support.handle_submit = function(resource, response, stay_open)
{
if(response.success) {
setup_csrf_token();
if (resource.match(/customers$/))
{
$("#customer").val(response.id);

View File

@@ -40,7 +40,8 @@
"chartist-plugin-axistitle": "^0.1.0",
"chartist-plugin-pointlabels": "^0.0.4",
"chartist-plugin-tooltip": "https://github.com/Globegitter/chartist-plugin-tooltip/archive/master.zip",
"remarkable-bootstrap-notify": "^3.1.3"
"remarkable-bootstrap-notify": "^3.1.3",
"js-cookie": "^2.1.2"
},
"overrides": {
"bootswatch-dist": {

View File

@@ -122,4 +122,9 @@
padding: 0.5em;
text-align: left;
clear: both;
}
.alert
{
margin-bottom: 5px;
}

View File

@@ -48054,7 +48054,9 @@ typeof h.headerrows&&(h.headerrows.length=0);"undefined"!=typeof h.columns&&(h.c
dialog_ref.close();
}
});
return { buttons: buttons, cssClass: dialog_class};
return { buttons: buttons.sort(function(a, b) {
return ($(b).text()) < ($(a).text()) ? 1 : -1;
}), cssClass: dialog_class};
};
$(selector).each(function(index, $element) {

View File

File diff suppressed because one or more lines are too long

View File

File diff suppressed because one or more lines are too long

View File

@@ -60,7 +60,9 @@
dialog_ref.close();
}
});
return { buttons: buttons, cssClass: dialog_class};
return { buttons: buttons.sort(function(a, b) {
return ($(b).text()) < ($(a).text()) ? 1 : -1;
}), cssClass: dialog_class};
};
$(selector).each(function(index, $element) {

View File

@@ -68,49 +68,16 @@
<link rel="stylesheet" type="text/css" href="templates/spacelab/css/bootstrap.min.css?rel=9ed20b1ee8"/>
<!-- start mincss template tags -->
<link rel="stylesheet" type="text/css" href="dist/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=f8daa2f957"/>
<link rel="stylesheet" type="text/css" href="dist/opensourcepos.min.css?rel=80813172ba"/>
<!-- end mincss template tags -->
<link rel="stylesheet" type="text/css" href="templates/spacelab/css/style.css"/>
<!-- start minjs template tags -->
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=75d94393ed"></script>
<script type="text/javascript" src="dist/opensourcepos.min.js?rel=1dbb3c287c" language="javascript"></script>
<!-- end minjs template tags -->
<?php endif; ?>
<script type="text/javascript">
// live clock
var clock_tick = function clock_tick() {
setInterval('update_clock();', 1000);
}
// start the clock immediatly
clock_tick();
var update_clock = function update_clock() {
document.getElementById('liveclock').innerHTML = moment().format("<?php echo dateformat_momentjs($this->config->item('dateformat').' '.$this->config->item('timeformat'))?>");
}
$.notifyDefaults({ placement: {
align: '<?php echo $this->config->item('config_notify_horizontal_position'); ?>',
from: '<?php echo $this->config->item('config_notify_vertical_position'); ?>'
}});
var post = $.post;
$.post = function() {
post.call(this, arguments[0], $.extend(arguments[1], {
<?php echo $this->security->get_csrf_token_name(); ?> : Cookies.get('<?php echo $this->config->item('csrf_cookie_name'); ?>')
}));
};
var setup_csrf = function() {
var csrf_cookie_val = Cookies.get('<?php echo $this->config->item('csrf_cookie_name'); ?>');
$('input[name="<?php echo $this->security->get_csrf_token_name(); ?>"]').val(csrf_cookie_val);
};
setup_csrf();
$(document).ajaxComplete(setup_csrf);
</script>
<?php $this->load->view('partial/lang_lines'); ?>
<?php $this->load->view('partial/header_js'); ?>
<style type="text/css">
html {