From 3488ac3ac7146df41764c8401c26fa12b00b0ed2 Mon Sep 17 00:00:00 2001 From: KhinSuLinn Date: Wed, 25 Oct 2017 14:04:01 +0630 Subject: [PATCH] users clients batchlineItem fix --- app/assets/stylesheets/scaffolds.scss | 2 +- .../batch_line_items_controller.rb | 9 ++++-- app/views/batch_line_items/_search.html.erb | 12 ++++--- app/views/batch_line_items/index.html.erb | 32 ++++++++++++------- app/views/clients/_form.html.erb | 2 +- app/views/clients/show.html.erb | 2 +- app/views/home/dashboard.html.erb | 3 +- app/views/users/_form.html.erb | 4 +-- app/views/users/index.html.erb | 3 +- config/database.yml | 24 +++++++------- db/schema.rb | 1 + 11 files changed, 55 insertions(+), 39 deletions(-) diff --git a/app/assets/stylesheets/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss index 4ce4266..7ecca32 100644 --- a/app/assets/stylesheets/scaffolds.scss +++ b/app/assets/stylesheets/scaffolds.scss @@ -29,7 +29,7 @@ a { &:hover { color: #fff; - background-color: #000; + // background-color: #000; } } diff --git a/app/controllers/batch_line_items_controller.rb b/app/controllers/batch_line_items_controller.rb index 1dedb52..fd7e551 100644 --- a/app/controllers/batch_line_items_controller.rb +++ b/app/controllers/batch_line_items_controller.rb @@ -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? diff --git a/app/views/batch_line_items/_search.html.erb b/app/views/batch_line_items/_search.html.erb index 296b471..65fb91a 100644 --- a/app/views/batch_line_items/_search.html.erb +++ b/app/views/batch_line_items/_search.html.erb @@ -1,17 +1,19 @@ - + +
+ Batch Line Items ( <%= @result_count %> ) - + - - + - + + <% @batchLineItems.each do |item| %> diff --git a/app/views/batch_line_items/index.html.erb b/app/views/batch_line_items/index.html.erb index d5739b4..ebc158e 100644 --- a/app/views/batch_line_items/index.html.erb +++ b/app/views/batch_line_items/index.html.erb @@ -31,8 +31,8 @@
- Batch Line Item List -
+ Batch Line Item List +
<% flash.each do |key, value| %> <% if key =='message' %> @@ -45,6 +45,7 @@
Serail NoSerial No Asset Identity Manufacture UID Batch No Asset Type Created At Update At Updated At
<%= item.serial_no rescue '' %>
+ Batch Line Items ( <%= @result_count %> ) @@ -52,11 +53,11 @@ - + - <% @batchLineItems.each do |item| %> + <% @batchLineItems.each do |item| %> @@ -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("") }); - $('#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) { diff --git a/app/views/clients/_form.html.erb b/app/views/clients/_form.html.erb index 6817a8e..9fb47e8 100644 --- a/app/views/clients/_form.html.erb +++ b/app/views/clients/_form.html.erb @@ -39,7 +39,7 @@
<%= 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' %>
diff --git a/app/views/clients/show.html.erb b/app/views/clients/show.html.erb index 4163fe0..974aa3a 100644 --- a/app/views/clients/show.html.erb +++ b/app/views/clients/show.html.erb @@ -1,7 +1,7 @@
diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 52fd98f..abdecf3 100644 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -23,7 +23,8 @@ - + + <% end %> diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 6ae1731..0cc35ff 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -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 { diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index d1d9878..0625205 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -35,7 +35,8 @@ - + +
Serial No Asset IdentityBatch No Asset Type Created At Update At Updated At
<%= item.serial_no rescue '' %> <%= item.asset_identity rescue '' %> <%= user.nrc rescue '' %> <%= user.email rescue '' %> <%= user.phone rescue '' %><%= user.address rescue '' %><%= user.address rescue '' %> <%= user.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %>
<%= user.nrc rescue '' %> <%= user.email rescue '' %> <%= user.phone rescue '' %><%= user.address rescue '' %><%= user.address rescue '' %> <%= user.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %> <%= link_to 'Detail', diff --git a/config/database.yml b/config/database.yml index 8ffb98d..53e4b5e 100644 --- a/config/database.yml +++ b/config/database.yml @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 140480b..0f560aa 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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"