Revision 9ef0dcd3
Von Sven Schöling vor etwa 3 Jahren hinzugefügt
SL/Controller/DeliveryOrder.pm | ||
---|---|---|
use parent qw(SL::Controller::Base);
|
||
|
||
use SL::Helper::Flash qw(flash_later);
|
||
use SL::Helper::Number qw(_format_number_units);
|
||
use SL::Helper::Number qw(_format_number_units _parse_number);
|
||
use SL::Presenter::Tag qw(select_tag hidden_tag div_tag);
|
||
use SL::Locale::String qw(t8);
|
||
use SL::SessionFile::Random;
|
||
... | ... | |
|
||
}
|
||
|
||
sub action_stock_in_out_dialog {
|
||
my ($self) = @_;
|
||
|
||
my $part = SL::DB::Part->load_cached($::form->{parts_id}) or die "need parts_id";
|
||
my $stock = $::form->{stock};
|
||
my $unit = $::form->{unit};
|
||
my $qty = _parse_number($::form->{qty_as_number});
|
||
|
||
my $inout = $self->type_data->transfer;
|
||
|
||
my @contents = DO->get_item_availability(parts_id => $part->id);
|
||
my $stock_info = DO->unpack_stock_information(packed => $stock);
|
||
|
||
$self->merge_stock_data($stock_info, \@contents, $part);
|
||
|
||
$self->render("delivery_order/stock_dialog", { layout => 0 },
|
||
WHCONTENTS => $self->order->delivered ? $stock_info : \@contents,
|
||
part => $part,
|
||
do_qty => $qty,
|
||
do_unit => $unit,
|
||
);
|
||
|
||
}
|
||
|
||
sub merge_stock_data {
|
||
my ($self, $stock_info, $contents, $part) = @_;
|
||
# TODO rewrite to mapping
|
||
|
||
if (!$self->order->delivered) {
|
||
for my $row (@$contents) {
|
||
$row->{available_qty} = _format_number_units($row->{qty}, $row->{unit}, $part->unit);
|
||
|
||
for my $sinfo (@{ $stock_info }) {
|
||
next if $row->{bin_id} != $sinfo->{bin_id} ||
|
||
$row->{warehouse_id} != $sinfo->{warehouse_id} ||
|
||
$row->{chargenumber} ne $sinfo->{chargenumber} ||
|
||
$row->{bestbefore} ne $sinfo->{bestbefore};
|
||
|
||
$row->{"stock_$_"} = $sinfo->{$_}
|
||
for qw(qty unit error delivery_order_items_stock_id);
|
||
}
|
||
}
|
||
|
||
} else {
|
||
for my $sinfo (@{ $stock_info }) {
|
||
my $bin = SL::DB::Bin->load_cached($sinfo->{bin_id});
|
||
$sinfo->{warehouse_description} = $bin->warehouse->description;
|
||
$sinfo->{bin_description} = $bin->escription;
|
||
map { $sinfo->{"stock_$_"} = $sinfo->{$_} } qw(qty unit);
|
||
}
|
||
}
|
||
}
|
||
|
||
# load the second row for one or more items
|
||
#
|
||
# This action gets the html code for all items second rows by rendering a template for
|
js/kivi.DeliveryOrder.js | ||
---|---|---|
});
|
||
};
|
||
|
||
ns.open_stock_in_out_dialog = function(clicked, in_out) {
|
||
var $row = $(clicked).parents("tbody").first();
|
||
var id = $row.find('[name="orderitem_ids[+]"]').val();
|
||
$row.uniqueId();
|
||
|
||
kivi.popup_dialog({
|
||
id: "stock_in_out",
|
||
url: "controller.pl?action=DeliveryOrder/stock_in_out_dialog",
|
||
data: {
|
||
id: $("#id").val(),
|
||
type: $("#type").val(),
|
||
parts_id: $row.find("[name$=parts_id]").val(),
|
||
unit: $row.find("[name$=unit]").val(),
|
||
qty_as_number: $("qty_" + id).val(),
|
||
stock: $("stock_" + id).val(),
|
||
item_id: id,
|
||
row: $row.attr("id"),
|
||
},
|
||
dialog: { title: kivi.t8('Transfer stock') }
|
||
});
|
||
};
|
||
|
||
ns.print = function() {
|
||
$('#print_options').dialog('close');
|
||
|
templates/webpages/delivery_order/stock_dialog.html | ||
---|---|---|
[%- USE T8 %]
|
||
[%- USE HTML %]
|
||
[%- USE LxERP %]
|
||
[%- IF delivered %]
|
||
[%- SET RO = ' readonly' %]
|
||
[%- END %]
|
||
|
||
<table>
|
||
<tr>
|
||
<td>[% 'Part Number' | $T8 %]</td>
|
||
<td>[% part.partnumber | html %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% 'Description' | $T8 %]</td>
|
||
<td>[% part.description | html %]</td>
|
||
</tr>
|
||
<tr>
|
||
<td>[% 'Qty according to delivery order' | $T8 %]</td>
|
||
<td>[% LxERP.format_amount(do_qty) %] [% do_unit | html %]</td>
|
||
</tr>
|
||
</table>
|
||
|
||
[%- UNLESS WHCONTENTS.size %]
|
||
<p>[% 'There are no items in stock.' | $T8 %]</p>
|
||
[%- ELSE %]
|
||
|
||
[% L.hidden_tag("in_out", in_out) %]
|
||
[% L.hidden_tag("parts_id", parts_id) %]
|
||
[% L.hidden_tag("do_qty", do_qty) %]
|
||
[% L.hidden_tag("do_unit", do_unit) %]
|
||
[% L.hidden_tag("row", row) %]
|
||
|
||
<p>
|
||
<table>
|
||
<tr class="listheading">
|
||
<th> </th>
|
||
<th>[% 'Warehouse' | $T8 %]</th>
|
||
<th>[% 'Bin' | $T8 %]</th>
|
||
<th>[% 'Charge Number' | $T8 %]</th>
|
||
[% IF INSTANCE_CONF.get_show_bestbefore %]
|
||
<th>[% 'Best Before' | $T8 %]</th>
|
||
[% END %]
|
||
[%- UNLESS delivered %]
|
||
<th align="right">[% 'Available qty' | $T8 %]</th>
|
||
[%- END %]
|
||
<th align="right">[% 'Qty' | $T8 %]</th>
|
||
<th align="right">[% 'Unit' | $T8 %]</th>
|
||
</tr>
|
||
|
||
[%- FOREACH row = WHCONTENTS %]
|
||
<tr [% IF row.stock_error %] class="error"[% ELSE %]class="listrow"[% END %]>
|
||
<td>[% loop.count %]</td>
|
||
<td>[% row.warehousedescription | html %]</td>
|
||
<td>[% row.bindescription | html %]</td>
|
||
<td>[% row.chargenumber | html %]</td>
|
||
[% IF INSTANCE_CONF.get_show_bestbefore %]
|
||
<td>[% row.bestbefore | html %]</td>
|
||
[% END %]
|
||
|
||
[%- IF delivered %]
|
||
|
||
<td>[% LxERP.format_amount(row.stock_qty) | html %]</td>
|
||
<td>[% row.stock_unit | html %]</td>
|
||
|
||
[%- ELSE %]
|
||
|
||
<td>[% row.available_qty | html %]</td>
|
||
<td><input name="qty_[% loop.count %]" style="text-align: right;" size="12"
|
||
[%- IF row.stock_qty %]
|
||
value="[% LxERP.format_amount(row.stock_qty) %]"
|
||
[%- ELSIF ((WHCONTENTS.size == 1) && (!row.stock_qty)) %]
|
||
value="[% do_qty | html %]"
|
||
[%- END %]
|
||
></td>
|
||
<td>
|
||
[% L.select_tag("unit_" _ loop.count, part.unit_obj.convertible_units, value_key="name", default=row.stock_unit) %]
|
||
</td>
|
||
|
||
[%- END %]
|
||
</tr>
|
||
|
||
<input type="hidden" name="warehouse_id_[% loop.count %]" value="[% HTML.escape(row.warehouse_id) %]">
|
||
<input type="hidden" name="bin_id_[% loop.count %]" value="[% HTML.escape(row.bin_id) %]">
|
||
<input type="hidden" name="chargenumber_[% loop.count %]" value="[% HTML.escape(row.chargenumber) %]">
|
||
<input type="hidden" name="delivery_order_items_stock_id_[% loop.count %]" value="[% HTML.escape(row.stock_delivery_order_items_stock_id) %]">
|
||
[% IF INSTANCE_CONF.get_show_bestbefore %]
|
||
<input type="hidden" name="bestbefore_[% loop.count %]" value="[% HTML.escape(row.bestbefore) %]">
|
||
[% END %]
|
||
[%- END %]
|
||
</table>
|
||
</p>
|
||
|
||
<hr size="3" noshade>
|
||
|
||
<p>
|
||
[%- IF !delivered %]
|
||
[% L.button_tag('kivi.DeliveryOrder.save_updated_stock()', 'Save') | $T8 %]
|
||
[%- END %]
|
||
</p>
|
||
|
||
[%- END %]
|
||
</form>
|
||
|
||
|
templates/webpages/delivery_order/tabs/_row.html | ||
---|---|---|
|
||
<td>
|
||
<span id="stock_[% ID %]">[% SELF.calculate_stock_in_out(ITEM) %]</span>
|
||
<input type=hidden id='stock_in_out_qty_matches_[% ID %]' value='$matches'>
|
||
<input type="button" onclick="kivi.DeliveryOrder.open_stock_in_out_window('[% in_out %]', ID);" value="?">
|
||
[% P.button_tag("kivi.DeliveryOrder.open_stock_in_out_dialog(this, '" _ in_out _"')", "?") %]
|
||
</td>
|
||
</tr>
|
||
|
Auch abrufbar als: Unified diff
DeliveryOrder: erste Version Lager-Dialog