From: Moritz Bunkus Date: Tue, 20 Feb 2007 09:09:59 +0000 (+0000) Subject: Bei Berichtsfunktion nach Projekten suchen und sich Projekte ausgeben lassen (bisher... X-Git-Tag: release-2.4.2~84 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=72eaa1a75c2b38a91ae8eeaf98319da9de3eac3a;p=kivitendo-erp.git Bei Berichtsfunktion nach Projekten suchen und sich Projekte ausgeben lassen (bisher nur OE; IR und IS folgen). --- diff --git a/SL/OE.pm b/SL/OE.pm index 64ba141d5..d471a815c 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -52,6 +52,15 @@ sub transactions { my ($null, $department_id) = split /--/, $form->{department}; my $department = " AND o.department_id = $department_id" if $department_id; + my @values; + + if ($form->{"project_id"}) { + $department .= + qq|AND ((globalproject_id = ?) OR EXISTS | . + qq| (SELECT * FROM orderitems oi | . + qq| WHERE oi.project_id = ? AND oi.trans_id = o.id))|; + push(@values, $form->{"project_id"}, $form->{"project_id"}); + } my $rate = ($form->{vc} eq 'customer') ? 'buy' : 'sell'; @@ -65,6 +74,7 @@ sub transactions { my $query = qq|SELECT o.id, o.ordnumber, o.transdate, o.reqdate, o.amount, ct.name, o.netamount, o.$form->{vc}_id, + o.globalproject_id, pr.projectnumber AS globalprojectnumber, ex.$rate AS exchangerate, o.closed, o.delivered, o.quonumber, o.shippingpoint, o.shipvia, e.name AS employee @@ -73,6 +83,7 @@ sub transactions { LEFT JOIN employee e ON (o.employee_id = e.id) LEFT JOIN exchangerate ex ON (ex.curr = o.curr AND ex.transdate = o.transdate) + LEFT JOIN project pr ON o.globalproject_id = pr.id WHERE o.quotation = '$quotation' $department|; @@ -107,7 +118,10 @@ sub transactions { $query .= " ORDER by $sortorder"; my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); + $sth->execute(@values) || + $form->dberror($query . " (" . join(", ", @values) . ")"); + + dump_query(0, "laqje", $query, @values); my %id = (); while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 0d6c3ce58..3baa8799f 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -1375,6 +1375,19 @@ sub search { |; } + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", + "all" => 1 }); + + my %labels = (); + my @values = (""); + foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { + push(@values, $item->{"id"}); + $labels{$item->{"id"}} = $item->{"projectnumber"}; + } + my $projectnumber = + NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values, + '-labels' => \%labels)); + $form->header; print qq| @@ -1399,6 +1412,10 @@ sub search { $ordlabel + + | . $locale->text("Project Number") . qq| + $projectnumber + | . $locale->text('From') . qq| $button1 @@ -1426,6 +1443,7 @@ sub search { $employee | . $locale->text('Ship via') . qq| + $employee | @@ -1434,6 +1452,8 @@ sub search { . $locale->text('Tax') . qq| | . $locale->text('Total') . qq| + | + . $locale->text('Project Number') . qq| | @@ -1499,8 +1519,8 @@ sub orders { @columns = $form->sort_columns("transdate", "reqdate", "id", "$ordnumber", "name", "netamount", "tax", "amount", - "curr", "employee", "shipvia", "open", - "closed", "delivered"); + "curr", "employee", "shipvia", "globalprojectnumber", + "open", "closed", "delivered"); $form->{l_open} = $form->{l_closed} = "Y" if ($form->{open} && $form->{closed}); @@ -1584,6 +1604,8 @@ sub orders { qq|| . $locale->text('Ship via') . qq||; + $column_header{globalprojectnumber} = + qq|| . $locale->text('Project Number') . qq||; $column_header{open} = qq|| . $locale->text('O') . qq||; $column_header{closed} = @@ -1700,6 +1722,7 @@ sub orders { $column_data{employee} = "$oe->{employee} "; $column_data{shipvia} = "$oe->{shipvia} "; + $column_data{globalprojectnumber} = "" . H($oe->{globalprojectnumber}) . ""; if ($oe->{closed}) { $column_data{closed} = "X";