update payment select
This commit is contained in:
@@ -520,30 +520,31 @@
|
||||
<span class="hidden" id="member_discount"><%= @membership.discount%></span>
|
||||
<span class="hidden" id="membership_id"><%= @obj_sale.customer.membership_id rescue 0%></span>
|
||||
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="paymentModalLabel">Choose Payment Method</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<select class="form-control show-tick payment_method" multiple="true" id="payment_method" >
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="paymentModalLabel">Choose Payment Method</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- <select class="form-control show-tick payment_method" multiple="true" id="payment_method" > -->
|
||||
<!-- <option value="Cash">Cash</option> -->
|
||||
<option value="Credit">Credit</option>
|
||||
<% @payment_methods.each do |pay| %>
|
||||
<option value="<%= pay.payment_method %>">
|
||||
<%= pay.payment_method %>
|
||||
</option>
|
||||
<%end %>
|
||||
<button class='btn btn- waves-effect payment_btn ' data-type='Credit' data-value='Credit'>Credit</button>
|
||||
<% @payment_methods.each do |pay| %>
|
||||
<!-- <option value="<%= pay.payment_method %>">
|
||||
<%= pay.payment_method %>
|
||||
</option> -->
|
||||
<button class='btn btn- waves-effect payment_btn ' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
|
||||
<%end %>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="modal-footer p-r-30">
|
||||
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
<!-- </select> -->
|
||||
</div>
|
||||
<div class="modal-footer p-r-30">
|
||||
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
|
||||
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -735,11 +736,32 @@
|
||||
});
|
||||
});
|
||||
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.payment_btn', function(event){
|
||||
active = $(this).hasClass('selected-payment');
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
group = $(this).data('group');
|
||||
payments = $(".payment_btn");
|
||||
$(payments).each(function(i){
|
||||
if ($(payments[i]).attr('data-type')==type){
|
||||
$('.'+type).removeClass("selected-payment");
|
||||
}
|
||||
});
|
||||
if (active) {
|
||||
$(this).removeClass('selected-payment');
|
||||
}else{
|
||||
$(this).addClass('selected-payment');
|
||||
}
|
||||
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
$(".choose_payment").on('click', function () {
|
||||
$( "#loading_wrapper").show();
|
||||
|
||||
var sale_id = $('#sale_id').val();
|
||||
type = $('.payment_method').val();
|
||||
console.log(type)
|
||||
if(parseInt(jQuery.inArray("Credit", type)) == -1){
|
||||
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1) {
|
||||
calculate_member_discount(sale_id,"Card");
|
||||
@@ -749,21 +771,21 @@
|
||||
}
|
||||
}
|
||||
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: ajax_url,
|
||||
success: function (result) {
|
||||
$( "#loading_wrapper" ).hide();
|
||||
receipt_no = ($("#receipt_no").html()).trim();
|
||||
if((receipt_no!=undefined) && (receipt_no!=""))
|
||||
createReceiptNoInFirstBillData(receipt_no,type);
|
||||
// For Server Print - from jade
|
||||
if ($("#server_mode").val() == "cloud") {
|
||||
code2lab.printFile(result.filepath, result.printer_url);
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
// $.ajax({
|
||||
// type: "GET",
|
||||
// url: ajax_url,
|
||||
// success: function (result) {
|
||||
// $( "#loading_wrapper" ).hide();
|
||||
// receipt_no = ($("#receipt_no").html()).trim();
|
||||
// if((receipt_no!=undefined) && (receipt_no!=""))
|
||||
// createReceiptNoInFirstBillData(receipt_no,type);
|
||||
// // For Server Print - from jade
|
||||
// if ($("#server_mode").val() == "cloud") {
|
||||
// code2lab.printFile(result.filepath, result.printer_url);
|
||||
// }
|
||||
// location.reload();
|
||||
// }
|
||||
// });
|
||||
});
|
||||
|
||||
function calculate_member_discount(sale_id,type) {
|
||||
|
||||
Reference in New Issue
Block a user