Pull from master

This commit is contained in:
San Wai Lwin
2018-03-15 13:48:52 +06:30
parent 96f8640df7
commit 1188f6e8e9
29 changed files with 242 additions and 97 deletions

23
app/views/origami/split_bill/index.html.erb Normal file → Executable file
View File

@@ -624,20 +624,39 @@ function orderItemSplitBillProcess(cnt_items){
}
var order_ids = [];
var arr_order_ids = [];
if(order_items!=undefined && order_items!=null){
$.each(order_items,function(key,value){
var orderIds = {};
if($.inArray(value.order_id,order_ids) == -1){
order_ids.push(value.order_id);
orderIds[value.order_id] = 1;
arr_order_ids.push(orderIds);
}else{
if(arr_order_ids != null & arr_order_ids!=""){
if(arr_order_ids.length > 0){
$.each(arr_order_ids, function(k,val){
$.each(val,function(kk,vval){
if((val[kk]!= undefined) && (kk == value.order_id)){
val[kk] += 1;
}
});
arr_order_ids[k] = val;
});
}
}
}
});
}
// console.log(JSON.stringify(arr_order_ids));
var ajax_url = "/origami/split_bills";
$.ajax({
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : order_ids, 'order_items' : JSON.stringify(order_items), 'orders' : ''},
data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : order_ids, 'arr_order_ids': JSON.stringify(arr_order_ids), 'order_items' : JSON.stringify(order_items), 'orders' : ''},
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
@@ -670,7 +689,7 @@ function orderSplitBillProcess(cnt_orders){
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : [], 'order_items' : '', 'orders' : JSON.stringify(orders)},
data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : [], 'order_items' : '', 'orders' : JSON.stringify(orders), 'arr_order_ids': []},
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);