%tr{class: document.document_verified? ? "success" : ""}
  %td
    = i(:file) + " " + document.title
  %td{style:"text-align:center;vertical-align:middle"}
    -if document.document?
      =link_to ic(:download), public_download_document_path(document.download_token),class: "btn btn-primary btn-xs",title: "Télécharger le document"
    -else
      Pas encore disponible
  %td{style:"text-align:center;vertical-align:middle"}
    -if !document.not_available?
      -if !document.returned_document?
        = form_tag upload_returned_public_accepted_offer_document_path(@accepted_offer, document), name: :returned_document, method: :post, multipart: true do
          %span.btn.btn-xs.btn-default.btn-file
            = ic(:'folder-open')
            = file_field_tag :returned_document
          %button.btn.btn-xs.upload-file{type: :submit, title: "Valider le document"}
            = ic(:check)

      -else
        =link_to i(:"download"),download_returned_public_accepted_offer_document_path(@accepted_offer, document), class:"btn btn-xs btn-primary",title: "Télécharger le document"
        -if !document.document_verified?
          =link_to i(:"remove"),destroy_returned_public_accepted_offer_document_path(@accepted_offer, document), class:"btn btn-xs btn-danger",  title: "Supprimer le fichier chargé", :data => {:confirm => 'Voulez-vous vraiment supprimer le fichier chargé ?'}
    -else
      = "Pas encore disponible"
  %td{style:"text-align:right;vertical-align:middle"}
    =document.human_state

:javascript
  $(".upload-file").prop("disabled","disabled");
  $(".btn-file  input").change(function(){

    $(this).parent().next(".upload-file").prop("disabled","");
    $(this).parent().next(".upload-file").addClass("btn-success");
  })
