%h1
  = "Gestion des offres par client pour le besoin "
  <strong>
  = @offer.need.title
  </strong>

%h4
  = "Personnes intéressées: "
  <strong>
  =pluralize(@offer.need.wishes.length, "Personne")
  </strong>
%h4
  = "Offres acceptées: "
  <strong>
  =pluralize(@offer.accepted_offers.length, "Personne")
  </strong>
%h4
  = "Prix proposé: "
  <strong>
  =number_to_currency(@offer.price, locale: :fr)
  </strong>
%h4
  = "Fournisseur: "
  <strong>
  =@offer.supplier
  </strong>
%br

%div{style:"display-block"}

  =link_to ic(:"upload") + " Charger un document pour toutes les offres acceptées", upload_documents_admin_offer_path, class: "btn btn-primary",style:{display: "inline-block"}
  =link_to ic(:"download") + " Télécharger le zip de l'offre", download_zip_admin_offer_path, class: "btn btn-primary",style:{display: "inline-block"}
%br

%table.table.admin-table.table-hover.table-striped
  %thead.rows_header
    %tr
      %th
        Société
      %th
        Nom/Prénom
      %th
        Téléphone
      %th
        Email
      %th{style:"text-align:center"}
        Offres acceptée?
      %th{style:"text-align:center"}
        Documents
      %th{style:"text-align:center"}
        État

  %tbody.rows
    -@offer.need.wishes.each do |wish|
      -accepted_offer = @offer.accepted_offers.where(customer_id: wish.customer.id).first
      -if accepted_offer && accepted_offer.documents_completed?
        -class_name = "success"
      %tr{class: class_name}
        %td
          -if wish.customer.organisation
            =wish.customer.organisation
        %td
          =wish.customer.firstname + " " + wish.customer.name
        %td
          -if wish.customer.phone
            = ic("phone") + " #{wish.customer.phone}"
        %td
          -if wish.customer.email
            = link_to ic("envelope-o") + " #{wish.customer.email}", 'mailto:' + wish.customer.email
        %td{style:"text-align:center"}

          -if accepted_offer
            =ic(:"check") + " Acceptée"
          -else
            \-

        %td{style:"text-align:center"}
          -if accepted_offer
            =link_to ic(:file) + " #{accepted_offer.documents.where(state: :document_verified).count} / #{accepted_offer.documents.count}", admin_offer_accepted_offer_path(@offer, accepted_offer), style:"display:inline-block", class: "btn btn-primary btn-xs"

        %td{style:"text-align:center"}
          -if accepted_offer
            =accepted_offer.human_admin_state

          -else
            Pas encore acceptée

=link_to ic(:"chevron-circle-left") + " Gestion des offres", admin_offers_path, class: "btn btn-default"

:javascript
