From 86d068ddd45a0e1537c803e0d51b548f64cb78ea Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 12 Jan 2018 16:29:17 +0630 Subject: [PATCH 1/2] check checkout_time is available ot not --- .../api/check_in_process_controller.rb | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index cf34700e..ac43bfd9 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -35,31 +35,35 @@ class Api::CheckInProcessController < Api::ApiController dining_facility = DiningFacility.find(params[:dining_id]) if dining_facility.status == "available" lookup_checkout_time = Lookup.collection_of("checkout_time") - - checkout_at = Time.now.utc - - if !lookup_checkout_time.nil? - if lookup_checkout_time[0][0] == 'hr' - checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour - else - checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes - end - end - - dining_facility.status = "occupied" - dining_facility.save! - - if dining_facility.type == "Table" - type = "TableBooking" - else - type = "RoomBooking" - end - booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, - :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) - booking.save! + if !lookup_checkout_time.empty? + checkout_at = Time.now.utc - render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") } + if !lookup_checkout_time.nil? + if lookup_checkout_time[0][0] == 'hr' + checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour + else + checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes + end + end + + dining_facility.status = "occupied" + dining_facility.save! + + if dining_facility.type == "Table" + type = "TableBooking" + else + type = "RoomBooking" + end + + booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, + :checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name }) + booking.save! + + render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") } + else + render :json => { :status => true } + end else error_message = "#{dining_facility.type} is not available!" render :json => { :status => false, :error_message => error_message } From a8a86e3202acc7d82adcdae3e107cd48dd440ba0 Mon Sep 17 00:00:00 2001 From: phyusin Date: Fri, 12 Jan 2018 16:36:59 +0630 Subject: [PATCH 2/2] show success message for settle --- app/views/origami/shifts/show.html.erb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/views/origami/shifts/show.html.erb b/app/views/origami/shifts/show.html.erb index 0f9265e6..f2ee019e 100755 --- a/app/views/origami/shifts/show.html.erb +++ b/app/views/origami/shifts/show.html.erb @@ -168,6 +168,17 @@ } else if(payment_type == "CUP"){ $("#loading_wrapper").hide(); + swal({ + title: 'Information!', + text: 'Settlement is successfully.', + type: 'success', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/shift/close'; + }); // reqCBBankAlipaySettlement(); } // else if(payment_type == "Alipay"){