diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 64208520..5c4ffef3 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1,5 +1,23 @@ //middle edit $(function() { + $("#loading_wrapper").show(); + getAllMenu(); + //get menu item cache + function getAllMenu(){ + $.ajax({ + type: "GET", + url: '/foodcourt/get_all_menu', + data: {}, + success:function(result){ + console.log(result) + localStorage.setItem("menus", JSON.stringify(result)); + var menu = localStorage.getItem("menus"); + if (menu != null ) { + $( "#loading_wrapper").hide(); + } + } + }); + } var role = $('#role').val(); var second_display_lookup = $("#display_type").val(); type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court"); @@ -623,7 +641,7 @@ $(function() { row = "
"+attributes[field]["type"]+"
"; $(value).each(function(i){ - disabled = "" + disabled = "false"; status =""; if(parseInt(jQuery.inArray(value[i], selected_item)) !== -1){ status = "selected-attribute"; @@ -1041,7 +1059,11 @@ $(function() { }else if(result.data == 'OK'){ window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text(); }else{ - window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment"; + if(result.current_user_role == 'foodcourt_cashier'){ + window.location.href = "/foodcourt/sale/"+result.data["sale_id"]+"/"+type+"/payment"; } + else{ + window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment"; + } } } } diff --git a/app/assets/javascripts/foodcourt.js b/app/assets/javascripts/foodcourt.js new file mode 100644 index 00000000..9574824c --- /dev/null +++ b/app/assets/javascripts/foodcourt.js @@ -0,0 +1,591 @@ +//= require jquery +//= require tether +//= require jquery_ujs +//= require bootstrap/js/popper.min +//= require bootstrap/js/bootstrap-material-design.min +//= require momentjs/moment +//= require bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker +//= require jquery-slimscroll/jquery.slimscroll.js +//= require bootstrap-notify/bootstrap-notify.js +//= require node-waves/waves.js +//= require sweetalert/sweetalert.min.js +//= require fileinput.min +//= require cable +//= require turbolinks +//= require BSBMaterial/turbolink_admin.js +//= require BSBMaterial/demo.js + +/* Constant Varaibles */ +_CREDIT_PAYMENTS_ = "/   CREDIT PAYMENTS"; +_CUSTOMERS_ = "/   CUSTOMERS"; +_DISCOUNTS_ = "/   DISCOUNTS"; +_IN_DUTIES_ = "/   IN DUTIES"; +_JCB_ = "/   JCB PAYMENT"; +_MASTER_ = "/   MASTER PAYMENT"; +_MPU_ = "/   MPU PAYMENT"; +_ALIPAY_ = "/   Alipay"; +_JUNCTIONPAY_ = "/   JunctionPay"; +_PAYMAL_ = "/   PAYMAL"; +_DINGA_ = "/   DINGA PAYMENT"; +_GIFT_VOUCHER_ = "/   GIFT VOUCHER"; +_OTHER_CHARGES_ = "/   CHARGES"; +_OTHER_PAYMENTS_ = "/   OTHER PAYMENT"; +_PAYMENTS_ = "/   PAYMENT"; +_PAYPAR_PAYMENT_ = "/   PAYPAR PAYMENT"; +_COMMISSIONS_ = "/   COMMISSIONS"; +_REDEEM_PAYMENT_ = "/   REDEEM PAYMENT"; +_SALE_EDIT_ = "/   SALE EDIT"; +_SPLIT_BILL_ = "/   SPLIT BILL"; +_UNION_ = "/   UNION PAYMENT"; +_VISA_ = "/   VISA PAYMENT"; +_VOUCHER_ = "/   VOUCHER"; +_SURVEY_ = "/   SURVEY"; +/* Constant Varaibles */ + +$(document).on('turbolinks:load', function() { + + $("#customer_image_path").fileinput({ + previewFileType: "image", + allowedFileExtensions: ["jpg", "gif", "png"], + browseClass: "btn btn-success", + browseLabel: "Pick Image", + browseIcon: " ", + removeClass: "btn btn-danger", + removeLabel: "Delete", + removeIcon: " ", + showUpload: false, + // uploadClass: "btn btn-info", + // uploadLabel: "Upload", + // uploadIcon: " ", + previewTemplates: { + image: '
\n' + + ' {caption}\n' + + '
\n', + } + }); + + $('.datetimepicker').bootstrapMaterialDatePicker({ + format: 'DD-MM-YYYY - HH:mm', + clearButton: true, + weekStart: 1 + }); + + $('.datepicker').bootstrapMaterialDatePicker({ + format: 'DD-MM-YYYY', + clearButton: true, + weekStart: 1, + time: false + }); + + $('.timepicker').bootstrapMaterialDatePicker({ + format: 'HH:mm', + clearButton: true, + date: false + }); + + // For selected order return + var order_status = ""; + order_status = $(".selected-item").children().find(".orders-order-status").text().substr(0,6).trim(); + + // Enable/Disable Button + //control_button(order_status); + + $(".orders").on('click', function(){ + $("#order-sub-total").text(''); + // $("#order-food").text(''); + // $("#order-beverage").text(''); + $("#order-discount").text(''); + $("#order-Tax").text(''); + $("#order-grand-total").text(''); + + var zone_name=$(this).find(".orders-table").text(); + var receipt_no=$(this).find(".orders-receipt-no").text(); + var unique_id = $(this).find(".orders-id").text(); + var order_status=$(this).find(".orders-order-status").text().trim(); + + // Enable/Disable Button + //control_button(order_status); + + var customer_id=$(this).find(".customer-id").text(); + show_customer_details(customer_id); + + $("#re-print").val(unique_id); + + var cashier=""; + var receipt_date=""; + var sub_total=0.0; + var discount_amount=0; + var tax_amount=0; + var grand_total_amount=0; + + $("#order-title").text("ORDER DETAILS - " + zone_name); + // clear order items + $("#order-items-table").children("tbody").empty(); + + // AJAX call for order + $.ajax({ + type: "POST", + url: "/origami/" + unique_id, + data: { 'booking_id' : unique_id }, + success:function(result){ + for (i = 0; i < result.length; i++) { + var data = JSON.stringify(result[i]); + var parse_data = JSON.parse(data); + var show_date = ""; + + // Receipt Header + receipt_no = result[i].receipt_no; + cashier = result[i].cashier_name; + if(result[i].receipt_date != null){ + receipt_date = new Date(result[i].receipt_date); + show_date = receipt_date.getDate() + "-" + receipt_date.getMonth() + "-" + receipt_date.getFullYear() + ' ' + receipt_date.getHours()+ ':' + receipt_date.getMinutes() + } + + //Receipt Charges + sub_total += parseFloat(parse_data.price); + + discount_amount = parse_data.discount_amount == null? '0.0' : parse_data.discount_amount; + tax_amount = parse_data.tax_amount; + grand_total_amount = parse_data.grand_total_amount; + + // Ordered Items + var order_items_rows = "" + + "" + parse_data.item_name + "" + + "" + parse_data.qty + "" + + "" + parse_data.price + "" + + ""; + + $("#order-items-table").children("tbody").append(order_items_rows); + } + + // Cashier Info + $("#receipt_no").text(receipt_no); + $("#cashier").text(cashier == null ? "" : cashier); + $("#receipt_date").text(show_date); + + // Payment Info + $("#order-sub-total").text(sub_total); + // $("#order-food").text(''); + // $("#order-beverage").text(''); + $("#order-discount").text(discount_amount); + $("#order-Tax").text(tax_amount); + $("#order-grand-total").text(grand_total_amount); + } + }); + // End AJAX Call + + $('.orders').removeClass('selected-item'); + $(this).addClass('selected-item'); + }); + + // Payment for Bill + $('#pay-bill').click(function() { + var sale_id=$(".selected-item").find(".orders-id").text().substr(0,16); + if(sale_id!=""){ + window.location.href = '/origami/sale/'+ sale_id + "/payment" + } + else { + alert("Please select an order!"); + } + + return false; + }); + + $(document).on('click', '.access_modal', function(event){ + type = $(this).data("type"); + $(".ok").attr("data-action",type); + $('#AccessCodeModal').modal('show'); + }); + + $(document).on('click', '.access_number', function(event){ + if(event.handled !== true) { + var original_value = $('#access_code').val(); + var input_type = $(this).attr("data-type"); + + switch (input_type) { + case 'num': + var input_value = $(this).attr("data-value"); + if (original_value){ + $('#access_code').val(original_value + input_value); + }else{ + $('#access_code').val(original_value + input_value); + } + break; + case 'ok': + var type = $(this).attr("data-action"); + code = $('#access_code').val(); + check_emp_access_code(code,type) + break; + case 'clr': + $('#access_code').val(""); + break; + } + event.handled = true; + } else { + return false; + } + }); + + $(document).on("click", ".credit_detail",function(){ + var sale_id = $(this).attr("data-id"); + var cashier_type = $(this).attr("data-type"); + if(cashier_type=='cashier'){ + window.location.href = "/origami/cashier/credit_sales/"+sale_id; + }else{ + window.location.href = "/origami/quick_service/credit_sales/"+sale_id; + } + }); +}); + +/* start check first bill or not funs: */ +function checkReceiptNoInFirstBillData(receipt_no,payment) { + // localStorage.removeItem('receipt_lists'); + var status = false; + var json_data = []; + if((receipt_no!=undefined) && (receipt_no!="")){ + if(localStorage.hasOwnProperty("receipt_lists")===true){ + var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + if (payment) { + json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no }); + }else{ + json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); + } + + if((arr_data.length) > (json_data.length)){ + status = true; + } + } + } + + if (payment) { + if (json_data.length>0) { + return json_data[0]["payment"]; + }else{ + return false; + } + }else{ + return status; + } +} + +function createReceiptNoInFirstBillData(receipt_no,payment) { + var arr_data = []; + var json_data = []; + if(localStorage.hasOwnProperty("receipt_lists") === true){ + arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no }); + if (payment) { + jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); + jdata.push({'receipt_no':receipt_no,'payment':payment}); + localStorage.setItem("receipt_lists",JSON.stringify(jdata)); + } + } + if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){ + arr_data.push({'receipt_no':receipt_no,'payment':payment}); + localStorage.setItem("receipt_lists",JSON.stringify(arr_data)); + } +} + +function deleteReceiptNoInFirstBillData(receipt_no) { + if(localStorage.hasOwnProperty("receipt_lists") ===true ){ + var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); + localStorage.setItem("receipt_lists",JSON.stringify(json_data)); + } +} +/* end check first bill or not funs: */ + +//start CB ECR integration +//set CB com port data +function setCommPorts(comPortLists) { + var sale_id = $('#sale_id').val(); + $('#com_port_name').html(""); + var jsonPortLists = $.parseJSON(comPortLists); + // alert(jsonPortLists); + if((jsonPortLists!=undefined && jsonPortLists!='') && (jsonPortLists.length > 0)){ + $.each(jsonPortLists,function(key,value){ + $('#com_port_name').append(""); + }); + } + else{ + swal({ + title: 'Oops', + text: 'Payment device has been disconnected! Please plug it in.', + type: 'error', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment/others_payment"; + }); + } +} + +/** pay with CB bank **/ +function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no,cashier_type) { + $("#loading_wrapper").show(); + var com_port = $("#com_port_name").val(); + reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type); +} + +//add req data to card_sale_trans table +function reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type) { + var jobj = {"cmd_type" : cmd_type, "payment_type" : "CARD", "amt" : bnk_bill_amount, "sale_id" : sale_id, "inv_no" : receipt_no, "com_port" : com_port}; + $.ajax({ + type: "POST", + url: "/origami/bank_integration/sale_trans", + data: {type:"request", data: jobj}, + dataType: "json", + success: function(data) { + if (data.status == "success"){ + card_sale_trans_id = data.card_sale_trans_id; + resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type); + } + } + }); +} + +//add res data to card_sale_trans table +function resCardSaleTrans(card_sale_trans_id,cmd_type,payment_type, bnk_bill_amount, sale_id, receipt_no,com_port,cashier_type) { + + var resMsg = ""; + var card_payment_type=""; + if($("#loading_wrapper").is(":visible")){ + if(payment_type=="mpu" || payment_type=="visa" || payment_type=="master" || payment_type=="jcb" || payment_type=="unionpay"){ + card_payment_type = "CARD"; + } + else if(payment_type == "alipay"){ + card_payment_type = "EWALLET"; + } + + bnk_bill_amount = parseFloat(bnk_bill_amount); + + resMsg = code2lab.reqBankPayment(cmd_type,card_payment_type,bnk_bill_amount,receipt_no,com_port); + } + + if(resMsg.includes("STATUS")){ + var jobj = $.parseJSON(resMsg); + + $.ajax({ + type: "POST", + url: "/origami/bank_integration/sale_trans", + data: {type:"response", card_sale_trans_id: card_sale_trans_id, data: jobj}, + dataType: "json", + success: function(data) { + if(data.status == "success"){ + resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type); + } + } + }); + }else{ + if(payment_type!="master"){ + payment_type = payment_type.toUpperCase(); + }else{ + payment_type = "Master"; + } + + $("#loading_wrapper").hide(); + swal({ + title: 'Oops', + text: resMsg.toString(), + type: 'error', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + var url_param = "payment"; + if(location.pathname.includes("credit_payment")){ + url_param = "credit_payment"; + } + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/"+url_param+"/others_payment/"+payment_type; + }); + } +} + + +function resCBPay(resMsg,card_sale_trans_id,cmd_type,payment_type,bnk_bill_amount,sale_id,receipt_no,com_port,cashier_type) { + $("#loading_wrapper").hide(); + var jobj = $.parseJSON(resMsg); + $("#reference_no").val(jobj.REFNUM); + if(jobj.STATUS == "Approved"){ + $.ajax({type: "POST", + url: "/origami/payment/"+payment_type, + data: "amount="+ bnk_bill_amount + "&sale_id="+ sale_id + "&ref_no=" + jobj.REFNUM, + success:function(result){ + if(result){ + swal({ + title: "Information!", + text: "Payment Successfully", + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + var url_param = "payment"; + if(location.pathname.includes("credit_payment")){ + url_param = "credit_payment"; + } + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/"+url_param; + }); + } + } + }); + }else{ + if(payment_type!="master"){ + payment_type = payment_type.toUpperCase(); + }else{ + payment_type = "Master"; + } + swal({ + title: 'Oops', + text: "Transaction is " + (jobj.STATUS).toLowerCase(), + type: 'error', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + var url_param = "payment"; + if(location.pathname.includes("credit_payment")){ + url_param = "credit_payment"; + } + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/"+url_param+"/others_payment/"+payment_type; + }); + } +} +//end CB ECR integration + +function setHeaderBreadCrumb(params){ + $("#others_payment").html(params); +} + +//show hide nav bar for webview +function showHideNavbar(webview,page){ + if(webview){ + $("nav.navbar").addClass("hidden"); + $("section").addClass("section-margin"); + $(".page-loader-wrapper").addClass("hidden"); + if(page!=undefined){ + $("#back").hide(); + } + }else{ + $("nav.navbar").removeClass("hidden"); + $("section").removeClass("section-margin"); + $(".page-loader-wrapper").removeClass("hidden"); + if(page!=undefined){ + $("#back").show(); + } + } +} + +function createAccessCode(code) { + localStorage.setItem("access_code",code); +} + +//get menu item cache +function getAllMenu(){ + $.ajax({ + type: "GET", + url: '/origami/get_all_menu', + data: {}, + success:function(result){ + console.log(result) + localStorage.setItem("menus", JSON.stringify(result)); + + var menu = localStorage.getItem("menus"); + if (menu != null ) { + $( "#loading_wrapper").hide(); + } + } + }); +} + +/* String format */ +if (!String.prototype.formatUnicorn) { + String.prototype.formatUnicorn=function(){ + var e=this.toString(); + if(!arguments.length){ + return e; + } + var t=typeof arguments[0],n="string"==t||"number"==t?Array.prototype.slice.call(arguments):arguments[0]; + for(var i in n){ + e=e.replace(new RegExp("\\{"+i+"\\}","gi"),n[i]==null?'':n[i]); + } + return e; + }; +} +/* String format */ + +//credit sales lists +function timeFormat(date){ + var isPM = date.getHours() >= 12; + var isMidday = date.getHours() == 12; + var time = [(date.getHours()>10? date.getHours() : '0'+date.getHours()) - (isPM && !isMidday ? 12 : 0), + (date.getMinutes()>10? date.getMinutes() : '0'+date.getMinutes()) || '00'].join(':') + + (isPM ? ' PM' : ' AM'); + return time; +} + +function getCreditData(cashier_type){ + var filter = $("#filter").val(); + var customer = $("#sel_customer").val(); + + var receipt_no = ""; + var customer_id = ""; + if((filter!=undefined) && (filter!=null) && (filter!="")){ + receipt_no = filter; + } + if((customer!=undefined) && (customer!=null) && (customer!="")){ + customer_id = customer; + } + getCreditSales(receipt_no, customer_id, cashier_type); +} + +function getCreditSales(filter, customer, cashier_type){ + // $(".credit_items").hide(); + $(".tbd_credit_lists").empty(); + var html_credit_items = $("#html_credit_items").html(); + var receipt_no = ""; + var customer_id = ""; + if((filter!=undefined) && (filter!=null) && (filter!="")){ + receipt_no = filter; + } + if((customer!=undefined) && (customer!=null) && (customer!="")){ + customer_id = customer; + } + $.ajax({ + type: "POST", + data: {receipt_no: receipt_no, customer_id: customer_id}, + dataType: 'json', + url: "/origami/"+cashier_type+"/credit_sales", + success: function(data){ + // console.log(data); + if(data.status){ + var credit_sales = data.data; + // console.log(credit_sales); + if(credit_sales.length > 0){ + $(".credit_items").show(); + for (var i = 0; i < credit_sales.length ; i++) { + var sale_date = new Date(credit_sales[i].sale_date); + var receipt_date = sale_date.getFullYear() +'-'+ (sale_date.getMonth() > 10 ? (sale_date.getMonth()+1) : '0' + (sale_date.getMonth()+1)) +'-'+ (sale_date.getDate() > 10 ? sale_date.getDate() : '0' + sale_date.getDate()); + $('.tbd_credit_lists').append(html_credit_items.formatUnicorn({ + 'key':i, + 'sale_id':credit_sales[i].sale_id, + 'receipt_date':receipt_date +" "+timeFormat(sale_date), + 'receipt_no':credit_sales[i].receipt_no, + 'cashier_name':credit_sales[i].cashier_name, + 'customer_name':credit_sales[i].customer_name, + 'credit_amount':credit_sales[i].payment_amount, + 'cashier_type':cashier_type + })); + } + } + }else{ + $(".tbd_credit_lists").html(data.message); + } + } + }); +} +//End of credit sales function diff --git a/app/assets/stylesheets/foodcourt.scss b/app/assets/stylesheets/foodcourt.scss new file mode 100644 index 00000000..64cc2937 --- /dev/null +++ b/app/assets/stylesheets/foodcourt.scss @@ -0,0 +1,729 @@ +@import "material_icons"; +@import "tether"; +@import "bootstrap/css/bootstrap-material-design.min"; +@import "node-waves/waves"; +@import "animate-css/animate"; +@import "sweetalert/sweetalert.css"; +@import "multi-select/css/multi-select.css"; +@import "bootstrap-material-datetimepicker/css/bootstrap-material-datetimepicker"; +@import "morrisjs/morris"; +@import "BSBMaterial/style"; +@import "BSBMaterial/themes/all-themes"; +@import "reset"; +@import "fileinput.min"; + + +/* Reset */ +.col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12, .col-auto, .col-lg, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-auto, .col-md, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12, .col-md-auto, .col-sm, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-auto { + padding-left: 5px; + padding-right: 5px; +} + +.col-lg-1, .col-md-1, .col-sm-1,col-xl-1{ + padding-left: 1px ; + padding-right: 1px ; +} + +.ls-closed section.content { + margin-left: 5px; +} + +section.content { + margin: 70px 5px 0 225px; +} + +.table { + margin-bottom: 0px; +} + +select.form-control { + height: inherit !important; +} + +.form-horizontal .form-group { + margin-right: 0px !important; +} + +.card-columns { + font-size: 18px !important; +} + +@media (min-width:769px) and (max-width:1024px) { + .btn-block { + font-size: 11px !important; + } +} + +/* End Reset */ + +#back { + padding: 0px 0px 7px 0px; +} + +/* +.order-info { + min-height:300px; + max-height:500px; + overflow:auto +} +*/ + +.others-payment{ + line-height:100px; + text-align:center; + color:white; + width:300px; + height:100px; + font-size:18px; +} + +.orders-table { + cursor: pointer; +} + +.cashier_number{ + width: 33%; + height:58px; + line-height:58px; + text-align:center; + background:#54A5AF; + // float:left; + // margin:2px; + font-size:20px; + color:white; + // cursor:pointer; +} + +.access_number{ + width: 33%; + height:58px; + line-height:58px; + text-align:center; + background:#54A5AF; + // float:left; + // margin:2px; + font-size:20px; + color:white; + // cursor:pointer; +} + +.del_cashier_number{ + opacity:0.6, +} + +.pay{ + width: 86%; + height:174px; + line-height:174px; + text-align:center; + font-size:20px; + color:white; +} + +.move_table{ + width: 100%; + height:74px; + line-height:74px; + text-align:center; + font-size:20px; + color:white; +} + + +.payment{ + height:50px; + line-height:50px; + align:center; + color:white; + font-size:16px; + margin:5px; +} + +.font-12 { + font-size: 12px; +} + +.cash-color{ + background-color:#2196F3; +} + +.credit-color{ + background-color:#FFA500; +} + +.other-payment-color{ + background-color:#795548; +} + +.others-color{ + background-color:#E1BEE7; + height: 30px !important; + line-height: 30px !important; +} + + +.cashier_number:hover{ + background:#A9F5F2; +} + +.action-btn { + white-space: normal !important; + height: 60px; + margin-bottom: 5px; +} + +.radius-btn { + border-radius:5px; + color:#fff; + background-color:red; +} + +.bottom-5 { + margin-bottom: 5px; +} + +.fluid { + width: 100%; +} + +.style2 { + border-top: 3px double #8c8b8b; +} + +.long{ + width:43%; +} + +.sold { + background-color: red; +} + +.paid { + background-color: green; +} + +.selected-item { + color: #fff !important; + background-color: blue !important; +} + +.selected-account { + color: #fff !important; + background-color: blue !important; +} + +.selected-payment { + color: #fff !important; + background-color: blue !important; +} +.payment_btn { + white-space: normal !important; + margin-bottom: 15px; + margin-right: 15px; + color:#fff !important; + # background-color: green !important; +} + +/* Reciept Style */ +#order-charges-table td { + border-top: none !important; +} + +.charges-name { + width: 80%; + text-align: left; +} + +.item-name { + width: 60%; + text-align: left; +} + +.item-attr { + width: 20%; + text-align: right; +} + +.item-attr-edit{ + width: 10%; + text-align: left; +} + +.display-none{ + display: none; +} + +.text-white{ + color: #fff; +} + +/* Colors */ +.purple { + background-color:#7a62d3; +} + +.orange{ + background-color:#FF7F50; +} + +.red { + background-color:#F44336; +} + +.green{ + background-color: #009900; +} + +.orange{ + background-color: #FF8C00; +} + +.blue{ + background-color: blue; +} + +/* End Colors */ + +.left{ + margin-left:1px; +} + +.dtp-date .left{ + margin-left:0px; +} + +.bottom{ + margin-bottom:1px; +} + +/* Discount */ + +.required abbr{ + color: red !important; +} + +.border-top{ + border-top:1px solid #fff; +} + +.border-right{ + border-right:1px solid #fff; +} + +.border-left{ + border-left:1px solid #fff; +} + +#sxModal { + display: none; + overflow: auto; + width: 100%; + height: 100%; + background-color: #000; + background-color: rgba(0,0,0,0.4); + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 1100; +} + +#sxModal-Content { + position: relative; + left: 42%; + top: 30%; + background-color: #32ad1a; + color: #fff; + text-align: center; + width: 200px; + height: 200px; + padding-top: 5%; + border-radius: 100px; + z-index: 1101; +} + +/*Loading gif for payment*/ + +#loading_wrapper{ + position: fixed; + background-color: #C8C8C8 ; + height: 100%; + width: 100%; + left: 0; + opacity: 0.6; + top: 0; + z-index: 9999999; +} + +#loading{ + position: relative; + height: 100%; + width: 100%; + background-image: url('../../../image/loading-ajax.gif'); + background-position: center center; + background-repeat: no-repeat; + opacity: 1; + filter: alpha(opacity=100); /* ie */ + -moz-opacity: 1; /* mozilla */ + +} + +/* For Payment Page */ + +.payment-long { + width:43%; +} + +.payment-left { + margin-left: 20px; +} + +/* End Payment Page */ + +/* Logout Icon */ + +i.logout_icon{ + position: relative; + top: 5px; +} + +/* End Logout Icon */ + +/* Notify */ + +#notify-wrapper { + position: absolute; + top: 55px; + left: 10px; + z-index: 9999; + opacity: 0.8; +} + +[data-notify="container"] { + margin-bottom: 5px !important; + margin-left:5px !important; + position:relative !important; + top: 25% !important; + width: 100% !important; +} + +/* End Notify */ + +/* selected color for split bills */ +.selected-split-item { + color: #fff !important; + background-color: #5DADE2 !important; +} + +/* Start Is Member Modal */ +#is_memberModal .modal-body { + height: 260px !important; +} + +#is_memberModal .btn { + width: 80%; +} + +#is_paymemberModal .modal-body { + height: 150px !important; +} + +#is_paymemberModal .btn { + width: 80%; +} +/* End Is Member Modal */ + +/* Start iframe */ +iframe { + border: none; + overflow: hidden !important; + width: 400px; + height: 550px; +} + +#pdfModal .btn { + width: 150%; + height: 100%; +} + +#receipt_pdf { + height: 400px; +} +/* End iframe */ + +/* section class for webview */ +.section-margin { + margin-top: -50px; +} + +.tax-btn-box { + width: 230px; + height: 80px; +} + +/*Pagination*/ +nav.pagination { + margin:10px; + +} +nav.pagination .current{ + background-color:#1f91f3; + color:#fff; + padding:4px 10px; + margin-top:-4px; +} +nav.pagination .page a,.next a,.last a,.prev a,.first a{ + padding:6.5px 10px; + margin-left: 3px; +} + +nav.pagination .page a:hover, +a:focus { + background-color: #ccc; + text-decoration: none; + +} +nav.pagination .page a:hover, +.first a:hover,.last a:hover,.prev a:hover,.next a:hover{ + background-color: #ccc; + text-decoration: none; + +} + +#oqs_loading_wrapper{ + position: fixed; + background-color: #C8C8C8 ; + height: 100%; + width: 100%; + left: 0; + opacity: 0.6; + top: 0; + z-index: 100; +} +#oqs_loading{ + position: relative; + height: 100%; + width: 100%; + background-image: url('../../../image/loading-ajax.gif'); + background-position: center center; + background-repeat: no-repeat; + opacity: 1; + z-index: 101; + filter: alpha(opacity=100); /* ie */ + -moz-opacity: 1; /* mozilla */ +} +.existing_invoice{ + background-color:#ffab51; + color:#fff; + +} + + +/*----chane font_size (Amount Due && Balance)----*/ +#balance{ + height: 50%; + font-size: 20px; +} + +.amount_balance{ + height: 50%; + font-size: 20px; +} + + +#amount_due{ + height: 50%; + font-size: 20px; +} + +/*customer modal UI */ + .wizard { + background: #f1f1f1; + padding: 10px; + } + .wizard .nav-tabs { + position: relative; + border: 0px; + } + .wizard > div.wizard-inner { + position: relative; + margin: 0 0 0 145px !important; + } + .connecting-line{ + height:12px; + background: #e0e0e0; + position: absolute; + width: 110%; + margin: 0 auto; + left: 0; + right: 0; + top:38%; + z-index: 1; + border-radius: 15px; + } + .active-line{ + height:12px; + background: #e0e0e0; + position: absolute; + width: 5%; + margin: 0 auto; + left: 0; + right: 0; + top:61%; + z-index: 1; + border-radius: 15px !important; + } + .connecting-line a.active{ + background-color: #2ED4E0; + } + .border-right{ + border-radius: 15px 0 0 15px; + } + .border-left{ + border-radius: 0; + } + .wizard .nav-tabs > li { + margin-bottom: -20px; + } + .wizard .nav-tabs > li > a.active > a, .wizard .nav-tabs > li > a.active > a:hover, .wizard .nav-tabs > li > a.active > a:focus { + cursor: default; + border: 0; + color:#2ED4E0; + border-bottom-color: transparent; + } + .wizard .nav-tabs li p{ + padding-top:40px; + font-size: 14px; + text-align: center; + } + .list-inline{ + text-align: center; + } + span.round-tab { + width: 28px; + height: 28px; + line-height: 28px; + display: inline-block; + border-radius: 100px; + background:#DFE3E4; + border: 2px solid #fff; + z-index:1; + position:absolute; + text-align: center; + font-size: 16px; + } + .wizard li > a.active span.round-tab{ + background:#2196F3; + color:white; + border: 1px solid #fff; + } + span.round-tab:hover{ + color: white; + border: 1px solid #fff; + background-color:#2196F3; + } + .wizard .nav-tabs > li { + width: 25%; + } + .wizard .nav-tabs > li a{ + width: 28px; + height: 28px; + margin: 18px auto; + border-radius: 100%; + padding: 0; + color: #777; + } + .wizard .tab-pane { + position: relative; + padding-top: 5px; + border-top: 1px solid #fff; + margin-top: 20px; + } + .next-step:hover, .next-step, .prev-step:hover, .prev-step{ + position: relative; + background-color: #2196F3; + font-size: 14px; + color: #FFFFFF; + } +/*customer modal UI */ + +.payment-btn-box { + width: 130px; + height: 50px; +} + +@media screen and (max-width: 785px) { + section.content{ + margin: 80px 15px 0 225px; + } + + .mbl_view{ + display: none; + } + + .navbar-brand-txt{ + margin-top: -15px; + } + + .toggle_mbl { + text-align: right; + } + + .toggle_mbl img{ + width: 24px; + margin-bottom: 14px; + } + + .toggle_mbl a:hover, a:focus{ + background-color: unset; + } + + .col-mbl-view{ + width: 50%; + } + + .info-box .icon{ + display: none; + } + + .mbl_product_div{ + display: none; + } + + .sidebar .menu{ + top: 10px; + } + + .page-header{ + width: 100% !important; + } + + .ls-closed .bars:after, .ls-closed .bars:before{ + top: 14px; + } + + .mbl_card{ + width: 100% !important; + } + + .mbl_lbl{ + display: none; + } + + .mbl-style{ + padding: 10px 10px; + } + + .m-auto{ + width: 33%; + } + + .online_order{ + text-align: right; + } + + .mbl-right-btn{ + text-align: right; + } +} diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb index 0e8ea909..bc06496d 100755 --- a/app/controllers/api/api_controller.rb +++ b/app/controllers/api/api_controller.rb @@ -4,8 +4,15 @@ class Api::ApiController < ActionController::API # before_action :lookup_domain helper_method :current_token, :current_login_employee, :get_cashier - + before_action :core_allow + def core_allow + headers['Access-Control-Allow-Origin'] = '*' + headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS' + headers['Access-Control-Request-Method'] = '*' + headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization' + end private + #this is base api base controller to need to inherit. #all token authentication must be done here #response format must be set to JSON diff --git a/app/controllers/base_foodcourt_controller.rb b/app/controllers/base_foodcourt_controller.rb new file mode 100644 index 00000000..5a37529b --- /dev/null +++ b/app/controllers/base_foodcourt_controller.rb @@ -0,0 +1,58 @@ +class BaseFoodcourtController < ActionController::Base + include LoginVerification + layout "foodcourt" + + before_action :check_user + + #before_action :check_installation + protect_from_forgery with: :exception + + helper_method :current_token + + rescue_from CanCan::AccessDenied do |exception| + flash[:warning] = exception.message + # redirect_to origami_root_path + redirect_to origami_dashboard_path + end + + def check_user + if check_mobile + if current_user.nil? + return render status: 401, json: { + message: "User using other device!" + }.to_json + end + else + if current_user.nil? + redirect_to root_path + end + end + end + + # def checkin_process + # CheckinJob.set(wait: 1.minute).perform_later() + # end + + ##already in LoginVerification + # Get current Cashier + # def get_cashier + # @cashier = Employee.where("role = 'cashier' AND token_session <> ''") + # end + + #check webview + def check_mobile + status = false + authenticate_with_http_token do |token, options| + if token + session[:webview] = true + session[:session_token] = token + end + end + + if session[:webview] && request.user_agent =~ /android|blackberry|iphone|ipad|ipod|iemobile|mobile|webos/i + status = true + end + + return status + end +end diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index 4b8f1067..5ae86b18 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -18,7 +18,7 @@ module LoginVerification def current_shop begin - shop_code ='262' + shop_code ='263' @shop =Shop.find_by_shop_code(shop_code) return @shop rescue @@ -42,7 +42,7 @@ module LoginVerification #Shop Name in Navbor def shop_detail - shop_code ='262' + shop_code ='263' @shop = Shop.find_by_shop_code(shop_code) return @shop end diff --git a/app/controllers/foodcourt/addorders_controller.rb b/app/controllers/foodcourt/addorders_controller.rb new file mode 100755 index 00000000..7960c2f9 --- /dev/null +++ b/app/controllers/foodcourt/addorders_controller.rb @@ -0,0 +1,310 @@ +class Foodcourt::AddordersController < BaseFoodcourtController + # before_action :set_dining, only: [:detail] + + def index + @webview = false + if check_mobile + @webview = true + end + + @tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") + @rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") + @all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc') + @all_room = Room.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc') + end + + def detail + @cashier_type = params[:type] + @webview = false + if check_mobile + @webview = true + end + display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) + if !display_type.nil? && display_type.value.to_i ==2 + @display_type = display_type.value + else + @display_type = nil + end + # if params[:menu] == "true" + @menus = [] + @menu = [] + + @table_id = params[:id] + @table = DiningFacility.find(@table_id) + @booking = @table.get_booking + if @booking + @booking_id = @booking.booking_id + @obj_order = @booking.orders.first + @customer = @obj_order.customer + @date = @obj_order.created_at + @order_items = @booking.order_items + end + end + + def get_menu_category () + if (params[:id]) + + #Pull this menu + @menu = MenuCategory.find_by_id(params[:id]) + + # puts @menu.menu_items[1].item_attributes.to_json + return @menu + else + MenuCategory.current_menu + end + end + + def get_item_instance + @instance = MenuItemInstance.find(params[:id]) + end + + def get_menu() + if (params[:id]) + #Pull this menu + @menu = Menu.find_by_id(params[:id]) + @menu_category = MenuCategory.where("menu_id='#{@menu.id}'").order("order_by asc") + # puts @menu.menu_items[1].item_attributes.to_json + return @menu + else + Menu.current_menu + end + end + + def get_menu_sub_category () + + id = params[:id] + + if (id) + #Pull this menu + @sub_menu = MenuCategory.where("menu_category_id = #{id}").active + + # puts @menu.menu_items[1].item_attributes.to_json + return @sub_menu + end + end + + def get_all_product() + @product = Product.all + end + + def create + if params[:booking_id].present? + booking = Booking.find(params[:booking_id]) + end + if params[:table_id].present? + if booking.nil? || booking.dining_facility_id.to_i != params[:table_id].to_i + table = DiningFacility.find(params[:table_id]) + booking = table.get_current_booking + end + end + + is_extra_time = false + extra_time = '' + + items_arr = [] + JSON.parse(params[:order_items]).each { |i| + i["item_instance_code"] = i["item_instance_code"].downcase.to_s + if i["item_instance_code"].include? "ext" + is_extra_time = true + arr_exts = i["item_instance_code"].split("_") + if arr_exts[1].match(/^(\d)+$/) + time = arr_exts[1].to_i*60*i["quantity"].to_i + extra_time = Time.at(time) + end + end + if i["parent_order_item_id"]; + items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])} + else + items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])} + end + items_arr.push(items) + } + # begin + if params[:order_source] == "quick_service" && params[:table_id].to_i == 0 + customer_id = "CUS-000000000002" # for no customer id from mobile + else + customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile + end + + @order = Order.new + @order.source = params[:order_source] + @order.order_type = params[:order_type] + @order.customer_id = customer_id + @order.items = items_arr + @order.guest = params[:guest_info] + @order.table_id = params[:table_id] # this is dining facilities's id + @order.new_booking = true + @order.waiters = current_login_employee.name + @order.employee_name = current_login_employee.name + @order.shop_code =@shop.shop_code + @order.is_extra_time = is_extra_time + @order.extra_time = extra_time + + if booking.nil? || booking.sale_id.present? || booking.booking_status == 'moved' + @order.new_booking = true + else + @order.new_booking = false + @order.booking_id = booking.booking_id + end + + @status, @booking = @order.generate + + if @status && @booking + #send order broadcast to order_channel + if @order.table_id.to_i > 0 + table = DiningFacility.find(@booking.dining_facility_id) + type = 'order' + from = getCloudDomain #get sub domain in cloud mode + ActionCable.server.broadcast "order_channel",table: table,type:type,from:from + + end + + if params[:order_source] != "quick_service" && params[:order_source] != "food_court" + 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" + if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court') + + @status, @sale = Sale.request_bill(@order,current_user,current_login_employee) + + # for second display + if @order.source == 'quick_service' + from = getCloudDomain #get sub domain in cloud mode + ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from + end + #end + result = {:status=> @status, :data => @sale ,:current_user_role =>current_user.role} + render :json => result.to_json + end + else + result = {:status=> @status, :data => 0 } + render :json => result.to_json + end + + end + + # render json for http status code + def return_json_status_with_code(code, msg) + render status: code, json: { + message: msg, + booking_id: booking_id + }.to_json + end + + def check_order_with_table(table_id) + table = DiningFacility.find(table_id) + if table + booking = table.get_current_booking + # puts booking + if booking + if !booking.sale_id.nil? + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" + @order.new_booking = true + return false + end + else + @order.new_booking = false + @order.booking_id = booking.booking_id + return false + end + end + end + end + + # this can always true + def check_order_with_booking(booking) + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" + @order.new_booking = true + return false + else + @order.new_booking = false + @order.booking_id = params[:booking_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_and_shop_code("sidekiq",@shop.shop_code) + 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 + + from = getCloudDomain #get sub domain in cloud mode + 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 + + #get cloud domain + def getCloudDomain + from = "" + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain.to_s + "." + request.domain.to_s + end + + return from + end + +end diff --git a/app/controllers/foodcourt/card_payments_controller.rb b/app/controllers/foodcourt/card_payments_controller.rb new file mode 100755 index 00000000..2c6aa0dd --- /dev/null +++ b/app/controllers/foodcourt/card_payments_controller.rb @@ -0,0 +1,27 @@ +class Foodcourt::CardPaymentsController < BaseFoodcourtController + def index + @membership_rebate_balance = 0 + @membership_id = 0 + if !@membership_id.nil? + membership_setting = MembershipSetting.find_by_membership_type("paypar_url") + membership_data = SalePayment.get_paypar_account(membership_setting.gateway_url,membership_setting.auth_token,@membership_id) + if membership_data["status"]==true + membership_account_data = membership_data["data"]; + membership_account_data.each do |acc_data| + if acc_data["accountable_type"] == "REBATEACCOUNT" + @membership_rebate_balance=acc_data["balance"] + else + @membership_rebate_balance = 0 + end + end + else + @membership_rebate_balance = 0 + end + end + + end + + def create + end + +end diff --git a/app/controllers/foodcourt/cash_ins_controller.rb b/app/controllers/foodcourt/cash_ins_controller.rb new file mode 100755 index 00000000..9f96dffd --- /dev/null +++ b/app/controllers/foodcourt/cash_ins_controller.rb @@ -0,0 +1,44 @@ +class Foodcourt::CashInsController < BaseFoodcourtController + def new + end + + def create + reference = params[:reference] + remark = params[:remark] + amount = params[:amount] + payment_method = params[:payment_method] + payment_method_reference = params[:payment_method_reference] + type = params[:type] + + p_jour = PaymentJournal.new + + p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user) + shift = ShiftSale.current_open_shift(current_user) + + current_shift = ShiftSale.current_shift(@shop.shop_code) + # set cashier + if shift != nil + shift = shift + else + + open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") + if open_cashier.count>0 + shift = ShiftSale.current_open_shift(open_cashier[0]) + + if shift + emp = Employee.find_by_id(shift.employee_id) + shift = ShiftSale.current_open_shift(emp) + else + shift = ShiftSale.current_open_shift(current_shift) + end + else + # shift = Employee.find(current_shift.employee_id).name + shift =current_shift + end + end + puts shift.to_json + shift.cash_in = shift.cash_in + amount.to_f + shift.save + end + +end diff --git a/app/controllers/foodcourt/cash_outs_controller.rb b/app/controllers/foodcourt/cash_outs_controller.rb new file mode 100755 index 00000000..f890f51c --- /dev/null +++ b/app/controllers/foodcourt/cash_outs_controller.rb @@ -0,0 +1,39 @@ +class Foodcourt::CashOutsController < BaseFoodcourtController + def new + end + + def create + reference = params[:reference] + remark = params[:remark] + amount = params[:amount] + p_jour = PaymentJournal.new + p_jour.cash_out(reference, remark, amount, current_user) + shift = ShiftSale.current_open_shift(current_user) + + current_shift = ShiftSale.current_shift(@shop.shop_code) + + # set cashier + if shift != nil + shift = shift + else + open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") + if open_cashier.count>0 + + shift = ShiftSale.current_open_shift(open_cashier[0]) + + if shift + emp = Employee.find_by_id(shift.employee_id) + shift = ShiftSale.current_open_shift(emp) + else + shift = ShiftSale.current_open_shift(current_shift) + end + else + # shift = Employee.find(current_shift.employee_id).name + shift =current_shift + end + end + shift.cash_out = shift.cash_out + amount.to_i + shift.save + end + +end diff --git a/app/controllers/foodcourt/customers_controller.rb b/app/controllers/foodcourt/customers_controller.rb new file mode 100644 index 00000000..853d58c0 --- /dev/null +++ b/app/controllers/foodcourt/customers_controller.rb @@ -0,0 +1,193 @@ +class Foodcourt::CustomersController < BaseFoodcourtController + load_and_authorize_resource + def index + end + + # GET /crm/customers/1 + # GET /crm/customers/1.json + def show + end + + def get_customer + filter = params[:filter] + type = params[:type] + + if filter.nil? + @crm_customers = Customer.order("customer_id").page(params[:page]) + #@products = Product.order("name").page(params[:page]).per(5) + else + @crm_customers = Customer.search(filter) + # search account no from paypar + if !@crm_customers.present? && type == "card" + response = Customer.search_paypar_account_no(filter) + if response["status"] == true + @crm_customers = Customer.new + @crm_customers.name = response["customer_data"]["name"] + @crm_customers.contact_no = response["customer_data"]["phone"] + @crm_customers.email = response["customer_data"]["email"] + @crm_customers.date_of_birth = response["customer_data"]["DOB"] + @crm_customers.nrc_no = response["customer_data"]["NRC"] + @crm_customers.address = response["customer_data"]["address"] + @crm_customers.card_no = response["customer_data"]["customer_card_no"] + @crm_customers.paypar_account_no = filter + @crm_customers.membership_id = response["customer_data"]["id"] + @crm_customers.membership_type = response["customer_data"]["member_group_id"] + @crm_customers.customer_type = "Dinein" + @crm_customers.tax_profiles = ["1", "2"] + @crm_customers.save + @crm_customers = Customer.search(filter) + else + @crm_customers = [{"customer_id": response["status"],"message": response["message"] }] + end + end + end + + render :json => @crm_customers.to_json + end + + def add_customer + @webview = false + if check_mobile + @webview = true + end + + @sale_id = params[:sale_id] + @cashier_type = params[:type] + @page = params[:dir_page] + + if(@sale_id[0,3] == "SAL") + @booking = Booking.find_by_sale_id(@sale_id) + if @booking.dining_facility_id.to_i > 0 + @dining_facility = DiningFacility.find(@booking.dining_facility_id) + else + @dining_facility = nil + end + + else + @booking_order = BookingOrder.find_by_order_id(@sale_id) + @booking = Booking.find(@booking_order.booking_id) + if @booking.dining_facility_id.to_i > 0 + @dining_facility = DiningFacility.find(@booking.dining_facility_id) + else + @dining_facility = nil + end + end + + filter = params[:filter] + + if filter.nil? + @crm_customers = Customer.order("customer_id") #.page(params[:page]) + #@products = Product.order("name").page(params[:page]).per(5) + else + @crm_customers = Customer.search(filter) + end + #@crm_customers = Customer.all + @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(20) + @crm_customer = Customer.new + @count_customer = Customer.count_customer + + # @taxes = TaxProfile.where(:group_type => 'cashier') + @taxes = TaxProfile.unscoped.select("id, (CONCAT(name,'(',(SELECT name FROM lookups WHERE lookup_type='tax_profiles' AND value=group_type),')')) as name") + .order("group_type ASC,order_by ASC") + # if flash["errors"] + # @crm_customer.valid? + # end + @membership_types = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("member_group_type") + #get paypar accountno + @paypar_accountno = Customer.where("paypar_account_no IS NOT NULL AND paypar_account_no != ''").pluck("paypar_account_no") + #for create customer on/off + @create_flag = true + lookup_customer = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('customer_settings') + if !lookup_customer.empty? + lookup_customer.each do |create_setting| + if create_setting[0].downcase == "create" + if create_setting[1] == '0' && current_login_employee.role == 'cashier' + @create_flag = false + end + end + end + end + + respond_to do |format| + # format.html { render :template => "crm/customers/index" } + format.html { render action: "index"} + format.json { render json: @crm_customers } + end + end + + def update_sale_by_customer + + id = params[:sale_id][0,3] + customer_id = params[:customer_id] + customer = Customer.find(customer_id) + order_source = params[:type] + # Check and find with card no + # if(!customer_id.include? "CUS") + # customer = Customer.find_by_paypar_account_no(customer_id) + # if(customer != nil) + # customer_id = customer.customer_id + # end + # end + + if(id == "SAL") + sale = Sale.find(params[:sale_id]) + status = sale.update_attributes(customer_id: customer_id) + sale.sale_orders.each do |sale_order| + order = Order.find(sale_order.order_id) + status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type) + end + action_by = current_user.id + remark = "Assign Customer Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Customer ID ->#{customer.customer_id}- Customer Name ->#{customer.name}" + sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"ASSIGNCUSTOMER" ) + + else + @booking = BookingOrder.find_by_order_id(params[:sale_id]) + @orders = BookingOrder.where("booking_id = ? ", @booking.booking_id) + + @orders.each do |bo| + order = Order.find(bo.order_id) + status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type) + end + + end + + if status == true + render json: JSON.generate({:status => true}) + if(id == "SAL") + sale.compute_by_sale_items(sale.total_discount, nil, order_source) + end + else + render json: JSON.generate({:status => false, :error_message => "Record not found"}) + end + end + + def send_account + amount = params[:amount] + account_no = params[:account_no] + receipt_no = params[:receipt_no] + sale = Sale.find_by_receipt_no(receipt_no) + @out = [] + action_by = current_user.name + membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code) + if membership_setting.gateway_url + member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code) + if member_actions.gateway_url + @campaign_type_id = nil + url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s + merchant_uid= member_actions.merchant_account_id + auth_token = member_actions.auth_token.to_s + membership_data = SalePayment.get_paypar_account_data(url,membership_setting.auth_token,merchant_uid,auth_token,account_no,amount,receipt_no) + + if membership_data["status"]==true + remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Transaction ref: #{membership_data[:transaction_ref]} | Reload amount #{membership_data[:reload_amount]} | Old Balance Amount #{membership_data[:old_balance_amount]} | DateTime : #{membership_data[:date]}" + sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" ) + else + remark = "Payment by account no Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Remark : #{membership_data[:message]}" + sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"PAYBYACCOUNT" ) + end + @out = membership_data + render json: JSON.generate({:status => membership_data["status"], :message => membership_data["message"]}) + end + end + end +end diff --git a/app/controllers/foodcourt/dashboard_controller.rb b/app/controllers/foodcourt/dashboard_controller.rb new file mode 100644 index 00000000..9fd19ec7 --- /dev/null +++ b/app/controllers/foodcourt/dashboard_controller.rb @@ -0,0 +1,121 @@ +class Foodcourt::DashboardController < BaseFoodcourtController + + def index + today = DateTime.now.strftime('%Y-%m-%d') + + @display_type = Lookup.where("shop_code='#{@shop.shop_code}'").find_by_lookup_type("display_type") + + @sale_data = Array.new + @total_payment_methods = Sale.total_payment_methods(@shop,today,current_user) + if !@total_payment_methods.nil? + @total_payment_methods.each do |payment| + if payment.payment_method == "mpu" || payment.payment_method == "visa" || payment.payment_method == "master" || payment.payment_method == "jcb" || payment.payment_method == "unionpay" || payment.payment_method == "alipay" + pay = Sale.payment_sale(@shop,'card', today, current_user) + @sale_data.push({'card' => pay.payment_amount}) + else + pay = Sale.payment_sale(@shop,payment.payment_method, today, current_user) + @sale_data.push({payment.payment_method => pay.payment_amount}) + end + end + else + @sale_data = nil + end + @summ_sale = Sale.summary_sale_receipt(@shop,today,current_user) + @total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(@shop,today,current_user,@from,@to,@from_time,@to_time) + # @total_other_customer = Sale.total_other_customer(today,current_user) + + @total_order = Sale.total_order(@shop,today,current_user) + @total_accounts = Sale.total_account(@shop,today,current_user) + @account_data = Array.new + if !@total_accounts.nil? + @total_accounts.each do |account| + acc = Sale.account_data(@shop,account.account_id, today,current_user) + if !acc.nil? + @account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc}) + end + end + else + @account_data = nil + end + + @top_items = Sale.top_items(@shop,today,current_user) + @total_foc_items = Sale.total_foc_items(@shop,today,current_user) + + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() + @current_user = current_user + #dine-in cashier + dinein_cashier = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier') + @dinein_cashier = 0 + if !dinein_cashier[0].nil? + @dinein_cashier = dinein_cashier[0][1] + end + + #quick service + quick_service = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('quick_service') + @quick_service = 0 + if !quick_service[0].nil? + @quick_service = quick_service[0][1] + end + + #fourt court + food_court = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('food_court') + @food_court = 0 + @food_court_name = nil + if !food_court[0].nil? + @food_court = food_court[0][1] + @food_court_name = food_court[0][0] + end + + #order reservation + order_reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('order_reservation') + @order_reservation = 0 + if !order_reservation.empty? + order_reservation.each do |order_reserve| + if order_reserve[0] == 'OrderReservation' + @order_reservation = order_reserve[1] + end + end + end + + #dashboard settings on/off for supervisor and cashier + dashboard_settings = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dashboard_settings') + @setting_flag = true + if !dashboard_settings.empty? + dashboard_settings.each do |setting| + if setting[0].to_s.downcase == current_user.role.downcase && setting[1] == '0' + @setting_flag = false + end + end + end + + #reservation + reservation = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('reservation') + @reservation = 0 + if !reservation.empty? + reservation.each do |reserve| + if reserve[0] == 'Reservation' + @reservation = reserve[1] + end + end + end + end + +def get_all_menu + @menus = Menu.includes(:menu_categories => {:menu_items => :menu_item_instances}).includes(:menu_categories => {:menu_items => :item_sets }).active.all.where("shop_code='#{@shop.shop_code}'") + @item_attributes = MenuItemAttribute.all.load + @item_options = MenuItemOption.all.load +end + +def get_credit_sales + credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code) + if !credit_sales.nil? + result = {:status=> true, :data=> credit_sales } + else + result = {:status=> false, :message=>"There is no record." } + end + + render :json => result.to_json +end + +end diff --git a/app/controllers/foodcourt/discounts_controller.rb b/app/controllers/foodcourt/discounts_controller.rb new file mode 100755 index 00000000..80d30cd9 --- /dev/null +++ b/app/controllers/foodcourt/discounts_controller.rb @@ -0,0 +1,336 @@ +class Foodcourt::DiscountsController < BaseFoodcourtController + authorize_resource :class => false + + #discount page show from origami index with selected order + def index + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() + @webview = false + if check_mobile + @webview = true + end + + sale_id = params[:id] + @cashier_type = params[:type] + if Sale.exists?(sale_id) + @sale_data = Sale.find(sale_id) + if @sale_data.bookings[0].dining_facility_id.to_i > 0 + @table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id) + else + @table = nil + end + end + + @member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code) + @accounts = Account.where("shop_code='#{@shop.shop_code}'") + end + + #discount page show from origami index with selected order + def create + order_source = params[:cashier_type] + sale_id = params[:sale_id] + discount_items = JSON.parse(params[:discount_items]) + overall_discount = params[:overall_discount] + sub_total = params[:sub_total] + + if Sale.exists?(sale_id) + sale = Sale.find(sale_id) + if sale.bookings[0].dining_facility_id.to_i > 0 + table_id = sale.bookings[0].dining_facility_id + table = DiningFacility.find(table_id) + else + table = nil + table_id = nil + end + + + # sale.total_discount = overall_discount.to_f + # sale.total_amount = sub_total.to_f + # sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax; + # sale.save + if discount_items.length > 0 + + #save sale item for discount + discount_items.each do |di| + origin_sale_item = SaleItem.find(di["id"]) + + sale_item = SaleItem.new + + # if !origin_sale_item.nil? + # menu_category = MenuCategory.get_menu_category(origin_sale_item.product_code) #get menu category for menu items + # if !menu_category.nil? + # sale_item.menu_category_code = menu_category.code + # sale_item.menu_category_name = menu_category.name + # end + # end + + sale_item.menu_category_code = origin_sale_item.menu_category_code + sale_item.menu_category_name = origin_sale_item.menu_category_name + + sale_item.sale_id = sale_id + sale_item.product_code = origin_sale_item != nil ? origin_sale_item.product_code : sale_id + sale_item.product_name = di["name"] + sale_item.item_instance_code = origin_sale_item.item_instance_code + sale_item.product_alt_name = "" + sale_item.status = "Discount" + + sale_item.qty = -1 + sale_item.unit_price = di["price"].to_f * -1 + sale_item.taxable_price = di["price"] + sale_item.is_taxable = 1 + sale_item.account_id = origin_sale_item.account_id + + sale_item.price = di["price"] + sale_item.save + + action_by = current_user.name + remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} " + + sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_name, action_by,remark,"ITEMDISCOUNT" ) + + end + end + + # Re-calc All Amount in Sale + if overall_discount.to_f > 0 + action_by = current_user.name + if table.nil? + remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- no Table " + else + remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} " + end + + sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"OVERALLDISCOUNT" ) + end + sale.compute_by_sale_items(overall_discount.to_f, nil,order_source) + if !table.nil? + result = {:status=> "Success", :table_id => table_id, :table_type => table.type } + else + result = {:status=> "Success" } + end + else + if !table.nil? + result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type } + else + result = {:status=> "Please, Check Again!" } + end + end + + + render :json => result.to_json + end + + # Remove selected discount Items + def remove_discount_items + order_source = params[:cashier_type] + sale_id = params[:sale_id] + discount_items = JSON.parse(params[:discount_items]) + if Sale.exists?(sale_id) + sale = Sale.find(sale_id) + if sale.bookings[0].dining_facility_id.to_i > 0 + table_id = sale.bookings[0].dining_facility_id + table = DiningFacility.find(table_id) + else + table_id = nil + table = nil + end + + + if discount_items.length > 0 + #destroy sale item for discount + discount_items.each do |di| + sale_item = SaleItem.find(di["id"]) + sale.total_amount = (sale.total_amount + sale_item.price.abs) + + action_by = current_user.name + if table.nil? + remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- No Table " + else + remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} " + end + sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEITEMDISCOUNT" ) + + sale_item.destroy + end + end + + # sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax; + # sale.save + # Re-calc All Amount in Sale + sale.compute_by_sale_items(sale.total_discount, nil, order_source) + if table.nil? + result = {:status=> "Success"} + else + result = {:status=> "Success", :table_id => table_id, :table_type => table.type } + end + + else + if table.nil? + result = {:status=> "Please, Check Again!"} + else + result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type } + end + + end + + render :json => result.to_json + end + + # Remove all discount Items + def remove_all_discount + sale_id = params[:id] + order_source = params[:type] + + if Sale.exists?(sale_id) + sale = Sale.find(sale_id) + + if sale.bookings[0].dining_facility_id.to_i > 0 + table_id = sale.bookings[0].dining_facility_id + table = DiningFacility.find(table_id) + table_type = table.type + else + table_id = nil + table = nil + table_type = nil + end + + discount_items = [] + #destroy all discount sale item + sale.sale_items.each do |si| + if si.status == "Discount" && si.price < 0 + sale.total_amount = (sale.total_amount + si.price.abs) + discount_items.push(si) + end + end + + # sale.total_discount = 0 + # sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax; + # sale.save + + #destroy in sale.sale_items + sale.sale_items.destroy(discount_items) + + action_by = current_user.name + if table.nil? + remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- No Table" + else + remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} " + end + sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_name, action_by,remark,"REMOVEALLDISCOUNT" ) + + # Re-calc All Amount in Sale + sale.compute_by_sale_items(0, nil, order_source) + if table.nil? + result = {:status=> "Success"} + else + result = {:status=> "Success", :table_id => table_id, :dining => table.name, :table_type => table_type } + end + + else + if table.nil? + result = {:status=> "Please, Check Again!"} + else + result = {:status=> "Please, Check Again!", :table_id => table_id, :dining => table.name, :table_type => table_type } + end + + end + + render :json => result.to_json + end + + # Member Discount + def member_discount + order_source = params[:cashier_type] + sale_id = params[:sale_id] + is_card = params[:is_card] + sub_total = params[:sub_total] + tax_type = params[:tax_type] + sale = Sale.find(sale_id) + if is_card == 'true' + is_card = true + else is_card.to_s == 'false' + is_card = false + end + # Check for Card Payment + is_card_payment = SalePayment.get_sale_payments_by_card(sale.sale_payments) + + # if is_card != "true" + account_types = Account.where("discount=?",true) + table_id = sale.bookings[0].dining_facility_id + table_type = DiningFacility.find(table_id).type + + # Get Prices for each accounts (eg: food, beverage) + account_price = SaleItem.calculate_price_by_accounts(sale.sale_items) + acc_prices = Array.new; + + account_types.each do |at| + account_price.each do |pc| + if pc[:name] == at.title && pc[:price]>0 + str={type:pc[:name],amount:pc[:price]} + acc_prices.push(str) + end + end + end + generic_customer_id = sale.customer.membership_id + receipt_no = sale.receipt_no + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("member_discount") + merchant_uid = memberaction.merchant_account_id.to_s + campaign_type_id = memberaction.additional_parameter["campaign_type_id"] + auth_token = memberaction.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + account_no = sale.customer.paypar_account_no rescue nil + + # Check for items for Paypar Cloud + if acc_prices.length > 0 + begin + response = HTTParty.post(url, + :body => { account_no: account_no, + generic_customer_id:generic_customer_id , + campaign_type_id: campaign_type_id, + receipt_no: receipt_no, + merchant_uid:merchant_uid, + campaign_method:acc_prices.to_json, + total_sale_transaction_amount: sale.grand_total, + is_card: is_card, + auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json; version=3' + }, :timeout => 10) + rescue HTTParty::Error + response = {"status": false, "message": "Http party error" } + + rescue Net::OpenTimeout + response = {"status": false, "message": "Connection TIme out " } + rescue OpenURI::HTTPError + response = {"status": false, "message": "Can't open membership server " } + + rescue SocketError + response = {"status": false, "message": "Can't open membership server " } + end + else + response = {"status": false, "message": "You have no selected discount item" } + end + Rails.logger.debug "-------------- Member Discount Osaka ---------" + Rails.logger.debug response.to_json + # Re-calc All Amount in Sale + if response["status"] == true + discount_amount = response["discount_earned"] + if response["discount_bonus_earned"] + discount_amount = discount_amount + response["discount_bonus_earned"] + end + sale.compute_by_sale_items(discount_amount, 'member_discount', order_source, tax_type) + result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type } + elsif response["status"] == "500" + result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type } + else + result = {:status=> response["message"],:title=>"Alert", :table_id => table_id,:table_type => table_type } + end + + render :json => result.to_json + + # end #end Is Card Payment + end + +end diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb new file mode 100644 index 00000000..a02d7b89 --- /dev/null +++ b/app/controllers/foodcourt/food_court_controller.rb @@ -0,0 +1,201 @@ +class Foodcourt::FoodCourtController < ApplicationController + # before_action :set_dining, only: [:detail] + before_action :check_user + def check_user + if current_user.nil? + redirect_to root_path + end + end + + def index + today = DateTime.now + day = Date.today.wday + # if params[:menu] == "true" + @menus = [] + @menu = [] + # else + # @menus = Menu.all + # @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') + # end + @zone = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true") + @customer = Customer.all + @tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @cashier_type = "food_court" + #checked quick_service only + @quick_service_only = true + lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier') + if !lookup_dine_in.empty? + lookup_dine_in.each do |dine_in| + if dine_in[0].downcase == "dineincashier" + if dine_in[1] == '1' + @quick_service_only = false + end + end + end + end + + render "foodcourt/addorders/detail" + end + + def modify_order + @cashier_type = "food_court" + today = DateTime.now + day = Date.today.wday + # if params[:menu] == "true" + @menus = [] + @menu = [] + # else + # @menus = Menu.all + # @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') + # end + if(params[:id][0,3] == "BKI") + @table_id = nil + @table = nil + @booking = Booking.find(params[:id]) + else + @table_id = params[:id] + @table = DiningFacility.find(@table_id) + @booking = @table.get_booking + end + + @sale_id = @booking.sale_id + + if @booking + @booking_id = @booking.booking_id + @obj_order = @booking.orders.first + @customer = @obj_order.customer + @date = @obj_order.created_at + @order_items = @booking.order_items + end + + render "foodcourt/addorders/detail" + end + + def update_modify_order + booking = Booking.find(params[:booking_id]) + sale = booking.sale + if sale && sale.sale_status != 'new' + render :json => { :status => false } + end + + is_extra_time = false + extra_time = '' + cashier_type = "food_court" + + items_arr = [] + JSON.parse(params[:order_items]).each { |i| + i["item_instance_code"] = i["item_instance_code"].downcase.to_s + if i["item_instance_code"].include? "ext" + is_extra_time = true + arr_exts = i["item_instance_code"].split("_") + if arr_exts[1].match(/^(\d)+$/) + time = arr_exts[1].to_i*60*i["quantity"].to_i + extra_time = Time.at(time) + end + end + if i["parent_order_item_id"] + items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": i["options"]} + else + items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]} + end + items_arr.push(items) + } + + # begin + order = Order.new + order.source = params[:order_source] + order.order_type = params[:order_type] + order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile + order.items = items_arr + order.guest = params[:guest_info] + order.table_id = params[:table_id] # this is dining facilities's id + order.waiters = current_login_employee.name + order.employee_name = current_login_employee.name + + order.is_extra_time = is_extra_time + order.extra_time = extra_time + + order.new_booking = false + order.booking_id = booking.booking_id + + if order.generate + if sale + Sale.add_to_existing_pending_invoice(nil, sale.sale_id, booking) + render :json => { :status => true, :data => sale } + else + render :json => { :status => true, :data => 'OK' } + end + else + render :json => { :status => false } + end + + end + + def get_menu_category () + if (params[:id]) + puts params[:id] + #Pull this menu + @menu = MenuCategory.find_by_id(params[:id]) + # puts @menu.menu_items[1].item_attributes.to_json + return @menu + else + MenuCategory.current_menu + end + end + + + def get_menu_sub_category () + id = params[:id] + if (id) + #Pull this menu + @sub_menu = MenuCategory.where("menu_category_id = #{id}").active + # puts @menu.menu_items[1].item_attributes.to_json + return @sub_menu + end + end + + def get_all_product() + @product = Product..where("shop_code='#{@shop.shop_code}'") + end + + # render json for http status code + def return_json_status_with_code(code, msg) + render status: code, json: { + message: msg, + booking_id: booking_id + }.to_json + end + + def check_order_with_table(table_id) + table = DiningFacility.find(table_id) + if table + booking = table.get_current_booking + # puts booking + if booking + if !booking.sale_id.nil? + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" + @order.new_booking = true + return false + end + else + @order.new_booking = false + @order.booking_id = booking.booking_id + return false + end + end + end + end + # this can always true + def check_order_with_booking(booking) + if booking.sale.sale_status == "completed" || booking.sale.sale_status == "new" + @order.new_booking = true + return false + else + @order.new_booking = false + @order.booking_id = params[:booking_id] + return false + end + end + +end diff --git a/app/controllers/foodcourt/home_controller.rb b/app/controllers/foodcourt/home_controller.rb new file mode 100755 index 00000000..3d424f14 --- /dev/null +++ b/app/controllers/foodcourt/home_controller.rb @@ -0,0 +1,168 @@ +class Foodcourt::HomeController < BaseFoodcourtController + authorize_resource :class => false + before_action :set_dining, only: [:show] + + def index + @webview = check_mobile + @tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @complete = Sale.completed_sale("cashier",@shop.shop_code) + @orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + + @customers = Customer.pluck("customer_id, name") + @occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count + @shift = ShiftSale.current_open_shift(current_user) + end + + # origami table detail + def show + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() + @webview = check_mobile + + @tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @complete = Sale.completed_sale("cashier",@shop.shop_code) + @orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @customers = Customer.pluck("customer_id, name") + @shift = ShiftSale.current_open_shift(current_user) + + @status_order = "" + @status_sale = "" + @sale_array = Array.new + + @membership = MembershipSetting.find_by_shop_code(@shop.shop_code) + @payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'") + @dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") + #@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'") + @order_items = Array.new + @dining_booking.each do |booking| + if booking.sale_id.nil? && booking.booking_status != 'moved' + @order_items = Array.new + # @assigned_order_items = Array.new + if booking.booking_orders.empty? + @booking = booking + else + booking.booking_orders.each do |booking_order| + order = Order.find(booking_order.order_id) + if (order.status == "new") + @obj_order = order + @customer = order.customer + @date = order.created_at + @booking= booking + order.order_items.each do |item| + @order_items.push(item) + # assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id) + # if !assigned_order_items.nil? + # @assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id}) + # end + end + @account_arr = Array.new + if @customer.tax_profiles + accounts = @customer.tax_profiles + @account_arr =[] + accounts.each do |acc| + account = TaxProfile.find_by_id(acc) + if !account.nil? + @account_arr.push(account) + end + end + end + end + end + end + @status_order = 'order' + else + sale = Sale.find(booking.sale_id) + if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste' + @sale_array.push(sale) + if @status_order == 'order' + @status_order = 'sale' + end + @booking= booking + @date = sale.created_at + @status_sale = 'sale' + @obj_sale = sale + @customer = sale.customer + accounts = @customer.tax_profiles + @account_arr =[] + accounts.each do |acc| + account = TaxProfile.find_by_id(acc) + if !account.nil? + @account_arr.push(account) + end + end + end + @sale_taxes = [] + sale_taxes = SaleTax.where("sale_id = ?", sale.sale_id) + if !sale_taxes.empty? + sale_taxes.each do |sale_tax| + @sale_taxes.push(sale_tax) + end + end + end + end + + #for bank integration + @checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time') + @checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time') + + accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC") + @tax_arr =[] + accounts.each do |acc| + @tax_arr.push(acc.name) + end + + lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill') + @split_bill = 0 + if !lookup_spit_bill[0].nil? + @split_bill = lookup_spit_bill[0][1] + end + + #for edit order on/off + @edit_order_origami = true + lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order') + if !lookup_edit_order.empty? + lookup_edit_order.each do |edit_order| + if edit_order[0].downcase == "editorderorigami" + if edit_order[1] == '0' && (current_login_employee.role == 'cashier' || current_login_employee.role == 'waiter') + @edit_order_origami = false + end + end + end + end + + #for changable on/off + @changable_tax = true + lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax') + if !lookup_changable_tax.empty? + lookup_changable_tax.each do |changable_tax| + if changable_tax[0].downcase == "change" + if changable_tax[1] == '0' + @changable_tax = false + end + end + end + end + + end + +def check_emp_access_code + pin_code = params[:code] + employee = Employee.find_by_emp_id(pin_code) + if employee && (employee.role == "manager" || employee.role == "supervisor") + result = {:status=> true, :message=>"Success" } + else + result = {:status=> false, :message=>"Invalid Access Code" } + end + render :json => result.to_json + +end + +private + +def set_dining + @dining = DiningFacility.find(params[:dining_id]) +end + +end diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb new file mode 100755 index 00000000..fce37da2 --- /dev/null +++ b/app/controllers/foodcourt/orders_controller.rb @@ -0,0 +1,96 @@ +class Foodcourt::OrdersController < BaseFoodcourtController + def show + @webview = false + if check_mobile + @webview = true + end + + @tables = Table.unscoped.all.active.order('status desc') + @rooms = Room.unscoped.all.active.order('status desc') + @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) + @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @order = Order.find(params[:order_id]) + booking = Booking.select('bookings.booking_id, bookings.dining_facility_id') + .joins(" JOIN booking_orders as bo on bo.booking_id = bookings.booking_id") + .where("bo.order_id='#{params[:order_id]}'").first() + + @booking = Array.new + if !booking.nil? + if booking.dining_facility_id.to_i > 0 + dining_facilities = DiningFacility.find_by_id(booking.dining_facility_id) + @booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => dining_facilities.type}) + else + @booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => nil}) + end + + end + @customers = Customer.pluck("customer_id, name") + #for split bill + lookup_spit_bill = Lookup.collection_of('split_bill') + @split_bill = 0 + if !lookup_spit_bill[0].nil? + @split_bill = lookup_spit_bill[0][1] + end + + sale_order = SaleOrder.find_by_order_id(@order.order_id) + if sale_order + unless sale_order.sale_id.nil? + sale = Sale.find(sale_order.sale_id) + @sale_status = sale.sale_status + end + end + + @order.order_items.each_with_index do |item, order_item_index| + if !item.set_menu_items.nil? + instance_item_sets = JSON.parse(item.set_menu_items) + arr_instance_item_sets = Array.new + instance_item_sets.each do |instance_item| + item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name + arr_instance_item_sets.push(item_instance_name) + item.price = item.price.to_f + instance_item["price"].to_f + end + @order.order_items[order_item_index].set_menu_items = arr_instance_item_sets + end + end + + # bookings = Booking.all + # if !bookings.today.nil? + # @order_items_count = Hash.new + # bookings.each do |booking| + # if booking.sale_id.nil? && booking.booking_status != 'moved' + # if !booking.booking_orders.empty? + # booking.booking_orders.each do |booking_order| + # order = Order.find(booking_order.order_id) + # if !order.order_items.empty? + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, order.order_items.count) + # else + # @order_items_count[booking.dining_facility_id] += order.order_items.count + # end + # end + # end + # end + # else + # if !booking.sale_id.nil? + # sale = Sale.find(booking.sale_id) + # if sale.sale_status !='completed' + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) + # else + # @order_items_count[booking.dining_facility_id] = sale.sale_items.count + # end + # end + # end + # end + # end + # end + end + def app_orders + @bookings = Booking.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") + .joins("JOIN orders ON orders.order_id=booking_orders.order_id") + .where("orders.source='app' and bookings.shop_code='#{@shop.shop_code}'").order("created_at desc") + end + def app_order_by_booking + + end +end diff --git a/app/controllers/foodcourt/other_charges_controller.rb b/app/controllers/foodcourt/other_charges_controller.rb new file mode 100755 index 00000000..c02cb0ca --- /dev/null +++ b/app/controllers/foodcourt/other_charges_controller.rb @@ -0,0 +1,85 @@ +class Foodcourt::OtherChargesController < BaseFoodcourtController + authorize_resource :class => false + + def index + @webview = false + if check_mobile + @webview = true + end + + sale_id = params[:sale_id] + @cashier_type = params[:type] + if Sale.exists?(sale_id) + @sale_data = Sale.find(sale_id) + if @sale_data.bookings[0].dining_facility_id.to_i > 0 + @table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id) + else + @table = nil + end + end + end + + def create + sale_id = params[:sale_id] + other_charges_items = JSON.parse(params[:other_charges_items]) + sub_total = params[:sub_total] + cashier_type = params[:cashier_type] + + if Sale.exists?(sale_id) + sale = Sale.find(sale_id) + if sale.bookings[0].dining_facility_id.to_i > 0 + table_id = sale.bookings[0].dining_facility_id + table = DiningFacility.find(table_id) + else + table_id = nil + table = nil + end + + + # sale.total_amount = sub_total.to_f + # sale.grand_total = sub_total.to_f + sale.total_tax; + # sale.save + if other_charges_items.length > 0 + #save sale item for discount + other_charges_items.each do |di| + # origin_sale_item = SaleItem.find(di["id"]) + sale_item = SaleItem.new + + sale_item.sale_id = sale_id + sale_item.menu_category_code = "0.0" + sale_item.menu_category_name = "Other Charges" + sale_item.product_code = "Other Charges" + sale_item.product_name = "*" + di["name"] + sale_item.product_alt_name = "" + sale_item.status = "Other Charges" + + sale_item.qty = 1 + sale_item.unit_price = di["price"] + sale_item.taxable_price = di["price"] * 1 + sale_item.is_taxable = di["is_taxable"] + sale_item.account_id = 0 + + sale_item.price = di["price"] * 1 + sale_item.save + + action_by = current_user.name + if table.nil? + remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->" + else + remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}" + end + + sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_name, action_by,remark,"ADDOTHERCHARGES" ) + + end + end + + # Re-calc All Amount in Sale + sale.compute_by_sale_items(sale.total_discount, nil, cashier_type) + end + if !table.nil? + dining = {:table_id => table_id, :table_type => table.type } + render :json => dining.to_json + end + end +end diff --git a/app/controllers/foodcourt/paymal_controller.rb b/app/controllers/foodcourt/paymal_controller.rb new file mode 100644 index 00000000..fca05a41 --- /dev/null +++ b/app/controllers/foodcourt/paymal_controller.rb @@ -0,0 +1,97 @@ +class Foodcourt::PaymalController < BaseFoodcourtController + def index + @sale_id = params[:sale_id] + payment_method = params[:payment_method] + @cashier_type = params[:type] + @membership_rebate_balance=0 + sale_data = Sale.find_by_sale_id(@sale_id) + @receipt_no = sale_data.receipt_no + # @shop = Shop.first + if @shop.is_rounding_adj + new_total = Sale.get_rounding_adjustment(sale_data.grand_total) + else + new_total = sale_data.grand_total + end + @rounding_adj = new_total-sale_data.grand_total + # @rounding_adj = sale_data.rounding_adjustment + + @payparcount = 0 + others = 0 + sale_data.sale_payments.each do |sale_payment| + if sale_payment.payment_method == "paypar" + @payparcount = @payparcount + sale_payment.payment_amount + else + others = others + sale_payment.payment_amount + end + end + @payment_prices = sale_data.grand_total - @payparcount -others + + + if sale_data + if sale_data.customer_id + customer_data= Customer.find_by_customer_id(sale_data.customer_id) + if customer_data + @membership_id = customer_data.membership_id + if !@membership_id.nil? + membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code) + if membership_setting.gateway_url + member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code) + if member_actions.gateway_url + @campaign_type_id = nil + url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s + merchant_uid= member_actions.merchant_account_id + auth_token = member_actions.auth_token.to_s + membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token) + if membership_data["status"]==true + @membership_rebate_balance=membership_data["balance"] + @out = true, @membership_rebate_balance,@membership_id + end + else + @out =false,0 + end + else + @out = false,0 + end + else + @out = false, 0 + end + else + @out = false, 0 + end + else + @out = false, 0 + end + else + @out = false, 0 + end + @out = false, 0 +end + +def create + cash = params[:payment_amount] + sale_id = params[:sale_id] + transaction_ref = params[:transaction_ref] + account_no = params[:account_no] + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + # shop_details = Shop.first + + # rounding adjustment + # if shop_details.is_rounding_adj + # new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + # rounding_adj = new_total-saleObj.grand_total + # saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + # end + + # saleObj = Sale.find(sale_id) + sale_payment = SalePayment.new + status, @sale,@membership_data = sale_payment.process_payment(saleObj, current_user, cash, "paymal",account_no) + + if status == true && @membership_data["status"] == true + @out = true, "Success!" + else + @out =false, @membership_data["message"] + end + end + end +end diff --git a/app/controllers/foodcourt/payments_controller.rb b/app/controllers/foodcourt/payments_controller.rb new file mode 100755 index 00000000..37bfe276 --- /dev/null +++ b/app/controllers/foodcourt/payments_controller.rb @@ -0,0 +1,691 @@ +class Foodcourt::PaymentsController < BaseFoodcourtController + authorize_resource :class => false + def index + end + + def create + cash = params[:cash] + sale_id = params[:sale_id] + member_info = nil + type = params[:type] + tax_type = params[:tax_type] + path = request.fullpath + latest_order_no = nil + is_kbz = params[:is_kbz] + + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + sale_items = SaleItem.get_all_sale_items(sale_id) + #shop_detail = Shop.first + # rounding adjustment + if !path.include? ("credit_payment") + if @shop.is_rounding_adj + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + rounding_adj = new_total - saleObj.grand_total + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) if rounding_adj > 0 + end + end + #end rounding adjustment + sp = SalePayment.where('sale_id=? and payment_method=? and payment_status=?', sale_id, 'kbzpay', 'paid').last + if is_kbz == 'false' + Rails.logger.info '################ CASH PAYMENT #################' + sale_payment = SalePayment.new + sale_payment.process_payment(saleObj, current_user, cash, "cash") + else + sp.kbz_edit_sale_payment(sp.received_amount.to_f, current_user) + end + + # end + + if !path.include? ("credit_payment") + rebate_amount = nil + # For Cashier by Zone + # bookings = Booking.where("sale_id='#{sale_id}'") + bookings = Booking.find_by_sale_id(sale_id) + + shift = ShiftSale.current_open_shift(current_user) + if !shift.nil? + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + else + if bookings.dining_facility_id.to_i > 0 + table = DiningFacility.find(bookings.dining_facility_id) + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) + + type = 'payment' + from = getCloudDomain #get sub domain in cloud mode + ActionCable.server.broadcast "order_channel",table: table,type:type,from:from + else + shift = ShiftSale.find(saleObj.shift_sale_id) + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + end + end + + # For Print + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + unique_code = "ReceiptBillPdf" + print_settings = PrintSetting.all + if !print_settings.nil? + print_settings.each do |setting| + if setting.unique_code == 'ReceiptBillPdf' + unique_code = "ReceiptBillPdf" + elsif setting.unique_code == 'ReceiptBillStarPdf' + unique_code = "ReceiptBillStarPdf" + end + end + end + + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + # else + + end + end + end + end + + customer= Customer.find(saleObj.customer_id) + + # get member information + rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote') + + if customer.membership_id != nil && rebate && credit_data.nil? + member_info = Customer.get_member_account(customer) + + if member_info["status"] == true + rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) + current_balance = SaleAudit.paymal_search(sale_id) + end + end + + #orders print out + if type == "quick_service" + booking = Booking.find_by_sale_id(sale_id) + if booking.dining_facility_id.to_i>0 + table_id = booking.dining_facility_id + else + table_id = 0 + end + + latest_order = booking.booking_orders.order("order_id DESC").limit(1).first() + if !latest_order.nil? + latest_order_no = latest_order.order_id + end + + booking.booking_orders.each do |order| + # Order.pay_process_order_queue(order.order_id, table_id) + oqs = OrderQueueStation.new + oqs.pay_process_order_queue(order.order_id, table_id) + + assign_order = AssignedOrderItem.assigned_order_item_by_job(order.order_id) + from = getCloudDomain #get sub domain in cloud mode + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from + end + + end + + #for card sale data + card_data = Array.new + card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id) + if !card_sale_trans_ref_no.nil? + card_sale_trans_ref_no.each do |cash_sale_trans| + card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s + card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s + card_no = cash_sale_trans.pan.last(4) + card_no = card_no.rjust(19,"**** **** **** ") + card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id}) + end + end + + #card_balance amount for Paymal payment + card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) + + # get printer info + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + # Calculate Food and Beverage Total + item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) + other_amount = SaleItem.calculate_other_charges(sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, 'Foodcourt',current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + + #end + end + logger.debug 'saleObj++++++++++++++++++++++++++' + logger.debug saleObj.to_json + if !saleObj.nil? + # InventoryJob.perform_now(self.id) + # InventoryDefinition.calculate_product_count(saleObj) + end + end + + # status, filename, sale_receipt_no, printer_name = Payment.pay(getCloudDomain, cash, sale_id, member_info, type, tax_type, path, latest_order_no, shop_detail, current_user, nil, nil) + render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name}) + end + + def show + display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) + if !display_type.nil? && display_type.value.to_i ==2 + @display_type = display_type.value + else + @display_type = nil + end + path = request.fullpath + sale_id = params[:sale_id] + @trans_flag = true + if params[:type] == "transaction" + @trans_flag = false + @cashier_type = "cashier" + else + @cashier_type = params[:type] + end + + if path.include? ("credit_payment") + @sale_payment = SalePayment.get_credit_amount_due_left(sale_id) + end + + @member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code) + @membership_rebate_balance=0 + + if Sale.exists?(sale_id) + @cash = 0.0 + @kbz_pay_amount = 0.0 + @other = 0.0 + @ppamount = 0.0 + @visacount= 0.0 + @jcbcount= 0.0 + @mastercount = 0.0 + @unionpaycount = 0.0 + @alipaycount = 0.0 + @junctionpaycount = 0.0 + @credit = 0.0 + @paymalcount = 0.0 + @dingacount = 0.0 + @giftvouchercount = 0.0 + @sale_data = Sale.find_by_sale_id(sale_id) + @balance = 0 + @accountable_type = '' + @table_no = '' + @dining = '' + @other_payment = 0.0 + @pdf_view = nil + @lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code) + if !@lookup_pdf.nil? + @pdf_view = @lookup_pdf.value + end + + amount = SalePayment.get_kbz_pay_amount(sale_id, current_user,@shop) + @kbz_pay_amount += amount.to_f + + #for changable on/off + @changable_tax = true + lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax') + if !lookup_changable_tax.empty? + lookup_changable_tax.each do |changable_tax| + if changable_tax[0].downcase == "change" + if changable_tax[1] == '0' + @changable_tax = false + end + end + end + end + + # @shop = shop_detail #show shop info + + @customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'") + + saleObj = Sale.find(sale_id) + + #total customer with individual total amount + @individual_total = Array.new + if !saleObj.equal_persons.nil? + per_person_amount = saleObj.grand_total.to_f / saleObj.equal_persons.to_i + @individual_total.push({'total_customer' => saleObj.equal_persons.to_i, 'per_person_amount' => per_person_amount.to_f }) + end + + # rounding adjustment + # if @shop.is_rounding_adj + # a = saleObj.grand_total % 25 # Modulus + # b = saleObj.grand_total / 25 # Division + # #not calculate rounding if modulus is 0 and division is even + # #calculate rounding if modulus is zero or not zero and division are not even + # if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + # new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + # @rounding_adj = new_total-saleObj.grand_total + # else + # @rounding_adj = @sale_data.rounding_adjustment + # end + # else + # @rounding_adj = @sale_data.rounding_adjustment + # end + #end rounding adjustment + + # rounding adjustment + if @shop.is_rounding_adj + a = saleObj.grand_total % 25 # Modulus + b = saleObj.grand_total / 25 # Division + #not calculate rounding if modulus is 0 and division is even + #calculate rounding if modulus is zero or not zero and division are not even + if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + @rounding_adj = new_total-saleObj.grand_total + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj) + @sale_data.grand_total = new_total + @sale_data.old_grand_total = saleObj.grand_total + @sale_data.rounding_adjustment = @rounding_adj + else + @rounding_adj = @sale_data.rounding_adjustment + end + else + @rounding_adj = @sale_data.rounding_adjustment + end + #end rounding adjustment + + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() + + #get customer amount + @customer = Customer.find(@sale_data.customer_id) + # accounts = @customer.tax_profiles + accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC") + @account_arr =[] + @tax_arr =[] + accounts.each do |acc| + account = TaxProfile.find(acc.id) + # @account_arr.push(account) + @tax_arr.push(account.name) + end + sale_taxes = SaleTax.where("sale_id = ?", saleObj.sale_id) + if !sale_taxes.empty? + sale_taxes.each do |sale_tax| + @account_arr.push(sale_tax) + end + end + rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + # get member information + if @customer.membership_id != nil && rebate + response = Customer.get_member_account(@customer) + if response["status"]==true + response["account_data"].each do |res| + if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" + @balance = @balance.to_f + res["balance"].to_f + # @accountable_type = res["accountable_type"] + @accountable_type = "Rebate Balance" + end + end + end + end + + #end customer amount + + #paymal payment + + @sale_data.bookings.each do |sbk| + if sbk.dining_facility_id.to_i >0 + df = DiningFacility.find(sbk.dining_facility_id) + @table_no = df.type + ' ' + df.name + @checkin_time = sbk.checkin_at + @dining = df + break + else + @table_no = nil + @checkin_time = nil + @dining = nil + end + end + + if path.include? ("credit_payment") + @sale_payment_data = SalePayment.get_sale_payment_for_credit(@sale_data) + else + @sale_payment_data = SalePayment.get_sale_payments(@sale_data) + end + @sale_payment_data.each do |spay| + if spay.payment_method == "cash" + @cash += spay.payment_amount + end + if spay.payment_method !="creditnote" + @other_payment += spay.payment_amount + end + + if spay.payment_method == "mpu" + @other += spay.payment_amount + elsif spay.payment_method == "paypar" + @ppamount += spay.payment_amount + elsif spay.payment_method == "visa" + @visacount += spay.payment_amount + elsif spay.payment_method == "jcb" + @jcbcount += spay.payment_amount + elsif spay.payment_method == "master" + @mastercount += spay.payment_amount + elsif spay.payment_method == "unionpay" + @unionpaycount += spay.payment_amount + elsif spay.payment_method == "JunctionPay" + @junctionpaycount += spay.payment_amount + elsif spay.payment_method == "creditnote" + @credit += spay.payment_amount + elsif spay.payment_method == "paymal" + @paymalcount += spay.payment_amount + elsif spay.payment_method == "alipay" + @alipaycount += spay.payment_amount + elsif spay.payment_method == "dinga" + @dingacount += spay.payment_amount + elsif spay.payment_method == "giftvoucher" + @giftvouchercount += spay.payment_amount + end + + end + end + end + + def reprint + sale_id = params[:sale_id] + member_info = nil + latest_order_no = nil + saleObj = Sale.find(sale_id) + + # For Cashier by Zone + bookings = Booking.where("sale_id='#{sale_id}'") + + booking = Booking.find_by_sale_id(sale_id) + latest_order = booking.booking_orders.joins(" JOIN orders ON orders.order_id = booking_orders.order_id").where("orders.source = 'quick_service'").order("order_id DESC").limit(1).first() + if !latest_order.nil? + latest_order_no = latest_order.order_id + end + # if bookings.count > 1 + # # for Multiple Booking + # table = DiningFacility.find(bookings[0].dining_facility_id) + # else + # table = DiningFacility.find(bookings[0].dining_facility_id) + # end + shift = ShiftSale.current_open_shift(current_user) + if !shift.nil? + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + else + if bookings[0].dining_facility_id.to_i > 0 + table = DiningFacility.find(bookings[0].dining_facility_id) + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) + else + shift = ShiftSale.find(saleObj.shift_sale_id) + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + end + end + + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + unique_code = "ReceiptBillPdf" + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + else + unique_code = "ReceiptBillPdf" + end + end + end + end + customer= Customer.find(saleObj.customer_id) + + #shop detail + #shop_detail = Shop.first + # get member information + rebate = MembershipSetting.find_by_rebate(1) + if customer.membership_id != nil && rebate + member_info = Customer.get_member_account(customer) + rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) + current_balance = SaleAudit.paymal_search(sale_id) + end + + #for card sale data + card_data = Array.new + card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id) + if !card_sale_trans_ref_no.nil? + card_sale_trans_ref_no.each do |cash_sale_trans| + card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s + card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s + card_no = cash_sale_trans.pan.last(4) + card_no = card_no.rjust(19,"**** **** **** ") + card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id}) + end + end + + #card_balance amount for Paymal payment + card_balance_amount,transaction_ref= SaleAudit.getCardBalanceAmount(sale_id) + + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + + # Calculate price_by_accounts + item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) + other_amount = SaleItem.calculate_other_charges(saleObj.sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) + + result = { + :status => true, + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + + # Mobile Print + render :json => result.to_json + # end + end + + def foc + cash = params[:cash] + sale_id = params[:sale_id] + sub_total = params[:sub_total] + remark = params[:remark] + member_info = nil + rebate_amount = nil + current_balance = nil + order_source = params[:type] + + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + #calculate cash acmount + cash = saleObj.total_amount + + if saleObj.discount_type == "member_discount" + saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0) + saleObj.compute_by_sale_items(0, nil, order_source) + end + + saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0) + + sale_payment = SalePayment.new + sale_payment.process_payment(saleObj, current_user, cash, "foc" ,remark) + + bookings = Booking.where("sale_id='#{sale_id}'") + if bookings[0].dining_facility_id.to_i > 0 + table = DiningFacility.find(bookings[0].dining_facility_id) + type = 'payment' + from = getCloudDomain #get sub domain in cloud mode + ActionCable.server.broadcast "order_channel",table: table,type:type,from:from + end + + + + # For Cashier by Zone + bookings = Booking.where("sale_id='#{sale_id}'") + + shift = ShiftSale.current_open_shift(current_user) + if !shift.nil? + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + else + if bookings[0].dining_facility_id.to_i > 0 + table = DiningFacility.find(bookings[0].dining_facility_id) + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) + else + shift = ShiftSale.find(saleObj.shift_sale_id) + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + end + end + + # Re-call Sale Data + saleObj = Sale.find(sale_id) + + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + # unique_code = "ReceiptBillPdf" + customer= Customer.find(saleObj.customer_id) + + #shop detail + #shop_detail = Shop.first + printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") + + unique_code="ReceiptBillPdf" + if !printer.empty? + printer.each do |printer_setting| + if printer_setting.unique_code == 'ReceiptBillPdf' + unique_code="ReceiptBillPdf" + elsif printer_setting.unique_code == 'ReceiptBillA5Pdf' + unique_code="ReceiptBillA5Pdf" + elsif printer_setting.unique_code == 'ReceiptBillStarPdf' + unique_code="ReceiptBillStarPdf" + end + end + end + # get printer info + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + # Calculate Food and Beverage Total + item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) + + other_amount = SaleItem.calculate_other_charges(saleObj.sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil) + result = { + :status => true, + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + + # Mobile Print + render :json => result.to_json + + if params[:type] == "quick_service" + booking = Booking.find_by_sale_id(sale_id) + if booking.dining_facility_id.to_i>0 + table_id = booking.dining_facility_id + else + table_id = 0 + end + + booking.booking_orders.each do |order| + Order.pay_process_order_queue(order.order_id,table_id) + end + end + # end + if !saleObj.nil? + #InventoryJob.perform_now(self.id) + # InventoryDefinition.calculate_product_count(saleObj) + end + end + end + + def rounding_adj + + saleObj = Sale.find(params[:sale_id]) + + if @shop.is_rounding_adj + a = saleObj.grand_total % 25 # Modulus + b = saleObj.grand_total / 25 # Division + #not calculate rounding if modulus is 0 and division is even + #calculate rounding if modulus is zero or not zero and division are not even + if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + rounding_adj = new_total-saleObj.grand_total + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + end + end + end + + #print function for receipt + def print + filename = params[:filename] + receipt_no = params[:receipt_no] + printer_name = params[:printer_name] + cashier_type = params[:type] + + if cashier_type.strip.downcase == "doemal_order" + unique_code = "ReceiptBillOrderPdf" + else + receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + unique_code = "ReceiptBillPdf" + print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'") + if !print_settings.nil? + print_settings.each do |setting| + if setting.unique_code == 'ReceiptBillPdf' + unique_code = "ReceiptBillPdf" + elsif setting.unique_code == 'ReceiptBillStarPdf' + unique_code = "ReceiptBillStarPdf" + end + end + end + if !receipt_bill_a5_pdf.empty? + receipt_bill_a5_pdf.each do |receipt_bilA5| + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[1] == '1' + unique_code = "ReceiptBillA5Pdf" + # else + # unique_code = "ReceiptBillPdf" + end + end + end + end + end + # get printer info + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name) + + result = { + :status => true, + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + Rails.logger.debug "$$$$$$$$$ result ::" + Rails.logger.debug result + # Mobile Print + render :json => result.to_json + # render :json => {status: true} + end + + #changable tax for sale + def change_tax + sale_id = params[:sale_id] + order_source = params[:cashier_type] + tax_type = params[:tax_type] + sale = Sale.find(sale_id) + sale.compute_by_sale_items(sale.total_discount, nil, order_source, tax_type) + + render json: JSON.generate({:status => true}) + end + + #get cloud domain + def getCloudDomain + from = "" + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain.to_s + "." + request.domain.to_s + end + + return from + end +end diff --git a/app/controllers/foodcourt/paypar_payments_controller.rb b/app/controllers/foodcourt/paypar_payments_controller.rb new file mode 100755 index 00000000..fd1b4c1b --- /dev/null +++ b/app/controllers/foodcourt/paypar_payments_controller.rb @@ -0,0 +1,32 @@ +class Foodcourt::PayparPaymentsController < BaseFoodcourtController + def create + sale_id = params[:sale_id] + @cashier_type = params[:type] + redeem_amount = params[:redeem_amount] + membership_id = params[:membership_id] + payment_method = "paypar" + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + # shop_details = Shop.first + + # rounding adjustment + if @shop.is_rounding_adj + new_total = Sale.get_rounding_adjustment(saleObj.grand_total) + rounding_adj = new_total-saleObj.grand_total + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) + end + + sale_payment = SalePayment.new + status,msg =sale_payment.process_payment(saleObj, current_user, redeem_amount,payment_method) + if status == true + @out = true, "Success!" + else + @out =false, "Please try again payment!" + end + else + @out = false, "There has no sale record!" + end + + end + +end diff --git a/app/controllers/foodcourt/request_bills_controller.rb b/app/controllers/foodcourt/request_bills_controller.rb new file mode 100755 index 00000000..4e3057fe --- /dev/null +++ b/app/controllers/foodcourt/request_bills_controller.rb @@ -0,0 +1,113 @@ +class Foodcourt::RequestBillsController < ApplicationController + before_action :check_user + + def check_user + if current_user.nil? + redirect_to root_path + end + end + # Print Request Bill and add to sale tables + def print + if !ShiftSale.current_shift(@shop.shop_code).nil? + order_id = params[:id] # order_id + order = Order.find(order_id) + booking = order.booking + if booking.checkin_at.utc > Time.now.utc && booking.checkout_at.nil? + @status = false + @error_message = "Operation failed, Could not request bill!" + else + table = DiningFacility.find_by(id: booking.dining_facility_id) + + if sale_data = booking.sale + @status = true + elsif sale_data = Sale.generate_invoice_from_booking(booking, current_login_employee, current_user, order.source, params[:current_checkin_induties_count]) + @status = true + # in-duty update + in_duties = InDuty.where("booking_id=?", booking.id) + if !in_duties.empty? + in_duties.each do |in_duty| + induty = InDuty.find(in_duty.id) + induty.sale_id = sale_data.sale_id + induty.out_time = Time.now.utc + induty.save + end + end + end + + # Bind shift sale id to sale + # @sale_data.shift_sale_id = shift.id + # @sale_data.save + + action_by = current_user.name + type = "REQUEST_BILL" + + remark = "Request bill Receipt No #{sale_data.receipt_no}" + sale_audit = SaleAudit.record_audit_sale(sale_data.sale_id,remark,action_by,type ) + + # Promotion Activation + Promotion.promo_activate(sale_data,@shop.shop_code) + + #bill channel + if ENV["SERVER_MODE"] == 'cloud' + from = request.subdomain + "." + request.domain + else + from = "" + end + + if order.source == "cashier" || order.source == "quick_service" + ActionCable.server.broadcast "bill_channel",table: table, from: from + end + if order.source == "quick_service" || order.source == "food_court" + result = {:status=> @status, :data => sale_data.sale_id } + render :json => result.to_json + else + #check checkInOut pdf print + checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time') + if !booking.dining_facility_id.nil? + terminal = DiningFacility.find_by_id(booking.dining_facility_id) + cashier_terminal = CashierTerminal.find_by_id(terminal.zone_id) + + if (!checkout_time.empty?) && (ENV["SERVER_MODE"] != "cloud") #no print in cloud server + unique_code = "CheckInOutPdf" + printer = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + + # print when complete click + order_queue_printer = Printer::OrderQueuePrinter.new(printer) + + if !printer.nil? + order_queue_printer.print_check_in_out(printer, cashier_terminal, booking, table) + end + end + end + end + end + @status = true + else + @status = false + @error_message = "No Current Open Shift for This Employee" + end + +# Not Use for these printed bill cannot give customer + # unique_code = "ReceiptBillPdf" + # #shop detail + # shop_details = Shop.find(1) + # # customer= Customer.where('customer_id=' +.customer_id) + # customer= Customer.find(@sale_data.customer_id) + # # get member information + # member_info = Customer.get_member_account(customer) + # # get printer info + # print_settings=PrintSetting.find_by_unique_code(unique_code) + + # # find order id by sale id + # # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + + # # Calculate price_by_accounts + # item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) + + # printer = Printer::ReceiptPrinter.new(print_settings) + + + # printer.print_receipt_bill(print_settings, false, nil,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) + end + +end diff --git a/app/controllers/foodcourt/sale_edit_controller.rb b/app/controllers/foodcourt/sale_edit_controller.rb new file mode 100755 index 00000000..9971e50d --- /dev/null +++ b/app/controllers/foodcourt/sale_edit_controller.rb @@ -0,0 +1,232 @@ +class Foodcourt::SaleEditController < BaseFoodcourtController + authorize_resource class: false + # Index for sale item void OR edit + def edit + sale_id = params[:sale_id] + if params[:table_id] + @table_id = params[:table_id] + @table_type = DiningFacility.find(@table_id).type + else + @table_id = nil + @table_type = nil + end + + @cashier_type = params[:type] + @saleobj = Sale.find(sale_id) + end + + # create item void. make duplicate old record and update qty and price + def item_void + saleitemId = params[:sale_item_id] + remark = params[:remark] + access_code = params[:access_code] + order_source = params[:type] + saleitemObj = SaleItem.find(saleitemId) + saleitemObj.status = 'void' + saleitemObj.remark = remark + saleitemObj.save + @newsaleitem = SaleItem.new + @newsaleitem = saleitemObj.dup + # @newsaleitem.save + @newsaleitem.qty = saleitemObj.qty * -1 + @newsaleitem.price = saleitemObj.price * -1 + @newsaleitem.is_taxable = 1 + @newsaleitem.taxable_price = saleitemObj.taxable_price * -1 + @newsaleitem.product_name = saleitemObj.product_name + ' (VOID)' + @newsaleitem.remark = remark + @newsaleitem.save + + # re-calc tax + saleObj = Sale.find(saleitemObj.sale_id) + + + # booking = Booking.find_by_sale_id(saleitemObj.sale_id) + # booking.booking_orders.each do |bo| + # order = Order.find(bo.order_id) + # order.order_items.each do |o| + # if saleitemObj.product_code == o.item_code + # o.qty = saleitemObj.qty * -1 + # o.price = saleitemObj.price * -1 + # o.save + # end + # end + # end + # FOr Sale Audit + action_by = current_user.name + if access_code != "null" && current_user.role == "cashier" + action_by = Employee.find_by_emp_id(access_code).name + end + remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}" + sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMVOID" ) + + saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source) + ProductCommission.create_product_commission(@newsaleitem, saleitemObj) + end + + def item_foc + saleitemId = params[:sale_item_id] + remark = params[:remark] + access_code = params[:access_code] + order_source = params[:type] + saleitemObj = SaleItem.find(saleitemId) + saleitemObj.status = 'foc' + saleitemObj.remark = remark + saleitemObj.save + + @newsaleitem = saleitemObj.dup + @newsaleitem.qty = saleitemObj.qty * -1 + @newsaleitem.unit_price = saleitemObj.unit_price * 1 + @newsaleitem.taxable_price = saleitemObj.taxable_price * -1 + @newsaleitem.price = saleitemObj.price * -1 + @newsaleitem.product_name = saleitemObj.product_name + ' (FOC)' + @newsaleitem.remark = remark + @newsaleitem.save + + # re-calc tax + saleObj = Sale.find(saleitemObj.sale_id) + + order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id + order = Order.find(order_id) + + action_by = current_user.name + if access_code != "null" && current_user.role == "cashier" + action_by = Employee.find_by_emp_id(access_code).name + end + remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}" + sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMFOC" ) + + saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source) + ProductCommission.create_product_commission(@newsaleitem, saleitemObj) + end + + # def item_edit + # saleitemId = params[:sale_item_id] + # update_qty = params[:update_qty] + # update_price = params[:update_price] + # saleitemObj = SaleItem.find(saleitemId) + # saleitemObj.status = 'void' + # saleitemObj.save + # @newsaleitem = SaleItem.new + # @newsaleitem = saleitemObj.dup + # @newsaleitem.save + # @newsaleitem.qty = update_qty + # @newsaleitem.price = update_price + # @newsaleitem.unit_price = update_price + # @newsaleitem.taxable_price = update_price + # @newsaleitem.is_taxable = 0 + # @newsaleitem.remark = 'edit' + # @newsaleitem.product_name = saleitemObj.product_name + " - updated" + # @newsaleitem.save + # end + + def item_edit + saleitemId = params[:sale_item_id] + update_qty = params[:update_qty] + update_price = params[:update_price] + access_code = params[:access_code] + order_source = params[:type] + saleitemObj = SaleItem.find(saleitemId) + original_qty = saleitemObj.qty + original_price = saleitemObj.unit_price + sale = Sale.find(saleitemObj.sale_id) + + saleitemObj.qty = update_qty + saleitemObj.price = update_qty.to_f * update_price.to_f + saleitemObj.unit_price = update_price + saleitemObj.taxable_price = update_qty.to_f * update_price.to_f + + action_by = current_user.name + if access_code != "null" && current_user.role == "cashier" + action_by = Employee.find_by_emp_id(access_code).name + end + remark = "Update From Qty=>#{original_qty} Price=>[#{original_price}] to qty=>#{update_qty} Price =>[#{saleitemObj.price}]| Receipt No #{sale.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}" + sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"SALEITEMEDIT" ) + # saleitemObj.remark = 'edit' + + unless saleitemObj.product_name.include? 'UPDATED' + saleitemObj.product_name = saleitemObj.product_name + ' (UPDATED)' + end + + saleitemObj.save + + # re-calc tax + # saleObj = Sale.find(saleitemObj.sale_id) + + # order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id + # order = Order.find(order_id) + + # order.order_items.each do |o| + # if saleitemObj.product_code == o.item_code + # o.qty = update_qty + # o.price = update_price + # o.save + # end + # end + + sale.compute_by_sale_items(sale.total_discount, nil, order_source) + + ProductCommission.edit_product_commission(saleitemObj,sale.shop_code) + end + + # make cancel void item + def item_void_cancel + saleitemId = params[:sale_item_id] + access_code = params[:access_code] + order_source = params[:type] + + saleitemObj = SaleItem.find(saleitemId) + + saleObj = saleitemObj.sale + + saleObj.sale_items.where(product_code: saleitemObj.product_code) + .where(qty: saleitemObj.qty.abs) + .where(unit_price: saleitemObj.unit_price) + .where(status: saleitemObj.status).first.update(status: nil, remark: nil) + + saleitemObj.destroy + # re-calc tax + + order_id = SaleOrder.find_by_sale_id(saleitemObj.sale_id).order_id + order = Order.find(order_id) + + action_by = current_user.name + if access_code != "null" && current_user.role == "cashier" + action_by = Employee.find_by_emp_id(access_code).name + end + remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}" + sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,current_user.name, action_by,remark,"ITEMCANCELVOID" ) + + saleObj.compute_by_sale_items(saleObj.total_discount, nil, order_source) + ProductCommission.remove_product_commission(saleitemObj) + end + + # remove all void items + def cancel_all_void + sale_id = params[:sale_id] + order_source = params[:type] + saleObj = Sale.find(sale_id) + saleObj.sale_items.each do |item| + if item.qty.to_i < 0 + item.destroy + else + item.status = nil + end + item.save + ProductCommission.remove_product_commission(item) + end + saleObj.sale_items.reset + # re-calc tax + saleObj.compute_by_sale_items(saleObj.total_discount,nil, order_source) + end + + def apply_void + sale_id = params[:sale_id] + order_source = params[:type] + saleObj = Sale.find(sale_id) + saleObj.compute_without_void(order_source) + saleObj.sale_items.each do |item| + ProductCommission.remove_product_commission(item) + end + end + +end diff --git a/app/controllers/foodcourt/sales_controller.rb b/app/controllers/foodcourt/sales_controller.rb new file mode 100755 index 00000000..f51786f9 --- /dev/null +++ b/app/controllers/foodcourt/sales_controller.rb @@ -0,0 +1,78 @@ +class Foodcourt::SalesController < BaseFoodcourtController + def show + @webview = false + if check_mobile + @webview = true + end + + @tables = Table.unscoped.all.active.order('status desc') + @rooms = Room.unscoped.all.active.order('status desc') + @complete = Sale.completed_sale("cashier",@shop.shop_code) + @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @customers = Customer.pluck("customer_id, name") + @sale = Sale.find(params[:sale_id]) + @order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id + @booking = BookingOrder.find_by_order_id(@order).booking_id + if Booking.find(@booking).dining_facility_id.to_i>0 + @table_id = Booking.find(@booking).dining_facility_id + @dining = DiningFacility.find(@table_id) + else + @table_id = nil + @dining = nil + end + end + + def add_to_existing_invoice + dining = params[:dining_id] + sale_id = params[:sale_id] + tax_type = params[:tax_type] + sale_data = [] + table = DiningFacility.find(dining) + existing_booking = Booking.find_by_sale_id(sale_id) + table.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ").each do |booking| + if booking.sale_id.nil? + order_array = [] + booking.booking_orders.each do |booking_order| + + booking.booking_status = 'moved' + order = Order.find(booking_order.order_id) + order.status = 'billed' + order.order_items.each do |item| + item.order_item_status = 'billed' + end + # create sale item + saleobj = Sale.find(sale_id) + order.order_items.each do |orer_item| + saleobj.add_item (orer_item) + if !orer_item.set_menu_items.nil? + saleobj.add_sub_item(orer_item.set_menu_items) + end + sale_data.push(orer_item) + end + + # Re-compute for add + saleobj.compute(order.source,tax_type) + saleobj.save + order.save + booking.save + + order_array.push(order.order_id) + end + + receipt_no = Sale.find(sale_id).receipt_no + action_by = current_user.name + type = "ADD_TO_EXISTING" + + remark = "#{action_by} add to existing order #{order_array} to Receipt No=>#{receipt_no} in #{table.name}" + sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type ) + + booking_order = BookingOrder.where('booking_id=?',booking) + booking_order.each do |bo| + bo.booking_id = existing_booking.booking_id + bo.save + end + end + end + end + +end diff --git a/app/controllers/foodcourt/second_display_controller.rb b/app/controllers/foodcourt/second_display_controller.rb new file mode 100644 index 00000000..e180ed1d --- /dev/null +++ b/app/controllers/foodcourt/second_display_controller.rb @@ -0,0 +1,34 @@ +class Foodcourt::SecondDisplayController < BaseFoodcourtController + + def index + @display_images = DisplayImage.all + end + + def show + end + + def customer_view + display_type = Lookup.find_by_lookup_type("display_type") + if !display_type.nil? && display_type.value.to_i == 2 + if params[:status]!= "billed" + tax_profiles = TaxProfile.all.order("order_by asc") + else + tax_profiles = nil + end + 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 + end + #Shop Name in Navbor + # helper_method :shop_detail + # def shop_detail + # @shop = Shop.first + # end + + +end diff --git a/app/controllers/foodcourt/shifts_controller.rb b/app/controllers/foodcourt/shifts_controller.rb new file mode 100755 index 00000000..d0048dbf --- /dev/null +++ b/app/controllers/foodcourt/shifts_controller.rb @@ -0,0 +1,158 @@ +class Foodcourt::ShiftsController < BaseFoodcourtController + def index + end + + def show + @cashier_type = params[:type] + @shift = ShiftSale.current_open_shift(current_user) + #for bank integration + bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration') + @bank_integration = 0 + if !bank_integration[0].nil? + @bank_integration = bank_integration[0][1] + end + + end + + def new + @float = Lookup.where('lookup_type=?','float_value') + @terminal = CashierTerminal.available.where("shop_code='#{@shop.shop_code}'") + end + + def create + opening_balance = params[:opening_balance] + cashier_terminal_param = params[:cashier_terminal] + + # Multiple Cashier + cashier_terminal = CashierTerminal.find(cashier_terminal_param) + if cashier_terminal.is_currently_login + respond_to do |format| + format.html { redirect_to settings_order_queue_stations_url, notice: 'Cashier Terminal already signin!' } + end + end + + # Update Cashier Terminal + cashier_terminal.is_currently_login = 1 + cashier_terminal.save + + @shift_sale = ShiftSale.new + @shift_sale.create(opening_balance,cashier_terminal_param, current_user) + end + + + + def update_shift + closing_balance = params[:closing_balance] + shift_id = params[:shift_id] + @shift = ShiftSale.find_by_id(shift_id) + if @shift + @shift.shift_closed_at = DateTime.now.utc + @shift.closing_balance = closing_balance.to_f + @shift.save + + # Multiple Cashier + cashier_terminal = @shift.cashier_terminal + cashier_terminal.is_currently_login = 0 + cashier_terminal.save + + #add shift_sale_id to card_settle_trans + bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code) + if !bank_integration.nil? + card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL']) + + card_settle_trans.each do |data| + card_sett_trans = CardSettleTran.find(data.id) + card_sett_trans.shift_sale_id = @shift.id + card_sett_trans.save() + end + end + + if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + + + + # if !close_cashier_print[0].nil? + # @close_cashier_print = close_cashier_print[0][1] + # end + close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") + unique_code = "CloseCashierPdf" + + if !close_cashier_pdf.empty? + close_cashier_pdf.each do |close_cashier| + if close_cashier[0] == 'CloseCashierCustomisePdf' + if close_cashier[1] == '1' + unique_code="CloseCashierCustomisePdf" + else + unique_code="CloseCashierPdf" + end + end + end + end + shop_details = shop_detail + #get tax + shift_obj = ShiftSale.where('id =?',@shift.id) + sale_items = '' + @lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code) + if @lookup.to_i == 1 + @sale_items = Sale.get_shift_sale_items(@shift.id) + other_charges = Sale.get_other_charges() + @total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift) + end + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'") + @total_waste = Sale.get_total_waste(shift_id).sum(:grand_total) + @total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total) + #other payment details for mpu or visa like card + @other_payment = ShiftSale.get_by_shift_other_payment(@shift) + + # Calculate price_by_accounts + @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount') + @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount') + @total_member_discount = ShiftSale.get_total_member_discount(@shift) + @total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount + @total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount + @total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount + @total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments + + # get printer info + print_settings = PrintSetting.find_by_unique_code(unique_code) + printer = Printer::CashierStationPrinter.new(print_settings) + + # print close cashier setting + close_cashier_print = Lookup.collection_of('close_cashier_print') + if close_cashier_print.empty? + @settings_lookup = Lookup.new(lookup_type: "close_cashier_print", name: "CloseCashierPrint", value: "1") + @settings_lookup.save + end + find_close_cashier_print = Lookup.collection_of('close_cashier_print') + if find_close_cashier_print[0][1].to_i > 0 + printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + end + end + end + Employee.logout(@shop,session[:session_token]) + session[:session_token] = nil + end + + def edit + end + + def sale_summary + @shift = ShiftSale.current_open_shift(current_user) + + # @shift = ShiftSale.find_by_id(shift_id) + if @shift + #get tax + shift_obj = ShiftSale.where('id =?',@shift.id) + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'") + #other payment details for mpu or visa like card + @other_payment = ShiftSale.get_by_shift_other_payment(@shift) + + # Calculate price_by_accounts + @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount') + @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount') + @total_member_discount = ShiftSale.get_total_member_discount(@shift) + end + + end + +end diff --git a/app/controllers/foodcourt/surveys_controller.rb b/app/controllers/foodcourt/surveys_controller.rb new file mode 100644 index 00000000..363bc6ba --- /dev/null +++ b/app/controllers/foodcourt/surveys_controller.rb @@ -0,0 +1,112 @@ +class Foodcourt::SurveysController < BaseFoodcourtController + def new + @webview = false + if check_mobile + @webview = true + end + + @survey = Survey.new + @id = params[:id] + @cashier_type = params[:type] + + if(@id[0,3] == "SAL") + @sale = Sale.find(@id) + @receipt_no = @sale.receipt_no + @grand_total = @sale.grand_total + @booking = Booking.find_by_sale_id(@id) + + if @booking.dining_facility_id.to_i>0 + @dining_facility = DiningFacility.find(@booking.dining_facility_id) + @table_type = @dining_facility.type + @survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code) + survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code) + if !survey_process.nil? + @survey_data = survey_process + end + else + @dining_facility = nil + @table_type = nil + end + + else + @dining_facility = DiningFacility.find(@id) + @table_type = @dining_facility.type + @receipt_no = nil + @grand_total = nil + @survey_data = Survey.find_by_dining_name_and_receipt_no_and_shop_code(@dining_facility.name,nil,@shop.shop_code) + end + end + + def create + @type = params[:cashier_type] + @sale_id = params[:sale_id] + if params[:table_id].to_i>0 + @dining_facility = DiningFacility.find(params[:table_id]) + if params[:sale_id].to_i > 0 + # cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id) + # shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil) + # set cashier + open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'") + current_shift = ShiftSale.current_shift(@shop.shop_code) + current_shift_user =Employee.find_by_id(current_user.employee_id) + if open_cashier.count>0 + shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0]) + else + shift_by_terminal = ShiftSale.current_open_shift(current_shift_user) + end + else + sale = Sale.find(@sale_id) + shift = ShiftSale.find(sale.shift_sale_id) + shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil) + end + else + sale = Sale.find(@sale_id) + shift = ShiftSale.find(sale.shift_sale_id) + shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil) + end + + if @type == "quick_service" || @type == "food_court" + @url = "/foodcourt/sale/"+@sale_id+"/"+@type+"/payment" + else + @url = "/foodcourt/"+@dining_facility.type.downcase+"/"+params[:table_id] + end + + + if params[:survey_id].nil? || params[:survey_id] == "" + @survey = Survey.new(survey_params) + @survey.shift_id = shift_by_terminal.id + @survey.foreigner = params["survey"]["foreigner"].to_json + @survey.shop_code = @shop.shop_code + # respond_to do |format| + if @survey.save + redirect_to @url + end + # end + else + survey = Survey.find_by_id(params[:survey_id]) + survey.child = params["survey"]["child"] + survey.adult = params["survey"]["adult"] + survey.male = params["survey"]["male"] + survey.female = params["survey"]["female"] + survey.local = params["survey"]["local"] + survey.dining_name = params["survey"]["dining_name"] + survey.receipt_no = params["survey"]["receipt_no"] + survey.shift_id = shift_by_terminal.id + survey.created_by = params["survey"]["created_by"] + survey.total_customer = params["survey"]["total_customer"] + survey.total_amount = params["survey"]["total_amount"] + survey.foreigner = params["survey"]["foreigner"].to_json + if survey.save! + redirect_to @url + end + end + end + + private + + # Never trust parameters from the scary internet, only allow the white list through. + def survey_params + params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount,:survey_id) + end + +end diff --git a/app/controllers/foodcourt/void_controller.rb b/app/controllers/foodcourt/void_controller.rb new file mode 100755 index 00000000..92aba110 --- /dev/null +++ b/app/controllers/foodcourt/void_controller.rb @@ -0,0 +1,171 @@ +class Foodcourt::VoidController < BaseFoodcourtController + authorize_resource :class => false + def overall_void + + sale_id = params[:sale_id] + remark = params[:remark] + order_source = params[:type] #tax profile source + access_code = params[:access_code] + if Sale.exists?(sale_id) + sale = Sale.find_by_sale_id(sale_id) + if sale.discount_type == "member_discount" + sale.update_attributes(total_discount: 0) + sale.compute_by_sale_items(0, nil, order_source) + end + + # update count for shift sale + if(sale.sale_status == "completed") + if sale.shift_sale_id != nil + shift = ShiftSale.find(sale.shift_sale_id) + shift.calculate(sale_id, "void") + end + else + # void before sale payment complete + if sale.shift_sale_id != nil + shift = ShiftSale.find(sale.shift_sale_id) + shift.total_void = shift.total_void + sale.grand_total + shift.save + end + end + + sale.rounding_adjustment = 0.0 + sale.payment_status = 'void' + sale.sale_status = 'void' + sale.save + + # No Need + # bookings = sale.bookings + # bookings.each do |booking| + # orders = booking.orders + # orders.each do |order| + # # order.status = 'void' + # end + # end + + if sale.bookings[0].dining_facility_id.to_i > 0 + table_avaliable = true + table_count = 0 + table = sale.bookings[0].dining_facility + table.bookings.each do |booking| + if booking.booking_status != 'moved' + if booking.sale_id + if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste' + table_avaliable = false + table_count += 1 + else + table_avaliable = true + end + else + table_avaliable = false + table_count += 1 + end + end + end + + if table_avaliable && table_count == 0 + table.status = 'available' + table.save + end + else + table = nil + end + + # FOr Sale Audit + action_by = current_user.name + if access_code != "null" && current_user.role == "cashier" + action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name + end + + # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" + sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,"SALEVOID" ) + + # For Print + + member_info = nil + rebate_amount = nil + current_balance = nil + + # For Cashier by Zone + bookings = Booking.where("sale_id='#{sale_id}'") + if bookings.count > 1 + # for Multiple Booking + if bookings[0].dining_facility_id.to_i>0 + table = DiningFacility.find(bookings[0].dining_facility_id) + end + end + + if bookings[0].dining_facility_id.to_i > 0 + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) + else + shift = ShiftSale.find(sale.shift_sale_id) + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + end + + + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + # get printer info + # print_settings = PrintSetting.find_by_unique_code('ReceiptBillPdf') # SaleItemsPdf + # + # if !print_settings.nil? + # unique_code = 'ReceiptBillPdf' + # elsif + # unique_code = 'ReceiptBillStarPdf' + # end + + customer= Customer.find(sale.customer_id) + + # get member information + rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + if customer.membership_id != nil && rebate + member_info = Customer.get_member_account(customer) + rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) + # current_balance = SaleAudit.paymal_search(sale_id) + current_balance = 0 + end + + printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") + + unique_code="ReceiptBillPdf" + if !printer.empty? + printer.each do |printer_setting| + if printer_setting.unique_code == 'ReceiptBillPdf' + unique_code="ReceiptBillPdf" + elsif printer_setting.unique_code == 'ReceiptBillA5Pdf' + unique_code="ReceiptBillA5Pdf" + elsif printer_setting.unique_code == 'ReceiptBillStarPdf' + unique_code="ReceiptBillStarPdf" + end + end + end + # get printer info + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + # Calculate Food and Beverage Total + item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) + other_amount = SaleItem.calculate_other_charges(sale.sale_items) + printer = Printer::ReceiptPrinter.new(print_settings) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + + # Mobile Print + render :json => result.to_json + # end + + #end print + + # update complete order items in oqs + SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr| + AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi| + aoi.delivery_status = 1 + aoi.save + end + end + end + end + +end diff --git a/app/controllers/foodcourt/waste_spoile_controller.rb b/app/controllers/foodcourt/waste_spoile_controller.rb new file mode 100755 index 00000000..d7847b27 --- /dev/null +++ b/app/controllers/foodcourt/waste_spoile_controller.rb @@ -0,0 +1,145 @@ +class Foodcourt::WasteSpoileController < BaseFoodcourtController + def waste_and_spoilage + + sale_id = params[:sale_id] + remark = params[:remark] + order_source = params[:type] + access_code = params[:access_code] #tax profile source + if Sale.exists?(sale_id) + sale = Sale.find_by_sale_id(sale_id) + SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax| + existing_tax.delete + end + sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0) + sale.payment_status = remark + sale.sale_status = remark + sale.save + + # add to sale item with foc + # sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null") + + sale.sale_items.each do|item| + # SaleItem.update_existing_item(item.qty, item, sale_id, remark, item.unit_price, item.price) + item.status = remark + item.remark = remark + item.save + end + + if sale.bookings[0].dining_facility_id.to_i > 0 + table_avaliable = true + table_count = 0 + table = sale.bookings[0].dining_facility + table.bookings.each do |booking| + if booking.booking_status != 'moved' + if booking.sale_id + if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void' && booking.sale.sale_status != 'spoile' && booking.sale.sale_status != 'waste' + table_avaliable = false + table_count += 1 + else + table_avaliable = true + end + else + table_avaliable = false + table_count += 1 + end + end + end + if table_avaliable && table_count == 0 + table.status = 'available' + table.save + end + else + table = nil + end + + # FOr Sale Audit + action_by = current_user.name + if access_code != "null" && current_user.role == "cashier" + action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name + end + # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" + sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark ) + + # For Print + + member_info = nil + rebate_amount = nil + current_balance = nil + + # For Cashier by Zone + bookings = Booking.where("sale_id='#{sale_id}'") + if bookings.count > 1 + # for Multiple Booking + if bookings[0].dining_facility_id.to_i>0 + table = DiningFacility.find(bookings[0].dining_facility_id) + end + end + + if bookings[0].dining_facility_id.to_i > 0 + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) + else + shift = ShiftSale.find(sale.shift_sale_id) + cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) + end + + + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + # unique_code = "ReceiptBillPdf" + customer= Customer.find(sale.customer_id) + + # get member information + rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + if customer.membership_id != nil && rebate + member_info = Customer.get_member_account(customer) + rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) + # current_balance = SaleAudit.paymal_search(sale_id) + current_balance = 0 + end + + printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") + + unique_code="ReceiptBillPdf" + if !printer.empty? + printer.each do |printer_setting| + if printer_setting.unique_code == 'ReceiptBillPdf' + unique_code="ReceiptBillPdf" + elsif printer_setting.unique_code == 'ReceiptBillA5Pdf' + unique_code="ReceiptBillA5Pdf" + elsif printer_setting.unique_code == 'ReceiptBillStarPdf' + unique_code="ReceiptBillStarPdf" + end + end + end + + # get printer info + print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + # Calculate Food and Beverage Total + item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) + other_amount = SaleItem.calculate_other_charges(sale.sale_items) + printer = Printer::ReceiptPrinter.new(print_settings) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil) + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + + # Mobile Print + render :json => result.to_json + # end + + #end print + + # update complete order items in oqs + SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr| + AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi| + aoi.delivery_status = 1 + aoi.save + end + end + end + end + +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 32d47ce3..af100ec5 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -78,6 +78,9 @@ class HomeController < ApplicationController elsif @employee.role == "kitchen" session[:session_token] = @employee.token_session redirect_to oqs_root_path + elsif @employee.role == "foodcourt_cashier" + session[:session_token] = @employee.token_session + route_by_role(@employee) else render :index end @@ -221,6 +224,14 @@ class HomeController < ApplicationController redirect_to origami_dashboard_path elsif employee.role == "account" redirect_to reports_dailysale_index_path + elsif employee.role == "foodcourt_cashier" + #check if cashier has existing open cashier + shift = ShiftSale.current_open_shift(employee) + if !shift.nil? + redirect_to foodcourt_food_court_path + else + redirect_to new_foodcourt_shift_path + end end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index fac5937a..0b0613d7 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -113,7 +113,7 @@ class Origami::PaymentsController < BaseOrigamiController end end - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt",current_balance,nil,other_amount,nil,nil,nil,nil) result = { :filepath => filename, @@ -278,7 +278,7 @@ class Origami::PaymentsController < BaseOrigamiController end #card_balance amount for Paymal payment - card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id) + card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) # get printer info print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) @@ -288,7 +288,7 @@ class Origami::PaymentsController < BaseOrigamiController other_amount = SaleItem.calculate_other_charges(sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) #end end @@ -600,7 +600,7 @@ class Origami::PaymentsController < BaseOrigamiController end #card_balance amount for Paymal payment - card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id) + card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) @@ -612,7 +612,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) result = { :status => true, @@ -711,7 +711,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "FOC",nil,nil,other_amount,nil,nil,nil,nil) result = { :status => true, :filepath => filename, diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 5f5b5352..38ae404d 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -145,7 +145,7 @@ class Origami::VoidController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 82c63d80..ff86bbd2 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -119,7 +119,7 @@ class Origami::WasteSpoileController < BaseOrigamiController discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) other_amount = SaleItem.calculate_other_charges(sale.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, remark,current_balance,nil,other_amount,nil,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index d8a6416f..81704ace 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -206,7 +206,7 @@ authorize_resource :class => false end #card_balance amount for Paymal payment - card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id) + card_balance_amount,transaction_ref = SaleAudit.getCardBalanceAmount(sale_id) # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) @@ -218,7 +218,7 @@ authorize_resource :class => false printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil,transaction_ref) result = { :status => true, diff --git a/app/controllers/settings/cashier_terminals_controller.rb b/app/controllers/settings/cashier_terminals_controller.rb index 29fe202f..bb57eb64 100755 --- a/app/controllers/settings/cashier_terminals_controller.rb +++ b/app/controllers/settings/cashier_terminals_controller.rb @@ -5,7 +5,7 @@ class Settings::CashierTerminalsController < ApplicationController # GET /settings/cashier_terminals # GET /settings/cashier_terminals.json def index - @settings_cashier_terminals = CashierTerminal.all + @settings_cashier_terminals = CashierTerminal.where("shop_code=?",@shop.shop_code) end # GET /settings/cashier_terminals/1 diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index a76c87ce..bed00c2e 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -364,7 +364,7 @@ class Transactions::SalesController < ApplicationController other_amount = SaleItem.calculate_other_charges(sale.sale_items) #other charges printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/models/ability.rb b/app/models/ability.rb index ddea0ae1..64f783bd 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -29,7 +29,7 @@ class Ability can :manage, Order can :manage, Booking can :manage, Sale - + can :manage, Customer can :manage, DiningQueue @@ -57,8 +57,8 @@ class Ability can :show, :product_sale can :get_customer, Customer - can :add_customer, Customer - can :update_sale_by_customer, Customer + can :add_customer, Customer + can :update_sale_by_customer, Customer can :index, :other_charge can :create, :other_charge @@ -73,11 +73,11 @@ class Ability can :create, :payment can :reprint, :payment can :rounding_adj, :payment - can :foc, :payment - can :print, :payment + can :foc, :payment + can :print, :payment can :change_tax, :payment - can :move_dining, :movetable + can :move_dining, :movetable can :moving, :movetable can :move_dining, :moveroom @@ -123,11 +123,11 @@ class Ability can :print, :print can :print_order_summary, :print - can :read, ShiftSale - can :update, ShiftSale + can :read, ShiftSale + can :update, ShiftSale + + elsif user.role == "cashier" || user.role =="foodcourt_cashier" - elsif user.role == "cashier" - # can :overall_void, :void can :index, :home can :show, :home @@ -136,10 +136,10 @@ class Ability can :update, Order can :manage, Booking can :manage, OrderQueueStation - can :read, Sale - can :update, Sale + can :read, Sale + can :update, Sale - can :manage, Customer + can :manage, Customer can :manage, OrderReservation @@ -160,11 +160,11 @@ class Ability can :create, :payment can :reprint, :payment can :rounding_adj, :payment - can :foc, :payment + can :foc, :payment can :print, :payment can :change_tax, :payment - can :move_dining, :movetable + can :move_dining, :movetable can :moving, :movetable can :move_dining, :moveroom @@ -204,7 +204,7 @@ class Ability can :item_edit, :sale_edit can :overall_void, :void - + elsif user.role == "account" can :index, :dailysale @@ -228,14 +228,14 @@ class Ability elsif user.role == "supervisor" can :manage, Employee - + can :edit, :sale_edit can :item_void, :sale_edit can :item_foc, :sale_edit can :item_edit, :sale_edit can :item_void_cancel, :sale_edit - can :cancel_all_void, :sale_edit - can :apply_void, :sale_edit + can :cancel_all_void, :sale_edit + can :apply_void, :sale_edit can :overall_void, :void can :index, :other_charge @@ -246,7 +246,7 @@ class Ability can :remove_all_discount, :discount can :member_discount, :discount - can :move_dining, :movetable + can :move_dining, :movetable can :moving, :movetable can :move_dining, :moveroom @@ -297,9 +297,9 @@ class Ability elsif user.role == "waiter" can :index, :home - can :show, :home + can :show, :home - can :manage, Customer + can :manage, Customer can :get_customer, Customer can :add_customer, Customer can :update_sale_by_customer, Customer @@ -313,7 +313,7 @@ class Ability can :member_discount, :discount #ability for move table - can :move_dining, :movetable + can :move_dining, :movetable can :moving, :movetable can :move_dining, :moveroom @@ -339,7 +339,7 @@ class Ability can :print_order_summary, :print elsif user.role == "kitchen" - + #oqs Home can :manage, OrderQueueStation can :index, :home diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 457566db..4903c692 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -203,7 +203,7 @@ class OrderReservation < ApplicationRecord other_amount = SaleItem.calculate_other_charges(saleObj.sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_details, "Paid",nil,nil,other_amount,nil,nil, order_reservation) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,saleObj.sale_items,saleObj,saleObj.customer.name, item_price_by_accounts, discount_price_by_accounts, nil,nil,shop_details, "Paid",nil,nil,other_amount,nil,nil, order_reservation,nil) #receipt bill pdf setting result = {:status=> true, diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index a935c3b0..9b51e4f3 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -188,20 +188,20 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation) + def print_receipt_bill(printer_settings, kbz_pay_status, qr_code, cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,order_reservation,transaction_ref) #Use CUPS service #Generate PDF #Print if !printer_settings.nil? if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder") - pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) + pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref) settings = PrintSetting.where("shop_code='#{shop_details.shop_code}'") if !settings.nil? settings.each do |setting| if setting.unique_code == 'ReceiptBillPdf' - pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) + pdf = ReceiptBillPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref) elsif setting.unique_code == 'ReceiptBillStarPdf' - pdf = ReceiptBillStarPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) + pdf = ReceiptBillStarPdf.new(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref) end end end @@ -211,7 +211,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker receipt_bill_a5_pdf.each do |receipt_bilA5| if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[1] == '1' - pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) + pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount,transaction_ref) # else # pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount) end diff --git a/app/models/sale.rb b/app/models/sale.rb index 9e0ab2de..535e32ce 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -2088,7 +2088,6 @@ end def unique_tax_profiles(order_source, customer_id) tax_data = TaxProfile.where(group_type: order_source,shop_code: self.shop_code) - customer_tax_profiles = Customer.select(:tax_profiles).where(customer_id: customer_id).first if customer_tax_profiles.present? tax_data = tax_data.where(id: customer_tax_profiles.tax_profiles) diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index 1488cad1..7b5c52e5 100755 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -150,6 +150,7 @@ class SaleAudit < ApplicationRecord def self.getCardBalanceAmount(sale_id) card_balance_amount = 0 + transaction_ref ='' sale_audits = SaleAudit.where("sale_id='#{sale_id}' AND action='PAYMAL'") if !sale_audits.nil? sale_audits.each do |sale_audit| @@ -159,6 +160,7 @@ class SaleAudit < ApplicationRecord if remark[0] if remark[0]["status"] card_balance_amount = remark[0]["card_balance_amount"] + transaction_ref = remark[0]["transaction_ref"] end end end @@ -166,7 +168,7 @@ class SaleAudit < ApplicationRecord end end - return card_balance_amount + return card_balance_amount,transaction_ref end def self.valid_json(json) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index d01b2069..9041484f 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -227,14 +227,14 @@ class SalePayment < ApplicationRecord 'Accept' => 'application/json; version=3' }, :timeout => 10 ) + rescue Errno::ECONNREFUSED + response = { "status" => false, "message" => "Can't open membership server"} rescue Net::OpenTimeout - response = { status: false } - + response = { "status" => false, "message" => "No internet connection " } rescue OpenURI::HTTPError - response = { status: false} - + response = { "status" => false, "message" => "No internet connection "} rescue SocketError - response = { status: false} + response = { "status" => false, "message" => "No internet connection "} end Rails.logger.debug "Get Paypar Account " Rails.logger.debug response.to_json diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index 3125ca8d..2bf44dcc 100755 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -16,7 +16,6 @@ class ShiftSale < ApplicationRecord belongs_to :cashier_terminal belongs_to :employee, :foreign_key => 'employee_id' has_many :sales - belongs_to :shop def self.current_shift(shop_code) # today_date = DateTime.now.strftime("%Y-%m-%d") @@ -84,6 +83,7 @@ class ShiftSale < ApplicationRecord self.shift_started_at = DateTime.now self.employee_id = current_user.id self.opening_balance = opening_balance + self.shop_code = current_user.shop_code self.other_sales = 0 self.save end diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 02443c0c..8a844c40 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -2,7 +2,7 @@ class ReceiptBillA5Pdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move - def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) + def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount,transaction_ref) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -73,11 +73,12 @@ class ReceiptBillA5Pdf < Prawn::Document end #end card sale trans data #start card blanace amount - if !card_balance_amount.nil? + if !card_balance_amount.nil? && card_balance_amount >0 card_balance_data(card_balance_amount) + card_transaction_ref(transaction_ref) end #end card blanace amount - + if discount_price_by_accounts.length > 0 && shop_details.show_account_info discount_account(discount_price_by_accounts,printer_settings.precision,delimiter) end @@ -100,7 +101,7 @@ class ReceiptBillA5Pdf < Prawn::Document if shop_details.note && !shop_details.note.nil? shop_note(printed_status) end - + footer(printed_status) end @@ -130,7 +131,7 @@ class ReceiptBillA5Pdf < Prawn::Document text "OrderNo : #{ latest_order_no }", :size => self.header_font_size+2,:align => :left end move_down line_move - + # move_down 2 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do @@ -154,7 +155,7 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([self.item_description_width, y_position], :width =>self.item_description_width, :height => self.item_height) do text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left - end + end bounding_box([self.item_description_width - 2,y_position], :width =>self.item_description_width, :height => self.item_height) do text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right end @@ -172,7 +173,7 @@ class ReceiptBillA5Pdf < Prawn::Document # bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do - # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } + # text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') } # - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" , # :size => self.item_font_size,:align => :right # end @@ -209,7 +210,7 @@ class ReceiptBillA5Pdf < Prawn::Document end def add_line_item_row(sale_items,precision,delimiter) - + if precision.to_i > 0 item_name_width = (self.item_width+self.price_width) item_qty_front_width = (self.item_width+self.price_width) + 5 @@ -229,17 +230,17 @@ class ReceiptBillA5Pdf < Prawn::Document sub_total = 0.0 total_qty = 0.0 sale_items.each do |item| - # check for item not to show + # check for item not to show show_price = Lookup.find_by_lookup_type("show_price") sub_total += item.price #(item.qty*item.unit_price) - comment for room charges if item.status != 'Discount' && item.qty > 0 if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0 - total_qty += item.qty + total_qty += item.qty else if item.price != 0 - total_qty += item.qty + total_qty += item.qty end end end @@ -272,7 +273,7 @@ class ReceiptBillA5Pdf < Prawn::Document # end text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - + end def item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -297,10 +298,10 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width) do text "#{product_name}", :size => self.item_font_size,:align => :left end - # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size - text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size + text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix if show_alt_name if !(item.product_alt_name).empty? @@ -370,7 +371,7 @@ class ReceiptBillA5Pdf < Prawn::Document end bounding_box([self.description_width,y_position], :width =>self.label_width) do text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right - end + end end move_down line_move @@ -383,12 +384,12 @@ class ReceiptBillA5Pdf < Prawn::Document text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right end move_down line_move - + sale_payment(sale_data,precision,delimiter) - + end - def sale_payment(sale_data,precision,delimiter) + def sale_payment(sale_data,precision,delimiter) stroke_horizontal_rule # move_down 10 sql = "SELECT SUM(payment_amount) @@ -419,13 +420,13 @@ class ReceiptBillA5Pdf < Prawn::Document text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left end end - + bounding_box([self.description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end move_down line_move end - if sale_data.amount_received > 0 + if sale_data.amount_received > 0 y_position = cursor move_down line_move bounding_box([0,y_position], :width =>self.description_width, :height => self.item_height) do @@ -435,12 +436,12 @@ class ReceiptBillA5Pdf < Prawn::Document text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end #move_down line_move - end + end end # show member information def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance) - if rebate_amount != nil + if rebate_amount != nil if rebate_amount["status"] == true stroke_horizontal_rule total = 0 @@ -469,8 +470,8 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([self.description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - - end + + end # Total Rebate Amount if birthday if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate" rebate_balance = rebate_balance + res["deposit"] @@ -482,7 +483,7 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([self.description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - end + end #end Total rebate if birthday end @@ -505,7 +506,7 @@ class ReceiptBillA5Pdf < Prawn::Document text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end - + end end @@ -515,7 +516,7 @@ class ReceiptBillA5Pdf < Prawn::Document if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" total_balance = total_balance + res["balance"] - + end end move_down line_move @@ -527,7 +528,7 @@ class ReceiptBillA5Pdf < Prawn::Document text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end - + end def customer(customer_name) @@ -555,7 +556,7 @@ class ReceiptBillA5Pdf < Prawn::Document end bounding_box([self.description_width,y_position], :width =>self.label_width) do text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right - end + end move_down line_move end end @@ -571,7 +572,7 @@ class ReceiptBillA5Pdf < Prawn::Document end bounding_box([self.label_width,y_position], :width =>self.description_width) do text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right - end + end move_down line_move end end @@ -584,7 +585,7 @@ class ReceiptBillA5Pdf < Prawn::Document bounding_box([self.label_width,y_position], :width =>self.item_description_width) do text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end - move_down line_move + move_down line_move end #individual payment per person @@ -623,17 +624,17 @@ class ReceiptBillA5Pdf < Prawn::Document JOIN sale_audits sa ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id where sa.sale_id='#{sale_data.sale_id}')) = 0 - THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment| + THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment| if payment.payment_method == "creditnote" y_position = cursor stroke_horizontal_rule - + bounding_box([self.label_width,y_position], :width =>self.description_width) do move_down 70 stroke_horizontal_rule end - + bounding_box([self.label_width,y_position], :width =>self.description_width) do move_down 73 text "Approved By" , :size => self.item_font_size,:align => :center @@ -650,8 +651,8 @@ class ReceiptBillA5Pdf < Prawn::Document move_down 70 stroke_horizontal_rule end - - if sale_data.payment_status == "foc" + + if sale_data.payment_status == "foc" bounding_box([self.label_width,y_position], :width =>self.description_width) do move_down 73 text "Acknowledged By" , :size => self.item_font_size,:align => :center @@ -661,10 +662,10 @@ class ReceiptBillA5Pdf < Prawn::Document move_down 73 text "Approved By" , :size => self.item_font_size,:align => :center end - end - - end - + end + + end + end def shop_note(shop) @@ -674,8 +675,8 @@ class ReceiptBillA5Pdf < Prawn::Document move_down line_move y_position = cursor - - text "#{shop.note}", :size => self.item_font_size,:align => :left + + text "#{shop.note}", :size => self.item_font_size,:align => :left move_down line_move end @@ -688,10 +689,10 @@ class ReceiptBillA5Pdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.item_description_width) do text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :right - end + end move_down line_move end @@ -721,7 +722,6 @@ class ReceiptBillA5Pdf < Prawn::Document #start card balance data def card_balance_data(card_balance_amount) - if card_balance_amount > 0 move_down line_move stroke_horizontal_rule move_down line_move @@ -729,11 +729,24 @@ class ReceiptBillA5Pdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width) do text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right end - end + end + #start card transaction_ref + def card_transaction_ref(transaction_ref) + move_down line_move + stroke_horizontal_rule + move_down line_move + + y_position = cursor + bounding_box([0, y_position], :width =>self.label_width) do + text "Transaction ref: ",:style => :bold, :size => header_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{transaction_ref}" , :size => self.item_font_size,:align => :right + end end #check ReceiptBillAltName included @@ -753,4 +766,4 @@ class ReceiptBillA5Pdf < Prawn::Document end return status end -end \ No newline at end of file +end diff --git a/app/pdf/receipt_bill_order_pdf.rb b/app/pdf/receipt_bill_order_pdf.rb index e66cb37e..c08aff35 100644 --- a/app/pdf/receipt_bill_order_pdf.rb +++ b/app/pdf/receipt_bill_order_pdf.rb @@ -78,13 +78,13 @@ class ReceiptBillOrderPdf < Prawn::Document def cashier_info(sale_data, customer_name, latest_order_no,order_reservation) move_down line_move - + # move_down 2 - + y_position = cursor bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do text "Order Date " , :size => self.item_font_size, :align => :left - end + end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do text "#{order_reservation.created_at.strftime('%d-%m-%Y %H:%M %p')}", :size => self.item_font_size,:align => :right end @@ -92,7 +92,7 @@ class ReceiptBillOrderPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do text "Requested Date Time " , :size => self.item_font_size, :align => :left - end + end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do text "#{order_reservation.requested_time.strftime('%d-%m-%Y %H:%M %p')}", :size => self.item_font_size,:align => :right end @@ -100,7 +100,7 @@ class ReceiptBillOrderPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do text "Payment Type" , :size => self.item_font_size, :align => :left - end + end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do text "#{order_reservation.payment_type}", :size => self.item_font_size,:align => :right end @@ -108,7 +108,7 @@ class ReceiptBillOrderPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width , :height => self.item_height) do text "#{customer_name} " , :size => self.item_font_size, :align => :left - end + end bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do text "Online Order", :size => self.item_font_size,:align => :right end @@ -167,14 +167,14 @@ class ReceiptBillOrderPdf < Prawn::Document total_qty = 0.0 show_price = Lookup.find_by_lookup_type("show_price") sale_items.each do |item| - # check for item not to show + # check for item not to show if item.status != 'Discount' && item.qty > 0 if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0 - total_qty += item.qty + total_qty += item.qty else if item.price != 0 - total_qty += item.qty + total_qty += item.qty end end end @@ -191,7 +191,7 @@ class ReceiptBillOrderPdf < Prawn::Document qty = item.qty total_price = item.price #item.qty*item.unit_price - comment for room charges price = item.unit_price - + # end if !show_price.nil? && show_price.value.to_i>0 item_row(item,precision,delimiter,product_name,price,qty ,total_price) @@ -220,24 +220,24 @@ class ReceiptBillOrderPdf < Prawn::Document bounding_box([self.description_width - 48,y_position], :width =>self.label_width, :height => self.item_height) do text "#{number_with_precision(order_reservation.delivery_fee, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end + end end if order_reservation.total_tax > 0 y_position = cursor bounding_box([0, y_position], :width =>self.item_description_width , :height => self.item_height) do text "Tax " , :size => self.item_font_size, :align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do text "#{number_with_precision(order_reservation.total_tax, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end - end + end + end y_position = cursor bounding_box([0, y_position], :width =>self.item_description_width , :height => self.item_height) do text "Convenience Charges " , :size => self.item_font_size, :align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do text "#{number_with_precision(order_reservation.convenience_charge, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end @@ -250,8 +250,8 @@ class ReceiptBillOrderPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width, :height => self.item_height) do text "#{number_with_precision(order_reservation.discount_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end - end + end + end end #Change items rows @@ -277,10 +277,10 @@ class ReceiptBillOrderPdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_width) do text "#{product_name}", :size => self.item_font_size,:align => :left end - # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size - text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + # text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size + text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix if show_alt_name if !(item.product_alt_name).empty? @@ -310,10 +310,10 @@ class ReceiptBillOrderPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(order_reservation.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right - end + end move_down line_move - # sale_payment(sale_data,precision,delimiter) + # sale_payment(sale_data,precision,delimiter) end #Change Footer @@ -326,10 +326,10 @@ class ReceiptBillOrderPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width) do text "#{printed_status}",:style => :bold, :size => header_font_size - 1,:align => :left - end + end bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size - 1,:align => :left - end + end move_down line_move end @@ -351,4 +351,4 @@ class ReceiptBillOrderPdf < Prawn::Document end return status end -end \ No newline at end of file +end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 2a99e9f9..9462533c 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -5,7 +5,7 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move - def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) + def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount,transaction_ref) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -76,8 +76,9 @@ class ReceiptBillPdf < Prawn::Document end #end card sale trans data #start card blanace amount - if !card_balance_amount.nil? + if !card_balance_amount.nil? && card_balance_amount >0 card_balance_data(card_balance_amount) + card_transaction_ref(transaction_ref) end #end card blanace amount @@ -797,7 +798,6 @@ class ReceiptBillPdf < Prawn::Document #start card balance data def card_balance_data(card_balance_amount) - if card_balance_amount > 0 move_down line_move stroke_horizontal_rule move_down line_move @@ -809,6 +809,19 @@ class ReceiptBillPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right end + end + #start card transaction_ref + def card_transaction_ref(transaction_ref) + move_down line_move + stroke_horizontal_rule + move_down line_move + + y_position = cursor + bounding_box([0, y_position], :width =>self.label_width) do + text "Transaction ref: ",:style => :bold, :size => header_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{transaction_ref}" , :size => self.item_font_size,:align => :right end end diff --git a/app/pdf/receipt_bill_star_pdf.rb b/app/pdf/receipt_bill_star_pdf.rb index 0b1f8ce2..26d0a944 100644 --- a/app/pdf/receipt_bill_star_pdf.rb +++ b/app/pdf/receipt_bill_star_pdf.rb @@ -3,7 +3,7 @@ class ReceiptBillStarPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :margin_top, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move - def initialize(printer_settings, status, qr , sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount) + def initialize(printer_settings, status, qr , sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount,transaction_ref) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -75,8 +75,9 @@ class ReceiptBillStarPdf < Prawn::Document end #end card sale trans data #start card blanace amount - if !card_balance_amount.nil? + if !card_balance_amount.nil? && card_balance_amount >0 card_balance_data(card_balance_amount) + card_transaction_ref(transaction_ref) end #end card blanace amount @@ -722,19 +723,32 @@ class ReceiptBillStarPdf < Prawn::Document #start card balance data def card_balance_data(card_balance_amount) - if card_balance_amount > 0 - move_down line_move - stroke_horizontal_rule - move_down line_move + move_down line_move + stroke_horizontal_rule + move_down line_move - y_position = cursor - bounding_box([0, y_position], :width =>self.label_width) do - text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right - end - end + y_position = cursor + bounding_box([0, y_position], :width =>self.label_width) do + text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right + end + end + + #start card balance data + def card_transaction_ref(transaction_ref) + move_down line_move + stroke_horizontal_rule + move_down line_move + + y_position = cursor + bounding_box([0, y_position], :width =>self.label_width) do + text "Transaction ref: ",:style => :bold, :size => header_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{transaction_ref}" , :size => self.item_font_size,:align => :right + end end #check ReceiptBillAltName included diff --git a/app/views/foodcourt/addorders/_menu_item.json.jbuilder b/app/views/foodcourt/addorders/_menu_item.json.jbuilder new file mode 100755 index 00000000..2768fa9c --- /dev/null +++ b/app/views/foodcourt/addorders/_menu_item.json.jbuilder @@ -0,0 +1,81 @@ +# Format for attributes json +attr_format = [] +# Format for attributes json +if item.item_attributes.count > 0 + item_attributes = MenuItemAttribute.where(id: item.item_attributes) + attr_format = item_attributes.group_by {|att| att.attribute_type }.map { |type, values| {type: type, values: values.map(&:name)} } +end + +# Format for option json +opt_format = [] +# Format for attributes json +if item.item_options.count > 0 + item_options = MenuItemOption.where(id: item.item_options) + opt_format = item_options.group_by {|opt| opt.option_type }.map { |type, values| {type: type, values: values.map(&:name)} } +end + + +#Menu Item Information +json.id item.id +json.code item.item_code +json.name item.name +json.alt_name item.alt_name +json.image item.image_path.url +json.description item.description +json.information item.information +json.type item.type +json.account_id item.account_id +json.min_qty item.min_qty +json.is_available item.is_available +json.is_sub_item item.is_sub_item +json.unit item.unit + +# Item Sets of Menu Item +json.item_sets item.item_sets.includes(:menu_item_instances) do |its| + json.id its.id + json.name its.name + json.alt_name its.alt_name + json.min_selectable_qty its.min_selectable_qty + json.max_selectable_qty its.max_selectable_qty + json.instances its.menu_item_instances do |i| + json.id i.id + end +end + +json.attributes attr_format +json.options opt_format +# json.min_selectable_item item.min_selectable_item +# json.max_selectable_item item.max_selectable_item + +#Item instance +# if item.menu_item_instances.count == 1 then +# item_instance = item.menu_item_instances[0] +# json.price = item_instance.price +# json.is_available = item_instance.is_available +# json.is_on_promotion = item_instance.is_on_promotion +# json.promotion_price = item_instance.promotion_price +# json.item_attributes = item_instance.item_attributes + +json.instances item.menu_item_instances do |is| + if is.is_available + # Convert id to name for attributes + instance_attr = MenuItemAttribute.where(id: item.item_attributes).pluck(:name) + + json.id is.id + json.code is.item_instance_code + json.name is.item_instance_name + json.price is.price + json.is_available is.is_available + json.is_default is.is_default + json.is_on_promotion is.is_on_promotion + json.promotion_price is.promotion_price + json.values instance_attr + end +end + +#Child Menu items +# if (item.children) then +# json.set_items item.children.each do |item| +# json.partial! 'api/restaurant/menu/menu_item', item: item +# end +# end diff --git a/app/views/foodcourt/addorders/create.json.jbuilder b/app/views/foodcourt/addorders/create.json.jbuilder new file mode 100755 index 00000000..175e6e94 --- /dev/null +++ b/app/views/foodcourt/addorders/create.json.jbuilder @@ -0,0 +1,15 @@ +if @status == true + json.status :success + json.id @order.id + json.booking_id @booking.id + json.order_items do + json.array! @order.order_items, :item_code, :item_name, :qty, :options, :remark + end +else + json.status :error + if @error_messages + json.error_messages @error_messages + else + json.error_messages @order.errors + end +end diff --git a/app/views/foodcourt/addorders/detail.html.erb b/app/views/foodcourt/addorders/detail.html.erb new file mode 100644 index 00000000..247d4957 --- /dev/null +++ b/app/views/foodcourt/addorders/detail.html.erb @@ -0,0 +1,810 @@ +<%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %> +<%= javascript_include_tag 'addorder', 'data-turbolinks-track': 'reload' %> + + +<% type = request.path_info.include?('quick_service') || request.path_info.include?('food_court')%> +<% modify_order = request.path_info.include?('modify_order')%> +
+ + + + + +
+ + + + + + +
+
+
+
+ +
+
+
+
+ +
+ +
+
+ <% if type %> +
+
+ ORDER DETAILS +
+ + <% if modify_order %> + <% if @table.nil? %> + +
Table :
+ + + + <% else%> + +
Table : <%=@table.name%>
+ + + + <% end%> + + + + + +
+ +
+ <% else%> + +
+ +
+
+ +
+ <% end%> +
+ <% else %> +
+
+ ORDER DETAILS | Table-<%=@table.name%> + + + + + + + +
+
+ +
+ <% end%> + +
+
+
+ + + + + + + + + + + + +
#ItemsQTYPrice
+
+ +
+
+ + + + + + + + + + + + <% if type && !modify_order%> + + <% end %> + " id="server_mode"> +
+ + + diff --git a/app/views/foodcourt/addorders/get_all_product.json.jbuilder b/app/views/foodcourt/addorders/get_all_product.json.jbuilder new file mode 100755 index 00000000..01921c59 --- /dev/null +++ b/app/views/foodcourt/addorders/get_all_product.json.jbuilder @@ -0,0 +1,4 @@ + +json.array! @product, :id, :item_code, :name, :alt_name,:image_path, + :description,:information,:taxable,:unit_price, :created_at, + :updated_at, :created_by \ No newline at end of file diff --git a/app/views/foodcourt/addorders/get_item_instance.json.jbuilder b/app/views/foodcourt/addorders/get_item_instance.json.jbuilder new file mode 100644 index 00000000..c95f782d --- /dev/null +++ b/app/views/foodcourt/addorders/get_item_instance.json.jbuilder @@ -0,0 +1,39 @@ +if(@instance) + menu_item = MenuItem.find(@instance.menu_item_id) + # Format for option json + opt_format = [] + # Format for attributes json + menu_item.item_options.each do|opt| + menu_opt = MenuItemOption.find(opt) + if opt_format.count == 0 + opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] }) + next + end + + opt_format.each do |of| + if menu_opt.option_type.in? opt_format.map {|k| k[:type]} + if menu_opt.option_type == of[:type] + of[:values].push(menu_opt.name) + end + else + new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] } + opt_format.push(new_opt) + break + end + end + end + + json.success true + json.id @instance.id + json.name @instance.item_instance_name + json.code @instance.item_instance_code + + json.item_id @instance.menu_item_id + json.attributes @instance.item_attributes + json.price @instance.price + json.is_default @instance.is_default + + json.options opt_format +else + json.success false +end diff --git a/app/views/foodcourt/addorders/get_menu.json.jbuilder b/app/views/foodcourt/addorders/get_menu.json.jbuilder new file mode 100644 index 00000000..bbe18fff --- /dev/null +++ b/app/views/foodcourt/addorders/get_menu.json.jbuilder @@ -0,0 +1 @@ +json.array! @menu_category \ No newline at end of file diff --git a/app/views/foodcourt/addorders/get_menu_category.json.jbuilder b/app/views/foodcourt/addorders/get_menu_category.json.jbuilder new file mode 100755 index 00000000..d5822d3d --- /dev/null +++ b/app/views/foodcourt/addorders/get_menu_category.json.jbuilder @@ -0,0 +1,8 @@ +if @menu.menu_items + json.menu_items @menu.menu_items do |item| + if item.is_available + json.partial! 'foodcourt/addorders/menu_item', item: item + end + + end +end diff --git a/app/views/foodcourt/addorders/get_menu_sub_category.json.jbuilder b/app/views/foodcourt/addorders/get_menu_sub_category.json.jbuilder new file mode 100644 index 00000000..d391e4c5 --- /dev/null +++ b/app/views/foodcourt/addorders/get_menu_sub_category.json.jbuilder @@ -0,0 +1,9 @@ +if @sub_menu + json.sub_category @sub_menu.each do |sub_cat| + json.id sub_cat.id + json.code sub_cat.code + json.name sub_cat.name + json.menu_id sub_cat.menu_id + json.menu_category_id sub_cat.menu_category_id + end +end diff --git a/app/views/foodcourt/cash_ins/new.html.erb b/app/views/foodcourt/cash_ins/new.html.erb new file mode 100755 index 00000000..7bc17066 --- /dev/null +++ b/app/views/foodcourt/cash_ins/new.html.erb @@ -0,0 +1,101 @@ +
+
+
+

<%= t :cash_in %>

+
+ + + + + + + + + + + + + + + + + + + + + +
<%= t :payment_reference %> + + +
<%= t("views.right_panel.detail.remark") %> + + +
<%= t :payment_method %> + + + + + +
<%= t :reference_number %> + + +
<%= t("views.right_panel.detail.amount") %> + + +
+
+
+
+
+ + +
+ +
+
+
+ + diff --git a/app/views/foodcourt/cash_mgmt/create.html.erb b/app/views/foodcourt/cash_mgmt/create.html.erb new file mode 100755 index 00000000..1b4805a2 --- /dev/null +++ b/app/views/foodcourt/cash_mgmt/create.html.erb @@ -0,0 +1,2 @@ +

CashMgmt#create

+

Find me in app/views/cash_mgmt/create.html.erb

diff --git a/app/views/foodcourt/cash_mgmt/index.html.erb b/app/views/foodcourt/cash_mgmt/index.html.erb new file mode 100755 index 00000000..88195969 --- /dev/null +++ b/app/views/foodcourt/cash_mgmt/index.html.erb @@ -0,0 +1,2 @@ +

CashMgmt#index

+

Find me in app/views/cash_mgmt/index.html.erb

\ No newline at end of file diff --git a/app/views/foodcourt/cash_mgmt/new.html.erb b/app/views/foodcourt/cash_mgmt/new.html.erb new file mode 100755 index 00000000..b06a8d2d --- /dev/null +++ b/app/views/foodcourt/cash_mgmt/new.html.erb @@ -0,0 +1,3 @@ +

CashMgmt#new

+

Find me in app/views/cash_mgmt/new.html.erb

+ diff --git a/app/views/foodcourt/cash_outs/new.html.erb b/app/views/foodcourt/cash_outs/new.html.erb new file mode 100755 index 00000000..14a9ec97 --- /dev/null +++ b/app/views/foodcourt/cash_outs/new.html.erb @@ -0,0 +1,53 @@ +
+
+
+

<%= t :cash_out %>

+ + + + + + + + + + + + + +
<%= t :payment_reference %>
<%= t("views.right_panel.detail.remark") %>
<%= t("views.right_panel.detail.amount") %>
+
+
+

+ + +
+
+
+ diff --git a/app/views/foodcourt/customers/index.html.erb b/app/views/foodcourt/customers/index.html.erb new file mode 100644 index 00000000..82d72d07 --- /dev/null +++ b/app/views/foodcourt/customers/index.html.erb @@ -0,0 +1,715 @@ + +
+
+
+
+
+
+ <% path ="/foodcourt/#{@sale_id}/#{@cashier_type}/customers/#{@page}" %> + <%= form_tag path, :id => "filter_form", :method => :get do %> +
+
+ + + +
+ + + + + + + + +
+ <% end %> +
+
+ +
+
+
+
+ <%= paginate @crm_customers %> +
+
+ + + + + + + + + + + + + + + + + <% if @crm_customers.count > 0 %> + <% @i = 0 %> + <% @crm_customers.each do |crm_customer| %> + + + + + + + + + + + + + + <% end %> + <%else%> + + <% end %> + +
<%= t("views.right_panel.detail.sr_no") %><%= t :customer %> <%= t("views.right_panel.detail.type") %><%= t("views.right_panel.detail.name") %><%= t("views.right_panel.detail.card_no") %><%= t("views.right_panel.detail.membership_type") %><%= t("views.right_panel.detail.contact_no") %><%= t("views.right_panel.detail.email") %>
+ + <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %> + <%= @i += 1 %> + <%else%> + - + <% end %> + <%= crm_customer.customer_type rescue '-' %><%= crm_customer.name %><%= crm_customer.card_no rescue '-' %> + <% if !@membership_types.nil? %> + <% @membership_types.each do |member_type| %> + <% if member_type[1] == crm_customer.membership_type %> + <%= member_type[0] %> + <% end %> + <% end %> + <% end %> + <%= crm_customer.contact_no %><%= crm_customer.email %>

There are no record for your search

+
+
+
+
+ + + + <%if !@dining_facility.nil?%> + + + + <% elsif @cashier_type == 'quick_service' || @cashier_type == "food_court" %> + + + + <%else%> + + + + <%end%> + +
+
+
+
+ +
+ <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> + + <%= f.error_notification %> + <%= f.hidden_field :id, :class => "form-control col-md-6 " %> +
+
+
+
+ +
+ +
+
+
+
+
+
+   +   +   + +
+
+
"> +
+ <%= f.input :name, :class => "form-control name", :required => true %> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['name']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end -%> +
+
+
"> +
+ <%= f.input :contact_no, :class => "form-control contact_no" ,:required => true%> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['contact_no']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end %> +
+
+ +
"> +
+ <%= f.input :email, :class => "form-control email" ,:required => true%> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['email']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end %> +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+ + <%= f.file_field :image_path, :class => "img-thumbnail" %> +
+
+
+
+
+
+ + +
+
+
+
+ <%= f.input :nrc_no,:label => "NRC No", :class => "form-control nrc_no" %> +
+
+
+
+ <%= f.input :company, :class => "form-control col-md-6 company"%> + + <% flash.each do |name, msg| %> + <% str="[\"#{msg['company']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end -%> +
+
+
+
+ + <%= f.text_field :date_of_birth, :value=>"01-01-1990",:class=>"datepicker form-control col-md-12"%> +
+
+
+
+ <%= f.input :address, :class => "form-control address" %> +
+
+
+
+ + +
+
+ +
+
+ <%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control tax_profiles" %> +
+
+ +
"> +
+ <%= f.input :card_no, :class => "form-control card_no"%> + <% flash.each do |name, msg| %> + <% str="[\"#{msg['card_no']}\"]" + str.gsub!('["', '') + str.gsub!('"]', '') %> + <%= str %> + <% end %> +
+
+ +
+
+ +
+ +
+
+
+
+ +
+
+ + +
+
+
+
+ + <%= f.submit t("views.btn.submit"),:class => 'btn bg-blue btn-md waves-effect', :id => 'submit_customer' %> + +
+
+
+
+ <% end %> +
+
+
+
+
+
+
+
+ +
+

Card Tap

+
+ +
+
+
+ diff --git a/app/views/foodcourt/dashboard/_menu.json.jbuilder b/app/views/foodcourt/dashboard/_menu.json.jbuilder new file mode 100644 index 00000000..9c9f1963 --- /dev/null +++ b/app/views/foodcourt/dashboard/_menu.json.jbuilder @@ -0,0 +1,112 @@ +json.id menu.id +json.name menu.name +json.is_ordering menu.is_ordering +json.is_active menu.is_active +json.valid_time_from menu.valid_time_from.strftime("%H:%M") +json.valid_time_to menu.valid_time_to.strftime("%H:%M") + +if (menu.menu_categories) + order_by = Lookup.find_by_lookup_type("order_by") + # if !order_by.nil? && order_by.value == "name" + # categories = MenuCategory.unscoped.where("menu_id ='#{menu.id}'").order("name asc") + # else + # categories = menu.menu_categories + # end + categories = menu.menu_categories + json.categories categories do |category| + if category.is_available + parent_category = category.parent + if !parent_category.nil? + json.sub_category "true" + else + json.sub_category "false" + end + valid_time = category.valid_time + json.valid_time valid_time + + json.id category.id + json.code category.code + json.order_by category.order_by + json.name category.name + json.alt_name category.alt_name + json.order_by category.order_by + json.parent_id category.menu_category_id + json.is_available category.is_available + + if !order_by.nil? && order_by.value == "name" + menu_items = category.menu_items.sort_by(&:name) + else + menu_items = category.menu_items + end + + if category.menu_items + json.items menu_items do |item| + if item.is_available + # Format for attributes json + attr_format = [] + # Format for attributes json + if item.item_attributes.count > 0 + item_attributes = @item_attributes.select{ |x| item.item_attributes.include?(x.id.to_s) } + attr_format = item_attributes.group_by {|att| att.attribute_type }.map { |type, values| {type: type, values: values.map(&:name)} } + end + + # Format for option json + opt_format = [] + # Format for attributes json + if item.item_options.count > 0 + item_options = @item_options.select{ |x| item.item_options.include?(x.id.to_s) } + opt_format = item_options.group_by {|opt| opt.option_type }.map { |type, values| {type: type, values: values.map(&:name)} } + end + + #Menu Item Information + json.id item.id + json.code item.item_code + json.name item.name + json.alt_name item.alt_name + json.image item.image_path.url + json.description item.description + json.information item.information + json.type item.type + json.account_id item.account_id + json.min_qty item.min_qty + json.is_available item.is_available + json.is_sub_item item.is_sub_item + json.unit item.unit + + # Item Sets of Menu Item + json.item_sets item.item_sets.map { |its| + { id: its.id, + name: its.name, + alt_name: its.alt_name, + min_selectable_qty: its.min_selectable_qty, + max_selectable_qty: its.max_selectable_qty, + instances: its.menu_item_instances.pluck(:id).map { |id| {id: id}} + } + } + + json.attributes attr_format + json.options opt_format + + json.instances item.menu_item_instances do |is| + if is.is_available + # Convert id to name for attributes + instance_attr = @item_attributes.select{ |x| item.item_attributes.include?(x.id) }.pluck(:name) + + json.id is.id + json.code is.item_instance_code + json.name is.item_instance_name + json.price is.price + json.is_available is.is_available + json.is_default is.is_default + json.is_on_promotion is.is_on_promotion + json.promotion_price is.promotion_price + json.values instance_attr + end + end + + end + end + end + end + end +end diff --git a/app/views/foodcourt/dashboard/get_all_menu.json.jbuilder b/app/views/foodcourt/dashboard/get_all_menu.json.jbuilder new file mode 100644 index 00000000..cce593ff --- /dev/null +++ b/app/views/foodcourt/dashboard/get_all_menu.json.jbuilder @@ -0,0 +1,18 @@ +menu_json = json.array! @menus do |menu| + + if !menu.is_ordering + json.id menu.id + json.name menu.name + json.valid_days menu.valid_days + json.valid_time_from menu.valid_time_from.strftime("%H:%M") + json.valid_time_to menu.valid_time_to.strftime("%H:%M") + + json.partial! 'foodcourt/dashboard/menu', menu: menu + # if (@current_menu) + # json.current_menu do + # json.partial! 'api/restaurant/menu/menu', menu: @current_menu + # end + # end + end + +end diff --git a/app/views/foodcourt/dashboard/index.html.erb b/app/views/foodcourt/dashboard/index.html.erb new file mode 100644 index 00000000..1caab8e6 --- /dev/null +++ b/app/views/foodcourt/dashboard/index.html.erb @@ -0,0 +1,281 @@ +
+ +
+ +

<%= t :date_time %> : <%= Time.zone.now.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %>

+
+ <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> + + +
+ <% if @quick_service == '1' %> +
+
+
+ arrow_forward +
+
<%= t :quick_service %>
+
+
+ <% end %> + <% if @food_court == '1' %> +
+
+
+ arrow_forward +
+
<%= @food_court_name %>
+
+
+ <% end %> + <% if @dinein_cashier == '1' %> +
+
+
+ arrow_forward +
+
<%= t :dine_in_cashier %>
+
+
+ <% end %> + <% if @reservation == '1' %> +
+
+
+ arrow_forward +
+
<%= t :reservation %>
+
+
+ <% end %> + <% if @order_reservation == '1' %> +
+
+
+ arrow_forward +
+
<%= t :order_reservation %>
+
+
+ <% end %> +
+ + <% if !@current_user.nil? && @current_user.role != 'waiter' && @setting_flag %> + +
+ + <% if !@summ_sale.nil? %> + +
+
+
+
<%= t :sale %>
+ + + + + + + <% revenue = @summ_sale.total_amount - @summ_sale.total_discount%> + + + + + + + + + + + + + + + +
<%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.receipt") %> : <%= @summ_sale.total_receipt %>
<%= t("views.right_panel.detail.sale") %> <%= t :revenue %> : <%= number_with_precision( revenue, precision: precision.to_i ,delimiter: delimiter) %>
<%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.discount") %> : <%= number_with_precision( @summ_sale.total_discount, precision: precision.to_i ,delimiter: delimiter) %>
<%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.tax") %> : <%= number_with_precision( @summ_sale.total_tax , precision: precision.to_i ,delimiter: delimiter)%>
<%= t("views.right_panel.detail.total") %> <%= t :sale %> : <%= number_with_precision( @summ_sale.grand_total , precision: precision.to_i ,delimiter: delimiter)%>
+ + <% if !(@total_payment_methods.nil?) %> + <% @total_payment_methods.each do |payment| %> + <% if !@sale_data[0].empty? %> + <% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' %> + + <% if payment.payment_method == 'paypar' %> + + <% else %> + + <% end %> + + + <% end %> + <% end %> + <% end %> + + <% total_card = @sale_data.select { |hash| hash["card"]!=nil }.first %> + <% if !total_card.nil? %> + + + + + <% end %> + + <% end %> +
Redeem Sale : <%= payment.payment_method.to_s.capitalize %> Sale : + <% @sale_data.each do |data| %> + <% pay_mth = payment.payment_method %> + <%= data[""+pay_mth+""] %> + <% end %> +
<%= t("views.right_panel.detail.other_payment") %> : + <%= total_card["card"].to_f %> +
+
+
+
+ <% end %> +
+
+
+
<%= t :customer %>
+ + <% if !@total_customer.nil? %> + + + + + <% end %> + <% if !@total_dinein.nil? %> + + + + + <% end %> + <% if !@total_takeaway.nil? %> + + + + + <% end %> + + <% if !@total_membership.nil? %> + + + + + <% end %> +
<%= t("views.right_panel.detail.total") %> <%= t :customer %> : <%= @total_customer %>
<%= t("views.right_panel.detail.dine_in") %> : <%= @total_dinein %>
<%= t("views.right_panel.detail.takeaway") %> : <%= @total_takeaway %>
<%= t("views.right_panel.detail.membership") %> : <%= @total_membership %>
+
+
+
+
+
+
+
<%= t("views.right_panel.detail.order") %>
+ + <% if !@total_order.nil? %> + + + + + <% end %> + + <% if !@total_accounts.nil? %> + <% @total_accounts.each do |account| %> + + + + + <% end %> + <% end %> + <% if !@top_items.nil? %> + + + + + <% end %> + <% if !@total_foc_items.nil? %> + + + + + <% end %> +
<%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.order") %> : <%= @total_order.total_order %>
<%= account.title %> (Account) : + <% @account_data.each do |data| %> + <% acc = account.title %> + <%= data[""+acc+""] %> <% if !data[''+acc+''].nil? %> ( <%= data[''+acc+'_amount'] %> ) <% end %> + <% end %> +
<%= t :top %> <%= t("views.right_panel.detail.item") %> : <%= @top_items.item_name %> +
(<%= @top_items.item_total_price %>)
<%= t("views.right_panel.detail.total") %> <%= t("views.btn.foc") %> <%= t("views.right_panel.detail.item") %> : <%= @total_foc_items.to_int %>
+
+
+
+
+ <% end %> +
+ + " id="server_mode"> + diff --git a/app/views/foodcourt/discounts/index.html.erb b/app/views/foodcourt/discounts/index.html.erb new file mode 100755 index 00000000..5ca020a3 --- /dev/null +++ b/app/views/foodcourt/discounts/index.html.erb @@ -0,0 +1,919 @@ +
+ + <% if !@print_settings.nil? %> + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> + <% end %> +
+ +
+ +
+ +
+
+
+ <%if !@table.nil?%> + + + <%else%> + + + <%end%> + + +

Receipt No: <%=@sale_data.receipt_no rescue ' '%>

+ +
+
+

Date: <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+ + + + + + + + + + + <% sub_total = 0 %> + <% @sale_data.sale_items.each do |sale_item| %> + <% sub_total += sale_item.qty * sale_item.unit_price %> + <% if sale_item.price > 0 && sale_item.status.blank? %> + > + + + + + <% elsif sale_item.price < 0 && sale_item.status == "Discount" %> + > + + + + + <% end %> + <% end %> + +
ItemsQTYPrice
+ + + <%=sale_item.product_name%>@<%=sale_item.unit_price%> + + <%=sale_item.qty%> + + <%=(sale_item.qty*sale_item.unit_price)%> +
+ + + <%=sale_item.product_name%>@<%=sale_item.unit_price%> + + <%=sale_item.qty.abs%> + + <%=(sale_item.qty*sale_item.unit_price)%> +
+
+
+ +
+
+
+ + + +
+ +
+
+
Discount Control
+
+
+
+
+
+
+ + +
+
+
+ <% @accounts.each do |acc| %> + + <% end %> +
+
+
+
+ +
+
+
+
+
+
+
5%
+
+
+
+
1
+
2
+
3
+
+
+
+ +
+
+
10%
+
+
+
+
4
+
5
+
6
+
+
+
+ +
+
+
15%
+
+
+
+
7
+
8
+
9
+
+
+
+ +
+
+
20%
+
+
+
+
0
+
.
+
00
+
+
+
+ +
+
+
30%
+
+
+
+
+
DEL
+
CLR
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+ + +
+ +
+ +
+ + + + + <% if @member_discount%> + + <%end %> +
+
+
+
+ + diff --git a/app/views/foodcourt/orders/app_order_by_booking.html.erb b/app/views/foodcourt/orders/app_order_by_booking.html.erb new file mode 100644 index 00000000..e531e024 --- /dev/null +++ b/app/views/foodcourt/orders/app_order_by_booking.html.erb @@ -0,0 +1,39 @@ +
+ +
+
+
+
+
+
+
+ ORDER DETAILS + Booking Id : +
+
+
+
+ + + + + + + + + + + +
#ItemsQTY
+
+ +
+
+
+
+
diff --git a/app/views/foodcourt/orders/app_orders.html.erb b/app/views/foodcourt/orders/app_orders.html.erb new file mode 100644 index 00000000..5356333f --- /dev/null +++ b/app/views/foodcourt/orders/app_orders.html.erb @@ -0,0 +1,17 @@ +
+ +
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/foodcourt/orders/show.html.erb b/app/views/foodcourt/orders/show.html.erb new file mode 100755 index 00000000..53fdb437 --- /dev/null +++ b/app/views/foodcourt/orders/show.html.erb @@ -0,0 +1,391 @@ + +
+ +
+ + + + +
+
+ +
+
+ <% @complete.each do |sale| %> +
+
+ <%= sale.receipt_no %><%= sale.sale_status %> +
+
+ <% end %> +
+
+ + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> + <% if table.get_booking.nil? %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= table.name %>
+ <%= table.zone.name %> + billed +
+
+
+ <% else %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= table.name %>
+ <%= table.zone.name %> + new +
+
+ <% end %> + <% else %> +
+
+ <%= table.name %>
+ <%= table.zone.name %> + new +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> + <% if room.get_booking.nil? %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + billed +
+
+ <% else %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + new +
+
+ <% end %> + <% else %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @orders.each do |order| %> +
text-white" data-id = "<%= order.order_id %>"> +
+ <% + order_status = "" + sale_order = SaleOrder.find_by_order_id(order) + if sale_order + unless sale_order.sale_id.nil? + sale = Sale.find(sale_order.sale_id) + order_status = sale.sale_status + if order_status == 'new' + order_status = order.status + end + end + else + order_status = order.status + end + %> + <%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %> +
+
+ <% end %> +
+
+ + +
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + +
<%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %><%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %> <%= t :customer %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.credit_amount") %>
+
+
+
+ +
+
+ +
+ + +
+
+
+
ORDERS DETAILS
+
+
+
+
+ Order No: <%= @order.order_id %> + +
+
+ Date: <%= @order.created_at.utc.getlocal.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> +
+
+
+
+ Customer : +
+ +
+
"> +
+ + + + + + + + + + <% + sub_total = 0 + @order.order_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + <% unless sale_item.price <= 0 %> + + + + + + <% + end + end + %> + +
ItemsQTYPrice
+ <%= sale_item.item_name %> + <% if !sale_item.set_menu_items.nil? + sale_item.set_menu_items.each do |item_instance| %> +
<%= item_instance %> + <% end + end %> +
<%= sale_item.qty %><%= sale_item.price %>
+
+
+ +
+
+
+ + +
+ + <% if !@split_bill.nil? && @split_bill == '1' %> + + <% end %> + <% if @sale_status != 'completed' %> + + <% end %> + +
+
+
+ + + + + + diff --git a/app/views/foodcourt/other_charges/index.html.erb b/app/views/foodcourt/other_charges/index.html.erb new file mode 100755 index 00000000..0a446619 --- /dev/null +++ b/app/views/foodcourt/other_charges/index.html.erb @@ -0,0 +1,406 @@ +
+
+ +
+ +
+ +
+
+
+ +

Receipt No: <%=@sale_data.receipt_no rescue ' '%>

+ +
+
+

Date: <%=@sale_data.receipt_date.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>

+
+
+
+
+ + + + + + + + + + <% sub_total = 0 %> + <% @sale_data.sale_items.each do |sale_item| %> + <% + sub_total += sale_item.qty*sale_item.unit_price + unless sale_item.price == 0 + %> + > + + + + + <% + end + end + %> + +
ItemsQTYPrice
+ + <%=sale_item.product_name%>@<%=sale_item.unit_price%> + + <%=sale_item.qty%> + + <%=(sale_item.qty*sale_item.unit_price)%> +
+
+
+ +
+
+
+ + + +
+ +
+
+
Other Charges Control
+
+
+
+
+
+
+ +
+
+
+ +
+
+ + Is Taxable +
+
+
+
+ +
+ +
+
+
+
+
+
3000
+
+
+
+
1
+
2
+
3
+
+
+
+ +
+
+
5000
+
+
+
+
4
+
5
+
6
+
+
+
+ +
+
+
10000
+
+
+
+
7
+
8
+
9
+
+
+
+ +
+
+
15000
+
+
+
+
0
+
.
+
00
+
+
+
+ +
+
+
20000
+
+
+
+
+
DEL
+
CLR
+
+
+
+
+
+ +
+
+ + +
+
+
+
+
+
+ + +
+ +
+ <%if !@table.nil?%> + + <%else%> + + <%end%> + +
+
+
+
+ diff --git a/app/views/foodcourt/paymal/create.json.jbuilder b/app/views/foodcourt/paymal/create.json.jbuilder new file mode 100644 index 00000000..f352b148 --- /dev/null +++ b/app/views/foodcourt/paymal/create.json.jbuilder @@ -0,0 +1,2 @@ +json.set! :status, @out[0] +json.set! :message, @out[1] \ No newline at end of file diff --git a/app/views/foodcourt/paymal/index.html.erb b/app/views/foodcourt/paymal/index.html.erb new file mode 100644 index 00000000..17d99db0 --- /dev/null +++ b/app/views/foodcourt/paymal/index.html.erb @@ -0,0 +1,404 @@ +
+ +
+
+
+
+ + + +
+
+ + <%@payment_prices = @payment_prices +@rounding_adj%> + +
+
+
+ <% if @payparcount > 0 %> +
+
+ + +
+
+
+ <% end %> +
+
+ + +
+
+
+
+
+ +
0.0
+
+
+
+
+
+ +
+ +
+
+
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Nett
+
Del
+
Clr
+
+
+
+
+
1000
+
3000
+
+
+
5000
+
10000
+
+
+
Pay
+
+
+ +
+
+ + +
+
+ +
+
+ +
+

Card Tap

+
+ +
+
+
+ + + + + diff --git a/app/views/foodcourt/payments/create.json.jbuilder b/app/views/foodcourt/payments/create.json.jbuilder new file mode 100755 index 00000000..f1dd8cad --- /dev/null +++ b/app/views/foodcourt/payments/create.json.jbuilder @@ -0,0 +1,2 @@ +json.status true + diff --git a/app/views/foodcourt/payments/show.html.erb b/app/views/foodcourt/payments/show.html.erb new file mode 100755 index 00000000..f3439910 --- /dev/null +++ b/app/views/foodcourt/payments/show.html.erb @@ -0,0 +1,1788 @@ +
+ + <% if !@print_settings.nil? %> + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> + <% end %> + +
+
+
+
+
+
+
Receipt No : <%=@sale_data.receipt_no rescue ' '%>
+
Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %>
+
+
+
Table No : <%=@table_no%>
+ +
Sale ID : <% if @sale_data %><%=@sale_data.sale_id %><% end %>
+
+ +
+
+ Customer : + <% if @cashier_type == 'quick_service' || @cashier_type == 'food_court' %> + + <% else %> + <%= @sale_data.customer.name%> + <% end %> + +
+
Checkin Time : <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %> + <%end%>
+
+
+
+ +
+
+
+ + + + + + + + + +
#ItemsQTYPrice
+
+
+
+ +
+ + + <% sub_total = 0 + count = 0 + %> + <% @sale_data.sale_items.each do |sale_item| + count += 1 + %> + + <% sub_total += sale_item.price%> + + + + + + + <%end %> + +
<%= count %><%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%><%=sale_item.qty%><%=(number_with_precision(sale_item.price, precision: precision.to_i ))%>
+
+
+
+ + + + +
+
+ +
+
+
+
+
Amount Due <% if !@sale_payment.nil? %>( Credit )<% end %>
+
+ + + + <% if @sale_payment.nil? %> + <%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %> + <% else %> + <%= number_with_precision(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%> + <% end %> + + +
+
+ +
+
Cash
+
+ <%= number_with_precision(@cash, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %> +
+
+ <% if @sale_payment.nil? && @cashier_type != "food_court" %> +
+
Credit
+
<%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
+ <% else %> + + <% end %> +
+
Other Payments
+
+ <%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %> +
+
+
+
+
+ +
+
+
MPU
+ <% if @other != 0.0 %> +
<%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
Redeem
+ <% if @ppamount != 0.0 %> +
<%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
VISA
+ <% if @visacount != 0.0 %> +
<%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
JCB
+ <% if @jcbcount != 0.0 %> +
<%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
MASTER
+ <% if @mastercount != 0.0 %> +
<%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + + +
+
+
UNIONPAY
+ <% if @unionpaycount != 0.0 %> +
<%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
Alipay
+ <% if @alipaycount != 0.0 %> +
<%= number_with_precision(@alipaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
PAYMAL
+ <% if @paymalcount != 0.0 %> +
<%= number_with_precision(@paymalcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ +
+
+
DINGA
+ <% if @dingacount != 0.0 %> +
<%= number_with_precision(@dingacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
JUNCTION PAY
+ <% if @junctionpaycount != 0.0 %> +
<%= number_with_precision(@junctionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ + +
+
+
GIFT VOUCHER
+ <% if @giftvouchercount != 0.0 %> +
<%= number_with_precision(@giftvouchercount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+ <% else %> +
<%= number_with_precision(0, precision: precision.to_i ) %>
+ <% end %> +
+ +
+
Balance
+
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
+
+ +
+
+ + +
+
+
+ + + <% if current_login_employee.role == "cashier" %> + <% if @other_payment <= 0 && @sale_payment.nil? %> + <%if @sale_data.total_discount == 0 %> + FOC + <% end %> + <%end %> + <% if @sale_payment.nil? %> + Void + <% if @other_payment <= 0 %> + <%if @sale_data.total_discount == 0 %> + Waste + Spoile + <% end %> + <% end %> + <% end %> + <% else %> + <% if @other_payment <= 0 && @sale_payment.nil?%> + <%if @sale_data.total_discount == 0 %> + + + <% end %> + <% end %> + <% end %> + <% end %> + +<% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment.nil? %> +
+ + + + <% if current_login_employee.role == "cashier" %> + Edit + <% else %> + +
+ <% end %> + <% end %> + <% end %> +
+
+
+ +
+ +
+ +
+
+
+
+
+ +
+ +
+ +
+
+
+ +
+
+
+ + + + + + +
+
+

Card Tap

+
+
+ +
+
+ + + + + diff --git a/app/views/foodcourt/paypar_payments/create.json.jbuilder b/app/views/foodcourt/paypar_payments/create.json.jbuilder new file mode 100755 index 00000000..f352b148 --- /dev/null +++ b/app/views/foodcourt/paypar_payments/create.json.jbuilder @@ -0,0 +1,2 @@ +json.set! :status, @out[0] +json.set! :message, @out[1] \ No newline at end of file diff --git a/app/views/foodcourt/paypar_payments/index.html.erb b/app/views/foodcourt/paypar_payments/index.html.erb new file mode 100755 index 00000000..4e74da85 --- /dev/null +++ b/app/views/foodcourt/paypar_payments/index.html.erb @@ -0,0 +1,21 @@ +
+ +
+
+ <% if @membership_id!=0 %> +
+
Redim Amount
+
+ <% end %> +
+
+
+ +
+ +
+ diff --git a/app/views/foodcourt/request_bills/print.json.jbuilder b/app/views/foodcourt/request_bills/print.json.jbuilder new file mode 100755 index 00000000..332a9cec --- /dev/null +++ b/app/views/foodcourt/request_bills/print.json.jbuilder @@ -0,0 +1,7 @@ +if @status == true + #show invoice number and stuff + json.status @status +else + json.status @status + json.error_message @error_message +end diff --git a/app/views/foodcourt/reservation/index.html.erb b/app/views/foodcourt/reservation/index.html.erb new file mode 100644 index 00000000..1575b1e5 --- /dev/null +++ b/app/views/foodcourt/reservation/index.html.erb @@ -0,0 +1,149 @@ +<%= stylesheet_link_tag 'reservation', media: 'all', 'data-turbolinks-track': 'reload' %> +<%= javascript_include_tag 'reservation', 'data-turbolinks-track': 'reload' %> +
+
+
+
+
+
<%= t :make_reservation %>
+
+
+
+
+
+ +
+
+
+
+
+   + +
+
+ +
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+
+
+
+ + +
+
+
+ +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+
+
diff --git a/app/views/foodcourt/sale_edit/apply_void.json.jbuilder b/app/views/foodcourt/sale_edit/apply_void.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/sale_edit/apply_void.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/sale_edit/cancel_all_void.json.jbuilder b/app/views/foodcourt/sale_edit/cancel_all_void.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/sale_edit/cancel_all_void.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/sale_edit/edit.html.erb b/app/views/foodcourt/sale_edit/edit.html.erb new file mode 100755 index 00000000..e1a8dd85 --- /dev/null +++ b/app/views/foodcourt/sale_edit/edit.html.erb @@ -0,0 +1,427 @@ +
+
+ +
+
+
+
INVOICE DETAILS
+
+
+
+
+

Receipt No: + <%= @saleobj.receipt_no rescue '' %> +

+
+
+

Date: + <%= @saleobj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %> +

+
+
+
+
+

Customer :

+
+ +
+
+ + + + + + + + + + + + + <% + count = 0 + sub_total = 0 + @saleobj.sale_items.each do |sale_item| + count += 1 + sub_total = sub_total + sale_item.price + %> + + <% + # Can't check for discount + unless sale_item.price == 0 + %> + + + + <% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != 'foc' %> + + + + + + <% elsif sale_item.qty.to_i < 0 || sale_item.status == 'edit' %> + + + + + <% else %> + + + + <% end %> + + <% + end + end + %> + +
#ItemsQTY + Price + Action
<%= count %> + <%= sale_item.product_name %> + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ + +
+ + + + +
+
+
+ + + + diff --git a/app/views/foodcourt/sale_edit/item_void.json.jbuilder b/app/views/foodcourt/sale_edit/item_void.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/sale_edit/item_void.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/sale_edit/item_void_cancel.json.jbuilder b/app/views/foodcourt/sale_edit/item_void_cancel.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/sale_edit/item_void_cancel.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/sales/add_to_existing_invoice.json.jbuilder b/app/views/foodcourt/sales/add_to_existing_invoice.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/sales/add_to_existing_invoice.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/sales/show.html.erb b/app/views/foodcourt/sales/show.html.erb new file mode 100755 index 00000000..fd74df43 --- /dev/null +++ b/app/views/foodcourt/sales/show.html.erb @@ -0,0 +1,565 @@ +
+
+ +
+ + + + "> + +
+
+ +
+
+ <% @complete.each do |sale| %> +
+
+ <%= sale.receipt_no %><%= sale.sale_status %> +
+
+ <% end %> +
+
+ + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> + <% if table.get_booking.nil? %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= table.name %>
+ <%= table.zone.name %> + + billed +
+
+
+ <% else %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= table.name %>
+ <%= table.zone.name %> + + new +
+
+ <% end %> + <% else %> +
+
+ <%= table.name %>
+ <%= table.zone.name %> + new +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> + <% if room.get_booking.nil? %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + + billed +
+
+ <% else %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + + new +
+
+ <% end %> + <% else %> +
+
+ <%= room.name %>
+ <%= room.zone.name %> + +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @orders.each do |order| %> +
text-white" data-id="<%= order.order_id %>"> +
+ <% + order_status = "" + sale_order = SaleOrder.find_by_order_id(order) + if sale_order + unless sale_order.sale_id.nil? + sale = Sale.find(sale_order.sale_id) + order_status = sale.sale_status + if order_status == 'new' + order_status = order.status + end + end + else + order_status = order.status + end + %> + <%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %> +
+
+ <% end %> +
+
+ + +
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + +
<%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %><%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %> <%= t :customer %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.credit_amount") %>
+
+
+
+ +
+
+ +
+ + + +
+
+
+
INVOICE DETAILS | Table <%= @dining.name rescue "" %>
+
+
+
+
+ Receipt No: + <%= @sale.receipt_no rescue '' %> + +
+
+ Date: <%= @sale.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> +
+
+
+
+ Customer : <%= @sale.customer.name rescue "-" %> + +
+ +
+
+
+ + + + + + + + + + <% + sub_total = 0 + @sale.sale_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + + <% #unless sale_item.price <= 0 %> + + + + + + <% + + #end + end + + %> + +
ItemsQTYPrice
<%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
+
+
+ +
+
+
+ + +
+ + <% if @sale.sale_status != 'void' && @sale.sale_status != 'waste' && @sale.sale_status != 'spoile' %> + <% if current_login_employee.role == "cashier" %> + <% if @sale.payment_status != 'foc' %> + Void + <% end %> + Re.Print + <% else %> + <% if @sale.payment_status != 'foc' %> + + <% end %> + + <% end %> + <% end %> + +
+
+ + +
+ + + + + + + + + diff --git a/app/views/foodcourt/second_display/_second_display.html.erb b/app/views/foodcourt/second_display/_second_display.html.erb new file mode 100644 index 00000000..c09d6c4c --- /dev/null +++ b/app/views/foodcourt/second_display/_second_display.html.erb @@ -0,0 +1,67 @@ +
+
+ +
+
+
+
+ + + + + + + + + + + + + +
#ItemsQTYPrice
+
+
+
+ +
+ +
+
+
+
+ <% @display_images.each do |p| %> + <%= image_tag "#{p.image}", :alt => "rss feed"%> + <% break %> + <% end %> +
+
+
+
+ diff --git a/app/views/foodcourt/second_display/_slider.html.erb b/app/views/foodcourt/second_display/_slider.html.erb new file mode 100644 index 00000000..71f463b7 --- /dev/null +++ b/app/views/foodcourt/second_display/_slider.html.erb @@ -0,0 +1,20 @@ +<%= stylesheet_link_tag 'wow_style', media: 'all', 'data-turbolinks-track': 'reload' %> +<%= javascript_include_tag 'wowslider', 'data-turbolinks-track': 'reload' %> +<%= javascript_include_tag 'wow_script', 'data-turbolinks-track': 'reload' %> +
+
+
+
+
    + <% @display_images.each do |p| %> +
  • + <%= image_tag "#{p.image}", :alt => "rss feed"%> +
  • + <% end %> +
+
+
+
+
+
+ diff --git a/app/views/foodcourt/second_display/index.html.erb b/app/views/foodcourt/second_display/index.html.erb new file mode 100644 index 00000000..5b4ad7f0 --- /dev/null +++ b/app/views/foodcourt/second_display/index.html.erb @@ -0,0 +1,20 @@ +
+ +
+ <%= render 'slider' %> +
+ + +
+ diff --git a/app/views/foodcourt/shifts/create.json.jbuilder b/app/views/foodcourt/shifts/create.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/shifts/create.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/shifts/edit.html.erb b/app/views/foodcourt/shifts/edit.html.erb new file mode 100755 index 00000000..60d5c6d8 --- /dev/null +++ b/app/views/foodcourt/shifts/edit.html.erb @@ -0,0 +1 @@ +

Close Cashier

diff --git a/app/views/foodcourt/shifts/index.html.erb b/app/views/foodcourt/shifts/index.html.erb new file mode 100755 index 00000000..ebec0301 --- /dev/null +++ b/app/views/foodcourt/shifts/index.html.erb @@ -0,0 +1,2 @@ +

Origami::Shifts#index

+

Find me in app/views/origami/shifts/index.html.erb

diff --git a/app/views/foodcourt/shifts/new.html.erb b/app/views/foodcourt/shifts/new.html.erb new file mode 100755 index 00000000..eb02d644 --- /dev/null +++ b/app/views/foodcourt/shifts/new.html.erb @@ -0,0 +1,126 @@ +
+

Open Cashier

+
+
+
+ + + + + + <% @float.each do |float| %> + + + + + <% end %> + + + + +
Cashier Terminal + + +
<%= float.name %>
Total
+ +
+
+
+
+
+
1
+
2
+
3
+
+
+
4
+
5
+
6
+
+
+
7
+
8
+
9
+
+
+
0
+
.
+
00
+
+
+
Clr
+
Calculate
+
Open Cashier
+
+
+ +
+
+
+
+ diff --git a/app/views/foodcourt/shifts/sale_summary.html.erb b/app/views/foodcourt/shifts/sale_summary.html.erb new file mode 100755 index 00000000..321a3941 --- /dev/null +++ b/app/views/foodcourt/shifts/sale_summary.html.erb @@ -0,0 +1,201 @@ +
+ +
+

Sales Summary Quick View

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Cashier Cashier Terminal Opening Date Opening float Received Amount Cast In Cast Out Total Receipt Dining Count Takeaway Count Total Void
<%= @shift.employee.name%><%=@shift.cashier_terminal.name%><%= @shift.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') %> + <%=@shift.opening_balance %><%=@shift.closing_balance %><%=@shift.cash_in %><%=@shift.cash_out %><%= @shift.total_receipt %><%= @shift.dining_count %><%= @shift.takeaway_count %>(<%= @shift.total_void.round(2) %>)
+ + <% @total_amount_by_account.each do |amount| %> + + + + + + <%end%> + + + + + + + <% @total_discount_by_account.each do |amount| %> + + + + + + <%end%> + + <% if !@total_member_discount[0].member_discount.nil? + @member_discount = @total_member_discount[0].member_discount rescue 0.0 + @overall = @shift.total_discounts - @member_discount + %> + + + + + + <%else @overall = @shift.total_discounts %> + + <%end%> + + + + + + + + + + + + <% @sale_taxes.each do |tax| %> + + + + + + <%end%> + + + + + + + + + + + + + + + +
Total <%= amount.account_name %> Amount<%= amount.total_price.round(2) %>
Net Sales<%=@shift.nett_sales %>
Total <%= amount.account_name %> Discount<%= amount.total_price.round(2) %>
Total Member Discount<%= @member_discount %>
Total Overall Discount<%= @overall %>
Total Discount<%= @shift.total_discounts %>
<%= tax.tax_name %> <%= tax.st_amount.round(2) %>
Total Tax <%=@shift.total_taxes %>
Rounding Adj <%= @shift.total_rounding.round(2) %>
Grand Total <%= @shift.grand_total.round(2) %>
+
+ + + + + + + + + + + + <% @total_amount = 0 + + @other_payment.each do |other| %> + + + + + + + + + + <% @total_amount = @total_amount+other.mpu_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.visa_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.master_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.jcb_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.paypar_amount rescue 0.0 %> + + + + + + <% @total_amount = @total_amount+other.foc_amount rescue 0.0 %> + + <%end%> + + + + + + + + + + + + +
Cash Payment <%=@shift.cash_sales %>
Credit Payment <%=@shift.credit_sales %>
Other Payment Detail
MPU Payment <%=other.mpu_amount.round(2) rescue 0.0 %>
VISA Payment <%=other.visa_amount.round(2) rescue 0.0 %>
JCB Payment <%=other.master_amount.round(2) rescue 0.0 %>
Master Payment <%=other.jcb_amount.round(2) rescue 0.0 %>
Reedem Payment <%=other.paypar_amount.round(2) rescue 0.0 %>
FOC <%=other.foc_amount.round(2) rescue 0.0 %>
Total Other Payment <%=@shift.other_sales %>
Total Payment <%= @total_amount+@shift.cash_sales+@shift.credit_sales %>
+
+
+ +
+


+ + +
+
+ + diff --git a/app/views/foodcourt/shifts/show.html.erb b/app/views/foodcourt/shifts/show.html.erb new file mode 100755 index 00000000..e2f2275c --- /dev/null +++ b/app/views/foodcourt/shifts/show.html.erb @@ -0,0 +1,282 @@ +
+ + +
+
+

<%= t :close_cashier %>

+
+ + + + + + + + + + +
<%= t :shift_started_at %><%= @shift.shift_started_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-' %>
<%= t :cashier_name %><%= @shift.employee.name rescue ''%>
+
+
+
+ <%= t :closing_balance %> +
+
+ +
+

+
+
+ + + <% if @bank_integration == '1' && @cashier_type!="ordering" %> + + <% end %> +
+
+ + +
+ diff --git a/app/views/foodcourt/shifts/update_shift.json.jbuilder b/app/views/foodcourt/shifts/update_shift.json.jbuilder new file mode 100755 index 00000000..08bf292c --- /dev/null +++ b/app/views/foodcourt/shifts/update_shift.json.jbuilder @@ -0,0 +1 @@ +json.status true diff --git a/app/views/foodcourt/surveys/_form.html.erb b/app/views/foodcourt/surveys/_form.html.erb new file mode 100755 index 00000000..c0ed9f59 --- /dev/null +++ b/app/views/foodcourt/surveys/_form.html.erb @@ -0,0 +1,534 @@ +
+
+
+
+ <%= simple_form_for(@survey, :url => foodcourt_create_surveys_path) do |f| %> + <%= f.error_notification %> +
+ <% if !@survey_data.nil? %> +
+
+
+ <%= f.input :child, input_html: { value: @survey_data.child, class: 'col-md-10', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyChild(this.value);" }%> +
+
+
+
+ <%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyAdult(this.value);" }%> +
+
+
+
+
+
+ <%= f.input :male , input_html: { value: @survey_data.male, class: 'col-md-10', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyMale(this.value);" }%> +
+
+
+
+ <%= f.input :female , input_html: { value: @survey_data.female, class: 'col-md-10', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyFemale(this.value);" }%> +
+
+
+ <%= f.input :total_customer, input_html: { value:@survey_data.total_customer , :readonly => true, class: 'col-md-11'} %> + <%= f.input :local , input_html: { value: @survey_data.local, class: 'col-md-11', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyLocal(this.value);" }%> + + +
+ Foreigner +
+
+
+ + + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ <% else %> +
+
+
+ <%= f.input :child , input_html: { class: 'col-md-10' ,min:'1', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyChild(this.value);" }%> +
+
+
+
+ <%= f.input :adult , input_html: { class: 'col-md-10' ,min:'1', :onChange => "total_customer();", :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyAdult(this.value);" }%> +
+
+
+
+
+
+ <%= f.input :male , input_html: { min:'1',class: 'col-md-10' , :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyMale(this.value);" }%> +
+
+
+
+ <%= f.input :female , input_html: { min:'1',class: 'col-md-10' , :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyFemale(this.value);" }%> +
+
+
+ <%= f.input :total_customer, input_html: { :readonly => true,min:'1', class: 'col-md-11'} %> + <%= f.input :local , input_html: { min:'1',class: 'col-md-11', :onkeypress => "return isNumberKey(event);", :onkeyup => "surveyLocal(this.value);" }%> + +
+ Foreigner +
+
+
+ + + +
+
+
+
+ + +
+
+
+
+ +
+
+ +
+ <% end %> + + <%if !@dining_facility.nil? %> + + + <%= f.input :dining_name, :as => :hidden, :input_html => { :value => @dining_facility.name } %> + <%else%> + + + <%= f.input :dining_name, :as => :hidden, :input_html => { :value => 0 } %> + <%end%> + + + + <% if !@survey_data.nil? %> + /> + <% else %> + + <% end %> + + + <%= f.input :created_by, :as => :hidden, :input_html => { :value => current_login_employee.name } %> + <%= f.input :receipt_no, :as => :hidden, :input_html => { :value => @receipt_no} %> + <%= f.input :total_amount, :as => :hidden, :input_html => { :value => @grand_total } %> +
+
+ <%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %> +
+ <% end %> +
+
+
+
+
+
+
+
+
+
+
1
+
2
+
3
+
+
+
+ +
+
+
+
4
+
5
+
6
+
+
+
+ +
+
+
+
7
+
8
+
9
+
+
+
+ +
+
+
+
0
+
.
+
00
+
+
+
+ +
+
+
+
+
DEL
+
CLR
+
+
+
+
+
+
+
+
+ +
+ +
+ +
+ +
+ + diff --git a/app/views/foodcourt/surveys/_survey.json.jbuilder b/app/views/foodcourt/surveys/_survey.json.jbuilder new file mode 100755 index 00000000..1a0e4aa8 --- /dev/null +++ b/app/views/foodcourt/surveys/_survey.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! settings_account, :id, :title, :account_type, :created_at, :updated_at +json.url settings_account_url(settings_account, format: :json) diff --git a/app/views/foodcourt/surveys/edit.html.erb b/app/views/foodcourt/surveys/edit.html.erb new file mode 100755 index 00000000..96fca006 --- /dev/null +++ b/app/views/foodcourt/surveys/edit.html.erb @@ -0,0 +1,12 @@ + + + <%= render 'form', settings_account: @settings_account %> diff --git a/app/views/foodcourt/surveys/index.html.erb b/app/views/foodcourt/surveys/index.html.erb new file mode 100755 index 00000000..c3d9cdfa --- /dev/null +++ b/app/views/foodcourt/surveys/index.html.erb @@ -0,0 +1,91 @@ + + +
+
+
+ + + + + + + + + + + + + + + <% @settings_accounts.each do |account| %> + + + + + + + + + + <% end %> + +
<%= t("views.right_panel.detail.title") %><%= t("views.right_panel.detail.account_type") %><%= t("views.right_panel.detail.discount") %><%= t("views.right_panel.detail.point") %><%= t("views.right_panel.detail.bonus") %><%= t("views.right_panel.detail.rebate") %><%= t("views.right_panel.detail.actions") %>
<%= account.title %><%= account.account_type == 1 ? "Expense" : "Income"%><%= account.discount %><%= account.point %><%= account.bonus %><%= account.rebate %> + <%= link_to t("views.btn.show"), settings_account_path(account),:class => 'btn btn-info btn-sm waves-effect' %> + <%= link_to t("views.btn.edit"), edit_settings_account_path(account),:class => 'btn btn-primary btn-sm waves-effect' %> +
+
+
+
+
+
+
view_headline <%= t("views.right_panel.header.page_detail") %>
+

+ 1) <%= t("views.right_panel.detail.title") %> - <%= t("views.right_panel.detail.title_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.account_txt") %>
+ 2) <%= t("views.right_panel.detail.account_type") %> - <%= t("views.right_panel.detail.account_type_txt") %>
+ 3) <%= t("views.right_panel.detail.discount") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.discount_txt") %>
+ 4) <%= t("views.right_panel.detail.point") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.point_txt") %>
+ 5) <%= t("views.right_panel.detail.bonus") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.bonus_txt") %>
+ 6) <%= t("views.right_panel.detail.rebate") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.rebate_txt") %>
+ 7) <%= t("views.right_panel.detail.actions") %> - <%= t("views.right_panel.detail.actions_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+

+
list <%= t("views.right_panel.header.button_lists") %>
+

+ 1) <%= t("views.right_panel.button.new") %> - <%= t("views.right_panel.detail.new_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+ 2) <%= t("views.right_panel.button.show") %> - <%= t("views.right_panel.detail.show_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+ 2) <%= t("views.right_panel.button.edit") %> - <%= t("views.right_panel.detail.edit_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+

+
list <%= t("views.right_panel.header.link_lists") %>
+

+ 1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %>
+ 2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.dashboard_txt") %>
+

+
+
+
+
+ +
+
+ + diff --git a/app/views/foodcourt/surveys/index.json.jbuilder b/app/views/foodcourt/surveys/index.json.jbuilder new file mode 100755 index 00000000..10158c29 --- /dev/null +++ b/app/views/foodcourt/surveys/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @settings_accounts, partial: 'settings_accounts/settings_account', as: :settings_account diff --git a/app/views/foodcourt/surveys/new.html.erb b/app/views/foodcourt/surveys/new.html.erb new file mode 100755 index 00000000..ee4d9a57 --- /dev/null +++ b/app/views/foodcourt/surveys/new.html.erb @@ -0,0 +1,3 @@ + + + <%= render 'form', survey: @survey %> diff --git a/app/views/foodcourt/surveys/show.html.erb b/app/views/foodcourt/surveys/show.html.erb new file mode 100755 index 00000000..4c28f27c --- /dev/null +++ b/app/views/foodcourt/surveys/show.html.erb @@ -0,0 +1,84 @@ + + + +
+ +
+
+
+
+

Account

+ + + + + + + + + + + + + + + + + + + + + + + + + +
<%= t("views.right_panel.detail.title") %><%= t("views.right_panel.detail.account_type") %><%= t("views.right_panel.detail.can_get_points") %><%= t("views.right_panel.detail.can_rebate") %><%= t("views.right_panel.detail.actions") %>
<%= @settings_account.title %><%= @settings_account.account_type %><%= @settings_account.point %><%= @settings_account.rebate %><%= link_to t("views.btn.edit"), edit_settings_account_path(@settings_account),:class => 'btn btn-primary btn-sm waves-effect' %> + + + +
+
+
+
+ +
+
+
+
view_headline <%= t("views.right_panel.header.page_detail") %>
+

+ 1) <%= t("views.right_panel.detail.title") %> - <%= t("views.right_panel.detail.title_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.account_txt") %>
+ 2) <%= t("views.right_panel.detail.account_type") %> - <%= t("views.right_panel.detail.account_type_txt") %>
+ 3) <%= t("views.right_panel.detail.can_get_points") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.point_txt") %>
+ 4) <%= t("views.right_panel.detail.can_rebate") %> - <%= t("views.right_panel.detail.status_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.rebate_txt") %>
+ 5) <%= t("views.right_panel.detail.actions") %> - <%= t("views.right_panel.detail.actions_txt2") %> <%= t("views.right_panel.detail.account_txt") %>
+

+
list <%= t("views.right_panel.header.button_lists") %>
+

+ 1) <%= t("views.right_panel.button.edit") %> - <%= t("views.right_panel.detail.edit_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+ 2) <%= t("views.right_panel.button.delete") %> - <%= t("views.right_panel.detail.delete_btn_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+

+
list <%= t("views.right_panel.header.link_lists") %>
+

+ 1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %>
+ 2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.account_txt") %>
+

+
+
+
+
+ diff --git a/app/views/foodcourt/surveys/show.json.jbuilder b/app/views/foodcourt/surveys/show.json.jbuilder new file mode 100755 index 00000000..e9673454 --- /dev/null +++ b/app/views/foodcourt/surveys/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "settings_accounts/settings_account", settings_account: @settings_account diff --git a/app/views/layouts/CRM.html.erb b/app/views/layouts/CRM.html.erb index 955abc98..f41f96f3 100755 --- a/app/views/layouts/CRM.html.erb +++ b/app/views/layouts/CRM.html.erb @@ -36,32 +36,36 @@
<%= render 'layouts/header' %> -
- <%= render 'layouts/left_sidebar' %> - <%= render 'layouts/right_sidebar' %> +
+ <%if current_login_employee.role == "foodcourt_cashier" %> + <%= render 'layouts/foodcourt_left_sidebar' %> + <% else %> + <%= render 'layouts/left_sidebar' %> + <%end%> + <%= render 'layouts/right_sidebar' %>
-
+
<% flash.each do |type, message| %> <% if !flash["errors"]%> - <% + <% if type == "notice" color = "alert-success" end if type == "error" color = "alert-danger" - end + end %> <% if flash["error"] || flash["notice"]%> <% end %> - <% end %> - <% end %> - <%= yield %> + <% end %> + <% end %> + <%= yield %>
- \ No newline at end of file + diff --git a/app/views/layouts/_foodcourt_left_sidebar.html.erb b/app/views/layouts/_foodcourt_left_sidebar.html.erb new file mode 100644 index 00000000..520a3251 --- /dev/null +++ b/app/views/layouts/_foodcourt_left_sidebar.html.erb @@ -0,0 +1,54 @@ + + + - - + <% if current_login_employee.role !='foodcourt_cashier' %> + + <% end %> + + + + + +
+ +<%end%> + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d03889f7..cd405859 100755 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -4,7 +4,7 @@ - + SmartSales : Restaurant <%= csrf_meta_tags %> @@ -12,10 +12,10 @@ <%= stylesheet_link_tag 'application', media: 'all' %> - <%= javascript_include_tag 'application' %> + <%= javascript_include_tag 'application' %> - +
@@ -37,27 +37,32 @@
<%= render 'layouts/header' %> -
- <%= render 'layouts/left_sidebar' %> - <%= render 'layouts/right_sidebar' %> +
+ <%if current_login_employee.role == "foodcourt_cashier" %> + <%= render 'layouts/foodcourt_left_sidebar' %> + <% else %> + <%= render 'layouts/left_sidebar' %> + <%end%> + + <%= render 'layouts/right_sidebar' %>
-
+
<% flash.each do |type, message| %> - <% if type == "notice" + <% if type == "notice" color = "alert-success" elsif type == "error" color = "alert-danger" else color = "bg-black" end %> - + - <% end %> - <%= yield %> -
+ <% end %> + <%= yield %> +
- \ No newline at end of file + diff --git a/app/views/layouts/foodcourt.html.erb b/app/views/layouts/foodcourt.html.erb new file mode 100644 index 00000000..05b1542b --- /dev/null +++ b/app/views/layouts/foodcourt.html.erb @@ -0,0 +1,63 @@ + + + + + + + + SmartSales : Restaurant + <%= csrf_meta_tags %> + + + + + <%= stylesheet_link_tag 'origami', media: 'all' %> + <%= javascript_include_tag 'origami', 'data-turbolinks-track': 'reload' %> + + + + +
+
+
+
+
+
+
+
+
+
+
+
+

Please wait...

+
+
+ + +
+ + <%= render 'layouts/header' %> +
+ <%= render 'layouts/foodcourt_left_sidebar' %> + <%= render 'layouts/right_sidebar' %> +
+ + +
+ <% flash.each do |type, message| %> + <% if type == "notice" + color = "alert-success" + elsif type == "error" + color = "alert-danger" + else + color = "bg-black" + end %> + + + <% end %> + <%= yield %> +
+ + diff --git a/app/views/transactions/bookings/index.html.erb b/app/views/transactions/bookings/index.html.erb index b5f598e5..a06b3e47 100755 --- a/app/views/transactions/bookings/index.html.erb +++ b/app/views/transactions/bookings/index.html.erb @@ -3,7 +3,11 @@ - <%= link_to 'Back', dashboard_path %> + <%if current_login_employee.role == "foodcourt_cashier" %> + <%= link_to 'Back', foodcourt_food_court_path %> + <% else %> + <%= link_to 'Back', dashboard_path %> + <%end%>
diff --git a/app/views/transactions/orders/index.html.erb b/app/views/transactions/orders/index.html.erb index 47216911..357261ec 100755 --- a/app/views/transactions/orders/index.html.erb +++ b/app/views/transactions/orders/index.html.erb @@ -4,7 +4,11 @@ - <%= link_to 'Back', dashboard_path %> + <%if current_login_employee.role == "foodcourt_cashier" %> + <%= link_to 'Back', foodcourt_food_court_path %> + <% else %> + <%= link_to 'Back', dashboard_path %> + <%end%>
diff --git a/app/views/transactions/sales/index.html.erb b/app/views/transactions/sales/index.html.erb index 7ca7c08f..c0f3ee6e 100644 --- a/app/views/transactions/sales/index.html.erb +++ b/app/views/transactions/sales/index.html.erb @@ -3,7 +3,11 @@ - <%= link_to 'Back', dashboard_path %> + <%if current_login_employee.role == "foodcourt_cashier" %> + <%= link_to 'Back', transactions_bookings_path %> + <% else %> + <%= link_to 'Back', dashboard_path %> + <%end%>
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 63881a4f..5479bcca 100755 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -60,3 +60,7 @@ Rails.application.config.assets.precompile += %w( order_reservation.js ) # --- Reservation ---- Rails.application.config.assets.precompile += %w( reservation.css ) Rails.application.config.assets.precompile += %w( reservation.js ) + +# --- Foodcourt ---- +Rails.application.config.assets.precompile += %w( foodcourt.css ) +Rails.application.config.assets.precompile += %w( foodcourt.js ) diff --git a/config/routes.rb b/config/routes.rb index 23d3b3f7..4dcc5911 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -43,7 +43,7 @@ scope "(:locale)", locale: /en|mm/ do #Session Login and Logout post 'authenticate' => "authenticate#create" delete 'authenticate' => "authenticate#destroy" - + resources :shops, only: [:index, :show] resources :verifications, only: [:new] post 'verifications/update' => "verifications#update" @@ -59,7 +59,7 @@ scope "(:locale)", locale: /en|mm/ do resources :menu_item_instances, only: [:show] get "item_sets" => "item_sets#index" end - + namespace :payment do post 'mobilepayment/:cashier_id/:receipt_no/cash' =>"mobilepayment#cash" end @@ -603,5 +603,92 @@ scope "(:locale)", locale: /en|mm/ do post '/run_teamviewer' => 'home#run_teamviewer', :defaults => { :format => 'json' } # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + +#only for foodcourt + namespace :foodcourt do + root "home#index" + + post '/check_emp_access_code/:code' => 'home#check_emp_access_code', :defaults => { :format => 'json' } + + get "dashboard" => "dashboard#index" + get "get_all_menu" => "dashboard#get_all_menu" + get "/table/:table_id/sale/:sale_id/:type/edit" => "sale_edit#edit" + get "/table/sale/:sale_id/:type/edit" => "sale_edit#edit" + post 'item_void' => "sale_edit#item_void" + post 'item_foc' => "sale_edit#item_foc" + post 'item_edit' => "sale_edit#item_edit" + post 'item_void_cancel' => "sale_edit#item_void_cancel" + post 'cancel_all_void' => 'sale_edit#cancel_all_void' + post 'apply_void' => 'sale_edit#apply_void' + get 'sale/:sale_id' => 'sales#show' + get 'order/:order_id' => "orders#show" + + # Other Charges + get "/:sale_id/:type/other_charges" => "other_charges#index" + post "/:sale_id/other_charges" => "other_charges#create" + + # Discount + get "/:id/:type/discount" => "discounts#index" + post "/:id/discount" => "discounts#create" + get "/:id/:type/remove_all_discount" => "discounts#remove_all_discount" + post "/:id/remove_discount_items" => "discounts#remove_discount_items" + + # Discount for Member + post "/:id/member_discount" => "discounts#member_discount" + + get "/:id/request_bills" => "request_bills#print", :as => "request_bill" + get '/:sale_id/reprint' => 'payments#reprint', :defaults => {:format => 'json'} + + #---------Shift ---------------# + resources :shifts, only: [:index, :new, :create, :edit] + post 'close_shift' => 'shifts#update_shift' + get 'shift/:type/close' => 'shifts#show' + get 'shift/sale_summary' => 'shifts#sale_summary' + + resources :cash_mgmt, only: [:new, :create] + + post 'sale/:sale_id/:type/payment/print' => 'payments#print' #route for print receipt + get 'sale/:sale_id/:type/payment' => 'payments#show' + post 'payment/:type/foc' => 'payments#foc', :defaults => {:format => 'json'} + post 'payment/cash' => 'payments#create' + post 'payment/paymal' => 'paymal#create' + + post 'payment/:type/change_tax' => 'payments#change_tax', :defaults => {:format => 'json'} + + #---------Void --------------# + post 'sale/:sale_id/:type/void' => 'void#overall_void' + + post 'sale/:sale_id/:type/waste_and_spoilage' => "waste_spoile#waste_and_spoilage" + + #---------Add Customer --------------# + #resources :customers + get '/:sale_id/:type/customers/:dir_page', to: "customers#add_customer" + get '/:customer_id/get_customer' => 'home#get_customer', :as => "show_customer_details" + post '/:sale_id/:type/customers/update_sale', to: "customers#update_sale_by_customer" # update customer id in sale table + + post '/:sale_id/get_customer' => "customers#get_customer" + post '/:sale_id/send_account' => "customers#send_account" + + get '/:id/:type/surveys', to: "surveys#new" + match '/:id/create_survey', to: "surveys#create", as: "create_surveys", via: [:post, :patch, :put] + + get '/addorders/get_menu/:id' => "addorders#get_menu",:as => "get_menu", :defaults => { :format => 'json' } + get '/addorders/get_menu_category/:id' => "addorders#get_menu_category",:as => "get_menu_category", :defaults => { :format => 'json' } + get '/addorders/get_menu_sub_category/:id' => "addorders#get_menu_sub_category",:as => "get_menu_sub_category", :defaults => { :format => 'json' } + get '/addorders/products/list' => "addorders#get_all_product",:as => "get_all_product", :defaults => { :format => 'json' } + + get '/:addorders/:id' => "addorders#detail" + post '/:addorders/create' => "addorders#create",:as => "addorder_create", :defaults => { :format => 'json' } + + + get '/addorders/get_item_instance/:id' => "addorders#get_item_instance",:as => "get_item_instance", :defaults => { :format => 'json' } + + resources :second_display #second display routes + + post '/customer_view' => "second_display#customer_view",:as => "customer_view", :defaults => { :format => 'json' } + get "food_court" => "food_court#index" + get "app_orders" => "orders#app_orders" + get "app_order/:booking_id" => "orders#app_order_by_booking" + end end end diff --git a/server2.pid b/server2.pid index ded42b32..edf425a9 100644 --- a/server2.pid +++ b/server2.pid @@ -1 +1 @@ -3453 \ No newline at end of file +15225 \ No newline at end of file