diff --git a/app/assets/javascripts/channels/order_reservation.js b/app/assets/javascripts/channels/order_reservation.js index 68da8d87..52b4cef5 100644 --- a/app/assets/javascripts/channels/order_reservation.js +++ b/app/assets/javascripts/channels/order_reservation.js @@ -17,7 +17,7 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel' var rowCount = key+1; var date = new Date(value.created_at); var time = timeFormat(date); - var created_at = date.getFullYear() +'-'+ (date.getMonth() > 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate()>10?date.getDate() : '0'+date.getDate()); + var created_at = date.getFullYear() +'-'+ (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >=10?date.getDate() : '0'+date.getDate()); var delivery_type = ""; if(value.delivery_type == "service"){ diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js index 66c28e8d..81afc303 100644 --- a/app/assets/javascripts/order_reservation.js +++ b/app/assets/javascripts/order_reservation.js @@ -2,6 +2,9 @@ $(function() { $("#discount").hide(); $(".expected_time").hide(); + $('#accepted').hide(); + $('#cancel').hide(); + $(".tbl_customer").hide(); $(function() { $('.first-1').click(); }); @@ -11,8 +14,9 @@ $(function() { $(".nav-item").on("click", function(){ type = $(this).attr("data-type"); refreshDetailData(); - $('#accepted').show(); - $('#cancel').show(); + $('#accepted').hide(); + $('#cancel').hide(); + $(".tbl_customer").hide(); if (type == "pending") { $(".first-1").click(); $('#accepted').text("ACCEPT"); @@ -26,13 +30,14 @@ $(function() { $('#accepted').text("READY TO DELIVERY"); $('#accepted').attr("data-value","delivery"); }else if(type == "completed"){ + // $('#cancel').hide(); $(".fourth-1").click(); - $('#accepted').text("PICK-UP"); + $('#accepted').text("COMPLETE"); $('#accepted').attr("data-value","completed"); }else if(type == "processed"){ $(".fifth-1").click(); - $('#accepted').hide(); - $('#cancel').hide(); + // $('#accepted').hide(); + // $('#cancel').hide(); } // console.log(type); }); @@ -94,7 +99,7 @@ $(function() { $(".time_interval").on("click",function(){ var type = ''; if($(".timer_type").hasClass("selected-item")){ - type = '+'; + type = 'after'; } var minutes = $(this).attr("data-value"); // console.log(type); @@ -104,14 +109,14 @@ $(function() { var order_id = $('#order_id').text(); var ref_no = $('#ref_no').text(); var callback = $('#callback_url').text(); - var requested_time = new Date($("#requested_date_time").text()); - if(type == 'plus'){ - requested_time.setMinutes(requested_time.getMinutes() + minutes); - }else{ - requested_time.setMinutes(requested_time.getMinutes() - minutes); - } + // var requested_time = new Date($("#requested_date_time").text()); + // if(type == 'after'){ + // requested_time.setMinutes(requested_time.getMinutes() + minutes); + // }else{ + // requested_time.setMinutes(requested_time.getMinutes() - minutes); + // } // console.log(requested_time); - callback_url(callback,ref_no,order_id,status,type,minutes,requested_time); + callback_url(callback,ref_no,order_id,status,type,minutes); }); $(document).on('click','.access_number', function(event){ @@ -201,20 +206,30 @@ function show_order_detail(url,sr_no){ dataType: "json", success: function(data) { // console.log(data); + $(".tbl_customer").show(); + if(data.status != "delivered"){ + $('#accepted').show(); + if(data.status != "ready_to_delivery" && data.status != "send_to_kitchen"){ + $('#cancel').show(); + } + }else{ + $('#accepted').hide(); + $('#cancel').hide(); + } var delivery = data["delivery"]; var items = data["order_items"]; var item_list = $('.summary-items'); 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; + var requested_date = newDate.getFullYear() + '-' + (newDate.getMonth() >= 10? newDate.getMonth() : '0' + (newDate.getMonth() + 1)) +'-'+ (newDate.getDate() >= 10? newDate.getDate() : '0' + newDate.getDate()) +' '+time; if((data.expected_waiting_time!=undefined) && (data.expected_waiting_time!=null)){ - var expDate = new Date(data.expected_waiting_time); - var exptime = timeFormat(expDate); - var expected_time = expDate.getFullYear() + '-' + (expDate.getMonth() > 10? expDate.getMonth() : '0' + (expDate.getMonth() + 1)) +'-'+ (expDate.getDate() > 10? expDate.getDate() : '0' + expDate.getDate()) +' '+exptime; + // var expDate = new Date(data.expected_waiting_time); + // var exptime = timeFormat(expDate); + // var expected_time = expDate.getFullYear() + '-' + (expDate.getMonth() >= 10? expDate.getMonth() : '0' + (expDate.getMonth() + 1)) +'-'+ (expDate.getDate() >= 10? expDate.getDate() : '0' + expDate.getDate()) +' '+exptime; $('.expected_time').show(); - $('#expected_time').text(expected_time? expected_time : ''); + $('#expected_time').text(data.expected_waiting_time? data.expected_waiting_time : ''); }else{ $('.expected_time').hide(); $('#expected_time').text(''); @@ -334,7 +349,7 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas $.ajax({ type: "POST", url: url, - data: {order_id: order_id, status: status, expected_time: expected_time, remark: reason, access_code: access_code}, + data: {order_id: order_id, status: status, min_type: min_type, expected_time: waiting_time, remark: reason, access_code: access_code}, dataType: "json", success: function(data) { if (data.status) { @@ -383,7 +398,7 @@ function showNewOrder(order_reservation){ if((order_reservation!=undefined) && (order_reservation!=null) && (order_reservation!="")){ var date = new Date(order_reservation.requested_time); var time = timeFormat(date); - var requested_date = date.getFullYear() + '-' + (date.getMonth() > 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() > 10? date.getDate() : '0' + date.getDate()) +' '+time; + var requested_date = date.getFullYear() + '-' + (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >= 10? date.getDate() : '0' + date.getDate()) +' '+time; //audio play var audio = new Audio('/beep-07.wav'); // define your audio // setTimeout(function(){ diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index d937c6c3..49afe833 100755 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -220,33 +220,39 @@ class Api::OrdersController < Api::ApiController if ENV["SERVER_MODE"] != "cloud" #no print in cloud server # print assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code) - # order queue stations - oqs = assigned_item.order_queue_station + assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'") - order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf - - unique_code="OrderItemPdf" - if !order_slim_pdf.empty? - order_slim_pdf.each do |order_item_slim| - if order_item_slim[0] == 'OrderSlimPdf' - if order_item_slim[1] == '1' - unique_code="OrderItemSlimPdf" - else - unique_code="OrderItemPdf" - end - elsif order_item_slim[0] == 'OrderSetPdf' - if order_item_slim[1] == '1' - unique_code="OrderSetItemPdf" - else - unique_code="OrderItemPdf" + if !assigned_items.nil? + assigned_items.each do |assign_item| + # order queue stations + oqs = assign_item.order_queue_station + + order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf + + unique_code="OrderItemPdf" + if !order_slim_pdf.empty? + order_slim_pdf.each do |order_item_slim| + if order_item_slim[0] == 'OrderSlimPdf' + if order_item_slim[1] == '1' + unique_code="OrderItemSlimPdf" + else + unique_code="OrderItemPdf" + end + elsif order_item_slim[0] == 'OrderSetPdf' + if order_item_slim[1] == '1' + unique_code="OrderSetItemPdf" + else + unique_code="OrderItemPdf" + end + end end end + + print_settings=PrintSetting.find_by_unique_code(unique_code) + order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) + order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty ) end end - - print_settings=PrintSetting.find_by_unique_code(unique_code) - order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty ) end return return_json_status_with_code(200, "updated successfully!") diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index bf32f43b..c7487b97 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -9,7 +9,12 @@ class Origami::OrderReservationController < BaseOrigamiController def update @id = params[:order_id] @status = params[:status] - expected_waiting_time = params[:expected_time] + min_type = params[:min_type] + if min_type != "" + expected_waiting_time = params[:expected_time] + else + expected_waiting_time = min_type + " " +params[:expected_time] + end remark = params[:remark] access_code = params[:access_code] @order_reservation = OrderReservation.find(@id) diff --git a/app/controllers/reports/order_reservation_controller.rb b/app/controllers/reports/order_reservation_controller.rb index b101c37e..bb351982 100644 --- a/app/controllers/reports/order_reservation_controller.rb +++ b/app/controllers/reports/order_reservation_controller.rb @@ -1,7 +1,7 @@ class Reports::OrderReservationController < BaseReportController # authorize_resource :class => false def index - @providers = [["All",''], ["food2u","food2u"], ["Pick-Up","pick_up"], ["ygndoor2door","ygndoor2door"], ["Direct Delivery","direct_delivery"]] + @providers = [["All",''], ["Direct Delivery","direct_delivery"],["Pick-Up","pick_up"],["food2u","food2u"], ["ygndoor2door","ygndoor2door"]] from, to = get_date_range_from_params diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index 35b2e2ee..734cd9ec 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -30,7 +30,7 @@ class OrderReservation < ApplicationRecord order_reservation.payment_type = order_reserve[:payment_info][:payment_type] order_reservation.payment_status = order_reserve[:payment_info][:payment_status] order_reservation.payment_ref = order_reserve[:payment_info][:payment_ref] - order_reservation.taxes = order_reserve[:payment_info][:taxes] + order_reservation.taxes = order_reserve[:payment_info][:taxes].to_json order_reservation.total_amount = order_reserve[:payment_info][:sub_total] order_reservation.total_tax = order_reserve[:payment_info][:total_tax] order_reservation.discount_amount = order_reserve[:payment_info][:discount_amount] @@ -193,7 +193,7 @@ class OrderReservation < ApplicationRecord order_reservation.sale_id = sale_id end if !expected_waiting_time.nil? - order_reservation.expected_waiting_time = DateTime.parse(expected_waiting_time).utc + order_reservation.expected_waiting_time = expected_waiting_time end order_reservation.status = status if !remark.nil? diff --git a/app/views/origami/order_reservation/index.html.erb b/app/views/origami/order_reservation/index.html.erb index 19f78519..75c3f7e0 100644 --- a/app/views/origami/order_reservation/index.html.erb +++ b/app/views/origami/order_reservation/index.html.erb @@ -360,7 +360,7 @@ @@ -394,8 +394,8 @@ -
- +
+
@@ -467,7 +467,7 @@
- +
diff --git a/app/views/reports/order_reservation/index.html.erb b/app/views/reports/order_reservation/index.html.erb index 77e03adc..ef5feafc 100755 --- a/app/views/reports/order_reservation/index.html.erb +++ b/app/views/reports/order_reservation/index.html.erb @@ -71,7 +71,6 @@ delimiter = "" end %> <% - discount_amount = 0.0 delivery_fee = 0.0 convenience_charge = 0.0 @@ -96,20 +95,24 @@ discount_amount = order_reservation.discount_amount delivery_fee = order_reservation.delivery_fee ? order_reservation.delivery_fee : 0.0 convenience_charge = order_reservation.convenience_charge - - (order_reservation.taxes).each do |tax| %> - - <% end - + JSON.parse(order_reservation.taxes).each do |tax_data| + if tax_data[0] == "delivery_tax" + delivery_tax = tax_data[1] + elsif tax_data[0] == "convenience_tax" + convenience_tax = tax_data[1] + elsif tax_data[0] == "commercial_tax" + commercial_tax = tax_data[1] + end + end total_discount_amount += discount_amount.to_f total_delivery_fee += delivery_fee.to_f - total_convenience_charge += convenience_charge - total_delivery_tax += delivery_tax - total_convenience_tax += convenience_tax - total_commercial_tax += commercial_tax - total_tax += order_reservation.total_tax - total_amount += order_reservation.total_amount - grand_total += order_reservation.grand_total + total_convenience_charge += convenience_charge.to_f + total_delivery_tax += delivery_tax.to_f + total_convenience_tax += convenience_tax.to_f + total_commercial_tax += commercial_tax.to_f + total_tax += order_reservation.total_tax.to_f + total_amount += order_reservation.total_amount.to_f + grand_total += order_reservation.grand_total.to_f %> <% if order_reservation.provider == 'pick_up' @@ -123,7 +126,7 @@ - + diff --git a/app/views/reports/order_reservation/index.xls.erb b/app/views/reports/order_reservation/index.xls.erb index 0b6ddcd6..c674cc9b 100755 --- a/app/views/reports/order_reservation/index.xls.erb +++ b/app/views/reports/order_reservation/index.xls.erb @@ -63,19 +63,25 @@ delivery_fee = order_reservation.delivery_fee ? order_reservation.delivery_fee : 0.0 convenience_charge = order_reservation.convenience_charge - (order_reservation.taxes).each do |tax| %> - - <% end + JSON.parse(order_reservation.taxes).each do |tax_data| + if tax_data[0] == "delivery_tax" + delivery_tax = tax_data[1] + elsif tax_data[0] == "convenience_tax" + convenience_tax = tax_data[1] + elsif tax_data[0] == "commercial_tax" + commercial_tax = tax_data[1] + end + end total_discount_amount += discount_amount.to_f total_delivery_fee += delivery_fee.to_f - total_convenience_charge += convenience_charge - total_delivery_tax += delivery_tax - total_convenience_tax += convenience_tax - total_commercial_tax += commercial_tax - total_tax += order_reservation.total_tax - total_amount += order_reservation.total_amount - grand_total += order_reservation.grand_total + total_convenience_charge += convenience_charge.to_f + total_delivery_tax += delivery_tax.to_f + total_convenience_tax += convenience_tax.to_f + total_commercial_tax += commercial_tax.to_f + total_tax += order_reservation.total_tax.to_f + total_amount += order_reservation.total_amount.to_f + grand_total += order_reservation.grand_total.to_f %> <% if order_reservation.provider == 'pick_up' @@ -89,7 +95,7 @@ - +
@@ -413,8 +413,8 @@ - EXPECTED TIME
- + COOKING TIME
+ MINS
<%= order_reservation.email %> <%= order_reservation.order_reservation_type %><%= order_reservation.requested_time.utc.getlocal.strftime("%d %m %Y %I:%M %p") %><%= order_reservation.requested_time.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %> <%= provider%> <%= order_reservation.payment_type%> <%= order_reservation.payment_status%>
<%= order_reservation.email %> <%= order_reservation.order_reservation_type %><%= order_reservation.requested_time.utc.getlocal.strftime("%d %m %Y %I:%M %p") %><%= order_reservation.requested_time.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %> <%= provider%> <%= order_reservation.payment_type%> <%= order_reservation.payment_status%>