change database

This commit is contained in:
May Zin Oo
2018-03-05 11:13:37 +06:30
34 changed files with 22441 additions and 89 deletions

View File

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

View File

@@ -2,7 +2,7 @@ class BatchLineItemsController < ApplicationController
require "csv" require "csv"
skip_before_filter :verify_authenticity_token skip_before_filter :verify_authenticity_token
before_action :authenticate_member! before_action :authenticate_member!
require 'digest/md5'
def index def index
# user_id=current_member.user_id # user_id=current_member.user_id
@@ -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]
@@ -39,12 +42,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?
@@ -96,13 +99,13 @@ 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")
.joins('inner join product_categories product on product.id=batches.product_category_id') .joins('inner join product_categories product on product.id=batches.product_category_id')
.where('batch_id in (?)',batch_list) .where('batch_id in (?)',batch_list)
.select("*,product.product_type_id ,product.name,'' as secret_token,'' as location") .select("*,product.product_type_id ,product.name,'' as secret_token,'' as location_name")
else else
Batch.where("client_id=? ",client_id).update_all("export_count = export_count + 1,exported_by='"+exported_by+"'") Batch.where("client_id=? ",client_id).update_all("export_count = export_count + 1,exported_by='"+exported_by+"'")
sub_query="(select * from batches where client_id ="+client_id+" and product_category_id="+ product_category_id+")" sub_query="(select * from batches where client_id ="+client_id+" and product_category_id="+ product_category_id+")"
@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')
.joins('inner join product_categories as product on product.id=batches.product_category_id') .joins('inner join product_categories as product on product.id=batches.product_category_id')
.select("*,product.product_type_id ,product.name,'' as secret_token,'' as location") .select("*,product.product_type_id ,product.name,'' as secret_token,'' as location_name")
end end
datestr= Time.now.strftime("%Y/%m/%d %H:%M:%S") datestr= Time.now.strftime("%Y/%m/%d %H:%M:%S")
@@ -112,4 +115,71 @@ class BatchLineItemsController < ApplicationController
format.csv { send_data @batchLineItems.to_csv(client_id,location_code), filename: "#{filename}.csv" } format.csv { send_data @batchLineItems.to_csv(client_id,location_code), filename: "#{filename}.csv" }
end end
end end
def generate_cards
end
def generate_card_account_items
# Generate Code
batch_id=params[:id]
client_id=""
qty = params[:qty]
total_count=0
# check_member= Member.authenticate_session_token(session_token)
# if !check_member.nil?
encrypt_key=""
asset_identity=""
find_batch = Batch.find_by_id(batch_id)
if !find_batch.nil?
puts 'hkjfklasj'
card_type=find_batch.adult_or_child.upcase
product_category_id=find_batch.product_category_id
find_product_category=ProductCategory.find_by_id(product_category_id)
if !find_product_category.nil?
product_type=find_product_category.product_type_id
find_user=Client.find_by_id(find_batch.client_id)
if !find_user.nil?
encrypt_key=find_user.secrect_key
location_code=find_user.location_code
client_id=find_user.id
if !encrypt_key.nil?
# Generate with qty
qty.to_i.times do |i|
serial_no=BatchLineItem.generate_serial_no(client_id.to_s)
asset_identity=BatchLineItem.generate_account_no(location_code)
security_code=BatchLineItem.generate_security_code
out=BatchLineItem.create_product(asset_identity,serial_no,batch_id,"","",security_code)
total_count+=1
end
respond_to do |format|
format.html { redirect_to batch_url(batch_id), notice: 'Successfully generated.' }
format.json { head :no_content }
end
# Generate with qty
else
@out=false,'Invalid User!'
end
else
@out=false,"Client doesn't exist!"
end
else
@out=false,"Product Category doesn't exist!"
end
else
@out=false,"Batch doesn't exist!"
end
# else
# @out=false,'Sorry!Unauthorized user!'
# end
# Generate Code
end
end end

View File

