.qi_header
  .right
    =link_to ic(:plus)+" Demande de commande", admin_p_customers_path(:offre => true), :class => "btn btn-primary btn-ap-add"
    
  %h1
    Tableaux de bord achats


.qi_search_row
  =form_tag "", :method => "get",  :onsubmit => "" do
    -params[:search] =params[:search] || {}

    
    %table
      %tr
    
        %td
          Statut :
          =select_tag "search[state]", options_for_select([["",""]]+PCustomerSheet.group(:state).all.map{|a| [a.state, a.state]}, params[:search][:state])
  
        
          


      
      
  
    =#render :partial => "qi/qi_ordered_table_search_footer", :locals => {:collection_object => @p_customer_sheets}

-nbr_td = 15

.qi_pannel.padding.new_table_container
  .table-slider
    .inner
  
  .table-area{:style => "overflow:auto;"}
    .table-area-inner

      =form_tag new_admin_price_document_path(), :method => "get" do
      
        =hidden_field_tag :"document_type", "Demande prix"
        =hidden_field_tag :"price_line_ids[]", ""
        .freezeTable
          %table.table.table-striped.table-hover.table-bordered.data_table
            %thead.header
              %tr
                %th
                %th
                  Produit
                %th
                  Référence
                %th Qté
            
                %th.mask
                  N° Commande
                %th.mask
                  Client
                %th.mask
                  Statut
              
                %th.mask Date saisie 
                %th.mask Date validation 
                %th.mask Date livraison (ETA)
              
                %th.mask
                  Qté commandée
                %th.mask Commentaire
                %th.mask BPA
                %th.mask AV BPA
                %th.mask PAS BPA
                
              


            %tbody
              -p_product_id = nil
              -@price_lines.where.not(:p_product_ref_id => nil).group(:p_product_ref_id).order("p_product_id ASC").each do |plr|
              
                -if p_product_id != plr.p_product_id
                  -p_product_id = plr.p_product_id
                  %tr.prdct_tr
                    -nbr_td.times.each do 
                      %td
            
            
          
                  
              
              
                -ppr_lines = @price_lines.where(:p_product_ref_id => plr.p_product_ref.id)
                %tr.ref_tr
                  %td
                  %td
                    =link_to plr.p_product_ref.p_product.name, [:admin, plr.p_product_ref]
                  %td
                    =link_to [:admin, plr.p_product_ref] do
                      =plr.p_product_ref.ct_sub_name 
                      =plr.p_product_ref.p_product_color.name if plr.p_product_ref.p_product_color
                
                  %td
                    =ppr_lines.sum(:qte)
              
                
                  %td.mask
                  %td.mask
                  %td.mask
                  %td.mask
                  %td.mask
                  %td.mask
                  %td.mask
                  %td.mask
                
                
                  %td.mask
                    =ppr_lines.where(:cc_state => "BPA").sum(:qte)
                  %td.mask
                    =ppr_lines.where(:cc_state => "AV BPA").sum(:qte)
                  %td.mask
                    =ppr_lines.where(:cc_state => "PAS BPA").sum(:qte)
                
                -ppr_lines.each do |price_line|
                  %tr
                    %td
                      =check_box_tag :"price_line_ids[]", price_line.id
                    %td
                    %td
                    %td
                    %td
                      =link_to [:admin, price_line.price_line_block.price_lineable] do
                        =price_line.price_line_block.price_lineable.id
                        =price_line.price_line_block.price_lineable.past_id
                
                  
                  
                    %td
                      =link_to price_line.p_customer.show_name, [:admin, price_line.p_customer]
                  
                    %td
                      =state_helper price_line.price_line_block.price_lineable.state
                  
                    %td
                      = l price_line.cc_creation_date, :format => :short_date
                  
                    %td
                      = l price_line.cc_validation_date, :format => :short_date if price_line.cc_validation_date
                  
                  
                    %td
                      = l price_line.cc_wish_date, :format => "semaine %V (%Y)"
                    
                    %td
                      =price_line.qte
                  
                    %td
                      =price_line.comment
                    
                    %td
                      =price_line.qte if price_line.cc_state == "BPA"
                  
                    %td
                      =price_line.qte if price_line.cc_state == "AV BPA"
                  
                    %td
                      =price_line.qte if price_line.cc_state == "PAS BPA"
                    
                -p_product_id = plr.p_product_id
            
            %tr
              -nbr_td.times.each do 
                %td
        
        =submit_tag "Créer une demande de prix", :class => "btn btn-primary"
              
              
                  
                  
                  
:scss
  .ref_tr{
    td{
      border-top:3px solid gray;
    }
  }
  
  .prdct_tr{
    td{
      border-bottom:3px solid red;
    }
  }
                  
                  
                  
                  
                  
                  
                  