update action cable and other bugs

This commit is contained in:
Aung Myo
2018-05-21 13:00:55 +06:30
parent e722ab88e9
commit 7e8b69aa7c
26 changed files with 749 additions and 537 deletions

View File

@@ -6,68 +6,73 @@ App.call_waiter = App.cable.subscriptions.create('CallWaiterChannel', {
disconnected: function() {},
received: function(data) {
table = data.table
time = data.time
// for Notificaiotn message
var element = "#notify-wrapper"
var animateEnter = "";
var animateExit = "";
if (time == 'print_error') {
var colorName = "alert-danger";
var placementFrom = "center";
var placementAlign = "center";
var text = " Hello <br> "+table ;
style =""
}else{
var colorName = "alert-warning";
var placementFrom = "top";
var placementAlign = "center";
var text = " Calling Waiter <br> "+table.name ;
style ="width:180px !important;"
}
if (text != null || colorName != null){
showNotification(element, colorName, text, placementFrom, placementAlign, animateEnter, animateExit);
}
function showNotification(element, colorName, text, placementFrom, placementAlign, animateEnter, animateExit) {
if (colorName === null || colorName === '') { colorName = 'bg-black'; }
if (animateEnter === null || animateEnter === '') { animateEnter = 'animated fadeInDown'; }
if (animateExit === null || animateExit === '') { animateExit = 'animated fadeOutUp'; }
var allowDismiss = true;
$.notify({
message: text
},
var hostname = location.hostname.trim();
if(data.from == "" || hostname == data.from)
{
element: element,
type: colorName,
allow_dismiss: allowDismiss,
timer: 200000000000000,
placement: {
from: placementFrom,
align: placementAlign
},
animate: {
enter: animateEnter,
exit: animateExit
},
template: '<div data-notify="container" style="'+style+'" class="bootstrap-notify-container alert alert-dismissible {0} ' + (allowDismiss ? "p-r-30" : "") + '" role="alert">' +
'<button type="button" aria-hidden="true" class="close notify-close float-right m-l-5 m-t--5" data-notify="dismiss">×</button>' +
'<span data-notify="icon"></span> ' +
'<span data-notify="title">{1}</span> ' +
'<span data-notify="message">{2}</span>' +
'<div class="progress" data-notify="progressbar">' +
'<div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' +
'</div>' +
'<a href="{3}" target="{4}" data-notify="url"></a>' +
'</div>'
});
table = data.table
time = data.time
// for Notificaiotn message
var element = "#notify-wrapper"
var animateEnter = "";
var animateExit = "";
if (time == 'print_error') {
var colorName = "alert-danger";
var placementFrom = "center";
var placementAlign = "center";
var text = " Hello <br> "+table ;
style =""
}else{
var colorName = "alert-warning";
var placementFrom = "top";
var placementAlign = "center";
var text = " Calling Waiter <br> "+table.name ;
style ="width:180px !important;"
}
if (text != null || colorName != null){
showNotification(element, colorName, text, placementFrom, placementAlign, animateEnter, animateExit);
}
function showNotification(element, colorName, text, placementFrom, placementAlign, animateEnter, animateExit) {
if (colorName === null || colorName === '') { colorName = 'bg-black'; }
if (animateEnter === null || animateEnter === '') { animateEnter = 'animated fadeInDown'; }
if (animateExit === null || animateExit === '') { animateExit = 'animated fadeOutUp'; }
var allowDismiss = true;
$.notify({
message: text
},
{
element: element,
type: colorName,
allow_dismiss: allowDismiss,
timer: 200000000000000,
placement: {
from: placementFrom,
align: placementAlign
},
animate: {
enter: animateEnter,
exit: animateExit
},
template: '<div data-notify="container" style="'+style+'" class="bootstrap-notify-container alert alert-dismissible {0} ' + (allowDismiss ? "p-r-30" : "") + '" role="alert">' +
'<button type="button" aria-hidden="true" class="close notify-close float-right m-l-5 m-t--5" data-notify="dismiss">×</button>' +
'<span data-notify="icon"></span> ' +
'<span data-notify="title">{1}</span> ' +
'<span data-notify="message">{2}</span>' +
'<div class="progress" data-notify="progressbar">' +
'<div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' +
'</div>' +
'<a href="{3}" target="{4}" data-notify="url"></a>' +
'</div>'
});
}
//end Notificaiotn message
}
}
//end Notificaiotn message
}
});

View File

