Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 18a627a6

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

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

DeliveryOrder: serialize stock to yaml

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
53 53

  
54 54

  
55 55
# safety
56
__PACKAGE__->run_before('check_auth');
56
__PACKAGE__->run_before('check_auth',
57
                        except => [ qw(pack_stock_information) ]);
57 58

  
58 59
__PACKAGE__->run_before('get_unalterable_data',
59 60
                        only => [ qw(save save_as_new save_and_delivery_order save_and_invoice save_and_ap_transaction
......
906 907
    part  => $part,
907 908
    do_qty => $qty,
908 909
    do_unit => $unit,
910
    delivered => $self->order->delivered,
909 911
  );
912
}
913

  
914
# we're using the old YAML based stock packing, but don't want to do this in
915
# the frontend so we're doing a tiny roundtrip to the backend, back the info in
916
# perl, serve it back to the frontend and store it in the DOM there
917
sub action_pack_stock_information {
918
  my ($self) = @_;
919

  
920
  my $stock_info = $::form->{stock_info};
921
  my $yaml = SL::YAML::Dump($stock_info);
910 922

  
923
  $self->render(\$yaml, { layout => 0, process => 0 });
911 924
}
912 925

  
913 926
sub merge_stock_data {
js/kivi.DeliveryOrder.js
84 84
    $row.uniqueId();
85 85

  
86 86
    kivi.popup_dialog({
87
      id: "stock_in_out",
87
      id: "stock_in_out_dialog",
88 88
      url: "controller.pl?action=DeliveryOrder/stock_in_out_dialog",
89 89
      data: {
90 90
        id:            $("#id").val(),
......
100 100
    });
101 101
  };
102 102

  
103
  ns.save_updated_stock = function() {
104
    // stock information is saved in DOM as a yaml dump.
105
    // we don't want to do this in javascript so we do a tiny roundtrip to the backend
106

  
107
    let data = [];
108
    $("#stock-in-out-table tr.listrow").each((i,row) => {
109
      data.push({
110
        qty:         kivi.parse_amount($(row).find(".data-qty").val()),
111
        warehouse_id:                  $(row).find(".data-warehouse-id").val(),
112
        bin_id:                        $(row).find(".data-bin-id").val(),
113
        chargenumber:                  $(row).find(".data-chargenumber").val(),
114
        bestbefore:                    $(row).find(".data-bestbefore").val(),
115
        unit:                          $(row).find(".data-unit").val(),
116
        delivery_order_items_stock_id: $(row).find(".data-stock-id").val(),
117
      });
118
    });
119

  
120
    let row = $(".data-row").val();
121

  
122
    $.post("controller.pl", kivi.serialize({
123
        action: "DeliveryOrder/pack_stock_information",
124
        stock_info: data
125
      }),
126
      (data) => {
127
        $("[name=stock_info_" + row + "]").val(data);
128
        $("#stock_in_out_dialog").dialog("close");
129
      }
130
    );
131
  };
132

  
103 133
  ns.print = function() {
104 134
    $('#print_options').dialog('close');
105 135

  
templates/webpages/delivery_order/stock_dialog.html
1 1
[%- USE T8 %]
2 2
[%- USE HTML %]
3 3
[%- USE LxERP %]
4
[%- USE L %]
4 5
 [%- IF delivered %]
5 6
 [%- SET RO = ' readonly' %]
6 7
 [%- END %]
......
28 29
  [% L.hidden_tag("parts_id", parts_id) %]
29 30
  [% L.hidden_tag("do_qty", do_qty) %]
30 31
  [% L.hidden_tag("do_unit", do_unit) %]
31
  [% L.hidden_tag("row", row) %]
32
  [% L.hidden_tag("row", row, class="data-row") %]
32 33

  
33 34
  <p>
34
   <table>
35
   <table id="stock-in-out-table">
35 36
    <tr class="listheading">
36 37
     <th>&nbsp;</th>
37 38
     <th>[% 'Warehouse' | $T8 %]</th>
......
60 61
     [%- IF delivered %]
61 62

  
62 63
     <td>[% LxERP.format_amount(row.stock_qty) | html %]</td>
63
     <td>[% row.stock_unit | html %]</td>
64
     <td>
65
      [% row.stock_unit | html %]
66
      [% L.hidden_tag("unit", row.stock_unit, class="data-unit") %]
67
     </td>
64 68

  
65 69
     [%- ELSE %]
66 70

  
67 71
     <td>[% row.available_qty | html %]</td>
68
     <td><input name="qty_[% loop.count %]" style="text-align: right;" size="12"
69
                [%- IF row.stock_qty %]
70
                value="[% LxERP.format_amount(row.stock_qty) %]"
71
                [%- ELSIF ((WHCONTENTS.size == 1) && (!row.stock_qty)) %]
72
                value="[% do_qty | html %]"
73
                [%- END %]
74
                ></td>
75 72
     <td>
76
       [% L.select_tag("unit_" _ loop.count, part.unit_obj.convertible_units, value_key="name", default=row.stock_unit) %]
77
     </td>
73
      [% L.input_tag("qty", row.stock_qty                              ? LxERP.format_amount(row.stock_qty)
74
                          : (WHCONTENTS.size == 1) && (!row.stock_qty) ? LxERP.format_amount(do_qty)
75
                          : "", class="numeric data-qty", size="12") %]</td>
76
     <td>[% L.select_tag("unit_" _ loop.count, part.unit_obj.convertible_units, value_key="name", default=row.stock_unit, class="data-unit") %]</td>
78 77

  
79 78
     [%- END %]
79
     <td style="display:none">
80
      [% L.hidden_tag("warehouse_id", row.warehouse_id, class="data-warehouse-id") %]
81
      [% L.hidden_tag("bin_id", row.bin_id, class="data-bin-id") %]
82
      [% L.hidden_tag("chargenumber", row.chargenumber, class="data-chargenumber") %]
83
      [% L.hidden_tag("delivery_order_items_stock_id", row.delivery_order_items_stock_id, class="data-stock-id") %]
84
      [% L.hidden_tag("bestbefore", row.bestbefore, class="data-bestbefore") IF INSTANCE_CONF.get_show_bestbefore %]
85
     </td>
80 86
    </tr>
81 87

  
82
    <input type="hidden" name="warehouse_id_[% loop.count %]" value="[% HTML.escape(row.warehouse_id) %]">
83
    <input type="hidden" name="bin_id_[% loop.count %]"       value="[% HTML.escape(row.bin_id) %]">
84
    <input type="hidden" name="chargenumber_[% loop.count %]" value="[% HTML.escape(row.chargenumber) %]">
85
    <input type="hidden" name="delivery_order_items_stock_id_[% loop.count %]" value="[% HTML.escape(row.stock_delivery_order_items_stock_id) %]">
86
    [% IF INSTANCE_CONF.get_show_bestbefore %]
87
    <input type="hidden" name="bestbefore_[% loop.count %]" value="[% HTML.escape(row.bestbefore) %]">
88
    [% END %]
89 88
    [%- END %]
90 89
   </table>
91 90
  </p>
92 91

  
93 92
  <hr size="3" noshade>
94 93

  
95
  <p>
96
   [%- IF !delivered %]
97
   [% L.button_tag('kivi.DeliveryOrder.save_updated_stock()', 'Save') | $T8 %]
98
   [%- END %]
99
  </p>
94
  <p>[% L.button_tag('kivi.DeliveryOrder.save_updated_stock()', LxERP.t8('Save')) IF !delivered %]</p>
100 95

  
101 96
  [%- END %]
102 97
 </form>

Auch abrufbar als: Unified diff