add customer at first
This commit is contained in:
@@ -1187,79 +1187,18 @@ $(function() {
|
||||
|
||||
// Pay Discount for Payment
|
||||
$("#create_pay_order").on('click', function(e){
|
||||
$("#sxModal").show();
|
||||
$("#sxModal").attr('data-for', 'member');
|
||||
$(this).attr('disabled', 'disabled');
|
||||
e.preventDefault();
|
||||
type = $("#link_type").val();
|
||||
modify_order = window.location.href.indexOf("modify_order");
|
||||
$("#oqs_loading_wrapper").show();
|
||||
if (modify_order !=-1) {
|
||||
var ajax_url = '../../../'+type+'/update_modify_order';
|
||||
var table_type = $('#table_type').text();
|
||||
var table_id = $('#table_id').text();
|
||||
var customer_id = $('#customer_id').text();
|
||||
var booking_id = $('#booking_id').text();
|
||||
var sale_id = $('#sale_id').text();
|
||||
}else{
|
||||
var ajax_url = 'addorders/create';
|
||||
var table_type = $('#table_id').find("option:selected").data('type');
|
||||
var table_id = $('#table_id').val();
|
||||
var customer_id = $('#customer_id').val();
|
||||
var booking_id = $('#booking_id').text();
|
||||
var sale_id = ""
|
||||
}
|
||||
var order_items = JSON.stringify(get_order_item_rows());
|
||||
if (booking_id.length > 0) {
|
||||
getCardNo();
|
||||
});
|
||||
|
||||
var params = {'order_source': type, 'order_type': "dine_in",
|
||||
'customer_id': customer_id, 'guest_info': "",'booking_id':booking_id,
|
||||
'table_id': table_id,
|
||||
'order_items': order_items,'sale_id': sale_id,'create_type': "create_pay" };
|
||||
}else{
|
||||
var params = {'order_source': type, 'order_type': "dine_in",
|
||||
'customer_id': customer_id, 'guest_info': "",
|
||||
'table_id': table_id,
|
||||
'order_items': order_items,'sale_id': sale_id,'create_type': "create_pay" };
|
||||
$("#sxModal .btn_cancel").on('click',function(){
|
||||
if($("#order-items-table tr").length > 1){
|
||||
$( "#create_pay_order" ).prop( "disabled", false );
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
if (result.status) {
|
||||
if (result.data == null){
|
||||
swal({
|
||||
title: "Please Open Shift !",
|
||||
text: result.status,
|
||||
type: "warning",
|
||||
confirmButtonColor: "#DD6B55",
|
||||
confirmButtonText: "Ok",
|
||||
closeOnConfirm: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text();
|
||||
});
|
||||
|
||||
}else if(result.data == 'OK'){
|
||||
if (window.location.pathname.includes('foodcourt')) {
|
||||
order_id = $('#order_id').val()
|
||||
window.location.href = '/foodcourt/food_court/'+order_id+'/request_bill'
|
||||
}
|
||||
else {
|
||||
window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text();
|
||||
}
|
||||
}else{
|
||||
if(result.current_user_role == 'cashier'){
|
||||
window.location.href = "/foodcourt/sale/"+result.data["sale_id"]+"/"+type+"/payment";
|
||||
}
|
||||
else{
|
||||
module_name = window.location.pathname.includes('origami') ? 'origami' : 'foodcourt'
|
||||
window.location.href = "/"+module_name+"/sale/"+result.data["sale_id"]+"/"+type+"/payment";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$("#sxModal").hide();
|
||||
});
|
||||
|
||||
//click item row for update qty
|
||||
@@ -1374,29 +1313,6 @@ $(function() {
|
||||
});
|
||||
}
|
||||
|
||||
/* Get Item rows */
|
||||
function get_order_item_rows(){
|
||||
var order_items = [];
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
$(item_row).each(function(i){
|
||||
var order_item = {};
|
||||
|
||||
order_item.order_item_id = $(item_row[i]).attr('data-row');
|
||||
order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
|
||||
order_item.quantity = $(item_row[i]).children('#item_qty').text();
|
||||
//parent id
|
||||
if ($(item_row[i]).attr('data-parent')=="true") {
|
||||
parent_id = $(item_row[i]).attr('data-row');
|
||||
}
|
||||
if ($(item_row[i]).attr('data-sub-item')=="true") {
|
||||
order_item.parent_order_item_id = parent_id
|
||||
}
|
||||
//end parent id
|
||||
order_item.options = $(item_row[i]).attr('data-options');
|
||||
order_items.push(order_item);
|
||||
});
|
||||
return order_items;
|
||||
}
|
||||
// Get Selected Class
|
||||
function get_selected_attributes(selected_class) {
|
||||
var item_row = $('.'+selected_class);
|
||||
@@ -1969,3 +1885,26 @@ $(function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
/* Get Item rows */
|
||||
function get_order_item_rows(){
|
||||
var order_items = [];
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
$(item_row).each(function(i){
|
||||
var order_item = {};
|
||||
|
||||
order_item.order_item_id = $(item_row[i]).attr('data-row');
|
||||
order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
|
||||
order_item.quantity = $(item_row[i]).children('#item_qty').text();
|
||||
//parent id
|
||||
if ($(item_row[i]).attr('data-parent')=="true") {
|
||||
parent_id = $(item_row[i]).attr('data-row');
|
||||
}
|
||||
if ($(item_row[i]).attr('data-sub-item')=="true") {
|
||||
order_item.parent_order_item_id = parent_id
|
||||
}
|
||||
//end parent id
|
||||
order_item.options = $(item_row[i]).attr('data-options');
|
||||
order_items.push(order_item);
|
||||
});
|
||||
return order_items;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user