2012-10-17 20:45:52 +02:00
|
|
|
- content_for :javascript do
|
2011-05-27 14:09:01 +02:00
|
|
|
:javascript
|
|
|
|
$(function() {
|
|
|
|
$('.destroy_stock_change').live('click', function() {
|
2013-06-13 23:33:24 +02:00
|
|
|
$(this).prev('input').val('1'); // check for destruction
|
|
|
|
|
|
|
|
var stock_change = $(this).closest('tr');
|
|
|
|
stock_change.hide(); // do not remove (to ensure destruction)
|
|
|
|
unmark_article_unavailable_for_delivery( stock_change.data('id') );
|
2011-05-27 14:09:01 +02:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.remove_new_stock_change').live('click', function() {
|
2013-06-13 23:33:24 +02:00
|
|
|
var stock_change = $(this).closest('tr');
|
|
|
|
stock_change.remove();
|
|
|
|
unmark_article_unavailable_for_delivery( stock_change.data('id') );
|
2011-05-27 14:09:01 +02:00
|
|
|
return false;
|
|
|
|
})
|
|
|
|
});
|
2013-06-13 23:33:24 +02:00
|
|
|
function mark_article_unavailable_for_delivery(stock_article_id) {
|
|
|
|
var articleTr = $('#stock_article_' + stock_article_id);
|
|
|
|
articleTr.addClass('unavailable');
|
|
|
|
$('.button-add-stock-change', articleTr).attr('disabled', 'disabled');
|
|
|
|
}
|
|
|
|
function unmark_article_unavailable_for_delivery(stock_article_id) {
|
|
|
|
var articleTr = $('#stock_article_' + stock_article_id);
|
|
|
|
articleTr.removeClass('unavailable');
|
|
|
|
$('.button-add-stock-change', articleTr).removeAttr('disabled');
|
|
|
|
}
|
|
|
|
function is_article_unavailable_for_delivery(stock_article_id) {
|
|
|
|
var articleTr = $('#stock_article_' + stock_article_id);
|
|
|
|
return articleTr.hasClass('unavailable');
|
|
|
|
}
|
2011-05-27 14:09:01 +02:00
|
|
|
|
2013-06-13 23:33:24 +02:00
|
|
|
-# remove validate true for the form, because it disabled html5 validation
|
|
|
|
-# is there anything broken with the simple_form validation? (bootstrap issue?)
|
|
|
|
= simple_form_for [@supplier, @delivery] do |f|
|
2013-01-26 15:57:29 +01:00
|
|
|
= f.hidden_field :supplier_id
|
2013-06-13 23:33:24 +02:00
|
|
|
.row-fluid
|
|
|
|
|
|
|
|
.span6
|
|
|
|
%h2 #{t '.title_select_stock_articles'}
|
|
|
|
.well.well-small
|
|
|
|
.btn-toolbar
|
|
|
|
.btn-group
|
|
|
|
= link_to t('.new_stock_article'), new_stock_article_supplier_deliveries_path(@supplier), remote: true, class: 'btn'
|
|
|
|
%table.table.table-condensed.table-hover#stock_articles_for_adding
|
|
|
|
%thead
|
|
|
|
%tr
|
|
|
|
%th
|
|
|
|
= t '.article'
|
|
|
|
%span.sorter-bar.default-sort-asc{:data => {'compare-function' => 'compareText', 'sort-criterion' => 'sort-by-name'}}
|
|
|
|
%th= t '.unit'
|
2013-06-13 23:51:37 +02:00
|
|
|
%th= t '.price'
|
2013-06-13 23:33:24 +02:00
|
|
|
%th= t '.vat'
|
|
|
|
%th
|
|
|
|
= t '.category'
|
|
|
|
%span.sorter-bar{:data => {'compare-function' => 'compareText', 'sort-criterion' => 'sort-by-category'}}
|
|
|
|
%th= t '.actions'
|
|
|
|
%tbody
|
|
|
|
- for article in stock_articles_for_table(@supplier)
|
|
|
|
= render :partial => 'stock_article_for_adding', :locals => {:article => article}
|
|
|
|
|
|
|
|
.span6
|
|
|
|
%h2 #{t '.title_fill_quantities'}
|
|
|
|
%table.table.table-condensed#stock_changes
|
|
|
|
%thead
|
|
|
|
%tr
|
|
|
|
%th
|
|
|
|
= t '.article'
|
|
|
|
%span.sorter-bar.default-sort-asc{:data => {'compare-function' => 'compareText', 'sort-criterion' => 'sort-by-name'}}
|
|
|
|
%th= t '.price_per_unit'
|
|
|
|
%th= t '.quantity'
|
|
|
|
%th= t '.actions'
|
|
|
|
%tbody
|
2013-06-13 23:51:37 +02:00
|
|
|
-# see also the partial 'stock_change' which is used for AJAX updates!
|
|
|
|
-# see also the partial 'stock_change' which is used for AJAX updates!
|
|
|
|
-# see also the partial 'stock_change' which is used for AJAX updates!
|
2013-06-13 23:33:24 +02:00
|
|
|
= f.fields_for :stock_changes do |stock_change_form|
|
|
|
|
- stock_change = stock_change_form.object
|
|
|
|
%tr{:id => "stock_change_stock_article_#{stock_change.stock_article.id}", :data => {:id => stock_change.stock_article.id}}
|
|
|
|
%td.sort-by-name
|
|
|
|
= stock_change_form.hidden_field :stock_article_id
|
|
|
|
%span.stock_article_name= stock_change.stock_article.name
|
|
|
|
%td.numeric.price-per-unit #{number_to_currency stock_change.stock_article.price}/#{stock_change.stock_article.unit}
|
|
|
|
%td= stock_change_form.text_field :quantity, :size => 5, :autocomplete => 'off'
|
|
|
|
%td
|
|
|
|
= stock_change_form.hidden_field :_destroy
|
|
|
|
= link_to t('.remove_article'), "#", :class => 'destroy_stock_change btn btn-small'
|
|
|
|
|
|
|
|
%h2 #{t '.title_finish_delivery'}
|
|
|
|
= f.input :delivered_on, as: :date_picker
|
|
|
|
= f.input :note, input_html: {size: '35x4'}
|
|
|
|
.form-actions
|
|
|
|
= f.submit class: 'btn btn-primary'
|
|
|
|
= link_to t('ui.or_cancel'), supplier_deliveries_path(@supplier)
|