Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 18a627a6

Von Sven Schöling vor etwa 3 Jahren hinzugefügt

  • ID 18a627a60525c399009c39b4e6ce7cf5ade46a87
  • Vorgänger 8496b280
  • Nachfolger 241a16d8

DeliveryOrder: serialize stock to yaml

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
# safety
__PACKAGE__->run_before('check_auth');
__PACKAGE__->run_before('check_auth',
except => [ qw(pack_stock_information) ]);
__PACKAGE__->run_before('get_unalterable_data',
only => [ qw(save save_as_new save_and_delivery_order save_and_invoice save_and_ap_transaction
......
part => $part,
do_qty => $qty,
do_unit => $unit,
delivered => $self->order->delivered,
);
}
# we're using the old YAML based stock packing, but don't want to do this in
# the frontend so we're doing a tiny roundtrip to the backend, back the info in
# perl, serve it back to the frontend and store it in the DOM there
sub action_pack_stock_information {
my ($self) = @_;
my $stock_info = $::form->{stock_info};
my $yaml = SL::YAML::Dump($stock_info);
$self->render(\$yaml, { layout => 0, process => 0 });
}
sub merge_stock_data {
js/kivi.DeliveryOrder.js
$row.uniqueId();
kivi.popup_dialog({
id: "stock_in_out",
id: "stock_in_out_dialog",
url: "controller.pl?action=DeliveryOrder/stock_in_out_dialog",
data: {
id: $("#id").val(),
......
});
};
ns.save_updated_stock = function() {
// stock information is saved in DOM as a yaml dump.
// we don't want to do this in javascript so we do a tiny roundtrip to the backend
let data = [];
$("#stock-in-out-table tr.listrow").each((i,row) => {
data.push({
qty: kivi.parse_amount($(row).find(".data-qty").val()),
warehouse_id: $(row).find(".data-warehouse-id").val(),
bin_id: $(row).find(".data-bin-id").val(),
chargenumber: $(row).find(".data-chargenumber").val(),
bestbefore: $(row).find(".data-bestbefore").val(),
unit: $(row).find(".data-unit").val(),
delivery_order_items_stock_id: $(row).find(".data-stock-id").val(),
});
});
let row = $(".data-row").val();
$.post("controller.pl", kivi.serialize({
action: "DeliveryOrder/pack_stock_information",
stock_info: data
}),
(data) => {
$("[name=stock_info_" + row + "]").val(data);
$("#stock_in_out_dialog").dialog("close");
}
);
};
ns.print = function() {
$('#print_options').dialog('close');
templates/webpages/delivery_order/stock_dialog.html
[%- USE T8 %]
[%- USE HTML %]
[%- USE LxERP %]
[%- USE L %]
[%- IF delivered %]
[%- SET RO = ' readonly' %]
[%- END %]
......
[% 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) %]
[% L.hidden_tag("row", row, class="data-row") %]
<p>
<table>
<table id="stock-in-out-table">
<tr class="listheading">
<th>&nbsp;</th>
<th>[% 'Warehouse' | $T8 %]</th>
......
[%- IF delivered %]
<td>[% LxERP.format_amount(row.stock_qty) | html %]</td>
<td>[% row.stock_unit | html %]</td>
<td>
[% row.stock_unit | html %]
[% L.hidden_tag("unit", row.stock_unit, class="data-unit") %]
</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>
[% L.input_tag("qty", row.stock_qty ? LxERP.format_amount(row.stock_qty)
: (WHCONTENTS.size == 1) && (!row.stock_qty) ? LxERP.format_amount(do_qty)
: "", class="numeric data-qty", size="12") %]</td>
<td>[% L.select_tag("unit_" _ loop.count, part.unit_obj.convertible_units, value_key="name", default=row.stock_unit, class="data-unit") %]</td>
[%- END %]
<td style="display:none">
[% L.hidden_tag("warehouse_id", row.warehouse_id, class="data-warehouse-id") %]
[% L.hidden_tag("bin_id", row.bin_id, class="data-bin-id") %]
[% L.hidden_tag("chargenumber", row.chargenumber, class="data-chargenumber") %]
[% L.hidden_tag("delivery_order_items_stock_id", row.delivery_order_items_stock_id, class="data-stock-id") %]
[% L.hidden_tag("bestbefore", row.bestbefore, class="data-bestbefore") IF INSTANCE_CONF.get_show_bestbefore %]
</td>
</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>
<p>[% L.button_tag('kivi.DeliveryOrder.save_updated_stock()', LxERP.t8('Save')) IF !delivered %]</p>
[%- END %]
</form>

Auch abrufbar als: Unified diff