From b2532ce5f3f379e173b7caf5e2f5f94df313dad1 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Wed, 8 May 2019 17:59:57 +0630 Subject: [PATCH 1/6] show response errors,sync and update member --- app/controllers/crm/customers_controller.rb | 200 ++++++++++++++++---- app/views/crm/customers/index.html.erb | 24 ++- app/views/layouts/CRM.html.erb | 14 +- config/routes.rb | 2 + db/seeds.rb | 8 +- 5 files changed, 203 insertions(+), 45 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 21c2d373..5979ce21 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -1,6 +1,6 @@ class Crm::CustomersController < BaseCrmController load_and_authorize_resource except: [:create] - before_action :set_crm_customer, only: [:show, :edit, :update, :destroy] + before_action :set_crm_customer, only: [:show, :edit, :update, :destroy,:sync] # GET /crm/customers # GET /crm/customers.json @@ -8,6 +8,7 @@ class Crm::CustomersController < BaseCrmController filter = params[:filter] filter_card_no = params[:filter_card_no] type = params[:type] + @customer_update_phone_email =false if filter_card_no=="" @crm_customers = Customer.all elsif !filter_card_no.nil? @@ -16,25 +17,44 @@ class Crm::CustomersController < BaseCrmController @crm_customers = Customer.all else @crm_customers = Customer.search(filter) + paymal_customer = Customer.search_paypar_account_no(filter) # search account no from paypar - if !@crm_customers.present? && type == "card" - response = Customer.search_paypar_account_no(filter) - if response["status"] == true - @crm_customers = Customer.new - @crm_customers.name = response["customer_data"]["name"] - @crm_customers.contact_no = response["customer_data"]["phone"] - @crm_customers.email = response["customer_data"]["email"] - @crm_customers.date_of_birth = response["customer_data"]["DOB"] - @crm_customers.nrc_no = response["customer_data"]["NRC"] - @crm_customers.address = response["customer_data"]["address"] - @crm_customers.card_no = response["customer_data"]["customer_card_no"] - @crm_customers.paypar_account_no = filter - @crm_customers.membership_id = response["customer_data"]["id"] - @crm_customers.membership_type = response["customer_data"]["member_group_id"] - @crm_customers.customer_type = "Dinein" - @crm_customers.tax_profiles = ["1", "2"] - @crm_customers.save - @crm_customers = Customer.search(filter) + if type == "card" + + response = Customer.search_paypar_account_no(filter) + if !@crm_customers.present? + if response["status"] == true + @crm_customers = Customer.new + @crm_customers.name = response["customer_data"]["name"] + @crm_customers.contact_no = response["customer_data"]["phone"] + @crm_customers.email = response["customer_data"]["email"] + @crm_customers.date_of_birth = response["customer_data"]["DOB"] + @crm_customers.nrc_no = response["customer_data"]["NRC"] + @crm_customers.address = response["customer_data"]["address"] + @crm_customers.card_no = response["customer_data"]["customer_card_no"] + @crm_customers.paypar_account_no = filter + @crm_customers.membership_id = response["customer_data"]["id"] + @crm_customers.membership_type = response["customer_data"]["member_group_id"] + @crm_customers.customer_type = "Dinein" + @crm_customers.tax_profiles = ["1", "2"] + @crm_customers.save + @crm_customers = Customer.search(filter) + flash[:notice]='Customer was successfully created.' + else + flash[:error]=response["message"] + end + else + @crm_customers.each do |customer| + if customer.contact_no != response["customer_data"]["phone"] + @customer_update_phone_email =true + end + if customer.email != response["customer_data"]["email"] + @customer_update_phone_email =true + end + if customer.name != response["customer_data"]["name"] + @customer_update_phone_email =true + end + end end end end @@ -69,6 +89,7 @@ class Crm::CustomersController < BaseCrmController # if flash["errors"] # @crm_customer.valid? # end + # puts @crm_customers.to_json respond_to do |format| format.html # index.html.erb format.json { render json: @crm_customers } @@ -120,7 +141,91 @@ class Crm::CustomersController < BaseCrmController def edit @customer = Customer.find(params[:id]) end + def sync + @customer = Customer.find(params[:id]) + respond_to do |format| + name = @customer.name + phone = @customer.contact_no + email = @customer.email + dob = @customer.date_of_birth + address = @customer.address + nrc = @customer.nrc_no + card_no = @customer.card_no + paypar_account_no = @customer.paypar_account_no + id = @crm_customer.membership_id + member_group_id = @customer.membership_type + if !id.present? && !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 + member_params = { name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc,card_no:card_no, + member_group_id: member_group_id, + id:id, + merchant_uid:merchant_uid,auth_token:auth_token}.to_json + + # Check for paypar account exists + # if paypar_account_no != nil || paypar_account_no != '' + if paypar_account_no.present? + member_params = { name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc,card_no:card_no, + paypar_account_no: paypar_account_no, + member_group_id: member_group_id, + id:id, + merchant_uid:merchant_uid,auth_token:auth_token}.to_json + end + + begin + response = HTTParty.post(url, + :body => member_params, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json; version=3' + }, + :timeout => 10 + ) + rescue Net::OpenTimeout + response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} + end + customer = Customer.find(@crm_customer.customer_id) + Rails.logger.debug "--------Sync Member response -------" + Rails.logger.debug response.to_json + if response["status"] == true + + status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) + + format.html { redirect_to crm_customers_path } + flash[:member_notice] ='Member was successfully synced' + else + # Check membership id and bind to user + if response["membership_id"] != nil + status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id ) + format.html { redirect_to crm_customers_path } + flash[:member_notice] ='Member was successfully synced' + else + status = customer.update_attributes(membership_type:member_group_id) + end + # When paypar account no not exist in paypar + if response["message"] == "Account does not exist." + customer.destroy + format.html { redirect_to crm_customers_path } + flash[:member_error] ='Member cannot created.Invalid Account.' + end + format.html { redirect_to crm_customers_path } + flash[:member_error] =response["message"] + end + end + end + end # POST /crm/customers # POST /crm/customers.json def create @@ -196,9 +301,11 @@ class Crm::CustomersController < BaseCrmController 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]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' } + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page] } + flash[:member_notice]='Member was successfully created.' else - format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} + format.html { redirect_to crm_customers_path } + flash[:member_notice]='Member was successfully created.' end # format.json { render :index, status: :created, location: @crm_customers } else @@ -207,24 +314,28 @@ class Crm::CustomersController < BaseCrmController # Check membership id and bind to user if response["membership_id"] != nil status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id ) + format.html { redirect_to crm_customers_path } + flash[:member_notice]='Member was successfully created.' else status = customer.update_attributes(membership_type:member_group_id) end - # When paypar account no not exist in paypar - if response["message"] == "Account has not exist." + if response["message"] == "Account does not exist." customer.destroy if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer cannot created.' + response["message"]} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page] } + flash[:member_error]='Member cannot created.Invalid Account.' else - format.html { redirect_to crm_customers_path, notice: 'Customer cannot created.' + response["message"] } + format.html { redirect_to crm_customers_path } + flash[:member_error]='Member cannot created.Invalid Account.' end end - if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' + response["message"]} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page] } + flash[:member_notice]='Member was successfully created.' + response["message"] else - format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' } + format.html { redirect_to crm_customers_path } + # flash[:member_notice]='Member was successfully created.' end end else @@ -333,16 +444,19 @@ class Crm::CustomersController < BaseCrmController 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'} + format.html { redirect_to crm_customers_path } + flash[:member_notice]='Member was successfully updated' else # Check membership id and bind to user if response["membership_id"] != nil status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id ) + format.html { redirect_to crm_customers_path } + flash[:member_notice]='Member was successfully updated' else status = customer.update_attributes(membership_type:member_group_id) + format.html { redirect_to crm_customers_path } + flash[:member_error]=response["message"] end - - format.html { redirect_to crm_customers_path, notice: response["error"] } end else membership = MembershipSetting.find_by_membership_type("paypar_url") @@ -395,7 +509,8 @@ class Crm::CustomersController < BaseCrmController else status = customer.update_attributes(membership_type:member_group_id ) end - format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' } + format.html { redirect_to crm_customers_path } + flash[:member_notice] ='Member was successfully updated.' format.json { render :show, status: :ok, location: @crm_customer } else customer = Customer.find(@crm_customer.customer_id) @@ -405,7 +520,8 @@ class Crm::CustomersController < BaseCrmController else status = customer.update_attributes(membership_type:member_group_id ) end - format.html { redirect_to crm_customers_path, notice: response["message"] } + format.html { redirect_to crm_customers_path } + flash[:member_error] =response["message"] end end else @@ -438,6 +554,23 @@ class Crm::CustomersController < BaseCrmController end end + def customer_update_phone_email + @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.save + respond_to do |format| + format.html { redirect_to crm_customers_path } + flash[:member_notice]='Membership was successfully updated' + end + end + + + end + private # Use callbacks to share common setup or constraints between actions. def set_crm_customer @@ -452,3 +585,4 @@ class Crm::CustomersController < BaseCrmController end end + diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 76d1dce8..6b9707f5 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -9,12 +9,27 @@ --> -
+
+
+ <% if flash[:member_notice] %> + + <% elsif flash[:member_error] %> + + <% end %> +
+
+
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
@@ -47,6 +62,7 @@ <%end %>
+
<%= paginate @crm_customers %> @@ -107,6 +123,12 @@ <%= crm_customer.card_no rescue '-' %> + <% if crm_customer.membership_id.nil? && !crm_customer.membership_type.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" %> + <% end %> <%= link_to t("views.btn.show"), crm_customer_path(crm_customer), :class => "btn btn-md bg-blue waves-effect" %> diff --git a/app/views/layouts/CRM.html.erb b/app/views/layouts/CRM.html.erb index 8ba5d9c7..955abc98 100755 --- a/app/views/layouts/CRM.html.erb +++ b/app/views/layouts/CRM.html.erb @@ -46,18 +46,18 @@ <% flash.each do |type, message| %> <% if !flash["errors"]%> <% - if type == "notice" + if type == "notice" color = "alert-success" - elsif type == "error" + end + if type == "error" color = "alert-danger" - else - color = "bg-black" end %> - - +

