Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9ef0dcd3

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

  • ID 9ef0dcd3d48a961e72e96f98956ac6938b7bd323
  • Vorgänger 575baa0a
  • Nachfolger 2cf35cb6

DeliveryOrder: erste Version Lager-Dialog

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
4 4
use parent qw(SL::Controller::Base);
5 5

  
6 6
use SL::Helper::Flash qw(flash_later);
7
use SL::Helper::Number qw(_format_number_units);
7
use SL::Helper::Number qw(_format_number_units _parse_number);
8 8
use SL::Presenter::Tag qw(select_tag hidden_tag div_tag);
9 9
use SL::Locale::String qw(t8);
10 10
use SL::SessionFile::Random;
......
886 886

  
887 887
}
888 888

  
889
sub action_stock_in_out_dialog {
890
  my ($self) = @_;
891

  
892
  my $part = SL::DB::Part->load_cached($::form->{parts_id}) or die "need parts_id";
893
  my $stock = $::form->{stock};
894
  my $unit = $::form->{unit};
895
  my $qty = _parse_number($::form->{qty_as_number});
896

  
897
  my $inout = $self->type_data->transfer;
898

  
899
  my @contents   = DO->get_item_availability(parts_id => $part->id);
900
  my $stock_info = DO->unpack_stock_information(packed => $stock);
901

  
902
  $self->merge_stock_data($stock_info, \@contents, $part);
903

  
904
  $self->render("delivery_order/stock_dialog", { layout => 0 },
905
    WHCONTENTS => $self->order->delivered ? $stock_info : \@contents,
906
    part  => $part,
907
    do_qty => $qty,
908
    do_unit => $unit,
909
  );
910

  
911
}
912

  
913
sub merge_stock_data {
914
  my ($self, $stock_info, $contents, $part) = @_;
915
  # TODO rewrite to mapping
916

  
917
  if (!$self->order->delivered) {
918
    for my $row (@$contents) {
919
      $row->{available_qty} = _format_number_units($row->{qty}, $row->{unit}, $part->unit);
920

  
921
      for my $sinfo (@{ $stock_info }) {
922
        next if $row->{bin_id}       != $sinfo->{bin_id} ||
923
                $row->{warehouse_id} != $sinfo->{warehouse_id} ||
924
                $row->{chargenumber} ne $sinfo->{chargenumber} ||
925
                $row->{bestbefore}   ne $sinfo->{bestbefore};
926

  
927
        $row->{"stock_$_"} = $sinfo->{$_}
928
          for qw(qty unit error delivery_order_items_stock_id);
929
      }
930
    }
931

  
932
  } else {
933
    for my $sinfo (@{ $stock_info }) {
934
      my $bin = SL::DB::Bin->load_cached($sinfo->{bin_id});
935
      $sinfo->{warehouse_description} = $bin->warehouse->description;
936
      $sinfo->{bin_description}       = $bin->escription;
937
      map { $sinfo->{"stock_$_"}      = $sinfo->{$_} } qw(qty unit);
938
    }
939
  }
940
}
941

  
889 942
# load the second row for one or more items
890 943
#
891 944
# This action gets the html code for all items second rows by rendering a template for
js/kivi.DeliveryOrder.js
78 78
    });
79 79
  };
80 80

  
81
  ns.open_stock_in_out_dialog = function(clicked, in_out) {
82
    var $row = $(clicked).parents("tbody").first();
83
    var id = $row.find('[name="orderitem_ids[+]"]').val();
84
    $row.uniqueId();
85

  
86
    kivi.popup_dialog({
87
      id: "stock_in_out",
88
      url: "controller.pl?action=DeliveryOrder/stock_in_out_dialog",
89
      data: {
90
        id:            $("#id").val(),
91
        type:          $("#type").val(),
92
        parts_id:      $row.find("[name$=parts_id]").val(),
93
        unit:          $row.find("[name$=unit]").val(),
94
        qty_as_number: $("qty_" + id).val(),
95
        stock:         $("stock_" + id).val(),
96
        item_id:       id,
97
        row:           $row.attr("id"),
98
      },
99
      dialog: { title: kivi.t8('Transfer stock') }
100
    });
101
  };
