1 #=====================================================================
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
10 # Author: Dieter Simader
11 # Email: dsimader@sql-ledger.org
12 # Web: http://www.sql-ledger.org
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #######################################################################
30 # warehouse and packinglist
32 #######################################################################
34 use List::Util qw(min max first);
35 use POSIX qw(strftime);
45 use SL::ReportGenerator;
49 require "bin/mozilla/common.pl";
50 require "bin/mozilla/reportgenerator.pl";
54 # contents of the "transfer_type" table:
55 # $locale->text('back')
56 # $locale->text('correction')
57 # $locale->text('disposed')
58 # $locale->text('found')
59 # $locale->text('missing')
60 # $locale->text('stock')
61 # $locale->text('shipped')
62 # $locale->text('transfer')
63 # $locale->text('used')
64 # $locale->text('return_material')
65 # $locale->text('release_material')
67 # --------------------------------------------------------------------
69 # --------------------------------------------------------------------
71 sub transfer_warehouse_selection {
72 $lxdebug->enter_sub();
74 $auth->assert('warehouse_management');
76 $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES',
79 show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} });
81 my $units = AM->retrieve_units(\%myconfig, $form);
82 $form->{UNITS} = AM->unit_select_data($units, $form->{unit}, 0, $form->{partunit});
84 if (scalar @{ $form->{WAREHOUSES} }) {
85 $form->{warehouse_id} ||= $form->{WAREHOUSES}->[0]->{id};
86 $form->{bin_id} ||= $form->{WAREHOUSES}->[0]->{BINS}->[0]->{id};
91 $form->{jsscript} = 1;
93 if ($form->{trans_type} eq 'removal') {
94 $form->{nextsub} = "removal_parts_selection";
95 $form->{title} = $locale->text('Removal from Warehouse');
96 $content = $form->parse_html_template('wh/warehouse_selection');
98 } elsif ($form->{trans_type} eq 'stock') {
99 $form->{title} = $locale->text('Stock');
100 $content = $form->parse_html_template('wh/warehouse_selection_stock');
102 } elsif (!$form->{trans_type} || ($form->{trans_type} eq 'transfer')) {
103 $form->{nextsub} = "transfer_parts_selection";
104 $form->{title} = $locale->text('Transfer');
105 $content = $form->parse_html_template('wh/warehouse_selection');
112 $lxdebug->leave_sub();
115 sub transfer_parts_selection {
116 $lxdebug->enter_sub();
118 $auth->assert('warehouse_management');
120 transfer_or_removal_prepare_contents('direction' => 'transfer');
122 $form->{title} = $locale->text('Transfer');
124 print $form->parse_html_template("wh/transfer_parts_selection");
126 $lxdebug->leave_sub();
129 sub transfer_or_removal_prepare_contents {
130 $lxdebug->enter_sub();
132 $auth->assert('warehouse_management');
136 $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES',
137 'bins' => 'BINS', });
139 my $warehouse_idx = get_warehouse_idx($form->{warehouse_id});
140 $form->show_generic_error($locale->text("The selected warehouse does not exist.")) if (-1 == $warehouse_idx);
142 my $warehouse = $form->{WAREHOUSES}->[$warehouse_idx];
144 $form->{initial_warehouse_idx} = $warehouse_idx;
145 $form->{warehouse_description} = $warehouse->{description};
146 $warehouse->{selected} = 1;
148 $form->show_generic_error($locale->text("The source warehouse does not contain any bins.")) if (0 == scalar @{ $warehouse->{BINS} });
150 map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber partunit);
152 $form->{sort} = 'bindescription';
153 my @contents = WH->get_warehouse_report("warehouse_id" => $form->{warehouse_id},
154 "bin_id" => $form->{bin_id},
155 "chargenumber" => $form->{chargenumber},
156 "partnumber" => $form->{partnumber},
157 "description" => $form->{description});
159 $form->show_generic_error($locale->text("The selected warehouse is empty.")) if (0 == scalar(@contents));
161 my $all_units = AM->retrieve_units(\%myconfig, $form);
163 foreach (@contents) {
164 $_->{qty} = $form->format_amount_units('amount' => $_->{qty},
165 'part_unit' => $_->{partunit},
166 'conv_units' => 'convertible');
167 my $this_unit = $_->{partunit};
169 if ($all_units->{$_->{partunit}} && ($all_units->{g}->{base_unit} eq $all_units->{$_->{partunit}}->{base_unit})) {
173 $_->{UNITS} = AM->unit_select_data($all_units, $this_unit, 0, $_->{partunit});
176 my $transfer_types = WH->retrieve_transfer_types($args{direction});
177 map { $_->{description} = $locale->text($_->{description}) } @{ $transfer_types };
179 $form->{CONTENTS} = \@contents;
180 $form->{TRANSFER_TYPES} = $transfer_types;
182 $lxdebug->leave_sub();
187 $lxdebug->enter_sub();
189 $auth->assert('warehouse_management');
191 $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES', 'bins' => 'BINS' });
193 my $warehouse_idx = get_warehouse_idx($form->{warehouse_id});
194 $form->show_generic_error($locale->text("The selected warehouse does not exist.")) if (-1 == $warehouse_idx);
196 my $warehouse = $form->{WAREHOUSES}->[$warehouse_idx];
198 $form->show_generic_error($locale->text("The source warehouse does not contain any bins.")) if (0 == scalar @{ $warehouse->{BINS} });
200 map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber partunit);
202 $form->{sort} = 'bindescription';
203 my @contents = WH->get_warehouse_report("warehouse_id" => $form->{warehouse_id});
204 my $all_units = AM->retrieve_units(\%myconfig, $form);
208 foreach my $row (1 .. $form->{rowcount}) {
209 $form->{"qty_$row"} =~ s/^\s*//;
210 $form->{"qty_$row"} =~ s/\s*$//;
211 next if (!$form->{"qty_$row"});
213 my $bin_idx = get_bin_idx($warehouse_idx, $form->{"src_bin_id_$row"});
214 $form->show_generic_error($locale->text("The selected bin does not exist.")) if (-1 == $bin_idx);
215 my $bin = $warehouse->{BINS}->[$bin_idx];
217 my $orig_qty = $form->{"qty_$row"} . " " . $form->{"unit_$row"};
220 'src_warehouse_id' => $form->{warehouse_id},
221 'transfer_type_id' => $form->{transfer_type_id},
224 map { $transfer->{$_} = $form->{"${_}_${row}"} } qw(src_bin_id chargenumber parts_id qty dst_warehouse_id dst_bin_id);
228 foreach (@contents) {
229 if (($_->{binid} == $transfer->{src_bin_id}) && ($_->{parts_id} == $transfer->{parts_id}) && ($_->{chargenumber} eq $transfer->{chargenumber})) {
236 $form->error($locale->text("There is not enough left of '#1' in bin '#2' for the removal of #3.",
237 $form->{"partdescription_$row"}, $bin->{description}, $orig_qty));
240 $transfer->{qty} = $form->parse_amount(\%myconfig, $transfer->{qty}) * $all_units->{$form->{"unit_$row"}}->{factor};
241 $transfer->{qty} /= $all_units->{$entry->{partunit}}->{factor} || 1;
243 if (($entry->{qty} < $transfer->{qty}) || (0 >= $transfer->{qty})) {
244 $form->error($locale->text("There is not enough left of '#1' in bin '#2' for the removal of #3.",
245 $form->{"partdescription_$row"}, $bin->{description}, $orig_qty));
248 $transfer->{comment} = $form->{comment};
250 push @transfers, $transfer;
252 $entry->{qty} -= $transfer->{qty};
255 if (!scalar @transfers) {
256 $form->show_generic_information($locale->text('Nothing has been selected for transfer.'));
260 WH->transfer(@transfers);
262 $form->{trans_type} = 'transfer';
263 $form->{saved_message} = $locale->text('The parts have been transferred.');
265 transfer_warehouse_selection();
267 $lxdebug->leave_sub();
270 # --------------------------------------------------------------------
272 # --------------------------------------------------------------------
274 sub transfer_stock_update_part {
275 $lxdebug->enter_sub();
277 $form->{trans_type} = 'stock';
278 $form->{qty} = $form->parse_amount(\%myconfig, $form->{qty});
280 if (!$form->{partnumber} && !$form->{description}) {
281 delete @{$form}{qw(parts_id partunit)};
282 transfer_warehouse_selection();
284 } elsif (($form->{partnumber} && ($form->{partnumber} ne $form->{old_partnumber})) || $form->{description}) {
286 $form->{no_services} = 1;
287 $form->{no_assemblies} = 1;
289 my $parts = Common->retrieve_parts(\%myconfig, $form, 'description', 1);
291 if (scalar @{ $parts } == 1) {
292 @{$form}{qw(parts_id partnumber description)} = @{$parts->[0]}{qw(id partnumber description)};
293 transfer_stock_get_partunit();
294 transfer_warehouse_selection();
297 select_part('transfer_stock_part_selected', @{ $parts });
301 transfer_stock_get_partunit();
302 transfer_warehouse_selection();
305 $lxdebug->leave_sub();
308 sub transfer_stock_part_selected {
309 $lxdebug->enter_sub();
313 @{$form}{qw(parts_id partnumber description)} = @{$part}{qw(id partnumber description)};
315 transfer_stock_get_partunit();
316 transfer_warehouse_selection();
318 $lxdebug->leave_sub();
321 sub transfer_stock_get_partunit {
322 $lxdebug->enter_sub();
324 if ($form->{parts_id}) {
325 my $part_info = IC->get_basic_part_info('id' => $form->{parts_id});
326 $form->{partunit} = $part_info->{unit};
329 $lxdebug->leave_sub();
333 $lxdebug->enter_sub();
335 $form->{qty} = $form->parse_amount(\%myconfig, $form->{qty});
337 if ($form->{qty} <= 0) {
338 $form->show_generic_error($locale->text('Invalid quantity.'), 'back_button' => 1);
341 if (!$form->{warehouse_id} || !$form->{bin_id}) {
342 $form->error($locale->text('The warehouse or the bin is missing.'));
346 'transfer_type' => 'stock',
347 'dst_warehouse_id' => $form->{warehouse_id},
348 'dst_bin_id' => $form->{bin_id},
349 'chargenumber' => $form->{chargenumber},
350 'parts_id' => $form->{parts_id},
351 'qty' => $form->{qty},
352 'unit' => $form->{unit},
353 'comment' => $form->{comment},
356 WH->transfer($transfer);
358 delete @{$form}{qw(parts_id partnumber description qty unit chargenumber comment)};
360 $form->{saved_message} = $locale->text('The parts have been stocked.');
361 $form->{trans_type} = 'stock';
363 transfer_warehouse_selection();
365 $lxdebug->leave_sub();
368 # --------------------------------------------------------------------
370 # --------------------------------------------------------------------
372 sub removal_parts_selection {
373 $lxdebug->enter_sub();
375 $auth->assert('warehouse_management');
377 transfer_or_removal_prepare_contents('direction' => 'out');
379 $form->{title} = $locale->text('Removal');
381 print $form->parse_html_template("wh/removal_parts_selection");
383 $lxdebug->leave_sub();
387 $lxdebug->enter_sub();
389 $auth->assert('warehouse_management');
391 $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES',
392 'bins' => 'BINS', });
394 my $warehouse_idx = get_warehouse_idx($form->{warehouse_id});
395 $form->show_generic_error($locale->text("The selected warehouse does not exist.")) if (-1 == $warehouse_idx);
397 my $warehouse = $form->{WAREHOUSES}->[$warehouse_idx];
399 $form->show_generic_error($locale->text("The warehouse does not contain any bins.")) if (0 == scalar @{ $warehouse->{BINS} });
401 map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber partunit);
403 $form->{sort} = 'bindescription';
404 my @contents = WH->get_warehouse_report("warehouse_id" => $form->{warehouse_id});
405 my $all_units = AM->retrieve_units(\%myconfig, $form);
409 foreach my $row (1 .. $form->{rowcount}) {
410 $form->{"qty_$row"} =~ s/^\s*//;
411 $form->{"qty_$row"} =~ s/\s*$//;
412 next if (!$form->{"qty_$row"});
414 my $bin_idx = get_bin_idx($warehouse_idx, $form->{"src_bin_id_$row"});
415 $form->show_generic_error($locale->text("The selected bin does not exist.")) if (-1 == $bin_idx);
416 my $bin = $warehouse->{BINS}->[$bin_idx];
418 my $orig_qty = $form->{"qty_$row"} . " " . $form->{"unit_$row"};
421 'src_warehouse_id' => $form->{warehouse_id},
422 'transfer_type_id' => $form->{transfer_type_id},
425 map { $transfer->{$_} = $form->{"${_}_${row}"} } qw(src_bin_id chargenumber parts_id qty);
429 foreach (@contents) {
430 if (($_->{binid} == $transfer->{src_bin_id}) && ($_->{parts_id} == $transfer->{parts_id}) && ($_->{chargenumber} eq $transfer->{chargenumber})) {
437 $form->error($locale->text("There is not enough left of '#1' in bin '#2' for the removal of #3.",
438 $form->{"partdescription_$row"}, $bin->{description}, $orig_qty));
441 $transfer->{qty} = $form->parse_amount(\%myconfig, $transfer->{qty}) * $all_units->{$form->{"unit_$row"}}->{factor};
442 $transfer->{qty} /= $all_units->{$entry->{partunit}}->{factor} || 1;
444 if (($entry->{qty} < $transfer->{qty}) || (0 >= $transfer->{qty})) {
445 $form->error($locale->text("There is not enough left of '#1' in bin '#2' for the removal of #3.",
446 $form->{"partdescription_$row"}, $bin->{description}, $orig_qty));
449 $transfer->{comment} = $form->{comment};
451 push @transfers, $transfer;
453 $entry->{qty} -= $transfer->{qty};
456 if (!scalar @transfers) {
457 $form->show_generic_information($locale->text('Nothing has been selected for removal.'));
461 WH->transfer(@transfers);
463 $form->{trans_type} = 'removal';
464 $form->{saved_message} = $locale->text('The parts have been removed.');
466 transfer_warehouse_selection();
468 $lxdebug->leave_sub();
471 # --------------------------------------------------------------------
473 # --------------------------------------------------------------------
476 $lxdebug->enter_sub();
478 $auth->assert('warehouse_management');
480 $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES',
481 'bins' => 'BINS', });
483 show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} });
485 $form->{jsscript} = 1;
488 print $form->parse_html_template("wh/journal_filter", { "UNITS" => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)) });
490 $lxdebug->leave_sub();
493 sub generate_journal {
494 $lxdebug->enter_sub();
496 $auth->assert('warehouse_management');
498 $form->{title} = $locale->text("WHJournal");
499 $form->{sort} ||= 'date';
502 my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber partdescription chargenumber trans_type comment qty employee projectnumber);
505 map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber);
507 $filter{qty_op} = WH->convert_qty_op($form->{qty_op});
508 if ($filter{qty_op}) {
509 $form->isblank(qty, $locale->text('Quantity missing.'));
510 $form->isblank(qty_unit, $locale->text('Unit missing.'));
512 $filter{qty} = $form->{qty};
513 $filter{qty_unit} = $form->{qty_unit};
517 my $report = SL::ReportGenerator->new(\%myconfig, $form);
519 my @hidden_variables = map { "l_${_}" } @columns;
520 push @hidden_variables, qw(warehouse_id bin_id partnumber description chargenumber qty_op qty qty_unit fromdate todate);
523 'date' => { 'text' => $locale->text('Date'), },
524 'trans_id' => { 'text' => $locale->text('Trans Id'), },
525 'trans_type' => { 'text' => $locale->text('Trans Type'), },
526 'comment' => { 'text' => $locale->text('Comment'), },
527 'warehouse_from' => { 'text' => $locale->text('Warehouse From'), },
528 'warehouse_to' => { 'text' => $locale->text('Warehouse To'), },
529 'bin_from' => { 'text' => $locale->text('Bin From'), },
530 'bin_to' => { 'text' => $locale->text('Bin To'), },
531 'partnumber' => { 'text' => $locale->text('Part Number'), },
532 'partdescription' => { 'text' => $locale->text('Description'), },
533 'chargenumber' => { 'text' => $locale->text('Charge Number'), },
534 'qty' => { 'text' => $locale->text('Qty'), },
535 'employee' => { 'text' => $locale->text('Employee'), },
536 'projectnumber' => { 'text' => $locale->text('Project Number'), },
539 my $href = build_std_url('action=generate_journal', grep { $form->{$_} } @hidden_variables);
540 map { $column_defs{$_}->{link} = $href . "&sort=${_}&order=" . Q($_ eq $form->{sort} ? 1 - $form->{order} : $form->{order}) } @columns;
542 my %column_alignment = map { $_ => 'right' } qw(qty);
544 map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
546 $report->set_columns(%column_defs);
547 $report->set_column_order(@columns);
549 $report->set_export_options('generate_journal', @hidden_variables);
551 $report->set_sort_indicator($form->{sort}, $form->{order});
553 $report->set_options('output_format' => 'HTML',
554 'title' => $form->{title},
555 'attachment_basename' => strftime('warehouse_journal_%Y%m%d', localtime time));
556 $report->set_options_from_form();
558 my $all_units = AM->retrieve_units(\%myconfig, $form);
559 my @contents = WH->get_warehouse_journal(%filter);
561 foreach $entry (@contents) {
562 $entry->{qty} = $form->format_amount_units('amount' => $entry->{qty},
563 'part_unit' => $entry->{partunit},
564 'conv_units' => 'convertible');
565 $entry->{trans_type} = $locale->text($entry->{trans_type});
569 foreach my $column (@columns) {
570 next if ($column eq 'trans_type');
573 'data' => $entry->{$column},
574 'align' => $column_alignment{$column},
578 $row->{trans_type} = {
579 'raw_data' => $entry->{trans_type},
580 'align' => $column_alignment{trans_type},
583 $report->add_data($row);
586 $report->generate_with_headers();
588 $lxdebug->leave_sub();
591 # --------------------------------------------------------------------
593 # --------------------------------------------------------------------
596 $lxdebug->enter_sub();
598 $auth->assert('warehouse_content | warehouse_management');
600 $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES',
601 'bins' => 'BINS', });
603 show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} });
605 $form->{onload} .= "fokus('partnumber');";
606 $form->{title} = $locale->text("Report about wareouse contents");
609 print $form->parse_html_template("wh/report_filter",
610 { "nextsub" => "generate_report",
611 "WAREHOUSES" => $form->{WAREHOUSES},
612 "UNITS" => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)) });
614 $lxdebug->leave_sub();
617 sub generate_report {
618 $lxdebug->enter_sub();
620 $auth->assert('warehouse_content | warehouse_management');
622 $form->{title} = $locale->text("Report about wareouse contents");
623 $form->{sort} ||= 'partnumber';
624 my $sort_col = $form->{sort};
627 my @columns = qw(warehousedescription bindescription partnumber partdescription chargenumber qty);
630 map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber);
632 $filter{qty_op} = WH->convert_qty_op($form->{qty_op});
633 if ($filter{qty_op}) {
634 $form->isblank(qty, $locale->text('Quantity missing.'));
635 $form->isblank(qty_unit, $locale->text('Unit missing.'));
637 $filter{qty} = $form->{qty};
638 $filter{qty_unit} = $form->{qty_unit};
642 $form->{subtotal} = '' if (!first { $_ eq $sort_col } qw(partnumber partdescription));
644 my $report = SL::ReportGenerator->new(\%myconfig, $form);
646 my @hidden_variables = map { "l_${_}" } @columns;
647 push @hidden_variables, qw(warehouse_id bin_id partnumber description chargenumber qty_op qty qty_unit l_warehousedescription l_bindescription);
648 push @hidden_variables, qw(include_empty_bins subtotal);
651 'warehousedescription' => { 'text' => $locale->text('Warehouse'), },
652 'bindescription' => { 'text' => $locale->text('Bin'), },
653 'partnumber' => { 'text' => $locale->text('Part Number'), },
654 'partdescription' => { 'text' => $locale->text('Description'), },
655 'chargenumber' => { 'text' => $locale->text('Charge Number'), },
656 'qty' => { 'text' => $locale->text('Qty'), },
659 my $href = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
660 map { $column_defs{$_}->{link} = $href . "&sort=${_}&order=" . Q($_ eq $sort_col ? 1 - $form->{order} : $form->{order}) } @columns;
662 my %column_alignment = map { $_ => 'right' } qw(qty);
664 map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
666 $report->set_columns(%column_defs);
667 $report->set_column_order(@columns);
669 $report->set_export_options('generate_report', @hidden_variables);
671 $report->set_sort_indicator($sort_col, $form->{order});
673 $report->set_options('output_format' => 'HTML',
674 'title' => $form->{title},
675 'attachment_basename' => strftime('warehouse_report_%Y%m%d', localtime time));
676 $report->set_options_from_form();
678 my $all_units = AM->retrieve_units(\%myconfig, $form);
679 my @contents = WH->get_warehouse_report(%filter);
684 foreach $entry (@contents) {
685 $subtotal += $entry->{qty};
686 $entry->{qty} = $form->format_amount_units('amount' => $entry->{qty},
687 'part_unit' => $entry->{partunit},
688 'conv_units' => 'convertible');
690 $row_set = [ { map { $_ => { 'data' => $entry->{$_}, 'align' => $column_alignment{$_} } } @columns } ];
692 if (($form->{subtotal} eq 'Y')
693 && (($idx == (scalar @contents - 1))
694 || ($entry->{$sort_col} ne $contents[$idx + 1]->{$sort_col}))) {
696 my $row = { map { $_ => { 'data' => '', 'class' => 'listsubtotal', 'align' => $column_alignment{$_}, } } @columns };
697 $row->{qty}->{data} = $form->format_amount_units('amount' => $subtotal,
698 'part_unit' => $entry->{partunit},
699 'conv_units' => 'convertible');
702 push @{ $row_set }, $row;
705 $report->add_data($row_set);
710 $report->generate_with_headers();
712 $lxdebug->leave_sub();
715 # --------------------------------------------------------------------
717 # --------------------------------------------------------------------
719 sub show_no_warehouses_error {
720 $lxdebug->enter_sub();
722 my $msg = $locale->text('No warehouse has been created yet.') . ' ';
724 if ($auth->check_right($form->{login}, 'config')) {
725 $msg .= $locale->text('You can create warehouses and bins via the menu "System -> Warehouses".');
727 $msg .= $locale->text('Please ask your administrator to create warehouses and bins.');
730 $form->show_generic_error($msg);
732 $lxdebug->leave_sub();
735 sub get_warehouse_idx {
736 my ($warehouse_id) = @_;
738 for (my $i = 0; $i < scalar @{$form->{WAREHOUSES}}; $i++) {
739 return $i if ($form->{WAREHOUSES}->[$i]->{id} == $warehouse_id);
746 my ($warehouse_index, $bin_id) = @_;
748 my $warehouse = $form->{WAREHOUSES}->[$warehouse_index];
750 return -1 if (!$warehouse);
752 for (my $i = 0; $i < scalar @{ $warehouse->{BINS} }; $i++) {
753 return $i if ($warehouse->{BINS}->[$i]->{id} == $bin_id);
760 call_sub($form->{update_nextsub} || $form->{nextsub});
764 call_sub($form->{continue_nextsub} || $form->{nextsub});
768 call_sub($form->{stock_nextsub} || $form->{nextsub});