Files
sx-fc/app/views/origami/movetable/move_dining.html.erb
2017-10-24 18:16:03 +06:30

296 lines
9.6 KiB
Plaintext
Executable File

<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
<!-- Nav tabs -->
<ul class="nav nav-tabs tab-col-teal" role="tablist" id="mytab">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Tables</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#rooms" role="tab">Rooms</a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="max-height:570px; overflow:auto">
<!--- Panel 0 - Completed Orders -->
<!--- Panel 1 - Table Orders -->
<div class="tab-pane active" id="tables" role="tabpanel">
<div class="card-columns" style="padding-top:10px;" >
<% @tables.each do |table| %>
<% if table.status == 'occupied' %>
<div class="card tables red text-white" data-id="<%= table.id %>" data-name="<%= table.name %>">
<div class="card-block">
<%= table.name %>
</div>
</div>
<% else %>
<div class="card tables green text-white" data-id="<%= table.id %>" data-name="<%= table.name %>">
<div class="card-block">
<%= table.name %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<!--- Panel 2 - Room Orders -->
<div class="tab-pane" id="rooms" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;" >
<% @rooms.each do |room| %>
<% if room.status == 'occupied' %>
<div class="card rooms red text-white" data-id="<%= room.id %>" data-name="<%= room.name %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% else %>
<div class="card rooms green text-white" data-id="<%= room.id %>" data-name="<%= room.name %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<!--- Panel 3 - s -->
</div>
<!-- tabs - End -->
</div>
<!-- Column One -->
<!-- Column Two -->
<div class="col-lg-5 col-md-5 col-sm-5">
<div class="card" >
<div class="card-header">
<div><strong id="order-title"> MOVE --> <span style='color:red'> ' <%= @dining.name %> ' </span> to <span style='color:blue' id="moved"> </span></strong></div>
<input type='hidden' id="change_table_value" value="" />
</div>
<div class="card-block">
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6">
<p> Receipt No: <span id="receipt_no">
<% if @status_sale == 'sale' %>
<%= @sale_array[0].receipt_no rescue '' %>
<% end %>
</span></p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
</div>
</div>
<div class="card-text" style="min-height:500px; max-height:500px; overflow:auto" >
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-attr">QTY</td>
<th class="item-attr">Price</td>
</tr>
</thead>
<tbody>
<%
count = 0
sub_total = 0
if @status_sale == "sale"
puts @sale_array[0]
@sale_array[0].sale_items.each do |sale_item|
count += 1
sub_total = sub_total + sale_item.price
%>
<input type="hidden" id="sale_id" value="<%= @sale_array[0].sale_id %>">
<% unless sale_item.price <= 0 %>
<tr>
<td><%= count %></td>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.price %></td>
</tr>
<%
end
end
end
if @status_order == 'order' && @status_sale != 'sale'
unless @order_items.nil?
count = 0
@order_items.each do |order_item |
puts @order_items.size
puts "view"
count += 1
sub_total = sub_total + order_item.price
unless order_item.price <= 0 %>
<tr>
<td><%= count %></td>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
end
end
end
%>
</tbody>
</table>
</div>
<%
if @status_sale == 'sale'
unless @order_items.nil?
%>
Pending New Order
<table class="table table-striped">
<%
@order_items.each do |order_item |
%>
<tr>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
%>
</table>
<button class='btn btn-blue'> Add to existing invoice </button>
<%
else
@sale_array.each do |sale|
if @sale_array.size > 1
unless sale.receipt_no == @sale_array[0].receipt_no
%>
Pending Payment
<table class="table table-striped">
<tr>
<td>Receipt No - <%= sale.receipt_no %></td>
<td><button class='btn btn-lg btn-blue '>Show Detail </button></td>
</tr>
</table>
<%
end
end
end
end
end
%>
<div class="row">
<div class="col-md-12">
<div class="pay purple" id="move_table">MOVE TABLE</div>
</div>
</div>
</div>
</div>
</div>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-default btn-block" id='back'>Back</button>
</div>
</div>
<script>
$(document).ready(function(){
$(".tables").on('click', function(){
$('.tables').removeClass('selected-item');
$(this).addClass('selected-item');
var dining_name = $(this).attr("data-name");
var dining_id = $(this).attr("data-id");
var change_from = "<%= @dining.id %>";
if (dining_id == change_from) {
/*$.alert({
title: 'Alert!',
content: 'Please Select Another Table',
type: 'red',
typeAnimated: true,
btnClass: 'btn-danger',
});*/
swal({
title: "Alert!!",
text: 'Please Select Another Table !',
type: 'warning',
});
}else{
$('#moved').text(" ' " + dining_name + " ' ")
$('#change_table_value').val(dining_id);
}
})
$(".rooms").on('click', function(){
$('.rooms').removeClass('selected-item');
$(this).addClass('selected-item');
var dining_name = $(this).attr("data-name");
var dining_id = $(this).attr("data-id");
var change_from = "<%= @dining.id %>";
if (dining_id == change_from) {
swal({
title: "Alert!!",
text: 'Please Select Another Table !',
type: 'warning',
});
}else{
$('#moved').text(dining_name)
$('#change_table_value').val(dining_id);
}
})
$('#move_table').on('click',function(){
change_to = $('#change_table_value').val();
change_from = "<%= @dining.id %>";
if (change_to == ""){
swal({
title: "Alert!!",
text: 'Please Select Table !',
type: 'warning',
});
}else{
$.ajax({type: "POST",
url: "<%= origami_moving_path %>",
data: "change_from="+ change_from + "&change_to=" + change_to,
success:function(result){
swal({
title: "Information!",
text: 'Moving Success',
type: 'success',
}, function (){
if (result.get_type == 'Table'){
window.location.href = '/origami/table/' + change_to;
}else{
window.location.href = '/origami/room/' + change_to;
}
});
}
});
}
})
});
$('#back').on('click',function(){
window.location.href = '/origami/table/'+ "<%= @dining.id %>";
})
</script>