.qi_header
  .right
    -if false
      = link_to ic(:minus)+' Sortie de stock', new_admin_stock_movement_path(:movement_type => "deb"), :class => "btn btn-primary bgbd-documents", :remote => true
      = link_to ic(:plus)+' Entrée de stock', new_admin_stock_movement_path(:movement_type => "cred"), :class => "btn btn-primary bgbd-documents", :remote => true

  %h1
    Résumé des stocks



.qi_search_row
  =form_tag "", :method => "get",  :onsubmit => "" do
    %table.qi_search_row_top
      %tr
        %td
          Produit :
        %td

          %input.form-control{:name => "p_product_ref", :class => "p_product_ref_autocomplete_input", :type => "text", :value => params[:p_product_ref]}


          = hidden_field_tag "p_product_ref_id".to_sym, params[:p_product_ref_id], :class => "p_product_ref_id"

          :javascript
            qi_autocomplete('p_product_ref');
    =link_to ic(:search)+" Rechercher", "#", :class => "btn btn-default btn-qi-search", :onclick => "$(this).closest('form').submit();$(this).html('...');return false;"


.clear

.qi_pannel.padding.new_table_container
  / .table-slider
  /   .inner
  /     <form class="range-field">
  /     <input type="range" min="0" max="100" step="0.1" class="range" value="0" />
  /     </form>
  .table-area
    .table-area-inner


      .freezeTable
        %table.table.table-striped.table-hover.table-bordered.data_table
          %thead.header
            %tr
              %th ID
              %th Code
              %th Produit
              %th Unités en stock
              %th En Stock
              %th Valorisation de stock
              %th Unités sorties
              %th Sorties (KG)
              %th Sorties (€)


          %tbody
            -if params[:p_product_ref_id].present?
              -PProductRef.where(p_product_id: params[:p_product_ref_id]).each do |p|
                -@line_stocks = LineStock.where(p_product_ref_id: params[:p_product_ref_id])
                %tr
                  %td=params[:p_product_ref_id]
                  %td=p.code
                  %td=p.name
                  %td=@line_stocks.sum(:qte_available)
                  %td=@line_stocks.sum(:cc_qte_kg_available).to_i
                  %td=number_to_currency @line_stocks.sum(:price_ht)
                  %td=@line_stocks.sum(:qte_used)
                  %td=@line_stocks.sum(:cc_qte_kg_used).to_i
                  %td=number_to_currency @line_stocks.sum(:cc_price_ht_used)
            -else
              -PProductRef.all.each do |p|
                -@line_stocks = LineStock.where(p_product_ref_id: p.id)
                %tr
                  %td=p.p_product_id
                  %td=p.code
                  %td=p.name
                  %td=@line_stocks.sum(:qte_available)
                  %td=@line_stocks.sum(:cc_qte_kg_available).to_i
                  %td=number_to_currency @line_stocks.sum(:price_ht)
                  %td=@line_stocks.sum(:qte_used)
                  %td=@line_stocks.sum(:cc_qte_kg_used).to_i
                  %td=number_to_currency @line_stocks.sum(:cc_price_ht_used)















