From 41a039692bf1d655df629fd833fd6d6d428eb29b Mon Sep 17 00:00:00 2001 From: Thomas Kasulke Date: Wed, 16 May 2007 14:25:47 +0000 Subject: [PATCH] Verbesserung der Suchfunktionen der Historie und Visualisierung der Sortierreihenfolge. --- SL/Form.pm | 9 +-- bin/mozilla/am.pl | 57 +++++++++++-------- bin/mozilla/common.pl | 10 +++- locale/de/all | 1 + .../webpages/common/search_history_de.html | 6 +- .../common/search_history_master.html | 6 +- .../webpages/common/show_history_de.html | 12 ++-- .../webpages/common/show_history_master.html | 12 ++-- 8 files changed, 64 insertions(+), 49 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index 537372a7c..7803fc394 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -2488,12 +2488,13 @@ sub get_history { qq|SELECT h.employee_id, h.itime::timestamp(0) AS itime, h.addition, h.what_done, emp.name, h.snumbers, h.trans_id AS id | . qq|FROM history_erp h | . qq|LEFT JOIN employee emp ON (emp.id = h.employee_id) | . - qq|WHERE trans_id = ? |. $order - . $restriction; - + qq|WHERE trans_id = | . $trans_id + . $restriction . qq| | + . $order; + my $sth = $dbh->prepare($query) || $self->dberror($query); - $sth->execute($trans_id) || $self->dberror("$query ($trans_id)"); + $sth->execute() || $self->dberror("$query"); while(my $hash_ref = $sth->fetchrow_hashref()) { $hash_ref->{addition} = $main::locale->text($hash_ref->{addition}); diff --git a/bin/mozilla/am.pl b/bin/mozilla/am.pl index 3b47b8eac..6294a1897 100644 --- a/bin/mozilla/am.pl +++ b/bin/mozilla/am.pl @@ -3061,7 +3061,6 @@ sub show_am_history { $restriction .= " OR addition = '" . $_ . "'"; } } - $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 "") @@ -3071,38 +3070,48 @@ sub show_am_history { : "" ) ); + $restriction .= ($form->{mitarbeiter} eq "" ? "" + : ($form->{mitarbeiter} =~ /^[0-9]*$/ + ? " AND employee_id = " . $form->{mitarbeiter} + : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh))); + my $dbh = $form->dbconnect(\%myconfig); - my $searchSNumber = $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'}; - $restriction .= ($form->{mitarbeiter} eq "" ? "" - : ($form->{mitarbeiter} =~ /^[0-9]*$/ - ? " AND employee_id = " . $form->{mitarbeiter} - : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh))); - my $query = qq|SELECT trans_id AS id FROM history_erp WHERE sNumbers = '$searchSNumber' |; + 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|'|); my $sth = $dbh->prepare($query); $sth->execute() || $form->dberror($query); - - if($sth->fetch() <= 0) { - $sth->finish(); - my $query = qq|SELECT id FROM $search{$form->{what2search}} - WHERE $searchNo{$form->{'what2search'}} ILIKE '$form->{"searchid"}' - |; - } - $sth->execute() || $form->dberror($query); - $form->{title} = $locale->text("History Search"); + + $form->{title} = $locale->text("History Search"); $form->header(); - my $daten = ""; - while(my $hash_ref = $sth->fetchrow_hashref()){ - $daten = $form->get_history($dbh,$hash_ref->{id},$restriction,$form->{order}); + + my $i = 1; + my $daten = qq||; + while(my $hash_ref = $sth->fetchrow_hashref()){ + if($i) { + $daten .= $hash_ref->{id}; + $i = 0; + } + else { + $daten .= " OR trans_id = " . $hash_ref->{id}; + } } - $dbh->disconnect(); + + my ($sort, $sortby) = split(/\-\-/, $form->{order}); + $sort =~ s/.*\.(.*)$/$1/; + print $form->parse_html_template("/common/show_history", - {"DATEN" => $daten, - "SUCCESS" => ($daten != 0 ? 1 : 0), - "NONEWWINDOW" => 1 + {"DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}), + "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"), + "NONEWWINDOW" => 1, + uc($sort) => 1, + uc($sort)."BY" => $sortby }); - $lxdebug->leave_sub(); + $dbh->disconnect(); + $lxdebug->leave_sub(); } sub get_employee_id { diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 7f557fb43..7c8b1e5f1 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -538,12 +538,16 @@ sub reformat_numbers { sub show_history { $lxdebug->enter_sub(); my $dbh = $form->dbconnect(\%myconfig); - + my ($sort, $sortby) = split(/\-\-/, $form->{order}); + $sort =~ s/.*\.(.*)/$1/; + $form->{title} = $locale->text("History"); $form->header(); print $form->parse_html_template( "common/show_history", { - "DATEN" => $form->get_history($dbh,$form->{input_name}), - "SUCCESS" => ($form->get_history($dbh,$form->{input_name}) ne "0") + "DATEN" => $form->get_history($dbh,$form->{input_name},"",$form->{order}), + "SUCCESS" => ($form->get_history($dbh,$form->{input_name}) ne "0"), + uc($sort) => 1, + uc($sort)."BY" => $sortby } ); $dbh->disconnect(); diff --git a/locale/de/all b/locale/de/all index aa7c06b7c..8a5821272 100644 --- a/locale/de/all +++ b/locale/de/all @@ -1226,6 +1226,7 @@ gestartet', 'new Window' => 'neues Fenster', 'none (pricegroup)' => 'keine', 'number' => 'Nummer', + 'order' => 'Reihenfolge', 'packing_list' => 'Versandliste', 'pick_list' => 'Entnahmeliste', 'plural first char' => 'P', diff --git a/templates/webpages/common/search_history_de.html b/templates/webpages/common/search_history_de.html index bee9fee45..775d1bcf5 100644 --- a/templates/webpages/common/search_history_de.html +++ b/templates/webpages/common/search_history_de.html @@ -4,7 +4,7 @@ -
> + @@ -70,7 +70,7 @@ var tempString = ""; function addForm(last, remove) { if(last == "INIT") { - tempString = ""; for(i=0;i" + translated[defaults[i]] + "\<\/option\>" + "\n"; } @@ -100,7 +100,7 @@ document.getElementById('inputText').innerHTML += ((document.getElementById('inputText').innerHTML == "") ? ("Sie haben bereits die folgenden Einschränkungen vorgenommen:
") : ("
")) + translated[last]; if(defaults.length > 0) { document.getElementById('einschraenkungen').value += ((document.getElementById('einschraenkungen').value == "") ? ("") : (",")) + last; - tempString = ""; for(i=0;i" + translated[defaults[i]] + "\<\/option\>" + "\n"; } diff --git a/templates/webpages/common/search_history_master.html b/templates/webpages/common/search_history_master.html index 46cc67a67..d067a0473 100644 --- a/templates/webpages/common/search_history_master.html +++ b/templates/webpages/common/search_history_master.html @@ -4,7 +4,7 @@ -> + @@ -70,7 +70,7 @@ var tempString = ""; function addForm(last, remove) { if(last == "INIT") { - tempString = ""; for(i=0;i" + translated[defaults[i]] + "\<\/option\>" + "\n"; } @@ -100,7 +100,7 @@ document.getElementById('inputText').innerHTML += ((document.getElementById('inputText').innerHTML == "") ? ("You've already chosen the following limitations:
") : ("
")) + translated[last]; if(defaults.length > 0) { document.getElementById('einschraenkungen').value += ((document.getElementById('einschraenkungen').value == "") ? ("") : (",")) + last; - tempString = ""; for(i=0;i" + translated[defaults[i]] + "\<\/option\>" + "\n"; } diff --git a/templates/webpages/common/show_history_de.html b/templates/webpages/common/show_history_de.html index aa3ec4027..a0b0e40c4 100644 --- a/templates/webpages/common/show_history_de.html +++ b/templates/webpages/common/show_history_de.html @@ -29,22 +29,22 @@ diff --git a/templates/webpages/common/show_history_master.html b/templates/webpages/common/show_history_master.html index b02d51e33..a5db56a81 100644 --- a/templates/webpages/common/show_history_master.html +++ b/templates/webpages/common/show_history_master.html @@ -29,22 +29,22 @@
-  Zeitpunkt  +  Zeitpunkt   -  Mitarbeiter  +  Mitarbeiter   -  Aktion  +  Aktion  -  Zusatz  +  Zusatz  -  ID-Nummer (intern)  +  ID-Nummer (intern)   -  Buchungsnummer  +  Buchungsnummer  
-- 2.20.1
-  Zeitpunkt  +  Zeitpunkt   -  Mitarbeiter  +  Mitarbeiter   -  Aktion  +  Aktion  -  Zusatz  +  Zusatz  -  ID-Nummer  +  ID-Nummer   -  Belegnummer  +  Belegnummer