<commit_before><div class="row wrapper border-bottom white-bg page-heading">
  <div class="col-sm-4">
    <h2>Receipts</h2>
    <ol class="breadcrumb">
      <li>
        <a href="#">Stock</a>
      </li>
      <li class="active">
        <strong>Receipts</strong>
      </li>
    </ol>
  </div>
  <div class="col-sm-8">
    <div class="title-action">
    <% if policy(Receipt).new? %>
      <%= link_to 'New Receipt', new_receipt_path, :class => "btn btn-primary"%>
    <% end %>
    </div>
  </div>
</div>


<div class="ibox float-e-margins">
  <div class="ibox-content">
      <%= form_tag( receipts_path ,{ class: 'form-inline', style: 'display: inline-block;', role: 'form', method: 'GET'}) do %>
        <div class="form-group">
          <%= label_tag :project, "Project", { :class => ' control-label', :required => true } %>

          <div class="">
            <%= select_tag  :project,  options_from_collection_for_select( Project.all, 'id', 'project_code', params[:project] ) , { :required => true, :prompt => "-- Choose --", :class => 'form-control col-md-3 data-parsley-required' }  %>
          </div>
        </div>
        <div class="form-group">
          <%= label_tag :hub, "Hub", { :class => ' control-label'} %>

          <div class="">
            <%= select_tag  :hub,  options_from_collection_for_select( Hub.all, 'id', 'name', params[:hub] ) , {:required => true , :prompt => "-- Choose --", :class => 'form-control col-md-3 data-parsley-required' }  %>
          </div>
        </div>
        <div class="form-group">
          <%= label_tag :status, "Status", { :class => ' control-label'} %>

          <div class="">
            <%= select_tag  :status,  options_for_select( ["Draft", "Posted"], params[:status]) , { :prompt => "-- Choose --", :class => 'form-control col-md-3' }  %>
          </div>
        </div>
        <div class="form-group">
          <%= label_tag :received_date, "Received Date", { :class => ' control-label'} %>

          <div class="">
            <%= text_field_tag  :received_date, params[:received_date], { id: 'received-date-picker',class: 'form-control'}  %>
          </div>
        </div>
        
        <div class="form-group">
          <label for=""></label>
          <div>
              <input type="submit" name="filter" value="Go" class="btn btn-sm btn-primary" />
          </div>
        </div>

        <% end %>


        <%= form_tag( receipts_path ,{ class: 'form-inline pull-right', style: 'display: inline-block;',role: 'form', method: 'GET'}) do %>
        <div class="form-group">
          <%= label_tag :grn_no, "GRN", { :class => ' control-label'} %>

          <div class="">
            <%= text_field_tag  :grn_no, params[:grn_no], { class: 'form-control'}  %>
          </div>
        </div>

        <div class="form-group">
          <label for=""></label>
          <div>
              <input type="submit" name="find" value="Go" class="btn btn-sm btn-primary" />
          </div>
        </div>


      <% end %>
  </div>
</div>

<div class="ibox float-e-margins">
  <div class="ibox-content">

    <table class="table table-striped cats-datatable">
      <thead>
      <tr>
            <th>GRN Number</th>
            <th>Received Date</th>
            <th>Status</th>
            <th>Remark</th>
            <th>Actions</th>
      </tr>
      </thead>

      <tbody>

      <% can_edit = policy(Receipt).edit? %>
      
        <% @receipts.each do |receipt| %>
            <tr>
                <td><%= receipt.grn_no %></td>
                <td><%= receipt.received_date ? receipt.received_date.strftime('%d/%m/%Y') : '-' %></td>
                <td><%= receipt.draft ? "Draft" : "Posted" %></td>
                <td><%= receipt.remark ? receipt.remark : '-' %></td>
                <td>
                <% if can_edit %>
                    <%= link_to 'Edit', edit_receipt_path(receipt) %> &middot;
                    <%= link_to 'Delete', receipt, method: :delete, data: { confirm: 'Are you sure?' } %>
                <%end%>                
                </td>
            </tr>
        <% end %>
      </tbody>
    </table>        
    
  </div>
</div>

<script type="text/javascript">
  $( function() { 
    $('#received-date-picker').daterangepicker(
      {
          locale: {
            format: 'DD/MM/YYYY'
          },
          maxDate: '0', 
          autoUpdateInput: false
      }, 
      function( start, end  ) { 
        $('#received-date-picker').val( start.format('DD/MM/YYYY') + ' - ' + end.format('DD/MM/YYYY')); 
      }
    ); 
  });

</script><commit_msg>fix CATS-1662<commit_after><div class="row wrapper border-bottom white-bg page-heading">
  <div class="col-sm-4">
    <h2>Receipts</h2>
    <ol class="breadcrumb">
      <li>
        <a href="#">Stock</a>
      </li>
      <li class="active">
        <strong>Receipts</strong>
      </li>
    </ol>
  </div>
  <div class="col-sm-8">
    <div class="title-action">
    <% if policy(Receipt).new? %>
      <%= link_to 'New Receipt', new_receipt_path, :class => "btn btn-primary"%>
    <% end %>
    </div>
  </div>
