From 31b33594c621ffaa9ee53a5137d66d854f48f05b Mon Sep 17 00:00:00 2001 From: phyusin Date: Tue, 26 Jun 2018 15:43:58 +0630 Subject: [PATCH 1/4] check order reservataion status --- app/assets/javascripts/order_reservation.js | 17 +++++-- .../origami/order_reservation_controller.rb | 50 ++++++++++++++----- .../pending_order/completed_sale.html.erb | 4 +- app/views/origami/sales/show.html.erb | 2 + 4 files changed, 54 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js index 4dd86dfd..96be3a43 100644 --- a/app/assets/javascripts/order_reservation.js +++ b/app/assets/javascripts/order_reservation.js @@ -15,12 +15,12 @@ $(function() { customTableClick(); $(".nav-item").on("click", function(){ - type = $(this).attr("data-type"); - refreshDetailData(); + var type = $(this).attr("data-type"); $('#accepted').hide(); $('#cancel').hide(); $(".tbl_customer").hide(); $(".order_close_cashier").hide(); + refreshDetailData(); if (type == "pending") { $(".first-1").click(); $('#accepted').text("ACCEPT"); @@ -240,6 +240,11 @@ function customTableClick(){ } function refreshDetailData(){ + $("#ref_no").text(""); + $("#callback_url").text(""); + $("#order_id").text(""); + $("#status").text(""); + $('#requested_date_time').text(""); $("#sr_number").text(""); $("#delivery_info").text(""); @@ -260,7 +265,7 @@ function refreshDetailData(){ //show order list function show_order_detail(url,sr_no){ - $('.summary-items').html(""); + // $('.summary-items').html(""); //Start Ajax $.ajax({ type: "GET", @@ -470,8 +475,10 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas closeOnConfirm: false, closeOnCancel: false, allowOutsideClick: false - }, function () { - window.location.href = '/origami/order_reservation'; + }, function (isConfirm) { + if(isConfirm){ + window.location.href = '/origami/order_reservation'; + } }); } } diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index 10f7f679..4654eb22 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -17,29 +17,53 @@ class Origami::OrderReservationController < BaseOrigamiController expected_waiting_time = min_type + " " +params[:expected_time] end remark = params[:remark] - access_code = params[:access_code] - @order_reservation = OrderReservation.find(@id) + # access_code = params[:access_code] order_reserve = OrderReservation.find_by_transaction_ref(params[:ref_no]) if !order_reserve.nil? if !ShiftSale.current_shift.nil? if @status == "processed" - result = OrderReservation.create_doemal_order(@order_reservation,current_user) + if order_reserve.status == "accepted" + result = OrderReservation.create_doemal_order(order_reserve,current_user) + else + Rails.logger.debug "Order reservation :: " + order_reserve.to_json + " :: send status ::" + @status + result = {status: false, message: 'Could not send order to kitchen!'} + end elsif @status == "delivery" - OrderReservation.update_order_reservation(@id, nil, "ready_to_delivery") - response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"ready_to_delivery") - result = {:status=> true, :message => "ready for delivery" } + if order_reserve.status == "send_to_kitchen" + OrderReservation.update_order_reservation(@id, nil, "ready_to_delivery") + response = OrderReservation.send_status_to_ordering(order_reserve.callback_url,order_reserve.transaction_ref,"ready_to_delivery") + result = {:status=> true, :message => "ready for delivery" } + else + Rails.logger.debug "Order reservation :: " + order_reserve.to_json + " :: send status ::" + @status + result = {status: false, message: 'Could not ready order to deliver!'} + end elsif @status == "completed" - result = OrderReservation.update_doemal_payment(@order_reservation,current_user) + if order_reserve.status == "ready_to_delivery" + result = OrderReservation.update_doemal_payment(order_reserve,current_user) + else + Rails.logger.debug "Order reservation :: " + order_reserve.to_json + " :: send status ::" + @status + result = {status: false, message: 'Could not deliver order!'} + end else if @status == "rejected" - OrderReservation.update_order_reservation(@id, nil, "rejected",nil,remark,access_code,current_user) - response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"rejected") - result = {:status=> true, :message => "rejected" } + if order_reserve.status == "new" || order_reserve.status == "accepted" + OrderReservation.update_order_reservation(@id, nil, "rejected",nil,remark,access_code,current_user) + response = OrderReservation.send_status_to_ordering(order_reserve.callback_url,order_reserve.transaction_ref,"rejected") + result = {:status=> true, :message => "rejected" } + else + Rails.logger.debug "Order reservation :: " + order_reserve.to_json + " :: send status ::" + @status + result = {status: false, message: 'Could not reject order!'} + end else - OrderReservation.update_order_reservation(@id, nil, "accepted", expected_waiting_time) - response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"accepted") - result = {:status=> true, :message => "accepted" } + if order_reserve.status == "new" + OrderReservation.update_order_reservation(@id, nil, "accepted", expected_waiting_time) + response = OrderReservation.send_status_to_ordering(order_reserve.callback_url,order_reserve.transaction_ref,"accepted") + result = {:status=> true, :message => "accepted" } + else + Rails.logger.debug "Order reservation :: " + order_reserve.to_json + " :: send status ::" + @status + result = {status: false, message: 'Could not accept order!'} + end end end else diff --git a/app/views/origami/pending_order/completed_sale.html.erb b/app/views/origami/pending_order/completed_sale.html.erb index 46dc035d..1a649634 100644 --- a/app/views/origami/pending_order/completed_sale.html.erb +++ b/app/views/origami/pending_order/completed_sale.html.erb @@ -173,7 +173,9 @@ <% if current_user.role != "waiter" %> <% if @sale.sale_status != 'void' && @sale.sale_status != 'waste' && @sale.sale_status != 'spoile' %> <% if current_user.role == "cashier" %> - Void + <% if @sale.payment_status != 'foc' %> + Void + <% end %> Re.Print <% else %> diff --git a/app/views/origami/sales/show.html.erb b/app/views/origami/sales/show.html.erb index b373fd45..865433ad 100755 --- a/app/views/origami/sales/show.html.erb +++ b/app/views/origami/sales/show.html.erb @@ -257,7 +257,9 @@ <% if @sale.sale_status != 'void' && @sale.sale_status != 'waste' && @sale.sale_status != 'spoile' %> <% if current_login_employee.role == "cashier" %> + <% if @sale.payment_status != 'foc' %> Void + <% end %> Re.Print <% else %> From 13b8167ebb2201538808aff7fc8d76b7b2ecce89 Mon Sep 17 00:00:00 2001 From: phyusin Date: Tue, 26 Jun 2018 15:55:55 +0630 Subject: [PATCH 2/4] checn room acc --- app/controllers/origami/rooms_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 9d40d4a2..7bbe5581 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -129,7 +129,7 @@ class Origami::RoomsController < BaseOrigamiController accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC") @tax_arr =[] accounts.each do |acc| - @tax_arr.push(account.name) + @tax_arr.push(acc.name) end lookup_spit_bill = Lookup.collection_of('split_bill') From 279b5976ae53c725e76faca02db9cbe8ca30c371 Mon Sep 17 00:00:00 2001 From: phyusin Date: Tue, 26 Jun 2018 17:02:04 +0630 Subject: [PATCH 3/4] order reservation --- app/controllers/origami/order_reservation_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index 4654eb22..fcfdcbb4 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -17,7 +17,7 @@ class Origami::OrderReservationController < BaseOrigamiController expected_waiting_time = min_type + " " +params[:expected_time] end remark = params[:remark] - # access_code = params[:access_code] + access_code = params[:access_code] order_reserve = OrderReservation.find_by_transaction_ref(params[:ref_no]) if !order_reserve.nil? From 86916fb7e75adc5d6bcdfad68b93f48c702f22ea Mon Sep 17 00:00:00 2001 From: phyusin Date: Tue, 26 Jun 2018 18:22:53 +0630 Subject: [PATCH 4/4] check induties process --- .../origami/in_duties_controller.rb | 27 ++++++++++--------- .../origami/request_bills_controller.rb | 10 +++++++ app/views/origami/home/show.html.erb | 5 ++-- app/views/origami/in_duties/_form.html.erb | 1 - .../origami/in_duties/index_in_duty.html.erb | 8 +++--- app/views/origami/rooms/show.html.erb | 6 +++-- config/routes.rb | 8 +++--- 7 files changed, 39 insertions(+), 26 deletions(-) diff --git a/app/controllers/origami/in_duties_controller.rb b/app/controllers/origami/in_duties_controller.rb index 7ac2d306..5210851b 100755 --- a/app/controllers/origami/in_duties_controller.rb +++ b/app/controllers/origami/in_duties_controller.rb @@ -2,10 +2,9 @@ class Origami::InDutiesController < BaseOrigamiController before_action :set_in_duty, only: %i[show edit update edit_in_duty update_for_in_duty destroy destroy_in_duty] def index_in_duty - @sale_id = params[:sale_id] - booking = Booking.where("sale_id=?",@sale_id).first - @booking_id = booking.booking_id - @duty_in = InDuty.where('dinning_id=? and sale_id=?', booking.dining_facility_id, @sale_id) + @booking_id = params[:booking_id] + booking = Booking.where("booking_id=?",@booking_id).first + @duty_in = InDuty.where('dinning_id=? and booking_id=?', booking.dining_facility_id, @booking_id) @table = DiningFacility.find(booking.dining_facility_id) @in_duty = InDuty.new @duties_in = Kaminari.paginate_array(@duty_in).page(params[:page]).per(10) @@ -29,8 +28,7 @@ class Origami::InDutiesController < BaseOrigamiController def edit_in_duty @in_duty = InDuty.find(params[:id]) - @sale_id = params[:sale_id] - booking = Booking.where("sale_id=?",@sale_id).first + booking = Booking.where("booking_id=?",@in_duty.booking_id).first @booking_id = booking.booking_id @table = DiningFacility.find(booking.dining_facility_id) @commissioner = @in_duty.commissioner @@ -60,10 +58,14 @@ class Origami::InDutiesController < BaseOrigamiController unless in_duty_id.empty? @in_duty = InDuty.find(in_duty_id.to_i) end - + data = InDuty.find_by_booking_id(in_duty_params[:booking_id]) + if !data.nil? + if !data.sale_id.nil? + @in_duty.sale_id = data.sale_id + end + end @in_duty.dinning_id = in_duty_params[:dinning_id] @in_duty.booking_id = in_duty_params[:booking_id] - @in_duty.sale_id = in_duty_params[:sale_id] @in_duty.commissioner_ids = in_duty_params[:commissioner_ids] @in_duty.in_time = in_duty['in_time'] @in_duty.out_time = in_duty['out_time'] @@ -97,7 +99,7 @@ class Origami::InDutiesController < BaseOrigamiController @in_duty.out_time = in_duty_params[:out_time] respond_to do |format| if @in_duty.save - format.html { redirect_to origami_index_in_duty_path(in_duty_params[:sale_id]), notice: 'In duty was successfully updated.' } + format.html { redirect_to origami_index_in_duty_path(in_duty_params[:booking_id]), notice: 'In duty was successfully updated.' } format.json { render :show, status: :ok, location: @in_duty } else format.html { render :edit } @@ -110,9 +112,8 @@ class Origami::InDutiesController < BaseOrigamiController # DELETE /in_duties/1.json def destroy_in_duty @table_id = params[:table_id] - @sale_id = params[:sale_id] - booking = Booking.where("sale_id=?",@sale_id).first - @booking_id = booking.booking_id + @booking_id = params[:booking_id] + booking = Booking.where("booking_id=?",@booking_id).first @in_duty.destroy flash[:notice] = 'In duty was successfully destroyed.' @@ -128,7 +129,7 @@ class Origami::InDutiesController < BaseOrigamiController # Never trust parameters from the scary internet, only allow the white list through. def in_duty_params - params.require(:in_duty).permit(:id, :dinning_id, :booking_id, :sale_id, :commissioner_ids, :in_time, :out_time) + params.require(:in_duty).permit(:id, :dinning_id, :booking_id, :commissioner_ids, :in_time, :out_time) end end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index c7bff41b..1932821d 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -27,6 +27,16 @@ class Origami::RequestBillsController < ApplicationController @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee, current_user, order.source) @sale_data = Sale.find_by_sale_id(@sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_id) + + # in-duty update + in_duties = InDuty.where("booking_id=?",bk_order.booking_id) + if !in_duties.empty? + in_duties.each do |in_duty| + induty = InDuty.find(in_duty.id) + induty.sale_id = @sale_id + induty.save + end + end else @sale_data = Sale.find_by_sale_id(check_booking.sale_id) @sale_items = SaleItem.where("sale_id=?",@sale_data.sale_id) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 8a1a2673..2bd92cf3 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -487,6 +487,7 @@ + <% if !@split_bill.nil? %> <% if @split_bill == '1' %> @@ -1061,8 +1062,8 @@ $('#in_duties').on('click', function () { var dining_id = "<%= @dining.id %>"; - var sale_id = "<%= @obj_sale.sale_id rescue "" %>"; - window.location.href = '/origami/assign_in_duty/'+ sale_id; + var booking_id = "<%= @booking.booking_id rescue "" %>"; + window.location.href = '/origami/assign_in_duty/'+ booking_id; }); $('#void').on('click', function () { diff --git a/app/views/origami/in_duties/_form.html.erb b/app/views/origami/in_duties/_form.html.erb index 800e356a..ff552e86 100755 --- a/app/views/origami/in_duties/_form.html.erb +++ b/app/views/origami/in_duties/_form.html.erb @@ -6,7 +6,6 @@ <%= f.error_notification %> <%= f.hidden_field :id, :class => "form-control col-md-6 " %> <%= f.hidden_field :booking_id, :value => @booking_id %> - <%= f.hidden_field :sale_id, :value => @sale_id %>
<%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %> diff --git a/app/views/origami/in_duties/index_in_duty.html.erb b/app/views/origami/in_duties/index_in_duty.html.erb index 16a8a03f..3f036186 100755 --- a/app/views/origami/in_duties/index_in_duty.html.erb +++ b/app/views/origami/in_duties/index_in_duty.html.erb @@ -32,7 +32,7 @@ <%= in_duty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> <%= in_duty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> - @@ -67,9 +67,9 @@ $(this).closest('tr').find('.checkbox_check').prop("checked", true); var in_duty_id = $(this).attr('data-ref'); - var table_id = "<%= @table.id %>"; - var sale_id = "<%= @sale_id %>"; - var url = "/origami/assign_in_duty/table/" + sale_id + "/in_duty/" + in_duty_id + "/edit"; + // var table_id = "<%= @table.id %>"; + // var sale_id = "<%= @sale_id %>"; + var url = "/origami/assign_in_duty/" + in_duty_id + "/edit"; $.ajax({ type: "GET", diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 8da2c33d..52c5d108 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -470,6 +470,7 @@ + <% if !@split_bill.nil? %> <% if @split_bill == '1' %> @@ -1171,8 +1172,9 @@ $('#add_invoice').on('click',function(){ }); $('#in_duties').on('click', function () { - var dining_id = "<%= @room.id %>" - window.location.href = '/origami/assign_in_duty/'+ dining_id; + var dining_id = "<%= @room.id %>"; + var booking_id = "<%= @booking.booking_id rescue "" %>"; + window.location.href = '/origami/assign_in_duty/'+ booking_id; }); // Ordering diff --git a/config/routes.rb b/config/routes.rb index 21564073..1b7f3682 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -132,12 +132,12 @@ scope "(:locale)", locale: /en|mm/ do post 'apply_void' => 'sale_edit#apply_void' # in_duties get '/table/:sale_id/assign_in_duty' => 'in_duties#assign_in_duty', as: 'assign_in_duty' - get 'assign_in_duty/:sale_id' => 'in_duties#index_in_duty', as: 'index_in_duty' - post 'assign_in_duty/:sale_id' => 'in_duties#create_for_in_duty' + get 'assign_in_duty/:booking_id' => 'in_duties#index_in_duty', as: 'index_in_duty' + post 'assign_in_duty/:booking_id' => 'in_duties#create_for_in_duty' - get 'assign_in_duty/table/:sale_id/in_duty/:id/edit' => 'in_duties#edit_in_duty' ,as: 'edit_in_duty' + get 'assign_in_duty/:id/edit' => 'in_duties#edit_in_duty' ,as: 'edit_in_duty' patch 'edit_in_duty/:id' => 'in_duties#update_for_in_duty', as: 'update_for_in_duty' - delete 'table/:table_id/:sale_id/destroy_in_duty/:id' => 'in_duties#destroy_in_duty', as: 'destroy_in_duty' + delete 'table/:table_id/:booking_id/destroy_in_duty/:id' => 'in_duties#destroy_in_duty', as: 'destroy_in_duty' get 'table/:dining_id/movetable' => "movetable#move_dining" get 'table/:dining_id/moveroom' => "moveroom#move_dining"