diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js
index 87b74809..b2f94bc0 100644
--- a/app/assets/javascripts/origami.js
+++ b/app/assets/javascripts/origami.js
@@ -51,6 +51,7 @@ $(document).ready(function(){
var customer_id=$(this).find(".customer-id").text();
show_customer_details(customer_id);
+ $("#re-print").val(unique_id);
var cashier="";
var receipt_date="";
@@ -199,6 +200,14 @@ $(document).ready(function(){
return false;
});
+ $('#re-print').click(function() {
+ var sale_id = $(".selected-item").find(".orders-id").text();
+
+ window.location.href = '/origami/'+ sale_id + "/reprint"
+
+ return false;
+ });
+
function show_customer_details(customer_id){
if(window.location.pathname.substring(0, 12) == "/origami/SAL"){
@@ -297,19 +306,25 @@ function control_button(order_status){
$("#request_bills").prop('disabled', true);
$("#discount").prop('disabled', false);
$("#pay-bill").prop('disabled', false);
+ $("#re-print").prop('disabled', true);
}
else if(order_status=="new") {
$("#customer").prop('disabled', false);
$("#request_bills").prop('disabled', false);
$("#discount").prop('disabled', true);
$("#pay-bill").prop('disabled', true);
+ $("#re-print").prop('disabled', true);
+ }else if(order_status=="completed"){
+ $("#re-print").prop('disabled', false);
}
else {
$("#customer").prop('disabled', true);
$("#request_bills").prop('disabled', true);
$("#discount").prop('disabled', true);
$("#pay-bill").prop('disabled', true);
+ $("#re-print").prop('disabled', true);
}
+
}
/* For Receipt - Update Balance */
diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb
index 01cedcbe..92c4fe3f 100644
--- a/app/controllers/origami/payments_controller.rb
+++ b/app/controllers/origami/payments_controller.rb
@@ -77,4 +77,28 @@ class Origami::PaymentsController < BaseOrigamiController
end
end
end
+
+ def reprint
+
+ sale_id = params[:sale_id]
+
+ saleObj = Sale.find(sale_id)
+
+ unique_code = "ReceiptBillPdf"
+ customer= Customer.find(saleObj.customer_id)
+
+ # get member information
+ member_info = Customer.get_member_account(customer)
+
+ # get printer info
+ print_settings=PrintSetting.find_by_unique_code(unique_code)
+
+ # Calculate Food and Beverage Total
+ food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
+
+ printer = Printer::ReceiptPrinter.new(print_settings)
+ printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
+ end
+
+
end
diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb
index 9f6cd7d6..66d65aea 100644
--- a/app/views/origami/home/index.html.erb
+++ b/app/views/origami/home/index.html.erb
@@ -383,6 +383,6 @@
-
+
diff --git a/config/routes.rb b/config/routes.rb
index fc21337a..e1baa28d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -83,7 +83,7 @@ Rails.application.routes.draw do
post "/:id/discount" => "discounts#create"
get "/:id/request_bills" => "request_bills#print"
-
+ get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' }
#--------- Payment ------------#
get 'sale/:sale_id/payment' => 'payments#show'