From 3716cbdda7657f059202c5751645567243729ced Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 20 Jun 2019 18:26:10 +0630 Subject: [PATCH] customer update --- .../api/payment/mobilepayment_controller.rb | 3 +++ app/controllers/crm/customers_controller.rb | 14 +++++++++----- app/views/crm/customers/index.html.erb | 4 ++-- config/routes.rb | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/payment/mobilepayment_controller.rb b/app/controllers/api/payment/mobilepayment_controller.rb index 329ea8af..cd9f9e00 100644 --- a/app/controllers/api/payment/mobilepayment_controller.rb +++ b/app/controllers/api/payment/mobilepayment_controller.rb @@ -158,6 +158,9 @@ class Api::Payment::MobilepaymentController < Api::ApiController # #end # end + else + @out =false,"Something wrong!" end + end end diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index c895c4b6..aacfa39f 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -8,7 +8,7 @@ class Crm::CustomersController < BaseCrmController filter = params[:filter] filter_card_no = params[:filter_card_no] type = params[:type] - @customer_update_phone_email =false + @customer_update_phone_email_membertype =false if filter_card_no=="" @crm_customers = Customer.all elsif !filter_card_no.nil? @@ -46,13 +46,16 @@ class Crm::CustomersController < BaseCrmController else @crm_customers.each do |customer| if customer.contact_no != response["customer_data"]["phone"] - @customer_update_phone_email =true + @customer_update_phone_email_membertype =true end if customer.email != response["customer_data"]["email"] - @customer_update_phone_email =true + @customer_update_phone_email_membertype =true end if customer.name != response["customer_data"]["name"] - @customer_update_phone_email =true + @customer_update_phone_email_membertype =true + end + if customer.membership_type.to_i != response["customer_data"]["member_group_id"] + @customer_update_phone_email_membertype =true end end end @@ -554,13 +557,14 @@ class Crm::CustomersController < BaseCrmController end end - def customer_update_phone_email + def customer_update_phone_email_member_type @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 respond_to do |format| format.html { redirect_to crm_customers_path } diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 3948d86f..55295c9e 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -126,8 +126,8 @@ <% if crm_customer.membership_id.nil? && !crm_customer.membership_type.nil? && !crm_customer.membership_type =="" && !crm_customer.paypar_account_no =="" && !crm_customer.paypar_account_no.nil? %> <%= link_to t("views.btn.sync"), crm_customer_sync_path(crm_customer), :class => "btn btn-md bg-green waves-effect" %> <% end %> - <% if @customer_update_phone_email %> - <%= link_to t("views.btn.update"), crm_customer_update_phone_email_path(crm_customer), :class => "btn btn-md bg-green waves-effect" %> + <% if @customer_update_phone_email_membertype %> + <%= link_to t("views.btn.update"), crm_customer_update_phone_email_member_type_path(crm_customer), :class => "btn btn-md bg-green waves-effect" %> <% end %> <%= link_to t("views.btn.show"), crm_customer_path(crm_customer), :class => "btn btn-md bg-blue waves-effect" %> diff --git a/config/routes.rb b/config/routes.rb index 2ad2361e..c2058111 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -374,7 +374,7 @@ scope "(:locale)", locale: /en|mm/ do root "home#index" resources :customers get "/customers/:id/sync" => "customers#sync", as:"customer_sync" - get "/customers/:id/customer_update_phone_email" => "customers#customer_update_phone_email", as:"customer_update_phone_email" + get "/customers/:id/customer_update_phone_email_member_type" => "customers#customer_update_phone_email_member_type", as:"customer_update_phone_email_member_type" resources :dining_queues post "update_booking", to: "bookings#update_booking", as: "update_booking" #assign and cancel get '/print/:id', to: "home#print_order" #print order for crm