@@ -5,12 +5,16 @@ App.checkin = App.cable.subscriptions.create('CheckInBookingChannel', {
disconnected: function() {},
received: function(data) {
if($('.table_'+data.table.id).hasClass('green')){
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('blue');
}
$('.new_text_'+data.table.id).removeClass('hide');
received: function(data) {
var hostname = location.hostname.trim();
if(data.from == "" || hostname == data.from)
{
if($('.table_'+data.table.id).hasClass('green')){
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('blue');
}
$('.new_text_'+data.table.id).removeClass('hide');
}
}
});

View File

@@ -3,36 +3,40 @@ App.check_new_order = App.cable.subscriptions.create('CheckNewOrderChannel', {
disconnected: function() {},
received: function(data) {
var order = data.data;
var shop_code = data.shop_code;
if(order.length > 0){
var order_lists = "";
$.each(order, function(key, value){
if(key==0){
order_lists = value.order_reservation_id;
}else if(key == (order.length - 1)){
order_lists += ' and ' + value.order_reservation_id;
}else{
order_lists += ', ' + value.order_reservation_id;
}
});
received: function(data) {
var hostname = location.hostname.trim();
if(data.from == "" || hostname == data.from)
{
var order = data.data;
var shop_code = data.shop_code;
if(order.length > 0){
var order_lists = "";
$.each(order, function(key, value){
if(key==0){
order_lists = value.order_reservation_id;
}else if(key == (order.length - 1)){
order_lists += ' and ' + value.order_reservation_id;
}else{
order_lists += ', ' + value.order_reservation_id;
}
});
// alert(order_lists);
checkNewOrderAlert(shop_code, order_lists);
// $("#notify_new_order_lists").text(order_lists);
// if($("#"+shop_code+"_notify_new_order").hasClass("hidden")){
// $("#"+shop_code+"_notify_new_order").removeClass("hidden");
// }
// $("#"+shop_code+"_notify_new_order").on('shown.bs.modal', function(e){
// // $(document).off('focusin.modal');
// $("#"+shop_code+"_notify_new_order").focus();
// $("#"+shop_code+"_doemal_new_order").addClass("hidden");
// $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden");
// $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden");
// }).on('hide.bs.modal', function (e) {
// $("#"+shop_code+"_notify_new_order").addClass("hidden");
// }).modal({show: true, keyboard: false, backdrop: false});
// alert(order_lists);
checkNewOrderAlert(shop_code, order_lists);
// $("#notify_new_order_lists").text(order_lists);
// if($("#"+shop_code+"_notify_new_order").hasClass("hidden")){
// $("#"+shop_code+"_notify_new_order").removeClass("hidden");
// }
// $("#"+shop_code+"_notify_new_order").on('shown.bs.modal', function(e){
// // $(document).off('focusin.modal');
// $("#"+shop_code+"_notify_new_order").focus();
// $("#"+shop_code+"_doemal_new_order").addClass("hidden");
// $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden");
// $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden");
// }).on('hide.bs.modal', function (e) {
// $("#"+shop_code+"_notify_new_order").addClass("hidden");
// }).modal({show: true, keyboard: false, backdrop: false});
}
}
}
});

View File

@@ -3,36 +3,40 @@ App.check_order_ready_to_delivery = App.cable.subscriptions.create('CheckOrderRe
disconnected: function() {},
received: function(data) {
var order = data.data;
var shop_code = data.shop_code;
if(order.length > 0){
var order_lists = "";
$.each(order, function(key, value){
if(key==0){
order_lists = value.order_reservation_id;
}else if(key == (order.length - 1)){
order_lists += ' and ' + value.order_reservation_id;
}else{
order_lists += ', ' + value.order_reservation_id;
}
});
received: function(data) {
var hostname = location.hostname.trim();
if(data.from == "" || hostname == data.from)
{
var order = data.data;
var shop_code = data.shop_code;
if(order.length > 0){
var order_lists = "";
$.each(order, function(key, value){
if(key==0){
order_lists = value.order_reservation_id;
}else if(key == (order.length - 1)){
order_lists += ' and ' + value.order_reservation_id;
}else{
order_lists += ', ' + value.order_reservation_id;
}
});
// alert(order_lists);
checkOrderReadyToKitchenAlert(shop_code, order_lists);
// $("#notify_order_ready_to_delivery_lists").text(order_lists);
// if($("#notify_order_ready_to_delivery").hasClass("hidden")){
// $("#"+shop_code+"_notify_order_ready_to_delivery").removeClass("hidden");
// }
// $("#"+shop_code+"_notify_order_ready_to_delivery").on('shown.bs.modal', function(e){
// // $(document).off('focusin.modal');
// $("#"+shop_code+"_notify_order_ready_to_delivery").focus();
// $("#"+shop_code+"_doemal_new_order").addClass("hidden");
// $("#"+shop_code+"_notify_new_order").addClass("hidden");
// $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden");
// }).on('hide.bs.modal', function (e) {
// $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden");
// }).modal({show: true, keyboard: false, backdrop: false});
// alert(order_lists);
checkOrderReadyToKitchenAlert(shop_code, order_lists);
// $("#notify_order_ready_to_delivery_lists").text(order_lists);
// if($("#notify_order_ready_to_delivery").hasClass("hidden")){
// $("#"+shop_code+"_notify_order_ready_to_delivery").removeClass("hidden");
// }
// $("#"+shop_code+"_notify_order_ready_to_delivery").on('shown.bs.modal', function(e){
// // $(document).off('focusin.modal');
// $("#"+shop_code+"_notify_order_ready_to_delivery").focus();
// $("#"+shop_code+"_doemal_new_order").addClass("hidden");
// $("#"+shop_code+"_notify_new_order").addClass("hidden");
// $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden");
// }).on('hide.bs.modal', function (e) {
// $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden");
// }).modal({show: true, keyboard: false, backdrop: false});
}
}
}
});

View File

@@ -4,35 +4,39 @@ App.check_order_send_to_kitchen = App.cable.subscriptions.create('CheckOrderSend
disconnected: function() {},
received: function(data) {
var order = data.data;
var shop_code = data.shop_code;
if(order.length > 0){
var order_lists = "";
$.each(order, function(key, value){
if(key==0){
order_lists = value.order_reservation_id;
}else if(key == (order.length - 1)){
order_lists += ' and ' + value.order_reservation_id;
}else{
order_lists += ', ' + value.order_reservation_id;
}
});
var hostname = location.hostname.trim();
if(data.from == "" || hostname == data.from)
{
var order = data.data;
var shop_code = data.shop_code;
if(order.length > 0){
var order_lists = "";
$.each(order, function(key, value){
if(key==0){
order_lists = value.order_reservation_id;
}else if(key == (order.length - 1)){
order_lists += ' and ' + value.order_reservation_id;
}else{
order_lists += ', ' + value.order_reservation_id;
}
});
// alert(order_lists);
checkOrderSendToKitchen(shop_code, order_lists);
// $("#notify_order_send_to_kitchen_lists").text(order_lists);
// if($("#notify_order_send_to_kitchen").hasClass("hidden")){
// $("#"+shop_code+"_notify_order_send_to_kitchen").removeClass("hidden");
// }
// $("#"+shop_code+"_notify_order_send_to_kitchen").on('shown.bs.modal', function(e){
// // $(document).off('focusin.modal');
// $("#"+shop_code+"_notify_order_send_to_kitchen").focus();
// $("#"+shop_code+"_doemal_new_order").addClass("hidden");
// $("#"+shop_code+"_notify_new_order").addClass("hidden");
// $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden");
// }).on('hide.bs.modal', function (e) {
// $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden");
// }).modal({show: true, keyboard: false, backdrop: false});
// alert(order_lists);
checkOrderSendToKitchen(shop_code, order_lists);
// $("#notify_order_send_to_kitchen_lists").text(order_lists);
// if($("#notify_order_send_to_kitchen").hasClass("hidden")){
// $("#"+shop_code+"_notify_order_send_to_kitchen").removeClass("hidden");
// }
// $("#"+shop_code+"_notify_order_send_to_kitchen").on('shown.bs.modal', function(e){
// // $(document).off('focusin.modal');
// $("#"+shop_code+"_notify_order_send_to_kitchen").focus();
// $("#"+shop_code+"_doemal_new_order").addClass("hidden");
// $("#"+shop_code+"_notify_new_order").addClass("hidden");
// $("#"+shop_code+"_notify_order_ready_to_delivery").addClass("hidden");
// }).on('hide.bs.modal', function (e) {
// $("#"+shop_code+"_notify_order_send_to_kitchen").addClass("hidden");
// }).modal({show: true, keyboard: false, backdrop: false});
}
}
}
});

View File

@@ -6,6 +6,9 @@ App.order = App.cable.subscriptions.create('CheckinChannel', {
disconnected: function() {},
received: function(data) {
var hostname = location.hostname.trim();
if(data.from == "" || hostname == data.from)
{
$.each(data.table,function(key,value){
if($('.table_'+value.table_id).hasClass('blue')){
$('.table_'+value.table_id).removeClass('blue');
@@ -22,5 +25,6 @@ App.order = App.cable.subscriptions.create('CheckinChannel', {
$('.new_text_'+value.table_id).removeClass('hide');
});
}
}
});

View File

@@ -3,7 +3,12 @@ App.order = App.cable.subscriptions.create('OrderChannel', {
disconnected: function() {},
received: function(data) {
received: function(data) {
var hostname = location.hostname.trim();
console.log(hostname)
console.log(data.from)
if(data.from == "" || hostname == data.from)
{
if (data.type == 'order') {
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('blue');
@@ -14,6 +19,7 @@ App.order = App.cable.subscriptions.create('OrderChannel', {
$('.new_text_'+data.table.id).html('');
$('.new_text_'+data.table.id).removeClass('hide')
}
}
}
});

View File

@@ -6,83 +6,86 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann
disconnected: function() {},
received: function(data) {
var oqs_id = $('.oqs_active').attr('data-id');
items = data.order;
for(var field in items) {
var price = parseFloat(items[field].price).toFixed(2);
if (items[field]["options"] == "[]" || items[field]["options"] == "") {
var options = "";
}else{
var options = items[field]["options"];
}
//for count
test = document.getElementsByClassName("oqs_count");
var hostname = location.hostname.trim();
if(data.from == "" || hostname == data.from){
var oqs_id = $('.oqs_active').attr('data-id');
items = data.order;
for(var field in items) {
var price = parseFloat(items[field].price).toFixed(2);
if (items[field]["options"] == "[]" || items[field]["options"] == "") {
var options = "";
}else{
var options = items[field]["options"];
}
//for count
test = document.getElementsByClassName("oqs_count");
for (var i = 0; i < test.length; i++) {
oqs_count_id = $(".oqs_count"+i).attr("data-id");
oqs_count = $(".oqs_count"+i).text();
if ( oqs_count_id == items[field]["order_queue_station_id"]) {
oqs_count_total = +oqs_count +1 ;
$(".oqs_count"+i).text(oqs_count_total)
}
}
//end count
for (var i = 0; i < test.length; i++) {
oqs_count_id = $(".oqs_count"+i).attr("data-id");
oqs_count = $(".oqs_count"+i).text();
if ( oqs_count_id == items[field]["order_queue_station_id"]) {
oqs_count_total = +oqs_count +1 ;
$(".oqs_count"+i).text(oqs_count_total)
}
}
//end count
var date = new Date(items[field]["created_at"]);
// var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
var show_date =date.getHours()+ ':' + date.getMinutes() +' '+(date.getHours() >= 12 ? 'PM' : 'AM');
var date = new Date(items[field]["created_at"]);
// var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
var show_date =date.getHours()+ ':' + date.getMinutes() +' '+(date.getHours() >= 12 ? 'PM' : 'AM');
if (oqs_id == items[field]["order_queue_station_id"]) {
var table_type = (items[field]["table_type"] != null) ? items[field]["table_type"]:"";
var zone = (items[field]["zone"] != null) ? "-"+items[field]["zone"]:"No Table";
(name === 'true') ? 'Y' :'N';
row ='<div class="card queue_station animated shake queue_station_box" data-order-no="'+items[field]["order_id"]+'">'
+'<strong class="hidden">'+items[field]["order_id"]+'</strong>'
+'<div class="card-block">'
if (oqs_id == items[field]["order_queue_station_id"]) {
var table_type = (items[field]["table_type"] != null) ? items[field]["table_type"]:"";
var zone = (items[field]["zone"] != null) ? "-"+items[field]["zone"]:"No Table";
(name === 'true') ? 'Y' :'N';
row ='<div class="card queue_station animated shake queue_station_box" data-order-no="'+items[field]["order_id"]+'">'
+'<strong class="hidden">'+items[field]["order_id"]+'</strong>'
+'<div class="card-block">'
+'<div class="row">'
+'<span class="col-md-4 order-zone-type font-13">'+table_type+''+ zone+'</span>'
+'<span class="order-zone hidden font-14">'+ zone +'</span>'
+'<span class="col-md-8"><small class="float-right font-13">'+items[field]["order_id"]+'</small></span>'
+'</div>'
+'<p class="m-b--10">'
+'<span class="order-item font-15">'+ items[field]["item_name"] +'- </span>'
+'<span class="order-qty"> [x'+ items[field]["qty"] +'] </span>'
+'</p>'
+'<div class="row">'
+'<span class="col-md-4 order-zone-type font-13">'+table_type+''+ zone+'</span>'
+'<span class="order-zone hidden font-14">'+ zone +'</span>'
+'<span class="col-md-8"><small class="float-right font-13">'+items[field]["order_id"]+'</small></span>'
+'</div>'
+'<p class="m-b--10">'
+'<span class="order-item font-15">'+ items[field]["item_name"] +'- </span>'
+'<span class="order-qty"> [x'+ items[field]["qty"] +'] </span>'
+'</p>'
+'<br/><p class="card-text item-options">'+ options +'</p>'
+'<br/><p class="card-text item-options">'+ options +'</p>'
+'<span class="card-text">'
+'<span class="text-muted">Order at - '
+'<span class="order-at">'+ show_date +'</span> <br>'
+'<span class="card-text">'
+'<span class="text-muted">Order at - '
+'<span class="order-at">'+ show_date +'</span> <br>'
+'Order By - <span class="order-by">'+ items[field]["item_order_by"] +'</span> '
+'</span> '
+'</span>'
+'Order By - <span class="order-by">'+ items[field]["item_order_by"] +'</span> '
+'</span> '
+'</span>'
+'<p class="hidden order-customer">'+ items[field]["customer_name"] +'</p> '
+'<p class="hidden assigned-order-item">'+ items[field]["assigned_order_item_id"] +'</p> '
+'</div>'
+'<p class="hidden order-customer">'+ items[field]["customer_name"] +'</p> '
+'<p class="hidden assigned-order-item">'+ items[field]["assigned_order_item_id"] +'</p> '
+'</div>'
+'<div class="card-footer">'
+'<button id="edit_'+ items[field]["assigned_order_item_id"]+'" class="btn btn-warning order-item order-item-edit">EDIT</button>'
+' <button id="assigned_queue_' + items[field]["assigned_order_item_id"] +'" class="btn btn-primary order-item order-complete">COMPLETE</button>'
+'</div>'
+'</div>';
$('.oqs_append').append(row);
}
}//end looping
+'<div class="card-footer">'
+'<button id="edit_'+ items[field]["assigned_order_item_id"]+'" class="btn btn-warning order-item order-item-edit">EDIT</button>'
+' <button id="assigned_queue_' + items[field]["assigned_order_item_id"] +'" class="btn btn-primary order-item order-complete">COMPLETE</button>'
+'</div>'
+'</div>';
$('.oqs_append').append(row);
}
}//end looping
var $divs = $("div.queue_station");
var SortListDivs = $divs.sort(function (a, b) {
var $divs = $("div.queue_station");
var SortListDivs = $divs.sort(function (a, b) {
first = $(a).attr('data-order-no');
next = $(b).attr('data-order-no');
first = $(a).attr('data-order-no');
next = $(b).attr('data-order-no');
return parseInt(next.substring(4, 16)) - parseInt(first.substring(4, 16));
});
$("#oqs_container").html(SortListDivs);
return parseInt(next.substring(4, 16)) - parseInt(first.substring(4, 16));
});
$("#oqs_container").html(SortListDivs);
}
},
});

View File

@@ -4,50 +4,53 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel'
disconnected: function() {},
received: function(data) {
var shop_code = data.shop_code;
var order = data.data;
if(order.length > 0){
$('.custom-table.'+shop_code+'_order_reserve_cable tbody').html("");
$("."+shop_code+" > .nav-item.red > a > p.num").text(order.length);
$.each(order, function(key,value){
var active_class = "";
if(key==0){
active_class = "tr-active";
showNewOrder(order[key],shop_code);
}
var rowCount = key+1;
var date = new Date(value.created_at);
var time = timeFormat(date);
var created_at = date.getFullYear() +'-'+ (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >=10?date.getDate() : '0'+date.getDate());
var hostname = location.hostname.trim();
if(data.from == "" || hostname == data.from){
var shop_code = data.shop_code;
var order = data.data;
if(order.length > 0){
$('.custom-table.'+shop_code+'_order_reserve_cable tbody').html("");
$("."+shop_code+" > .nav-item.red > a > p.num").text(order.length);
$.each(order, function(key,value){
var active_class = "";
if(key==0){
active_class = "tr-active";
showNewOrder(order[key],shop_code);
}
var rowCount = key+1;
var date = new Date(value.created_at);
var time = timeFormat(date);
var created_at = date.getFullYear() +'-'+ (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >=10?date.getDate() : '0'+date.getDate());
var delivery_type = "";
if(value.provider == "food2u" || value.provider == "yangondoor2door"){
delivery_type = "DELIVERY";
}else if(value.provider == "pick_up"){
delivery_type = "PICK-UP";
}else{
delivery_type = "DIRECT DELIVERY";
}
var delivery_type = "";
if(value.provider == "food2u" || value.provider == "yangondoor2door"){
delivery_type = "DELIVERY";
}else if(value.provider == "pick_up"){
delivery_type = "PICK-UP";
}else{
delivery_type = "DIRECT DELIVERY";
}
row = '<tr class="custom-tr first-'+rowCount+' '+active_class+'" style="" data-id="'+value.order_reservation_id+'" data-sr-no="'+rowCount+'">'
+'<td width ="5%" class="align-left">'+rowCount
+'</td>'
+'<td width ="20%" class="align-center">'+created_at
+'</td>'
+'<td width ="20%" class="align-center">'+time
+'</td>'
+'<td width ="20%" class="align-center">'+value.grand_total
+'</td>'
+'<td width ="30%" class="align-center">'
+'<span class="font-10 col-blue">'+ delivery_type +'</span>'
+'</td>'
+' </tr>';
$('.custom-table.'+shop_code+'_order_reserve_cable tbody').append(row);
});
row = '<tr class="custom-tr first-'+rowCount+' '+active_class+'" style="" data-id="'+value.order_reservation_id+'" data-sr-no="'+rowCount+'">'
+'<td width ="5%" class="align-left">'+rowCount
+'</td>'
+'<td width ="20%" class="align-center">'+created_at
+'</td>'
+'<td width ="20%" class="align-center">'+time
+'</td>'
+'<td width ="20%" class="align-center">'+value.grand_total
+'</td>'
+'<td width ="30%" class="align-center">'
+'<span class="font-10 col-blue">'+ delivery_type +'</span>'
+'</td>'
+' </tr>';
$('.custom-table.'+shop_code+'_order_reserve_cable tbody').append(row);
});
}
customTableClick();
}
customTableClick();
}
});

View File

@@ -5,33 +5,36 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayChannel', {
disconnected: function() {},
received: function(data) {
var data_obj = data.data;
var status = data.status;
var count = 0
var sub_total = 0
if (data.status == "order") {
for(var i in data_obj) {
received: function(data) {
var hostname = location.hostname.trim();
if(data.from == "" || hostname == data.from){
var data_obj = data.data;
var status = data.status;
var count = 0
var sub_total = 0
if (data.status == "order") {
for(var i in data_obj) {
sub_total = sub_total + (data_obj[i].price * data_obj[i].qty)
count += 1
row ='<tr>'
+'<td>'+count+'</td>'
+'<td class="item-name">'+data_obj[i].item_name+'</td>'
+'<td class="item-attr">'+data_obj[i].qty +'</td>'
+ '<td class="item-attr">'+data_obj[i].qty*data_obj[i].price +'</td>'
+'</tr>'
$(".second_display_items").append(row);
}//end looping
}else{
$('#s_sub_total').empty();
$('#s_sub_total').append(data_obj.total_amount);
$('#s_total_discount').empty();
$('#s_total_discount').append(data_obj.total_discount);
$('#s_tatal_tax').empty();
$('#s_tatal_tax').append(data_obj.total_tax);
$('#s_grand_total').empty();
$('#s_grand_total').append(data_obj.grand_total);
sub_total = sub_total + (data_obj[i].price * data_obj[i].qty)
count += 1
row ='<tr>'
+'<td>'+count+'</td>'
+'<td class="item-name">'+data_obj[i].item_name+'</td>'
+'<td class="item-attr">'+data_obj[i].qty +'</td>'
+ '<td class="item-attr">'+data_obj[i].qty*data_obj[i].price +'</td>'
+'</tr>'
$(".second_display_items").append(row);
}//end looping
}else{
$('#s_sub_total').empty();
$('#s_sub_total').append(data_obj.total_amount);
$('#s_total_discount').empty();
$('#s_total_discount').append(data_obj.total_discount);
$('#s_tatal_tax').empty();
$('#s_tatal_tax').append(data_obj.total_tax);
$('#s_grand_total').empty();
$('#s_grand_total').append(data_obj.grand_total);
}
}
}
});

View File

@@ -6,161 +6,163 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
disconnected: function() {},
received: function(data) {
var items = data.data;
var tax = data.tax_profiles;
var status= data.status
if (status == "reload") {
jQuery('#s_reload').click();
}
$('#second_display_slider').addClass("hidden")
$('#second_display_items').removeClass("hidden")
// append items
if (status == "add") {
for(var i in items) {
qty = parseInt(items[i].qty);
append = 0;
price = items[i].price;
instance_name = items[i].instance;
if (instance_name == "undefined"){
instance = '';
}else{
instance = "("+items[i].instance+")";
}
// d_option = items[i].options;
// if (d_option){
// option_name = "-"+items[i].options;
// }else{
// option_name = '';
// }
d_option = items[i].opt;
if (items[i].click_type != "add_icon"){
option_name = "-"+items[i].options;
data_option = items[i].options ;
}else{
option_name = ' ';
data_option = '[]';
}
var rowCount = $('.second_display_items tbody tr').length+1;
var item_row = $('.second_display_items tbody tr');
$(item_row).each(function(j){
var item_code = $(item_row[j]).attr('data-code');
var instance_code = $(item_row[j]).attr('data-instance-code');
var r_option = $(item_row[j]).attr('data-options');
if (item_code == items[i].item_code && instance_code == items[i].instance_code && r_option==d_option) {
if (qty > 1) {
qty = parseInt($(item_row[j]).children('#item_qty').text()) + qty;
}else{
qty = parseInt($(item_row[j]).children('#item_qty').text()) + 1;
}
$(item_row[j]).children('#item_qty').text(qty);
parseFloat($(item_row[j]).children('#item_price').text(parseFloat(price*qty).toFixed(2)));
append =1;
}else{
if (qty > 1) {
qty = qty;
}else{
qty = 1;
}
}
});
if (append===0) {
row ="<tr class='item_box' data-price ='"
+price+ "' 'data-instance ='"
+instance+ "' data-code='"+items[i].item_code+"' data-instance-code='"
+items[i].instance_code+"' data-attributes='"
+items[i].attributes+"' data-options ='"
+data_option+"' data-opt ='"
+items[i].options+"' data-row ='"+rowCount+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + items[i].name+ ' ' + instance + ' ' + option_name +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(price).toFixed(2)
+'</td>'
+'</tr>';
$(".second_display_items tbody").append(row);
}
var hostname = location.hostname.trim();
if(data.from == "" || hostname == data.from){
var items = data.data;
var tax = data.tax_profiles;
var status= data.status
if (status == "reload") {
jQuery('#s_reload').click();
}
}
if (status == "set_add") {
// var option_arr = [];
var attribute_arr = [];
var rowCount = $('.second_display_items tbody tr').length+1;
for(var i in items) {
code = items[i].code;
item_code = items[i].item_code;
name = items[i].name;
item_name = items[i].item_name;
qty = items[i].qty;
$('#second_display_slider').addClass("hidden")
$('#second_display_items').removeClass("hidden")
// append items
if (status == "add") {
for(var i in items) {
qty = parseInt(items[i].qty);
append = 0;
price = items[i].price;
option = items[i].option;
sub_item = items[i].sub_item;
total = qty * price ;
// option_arr.push(option);
row ="<tr class='item_box' data-price ='"
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
+name+ "' data-code='"+item_code+"' data-instance-code='"
+code+"' data-attributes='"
+attribute_arr+"' data-options ='"
+option+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>"
instance_name = items[i].instance;
if (instance_name == "undefined"){
instance = '';
}else{
instance = "("+items[i].instance+")";
}
// d_option = items[i].options;
// if (d_option){
// option_name = "-"+items[i].options;
// }else{
// option_name = '';
// }
d_option = items[i].opt;
if (items[i].click_type != "add_icon"){
option_name = "-"+items[i].options;
data_option = items[i].options ;
}else{
option_name = ' ';
data_option = '[]';
}
var rowCount = $('.second_display_items tbody tr').length+1;
var item_row = $('.second_display_items tbody tr');
$(item_row).each(function(j){
var item_code = $(item_row[j]).attr('data-code');
var instance_code = $(item_row[j]).attr('data-instance-code');
var r_option = $(item_row[j]).attr('data-options');
if (item_code == items[i].item_code && instance_code == items[i].instance_code && r_option==d_option) {
if (qty > 1) {
qty = parseInt($(item_row[j]).children('#item_qty').text()) + qty;
}else{
qty = parseInt($(item_row[j]).children('#item_qty').text()) + 1;
}
$(item_row[j]).children('#item_qty').text(qty);
parseFloat($(item_row[j]).children('#item_price').text(parseFloat(price*qty).toFixed(2)));
append =1;
}else{
if (qty > 1) {
qty = qty;
}else{
qty = 1;
}
}
});
if (append===0) {
row ="<tr class='item_box' data-price ='"
+price+ "' 'data-instance ='"
+instance+ "' data-code='"+items[i].item_code+"' data-instance-code='"
+items[i].instance_code+"' data-attributes='"
+items[i].attributes+"' data-options ='"
+data_option+"' data-opt ='"
+items[i].options+"' data-row ='"+rowCount+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name + ''+option+'</td>'
+'<td class="item-cell-name" id="item_name" >' + items[i].name+ ' ' + instance + ' ' + option_name +'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(total).toFixed(2)
+ parseFloat(price).toFixed(2)
+'</td>'
+'</tr>';
$(".second_display_items tbody").append(row);
rowCount = rowCount + 1;
}
}
//end apend items
var total_price = 0;
var taxable_amount = 0;
var total_discount = 0
var total_tax_amount = 0
var item_row = $('.second_display_items tbody tr');
//calculate Sub Total
$(item_row).each(function(i){
var unit_price = parseFloat($(item_row[i]).attr('data-price'));
var qty = parseFloat($(item_row[i]).children('#item_qty').text());
total_price += qty*unit_price;
});
//calculate Tax Amount
for(var i in tax) {
// substract , to give after discount
var total_tax = total_price - total_discount
// include or execulive
if (tax[i].inclusive){
rate = tax[i].rate
divided_value = (100 + rate)/rate
total_tax_amount = total_tax_amount + (total_tax / divided_value)
}else{
total_tax_amount = total_tax_amount + (total_tax * tax[i].rate / 100)
}
}
}
//end calculate Tax amount
var fixed_total_price = parseFloat(total_price).toFixed(2);
var fixed_taxable_amount = parseFloat(total_tax_amount).toFixed(2);
var fixed_grand_total = parseFloat(total_price + total_tax_amount).toFixed(2);
if (status == "set_add") {
// var option_arr = [];
var attribute_arr = [];
var rowCount = $('.second_display_items tbody tr').length+1;
for(var i in items) {
code = items[i].code;
item_code = items[i].item_code;
name = items[i].name;
item_name = items[i].item_name;
qty = items[i].qty;
price = items[i].price;
option = items[i].option;
sub_item = items[i].sub_item;
total = qty * price ;
// option_arr.push(option);
row ="<tr class='item_box' data-price ='"
+price+ "' data-toggle='modal' data-target='#sx_itemModal' 'data-instance ='"
+name+ "' data-code='"+item_code+"' data-instance-code='"
+code+"' data-attributes='"
+attribute_arr+"' data-options ='"
+option+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>"
+'<td class="item-cell-no">'+rowCount+'</td>'
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name + ''+option+'</td>'
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
+'<td class="item-cell-price" id="item_price">'
+ parseFloat(total).toFixed(2)
+'</td>'
+'</tr>';
$(".second_display_items tbody").append(row);
rowCount = rowCount + 1;
}
}
//end apend items
var total_price = 0;
var taxable_amount = 0;
var total_discount = 0
var total_tax_amount = 0
var item_row = $('.second_display_items tbody tr');
//calculate Sub Total
$(item_row).each(function(i){
var unit_price = parseFloat($(item_row[i]).attr('data-price'));
var qty = parseFloat($(item_row[i]).children('#item_qty').text());
total_price += qty*unit_price;
});
//calculate Tax Amount
for(var i in tax) {
// substract , to give after discount
var total_tax = total_price - total_discount
// include or execulive
if (tax[i].inclusive){
rate = tax[i].rate
divided_value = (100 + rate)/rate
total_tax_amount = total_tax_amount + (total_tax / divided_value)
}else{
total_tax_amount = total_tax_amount + (total_tax * tax[i].rate / 100)
}
}
//end calculate Tax amount
var fixed_total_price = parseFloat(total_price).toFixed(2);
var fixed_taxable_amount = parseFloat(total_tax_amount).toFixed(2);
var fixed_grand_total = parseFloat(total_price + total_tax_amount).toFixed(2);
$('#s_sub_total').empty();
$('#s_sub_total').append(fixed_total_price);
$('#s_tatal_tax').empty();
$('#s_tatal_tax').append(fixed_taxable_amount);
$('#s_grand_total').empty();
$('#s_grand_total').append(fixed_grand_total);
$('#s_sub_total').empty();
$('#s_sub_total').append(fixed_total_price);
$('#s_tatal_tax').empty();
$('#s_tatal_tax').append(fixed_taxable_amount);
$('#s_grand_total').empty();
$('#s_grand_total').append(fixed_grand_total);
}
}
});

View File

@@ -47,9 +47,12 @@ class Api::BillController < Api::ApiController
Promotion.promo_activate(@sale)
#BillBroadcastJob.perform_later(table)
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "bill_channel",table: table
#end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "bill_channel",table: table, from: from
else
@status = false
@error_message = "No Current Open Shift"

View File

@@ -6,9 +6,12 @@ class Api::CallWaitersController < ActionController::API
@time = params[:time]
@table = DiningFacility.find(@table_id)
# CallWaiterJob.perform_later(@table,@time)
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time
#end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "call_waiter_channel",table: @table,time:@time,from: from
# get printer info
@shop = Shop.first
unique_code = "CallWaiterPdf"

View File

@@ -6,7 +6,16 @@ class Api::CheckInProcessController < Api::ApiController
booking = dining_facility.get_current_checkout_booking
if !booking.nil?
DiningFacility.check_in_booking(params[:dining_id])
# DiningFacility.check_in_booking(params[:dining_id])
table = DiningFacility.find(params[:dining_id])
#Send to background job for processing
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from
check_in_time = booking.checkin_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")
check_out_time = booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M")

View File

@@ -73,7 +73,12 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
order_reservation = OrderReservation.get_pending_orders #find(order_reservation_id)
ActionCable.server.broadcast "order_reservation_channel",data: order_reservation,shop_code: shop_code
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "order_reservation_channel",data: order_reservation,shop_code: shop_code,from:from
else
result = { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is already existed!" }
end

View File

@@ -181,6 +181,12 @@ puts params[:id]
@status, @booking = @order.generate
if @status && @booking
if params[:order_source] != "quick_service"
process_order_queue(@order.order_id,@order.table_id,@order.source)
end
end
# Order.send_customer_view(@booking)
if current_user.role != "waiter" && params[:create_type] == "create_pay"
@@ -188,8 +194,12 @@ puts params[:id]
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
# for second display
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale"
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from
#end
result = {:status=> @status, :data => @sale }
render :json => result.to_json
@@ -240,6 +250,81 @@ puts params[:id]
return false
end
end
def process_order_queue(order_id,table_id,order_source)
print_status = nil
cup_status = nil
#Send to background job for processing
order = Order.find(order_id)
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if ENV["SERVER_MODE"] != 'cloud'
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
end
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, order_source)
end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
if ENV["SERVER_MODE"] != 'cloud'
cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
end
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, order_source)
end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
if ENV["SERVER_MODE"] != 'cloud'
from = ""
msg = ' Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error',from:from
end
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(order_id, table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id, order_source)
end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
end
end
end
end
def check_cup_status(status)
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
return true
end
return false
end
private

View File

@@ -13,8 +13,12 @@ class Origami::SecondDisplayController < BaseOrigamiController
else
tax_profiles = nil
end
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status]
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status],from:from
# end
end
#Shop Name in Navbor

View File

@@ -337,9 +337,13 @@ class Origami::SplitBillController < BaseOrigamiController
end
Promotion.promo_activate(sale)
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "bill_channel",table: table
#end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "bill_channel",table: table,from:from
render :json => { status: status }
else
render :json => { status: false, error_message: 'No Current Open Shift!'}

View File

@@ -157,15 +157,25 @@ class DiningFacility < ApplicationRecord
#Send to background job for processing
# CheckInBookingJob.perform_later(table)
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "check_in_booking_channel",table: table
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "check_in_booking_channel",table: table,from:from
#end
end
def self.checkin_time
table = DiningFacility.get_checkin_booking
if table.length > 0
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "checkin_channel",table: table
ActionCable.server.broadcast "checkin_channel",table: table,from:from
end
end
end

View File

@@ -1,3 +1,3 @@
class DisplayImage < ApplicationRecord
belongs_to :shop
belongs_to :shop
end

View File

@@ -71,9 +71,9 @@ class Order < ApplicationRecord
BookingOrder.create({:booking_id => booking.booking_id, :order => self})
#Send order to queue one it done!
if self.source != "quick_service"
process_order_queue
end
# if self.source != "quick_service"
# process_order_queue
# end
#send order to broadcast job
send_order_broadcast(booking)
@@ -108,9 +108,9 @@ class Order < ApplicationRecord
BookingOrder.create({:booking_id => booking.booking_id, :order => self})
#Send order to queue one it done!
if self.source != "quick_service"
process_order_queue
end
# if self.source != "quick_service"
# process_order_queue
# end
#send order to broadcast job
send_order_broadcast(booking)
@@ -283,69 +283,7 @@ class Order < ApplicationRecord
# Counter number of quantityf
end
#Process order items and send to order queue
def process_order_queue
print_status = nil
cup_status = nil
#Send to background job for processing
order = Order.find(self.id)
sidekiq = Lookup.find_by_lookup_type("sidekiq")
if ENV["SERVER_MODE"] != 'cloud'
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
end
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id, self.source)
end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
if ENV["SERVER_MODE"] != 'cloud'
cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
end
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id, self.source)
end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
if ENV["SERVER_MODE"] != 'cloud'
msg = ' Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
end
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id, self.source)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
end
end
end
#Process order items and send to order queue
def self.pay_process_order_queue(id,table_id)
# if ENV["SERVER_MODE"] != 'cloud'
@@ -378,9 +316,13 @@ class Order < ApplicationRecord
type = 'order'
#Send to background job for processing
# OrderBroadcastJob.perform_later(table,type)
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "order_channel",table: table,type:type
#end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
end
end
@@ -534,11 +476,78 @@ class Order < ApplicationRecord
end
end
end
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "second_display_channel",data: @data_array,status:@status
#end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "second_display_channel",data: @data_array,status:@status,from:from
end
#Process order items and send to order queue
# def process_order_queue
# print_status = nil
# cup_status = nil
# #Send to background job for processing
# order = Order.find(self.id)
# sidekiq = Lookup.find_by_lookup_type("sidekiq")
# if ENV["SERVER_MODE"] != 'cloud'
# cup_status = `#{"sudo service cups status"}`
# print_status = check_cup_status(cup_status)
# end
# if print_status
# if !sidekiq.nil?
# OrderQueueProcessorJob.perform_later(self.id, self.table_id)
# else
# if order
# oqs = OrderQueueStation.new
# oqs.process_order(order, self.table_id, self.source)
# end
# # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
# # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
# end
# else
# if ENV["SERVER_MODE"] != 'cloud'
# cup_start = `#{"sudo service cups start"}`
# cup_status = `#{"sudo service cups status"}`
# print_status = check_cup_status(cup_status)
# end
# if print_status
# if !sidekiq.nil?
# OrderQueueProcessorJob.perform_later(self.id, self.table_id)
# else
# if order
# oqs = OrderQueueStation.new
# oqs.process_order(order, self.table_id, self.source)
# end
# # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
# # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
# end
# else
# if ENV["SERVER_MODE"] != 'cloud'
# msg = ' Print Error ! Please contact to service'
# ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
# end
# if !sidekiq.nil?
# OrderQueueProcessorJob.perform_later(self.id, self.table_id)
# else
# if order
# oqs = OrderQueueStation.new
# oqs.process_order(order, self.table_id, self.source)
# end
# assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
# end
# end
# end
# end
private
def generate_custom_id

View File

@@ -116,7 +116,19 @@ class OrderQueueStation < ApplicationRecord
order = Order.find(order_id)
order_items = order.order_items
Order.pay_process_order_queue(order_id,table_id)
# Order.pay_process_order_queue(order_id,table_id)
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id)
end
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from
if table_id.to_i > 0
# get dining
dining = DiningFacility.find(table_id)

View File

@@ -317,9 +317,15 @@ class OrderReservation < ApplicationRecord
end
order_reservation = OrderReservation.where("status='new'")
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code
end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code,from:from
else
from = ""
end
# if ENV["SERVER_MODE"] == 'cloud'
# ActionCable.server.broadcast "check_new_order_channel",data: order_reservation, shop_code: shop_code
# end
end
end
@@ -332,9 +338,15 @@ class OrderReservation < ApplicationRecord
end
order_reservation = OrderReservation.where("status='accepted' and requested_time <= '#{Time.now.utc}'")
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code
end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code,from:from
else
from = ""
end
# if ENV["SERVER_MODE"] == 'cloud'
# ActionCable.server.broadcast "check_order_send_to_kitchen_channel",data: order_reservation, shop_code: shop_code
# end
end
end
@@ -347,9 +359,15 @@ class OrderReservation < ApplicationRecord
end
order_reservation = OrderReservation.where("status='send_to_kitchen' and requested_time <= '#{Time.now.utc}'")
if order_reservation.length > 0
if ENV["SERVER_MODE"] == 'cloud'
ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code
end
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code,from:from
else
from = ""
end
# if ENV["SERVER_MODE"] == 'cloud'
# ActionCable.server.broadcast "check_order_ready_to_delivery_channel",data: order_reservation, shop_code: shop_code
# end
end
end

View File

@@ -609,7 +609,12 @@ class SalePayment < ApplicationRecord
#Send to background job for processing
# OrderBroadcastJob.perform_later(table,type)
#if ENV["SERVER_MODE"] != 'cloud'
ActionCable.server.broadcast "order_channel",table: table,type:type
if ENV["SERVER_MODE"] == 'cloud'
from = request.subdomain + "." + request.domain
else
from = ""
end
ActionCable.server.broadcast "order_channel",table: table,type:type,from:from
#end
end
end

View File

@@ -2,13 +2,11 @@ class CreateDisplayImages < ActiveRecord::Migration[5.1]
def change
create_table :display_images do |t|
t.integer :shop_id
t.string :name
t.binary :image
t.string :created_by
t.timestamps
end
end
def down
drop_table :display_images
end
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe DisplayImage, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end