search in batches
This commit is contained in:
@@ -1,26 +1,25 @@
|
||||
<div class="row ">
|
||||
<nav class="breadcrumb">
|
||||
<a class="breadcrumb-item active" href="<%= dashboard_path %>">Home</a>
|
||||
<a class="breadcrumb-item active" href="#">Batch Line Item List</a>
|
||||
</nav>
|
||||
<nav class="breadcrumb">
|
||||
<a class="breadcrumb-item active" href="<%= dashboard_path %>">Home</a>
|
||||
<a class="breadcrumb-item active" href="#">Batch Line Item List</a>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="row content">
|
||||
<%= form_tag export_path(:format => :csv),:method => :post do%>
|
||||
<div class="col-lg-4">
|
||||
<label><strong>Select Client:</strong></label>
|
||||
<%= select_tag "client", options_from_collection_for_select(@clients, "id", "name"), :class => 'form-control'%>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<label><strong>Select Product:</strong></label>
|
||||
<%= select_tag "product_category", options_from_collection_for_select(@product_categories, "id", "name"), :class => 'form-control'%>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<label><strong>Select Batch:</strong></label><br>
|
||||
<select class='selectpicker' id='batch' name='batch[]' multiple= "multiple"></select>
|
||||
<%= button_tag "Export csv?",:class =>'btn btn-primary btn-sm',:id =>"btnexport" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= form_tag export_path(:format => :csv),:method => :post do%>
|
||||
<div class="col-lg-4">
|
||||
<label><strong>Select Client:</strong></label>
|
||||
<%= select_tag "client", options_from_collection_for_select(@clients, "id", "name"), :class => 'form-control'%>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<label><strong>Select Product:</strong></label>
|
||||
<%= select_tag "product_category", options_from_collection_for_select(@product_categories, "id", "name"), :class => 'form-control'%>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<label><strong>Select Batch:</strong></label><br>
|
||||
<select class='selectpicker' id='batch' name='batch[]' multiple= "multiple"></select>
|
||||
<%= button_tag "Export csv?",:class =>'btn btn-primary btn-sm',:id =>"btnexport" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="row show_image">
|
||||
<div class="col-lg-6"></div>
|
||||
@@ -29,52 +28,51 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row content">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<strong>Batch Line Item List</strong>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<% flash.each do |key, value| %>
|
||||
<% if key =='message' %>
|
||||
<div class="alert alert-danger center">
|
||||
<a class="close" data-dismiss="alert">×</a>
|
||||
<%= value %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div id ="filterrific_results">
|
||||
<table class="table" style="border-top:none">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Serial No</th>
|
||||
<th>Asset Identity</th>
|
||||
<th>Manufacture UID</th>
|
||||
<th>Batch No</th>
|
||||
<th>Asset Type</th>
|
||||
<th>Created At </th>
|
||||
<th>Update At </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @batchLineItems.each do |item| %>
|
||||
<tr>
|
||||
<td><%= item.serial_no rescue '' %></td>
|
||||
<td><%= item.asset_identity rescue '' %></td>
|
||||
<td><%= item.manufacture_uid rescue '' %></td>
|
||||
<td><%= item.batch_name rescue '' %></td>
|
||||
<td><%= item.asset_type rescue '' %></td>
|
||||
<td><%= item.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
<td><%= item.updated_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%=paginate @batchLineItems %>
|
||||
<div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<strong>Batch Line Item List</strong>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<% flash.each do |key, value| %>
|
||||
<% if key =='message' %>
|
||||
<div class="alert alert-danger center">
|
||||
<a class="close" data-dismiss="alert">×</a>
|
||||
<%= value %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div id ="filterrific_results">
|
||||
<table class="table" style="border-top:none">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Serial No</th>
|
||||
<th>Asset Identity</th>
|
||||
<th>Manufacture UID</th>
|
||||
<th>Batch No</th>
|
||||
<th>Asset Type</th>
|
||||
<th>Created At </th>
|
||||
<th>Update At </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @batchLineItems.each do |item| %>
|
||||
<tr>
|
||||
<td><%= item.serial_no rescue '' %></td>
|
||||
<td><%= item.asset_identity rescue '' %></td>
|
||||
<td><%= item.manufacture_uid rescue '' %></td>
|
||||
<td><%= item.batch_name rescue '' %></td>
|
||||
<td><%= item.asset_type rescue '' %></td>
|
||||
<td><%= item.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
<td><%= item.updated_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%=paginate @batchLineItems %>
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#loading').hide();
|
||||
@@ -133,7 +131,7 @@ $(document).ready(function(){
|
||||
function filter(client,product_category,batch){
|
||||
if (batch==null){
|
||||
batch=""
|
||||
}
|
||||
}
|
||||
paramlist='client='+client+"&product_category="+product_category+"&batch="+batch
|
||||
|
||||
$.ajax({
|
||||
@@ -147,7 +145,6 @@ $(document).ready(function(){
|
||||
$('#loading').hide();
|
||||
},
|
||||
success: function(data) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
36
app/views/batches/_search.html.erb
Normal file
36
app/views/batches/_search.html.erb
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
<div class="card-header">
|
||||
<strong>Batch List</strong>
|
||||
<strong>(Count: <%= @count %> ) </strong>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<table class="table" style="border-top:none" id="myTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order Ref</th>
|
||||
<th>Created By</th>
|
||||
<th>Qty Processing</th>
|
||||
<th>Qty Success</th>
|
||||
<th>Qty Fail</th>
|
||||
<th>Export Count</th>
|
||||
<th>Exported By</th>
|
||||
<th>Created At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @batches.each do |batch| %>
|
||||
<tr>
|
||||
<td><%= batch.order_ref rescue '' %></td>
|
||||
<td><%= batch.user_name rescue '' %></td>
|
||||
<td><%= batch.qty_processing rescue '' %></td>
|
||||
<td><%= batch.qty_success rescue '' %></td>
|
||||
<td><%= batch.qty_fail rescue '' %></td>
|
||||
<td><%= batch.export_count %></td>
|
||||
<td><%= batch.exported_by %></td>
|
||||
<td><%= batch.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= paginate @batches %>
|
||||
</div>
|
||||
@@ -1,44 +1,144 @@
|
||||
<div class="row ">
|
||||
<nav class="breadcrumb">
|
||||
<a class="breadcrumb-item active" href="<%= dashboard_path %>">Home</a>
|
||||
<a class="breadcrumb-item active" href="#">Batches</a>
|
||||
</nav>
|
||||
</div>
|
||||
<nav class="breadcrumb">
|
||||
<a class="breadcrumb-item active" href="<%= dashboard_path %>">Home</a>
|
||||
<a class="breadcrumb-item active" href="#">Batches</a>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="row content">
|
||||
<div class="col-lg-4">
|
||||
<label><strong>Search:</strong></label>
|
||||
<input type="text" id="myInput" class="form-control">
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<label><strong>Select Client:</strong></label>
|
||||
<%= select_tag "client", options_from_collection_for_select(@clients, "id", "name"), prompt: "All", :class => 'form-control'%>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
<label><strong>Select Product:</strong></label>
|
||||
<%= select_tag "product_category", options_from_collection_for_select(@product_categories, "id", "name"), prompt: "All", :class => 'form-control'%>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row show_image">
|
||||
<div class="col-lg-6"></div>
|
||||
<div class="col-lg-4" id="loading">
|
||||
<img src="<%= asset_path( 'spinner.gif' ) %>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row content">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<strong>Batch List</strong>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<table class="table" style="border-top:none">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order Ref</th>
|
||||
<th>Created By</th>
|
||||
<th>Qty Processing</th>
|
||||
<th>Qty Success</th>
|
||||
<th>Qty Fail</th>
|
||||
<th>Export Count</th>
|
||||
<th>Exported By</th>
|
||||
<th>Created At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @batches.each do |batch| %>
|
||||
<tr>
|
||||
<td><%= batch.order_ref rescue '' %></td>
|
||||
<td><%= batch.user_name rescue '' %></td>
|
||||
<td><%= batch.qty_processing rescue '' %></td>
|
||||
<td><%= batch.qty_success rescue '' %></td>
|
||||
<td><%= batch.qty_fail rescue '' %></td>
|
||||
<td><%= batch.export_count %></td>
|
||||
<td><%= batch.exported_by %></td>
|
||||
<td><%= batch.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= paginate @batches %>
|
||||
<div class="card">
|
||||
<div id="filterrific_results">
|
||||
<div class="card-header">
|
||||
<strong>Batch List</strong>
|
||||
<strong>(Count: <%= @count %> ) </strong>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="card-block">
|
||||
|
||||
<table class="table" style="border-top:none" id="myTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order Ref</th>
|
||||
<th>Created By</th>
|
||||
<th>Qty Processing</th>
|
||||
<th>Qty Success</th>
|
||||
<th>Qty Fail</th>
|
||||
<th>Export Count</th>
|
||||
<th>Exported By</th>
|
||||
<th>Created At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @batches.each do |batch| %>
|
||||
<tr>
|
||||
<td><%= batch.order_ref rescue '' %></td>
|
||||
<td><%= batch.user_name rescue '' %></td>
|
||||
<td><%= batch.qty_processing rescue '' %></td>
|
||||
<td><%= batch.qty_success rescue '' %></td>
|
||||
<td><%= batch.qty_fail rescue '' %></td>
|
||||
<td><%= batch.export_count %></td>
|
||||
<td><%= batch.exported_by %></td>
|
||||
<td><%= batch.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%= paginate @batches %>
|
||||
<div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
// function mySearch() {
|
||||
// var input, filter, table, tr, td, i;
|
||||
// input = document.getElementById("myInput");
|
||||
// filter = input.value.toUpperCase();
|
||||
|
||||
// table = document.getElementById("myTable");
|
||||
// tr = table.getElementsByTagName("tr");
|
||||
// for (i = 0; i < tr.length; i++) {
|
||||
// td = tr[i].getElementsByTagName("td")[0];
|
||||
// console.log(td);
|
||||
// if (td) {
|
||||
// console.log(td.innerHTML.toUpperCase().indexOf(filter));
|
||||
// if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
|
||||
// tr[i].style.display = "";
|
||||
// } else {
|
||||
// tr[i].style.display = "none";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
$(document).ready(function(){
|
||||
|
||||
$('#loading').hide();
|
||||
client_id=$("#client").val();
|
||||
product_category_id=$("#product_category").val();
|
||||
search_keyword=$('#myInput').val();
|
||||
|
||||
|
||||
$('#product_category').on('change', function() {
|
||||
product_category=$(this).val();
|
||||
client=$("#client").val();
|
||||
search_keyword=$('#myInput').val();
|
||||
filter(client,product_category,search_keyword);
|
||||
});
|
||||
|
||||
$('#client').on('change', function() {
|
||||
client=$(this).val();
|
||||
product_category=$("#product_category").val();
|
||||
search_keyword=$('#myInput').val();
|
||||
filter(client,product_category,search_keyword);
|
||||
});
|
||||
|
||||
$('#myInput').keyup(function(){
|
||||
search_keyword = $(this).val().toLowerCase();
|
||||
client=$("#client").val();
|
||||
product_category=$("#product_category").val();
|
||||
filter(client,product_category,search_keyword);
|
||||
|
||||
});
|
||||
|
||||
function filter(client,product_category,search_keyword){
|
||||
|
||||
$.ajax({
|
||||
type:'GET',
|
||||
url: '<%= batch_filter_path %>',
|
||||
data : {'client_id':client ,'product_category_id':product_category,'search_keyword':search_keyword},
|
||||
beforeSend: function(){
|
||||
$('#loading').show();
|
||||
},
|
||||
complete: function(){
|
||||
$('#loading').hide();
|
||||
},
|
||||
success: function(data) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
})
|
||||
</script>
|
||||
6
app/views/batches/search.js.erb
Normal file
6
app/views/batches/search.js.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<% js = escape_javascript(
|
||||
|
||||
render(partial: 'batches/search', locals: { batches: @batches })
|
||||
) %>
|
||||
$("#filterrific_results").html("<%= js %>");
|
||||
$('.pagination a').attr('data-remote', 'true');
|
||||
Reference in New Issue
Block a user