edit ticket controller
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
class Api::AuthController < ApplicationController
|
class Api::AuthController < ApplicationController
|
||||||
skip_before_filter :verify_authenticity_token
|
skip_before_filter :verify_authenticity_token
|
||||||
def login
|
def login
|
||||||
|
|
||||||
username = params[:username]
|
username = params[:username]
|
||||||
access = params[:access_code]
|
access = params[:access_code]
|
||||||
|
|
||||||
member = Member.find_by_email(username)
|
member = Member.find_by_email(username)
|
||||||
if member && member.valid_password?(access)
|
if member && member.valid_password?(access)
|
||||||
member.session_token = SecureRandom.hex
|
member.session_token = SecureRandom.hex
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
def register
|
def register
|
||||||
batch_id=params[:batch_id]
|
batch_id=params[:batch_id]
|
||||||
session_token=params[:session_token]
|
session_token=params[:session_token]
|
||||||
manufacture_uid = params[:card_manufacture]
|
manufacture_uid = params[:card_manufacture]
|
||||||
# card_type = params[:card_type]
|
|
||||||
user_id=""
|
user_id=""
|
||||||
|
|
||||||
check_member= Member.authenticate_session_token(session_token)
|
check_member= Member.authenticate_session_token(session_token)
|
||||||
@@ -15,44 +14,51 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
encrypt_key=find_user.secrect_key
|
encrypt_key=find_user.secrect_key
|
||||||
user_id=find_user.id
|
user_id=find_user.id
|
||||||
end
|
end
|
||||||
if !encrypt_key.nil?
|
|
||||||
serial_no=BatchLineItem.generate_serial_no(user_id.to_s)
|
if !encrypt_key.nil?
|
||||||
str="manufacture_uid="+manufacture_uid.to_s+"&serial_no="+serial_no.to_s
|
check_manufacture = BatchLineItem.find_by_manufacture_uid(manufacture_uid)
|
||||||
|
if check_manufacture.nil?
|
||||||
|
serial_no=BatchLineItem.generate_serial_no(user_id.to_s)
|
||||||
|
str="manufacture_uid="+manufacture_uid.to_s+"&serial_no="+serial_no.to_s
|
||||||
|
|
||||||
digest_data= Digest::MD5.hexdigest(str)
|
digest_data= Digest::MD5.hexdigest(str)
|
||||||
hex_data=digest_data.hex
|
hex_data=digest_data.hex
|
||||||
hex_str=hex_data.to_s
|
hex_str=hex_data.to_s
|
||||||
wristband_code=hex_str[0..15]
|
wristband_code=hex_str[0..15]
|
||||||
|
check_wirstband=BatchLineItem.find_by_wristband_code(wristband_code)
|
||||||
|
|
||||||
|
if check_wirstband.nil?
|
||||||
|
puts 'Check Wristband'
|
||||||
|
card_type=""
|
||||||
|
find_batch= Batch.find_by_id(batch_id)
|
||||||
|
if !find_batch.nil?
|
||||||
|
card_type=find_batch.adult_or_child.upcase
|
||||||
|
end
|
||||||
|
batchLineItem=BatchLineItem.new
|
||||||
|
batchLineItem.wristband_code=wristband_code
|
||||||
|
batchLineItem.serial_no=serial_no
|
||||||
|
batchLineItem.batch_id=batch_id
|
||||||
|
batchLineItem.manufacture_uid = manufacture_uid
|
||||||
|
batchLineItem.card_type = card_type
|
||||||
|
|
||||||
|
if batchLineItem.save
|
||||||
|
lookup=Lookup.find_by_name('generate_serial_no')
|
||||||
|
max_serail_no=lookup.max_value
|
||||||
|
lookup.max_value=max_serail_no.to_i+1
|
||||||
|
lookup.save
|
||||||
|
|
||||||
check_manufacture = BatchLineItem.find_by_manufacture_uid_and_wristband_code(manufacture_uid,wristband_code)
|
@out = true,batchLineItem.serial_no,batchLineItem.wristband_code
|
||||||
if check_manufacture.nil?
|
else
|
||||||
card_type=""
|
@out=false,'Error occurs in registration encoder!'
|
||||||
find_batch= Batch.find_by_id(batch_id)
|
end
|
||||||
if !find_batch.nil?
|
|
||||||
card_type=find_batch.adult_or_child.upcase
|
|
||||||
end
|
|
||||||
batchLineItem=BatchLineItem.new
|
|
||||||
batchLineItem.wristband_code=wristband_code
|
|
||||||
batchLineItem.serial_no=serial_no
|
|
||||||
batchLineItem.batch_id=batch_id
|
|
||||||
batchLineItem.manufacture_uid = manufacture_uid
|
|
||||||
batchLineItem.card_type = card_type
|
|
||||||
|
|
||||||
if batchLineItem.save
|
|
||||||
lookup=Lookup.find_by_name('generate_serial_no')
|
|
||||||
max_serail_no=lookup.max_value
|
|
||||||
lookup.max_value=max_serail_no.to_i+1
|
|
||||||
lookup.save
|
|
||||||
|
|
||||||
@out = true,batchLineItem.serial_no,batchLineItem.wristband_code
|
|
||||||
else
|
else
|
||||||
@out=false,'Error occurs in registration encoder!'
|
@out=false,'Wristband is already registered!'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,'Wristband code is already exists!'
|
@out=false,'Wristband is already registered!'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,'Invalid Encryption Key!'
|
@out=false,'Invalid User!'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,'Sorry!Unauthorized user!'
|
@out=false,'Sorry!Unauthorized user!'
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ class BatchLineItemsController < ApplicationController
|
|||||||
user_id=current_member.user_id
|
user_id=current_member.user_id
|
||||||
|
|
||||||
@batches=Batch.where('user_id=?',user_id)
|
@batches=Batch.where('user_id=?',user_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').page(params[:page]).per(2)
|
@batchLineItems=BatchLineItem.joins('inner join batches on batches.id=batch_line_items.batch_id')
|
||||||
|
.where('batches.user_id=?',user_id)
|
||||||
|
.select('batch_line_items.*,batches.order_ref as batch_name').page(params[:page]).per(2)
|
||||||
end
|
end
|
||||||
def export
|
def export
|
||||||
batch_list=params[:batch]
|
batch_list=params[:batch]
|
||||||
@@ -30,7 +32,7 @@ class BatchLineItemsController < ApplicationController
|
|||||||
end
|
end
|
||||||
@batchLineItems = BatchLineItem.all.select('serial_no,wristband_code,batch_id,manufacture_uid,card_type')
|
@batchLineItems = BatchLineItem.all.select('serial_no,wristband_code,batch_id,manufacture_uid,card_type')
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.csv { send_data @batchLineItems.to_csv(user_id), filename: "encoder-#{Date.today}.csv" }
|
format.csv { send_data @batchLineItems.to_csv(user_id), filename: "encoder-#{Date.today}.csv" }
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class BatchesController < ApplicationController
|
class BatchesController < ApplicationController
|
||||||
|
skip_before_filter :verify_authenticity_token
|
||||||
|
before_action :authenticate_member!
|
||||||
def index
|
def index
|
||||||
@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])
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class HomeController < ApplicationController
|
class HomeController < ApplicationController
|
||||||
skip_before_filter :verify_authenticity_token
|
skip_before_filter :verify_authenticity_token
|
||||||
|
before_action :authenticate_member!
|
||||||
|
|
||||||
def index
|
def index
|
||||||
redirect_to new_member_session_path
|
redirect_to new_member_session_path
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
skip_before_filter :verify_authenticity_token
|
skip_before_filter :verify_authenticity_token
|
||||||
|
before_action :authenticate_member!
|
||||||
before_action :set_user, only: [:show, :edit, :update, :destroy]
|
before_action :set_user, only: [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
# GET /users
|
# GET /users
|
||||||
@@ -32,7 +33,7 @@ class UsersController < ApplicationController
|
|||||||
key=cipher.random_key
|
key=cipher.random_key
|
||||||
secrect_key= Base64.encode64(key)
|
secrect_key= Base64.encode64(key)
|
||||||
@user.secrect_key=secrect_key
|
@user.secrect_key=secrect_key
|
||||||
|
@email=email
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @user.save
|
if @user.save
|
||||||
member_id= current_member.id
|
member_id= current_member.id
|
||||||
|
|||||||
@@ -24,13 +24,12 @@ class BatchLineItem < ApplicationRecord
|
|||||||
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?
|
||||||
max_value=find_lookup.max_value
|
max_value=find_lookup.max_value
|
||||||
|
max_value=max_value +1
|
||||||
prefix=find_lookup.prefix
|
prefix=find_lookup.prefix
|
||||||
max_length=find_lookup.max_length
|
max_length=find_lookup.max_length
|
||||||
|
|
||||||
max_value=max_value +1
|
|
||||||
sufix_len=max_length-prefix.length
|
sufix_len=max_length-prefix.length
|
||||||
sufix_str="0" * sufix_len
|
sufix_str="0" * sufix_len
|
||||||
|
value_len= max_value.to_s.length
|
||||||
start=0
|
start=0
|
||||||
ends=sufix_len-value_len-1
|
ends=sufix_len-value_len-1
|
||||||
sufix_str= sufix_str[start..ends]
|
sufix_str= sufix_str[start..ends]
|
||||||
@@ -38,14 +37,7 @@ class BatchLineItem < ApplicationRecord
|
|||||||
prefix_str=prefix.to_s + user_id.to_s
|
prefix_str=prefix.to_s + user_id.to_s
|
||||||
|
|
||||||
serial_no=prefix_str.to_s+sufix_str+max_value.to_s
|
serial_no=prefix_str.to_s+sufix_str+max_value.to_s
|
||||||
return serial_no
|
return serial_no
|
||||||
else
|
|
||||||
lookup= Lookup.new
|
|
||||||
lookup.name="generate_serial_no"
|
|
||||||
lookup.max_value=0
|
|
||||||
lookup.prefix='0000'
|
|
||||||
lookup.max_length=16
|
|
||||||
lookup.save
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def self.to_csv(user_id)
|
def self.to_csv(user_id)
|
||||||
@@ -68,7 +60,7 @@ class BatchLineItem < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def self.encrypted(message,encrypt_key)
|
def self.encrypted(message,encrypt_key)
|
||||||
cipher = OpenSSL::Cipher::Cipher.new("aes-128-cbc")
|
cipher = OpenSSL::Cipher::Cipher.new("aes-128-cbc")
|
||||||
cipher.encrypt
|
cipher.encrypt
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<div class="col-md-5" >
|
<div class="col-md-5" >
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email" class="string optional control-label">Registered Email:</label>
|
<label for="email" class="string optional control-label">Registered Email:</label>
|
||||||
<input type="text" id="registered_email" name="registered_email" class="form-control" placeholder="Please enter member mail">
|
<input type="text" id="registered_email" name="registered_email" class="form-control" placeholder="Please enter member mail" value="<%= @email %>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
@@ -65,14 +65,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<script >
|
<script >
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
status='disabled'
|
error_count="<%= @user.errors.count %>"
|
||||||
|
if (error_count>0){
|
||||||
|
status=''
|
||||||
|
}else{
|
||||||
|
status='disabled'
|
||||||
|
}
|
||||||
|
|
||||||
name=$("#user_name").val()
|
name=$("#user_name").val()
|
||||||
if (name.trim() !=""){
|
if (name.trim() !=""){
|
||||||
status=''
|
status=''
|
||||||
}
|
}
|
||||||
enable_control(status)
|
enable_control(status)
|
||||||
|
|
||||||
$("#check_email").click(function(){
|
$("#check_email").click(function(){
|
||||||
|
|||||||
Reference in New Issue
Block a user