
- @contact = @contact || Contact.new(:provenance_id => 3)
=semantic_form_for [:public, @contact], :remote => true do |f|
  =f.inputs do

    =f.hidden_field :provenance_id
    =f.hidden_field :raison_id
    
    -if @contact.raison_id == 4
      -p_ids = []
      
      -if @contact.contact_products.size > 0
        %h3
          Ma demande concerne les produits suivants :
        %table.contact_products_table.table
          =f.semantic_fields_for :contact_products do |f|
            %tr
              %td
                =f.hidden_field :d_product_id
                =image_tag f.object.d_product.icon.file.url 
              %td
                =f.label :qte, "Quantité souhaitée (#{f.object.d_product.unit}) :"
              %td
                =f.input :qte, :label => false
                -p_ids << f.object.d_product_id
              %td
                =link_to "supprimer ce produit", public_contact_product_path(:id => f.object.d_product_id), :method => :delete
      

      -if p_ids.size > 0 and p_ids.size < DProduct.where(:orderable => true).where("icon_id is not null").count.to_i
        %h3 
          Demander un devis pour les produits suivants également :
        #products
          -DProduct.where(:orderable => true).where("icon_id is not null").where("id not in (?)", p_ids).order(:name).each do |d_product|
            =link_to new_public_contact_product_path(:token => d_product.id) do
              =image_tag d_product.icon.file.url
      
      -else
        %h3 
          Demander un devis pour les produits suivants :
        #products
          -DProduct.where(:orderable => true).where("icon_id is not null").order(:name).each do |d_product|
            =link_to new_public_contact_product_path(:token => d_product.id) do
              =image_tag d_product.icon.file.url
            
            
            
    %h3
      Mes coordonnées : 
    %table{:style => "border-collapse:collapse;width:100%;"}
      %tr
        
        %td{:style => "width:50%;vertical-align:top;padding-right:6px;"}
    
          =f.input :name, :label => false, :placeholder => qit("contact nom","Nom*")
      
        %td{:style => "width:50%;vertical-align:top;padding-left:6px;"}
          =f.input :firstname, :label => false, :placeholder => qit("contact prenom","Prénom*")


      %tr
        %td{:colspan => 2}
          =f.input :corporate, :label => false, :placeholder => qit("contact organisation","Organisation*")
      
      -if @contact.raison_id == 4
        %tr
          %td{:colspan => 2}
            =f.input :address, :label => false, :placeholder => "Adresse*"
        %tr
          %td{:colspan => 2}
            =f.input :address2, :label => false, :placeholder => "Adresse (suite)"
      
        %tr
          %td{:style => "width:50%;vertical-align:top;padding-right:6px;"}
    
            =f.input :cp, :label => false, :placeholder => "Code postal*"
      
          %td{:style => "width:50%;vertical-align:top;padding-left:6px;"}
            =f.input :city, :label => false, :placeholder => "Ville*"
      
      %tr
        
        %td{:style => "width:50%;vertical-align:top;padding-right:6px;"}
          =f.input :email, :label =>  false , :placeholder  =>"Email"
        %td{:style => "width:50%;vertical-align:top;padding-left:6px;"}
          =f.input :phone, :label => false, :placeholder => qit("contact tel","Téléphone")
      %tr
        %td{:colspan => 2}
          =f.input :message, :label =>false , :placeholder => "Message"
  
  
  
    .submit
      =f.submit "Envoyer", :class => "btn"
  
  
  
      
      
      
    .clear    
  