X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FAR.pm;h=a2512c8aa331a0d1b4a232d68db9a62dda9e6ee2;hb=644504117346e1ae8f2bafa9493cccfdba4f656b;hp=df470761c849030f7b36f78a6ba114c6aae850c5;hpb=0519635df1f3b84e4c86acb3c251deb051055c3a;p=kivitendo-erp.git diff --git a/SL/AR.pm b/SL/AR.pm index df470761c..a2512c8aa 100644 --- a/SL/AR.pm +++ b/SL/AR.pm @@ -54,7 +54,7 @@ sub post_transaction { my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig); $form->{defaultcurrency} = $form->get_default_currency($myconfig); - delete $form->{currency} unless $form->{default_currency}; + delete $form->{currency} unless $form->{defaultcurrency}; # set exchangerate $form->{exchangerate} = ($form->{currency} eq $form->{defaultcurrency}) ? 1 : @@ -349,7 +349,7 @@ sub post_payment { $form->{exchangerate} = $form->format_amount($myconfig, $form->{exchangerate}); $form->{defaultcurrency} = $form->get_default_currency($myconfig); - delete $form->{currency} unless $form->{default_currency}; + delete $form->{currency} unless $form->{defaultcurrency}; # Get the AR accno (which is normally done by Form::create_links()). $query = @@ -435,7 +435,8 @@ sub ar_transactions { qq|LEFT JOIN employee e2 ON (a.salesman_id = e2.id) | . qq|LEFT JOIN project pr ON (a.globalproject_id = pr.id)| . qq|LEFT JOIN tax_zones tz ON (tz.id = c.taxzone_id)| . - qq|LEFT JOIN payment_terms pt ON (pt.id = c.payment_id)|; + qq|LEFT JOIN payment_terms pt ON (pt.id = c.payment_id)| . + qq|LEFT JOIN department d ON (d.id = a.department_id)|; my $where = "1 = 1"; if ($form->{customer_id}) { @@ -445,11 +446,21 @@ sub ar_transactions { $where .= " AND c.name ILIKE ?"; push(@values, $form->like($form->{customer})); } - if ($form->{department}) { - my ($null, $department_id) = split /--/, $form->{department}; + 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 = ?"; push(@values, $department_id); } + if ($form->{department}) { + my $department = "%" . $form->{department} . "%"; + $where .= " AND d.description ILIKE ?"; + push(@values, $department); + } foreach my $column (qw(invnumber ordnumber notes transaction_description)) { if ($form->{$column}) { $where .= " AND a.$column ILIKE ?"; @@ -479,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';