users clients batchlineItem fix

This commit is contained in:
KhinSuLinn
2017-10-25 14:04:01 +06:30
parent dce9c48eef
commit 3488ac3ac7
11 changed files with 55 additions and 39 deletions

View File

@@ -29,7 +29,7 @@ a {
&:hover {
color: #fff;
background-color: #000;
// background-color: #000;
}
}

View File

@@ -21,13 +21,16 @@ class BatchLineItemsController < ApplicationController
sub_query="(select * from batches where client_id="+client_id.to_s+" and product_category_id ="+@product_category_id.to_s+" )"
@batchLineItems=BatchLineItem.joins('inner join '+sub_query+' as batches on batches.id=batch_line_items.batch_id')
.select('batch_line_items.*,batches.order_ref as batch_name').order('batch_line_items.id desc').page(params[:page]).per(10)
@result_count= @batchLineItems.total_count
else
@batchLineItems=BatchLineItem.joins('inner join batches on batches.id=batch_line_items.batch_id')
.select('batch_line_items.*,batches.order_ref as batch_name').order('batch_line_items.id desc').page(params[:page]).per(10)
@result_count= @batchLineItems.total_count
end
end
def search
# user_id=current_member.user_id
# user_id=current_member.user_id
batch_list=params[:batch]
client_id=params[:client]
product_category_id=params[:product_category]
@@ -40,12 +43,12 @@ class BatchLineItemsController < ApplicationController
@batchLineItems=BatchLineItem.joins('inner join '+ sub_query +' as batches on batches.id=batch_line_items.batch_id')
.select('batch_line_items.*,batches.order_ref as batch_name').order('batch_line_items.id desc').page(params[:page]).per(10)
@result_count= @batchLineItems.total_count
else
sub_query="(select * from batches where client_id="+client_id.to_s+" and product_category_id="+product_category_id.to_s+")"
@batchLineItems=BatchLineItem.joins('inner join '+ sub_query +'as batches on batches.id=batch_line_items.batch_id')
.select('batch_line_items.*,batches.order_ref as batch_name').order('batch_line_items.id desc').page(params[:page]).per(10)
@result_count= @batchLineItems.total_count
end
# if @batchLineItems.nil?

View File

@@ -1,17 +1,19 @@
<table class="table" style="border-top:none">
<table class="table" style="border-top:none">
<thead>
<tr><b><i>Batch Line Items ( <%= @result_count %> )</i></b></tr>
<tr>
<th>Serail No</th>
<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>
<th>Updated At </th>
</tr>
</thead>
<tbody>
<tbody>
<% @batchLineItems.each do |item| %>
<tr>
<td><%= item.serial_no rescue '' %></td>

View File

