<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 :sale %></li>
    <span class="float-right">
      <%= link_to 'Back', dashboard_path %>
    </span>
  </ol>
</div>
<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_sales_path, :method => :get do %>
                    <div class="row clearfix">
                       <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
                         <label><%= t("views.right_panel.detail.enter_keyboards") %></label>
                         <input type="text" id="receipt_no" name="receipt_no" class="form-control" placeholder="Receipt No/Cashier Name/Status" style="margin-right: 10px">
                       </div>
                       <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3"> 
                         <label class=""><%= 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">
                        <label class=""><%= 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">
                        <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-striped">
            <thead>
             
              <tr>
                <th><%= t("views.right_panel.detail.sale_id") %></th>
                <th><%= t("views.right_panel.detail.receipt_no") %></th>
                <th><%= t("views.right_panel.detail.total_discount") %></th>
                <th><%= t("views.right_panel.detail.tax_amount") %></th>
                <th><%= t("views.right_panel.detail.sub_total") %></th>
                <th><%= t("views.right_panel.detail.grand_total") %></th>
                <th><%= t :cashier %></th>
                <th><%= t("views.right_panel.detail.sales_status") %></th>
                <th><%= t("views.right_panel.detail.receipt_date") %></th>
              </tr>
            </thead>

            <tbody>
              <% if @sales != 0 %>
                  <% @sales.each do |sale| %>
                    <tr>
                      <td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
                      <td><%= sale.receipt_no %></td>
                      <td><%= sale.total_discount %></td>
                      <td><%= sale.total_tax %></td>
                      <td><%= sale.total_amount %></td>
                      <td><%= sale.grand_total rescue '-' %></td>
                      <td><%= sale.cashier_name rescue '-' %></td>
                      <td> <%= sale.sale_status %> </td>
                      <td> <%= sale.receipt_date.utc.getlocal.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 @sales != 0 %>
               <%= paginate @sales %>
           <% 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>





     

