.qi_header
  .right= link_to 'Ajouter un commercial', new_admin_p_commercial_path(), :class => "btn btn-primary", :remote => true
  %h1
    Achats
    %span
      =link_to "Commerciaux", admin_p_commercials_path()
    
    %span
      =@p_commercial.firstname
      =@p_commercial.name

    %span
      =number_to_currency @p_commercial.ca_ht
      HT
      ="-"
      =number_to_currency @p_commercial.ca_ttc
      TTC
      

  
  



.qi_row#tabs
  .qi_pannel
    %ul.nav.nav-tabs
      -params[:tab] = params[:tab] || "clients"
      %li{:class => ("active" if params[:tab] == "clients")}=link_to "Cliens", "?tab=clients"
      %li{:class => ("active" if params[:tab] == "offres")}=link_to "Offres", "?tab=offres"
      %li{:class => ("active" if params[:tab] == "bills")}=link_to "Factures & Avoirs", "?tab=bills"
    
    .tab-content{:style => "min-height:1000px;margin-bottom:300px;"}
      
      -if params[:tab] == "bills"
        .qi_row
          .qi_pannel.qi_plain.padding
          
            %table.table
              %tr
                -if params[:detail]
                  %th ID doc.
                %th Date
                %th N° offre
                -if params[:detail]
                  %th Code client
                %th Client
    
                %th Type
                %th Numéro
                -if !params[:detail]
      
                  %th Total HT
                  %th Total TTC
    
     
                  %th
                    Payée
                  %th
                    Solde
                  %th Echéance
      
                  %th Jours de retard
      
                  %th 
    
                -else
                  -@totals = {}
                  %th Code
                  %th Produit
                  %th Qte
                  %th{:style => "width:80px"} Prix U HT
      
                  %th Prix Tot HT.
                  %th TVA
                  %th{:style => "width:80px"} Prix Tot TTC
    



              %tbody#p_customer_sheets_rows
                =render @p_commercial.p_documents.where(:p_document_type_id => [4,7])
      
      
      -if params[:tab] == "offres"
        .qi_row
          .qi_pannel.qi_plain.padding
          
            %table.table.table-hover.table-striped
              %tr
                %th ID
                %th Date
                %th Client
        
                %th Non livrés
                %th Livrés
                %th Total HT
                %th Total TTC
                %th Statut

                %th
  

              %tbody#p_customer_sheets_rows
                =render @p_commercial.p_customer_sheets
                
                
                
                
      
      -if params[:tab] == "clients"
        .qi_row
          .qi_pannel.qi_plain.padding
          
            %table.table
              %tr
                %th
                %th=sort_link "code", "Code"
                %th Nom
                %th Adresse
                %th 
                  =sort_link "cache_ca", "CA (HT)"
                %th
                  =sort_link "cache_encours_th", "Encours"
                %th
          
              %tbody#p_customers_rows
                =render @p_commercial.p_customers
                
        
        
        
        
        
        
      
