<!-- <div class="row">
  <div class="col-lg-12">
    <ol class="breadcrumb">
       <li><a href="<%= crm_root_path %>">Home</a></li>
       <li class="active">
           <a href="<%= transactions_credit_notes_path %>">Credit Note</a>
       </li>
       
    </ol>
  </div>
</div> -->
<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.credit_note") %></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="">
                    <%= form_tag transactions_credit_notes_path, :method => :get do %>
                       <div class="row clearfix">
                         <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                           <label class="font-14"><%= t("views.right_panel.detail.enter_keyboards") %></label>
                           <input type="text" name="receipt_no" class="form-control m-t-3" placeholder="Receipt No/Cashier Name/Status" style="margin-right: 10px">
                         </div>
                         <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
                          <label class="font-14"><%= t("views.right_panel.detail.select_customer") %></label>
                           <select class="selectpicker form-control col-md-12 " name="customer"  style="height: 40px" >
                            <option value=""><%= t("views.right_panel.detail.select_customer") %></option>
                              <%  @customers.each do |customer| %>
                                 <option value="<%= customer.customer_id %>">
                                <%= customer.name %></option>
                              <%end %>
                            </select>   
                        </div>
                         <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
                           <label class="font-14"><%= t("views.right_panel.detail.from") %></label>
                           <input class="form-control datepicker m-t-3" name="from" id="date" type="text" placeholder="From date">
                        </div>
                        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
                          <label class="font-14"><%= t("views.right_panel.detail.to") %></label>
                          <input class="form-control datepicker m-t-3" name="to" id="date" type="text" placeholder="To date">
                        </div>
                        
                        <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
                          <label class="font-14"> &nbsp;</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.credit_amount") %></th>
                <th><%= t :cashier %></th>
                <th><%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
                <th><%= t("views.right_panel.detail.receipt_date") %></th>
              </tr>
            </thead>

            <tbody>
            <% if @credit_notes != 0 %>

                  <% @credit_notes.each do |sale| %>
                    <tr>
                      <td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
                      <td><%= sale.receipt_no %></td>
                      <td><%credit = SalePayment.where('sale_id = ? AND payment_method=?', sale.sale_id,"creditnote").first %>
                        <%= credit.payment_amount rescue '-' %>
                      </td>
                      <td><%= sale.cashier_name rescue '-' %></td>
                      <td><%= link_to sale.customer.name, crm_customer_path(sale.customer_id) %></td>
                      <td> <%= sale.receipt_date.strftime("%d-%m-%Y %I:%M %p") %> </td>
                    </tr>
                  <% end %>
              <% else %>
                    <tr><td colspan="8"><strong><p style="text-align: center"><%= t("views.right_panel.detail.no_data_txt") %>....</p></strong></td></tr>
              <% end %>
            </tbody>
          </table>
           <br>
           <% if @credit_notes != 0 %>
               <%= paginate @credit_notes %>
           <% end %>
        </div>
        </div>
      </div>

  </div>
</div>
<!-- 
<script type="text/javascript">
  $(function () {

            $('.datepicker').datepicker({
               format : 'dd-mm-yyyy',
               autoclose: true
            });
            $('.datepicker').attr('ReadOnly','true');
            $('.datepicker').css('cursor','pointer');

     
  });
</script> -->



     

