Files
sx-fc/app/views/foodcourt/orders/app_orders.html.erb
2020-03-04 10:53:39 +06:30

371 lines
16 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<style type ="text/css">
.assign {
background-color:blue;
}
.completed{
background-color:green;
}
</style>
<%= javascript_include_tag 'custom', 'data-turbolinks-track': 'reload' %>
<button type="button" class="btn btn-block btn-default waves-effect float-right" id='back' style="width: 112px; margin-right: -10px">
<i class="material-icons">reply</i>
Back
</button>
<!-- Nav tabs -->
<ul class="nav nav-tabs tab-col-teal m-t--10" role="tablist">
<li class="nav-item">
<a class="nav-link <%= 'active' if params[:active].blank? %>" data-toggle="tab" href="#mobile_orders" role="tab">Mobile Orders</a>
</li>
<li class="nav-item">
<a class="nav-link <%= params[:active] ? 'active' : '' %>" data-toggle="tab" href="#complete" role="tab"><%= t :competed %></a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="container-fluid " style="padding:0px 3px 0px 3px;margin-top:20px">
<div id="oqs_loading_wrapper" style="display:none;">
<div id="oqs_loading"></div>
</div>
<div class="row m-t--10">
<% if !@booking.nil?%>
<div class="col-md-8 col-lg-8 col-sm-12 float-left">
<% else %>
<div class="col-md-12 col-lg-12 col-sm-12">
<% end %>
<div class="tab-content" id="custom-slimscroll">
<!-- Panel 0 - Mobile Orders -->
<div class="tab-pane <%= 'active' if params[:active].blank? %>" id='mobile_orders' role='tabpanel'>
<div id="custom-slimscroll">
<div class="card-columns">
<% bk_color ='' %>
<% @bookings.each do |bk|
bk_status ='new'
if !@booking.nil?
if bk.booking_id == @booking.booking_id
bk_color ='bg-secondary'
else
bk_color =bk.booking_status
end
else
bk_color =bk.booking_status
end %>
<%= link_to foodcourt_app_order_by_booking_path(booking_id:bk.booking_id), class: 'item-card' do %>
<div class="card <%= bk_color %> text-white" data-id ="<%= bk.booking_id %>">
<div class="card-block">
Cus Ph: <%= bk.contact_no %><span style="font-size:12px;float:right;line-height:inherit;">Order Time: <%= bk.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span><br>
Order No: <%= bk.orders.first.try(:order_id) %><span style="font-size:12px;float:right;line-height:inherit;"><%= bk_status %></span> </div>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
<!--- Panel 1 - Completed Orders -->
<div class="tab-pane <%= params[:active] ? 'active' : '' %>" id="complete" role="tabpanel">
<div class="card-columns">
<% bk_color ='' %>
<% @completed.each do |c| %>
<%
if !@booking.nil?
if c.booking_id == @booking.booking_id
bk_color ='bg-secondary'
else
bk_color = c.booking_status
end
else
bk_color = c.booking_status
end
%>
<%= link_to foodcourt_app_order_by_booking_path(booking_id: c.booking_id, active: 'completed'), class: 'item-card' do %>
<div class="card <%= bk_color %> text-white" data-id ="<%= c.booking_id %>">
<div class="card-block">
Cus Ph: <%= c.contact_no %><span style="font-size:12px;float:right;line-height:inherit;">Order Time: <%= c.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span><br>
Order No: <%= c.orders.first.try(:order_id) %><span style="font-size:12px;float:right;line-height:inherit;">competed</span> </div>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
</div>
<% if !@booking.nil?%>
<div class="col-md-3 col-lg-3 col-sm-12">
<span id="sale_id" style="display:none"><%= @booking.sale_id %></span>
<div class="card">
<div class="card-header" style="padding: 0.12rem 0.25rem">
<div class="row" style="margin:auto">
<div class="col-md-12 col-lg-12 col-sm-12">
<strong id="order-title" class="font-14 p-l-10">ORDER DETAILS </strong>| <span class="font-14">Table-<%=@booking.dining_facility.try(:name)%></span><br>
<span class="font-14 p-l-10"><b>Booking</b> - <%=@booking.booking_id%></span><br>
<span class="font-14 p-l-10"><b>Order No</b> - <%=@booking.order_id%></span>
</div>
</div>
</div>
<div class="card-body">
<div class="card-text" id="order-detail-slimscroll" data-height="320">
<table class="table table-striped summary-items">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-qty">Qty</th>
<th class="item-attr">Price</th>
</tr>
</thead>
<tbody class="font-13">
<%
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=""><%=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 class="card-footer custom-card-footer" style="padding: 0.35rem 0.15rem !important;">
<table class="table" id="order-charges-table" border="0">
<tr>
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Sub Total</strong></td>
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total"><%=number_with_precision(sub_total, precision: precision.to_i)%></strong></td>
</tr>
<tr>
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>(Discount)</strong></td>
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total">(<%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>)</strong></td>
</tr>
<tr>
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total Tax</strong></td>
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total"><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></strong></td>
</tr>
<tr>
<td colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Rounding Adj</strong></td>
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total"><%= 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 colspan="2" style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Grand Total</strong></td>
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total"><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></strong></td>
</tr>
</table>
<button type="button" class="btn btn-primary action-btn create col-md-12" id="done_order" style="padding-top:4px !important;padding-bottom:4px !important;">DONE</button>
</div>
</div>
</div>
<div class="col-md-1 col-lg-1 col-sm-12">
<a class="btn btn-block bg-red waves-effect access_modal" data-toggle="modal" data-type="void"> Void</a>
</div>
<% end %>
</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="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>
</div>
<script type="text/javascript">
  $('#back').on('click', function () {
     window.location.href ="<%=foodcourt_food_court_path %>";
  });
  $('#done_order').on('click', function () {
    swal({
      title: "Alert !",
      text: 'Order Complete?',
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "Yes",
      cancelButtonClass: 'btn btn-danger',
      closeOnConfirm: false
    }, function (isConfirm) {
      if (isConfirm) {
        $('.confirm').prop("disabled",true);
        $.ajax({
          type: "POST",
          url: "/foodcourt/<%=@booking_id %>/<%=@order_id %>/completed",
          data: {customer_id:"<%=@customer_id %>"},
          dataType: "json",
          success: function(data) {
            swal({
             title: "Information!",
             text: 'Send sms to customer ',
             type: "success",
           }, function () {
             window.location.href ="<%=foodcourt_app_order_by_booking_path %>";
           });
          }
        });
      }
    });
  });