@@ -1,17 +1,75 @@
class BatchesController < ApplicationController class BatchesController < ApplicationController
skip_before_filter :verify_authenticity_token skip_before_filter :verify_authenticity_token
before_action :authenticate_member! # before_action :authenticate_member!
before_action :set_batch,:authenticate_member!, only: [:show, :edit, :update, :destroy]
def index def index
@product_category_id="" @product_category_id=""
@clients=Client.all.order('id desc') @clients=Client.all.order('id desc')
@product_categories=ProductCategory.all.order('id desc') @product_categories=ProductCategory.all.order('id desc')
@batches=Batch.joins('inner join users on users.id=batches.user_id') @batches=Batch.joins('inner join users on users.id=batches.user_id')
.select('batches.*,users.name as user_name').order('batches.id desc').page(params[:page]) .select('batches.*,users.name as user_name').order('batches.id desc').page(params[:page])
@count = Batch.joins('inner join users on users.id=batches.user_id') @count = Batch.joins('inner join users on users.id=batches.user_id')
.select('batches.*').count .select('batches.*').count
end end
def show
@batchLineItems=BatchLineItem.where("batch_id=?",params[:id]).page(params[:page]).per(10)
@result_count= @batchLineItems.total_count
end
def new
@batch = Batch.new
end
def edit
end
def create
date = DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d")
order_ref = params[:batch][:order_ref]
puts order_ref
adult_or_child=params[:adult_or_child]
client_id=params[:client_id]
product_category_id=params[:product_category_id]
@batch = Batch.create_batch(date,order_ref,2,"adult_or_child",6,3)
puts @batch.order_ref
respond_to do |format|
if @batch.save
format.html { redirect_to @batch, notice: 'Batch was successfully created.' }
format.json { render :show, status: :created, location: @batch }
else
format.html { render :new }
format.json { render json: @batch.errors, status: :unprocessable_entity }
end
end
end
def update
respond_to do |format|
if @batch.update(batch_params)
format.html { redirect_to @batch, notice: 'Batch was successfully updated.' }
format.json { render :show, status: :ok, location: @batch }
else
format.html { render :edit }
format.json { render json: @batch.errors, status: :unprocessable_entity }
end
end
end
def destroy
@batch.destroy
respond_to do |format|
format.html { redirect_to batches_url, notice: 'Batch was successfully destroyed.' }
format.json { head :no_content }
end
end
def search def search
client_id=params[:client_id] client_id=params[:client_id]
product_category_id=params[:product_category_id] product_category_id=params[:product_category_id]
@@ -51,4 +109,14 @@ class BatchesController < ApplicationController
end end
end end
private
# Use callbacks to share common setup or constraints between actions.
def set_batch
@batch = Batch.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def batch_params
params.require(:batch).permit(:date,:user_id, :client_id, :order_ref,:batch_start,:batch_end,:exported_by,:qty_processing,:qty_success,:qty_fail,:batch_start_time,:batch_end_time,:export_count,:remark,:adult_or_child,:product_category_id)
end
end end

View File

@@ -1,5 +1,8 @@
class Batch < ApplicationRecord class Batch < ApplicationRecord
has_many :batch_line_item has_many :batch_line_item
belongs_to :client
belongs_to :product_category
belongs_to :user
def self.create_batch(date,order_ref,user_id,adult_or_child,client_id,product_category_id) def self.create_batch(date,order_ref,user_id,adult_or_child,client_id,product_category_id)
batch = Batch.new batch = Batch.new

View File

