.qi_header
  .right=# link_to 'Ajouter une taille', new_admin_product_size_path, :class => "btn btn-primary", :remote => true
  %h1 

    Boutique
    %span
      Détail des sous produits de la commande
      ="#"+@product_order.id.to_s

  

.qi_row
  .qi_pannel.qi_plain.padding
    

    %table.table
      %tr
        %td
          %h3 Adresse de facturation
          =render @product_order.particular_bill if @product_order.particular_bill
        %td
          %h3 Adresse de livraison
          =render @product_order.particular_send if @product_order.particular_send
    
    %table.table
      -@product_order.product_order_products.order(:product_id).each do |product_order_product|
      
        %tr
          %td
            %strong
              -if product_order_product.product
                =link_to admin_product_path(product_order_product.product) do
                  = product_order_product.archived_product.lang(:fr).title
              -else
                = product_order_product.archived_product.lang(:fr).title
            %table.sub_products{:style => "width:100%;margin-bottom:20px;margin-top:5px;"}
              %tr
                %th Référence
                %th Nom
                %th Nbr / produits
                %th Prix / produits
                %th Nbr
                %th Prix tot. HT
                %th Prix tot. TTC
                
              -product_order_product.sub_products.each do |sub_product|
                %tr
                  %td
                    =sub_product.reference
                  %td
                    =sub_product.name
                  %td
                    =sub_product.qte
                  %td
                    =number_to_currency sub_product.price_ht_with_qte
                  %td
                    =sub_product.qte_tot
                  %td
                    =number_to_currency sub_product.price_tot_with_qte
                  
                  %td
                    =number_to_currency sub_product.price_tot_with_qte*1.2
                    
                    
                    
          %td
            = product_order_product.archived_product_size.name if product_order_product.archived_product_size
          %td
            = product_order_product.archived_product_option.lang(I18n.locale).name if product_order_product.archived_product_option

          %td
            = number_to_currency(product_order_product.archived_product.final_price_ttc.to_f, locale: :fr) if product_order_product.archived_product
          %td
            =product_order_product.qty
          %td
            = number_to_currency(product_order_product.archived_final_price_ttc_with_qty, locale: :fr) if product_order_product.archived_product
        
  
    
      %tr
        %td{:colspan => 4, :style => "border:0;"}
        %td Total :
        %td= number_to_currency(@product_order.archived_total_articles, locale: :fr)
    
      -if @product_order.vourcher_code_archived
        %tr
          %td{:colspan => 4, :style => "border:0;"}
          %td
            =qit "Code réduction tableau", "Code de réduction "
            ="("+@product_order.vourcher_code_archived.slug+") :"
          %td  
            ="-"
            =number_to_currency @product_order.archived_vourcher_reduction, locale: :fr
    
      %tr
        %td{:colspan => 4, :style => "border:0;"}
        %td Frais de port :
        %td= number_to_currency(@product_order.archived_total_fdp, locale: :fr)
      %tr
        %td{:colspan => 4, :style => "border:0;"}
        %td
          %strong Total :
        %td
          %strong
            = number_to_currency(@product_order.archived_total_ttc, locale: :fr)
    
    
    
    .fdp
      %table.table
        %tr
          %td
            =@product_order.product_fdp_archived.fdp_description
          %td
            =number_to_currency @product_order.product_fdp_archived.price
    %br
    
    %hr
    
    %h3 Détail des sous produits
    %table.table
      %tr
        %th Fournisseur
        %th Référence
        %th Nom
        %th Nbr Prod.
        %th Nbr
        %th Prix tot. HT
        %th Prix tot. TTC
      -@product_order.sub_products.group(:reference).each do |sub_product_group|
        %tr
          %td
            = sub_product_group.fournisseur.name if sub_product_group.fournisseur
          %td= sub_product_group.reference
          %td= sub_product_group.name
          
          -sub_products = @product_order.sub_products.where(:reference => sub_product_group.reference)
          %td
            =sub_products.count
          %td
            -i = 0.0
            -sub_products.each do |sub_product|
              -i += sub_product.qte_tot
            =i

          %td
            -i = 0.0
            -sub_products.each do |sub_product|
              -i += sub_product.price_tot_with_qte
            =number_to_currency i

          %td
            =number_to_currency i*1.2
            =#number_to_currency sub_product.price_tot_with_qte
          
    %hr
    %h3 Détail par fournisseurs
    %table.table
      %tr
        %th Fournisseur
        %th Prix HT
        %th Prix TTC
      -@product_order.fournisseurs.uniq.each do |fournisseur|
        %tr
          %td=fournisseur.name
          %td
            -i = 0.0
            -@product_order.sub_products.where(:fournisseur_id => fournisseur.id).each do |sub_product|
              -i += sub_product.price_tot_with_qte
            =number_to_currency i
     
          %td
            =number_to_currency i*1.2
    %hr
    %br
    %table.table
      %thead
        %tr
          %th Identifiant paiement
          %th Date de paiement
          %th Type de paiement
  
          %th ID Ogone
          %th Status Ogone
          %th Erreur Ogone
          %th N°Carte
          %th Montant
          %th
    
  
      %tbody#product_order_payments
        =render @product_order.product_order_payments.order("created_at DESC")

