.qi_header
  %h1
    Mouvements de stock manuels
    %span
      Détail du mouvement
      ="##{@stock_movement.id}"



.qi_row
  .qi_pannel.qi_plain.padding
    %table.table
      %tr
        %th Date :
        %td=l @stock_movement.date
      %tr
        %th Type de mouvement :
        %td=@stock_movement.movement_type




    %h3 Contenu
    %table.table.table-hover.table-stripped
      %tr
        %th
          Produit
        %th
          DLUO
        %th Qté
        %th Prix / conditionnement
        %th Valeur
      -@stock_movement.stock_movement_lines.each do |sml|
        %tr
          %td
            =sml.p_product_ref.name if sml.p_product_ref

          %td
            =l sml.dluo if sml.dluo

          %td
            =sml.qte

          %td
            =number_to_currency(sml.tot_amount_ht / sml.qte) if sml.tot_amount_ht

          %td
            =number_to_currency sml.tot_amount_ht




  %br
  %br
  %p
    =link_to "Générer les stocks", generate_stocks_admin_stock_movement_path(@stock_movement), :class => "btn btn-primary" if !@stock_movement.stock_done

  %h3 Stocks générés
  #bills
    -params[:search][:per_page] = params[:search][:per_page] || 5000
    -per_page = params[:search][:per_page]
    -page = (params[:page] and params[:page] != "") ? params[:page] : 1

    -@line_stocks = @stock_movement.line_stocks

    -@line_stocks = sort_by_sorting(@line_stocks, "date DESC")
    -@line_stocks = @line_stocks.page(page).per(per_page)
    %br



    .clear
    =render :partial => "qi/qi_ordered_table", :locals => {:qi_ordered_table_collection => @line_stocks}
