Presenter: Neue Struktur in den restlichen Bereichen umgesetzt
[kivitendo-erp.git] / bin / mozilla / wh.pl
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2004
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #############################################################################
7 # SQL-Ledger, Accounting
8 # Copyright (c) 1998-2002
9 #
10 #  Author: Dieter Simader
11 #   Email: dsimader@sql-ledger.org
12 #     Web: http://www.sql-ledger.org
13 #
14 #
15 # This program is free software; you can redistribute it and/or modify
16 # it under the terms of the GNU General Public License as published by
17 # the Free Software Foundation; either version 2 of the License, or
18 # (at your option) any later version.
19 #
20 # This program is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 # MA 02110-1335, USA.
28 #
29 #######################################################################
30 #
31 # warehouse and packinglist
32 #
33 #######################################################################
34
35 use List::Util qw(min max first);
36 use POSIX qw(strftime);
37
38 use SL::Form;
39 use SL::User;
40
41 use SL::AM;
42 use SL::CT;
43 use SL::IC;
44 use SL::WH;
45 use SL::OE;
46 use SL::Locale::String qw(t8);
47 use SL::ReportGenerator;
48 use SL::Presenter::Part;
49
50 use SL::DB::Part;
51
52 use Data::Dumper;
53
54 require "bin/mozilla/common.pl";
55 require "bin/mozilla/reportgenerator.pl";
56
57 use strict;
58
59 # parserhappy(R):
60
61 # contents of the "transfer_type" table:
62 #  $locale->text('back')
63 #  $locale->text('correction')
64 #  $locale->text('disposed')
65 #  $locale->text('found')
66 #  $locale->text('missing')
67 #  $locale->text('stock')
68 #  $locale->text('shipped')
69 #  $locale->text('transfer')
70 #  $locale->text('used')
71 #  $locale->text('return_material')
72 #  $locale->text('release_material')
73 #  $locale->text('assembled')
74
75 # --------------------------------------------------------------------
76 # Transfer
77 # --------------------------------------------------------------------
78
79 sub transfer_warehouse_selection {
80   $main::lxdebug->enter_sub();
81
82   $main::auth->assert('warehouse_management');
83
84   my $form     = $main::form;
85   my %myconfig = %main::myconfig;
86   my $locale   = $main::locale;
87
88   $form->get_lists('warehouses' => { 'key'    => 'WAREHOUSES',
89                                      'bins'   => 'BINS', });
90
91   show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} });
92
93   my $units      = AM->retrieve_units(\%myconfig, $form);
94
95   my $part = 0;
96   if ( $form->{parts_id} ) {
97     $part = SL::DB::Part->new();
98     $part->id($form->{parts_id});
99     $part->load();
100   }
101
102   # der zweite Parameter von unit_select_data gibt den default-Namen (selected) vor
103   $form->{UNITS} = AM->unit_select_data($units, $form->{unit}, 0, $part ? $part->unit : 0);
104
105   if (scalar @{ $form->{WAREHOUSES} }) {
106     $form->{warehouse_id} ||= $form->{WAREHOUSES}->[0]->{id};
107     $form->{bin_id}       ||= $form->{WAREHOUSES}->[0]->{BINS}->[0]->{id};
108   }
109
110   my $content;
111
112   if ($form->{trans_type} eq 'removal') {
113     setup_wh_transfer_warehouse_selection_action_bar("removal_parts_selection");
114     $form->{title}   = $locale->text('Removal from Warehouse');
115     $content         = $form->parse_html_template('wh/warehouse_selection');
116
117   } elsif (!$form->{trans_type} || ($form->{trans_type} eq 'transfer')) {
118     setup_wh_transfer_warehouse_selection_action_bar("transfer_parts_selection");
119     $form->{title}   = $locale->text('Transfer');
120     $content         = $form->parse_html_template('wh/warehouse_selection');
121
122   } elsif ($form->{trans_type} eq 'assembly') {
123     setup_wh_transfer_warehouse_selection_assembly_action_bar();
124     $form->{title} = $locale->text('Produce Assembly');
125     $content       = $form->parse_html_template('wh/warehouse_selection_assembly');
126   }
127
128   $form->header();
129   print $content;
130
131   $main::lxdebug->leave_sub();
132 }
133
134 sub transfer_parts_selection {
135   $main::lxdebug->enter_sub();
136
137   $main::auth->assert('warehouse_management');
138
139   my $form     = $main::form;
140   my %myconfig = %main::myconfig;
141   my $locale   = $main::locale;
142
143   transfer_or_removal_prepare_contents('direction' => 'transfer');
144
145   setup_wh_transfer_parts_action_bar();
146
147   $form->{title} = $locale->text('Transfer');
148   $form->header();
149   print $form->parse_html_template("wh/transfer_parts_selection");
150
151   $main::lxdebug->leave_sub();
152 }
153
154 sub transfer_or_removal_prepare_contents {
155   $main::lxdebug->enter_sub();
156
157   $main::auth->assert('warehouse_management');
158
159   my %args = @_;
160
161   my $form     = $main::form;
162   my %myconfig = %main::myconfig;
163   my $locale   = $main::locale;
164
165   $form->get_lists('warehouses' => { 'key'    => 'WAREHOUSES',
166                                      'bins'   => 'BINS', });
167
168   my $warehouse_idx = get_warehouse_idx($form->{warehouse_id});
169   $form->show_generic_error($locale->text("The selected warehouse does not exist.")) if (-1 == $warehouse_idx);
170
171   my $warehouse = $form->{WAREHOUSES}->[$warehouse_idx];
172
173   $form->{initial_warehouse_idx} = $warehouse_idx;
174   $form->{warehouse_description} = $warehouse->{description};
175   $warehouse->{selected}         = 1;
176
177   $form->show_generic_error($locale->text("The source warehouse does not contain any bins.")) if (0 == scalar @{ $warehouse->{BINS} });
178
179   map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber bestbefore partunit ean);
180
181   $form->{sort} = 'bindescription';
182   my @contents  = WH->get_warehouse_report("warehouse_id" => $form->{warehouse_id},
183                                            "bin_id"       => $form->{bin_id},
184                                            "chargenumber" => $form->{chargenumber},
185                                            "bestbefore"   => $form->{bestbefore},
186                                            "partsid"      => $form->{part_id},
187                                            "ean"          => $form->{ean});
188
189   if (0 == scalar(@contents)) {
190     $form->show_generic_error($locale->text("The selected warehouse is empty, or no stocked items where found that match the filter settings."));
191   }
192
193   my $all_units = AM->retrieve_units(\%myconfig, $form);
194
195   foreach (@contents) {
196     $_->{qty} = $form->format_amount_units('amount'     => $_->{qty},
197                                            'part_unit'  => $_->{partunit},
198                                            'conv_units' => 'convertible');
199     my $this_unit = $_->{partunit};
200
201     if ($all_units->{$_->{partunit}} && ($all_units->{g}->{base_unit} eq $all_units->{$_->{partunit}}->{base_unit})) {
202       $this_unit = "kg";
203     }
204
205     $_->{UNITS} = AM->unit_select_data($all_units, $this_unit, 0, $_->{partunit});
206   }
207
208   my $transfer_types = WH->retrieve_transfer_types($args{direction});
209   map { $_->{description} = $locale->text($_->{description}) } @{ $transfer_types };
210
211   $form->{CONTENTS}       = \@contents;
212   $form->{TRANSFER_TYPES} = $transfer_types;
213
214   $main::lxdebug->leave_sub();
215 }
216
217
218 sub transfer_parts {
219   $main::lxdebug->enter_sub();
220
221   $main::auth->assert('warehouse_management');
222
223   my $form     = $main::form;
224   my %myconfig = %main::myconfig;
225   my $locale   = $main::locale;
226
227   $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES', 'bins' => 'BINS' });
228
229   my $warehouse_idx = get_warehouse_idx($form->{warehouse_id});
230   $form->show_generic_error($locale->text("The selected warehouse does not exist.")) if (-1 == $warehouse_idx);
231
232   my $warehouse = $form->{WAREHOUSES}->[$warehouse_idx];
233
234   $form->show_generic_error($locale->text("The source warehouse does not contain any bins.")) if (0 == scalar @{ $warehouse->{BINS} });
235
236   map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber bestbefore partunit);
237
238   $form->{sort} = 'bindescription';
239   my @contents  = WH->get_warehouse_report("warehouse_id" => $form->{warehouse_id});
240   my $all_units = AM->retrieve_units(\%myconfig, $form);
241
242   my @transfers;
243
244   foreach my $row (1 .. $form->{rowcount}) {
245     $form->{"qty_$row"} =~ s/^\s*//;
246     $form->{"qty_$row"} =~ s/\s*$//;
247     next if (!$form->{"qty_$row"});
248
249     my $bin_idx = get_bin_idx($warehouse_idx, $form->{"src_bin_id_$row"});
250     $form->show_generic_error($locale->text("The selected bin does not exist.")) if (-1 == $bin_idx);
251     my $bin     = $warehouse->{BINS}->[$bin_idx];
252
253     my $orig_qty = $form->{"qty_$row"} . " " . $form->{"unit_$row"};
254
255     my $transfer = {
256       'src_warehouse_id' => $form->{warehouse_id},
257       'transfer_type_id' => $form->{transfer_type_id},
258     };
259
260     map { $transfer->{$_} = $form->{"${_}_${row}"} } qw(src_bin_id chargenumber bestbefore parts_id qty dst_warehouse_id dst_bin_id);
261
262     my $entry;
263
264     foreach (@contents) {
265       if (($_->{binid} == $transfer->{src_bin_id}) && ($_->{parts_id} == $transfer->{parts_id}) && ($_->{chargenumber} eq $transfer->{chargenumber}) && $_->{bestbefore} eq $transfer->{bestbefore}) {
266         $entry = $_;
267         last;
268       }
269     }
270
271     if (!$entry) {
272       $form->error($locale->text("There is not enough left of '#1' in bin '#2' for the removal of #3.",
273                                  $form->{"partdescription_$row"}, $bin->{description}, $orig_qty));
274     }
275
276     $transfer->{qty}  = $form->parse_amount(\%myconfig, $transfer->{qty}) * $all_units->{$form->{"unit_$row"}}->{factor};
277     $transfer->{qty} /= $all_units->{$entry->{partunit}}->{factor} || 1;
278
279     if (($entry->{qty} < $transfer->{qty}) || (0 >= $transfer->{qty})) {
280       $form->error($locale->text("There is not enough left of '#1' in bin '#2' for the removal of #3.",
281                                  $form->{"partdescription_$row"}, $bin->{description}, $orig_qty));
282     }
283
284     $transfer->{comment} = $form->{comment};
285     $transfer->{change_default_bin} = $form->{change_default_bin};
286
287     push @transfers, $transfer;
288
289     $entry->{qty} -= $transfer->{qty};
290   }
291
292   if (!scalar @transfers) {
293     $form->show_generic_information($locale->text('Nothing has been selected for transfer.'));
294     $::dispatcher->end_request;
295   }
296
297   WH->transfer(@transfers);
298
299   $form->{trans_type}    = 'transfer';
300   $form->{saved_message} = $locale->text('The parts have been transferred.');
301
302   transfer_warehouse_selection();
303
304   $main::lxdebug->leave_sub();
305 }
306
307 # --------------------------------------------------------------------
308 # Transfer: stock
309 # --------------------------------------------------------------------
310
311 # --------------------------------------------------------------------
312 # Transfer: assemblies
313 # Dies ist die Auswahlmaske für ein assembly.
314 # Die ist einfach von transfer_assembly_update_part kopiert und nur um den trans_type (assembly) korrigiert worden
315 # Es wäre schön, hier nochmal check_assembly_max_create auf, um die max. Fertigungszahl herauszufinden.
316 # Ich lass das mal als auskommentierte Idee bestehen jb 18.3.09
317 # --------------------------------------------------------------------
318
319 sub transfer_assembly_update_part {
320   my $form     = $main::form;
321   my %myconfig = %main::myconfig;
322   my $locale   = $main::locale;
323
324   $form->{trans_type} = 'assembly';
325   $form->{qty}        = $form->parse_amount(\%myconfig, $form->{qty});
326
327   if (!$form->{parts_id}) {
328     delete $form->{partunit};
329     transfer_warehouse_selection();
330     return;
331
332   }
333
334   my $part = SL::DB::Part->new(id => $::form->{parts_id})->load;
335   @{$form}{qw(parts_id partnumber description)} = ($part->id, $part->partnumber, $part->description);
336
337   transfer_stock_get_partunit();
338   transfer_warehouse_selection();
339 }
340
341 sub transfer_stock_part_selected {
342   $main::lxdebug->enter_sub();
343
344   my $part = shift;
345
346   my $form     = $main::form;
347
348   @{$form}{qw(parts_id partnumber description ean warehouse_id bin_id)} = @{$part}{qw(id partnumber description ean warehouse_id bin_id)};
349
350   transfer_stock_get_partunit();
351   transfer_warehouse_selection();
352
353   $main::lxdebug->leave_sub();
354 }
355
356 sub transfer_stock_get_partunit {
357   $main::lxdebug->enter_sub();
358
359   my $form     = $main::form;
360
361   if ($form->{parts_id}) {
362     my $part_info     = IC->get_basic_part_info('id' => $form->{parts_id});
363     $form->{partunit} = $part_info->{unit};
364   }
365
366   $main::lxdebug->leave_sub();
367 }
368
369 # vorüberlegung jb 22.2.2009
370 # wir benötigen für diese funktion, die anzahl die vom erzeugnis hergestellt werden soll. vielleicht direkt per js fehleingaben verhindern?
371 # ferner dann nochmal mit check_asssembly_max_create gegenprüfen und dann transaktionssicher wegbuchen.
372 # wir brauchen eine hilfsfunktion, die nee. brauchen wir nicht. der algorithmus läuft genau wie bei check max_create, nur dass hier auch eine lagerbewegung (verbraucht) stattfindet
373 # Manko ist derzeit noch, dass unterschiedliche Lagerplätze, bzw. das Quelllager an sich nicht ausgewählt werden können.
374 # Laut Absprache in KW11 09 Ã¼bernimmt mb hier den rest im April ... jb 18.3.09
375
376 sub create_assembly {
377   $main::lxdebug->enter_sub();
378
379   my $form     = $main::form;
380   my %myconfig = %main::myconfig;
381   my $locale   = $main::locale;
382
383   $form->{qty} = $form->parse_amount(\%myconfig, $form->{qty});
384   if ($form->{qty} <= 0) {
385     $form->show_generic_error($locale->text('Invalid quantity.'));
386   }
387   # TODO Es wäre schön, hier schon die maximale Anzahl der zu fertigenden Erzeugnisse zu haben
388   #else { if ($form->{qty} > $maxcreate) { #s.o.
389   #     $form->show_generic_error($locale->text('Can not create that quantity with current stock'));
390   #     $form->show_generic_error('Maximale Stückzahl' . $maxcreate);
391   #   }
392   #  }
393
394   if (!$form->{warehouse_id} || !$form->{bin_id}) {
395     $form->error($locale->text('The warehouse or the bin is missing.'));
396   }
397
398   if (!$::instance_conf->get_show_bestbefore) {
399       $form->{bestbefore} = '';
400   }
401
402   # WIESO war das nicht vorher schon ein %HASH?? ein hash ist ein hash! das hat mich mehr als eine Stunde gekostet herauszufinden. grr. jb 3.3.2009
403   # Anm. jb 18.3. vielleicht auch nur meine unwissenheit in perl-datenstrukturen
404   my %TRANSFER = (
405     'transfer_type'    => 'assembly',
406     'login'            => $::myconfig{login},
407     'dst_warehouse_id' => $form->{warehouse_id},
408     'dst_bin_id'       => $form->{bin_id},
409     'chargenumber'     => $form->{chargenumber},
410     'bestbefore'       => $form->{bestbefore},
411     'assembly_id'      => $form->{parts_id},
412     'qty'              => $form->{qty},
413     'unit'             => $form->{unit},
414     'comment'          => $form->{comment}
415   );
416
417   my $ret = WH->transfer_assembly (%TRANSFER);
418   # Frage: Ich pack in den return-wert auch gleich die Fehlermeldung. Irgendwelche Nummern als Fehlerkonstanten definieren find ich auch nicht besonders schick...
419   # Ideen? jb 18.3.09
420   if ($ret ne "1"){
421     # Die locale-Funktion kann keine Double-Quotes escapen, deswegen hier erstmal so (ein wahrscheinlich immerwährender Hotfix) s.a. Frage davor jb 25.4.09
422     $form->show_generic_error($ret);
423   }
424
425   delete @{$form}{qw(parts_id partnumber description qty unit chargenumber bestbefore comment)};
426
427   $form->{saved_message} = $locale->text('The assembly has been created.');
428   $form->{trans_type}    = 'assembly';
429
430   transfer_warehouse_selection();
431
432   $main::lxdebug->leave_sub();
433 }
434
435 # --------------------------------------------------------------------
436 # Transfer: removal
437 # --------------------------------------------------------------------
438
439 sub removal_parts_selection {
440   $main::lxdebug->enter_sub();
441
442   $main::auth->assert('warehouse_management');
443
444   my $form     = $main::form;
445   my %myconfig = %main::myconfig;
446   my $locale   = $main::locale;
447
448   transfer_or_removal_prepare_contents('direction' => 'out');
449
450   setup_wh_removal_parts_selection_action_bar();
451
452   $form->{title} = $locale->text('Removal');
453   $form->header();
454   print $form->parse_html_template("wh/removal_parts_selection");
455
456   $main::lxdebug->leave_sub();
457 }
458
459 sub remove_parts {
460   $main::lxdebug->enter_sub();
461
462   $main::auth->assert('warehouse_management');
463
464   my $form     = $main::form;
465   my %myconfig = %main::myconfig;
466   my $locale   = $main::locale;
467
468   $form->get_lists('warehouses' => { 'key'    => 'WAREHOUSES',
469                                      'bins'   => 'BINS', });
470
471   my $warehouse_idx = get_warehouse_idx($form->{warehouse_id});
472   $form->show_generic_error($locale->text("The selected warehouse does not exist.")) if (-1 == $warehouse_idx);
473
474   my $warehouse = $form->{WAREHOUSES}->[$warehouse_idx];
475
476   $form->show_generic_error($locale->text("The warehouse does not contain any bins.")) if (0 == scalar @{ $warehouse->{BINS} });
477
478   map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber bestbefore partunit);
479
480   $form->{sort} = 'bindescription';
481   my @contents  = WH->get_warehouse_report("warehouse_id" => $form->{warehouse_id});
482   my $all_units = AM->retrieve_units(\%myconfig, $form);
483
484   my @transfers;
485
486   foreach my $row (1 .. $form->{rowcount}) {
487     $form->{"qty_$row"} =~ s/^\s*//;
488     $form->{"qty_$row"} =~ s/\s*$//;
489     next if (!$form->{"qty_$row"});
490
491     my $bin_idx = get_bin_idx($warehouse_idx, $form->{"src_bin_id_$row"});
492     $form->show_generic_error($locale->text("The selected bin does not exist.")) if (-1 == $bin_idx);
493     my $bin     = $warehouse->{BINS}->[$bin_idx];
494
495     my $orig_qty = $form->{"qty_$row"} . " " . $form->{"unit_$row"};
496
497     my $transfer = {
498       'src_warehouse_id' => $form->{warehouse_id},
499       'transfer_type_id' => $form->{transfer_type_id},
500     };
501
502     map { $transfer->{$_} = $form->{"${_}_${row}"} } qw(src_bin_id chargenumber bestbefore parts_id qty);
503
504     my $entry;
505
506     foreach (@contents) {
507       if (($_->{binid} == $transfer->{src_bin_id}) && ($_->{parts_id} == $transfer->{parts_id}) && ($_->{chargenumber} eq $transfer->{chargenumber}) && ($_->{bestbefore} eq $transfer->{bestbefore})) {
508         $entry = $_;
509         last;
510       }
511     }
512
513     if (!$entry) {
514       $form->error($locale->text("There is not enough left of '#1' in bin '#2' for the removal of #3.",
515                                  $form->{"partdescription_$row"}, $bin->{description}, $orig_qty));
516     }
517
518     $transfer->{qty}  = $form->parse_amount(\%myconfig, $transfer->{qty}) * $all_units->{$form->{"unit_$row"}}->{factor};
519     $transfer->{qty} /= $all_units->{$entry->{partunit}}->{factor} || 1;
520
521     if (($entry->{qty} < $transfer->{qty}) || (0 >= $transfer->{qty})) {
522       $form->error($locale->text("There is not enough left of '#1' in bin '#2' for the removal of #3.",
523                                  $form->{"partdescription_$row"}, $bin->{description}, $orig_qty));
524     }
525
526     $transfer->{comment} = $form->{comment};
527
528     push @transfers, $transfer;
529
530     $entry->{qty} -= $transfer->{qty};
531   }
532
533   if (!scalar @transfers) {
534     $form->show_generic_information($locale->text('Nothing has been selected for removal.'));
535     $::dispatcher->end_request;
536   }
537
538   WH->transfer(@transfers);
539
540   $form->{trans_type}    = 'removal';
541   $form->{saved_message} = $locale->text('The parts have been removed.');
542
543   transfer_warehouse_selection();
544
545   $main::lxdebug->leave_sub();
546 }
547
548 # --------------------------------------------------------------------
549 # Journal
550 # --------------------------------------------------------------------
551
552 sub journal {
553   $main::lxdebug->enter_sub();
554
555   $main::auth->assert('warehouse_management');
556
557   my $form     = $main::form;
558   my %myconfig = %main::myconfig;
559   my $locale   = $main::locale;
560
561   $form->{title} = $locale->text('Report about warehouse transactions');
562   $form->get_lists('warehouses' => { 'key'  => 'WAREHOUSES',
563                                      'bins' => 'BINS', });
564
565   show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} });
566
567   setup_wh_journal_action_bar();
568
569   $form->header();
570   print $form->parse_html_template("wh/journal_filter", { "UNITS" => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)) });
571
572   $main::lxdebug->leave_sub();
573 }
574
575 sub generate_journal {
576   $main::lxdebug->enter_sub();
577
578   $main::auth->assert('warehouse_management');
579
580   my $form     = $main::form;
581   my %myconfig = %main::myconfig;
582   my $locale   = $main::locale;
583
584   $form->{title}   = $locale->text("WHJournal");
585   $form->{sort}  ||= 'date';
586
587   $form->{report_generator_output_format} = 'HTML' if !$form->{report_generator_output_format};
588
589   my %filter;
590   my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber type_and_classific partdescription chargenumber bestbefore trans_type comment qty unit partunit employee oe_id projectnumber);
591
592   # filter stuff
593   map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id classification_id partnumber description chargenumber bestbefore transtype_id transtype_ids comment projectnumber);
594
595   $filter{qty_op} = WH->convert_qty_op($form->{qty_op});
596   if ($filter{qty_op}) {
597     $form->isblank("qty",      $locale->text('Quantity missing.'));
598     $form->isblank("qty_unit", $locale->text('Unit missing.'));
599
600     $filter{qty}      = $form->{qty};
601     $filter{qty_unit} = $form->{qty_unit};
602   }
603   # /filter stuff
604
605   my $allrows        = !!($form->{report_generator_output_format} ne 'HTML') ;
606
607   # manual paginating
608   my $pages          = {};
609   my $page           = $::form->{page} || 1;
610   $pages->{per_page} = $::form->{per_page} || 15;
611   my $first_nr       = ($page - 1) * $pages->{per_page};
612   my $last_nr        = $first_nr + $pages->{per_page};
613
614   # no optimisation if qty op
615   if ( !$allrows && $form->{maxrows} && !$filter{qty_op}) {
616     $filter{limit}  = $pages->{per_page};
617     $filter{offset} = ($page - 1) * $pages->{per_page};
618     $first_nr       = 0;
619     $last_nr        = $pages->{per_page};
620   }
621
622   my @contents  = WH->get_warehouse_journal(%filter);
623   # get maxcount
624   if (!$form->{maxrows}) {
625     $form->{maxrows} = scalar @contents ;
626   }
627
628   my $report = SL::ReportGenerator->new(\%myconfig, $form);
629
630   my @hidden_variables = map { "l_${_}" } @columns;
631   push @hidden_variables, qw(warehouse_id bin_id partnumber description chargenumber bestbefore qty_op qty qty_unit unit partunit fromdate todate transtype_ids comment projectnumber);
632   push @hidden_variables, qw(classification_id);
633
634   my %column_defs = (
635     'date'            => { 'text' => $locale->text('Date'), },
636     'trans_id'        => { 'text' => $locale->text('Trans Id'), },
637     'trans_type'      => { 'text' => $locale->text('Trans Type'), },
638     'comment'         => { 'text' => $locale->text('Comment'), },
639     'warehouse_from'  => { 'text' => $locale->text('Warehouse From'), },
640     'warehouse_to'    => { 'text' => $locale->text('Warehouse To'), },
641     'bin_from'        => { 'text' => $locale->text('Bin From'), },
642     'bin_to'          => { 'text' => $locale->text('Bin To'), },
643     'partnumber'      => { 'text' => $locale->text('Part Number'), },
644     'type_and_classific'
645                       => { 'text' => $locale->text('Type'), },
646     'partdescription' => { 'text' => $locale->text('Part Description'), },
647     'chargenumber'    => { 'text' => $locale->text('Charge Number'), },
648     'bestbefore'      => { 'text' => $locale->text('Best Before'), },
649     'qty'             => { 'text' => $locale->text('Qty'), },
650     'unit'            => { 'text' => $locale->text('Part Unit'), },
651     'partunit'        => { 'text' => $locale->text('Unit'), },
652     'employee'        => { 'text' => $locale->text('Employee'), },
653     'projectnumber'   => { 'text' => $locale->text('Project Number'), },
654     'oe_id'           => { 'text' => $locale->text('Document'), },
655   );
656
657   if ($form->{transtype_ids} && 'ARRAY' eq ref $form->{transtype_ids}) {
658     for (my $i = 0; $i < scalar(@{ $form->{transtype_ids} }); $i++) {
659       delete $form->{transtype_ids}[$i] if $form->{transtype_ids}[$i] eq '';
660     }
661     $form->{transtype_ids} = join(",", @{ $form->{transtype_ids} });
662   }
663
664   my $href = build_std_url('action=generate_journal', grep { $form->{$_} } @hidden_variables);
665   $href .= "&maxrows=".$form->{maxrows};
666
667   map { $column_defs{$_}->{link} = $href ."&page=".$page. "&sort=${_}&order=" . Q($_ eq $form->{sort} ? 1 - $form->{order} : $form->{order}) } @columns;
668
669   my %column_alignment = map { $_ => 'right' } qw(qty);
670
671   map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
672   $column_defs{partunit}->{visible} = 1;
673   $column_defs{type_and_classific}->{visible} = 1;
674   $column_defs{type_and_classific}->{link} ='';
675
676   $report->set_columns(%column_defs);
677   $report->set_column_order(@columns);
678
679   $report->set_export_options('generate_journal', @hidden_variables, qw(sort order));
680
681   $report->set_sort_indicator($form->{sort}, $form->{order});
682
683   $report->set_options('output_format'        => 'HTML',
684                        'title'                => $form->{title},
685                        'attachment_basename'  => strftime($locale->text('warehouse_journal_list') . '_%Y%m%d', localtime time));
686   $report->set_options_from_form();
687   $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
688
689   my $all_units = AM->retrieve_units(\%myconfig, $form);
690
691   my %doc_types = ( 'sales_quotation'         => { script => 'oe', title => $locale->text('Sales quotation') },
692                     'sales_order'             => { script => 'oe', title => $locale->text('Sales Order') },
693                     'request_quotation'       => { script => 'oe', title => $locale->text('Request quotation') },
694                     'purchase_order'          => { script => 'oe', title => $locale->text('Purchase Order') },
695                     'sales_delivery_order'    => { script => 'do', title => $locale->text('Sales delivery order') },
696                     'purchase_delivery_order' => { script => 'do', title => $locale->text('Purchase delivery order') },
697                     'sales_invoice'           => { script => 'is', title => $locale->text('Sales Invoice') },
698                     'purchase_invoice'        => { script => 'ir', title => $locale->text('Purchase Invoice') },
699                   );
700
701   my $idx       = 0;
702
703   foreach my $entry (@contents) {
704     $entry->{type_and_classific} = SL::Presenter::Part::type_abbreviation($entry->{part_type}) .
705                                    SL::Presenter::Part::classification_abbreviation($entry->{classification_id});
706     $entry->{qty}        = $form->format_amount(\%myconfig, $entry->{qty});
707     $entry->{trans_type} = $locale->text($entry->{trans_type});
708
709     my $row = { };
710
711     foreach my $column (@columns) {
712       $row->{$column} = {
713         'data'  => $entry->{$column},
714         'align' => $column_alignment{$column},
715       };
716     }
717
718     $row->{trans_type}->{raw_data} = $entry->{trans_type};
719
720     if ($form->{l_oe_id}) {
721       $row->{oe_id}->{data} = '';
722       my $info              = $entry->{oe_id_info};
723
724       if ($info && $info->{id} && $info->{type} && $doc_types{$info->{type}}) {
725         $row->{oe_id} = { data => $doc_types{ $info->{type} }->{title} . ' ' . $info->{number},
726                           link => build_std_url('script=' . $doc_types{ $info->{type} }->{script} . '.pl', 'action=edit', 'id=' . $info->{id}, 'type=' . $info->{type}) };
727       }
728     }
729
730     if ( $allrows || ($idx >= $first_nr && $idx < $last_nr )) {
731       $report->add_data($row);
732     }
733     $idx++;
734   }
735
736   if ( ! $allrows ) {
737       $pages->{max}  = SL::DB::Helper::Paginated::ceil($form->{maxrows}, $pages->{per_page}) || 1;
738       $pages->{page} = $page < 1 ? 1: $page > $pages->{max} ? $pages->{max}: $page;
739       $pages->{common} = [ grep { $_->{visible} } @{ SL::DB::Helper::Paginated::make_common_pages($pages->{page}, $pages->{max}) } ];
740
741       $report->set_options('raw_bottom_info_text' => $form->parse_html_template('common/paginate',
742                                                             { 'pages' => $pages , 'base_url' => $href.'&sort='.$form->{sort}.'&order='.$form->{order}}) );
743   }
744   $report->generate_with_headers();
745
746   $main::lxdebug->leave_sub();
747 }
748
749 # --------------------------------------------------------------------
750 # Report
751 # --------------------------------------------------------------------
752
753 sub report {
754   $main::lxdebug->enter_sub();
755
756   $main::auth->assert('warehouse_contents | warehouse_management');
757
758   my $form     = $main::form;
759   my %myconfig = %main::myconfig;
760   my $locale   = $main::locale;
761
762   $form->get_lists('warehouses' => { 'key'    => 'WAREHOUSES',
763                                      'bins'   => 'BINS', });
764
765   show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} });
766
767   $form->{title}   = $locale->text("Report about warehouse contents");
768
769   setup_wh_report_action_bar();
770
771   $form->header();
772   print $form->parse_html_template("wh/report_filter",
773                                    { "WAREHOUSES" => $form->{WAREHOUSES},
774                                      "UNITS"      => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)) });
775
776   $main::lxdebug->leave_sub();
777 }
778
779 sub generate_report {
780   $main::lxdebug->enter_sub();
781
782   $main::auth->assert('warehouse_contents | warehouse_management');
783
784   my $form     = $main::form;
785   my %myconfig = %main::myconfig;
786   my $locale   = $main::locale;
787
788   $form->{title}   = $locale->text("Report about warehouse contents");
789   $form->{sort}  ||= 'partnumber';
790   my $sort_col     = $form->{sort};
791
792   my %filter;
793   my @columns = qw(warehousedescription bindescription partnumber type_and_classific partdescription chargenumber bestbefore comment qty partunit  purchase_price stock_value);
794
795   # filter stuff
796   map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id classification_id partnumber description chargenumber bestbefore date include_invalid_warehouses);
797
798   # show filter stuff also in report
799   my @options;
800   my $currentdate = $form->current_date(\%myconfig);
801   push @options, $locale->text('Printdate') . " : ".$locale->date(\%myconfig, $currentdate, 1);
802
803   # dispatch all options
804   my $dispatch_options = {
805    warehouse_id   => sub { push @options, $locale->text('Warehouse') . " : " .
806                                             SL::DB::Manager::Warehouse->find_by(id => $form->{warehouse_id})->description},
807    bin_id         => sub { push @options, $locale->text('Bin') . " : " .
808                                             SL::DB::Manager::Bin->find_by(id => $form->{bin_id})->description},
809    partnumber     => sub { push @options, $locale->text('Partnumber')     . " : $form->{partnumber}"},
810    classification_id => sub { push @options, $locale->text('Parts Classification'). " : ".
811                                                SL::DB::Manager::PartClassification->get_first(where => [ id => $form->{classification_id} ] )->description; },
812    description    => sub { push @options, $locale->text('Description')    . " : $form->{description}"},
813    chargenumber   => sub { push @options, $locale->text('Charge Number')  . " : $form->{chargenumber}"},
814    bestbefore     => sub { push @options, $locale->text('Best Before')    . " : $form->{bestbefore}"},
815    include_invalid_warehouses    => sub { push @options, $locale->text('Include invalid warehouses ')},
816   };
817   foreach (keys %filter) {
818    $dispatch_options->{$_}->() if $dispatch_options->{$_};
819   }
820   push @options, $locale->text('Stock Qty for Date') . " " . $locale->date(\%myconfig, $form->{date}?$form->{date}:$currentdate, 1);
821
822   # / end show filter stuff also in report
823
824   $filter{qty_op} = WH->convert_qty_op($form->{qty_op});
825   if ($filter{qty_op}) {
826     $form->isblank("qty",      $locale->text('Quantity missing.'));
827     $form->isblank("qty_unit", $locale->text('Unit missing.'));
828
829     $filter{qty}      = $form->{qty};
830     $filter{qty_unit} = $form->{qty_unit};
831   }
832   # /filter stuff
833
834   $form->{report_generator_output_format} = 'HTML' if !$form->{report_generator_output_format};
835
836   # manual paginating
837   my $allrows        = !!($form->{report_generator_output_format} ne 'HTML') ;
838   my $page           = $::form->{page} || 1;
839   my $pages          = {};
840   $pages->{per_page} = $::form->{per_page} || 20;
841   my $first_nr       = ($page - 1) * $pages->{per_page};
842   my $last_nr        = $first_nr + $pages->{per_page};
843
844   # no optimisation if qty op
845   if ( !$allrows && $form->{maxrows} && !$filter{qty_op}) {
846     $filter{limit}  = $pages->{per_page};
847     $filter{offset} = ($page - 1) * $pages->{per_page};
848     $first_nr       = 0;
849     $last_nr        = $pages->{per_page};
850   }
851
852   my @contents  = WH->get_warehouse_report(%filter);
853
854   # get maxcount
855   if (!$form->{maxrows}) {
856     $form->{maxrows} = scalar @contents ;
857   }
858
859   $form->{subtotal} = '' if (!first { $_ eq $sort_col } qw(partnumber partdescription));
860
861   my $report = SL::ReportGenerator->new(\%myconfig, $form);
862
863   my @hidden_variables = map { "l_${_}" } @columns;
864   push @hidden_variables, qw(warehouse_id bin_id partnumber partstypes_id description chargenumber bestbefore qty_op qty qty_unit partunit l_warehousedescription l_bindescription);
865   push @hidden_variables, qw(include_empty_bins subtotal include_invalid_warehouses date);
866   push @hidden_variables, qw(classification_id);
867
868   my %column_defs = (
869     'warehousedescription' => { 'text' => $locale->text('Warehouse'), },
870     'bindescription'       => { 'text' => $locale->text('Bin'), },
871     'partnumber'           => { 'text' => $locale->text('Part Number'), },
872     'type_and_classific'   => { 'text' => $locale->text('Type'), },
873     'partdescription'      => { 'text' => $locale->text('Part Description'), },
874     'chargenumber'         => { 'text' => $locale->text('Charge Number'), },
875     'bestbefore'           => { 'text' => $locale->text('Best Before'), },
876     'qty'                  => { 'text' => $locale->text('Qty'), },
877     'partunit'             => { 'text' => $locale->text('Unit'), },
878     'stock_value'          => { 'text' => $locale->text('Stock value'), },
879     'purchase_price'       => { 'text' => $locale->text('Purchase price'), },
880   );
881
882   my $href = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
883   $href .= "&maxrows=".$form->{maxrows};
884
885   map { $column_defs{$_}->{link} = $href . "&page=".$page."&sort=${_}&order=" . Q($_ eq $sort_col ? 1 - $form->{order} : $form->{order}) } @columns;
886
887   my %column_alignment = map { $_ => 'right' } qw(qty purchase_price stock_value);
888
889   map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
890
891   $column_defs{partunit}->{visible}           = 1;
892   $column_defs{type_and_classific}->{visible} = 1;
893   $column_defs{type_and_classific}->{link} ='';
894
895   $report->set_columns(%column_defs);
896   $report->set_column_order(@columns);
897
898   $report->set_export_options('generate_report', @hidden_variables, qw(sort order));
899
900   $report->set_sort_indicator($sort_col, $form->{order});
901
902   $report->set_options('top_info_text'        => join("\n", @options),
903                        'output_format'        => 'HTML',
904                        'title'                => $form->{title},
905                        'attachment_basename'  => strftime($locale->text('warehouse_report_list') . '_%Y%m%d', localtime time));
906   $report->set_options_from_form();
907   $locale->set_numberformat_wo_thousands_separator(\%myconfig) if lc($report->{options}->{output_format}) eq 'csv';
908
909   my $all_units = AM->retrieve_units(\%myconfig, $form);
910   my $idx       = 0;
911
912   my @subtotals_columns = qw(qty stock_value);
913   my %subtotals         = map { $_ => 0 } @subtotals_columns;
914
915   my $total_stock_value = 0;
916
917   foreach my $entry (@contents) {
918
919     $entry->{type_and_classific} = SL::Presenter::Part::type_abbreviation($entry->{part_type}).
920                                    SL::Presenter::Part::classification_abbreviation($entry->{classification_id});
921     map { $subtotals{$_} += $entry->{$_} } @subtotals_columns;
922     $total_stock_value   += $entry->{stock_value} * 1;
923     $entry->{qty}         = $form->format_amount(\%myconfig, $entry->{qty});
924 #    $entry->{qty}         = $form->format_amount_units('amount'     => $entry->{qty},
925 #                                                       'part_unit'  => $entry->{partunit},
926 #                                                       'conv_units' => 'convertible');
927     $entry->{stock_value} = $form->format_amount(\%myconfig, $entry->{stock_value} * 1, 2);
928     $entry->{purchase_price} = $form->format_amount(\%myconfig, $entry->{purchase_price} * 1, 2);
929
930     my $row_set = [ { map { $_ => { 'data' => $entry->{$_}, 'align' => $column_alignment{$_} } } @columns } ];
931
932     if ( ($form->{subtotal} eq 'Y' && !$form->{report_generator_csv_options_for_import} )
933         && (($idx == (scalar @contents - 1))
934             || ($entry->{$sort_col} ne $contents[$idx + 1]->{$sort_col}))) {
935
936       my $row = { map { $_ => { 'data' => '', 'class' => 'listsubtotal', 'align' => $column_alignment{$_}, } } @columns };
937       $row->{qty}->{data}         = $form->format_amount(\%myconfig, $subtotals{qty});
938 #      $row->{qty}->{data}         = $form->format_amount_units('amount'     => $subtotals{qty} * 1,
939 #                                                               'part_unit'  => $entry->{partunit},
940 #                                                               'conv_units' => 'convertible');
941       $row->{stock_value}->{data} = $form->format_amount(\%myconfig, $subtotals{stock_value} * 1, 2);
942       $row->{purchase_price}->{data} = $form->format_amount(\%myconfig, $subtotals{purchase_price} * 1, 2);
943
944       %subtotals                  = map { $_ => 0 } @subtotals_columns;
945
946       push @{ $row_set }, $row;
947     }
948
949     if ( $allrows || ($idx >= $first_nr && $idx < $last_nr )) {
950         $report->add_data($row_set);
951     }
952     $idx++;
953   }
954
955   if ( $column_defs{stock_value}->{visible} && !$form->{report_generator_csv_options_for_import} ) {
956     $report->add_separator();
957
958     my $row                      = { map { $_ => { 'data' => '', 'class' => 'listsubtotal', } } @columns };
959
960     my $left_col                 = first { $column_defs{$_}->{visible} } @columns;
961
962     $row->{$left_col}->{data}    = $locale->text('Total stock value');
963     $row->{stock_value}->{data}  = $form->format_amount(\%myconfig, $total_stock_value, 2);
964     $row->{stock_value}->{align} = 'right';
965
966     $report->add_data($row);
967   }
968   if ( ! $allrows ) {
969     $pages->{max}  = SL::DB::Helper::Paginated::ceil($form->{maxrows}, $pages->{per_page}) || 1;
970     $pages->{page} = $page < 1 ? 1: $page > $pages->{max} ? $pages->{max}: $page;
971     $pages->{common} = [ grep { $_->{visible} } @{ SL::DB::Helper::Paginated::make_common_pages($pages->{page}, $pages->{max}) } ];
972
973     $report->set_options('raw_bottom_info_text' => $form->parse_html_template('common/paginate',
974                                                                               {'pages' => $pages , 'base_url' => $href}) );
975   }
976
977   $report->generate_with_headers();
978
979   $main::lxdebug->leave_sub();
980 }
981
982 # --------------------------------------------------------------------
983 # Utility functions
984 # --------------------------------------------------------------------
985
986 sub show_no_warehouses_error {
987   $main::lxdebug->enter_sub();
988
989   my $form     = $main::form;
990   my %myconfig = %main::myconfig;
991   my $locale   = $main::locale;
992
993   my $msg = $locale->text('No warehouse has been created yet or the quantity of the bins is not configured yet.') . ' ';
994
995   if ($main::auth->check_right($::myconfig{login}, 'config')) {
996     $msg .= $locale->text('You can create warehouses and bins via the menu "System -> Warehouses".');
997   } else {
998     $msg .= $locale->text('Please ask your administrator to create warehouses and bins.');
999   }
1000
1001   $form->show_generic_error($msg);
1002
1003   $main::lxdebug->leave_sub();
1004 }
1005
1006 sub get_warehouse_idx {
1007   my ($warehouse_id) = @_;
1008
1009   my $form     = $main::form;
1010
1011   for (my $i = 0; $i < scalar @{$form->{WAREHOUSES}}; $i++) {
1012     return $i if ($form->{WAREHOUSES}->[$i]->{id} == $warehouse_id);
1013   }
1014
1015   return -1;
1016 }
1017
1018 sub get_bin_idx {
1019   my ($warehouse_index, $bin_id) = @_;
1020
1021   my $form     = $main::form;
1022
1023   my $warehouse = $form->{WAREHOUSES}->[$warehouse_index];
1024
1025   return -1 if (!$warehouse);
1026
1027   for (my $i = 0; $i < scalar @{ $warehouse->{BINS} }; $i++) {
1028     return $i if ($warehouse->{BINS}->[$i]->{id} == $bin_id);
1029   }
1030
1031   return -1;
1032 }
1033
1034 sub new_item {
1035   $main::lxdebug->enter_sub();
1036   my %params = @_;
1037
1038   my $form     = $main::form;
1039
1040   # change callback
1041   $form->{old_callback} = $form->escape($form->{callback}, 1);
1042   $form->{callback}     = $form->escape("$form->{script}?action=$params{action}", 1);
1043
1044   # save all form variables except action in a previousform variable
1045   my $previousform = join '&', map { my $value = $form->{$_}; $value =~ s/&/%26/; "$_=$value" } grep { !/action/ } keys %$form;
1046   my @HIDDENS = ();
1047
1048 #  push @HIDDENS,      { 'name' => 'previousform', 'value' => $form->escape($previousform, 1) };
1049   push @HIDDENS, map +{ 'name' => $_,             'value' => $form->{$_} }, qw(partnumber description unit vc sellprice ean);
1050   push @HIDDENS,      { 'name' => 'taxaccount2',  'value' => $form->{taxaccounts} };
1051   push @HIDDENS,      { 'name' => 'notes',        'value' => $form->{longdescription} };
1052
1053   $form->header();
1054   print $form->parse_html_template("generic/new_item", { HIDDENS => [ sort { $a->{name} cmp $b->{name} } @HIDDENS ] } );
1055
1056   $main::lxdebug->leave_sub();
1057 }
1058
1059 sub update {
1060   my $form     = $main::form;
1061   call_sub($form->{update_nextsub} || $form->{nextsub});
1062 }
1063
1064 sub continue {
1065   my $form     = $main::form;
1066   call_sub($form->{continue_nextsub} || $form->{nextsub});
1067 }
1068
1069 sub stock {
1070   my $form     = $main::form;
1071   call_sub($form->{stock_nextsub} || $form->{nextsub});
1072 }
1073
1074 sub setup_wh_transfer_warehouse_selection_action_bar {
1075   my ($action) = @_;
1076
1077   for my $bar ($::request->layout->get('actionbar')) {
1078     $bar->add(
1079       action => [
1080         t8('Update'),
1081         submit    => [ '#form', { action => $action } ],
1082         accesskey => 'enter',
1083       ],
1084     );
1085   }
1086 }
1087
1088 sub setup_wh_transfer_warehouse_selection_assembly_action_bar {
1089   my ($action) = @_;
1090
1091   for my $bar ($::request->layout->get('actionbar')) {
1092     $bar->add(
1093       action => [
1094         t8('Update'),
1095         submit    => [ '#form', { action => 'transfer_assembly_update_part' } ],
1096         accesskey => 'enter',
1097       ],
1098       action => [
1099         t8('Produce'),
1100         submit   => [ '#form', { action => 'create_assembly' } ],
1101         disabled => $::form->{parts_id} ? undef : $::locale->text('No assembly has been selected yet.'),
1102       ],
1103     );
1104   }
1105 }
1106
1107 sub setup_wh_transfer_parts_action_bar {
1108   my ($action) = @_;
1109
1110   for my $bar ($::request->layout->get('actionbar')) {
1111     $bar->add(
1112       action => [
1113         t8('Transfer'),
1114         submit    => [ '#form', { action => 'transfer_parts' } ],
1115         accesskey => 'enter',
1116       ],
1117       action => [
1118         t8('Back'),
1119         call => [ 'kivi.history_back' ],
1120       ],
1121     );
1122   }
1123 }
1124
1125 sub setup_wh_removal_parts_selection_action_bar {
1126   my ($action) = @_;
1127
1128   for my $bar ($::request->layout->get('actionbar')) {
1129     $bar->add(
1130       action => [
1131         t8('Transfer out'),
1132         submit    => [ '#form', { action => 'remove_parts' } ],
1133         accesskey => 'enter',
1134       ],
1135       action => [
1136         t8('Back'),
1137         call => [ 'kivi.history_back' ],
1138       ],
1139     );
1140   }
1141 }
1142
1143 sub setup_wh_report_action_bar {
1144   my ($action) = @_;
1145
1146   for my $bar ($::request->layout->get('actionbar')) {
1147     $bar->add(
1148       action => [
1149         t8('Show'),
1150         submit    => [ '#form', { action => 'generate_report' } ],
1151         accesskey => 'enter',
1152       ],
1153     );
1154   }
1155 }
1156
1157 sub setup_wh_journal_action_bar {
1158   my ($action) = @_;
1159
1160   for my $bar ($::request->layout->get('actionbar')) {
1161     $bar->add(
1162       action => [
1163         t8('Show'),
1164         submit    => [ '#form', { action => 'generate_journal' } ],
1165         accesskey => 'enter',
1166       ],
1167     );
1168   }
1169 }
1170
1171 1;
1172
1173 __END__
1174
1175 =head1 NAME
1176
1177 bin/mozilla/wh.pl - Warehouse frontend.
1178
1179 =head1 FUNCTIONS
1180
1181 =over 4
1182
1183 =item new_item
1184
1185 call new item dialogue from warehouse masks.
1186
1187 PARAMS:
1188   action  => name of sub to be called when new item is done
1189
1190 =back
1191
1192 =cut