X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/596cce1fb449f9400899105d5fc3f793b18cb142..d73692451ea1eaa7de9ed4e8bd3160b1e88cd7e9:/SL/AR.pm diff --git a/SL/AR.pm b/SL/AR.pm index fe3e4431b..a2512c8aa 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -446,6 +446,11 @@ sub ar_transactions { $where .= " AND c.name ILIKE ?"; push(@values, $form->like($form->{customer})); } + if ($form->{business_id}) { + my $business_id = $form->{business_id}; + $where .= " AND c.business_id = ?"; + push(@values, $business_id); + } if ($form->{department_id}) { my $department_id = $form->{department_id}; $where .= " AND a.department_id = ?"; @@ -485,10 +490,21 @@ sub ar_transactions { } } - 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';