= render :partial => 'order_head'

.single_column{:style => 'clear:both;margin-bottom:7em;'}
  - form_tag(:action => 'saveOrder', :id => @order) do
    .box_title
      %h2 Anderer Bestellungen
    .column_content
      %table#order.list
        %thead
          %tr
            %th Name
            %th
            %th Lieferantin
            %th{:style => "width:5em;"} Einheit
            %th{:style => "width:4.5em;"} Preis
            %th(style="width:20px") Verfügbar
            %th#col_required(style="width:110px") Menge
            %th Summe
        %tbody
          - total = 0
          - i = 0
          - for category_name, order_articles in @articles_grouped_by_category
            %tr{:style => "background-color:#EFEFEF"}
              %td{:style => "text-align:left"}
                %b=h category_name
              %td{:colspan => "9"}
            - for order_article in order_articles
              - article_total = @price[i] * @quantity[i]
              - total += article_total
              %tr{:class => cycle('even', 'odd', :name => 'articles')+' order-article', :valign => "top"}
                %td.name= order_article.article.name
                %td=h order_article.article.origin
                %td=h truncate order_article.article.supplier.name, :length => 11
                %td=h order_article.article.unit
                %td= number_to_currency @price[i]
                %td= @quantity_available[i]
                %td{:style => "text-align:right;"}
                  = hidden_field_tag "ordered[#{order_article.id}][quantity]", @quantity[i], :id => "q_#{i}", :size => "2"
                  %span.used{:id => "q_used_#{i}"}= @used_quantity[i]
                  = button_to_function('+', "increaseStockQuantity(#{i})")
                  = button_to_function('-', "decreaseStockQuantity(#{i})")

                %td{:id => "td_price_#{i}", :style => "text-align:right; padding-right:10px; width:4em"}
                  %span{:id => "price_#{i}_display"}= number_to_currency(article_total, :unit => "")
                  €
                  .article-info
                    %h3= order_article.article.name
                    .right
                      Gesamt-Einheiten:
                      %span{:id => "q_total_#{i}"}= @quantity[i] + @others_quantity[i]
                      %br/
                    .left
                      Hersteller:
                      = order_article.article.manufacturer
                      %br/
                      Gebinde:
                      = order_article.article.quantity_available
                      *
                      = order_article.article.unit
                      %br/
                      Notiz:
                      = order_article.article.note
                      %br/
              - i = i + 1
      = render "order_footer", :total => total

%script{:type => "text/" + "javascript"}
  // preset data
  - for i in 0...@price.size
    = "addData(#{@price[i]}, 1, #{@price[i] * @quantity[i]}, #{@others_quantity[i]}, 0, #{@used_quantity[i]}, #{@quantity_available[i]});"
    = "setGroupBalance(#{@availableFunds});"
    // localization
    setDecimalSeparator(",");
    // initialize javascript
    updateBalance();