diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js index 00d04f89..a5bdb968 100644 --- a/app/assets/javascripts/order_reservation.js +++ b/app/assets/javascripts/order_reservation.js @@ -504,17 +504,26 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas dataType: "json", success: function(data) { if (data.status) { - swal({ - title: 'Information', - text: "Order has been "+data.message, - type: 'success', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/order_reservation'; - }); + if(status != "completed"){ + swal({ + title: 'Information', + text: "Order has been "+data.message, + type: 'success', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/order_reservation'; + }); + }else{ + //PDF lightbox data + var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6); + $("#sale_receipt_no").val(result.receipt_no); + $("#filename").val(result.filename); + $("#printer_name").val(result.printer_name); + $("#receipt_pdf").attr("src", pdfPath); + } }else{ swal({ title: 'Oops', @@ -672,4 +681,10 @@ function getOnlineOrderCount(){ // alert(count); return count; } -/* online order count*/ \ No newline at end of file +/* online order count*/ + +/* pdf print out */ +function print_receipt(){ + +} +/* pdf print out */ \ No newline at end of file diff --git a/app/controllers/api/check_in_process_controller.rb b/app/controllers/api/check_in_process_controller.rb index 7609dd79..602ef600 100644 --- a/app/controllers/api/check_in_process_controller.rb +++ b/app/controllers/api/check_in_process_controller.rb @@ -11,7 +11,7 @@ class Api::CheckInProcessController < Api::ApiController booking = nil end else - booking = dining_facility.get_current_checkout_booking + booking = dining_facility.get_current_booking end if !booking.nil? diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index 67df6e6f..3474fec7 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -5,11 +5,7 @@ class Origami::OrderReservationController < BaseOrigamiController @count_on_order = OrderReservation.get_count_on_order @count_on_completed = OrderReservation.get_count_on_completed @shop = Shop.find_by_id(1) - receipt_bill = Lookup.collection_of("order_reservation") - @receipt_bill = 0 - if !receipt_bill[0].nil? - @receipt_bill = receipt_bill[0][1] - end + @receipt_bill = check_receipt_bill end def update @@ -23,6 +19,7 @@ class Origami::OrderReservationController < BaseOrigamiController end remark = params[:remark] access_code = params[:access_code] + receipt_bill = check_receipt_bill order_reserve = OrderReservation.find_by_transaction_ref(params[:ref_no]) if !order_reserve.nil? @@ -45,7 +42,7 @@ class Origami::OrderReservationController < BaseOrigamiController end elsif @status == "completed" if order_reserve.status == "ready_to_delivery" - result = OrderReservation.update_doemal_payment(order_reserve,current_user) + result = OrderReservation.update_doemal_payment(order_reserve,current_user,receipt_bill) else Rails.logger.debug "Order reservation :: " + order_reserve.to_json + " :: send status ::" + @status result = {status: false, message: 'Could not deliver order!'} @@ -106,4 +103,19 @@ class Origami::OrderReservationController < BaseOrigamiController render :json => order_reservation end + def check_receipt_bill + receipt_bill = Lookup.collection_of("order_reservation") + + status = 0 + if !receipt_bill.nil? + receipt_bill.each do |receipt| + if receipt[0].strip.downcase == "receiptbill" + status = receipt[1].to_i + end + end + end + + return status + end + end diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb index e38a53d9..e799547d 100644 --- a/app/models/order_reservation.rb +++ b/app/models/order_reservation.rb @@ -145,7 +145,7 @@ class OrderReservation < ApplicationRecord return result end - def self.update_doemal_payment(order,current_user) + def self.update_doemal_payment(order,current_user,receipt_bill) if(Sale.exists?(order.sale_id)) saleObj = Sale.find(order.sale_id) shop_details = Shop.first @@ -175,8 +175,30 @@ class OrderReservation < ApplicationRecord #order reservation status updated update_order_reservation(order.id, saleObj.sale_id, DELIVERED) - result = {:status=> true, :message => DELIVERED } - return result + if receipt_bill == 1 + #receipt bill pdf setting + # get printer info + unique_code = "ReceiptBillOrderPdf" + print_settings=PrintSetting.find_by_unique_code(unique_code) + # Calculate Food and Beverage Total + item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) + discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) + 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,card_balance_amount) + #receipt bill pdf setting + + result = {:status=> true, + :filepath => filename, + :receipt_no => sale_receipt_no, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings , + :message => DELIVERED } + else + result = {:status=> true, :message => DELIVERED } + end + return result end end diff --git a/app/views/origami/order_reservation/index.html.erb b/app/views/origami/order_reservation/index.html.erb index d4c4e9cf..d6d50307 100644 --- a/app/views/origami/order_reservation/index.html.erb +++ b/app/views/origami/order_reservation/index.html.erb @@ -651,3 +651,32 @@ + + +