2011-05-19 22:35:13 +02:00
|
|
|
= simple_form_for [@supplier, @article], :validate => true, :remote => true do |f|
|
2012-10-19 01:12:47 +02:00
|
|
|
= f.hidden_field :shared_updated_on
|
|
|
|
= f.hidden_field :supplier_id
|
|
|
|
.modal-header
|
2013-04-12 15:45:24 +02:00
|
|
|
= link_to t('ui.marks.close').html_safe, '#', class: 'close', data: {dismiss: 'modal'}
|
2013-12-06 12:34:14 +01:00
|
|
|
%h3= @article.new_record? ? t('.title_new') : t('.title_edit')
|
2012-10-19 01:12:47 +02:00
|
|
|
.modal-body
|
2013-12-06 14:33:51 +01:00
|
|
|
= f.input :availability
|
2012-10-19 01:12:47 +02:00
|
|
|
= f.input :name
|
2013-12-10 16:41:26 +01:00
|
|
|
.twocol
|
|
|
|
= f.input :unit_quantity, label: Article.human_attribute_name(:unit),
|
|
|
|
input_html: {class: 'input-mini', title: Article.human_attribute_name(:unit_quantity)}
|
|
|
|
= f.input :unit, label: '×'.html_safe,
|
|
|
|
input_html: {class: 'input-mini', title: Article.human_attribute_name(:unit)}
|
2013-11-20 23:40:38 +01:00
|
|
|
|
2012-10-19 01:12:47 +02:00
|
|
|
= f.input :note
|
|
|
|
= f.association :article_category
|
2013-11-20 23:40:38 +01:00
|
|
|
/ TODO labels
|
|
|
|
|
2013-12-10 16:41:26 +01:00
|
|
|
.twocol
|
|
|
|
= f.input :price do
|
2013-11-20 23:40:38 +01:00
|
|
|
.input-prepend
|
|
|
|
%span.add-on= t 'number.currency.format.unit'
|
|
|
|
= f.input_field :price, class: 'input-mini'
|
2013-12-10 16:41:26 +01:00
|
|
|
= f.input :tax do
|
|
|
|
.input-append
|
|
|
|
= f.input_field :tax, class: 'input-mini'
|
|
|
|
%span.add-on %
|
|
|
|
= f.input :deposit do
|
2013-11-20 23:40:38 +01:00
|
|
|
.input-prepend
|
|
|
|
%span.add-on= t 'number.currency.format.unit'
|
|
|
|
= f.input_field :deposit, class: 'input-mini'
|
2013-12-10 16:41:26 +01:00
|
|
|
.control-group
|
|
|
|
%label.control-label{for: 'article_fc_price'}
|
2013-12-06 12:19:13 +01:00
|
|
|
= Article.human_attribute_name(:fc_price)
|
2013-12-10 16:41:26 +01:00
|
|
|
.controls.control-text#article_fc_price
|
|
|
|
= number_to_currency(@article.fc_price) rescue nil
|
2009-01-16 16:19:26 +01:00
|
|
|
|
2013-12-06 14:33:51 +01:00
|
|
|
= f.input :origin
|
|
|
|
= f.input :manufacturer
|
2012-10-19 01:12:47 +02:00
|
|
|
= f.input :order_number
|
|
|
|
.modal-footer
|
2013-04-12 15:45:24 +02:00
|
|
|
= link_to t('ui.close'), '#', class: 'btn', data: {dismiss: 'modal'}
|
2012-10-19 01:12:47 +02:00
|
|
|
= f.submit class: 'btn btn-primary'
|
2009-01-16 16:19:26 +01:00
|
|
|
|
2013-12-06 12:19:13 +01:00
|
|
|
:javascript
|
|
|
|
var form = $('form.edit_article, form.new_article');
|
2013-12-10 13:30:15 +01:00
|
|
|
$('#article_price, #article_tax, #article_deposit', form).on('change keyup', function() {
|
2013-12-06 12:19:13 +01:00
|
|
|
var price = parseFloat($('#article_price', form).val());
|
|
|
|
var tax = parseFloat($('#article_tax', form).val());
|
|
|
|
var deposit = parseFloat($('#article_deposit', form).val());
|
|
|
|
// Article#gross_price and Article#fc_price
|
|
|
|
var gross_price = (price + deposit) * (tax / 100 + 1);
|
|
|
|
var fc_price = gross_price * (#{FoodsoftConfig[:price_markup].to_f} / 100 + 1);
|
2013-12-10 16:41:26 +01:00
|
|
|
$('#article_fc_price').html($.isNumeric(fc_price) ? I18n.l("currency", fc_price) : '…');
|
2013-12-06 12:19:13 +01:00
|
|
|
});
|