add req bill and payment #left order and sale
This commit is contained in:
@@ -41,10 +41,22 @@
|
||||
<th><%= t :cashier %></th>
|
||||
<th><%= t("views.right_panel.detail.sales_status") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_generated_at") %></th>
|
||||
<% if @sale["sale_status"] == "completed" %>
|
||||
<% if @sale.sale_status == "completed" %>
|
||||
<th>
|
||||
<button type="button" class="btn btn-block bg-red waves-effect" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void</button>
|
||||
</th>
|
||||
<% else %>
|
||||
<% if current_login_employee.role == "administrator" %>
|
||||
<%if @membership.discount && @sale.customer.membership_id %>
|
||||
<th>
|
||||
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">Pay</button>
|
||||
</th>
|
||||
<%else%>
|
||||
<th>
|
||||
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
|
||||
</th>
|
||||
<%end%>
|
||||
<%end%>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -266,7 +278,107 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
|
||||
<span class="hidden" id="member_discount"><%= @membership.discount%></span>
|
||||
<span class="hidden" id="membership_id"><%= @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" > -->
|
||||
<!-- <option value="Cash">Cash</option> -->
|
||||
<div class="row text-center">
|
||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||
<button class='btn btn-md waves-effect payment-btn-box payment_btn bg-green' data-type='Credit' data-value='Credit'>Credit</button>
|
||||
</div>
|
||||
|
||||
<% @payment_methods.each_with_index do |pay, pay_index| %>
|
||||
<%if (pay_index+1)%3 == 0 %>
|
||||
<div class="row clearfix"></div>
|
||||
<% end %>
|
||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||
<button class='btn btn-md payment-btn-box waves-effect payment_btn bg-green' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
|
||||
</div>
|
||||
<%end %>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- </select> -->
|
||||
</div>
|
||||
<div class="modal-footer p-r-30 pb-3">
|
||||
<button type="button" class="btn btn-md btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
|
||||
<button type="button" class="btn btn-md btn-link bg-blue waves-effect choose_payment">SAVE</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Get Selected Class
|
||||
function get_selected_attributes(selected_class) {
|
||||
var item_row = $('.'+selected_class);
|
||||
var attribute_arr = [];
|
||||
$(item_row).each(function(i){
|
||||
value = $(item_row[i]).attr('data-value');
|
||||
str = value;
|
||||
attribute_arr.push(str);
|
||||
});
|
||||
return attribute_arr;
|
||||
}
|
||||
|
||||
function calculate_member_discount(sale_id,type,tax_type) {
|
||||
var sub_total = $('#sub-total').text();
|
||||
if (type == "Cash") {
|
||||
is_card = false
|
||||
}else{
|
||||
is_card = true
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/origami/" + sale_id + "/member_discount",
|
||||
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier','tax_type':tax_type },
|
||||
async: false,
|
||||
success:function(result){ }
|
||||
});
|
||||
}
|
||||
|
||||
function createReceiptNoInFirstBillData(receipt_no,payment) {
|
||||
var arr_data = [];
|
||||
var json_data = [];
|
||||
if(localStorage.hasOwnProperty("receipt_lists") === true){
|
||||
arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
||||
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
|
||||
if (payment) {
|
||||
jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
||||
jdata.push({'receipt_no':receipt_no,'payment':payment});
|
||||
localStorage.setItem("receipt_lists",JSON.stringify(jdata));
|
||||
}
|
||||
}
|
||||
if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){
|
||||
arr_data.push({'receipt_no':receipt_no,'payment':payment});
|
||||
localStorage.setItem("receipt_lists",JSON.stringify(arr_data));
|
||||
}
|
||||
}
|
||||
|
||||
// click select option icon for add
|
||||
$('.payment_btn').on('click', function(event){
|
||||
active = $(this).hasClass('selected-payment');
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
group = $(this).data('group');
|
||||
payments = $(".payment_btn");
|
||||
|
||||
if (active) {
|
||||
$(this).removeClass('selected-payment');
|
||||
}else{
|
||||
$(this).addClass('selected-payment');
|
||||
}
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
$('#void').on('click', function () {
|
||||
var access_code = localStorage.getItem("access_code");
|
||||
if ($(this).attr('active')=== "true") {
|
||||
@@ -280,7 +392,7 @@
|
||||
closeOnConfirm: false
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
var sale_id = "<%= @sale.sale_id %>"
|
||||
var sale_id = "<%= @sale.sale_id %>";
|
||||
// console.log(sale_id)
|
||||
var ajax_url = "/transactions/sales/" + sale_id + '/cashier/void';
|
||||
var remark = $("#remark").val();
|
||||
@@ -291,10 +403,10 @@
|
||||
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
|
||||
success: function (result) {
|
||||
// For Server Print - from jade
|
||||
if ($("#server_mode").val() == "cloud") {
|
||||
code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||
}
|
||||
window.location.href = '/transactions/sales/';
|
||||
if ($("#server_mode").val() == "cloud") {
|
||||
code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||
}
|
||||
window.location.href = '/transactions/sales/';
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -303,5 +415,38 @@
|
||||
swal("Opps","You are not authorized for void","warning")
|
||||
}
|
||||
});
|
||||
|
||||
$(".choose_payment").on('click', function () {
|
||||
$("#loading_wrapper").show();
|
||||
var sale_id = "<%= @sale.sale_id %>";
|
||||
var type = get_selected_attributes('selected-payment');
|
||||
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
|
||||
|
||||
// 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 || parseInt(jQuery.inArray("PAYMAL",type))!= -1) {
|
||||
if(!location.pathname.includes("credit_payment")){
|
||||
calculate_member_discount(sale_id,"Card",tax_type);
|
||||
}
|
||||
}else{
|
||||
if(!location.pathname.includes("credit_payment")){
|
||||
calculate_member_discount(sale_id,"Cash",tax_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$( "#loading_wrapper" ).hide();
|
||||
receipt_no = "<%= @sale.receipt_no %>";
|
||||
if((receipt_no!=undefined) && (receipt_no!=""))
|
||||
createReceiptNoInFirstBillData(receipt_no,type);
|
||||
|
||||
window.location = '/origami/sale/'+sale_id+'/transaction/payment';
|
||||
});
|
||||
|
||||
$('#pay').on('click', function() {
|
||||
var sale_id = "<%= @sale.sale_id %>";
|
||||
window.location = '/origami/sale/'+sale_id+'/transaction/payment';
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user