@@ -3,6 +3,7 @@ class BatchLineItem < ApplicationRecord
attr_accessor :secret_token attr_accessor :secret_token
attr_accessor :location attr_accessor :location
attr_accessor :product_type attr_accessor :product_type
require 'digest/md5'
def self.generate_account_no(location_code) def self.generate_account_no(location_code)
super_merchant = "101" super_merchant = "101"
@@ -21,6 +22,18 @@ class BatchLineItem < ApplicationRecord
end end
return account_no return account_no
end end
def self.generate_security_code
o = [('0'..'8')].map { |i| i.to_a }.flatten
security_code = (0...8).map { o[rand(o.length)] }.join
find_account_no = BatchLineItem.find_by_security_code(security_code)
if !find_account_no.nil?
o = [('0'..'8')].map { |i| i.to_a }.flatten
security_code = (0...8).map { o[rand(o.length)] }.join
end
return security_code
end
def self.generate_serial_no(client_id) def self.generate_serial_no(client_id)
find_lookup=Lookup.find_by_name('generate_serial_no') find_lookup=Lookup.find_by_name('generate_serial_no')
if !find_lookup.nil? if !find_lookup.nil?
@@ -54,16 +67,22 @@ class BatchLineItem < ApplicationRecord
if !find_client.nil? if !find_client.nil?
encrypt_key=find_client.secrect_key encrypt_key=find_client.secrect_key
end end
attributes = %w{serial_no asset_identity batch_id manufacture_uid asset_type secret_token location} attributes = %w{serial_no asset_identity batch_id manufacture_uid asset_type secret_token location security_code}
CSV.generate(headers: true) do |csv| CSV.generate(headers: true) do |csv|
csv << attributes csv << attributes
all.each do |encoder| all.each do |encoder|
if encoder.product_type_id ==1 if encoder.product_type_id ==1
str="account_no="+encoder.asset_identity.to_s+"&manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s str="account_no="+encoder.asset_identity.to_s+"&manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s
else else
str="manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s str="manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s
end end
security_code = encoder.security_code
digest = Digest::MD5.hexdigest(security_code)
puts 'digest............'
puts digest
encryptd_data=BatchLineItem.encrypted(str,encrypt_key) encryptd_data=BatchLineItem.encrypted(str,encrypt_key)
encoder.secret_token=encryptd_data encoder.secret_token=encryptd_data
encoder.location=location_code encoder.location=location_code
@@ -89,7 +108,7 @@ class BatchLineItem < ApplicationRecord
return encrypted return encrypted
end end
def self.create_product(asset_identity,serial_no,batch_id,manufacture_uid,card_type) def self.create_product(asset_identity,serial_no,batch_id,manufacture_uid,card_type,security_code=nil)
batchLineItem=BatchLineItem.new batchLineItem=BatchLineItem.new
batchLineItem.asset_identity=asset_identity batchLineItem.asset_identity=asset_identity
batchLineItem.serial_no=serial_no batchLineItem.serial_no=serial_no
@@ -98,7 +117,10 @@ class BatchLineItem < ApplicationRecord
batchLineItem.asset_type = card_type batchLineItem.asset_type = card_type
batchLineItem.encoded_at = DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d") batchLineItem.encoded_at = DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d")
batchLineItem.verified_at =DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d") batchLineItem.verified_at =DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d")
if !security_code.nil?
batchLineItem.security_code = security_code
puts 'security_code;fksdfklsdjfklsdfklsdjfklsdjfklsdjflskd'
end
batch=Batch.find_by_id(batch_id) batch=Batch.find_by_id(batch_id)
if batchLineItem.save if batchLineItem.save

BIN
app/views/.DS_Store vendored

Binary file not shown.

BIN
app/views/batch_line_items/.DS_Store vendored Normal file

Binary file not shown.

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

@@ -0,0 +1,22 @@
<div class="row">
<nav class="breadcrumb">
<a class="breadcrumb-item" href="<%= dashboard_path %>">Home</a>
<a class="breadcrumb-item active" href="<%= clients_path %>">Clients</a>
<a class="breadcrumb-item active" href="#">Show</a>
</nav>
</div>
<div class="row content">
<div class="col-lg-6 show">
<%= form_tag generate_card_account_items_path,:method => :post do %>
<%= hidden_field_tag 'id', params[:id] %>
<%= label_tag(:qty, "Qty:") %>
<%= text_field_tag(:qty) %>
<%= submit_tag("Generate") %>
<% end %>
</div>
</div>
<div class="row">
<div class="col-lg-8">
<div class="col-lg-3"></div>
</div>
</div>

