change move table UI

This commit is contained in:
phyusin
2018-01-15 15:04:17 +06:30
parent 51041bf0ae
commit 9095dd46d9
3 changed files with 238 additions and 157 deletions

View File

@@ -19,10 +19,18 @@ class Origami::MovetableController < BaseOrigamiController
order = Order.find(booking_order.order_id) order = Order.find(booking_order.order_id)
@obj_order = order @obj_order = order
@customer = order.customer
@date = order.created_at @date = order.created_at
@booking= booking
order.order_items.each do |item| order.order_items.each do |item|
@order_items.push(item) @order_items.push(item)
end end
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end end
@status_order = 'order' @status_order = 'order'
else else
@@ -32,9 +40,17 @@ class Origami::MovetableController < BaseOrigamiController
if @status_order == 'order' if @status_order == 'order'
@status_order = 'sale' @status_order = 'sale'
end end
@booking= booking
@date = sale.created_at @date = sale.created_at
@status_sale = 'sale' @status_sale = 'sale'
@obj_sale = sale @obj_sale = sale
@customer = sale.customer
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end end
end end
end end

View File

@@ -135,7 +135,7 @@
<div id="save_order_id" data-order=""> <div id="save_order_id" data-order="">
<% end %> <% end %>
<strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %> <strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %>
<% if @booking.checkout_by.nil? && !@booking.reserved_by.nil? && %> <% if @booking.checkout_by.nil? && !@booking.reserved_by.nil? %>
<span class="float-right"><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %></span> <span class="float-right"><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% else %> <% else %>
<span class="float-right">Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span> <span class="float-right">Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span>
@@ -152,7 +152,7 @@
<% else %> <% else %>
<strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %> <strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %>
<% end %> <% end %>
</div> </div>
<div class="card-block"> <div class="card-block">
<div class="card-title"> <div class="card-title">
<div class="row p-l-5 p-r-5"> <div class="row p-l-5 p-r-5">

View File