$('#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) {
$('.confirm').prop("disabled",true);
var sale_id = $('#sale_id').text();
var remark = $("#remark").val();
var ajax_url = "/foodcourt/sale/" + sale_id +'/food_court/void';
$.ajax({
type: 'POST',
url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
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);
}
}
window.location.href = '/foodcourt/app_orders';
}
})
}
});
});
$(document).on('click', '.access_modal', function(event){
type = $(this).data("type");
$(".ok").attr("data-action",type);
$('#AccessCodeModal').modal('show');
});
$(document).on('click', '.access_number', function(event){
if(event.handled !== true) {
var original_value = $('#access_code').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value){
$('#access_code').val(original_value + input_value);
}else{
$('#access_code').val(original_value + input_value);
}
break;
case 'ok':
var type = $(this).attr("data-action");
code = $('#access_code').val();
check_emp_access_code(code,type)
break;
case 'clr':
$('#access_code').val("");
break;
}
event.handled = true;
} else {
return false;
}
});
function createAccessCode(code) {
localStorage.setItem("access_code",code);
}
function check_emp_access_code(access_code,type) {
var url = "/foodcourt/check_emp_access_code/" + access_code ;
$.ajax({
type: 'POST',
url: url,
data: {},
success: function (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 = '/foodcourt/table/' + dining_id + "/sale/" + sale_id + "/food_court/edit";
}else{
window.location.href = "/foodcourt/table/sale/" + sale_id + "/food_court/edit";
}
}else if(type == "void"){
$('#AccessCodeModal').modal('hide');
$('#voidModal').modal('show');
}else if(type == "waste") {
waste_and_spoilage("waste")
}else if(type == "spoile") {
waste_and_spoilage("spoile")
}else if(type == "foc"){
$('#AccessCodeModal').modal('hide');
$('#focModal').modal('show');
}
}else{
swal("Oops",result.message,"warning");
}
}
});
}
</script>