X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAR.pm;h=a4d1000390a4e1c956e88f2b2c5ba6e89e167e3e;hb=a8c6f09f1c148a46cfda8b773db7109c69ab1649;hp=fe3e4431bcde45d1bc799ab7931b7b883ecab734;hpb=596cce1fb449f9400899105d5fc3f793b18cb142;p=kivitendo-erp.git diff --git a/SL/AR.pm b/SL/AR.pm index fe3e4431b..a4d100039 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'; @@ -674,14 +690,14 @@ sub storno { } for my $row (@$rowref) { - delete @$row{qw(itime mtime link)}; + delete @$row{qw(itime mtime link acc_trans_id)}; $query = sprintf 'INSERT INTO acc_trans (%s) VALUES (%s)', join(', ', keys %$row), join(', ', map '?', values %$row); $row->{trans_id} = $new_id; $row->{amount} *= -1; do_query($form, $dbh, $query, (values %$row)); } - map { IO->set_datepaid(table => 'ap', id => $_, dbh => $dbh) } ($id, $new_id); + map { IO->set_datepaid(table => 'ar', id => $_, dbh => $dbh) } ($id, $new_id); $dbh->commit;