foodsoft/app/views/orders/_form.html.haml
Patrick Gansterer 2557645f4f Rails 5.0
2020-09-05 14:40:11 +02:00

73 lines
3.2 KiB
Text

= simple_form_for @order do |f|
= f.hidden_field :supplier_id
.fold-line
= f.input :starts, as: :date_picker_time
= f.input :boxfill, as: :date_picker_time if @order.is_boxfill_useful?
= f.input :ends, as: :date_picker_time
= f.input :pickup, as: :date_picker, input_html: {class: 'input-small'}
= f.input :end_action, collection: Order.end_actions,include_blank: false,
input_html: {class: 'input-xxlarge'}, value_method: ->(k){ k.first },
label_method: ->(k){ t("activerecord.attributes.order.end_actions.#{k.first}") }
= f.input :note, input_html: {rows: 2, class: 'input-xxlarge'}
%h2= t '.title'
- if @order.errors.has_key?(:articles)
.alert.alert-error
= @order.errors.messages[:articles].join(" ")
%table.table.table-hover#articleList
%tr
%th= check_box_tag 'checkall', "1", false, { 'data-check-all' => '#articleList' }
%th= heading_helper Article, :name
%th= heading_helper Article, :note
- if @order.stockit?
%th= t '.stockit'
- else
%th= heading_helper Article, :origin
%th= heading_helper Article, :manufacturer
%th= heading_helper Article, :units
%th= t '.prices'
- for category_name, articles in @order.articles_for_ordering
%tr.article-category
%td
%td{:colspan => "6", :style => "text-align:left"}
= category_name
%i.icon-tag
- for article in articles
/ check if the article is selected or has an error
- included = @order.article_ids.include?(article.id.to_s)
- row_class = ''
- if included
- row_class = 'selected'
- elsif @order.erroneous_article_ids.include?(article.id)
- row_class = 'error'
%tr{class: row_class, id: article.id}
%td= check_box_tag "order[article_ids][]", article.id, included, :id => "checkbox_#{article.id}"
%td.click-me{'data-check-this' => "#checkbox_#{article.id}"}= article.name
%td= truncate article.note, length: 25, tooltip: true
- if @order.stockit?
%td= "#{article.quantity_available} * #{article.unit}"
- else
%td= truncate article.origin, length: 15, tooltip: true
%td= truncate article.manufacturer, length: 15, tooltip: true
%td
= article.unit
- if article.unit_quantity > 1
%span{style: 'color: grey'} × #{article.unit_quantity}#{pkg_helper_icon}
%td= "#{number_to_currency(article.price)} / #{number_to_currency(article.fc_price)}"
%tr
%td
= check_box_tag 'checkall', "1", false, { 'data-check-all' => '#articleList' }
-# also when all are deselected, make sure this parameter is sent (controller removes empty values again)
= hidden_field_tag "order[article_ids][]", nil
%td{:colspan => "6"}= t '.select_all'
- if (@template_orders && !@template_orders.empty?)
= render :partial => 'template_orders_script'
.form-actions
= f.submit class: 'btn'
= link_to t('ui.or_cancel'), orders_path
- unless @order.erroneous_article_ids.empty?
 
= check_box_tag 'order[ignore_warnings]'
= t '.ignore_warnings'