$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(),
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(),
+ qty_as_number: $row.find("[name$=qty_as_number]").val(),
+ stock: $row.find("[name$=stock_info]").val(),
item_id: id,
row: $row.attr("id"),
},
});
};
+ 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,
+ row: row
+ }),
+ (data) => {
+ $("#" + row + " .data-stock-info").val(data);
+ $("#stock_in_out_dialog").dialog("close");
+ }
+ );
+ };
+
ns.print = function() {
$('#print_options').dialog('close');