.qi_header
  %h1
    =link_to ic(:user)+" Mon compte", public_my_account_path
    %span
      =link_to "Mes commandes", public_p_customer_sheets_path
    %span
      Détail d'une commande

.qi_row
  .qi_pannel.qi_plain.padding


    %table.table{:style => ""}
      %tr
        %td{:style => "border:0"}
          %h3 Adresse de facturation
  
          -if @p_customer_sheet.particular_bill
            %strong=@p_customer_sheet.particular_bill.organisation
            %br
            =@p_customer_sheet.particular_bill.firstname

            =@p_customer_sheet.particular_bill.name
            %br
            =@p_customer_sheet.particular_bill.address_2

            -if @p_customer_sheet.particular_bill.address_3?
              %br
              =@p_customer_sheet.particular_bill.address_3
            %br
            =@p_customer_sheet.particular_bill.cp

            =@p_customer_sheet.particular_bill.city
            %br
            =@p_customer_sheet.particular_bill.country
            %br
            %br
            =@p_customer_sheet.particular_bill.tel
  
  
        %td{:style => "border:0"}
          %h3 Adresse de livraison
  
          -if @p_customer_sheet.particular_bill
            %strong=@p_customer_sheet.particular_bill.organisation
            %br
            =@p_customer_sheet.particular_send.firstname

            =@p_customer_sheet.particular_send.name
            %br
            =@p_customer_sheet.particular_send.address_2

            -if @p_customer_sheet.particular_send.address_3?
              %br
              =@p_customer_sheet.particular_send.address_3
            %br
            =@p_customer_sheet.particular_send.cp

            =@p_customer_sheet.particular_send.city
            %br
            =@p_customer_sheet.particular_send.country
            %br
            %br
            =@p_customer_sheet.particular_bill.tel


    %h3 Résumé
    -ok = ok || false

    -sheet_lines = @p_customer_sheet.p_sheet_lines


    %table.table.sheet_line{:style => "width:100%;"}
      %tr.sheet_line_head
        %th 
          Etat
        %th
          Description
        %th Taille  
        %th
          Couleur
  
        %th
          Qte
        %th
          Prix U.
        %th 
          Prix Tot.
        %th
          Prix TTC


      -sheet_lines.each do |sheet_line|
        -p_sheet_line_lines = sheet_line.p_sheet_line_lines.where("qte > 0")
        -nbr_lines = p_sheet_line_lines.count
        -ok = true if sheet_line.shiped
        %tr.sheet_line_head
          %td
      
            - if sheet_line.shiped
              Livrée
            -elsif sheet_line.bl
              En cours de livraison
              %br
              -if sheet_line.p_product.p_product_cat_id != 6 or sheet_line.externe and @p_customer_sheet
                =link_to "Indiquer comme livré", set_sheet_line_ship_admin_p_customer_sheet_path(@p_customer_sheet, :p_sheet_line_ids => [sheet_line.id]), :remote => true
          %td
            %strong
              =sheet_line.product_name
       
     
          %td 
          %td 
  
          %td
            %strong=sheet_line.qte
      
          %td
            %strong=number_to_currency sheet_line.price if sheet_line.price
    
          %td
            %strong=number_to_currency sheet_line.price_tot if sheet_line.price_tot
    
          %td
            %strong=number_to_currency sheet_line.price_tot_ttc if sheet_line.price_tot_ttc
      
      
        -p_sheet_line_lines.each do |p_sheet_line_line|
          %tr
            %td
            %td

            %td
              =p_sheet_line_line.p_size.name if p_sheet_line_line.p_size
            %td
              =p_sheet_line_line.p_color.name if p_sheet_line_line.p_color
            %td
              =p_sheet_line_line.qte
      
            %td
            %td
            %td
      
    

      -total_with_labels =  PSheetLine.total_with_labels(sheet_lines)

      -total_with_labels.each do |index, total|


        %tr.sheet_line_head
          %td{:style => "text-align:right;padding-right:10px;", :colspan =>7}
            %strong
              =total[:label]
          %td
            =number_to_currency total[:value]

    :scss
      .sheet_line_head{
        td, th{
          border-color:rgba(0,0,0,0.5) !important;
        }
  
      }
      .marges{
        td{
          vertical-align:top;
        }
  
  
  
  
      }
    
    .qi_sub_header
      %h2 Documents
      
    
      %table.table
        %tr
          %th Date
          %th Type
          %th Numéro
          %th Total HT
          %th Total TTC
  

        %tbody#p_customer_sheets_rows
          -@p_customer_sheet.p_documents.order("created_at DESC").each do |p_document|
            %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
            


  
