finish reprint

This commit is contained in:
Aung Myo
2017-06-15 19:07:33 +06:30
parent b5743eb7a7
commit f0ea6f3c56
4 changed files with 41 additions and 2 deletions

View File

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

View File

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

View File

@@ -383,6 +383,6 @@
<button type="button" id="discount" class="btn btn-primary btn-lg btn-block">Discount</button>
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> -->
<button type="button" id="pay-bill" class="btn btn-primary btn-lg btn-block">Pay</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button>
<button type="button" id="re-print" class="btn btn-primary btn-lg btn-block">Re.Print</button>
</div>
</div>

View File

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