cadd print pdf in payment page

This commit is contained in:
phyusin
2018-03-08 10:01:54 +06:30
parent 5d8ba3c416
commit d9a7e341fa
5 changed files with 125 additions and 44 deletions

View File

@@ -1,4 +1,4 @@
<div class="container-fluid" data-no-turbolink="true">
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
@@ -387,7 +387,7 @@
</div>
<!-- pdf light box -->
<div class="modal fade" id="pdfModal" tabindex="-1" role="dialog" data-turbolinks-partial="pdfModal" >
<div class="modal fade" id="pdfModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
@@ -397,18 +397,16 @@
<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">
<input type="hidden" name="print_copies" id="print_copies">
<p id="changed_amount"></p>
<div class="text-center">
<iframe id="receipt_pdf" src="" style="width: 400px; height: 600px;"></iframe>
<!-- <object id="receipt_pdf" data="" type="application/pdf" width="400" height="600"></object> -->
</div>
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<% if ENV["SERVER_MODE"] != 'cloud' %>
<div class="col-md-5">
<button type="button" class="btn btn-link bg-red waves-effect" id="print_pdf" data-turbolinks="false" remote="true">Print</button>
<button type="button" class="btn btn-link bg-red waves-effect print_receipt">Print</button>
</div>
<% end %>
<div class="col-md-5">
@@ -419,11 +417,53 @@
</div>
</div>
</div>
</div>
</div>
<!-- customer light box -->
<div class="modal fade" id="is_memberModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="is_memberModalLabel">Is Member?</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-4">
<button type="button" class="btn btn-link bg-green waves-effect">Yes</button>
</div>
<div class="col-md-4">
<button type="button" class="btn btn-link bg-red waves-effect" data-dismiss="modal">No</button>
</div>
<div class="col-md-4">
<button type="button" class="btn btn-link bg-primary waves-effect">Member</button>
</div>
<div class="col-md-4">
<button type="button" class="btn btn-link bg-primary waves-effect">QR</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var cashier_type = "<%= @cashier_type %>";
var customer_id = "<%= @customer.id %>";
var customer_name = "<%= @customer.name %>";
$(document).ready(function(){
console.log(customer_name);
console.log(customer_id);
// if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){
// $("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
// }
/* start check first bill or not*/
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
@@ -552,7 +592,6 @@ var cashier_type = "<%= @cashier_type %>";
//PDF lightbox data
$("#sale_receipt_no").val(result.receipt_no);
$("#filename").val(result.filename);
$("#print_copies").val(result.count);
$("#printer_name").val(result.printer_name);
$("#receipt_pdf").attr("src", result.filename);
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
@@ -566,7 +605,6 @@ var cashier_type = "<%= @cashier_type %>";
<% end %>
}
//PDF lightbox data
// if($('#balance').text() < 0){
// swal({
// title: "Payment Successful!",
@@ -888,14 +926,14 @@ var cashier_type = "<%= @cashier_type %>";
}
}
$('#print_pdf').off('click');
//print pdf function
$("#print_pdf").on('click',function(){
$(".print_receipt").on('click',function(){
var sale_id = $('#sale_id').text();
var filename = $("#filename").val();
var printer_name = $("#printer_name").val();
var receipt_no = $("#sale_receipt_no").val();
var print_copies = $("#print_copies").val();
var params = { turbolinks: false, remote : true, 'filename':filename, 'receipt_no':receipt_no, 'print_copies':print_copies, 'printer_name':printer_name };
var params = { 'filename':filename, 'receipt_no':receipt_no, 'printer_name':printer_name };
// swal({
// title: "Alert",
// text: "Are you sure want to print?",
@@ -908,15 +946,15 @@ var cashier_type = "<%= @cashier_type %>";
// if (isConfirm) {
$.ajax({
type: "POST",
url: "<%= origami_payment_print_path %>",
url: "/origami/sale/"+sale_id+"/"+cashier_type+"/payment/print",
data: params,
success:function(result){
console.log(result);
// if (cashier_type=="cashier") {
// window.location.href = '/origami';
// }else{
// window.location.href = '/origami/quick_service';
// }
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
}
});
// }