<%= javascript_include_tag 'custom', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'foodcourt/addorder', 'data-turbolinks-track': 'reload' %>
<% if !@booking.nil? || @pending %>
<% else %>
<% end %>
<% bk_color ='' %> <% @completed.each do |c| %> <% if !@booking.nil? if c.booking_id == @booking.booking_id bg_color ='bg-secondary' else if c.sale.sale_status == 'void' bg_color = 'bg-danger' elsif c.sale.sale_status == 'completed' bg_color = 'bg-success' end end else if c.sale.sale_status == 'void' bg_color = 'bg-danger' elsif c.sale.sale_status == 'completed' bg_color = 'bg-success' end end %> <%= link_to foodcourt_app_order_by_booking_path(booking_id: c.booking_id, active: 'completed'), class: 'item-card' do %>
<%= c.contact_no %> <%= c.checkin_at.strftime("%I:%M %p") %>
<%= c.orders.first.try(:order_id) %><%= c.booking_status %>
<% end %> <% end %> <% @pending_completed.each do |pc| %> <% if @pending.present? %> <% if @pending.sale_id == pc.sale_id %> <% bg_color = 'bg-secondary' %> <% else %> <% if pc.sale_status == 'void' %> <% bg_color = 'bg-danger' %> <% elsif pc.sale_status == 'completed' %> <% bg_color = 'bg-success' %> <% end %> <% end %> <% else %> <% if pc.sale_status == 'void' %> <% bg_color = 'bg-danger' %> <% elsif pc.sale_status == 'completed' %> <% bg_color = 'bg-success' %> <% end %> <% end %> <%= link_to foodcourt_app_order_by_booking_path(pending_id: pc.sale_id, active: 'completed'), class: 'item-card' do %>
<%= pc.receipt_no %> <%= pc.created_at.strftime("%I:%M %p") %>
<%= pc.sale_status %>
<% end %> <% end %>
<% @pending_sales.each do |sale| %> <% if @pending.present? %> <% if @pending.sale_id == sale.sale_id %> <% bg_color = 'bg-secondary' %> <% else %> <% bg_color = 'bg-danger' %> <% end %> <% else %> <% bg_color = 'bg-danger' %> <% end %> <%= link_to foodcourt_app_order_by_booking_path(pending_id: sale.sale_id), class: 'item-card' do %>
<%= sale.receipt_no %> <%= sale.created_at.strftime('%I:%M %p') %>
Billed
<% end %> <% end %> <% @pending_orders.each do |order| %> <% if @pending.present? && @status == 'order' %> <% if @pending.booking_id == order.booking_id %> <% bg_color = 'bg-secondary' %> <% else %> <% bg_color = 'blue' %> <% end %> <% else %> <% bg_color = 'blue' %> <% end %> <%= link_to foodcourt_app_order_by_booking_path(pending_id: order.booking_id), class: 'item-card' do %>
<%= order.booking_id %> <%= order.created_at.strftime('%I:%M-%p') %>
new
<% end %> <% end %>
<% 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, active: 'mobile'), class: 'item-card' do %>
<%= bk.contact_no %> <%= bk.checkin_at.strftime("%I:%M %p") %>
<%= bk.orders.first.try(:order_id) %><%= bk_status %>
<% end %> <% end %>
<% if !@booking.nil?%>
ORDER DETAILS | Table-<%=@booking.dining_facility.try(:name)%>
Booking - <%=@booking.booking_id%> Order No - <%=@booking.order_id%>
<% sub_total = 0 count = 0 %> <% @sale_data.sale_items.each do |sale_item| count += 1 %> <% sub_total += sale_item.price%> <%end %>
# Items Qty Price
<%= count %> <%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%> <%=sale_item.qty%> <%=(number_with_precision(sale_item.price, precision: precision.to_i ))%>
<% end %> <% if @pending %>
<% if @status == 'sale' %> <% elsif @status == 'order' %> <% end %>
<% if @status == 'sale' %> <% table_name = @pending.try(:booking).try(:dining_facility).try(:name) %> <% elsif @status == 'order' %> <% table_name = @pending.try(:dining_facility).try(:name) %> <% end %> INVOICE DETAILS | Table - <%= table_name %>
<% if @status == 'sale' || @pending.try(:sale_status) == 'completed' || @pending.try(:sale_status) == 'void' %>
  Receipt No: <%= @pending.receipt_no rescue '' %>
<% else%>
  Order No: <%= @pending.booking_orders.first.order_id rescue '' %>
<% end%> <% if @status == 'sale' || @pending.try(:sale_status) == 'completed' || @pending.try(:sale_status) == 'void' %>
Date: <%= @pending.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%>  
<% else%>
Date: <%= @pending.orders.first.created_at.strftime("%I:%M %p") rescue '-'%>  
<% end%>
<% if @status == 'sale' %> " /> Customer: <%= @pending.customer.name rescue "-" %> <% else %> " /> Customer: <%= @pending.orders.first.customer.name rescue "-" %> <% end %>
<% if @status == 'sale' %> <% sub_total = 0 @pending.sale_items.each do |sale_item| sub_total = sub_total + sale_item.price %> <% end%> <% else %> <% sub_total = 0 total = 0 @pending.order_items.each do |order_item| total = order_item.qty * order_item.price sub_total = sub_total + total %> <% end %> <% end%>
Items QTY Price
<%= sale_item.product_name %> <%= sale_item.qty %> <%= sale_item.price %>
<%= order_item.item_name %> <%= order_item.qty %> <%= total %>
<% end %> <% if @pending || @booking %>
<% else %>
<% end %> <% if @booking && @booking.booking_status == 'assign' %> <% end %> <% if @booking && @booking.booking_status != 'void' %>
Void <% end %> <% if @pending && params[:active].nil? %> <% if current_user.role != "waiter" && @status == "order"%>
<%end%> <% if current_user.role != "waiter" && @status == "sale"%>
<%end%> <% if @status != "sale"%>
<% order_id = @pending.try(:orders).try(:first).try(:order_id) if @status == 'order' %> <%end%> <% elsif @pending && params[:active] == 'completed' %> <% if current_user.role != "waiter" %> <% if @pending.sale_status != 'void' && @pending.sale_status != 'waste' && @pending.sale_status != 'spoile' %>
<% if current_user.role == "cashier" %> <% if @pending.payment_status != 'foc' %> Void <% end %> Re.Print <% else %> <% if @pending.payment_status != 'foc' %> <% end %> <% end %> <% end %> <% end %> <% end %>
<%= render "read_modal" %>