<div class="page-header">
  <ol class="breadcrumb">
    <li class="breadcrumb-item"><a href="<%= root_path %>"><%= t("views.right_panel.button.home") %></a></li>
    <li class="breadcrumb-item active"><%= t :booking %></li>
    <span class="float-right">
      <%= link_to 'Back', root_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-5 p-r-5">
         <div class="table-responsive">
          <table class="table table-">
            <tbody>
              <tr>
                 <td colspan="8">
                    <%= form_tag transactions_bookings_path, :method => :get do %>
                    <div class="row clearfix">
                       <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 mbl-style">
                         <label><%= t("views.right_panel.detail.enter_keyboards") %></label>
                         <input type="text" id="receipt_no"  name="receipt_no" class="form-control" placeholder="Booking/ Sale ID/ Table/ Room" style="margin-right: 10px">
                       </div>
                       <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 col-mbl-view mbl-style">
                         <label class="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-3 col-md-3 col-sm-3 col-xs-3 col-mbl-view mbl-style">
                        <label class="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="col-lg-1 col-md-1 col-sm-1 col-xs-1 mbl-right-btn mbl-style">
                        <label></label>
                        <br><input type="submit" value="Search" class='btn btn-primary btn-md'>
                      </div>
                    </div>
                    <% end %>
                 </td>
              </tr>
            </tbody>
          </table>
        </div>
        <div class="card">
          <div class="table-responsive">
          <table class="table table-bordered table-striped table-hover">
            <thead>
              <tr>
                <th><%= t("views.right_panel.detail.booking_id") %></th>
                <th><%= t("views.right_panel.detail.sale_id") %></th>
                <th><%= t("views.right_panel.detail.table") %></th>
                <th><%= t("views.right_panel.detail.checkin_time") %></th>
                <th><%= t("views.right_panel.detail.checkout_time") %></th>
                <th><%= t("views.right_panel.detail.checkin_by") %></th>
               <th> <%= t("views.right_panel.detail.checkout_by") %></th>
                <th><%= t("views.right_panel.detail.booking_status") %></th>
                <th><%= t("views.right_panel.detail.booking_date") %></th>
              </tr>
            </thead>

            <tbody>
              <% if @bookings != 0 %>
                  <% @bookings.each do |booking| %>
                    <tr>
                      <td><%= link_to booking.booking_id, transactions_booking_path(booking) %></td>
                      <td><%= link_to booking.sale_id, transactions_sale_path(booking.sale_id) rescue '-' %></td>
                      <td><%= booking.dining_facility.name rescue '' %></td>
                      <td><%= booking.checkin_at.strftime("%I:%M %p") %></td>
                      <td><%= booking.checkout_at.strftime("%I:%M %p") rescue '-'  %></td>
                      <td><%= booking.checkin_by rescue '-' %></td>
                      <td><%= booking.checkout_by rescue '-' %></td>
                      <td> <%= booking.booking_status %> </td>
                      <td> <%= booking.created_at.strftime("%d-%m-%Y %I:%M %p") %> </td>
                    </tr>
                  <% end %>
              <% else %>
                    <tr><td colspan="8"><strong><p style="text-align: center">There is no data for search....</p></strong></td></tr>
              <% end %>
            </tbody>
          </table>
          <br>
           <% if @bookings != 0 %>
               <%= paginate @bookings %>
           <% end %>
        </div>
        </div>
      </div>

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

</script>