@@ -31,8 +31,8 @@
<div class="row content">
<div class="card">
<div class="card-header">
<strong>Batch Line Item List</strong>
</div>
<strong>Batch Line Item List</strong>
</div>
<div class="card-block">
<% flash.each do |key, value| %>
<% if key =='message' %>
@@ -45,6 +45,7 @@
<div id ="filterrific_results">
<table class="table" style="border-top:none">
<thead>
<tr><b><i>Batch Line Items ( <%= @result_count %> )</i></b></tr>
<tr>
<th>Serial No</th>
<th>Asset Identity</th>
@@ -52,11 +53,11 @@
<th>Batch No</th>
<th>Asset Type</th>
<th>Created At </th>
<th>Update At </th>
<th>Updated At </th>
</tr>
</thead>
<tbody>
<% @batchLineItems.each do |item| %>
<% @batchLineItems.each do |item| %>
<tr>
<td><%= item.serial_no rescue '' %></td>
<td><%= item.asset_identity rescue '' %></td>
@@ -87,8 +88,15 @@ $(document).ready(function(){
$('#product_category').on('change', function() {
product_category_id=$(this).val();
client_id=$("#client").val();
get_batch(client_id,product_category_id)
get_batch(client_id,product_category_id);
});
$("#client" ).on('change', function(){
client_id=$(this).val();
product_category_id=$("#product_category").val();
get_batch(client_id,product_category_id);
});
function get_batch(client_id,product_category_id){
$('#batch').multiselect('disable');
$.ajax({
@@ -103,7 +111,7 @@ $(document).ready(function(){
$.each(result.data, function (i, item){
$("#batch").append("<option value="+item.id+">"+ item.order_ref +"</option>")
});
$('#batch').multiselect("refresh");
$("#batch").multiselect('refresh');
$("#batch").multiselect('rebuild');
}
@@ -112,17 +120,18 @@ $(document).ready(function(){
}
$("#product_category").change(function(){
product_category=$(this).val();
client=$("#client").val()
client=$("#client").val();
batch=$("#batch").val();
filter(client,product_category,batch);
})
filter(client,product_category,batch);
});
$("#client" ).on('change', function(){
client=$(this).val();
product_category=$("#product_category").val();
batch=$("#batch").val();
filter(client,product_category,batch);
});
filter(client,product_category,batch);
})
$('#batch').change(function(){
client=$("#client :selected").val();
product_category=$("#product_category").val();
@@ -145,6 +154,7 @@ $(document).ready(function(){
},
complete: function(){
$('#loading').hide();
},
success: function(data) {

View File

@@ -39,7 +39,7 @@
<label></label>
<div class="actions">
<%= f.button :submit, :class => 'btn btn-primary',:id =>'btn_submit' %>
<%= link_to 'Cancel', users_path ,:class => 'btn btn-primary',:id => 'btnback' %>
<%= link_to 'Cancel', clients_path ,:class => 'btn btn-primary',:id => 'btnback' %>
</div>
</div>
</div>

View File

@@ -1,7 +1,7 @@
<div class="row">
<nav class="breadcrumb">
<a class="breadcrumb-item" href="<%= dashboard_path %>">Home</a>
<a class="breadcrumb-item active" href="<%= users_path %>">Clients</a>
<a class="breadcrumb-item active" href="<%= clients_path %>">Clients</a>
<a class="breadcrumb-item active" href="#">Show</a>
</nav>
</div>

View File

@@ -23,7 +23,8 @@
<td><%= user.nrc rescue '' %></td>
<td><%= user.email rescue '' %></td>
<td><%= user.phone rescue '' %></td>
<td><%= user.address rescue '' %></td>
<td><%= user.address rescue '' %></td>
<td></td>
<td><%= user.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
</tr>
<% end %>

View File

@@ -91,12 +91,12 @@ $(document).ready(function() {
success:function(result){
// $("#show-data").html('')
if (result.status == 'true'){
enable_control(false)
enable_control(false);
}
else
{
if (result.data === null){
enable_control(true)
enable_control(true);
}
else
{

View File

@@ -35,7 +35,8 @@
<td><%= user.nrc rescue '' %></td>
<td><%= user.email rescue '' %></td>
<td><%= user.phone rescue '' %></td>
<td><%= user.address rescue '' %></td>
<td><%= user.address rescue '' %></td>
<td></td>
<td><%= user.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
<td>
<%= link_to 'Detail',

View File

@@ -4,25 +4,23 @@
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: postgresql
# host: http://192.168.1.81
pool: 5
timeout: 5000
encoding: utf8
development:
<<: *default
database: nemo_encoder_production
username: nda
database: nemo_all
username: postgres
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: nemo_encoder_production_test
production:
<<: *default
database: nemo
username: deploy
password: OU771o3ja3Hn4$r
default: &default
adapter: postgresql
pool: 5
timeout: 5000
encoding: utf8

View File

@@ -14,6 +14,7 @@ ActiveRecord::Schema.define(version: 20170210103359) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "uuid-ossp"
create_table "batch_line_items", force: :cascade do |t|
t.integer "batch_id"