merge with crm
This commit is contained in:
@@ -63,61 +63,62 @@ class Crm::CustomersController < BaseCrmController
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /crm/customers
|
||||
# POST /crm/customers
|
||||
# POST /crm/customers.json
|
||||
def create
|
||||
|
||||
@crm_customers = Customer.new(customer_params)
|
||||
|
||||
respond_to do |format|
|
||||
puts @crm_customers.errors.to_json
|
||||
if @crm_customers.save
|
||||
name = customer_params[:name]
|
||||
phone = customer_params[:contact_no]
|
||||
email = customer_params[:email]
|
||||
dob = customer_params[:date_of_birth]
|
||||
address = customer_params[:address]
|
||||
nrc = customer_params[:nrc_no]
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,
|
||||
member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
end
|
||||
|
||||
if response["status"] == true
|
||||
name = customer_params[:name]
|
||||
phone = customer_params[:contact_no]
|
||||
email = customer_params[:email]
|
||||
dob = customer_params[:date_of_birth]
|
||||
address = customer_params[:address]
|
||||
nrc = customer_params[:nrc_no]
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"])
|
||||
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' }
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
|
||||
end
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
else
|
||||
|
||||
# @crm_customers.destroy
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
|
||||
if !member_group_id.nil?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
end
|
||||
|
||||
if response["status"] == true
|
||||
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
|
||||
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' }
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
|
||||
end
|
||||
# format.json { render :index, status: :created, location: @crm_customers }
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
# @crm_customers.destroy
|
||||
if params[:sale_id]
|
||||
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -135,7 +136,6 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /crm/customers/1
|
||||
# PATCH/PUT /crm/customers/1.json
|
||||
def update
|
||||
@@ -152,26 +152,66 @@ end
|
||||
id = @crm_customer.membership_id
|
||||
member_group_id = params[:member_group_id]
|
||||
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("update_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
begin
|
||||
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,
|
||||
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
end
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @crm_customer }
|
||||
if id.nil? && !member_group_id.nil?
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
begin
|
||||
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
},
|
||||
:timeout 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
end
|
||||
|
||||
if response["status"] == true
|
||||
|
||||
customer = Customer.find(@crm_customer.customer_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'}
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
end
|
||||
|
||||
else
|
||||
membership = MembershipSetting.find_by_membership_type("paypar_url")
|
||||
memberaction = MembershipAction.find_by_membership_type("update_membership_customer")
|
||||
merchant_uid = memberaction.merchant_account_id.to_s
|
||||
auth_token = memberaction.auth_token.to_s
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
begin
|
||||
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,
|
||||
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
end
|
||||
|
||||
if response["status"] == true
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @crm_customer }
|
||||
else
|
||||
format.html { redirect_to crm_customers_path, notice: response["message"] }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
|
||||
@@ -104,6 +104,6 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def dining_queue_params
|
||||
params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status)
|
||||
params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status,:seater,:remark)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
class Crm::HomeController < BaseCrmController
|
||||
def index
|
||||
|
||||
@booking = Booking.all
|
||||
@customer = Customer.all
|
||||
from = Time.now.beginning_of_day.utc
|
||||
to = Time.now.end_of_day.utc
|
||||
@queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC')
|
||||
|
||||
# @booking = Booking.all
|
||||
# @customer = Customer.all
|
||||
# from = Time.now.beginning_of_day.utc
|
||||
# to = Time.now.end_of_day.utc
|
||||
# @queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC')
|
||||
redirect_to crm_customers_path
|
||||
# .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user