move receive screen to orders
This commit is contained in:
parent
94b4454a1b
commit
d299fa4870
10 changed files with 75 additions and 79 deletions
|
|
@ -1,21 +0,0 @@
|
|||
= fields_for 'order_articles', order_article, index: order_article.id do |form|
|
||||
%tr{class: "#{cycle('even', 'odd', name: 'articles')} order-article", valign: "top"}
|
||||
- order_title = []
|
||||
- order_title.append Article.human_attribute_name(:manufacturer)+': ' + order_article.article.manufacturer unless order_article.article.manufacturer.to_s.empty?
|
||||
- order_title.append Article.human_attribute_name(:note)+': ' + order_article.article.note unless order_article.article.note.to_s.empty?
|
||||
- units_expected = (order_article.units_billed or order_article.units_to_order)
|
||||
%td= order_article.article.order_number
|
||||
%td.name{title: order_title.join("\n")}= order_article.article.name
|
||||
%td #{order_article.article.unit_quantity} × #{order_article.article.unit}
|
||||
%td #{order_article.quantity} + #{order_article.tolerance}
|
||||
%td
|
||||
= order_article.units_to_order
|
||||
%i.package pkg
|
||||
%td
|
||||
- unless order_article.units_billed.nil?
|
||||
= order_article.units_billed
|
||||
%i.package pkg
|
||||
%td
|
||||
= form.text_field :units_received, class: 'input-nano package', data: {'units-expected' => units_expected}
|
||||
/ TODO add almost invisible text_field for entering single units
|
||||
%td.units_delta
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
- new_article_data = articles_for_select2(@order.articles, @order_articles.map(&:article_id)) {|a| "#{a.name} (#{a.unit_quantity}⨯#{a.unit})" }
|
||||
- content_for :javascript do
|
||||
:javascript
|
||||
|
||||
var new_article_data = #{new_article_data.to_json};
|
||||
|
||||
function update_delta(input) {
|
||||
var units = $(input).val();
|
||||
var expected = $(input).data('units-expected');
|
||||
var html;
|
||||
|
||||
if (units.replace(/\s/g,"")=="") {
|
||||
// no value
|
||||
html = '';
|
||||
} else if (isNaN(units)) {
|
||||
html = '<i class="icon-remove" style="color: red"></i>';
|
||||
} else if (units == expected) {
|
||||
// equal value
|
||||
html = '<i class="icon-ok" style="color: green"></i>';
|
||||
} else if (units < expected) {
|
||||
html = '<span style="color: red">- '+(expected-units)+'</span>';
|
||||
} else /*if (units> expected)*/ {
|
||||
html = '<span style="color: green">+ '+(units-expected)+'</span>';
|
||||
}
|
||||
|
||||
$(input).closest('tr').find('.units_delta').html(html);
|
||||
}
|
||||
|
||||
$(document).on('change', 'input[data-units-expected]', function() {
|
||||
update_delta(this);
|
||||
});
|
||||
|
||||
$(function() {
|
||||
$('input[data-units-expected]').each(function() {
|
||||
update_delta(this);
|
||||
});
|
||||
|
||||
init_add_article('#add_article');
|
||||
});
|
||||
|
||||
function init_add_article(sel) {
|
||||
$(sel).removeAttr('disabled').select2({
|
||||
placeholder: '#{t '.add_article'}',
|
||||
data: new_article_data,
|
||||
// TODO implement adding a new article, like in deliveries
|
||||
}).on('change', function(e) {
|
||||
var selectedArticle = $(e.currentTarget).select2('data');
|
||||
if(!selectedArticle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: '#{finance_receive_add_article_path(@order)}',
|
||||
type: 'get',
|
||||
data: {article_id: selectedArticle.id},
|
||||
contentType: 'application/json; charset=UTF-8'
|
||||
});
|
||||
// clear selection
|
||||
$('#add_article').select2('data', null);
|
||||
// remove newly added item from list of items
|
||||
new_article_data = $.grep(new_article_data, function(el, i) {
|
||||
return el.id != selectedArticle.id;
|
||||
});
|
||||
init_add_article(sel)
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
%table.ordered-articles.table.table-striped.stupidtable
|
||||
%thead
|
||||
%tr
|
||||
%th.sort{:data => {:sort => 'string'}}= t('.number')
|
||||
%th.sort{:data => {:sort => 'string'}}= t('.article')
|
||||
%th= heading_helper GroupOrderArticle, :units
|
||||
%th Members
|
||||
%th Ordered
|
||||
%th Invoice
|
||||
%th Received
|
||||
%th
|
||||
%tbody#result_table
|
||||
- @order_articles.each do |order_article|
|
||||
= render :partial => 'edit_article', :locals => {:order_article => order_article}
|
||||
%tfoot
|
||||
%tr
|
||||
%th{:colspan => 8}
|
||||
%input#add_article{:style => 'width: 500px;'}
|
||||
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
$('div.container-fluid').prepend(
|
||||
'<%= j(render(:partial => 'shared/alert_success', :locals => {:alert_message => t('.notice', :name => @order_article.article.name)})) %>'
|
||||
);
|
||||
|
||||
(function() {
|
||||
$('.ordered-articles tr').removeClass('success');
|
||||
|
||||
var article_for_adding = $(
|
||||
'<%= j(render(:partial => 'edit_article', :locals => {:order_article => @order_article})) %>'
|
||||
).addClass('success');
|
||||
|
||||
$('.ordered-articles tbody').append(article_for_adding);
|
||||
updateSort('.ordered-articles');
|
||||
|
||||
$('#order_articles_<%= @order_article.id %>_units_received').focus();
|
||||
})();
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
- title "Receiving #{@order.name}"
|
||||
|
||||
= form_tag(finance_receive_path(@order), :method => :put) do
|
||||
%section#results
|
||||
= render 'edit_articles'
|
||||
|
||||
.form-actions
|
||||
.pull-left
|
||||
Surplus to
|
||||
= label_tag :rest_to_tolerance, class: 'inline' do
|
||||
= check_box_tag :rest_to_tolerance, 1, true
|
||||
member tolerance,
|
||||
%span{style: 'color: grey'}
|
||||
and
|
||||
= label_tag :rest_to_stock, class: 'inline' do
|
||||
= check_box_tag :rest_to_stock, 1, false, disabled: true
|
||||
stock
|
||||
|
||||
.pull-right
|
||||
= submit_tag t('.submit'), class: 'btn btn-primary'
|
||||
= link_to t('ui.or_cancel'), finance_order_index_path
|
||||
|
||||
%p= link_to_top
|
||||
Loading…
Add table
Add a link
Reference in a new issue