}
}
- if (!$main::auth->assert('sales_all_edit', 1)) {
+ if (!$main::auth->assert('sales_all_edit', 1)) {
+ # only show own invoices
$where .= " AND a.employee_id = (select id from employee where login= ?)";
push (@values, $form->{login});
- }
+ } else {
+ if ($form->{employee_id}) {
+ $where .= " AND a.employee_id = ?";
+ push @values, conv_i($form->{employee_id});
+ }
+ if ($form->{salesman_id}) {
+ $where .= " AND a.salesman_id = ?";
+ push @values, conv_i($form->{salesman_id});
+ }
+ };
+
my @a = qw(transdate invnumber name);
push @a, "employee" if $form->{l_employee};
my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
$form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 1 },
"departments" => "ALL_DEPARTMENTS",
"customers" => "ALL_VC",
+ "employees" => "ALL_EMPLOYEES",
+ "salesmen" => "ALL_SALESMEN",
"business_types" => "ALL_BUSINESS_TYPES");
$form->{SHOW_BUSINESS_TYPES} = scalar @{ $form->{ALL_BUSINESS_TYPES} } > 0;
# constants and subs for template
$form->{jsscript} = 1;
$form->{vc_keys} = sub { "$_[0]->{name}--$_[0]->{id}" };
+ $form->{employee_labels} = sub { $_[0]->{"name"} || $_[0]->{"login"} };
+ $form->{salesman_labels} = $form->{employee_labels};
$form->header;
print $form->parse_html_template('ar/search', { %myconfig });
<th align=right nowrap>[% 'Order Number' | $T8 %]</th>
<td colspan=3><input name=ordnumber size=20></td>
</tr>
+ <tr>
+ <th align="right">[% 'Employee' | $T8 %]</th>
+ <td>
+ [%- INCLUDE 'generic/multibox.html'
+ name = 'employee_id',
+ style = 'width: 250px',
+ DATA = ALL_EMPLOYEES,
+ id_key = 'id',
+ label_sub = 'employee_labels',
+ limit = vclimit,
+ show_empty = 1,
+ allow_textbox = 0,
+ default = ' ',
+ -%]
+ </td>
+ </tr>
+ <tr>
+ <th align="right">[% 'Salesman' | $T8 %]</th>
+ <td>
+ [%- INCLUDE 'generic/multibox.html'
+ name = 'salesman_id',
+ style = 'width: 250px',
+ DATA = ALL_SALESMEN,
+ id_key = 'id',
+ label_sub = 'salesman_labels',
+ limit = vclimit,
+ show_empty = 1,
+ allow_textbox = 0,
+ -%]
+ </td>
+ </tr>
<tr>
<th align=right nowrap>[% 'Transaction description' | $T8 %]</th>
<td colspan=3><input name=transaction_description size=40></td>