%h1 Détail d'un inscrit

%h2 Coordonnées

%p
  Nom :
  =@customer.name
%p
  Prénom :
  =@customer.firstname
%hr
%p
  Adresse :
  =@customer.address
%p
  Adresse (suite) :
  =@customer.address2
%p
  Code postal
  =@customer.cp
%p
  Ville :
  =@customer.city
%p
  Pays :
  =@customer.country
%hR
%p
  Nom :
  =@customer.name
%p
  Nom :
  =@customer.name
  
%h2 Commandes
-parts = 0
%table.table
  %tr
    %th
      Date
    %th Date de paiement
    %th Type de paiement
    %th Crédits
    %th Points binaires
    %th Parts
    %th Prix HT
    %th Prix TTC
  -@customer.orders.order("created_at").each do |order|
    %tr
      %td
        =l order.created_at
      %td
        =l order.paid_at if order.paid_at?
      %td
        -if order.payment_type_id == 1
          Offert
        -if order.payment_type_id == 2
          Carte bancaire
      %td
        =order.nbr_credits
      %td
        = order.binary_points
      
      %td
        = order.nbr_parts
        -if order.paid
          -parts = parts + order.nbr_parts.to_i
      %td
        =number_to_currency order.amount_ht
      %td
        =number_to_currency order.amount_ttc
%p
  parts comptés :
  %strong=parts
%p 
  compté par sql :
  =Credit.where(:customer_id => @customer.id).between(Date.today, Date.today).includes(:order).sum("orders.nbr_parts")
%p 
  via callif pour vérification :
  =@customer.callif_now[3] if @customer.callif_now

%h2 Commissions
%p
  Solde : 
  %strong=number_to_currency @customer.commissions.sum(:amount)
%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) 
          =commission.order.customer.pseudo
      %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