function order() {}
order.prototype = {
order: this,
modal: undefined,
cancellation: function (orderId) {
$.ajax({
url: '/order/cancellation',
data: {
order: orderId,
reason: 'Cancelamento de pedido não pago'
},
method: 'post',
beforeSend: function () {
ajaxLoader.ajaxStart();
},
complete: function () {
ajaxLoader.ajaxStop();
},
success: function (res) {
if (res.cancelOrderTotem) {
order.cancelOrderTotem();
return;
}
window.location.href = '/order/index?order=' + orderId;
},
error: function (e) {
alert(JSON.stringify(e));
}
});
},
printModal: function () {
var modal = new Modal({
title: translate["order-js-print-title"],
body: translate["order-js-print-rule-1"]
+ "
" + translate["order-js-print-rule-2"]
+ "
" + translate["order-js-print-rule-3"]
+ "
" + translate["order-js-print-confirm-message"],
okText: translate["order-js-print-confirm-button"],
cancel: function () {
order.modal.hide();
},
confirm: function () {
order.printConfirmation();
}
});
order.modal = modal;
order.modal.show();
},
printConfirmation: function () {
var orderId = $("#orderId").val();
order.generateTickets(orderId);
var errorMessage = translate["order-js-print-try-error"];
$.ajax({
url: '/print-at-home/print-confirmation',
data: {orderId: orderId},
success: function (data) {
if (data) {
order.modal.hide();
}
},
error: function () {
alert(errorMessage);
}
});
},
generateTickets: function (orderId) {
window.open('/print-at-home/print-at-home?orderId=' + orderId);
},
print: function () {
window.print();
},
submit: function (form) {
document.getElementById(form).submit();
},
changeOrderAccessMethod: function(orderId, message) {
var modal = new Modal({
title: translate["order-js-change-access-method-title"],
body: '