From 0970b0022e493ed2130c8d744e796a1e77224a68 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 24 May 2018 11:36:35 +0630 Subject: [PATCH] check shift open or not --- .../order_reserve/order_reservation_controller.rb | 2 +- .../origami/order_reservation_controller.rb | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb index 32e87a20..97c44df9 100644 --- a/app/controllers/api/order_reserve/order_reservation_controller.rb +++ b/app/controllers/api/order_reserve/order_reservation_controller.rb @@ -63,7 +63,7 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController order_reservation = params order_reservation_id, flag = OrderReservation.addOrderReservationInfo(order_reservation) - if flag #&& ENV["SERVER_MODE"] != 'cloud' + if flag shop = Shop.find_by_id(1) if !shop.shop_code.nil? shop_code = shop.shop_code diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index a3421fbd..ea760e33 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -48,8 +48,16 @@ class Origami::OrderReservationController < BaseOrigamiController end def send_status - response = OrderReservation.send_status_to_ordering(params[:url],params[:ref_no],params[:status],params[:waiting_time],params[:min_type],params[:reason]) - + order_reservation = OrderReservation.find_by_transaction_ref(params[:ref_no]) + if !order_reservation.nil? + if !ShiftSale.current_shift.nil? || params[:status] == 'accepted' || (order_reservation.status == 'new' && params[:status] == 'rejected') + response = OrderReservation.send_status_to_ordering(params[:url],params[:ref_no],params[:status],params[:waiting_time],params[:min_type],params[:reason]) + else + response = { status: false, message: 'No current shift open for this employee!'} + end + else + response = { status: false, message: 'There is no order for '+params[:ref_no]+'!'} + end render :json => response end