improvement
This commit is contained in:
@@ -9,25 +9,15 @@ class Crm::CustomersController < BaseCrmController
|
||||
filter = params[:filter]
|
||||
filter_card_no = params[:filter_card_no]
|
||||
type = params[:type]
|
||||
puts "type :"
|
||||
puts type
|
||||
puts "filter :"
|
||||
puts filter
|
||||
puts "filter card no"
|
||||
puts filter_card_no
|
||||
@customer_update_phone_email_membertype =false
|
||||
if filter_card_no==""
|
||||
@crm_customers = Customer.all
|
||||
puts "Filter card no"
|
||||
elsif !filter_card_no.nil?
|
||||
@crm_customers=Customer.where("card_no=?",filter_card_no)
|
||||
puts "Null filter card no"
|
||||
elsif filter.nil? || filter_card_no==""
|
||||
@crm_customers = Customer.all
|
||||
puts "filter null filter card no nulll"
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
puts "else"
|
||||
# paymal_customer = Customer.search_paypar_account_no(filter)
|
||||
# search account no from paypar
|
||||
if type == "card"
|
||||
@@ -35,20 +25,21 @@ class Crm::CustomersController < BaseCrmController
|
||||
response = Customer.search_paypar_account_no(filter)
|
||||
if !@crm_customers.present?
|
||||
if response["status"] == true
|
||||
@crm_customers = Customer.new
|
||||
@crm_customers.name = response["customer_data"]["name"]
|
||||
@crm_customers.contact_no = response["customer_data"]["phone"]
|
||||
@crm_customers.email = response["customer_data"]["email"]
|
||||
@crm_customers.date_of_birth = response["customer_data"]["DOB"]
|
||||
@crm_customers.nrc_no = response["customer_data"]["NRC"]
|
||||
@crm_customers.address = response["customer_data"]["address"]
|
||||
@crm_customers.card_no = response["customer_data"]["customer_card_no"]
|
||||
@crm_customers.paypar_account_no = filter
|
||||
@crm_customers.membership_id = response["customer_data"]["id"]
|
||||
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
|
||||
@crm_customers.customer_type = "Dinein"
|
||||
@crm_customers.tax_profiles = ["1", "2"]
|
||||
@crm_customers.save
|
||||
tax_ids =[]
|
||||
TaxProfile.all.each {|tax| tax_ids << "#{tax.id}"}
|
||||
@crm_customers =Customer.create(name: response["customer_data"]["name"],
|
||||
contact_no: response["customer_data"]["phone"],
|
||||
email: response["customer_data"]["email"],
|
||||
date_of_birth: response["customer_data"]["DOB"],
|
||||
nrc_no: response["customer_data"]["NRC"],
|
||||
address: response["customer_data"]["address"],
|
||||
card_no: response["customer_data"]["customer_card_no"],
|
||||
paypar_account_no: filter,
|
||||
membership_id: response["customer_data"]["id"],
|
||||
membership_type: response["customer_data"]["member_group_id"],
|
||||
customer_type: "Dinein",
|
||||
tax_profiles: tax_ids
|
||||
)
|
||||
@crm_customers = Customer.search(filter)
|
||||
flash[:member_notice]='Customer was successfully created.'
|
||||
else
|
||||
@@ -207,7 +198,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
|
||||
rescue Errno::ECONNREFUSED
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
rescue HTTParty::Error
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
@@ -307,7 +299,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
|
||||
rescue Errno::ECONNREFUSED
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
rescue HTTParty::Error
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
@@ -457,6 +450,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue Errno::ECONNREFUSED
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
rescue HTTParty::Error
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
@@ -522,6 +517,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue Errno::ECONNREFUSED
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
rescue HTTParty::Error
|
||||
response = {"status" => false, "message" => "No internet connection "}
|
||||
|
||||
@@ -593,11 +590,11 @@ class Crm::CustomersController < BaseCrmController
|
||||
@customer = Customer.find(params[:id])
|
||||
response = Customer.search_paypar_account_no(@customer.paypar_account_no)
|
||||
if response["status"] == true
|
||||
@customer.name =response["customer_data"]["name"]
|
||||
@customer.contact_no =response["customer_data"]["phone"]
|
||||
@customer.email =response["customer_data"]["email"]
|
||||
@customer.membership_type =response["customer_data"]["member_group_id"]
|
||||
@customer.save
|
||||
@customer.update_attributes(name: response["customer_data"]["name"],
|
||||
contact_no: response["customer_data"]["phone"],
|
||||
email: response["customer_data"]["email"],
|
||||
membership_type: response["customer_data"]["member_group_id"]
|
||||
)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to crm_customers_path }
|
||||
flash[:member_notice]='Membership was successfully updated'
|
||||
|
||||
Reference in New Issue
Block a user