fixed conflix after pull split bill

This commit is contained in:
Aung Myo
2018-02-19 14:21:26 +06:30
24 changed files with 977 additions and 275 deletions

View File

@@ -251,8 +251,8 @@ $('#back').on('click',function(){
function warnBeforeRedirect(linkURL) {
swal({
title: "Oops",
text: "Are you sure you want to Logout ?",
title: "Alert!",
text: "Are you sure you want to close cashier?",
type: "warning",
showCancelButton: true
}, function() {

View File

@@ -386,10 +386,8 @@
end
%>
</table>
<button class='btn btn-primary' id='add_invoice'> Add to existing invoice</button>
<% if !@spit_bill.nil? && @spit_bill == '1' %>
<button class='btn btn-primary' id='split_bill'> Split Bill</button>
<% end %>
<button class='btn btn-primary btn-block waves-effect' id='add_invoice'> Add to existing invoice</button>
<% end %>
<% if @sale_array.size > 1 %>
<br><br>
@@ -439,6 +437,11 @@
<!-- <button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect" disabled>Charges</button> -->
<button type="button" class="btn btn-block bg-blue waves-effect" id='move'>Move</button>
<button type="button" id="request_bills" class="btn btn-block bg-blue waves-effect">Req.Bill</button>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<!-- <button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect" disabled>First Bill</button> -->
<!-- <button type="button" id="pay" class="btn btn-block bg-blue waves-effect" disabled>Pay</button> -->
<!-- <button type="button" class="btn btn-block bg-blue waves-effect" disabled> Void</button> -->
@@ -461,6 +464,11 @@
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<% end %>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<% end %>
@@ -571,7 +579,7 @@
$("#survey").on('click', function () {
var sale = $('#sale_id').val();
if (sale) {
var sale_id = sale
var sale_id = sale;
} else {
var sale_id = "<%= @dining.id %>";
}
@@ -712,30 +720,6 @@
// Bill Request
$('#request_bills').click(function () {
var lookup_split_bill = '<%= @spit_bill %>';
if(lookup_split_bill == '1'){
swal({
title: "Information!",
text: "Do you want to Split bill?",
type: "success",
showCancelButton: true,
confirmButtonColor: "#009900",
confirmButtonText: "Yes, split it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var dining_id = "<%= @dining.id %>";
window.location.href = '/origami/table/' + dining_id + "/split_bills";
}else{
requestBillProcess();
}
});
}else{
requestBillProcess();
}
});
function requestBillProcess(){
var order_id = $('#save_order_id').attr('data-order');
var ajax_url = "/origami/" + order_id + "/request_bills";
$.ajax({
@@ -750,8 +734,14 @@
location.reload();
}
}
});
}
});
});
//split bill process
$('#split_bills').click(function(){
var dining_id = "<%= @dining.id %>";
window.location.href = '/origami/table/' + dining_id + "/split_bills";
});
$('#move').on('click', function () {
var dining_id = "<%= @dining.id %>";

View File

@@ -200,7 +200,14 @@
%>
<% unless sale_item.price <= 0 %>
<tr>
<td class='item-name'><%= sale_item.item_name %></td>
<td class='item-name'>
<%= sale_item.item_name %>
<% if !sale_item.set_menu_items.nil?
sale_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.price %></td>
</tr>
@@ -233,7 +240,10 @@
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn bg-default btn-block " id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" class="btn bg-default btn-block waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<% if !@split_bill.nil? && @split_bill == '1' %>
<button type="button" class="btn bg-blue btn-block waves-effect" id='by_order'>By Order</button>
<% end %>
<% if @sale_status != 'completed' %>
<!-- <button type="button" class="btn bg-blue btn-block" id='move'>MOVE</button> -->
<% end %>
@@ -278,5 +288,59 @@
})
$('#move').on('click',function(){
})
});
//order_split
$('#by_order').on('click',function () {
swal({
title: "Alert",
text: "Are you sure, you want to Split?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, split it!",
closeOnConfirm: false
}, function (isConfirm) {
if(isConfirm){
orderSplitBillProcess();
}
});
});
/* function for order items split bill process */
function orderSplitBillProcess(){
var booking = JSON.parse('<%= @booking.to_json.html_safe %>');
var orders = JSON.parse('<%= @orders.to_json.html_safe %>');
var order = JSON.parse('<%= @order.to_json.html_safe %>');
var arr_order = [];
arr_order.push({id : order.order_id});
var dining_id = booking[0].dining_facility_id || 0;
var type = booking[0].type || '';
var customer_id = order.customer_id || '';
var booking_id = "";
if(orders.length == 1){
booking_id = booking[0].booking_id;
}
var ajax_url = "/origami/split_bills";
$.ajax({
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : [], 'order_items' : '', 'orders' : JSON.stringify(arr_order)},
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
}
else{
if(type=='Table'){
window.location.href = '/origami/table/' + dining_id;
}else{
window.location.href = '/origami/room/' + dining_id;
}
}
}
});
}
</script>

