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';
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
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|;
$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)) {
<td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
}
+ $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|
<th align=right>$ordlabel</th>
<td colspan=3><input name="$ordnumber" size=20></td>
</tr>
+ <tr>
+ <th align="right">| . $locale->text("Project Number") . qq|</th>
+ <td colspan="3">$projectnumber</td>
+ </tr>
<tr>
<th align=right>| . $locale->text('From') . qq|</th>
$button1
<td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
<td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
. $locale->text('Ship via') . qq|</td>
+ <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
</tr>
<tr>
<td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
. $locale->text('Tax') . qq|</td>
<td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
. $locale->text('Total') . qq|</td>
+ <td><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y> |
+ . $locale->text('Project Number') . qq|</td>
</tr>
<tr>
<td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
@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});
qq|<th><a class=listheading href=$href&sort=shipvia>|
. $locale->text('Ship via')
. qq|</a></th>|;
+ $column_header{globalprojectnumber} =
+ qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
$column_header{open} =
qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
$column_header{closed} =
$column_data{employee} = "<td>$oe->{employee} </td>";
$column_data{shipvia} = "<td>$oe->{shipvia} </td>";
+ $column_data{globalprojectnumber} = "<td>" . H($oe->{globalprojectnumber}) . "</td>";
if ($oe->{closed}) {
$column_data{closed} = "<td align=center>X</td>";