</div>


<div class="ibox float-e-margins">
  <div class="ibox-content">
      <%= form_tag( receipts_path ,{ class: 'form-inline', style: 'display: inline-block;', role: 'form', method: 'GET'}) do %>
        <div class="form-group">
          <%= label_tag :project, "Project", { :class => ' control-label', :required => true } %>

          <div class="">
            <%= select_tag  :project,  options_from_collection_for_select( Project.all, 'id', 'project_code', params[:project] ) , { :required => true, :prompt => "-- Choose --", :class => 'form-control col-md-3 data-parsley-required' }  %>
          </div>
        </div>
        <div class="form-group">
          <%= label_tag :hub, "Hub", { :class => ' control-label'} %>

          <div class="">
            <%= select_tag  :hub,  options_from_collection_for_select( Hub.all, 'id', 'name', params[:hub] ) , {:required => true , :prompt => "-- Choose --", :class => 'form-control col-md-3 data-parsley-required' }  %>
          </div>
        </div>
        <div class="form-group">
          <%= label_tag :status, "Status", { :class => ' control-label'} %>

          <div class="">
            <%= select_tag  :status,  options_for_select( ["Draft", "Posted"], params[:status]) , { :prompt => "-- Choose --", :class => 'form-control col-md-3' }  %>
          </div>
        </div>
        <div class="form-group">
          <%= label_tag :received_date, "Received Date", { :class => ' control-label'} %>

          <div class="">
            <%= text_field_tag  :received_date, params[:received_date], { id: 'received-date-picker',class: 'form-control'}  %>
          </div>
        </div>
        
        <div class="form-group">
          <label for=""></label>
          <div>
              <input type="submit" name="filter" value="Go" class="btn btn-sm btn-primary" />
          </div>
        </div>

        <% end %>


        <%= form_tag( receipts_path ,{ class: 'form-inline pull-right', style: 'display: inline-block;',role: 'form', method: 'GET'}) do %>
        <div class="form-group">
          <%= label_tag :grn_no, "GRN", { :class => ' control-label'} %>

          <div class="">
            <%= text_field_tag  :grn_no, params[:grn_no], { class: 'form-control'}  %>
          </div>
        </div>

        <div class="form-group">
          <label for=""></label>
          <div>
              <input type="submit" name="find" value="Go" class="btn btn-sm btn-primary" />
          </div>
        </div>


      <% end %>
  </div>
</div>

<div class="ibox float-e-margins">
  <div class="ibox-content">

    <table class="table table-striped cats-datatable">
      <thead>
      <tr>
            <th>GRN Number</th>
            <th>Received Date</th>
            <th>Status</th>
            <th>Remark</th>
            <th>Actions</th>
      </tr>
      </thead>

      <tbody>

      <% can_edit = policy(Receipt).edit? %>
      
        <% @receipts.each do |receipt| %>
            <tr>
                <td><%= receipt.grn_no %></td>
                <td><%= receipt.received_date ? receipt.received_date.strftime('%d/%m/%Y') : '-' %></td>
                <td><%= receipt.draft ? "Draft" : "Posted" %></td>
                <td><%= receipt.remark ? receipt.remark : '-' %></td>
                <td>
                <% if can_edit %>
                    <%= link_to 'Edit', edit_receipt_path(receipt) %> &middot;
                    <%= link_to 'Delete', receipt, method: :delete, data: { confirm: 'Are you sure?' } %>
                <%end%>                
                </td>
            </tr>
            <tr>
             <table class="table" style="margin-left: 40px;">
              <thead>
                <tr>
                    <th>Commodity</th>
                    <th>Quantity</th>
                    <th>unit</th>
                    <th>project code</th>
                    
               </tr>
              </thead>
              <tbody>
            </tr>
            <% receipt.receipt_lines.each do |receipt_line| %>
            <tr>
             
              <td><%=  receipt_line&.commodity&.name %> </td>
              <td><%=  receipt_line&.quantity %> </td>
              <td><%=  receipt_line&.unit_of_measure&.name %> </td>
              <td><%=  receipt_line&.project&.project_code %> </td>
            </tr>
            <% end %>
            </tbody>
            </table>
        <% end %>
      </tbody>
    </table>        
    
  </div>
</div>

<script type="text/javascript">
  $( function() { 
    $('#received-date-picker').daterangepicker(
      {
          locale: {
            format: 'DD/MM/YYYY'
          },
          maxDate: '0', 
          autoUpdateInput: false
      }, 
      function( start, end  ) { 
        $('#received-date-picker').val( start.format('DD/MM/YYYY') + ' - ' + end.format('DD/MM/YYYY')); 
      }
    ); 
  });

</script>
{'fraction_non_alphanumeric': 0.19713512972052488, 'fraction_numerical': 0.0022037463688270057, 'mean_word_length': 1.7702552719200888, 'pattern_counts': {'":': 0, '<': 281, '<?xml version=': 0, '>': 311, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2865939', 'n_tokens_mistral': 3466, 'n_tokens_neox': 3200, 'n_words': 626}