ic.pl auf use strict umgeschrieben (experimentell)
[kivitendo-erp.git] / bin / mozilla / am.pl
index c4f2a29..02290c7 100644 (file)
@@ -36,6 +36,7 @@ use SL::CA;
 use SL::Form;
 use SL::User;
 use SL::USTVA;
+use SL::Iconv;
 use CGI::Ajax;
 use CGI;
 
@@ -223,10 +224,11 @@ sub account_header {
           30 => "Ausserordentlicher Aufwand",
           31 => "Betriebliche Steuern");
   foreach $item (sort({ $a <=> $b } keys(%eur))) {
+    my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $eur{$item}));
     if ($item == $form->{pos_eur}) {
-      $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $eur{$item}</option>\n|;
+      $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
     } else {
-      $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $eur{$item}</option>\n|;
+      $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
     }
 
   }
@@ -256,10 +258,11 @@ sub account_header {
              34 => 'Verr.kalk.Kosten',
              35 => 'Steuern Eink.u.Ertr.');
   foreach $item (sort({ $a <=> $b } keys %bwapos)) {
+    my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $bwapos{$item}));
     if ($item == $form->{pos_bwa}) {
-      $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $bwapos{$item}\n|;
+      $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $text\n|;
     } else {
-      $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $bwapos{$item}\n|;
+      $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $text\n|;
     }
 
   }
@@ -424,13 +427,13 @@ sub list_account {
     $ca->{heading}   = ( $ca->{charttype} eq 'H' ) ? 1:''; 
     $ca->{link_edit_account} = 
         qq|$form->{script}?action=edit_account&id=$ca->{id}|
-       .qq|&path=$form->{path}&login=$form->{login}|
+       .qq|&login=$form->{login}|
        .qq|&password=$form->{password}&callback=$callback|;
   }
   
   # Ajax 
   my $list_account_details_url = 
-              "$form->{script}?login=$form->{login}&path=$form->{path}"
+              "$form->{script}?login=$form->{login}"
              ."&password=$form->{password}&action=list_account_details&";
   
   
@@ -471,7 +474,7 @@ sub list_account_details {
 
   # construct callback
   $callback =
-    "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}";
+    "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}";
 
   $form->header;
 
@@ -3058,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 "") 
@@ -3068,39 +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);
+       
+  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 {