View File

@@ -28,49 +28,50 @@
</div> </div>
</div> </div>
<div class="row content"> <div class="row content">
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
<strong>Batch Line Item List</strong> <strong>Batch Line Item List</strong>
</div> </div>
<div class="card-block"> <div class="card-block">
<% flash.each do |key, value| %> <% flash.each do |key, value| %>
<% if key =='message' %> <% if key =='message' %>
<div class="alert alert-danger center"> <div class="alert alert-danger center">
<a class="close" data-dismiss="alert">×</a> <a class="close" data-dismiss="alert">×</a>
<%= value %> <%= value %>
<% end %> <% end %>
</div> </div>
<% end %> <% end %>
<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> <tr><b><i>Batch Line Items ( <%= @result_count %> )</i></b></tr>
<th>Serial No</th> <tr>
<th>Asset Identity</th> <th>Serial No</th>
<th>Manufacture UID</th> <th>Asset Identity</th>
<th>Batch No</th> <th>Manufacture UID</th>
<th>Asset Type</th> <th>Batch No</th>
<th>Created At </th> <th>Asset Type</th>
<th>Update At </th> <th>Created At </th>
</tr> <th>Updated At </th>
</thead> </tr>
<tbody> </thead>
<% @batchLineItems.each do |item| %> <tbody>
<tr> <% @batchLineItems.each do |item| %>
<td><%= item.serial_no rescue '' %></td> <tr>
<td><%= item.asset_identity rescue '' %></td> <td><%= item.serial_no rescue '' %></td>
<td><%= item.manufacture_uid rescue '' %></td> <td><%= item.asset_identity rescue '' %></td>
<td><%= item.batch_name rescue '' %></td> <td><%= item.manufacture_uid rescue '' %></td>
<td><%= item.asset_type rescue '' %></td> <td><%= item.batch_name rescue '' %></td>
<td><%= item.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td> <td><%= item.asset_type rescue '' %></td>
<td><%= item.updated_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td> <td><%= item.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
</tr> <td><%= item.updated_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
<% end %> </tr>
</tbody> <% end %>
</table> </tbody>
<%=paginate @batchLineItems %> </table>
<div> <%=paginate @batchLineItems %>
</div> <div>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
@@ -85,8 +86,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({
@@ -101,7 +109,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');
} }
@@ -110,17 +118,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();
@@ -143,6 +152,7 @@ $(document).ready(function(){
}, },
complete: function(){ complete: function(){
$('#loading').hide(); $('#loading').hide();
}, },
success: function(data) { success: function(data) {
} }

BIN
app/views/batches/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,2 @@
json.extract! batch, :id,:date,:user_id, :client_id, :order_ref,:batch_start,:batch_end,:exported_by,:qty_processing,:qty_success,:qty_fail,:batch_start_time,:batch_end_time,:export_count,:remark,:adult_or_child,:product_category_id
json.url batch_url(batch, format: :json)

View File

@@ -0,0 +1,29 @@
<%= simple_form_for(@batch) do |f| %>
<nav class="breadcrumb">
<a class="breadcrumb-item" href="<%= dashboard_path %>">Home</a>
<a class="breadcrumb-item active" href="<%= batches_path %>">Batch</a>
<a class="breadcrumb-item active" href="#">
<% if !@batch.id.nil? %>
Edit
<% else %>
New
<% end %>
</a>
</nav>
<div class="row">
<div class="col-md-6" id="textbox_group">
<div class ="form-group" >
<label for="name" class="string optional control-label">Name:</label>
<%= f.input :order_ref ,:label =>false,:error => false,:placeholder =>'Please enter name',input_html: { class: "form-control" } %>
<%= f.error :order_ref ,style: 'color: red' %>
</div>
<div class ="form-group" >
<label></label>
<div class="actions">
<%= f.button :submit, :class => 'btn btn-primary',:id =>'btn_submit' %>
<%= link_to 'Cancel', batches_path ,:class => 'btn btn-primary',:id => 'btnback' %>
</div>
</div>
</div>
</div>
<% end %>

