negos_app/app/views/admin/customers/show.html.haml
2016-02-16 21:09:48 +01:00

319 lines
6.8 KiB
Plaintext
Executable File

%h1 Détail d'un inscrit
-i = 0
-parents_id = [@customer.id]
-coms= [0, 10,5,5,4,4,3,3,2,1,1, 0, 0]
-coms_sum = 0.0
%table.table.table-striped
-mlm_children_ids = []
-mlm_children_id_by_levels = []
-while i != 14 do
-i += 1
%tr
%td
Niveau
=i
%td{:style => "width:500px"}
=parents_id = Customer.where(:parent_id => parents_id).select(:id).map{ |v| v.id}
-mlm_children_id_by_levels[i] = parents_id
-mlm_children_ids.concat parents_id
%td
=number_to_currency Order.where(:customer_id => parents_id, :paid => true, :payment_type_id => 2).sum(:amount_ht)
%td
=coms[i]
%td
=coms_sum += (com = Order.where(:customer_id => parents_id, :paid => true, :payment_type_id => 2).sum(:amount_ht) *(coms[i].to_f/100.00))
=number_to_currency com
=debug @customer.mlm_children_ids
=debug @customer.mlm_children_id_by_levels[1]
%p
%strong= number_to_currency coms_sum
%p
Soit avec les coms de participations
(
-part_com = Commission.where(:customer_id => @customer.id, :commission_type_id => 3).sum(:amount)
=number_to_currency part_com
)
=":"
%p
%strong
=number_to_currency(coms_sum + part_com)
%h2 Aperçu
%table.table.table-hover.table-striped.customer_table
%thead#customer_rows_header.rows_header
%tr
%td
%td
Nom d'utilisateur
%td Parrain
%td
Pays
%td
Email
%td
Nombre d'annonces
%td
Chiffre d'affaire
%td
Commissions
%td{:style => "width:100px"}
 
%tbody#customer_rows.rows
=render @customer
%h2 Coordonnées
.row
.col-md-6
%table.table.table-striped
%tbody
%tr
%td
Date d'inscription :
%td
=l @customer.created_at
%tr
%td
Compte professionnel ?
%td
-if @customer.pro
%strong Compte professionnel
%tr
%td
Organisation :
%td
=@customer.organisation
%tr
%td
Nom :
%td
=@customer.name
%tr
%td
Prénom :
%td
=@customer.firstname
%tr
%td
Code de recommandation de l'inscrit :
%td
%strong=@customer.mlm_token.upcase
%tr
%td
Lien de recommandation :
%td
=link_to mlm_token_url(@customer.mlm_token), mlm_token_url(@customer.mlm_token)
%tr
%td
Dite de présentation :
%td
=link_to "http://affiliation-sideplace.com/"+@customer.mlm_token, "http://affiliation-sideplace.com/"+@customer.mlm_token
.col-md-6
%table.table.table-striped
%tbody
%tr
%td
Adresse :
%td=@customer.address
%tr
%td
Adresse (suite) :
%td
=@customer.address2
%tr
%td
Code postal
%td
=@customer.cp
%tr
%td
Ville :
%td
=@customer.city
%tr
%td
Pays :
%td
=@customer.country
%tr
%td
Téléphone :
%td
=@customer.tel_number
%tr
%td
Email :
%td
=link_to @customer.email, "mailto:#{@customer.email}"
%tr
%td
Adresse mail validée ?
%td
=@customer.enabled
%h2 Commandes
%table.table.table-hover.table-striped.order_table
%thead#order_rows_header.rows_header
%tr
%th Compte
%th
Date
%th Date de paiement
%th Type de paiement
%th Crédits
%th Points binaires
%th Parts
%th Prix TTC
%th Prix HT
%th Commissions reversées
%th Delta
%td{:style => "width:100px"}
 
%tbody#order_rows.rows
=render @customer.orders.order("created_at")
%p
via callif pour vérification :
=@customer.callif_now[3] if @customer.callif_now
%h2 Commissions
%table.table.table-striped
%tbody
%tr
%td{:style => "width:170px"}
Solde :
%td
%strong=number_to_currency @customer.commissions.sum(:amount)
%tr
%td
Accumulées :
%td
%strong=number_to_currency @customer.commissions.where("amount > 0.0").sum(:amount)
%tr
%td
Delta chiffre d'affaire
%td
%strong
=number_to_currency( @customer.commissions.where("amount > 0.0").sum(:amount) - @customer.orders.where(:paid => true).where("unpaid is null").sum(:amount_ttc))
%table.table
-@customer.commissions.each do |commission|
%tr
%td{:style => "width:120px"}
= l commission.created_at, :format => :date
%td
-if commission.order
=#image_tag(commission.order.customer.avatar_url)
=link_to commission.order.customer.pseudo_admin, admin_customer_path(commission.order.customer)
%td
-if commission.commission_type_id == 1
Commission directe
-elsif commission.commission_type_id == 2
=ic :sitemap
Commission binaire
%td{:style => "text-align:right", :class => (commission.commission_type_id == 4 ? "red" : "green")}
=commission.commission_type_id == 4 ? "" : "+ "
=number_to_currency commission.amount
%h2 Recommandeur
%table.table.table-hover.table-striped.customer_table
%thead#customer_rows_header.rows_header
%tr
%td
%td
Nom d'utilisateur
%td Parrain
%td
Pays
%td
Email
%td
Nombre d'annonces
%td
Chiffre d'affaire
%td
Commissions
%td{:style => "width:100px"}
 
%tbody#customer_rows.rows
=render @customer.parent if @customer.parent
%h2 Affiliés directs
%table.table.table-hover.table-striped.customer_table
%thead#customer_rows_header.rows_header
%tr
%td
%td
Nom d'utilisateur
%td Parrain
%td
Pays
%td
Email
%td
Nombre d'annonces
%td
Chiffre d'affaire
%td
Commissions
%td{:style => "width:100px"}
 
%tbody#customer_rows.rows
=render @customer.children
%h2 Newsletter
%ul
-Newsgroup.all.each do |newsgroup|
%li
=check_box_tag "newsgroup", "newsgroup", (true if @customer.newsgroups.include?(newsgroup)), {:readonly => "readonly", :disabled => "disabled"}
=newsgroup.name