order reservation pdf setting

This commit is contained in:
phyusin
2018-11-29 13:19:29 +06:30
parent ed6310d462
commit 27f76e291b
5 changed files with 100 additions and 22 deletions

View File

@@ -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*/
/* online order count*/
/* pdf print out */
function print_receipt(){
}
/* pdf print out */

View File

@@ -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?

View File

@@ -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

View File

@@ -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

View File

@@ -651,3 +651,32 @@
</div>
</div>
</div>
<!-- pdf light box -->
<div class="modal fade" id="receciptpdfModal" tabindex="-1" role="dialog" >
<div class="modal-dialog modal-md " role="document">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title">
<span id="receiptpdfModalLabel"></span>
<span id="changed_amount" class="p-l-120"></span>
</h6>
</div>
<div class="modal-body" style="height: 400px;">
<input type="hidden" name="sale_receipt_no" id="sale_receipt_no">
<input type="hidden" name="filename" id="filename">
<input type="hidden" name="printer_name" id="printer_name">
<div class="text-center">
<iframe id="receipt_pdf" src="" class="pdf-iframe" scrolling="no"></iframe>
</div>
</div>
<div class="modal-footer">
<button type="button" class="mr-2 m-t-5 btn-lg btn-block bg-red waves-effect print_receipt" id="print_receipt"> Print
</button>
<button type="button" class="btn-lg btn-block bg-blue waves-effect btn_pdf_close" data-dismiss="modal">
CLOSE
</button>
</div>
</div>
</div>
</div>