@@ -15,84 +15,152 @@
</ul> </ul>
<!-- Nav tabs - End --> <!-- Nav tabs - End -->
<div id="custom-slimscroll"> <div id="custom-slimscroll">
<div class="tab-content" style=""> <div class="tab-content" style="">
<!--- Panel 1 - Table Orders --> <!--- Panel 1 - Table Orders -->
<div class="tab-pane active" id="tables" role="tabpanel"> <div class="tab-pane active" id="tables" role="tabpanel">
<div class="card-columns" style="padding-top:10px;" > <div class="card-columns" style="padding-top:10px;" >
<% @tables.each do |table| %> <% @tables.each do |table| %>
<% if table.status == 'occupied' %> <% if table.status == 'occupied' %>
<% if table.get_booking.nil? %>
<% if table.get_checkout_booking.nil? %>
<div class="card tables red text-white" data-id="<%= table.id %>" data-name="<%= table.name %>"> <div class="card tables red text-white" data-id="<%= table.id %>" data-name="<%= table.name %>">
<div class="card-block"> <% else %>
<%= table.name %> <div class="card tables orange text-white" data-id="<%= table.id %>">
<% end %>
<div class="card-block">
<%= table.name %>
</div>
</div>
<% else %>
<% if table.get_checkout_booking.nil? %>
<div class="card tables blue text-white" data-id="<%= table.id %>">
<% else %>
<div class="card tables orange text-white" data-id="<%= table.id %>">
<% end %>
<div class="card-block">
<%= table.name %>
</div>
</div>
<% end %>
<% 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>
</div> </div>
<% else %>
<div class="card tables green text-white" data-id="<%= table.id %>" data-name="<%= table.name %>"> <!--- Panel 2 - Room Orders -->
<div class="card-block"> <div class="tab-pane" id="rooms" role="tabpanel">
<%= table.name %> <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> </div>
<% end %>
<% end %>
</div> </div>
<% end %>
<% end %>
</div>
</div> </div>
<!--- Panel 2 - Room Orders --> <!--- Panel 3 - s -->
<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>
</div> </div>
<!-- tabs - End -->
<!--- Panel 3 - s -->
</div>
</div>
<!-- tabs - End -->
</div> </div>
<!-- Column One --> <!-- Column One -->
<!-- Column Two --> <!-- Column Two -->
<div class="col-lg-5 col-md-5 col-sm-5"> <div class="col-lg-5 col-md-5 col-sm-5">
<div class="card" > <div class="card" >
<div class="card-header"> <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> <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="" /> <input type='hidden' id="change_table_value" value="" />
<% if @status_order == 'order' && @status_sale != 'sale' %>
<% if !@obj_order.nil? %>
<div id="save_order_id" data-order="<%= @obj_order.order_id %>">
<% else %>
<div id="save_order_id" data-order="">
<% end %>
<strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %>
<% if @booking.checkout_by.nil? && !@booking.reserved_by.nil? %>
<span class="float-right"><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% else %>
<span class="float-right">Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% end %>
</div>
<% elsif @status_sale == 'sale' %>
<div><strong id="order-title">INVOICE DETAILS </strong> | Table <%= @dining.name rescue "" %>
<% if !@booking.reserved_by.nil? && %>
<span class="float-right"><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% else %>
<span class="float-right">Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% end %>
</div> </div>
<div class="card-block"> <% else %>
<div class="card-title row"> <strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %>
<div class="col-lg-6 col-md-6 col-sm-6"> <% end %>
<p class="m-l-10"> Receipt No: <span id="receipt_no"> </div>
<% if @status_sale == 'sale' %> <div class="card-block">
<%= @sale_array[0].receipt_no rescue '' %> <div class="card-title">
<% end %> <div class="row p-l-5 p-r-5">
</span></p> <% if (!@sale_array.empty?) && (!@date.nil?) %>
</div> <div class="col-lg-6 col-md-6 col-sm-6">
<div class="col-lg-6 col-md-6 col-sm-6 text-right"> &nbsp; Receipt No: <span id="receipt_no">
<p class="m-r-10">Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p> <% if @status_sale == 'sale' %>
</div> <%= @sale_array[0].receipt_no rescue '' %>
</div> <% end %>
<div class="card-title row customer_detail hide"> </span>
<div class="col-lg-6 col-md-6 col-sm-6"> <br>
<p>Customer : <span id="customer_name"></span></p> </div>
</div> <div class="col-lg-6 col-md-6 col-sm-6 text-right">
Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %></span>
<br>
</div>
<% elsif !@date.nil? %>
<div class="col-lg-7 col-md-7 col-sm-7">
&nbsp; Order No: <span id="order_no">
<% if @status_order == 'order' %>
<%= @obj_order.order_id rescue '' %>
</div> <% end %>
<div id="order-detail-slimscroll" data-height="130"> </span>
<br>
</div>
<div class="col-lg-5 col-md-5 col-sm-5 text-right">
Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y") rescue '-' %></span>
<br>
</div>
<% end %>
</div>
</div>
<div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6">
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @sale_array[0].customer_id rescue '' %></p>
&nbsp; Customer : <%= @sale_array[0].customer.name rescue '' %>
<% elsif @status_order == 'order'
%>
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
&nbsp; Customer : <%= @customer.name rescue "" %>
<% end %>
</div>
</div>
<div id="order-detail-slimscroll" data-height="130">
<div class="card-text" style="" > <div class="card-text" style="" >
<table class="table table-striped" id="order-items-table"> <table class="table table-striped" id="order-items-table">
<thead> <thead>
@@ -100,56 +168,53 @@
<th>#</th> <th>#</th>
<th class="item-name">Items</th> <th class="item-name">Items</th>
<th class="item-attr">QTY</th> <th class="item-attr">QTY</th>
<th class="item-attr">Price</th> <th class="item-attr">Price</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% <%
count = 0 count = 0
sub_total = 0 sub_total = 0
if @status_sale == "sale" if @status_sale == "sale"
puts @sale_array[0] @sale_array[0].sale_items.each do |sale_item|
@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 count += 1
sub_total = sub_total + order_item.price sub_total = sub_total + sale_item.price
%>
unless order_item.price <= 0 %> <input type="hidden" id="sale_id" value="<%= @sale_array[0].sale_id %>">
<% unless sale_item.price <= 0 %>
<tr> <tr>
<td><%= count %></td> <td><%= count %></td>
<td class='item-name'><%= order_item.item_name %></td> <td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= order_item.qty %></td> <td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td> <td class='item-attr'><%= sale_item.price %></td>
</tr> </tr>
<% <%
end end
end end
end end
if @status_order == 'order' && @status_sale != 'sale'
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item |
count += 1
sub_total = sub_total + (order_item.price * order_item.qty)
#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
%> end
</tbody> %>
</table> </tbody>
</table>
</div> </div>
</div> </div>
<% <%
@@ -212,10 +277,10 @@ end
</div> </div>
</div> </div>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$(".tables").on('click', function(){ $(".tables").on('click', function(){
$('.tables').removeClass('selected-item'); $('.tables').removeClass('selected-item');
$(this).addClass('selected-item'); $(this).addClass('selected-item');
var dining_name = $(this).attr("data-name"); var dining_name = $(this).attr("data-name");
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
var change_from = "<%= @dining.id %>"; var change_from = "<%= @dining.id %>";
@@ -227,69 +292,69 @@ $(document).ready(function(){
typeAnimated: true, typeAnimated: true,
btnClass: 'btn-danger', 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({ swal({
title: "Alert!!", title: "Alert!!",
text: 'Please Select Another Table !', text: 'Please Select Another Table !',
type: 'warning', 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{ }else{
$('#moved').text(dining_name) $('#moved').text(dining_name)
$('#change_table_value').val(dining_id); $('#change_table_value').val(dining_id);
} }
}) })
$('#move_table').on('click',function(){ $('#move_table').on('click',function(){
change_to = $('#change_table_value').val(); change_to = $('#change_table_value').val();
change_from = "<%= @dining.id %>"; change_from = "<%= @dining.id %>";
if (change_to == ""){ if (change_to == ""){
swal({ swal({
title: "Alert!!", title: "Alert!!",
text: 'Please Select Table !', text: 'Please Select Table !',
type: 'warning', type: 'warning',
}); });
}else{ }else{
$.ajax({type: "POST", $.ajax({type: "POST",
url: "<%= origami_moving_path %>", url: "<%= origami_moving_path %>",
data: "change_from="+ change_from + "&change_to=" + change_to, data: "change_from="+ change_from + "&change_to=" + change_to,
success:function(result){ success:function(result){
swal({ swal({
title: "Information!", title: "Information!",
text: 'Moving Success', text: 'Moving Success',
type: 'success', type: 'success',
}, function (){ }, function (){
if (result.get_type == 'Table'){ if (result.get_type == 'Table'){
window.location.href = '/origami/table/' + change_to; window.location.href = '/origami/table/' + change_to;
}else{ }else{
window.location.href = '/origami/room/' + change_to; window.location.href = '/origami/room/' + change_to;
} }
}); });
} }
}); });
} }
})
});
$('#back').on('click',function(){
window.location.href = '/origami/table/'+ "<%= @dining.id %>";
}) })
});
$('#back').on('click',function(){
window.location.href = '/origami/table/'+ "<%= @dining.id %>";
})
</script> </script>