This commit is contained in:
Sunandar
2017-02-06 13:08:52 +06:30
parent cccf9c0e9b
commit 90eeb2ea1c
3 changed files with 85 additions and 40 deletions

View File

@@ -4,21 +4,32 @@
<a class="breadcrumb-item active" href="#">Batch Line Item List</a>
</nav>
</div>
<div class="row top-content">
<% flash.each do |name, msg| %>
<div class="alert alert-danger">
<a class="close" data-dismiss="alert">×</a>
<%= msg %>
</div>
<% end %>
<br><br>
<%= form_tag export_path(:format => :csv),:method => :post do%>
<div class="col-lg-7">
<div class="col-lg-4">
</div>
<div class="col-lg-3">
<%= select_tag "client", options_from_collection_for_select(@clients, "id", "name"),:class => 'form-control'%>
</div>
<div class="col-lg-5">
<label><strong>Choose Batch:</strong></label>
<select class='selectpicker' id='batch' name='batch[]' multiple= "multiple" >
<% @batches.each do |batch| %>
<!--<% @batches.each do |batch| %>
<option value="<%= batch.id %>"><%= batch.order_ref %></option>
<% end %>
</select>
&nbsp; &nbsp;
<%= button_tag "Export CSV",:class =>'btn btn-primary btn-sm',:id =>"btnexport" %>
<% end %> -->
</select>
&nbsp; &nbsp;
<%= button_tag "Export CSV",:class =>'btn btn-primary btn-sm',:id =>"btnexport" %>
</div>
<% end %>
<% end %>
</div>
<div class="row content">
<div class="card">
@@ -58,9 +69,33 @@
</div>
</div>
<script>
$(document).ready(function(){
$('#batch').multiselect()
$("#batch").multiselect("refresh");
$(document).ready(function(){
client_id=$("#client").val();
get_batch(client_id)
$('#client').on('change', function() {
client_id=$(this).val()
get_batch(client_id)
});
function get_batch(client_id){
$('#batch').multiselect('disable');
$.ajax({
type: "GET",
url: '<%= get_batch_path %>',
dataType: "json",
data : {'client_id':client_id },
success: function(result){
if (result.status){
$('#batch').multiselect('enable');
$("#batch").empty();
$("#batch").append("<option value='all'>ALL</option>")
$.each(result.data, function (i, item){
$("#batch").append("<option value="+item.id+">"+ item.order_ref +"</option>")
});
$('#batch').multiselect("refresh");
$("#batch").multiselect('rebuild');
}
}
});
}
})
</script>