my $query =
qq|SELECT a.id, a.invnumber, a.transdate, a.duedate, a.amount, a.paid, | .
qq| a.ordnumber, v.name, a.invoice, a.netamount, a.datepaid, a.notes, | .
+ qq| a.globalproject_id, | .
+ qq| pr.projectnumber AS globalprojectnumber, | .
qq| e.name AS employee | .
qq|FROM ap a | .
qq|JOIN vendor v ON (a.vendor_id = v.id) | .
- qq|LEFT JOIN employee e ON (a.employee_id = e.id)|;
+ qq|LEFT JOIN employee e ON (a.employee_id = e.id) | .
+ qq|LEFT JOIN project pr ON (a.globalproject_id = pr.id) |;
my $where;
my @values;
$where .= " AND lower(a.notes) LIKE ?";
push(@values, $form->like($form->{notes}));
}
+ if ($form->{project_id}) {
+ $where .=
+ qq|AND ((a.globalproject_id = ?) OR EXISTS | .
+ qq| (SELECT * FROM invoice i | .
+ qq| WHERE i.project_id = ? AND i.trans_id = a.id))|;
+ push(@values, $form->{project_id}, $form->{project_id});
+ }
if ($form->{transdatefrom}) {
$where .= " AND a.transdate >= ?";
# connect to database
my $dbh = $form->dbconnect($myconfig);
+ my @values;
+
my $query = qq|SELECT a.id, a.invnumber, a.ordnumber, a.transdate,
a.duedate, a.netamount, a.amount, a.paid, c.name,
a.invoice, a.datepaid, a.terms, a.notes, a.shipvia,
- a.shippingpoint, a.storno,
+ a.shippingpoint, a.storno, a.globalproject_id,
+ pr.projectnumber AS globalprojectnumber,
e.name AS employee
FROM ar a
JOIN customer c ON (a.customer_id = c.id)
- LEFT JOIN employee e ON (a.employee_id = e.id)|;
+ LEFT JOIN employee e ON (a.employee_id = e.id)
+ LEFT JOIN project pr ON a.globalproject_id = pr.id|;
my $where = "1 = 1";
if ($form->{customer_id}) {
my $notes = $form->like(lc $form->{notes});
$where .= " AND lower(a.notes) LIKE '$notes'";
}
+ if ($form->{"project_id"}) {
+ $where .=
+ qq|AND ((a.globalproject_id = ?) OR EXISTS | .
+ qq| (SELECT * FROM invoice i | .
+ qq| WHERE i.project_id = ? AND i.trans_id = a.id))|;
+ push(@values, $form->{"project_id"}, $form->{"project_id"});
+ }
$where .= " AND a.transdate >= '$form->{transdatefrom}'"
if $form->{transdatefrom};
my $sortorder = join ', ', $form->sort_columns(@a);
$sortorder = $form->{sort} if $form->{sort};
- $query .= "WHERE $where
+ $query .= " WHERE $where
ORDER by $sortorder";
my $sth = $dbh->prepare($query);
- $sth->execute || $form->dberror($query);
+ $sth->execute(@values) ||
+ $form->dberror($query . " (" . join(", ", @values) . ")");
while (my $ar = $sth->fetchrow_hashref(NAME_lc)) {
push @{ $form->{AR} }, $ar;
use SL::PE;
require "$form->{path}/arap.pl";
+require "bin/mozilla/common.pl";
1;
<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 nowrap>| . $locale->text('Notes') . qq|</th>
<td colspan=3><input name=notes size=40></td>
</tr>
+ <tr>
+ <th align="right">| . $locale->text("Project Number") . qq|</th>
+ <td colspan="3">$projectnumber</td>
+ </tr>
<tr>
<th align=right nowrap>| . $locale->text('From') . qq|</th>
$button1
<tr>
<td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
<td nowrap>| . $locale->text('Subtotal') . qq|</td>
+ <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
+ <td nowrap>| . $locale->text('Project Number') . qq|</td>
</tr>
</table>
</td>
$option .= "\n<br>" if ($option);
$option .= $locale->text('Closed');
}
+ if ($form->{globalproject_id}) {
+ $callback .= "&globalproject_id=" . E($form->{globalproject_id});
+ $href .= "&globalproject_id=" . E($form->{globalproject_id});
+ }
- @columns = $form->sort_columns(
- qw(transdate id invnumber ordnumber name netamount tax amount paid datepaid due duedate notes employee)
- );
+ @columns =
+ qw(transdate id invnumber ordnumber name netamount tax amount paid datepaid
+ due duedate notes employee globalprojectnumber);
foreach $item (@columns) {
if ($form->{"l_$item"} eq "Y") {
$column_header{employee} =
"<th><a class=listheading href=$href&sort=employee>"
. $locale->text('Employee') . "</th>";
+ $column_header{globalprojectnumber} =
+ qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
$form->{title} = $locale->text('AP Transactions');
$ap->{notes} =~ s/\r\n/<br>/g;
$column_data{notes} = "<td>$ap->{notes} </td>";
$column_data{employee} = "<td>$ap->{employee} </td>";
+ $column_data{globalprojectnumber} =
+ "<td>" . H($ap->{globalprojectnumber}) . "</td>";
$i++;
$i %= 2;
use Data::Dumper;
require "$form->{path}/arap.pl";
+require "bin/mozilla/common.pl";
1;
<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->{fokus} = "search.customer";
$form->header;
<th align=right nowrap>| . $locale->text('Notes') . qq|</th>
<td colspan=3><input name=notes size=40></td>
</tr>
+ <tr>
+ <th align="right">| . $locale->text("Project Number") . qq|</th>
+ <td colspan="3">$projectnumber</td>
+ </tr>
<tr>
<th align=right nowrap>| . $locale->text('From') . qq|</th>
$button1
<tr>
<td align=right><input name="l_subtotal" class=checkbox type=checkbox value=Y></td>
<td nowrap>| . $locale->text('Subtotal') . qq|</td>
+ <td align=right><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y></td>
+ <td nowrap>| . $locale->text('Project Number') . qq|</td>
</tr>
</table>
</td>
$option .= "\n<br>" if ($option);
$option .= $locale->text('Closed');
}
+ if ($form->{globalproject_id}) {
+ $callback .= "&globalproject_id=" . E($form->{globalproject_id});
+ $href .= "&globalproject_id=" . E($form->{globalproject_id});
+ }
- @columns = $form->sort_columns(
- qw(transdate id type invnumber ordnumber name netamount tax amount paid datepaid due duedate notes employee shippingpoint shipvia)
- );
+ @columns =
+ qw(transdate id type invnumber ordnumber name netamount tax amount paid
+ datepaid due duedate notes employee shippingpoint shipvia
+ globalprojectnumber);
$form->{"l_type"} = "Y";
"<th><a class=listheading href=$href&sort=shipvia>"
. $locale->text('Ship via')
. "</a></th>";
+ $column_header{globalprojectnumber} =
+ qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
$form->{title} = $locale->text('AR Transactions');
$column_data{shippingpoint} = "<td>$ar->{shippingpoint} </td>";
$column_data{shipvia} = "<td>$ar->{shipvia} </td>";
$column_data{employee} = "<td>$ar->{employee} </td>";
+ $column_data{globalprojectnumber} =
+ "<td>" . H($ar->{globalprojectnumber}) . "</td>";
$i++;
$i %= 2;
'Post' => 'Buchen',
'Post Payment' => 'Zahlung buchen',
'Project' => 'Projekt',
+ 'Project Number' => 'Projektnummer',
'Project not on file!' => 'Dieses Projekt ist nicht in der Datenbank!',
'Remaining' => 'Rest',
'Select from one of the names below' => 'Wählen Sie einen der untenstehenden Namen',
'Post' => 'Buchen',
'Post Payment' => 'Zahlung buchen',
'Project' => 'Projekt',
+ 'Project Number' => 'Projektnummer',
'Project not on file!' => 'Dieses Projekt ist nicht in der Datenbank!',
'Remaining' => 'Rest',
'Sales Invoice' => 'Rechnung',