Files
sx-fc/app/views/foodcourt/orders/app_orders.html.erb
Myat Zin Wai Maw 7a4db5e0f4 app order with order
2019-12-04 16:18:06 +06:30

160 lines
6.3 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' %>
<% if @booking.nil?%>
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= foodcourt_food_court_path %>">Foodcourt</a></li>
<li class="breadcrumb-item active">Mobile Orders</li>
<span class="float-right">
<%= link_to 'Back', foodcourt_food_court_path %>
</span>
</ol>
</div>
<% end %>
<div class="container-fluid " style="padding:0px 3px 0px 3px;">
<div id="oqs_loading_wrapper" style="display:none;">
<div id="oqs_loading"></div>
</div>
<div class="row m-t--20">
<% if !@booking.nil?%>
<div class="col-md-9 col-lg-9 col-sm-12 m-t-10">
<% else %>
<div class="col-md-12 col-lg-12 col-sm-12 m-t-10">
<% end %>
<div id="custom-slimscroll">
<div class="card-columns">
<% bk_color ='' %>
<% @bookings.each do |bk|
bk_status ='completed'
if bk.booking_status =='assign'
bk_status ='new'
end
if !@booking.nil?
if bk.booking_id == @booking.booking_id
bk_color ='bg-red'
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) 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[0].order_id %><span style="font-size:12px;float:right;line-height:inherit;"><%= bk_status %></span> </div>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
<% if !@booking.nil?%>
<div class="col-md-3 col-lg-3 col-sm-12 m-t-10">
<div class="card-header" style="padding: 0.12rem 0.25rem">
<div class="row" style="margin:auto">
<div class="col-md-9 col-lg-9 col-sm-9">
<strong id="order-title" class="font-14 p-l-10">ORDER DETAILS </strong>| <span class="font-14">Table-<%=@booking.dining_facility.name%></span><br>
<strong class="font-14 p-l-10">Booking - <%=@booking.booking_id%></strong>
<strong class="font-14 p-l-10">Order No- <%=@booking.order_id%></strong>
</div>
<div class="col-md-3 col-lg-3 col-sm-3">
<button type="button" class="btn btn-block btn-default waves-effect" id='back'>
<i class="material-icons">reply</i>
Back
</button>
</div>
</div>
<div class="card-block">
<div class="card-text" id="order-detail-slimscroll" data-height="140">
<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" >
<% count =0 %>
<% total_price =0 %>
<% total_qty =0 %>
<% @booking.booking_orders.each do |bo| %>
<% bo.order.order_items.each do |oi| %>
<% count +=1 %>
<% total_price += oi.price %>
<% total_qty += oi.qty.to_i%>
<tr class="item_box">
<td><%= count%></td>
<td><%= oi.item_name%></td>
<td><%= oi.qty.to_i%></td>
<td class="item-attr"><%= oi.price%></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</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>Total:</strong></td>
<td style="padding:2px;" width="15%"><strong id="total_qty"><%=total_qty %></strong></td>
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total"><%=total_qty * total_price %></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;"><i class="material-icons" style="font-size:34px;width:34px">done</i></button>
</div>
</div>
</div>
</div>
<% end %>
</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 %>";
           });
          }
        });
      }
    });
  });
</script>