+ <% end %> <% end %> <% end %> <%= yield %> diff --git a/config/routes.rb b/config/routes.rb index 89963f1e..f25ff1b8 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -358,6 +358,8 @@ scope "(:locale)", locale: /en|mm/ do namespace :crm 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" 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 diff --git a/db/seeds.rb b/db/seeds.rb index 7a139b6e..a2307479 100755 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -209,19 +209,19 @@ queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf zone = Zone.create({id:1, name: "H1", is_active:true, created_by: "SYSTEM DEFAULT"}) -member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "https://staging.membership.paypar.ws",merchant_account_id:"pZBHXEFbGNj/G"}) +member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.82:3001",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE"}) member_actions= MembershipAction.create([{membership_type:"get_account_balance",is_active:1,gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"redeem",is_active:1,gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, - {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, - {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, + {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"}, + {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"}, {membership_type:"get_all_member_group",is_active:1,gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"rebate",is_active:1,gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_all_member_account",is_active:1,gateway_url:"/api/generic_customer/get_member_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_member_transactions",is_active:1,gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"member_discount",is_active:1,gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_member_campaign",is_active:1,gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, - {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"} + {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"} ]) payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://membership.paypar.ws"}) From 672eaafc4201839ca8ee3566d9b34c40c89dc36a Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 9 May 2019 18:08:25 +0630 Subject: [PATCH 2/6] when delete item options to update in menu items --- 10 | 0 Can't open membership server } | 0 .../settings/menu_item_options_controller.rb | 20 ++++++++++++++++++- .../settings/simple_menu_items_controller.rb | 1 - config/initializers/action_controller.rb | 10 +++++----- config/puma.rb | 20 +++++++++---------- db/seeds.rb | 8 ++++---- false, | 0 member_params, | 0 { | 0 10 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 10 create mode 100644 Can't open membership server } create mode 100644 false, create mode 100644 member_params, create mode 100644 { diff --git a/10 b/10 new file mode 100644 index 00000000..e69de29b diff --git a/Can't open membership server } b/Can't open membership server } new file mode 100644 index 00000000..e69de29b diff --git a/app/controllers/settings/menu_item_options_controller.rb b/app/controllers/settings/menu_item_options_controller.rb index 00791e5d..339039bf 100755 --- a/app/controllers/settings/menu_item_options_controller.rb +++ b/app/controllers/settings/menu_item_options_controller.rb @@ -55,7 +55,25 @@ class Settings::MenuItemOptionsController < ApplicationController # DELETE /settings/menu_item_options/1 # DELETE /settings/menu_item_options/1.json def destroy - @settings_menu_item_option.destroy + item_option_id =@settings_menu_item_option.id + item_option_id_string=""+item_option_id.to_s+"" + if @settings_menu_item_option.destroy + menu_items =MenuItem.all + menu_items.each do |item| + if item.item_options.include?(item_option_id) + item_update =item.item_options.reject { |i| i == item_option_id } + item.item_code =item.item_code + item.item_options =item_update + item.save + end + if item.item_options.include?(item_option_id_string) + item_update =item.item_options.reject { |i| i == item_option_id_string } + item.item_code =item.item_code + item.item_options =item_update + item.save + end + end + end flash[:notice] = 'Menu item option was successfully destroyed.' render :json => {:status=> "Success", :url => settings_menu_item_options_path }.to_json # respond_to do |format| diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index df70f61e..cd1c4507 100755 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -109,7 +109,6 @@ class Settings::SimpleMenuItemsController < ApplicationController @settings_menu_item.item_sets = sets end end - @settings_menu_item.menu_category_id = params[:menu_category_id] respond_to do |format| diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 5abb412e..7a123a02 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class ActionController::Base end else # check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end diff --git a/config/puma.rb b/config/puma.rb index fd89392f..6a545bed 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,10 @@ -application_path="#{File.expand_path("../..", __FILE__)}" -directory application_path -#environment ENV.fetch("RAILS_ENV") { "production" } -environment "production" -pidfile "#{application_path}/tmp/puma/pid" -state_path "#{application_path}/tmp/puma/state" -stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -port ENV.fetch("PORT") { 62158 } -workers 2 -preload_app! +# application_path="#{File.expand_path("../..", __FILE__)}" +# directory application_path +# #environment ENV.fetch("RAILS_ENV") { "production" } +# environment "production" +# pidfile "#{application_path}/tmp/puma/pid" +# state_path "#{application_path}/tmp/puma/state" +# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +# port ENV.fetch("PORT") { 62158 } +# workers 2 +# preload_app! diff --git a/db/seeds.rb b/db/seeds.rb index a2307479..9d498c2e 100755 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -209,19 +209,19 @@ queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf zone = Zone.create({id:1, name: "H1", is_active:true, created_by: "SYSTEM DEFAULT"}) -member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.82:3001",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE"}) +member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "https://staging.membership.paymal.ws",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) member_actions= MembershipAction.create([{membership_type:"get_account_balance",is_active:1,gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"redeem",is_active:1,gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, - {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"}, - {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"}, + {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, + {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_all_member_group",is_active:1,gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"rebate",is_active:1,gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_all_member_account",is_active:1,gateway_url:"/api/generic_customer/get_member_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_member_transactions",is_active:1,gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"member_discount",is_active:1,gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_member_campaign",is_active:1,gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, - {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"} + {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"} ]) payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://membership.paypar.ws"}) diff --git a/false, b/false, new file mode 100644 index 00000000..e69de29b diff --git a/member_params, b/member_params, new file mode 100644 index 00000000..e69de29b diff --git a/{ b/{ new file mode 100644 index 00000000..e69de29b From ae94a725164f353d6b260173a89ed8888068d328 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 9 May 2019 18:31:28 +0630 Subject: [PATCH 3/6] update condition for sync --- app/views/crm/customers/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 6b9707f5..3948d86f 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -123,7 +123,7 @@ <%= crm_customer.card_no rescue '-' %> - <% if crm_customer.membership_id.nil? && !crm_customer.membership_type.nil? %> + <% 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 %> From 66a6e5500ce18e6bc2dd6f2d03bbe7aabe11a104 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Mon, 13 May 2019 09:33:32 +0630 Subject: [PATCH 4/6] - --- config/initializers/action_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 7a123a02..214da8ec 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -19,12 +19,12 @@ class ActionController::Base render :json => [{ status: false, message: 'Invalid Access!'}] end else - # check for license file - # if check_license - # current_license(ENV["SX_PROVISION_URL"]) - # else - # redirect_to activate_path - # end + check for license file + if check_license + current_license(ENV["SX_PROVISION_URL"]) + else + redirect_to activate_path + end end end From eb4309355de75979a671a17ffe52de67fabc4bbe Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 16 May 2019 12:09:48 +0630 Subject: [PATCH 5/6] un comment puma --- app/controllers/crm/customers_controller.rb | 2 +- .../menu_item_attributes_controller.rb | 21 ++++++++++++++++++- app/models/sale_payment.rb | 3 ++- config/puma.rb | 20 +++++++++--------- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 5979ce21..8133968a 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -17,7 +17,7 @@ class Crm::CustomersController < BaseCrmController @crm_customers = Customer.all else @crm_customers = Customer.search(filter) - paymal_customer = Customer.search_paypar_account_no(filter) + # paymal_customer = Customer.search_paypar_account_no(filter) # search account no from paypar if type == "card" diff --git a/app/controllers/settings/menu_item_attributes_controller.rb b/app/controllers/settings/menu_item_attributes_controller.rb index 8187d2a9..4ac48542 100755 --- a/app/controllers/settings/menu_item_attributes_controller.rb +++ b/app/controllers/settings/menu_item_attributes_controller.rb @@ -55,7 +55,26 @@ class Settings::MenuItemAttributesController < ApplicationController # DELETE /settings/menu_item_attributes/1 # DELETE /settings/menu_item_attributes/1.json def destroy - @settings_menu_item_attribute.destroy + item_attribute_id =@settings_menu_item_attribute.id + item_attribute_id_string=""+item_attribute_id.to_s+"" + if @settings_menu_item_attribute.destroy + menu_items =MenuItem.all + menu_items.each do |item| + if item.item_attributes.include?(item_attribute_id) + item_update =item.item_attributes.reject { |i| i == item_attribute_id } + item.item_code =item.item_code + item.item_attributes =item_update + item.save + end + if item.item_attributes.include?(item_attribute_id_string) + item_update =item.item_attributes.reject { |i| i == item_attribute_id_string } + item.item_code =item.item_code + item.item_attributes =item_update + item.save + end + end + end + # @settings_menu_item_attribute.destroy flash[:notice] = 'Menu item attribute was successfully destroyed.' render :json => {:status=> "Success", :url => settings_menu_item_attributes_path }.to_json # respond_to do |format| diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 9d418f7b..f3c076ae 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -178,7 +178,8 @@ class SalePayment < ApplicationRecord def self.redeem(paypar_url,token,membership_id,received_amount,sale_id) # membership_actions_data = MembershipAction.find_by_membership_type("redeem"); membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem") - + puts "This is membership_actions_data" + puts membership_actions_data.to_json if !membership_actions_data.nil? url = paypar_url.to_s + membership_actions_data.gateway_url.to_s diff --git a/config/puma.rb b/config/puma.rb index 6a545bed..fd89392f 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,10 @@ -# application_path="#{File.expand_path("../..", __FILE__)}" -# directory application_path -# #environment ENV.fetch("RAILS_ENV") { "production" } -# environment "production" -# pidfile "#{application_path}/tmp/puma/pid" -# state_path "#{application_path}/tmp/puma/state" -# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -# port ENV.fetch("PORT") { 62158 } -# workers 2 -# preload_app! +application_path="#{File.expand_path("../..", __FILE__)}" +directory application_path +#environment ENV.fetch("RAILS_ENV") { "production" } +environment "production" +pidfile "#{application_path}/tmp/puma/pid" +state_path "#{application_path}/tmp/puma/state" +stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +port ENV.fetch("PORT") { 62158 } +workers 2 +preload_app! From acb81aa2ab0cbcf57faa1de2faaddc01004009c3 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 16 May 2019 12:11:53 +0630 Subject: [PATCH 6/6] comment --- config/initializers/action_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 214da8ec..5abb412e 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -19,7 +19,7 @@ class ActionController::Base render :json => [{ status: false, message: 'Invalid Access!'}] end else - check for license file + # check for license file if check_license current_license(ENV["SX_PROVISION_URL"]) else