X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fam.pl;h=a99204c334725c64b7114986545b2a7d22d947a5;hb=875873f10da35c4359e4bc994e709c247aab905e;hp=c812814438f99da072f5c7bf198ad124e549ebd5;hpb=c2def9059d4b1b8d8be43704409d49fe68f29a01;p=kivitendo-erp.git diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index c81281443..a99204c33 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -2818,6 +2818,9 @@ sub show_am_history { $auth->assert('config'); + my $callback = build_std_url(qw(action einschraenkungen fromdate todate mitarbeiter searchid what2search)); + $form->{order} ||= 'h.itime--1'; + my %search = ( "Artikelnummer" => "parts", "Kundennummer" => "customer", "Lieferantennummer" => "vendor", @@ -2837,28 +2840,17 @@ sub show_am_history { "Mahnungsnummer" => "dunning_id" ); - my $restriction; - my $tempNo = 0; - foreach(split(/\,/, $form->{einschraenkungen})) { - if($tempNo == 0) { - $restriction .= " AND addition = '" . $_ . "'"; - $tempNo = 1; - } else { - $restriction .= " OR addition = '" . $_ . "'"; - } + my $dbh = $form->dbconnect(\%myconfig); + + my $restriction = qq| AND (| . join(' OR ', map { " addition = " . $dbh->quote($_) } split(m/\,/, $form->{einschraenkungen})) . qq|)| if $form->{einschraenkungen}; + $restriction .= qq| AND h.itime::date >= | . conv_dateq($form->{fromdate}) if $form->{fromdate}; + $restriction .= qq| AND h.itime::date <= | . conv_dateq($form->{todate}) if $form->{todate}; + if ($form->{mitarbeiter} =~ m/^\d+$/) { + $restriction .= qq| AND employee_id = | . $form->{mitarbeiter}; + } elsif ($form->{mitarbeiter}) { + $restriction .= qq| AND employee_id = (SELECT id FROM employee WHERE name ILIKE | . $dbh->quote('%' . $form->{mitarbeiter} . '%') . qq|)|; } - $restriction .= - $form->{transdate} ne "" && $form->{reqdate} ne "" ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|' AND st.itime::date <= '| . $form->{reqdate} . qq|'| - : $form->{transdate} ne "" && $form->{reqdate} eq "" ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|'| - : $form->{transdate} eq "" && $form->{reqdate} ne "" ? qq| AND st.itime::date <= '| . $form->{reqdate} . qq|'| - : "" - ; - $restriction .= - $form->{mitarbeiter} eq "" ? "" - : $form->{mitarbeiter} =~ /^\d+$/ ? " AND employee_id = " . $form->{mitarbeiter} - : " AND employee_id = " . get_employee_id($form->{mitarbeiter}, $dbh); - my $dbh = $form->dbconnect(\%myconfig); my $query = qq|SELECT trans_id AS id FROM history_erp | . ( $form->{'searchid'} ? qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'| : qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|); @@ -2878,27 +2870,14 @@ sub show_am_history { "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"), "NONEWWINDOW" => 1, uc($sort) => 1, - uc($sort) . "BY" => $sortby + uc($sort) . "BY" => $sortby, + 'callback' => $callback, }); $dbh->disconnect(); $lxdebug->leave_sub(); } -sub get_employee_id { - $lxdebug->enter_sub(); - - $auth->assert('config'); - - my $query = qq|SELECT id FROM employee WHERE name = '| . $_[0] . qq|'|; - my $sth = $_[1]->prepare($query); - $sth->execute() || $form->dberror($query); - my $return = $sth->fetch(); - $sth->finish(); - return ${$return}[0]; - $lxdebug->leave_sub(); -} - sub swap_units { $lxdebug->enter_sub();