finished customer form and update

This commit is contained in:
Aung Myo
2017-06-20 17:57:50 +06:30
parent faae996d5d
commit 33cb8b64a3
13 changed files with 235 additions and 84 deletions

View File

@@ -7,23 +7,19 @@ class Crm::CustomersController < BaseCrmController
filter = params[:filter]
if filter.nil?
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
@crm_customers = Customer.all
else
@crm_customers = Customer.search(filter)
end
#@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)
@crm_customer = Customer.new
@count_customer = Customer.count_customer
# if flash["errors"]
# @crm_customer.valid?
# end
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
# end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @crm_customers }
@@ -50,14 +46,14 @@ class Crm::CustomersController < BaseCrmController
end
#get customer amount
@customer = Customer.find(params[:id])
response = Customer.get_member_account(@customer)
# @customer = Customer.find(params[:id])
# response = Customer.get_member_account(@customer)
if(response["status"] == true)
@membership = response["data"]
else
# if(response["status"] == true)
# @membership = response["data"]
# else
@membership = 0
end
# end
#end customer amount
@@ -87,6 +83,8 @@ class Crm::CustomersController < BaseCrmController
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")
@@ -97,7 +95,7 @@ class Crm::CustomersController < BaseCrmController
begin
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,
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',
@@ -155,6 +153,8 @@ end
phone = customer_params[:contact_no]
email = customer_params[:email]
dob = customer_params[:date_of_birth]
address = customer_params[:address]
nrc = customer_params[:nrc_no]
id = @crm_customer.membership_id
member_group_id = params[:member_group_id]
@@ -165,7 +165,7 @@ end
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,
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',
@@ -207,6 +207,7 @@ end
# Never trust parameters from the scary internet, only allow the white list through.
def customer_params
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth)
params.require(:customer).permit(:name, :company, :contact_no, :email,
:date_of_birth,:salution,:gender,:nrc_no,:address,:card_no)
end
end