X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fwh.pl;h=6d39dda4275c919925f91de16958bb72b2976a63;hb=fe73e0d261229f181e8133283b530509773d2151;hp=178de9f131aad03c1cc64bb6d8191b94aac1d291;hpb=21ca8cb76721b756440cfe75fd8710bfe1caf31b;p=kivitendo-erp.git diff --git a/bin/mozilla/wh.pl b/bin/mozilla/wh.pl index 178de9f13..6d39dda42 100644 --- a/bin/mozilla/wh.pl +++ b/bin/mozilla/wh.pl @@ -49,6 +49,8 @@ use Data::Dumper; require "bin/mozilla/common.pl"; require "bin/mozilla/reportgenerator.pl"; +use strict; + # parserhappy(R): # contents of the "transfer_type" table: @@ -69,9 +71,13 @@ require "bin/mozilla/reportgenerator.pl"; # -------------------------------------------------------------------- sub transfer_warehouse_selection { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('warehouse_management'); - $auth->assert('warehouse_management'); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES', 'bins' => 'BINS', }); @@ -112,13 +118,17 @@ sub transfer_warehouse_selection { $form->header(); print $content; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub transfer_parts_selection { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('warehouse_management'); - $auth->assert('warehouse_management'); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; transfer_or_removal_prepare_contents('direction' => 'transfer'); @@ -126,16 +136,20 @@ sub transfer_parts_selection { $form->header(); print $form->parse_html_template("wh/transfer_parts_selection"); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub transfer_or_removal_prepare_contents { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); - $auth->assert('warehouse_management'); + $main::auth->assert('warehouse_management'); my %args = @_; + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; + $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES', 'bins' => 'BINS', }); @@ -150,7 +164,7 @@ sub transfer_or_removal_prepare_contents { $form->show_generic_error($locale->text("The source warehouse does not contain any bins.")) if (0 == scalar @{ $warehouse->{BINS} }); - map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber partunit); + map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber partunit ean); $form->{sort} = 'bindescription'; my @contents = WH->get_warehouse_report("warehouse_id" => $form->{warehouse_id}, @@ -183,14 +197,18 @@ sub transfer_or_removal_prepare_contents { $form->{CONTENTS} = \@contents; $form->{TRANSFER_TYPES} = $transfer_types; - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub transfer_parts { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('warehouse_management'); - $auth->assert('warehouse_management'); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES', 'bins' => 'BINS' }); @@ -268,7 +286,7 @@ sub transfer_parts { transfer_warehouse_selection(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } # -------------------------------------------------------------------- @@ -276,24 +294,30 @@ sub transfer_parts { # -------------------------------------------------------------------- sub transfer_stock_update_part { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; $form->{trans_type} = 'stock'; $form->{qty} = $form->parse_amount(\%myconfig, $form->{qty}); - if (!$form->{partnumber} && !$form->{description}) { - delete @{$form}{qw(parts_id partunit)}; + if (!$form->{partnumber} && !$form->{description} && !$form->{ean}) { + delete @{$form}{qw(parts_id partunit ean)}; transfer_warehouse_selection(); - } elsif (($form->{partnumber} && ($form->{partnumber} ne $form->{old_partnumber})) || $form->{description}) { + } elsif (($form->{partnumber} && ($form->{partnumber} ne $form->{old_partnumber})) || $form->{description} || $form->{ean}) { $form->{no_services} = 1; - $form->{no_assemblies} = 1; + $form->{no_assemblies} = 0; # assemblies duerfen eingelagert werden (z.B. bei retouren) my $parts = Common->retrieve_parts(\%myconfig, $form, 'description', 1); - if (scalar @{ $parts } == 1) { - @{$form}{qw(parts_id partnumber description)} = @{$parts->[0]}{qw(id partnumber description)}; + if (!scalar @{ $parts }) { + new_item(action => "transfer_stock_update_part"); + } elsif (scalar @{ $parts } == 1) { + @{$form}{qw(parts_id partnumber description ean)} = @{$parts->[0]}{qw(id partnumber description ean)}; transfer_stock_get_partunit(); transfer_warehouse_selection(); @@ -306,19 +330,23 @@ sub transfer_stock_update_part { transfer_warehouse_selection(); } - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } # -------------------------------------------------------------------- # Transfer: assemblies -# Dies ist die Auswahlmaske für ein assembly. +# Dies ist die Auswahlmaske für ein assembly. # Die ist einfach von transfer_assembly_update_part kopiert und nur um den trans_type (assembly) korrigiert worden # Es wäre schön, hier nochmal check_assembly_max_create auf, um die max. Fertigungszahl herauszufinden. # Ich lass das mal als auskommentierte Idee bestehen jb 18.3.09 # -------------------------------------------------------------------- sub transfer_assembly_update_part { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; $form->{trans_type} = 'assembly'; $form->{qty} = $form->parse_amount(\%myconfig, $form->{qty}); @@ -345,31 +373,36 @@ sub transfer_assembly_update_part { } # hier die oben benannte idee -# my $maxcreate = Common->check_assembly_max_create(assembly_id => $form->{parts_id}, dbh => $my_dbh); - $lxdebug->leave_sub(); +# my $maxcreate = Common->check_assembly_max_create(assembly_id => $form->{parts_id}, dbh => $my_dbh); + $main::lxdebug->leave_sub(); } + sub transfer_stock_part_selected { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my $part = shift; - @{$form}{qw(parts_id partnumber description)} = @{$part}{qw(id partnumber description)}; + my $form = $main::form; + + @{$form}{qw(parts_id partnumber description ean)} = @{$part}{qw(id partnumber description ean)}; transfer_stock_get_partunit(); transfer_warehouse_selection(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub transfer_stock_get_partunit { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; if ($form->{parts_id}) { my $part_info = IC->get_basic_part_info('id' => $form->{parts_id}); $form->{partunit} = $part_info->{unit}; } - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } # vorüberlegung jb 22.2.2009 @@ -380,17 +413,21 @@ sub transfer_stock_get_partunit { # Laut Absprache in KW11 09 übernimmt mb hier den rest im April ... jb 18.3.09 sub create_assembly { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; $form->{qty} = $form->parse_amount(\%myconfig, $form->{qty}); if ($form->{qty} <= 0) { $form->show_generic_error($locale->text('Invalid quantity.'), 'back_button' => 1); } - # TODO Es wäre schön, hier schon die maximale Anzahl der zu fertigenden Erzeugnisse zu haben + # TODO Es wäre schön, hier schon die maximale Anzahl der zu fertigenden Erzeugnisse zu haben #else { if ($form->{qty} > $maxcreate) { #s.o. # $form->show_generic_error($locale->text('Can not create that quantity with current stock'), 'back_button' => 1); # $form->show_generic_error('Maximale Stückzahl' . $maxcreate , 'back_button' => 1); - # } + # } # } if (!$form->{warehouse_id} || !$form->{bin_id}) { @@ -400,11 +437,11 @@ sub create_assembly { # Anm. jb 18.3. vielleicht auch nur meine unwissenheit in perl-datenstrukturen my %TRANSFER = ( 'transfer_type' => 'assembly', - 'login' => $form->{login}, + 'login' => $form->{login}, 'dst_warehouse_id' => $form->{warehouse_id}, 'dst_bin_id' => $form->{bin_id}, 'chargenumber' => $form->{chargenumber}, - 'assembly_id' => $form->{parts_id}, + 'assembly_id' => $form->{parts_id}, 'qty' => $form->{qty}, 'unit' => $form->{unit}, 'comment' => $form->{comment} @@ -425,11 +462,15 @@ sub create_assembly { transfer_warehouse_selection(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub transfer_stock { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; $form->{qty} = $form->parse_amount(\%myconfig, $form->{qty}); @@ -461,7 +502,7 @@ sub transfer_stock { transfer_warehouse_selection(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } # -------------------------------------------------------------------- @@ -469,9 +510,13 @@ sub transfer_stock { # -------------------------------------------------------------------- sub removal_parts_selection { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('warehouse_management'); - $auth->assert('warehouse_management'); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; transfer_or_removal_prepare_contents('direction' => 'out'); @@ -479,13 +524,17 @@ sub removal_parts_selection { $form->header(); print $form->parse_html_template("wh/removal_parts_selection"); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub remove_parts { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('warehouse_management'); - $auth->assert('warehouse_management'); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES', 'bins' => 'BINS', }); @@ -564,7 +613,7 @@ sub remove_parts { transfer_warehouse_selection(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } # -------------------------------------------------------------------- @@ -572,9 +621,12 @@ sub remove_parts { # -------------------------------------------------------------------- sub journal { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); - $auth->assert('warehouse_management'); + $main::auth->assert('warehouse_management'); + + my $form = $main::form; + my %myconfig = %main::myconfig; $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES', 'bins' => 'BINS', }); @@ -586,27 +638,31 @@ sub journal { $form->header(); print $form->parse_html_template("wh/journal_filter", { "UNITS" => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)) }); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub generate_journal { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('warehouse_management'); - $auth->assert('warehouse_management'); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; $form->{title} = $locale->text("WHJournal"); $form->{sort} ||= 'date'; my %filter; - my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber partdescription chargenumber trans_type comment qty employee projectnumber); + my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber partdescription chargenumber trans_type comment qty employee oe_id projectnumber); # filter stuff map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber); $filter{qty_op} = WH->convert_qty_op($form->{qty_op}); if ($filter{qty_op}) { - $form->isblank(qty, $locale->text('Quantity missing.')); - $form->isblank(qty_unit, $locale->text('Unit missing.')); + $form->isblank("qty", $locale->text('Quantity missing.')); + $form->isblank("qty_unit", $locale->text('Unit missing.')); $filter{qty} = $form->{qty}; $filter{qty_unit} = $form->{qty_unit}; @@ -633,6 +689,7 @@ sub generate_journal { 'qty' => { 'text' => $locale->text('Qty'), }, 'employee' => { 'text' => $locale->text('Employee'), }, 'projectnumber' => { 'text' => $locale->text('Project Number'), }, + 'oe_id' => { 'text' => $locale->text('Document'), }, ); my $href = build_std_url('action=generate_journal', grep { $form->{$_} } @hidden_variables); @@ -645,19 +702,29 @@ sub generate_journal { $report->set_columns(%column_defs); $report->set_column_order(@columns); - $report->set_export_options('generate_journal', @hidden_variables); + $report->set_export_options('generate_journal', @hidden_variables, qw(sort order)); $report->set_sort_indicator($form->{sort}, $form->{order}); $report->set_options('output_format' => 'HTML', 'title' => $form->{title}, - 'attachment_basename' => strftime('warehouse_journal_%Y%m%d', localtime time)); + 'attachment_basename' => strftime($locale->text('warehouse_journal_list') . '_%Y%m%d', localtime time)); $report->set_options_from_form(); my $all_units = AM->retrieve_units(\%myconfig, $form); my @contents = WH->get_warehouse_journal(%filter); - foreach $entry (@contents) { + my %doc_types = ( 'sales_quotation' => { script => 'oe', title => $locale->text('Sales quotation') }, + 'sales_order' => { script => 'oe', title => $locale->text('Sales Order') }, + 'request_quotation' => { script => 'oe', title => $locale->text('Request quotation') }, + 'purchase_order' => { script => 'oe', title => $locale->text('Purchase Order') }, + 'sales_delivery_order' => { script => 'do', title => $locale->text('Sales delivery order') }, + 'purchase_delivery_order' => { script => 'do', title => $locale->text('Purchase delivery order') }, + 'sales_invoice' => { script => 'is', title => $locale->text('Sales Invoice') }, + 'purchase_invoice' => { script => 'ir', title => $locale->text('Purchase Invoice') }, + ); + + foreach my $entry (@contents) { $entry->{qty} = $form->format_amount_units('amount' => $entry->{qty}, 'part_unit' => $entry->{partunit}, 'conv_units' => 'convertible'); @@ -679,12 +746,22 @@ sub generate_journal { 'align' => $column_alignment{trans_type}, }; + if ($form->{l_oe_id}) { + $row->{oe_id}->{data} = ''; + my $info = $entry->{oe_id_info}; + + if ($info && $info->{id} && $info->{type} && $doc_types{$info->{type}}) { + $row->{oe_id} = { data => $doc_types{ $info->{type} }->{title} . ' ' . $info->{number}, + link => build_std_url('script=' . $doc_types{ $info->{type} }->{script} . '.pl', 'action=edit', 'id=' . $info->{id}, 'type=' . $info->{type}) }; + } + } + $report->add_data($row); } $report->generate_with_headers(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } # -------------------------------------------------------------------- @@ -692,9 +769,13 @@ sub generate_journal { # -------------------------------------------------------------------- sub report { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('warehouse_contents | warehouse_management'); - $auth->assert('warehouse_contents | warehouse_management'); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; $form->get_lists('warehouses' => { 'key' => 'WAREHOUSES', 'bins' => 'BINS', }); @@ -711,13 +792,17 @@ sub report { "WAREHOUSES" => $form->{WAREHOUSES}, "UNITS" => AM->unit_select_data(AM->retrieve_units(\%myconfig, $form)) }); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub generate_report { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + $main::auth->assert('warehouse_contents | warehouse_management'); - $auth->assert('warehouse_contents | warehouse_management'); + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; $form->{title} = $locale->text("Report about wareouse contents"); $form->{sort} ||= 'partnumber'; @@ -731,8 +816,8 @@ sub generate_report { $filter{qty_op} = WH->convert_qty_op($form->{qty_op}); if ($filter{qty_op}) { - $form->isblank(qty, $locale->text('Quantity missing.')); - $form->isblank(qty_unit, $locale->text('Unit missing.')); + $form->isblank("qty", $locale->text('Quantity missing.')); + $form->isblank("qty_unit", $locale->text('Unit missing.')); $filter{qty} = $form->{qty}; $filter{qty_unit} = $form->{qty_unit}; @@ -767,13 +852,13 @@ sub generate_report { $report->set_columns(%column_defs); $report->set_column_order(@columns); - $report->set_export_options('generate_report', @hidden_variables); + $report->set_export_options('generate_report', @hidden_variables, qw(sort order)); $report->set_sort_indicator($sort_col, $form->{order}); $report->set_options('output_format' => 'HTML', 'title' => $form->{title}, - 'attachment_basename' => strftime('warehouse_report_%Y%m%d', localtime time)); + 'attachment_basename' => strftime($locale->text('warehouse_report_list') . '_%Y%m%d', localtime time)); $report->set_options_from_form(); my $all_units = AM->retrieve_units(\%myconfig, $form); @@ -786,7 +871,7 @@ sub generate_report { my $total_stock_value = 0; - foreach $entry (@contents) { + foreach my $entry (@contents) { map { $subtotals{$_} += $entry->{$_} } @subtotals_columns; $total_stock_value += $entry->{stock_value} * 1; @@ -795,7 +880,7 @@ sub generate_report { 'conv_units' => 'convertible'); $entry->{stock_value} = $form->format_amount(\%myconfig, $entry->{stock_value} * 1, 2); - $row_set = [ { map { $_ => { 'data' => $entry->{$_}, 'align' => $column_alignment{$_} } } @columns } ]; + my $row_set = [ { map { $_ => { 'data' => $entry->{$_}, 'align' => $column_alignment{$_} } } @columns } ]; if (($form->{subtotal} eq 'Y') && (($idx == (scalar @contents - 1)) @@ -833,7 +918,7 @@ sub generate_report { $report->generate_with_headers(); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } # -------------------------------------------------------------------- @@ -841,11 +926,15 @@ sub generate_report { # -------------------------------------------------------------------- sub show_no_warehouses_error { - $lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); + + my $form = $main::form; + my %myconfig = %main::myconfig; + my $locale = $main::locale; my $msg = $locale->text('No warehouse has been created yet or the quantity of the bins is not configured yet.') . ' '; - if ($auth->check_right($form->{login}, 'config')) { + if ($main::auth->check_right($form->{login}, 'config')) { $msg .= $locale->text('You can create warehouses and bins via the menu "System -> Warehouses".'); } else { $msg .= $locale->text('Please ask your administrator to create warehouses and bins.'); @@ -853,12 +942,14 @@ sub show_no_warehouses_error { $form->show_generic_error($msg); - $lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); } sub get_warehouse_idx { my ($warehouse_id) = @_; + my $form = $main::form; + for (my $i = 0; $i < scalar @{$form->{WAREHOUSES}}; $i++) { return $i if ($form->{WAREHOUSES}->[$i]->{id} == $warehouse_id); } @@ -869,6 +960,8 @@ sub get_warehouse_idx { sub get_bin_idx { my ($warehouse_index, $bin_id) = @_; + my $form = $main::form; + my $warehouse = $form->{WAREHOUSES}->[$warehouse_index]; return -1 if (!$warehouse); @@ -880,15 +973,51 @@ sub get_bin_idx { return -1; } +=item new_item + +call new item dialogue from warehouse masks. + +PARAMS: + action => name of sub to be called when new item is done + +=cut +sub new_item { + $main::lxdebug->enter_sub(); + my %params = @_; + + my $form = $main::form; + + # change callback + $form->{old_callback} = $form->escape($form->{callback}, 1); + $form->{callback} = $form->escape("$form->{script}?action=$params{action}", 1); + + # save all form variables except action in a previousform variable + my $previousform = join '&', map { my $value = $form->{$_}; $value =~ s/&/%26/; "$_=$value" } grep { !/action/ } keys %$form; + my @HIDDENS = (); + +# push @HIDDENS, { 'name' => 'previousform', 'value' => $form->escape($previousform, 1) }; + push @HIDDENS, map +{ 'name' => $_, 'value' => $form->{$_} }, qw(partnumber description unit vc sellprice ean); + push @HIDDENS, { 'name' => 'taxaccount2', 'value' => $form->{taxaccounts} }; + push @HIDDENS, { 'name' => 'notes', 'value' => $form->{longdescription} }; + + $form->header(); + print $form->parse_html_template("generic/new_item", { HIDDENS => [ sort { $a->{name} cmp $b->{name} } @HIDDENS ] } ); + + $main::lxdebug->leave_sub(); +} + sub update { + my $form = $main::form; call_sub($form->{update_nextsub} || $form->{nextsub}); } sub continue { + my $form = $main::form; call_sub($form->{continue_nextsub} || $form->{nextsub}); } sub stock { + my $form = $main::form; call_sub($form->{stock_nextsub} || $form->{nextsub}); }