diff --git a/Gemfile.lock b/Gemfile.lock index b7f4b2ca..4e6ba0f6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -160,7 +160,7 @@ GEM railties (>= 3.1) multi_json (1.12.2) multi_xml (0.6.0) - mysql2 (0.4.9) + mysql2 (0.4.10) nested_form (0.3.2) net-scp (1.2.1) net-ssh (>= 2.6.5) @@ -368,4 +368,4 @@ RUBY VERSION ruby 2.4.1p111 BUNDLED WITH - 1.16.1 + 1.16.4 diff --git a/README.md b/README.md index 363d0be3..2d9d60c9 100755 --- a/README.md +++ b/README.md @@ -193,6 +193,7 @@ For MoveTablePdf in print settings 1) settings/lookups => { type:tax_profiles, name: Cashier, value:cashier } 2) settings/lookups => { type:tax_profiles, name: Quick Service, value: quick_service } 3) settings/lookups => { type:tax_profiles, name: Doemal, value: doemal } +4) settings/lookups => { type:tax_profiles, name: Food Court, value: food_court } /* Tax Profile Group Types in lookups */ /*Receipt Pdf View in lookups */ @@ -257,6 +258,17 @@ For TaxProfiles On/Off For Add Kitchen Role 1) settings/lookups => {type:employee_roles, name:Kitchen, value:kitchen} +For Food Court Settings On/Off + ** '0' means can not use food court and '1' means can use food court ** + => settings/lookups => { type:food_court, name: FoodCourt, value:'{0 or 1}' } + +/* Customer Types in lookups */ +1) settings/lookups => { type:customer_type, name: Dinein, value:Dinein } +2) settings/lookups => { type:customer_type, name: Takeaway, value: Takeaway } +3) settings/lookups => { type:customer_type, name: Doemal, value: Doemal } +4) settings/lookups => { type:customer_type, name: FoodCourt, value: FoodCourt } +/* Tax Profile Group Types in lookups */ + * ToDo list 1. Migration diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index acca225a..72ff4733 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -64,16 +64,19 @@ $(document).on('turbolinks:load', function() { for (i = 0; i < list.length; i++) { table_id.push(list[i].value); } - $('#table_id').val(table_id); + console.log(table_id) + $('#table').val(table_id); oqs_id = $("#oqs_id").val(); - if (table_id){ + status = $("#status").val(); + + if (table_id.length>0){ var table = table_id }else{ var table = null } - if (oqs_id > 0) { + if (oqs_id > 0 || status != "All" || table != null) { $(".oqs_click").removeClass('oqs_active'); $(".queue_station").removeClass('queue_station_box'); $("#completed").addClass('hide'); @@ -83,8 +86,8 @@ $(document).on('turbolinks:load', function() { // oqs_id = $(this).find(".oqs-id").text(); $("#oqs_active").attr('data-id',oqs_id); var url = 'oqs/get_items/'+oqs_id; - - show_details(url,table); + + show_details(url,table,status); }else{ $("#completed").removeClass('hide') $(".oqs_append").addClass('hide') @@ -94,6 +97,7 @@ $(document).on('turbolinks:load', function() { // $(".oqs_click").on("click", function(){ $(document).on('click', '.oqs_click', function(event){ oqs_id = $(this).val(); + status = $("#status").val(); var table_id = $('#table_id').val(); if (table_id){ var table = table_id @@ -101,7 +105,7 @@ $(document).on('turbolinks:load', function() { var table = null } - if (oqs_id > 0) { + if (oqs_id > 0 || status != "All" || table_id != null) { $(".oqs_click").removeClass('oqs_active'); $(".queue_station").removeClass('queue_station_box'); $("#completed").addClass('hide'); @@ -112,16 +116,45 @@ $(document).on('turbolinks:load', function() { $("#oqs_active").attr('data-id',oqs_id); var url = 'oqs/get_items/'+oqs_id; - show_details(url,table); + show_details(url,table,status); + }else{ + $("#completed").removeClass('hide') + $(".oqs_append").addClass('hide') + } + }); //End Click + + // $(".oqs_click").on("click", function(){ + $(document).on('click', '.status_click', function(event){ + oqs_id = $("#oqs_id").val(); + status = $(this).val(); + var table_id = $('#table_id').val(); + if (table_id){ + var table = table_id + }else{ + var table = null + } + + if (oqs_id > 0 || status != "All" || table != null) { + $(".oqs_click").removeClass('oqs_active'); + $(".queue_station").removeClass('queue_station_box'); + $("#completed").addClass('hide'); + $(".oqs_append").removeClass('hide'); + $("#oqs_active").addClass('oqs_active'); + $(".queue_station").addClass('queue_station_box'); + // oqs_id = $(this).find(".oqs-id").text(); + $("#oqs_active").attr('data-id',oqs_id); + var url = 'oqs/get_items/'+oqs_id; + + show_details(url,table,status); }else{ $("#completed").removeClass('hide') $(".oqs_append").addClass('hide') } - }); //End Click - function show_details(url,table_id){ + function show_details(url,table_id,status){ + console.log(table_id) var oqs_append = $('.oqs_append'); oqs_append.empty(); var filter = $('.filter').text(); @@ -130,7 +163,7 @@ $(document).on('turbolinks:load', function() { $.ajax({ type: "GET", url: url, - data: {'filter':filter,'table_id':table_id}, + data: {'filter':filter,'table_id':table_id,'status':status}, dataType: "json", success: function(data) { for(var field in data) { @@ -162,6 +195,10 @@ $(document).on('turbolinks:load', function() { table_type = "No Table" } + var delivery_status = '' + if (data[field]["delivery_status"] == true) { + delivery_status = "hidden" + } row ='
' +'
' @@ -191,9 +228,11 @@ $(document).on('turbolinks:load', function() { +' ' +'
' - +''; @@ -365,7 +404,9 @@ $(document).on('turbolinks:load', function() { success: function(result){ // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); @@ -389,7 +430,9 @@ $(document).on('turbolinks:load', function() { success: function(result){ // For Server Print - from jade if ($("#server_mode").val() == "cloud") { - code2lab.printFile(result.filepath.substr(6), result.printer_url); + if(typeof code2lab != 'undefined'){ + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } } location.reload(); } diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index d7c176ab..1c6acf1b 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -2,7 +2,7 @@ $(function() { var role = $('#role').val(); var second_display_lookup = $("#display_type"); console.log(second_display_lookup) - type = window.location.href.indexOf("quick_service"); + type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court"); modify_order = window.location.href.indexOf("modify_order"); //click menu sidebar menu category @@ -146,7 +146,7 @@ $(function() { } }else{ - type = window.location.href.indexOf("quick_service"); + type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court"); modify_order = window.location.href.indexOf("modify_order"); if (type != -1 && modify_order != -1) { @@ -155,7 +155,7 @@ $(function() { url_item = 'addorders/'+url_item; } if (type ==-1 && modify_order == -1){ - url_item = url_item + url_item = url_item; } //Start Ajax @@ -241,7 +241,7 @@ $(function() { } } }else{ - type = window.location.href.indexOf("quick_service"); + type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court"); modify_order = window.location.href.indexOf("modify_order"); if (type != -1 && modify_order != -1) { url = '../../../addorders/get_item_instance/'+value[i]["id"]; @@ -848,17 +848,18 @@ $(function() { $(this).attr('disabled', 'disabled'); e.preventDefault(); $("#oqs_loading_wrapper").show(); - + var cashier_type = $("#link_type").val(); quick_service = window.location.href.indexOf("quick_service"); - if (quick_service != -1) { - type = 'quick_service' + food_court = window.location.href.indexOf("food_court"); + if (quick_service != -1 || food_court != -1) { + type = cashier_type; var table_type = $('#table_type').text(); var table_id = $('#table_id').val(); var customer_id = $('#customer_id').val(); var booking_id = $('#booking_id').text(); var ajax_url = 'addorders/create'; }else{ - type = 'cashier' + type = 'cashier'; var table_type = $('#table_type').text(); var table_id = $('#table_id').text(); var customer_id = $('#customer_id').text(); @@ -886,14 +887,14 @@ $(function() { data: params, dataType: "json", success:function(result){ - if (type == "quick_service") { - window.location.href = "/origami/quick_service" + if (type == "quick_service" || type=="food_court") { + window.location.href = "/origami/"+type; }else{ if(table_type == "Table"){ - window.location.href = "/origami/table/" + table_id + window.location.href = "/origami/table/" + table_id; } else { - window.location.href = "/origami/room/" + table_id + window.location.href = "/origami/room/" + table_id; } } if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){ @@ -914,11 +915,11 @@ $(function() { $("#create_pay_order").on('click', function(e){ $(this).attr('disabled', 'disabled'); e.preventDefault(); - type = "quick_service" + type = $("#link_type").val(); modify_order = window.location.href.indexOf("modify_order"); $("#oqs_loading_wrapper").show(); if (modify_order !=-1) { - var ajax_url = '../../../quick_service/update_modify_order'; + var ajax_url = '../../../'+type+'/update_modify_order'; var table_type = $('#table_type').text(); var table_id = $('#table_id').text(); var customer_id = $('#customer_id').text(); @@ -962,13 +963,13 @@ $(function() { confirmButtonText: "Ok", closeOnConfirm: false }, function () { - window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text(); + window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text(); }); }else if(result.data == 'OK'){ - window.location.href = '/origami/quick_service/pending_order/' + $('#sale_id').text(); + window.location.href = '/origami/'+type+'/pending_order/' + $('#sale_id').text(); }else{ - window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment" + window.location.href = "/origami/sale/"+result.data["sale_id"]+"/"+type+"/payment"; } } } @@ -1096,13 +1097,14 @@ $(function() { $("#back").on("click", function(){ var table_id = $('#table_id').text(); var table_type = $('#table_type').text(); - type = window.location.href.includes("quick_service"); + var cashier_type = $("#link_type").val(); + type = window.location.href.includes("quick_service") || window.location.href.includes("food_court"); if (type == true) { var table_type = $('#table_id').find("option:selected").data('type'); var table_id = $('#table_id').val(); if(window.location.href.includes("modify_order")){ var link_url = window.location.href.split("/"); - window.location.href = "/origami/quick_service/pending_order/"+link_url[link_url.length - 1]; + window.location.href = "/origami/"+cashier_type+"/pending_order/"+link_url[link_url.length - 1]; }else{ window.location.href = "/origami/dashboard"; } diff --git a/app/assets/javascripts/channels/bill.js b/app/assets/javascripts/channels/bill.js index 278e3d41..f551c103 100755 --- a/app/assets/javascripts/channels/bill.js +++ b/app/assets/javascripts/channels/bill.js @@ -9,16 +9,18 @@ App.order = App.cable.subscriptions.create('BillChannel', { var hostname = location.hostname.trim(); if(data.from == "" || hostname == data.from) { - if($('.table_'+data.table.id).hasClass('blue')){ - $('.table_'+data.table.id).removeClass('blue'); - $('.table_'+data.table.id).removeClass('green'); - $('.table_'+data.table.id).addClass('red'); - }else{ - $('.table_'+data.table.id).removeClass('orange'); - $('.table_'+data.table.id).addClass('red'); - } - $('.new_text_'+data.table.id).removeClass('hide'); - $('.new_text_'+data.table.id).text('billed'); + if(data.table != undefined && data.table != null && data.table!=""){ + if($('.table_'+data.table.id).hasClass('blue')){ + $('.table_'+data.table.id).removeClass('blue'); + $('.table_'+data.table.id).removeClass('green'); + $('.table_'+data.table.id).addClass('red'); + }else{ + $('.table_'+data.table.id).removeClass('orange'); + $('.table_'+data.table.id).addClass('red'); + } + $('.new_text_'+data.table.id).removeClass('hide'); + $('.new_text_'+data.table.id).text('billed'); + } } } }); diff --git a/app/assets/javascripts/channels/order_queue_station.js b/app/assets/javascripts/channels/order_queue_station.js index ccb3b0d3..c17ca42c 100755 --- a/app/assets/javascripts/channels/order_queue_station.js +++ b/app/assets/javascripts/channels/order_queue_station.js @@ -68,8 +68,8 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann +'
' +'' +''; $('.oqs_append').append(row); diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js index 33316a31..6aeace1e 100644 --- a/app/assets/javascripts/custom.js +++ b/app/assets/javascripts/custom.js @@ -101,6 +101,36 @@ $(document).ready(function() { railBorderRadius: '0', touchScrollStep : 50 }); + + $('#make-reservation-slimscroll').slimScroll({ + height: height-$('#make-reservation-slimscroll').attr('data-height'), + size: '5px', + color: 'rgba(0,0,0,0.5)', + alwaysVisible: false, + borderRadius: '0', + railBorderRadius: '0', + touchScrollStep : 50 + }); + + $('#process-reservation-slimscroll').slimScroll({ + height: height-$('#process-reservation-slimscroll').attr('data-height'), + size: '5px', + color: 'rgba(0,0,0,0.5)', + alwaysVisible: false, + borderRadius: '0', + railBorderRadius: '0', + touchScrollStep : 50 + }); + + $('#reservation-info-slimscroll').slimScroll({ + height: height-$('#reservation-info-slimscroll').attr('data-height'), + size: '5px', + color: 'rgba(0,0,0,0.5)', + alwaysVisible: false, + borderRadius: '0', + railBorderRadius: '0', + touchScrollStep : 50 + }); // $('.delete').click(function(){ // var method = $(this).attr('data-method'); // var url = $(this).attr('data-ref'); @@ -198,6 +228,7 @@ function getOnlineOrderCount(){ url: "/origami/get_order_info", dataType: "json", success: function(data){ + console.log(data); if(parseInt(data) > 0){ count = parseInt(data); } diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js index bffd65fb..00d04f89 100644 --- a/app/assets/javascripts/order_reservation.js +++ b/app/assets/javascripts/order_reservation.js @@ -8,6 +8,9 @@ $(function() { $(".tbl_customer").hide(); $(".order_close_cashier").hide(); $(".order_payment_type").hide(); + $(".accepted_time").hide(); + $(".kitchen_time").hide(); + $(".ready_time").hide(); $(function() { $('.first-1').click(); }); @@ -290,7 +293,36 @@ function show_order_detail(url,sr_no){ var delivery = data["delivery"]; var items = data["order_items"]; var item_list = $('.summary-items'); + var action_times = ""; + $("#accepted_time").html(""); + $("#send_kitchen_time").html(""); + $("#ready_delivery_time").html(""); + if((data["action_times"]!=undefined) && (data["action_times"]!=null)){ + action_times = JSON.parse(data["action_times"]); + if((action_times.accepted_time!=undefined) && (action_times.accepted_time!="")){ + $(".accepted_time").show(); + var acceptedDate = new Date(action_times.accepted_time); + var acceptedTime = timeFormat(acceptedDate); + var accepted_time = getOrderMonth(acceptedDate.getMonth()) +' '+ (acceptedDate.getDate() >= 10? acceptedDate.getDate() : '0' + acceptedDate.getDate()) +', '+acceptedDate.getFullYear()+'('+getOrderDay(acceptedDate.getDay())+')'+' '+acceptedTime; + $("#accepted_time").html(accepted_time); + } + if((action_times.kitchen_time!=undefined) && (action_times.kitchen_time!="")){ + $(".kitchen_time").show(); + var kitchenDate = new Date(action_times.kitchen_time); + var kitchenTime = timeFormat(kitchenDate); + var kitchen_time = getOrderMonth(kitchenDate.getMonth()) +' '+ (kitchenDate.getDate() >= 10? kitchenDate.getDate() : '0' + kitchenDate.getDate()) +', '+kitchenDate.getFullYear()+'('+getOrderDay(kitchenDate.getDay())+')'+' '+kitchenTime; + $("#send_kitchen_time").html(kitchen_time); + } + if((action_times.ready_time!=undefined) && (action_times.ready_time!="")){ + $(".ready_time").show(); + var readyDate = new Date(action_times.ready_time); + var readyTime = timeFormat(readyDate); + var ready_time = getOrderMonth(readyDate.getMonth()) +' '+ (readyDate.getDate() >= 10? readyDate.getDate() : '0' + readyDate.getDate()) +', '+readyDate.getFullYear()+'('+getOrderDay(readyDate.getDay())+')'+' '+readyTime; + $("#ready_delivery_time").html(ready_time); + } + } + var newDate = new Date(data.requested_time); var time = timeFormat(newDate); // var requested_date = newDate.getFullYear() + '-' + (newDate.getMonth() >= 10? newDate.getMonth() : '0' + (newDate.getMonth() + 1)) +'-'+ (newDate.getDate() >= 10? newDate.getDate() : '0' + newDate.getDate()) +' '+time; diff --git a/app/assets/javascripts/reservation.js b/app/assets/javascripts/reservation.js new file mode 100644 index 00000000..0dea213e --- /dev/null +++ b/app/assets/javascripts/reservation.js @@ -0,0 +1,64 @@ +//= require custom.js + +$(function(){ + $(".room_type").hide(); + /*new customer UI func:*/ + //Initialize tooltips + $('.nav-tabs > li a[title]').tooltip(); + + //Wizard + $('a[data-toggle="tab"]').on('show.bs.tab', function (e) { + + var $target = $(e.target); + + if ($target.parent().hasClass('disabled')) { + return false; + } + }); + + $(".next-step").click(function (e) { + var $active = $('.wizard .nav-tabs li a.active'); + $active.parent().next().removeClass('disabled'); + nextTab($active); + $('.wizard .nav-tabs li.active .connecting-line').css({"border-bottom-left-radius": 0, "border-top-left-radius": 0}); + }); + + $(".prev-step").click(function (e) { + + var $active = $('.wizard .nav-tabs li a.active'); + prevTab($active); + + }); + /*new customer UI func:*/ + + $(".reservation_type").on("click", function(){ + if($(this).val() == "Dine-in"){ + $(".dining_type").show(); + $(".room_type").hide(); + }else{ + $(".dining_type").hide(); + $(".room_type").show(); + } + }); + + $(".number_limit").on("click", function(){ + if(parseInt($(this).val()) <= 0){ + if($(this).attr("data-type") == "room"){ + $("#room_count").val(1); + }else if($(this).attr("data-type") == "adult"){ + $("#adult_count").val(1); + }else{ + $("#child_count").val(1); + } + } + }); +}); + +/*customer UI tab btn*/ +function nextTab(elem) { + $(elem).parent().next().find('a[data-toggle="tab"]').click(); +} +function prevTab(elem) { + $(elem).parent().prev().find('a[data-toggle="tab"]').click(); +} +/*customer UI tab btn*/ \ No newline at end of file diff --git a/app/assets/stylesheets/CRM.scss b/app/assets/stylesheets/CRM.scss index 5bfab409..de416831 100755 --- a/app/assets/stylesheets/CRM.scss +++ b/app/assets/stylesheets/CRM.scss @@ -157,4 +157,115 @@ nav.pagination .page a:hover, i.logout_icon{ position: relative; top: 5px; -} \ No newline at end of file +} + +/*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: 105%; + 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; + } + .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 */ \ No newline at end of file diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 639a763b..b1718ee2 100755 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -107,4 +107,21 @@ i.logout_icon{ .float_right{ float : right; +} + +.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; +} + +.payment-btn-box { + width: 130px; + height: 50px; } \ No newline at end of file diff --git a/app/assets/stylesheets/login.scss b/app/assets/stylesheets/login.scss index a1058d25..f156d4d3 100755 --- a/app/assets/stylesheets/login.scss +++ b/app/assets/stylesheets/login.scss @@ -82,19 +82,24 @@ } .p-card{ - margin: 20px 0; + margin: 20px -8px; text-align: center; } .p-name{ + padding-left: 6px; + padding-right: 6px; padding-bottom: 20px; font-size: 14px; + weight : 30px; + height : 48px; } .style_image{ - height : 138px; + height : 137.5px; padding : 20px 0 20px 0; width : 70%; + opacity: 0.7; } .style_icon{ @@ -108,4 +113,8 @@ font-size: 21px; font-weight: bold; margin : 0 0 20px 0; +} + +.box { + margin : 0 -60px 0 -60px; } \ No newline at end of file diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 6d784645..2558d846 100755 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -524,4 +524,138 @@ nav.pagination .page a:hover, 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; } \ No newline at end of file diff --git a/app/assets/stylesheets/reservation.scss b/app/assets/stylesheets/reservation.scss new file mode 100644 index 00000000..6cc72696 --- /dev/null +++ b/app/assets/stylesheets/reservation.scss @@ -0,0 +1,110 @@ +/*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 80px !important; + } + .connecting-line{ + height:12px; + background: #e0e0e0; + position: absolute; + width: 115%; + 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; + } + .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 */ \ No newline at end of file diff --git a/app/assets/stylesheets/reset.css b/app/assets/stylesheets/reset.css index 1326a293..35b88ab8 100644 --- a/app/assets/stylesheets/reset.css +++ b/app/assets/stylesheets/reset.css @@ -286,13 +286,13 @@ section.content { /* shop name margin */ .shop-name-margin { - margin-left : 20%; + margin-left : 10%; } /* shop name margin */ /* online order margin */ .online-order-margin { - margin-left : 22%; + margin-left : 10%; margin-bottom : 9.9999px; } /* online order margin */ diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb index fc05fe20..6ebeda11 100644 --- a/app/controllers/api/order_reserve/order_reservation_controller.rb +++ b/app/controllers/api/order_reserve/order_reservation_controller.rb @@ -118,21 +118,21 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController if status == 'REMOVE' if order_reservation.status == "new" || order_reservation.status == "accepted" - OrderReservation.update_order_reservation(order_reservation_id, nil, "rejected",nil,remark) + OrderReservation.update_order_reservation(order_reservation_id, nil, "rejected",nil,remark, nil, current_login_employee) result = {:status=> true, :message => "rejected" } else result = {:status=> false, :message => "Status :: "+order_reservation.status+" cann't remove!" } end elsif status == 'FOC' if order_reservation.status == "new" || order_reservation.status == "accepted" || order_reservation.status == "send_to_kitchen" - OrderReservation.update_order_reservation(order_reservation_id, nil, nil,nil,reason) + OrderReservation.update_order_reservation(order_reservation_id, nil, 'foc',nil,reason, nil, current_login_employee) result = {:status=> true, :message => "FOC successfully" } else result = {:status=> false, :message => "Status :: "+order_reservation.status+" cann't get FOC!" } end elsif status == 'VOID' - if order_reservation.status == "ready_to_delivery" - OrderReservation.update_order_reservation(order_reservation_id, nil, nil,nil,reason) + if order_reservation.status == "ready_to_delivery" || order_reservation.status == "delivered" + OrderReservation.update_order_reservation(order_reservation_id, nil, 'void',nil,reason, nil, current_login_employee) result = {:status=> true, :message => "VOID successfully" } else result = {:status=> false, :message => "Status :: "+order_reservation.status+" cann't VOID!" } diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index 78864e34..72d621b3 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -3,7 +3,7 @@ module LoginVerification included do before_action :authenticate_session_token - helper_method :current_company, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration + helper_method :current_company,:current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration end #this is base api base controller to need to inherit. @@ -17,6 +17,14 @@ module LoginVerification end end + def current_shop + begin + return Shop.first + rescue + return nil + end + end + def current_login_employee @employee = Employee.find_by_token_session(session[:session_token]) end diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index a64d7af4..cc00984d 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -70,8 +70,8 @@ class Crm::CustomersController < BaseCrmController # GET /crm/customers/1 # GET /crm/customers/1.json def show - @orders = Order.where("customer_id=?", params[:id]) - @sales = Sale.where("customer_id=?", params[:id]) + @orders = Order.where("customer_id=?", params[:id]).limit(20) + @sales = Sale.where("customer_id=?", params[:id]).limit(20) if @orders @order_items = [] @@ -86,6 +86,10 @@ class Crm::CustomersController < BaseCrmController end end + params[:type] = nil + params[:customer_id] = params[:id] + @credit_sales = SalePayment.get_credit_sales(params) + #get customer amount @customer = Customer.find(params[:id]) @response = Customer.get_membership_transactions(@customer) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 0d155b9e..19bfb4a3 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -184,6 +184,15 @@ class HomeController < ApplicationController render :json => {:status=> "Success", :url => root_path }.to_json end + def run_teamviewer + if File.directory?("/opt/teamviewer") + output = IO.popen('/opt/teamviewer/tv_bin/script/teamviewer') + render :json => {:status=> true} + else + render :json => {:status=> false} + end + end + private # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/inventory/inventory_controller.rb b/app/controllers/inventory/inventory_controller.rb index 98a60c4e..d987a59d 100755 --- a/app/controllers/inventory/inventory_controller.rb +++ b/app/controllers/inventory/inventory_controller.rb @@ -1,24 +1,13 @@ class Inventory::InventoryController < BaseInventoryController load_and_authorize_resource def index - least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock' - THEN (SELECT balance FROM stock_journals - WHERE item_code = inventory_definitions.item_code AND remark != 'out of stock' - ORDER BY created_at DESC LIMIT 1) ELSE 0 END) - FROM stock_journals - WHERE stock_journals.item_code = inventory_definitions.item_code - ORDER BY stock_journals.created_at DESC LIMIT 1" - @inventory_definitions = InventoryDefinition.select("inventory_definitions.*, - (CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit, - (CASE WHEN sj.debit IS NULL THEN 0 ELSE sj.debit END) as debit, - (#{least_stock}) as balance") - .joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id") - .group("inventory_definitions.item_code") - .order("balance ASC") + filter = params[:filter] + + @inventory_definitions = InventoryDefinition.get_by_category(filter) end - + def show inventory_definition_id = params[:inventory_definition_id] inventory = InventoryDefinition.find(inventory_definition_id) diff --git a/app/controllers/inventory/inventory_definitions_controller.rb b/app/controllers/inventory/inventory_definitions_controller.rb index 1b0e072e..4491669e 100755 --- a/app/controllers/inventory/inventory_definitions_controller.rb +++ b/app/controllers/inventory/inventory_definitions_controller.rb @@ -14,6 +14,8 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController # GET /inventory_definitions/new def new + @menus = Menu.all + @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') @inventory_definition = InventoryDefinition.new end @@ -24,24 +26,44 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController # POST /inventory_definitions # POST /inventory_definitions.json def create - inventory = InventoryDefinition.find_by_item_code(inventory_definition_params[:item_code]) + inventory = InventoryDefinition.find_by_item_code(params[:item_code]) if inventory.nil? - @inventory_definition = InventoryDefinition.new(inventory_definition_params) + + @inventory_definition = InventoryDefinition.new + @inventory_definition.item_code = params[:item_code] + @inventory_definition.min_order_level = params[:min_order_level] + @inventory_definition.max_stock_level = params[:max_stock_level] + @inventory_definition.save else @inventory_definition = InventoryDefinition.find(inventory.id) - @inventory_definition.min_order_level = inventory_definition_params[:min_order_level] - @inventory_definition.max_stock_level = inventory.max_stock_level.to_i + inventory_definition_params[:max_stock_level].to_i + @inventory_definition.min_order_level = params[:min_order_level] + @inventory_definition.max_stock_level = inventory.max_stock_level.to_i + params[:max_stock_level].to_i end @inventory_definition.created_by = current_user.id - respond_to do |format| - if @inventory_definition.save - format.html { redirect_to inventory_path, notice: 'Inventory definition was successfully created.' } - format.json { render :show, status: :created, location: @inventory_definition } - else - format.html { render :new } - format.json { render json: @inventory_definition.errors, status: :unprocessable_entity } - end + if @inventory_definition.save + result = {:status=> true, :message => "Inventory definition was created successfully",:data=> @inventory_definition} + else + result = {:status=> false, :message => "Inventory definition was created successfully",:data=> @inventory_definition} end + render :json => result.to_json + # inventory = InventoryDefinition.find_by_item_code(inventory_definition_params[:item_code]) + # if inventory.nil? + # @inventory_definition = InventoryDefinition.new(inventory_definition_params) + # else + # @inventory_definition = InventoryDefinition.find(inventory.id) + # @inventory_definition.min_order_level = inventory_definition_params[:min_order_level] + # @inventory_definition.max_stock_level = inventory.max_stock_level.to_i + inventory_definition_params[:max_stock_level].to_i + # end + # @inventory_definition.created_by = current_user.id + # respond_to do |format| + # if @inventory_definition.save + # format.html { redirect_to inventory_path, notice: 'Inventory definition was successfully created.' } + # format.json { render :show, status: :created, location: @inventory_definition } + # else + # format.html { render :new } + # format.json { render json: @inventory_definition.errors, status: :unprocessable_entity } + # end + # end end # PATCH/PUT /inventory_definitions/1 diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb index d5ff6946..b7f7369d 100755 --- a/app/controllers/inventory/stock_checks_controller.rb +++ b/app/controllers/inventory/stock_checks_controller.rb @@ -1,7 +1,15 @@ class Inventory::StockChecksController < BaseInventoryController def index @check = StockCheck.new - @inventory_definitions = InventoryDefinition.active.all + # @inventory_definitions1 = InventoryDefinition.active.all + + @category = InventoryDefinition.select("inventory_definitions.*,"+ + "mc.name as name,mc.id as id ") + .joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" + + " JOIN menu_items mi ON mi.id = mii.menu_item_id" + + " JOIN menu_categories mc ON mc.id = mi.menu_category_id ") + .group("mi.menu_category_id") + .order("mi.menu_category_id desc") end def create @@ -12,7 +20,10 @@ class Inventory::StockChecksController < BaseInventoryController end def show - @check = StockCheck.find(params[:id]) + @check = StockCheck.find(params[:id]) + + @stock_check_items = StockCheckItem.get_items_with_category(params[:id]) + end def save_to_journal @@ -30,7 +41,7 @@ class Inventory::StockChecksController < BaseInventoryController member_info = nil unique_code = 'StockCheckPdf' - shop_details = Shop.find(1) + shop_details = current_shop checker = Employee.find(stockcheck.check_by) print_settings = PrintSetting.find_by_unique_code(unique_code) if !print_settings.nil? @@ -39,10 +50,23 @@ class Inventory::StockChecksController < BaseInventoryController end end + def get_menu_category () + if (params[:id]) + + #Pull this menu + @menu_category = InventoryDefinition.search_by_category(params[:id]) + puts @menu_category.to_json + # puts @menu.menu_items[1].item_attributes.to_json + return @menu_category + else + MenuCategory.current_menu + end + end + #Shop Name in Navbor helper_method :shop_detail def shop_detail - @shop = Shop.first + @shop = current_shop end # before_action :set_stock_check, only: [:show, :edit, :update, :destroy] diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb index c804d65a..acdef9f8 100644 --- a/app/controllers/oqs/edit_controller.rb +++ b/app/controllers/oqs/edit_controller.rb @@ -36,7 +36,7 @@ class Oqs::EditController < BaseOqsController order_item.remark = remarks order_item.save - if ENV["SERVER_MODE"] != "cloud" && order.source == 'cashier' #no print in cloud server + if ENV["SERVER_MODE"] != "cloud" #&& order.source == 'cashier' #no print in cloud server # print assigned_item = AssignedOrderItem.find_by_instance_code_and_order_id(order_item.item_instance_code, order_item.order_id) assigned_items = nil diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index be896f1e..aa06d103 100755 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -13,7 +13,8 @@ class Oqs::HomeController < BaseOqsController @queue_stations = OrderQueueStation.active - @queue_completed_item = completed_order(@filter) + # @queue_completed_item = completed_order(@filter) + @queue_completed_item = all_order(@filter) if !@queue_completed_item.empty? @queue_completed_item.each do |queue_item| if !queue_item.set_menu_items.nil? @@ -114,10 +115,11 @@ class Oqs::HomeController < BaseOqsController oqs_id = params[:id] filter = params[:filter] table_id = params[:table_id] - puts params - puts table_id - puts "sssssssssssss" - items = queue_items_query(false,oqs_id,filter,table_id) + status = params[:status] + + items = queue_items_query(false,oqs_id,filter,table_id,status) +puts "items0" +puts items.to_json if !items.empty? items.each do |item| if !item.set_menu_items.nil? @@ -155,13 +157,20 @@ class Oqs::HomeController < BaseOqsController # Query for OQS with delivery status - def queue_items_query(status,oqs_id=nil,filter,table_id) - if oqs_id == nil - oqs = '' + def queue_items_query(status,oqs_id=nil,filter,table_id,delivery_status) + if oqs_id != "0" + oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' " else - oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' " + oqs = '' end + if delivery_status == "All" + queue_status = '' + elsif delivery_status == "Processed" + queue_status = "and assigned_order_items.delivery_status = true " + else + queue_status = "and assigned_order_items.delivery_status = false " + end if !table_id.empty? tableId = table_id.to_a.map{|h| h}.join(",") table = "and df.id IN (#{tableId})" @@ -175,7 +184,8 @@ class Oqs::HomeController < BaseOqsController df.name as zone, df.type as table_type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, - cus.name as customer_name, odt.created_at") + cus.name as customer_name, odt.created_at, + assigned_order_items.delivery_status") .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id left join orders as od ON od.order_id = assigned_order_items.order_id @@ -184,7 +194,7 @@ class Oqs::HomeController < BaseOqsController left join booking_orders as bo on bo.order_id = assigned_order_items.order_id left join bookings as bk on bk.booking_id = bo.booking_id left join dining_facilities as df on df.id = bk.dining_facility_id") - .where("assigned_order_items.delivery_status = #{status} AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} #{table}") + .where("assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} #{table} #{queue_status}") query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) .order("assigned_order_items.assigned_order_item_id desc") .group("odt.order_items_id") @@ -193,7 +203,7 @@ class Oqs::HomeController < BaseOqsController # Completed Order def completed_order(filter) - query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, cus.name as customer_name, odt.created_at") + query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, cus.name as customer_name, odt.created_at,assigned_order_items.delivery_status") .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id left join orders as od ON od.order_id = assigned_order_items.order_id @@ -205,8 +215,28 @@ class Oqs::HomeController < BaseOqsController .where("assigned_order_items.delivery_status = true AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'") query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) .group("assigned_order_items.order_id") - .limit(20) - .order("assigned_order_items.created_at") + .limit(50) + .order("assigned_order_items.created_at desc") + + + # completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true'); + end + + # all Order + def all_order(filter) + query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, odt.set_menu_items, cus.name as customer_name, odt.created_at,assigned_order_items.delivery_status") + .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id + left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id + left join orders as od ON od.order_id = assigned_order_items.order_id + left join order_items as odt ON odt.item_instance_code = assigned_order_items.instance_code AND odt.order_id = assigned_order_items.order_id + left join customers as cus ON cus.customer_id = od.customer_id + left join booking_orders as bo on bo.order_id = assigned_order_items.order_id + left join bookings as bk on bk.booking_id = bo.booking_id + left join dining_facilities as df on df.id = bk.dining_facility_id") + .where("assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'") + query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) + .group("odt.order_items_id") + .order("assigned_order_items.created_at desc") # completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true'); diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 025da23c..35d2a534 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -14,6 +14,7 @@ class Origami::AddordersController < BaseOrigamiController end def detail + @cashier_type = params[:type] @webview = false if check_mobile @webview = true @@ -194,7 +195,7 @@ class Origami::AddordersController < BaseOrigamiController end - if params[:order_source] != "quick_service" + if params[:order_source] != "quick_service" && params[:order_source] != "food_court" process_order_queue(@order.order_id,@order.table_id,@order.source) end end @@ -202,13 +203,16 @@ class Origami::AddordersController < BaseOrigamiController # Order.send_customer_view(@booking) if current_user.role != "waiter" && params[:create_type] == "create_pay" - if @status && @booking && @order.source == 'quick_service' + 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 - from = getCloudDomain #get sub domain in cloud mode - ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from - #end + 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 } render :json => result.to_json end diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb index 6a885f7b..05faf4f7 100755 --- a/app/controllers/origami/credit_payments_controller.rb +++ b/app/controllers/origami/credit_payments_controller.rb @@ -48,4 +48,30 @@ class Origami::CreditPaymentsController < BaseOrigamiController end end + def create_credit_payment + arr_sale = JSON.parse(params[:data]) + if !ShiftSale.current_shift.nil? + if !arr_sale.nil? + arr_sale.each do |arr_sale| + arr_sale.each do |sale| + if(Sale.exists?(sale[0])) + saleObj = Sale.find(sale[0]) + remark = "credit note payment for Receipt No #{saleObj.receipt_no}" + sale_payment = SalePayment.new + @status, @sale = sale_payment.process_payment(saleObj, current_user, sale[1], "cash", remark, true) + end + end + end + end + if @status + render :json => {status: true} + else + render :json => {status: false, message: 'Some error occurred!'} + end + else + render :json => {status: false, message: 'No current shift open for this employee!'} + end + + end + end diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 0eee0400..94f4f1ea 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -76,7 +76,6 @@ class Origami::CustomersController < BaseOrigamiController filter = params[:filter] if filter.nil? - puts params[:page] @crm_customers = Customer.order("customer_id") #.page(params[:page]) #@products = Product.order("name").page(params[:page]).per(5) else diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index b9910803..08557cd6 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -59,6 +59,16 @@ class Origami::DashboardController < BaseOrigamiController if !quick_service[0].nil? @quick_service = quick_service[0][1] end + + #fourt court + food_court = Lookup.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.collection_of('order_reservation') @order_reservation = 0 @@ -80,6 +90,17 @@ class Origami::DashboardController < BaseOrigamiController end end end + + #reservation + reservation = Lookup.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 diff --git a/app/controllers/origami/dinga_controller.rb b/app/controllers/origami/dinga_controller.rb index be35a5c1..01e35004 100644 --- a/app/controllers/origami/dinga_controller.rb +++ b/app/controllers/origami/dinga_controller.rb @@ -7,13 +7,13 @@ class Origami::DingaController < BaseOrigamiController @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 + 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 @@ -35,12 +35,13 @@ class Origami::DingaController < BaseOrigamiController if !@membership_id.nil? membership_setting = MembershipSetting.find_by_membership_type("paypar_url") if membership_setting.gateway_url - member_actions =MembershipAction.find_by_membership_type("get_account_balance") - if member_actions.gateway_url + # payment_data =MembershipAction.find_by_membership_type("get_account_balance") + payment_data = PaymentMethodSetting.find_by_payment_method("DINGA") + if payment_data.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 + url = membership_setting.gateway_url.to_s + payment_data.gateway_url.to_s + merchant_uid= payment_data.merchant_account_id + auth_token = payment_data.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"] diff --git a/app/controllers/origami/food_court_controller.rb b/app/controllers/origami/food_court_controller.rb new file mode 100644 index 00000000..857da01f --- /dev/null +++ b/app/controllers/origami/food_court_controller.rb @@ -0,0 +1,262 @@ +class Origami::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 + @customer = Customer.all + @tables = Table.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') + @cashier_type = "food_court" + #checked quick_service only + @quick_service_only = true + lookup_dine_in = Lookup.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 "origami/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 = params[:sale_id] + + if @booking + @booking_id = @booking.booking_id + @order_items = Array.new + @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 + order.order_items.each do |item| + @order_items.push(item) + end + end + end + else + @booking = nil + end + render "origami/addorders/detail" + end + + def update_modify_order + Rails.logger.debug "Order Source - " + params[:order_source].to_s + Rails.logger.debug "Table ID - " + params[:table_id].to_s + 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.new_booking = true + @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 + + #Create Table Booking or Room Booking + if !params["booking_id"].nil? + # check booking id is already completed. + booking = Booking.find(params[:booking_id]) + if params[:table_id].to_i > 0 + table_status = booking.dining_facility_id.to_i == params[:table_id].to_i + else + table_status = true + end + if booking + if table_status && booking.booking_status != 'moved' + if !booking.sale_id.nil? + sale_status = check_order_with_booking(booking) + if sale_status + return return_json_status_with_code(400, "bill requested") + end + else + @order.new_booking = false + @order.booking_id = params[:booking_id] + end + else + if params[:table_id].to_i > 0 + sale_status = check_order_with_table(params[:table_id]) + if sale_status + return return_json_status_with_code(400, "bill requested") + end + end + end + end #booking exists + else + if params[:table_id].to_i > 0 + sale_status = check_order_with_table(params[:table_id]) + if sale_status + # return false , @message = "bill requested" + return return_json_status_with_code(400, "bill requested") + end + end + end + + @status, @booking = @order.generate + if(params[:sale_id][0,3] == "SAL") + if @status && @booking && (@order.source == 'quick_service' || @order.source == 'food_court') + if params[:sale_id] + @sale = Sale.find(params[:sale_id]) + if @order.table_id.to_i > 0 + @table_id = @order.table_id + else + @table_id = nil + end + update = Sale.add_to_existing_pending_invoice(@table_id,params[:sale_id],@booking) + end + + result = {:status=> true, :data => @sale } + render :json => result.to_json + end + elsif (params[:sale_id][0,3] == "BKI") + result = {:status=> true, :data => 'OK' } + render :json => result.to_json + else + result = {:status=> true, :data => nil } + render :json => result.to_json + 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.all + 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 + + def check_user + if current_user.nil? + redirect_to root_path + 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/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index f4f993d5..81f38324 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -97,7 +97,7 @@ class Origami::OrderReservationController < BaseOrigamiController end def get_order_info - order_reservation = OrderReservation.where("status = 'new' OR status='accepted' OR status='send_to_kitchen' OR status = 'ready_to_delivery'").count() + order_reservation = OrderReservation.where("status = 'new'").count() render :json => order_reservation end diff --git a/app/controllers/origami/paymal_controller.rb b/app/controllers/origami/paymal_controller.rb index 911d5a24..36c19327 100644 --- a/app/controllers/origami/paymal_controller.rb +++ b/app/controllers/origami/paymal_controller.rb @@ -1,68 +1,66 @@ class Origami::PaymalController < BaseOrigamiController 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 + @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 + @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("paypar_url") + if membership_setting.gateway_url + member_actions =MembershipAction.find_by_membership_type("get_account_balance") + 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 - others = others + sale_payment.payment_amount + @out =false,0 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("paypar_url") - if membership_setting.gateway_url - member_actions =MembershipAction.find_by_membership_type("get_account_balance") - 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 + 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 else @out = false, 0 end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 304e0d90..bade57a0 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -91,7 +91,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil) result = { :filepath => filename, @@ -234,6 +234,9 @@ class Origami::PaymentsController < BaseOrigamiController 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 = SaleAudit.getCardBalanceAmount(sale_id) # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) @@ -243,7 +246,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,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount) 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}) @@ -255,13 +258,21 @@ class Origami::PaymentsController < BaseOrigamiController def show path = request.fullpath sale_id = params[:sale_id] - @cashier_type = params[:type] + @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(1) - + @membership_rebate_balance=0 + if Sale.exists?(sale_id) @cash = 0.0 @other = 0.0 @@ -389,6 +400,8 @@ class Origami::PaymentsController < BaseOrigamiController #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) @@ -517,6 +530,10 @@ class Origami::PaymentsController < BaseOrigamiController 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 = SaleAudit.getCardBalanceAmount(sale_id) + # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) @@ -526,7 +543,7 @@ class Origami::PaymentsController < BaseOrigamiController 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,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) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,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) result = { :status => true, @@ -612,7 +629,7 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "FOC",nil,nil,other_amount,nil,nil) result = { :status => true, :filepath => filename, diff --git a/app/controllers/origami/pending_order_controller.rb b/app/controllers/origami/pending_order_controller.rb index f66c4017..20b3f6f7 100644 --- a/app/controllers/origami/pending_order_controller.rb +++ b/app/controllers/origami/pending_order_controller.rb @@ -2,17 +2,21 @@ class Origami::PendingOrderController < BaseOrigamiController def index # @dining= DiningFacility.where("status = 'occupied'") # @order = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status = 'billed' and source = 'quick_service'",DateTime.now.strftime('%Y-%m-%d')) - @sale = Sale.pending_sale - @order = Sale.pending_order - @completed = Sale.completed_sale("quick_service") + @cashier_type = params[:type] + @sale = Sale.pending_sale(@cashier_type) + @order = Sale.pending_order(@cashier_type) + @completed = Sale.completed_sale(@cashier_type) @customers = Customer.pluck("customer_id, name") @occupied_table = @sale.count.length + @order.count.length + end + def show - @sales = Sale.pending_sale - @orders = Sale.pending_order - @completed = Sale.completed_sale("quick_service") + @cashier_type = params[:type] + @sales = Sale.pending_sale(@cashier_type) + @orders = Sale.pending_order(@cashier_type) + @completed = Sale.completed_sale(@cashier_type) @customers = Customer.pluck("customer_id, name") @occupied_table = @sales.count.length + @orders.count.length @@ -51,9 +55,10 @@ class Origami::PendingOrderController < BaseOrigamiController end def completed_sale - @sales = Sale.pending_sale - @orders = Sale.pending_order - @completed = Sale.completed_sale("quick_service") + @cashier_type = params[:type] + @sales = Sale.pending_sale(@cashier_type) + @orders = Sale.pending_order(@cashier_type) + @completed = Sale.completed_sale(@cashier_type) @customers = Customer.pluck("customer_id, name") @occupied_table = @sales.count.length + @orders.count.length @@ -76,16 +81,19 @@ class Origami::PendingOrderController < BaseOrigamiController end def cash_ins + @cashier_type = params[:type] render "origami/cash_ins/new" end def cash_outs + @cashier_type = params[:type] render "origami/cash_outs/new" end def credit_sale - @sales = Sale.pending_sale - @orders = Sale.pending_order - @completed = Sale.completed_sale("quick_service") + @cashier_type = params[:type] + @sales = Sale.pending_sale(@cashier_type) + @orders = Sale.pending_order(@cashier_type) + @completed = Sale.completed_sale(@cashier_type) @occupied_table = @sales.count.length + @orders.count.length diff --git a/app/controllers/origami/quick_service_controller.rb b/app/controllers/origami/quick_service_controller.rb index 86433417..85d09486 100644 --- a/app/controllers/origami/quick_service_controller.rb +++ b/app/controllers/origami/quick_service_controller.rb @@ -21,10 +21,25 @@ class Origami::QuickServiceController < ApplicationController @customer = Customer.all @tables = Table.all.active.order('status desc') @rooms = Room.all.active.order('status desc') + @cashier_type = "quick_service" + #checked quick_service only + @quick_service_only = true + lookup_dine_in = Lookup.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 "origami/addorders/detail" end def modify_order + @cashier_type = "quick_service" today = DateTime.now day = Date.today.wday # if params[:menu] == "true" @@ -71,6 +86,7 @@ class Origami::QuickServiceController < ApplicationController Rails.logger.debug "Table ID - " + params[:table_id].to_s is_extra_time = false extra_time = '' + @cashier_type = "quick_service" items_arr = [] JSON.parse(params[:order_items]).each { |i| diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index 708f9f8f..c0edf879 100755 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -7,13 +7,13 @@ class Origami::RedeemPaymentsController < BaseOrigamiController sale_data = Sale.find_by_sale_id(@sale_id) @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 + 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 diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 22c8d25c..617e5c35 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -62,10 +62,12 @@ class Origami::RequestBillsController < ApplicationController from = "" end - ActionCable.server.broadcast "bill_channel",table: table, from: from - if order.source == "quick_service" + 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.sale_id } - render :json => result.to_json + render :json => result.to_json else #check checkInOut pdf print check_booking = Booking.find_by_sale_id(@sale_id) diff --git a/app/controllers/origami/reservation_controller.rb b/app/controllers/origami/reservation_controller.rb new file mode 100644 index 00000000..91ce359f --- /dev/null +++ b/app/controllers/origami/reservation_controller.rb @@ -0,0 +1,45 @@ +class Origami::ReservationController < BaseOrigamiController + + def index + @reservations = Reservation.all + end + + def show + end + + def new + end + + def edit + end + + def create + + end + + def update + + end + + # DELETE /crm/customers/1 + # DELETE /crm/customers/1.json + def destroy + @reservation.destroy + respond_to do |format| + format.html { redirect_to origami_reservation_url, notice: 'Reservation was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_origami_reservation + @reservation = Reservation.find(params[:reservation_id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def customer_params + + params.require(:reservation).permit(:reservation_id) + end +end diff --git a/app/controllers/origami/surveys_controller.rb b/app/controllers/origami/surveys_controller.rb index 31fa6b9d..700159bb 100644 --- a/app/controllers/origami/surveys_controller.rb +++ b/app/controllers/origami/surveys_controller.rb @@ -33,7 +33,7 @@ class Origami::SurveysController < BaseOrigamiController @table_type = @dining_facility.type @receipt_no = nil @grand_total = nil - @survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,"") + @survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil) end end @@ -64,7 +64,7 @@ class Origami::SurveysController < BaseOrigamiController shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil) end - if @type == "quick_service" + if @type == "quick_service" || @type == "food_court" @url = "/origami/sale/"+@sale_id+"/"+@type+"/payment" else @url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id] diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 1e9acafb..59089250 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -109,7 +109,7 @@ class Origami::VoidController < BaseOrigamiController customer= Customer.find(sale.customer_id) #shop detail - shop_details = Shop.find(1) + shop_details = current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate @@ -126,7 +126,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,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) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,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) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/origami/voucher_controller.rb b/app/controllers/origami/voucher_controller.rb index 74b35b3c..e512a48b 100755 --- a/app/controllers/origami/voucher_controller.rb +++ b/app/controllers/origami/voucher_controller.rb @@ -1,7 +1,7 @@ class Origami::VoucherController < BaseOrigamiController def index @sale_id = params[:sale_id] - + @cashier_type = params[:type] # limit voucher_amount sale_data = Sale.find_by_sale_id(@sale_id) total = sale_data.grand_total @@ -37,12 +37,13 @@ class Origami::VoucherController < BaseOrigamiController membership_id = customer_data.membership_id membership_setting = MembershipSetting.find_by_membership_type("paypar_url") if membership_setting.gateway_url - member_actions =MembershipAction.find_by_membership_type("get_account_balance") #need to modify here - if member_actions.gateway_url - campaign_type_id = member_actions.additional_parameter["campaign_type_id"] - 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 + # payment_data =MembershipAction.find_by_membership_type("get_account_balance") #need to modify here + payment_data = PaymentMethodSetting.find_by_payment_method("Voucher") + if payment_data.gateway_url + campaign_type_id = payment_data.additional_parameters["campaign_type_id"] + url = membership_setting.gateway_url.to_s + payment_data.gateway_url.to_s + merchant_uid= payment_data.merchant_account_id + auth_token = payment_data.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 # app_token: token,membership_id:membership_id, diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 6d2bb094..dcd387b6 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -90,7 +90,7 @@ class Origami::WasteSpoileController < BaseOrigamiController customer= Customer.find(sale.customer_id) #shop detail - shop_details = Shop.find(1) + shop_details = current_shop # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate @@ -107,7 +107,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,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, remark,current_balance,nil,other_amount,nil,nil) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/controllers/reports/credit_payment_controller.rb b/app/controllers/reports/credit_payment_controller.rb index ccd2b0b5..7a83474d 100755 --- a/app/controllers/reports/credit_payment_controller.rb +++ b/app/controllers/reports/credit_payment_controller.rb @@ -2,6 +2,7 @@ class Reports::CreditPaymentController < BaseReportController authorize_resource :class => false def index @filter_for_credit = [['All',''],['Paid','paid'],['Unpaid','unpaid']] + @sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]] from, to = get_date_range_from_params @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @@ -18,7 +19,8 @@ authorize_resource :class => false end @filter = params[:filter_check] - @sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter) + @order_source = params[:order_source] + @sale_data = Sale.get_by_shift_sale_credit_payment(@shift_sale_range,@shift,from,to,@filter,@order_source) @from = from @to = to diff --git a/app/controllers/settings/membership_actions_controller.rb b/app/controllers/settings/membership_actions_controller.rb index a41f7ad2..ea8d903b 100755 --- a/app/controllers/settings/membership_actions_controller.rb +++ b/app/controllers/settings/membership_actions_controller.rb @@ -72,6 +72,6 @@ class Settings::MembershipActionsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_membership_action_params - params.require(:membership_action).permit(:membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by) + params.require(:membership_action).permit(:membership_type, :is_active, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id, :created_by,:additional_parameters) end end diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index 65294c81..aad7ae45 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -5,7 +5,7 @@ class Settings::MenusController < ApplicationController # GET /settings/menus # GET /settings/menus.json def index - @settings_menus = Menu.all.page(params[:page]).per(10) + @settings_menus = Menu.unscoped.all.page(params[:page]).per(10) respond_to do |format| format.html format.xlsx @@ -95,8 +95,8 @@ class Settings::MenusController < ApplicationController :header_text => true} # Menu Sheet - wb.add_worksheet(name: menu.name) do |sheet| - sheet.add_row ["Name",menu.name], :style=>title + wb.add_worksheet(name: menu.name,is_ordering: menu.is_ordering) do |sheet| + sheet.add_row ["Name",menu.name,"is_ordering",menu.is_ordering], :style=>title sheet.add_row sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Instance Attribute", "Price", "Is Default", "Image Path"], :style=>header_text diff --git a/app/controllers/settings/payment_method_settings_controller.rb b/app/controllers/settings/payment_method_settings_controller.rb index 2fccfd67..46ad82d4 100755 --- a/app/controllers/settings/payment_method_settings_controller.rb +++ b/app/controllers/settings/payment_method_settings_controller.rb @@ -41,6 +41,7 @@ class Settings::PaymentMethodSettingsController < ApplicationController # PATCH/PUT /settings/payment_method_settings/1 # PATCH/PUT /settings/payment_method_settings/1.json def update + puts settings_payment_method_setting_params respond_to do |format| if @settings_payment_method_setting.update(settings_payment_method_setting_params) format.html { redirect_to settings_payment_method_setting_path(@settings_payment_method_setting), notice: 'Payment method setting was successfully updated.' } diff --git a/app/controllers/settings/shops_controller.rb b/app/controllers/settings/shops_controller.rb index 38c3336c..598e4f9b 100644 --- a/app/controllers/settings/shops_controller.rb +++ b/app/controllers/settings/shops_controller.rb @@ -59,11 +59,11 @@ class Settings::ShopsController < ApplicationController File.delete(delete_path) end end - save_path = Rails.root.join("public/#{Shop.find(1).shop_code}_#{a.original_filename}") + save_path = Rails.root.join("public/#{current_shop.shop_code}_#{a.original_filename}") File.open(save_path, 'wb') do |f| f.write a.read end - audio_name = "#{Shop.find(1).shop_code}_#{a.original_filename}" + audio_name = "#{current_shop.shop_code}_#{a.original_filename}" @settings_shop.display_images.where(:name => "order_audio").destroy_all @display_image = @settings_shop.display_images.create!(:shop_id => @shop.id, :name => "order_audio", :image => audio_name) else diff --git a/app/controllers/transactions/bookings_controller.rb b/app/controllers/transactions/bookings_controller.rb index 63090c9c..f8a74a53 100644 --- a/app/controllers/transactions/bookings_controller.rb +++ b/app/controllers/transactions/bookings_controller.rb @@ -35,7 +35,7 @@ class Transactions::BookingsController < ApplicationController def show @booking = Booking.find(params[:id]) - + @order = nil @order_items = [] @booking.booking_orders.each do |booking_order| @order = Order.find(booking_order.order_id) @@ -53,6 +53,19 @@ class Transactions::BookingsController < ApplicationController end end + def update_status + data = Booking.where("sale_id IS NULL AND booking_status='assign' AND booking_id = ?", params[:booking_id]) + if !data.nil? + booking = Booking.find(params[:booking_id]) + booking.booking_status = 'moved' + booking.save! + + render :json => {:status => true, :message => "Update status successfully."} + else + render :json => {:status => false, :error_message => "Can't update status!"} + end + end + private # Use callbacks to share common setup or constraints between actions. def set_transactions_booking diff --git a/app/controllers/transactions/credit_notes_controller.rb b/app/controllers/transactions/credit_notes_controller.rb index 27f52f12..f7070e8d 100755 --- a/app/controllers/transactions/credit_notes_controller.rb +++ b/app/controllers/transactions/credit_notes_controller.rb @@ -6,27 +6,34 @@ class Transactions::CreditNotesController < ApplicationController # GET /transactions/sales # GET /transactions/sales.json def index - + @sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]] @customers = Customer.all - filter = params[:filter] - customer = params[:customer] - from = params[:from] - to = params[:to] - - if filter.nil? && from.nil? && to.nil? && customer.nil? - @credit_notes = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING) - @credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20) - else - sale = Sale.search_credit_sales(customer,filter,from,to) - if sale.count > 0 - @credit_notes = sale - @credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20) - else - @credit_notes = 0 - end - end + filter = params[:filter] + customer = params[:customer] + from = params[:from] + to = params[:to] + order_source = params[:order_source] + if filter.nil? && from.nil? && to.nil? && customer.nil? && order_source.nil? + @credit_notes = Sale.select("sales.*, orders.source") + .joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id") + .where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount) + FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') + THEN NULL ELSE payment_method='creditnote' END)") + .joins(" JOIN bookings ON bookings.sale_id=sales.sale_id") + .joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") + .joins(" JOIN orders ON orders.order_id=booking_orders.order_id") + @credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20) + else + sale = Sale.search_credit_sales(customer,filter,from,to,order_source) + if !sale.nil? + @credit_notes = sale + @credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20) + else + @credit_notes = 0 + end + end respond_to do |format| format.html # index.html.erb format.json { render json: @credit_notes } diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index c1e58f6f..c93766a5 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -89,7 +89,8 @@ class Transactions::SalesController < ApplicationController # GET /transactions/sales/1 # GET /transactions/sales/1.json def show - + @membership = MembershipSetting::MembershipSetting + @payment_methods = PaymentMethodSetting.where("is_active='1'") @sale = Sale.find(params[:id]) @order_items = [] @@ -363,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,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) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,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) result = { :filepath => filename, :printer_model => print_settings.brand_name, diff --git a/app/models/booking.rb b/app/models/booking.rb index 7e5470d0..46c098b7 100755 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -46,16 +46,18 @@ class Booking < ApplicationRecord if filter.blank? keyword = '' else - keyword = "booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%" + keyword = "booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%" end if from.present? && to.present? - booking = Booking.where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ? and NOT booking_status = 'void' ", from,to) + booking = Booking.joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id") + .where("DATE_FORMAT(bookings.created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(bookings.created_at,'%d-%m-%Y') <= ? and NOT bookings.booking_status = 'void' ", from,to) query = booking.where(keyword) else - where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") + joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id") + .where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") end - + .order("sale_id DESC") end private diff --git a/app/models/customer.rb b/app/models/customer.rb index a88f79c0..55a41722 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -336,7 +336,7 @@ class Customer < ApplicationRecord def self.search(search) if search # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) - where("name LIKE ? OR contact_no LIKE ? OR card_no LIKE ? OR paypar_account_no ='#{search}'", "%#{search}%", "%#{search}%", "%#{search}%",) + where("name LIKE ? OR customer_type OR contact_no LIKE ? OR card_no LIKE ? OR DATE_FORMAT(date_of_birth,'%Y-%m-%d') LIKE ? OR nrc_no LIKE ? OR gender LIKE ? OR paypar_account_no ='#{search}'", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%") else find(:all) end diff --git a/app/models/inventory_definition.rb b/app/models/inventory_definition.rb index 56f726bb..13d295a1 100755 --- a/app/models/inventory_definition.rb +++ b/app/models/inventory_definition.rb @@ -61,4 +61,48 @@ class InventoryDefinition < ApplicationRecord end end end + + def self.search_by_category(cat_id) + @inventory_definitions = InventoryDefinition.select("inventory_definitions.*, + mi.name as item_name,mii.item_instance_name as instance_name," + + "mi.item_code as item_code,mii.item_instance_code as instance_code," + + "mc.name as menu_category_name,mc.id as menu_category_id ") + .joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" + + " JOIN menu_items mi ON mi.id = mii.menu_item_id" + + " JOIN menu_categories mc ON mc.id = mi.menu_category_id ") + .where("mc.id=#{cat_id}") + .group("mi.menu_category_id,inventory_definitions.item_code") + .order("mi.menu_category_id desc") + end + + def self.get_by_category(filter) + least_stock = "SELECT (CASE WHEN stock_journals.remark != 'out of stock' + THEN (SELECT balance FROM stock_journals + WHERE item_code = inventory_definitions.item_code AND remark != 'out of stock' + ORDER BY created_at DESC LIMIT 1) ELSE 0 END) + FROM stock_journals + WHERE stock_journals.item_code = inventory_definitions.item_code + ORDER BY stock_journals.created_at DESC LIMIT 1" + + @inventory_definitions = InventoryDefinition.select("inventory_definitions.*, + (CASE WHEN sj.credit IS NULL THEN 0 ELSE sj.credit END) as credit, + (CASE WHEN sj.debit IS NULL THEN 0 ELSE sj.debit END) as debit, + (#{least_stock}) as balance,"+ + "acc.title as account_name,mi.name as item_name, + mii.item_instance_name as instance_name," + + "mc.name as menu_category_name,mc.id as menu_category_id " + ) + .joins(" LEFT JOIN stock_journals sj ON sj.inventory_definition_id=inventory_definitions.id") + .joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" + + " JOIN menu_items mi ON mi.id = mii.menu_item_id" + + " JOIN menu_categories mc ON mc.id = mi.menu_category_id ") + .joins(" JOIN accounts acc ON acc.id = mi.account_id") + .where("inventory_definitions.item_code LIKE ? OR inventory_definitions.min_order_level LIKE ? + OR inventory_definitions.max_stock_level LIKE ? OR sj.balance LIKE ? OR mi.name LIKE ? + OR mii.item_instance_name LIKE ? OR mc.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%", + "%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") + .group("mi.menu_category_id,inventory_definitions.item_code") + .order("acc.title desc,mi.menu_category_id desc,balance ASC") + end + end diff --git a/app/models/menu.rb b/app/models/menu.rb index ee9414a9..58d540fd 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -91,9 +91,9 @@ class Menu < ApplicationRecord elsif sheet_name == "Menu" menu = Menu.find_by_id(row["id"]) if menu - Menu.create(name: row["name"], is_active: row["is_active"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"]) + Menu.create(name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"]) else - Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"]) + Menu.create(id:row["id"], name: row["name"], is_active: row["is_active"], is_ordering: row["is_ordering"], valid_days: row["valid_days"],valid_time_from: row["valid_time_from"], valid_time_to: row["valid_time_to"], created_by: row["created_by"]) end elsif sheet_name == "Menu Category" # MenuCategory.create(id:row["id"], menu_id: row["menu_id"], code: row["code"], name: row["name"], alt_name: row["alt_name"], order_by: row["order_by"], created_by: row["created_by"], menu_category_id: row["menu_category_id"], is_available: row["is_available"]) @@ -150,7 +150,9 @@ class Menu < ApplicationRecord sheet = spreadsheet.sheet(0) menu = sheet.row(1)[1] - imported_menu = Menu.create({name: menu, is_active: true, valid_days: "1,2,3,4,5,6,7",valid_time_from: "00:00:00", valid_time_to: "23:59:59", created_by: created_by}) + is_ordering = sheet.row(1)[3]?sheet.row(1)[3]:0 + + imported_menu = Menu.create({name: menu, is_active: true, is_ordering: is_ordering, valid_days: "1,2,3,4,5,6,7",valid_time_from: "00:00:00", valid_time_to: "23:59:59", created_by: created_by}) (4..sheet.last_row).each do |ii| row = Hash[[sheet.row(3),sheet.row(ii)].transpose] diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index a275d420..42891015 100755 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -48,7 +48,9 @@ class OrderQueueStation < ApplicationRecord # else if (order_item.qty > 0) - AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs) + if pdf_status.nil? + AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs) + end oqs_order_items.push(order_item) end # end @@ -87,7 +89,9 @@ class OrderQueueStation < ApplicationRecord # else if (order_item.qty > 0) - AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs) + if pdf_status.nil? + AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs) + end oqs_order_items.push(order_item) end # end @@ -233,14 +237,12 @@ class OrderQueueStation < ApplicationRecord print_settings=PrintSetting.find_by_unique_code(unique_code) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="") - - assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id) - AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(print_status: true) - else - move_print_pdf(change_to,current_user,table_id,order_items) + move_print_pdf(change_to,current_user,table_id,order_items,oqs) end - + + assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id) + AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(print_status: true) end #Print order_item in 1 slip per item @@ -277,16 +279,15 @@ class OrderQueueStation < ApplicationRecord order_queue_printer.print_order_item(print_settings, oqs,order_item.order_id, order_item.order_items_id, print_status="" ) end end - - assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id) - AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(print_status: true) else - move_print_pdf(change_to,current_user,table_id,assigned_items) + move_print_pdf(change_to,current_user,table_id,assigned_items,oqs) end + assigned =AssignedOrderItem.where("order_id = '#{ order.order_id }'").pluck(:assigned_order_item_id) + AssignedOrderItem.where('assigned_order_item_id IN (?)', assigned).update_all(print_status: true) end - def move_print_pdf(change_to,current_user,change_from,order_items) + def move_print_pdf(change_to,current_user,change_from,order_items,oqs) if ENV["SERVER_MODE"] != "cloud" #no print in cloud server # get printer info @from = (DiningFacility.find(change_from)).name @@ -296,18 +297,18 @@ class OrderQueueStation < ApplicationRecord @date = DateTime.now @shop = Shop.first unique_code = "MoveTablePdf" - pdf_no = PrintSetting.where(:unique_code => unique_code).count - #print_settings = PrintSetting.find_by_unique_code(unique_code) - printer_array = [] - printer_array = PrintSetting.where(:unique_code => unique_code) + # pdf_no = PrintSetting.where(:unique_code => unique_code).count + print_settings = PrintSetting.find_by_unique_code(unique_code) + # printer_array = [] + # printer_array = PrintSetting.where(:unique_code => unique_code) - for i in 0..pdf_no - if i != pdf_no - print_settings = printer_array[i] + # for i in 0..pdf_no + # if i != pdf_no + # print_settings = printer_array[i] printer = Printer::ReceiptPrinter.new(print_settings) - printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items) - end - end + printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items,oqs) + # end + # end end end end diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 43d0145e..bc7382c3 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -11,7 +11,7 @@ class OrderReservation < ApplicationRecord scope :latest_order, -> { order("order_reservation_id desc, created_at desc") } SEND_TO_KITCHEN = "send_to_kitchen" - READY_TO_DELIVERY = "ready_to_deliver" + READY_TO_DELIVERY = "ready_to_delivery" DELIVERED = "delivered" COMPLETED = "completed" @@ -134,7 +134,7 @@ class OrderReservation < ApplicationRecord #order status send to doemal callback_response = send_status_to_ordering(order.callback_url,order.transaction_ref,SEND_TO_KITCHEN) - #order reservation status updated + # order reservation status updated update_order_reservation(order.id, @sale.sale_id, SEND_TO_KITCHEN) result = {:status=> @status, :data => @sale, :message => "send to kitchen" } @@ -164,8 +164,12 @@ class OrderReservation < ApplicationRecord #end rounding adjustment sale_payment = SalePayment.new - sale_payment.process_payment(saleObj, current_user, saleObj.grand_total, "cash") - + if(order.payment_type == "COD") + sale_payment.process_payment(saleObj, current_user, saleObj.grand_total, "cash") + else + remark = "credit payment for Receipt No #{saleObj.receipt_no}" + @status, @sale = sale_payment.process_payment(saleObj, current_user, saleObj.grand_total, "creditnote", remark) + end #order status send to doemal callback_response = send_status_to_ordering(order.callback_url,order.transaction_ref,DELIVERED) #order reservation status updated @@ -237,6 +241,7 @@ class OrderReservation < ApplicationRecord def self.update_order_reservation(id, sale_id, status, expected_waiting_time=nil, remark=nil, access_code=nil, current_user=nil) order_reservation = OrderReservation.find(id) + action_times = {} if sale_id.present? order_reservation.sale_id = sale_id end @@ -251,12 +256,34 @@ class OrderReservation < ApplicationRecord end if status == "delivered" order_reservation.payment_status = "paid" + elsif status == 'foc' + order_reservation.payment_status = "paid" + elsif status == 'void' + order_reservation.payment_status = "void" end + + if status == "accepted" + action_times = {"accepted_time" => DateTime.now.utc, "kitchen_time" => "", "ready_time" => ""} + order_reservation.action_times = action_times.to_json + elsif status == SEND_TO_KITCHEN + if !order_reservation.action_times.nil? + action_data = JSON.parse(order_reservation.action_times) + action_data["kitchen_time"] = DateTime.now.utc + order_reservation.action_times = action_data.to_json + end + elsif status == READY_TO_DELIVERY + if !order_reservation.action_times.nil? + action_data = JSON.parse(order_reservation.action_times) + action_data["ready_time"] = DateTime.now.utc + order_reservation.action_times = action_data.to_json + end + end + order_reservation.save - # if !order_reservation.sale_id.nil? && status == "rejected" - # void_doemal_payment(order_reservation.sale_id, remark, access_code, current_user) - # end + if !order_reservation.sale_id.nil? && (status == "rejected" || status == "void") + void_doemal_payment(order_reservation.sale_id, remark, access_code, current_user) + end end def self.void_doemal_payment(sale_id, remark, access_code, current_user) @@ -281,11 +308,22 @@ class OrderReservation < ApplicationRecord sale.sale_status = 'void' sale.save - # FOr Sale Audit - action_by = current_user.name + # For Sale Audit + if !current_user.nil? + action_by = current_user.name + else + action_by = "doemal" + end + + approved_name = nil approved_by = Employee.find_by_emp_id(access_code) + + if !approved_by.nil? + approved_name = approved_by.name + end + cashier_name = Employee.where("id=?",sale.cashier_id).name # 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,sale.cashier_id, approved_by.name,remark,"SALEVOID" ) + sale_audit = SaleAudit.record_audit_for_edit(sale_id,cashier_name, approved_name,remark,"SALEVOID" ) # update complete order items in oqs SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr| @@ -386,7 +424,7 @@ class OrderReservation < ApplicationRecord end end - query = OrderReservation.select("order_reservations.*, sales.receipt_date, deliveries.provider, deliveries.delivery_fee, customers.name, customers.email") + query = OrderReservation.select("order_reservations.*, sales.receipt_date, sales.receipt_no, deliveries.provider, deliveries.delivery_fee, customers.name, customers.email") .joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id") .joins(" JOIN customers on customers.customer_id = order_reservations.customer_id") .joins(" JOIN sales on sales.sale_id = order_reservations.sale_id") diff --git a/app/models/payment_method_setting.rb b/app/models/payment_method_setting.rb index 4f1de785..a57e8a4d 100755 --- a/app/models/payment_method_setting.rb +++ b/app/models/payment_method_setting.rb @@ -1,4 +1,4 @@ class PaymentMethodSetting < ApplicationRecord # validations - validates_presence_of :payment_method #, :gateway_communication_type, :gateway_url, :auth_token, :merchant_account_id + validates_presence_of :payment_method , :gateway_communication_type #, :gateway_url, :auth_token, :merchant_account_id end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 607232af..8b7f5d56 100755 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -188,19 +188,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Bill Receipt Print - def print_receipt_bill(printer_settings,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) + def print_receipt_bill(printer_settings,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) #Use CUPS service #Generate PDF #Print - 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) + 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) receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf if !receipt_bill_a5_pdf.empty? 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) + 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) 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) + 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 end end @@ -266,13 +266,22 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker end #Move Table Print - def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by,order_items) + def print_move_table(printer_settings,to,from,shop_detail,date,type,moved_by,order_items,oqs) #Use CUPS service #Generate PDF #Print + pdf = MoveTablePdf.new(printer_settings,to,from,shop_detail,date,type,moved_by,order_items) pdf.render_file "tmp/print_move_table.pdf" - self.print("tmp/print_move_table.pdf") + + if oqs.print_copy + self.print("tmp/print_move_table.pdf",oqs.printer_name) + else + print_settings.print_copies = 1 + print_settings.save! + #no print in cloud server + self.print("tmp/print_move_table.pdf", oqs.printer_name) + end end #Bill Receipt Print diff --git a/app/models/reservation.rb b/app/models/reservation.rb new file mode 100644 index 00000000..4e5ff37a --- /dev/null +++ b/app/models/reservation.rb @@ -0,0 +1,15 @@ +class Reservation < ApplicationRecord + self.primary_key = "reservation_id" + + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id + + has_many :reservation_items + + scope :active, -> { where("created_at BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") } + + private + def generate_custom_id + self.order_reservation_id = SeedGenerator.generate_id(self.class.name, "RS") + end +end diff --git a/app/models/reservation_item.rb b/app/models/reservation_item.rb new file mode 100644 index 00000000..19e28b82 --- /dev/null +++ b/app/models/reservation_item.rb @@ -0,0 +1,13 @@ +class ReservationItem < ApplicationRecord + self.primary_key = "reservation_items_id" + + #primary key - need to be unique + before_create :generate_custom_id + + belongs_to :reservation, autosave: true + + private + def generate_custom_id + self.reservation_items_id = SeedGenerator.generate_id(self.class.name, "RSI") + end +end diff --git a/app/models/sale.rb b/app/models/sale.rb index 779db759..c772516d 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -734,10 +734,10 @@ class Sale < ApplicationRecord where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}' and shift_sale_id = ?","%#{filter}%","%#{filter}%",shift.id) end end - + .order("sale_id DESC") end - def self.search_credit_sales(customer,filter,from,to) + def self.search_credit_sales(customer,filter,from,to,order_source="") if filter.blank? keyword = '' else @@ -750,12 +750,30 @@ class Sale < ApplicationRecord custo = "and customer_id = '#{customer}'" end - if from.present? && to.present? - sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id") - .where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and sp.payment_method = 'creditnote' #{keyword} #{custo}", from,to) + if order_source.blank? + source = "" else - sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id") - .where("sp.payment_method ='creditnote' #{keyword} #{custo}") + if order_source == "cashier" + source = "and orders.source='cashier' or orders.source='emenu'" + else + source = "and orders.source='#{order_source}'" + end + end + + if from.present? && to.present? + sale = Sale.select("sales.*,orders.source").joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id") + .joins(" JOIN bookings ON bookings.sale_id=sales.sale_id") + .joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") + .joins(" JOIN orders ON orders.order_id=booking_orders.order_id") + .where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and (CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount) + FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}", from,to) + else + sale = Sale.select("sales.*,orders.source").joins(" JOIN sale_payments sp on sp.sale_id = sales.sale_id") + .joins(" JOIN bookings ON bookings.sale_id=sales.sale_id") + .joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") + .joins(" JOIN orders ON orders.order_id=booking_orders.order_id") + .where("(CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount) + FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}") end end @@ -1186,7 +1204,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay return query end -def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter) +def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source) sub_query = "SELECT (CASE WHEN SUM(payment_amount) > 0 THEN DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') ELSE '-' END) FROM `sale_payments` @@ -1205,7 +1223,7 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter) FROM shift_sales WHERE shift_sales.id = s.shift_sale_id" - sub_query3 = "SELECT (CASE WHEN shift_closed_at IS NOT NULL AND credit_payment > 0 + sub_query3 = "SELECT (CASE WHEN shift_closed_at IS NOT NULL OR shift_closed_at IS NULL AND credit_payment > 0 THEN employees.name ELSE '-' END) FROM shift_sales INNER JOIN employees ON employees.id=shift_sales.employee_id @@ -1223,10 +1241,19 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter) INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id WHERE sale_audits.sale_id = s.sale_id) = 0" end - + if order_source.blank? + source = "" + else + if order_source == "cashier" + source = "and orders.source='cashier' or orders.source='emenu'" + else + source = "and orders.source='#{order_source}'" + end + end query = SalePayment.select("s.receipt_no, sale_payments.*, SUM(sale_payments.payment_amount) as payment_amount, s.receipt_date as sale_date, + orders.source as order_source, s.cashier_name as cashier_name, (#{sub_query}) as credit_payment_receipt_date, (#{sub_query1}) as credit_payment, @@ -1234,13 +1261,16 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter) (#{sub_query2}) as credit_payment_shift_name") .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") .joins("INNER JOIN shift_sales ss ON ss.id = s.shift_sale_id") + .joins("INNER JOIN bookings ON bookings.sale_id=s.sale_id") + .joins("INNER JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") + .joins("INNER JOIN orders ON orders.order_id=booking_orders.order_id") if shift.present? - query = query.where("sale_payments.payment_method= 'creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?)",shift.to_a) + query = query.where("sale_payments.payment_method= 'creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?) #{source}",shift.to_a) elsif shift_sale_range.present? - query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?)",shift_sale_range.to_a) + query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.shift_sale_id in (?) #{source}",shift_sale_range.to_a) else - query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.receipt_date between ? and ? ",from,to) + query = query.where("sale_payments.payment_method='creditnote' and s.sale_status = 'completed' #{filter_check} and s.receipt_date between ? and ? #{source}",from,to) end query = query.group("s.sale_id") end @@ -2859,25 +2889,30 @@ end end end - def self.pending_sale + def self.pending_sale(type) query = Sale.all query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id") .joins("join orders as orders on orders.order_id = sale_orders.order_id") - query = query.where("sales.sale_status = 'new' AND orders.status = 'billed' AND orders.source =? ","quick_service") + query = query.where("sales.sale_status = 'new' AND orders.status = 'billed' AND orders.source =? ","#{type}") .group("sales.sale_id") end - def self.pending_order + def self.pending_order(type) query = Booking.all query = query.joins("join booking_orders as booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("join orders as orders on orders.order_id = booking_orders.order_id") - query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","quick_service") + query = query.where("bookings.booking_status = 'assign' AND orders.status = 'new' AND orders.source =? ","#{type}") .group("bookings.booking_id") end def self.completed_sale(type) + if type == "cashier" + type = "and orders.source = 'emenu' or orders.source = 'cashier'" + else + type = "and orders.source = '#{type}'" + end query = Sale.all query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id") .joins("join orders as orders on orders.order_id = sale_orders.order_id") - query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' AND orders.source =? ","#{type}") + query = query.where("sales.sale_status != 'new' AND orders.status = 'billed' #{type}") query = query.where("DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ? ",DateTime.now.strftime('%Y-%m-%d')) .group("sales.sale_id") end diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index b28753c4..33be29f1 100755 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -119,8 +119,36 @@ class SaleAudit < ApplicationRecord end - private - def generate_custom_id - self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI") + def self.getCardBalanceAmount(sale_id) + card_balance_amount = 0 + sale_audits = SaleAudit.where("sale_id='#{sale_id}' AND action='PAYMAL'") + if !sale_audits.nil? + sale_audits.each do |sale_audit| + if sale_audit.remark.split('}')[0] + if self.valid_json('['+ sale_audit.remark.split('}')[0] + '}]') + remark = JSON.parse(('['+ sale_audit.remark.split('}')[0] + '}]')) + if remark[0] + if remark[0]["status"] + card_balance_amount = remark[0]["card_balance_amount"] + end + end + end + end + end + end + + return card_balance_amount end + + def self.valid_json(json) + JSON.parse(json) + return true + rescue JSON::ParserError => e + return false + end + + private + def generate_custom_id + self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI") + end end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 97ee07a7..5a0fe2ba 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -169,14 +169,15 @@ class SalePayment < ApplicationRecord end def self.redeem(paypar_url,token,membership_id,received_amount,sale_id) - membership_actions_data = MembershipAction.find_by_membership_type("redeem"); + # membership_actions_data = MembershipAction.find_by_membership_type("redeem"); + membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem") if !membership_actions_data.nil? url = paypar_url.to_s + membership_actions_data.gateway_url.to_s merchant_uid = membership_actions_data.merchant_account_id auth_token = membership_actions_data.auth_token - campaign_type_id = membership_actions_data.additional_parameter["campaign_type_id"] + campaign_type_id = membership_actions_data.additional_parameters["campaign_type_id"] sale_data = Sale.find_by_sale_id(sale_id) if sale_data @@ -227,8 +228,9 @@ class SalePayment < ApplicationRecord end - def self.create_payment(paypar_url,token,membership_id,received_amount,sale_id) - membership_actions_data = MembershipAction.find_by_membership_type("create_payment"); + def self.create_payment(paypar_url,payment_type,membership_id,received_amount,sale_id) + # membership_actions_data = MembershipAction.find_by_membership_type("create_payment"); + membership_actions_data = PaymentMethodSetting.find_by_payment_method(payment_type) sale_data = Sale.find_by_sale_id(sale_id) customer_data = Customer.find_by_customer_id(sale_data.customer_id) if !membership_actions_data.nil? @@ -236,7 +238,6 @@ class SalePayment < ApplicationRecord url = paypar_url.to_s + membership_actions_data.gateway_url.to_s merchant_uid = membership_actions_data.merchant_account_id auth_token = membership_actions_data.auth_token - if sale_data others = 0 @@ -260,7 +261,7 @@ class SalePayment < ApplicationRecord auth_token:auth_token}.to_json end - + puts params # Control for Paypar Cloud begin response = HTTParty.post(url, @@ -457,7 +458,7 @@ class SalePayment < ApplicationRecord # account_no = customer_data.membership_id # end membership_setting = MembershipSetting.find_by_membership_type("paypar_url") - membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,account_no,self.received_amount,self.sale.sale_id) + membership_data = SalePayment.create_payment(membership_setting.gateway_url,"PAYMAL",account_no,self.received_amount,self.sale.sale_id) #record an payment in sale-audit remark = "#{membership_data} PayMal Payment- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} " @@ -507,7 +508,7 @@ class SalePayment < ApplicationRecord # end membership_setting = MembershipSetting.find_by_membership_type("paypar_url") - membership_data = SalePayment.create_payment(membership_setting.gateway_url,membership_setting.auth_token,account_no,self.received_amount,self.sale.sale_id) + membership_data = SalePayment.create_payment(membership_setting.gateway_url,"DINGA",account_no,self.received_amount,self.sale.sale_id) #record an payment in sale-audit remark = "#{membership_data} Dinga Payment- for Customer #{self.sale.customer_id} Sale Id [#{self.sale.sale_id}]| pay amount -> #{self.received_amount} " @@ -876,8 +877,10 @@ class SalePayment < ApplicationRecord .joins("INNER JOIN customers c ON c.customer_id = s.customer_id") .joins("INNER JOIN sale_orders so ON so.sale_id = s.sale_id") .joins("INNER JOIN orders o ON o.order_id = so.order_id") - - if params[:type] == "cashier" + + if params[:type].nil? + query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") + elsif params[:type] == "cashier" query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND o.source='#{params[:type]}' OR o.source='emenu' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") else query = query.where("(CASE WHEN (s.grand_total + s.amount_changed)=(select SUM(payment_amount) FROM sale_payments WHERE sale_id=s.sale_id AND payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' AND o.source='#{params[:type]}' END) and s.sale_status = 'completed' and s.payment_status='paid' #{receipt_no} #{customer}") diff --git a/app/models/stock_check_item.rb b/app/models/stock_check_item.rb index 9db680d2..05ee98a7 100755 --- a/app/models/stock_check_item.rb +++ b/app/models/stock_check_item.rb @@ -43,4 +43,19 @@ class StockCheckItem < ApplicationRecord end transaction end + + def self.get_items_with_category(id) + query = StockCheckItem.select("stock_check_items.*,acc.title as account_name, + mi.name as item_name, + mii.item_instance_name as instance_name," + + "mc.name as menu_category_name,mc.id as menu_category_id ") + .joins("JOIN menu_item_instances mii ON mii.item_instance_code = stock_check_items.item_code" + + " JOIN menu_items mi ON mi.id = mii.menu_item_id" + + " JOIN menu_categories mc ON mc.id = mi.menu_category_id ") + .joins(" JOIN accounts acc ON acc.id = mi.account_id") + .where("stock_check_items.stock_check_id=#{id}") + .group("mi.menu_category_id,stock_check_items.item_code") + .order("acc.title desc,mi.menu_category_id desc") + return query + end end diff --git a/app/pdf/order_item_customise_pdf.rb b/app/pdf/order_item_customise_pdf.rb index dde79917..dcd45ebd 100644 --- a/app/pdf/order_item_customise_pdf.rb +++ b/app/pdf/order_item_customise_pdf.rb @@ -52,6 +52,15 @@ class OrderItemCustomisePdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left @@ -142,4 +151,12 @@ class OrderItemCustomisePdf < Prawn::Document end end + def get_booking_id(order_no) + booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id") + .joins(" JOIN orders o ON o.order_id=bo.order_id") + .where("o.order_id='#{order_no}'") + .first() + + return booking.booking_id + end end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index c3bf566f..086447db 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -50,7 +50,16 @@ class OrderItemPdf < Prawn::Document end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left @@ -141,4 +150,12 @@ class OrderItemPdf < Prawn::Document end end + def get_booking_id(order_no) + booking = Order.joins(" JOIN booking_orders bo ON bo.order_id = orders.order_id") + .joins(" JOIN bookings b ON b.booking_id=bo.booking_id") + .where("orders.order_id='#{order_no}'") + .first() + + return booking.booking_id + end end diff --git a/app/pdf/order_item_slim_customise_pdf.rb b/app/pdf/order_item_slim_customise_pdf.rb index a63900a6..f2a67eb0 100644 --- a/app/pdf/order_item_slim_customise_pdf.rb +++ b/app/pdf/order_item_slim_customise_pdf.rb @@ -52,6 +52,15 @@ class OrderItemSlimCustomisePdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left @@ -141,4 +150,13 @@ class OrderItemSlimCustomisePdf < Prawn::Document end end end + + def get_booking_id(order_no) + booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id") + .joins(" JOIN orders o ON o.order_id=bo.order_id") + .where("o.order_id='#{order_no}'") + .first() + + return booking.booking_id + end end diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb index 92158663..5db7e78a 100755 --- a/app/pdf/order_item_slim_pdf.rb +++ b/app/pdf/order_item_slim_pdf.rb @@ -51,6 +51,15 @@ class OrderItemSlimPdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left @@ -140,4 +149,13 @@ class OrderItemSlimPdf < Prawn::Document end end + def get_booking_id(order_no) + booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id") + .joins(" JOIN orders o ON o.order_id=bo.order_id") + .where("o.order_id='#{order_no}'") + .first() + + return booking.booking_id + end + end diff --git a/app/pdf/order_set_item_customise_pdf.rb b/app/pdf/order_set_item_customise_pdf.rb index 2f985c5f..7cdea13a 100644 --- a/app/pdf/order_set_item_customise_pdf.rb +++ b/app/pdf/order_set_item_customise_pdf.rb @@ -51,6 +51,15 @@ class OrderSetItemCustomisePdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left @@ -157,4 +166,13 @@ class OrderSetItemCustomisePdf < Prawn::Document end end + def get_booking_id(order_no) + booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id") + .joins(" JOIN orders o ON o.order_id=bo.order_id") + .where("o.order_id='#{order_no}'") + .first() + + return booking.booking_id + end + end diff --git a/app/pdf/order_set_item_pdf.rb b/app/pdf/order_set_item_pdf.rb index 14a8ff62..1e9ca6cd 100755 --- a/app/pdf/order_set_item_pdf.rb +++ b/app/pdf/order_set_item_pdf.rb @@ -50,6 +50,15 @@ class OrderSetItemPdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 2 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left @@ -143,17 +152,26 @@ class OrderSetItemPdf < Prawn::Document end - #add updated qty text - def add_updated_qty_text(before_updated_qty, updated_qty, precision) - if before_updated_qty.to_i > 0 && !before_updated_qty.nil? - move_down 5 + #add updated qty text + def add_updated_qty_text(before_updated_qty, updated_qty, precision) + if before_updated_qty.to_i > 0 && !before_updated_qty.nil? + move_down 5 - # add option - y_position = cursor - bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do - text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + # add option + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left + end end end - end + + def get_booking_id(order_no) + booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id") + .joins(" JOIN orders o ON o.order_id=bo.order_id") + .where("o.order_id='#{order_no}'") + .first() + + return booking.booking_id + end end diff --git a/app/pdf/order_summary_customise_pdf.rb b/app/pdf/order_summary_customise_pdf.rb index 30a32117..a5b39dd9 100644 --- a/app/pdf/order_summary_customise_pdf.rb +++ b/app/pdf/order_summary_customise_pdf.rb @@ -55,7 +55,16 @@ class OrderSummaryCustomisePdf < Prawn::Document end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left @@ -144,4 +153,13 @@ class OrderSummaryCustomisePdf < Prawn::Document # end end end + + def get_booking_id(order_no) + booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id") + .joins(" JOIN orders o ON o.order_id=bo.order_id") + .where("o.order_id='#{order_no}'") + .first() + + return booking.booking_id + end end diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 5feb337e..e1d7e17d 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -54,7 +54,16 @@ class OrderSummaryPdf < Prawn::Document end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 5 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left @@ -154,4 +163,13 @@ class OrderSummaryPdf < Prawn::Document # end end end + + def get_booking_id(order_no) + booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id") + .joins(" JOIN orders o ON o.order_id=bo.order_id") + .where("o.order_id='#{order_no}'") + .first() + + return booking.booking_id + end end diff --git a/app/pdf/order_summary_set_customise_pdf.rb b/app/pdf/order_summary_set_customise_pdf.rb index 5f12fc4c..e2d22891 100644 --- a/app/pdf/order_summary_set_customise_pdf.rb +++ b/app/pdf/order_summary_set_customise_pdf.rb @@ -55,6 +55,15 @@ class OrderSummarySetCustomisePdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no} ", :size => self.order_no_font_size,:align => :left @@ -159,4 +168,13 @@ class OrderSummarySetCustomisePdf < Prawn::Document # end end end + + def get_booking_id(order_no) + booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id") + .joins(" JOIN orders o ON o.order_id=bo.order_id") + .where("o.order_id='#{order_no}'") + .first() + + return booking.booking_id + end end diff --git a/app/pdf/order_summary_set_pdf.rb b/app/pdf/order_summary_set_pdf.rb index 316bbe44..d07f7afe 100755 --- a/app/pdf/order_summary_set_pdf.rb +++ b/app/pdf/order_summary_set_pdf.rb @@ -54,6 +54,15 @@ class OrderSummarySetPdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 5 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left @@ -169,4 +178,13 @@ class OrderSummarySetPdf < Prawn::Document # end end end + + def get_booking_id(order_no) + booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id") + .joins(" JOIN orders o ON o.order_id=bo.order_id") + .where("o.order_id='#{order_no}'") + .first() + + return booking.booking_id + end end diff --git a/app/pdf/order_summary_slim_customise_pdf.rb b/app/pdf/order_summary_slim_customise_pdf.rb index 2b7402af..8225c0c3 100644 --- a/app/pdf/order_summary_slim_customise_pdf.rb +++ b/app/pdf/order_summary_slim_customise_pdf.rb @@ -54,7 +54,16 @@ class OrderSummarySlimCustomisePdf < Prawn::Document end # Write Order Information to PDF - def order_info(order_no, order_by, order_at) + def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no} ", :size => self.item_slim_font_size,:align => :left @@ -145,4 +154,13 @@ class OrderSummarySlimCustomisePdf < Prawn::Document # end end end + + def get_booking_id(order_no) + booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id") + .joins(" JOIN orders o ON o.order_id=bo.order_id") + .where("o.order_id='#{order_no}'") + .first() + + return booking.booking_id + end end diff --git a/app/pdf/order_summary_slim_pdf.rb b/app/pdf/order_summary_slim_pdf.rb index 1e93fc0d..8f60c711 100755 --- a/app/pdf/order_summary_slim_pdf.rb +++ b/app/pdf/order_summary_slim_pdf.rb @@ -54,6 +54,15 @@ class OrderSummarySlimPdf < Prawn::Document # Write Order Information to PDF def order_info(order_no, order_by, order_at) + #booking ID + booking_id = get_booking_id(order_no) + + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left + end + + move_down 1 y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do text "OrderNo: #{order_no} ", :size => self.item_font_size,:align => :left @@ -152,4 +161,13 @@ class OrderSummarySlimPdf < Prawn::Document # end end end + + def get_booking_id(order_no) + booking = Booking.joins(" JOIN booking_orders bo ON bo.booking_id = bookings.booking_id") + .joins(" JOIN orders o ON o.order_id=bo.order_id") + .where("o.order_id='#{order_no}'") + .first() + + return booking.booking_id + end end diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 0314b1a9..579c6ff8 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) + 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) 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 @@ -72,7 +72,12 @@ class ReceiptBillA5Pdf < Prawn::Document card_sale_data(card_data) end #end card sale trans data - + #start card blanace amount + if !card_balance_amount.nil? + card_balance_data(card_balance_amount) + 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 @@ -113,12 +118,17 @@ class ReceiptBillA5Pdf < Prawn::Document end def cashier_info(sale_data, customer_name, latest_order_no) + move_down line_move + text "Booking : #{ sale_data.bookings[0].booking_id }", :size => self.header_font_size+5,:align => :left + move_down line_move + move_down line_move if !latest_order_no.nil? move_down line_move - text "OrderNo : #{ latest_order_no }", :size => self.header_font_size,:align => :left + 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 @@ -707,6 +717,23 @@ class ReceiptBillA5Pdf < Prawn::Document end end + #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 + + 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 + end + #check ReceiptBillAltName included def show_alt_name bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index f060a95a..9dd3faeb 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -3,7 +3,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, 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) + 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) 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,6 +73,11 @@ class ReceiptBillPdf < Prawn::Document card_sale_data(card_data) end #end card sale trans data + #start card blanace amount + if !card_balance_amount.nil? + card_balance_data(card_balance_amount) + 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) @@ -113,12 +118,17 @@ class ReceiptBillPdf < Prawn::Document end def cashier_info(sale_data, customer_name, latest_order_no) + move_down line_move + text "Booking : #{ sale_data.bookings[0].booking_id }", :size => self.header_font_size+2,:align => :left + move_down line_move + move_down line_move if !latest_order_no.nil? move_down line_move - text "OrderNo : #{ latest_order_no }", :size => self.header_font_size,:align => :left + 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.description_width + self.price_num_width, :height => self.item_height) do @@ -509,9 +519,9 @@ class ReceiptBillPdf < Prawn::Document bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do text "Total Balance", :size => self.item_font_size,:align => :left end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right - end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end end end @@ -707,6 +717,23 @@ class ReceiptBillPdf < Prawn::Document end end + #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 + + 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 + end + #check ReceiptBillAltName included def show_alt_name bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf diff --git a/app/uploaders/commissioner_image_uploader.rb b/app/uploaders/commissioner_image_uploader.rb index 8baa6dac..9b65e4a8 100644 --- a/app/uploaders/commissioner_image_uploader.rb +++ b/app/uploaders/commissioner_image_uploader.rb @@ -20,10 +20,10 @@ class CommissionerImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.find(1).shop_code.nil? + if Shop.first.shop_code.nil? "#{original_filename}" if original_filename.present? else - "#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present? + "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? end end diff --git a/app/uploaders/customer_image_uploader.rb b/app/uploaders/customer_image_uploader.rb index 3c4c6f67..be1326d6 100644 --- a/app/uploaders/customer_image_uploader.rb +++ b/app/uploaders/customer_image_uploader.rb @@ -20,10 +20,10 @@ class CustomerImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.find(1).shop_code.nil? + if Shop.first.shop_code.nil? "#{original_filename}" if original_filename.present? else - "#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present? + "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? end end diff --git a/app/uploaders/employee_image_uploader.rb b/app/uploaders/employee_image_uploader.rb index f1e32849..17c9d120 100644 --- a/app/uploaders/employee_image_uploader.rb +++ b/app/uploaders/employee_image_uploader.rb @@ -20,10 +20,10 @@ class EmployeeImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.find(1).shop_code.nil? + if Shop.first.shop_code.nil? "#{original_filename}" if original_filename.present? else - "#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present? + "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? end end diff --git a/app/uploaders/menu_item_image_uploader.rb b/app/uploaders/menu_item_image_uploader.rb index 5e1016a6..8a340b22 100755 --- a/app/uploaders/menu_item_image_uploader.rb +++ b/app/uploaders/menu_item_image_uploader.rb @@ -15,15 +15,15 @@ class MenuItemImageUploader < CarrierWave::Uploader::Base # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir - "image/menu_images/#{Shop.find(1).shop_code}" + "image/menu_images/#{current_shop.shop_code}" # "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end def filename - if Shop.find(1).shop_code.nil? + if Shop.first.shop_code.nil? "#{original_filename}" if original_filename.present? else - "#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present? + "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? end end diff --git a/app/uploaders/product_image_uploader.rb b/app/uploaders/product_image_uploader.rb index 4b702a00..c39d867d 100755 --- a/app/uploaders/product_image_uploader.rb +++ b/app/uploaders/product_image_uploader.rb @@ -20,10 +20,10 @@ class ProductImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.find(1).shop_code.nil? + if Shop.first.shop_code.nil? "#{original_filename}" if original_filename.present? else - "#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present? + "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? end end diff --git a/app/uploaders/shop_image_uploader.rb b/app/uploaders/shop_image_uploader.rb index 009d83d9..394704c3 100644 --- a/app/uploaders/shop_image_uploader.rb +++ b/app/uploaders/shop_image_uploader.rb @@ -20,10 +20,10 @@ class ShopImageUploader < CarrierWave::Uploader::Base end def filename - if Shop.find(1).shop_code.nil? + if Shop.first.shop_code.nil? "#{original_filename}" if original_filename.present? else - "#{Shop.find(1).shop_code}_#{original_filename}" if original_filename.present? + "#{Shop.first.shop_code}_#{original_filename}" if original_filename.present? end end diff --git a/app/views/api/restaurant/menu/_menu.json.jbuilder b/app/views/api/restaurant/menu/_menu.json.jbuilder index 082b5f0a..f3ca6e19 100755 --- a/app/views/api/restaurant/menu/_menu.json.jbuilder +++ b/app/views/api/restaurant/menu/_menu.json.jbuilder @@ -1,6 +1,7 @@ json.id menu.id json.name menu.name json.is_active menu.is_active +json.is_ordering menu.is_ordering json.valid_time_from menu.valid_time_from.strftime("%H:%M") json.valid_time_to menu.valid_time_to.strftime("%H:%M") diff --git a/app/views/api/restaurant/menu/index.json.jbuilder b/app/views/api/restaurant/menu/index.json.jbuilder index a230a965..388b064e 100755 --- a/app/views/api/restaurant/menu/index.json.jbuilder +++ b/app/views/api/restaurant/menu/index.json.jbuilder @@ -1,6 +1,8 @@ menu_json = json.array! @menus do |menu| json.id menu.id json.name menu.name + json.is_active menu.is_active + json.is_ordering menu.is_ordering 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") diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index 5dcb86b0..ef5c76ba 100644 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -1,163 +1,225 @@ +
+
+
+
+ +
+ <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> + + <%= f.hidden_field :id, :class => "form-control " %> +
+
+ +
+
+ +
+ +
+
+
-<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> - -<%= f.hidden_field :id, :class => "form-control " %> +
+
+
+   +   +   + +
+
+
"> +
+ <%= f.input :name, :class => "form-control name", :required => true %> + <% flash.each do |test, 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 :name, :class => "form-control col-md-6 name", :required => true %> - <% flash.each do |test, msg| %> - <% - str="[\"#{msg['name']}\"]" - 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.input :nrc_no,:label => "NRC No", :class => "form-control nrc_no" %> -
+
+
+ +
+
+
+
+ +
+
+ +
+ + <%= 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"%> -
- <%= 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" %> +
+
+
+
+ + +
+
- <% flash.each do |name, msg| %> - <% str="[\"#{msg['company']}\"]" - str.gsub!('["', '') - str.gsub!('"]', '') %> - <%= str %> - <% end -%> -
-
"> - <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" ,:required => true%> +
+
+ <%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control tax_profiles" %> +
+
- <% flash.each do |name, msg| %> - <% str="[\"#{msg['contact_no']}\"]" - str.gsub!('["', '') - str.gsub!('"]', '') %> - <%= str %> - <% end %> -
+
"> +
+ <%= 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.input :email, :class => "form-control col-md-6 email" ,:required => true%> +
+
+ +
+ +
+
+
+
- <% flash.each do |name, msg| %> - <% str="[\"#{msg['email']}\"]" - str.gsub!('["', '') - str.gsub!('"]', '') %> - <%= str %> - <% end %> -
- -
- <%= f.input :address, :class => "form-control col-md-6 address" %> -
- -
- -
- +
+
+ + +
+
+
+
+ + + + + +
+
+
+
+
+ <%end%>
-
- -
- - <%= f.text_field :date_of_birth, :value=>"01-01-1990",:class=>"datepicker form-control col-md-12"%> -
- -
- -
- - <%= f.file_field :image_path, :class => "img-thumbnail" %> -
-
- -
- - -
- -
- <%= f.input :tax_profiles, :collection => @taxes, :input_html => { :multiple => true }, :class => "form-control col-md-6 tax_profiles" %> -
- -
"> - <%= f.input :card_no, :class => "form-control col-md-6 card_no"%> - <% flash.each do |name, msg| %> - <% str="[\"#{msg['card_no']}\"]" - str.gsub!('["', '') - str.gsub!('"]', '') %> - <%= str %> - <% end %> -
- -
- -
- -
-
-
- -
- - - -
- -
- - - - -
-<%end%> +
diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index ceb28f1c..275ae672 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -1,38 +1,41 @@ - diff --git a/app/views/inventory/inventory_definitions/_backupform.html.erb b/app/views/inventory/inventory_definitions/_backupform.html.erb new file mode 100755 index 00000000..9b42de68 --- /dev/null +++ b/app/views/inventory/inventory_definitions/_backupform.html.erb @@ -0,0 +1,119 @@ +
+
+
+
+
+ <%= simple_form_for([:inventory, @inventory_definition]) do |f| %> + <%= f.error_notification %> + +
+
+ <% arr = MenuItem.active.order("name desc").pluck(:name, :item_code) %> + <% Product.order("name desc").pluck(:name, :item_code).each do |p| %> + <% arr.push(p) %> + <% end %> +
+
+ + +
+
+ + <% sample = [] %> + <% if @inventory_definition.item_code.nil? %> + <% if !MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code).nil? %> + <% sample = MenuItemInstance.where("item_instance_code=?", @inventory_definition.item_code).pluck(:item_instance_name, :item_instance_code) %> + <% else %> + <% sample = Product.where("item_code=?", @inventory_definition.item_code).pluck(:name, :item_code) %> + <% end %> + <% end %> +
<%= f.input :item_code, collection: sample %>
+
+ + <%= f.input :min_order_level %> + <%= f.input :max_stock_level %> +
+ +
+ <%= f.submit t("views.btn.submit"), class: 'btn bg-blue waves-effect' %> +
+ + <% end %> +
+
+
+
+
+
+
+
view_headline <%= t("views.right_panel.header.page_detail") %>
+

+ 1) <%= t("views.right_panel.detail.select_item") %> - <%= t("views.right_panel.detail.select_txt") %> <%= t("views.right_panel.detail.item_txt") %>
+ 2) <%= t("views.right_panel.detail.item_code") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.item_code_txt2") %>
+ 3) <%= t("views.right_panel.detail.min_order") %> <%= t("views.right_panel.detail.level") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.min_order_level_txt") %>
+ 4) <%= t("views.right_panel.detail.max_stock") %> <%= t("views.right_panel.detail.level") %> - <%= t("views.right_panel.detail.write_txt") %><%= t("views.right_panel.detail.max_stock_level_txt") %>
+

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

+ 1) <%= t("views.btn.submit") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.inventory") %>
+

+ +
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.home_txt") %>
+

+
+
+
+
+ + + \ No newline at end of file diff --git a/app/views/inventory/inventory_definitions/_form.html.erb b/app/views/inventory/inventory_definitions/_form.html.erb old mode 100755 new mode 100644 index 9b42de68..36493eb4 --- a/app/views/inventory/inventory_definitions/_form.html.erb +++ b/app/views/inventory/inventory_definitions/_form.html.erb @@ -1,119 +1,637 @@ -
-
-
-
-
- <%= simple_form_for([:inventory, @inventory_definition]) do |f| %> - <%= f.error_notification %> +<%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %> -
-
- <% arr = MenuItem.active.order("name desc").pluck(:name, :item_code) %> - <% Product.order("name desc").pluck(:name, :item_code).each do |p| %> - <% arr.push(p) %> - <% end %> -
-
- - +
+ +
+ + +
+
+
+
+
- - <% sample = [] %> - <% if @inventory_definition.item_code.nil? %> - <% if !MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code).nil? %> - <% sample = MenuItemInstance.where("item_instance_code=?", @inventory_definition.item_code).pluck(:item_instance_name, :item_instance_code) %> - <% else %> - <% sample = Product.where("item_code=?", @inventory_definition.item_code).pluck(:name, :item_code) %> - <% end %> - <% end %> -
<%= f.input :item_code, collection: sample %>
- - <%= f.input :min_order_level %> - <%= f.input :max_stock_level %>
- -
- <%= f.submit t("views.btn.submit"), class: 'btn bg-blue waves-effect' %> -
- - <% end %>
+
+ + +
+
+ + + + + + + + + + + + +
#ItemsMin QtyMax Qty
+
+
+ +
-
-
-
-
-
view_headline <%= t("views.right_panel.header.page_detail") %>
-

- 1) <%= t("views.right_panel.detail.select_item") %> - <%= t("views.right_panel.detail.select_txt") %> <%= t("views.right_panel.detail.item_txt") %>
- 2) <%= t("views.right_panel.detail.item_code") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.item_code_txt2") %>
- 3) <%= t("views.right_panel.detail.min_order") %> <%= t("views.right_panel.detail.level") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.min_order_level_txt") %>
- 4) <%= t("views.right_panel.detail.max_stock") %> <%= t("views.right_panel.detail.level") %> - <%= t("views.right_panel.detail.write_txt") %><%= t("views.right_panel.detail.max_stock_level_txt") %>
-

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

- 1) <%= t("views.btn.submit") %> - <%= t("views.right_panel.detail.create_btn_txt") %> <%= t("views.right_panel.detail.inventory") %>
-

-
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.home_txt") %>
-

-
-
-
-
+