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 { &:hover {
color: #fff; 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+" )" 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') @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) .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 else
@batchLineItems=BatchLineItem.joins('inner join batches on batches.id=batch_line_items.batch_id') @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) .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
end end
def search def search
# user_id=current_member.user_id # user_id=current_member.user_id
batch_list=params[:batch] batch_list=params[:batch]
client_id=params[:client] client_id=params[:client]
product_category_id=params[:product_category] 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') @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) .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 else
sub_query="(select * from batches where client_id="+client_id.to_s+" and product_category_id="+product_category_id.to_s+")" 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') @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) .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
# if @batchLineItems.nil? # if @batchLineItems.nil?

View File

@@ -1,17 +1,19 @@
<table class="table" style="border-top:none">
<table class="table" style="border-top:none">
<thead> <thead>
<tr><b><i>Batch Line Items ( <%= @result_count %> )</i></b></tr>
<tr> <tr>
<th>Serail No</th> <th>Serial No</th>
<th>Asset Identity</th> <th>Asset Identity</th>
<th>Manufacture UID</th> <th>Manufacture UID</th>
<th>Batch No</th> <th>Batch No</th>
<th>Asset Type</th> <th>Asset Type</th>
<th>Created At </th> <th>Created At </th>
<th>Update At </th> <th>Updated At </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @batchLineItems.each do |item| %> <% @batchLineItems.each do |item| %>
<tr> <tr>
<td><%= item.serial_no rescue '' %></td> <td><%= item.serial_no rescue '' %></td>

View File

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

View File

@@ -39,7 +39,7 @@
<label></label> <label></label>
<div class="actions"> <div class="actions">
<%= f.button :submit, :class => 'btn btn-primary',:id =>'btn_submit' %> <%= 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> </div>
</div> </div>

View File

@@ -1,7 +1,7 @@
<div class="row"> <div class="row">
<nav class="breadcrumb"> <nav class="breadcrumb">
<a class="breadcrumb-item" href="<%= dashboard_path %>">Home</a> <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> <a class="breadcrumb-item active" href="#">Show</a>
</nav> </nav>
</div> </div>

View File

@@ -24,6 +24,7 @@
<td><%= user.email rescue '' %></td> <td><%= user.email rescue '' %></td>
<td><%= user.phone 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><%= user.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
</tr> </tr>
<% end %> <% end %>

View File

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

View File

@@ -36,6 +36,7 @@
<td><%= user.email rescue '' %></td> <td><%= user.email rescue '' %></td>
<td><%= user.phone 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><%= user.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
<td> <td>
<%= link_to 'Detail', <%= link_to 'Detail',

View File

@@ -4,25 +4,23 @@
# Ensure the SQLite 3 gem is defined in your Gemfile # Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3' # gem 'sqlite3'
# #
default: &default default: &default
adapter: postgresql adapter: postgresql
# host: http://192.168.1.81
pool: 5 pool: 5
timeout: 5000 timeout: 5000
encoding: utf8
development: development:
<<: *default <<: *default
database: nemo_encoder_production database: nemo_all
username: nda 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: &default
<<: *default adapter: postgresql
database: nemo
username: deploy pool: 5
password: OU771o3ja3Hn4$r 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
enable_extension "uuid-ossp"
create_table "batch_line_items", force: :cascade do |t| create_table "batch_line_items", force: :cascade do |t|
t.integer "batch_id" t.integer "batch_id"