View File

@@ -364,10 +364,7 @@
end
%>
</table>
<button class='btn bg-primary' id='add_invoice'> Add to existing invoice </button>
<% if !@spit_bill.nil? && @spit_bill == '1' %>
<button class='btn btn-primary' id='split_bill'> Split Bill</button>
<% end %>
<button class='btn bg-primary btn-block' id='add_invoice'> Add to existing invoice </button>
<% end %>
<% if @sale_array.size > 1 %>
<br><br>
@@ -411,6 +408,11 @@
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
<button type="button" class="btn bg-blue btn-block" id='move'>Move</button>
<button type="button" id="request_bills" class="btn bg-blue btn-block">Req.Bill</button>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<!-- <button type="button" id="first_bill" class="btn bg-blue btn-block" disabled>First Bill</button> -->
<!-- <button type="button" id="pay" class="btn bg-blue btn-block" disabled>Pay</button> -->
<!-- <button type="button" class="btn bg-blue btn-block" disabled=""> Void </button> -->
@@ -435,6 +437,11 @@
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<%end%>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<!-- <button type="button" id="void" class="btn bg-blue btn-block" > Void </button> -->
<% end %>
@@ -714,30 +721,6 @@ $('#pay').on('click',function() {
});
// Bill Request
$('#request_bills').click(function() {
var lookup_split_bill = '<%= @spit_bill %>';
if(lookup_split_bill == '1'){
swal({
title: "Information!",
text: "Do you want to Split bill?",
type: "success",
showCancelButton: true,
confirmButtonColor: "#009900",
confirmButtonText: "Yes, split it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var dining_id = "<%= @room.id %>";
window.location.href = '/origami/room/' + dining_id + "/split_bills";
}else{
requestBillProcess();
}
});
}else{
requestBillProcess();
}
});
function requestBillProcess(){
var order_id = $('#save_order_id').attr('data-order');
var ajax_url = "/origami/" + order_id + "/request_bills";
$.ajax({
@@ -753,7 +736,13 @@ function requestBillProcess(){
}
}
});
}
});
//split bill process
$('#split_bills').click(function(){
var dining_id = "<%= @room.id %>";
window.location.href = '/origami/room/' + dining_id + "/split_bills";
});
$('#move').on('click',function(){
var dining_id = "<%= @room.id %>"

View File

@@ -20,31 +20,93 @@
</div>
<div id="split-order-slimscroll" data-height="70">
<div class="card-text dining">
<% if !@orders.nil? %>
<% if !@orders.empty? %>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="row m-l-5">
<div class="col-lg-3 col-md-3 col-sm-3">
<ul class="nav nav-tabs tabs-left sideways">
<li class="order-row active">
<a href="#all_order" data-toggle="tab"><strong>All</strong></a>
</li>
<% @orders.each.with_index(0) do |order, order_index| %>
<% active_class = "" %>
<% if order_index == 0 %>
<% active_class = "active" %>
<% end %>
<li class="order-row <%= active_class %>">
<a href="#<%= order.order_id %>" data-toggle="tab"><%= order.order_id %></a>
<li class="order-row">
<a href="#<%= order.order_id %>" data-toggle="tab"><strong><%= order.order_id %></strong></a>
</li>
<% end %>
</ul>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="tab-content">
<div class="tab-pane active" id="all_order">
<div class="card-title">
<p class="m-l-2">Order Items</p>
</div>
<div id="order-detail-slimscroll-all_order" data-height="200">
<div class="card-text dining">
<table class="table table-default" id="order-items-table">
<thead>
<tr>
<th class="item-name">Items</th>
<th class="item-attr">QTY</th>
<th class="item-attr">Price</th>
</tr>
</thead>
<tbody>
<% if !@order_items.nil? %>
<% sub_total = 0 %>
<% @order_items.each do |order_item| %>
<% if order_item.include? ('all_order') %>
<% order_item['all_order'].each do |odr_item| %>
<%
sub_total += odr_item['qty'].to_f * odr_item['price'].to_f
%>
<tr class="item-row" id=<%= odr_item['order_items_id'] %> >
<td style="width:60%; text-align:left">
<span id="item-order-id" class="hidden"><%=odr_item['order_id'] %></span>
<span id="item-account-type" class="hidden"><%=odr_item['account_id'] %></span>
<span id="item-name-price">
<%=odr_item['item_name'] %>
<% if !odr_item['set_menu_items'].nil?
odr_item['set_menu_items'].each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</span>
</td>
<td style="width:20%; text-align:right">
<span id="item-qty"><%=odr_item['qty']%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-total-price"><%=(odr_item['qty'].to_f * odr_item['price'].to_f)%></span>
</td>
</tr>
<% end %>
<% end %>
<%
end
%>
<% end %>
</tbody>
</table>
</div>
</div>
<!-- <div class="card-footer"> -->
<table class="table m-b-20" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr align-right"><strong id="order-sub-total"><%=sub_total%></strong></td>
</tr>
</table>
<!-- </div> -->
</div>
<% @orders.each.with_index(0) do |order, order_index| %>
<% active_class = "" %>
<% if order_index == 0 %>
<% active_class = "active" %>
<% end %>
<div class="tab-pane <%= active_class %>" id="<%= order.order_id %>">
<div class="tab-pane" id="<%= order.order_id %>">
<div class="card-title">
<p class="m-l-2">Order Items</p>
</div>
@@ -59,32 +121,34 @@
</tr>
</thead>
<tbody>
<% if !order.order_items.nil? %>
<% if !@order_items.nil? %>
<% sub_total = 0 %>
<% order.order_items.each do |order_item| %>
<% @order_items.each do |order_item| %>
<% if order_item.include? (order.order_id.to_s) %>
<%
sub_total += order_item.qty*order_item.price
sub_total += order_item[order.order_id.to_s]['qty'].to_f * order_item[order.order_id.to_s]['price'].to_f
%>
<tr class="item-row" id=<%= order_item.order_items_id %> >
<tr class="item-row" id=<%= order_item[order.order_id.to_s]['order_items_id'] %> >
<td style="width:60%; text-align:left">
<span id="item-order-id" class="hidden"><%=order_item.order_id%></span>
<span id="item-account-type" class="hidden"><%=order_item.account_id%></span>
<span id="item-order-id" class="hidden"><%=order_item[order.order_id.to_s]['order_id'] %></span>
<span id="item-account-type" class="hidden"><%=order_item[order.order_id.to_s]['account_id'] %></span>
<span id="item-name-price">
<%=order_item.item_name%>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<%=order_item[order.order_id.to_s]['item_name'] %>
<% if !order_item[order.order_id.to_s]['set_menu_items'].nil?
order_item[order.order_id.to_s]['set_menu_items'].each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</span>
</td>
<td style="width:20%; text-align:right">
<span id="item-qty"><%=order_item.qty%></span>
<span id="item-qty"><%=order_item[order.order_id.to_s]['qty']%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-total-price"><%=(order_item.qty*order_item.price)%></span>
<span id="item-total-price"><%=(order_item[order.order_id.to_s]['qty'].to_f * order_item[order.order_id.to_s]['price'].to_f)%></span>
</td>
</tr>
<% end %>
<%
end
%>
@@ -124,13 +188,28 @@
</div>
<div id="split-receipt-slimscroll" data-height="150">
<div class="card-text dining">
<% if !@sale_data.nil? %>
<% if !@sale_data.empty? %>
<table class="table table-default">
<thead>
<th>#</th>
<th>Receipt No.</th>
<th>Total</th>
<th>Action</th>
</thead>
<tbody>
<% @sale_data.each do |sale_data| %>
<% if sale_data.sale_status != 'completed' %>
<tr class="receipt_row" id=<%= sale_data.sale_id %> >
<td>Receipt No. - <span id="receipt_no"><%= sale_data.receipt_no %></span></td>
<% @sale_data.each_with_index do |sale_data, sale_index| %>
<% if sale_data.sale_status != 'completed' && sale_data.sale_status != 'void' %>
<% checked = "" %>
<% if sale_index == 1 %>
<% checked = "checked" %>
<% end %>
<tr class="receipt-row" id=<%= sale_data.receipt_no %> data=<%= sale_data.grand_total %> >
<td><input type="radio" name="rdn_receipt" id="rdn_receipt" value="<%= sale_data.sale_id %>" <%= checked %>></td>
<td><span id="receipt_no"><%= sale_data.receipt_no %></span></td>
<td><span id="grand_total"><%= sale_data.grand_total %></span></td>
<td>
<button type="button" class="btn btn-block waves-effect btn-primary btn_pay" id=<%= sale_data.sale_id %> >Pay</button>
</td>
</tr>
<% end %>
<% end %>
@@ -148,16 +227,96 @@
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Action Panel -->
<div>
<button type="button" class="btn bg-default btn-block" id="back" ><i class="material-icons">reply</i> Back </button>
<button id="order_split" class="btn btn-primary text-center action-btn" style="width:100%">Orders Split</button>
<button id="order_item_split" class="btn btn-primary text-center action-btn">Order Items Split</button>
<button type="button" class="btn bg-default btn-block waves-effect" id="back" ><i class="material-icons">reply</i> Back </button>
<button id="equal_split" class="btn btn-block waves-effect bg-blue">= Split</button>
<button id="order_split" class="btn btn-block waves-effect bg-blue">By Order</button>
<button id="order_item_split" class="btn btn-block waves-effect bg-blue">By Order Item</button>
</div>
</div>
<!-- Column Three -->
</div>
<!-- modal for equal person -->
<div class="modal fade" id="equal_split_modal" tabindex="-1" role="dialog" aria-labelledby="equal_split_modal_label" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="equal_split_modal_label">Equal Split (per person)</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="form-group">
<input type="text" id="per_person" name="per_person" class="form-control" onkeypress="return isNumberKey(event);"/><br>
<span id="per_personErr" style="color:red;"></span>
</div>
</div>
</div>
<hr />
<div class="p-l-50">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="row bottom">
<div class="col-md-9">
<div class="row">
<div class="col-md-3 cashier_number" data-value="1" data-type="num" style="margin-left: 6px;">1</div>
<div class="col-md-3 left cashier_number" data-value="2" data-type="num">2</div>
<div class="col-md-3 left cashier_number" data-value="3" data-type="num">3</div>
</div>
</div>
</div>
<div class="row bottom clearfix">
<div class="col-md-9">
<div class="row">
<div class="col-md-3 cashier_number" data-value="4" data-type="num" style="margin-left: 6px;">4</div>
<div class="col-md-3 left cashier_number" data-value="5" data-type="num">5</div>
<div class="col-md-3 left cashier_number" data-value="6" data-type="num">6</div>
</div>
</div>
</div>
<div class="row bottom">
<div class="col-md-9">
<div class="row">
<div class="col-md-3 cashier_number" data-value="7" data-type="num" style="margin-left: 6px;">7</div>
<div class="col-md-3 left cashier_number" data-value="8" data-type="num">8</div>
<div class="col-md-3 left cashier_number" data-value="9" data-type="num">9</div>
</div>
</div>
</div>
<div class="row bottom">
<div class="col-md-9">
<div class="row">
<div class="col-md-3 cashier_number" style="margin-left: 6px;"></div>
<div class="col-md-3 left cashier_number red" data-type="del">DEL</div>
<div class="col-md-3 left cashier_number green" data-type="clr">CLR</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn bg-default" data-dismiss="modal">Close</button> &nbsp;&nbsp;
<button type="button" class="btn bg-blue btn_per_person">= Split</button>
</div>
</div>
</div>
</div>
<!-- modal for equal person -->
</div>
<script type="text/javascript">
var split_sale_id = "";
var split_receipt_no = "";
var split_total_amount = 0;
$(document).ready(function(){
$('#back').on('click',function(){
@@ -171,28 +330,28 @@
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0"){
$('#per_person').val(input_value);
}
else{
$('#per_person').val(original_value + '' + input_value);
}
var input_value = $(this).attr("data-value");
if (original_value == "0"){
$('#per_person').val(input_value);
}
else{
$('#per_person').val(original_value + '' + input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('#per_person').val(amount);
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('#per_person').val(amount);
break;
case 'del' :
var discount_text=$('#per_person').val();
$('#per_person').val(discount_text.substr(0,discount_text.length-1));
var discount_text=$('#per_person').val();
$('#per_person').val(discount_text.substr(0,discount_text.length-1));
break;
case 'clr':
$('#per_person').val("0");
$('#per_person').val("");
break;
}
event.handled = true;
@@ -242,6 +401,21 @@
// Selected Order
$('.order-row').on('click',function(){
var orders = JSON.parse('<%= @orders.to_json.html_safe %>');
var check_order_id = $(this).find('a').attr('href').substr(1);
if(check_order_id == 'all_order'){
if(orders.length > 0){
$.each(orders, function(key,value){
if($("a[href$='#"+value.order_id+"']").parent().hasClass('selected-split-item')){
$("a[href$='#"+value.order_id+"']").parent().removeClass('selected-split-item');
}
});
}
}else{
$("a[href$='#all_order']").parent().removeClass('selected-split-item');
}
if($(this).hasClass('selected-split-item') == true){
$(this).removeClass('selected-split-item');
}
@@ -254,7 +428,17 @@
$('#order_split').on('click',function () {
var cnt_orders = "<%= @orders.count %>";
var orders = get_selected_orders();// Selected Order Items
var cnt_odrs = parseInt(cnt_orders) - parseInt(orders.length);
var cnt_odrs = 0;
if(orders.length == 1){
if(orders[0].id == 'all_order'){
cnt_odrs = 0;
}else{
cnt_odrs = parseInt(cnt_orders) - parseInt(orders.length);
}
}else{
cnt_odrs = parseInt(cnt_orders) - parseInt(orders.length);
}
if (orders.length > 0){
// if(cnt_odrs > 0){
swal({
@@ -280,12 +464,92 @@
});
//selected receipt row click
$('.receipt_row').on('click',function(){
$('.btn_pay').on('click',function(){
var dining_id = $("#table_id").text();
var sale_id = $(this).attr('id').substr(0,16);
window.location = '/origami/table/' + dining_id + "/table_invoice/" + sale_id;
});
//equal split process
$('#equal_split').on('click', function(){
split_sale_id = $("input[type='radio'][name='rdn_receipt']:checked").val();
split_receipt_no = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('id');
split_total_amount = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('data');
if(split_sale_id != undefined && split_sale_id != ""){
$('#equal_split_modal').modal({backdrop: 'static', keyboard: true, show: true});
}
else{
swal("Opps","Please select one receipt!","warning");
}
});
$('.btn_per_person').on('click', function(){
var person = $('#per_person').val();
if((person!=undefined) && (person!="")){
$("#per_personErr").html('');
$('#equal_split_modal').modal('hide');
if(person > 1){
var ajax_url = "/origami/split_bills/surveys";
var dining_id = $("#table_id").text();
var type = $("#table_type").text();
$.ajax({
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id':dining_id, 'sale_id':split_sale_id, 'receipt_no':split_receipt_no, 'total_customer': person, 'total_amount':split_total_amount },
success: function (result) {
console.log(result);
if(result.status){
var ajax_url = "/origami/sale/" + split_sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
if((split_receipt_no!=undefined) && (split_receipt_no!=""))
createReceiptNoInFirstBillData(split_receipt_no,"");
// location.reload();
// if(type=='Table'){
// window.location.href = '/origami/table/' + dining_id;
// }else{
// window.location.href = '/origami/room/' + dining_id;
// }
window.location.href = '/origami/sale/' + split_sale_id + "/payment";
}
});
}
}
});
}else{
var ajax_url = "/origami/sale/" + split_sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
if((split_receipt_no!=undefined) && (split_receipt_no!=""))
createReceiptNoInFirstBillData(split_receipt_no,"");
// location.reload();
// if(type=='Table'){
// window.location.href = '/origami/table/' + dining_id;
// }else{
// window.location.href = '/origami/room/' + dining_id;
// }
window.location.href = '/origami/sale/' + split_sale_id + "/payment";
}
});
}
}else{
$("#per_personErr").html("can't be blank");
}
});
//equal split process
//slimscroll for order, order items, reciept
var height = ($(window).height() - ($('.legal').outerHeight() + $('.user-info').outerHeight() + $('.navbar').innerHeight()));
@@ -307,6 +571,15 @@
railBorderRadius: '0'
});
$('#order-detail-slimscroll-all_order').slimScroll({
height: height-$('#split-receipt-slimscroll').attr('data-height'),
size: '5px',
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
borderRadius: '0',
railBorderRadius: '0'
});
var orders = JSON.parse('<%= @orders.to_json.html_safe %>');
if(orders.length > 0){
$.each(orders, function(key,order){
@@ -417,6 +690,7 @@ function get_selected_order_items(){
order_item.order_id = $(this).find('#item-order-id').text().trim();
order_item.name = $(this).find('#item-name-price').text().split('@')[0];
order_item.account_id = $(this).find('#item-account-type').text();
order_item.qty = $(this).find('#item-qty').text();
order_item.price = $(this).find('#item-total-price').text();
order_items.push(order_item);
});

View File

@@ -5,42 +5,74 @@
<%= simple_form_for(@survey, :url => origami_create_surveys_path) do |f| %>
<%= f.error_notification %>
<div class="form-inputs p-l-10">
<% if !@survey_data.nil? %>
<%= f.input :child, input_html: { value: @survey_data.child, class: 'col-md-10' }%>
<%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10' }%>
<%= f.input :male , input_html: { value: @survey_data.male, class: 'col-md-10' }%>
<%= f.input :female , input_html: { value: @survey_data.female, class: 'col-md-10' }%>
<%= f.input :total_customer, input_html: { value: @survey_data.total_customer, class: 'col-md-10'} %>
<%= f.input :local , input_html: { value: @survey_data.local, class: 'col-md-10' }%>
<%= f.input :child , input_html: { class: 'col-md-10' }%>
<%= f.input :adult , input_html: { class: 'col-md-10' }%>
<%= f.input :male , input_html: { class: 'col-md-10' }%>
<%= f.input :female , input_html: { class: 'col-md-10' }%>
<%= f.input :total_customer, input_html: { class: 'col-md-10'} %>
<%= f.input :local , input_html: { class: 'col-md-10' }%>
<div class="row clearfix">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Foreigner</label>
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
<select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner][]" style="height: " >
<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
<div class="row clearfix">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Foreigner</label>
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
<select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner][]" style="height: " >
<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
</div>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Number</label>
<input type="number" name="survey[foreigner][]" class="form-control">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Number</label>
<input type="number" name="survey[foreigner][]" class="form-control">
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
<br>
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
<br>
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
</div>
</div>
</div>
<% else %>
<%= f.input :child , input_html: { class: 'col-md-10' }%>
<%= f.input :adult , input_html: { class: 'col-md-10' }%>
<%= f.input :male , input_html: { class: 'col-md-10' }%>
<%= f.input :female , input_html: { class: 'col-md-10' }%>
<%= f.input :total_customer, input_html: { class: 'col-md-10'} %>
<%= f.input :local , input_html: { class: 'col-md-10' }%>
<div class="row clearfix">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Foreigner</label>
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
<select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner][]" style="height: " >
<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
<div class="form-group p-l-10 p-r-10">
<label class="p-l-10">Number</label>
<input type="number" name="survey[foreigner][]" class="form-control">
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
<br>
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
</div>
</div>
<% end %>
<div class="hidden" id="newTemplate" >
</div>
<%if !@dining_facility.nil?%>
<input type="hidden" name="table_id" value="<%= @dining_facility.id %>">
<input type="hidden" name="table_type" value="<%= @table_type %>">
@@ -52,7 +84,15 @@
<%end%>
<input type="hidden" name="sale_id" value="<%=@id%>">
<input type="hidden" name="cashier_type" value="<%=@cashier_type%>">
<% if !@survey_data.nil? %>
<input type="hidden" name="survey_id" value=<%= @survey_data.id %> />
<% else %>
<input type="hidden" name="survey_id" />
<% end %>
<input type="hidden" name="table_id" value="<%=@dining_facility.id%>">
<%= f.input :dining_name, :as => :hidden, :input_html => { :value => @dining_facility.name } %>
<%= f.input :created_by, :as => :hidden, :input_html => { :value => current_login_employee.name } %>
<%= f.input :receipt_no, :as => :hidden, :input_html => { :value => @receipt_no} %>
<%= f.input :total_amount, :as => :hidden, :input_html => { :value => @grand_total } %>

View File

@@ -142,7 +142,7 @@
<div class="col-lg-1 col-md-1 col-sm-1">
<button id="back" type="button" class="btn btn-block btn-lg bg-default"> <i class="material-icons">reply</i> <%= t("views.btn.back") %>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<button type="button" id="void" class="btn bg-danger btn-block"> Void </button>
<button type="button" id="void" class="btn bg-danger btn-block" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true" > Void </button>
</div>
</div>
</div>
@@ -173,22 +173,40 @@ $('#pay').on('click',function() {
window.location.href = '/origami/sale/'+ sale_id + "/cashier/payment";
});
$('#back').on('click',function(){
window.location.href = '/origami/table/<%= @table.id %>';
var lookup_split_bill = '<%= @split_bill %>';
if(lookup_split_bill == '1'){
window.location.href = '/origami/table/<%= @table.id %>/split_bills';
}else{
window.location.href = '/origami/table/<%= @table.id %>';
}
});
$('#void').on('click',function () {
var sure = confirm("Are you sure want to Void");
if (sure == true) {
var sale_id = $('#sale_id').val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami/';
}
})
} else {
$('#void').on('click',function () {
if ($(this).attr('active')=== "true") {
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').val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami/';
}
});
}
});
}else{
swal("Opps","You are not authorized for void","warning")
}
});
</script>