ambassadeurs

This commit is contained in:
Nicolas Bally 2021-02-09 18:06:16 +01:00
parent 0848b6ef2e
commit 43ede8de94
4 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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"
}

View File

@ -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

View File

@ -0,0 +1,5 @@
class AddLinkTokenCountToPCustomers < ActiveRecord::Migration[6.0]
def change
add_column :p_customers, :link_token_count, :integer
end
end