update crm

This commit is contained in:
Aung Myo
2017-06-26 10:21:56 +06:30
parent d9c53e73f8
commit f426be57ab
5 changed files with 44 additions and 32 deletions

View File

@@ -77,6 +77,7 @@ class Crm::CustomersController < BaseCrmController
dob = customer_params[:date_of_birth] dob = customer_params[:date_of_birth]
address = customer_params[:address] address = customer_params[:address]
nrc = customer_params[:nrc_no] nrc = customer_params[:nrc_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?
@@ -87,16 +88,17 @@ 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, :body => { name: name,phone: phone,email: email, response = HTTParty.post(url,
dob: dob,address: address,nrc:nrc, :body => {name: name,phone: phone,email: email,
member_group_id: member_group_id, dob: dob,address: address,nrc:nrc,card_no:card_no,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json, member_group_id: member_group_id,
:headers => { merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
'Content-Type' => 'application/json', :headers => {
'Accept' => 'application/json' 'Content-Type' => 'application/json',
'Accept' => 'application/json'
}, },
:timeout => 10 :timeout => 10
) )
rescue Net::OpenTimeout rescue Net::OpenTimeout
response = { status: false } response = { status: false }
end end
@@ -149,10 +151,12 @@ end
dob = customer_params[:date_of_birth] dob = customer_params[:date_of_birth]
address = customer_params[:address] address = customer_params[:address]
nrc = customer_params[:nrc_no] nrc = customer_params[:nrc_no]
card_no = customer_params[:card_no]
id = @crm_customer.membership_id id = @crm_customer.membership_id
member_group_id = params[:member_group_id] member_group_id = params[:member_group_id]
if id.nil? && !member_group_id.nil? if id.nil? && !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")
merchant_uid = memberaction.merchant_account_id.to_s merchant_uid = memberaction.merchant_account_id.to_s
@@ -160,16 +164,17 @@ 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, :body => { name: name,phone: phone,email: email, response = HTTParty.post(url,
dob: dob,address: address,nrc:nrc, :body => { name: name,phone: phone,email: email,
member_group_id: member_group_id, dob: dob,address: address,nrc:nrc,
merchant_uid:merchant_uid,auth_token:auth_token}.to_json, card_no:card_no,member_group_id: member_group_id,
:headers => { merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
'Content-Type' => 'application/json', :headers => {
'Accept' => 'application/json' 'Content-Type' => 'application/json',
'Accept' => 'application/json'
}, },
:timeout => 10 :timeout => 10
) )
rescue Net::OpenTimeout rescue Net::OpenTimeout
response = { status: false } response = { status: false }
end end
@@ -185,20 +190,22 @@ end
end end
else else
membership = MembershipSetting.find_by_membership_type("paypar_url") membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("update_membership_customer") memberaction = MembershipAction.find_by_membership_type("update_membership_customer")
merchant_uid = memberaction.merchant_account_id.to_s merchant_uid = memberaction.merchant_account_id.to_s
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, :body => { name: name,phone: phone,email: email, response = HTTParty.post(url,
dob: dob,address: address,nrc:nrc, :body => {name: name,phone: phone,email: email,
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, dob: dob,address: address,nrc:nrc,card_no:card_no,
:headers => { id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
'Content-Type' => 'application/json', :headers => {
'Accept' => 'application/json' 'Content-Type' => 'application/json',
'Accept' => 'application/json'
}, },
:timeout => 10 :timeout => 10
) )
rescue Net::OpenTimeout rescue Net::OpenTimeout
response = { status: false } response = { status: false }

View File

@@ -130,8 +130,10 @@ $(document).on('click',".customer_tr",function(){
$('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected'); $('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected');
if (data.gender == 'Male') { if (data.gender == 'Male') {
$('.male').prop( "checked", true ) $('.male').prop( "checked", true )
$('.female').prop( "checked", false )
}else{ }else{
$('.female').prop( "checked", true ) $('.female').prop( "checked", true )
$('.male').prop( "checked", false )
} }
if(data.salutation == 'Mr') { if(data.salutation == 'Mr') {
@@ -152,7 +154,6 @@ $(document).on('click',".customer_tr",function(){
$("#new_customer").attr('class', 'simple_form edit_customer'); $("#new_customer").attr('class', 'simple_form edit_customer');
var id = "edit_customer_"+customer_id; var id = "edit_customer_"+customer_id;
alert(id)
$("#new_customer").attr('id', id); $("#new_customer").attr('id', id);
$(".edit_customer").attr('id', id); $(".edit_customer").attr('id', id);

View File

@@ -161,10 +161,10 @@
<%= f.input :address, :class => "form-control col-md-6 address" %> <%= f.input :address, :class => "form-control col-md-6 address" %>
</div> </div>
<div class="form-group"> <!-- <div class="form-group">
<label>Sr.No</label> <label>Sr.No</label>
<input type="text" name="" value="<%=@count_customer%>" class="form-control" readonly="true"> <input type="text" name="" value="<%=@count_customer%>" class="form-control" readonly="true">
</div> </div> -->
<div class="form-group"> <div class="form-group">
<label>Date Of Birth</label> <label>Date Of Birth</label>
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%> <%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%>

View File

@@ -129,8 +129,10 @@
<div class="card-title row"> <div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<p class="hidden customer-id"><%= @customer.customer_id %></p> <%if @customer %>
<p>Customer : <%= @customer.name %></p> <p class="hidden customer-id"><%= @customer.customer_id %></p>
<p>Customer : <%= @customer.name %></p>
<%end%>
</div> </div>
</div> </div>

View File

@@ -129,8 +129,10 @@
</div> </div>
<div class="card-title row customer_detail hide"> <div class="card-title row customer_detail hide">
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<%if @customer %>
<p class="hidden customer-id"><%= @customer.customer_id %></p> <p class="hidden customer-id"><%= @customer.customer_id %></p>
<p>Customer : <%= @customer.name %></p> <p>Customer : <%= @customer.name %></p>
<%end%>
</div> </div>
</div> </div>