.center
  %h3 Membres du réseau
  
  .domain_select
    Domaines :
    =link_to "Tous", public_reseaux_customers_path(:resaux_id => @reseaux, :domain_id => ""), :class => ("active" if params[:domain_id].to_s == "")
    
    -@reseaux.domains.uniq.each do |domain|
      =link_to domain.name, public_reseaux_customers_path(:resaux_id => @reseaux, :domain_id => domain.id), :class => ("active" if params[:domain_id].to_s == domain.id.to_s)
  %div{:style => "position:relative"}
    %table.table.table-hover.table-striped.customer_table
      %thead#customer_rows_header.rows_header

        %tr
          %th Domaine
      
          %th
            Nom

          %th
            
      
          %th
            Email
          -if !@vouistar
            %th
              CA
          %th
            Gains
        
          %th Dernière activité



          %th{:style => "width:100px;text-align:right;"}
            &nbsp;


        

      %tbody#customer_rows.rows
        -gain = 0.0
        -@customers.each do |customer|
          -css_class = ""
          -css_class "danger" if customer.lock

          %tr#customer_row{:id => customer.id, :class => css_class}
            %td
              =customer.domains.all.map{ |d| d.name}.join(", ")
            %td
              -if customer.organisation?
                =customer.organisation
                %br
            
              =customer.name
              =customer.firstname
            %td
              =customer.city
              -if customer.phone?
                %br
                = i("phone") + " #{customer.phone}"
     
              

   
            %td
              =link_to customer.email, "mailto:#{customer.email}"

            -if !@vouistar 
              %td
                =number_to_currency customer.accepted_offers.joins(:offer).where(:state => "documents_completed").sum("offers.price * accepted_offers.qte").to_f
          
            %td
              -g = customer.accepted_offers.joins(:offer).where(:state => "documents_completed").sum("offers.gain * accepted_offers.qte").to_f
              =number_to_currency g
              -gain += g
      

            %td=time_ago_in_words(customer.last_activity) if customer.last_activity
  
  
            %td.actions{:style => "width:150px;text-align:right;"}
              =link_to i(:eye), public_reseaux_customer_path(@reseaux, customer)
              =link_to i(:envelope), new_public_customer_message_path(:thing_type => "Customer", :thing_id => customer.id)
        