View File

@@ -0,0 +1 @@
<%= render 'form', batch: @batch %>

View File

@@ -4,6 +4,11 @@
<a class="breadcrumb-item active" href="#">Batches</a> <a class="breadcrumb-item active" href="#">Batches</a>
</nav> </nav>
</div> </div>
<div class="row top-content">
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")),new_batch_path,:class => 'btn btn-primary' %>
</span>
</div>
<div class="row content"> <div class="row content">
<div class="col-lg-4"> <div class="col-lg-4">
<label><strong>Search:</strong></label> <label><strong>Search:</strong></label>
@@ -46,7 +51,8 @@
<th>Qty Fail</th> <th>Qty Fail</th>
<th>Export Count</th> <th>Export Count</th>
<th>Exported By</th> <th>Exported By</th>
<th>Created At</th> <th>Created At</th>
<th>Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -60,6 +66,10 @@
<td><%= batch.export_count %></td> <td><%= batch.export_count %></td>
<td><%= batch.exported_by %></td> <td><%= batch.exported_by %></td>
<td><%= batch.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td> <td><%= batch.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
<td>
<%= link_to 'Detail',
batch_path(batch), :class => 'btn btn-primary btn-sm' %>
</td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

View File

@@ -0,0 +1 @@
<%= render 'form', batch: @batch %>

View File

@@ -0,0 +1,92 @@
<div class="row">
<nav class="breadcrumb">
<a class="breadcrumb-item" href="<%= dashboard_path %>">Home</a>
<a class="breadcrumb-item active" href="<%= clients_path %>">Batches</a>
<a class="breadcrumb-item active" href="#">Show</a>
<span style="float:right">
<%= link_to 'Generate QR Code', generate_cards_path(@batch.id),:class => 'btn btn-primary' %>
</span>
</nav>
</div>
<div class="row content">
<div class="col-lg-6 show">
<div class="row">
<div class="col-lg-4"><strong>Order Ref:</strong></div>
<div class="col-lg-8 uppercase"><%= @batch.order_ref %></div>
</div>
<div class="row">
<div class="col-lg-4"><strong>Exported By:</strong></div>
<div class="col-lg-8"><%= @batch.exported_by %></div>
</div>
<div class="row">
<div class="col-lg-4"><strong>User Name:</strong></div>
<div class="col-lg-8"><%= @batch.user.name %></div>
</div>
<div class="row">
<div class="col-lg-4"><strong>Client:</strong></div>
<div class="col-lg-8"><%= @batch.client.name %></div>
</div>
<div class="row">
<div class="col-lg-4"><strong>Date:</strong></div>
<div class="col-lg-8"><%= @batch.date.strftime("%e,%b %Y %I:%M %p") rescue '' %></div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-8">
<div class="col-lg-3"></div>
<div class="col-lg-4 btn-show-action">
<%= link_to 'Edit', edit_batch_path(@batch),:class => 'btn btn-primary' %>
<%= link_to 'Back', batches_path ,:class => 'btn btn-primary'%>
</div>
</div>
</div>
<div class="row content">
<div class="card">
<div class="card-header">
<strong>Batch Line Item List( <%= @result_count %> )</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>Updated 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>

View File

@@ -0,0 +1 @@
json.partial! "batches/batch", batch: @batch

BIN
app/views/clients/.DS_Store vendored Normal file

Binary file not shown.

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

@@ -23,7 +23,8 @@
<td><%= user.nrc rescue '' %></td> <td><%= user.nrc rescue '' %></td>
<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

@@ -35,7 +35,8 @@
<td><%= user.nrc rescue '' %></td> <td><%= user.nrc rescue '' %></td>
<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_production database: nemo_production
username: mayzin username: mayzin
# Warning: The database defined as "test" will be erased and default: &default
# re-generated from your development database when you run "rake". adapter: postgresql
# Do not set this db to the same as development or production.
test:
<<: *default
database: nemo_encoder_production_test
production: pool: 5
<<: *default timeout: 5000
database: nemo encoding: utf8
username: deploy
password: OU771o3ja3Hn4$r

