Files
sx-fc/app/views/origami/payments/show.html.erb
Aung Kyaw Phyoe 7ded9a9045 payment btn
2019-02-07 13:18:36 +06:30

1847 lines
76 KiB
Plaintext
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<% if !@print_settings.nil? %>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% end %>
<div class="row clearfix">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<div class="card">
<div class="card-header m-l-5 m-r-5">
<div id="order-title">
<div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Receipt No :</strong> <span id="receipt_no"><%=@sale_data.receipt_no rescue ' '%></span></div>
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Receipt Date :</strong> <span id="receipt_date"><%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %></span></div>
</div>
<div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Table No :</strong> <%=@table_no%></div>
<span class="hidden" id="dining"><%if !@dining.nil?%><%= @dining.id%><%end%></span>
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Sale ID :</strong> <span id="sale_id"><% if @sale_data %><%=@sale_data.sale_id %><% end %></span></div>
</div>
<div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6">
<strong>Customer :</strong>
<% if @cashier_type == 'quick_service' || @cashier_type == 'food_court' %>
<button type="button" class="btn bg-info waves-effect" id='customer_name'><%= @sale_data.customer.name%></button>
<% else %>
<span id="customer_name"><%= @sale_data.customer.name%></span>
<% end %>
<span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span></div>
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Checkin Time : </strong> <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %>
<%end%></div>
</div>
</div>
</div>
<div class="card-block m-l-5 m-r-5 m-t--10">
<div class="card-title">
<div id="table-details" class="card-text" >
<table class="table" id="append-table">
<tr>
<!-- <tr> -->
<th>#</th>
<th class="item-name">Items</th>
<th class="item-attr">QTY</th>
<th class="item-attr">Price</th>
<!-- </tr> -->
</tr>
</table>
</div>
</div>
<div id="order-detail-slimscroll" data-height="300">
<!-- <div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll"> -->
<div id="table-details" class="card-text m-t--10" >
<table class="table" id="append-table">
<tbody>
<% sub_total = 0
count = 0
%>
<% @sale_data.sale_items.each do |sale_item|
count += 1
%>
<% sub_total += sale_item.price%>
<tr>
<td><%= count %></td>
<td class="item-name"><%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%></td>
<td class="item-attr"><%=sale_item.qty%></td>
<td class="item-attr"><%=(number_with_precision(sale_item.price, precision: precision.to_i ))%></td>
</tr>
<%end %>
</tbody>
</table>
</div>
</div>
</div>
<div class="card-footer ">
<table class="table m-t--10 ">
<tfooter>
<tr>
<td class="charges-name"><strong>Sub Total</strong></td>
<td class="item-attr"><strong><span id="sub-total"><%=number_with_precision(sub_total, precision: precision.to_i)%></span></strong></td>
</tr>
<tr>
<%if @sale_data.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>(Discount)</strong></td>
<%end%>
<td class="item-attr"><strong><span>(<%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>)</span></strong></td>
</tr>
<tr>
<td class="charges-name">
<strong>
<% if !@account_arr.empty? %>
Tax
(<% @i = 0
@account_arr.each do |ct| %>
<%=ct.tax_name%>
<% if @account_arr.count != @i+1%>
+ <% @i =+1 %>
<%end%>
<%end %>)
<% else %>
No Tax
<% end %></strong><br>
<%if @sale_payment.nil? && @changable_tax %>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
<% end %>
</td>
<td class="item-attr"><strong><span id="total_tax"><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong><%= number_with_precision(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total</strong></td>
<td class="item-attr"><strong><span><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
</tr>
<%if @balance > 0%>
<tr>
<td class="charges-name"><strong><%= @accountable_type %></strong></td>
<td class="item-attr"><strong><span><%=number_with_precision(@balance, precision: precision.to_i )%></span></strong></td>
</tr>
<% end %>
<% if !@individual_total[0].nil? %>
<tr>
<td class="charges-name">
<strong>Split Bill for <%= @individual_total[0]['total_customer'] %> persons</strong>
</td>
<td></td>
</tr>
<tr>
<td class="charges-name">
<strong>Amount Due (per person)</strong>
</td>
<td class="item-attr"><strong><span><%= number_with_precision(@individual_total[0]['per_person_amount'], precision: precision.to_i )%></span></strong></td>
</tr>
<% end %>
</tfooter>
</table>
</div>
<!-- <div> -->
<!-- <INPUT TYPE="Button" class='btn btn-primary' VALUE="Reprint" onClick="" style='width:120px'/>
<INPUT TYPE="Submit" class='btn btn-primary' VALUE="CANCEL" action="origami/index" style='width:120px'/> -->
<!-- </div> -->
</div>
</div>
<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5">
<div class="card">
<div class="card-header">
<div class="row m-l-5 m-r-5">
<div class="col-md-8"><strong class='amount_balance'>Amount Due <% if !@sale_payment.nil? %>( Credit )<% end %></strong></div>
<div class="col-md-4">
<strong>
<span id="grand_total" class="hidden">
<% if @sale_payment.nil? %>
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
<% else %>
<%= number_with_precision(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
<% end %>
</span>
<span id="amount_due">
<% if @sale_payment.nil? %>
<%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
<% else %>
<%= number_with_precision(@sale_payment[0].payment_amount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%>
<% end %>
</span>
</strong>
</div>
</div>
<div class="row payment cash-color p-l-5 p-r-5">
<div class="col-md-8">Cash</div>
<div class="col-md-4" id="cash" >
<%= number_with_precision(@cash, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
</div>
</div>
<% if @sale_payment.nil? && @cashier_type != "food_court" %>
<div class="row payment credit-color p-l-5 p-r-5" id="credit_payment" >
<div class="col-md-8">Credit</div>
<div class="col-md-4" id="credit"><%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="col-md-4 hidden" id="credit">0</div>
<% end %>
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0 && @unionpaycount == 0.0 && @alipaycount == 0.0 && @paymalcount == 0.0 && @junctionpaycount == 0.0 && @dingacount == 0.0 && @giftvouchercount == 0.0 %>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id="others">
<%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
</div>
</div>
<% else %>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id="other_payment_amount">
<%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
</div>
</div>
<% end %>
</div>
<div class="card-block">
<div class="card-title m-l-5 m-r-5">
<!-- mpu -->
<div class="row <%= @other!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<% if @other != 0.0 %>
<div class="col-md-4 mpu is_card" id="others"><%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="others"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- paypar -->
<div class="row <%= @ppamount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<% if @ppamount != 0.0 %>
<div class="col-md-4" id="ppamount"><%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="ppamount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- Visa -->
<div class="row <%= @visacount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">VISA</div>
<% if @visacount != 0.0 %>
<div class="col-md-4 visa is_card" id="visacount"><%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="visacount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- JCB -->
<div class="row <%= @jcbcount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<% if @jcbcount != 0.0 %>
<div class="col-md-4 jcb is_card" id="jcbcount"><%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="jcbcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- Master -->
<div class="row <%= @mastercount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">MASTER</div>
<% if @mastercount != 0.0 %>
<div class="col-md-4 master is_card" id="mastercount"><%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="mastercount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- <br> -->
<!-- UNIONPAY -->
<div class="row <%= @unionpaycount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">UNIONPAY</div>
<% if @unionpaycount != 0.0 %>
<div class="col-md-4 master is_card" id="unionpaycount"><%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="unionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- Alipay -->
<div class="row <%= @alipaycount!=0.0 ? 'payment others-color' : 'hidden' %>">
<div class="col-md-5"></div>
<div class="col-md-3">Alipay</div>
<% if @alipaycount != 0.0 %>
<div class="col-md-4 alipay is_card" id="alipaycount"><%= number_with_precision(@alipaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="alipaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- PAYMAL -->
<div class="row <%= @paymalcount!=0.0 ? 'payment others-color' : 'hidden'%>">
<div class="col-md-5"></div>
<div class="col-md-3">PAYMAL</div>
<% if @paymalcount != 0.0 %>
<div class="col-md-4 master is_card" id="paymalcount"><%= number_with_precision(@paymalcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="paymalcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- DINGA -->
<div class="row <%= @dingacount!=0.0 ? 'payment others-color' : 'hidden'%>">
<div class="col-md-5"></div>
<div class="col-md-3">DINGA</div>
<% if @dingacount != 0.0 %>
<div class="col-md-4 master is_card" id="dingacount"><%= number_with_precision(@dingacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="dingacount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- Junction Pay -->
<div class="row <%= @junctionpaycount!=0.0 ? 'payment others-color' : 'hidden'%>">
<div class="col-md-5"></div>
<div class="col-md-3">JUNCTION PAY</div>
<% if @junctionpaycount != 0.0 %>
<div class="col-md-4 master is_card" id="junctionpaycount"><%= number_with_precision(@junctionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="junctionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<!-- Gift Voucher -->
<div class="row <%= @giftvouchercount!=0.0 ? 'payment others-color' : 'hidden'%>">
<div class="col-md-5"></div>
<div class="col-md-3">GIFT VOUCHER</div>
<% if @giftvouchercount != 0.0 %>
<div class="col-md-4 master is_card" id="giftvouchercount"><%= number_with_precision(@giftvouchercount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
<% else %>
<div class="col-md-4" id="giftvouchercount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
<% end %>
</div>
<div class="row m-l-5 m-r-5">
<div class="col-md-8"><strong class='amount_balance'>Balance</strong></div>
<div class="col-md-4"><strong><span id='balance'><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></span></strong></div>
</div>
<!-- <br> -->
</div>
</div>
<div class="card-footer">
<div class="row m-l-5 m-r-5">
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="row bottom">
<div class="col-md-4 cashier_number border-top border- border-left" data-value="1" data-type="num">1</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="2" data-type="num">2</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-top border- border-left" data-value="4" data-type="num">4</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="5" data-type="num">5</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-top border- border-left" data-value="7" data-type="num">7</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="8" data-type="num">8</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-top border- border-left" data-value="0" data-type="num">0</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="." data-type="num">.</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-top border- border-left green" data-type="nett">Nett</div>
<div class="col-md-4 cashier_number border-top border- border-left red" data-type="del">Del</div>
<div class="col-md-4 cashier_number border-top border- border-left orange" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<div class="row bottom">
<div class="cashier_number border-top border- border-left payment-long payment-left" data-value="1000" data-type="add">1000</div>
<div class="cashier_number border-top border- border-left payment-long" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom">
<div class="cashier_number border-top border- border-left payment-long payment-left" data-value="5000" data-type="add">5000</div>
<div class="cashier_number border-top border- border-left payment-long" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom">
<div class="pay border-top border- border-left purple payment-left" id="pay">Pay</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
<button type="button" class="btn btn-block btn-default waves-effect" id='back'>
<i class="material-icons">reply</i>
Back
</button>
<!-- -->
<% if current_login_employee.role == "cashier" %>
<% if @other_payment <= 0 && @sale_payment.nil? %>
<%if @sale_data.total_discount == 0 %>
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="foc"> FOC</a>
<% end %>
<%end %>
<% if @sale_payment.nil? %>
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
<% if @other_payment <= 0 %>
<%if @sale_data.total_discount == 0 %>
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="waste"> Waste</a>
<a class="btn btn-block bg-deep-purple waves-effect access_modal" data-toggle="modal" data-type="spoile"> Spoile</a>
<% end %>
<% end %>
<% end %>
<% else %>
<% if @other_payment <= 0 && @sale_payment.nil?%>
<%if @sale_data.total_discount == 0 %>
<button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button>
<%end %>
<%end %>
<% if @sale_payment.nil? %>
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
<% if @other_payment <= 0 %>
<%if @sale_data.total_discount == 0 %>
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="waste" value="waste" id="btn_waste" onclick="waste_and_spoilage('waste')">Waste</button>
<button type="button" class="btn btn-block bg-deep-purple waves-effect " data-status="spoile" value="spoile" id="btn_spoile" onclick="waste_and_spoilage('spoile')">Spoile</button>
<% end %>
<% end %>
<% end %>
<% end %>
<% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment.nil? %>
<hr>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect" >Customer</button>
<% if current_login_employee.role == "cashier" %>
<a class="btn btn-block bg-blue waves-effect access_modal" data-toggle="modal" data-type="edit">Edit</a>
<% else %>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<% end %>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
<!-- Waiter Buttons -->
<%end %>
</div>
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
</div>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="voidModalLabel">Please Enter Reason for Void</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-red waves-effect " id="void" active="true">VOID</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="focModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="focModalLabel">Please Enter Reason for FOC</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="foc_remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link bg-red waves-effect " id="foc" active="true">FOC</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- pdf light box -->
<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">
<h6 class="modal-title">
<span id="pdfModalLabel"></span>
<span id="changed_amount" class="p-l-120"></span>
</h6>
</div>
<div class="modal-body" style="height: 400px;">
<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">
<div class="text-center">
<iframe id="receipt_pdf" src="" class="pdf-iframe" scrolling="no"></iframe>
</div>
</div>
<div class="modal-footer">
<button type="button" class="mr-2 m-t-5 btn-lg btn-block bg-red waves-effect print_receipt" id="print_receipt"> Print
</button>
<button type="button" class="btn-lg btn-block bg-blue waves-effect btn_pdf_close" data-dismiss="modal">
CLOSE
</button>
</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">
<h1 class="modal-title" id="is_memberModalLabel">Are you Member?</h1>
</div>
<div class="modal-body">
<input type="hidden" name="paypar_account_no" id="paypar_account_no" />
<input type="hidden" name="qr_code" id="qr_code" />
<div class="row text-center m-t-20">
<% if !@customer_lists.nil? %>
<% @customer_lists.each do |cus| %>
<% if cus.customer_id != @customer.id %>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_customer_assign" data-id='<%= cus.customer_id %>'><%= cus.name %></button>
</div>
<% end %>
<% end %>
<% end %>
</div>
<div class="row text-center m-t-20">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_member">Card Member</button>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_qr_code">QR Code</button>
</div>
</div>
<div class="row clearfix"></div>
<div class="row text-center m-t-20">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<button type="button" class="btn btn-lg btn-link bg-green waves-effect btn_customer_yes">Yes</button>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<button type="button" class="btn btn-lg btn-link bg-red waves-effect" data-dismiss="modal">No</button>
</div>
</div>
</div>
<div class="modal-footer"></div>
</div>
</div>
</div>
<div class="modal fade" id="AccessCodeModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="AccessCodeModalLabel">Enter Access Code</h4>
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#111;">&times;</button>
</div>
<div class="modal-body" style="padding: 0px 25px 15px 25px !important">
<input type="password" id="access_code" class="access_code form-control col-md-12 ">
<div class="row bottom p-l-15 p-r-15 m-t-10">
<div class="col-md-3 access_number border-top border-left" data-value="1" data-type="num">1</div>
<div class="col-md-3 access_number border-top border-left" data-value="2" data-type="num">2</div>
<div class="col-md-3 access_number border-top border-left" data-value="3" data-type="num">3</div>
<div class="col-md-3 access_number border-top border-left" data-value="4" data-type="num">4</div>
</div>
<div class="row bottom p-l-15 p-r-15">
<div class="col-md-3 access_number border-top border-left" data-value="5" data-type="num">5</div>
<div class="col-md-3 access_number border-top border-left" data-value="6" data-type="num">6</div>
<div class="col-md-3 access_number border-top border-left" data-value="7" data-type="num">7</div>
<div class="col-md-3 access_number border-top border-left" data-value="8" data-type="num">8</div>
</div>
<div class="row bottom p-l-15 p-r-15">
<div class="col-md-3 access_number border-top border-left" data-value="9" data-type="num">9</div>
<div class="col-md-3 access_number border-top border-left" data-value="0" data-type="num">0</div>
<div class="col-md-3 access_number border-top border-left orange" data-type="clr">Clr</div>
<div class="col-md-3 access_number ok border-top border-left blue" data-type="ok" data-action="">OK</div>
</div>
</div>
</div>
</div>
</div>
<!-- change tax modal -->
<div class="modal fade" id="change_taxModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="change_taxModalLabel">TAX</h1>
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#111;">&times;</button>
</div>
<div class="modal-body">
<% if !@tax_arr.empty? %>
<% if @tax_arr.count > 1 %>
<div class="row text-center">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="all">
<% @i = 0
@tax_arr.each do |tax| %>
<%= tax %>
<% if @tax_arr.count != @i+1%>
+ <% @i =+1 %><br>
<%end%>
<% end %>
</button>
</div>
<% @tax_arr.each_with_index do |tax, tax_index| %>
<% if (tax_index+1)%2 == 0 %>
<div class="row clearfix"></div>
<% end %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>">
<%= tax %>
</button>
</div>
<% end %>
<% else %>
<div class="row clearfix"></div>
<div class="row text-center">
<% @tax_arr.each do |tax| %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>"><%= tax %></button>
</div>
<% end %>
<% end %>
<% end %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="no_tax">No Tax</button>
</div>
</div>
</div>
</div>
<div class="modal-footer"></div>
</div>
</div>
</div>
<div id="sxModal">
<div id="sxModal-Content">
<h3>Card Tap</h3>
</div>
<div class="m-r-20" align="right">
<button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button>
</div>
</div>
<!-- customer light box -->
<div class="modal fade m-t-40" id="is_paymemberModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<!-- <h1 class="modal-title" id="is_paymemberModalLabel">Are you Member?</h1> -->
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<input type="hidden" name="paypar_account_no" id="paypar_account_no" />
<input type="hidden" name="qr_code" id="qr_code" />
<div class="row text-center m-t-20" align="center">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<button type="button" class="btn btn-lg btn-link bg-primary btn_paymal_member">Card</button>
</div>
<!-- <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_paymal_qr_code">QR Code</button>
</div> -->
</div>
</div>
<div class="modal-footer"></div>
</div>
</div>
</div>
<script type="text/javascript">
// //control borwser back
window.location.hash="no-back-button";
window.location.hash="Again-No-back-button";//again because google chrome don't insert first hash into history
window.onhashchange=function(){window.location.hash="";}
var cashier_type = "<%= @cashier_type %>";
var customer_id = "<%= @customer.id %>";
var customer_name = "<%= @customer.name %>";
var pdf_view = '<%=@pdf_view%>';
var trans_flag = <%= @trans_flag %>;
var paymalcount = <%= @paymalcount %>;
// console.log(pdf_view)
$(document).ready(function(){
$("#sxModal").hide();
if(cashier_type == "food_court" && paymalcount == 0.0){
$("#is_paymemberModal").modal({show : true, backdrop : false, keyboard : false});
}
setHeaderBreadCrumb(_PAYMENTS_);
/* replace url type*/
if(!trans_flag){
localStorage.setItem("trans_flag", trans_flag);
var sale_id = $('#sale_id').text();
window.location.replace('/origami/sale/'+sale_id+'/cashier/payment');
}
/* replace url type*/
/* start check first bill or not*/
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
payment_type = '';
// if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment");
// console.log(payment_type)
// console.log(parseInt(jQuery.inArray("MPU", payment_type)))
if (member_id && member_discount) {
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
$("#credit_payment").hide();
} else{
$("#credit_payment").show();
}
if(parseInt(jQuery.inArray("MPU", payment_type)) != -1 ||
parseInt(jQuery.inArray("VISA", payment_type)) != -1 ||
parseInt(jQuery.inArray("JCB", payment_type)) != -1 ||
parseInt(jQuery.inArray("Master", payment_type)) != -1 ||
parseInt(jQuery.inArray("UNIONPAY", payment_type)) != -1 ||
parseInt(jQuery.inArray("Redeem", payment_type)) != -1 ||
parseInt(jQuery.inArray("PAYMAL", payment_type)) != -1 ||
parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 ||
parseInt(jQuery.inArray("Alipay", payment_type)) != -1 ||
parseInt(jQuery.inArray("DINGA", payment_type)) != -1 ||
parseInt(jQuery.inArray("GiftVoucher", payment_type)) != -1){
$("#card_payment").show();
} else{
$("#card_payment").hide();
}
}
// }
/* end check first bill or not*/
var dining_id = "<%= @sale_data.bookings[0].dining_facility_id %>";
$("#back").on('click', function() {
localStorage.removeItem('cash');
customer_display_view(null,"reload");
var sale_id = $('#sale_id').text();
var flag = localStorage.getItem("trans_flag");
if((flag!=null) && (flag != "true")){
window.location.href = '/transactions/sales/'+sale_id;
}else{
if (cashier_type=="cashier") {
window.location.href = '/origami/table/'+ dining_id;
}else{
window.location.href = '/origami/'+cashier_type+'/pending_order/'+sale_id;
}
}
});
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){
}
else {
$('#cash').text(localStorage.getItem("cash"));
}
update_balance();
//checkChangableTax
checkChangableTax();
// Disable click event cash to prevent
$(".payment .cash-color").off('click');
$('#credit_payment').click(function() {
var sale_id = $('#sale_id').text();
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type+"/payment/credit_payment"
return false;
});
$('#card_payment').click(function() {
localStorage.setItem("cash",$('#cash').text() );
var sale_id = $('#sale_id').text();
var url_param = "payment";
if(location.pathname.includes("credit_payment")){
url_param = "credit_payment";
}
if(cashier_type != "food_court"){
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/"+url_param+"/others_payment";
return false;
}else{
if(paymalcount == 0.0){
$("#is_paymemberModal").modal({show : true, backdrop : false, keyboard : false});
}
}
});
$('#pay').click(function() {
sub_total = $('#sub-total').text();
member = $('#membership_id').text();
// console.log(member)
if (parseInt(jQuery.inArray("MPU", payment_type)) != -1 && $('.mpu').text() == 0 && sub_total != 0.0 && member) {
swal("Oops","Please Pay with MPU Payment","warning");
}else if(parseInt(jQuery.inArray("Redeem", payment_type)) != -1 && $('#ppamount').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Redeem Payment","warning");
}else if(parseInt(jQuery.inArray("VISA", payment_type)) != -1 && $('#visacount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Visa Payment","warning");
}else if(parseInt(jQuery.inArray("JCB", payment_type)) != -1 && $('#jcbcount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with jcb Payment","warning");
}
else if(parseInt(jQuery.inArray("Master", payment_type)) != -1 && $('#mastercount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Master Payment","warning");
}
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with UNIONPAY Payment","warning");
}
else if(parseInt(jQuery.inArray("Alipay", payment_type)) != -1 && $('#alipaycount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Alipay Payment","warning");
}
else if(parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 && $('#junctionpaycount').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with JUNCTIONPAY Payment","warning");
}
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Credit Payment","warning");
}else if(parseInt(jQuery.inArray("PAYMAL", payment_type)) != -1 && $('#paymalcount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Paymal Payment","warning");
}else if(parseInt(jQuery.inArray("DINGA", payment_type)) != -1 && $('#dingacount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Dinga Payment","warning");
}else if(parseInt(jQuery.inArray("GiftVoucher", payment_type)) != -1 && $('#giftvouchercount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Gift Voucher","warning");
}else{
$( "#loading_wrapper").show();
if($('#balance').text() > 0){
swal ( "Oops", "Insufficient Amount!" , "error" );
$("#loading_wrapper").hide();
}else{
$(this).off("click");
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
if (credit <= 0 && (!location.pathname.includes("credit_payment"))) {
calculate_member_discount(sale_id,tax_type);
}
// $("#pdfModal").on('shown.bs.modal', function () {
// $('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
/* check credit payment or not*/
if(location.pathname.includes("credit_payment")){
var url = "<%= origami_credit_payment_cash_path %>";
}else{
var url = "<%= origami_payment_cash_path %>";
}
$.ajax({type: "POST",
url: url,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
}
else{
var msg = '';
}
$("#loading_wrapper" ).hide();
if(location.pathname.includes("credit_payment")){
payment_success_alert();
}else{
//PDF lightbox data
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
$("#sale_receipt_no").val(result.receipt_no);
$("#filename").val(result.filename);
$("#printer_name").val(result.printer_name);
$("#receipt_pdf").attr("src", pdfPath);
$("#changed_amount").text("");
if($('#balance').text() < 0){
<% if precision.to_i > 0 %>
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)).toFixed(<%= precision %>));
<% else %>
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)));
<% end %>
}
if (pdf_view == 1) {
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
$("#pdfModalLabel").text("Sale Completed");
}else{
//PDF lightbox data
print_receipt();
}
}
}
});
}
}
});
// $('#void').on('click',function () {
// if ($(this).attr('active') === "true") {
// var sale_id = $('#sale_id').text();
// var remark = $("#remark").val();
// var ajax_url = "/origami/sale/" + sale_id + '/void';
// $.ajax({
// type: 'POST',
// url: ajax_url,
// data: "remark="+ remark + "&sale_id=" + sale_id,
// success: function () {
// window.location.href = '/origami/';
// }
// })
// }else{
// swal("Oops","You are not authorized for void","warning")
// }
// });
});
// bind survey to order or sale
$("#survey").on('click', function () {
var sale = $('#sale_id').text();
if (sale) {
var sale_id = sale
} else {
var sale_id = $('#dining').text();
}
//var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/' + sale_id +"/"+ cashier_type + "/surveys";
});
// bind customer to order or sale
$("#customer").on('click', function () {
var sale = $('#sale_id').text();
if (sale) {
var sale_id = sale
} else {
var sale_id = $('#save_order_id').attr('data-order');
}
var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/' + sale_id + "/"+cashier_type+"/customers/payment";
});
// Add Other Charges
$('#other-charges').click(function () {
var sale = $('#sale_id').text();
if (sale != "") {
var sale_id = sale
} else {
var sale_id = $('#save_order_id').attr('data-order');
}
if (sale_id != "") {
window.location.href = '/origami/' + sale_id +"/"+cashier_type+ '/other_charges'
}
else {
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
});
// Discount for Payment
$('#discount').click(function () {
if ($(this).attr('active')=== "true") {
var sale = $('#sale_id').text();
if (sale != "") {
var sale_id = sale
} else {
var sale_id = $('#save_order_id').attr('data-order');
}
if (sale_id != "") {
window.location.href = '/origami/' + sale_id + "/"+cashier_type+'/discount'
}
else {
swal ( "Oops" , "Please select an table!" , "warning" );
}
}else{
swal("Oops","You are not authorized for Discount","warning")
}
return false;
});
$('#edit').on('click', function () {
var dining_id = $('#dining').text();
var sale_id = $('#sale_id').text();
if ($(this).attr('active')=== "true") {
if (dining_id) {
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/"+cashier_type+"/edit";
}else{
window.location.href = "/origami/table/sale/" + sale_id + "/"+cashier_type+"/edit";
}
}else{
swal("Oops","You are not authorized for void","warning")
}
});
$(document).on('click', '.cashier_number', function(event){
if(event.handled !== true) {
var original_value;
original_value = parseFloat($('#cash').text());
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#cash').text(input_value);
update_balance();
}else{
if($('#cash').text() == '0'){
$('#cash').text("");
}
$('#cash').append(input_value);
update_balance();
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#cash').text(amount);
update_balance();
break;
case 'del' :
var cash=$('#cash').text();
if(cash.length == 1)
$('#cash').text("0.0");
else
$('#cash').text(cash.substr(0,cash.length-1));
update_balance();
break;
case 'clr':
$('#cash').text("0.0");
update_balance();
break;
case 'nett':
var credit1 = $('#credit').text();
var card1 = $('#others').text();
var paypar1 = $('#ppamount').text();
var visa1 = $('#visacount').text();
var jcb1 = $('#jcbcount').text();
var master1 = $('#mastercount').text();
var unionpay1 = $('#unionpaycount').text();
var paymal1 = $('#paymalcount').text();
var alipay1 = $('#alipaycount').text();
var junctionpay1 = $('#junctionpaycount').text();
var dingapay1 = $('#dingacount').text();
var giftvoucherpay1 = $('#giftvouchercount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1) + parseFloat(alipay1) + parseFloat(junctionpay1) + parseFloat(paymal1) + parseFloat(dingapay1) + parseFloat(giftvoucherpay1);
var total = $('#amount_due').text();
var amt = 0;
<% if precision.to_i > 0 %>;
amt = parseFloat(parseFloat(total) - parseFloat(othertotal)).toFixed(<%= precision %>);
<% else %>
amt = parseFloat(parseFloat(total) - parseFloat(othertotal));
<% end %>
$('#cash').text(amt);
update_balance();
break;
}
event.handled = true;
} else {
return false;
}
});
function update_balance(){
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#others').text();
var paypar = $('#ppamount').text();
var visa = $('#visacount').text();
var jcb = $('#jcbcount').text();
var master = $('#mastercount').text();
var unionpay = $('#unionpaycount').text();
var paymal = $('#paymalcount').text();
var alipay = $('#alipaycount').text();
var junctionpay = $('#junctionpaycount').text();
var dinga = $('#dingacount').text();
var giftvoucher = $('#giftvouchercount').text();
var amount_due = $('#amount_due').text();
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay) + parseFloat(alipay) + parseFloat(junctionpay) + parseFloat(paymal) + parseFloat(dinga) + parseFloat(giftvoucher);
var result = parseFloat(amount_due) - parseFloat(total);
<% if precision.to_i > 0 %>
$('#balance').text(parseFloat(result).toFixed(<%= precision %>));
<% else %>
$('#balance').text(parseFloat(result));
<% end %>
show_hide_btn($('#balance').text());
}
function customer_display_view(data,status) {
$.ajax({
type: "POST",
url: '../../../customer_view',
data: {"data":data,"status":status},
dataType: "json",
success:function(result){
}
});
}
function calculate_member_discount(sale_id,tax_type) {
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
var item_row = $('.is_card');
if (member_id && member_discount) {
if (item_row.length < 1) {
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_type, 'tax_type':tax_type },
async: false,
success:function(result){
}
});
}
}
//print pdf function
// $(".print_receipt").on('click',function(){
$("#print_receipt").on('click touchstart', function(event){
$(this).off("click touchstart touchend");
print_receipt();
});
function print_receipt() {
if($('#pay').is(":visible")) {
$('#pay').prop("disabled",true);
}
var sale_id = $('#sale_id').text();
var filename = $("#filename").val();
var printer_name = $("#printer_name").val();
var receipt_no = $("#sale_receipt_no").val();
var params = { 'filename':filename, 'receipt_no':receipt_no, 'printer_name':printer_name };
$.ajax({
type: "POST",
url: "/origami/sale/"+sale_id+"/"+cashier_type+"/payment/print",
data: params,
success:function(result){
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
if (pdf_view ==1) {
var flag = localStorage.getItem("trans_flag");
localStorage.removeItem("trans_flag");
if((flag!=null) && (flag != "true")){
window.location.href = "/transactions/sales/"+sale_id;
}else{
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/'+cashier_type;
if (cashier_type=="quick_service"){
customer_display_view(null,"reload");
}
}
}
}else{
payment_success_alert();
}
}
});
}
function payment_success_alert(){
var title = "Payment Successful!";
if($('#balance').text() < 0){
var text = 'Changed amount ' + $('#balance').text() * (-1);
}else{
$('#pay').text("Pay");
var text = 'Thank You !';
}
var sale_id = $('#sale_id').text();
swal({
title: "Payment Successful!",
text: text,
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
var flag = localStorage.getItem("trans_flag");
localStorage.removeItem("trans_flag");
if((flag!=null) && (flag != "true")){
window.location.href = '/transactions/sales/'+sale_id;
}else{
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else {
window.location.href = '/origami/'+cashier_type;
if(cashier_type=="quick_service"){
customer_display_view(null,"reload");
}
}
}
});
}
$(".btn_pdf_close").on('click',function(){
var flag = localStorage.getItem("trans_flag");
if((flag!=null) && (flag != "true")){
var sale_id = $('#sale_id').text();
window.location.href = "/transactions/sales/"+sale_id;
}else{
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/'+cashier_type;
}
}
});
$(".btn_customer_yes").on('click',function(){
var sale_id = $('#sale_id').text();
window.location.href = "/origami/"+sale_id+"/"+cashier_type+"/customers/payment";
});
// Read Card Reader
$(".btn_member").on('click', function(){
var cardNo = "";
var customer_id = '';
var customer_name = '';
var membership_id = '';
var membership_type = '';
var sale_id = $("#sale_id").text() || 0;
var customer_mamber_card_no = 0;
$("#is_memberModal").hide();
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : customer_mamber_card_no ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
membership_id = data[0].membership_id;
membership_type = data[0].membership_type;
update_sale(membership_id, customer_id, customer_name,sale_id);
}
}
});
}
},100);
});
// Read NFC card no from java
function getCardNo(){
if(typeof code2lab != 'undefined'){
code2lab.readNFC();
}
}
// get CardNo from Java
function setCardNo(cardNo){
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
}
}
// QR Code Reader
$(".btn_qr_code").on('click', function(e){
$("#is_memberModal").hide();
var code = "";
var customer_id = '';
var customer_name = '';
var membership_id = '';
var membership_type = '';
setTimeout(function(){
code=getQRCode();
$("#qr_code").val(code);
});
if(sale_id != 0 && code != ""){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : code ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
membership_id = data[0].membership_id;
membership_type = data[0].membership_type;
update_sale(membership_id, customer_id, customer_name,sale_id);
}
}
});
}
});
// Read qrcode from java
function getQRCode(){
return code2lab.readQRCode();
}
function update_sale(membership_id, customer_id, customer_name, sale_id) {
var customer="";
if(customer_name != ""){
customer = '(' + customer_name + ')';
}
swal({
title: "Confirmation !",
text: 'Are You Sure to assign this customer' + customer + '!',
showCancelButton: true,
confirmButtonColor: "green",
confirmButtonText: "Yes!",
cancelButtonClass: 'btn btn-danger',
closeOnConfirm: false,
}, function () {
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
//change customer detail
$("#customer_name").html(customer_name);
$("#membership_id").html(membership_id);
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
swal("Alert!", "Record not found!", "error");
location.reload();
}
}
});
});
}
$("#sxModal .btn_cancel").on('click',function(){
$("#sxModal").hide();
});
$(".btn_customer_assign").on('click', function(){
var customer_id = $(this).attr('data-id');
var customer_name = $(this).text();
var sale_id = $("#sale_id").text() || 0;
update_sale("", customer_id, customer_name, sale_id);
});
$(document).on('click', '.access_modal', function(event){
type = $(this).data("type");
$(".ok").attr("data-action",type)
$('#AccessCodeModal').modal('show');
});
function check_emp_access_code(access_code,type) {
var url = "/origami/check_emp_access_code/" + access_code ;
$.ajax({
type: 'POST',
url: url,
data: {},
success: function (result) {
// console.log(result)
if (result.status == true) {
createAccessCode(code);
if (type == "edit") {
var dining_id = $('#dining').text();
var sale_id = $('#sale_id').text();
if (dining_id) {
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/"+cashier_type+"/edit";
}else{
window.location.href = "/origami/table/sale/" + sale_id + "/"+cashier_type+"/edit";
}
}else if(type == "void"){
$('#AccessCodeModal').modal('hide');
$('#voidModal').modal('show');
// overall_void();
}else if(type == "waste") {
// $('#AccessCodeModal').modal('hide');
// $('#focModal').modal('show');
waste_and_spoilage("waste")
}else if(type == "spoile") {
// $('#AccessCodeModal').modal('hide');
// $('#voidModal').modal('show');
waste_and_spoilage("spoile")
}else if(type == "foc"){
$('#AccessCodeModal').modal('hide');
$('#focModal').modal('show');
// overall_foc();
}
}else{
swal("Oops",result.message,"warning");
}
}
});
}
$('#foc').on('click', function () {
var access_code = localStorage.getItem("access_code");
var remark = $("#foc_remark").val();
var cash = $('#grand_total').text();
var sub_total = $('#sub-total').text();
var sale_id = $('#sale_id').text();
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total,'remark':remark,'type':cashier_type,'access_code':access_code };
swal({
title: "Alert",
text: "Are you sure want to FOC This Receipt?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, FOC it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
type: "POST",
url: "/origami/payment/"+cashier_type+"/foc",
data: params,
success:function(result){
customer_display_view(null,"reload");
if (cash >= 0) {
swal({
title: "Information!",
text: 'Thank You !',
}, function () {
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
var flag = localStorage.getItem("trans_flag");
if((flag!=null) && (flag != "true")){
window.location.href = '/transactions/sales/'+sale_id;
}else{
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/'+cashier_type;
}
}
});
}
}
});
}
});
});
$('#void').on('click', function () {
var access_code = localStorage.getItem("access_code");
swal({
title: "Alert",
text: "Are you sure want to Void?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, void it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var sale_id = $('#sale_id').text();
var remark = $("#remark").val();
var ajax_url = "/origami/sale/" + sale_id +'/'+cashier_type+ '/void';
$.ajax({
type: 'POST',
url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
success: function (result) {result
customer_display_view(null,"reload");
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
var flag = localStorage.getItem("trans_flag");
if((flag!=null) && (flag != "true")){
window.location.href = '/transactions/sales/'+sale_id;
}else{
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/'+cashier_type;
}
}
}
})
}
});
});
function waste_and_spoilage(remark) {
var access_code = localStorage.getItem("access_code");
var sale_id = $('#sale_id').text();
swal({
title: "Alert",
text: "Are you sure want to " + remark +" ?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, " +remark+ " it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var url = "/origami/sale/" + sale_id +'/'+cashier_type+'/waste_and_spoilage';
$.ajax({
type: 'POST',
url: url,
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
success: function (result) {
// console.log(result)
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
var flag = localStorage.getItem("trans_flag");
if((flag!=null) && (flag != "true")){
window.location.href = '/transactions/sales/'+sale_id;
}else{
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/'+cashier_type;
if(cashier_type=="quick_service"){
customer_display_view(null,"reload");
}
}
}
}
});
}
});
}
/* Start function for tax changable */
$(".change_tax").on("click",function(){
var balance = parseFloat($("#balance").text());
var sub_total = parseFloat($("#sub-total").text());
var total_tax = parseFloat($("#total_tax").text());
if(balance > 0 && (balance >= total_tax)){
$("#change_taxModal").modal({show: true, backdrop: false, keyboard: false});
}
else{
swal("Oops","You cann't change tax!","warning");
}
});
$("button[name=tax_type]").on("click", function(){
var type = $(this).attr("data-value");
var cashier_type = '<%= @cashier_type %>';
var sale_id = $('#sale_id').text();
localStorage.removeItem("tax_type");
swal({
title: "Alert",
text: "Are you sure want to change tax?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, change it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
type: "POST",
url: "/origami/payment/"+cashier_type+"/change_tax",
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: type},
success:function(data){
if(data.status){
// console.log(type);
localStorage.setItem("tax_type", type);
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment';
}
}
});
}else{
swal.close();
}
});
});
/* End function for tax changable */
/* check change tax is available or not*/
function checkChangableTax(){
var balance = parseFloat($("#balance").text());
var sub_total = parseFloat($("#sub-total").text());
var total_tax = parseFloat($("#total_tax").text());
if(balance > 0 && (balance >= total_tax)){
$(".change_tax").show();
}else{
$(".change_tax").hide();
}
}
/* customer light-box */
$("#customer_name").on("click",function(){
//start customer modal popup
if((cashier_type=='quick_service' || cashier_type=='food_court') && (customer_id!=undefined) && (customer_id!=null) && (customer_id!="")){
// if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
// }
}
});
// Read Card Reader - Paymal payment for FoodCourt
$(".btn_paymal_member").on('click', function (){
var cardNo = "";
var sale_id = $("#sale_id").text() || 0;
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
var customer_mamber_card_no = 0;
var payment_amount = parseFloat($("#grand_total").text());
$("#is_paymemberModal").hide();
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0;
}
if(sale_id != 0 && customer_mamber_card_no !=0){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/send_account" ,
data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
dataType: "json",
success: function(data) {
if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
// $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({
type: "POST",
url: "<%=origami_payment_paymal_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no},
success: function(result){
if(result.status == true){
swal({
title: "Information!",
text: result.message,
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
});
}else{
swal({
title: 'Oops',
text: result.message,
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: data.message.toString(),
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: 'Please Check Member',
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
},100);
});
// QR Code Reader
$(".btn_paymal_qr_code").on('click', function(e){
$("#is_paymemberModal").hide();
var code = "";
var sale_id = $("#sale_id").text() || 0;
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
var payment_amount = parseFloat($("#grand_total").text());
setTimeout(function(){
code=getQRCode();
if(sale_id != 0 && code != ""){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/send_account" ,
data: { account_no : code, amount : payment_amount, receipt_no : receipt_no},
dataType: "json",
success: function(data) {
if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
// $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({
type: "POST",
url: "<%=origami_payment_paymal_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:code},
success: function(result){
if(result.status == true){
swal({
title: "Information!",
text: result.message,
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
});
}else{
swal({
title: 'Oops',
text: result.message,
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: 'Please Check Member',
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}
},100);
});
function show_hide_btn(balance) {
// show discount when balance is greater than 0
// if(parseFloat(balance) > 0){
// $("#discount").show();
// $("#edit").show();
// }else{
// $("#discount").hide();
// $("#edit").hide();
// }
}
</script>