diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 43b0618e..4984150a 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -68,7 +68,7 @@ class Crm::CustomersController < BaseCrmController def create @crm_customers = Customer.new(customer_params) - + respond_to do |format| if @crm_customers.save name = customer_params[:name] @@ -77,6 +77,7 @@ class Crm::CustomersController < BaseCrmController dob = customer_params[:date_of_birth] address = customer_params[:address] nrc = customer_params[:nrc_no] + card_no = customer_params[:card_no] member_group_id = params[:member_group_id] if !member_group_id.nil? @@ -87,16 +88,17 @@ class Crm::CustomersController < BaseCrmController 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' + response = HTTParty.post(url, + :body => {name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc,card_no:card_no, + 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 - ) + :timeout => 10 + ) rescue Net::OpenTimeout response = { status: false } end @@ -149,10 +151,12 @@ end dob = customer_params[:date_of_birth] address = customer_params[:address] nrc = customer_params[:nrc_no] + card_no = customer_params[:card_no] id = @crm_customer.membership_id member_group_id = params[:member_group_id] 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 @@ -160,16 +164,17 @@ 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,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' + response = HTTParty.post(url, + :body => { name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc, + card_no:card_no,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 - ) + :timeout => 10 + ) rescue Net::OpenTimeout response = { status: false } end @@ -185,20 +190,22 @@ end 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' + response = HTTParty.post(url, + :body => {name: name,phone: phone,email: email, + 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, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' }, - :timeout => 10 + :timeout => 10 ) rescue Net::OpenTimeout response = { status: false } diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 67dc46f4..3270262e 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -130,8 +130,10 @@ $(document).on('click',".customer_tr",function(){ $('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected'); if (data.gender == 'Male') { $('.male').prop( "checked", true ) + $('.female').prop( "checked", false ) }else{ $('.female').prop( "checked", true ) + $('.male').prop( "checked", false ) } if(data.salutation == 'Mr') { @@ -152,7 +154,6 @@ $(document).on('click',".customer_tr",function(){ $("#new_customer").attr('class', 'simple_form edit_customer'); var id = "edit_customer_"+customer_id; - alert(id) $("#new_customer").attr('id', id); $(".edit_customer").attr('id', id); diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 0cd7d85b..2557e787 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -161,10 +161,10 @@ <%= f.input :address, :class => "form-control col-md-6 address" %> -
<%= @customer.customer_id %>
-Customer : <%= @customer.name %>
+ <%if @customer %> +<%= @customer.customer_id %>
+Customer : <%= @customer.name %>
+ <%end%>