View File

@@ -6,7 +6,7 @@ Rails.application.routes.draw do
root :to => 'home#index' root :to => 'home#index'
get "dashboard", to: "home#dashboard", as: "dashboard" get "dashboard", to: "home#dashboard", as: "dashboard"
resources :batches,:only =>[:index] resources :batches
devise_for :members devise_for :members
resources :batch_line_items,:only =>[:index] resources :batch_line_items,:only =>[:index]
resources :users resources :users
@@ -22,6 +22,10 @@ Rails.application.routes.draw do
match 'batch_line_items/export' => 'batch_line_items#export', :as => 'export', :via => [:post ,:get] match 'batch_line_items/export' => 'batch_line_items#export', :as => 'export', :via => [:post ,:get]
get 'get_batch' => 'batch_line_items#get_batch',:as => 'get_batch' get 'get_batch' => 'batch_line_items#get_batch',:as => 'get_batch'
get 'generate_cards/:id' => 'batch_line_items#generate_cards',:as => 'generate_cards'
post "generate_card_account_items" =>"batch_line_items#generate_card_account_items"
namespace :api, defaults: {format: :json} do namespace :api, defaults: {format: :json} do
#login #login
post "auth/login" =>"auth#login" post "auth/login" =>"auth#login"

View File

@@ -0,0 +1,5 @@
class AddSecurityCodeInItems < ActiveRecord::Migration[5.0]
def change
add_column :batch_line_items, :security_code, :string
end
end

View File

@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170210103359) do ActiveRecord::Schema.define(version: 20180226100816) 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"
@@ -26,6 +26,7 @@ ActiveRecord::Schema.define(version: 20170210103359) do
t.datetime "verified_at" t.datetime "verified_at"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.string "security_code"
t.index ["batch_id"], name: "index_batch_line_items_on_batch_id", using: :btree t.index ["batch_id"], name: "index_batch_line_items_on_batch_id", using: :btree
end end

View File

