-if false
  %tr
  
  
    %td
      =l p_document.created_at, :format => :date
  
    -if @p_documents
      %td
        =link_to "##{p_document.element.id}", admin_p_customer_sheet_path(p_document.element)
      %td
        =p_document.element.p_customer.show_name if p_document.element and p_document.element.p_customer
    
    
  
    %td
      =p_document.label
    %td
      =link_to p_document.d_number, admin_p_document_path(p_document.token)
    
    -totals = PSheetLine.totals(p_document.p_sheet_lines)
    %td
      = number_to_currency totals[:total]
      HT
  
    %td
      = number_to_currency totals[:total_ttc]
      TTC
  
    -if params[:p_document_type_id].to_i == 4
      %th
        ="oui" if p_document.theo_paid
      %th
        ="oui" if p_document.paid
      
      
    -if false
      %table
        %tr 
          %td
            Paid
          %td
            =p_document.paid
        %tr 
          %td
            TH Paid
          %td
            =p_document.theo_paid
        -p_document.p_payment_documents.each do |pp|
          %tr
            %td
              =pp.amount
            %td
              =pp.paid
              =pp.p_payment.paid
      
    
      
    %td.actions
      -if p_document.label == "Facture" and !@relances
        -#if p_document.relative_docs.where(:label => "Avoir").count == 0
        =link_to "Créer un avoir", create_avoir_admin_p_document_path(p_document) #, :data => {:confirm => "Voulez-vous vraiment créer un avoir ?"} 
        &nbsp;&nbsp;
      =link_to i(:eye), detail_admin_p_document_path(p_document)



  -skip_bill_details = skip_bill_details || false



%tr#p_document{:id => p_document.id}



  -if @case_multiple
    %td
      =check_box_tag "ids[]", p_document.token
    
    
    
  %td
    =l p_document.created_at, :format => :date



  -if !@p_customer_sheet or true
    %td
      =link_to "##{p_document.element.id}", admin_p_customer_sheet_path(p_document.element)
    
  -if p_document.p_customer
    %td
      =link_to p_document.p_customer.show_name, [:admin, p_document.p_customer]
  
  

  %td
    =p_document.label
  %td
    =link_to p_document.d_number, admin_p_document_path(p_document.token)
    
  %td.numeraire
    = number_to_currency p_document.cache_total_ht


  %td.numeraire
    = number_to_currency p_document.cache_total_ttc
  



  -if (!skip_bill_details)
   
    %td
      =ic(:check) if p_document.paid
  
    %td.numeraire
      -if p_document.cache_to_paid?
        =number_to_currency p_document.cache_to_paid
        

    %td
      =l p_document.echeance_date, :format => :date if p_document.echeance_date
    %td
      -if p_document.label == "Facture" or p_document.label == "Facture Acompte"
        -if p_document.echeance_date and !p_document.paid
          -j = (Date.today - p_document.echeance_date).to_i
        
          -if j > 0
            %span{:style => "color:red;"}
              =j
          -else
            %span{:style => "color:green;"}
              =j
  

    %td.actions
      -if p_document.label == "Facture" and !@relances
        -if p_document.relative_docs.where(:label => "Avoir").count == 0 or true
          =link_to "Créer un avoir", create_avoir_admin_p_document_path(p_document), :data => {:confirm => "Voulez-vous vraiment créer un avoir ?"} 
          &nbsp;&nbsp;
      =link_to i(:eye), detail_admin_p_document_path(p_document), :remote => false

      -if false
        -if p_document.compta_locked
          =ic :lock
        -else
          =link_to i(:pencil), edit_admin_p_document_path(p_document), :remote => true
  
  

      
 