ambassadeurs
This commit is contained in:
parent
0848b6ef2e
commit
43ede8de94
@ -6,6 +6,12 @@ class Public::PCustomersController < ApplicationController
|
||||
|
||||
|
||||
@p_customer = PCustomer.new()
|
||||
|
||||
if params[:a] and parent = PCustomer.where(:mlm_token => params[:a].to_s.upcase).first
|
||||
@p_customer.parent_code = parent.mlm_token
|
||||
parent.update_token_count
|
||||
end
|
||||
|
||||
@p_customer.particulars << Particular.new(:pro => false, :skip_validation => true)
|
||||
@p_customer.valid_public = true
|
||||
end
|
||||
|
@ -250,6 +250,11 @@ class PCustomer < ApplicationRecord
|
||||
end
|
||||
|
||||
|
||||
def update_token_count
|
||||
self.link_token_count = self.link_token_count.to_i + 1
|
||||
self.save
|
||||
end
|
||||
|
||||
|
||||
def self.qi_table_order
|
||||
{
|
||||
@ -275,6 +280,7 @@ class PCustomer < ApplicationRecord
|
||||
|
||||
:email => "Email",
|
||||
:particular_tel => "Téléphone",
|
||||
:link_token_count => {:name => "Nbr. aff. lien amb.", :reorder => true},
|
||||
:actions => "Actions"
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
=f.inputs do
|
||||
=f.hidden_field :valid_public
|
||||
|
||||
=f.input :parent_code, :label => "Code ambassadeur"
|
||||
=f.input :parent_code, :label => "Code ambassadeur", :collection => PCustomer.where(:ambassadeur => true).map{|a| ["#{a.mlm_token} - #{a.show_name}", a.mlm_token]}
|
||||
|
||||
=f.input :email, :label => "Email"
|
||||
=f.input :password, :label => "Mot de passe", :as => :password
|
||||
|
@ -0,0 +1,5 @@
|
||||
class AddLinkTokenCountToPCustomers < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :p_customers, :link_token_count, :integer
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user