@@ -1 +1 @@
{"files":{"application-55570bc046304f178e10e45bec721268c8bf8e0a3bc8f2c1f69ff39df39dee3e.js":{"logical_path":"application.js","mtime":"2017-01-19T15:25:44+06:30","size":416216,"digest":"55570bc046304f178e10e45bec721268c8bf8e0a3bc8f2c1f69ff39df39dee3e","integrity":"sha256-VVcLwEYwTxeOEORb7HISaMi/jgo7yPLB9p/znfOd7j4="},"application-13eed745f8cdce49cda636dbb6e1d13489cce811adff36b761521f71e31214e9.css":{"logical_path":"application.css","mtime":"2017-01-19T15:25:44+06:30","size":735,"digest":"13eed745f8cdce49cda636dbb6e1d13489cce811adff36b761521f71e31214e9","integrity":"sha256-E+7XRfjNzknNpjbbtuHRNInM6BGt/za3YVIfceMSFOk="},"application-dd37038c1f0879ef01c745fd8ef7928f3e45a56984deeabd50392be0a3162d6f.js":{"logical_path":"application.js","mtime":"2017-01-21T16:54:30+06:30","size":459409,"digest":"dd37038c1f0879ef01c745fd8ef7928f3e45a56984deeabd50392be0a3162d6f","integrity":"sha256-3TcDjB8Iee8Bx0X9jveSjz5FpWmE3uq9UDkr4KMWLW8="},"application-9db673cb6d4bf3821c5d6ed2f654d4ecb84adecf44609892b94d84b104a4ba68.css":{"logical_path":"application.css","mtime":"2017-01-21T16:54:27+06:30","size":261683,"digest":"9db673cb6d4bf3821c5d6ed2f654d4ecb84adecf44609892b94d84b104a4ba68","integrity":"sha256-nbZzy21L84IcXW7S9lTU7LhK3s9EYJiSuU2EsQSkumg="}},"assets":{"application.js":"application-dd37038c1f0879ef01c745fd8ef7928f3e45a56984deeabd50392be0a3162d6f.js","application.css":"application-9db673cb6d4bf3821c5d6ed2f654d4ecb84adecf44609892b94d84b104a4ba68.css"}} {"files":{"application-55570bc046304f178e10e45bec721268c8bf8e0a3bc8f2c1f69ff39df39dee3e.js":{"logical_path":"application.js","mtime":"2017-01-19T15:25:44+06:30","size":416216,"digest":"55570bc046304f178e10e45bec721268c8bf8e0a3bc8f2c1f69ff39df39dee3e","integrity":"sha256-VVcLwEYwTxeOEORb7HISaMi/jgo7yPLB9p/znfOd7j4="},"application-13eed745f8cdce49cda636dbb6e1d13489cce811adff36b761521f71e31214e9.css":{"logical_path":"application.css","mtime":"2017-01-19T15:25:44+06:30","size":735,"digest":"13eed745f8cdce49cda636dbb6e1d13489cce811adff36b761521f71e31214e9","integrity":"sha256-E+7XRfjNzknNpjbbtuHRNInM6BGt/za3YVIfceMSFOk="},"application-dd37038c1f0879ef01c745fd8ef7928f3e45a56984deeabd50392be0a3162d6f.js":{"logical_path":"application.js","mtime":"2017-01-21T16:54:30+06:30","size":459409,"digest":"dd37038c1f0879ef01c745fd8ef7928f3e45a56984deeabd50392be0a3162d6f","integrity":"sha256-3TcDjB8Iee8Bx0X9jveSjz5FpWmE3uq9UDkr4KMWLW8="},"application-9db673cb6d4bf3821c5d6ed2f654d4ecb84adecf44609892b94d84b104a4ba68.css":{"logical_path":"application.css","mtime":"2017-01-21T16:54:27+06:30","size":261683,"digest":"9db673cb6d4bf3821c5d6ed2f654d4ecb84adecf44609892b94d84b104a4ba68","integrity":"sha256-nbZzy21L84IcXW7S9lTU7LhK3s9EYJiSuU2EsQSkumg="},"spinner-c1cf81bef2ea82eaa43265a5ff786b7cd74e7d5f4f2de104b586f092ca0fb886.gif":{"logical_path":"spinner.gif","mtime":"2017-02-10T11:04:52+06:30","size":723,"digest":"c1cf81bef2ea82eaa43265a5ff786b7cd74e7d5f4f2de104b586f092ca0fb886","integrity":"sha256-wc+BvvLqguqkMmWl/3hrfNdOfV9PLeEEtYbwksoPuIY="},"application-4b07da359561fb578da05680a32fde19ae94afccd5ce3efeef8c5d0f2caa96df.js":{"logical_path":"application.js","mtime":"2017-03-08T14:08:26+06:30","size":482933,"digest":"4b07da359561fb578da05680a32fde19ae94afccd5ce3efeef8c5d0f2caa96df","integrity":"sha256-SwfaNZVh+1eNoFaAoy/eGa6Ur8zVzj7+74xdDyyqlt8="},"application-e6b1e1192547851708d9ee55b2e3889c54242c9f13777b26a8d33acbd5dedbac.css":{"logical_path":"application.css","mtime":"2017-10-26T17:47:18+06:30","size":260095,"digest":"e6b1e1192547851708d9ee55b2e3889c54242c9f13777b26a8d33acbd5dedbac","integrity":"sha256-5rHhGSVHhRcI2e5VsuOInFQkLJ8Td3smqNM6y9Xe26w="}},"assets":{"application.js":"application-4b07da359561fb578da05680a32fde19ae94afccd5ce3efeef8c5d0f2caa96df.js","application.css":"application-e6b1e1192547851708d9ee55b2e3889c54242c9f13777b26a8d33acbd5dedbac.css","spinner.gif":"spinner-c1cf81bef2ea82eaa43265a5ff786b7cd74e7d5f4f2de104b586f092ca0fb886.gif"}}

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B