-if true
  #p_sheet_line.product_stock_form.field.p_sheet_line_field{:id => form.object.id}
    %table{:style => "width:100%;"}
      %tr
        %td{:style => "width:70%;"}
          -if form.object.lock != true  
            =#link_to_remove_fields ic(:"trash-o"), form

          %label Produit :
          %input.p_product_autocomplete_input.form-control{:type => "text", :value => ("#{form.object.p_product.code} #{form.object.p_product.name}" if form.object.p_product), :readonly => ("true")}


          = form.hidden_field :p_product_id, :class => "p_product_id"
          = form.hidden_field :ok_price
          = form.hidden_field :price
         
        %td{:style => "width:30%;"}
          =form.input :cust_ref, :label => "Référence client :"
                
  




    
    
    -p_product = form.object.p_product if form.object.p_product
    %table.table.order_table
      -if p_product and p_product.p_sizes.count > 0
        %tr
          %th
        
        
      
      
          -if form.object.p_product
          
            -p_product.p_sizes.order("p_sizes.position ASC, p_sizes.id ASC").all.each do |p_size|
              %th.size_th
                =p_size.name
            %th.price_td Qte
            %th.price_td PU
            %th.price_td
              Prix tot.
        -if form.object.p_product 
          -p_product.p_colors.all.each do |p_color|
            %tr.color_line
              %td=p_color.name
    
              -p_product.p_sizes.order("p_sizes.position ASC, p_sizes.id ASC").all.each do |p_size|
                %td
                  -ps = p_product.p_product_stocks.where(:p_size_id => p_size.id, :p_color_id => p_color.id).first
        
                  -if ps
            
                    -p_sheet_line_line = nil
                    -form.object.p_sheet_line_lines.each do |a|
                      -if a.p_product_stock_id == ps.id
                        -p_sheet_line_line = a
                        
                    -#p_sheet_line_line = form.object.p_sheet_line_lines.where(:p_product_stock_id => ps.id).first
                    -if p_sheet_line_line
                      =form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder|
                        =builder.hidden_field :p_product_stock_id,:label => false, :as => :string
                        =builder.hidden_field :p_size_id
                        =builder.hidden_field :p_color_id
                        =builder.hidden_field :ok_code
                        =builder.input :qte,:label => false, :input_html => {:class => "qte"}
        
              %td.qte_color_tot.price_td
              %td.price.price_td{:data => {:price => form.object.price}}
                =#number_to_currency form.object.price
          
              %td.price_color_tot.price_td
      -elsif form.object.p_product 
        %tr.color_line
          %td 

          -p_product.p_product_stocks.each do |ps|
            %td
              
              -if ps
                -p_sheet_line_line = nil
                -form.object.p_sheet_line_lines.each do |a|
                  -if a.p_product_stock_id == ps.id
                    -p_sheet_line_line = a
                -if p_sheet_line_line
                  =form.fields_for(:p_sheet_line_lines, p_sheet_line_line) do |builder|
                    =builder.hidden_field :p_product_stock_id,:label => false, :as => :string
                    =builder.input :qte,:label => false, :input_html => {:class => "qte"}
    
          %td.qte_tot.price_td
          %td.price.price_td{:data => {:price => form.object.price}}
            =number_to_currency form.object.price
      
          %td.price_color_tot.price_td
      
    -if form.object.p_product 
      %table{:style => "width:100%"}

        
        
        %tr
        
          %td
            &nbsp
          %td
          %td.qte_tot.price_td{:style => "font-weight:bold;"}
            %strong=form.object.qte
        
          %td.price.price_td{:style => "font-weight:bold;text-align:right;", :data => {:price => form.object.price}}
            =form.input :ok_price, :label => false, :input_html => {:style => "display:inline-block;text-align:right"}
            =#%strong=number_to_currency form.object.price
      
        
          %td.price_tot.price_td{:style => "font-weight:bold;"}
            =number_to_currency form.object.price_tot
    %br

