%tr#p_product{:id => p_product.id}
  -tr = {}

  -tr[:code] = capture do
    %td{:style => "white-space: nowrap;"}= link_to p_product.code, edit_admin_p_product_path(p_product)
  
  -tr[:name] = capture do
    %td{:style => "white-space: nowrap;"}=link_to p_product.name, edit_admin_p_product_path(p_product)
  
  -tr[:p_customer_cats] = capture do
    %td=raw p_product.p_customer_cats.map{|a| a.name}.join(",")
    
  -tr[:p_product_cat] = capture do  
    %td
      = p_product.p_product_cat.name if p_product.p_product_cat
  
  -tr[:s_brand] = capture do
    %td
      = p_product.s_brand.name if p_product.s_brand
  
  

  -if p_product_ref = p_product.p_product_refs.first
    
    -tr[:uv] = capture do
      %td
        -if p_product_ref.uv?
          = p_product_ref.uv
        -else
          %span.red= ic :warning
  
    -tr[:capacite] = capture do
      %td
        =p_product_ref.capacite
  
    -tr[:price_calc] = capture do
      %td
        =p_product.price_calc
    
    -tr[:ct_price_ht] = capture do
      %td.numeraire
        -if p_product_ref.ct_price_ht.to_f == 0.0
          %span.red= ic :warning
        =number_to_currency p_product_ref.ct_price_ht
    
    -tr[:price_calc] = capture do
      %td.numeraire
        -if p_product.price_calc == "Kg" 
          -if p_product_ref.weight.to_f != 0.0
            =number_to_currency( p_product_ref.ct_price_ht / p_product_ref.weight)
          -else
            %span.red= ic :warning
    
    -tr[:tva_rate] = capture do
      %td.numeraire
        =p_product.tva_rate(1).rate if p_product.tva_rate(1)
        ="%"
  
    -tr[:weight] = capture do
      %td.numeraire
        -if p_product_ref.weight?
          = p_product_ref.weight
          Kg
        -elsif p_product.price_calc == "Kg"
          %span.red= ic :warning
    
  -tr[:country] = capture do  
    %td
      =p_product.country
  
  -tr[:sub_country] = capture do
    %td=p_product.sub_country
  
  -tr[:domaine] = capture do
    %td=p_product.domaine
    

      

  -tr[:actions] = capture do
    %td.actions
      -if current_admin.has_permission?("products-d")
        = link_to i(:"trash-o"), [:admin, p_product], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer ce produit ? ' } , :remote => true if !PriceLine.where(:p_product_ref_id => p_product.p_product_ref_ids).first
      =#debug PriceLine.where(:p_product_id => p_product.id).first
      -if current_admin.has_permission?("products-e")
        = link_to i(:pencil), edit_admin_p_product_path(p_product), :remote => false


  =render :partial => "qi/qi_ordered_table_object", :locals => {:tr => tr, :object => p_product}
  
