From cfc6a60d53597f6a879b28af37f84b4b5fa4cc6b Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 20 Feb 2007 09:09:28 +0000 Subject: [PATCH] Anzeige und Auswahl von Projektnummern bei Einkaufs- und Verkaufsbelegen nur noch per Drop-Down-Box. --- SL/Form.pm | 12 ++++++++++-- SL/IR.pm | 9 +++------ SL/IS.pm | 9 +++------ SL/OE.pm | 9 ++------- bin/mozilla/arap.pl | 2 +- bin/mozilla/common.pl | 7 +++++++ bin/mozilla/io.pl | 21 ++++++++++++++++----- bin/mozilla/ir.pl | 33 +++++++++++++++++++++++---------- bin/mozilla/is.pl | 36 ++++++++++++++++++++++++------------ bin/mozilla/oe.pl | 32 +++++++++++++++++--------------- locale/de/am | 1 + locale/de/cn | 1 + locale/de/common | 1 + locale/de/dn | 1 + locale/de/ic | 1 + locale/de/io | 1 + locale/de/ir | 1 + locale/de/is | 1 + locale/de/oe | 1 + 19 files changed, 115 insertions(+), 64 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index f7cf1a86b..842afe8af 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1451,8 +1451,16 @@ sub get_projects { if (!$all) { $where = "WHERE active "; if ($old_id) { - $where .= " OR (id = ?) "; - push(@values, $old_id); + if (ref($old_id) eq "ARRAY") { + my @ids = grep({ $_ } @{$old_id}); + if (@ids) { + $where .= " OR id IN (" . join(",", map({ "?" } @ids)) . ") "; + push(@values, @ids); + } + } else { + $where .= " OR (id = ?) "; + push(@values, $old_id); + } } } diff --git a/SL/IR.pm b/SL/IR.pm index af80fce2c..e75fd30e0 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -371,10 +371,6 @@ sub post_invoice { } - $project_id = 'NULL'; - if ($form->{"projectnumber_$i"}) { - $project_id = $form->{"projectnumber_$i"}; - } $deliverydate = ($form->{"deliverydate_$i"}) ? qq|'$form->{"deliverydate_$i"}'| @@ -387,7 +383,7 @@ sub post_invoice { VALUES ($form->{id}, $form->{"id_$i"}, '$form->{"description_$i"}', | . ($form->{"qty_$i"} * -1) . qq|, | . ($baseqty * -1) . qq|, $form->{"sellprice_$i"}, $fxsellprice, $allocated, - '$form->{"unit_$i"}', $deliverydate, (SELECT id FROM project WHERE projectnumber = '$project_id'), + '$form->{"unit_$i"}', $deliverydate, | . conv_i($form->{"project_id_$i"}) . qq|, '$form->{"serialnumber_$i"}')|; $dbh->do($query) || $form->dberror($query); } @@ -639,6 +635,7 @@ sub post_invoice { curr = '$form->{currency}', department_id = $form->{department_id}, storno = '$form->{storno}', + globalproject_id = | . conv_i($form->{"globalproject_id"}, 'NULL') . qq|, cp_id = | . conv_i($form->{cp_id}, 'NULL') . qq| WHERE id = $form->{id}|; $dbh->do($query) || $form->dberror($query); @@ -844,7 +841,7 @@ sub retrieve_invoice { # retrieve invoice $query = qq|SELECT a.cp_id, a.invnumber, a.transdate AS invdate, a.duedate, - a.orddate, a.quodate, + a.orddate, a.quodate, a.globalproject_id, a.ordnumber, a.quonumber, a.paid, a.taxincluded, a.notes, a.taxzone_id, a.storno, a.gldate, a.intnotes, a.curr AS currency FROM ap a diff --git a/SL/IS.pm b/SL/IS.pm index b59561656..da23eb4d9 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -685,10 +685,6 @@ sub post_invoice { } } - $project_id = 'NULL'; - if ($form->{"projectnumber_$i"}) { - $project_id = $form->{"projectnumber_$i"}; - } $deliverydate = ($form->{"deliverydate_$i"}) ? qq|'$form->{"deliverydate_$i"}'| @@ -708,7 +704,7 @@ sub post_invoice { '$form->{"description_$i"}', '$form->{"longdescription_$i"}', $form->{"qty_$i"}, $form->{"sellprice_$i"}, $fxsellprice, $form->{"discount_$i"}, $allocated, 'f', - '$form->{"unit_$i"}', $deliverydate, (SELECT id from project where projectnumber = '$project_id'), + '$form->{"unit_$i"}', $deliverydate, | . conv_i($form->{"project_id_$i"}) . qq|, '$form->{"serialnumber_$i"}', '$pricegroup_id', '$form->{"ordnumber_$i"}', '$form->{"transdate_$i"}', '$form->{"cusordnumber_$i"}', $baseqty, '$subtotal')|; $dbh->do($query) || $form->dberror($query); @@ -1009,6 +1005,7 @@ Message: $form->{message}\r| if $form->{message}; delivery_vendor_id = $form->{delivery_vendor_id}, employee_id = $form->{employee_id}, storno = '$form->{storno}', + globalproject_id = | . conv_i($form->{"globalproject_id"}, 'NULL') . qq|, cp_id = | . conv_i($form->{"cp_id"}, 'NULL') . qq| WHERE id = $form->{id} |; @@ -1484,7 +1481,7 @@ sub retrieve_invoice { # retrieve invoice $query = qq|SELECT a.invnumber, a.ordnumber, a.quonumber, a.cusordnumber, - a.orddate, a.quodate, + a.orddate, a.quodate, a.globalproject_id, a.transdate AS invdate, a.deliverydate, a.paid, a.storno, a.gldate, a.shippingpoint, a.shipvia, a.terms, a.notes, a.intnotes, a.taxzone_id, a.duedate, a.taxincluded, a.curr AS currency, a.shipto_id, a.cp_id, diff --git a/SL/OE.pm b/SL/OE.pm index 1967fc05d..64ba141d5 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -311,10 +311,6 @@ sub save { $netamount += $form->{"sellprice_$i"} * $form->{"qty_$i"}; - $project_id = 'NULL'; - if ($form->{"projectnumber_$i"}) { - $project_id = $form->{"projectnumber_$i"}; - } $reqdate = ($form->{"reqdate_$i"}) ? qq|'$form->{"reqdate_$i"}'| : "NULL"; @@ -335,7 +331,7 @@ sub save { $query .= qq|$form->{id}, $form->{"id_$i"}, '$form->{"description_$i"}', '$form->{"longdescription_$i"}', $form->{"qty_$i"}, $baseqty, $fxsellprice, $form->{"discount_$i"}, - '$form->{"unit_$i"}', $reqdate, (SELECT id from project where projectnumber = '$project_id'), + '$form->{"unit_$i"}', $reqdate, | . conv_i($form->{"project_id_$i"}, 'NULL') . qq|, '$form->{"serialnumber_$i"}', $form->{"ship_$i"}, '$pricegroup_id', '$form->{"ordnumber_$i"}', '$form->{"transdate_$i"}', '$form->{"cusordnumber_$i"}', '$subtotal')|; $dbh->do($query) || $form->dberror($query); @@ -671,13 +667,12 @@ sub retrieve { o.closed, o.reqdate, o.quonumber, o.department_id, o.cusordnumber, d.description AS department, o.payment_id, o.language_id, o.taxzone_id, o.delivery_customer_id, o.delivery_vendor_id, o.proforma, o.shipto_id, - o.globalproject_id, pr.projectnumber AS globalprojectnumber, + o.globalproject_id, o.delivered FROM oe o JOIN $form->{vc} cv ON (o.$form->{vc}_id = cv.id) LEFT JOIN employee e ON (o.employee_id = e.id) LEFT JOIN department d ON (o.department_id = d.id) - LEFT JOIN project pr ON (o.globalproject_id = pr.id) | . ($form->{id} ? qq|WHERE o.id = $form->{id}| diff --git a/bin/mozilla/arap.pl b/bin/mozilla/arap.pl index 48cb61027..073b51c72 100644 --- a/bin/mozilla/arap.pl +++ b/bin/mozilla/arap.pl @@ -272,7 +272,7 @@ sub add_transaction { sub check_project { $lxdebug->enter_sub(); - for $i (0 .. $form->{rowcount}) { + for $i (1 .. $form->{rowcount}) { my $suffix = $i ? "_$i" : ""; my $prefix = $i ? "" : "global"; $form->{"${prefix}project_id${suffix}"} = "" unless $form->{"${prefix}projectnumber$suffix"}; diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 6793a1ddc..0307d7776 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -452,6 +452,13 @@ sub E { return $form->escape($_[0]); } +sub NTI { + my ($element) = @_; + + $element =~ s/tabindex\s*=\s*"\d+"//; + return $element; +} + sub format_dates { $lxdebug->enter_sub(); diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 8b0b7fc69..d8b522de2 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -242,6 +242,13 @@ sub display_row { $delvar = 'reqdate'; } + my %projectnumber_labels = (); + my @projectnumber_values = (""); + foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { + push(@projectnumber_values, $item->{"id"}); + $projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"}; + } + for $i (1 .. $numrows) { # undo formatting @@ -486,11 +493,12 @@ sub display_row { $serialnumber |; } - print qq| - $projectnumber  - - -|; + print qq|$projectnumber | . + NTI($cgi->popup_menu('-name' => "project_id_$i", + '-values' => \@projectnumber_values, + '-labels' => \%projectnumber_labels, + '-default' => $form->{"project_id_$i"})); + if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) { my $reqdate_term = ($form->{type} eq 'invoice') @@ -881,6 +889,9 @@ sub display_form { relink_accounts(); + my $new_rowcount = $form->{"rowcount"} * 1 + 1; + $form->{"project_id_${new_rowcount}"} = $form->{"globalproject_id"}; + $form->language_payment(\%myconfig); # if we have a display_form diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 1b99f5fb5..6744764c6 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -36,6 +36,7 @@ use SL::PE; require "$form->{path}/io.pl"; require "$form->{path}/arap.pl"; +require "$form->{path}/common.pl"; 1; @@ -259,7 +260,14 @@ sub form_header { {forex}> |; - $form->get_lists("contacts" => "ALL_CONTACTS"); + my @old_project_ids = ($form->{"globalproject_id"}); + map({ push(@old_project_ids, $form->{"project_id_$_"}) + if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); + + $form->get_lists("contacts" => "ALL_CONTACTS", + "projects" => { "key" => "ALL_PROJECTS", + "all" => 0, + "old_id" => \@old_project_ids }); my (%labels, @values); foreach my $item (@{ $form->{"ALL_CONTACTS"} }) { @@ -268,8 +276,19 @@ sub form_header { ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : ""); } my $contact = - $cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, - '-labels' => \%labels, '-default' => $form->{"cp_id"}); + NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, + '-labels' => \%labels, '-default' => $form->{"cp_id"})); + + %labels = (); + @values = (""); + foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { + push(@values, $item->{"id"}); + $labels{$item->{"id"}} = $item->{"projectnumber"}; + } + my $globalprojectnumber = + NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, + '-labels' => \%labels, + '-default' => $form->{"globalproject_id"})); if (@{ $form->{TAXZONE} }) { $form->{selecttaxzone} = ""; @@ -457,11 +476,7 @@ sub form_header { | . $locale->text('Project Number') . qq| - - - - - + $globalprojectnumber @@ -813,8 +828,6 @@ sub update { &check_name(vendor); - &check_project; - $form->{exchangerate} = $exchangerate if ( $form->{forex} = ( diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 3b298f13d..f4556cf2c 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -353,8 +353,15 @@ sub form_header { |; + my @old_project_ids = ($form->{"globalproject_id"}); + map({ push(@old_project_ids, $form->{"project_id_$_"}) + if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); + $form->get_lists("contacts" => "ALL_CONTACTS", - "shipto" => "ALL_SHIPTO"); + "shipto" => "ALL_SHIPTO", + "projects" => { "key" => "ALL_PROJECTS", + "all" => 0, + "old_id" => \@old_project_ids }); my (%labels, @values); foreach my $item (@{ $form->{"ALL_CONTACTS"} }) { @@ -363,8 +370,8 @@ sub form_header { ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : ""); } my $contact = - $cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, - '-labels' => \%labels, '-default' => $form->{"cp_id"}); + NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, + '-labels' => \%labels, '-default' => $form->{"cp_id"})); %labels = (); @values = (""); @@ -377,10 +384,21 @@ sub form_header { my $shipto = qq| | . $locale->text('Shipping Address') . qq| | . - $cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, - '-labels' => \%labels, '-default' => $form->{"shipto_id"}) + NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, + '-labels' => \%labels, '-default' => $form->{"shipto_id"})) . qq||; + %labels = (); + @values = (""); + foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { + push(@values, $item->{"id"}); + $labels{$item->{"id"}} = $item->{"projectnumber"}; + } + my $globalprojectnumber = + NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, + '-labels' => \%labels, + '-default' => $form->{"globalproject_id"})); + # set option selected foreach $item (qw(AR customer currency department employee)) { $form->{"select$item"} =~ s/ selected//; @@ -743,11 +761,7 @@ print qq| | . $locale->text('Project Number') . qq| - - - - - + $globalprojectnumber @@ -1167,8 +1181,6 @@ sub update { &check_name(customer); - &check_project; - $form->{exchangerate} = $exchangerate if ( $form->{forex} = ( diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index e2fb8a2aa..0d6c3ce58 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -407,11 +407,15 @@ sub form_header { #quote select[customer|vendor] Bug 133 $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"}); + my @old_project_ids = ($form->{"globalproject_id"}); + map({ push(@old_project_ids, $form->{"project_id_$_"}) + if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); + $form->get_lists("contacts" => "ALL_CONTACTS", "shipto" => "ALL_SHIPTO", "projects" => { "key" => "ALL_PROJECTS", "all" => 0, - "old_id" => $form->{"globalproject_id"} }); + "old_id" => \@old_project_ids }); my (%labels, @values); foreach my $item (@{ $form->{"ALL_CONTACTS"} }) { @@ -420,8 +424,8 @@ sub form_header { ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : ""); } my $contact = - $cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, - '-labels' => \%labels, '-default' => $form->{"cp_id"}); + NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, + '-labels' => \%labels, '-default' => $form->{"cp_id"})); %labels = (); @values = (""); @@ -431,6 +435,13 @@ sub form_header { $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"}; } + my $shipto = qq| + | . $locale->text('Shipping Address') . qq| + | . + NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, + '-labels' => \%labels, '-default' => $form->{"shipto_id"})) + . qq||; + %labels = (); @values = (""); foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { @@ -438,16 +449,9 @@ sub form_header { $labels{$item->{"id"}} = $item->{"projectnumber"}; } my $globalprojectnumber = - $cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, - '-labels' => \%labels, - '-default' => $form->{"globalproject_id"}); - - my $shipto = qq| - | . $locale->text('Shipping Address') . qq| - | . - $cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, - '-labels' => \%labels, '-default' => $form->{"shipto_id"}) - . qq||; + NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, + '-labels' => \%labels, + '-default' => $form->{"globalproject_id"})); $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate}); @@ -1127,8 +1131,6 @@ sub update { &check_name($form->{vc}); - &check_project; - $buysell = 'buy'; $buysell = 'sell' if ($form->{vc} eq 'vendor'); $form->{exchangerate} = $exchangerate diff --git a/locale/de/am b/locale/de/am index 38e3ac18b..7b42a3a00 100644 --- a/locale/de/am +++ b/locale/de/am @@ -315,6 +315,7 @@ $self->{texts} = { $self->{subs} = { 'E' => 'E', 'H' => 'H', + 'NTI' => 'NTI', 'Q' => 'Q', 'account_header' => 'account_header', 'add' => 'add', diff --git a/locale/de/cn b/locale/de/cn index 402c50cec..2c5298994 100644 --- a/locale/de/cn +++ b/locale/de/cn @@ -207,6 +207,7 @@ $self->{texts} = { $self->{subs} = { 'E' => 'E', 'H' => 'H', + 'NTI' => 'NTI', 'Q' => 'Q', 'add' => 'add', 'add_transaction' => 'add_transaction', diff --git a/locale/de/common b/locale/de/common index 551e13532..e3c5b89e0 100644 --- a/locale/de/common +++ b/locale/de/common @@ -25,6 +25,7 @@ $self->{texts} = { $self->{subs} = { 'E' => 'E', 'H' => 'H', + 'NTI' => 'NTI', 'Q' => 'Q', 'build_std_url' => 'build_std_url', 'calculate_qty' => 'calculate_qty', diff --git a/locale/de/dn b/locale/de/dn index fe1aa2a9c..669fc3c30 100644 --- a/locale/de/dn +++ b/locale/de/dn @@ -200,6 +200,7 @@ gestartet', $self->{subs} = { 'E' => 'E', 'H' => 'H', + 'NTI' => 'NTI', 'Q' => 'Q', 'add' => 'add', 'add_transaction' => 'add_transaction', diff --git a/locale/de/ic b/locale/de/ic index 3e9677326..3f39db6b7 100644 --- a/locale/de/ic +++ b/locale/de/ic @@ -245,6 +245,7 @@ aktualisieren wollen?', $self->{subs} = { 'E' => 'E', 'H' => 'H', + 'NTI' => 'NTI', 'Q' => 'Q', 'add' => 'add', 'addtop100' => 'addtop100', diff --git a/locale/de/io b/locale/de/io index e8fc49d04..d7a9be111 100644 --- a/locale/de/io +++ b/locale/de/io @@ -144,6 +144,7 @@ $self->{texts} = { $self->{subs} = { 'E' => 'E', 'H' => 'H', + 'NTI' => 'NTI', 'Q' => 'Q', 'build_std_url' => 'build_std_url', 'calculate_qty' => 'calculate_qty', diff --git a/locale/de/ir b/locale/de/ir index 2e14867dd..0e493fafd 100644 --- a/locale/de/ir +++ b/locale/de/ir @@ -201,6 +201,7 @@ $self->{texts} = { $self->{subs} = { 'E' => 'E', 'H' => 'H', + 'NTI' => 'NTI', 'Q' => 'Q', 'add' => 'add', 'add_transaction' => 'add_transaction', diff --git a/locale/de/is b/locale/de/is index cd4ca7f25..96134c94a 100644 --- a/locale/de/is +++ b/locale/de/is @@ -226,6 +226,7 @@ $self->{texts} = { $self->{subs} = { 'E' => 'E', 'H' => 'H', + 'NTI' => 'NTI', 'Q' => 'Q', 'add' => 'add', 'add_transaction' => 'add_transaction', diff --git a/locale/de/oe b/locale/de/oe index 52db95a52..0905fba70 100644 --- a/locale/de/oe +++ b/locale/de/oe @@ -241,6 +241,7 @@ $self->{texts} = { $self->{subs} = { 'E' => 'E', 'H' => 'H', + 'NTI' => 'NTI', 'Q' => 'Q', 'add' => 'add', 'add_transaction' => 'add_transaction', -- 2.20.1