102

  
81 103
  ns.print = function() {
82 104
    $('#print_options').dialog('close');
83 105

  
templates/webpages/delivery_order/stock_dialog.html
1
[%- USE T8 %]
2
[%- USE HTML %]
3
[%- USE LxERP %]
4
 [%- IF delivered %]
5
 [%- SET RO = ' readonly' %]
6
 [%- END %]
7

  
8
 <table>
9
  <tr>
10
   <td>[% 'Part Number' | $T8 %]</td>
11
   <td>[% part.partnumber | html %]</td>
12
  </tr>
13
  <tr>
14
   <td>[% 'Description' | $T8 %]</td>
15
   <td>[% part.description | html %]</td>
16
  </tr>
17
  <tr>
18
   <td>[% 'Qty according to delivery order' | $T8 %]</td>
19
   <td>[% LxERP.format_amount(do_qty) %] [% do_unit | html %]</td>
20
  </tr>
21
 </table>
22

  
23
  [%- UNLESS WHCONTENTS.size %]
24
  <p>[% 'There are no items in stock.' | $T8 %]</p>
25
  [%- ELSE %]
26

  
27
  [% L.hidden_tag("in_out", in_out) %]
28
  [% L.hidden_tag("parts_id", parts_id) %]
29
  [% L.hidden_tag("do_qty", do_qty) %]
30
  [% L.hidden_tag("do_unit", do_unit) %]
31
  [% L.hidden_tag("row", row) %]
32

  
33
  <p>
34
   <table>
35
    <tr class="listheading">
36
     <th>&nbsp;</th>
37
     <th>[% 'Warehouse' | $T8 %]</th>
38
     <th>[% 'Bin' | $T8 %]</th>
39
     <th>[% 'Charge Number' | $T8 %]</th>
40
     [% IF INSTANCE_CONF.get_show_bestbefore %]
41
     <th>[% 'Best Before' | $T8 %]</th>
42
     [% END %]
43
     [%- UNLESS delivered %]
44
     <th align="right">[% 'Available qty' | $T8 %]</th>
45
     [%- END %]
46
     <th align="right">[% 'Qty' | $T8 %]</th>
47
     <th align="right">[% 'Unit' | $T8 %]</th>
48
    </tr>
49

  
50
    [%- FOREACH row = WHCONTENTS %]
51
    <tr [% IF row.stock_error %] class="error"[% ELSE %]class="listrow"[% END %]>
52
     <td>[% loop.count %]</td>
53
     <td>[% row.warehousedescription | html %]</td>
54
     <td>[% row.bindescription | html %]</td>
55
     <td>[% row.chargenumber | html %]</td>
56
     [% IF INSTANCE_CONF.get_show_bestbefore %]
57
     <td>[% row.bestbefore | html %]</td>
58
     [% END %]
59

  
60
     [%- IF delivered %]
61

  
62
     <td>[% LxERP.format_amount(row.stock_qty) | html %]</td>
63
     <td>[% row.stock_unit | html %]</td>
64

  
65
     [%- ELSE %]
66

  
67
     <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
     <td>
76
       [% L.select_tag("unit_" _ loop.count, part.unit_obj.convertible_units, value_key="name", default=row.stock_unit) %]
77
     </td>
78

  
79
     [%- END %]
80
    </tr>
81

  
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
    [%- END %]
90
   </table>
91
  </p>
92

  
93
  <hr size="3" noshade>
94

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

  
101
  [%- END %]
102
 </form>
103

  
104

  
templates/webpages/delivery_order/tabs/_row.html
88 88

  
89 89
    <td>
90 90
      <span id="stock_[% ID %]">[% SELF.calculate_stock_in_out(ITEM) %]</span>
91
      <input type=hidden id='stock_in_out_qty_matches_[% ID %]' value='$matches'>
92
      <input type="button" onclick="kivi.DeliveryOrder.open_stock_in_out_window('[% in_out %]', ID);" value="?">
91
      [% P.button_tag("kivi.DeliveryOrder.open_stock_in_out_dialog(this, '" _ in_out _"')", "?") %]
93 92
    </td>
94 93
  </tr>
95 94

  

Auch abrufbar als: Unified diff