
<div class="page-header">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
    <li class="breadcrumb-item active"><%= t("views.right_panel.detail.order") %></li>
    <span class="float-right">
      <%= link_to 'Back', dashboard_path %>
    </span>
  </ol>
</div>
<style>
  @media screen and (max-width: 785px) {
    section.content{
      margin: 80px 5px 0 5px !important;
    }
  }
</style>
<div class="row">
  <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
      <div class="main-box-body clearfix p-l-15 p-r-15">
       <%= form_tag transactions_orders_path, :method => :get do %>
            <div class="row clearfix">
              <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 mbl-style">
                <label class="form-control-label"><%= t("views.right_panel.button.search_keyboard") %></label>
                 <input type="text" id="receipt_no" name="filter" placeholder="Order ID" class="form-control input-md" >
            </div>
            <!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
                <label>Items Count</label>
                 <div id="slider">
                  <input class="bar" name="count" min="0" max="20" type="range" id="rangeinput" onchange="rangevalue.value=value"/>
                  <span class="highlight"></span>
                  <output id="rangevalue">0</output>
                </div>

            </div> -->
            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 col-mbl-view mbl-style">
                <label class="form-control-label mbl_lbl"><%= t("views.right_panel.detail.from") %></label>
             <input class="form-control datepicker" name="from" id="from" type="text" placeholder="From date">
            </div>
            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 col-mbl-view mbl-style">
              <label class="form-control-label mbl_lbl"><%= t("views.right_panel.detail.to") %></label>
              <input class="form-control datepicker" name="to" id="to" type="text" placeholder="To date">
            </div>

            <div class="form-group col-lg-1 col-md-1 col-sm-1 col-xs-1 mbl-right-btn mbl-style">
              <label >  &nbsp;</label>
             <br> <input type="submit" value="Search" class='btn btn-primary btn-md'>
            </div>
            </div>
      <% end %>
        <div class="card">
          <div class="table-responsive">
          <table class="table ">
            <thead>

              <tr>
                <th><%= t("views.right_panel.detail.order_id") %></th>

                <th><%= t :table %>/<%= t :room %></th>
                <th><%= t("views.right_panel.detail.order_by") %></th>
                <th><%= t("views.right_panel.detail.type") %></th>
                <th><%= t :customer %></th>
                <th><%= t("views.right_panel.detail.order_status") %></th>
                <th><%= t("views.right_panel.detail.order_date") %></th>
                <th><%= t("views.right_panel.detail.items_count") %></th>
              </tr>
            </thead>

            <tbody>
              <% @orders.each do |order|
                @dining = BookingOrder.find_by_order_id(order.order_id).booking.dining_facility
                %>

                <tr>
                  <td><%= link_to order.order_id, transactions_order_path(order) %></td>
                  <td><%if !@dining.nil? %> <%= @dining.type %>-<%= @dining.name %> <% else %>&nbsp; <% end %></td>
                  <td><%= order.waiters %></td>
                  <td><%= order.order_type %></td>
                  <td><%= order.customer.name rescue '-' %></td>
                  <td><%= order.status %></td>
                  <td> <%= order.date.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> </td>
                  <td> <%= order.item_count %> </td>

                </tr>
              <% end %>
            </tbody>
          </table>
          <br>

          <%if !@orders.nil?%>
            <%= paginate @orders %>
          <%end%>
        </div>
        </div>
      </div>

  </div>
</div>

<script type="text/javascript">
  $(function(){
    $("#receipt_no").val("<%=params[:filter]%>");
    $("#from").val("<%=params[:from]%>");
    $("#to").val("<%=params[:to]%>");
  });

</script>
