Update
This commit is contained in:
@@ -6,12 +6,12 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
# GET /crm/customers.json
|
# GET /crm/customers.json
|
||||||
def index
|
def index
|
||||||
filter = params[:filter]
|
filter = params[:filter]
|
||||||
|
|
||||||
if filter.nil?
|
if filter.nil?
|
||||||
@crm_customers = Customer.all
|
@crm_customers = Customer.all
|
||||||
else
|
else
|
||||||
@crm_customers = Customer.search(filter)
|
@crm_customers = Customer.search(filter)
|
||||||
|
|
||||||
end
|
end
|
||||||
#@crm_customers = Customer.all
|
#@crm_customers = Customer.all
|
||||||
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
||||||
@@ -32,7 +32,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
def show
|
def show
|
||||||
@orders = Order.where("customer_id=?", params[:id])
|
@orders = Order.where("customer_id=?", params[:id])
|
||||||
@sales = Sale.where("customer_id=?", params[:id])
|
@sales = Sale.where("customer_id=?", params[:id])
|
||||||
|
|
||||||
if @orders
|
if @orders
|
||||||
@order_items = []
|
@order_items = []
|
||||||
@orders.each do |order|
|
@orders.each do |order|
|
||||||
@@ -70,7 +70,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
def create
|
def create
|
||||||
|
|
||||||
@crm_customers = Customer.new(customer_params)
|
@crm_customers = Customer.new(customer_params)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @crm_customers.save
|
if @crm_customers.save
|
||||||
name = customer_params[:name]
|
name = customer_params[:name]
|
||||||
@@ -81,7 +81,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
nrc = customer_params[:nrc_no]
|
nrc = customer_params[:nrc_no]
|
||||||
card_no = customer_params[:card_no]
|
card_no = customer_params[:card_no]
|
||||||
member_group_id = params[:member_group_id]
|
member_group_id = params[:member_group_id]
|
||||||
|
|
||||||
if !member_group_id.nil?
|
if !member_group_id.nil?
|
||||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||||
@@ -90,7 +90,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
|
||||||
begin
|
begin
|
||||||
response = HTTParty.post(url,
|
response = HTTParty.post(url,
|
||||||
:body => {name: name,phone: phone,email: email,
|
:body => {name: name,phone: phone,email: email,
|
||||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||||
member_group_id: member_group_id,
|
member_group_id: member_group_id,
|
||||||
@@ -103,18 +103,24 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
)
|
)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false }
|
response = { status: false }
|
||||||
|
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
response = { status: false}
|
||||||
|
|
||||||
|
rescue SocketError
|
||||||
|
response = { status: false}
|
||||||
end
|
end
|
||||||
|
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
|
|
||||||
customer = Customer.find(@crm_customers.customer_id)
|
customer = Customer.find(@crm_customers.customer_id)
|
||||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||||
|
|
||||||
if params[:sale_id]
|
if params[:sale_id]
|
||||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' }
|
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' }
|
||||||
else
|
else
|
||||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
|
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
|
||||||
end
|
end
|
||||||
# format.json { render :index, status: :created, location: @crm_customers }
|
# format.json { render :index, status: :created, location: @crm_customers }
|
||||||
else
|
else
|
||||||
# @crm_customers.destroy
|
# @crm_customers.destroy
|
||||||
@@ -129,7 +135,7 @@ class Crm::CustomersController < BaseCrmController
|
|||||||
|
|
||||||
if params[:sale_id]
|
if params[:sale_id]
|
||||||
flash[:errors] = @crm_customers.errors
|
flash[:errors] = @crm_customers.errors
|
||||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
|
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
|
||||||
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
|
format.json { render json: @crm_customers.errors, status: :unprocessable_entity }
|
||||||
else
|
else
|
||||||
flash[:errors] = @crm_customers.errors
|
flash[:errors] = @crm_customers.errors
|
||||||
@@ -166,7 +172,7 @@ end
|
|||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
|
|
||||||
begin
|
begin
|
||||||
response = HTTParty.post(url,
|
response = HTTParty.post(url,
|
||||||
:body => { name: name,phone: phone,email: email,
|
:body => { name: name,phone: phone,email: email,
|
||||||
dob: dob,address: address,nrc:nrc,
|
dob: dob,address: address,nrc:nrc,
|
||||||
card_no:card_no,member_group_id: member_group_id,
|
card_no:card_no,member_group_id: member_group_id,
|
||||||
@@ -176,16 +182,22 @@ end
|
|||||||
'Accept' => 'application/json'
|
'Accept' => 'application/json'
|
||||||
},
|
},
|
||||||
:timeout => 10
|
:timeout => 10
|
||||||
)
|
)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false }
|
response = { status: false }
|
||||||
|
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
response = { status: false}
|
||||||
|
|
||||||
|
rescue SocketError
|
||||||
|
response = { status: false}
|
||||||
end
|
end
|
||||||
|
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
|
|
||||||
customer = Customer.find(@crm_customer.customer_id)
|
customer = Customer.find(@crm_customer.customer_id)
|
||||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||||
|
|
||||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'}
|
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'}
|
||||||
else
|
else
|
||||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||||
@@ -199,7 +211,7 @@ end
|
|||||||
auth_token = memberaction.auth_token.to_s
|
auth_token = memberaction.auth_token.to_s
|
||||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||||
begin
|
begin
|
||||||
response = HTTParty.post(url,
|
response = HTTParty.post(url,
|
||||||
:body => {name: name,phone: phone,email: email,
|
:body => {name: name,phone: phone,email: email,
|
||||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||||
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||||
@@ -211,6 +223,12 @@ end
|
|||||||
)
|
)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false }
|
response = { status: false }
|
||||||
|
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
response = { status: false}
|
||||||
|
|
||||||
|
rescue SocketError
|
||||||
|
response = { status: false}
|
||||||
end
|
end
|
||||||
|
|
||||||
if response["status"] == true
|
if response["status"] == true
|
||||||
@@ -219,8 +237,8 @@ end
|
|||||||
else
|
else
|
||||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@@ -251,7 +269,7 @@ end
|
|||||||
# Never trust parameters from the scary internet, only allow the white list through.
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
def customer_params
|
def customer_params
|
||||||
|
|
||||||
params.require(:customer).permit(:name, :company, :contact_no, :email,
|
params.require(:customer).permit(:name, :company, :contact_no, :email,
|
||||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no)
|
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
puts current_user.id
|
||||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ class Customer < ApplicationRecord
|
|||||||
)
|
)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false }
|
response = { status: false }
|
||||||
|
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
response = { status: false}
|
||||||
|
|
||||||
|
rescue SocketError
|
||||||
|
response = { status: false}
|
||||||
end
|
end
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
@@ -55,6 +61,12 @@ class Customer < ApplicationRecord
|
|||||||
)
|
)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false }
|
response = { status: false }
|
||||||
|
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
response = { status: false}
|
||||||
|
|
||||||
|
rescue SocketError
|
||||||
|
response = { status: false}
|
||||||
end
|
end
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ class SalePayment < ApplicationRecord
|
|||||||
)
|
)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false }
|
response = { status: false }
|
||||||
|
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
response = { status: false}
|
||||||
|
|
||||||
|
rescue SocketError
|
||||||
|
response = { status: false}
|
||||||
end
|
end
|
||||||
return response;
|
return response;
|
||||||
end
|
end
|
||||||
@@ -110,6 +116,12 @@ class SalePayment < ApplicationRecord
|
|||||||
)
|
)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = false
|
response = false
|
||||||
|
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
response = { status: false}
|
||||||
|
|
||||||
|
rescue SocketError
|
||||||
|
response = { status: false}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
response = false;
|
response = false;
|
||||||
@@ -312,6 +324,12 @@ class SalePayment < ApplicationRecord
|
|||||||
}, :timeout => 10)
|
}, :timeout => 10)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
response = { status: false }
|
response = { status: false }
|
||||||
|
|
||||||
|
rescue OpenURI::HTTPError
|
||||||
|
response = { status: false}
|
||||||
|
|
||||||
|
rescue SocketError
|
||||||
|
response = { status: false}
|
||||||
end
|
end
|
||||||
return response
|
return response
|
||||||
# puts response.to_json
|
# puts response.to_json
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class ShiftSale < ApplicationRecord
|
|||||||
#find open shift where is open today and is not closed and login by current cashier
|
#find open shift where is open today and is not closed and login by current cashier
|
||||||
today_date = DateTime.now.strftime("%Y-%m-%d")
|
today_date = DateTime.now.strftime("%Y-%m-%d")
|
||||||
puts today_date
|
puts today_date
|
||||||
shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
|
shift = ShiftSale.where("TO_CHAR(shift_started_at, 'YYYY-MM-DD')=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}", today_date).take
|
||||||
|
|
||||||
return shift
|
return shift
|
||||||
#end
|
#end
|
||||||
|
|||||||
Reference in New Issue
Block a user