-@import= true

-i = 0
Références non trouvées :
-count = 0
%table.table
  -@csv.each do |csv|
    -i += 1
    
    
    
    
    -if csv["Ref"].to_s != ""
      -p_product_stock = PProductStock.where(:code => csv["Ref"]).first
      
    
      -if p_product_stock
        -count +=1
        -p_product = p_product_stock.p_product
        %tr
          %td
            =p_product.name
          %td
            -name = "R0"
            -if p_degressif = p_product.p_degressifs.where(:nbr => 0.0).joins(:p_price_cats).where(:p_price_cats => {:name => name}).first
            
            -else
              -p_degressif = p_product.p_degressifs.create(:nbr => 0.0, :p_price_cat_ids => [1])
            =p_degressif.price =csv[name].to_s.gsub(",", ".")
            -p_degressif.save
          
          %td
            -name = "R1"
            -if p_degressif = p_product.p_degressifs.where(:nbr => 0.0).joins(:p_price_cats).where(:p_price_cats => {:name => name}).first
            
            -else
              -p_degressif = p_product.p_degressifs.create(:nbr => 0.0, :p_price_cat_ids => [2])
            =p_degressif.price =csv[name].to_s.gsub(",", ".")
            -p_degressif.save
          
          %td
            -name = "R2"
            -if p_degressif = p_product.p_degressifs.where(:nbr => 0.0).joins(:p_price_cats).where(:p_price_cats => {:name => name}).first
            
            -else
              -p_degressif = p_product.p_degressifs.create(:nbr => 0.0, :p_price_cat_ids => [3])
            =p_degressif.price =csv[name].to_s.gsub(",", ".")
            -p_degressif.save
          
          %td
            -name = "R5"
            -if p_degressif = p_product.p_degressifs.where(:nbr => 0.0).joins(:p_price_cats).where(:p_price_cats => {:name => name}).first
            
            -else
              -p_degressif = p_product.p_degressifs.create(:nbr => 0.0, :p_price_cat_ids => [4])
            =p_degressif.price =csv[name].to_s.gsub(",", ".")
            -p_degressif.save
          
          %td
            -name = "R10"
            -if p_degressif = p_product.p_degressifs.where(:nbr => 0.0).joins(:p_price_cats).where(:p_price_cats => {:name => name}).first
            
            -else
              -p_degressif = p_product.p_degressifs.create(:nbr => 0.0, :p_price_cat_ids => [5])
            =p_degressif.price =csv[name].to_s.gsub(",", ".")
            -p_degressif.save
          
          
      -else
        %tr
          %td=csv["Ref"]
          
    
  
    
  -if i == 10
    -#break
%p
  =count
  lignes de stock importées

.qi_header
  %h2 Importation
  
-if false
  =semantic_form_for [:admin, @j_contrat], :url => import_save_admin_j_lines_path(), :html => {:method => :post}, :remote => false do |f|
  
    =hidden_field_tag :id, @j_contrat.id
  
    .j_lines_form
      =f.semantic_fields_for :j_lines do |form|
        =render :partial => "admin/j_lines/inline_form", :locals => {:f => form}
      
    %center
      =f.submit "Importer", :class => "btn btn-primary"
      %br
      %br
      %br


