Beim Erstellen eines Lieferantenauftrages aus einem Kundenauftrag wird überprüft...
[kivitendo-erp.git] / bin / mozilla / am.pl
index 044bfee..6294a18 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|;
     }
 
   }
@@ -1509,35 +1512,35 @@ sub list_buchungsgruppe {
     . qq|</th>|;
   $column_header{income_accno_0} =
       qq|<th class=listheading>|
-    . $locale->text('Erlöse Inland')
+    . $locale->text('National Revenues')
     . qq|</th>|;
   $column_header{expense_accno_0} =
       qq|<th class=listheading>|
-    . $locale->text('Aufwand Inland')
+    . $locale->text('National Expenses')
     . qq|</th>|;
   $column_header{income_accno_1} =
       qq|<th class=listheading>|
-    . $locale->text('Erlöse EU m. UStId')
+    . $locale->text('Revenues EU with UStId')
     . qq|</th>|;
   $column_header{expense_accno_1} =
       qq|<th class=listheading>|
-    . $locale->text('Aufwand EU m. UStId')
+    . $locale->text('Expenses EU with UStId')
     . qq|</th>|;
   $column_header{income_accno_2} =
       qq|<th class=listheading>|
-    . $locale->text('Erlöse EU o. UStId')
+    . $locale->text('Revenues EU without UStId')
     . qq|</th>|;
   $column_header{expense_accno_2} =
       qq|<th class=listheading>|
-    . $locale->text('Aufwand EU o. UStId')
+    . $locale->text('Expenses EU without UStId')
     . qq|</th>|;
   $column_header{income_accno_3} =
       qq|<th class=listheading>|
-    . $locale->text('Erlöse Ausland')
+    . $locale->text('Foreign Revenues')
     . qq|</th>|;
   $column_header{expense_accno_3} =
       qq|<th class=listheading>|
-    . $locale->text('Aufwand Ausland')
+    . $locale->text('Foreign Expenses')
     . qq|</th>|;
   $form->header;
 
@@ -1658,8 +1661,8 @@ sub buchungsgruppe_header {
 
   $form->{title}    = $locale->text("$form->{title} Buchungsgruppe");
 
-  # $locale->text('Buchungsgruppe hinzufügen')
-  # $locale->text('Buchungsgruppe bearbeiten')
+  # $locale->text('Add Accounting Group')
+  # $locale->text('Edit Accounting Group')
 
   my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
   my %acc_type_map = (
@@ -1709,11 +1712,11 @@ sub buchungsgruppe_header {
 
   $linkaccounts .= qq|
              <tr>
-               <th align=right>| . $locale->text('Erlöse Inland') . qq|</th>
+               <th align=right>| . $locale->text('National Revenues') . qq|</th>
                <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
              </tr>
              <tr>
-               <th align=right>| . $locale->text('Aufwand Inland') . qq|</th>
+               <th align=right>| . $locale->text('National Expenses') . qq|</th>
                <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
              </tr>|;
   if ($form->{id}) {
@@ -1723,11 +1726,11 @@ sub buchungsgruppe_header {
     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/  value=$form->{expense_accno_id_1} selected/;
   }
   $linkaccounts .= qq|       <tr>
-               <th align=right>| . $locale->text('Erlöse EU m. UStId') . qq|</th>
+               <th align=right>| . $locale->text('Revenues EU with UStId') . qq|</th>
                <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
              </tr>
              <tr>
-               <th align=right>| . $locale->text('Aufwand EU m UStId') . qq|</th>
+               <th align=right>| . $locale->text('Expenses EU with UStId') . qq|</th>
                <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
              </tr>|;
 
@@ -1739,11 +1742,11 @@ sub buchungsgruppe_header {
   }
 
   $linkaccounts .= qq|       <tr>
-               <th align=right>| . $locale->text('Erlöse EU o. UStId') . qq|</th>
+               <th align=right>| . $locale->text('Revenues EU without UStId') . qq|</th>
                <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
              </tr>
              <tr>
-               <th align=right>| . $locale->text('Aufwand EU o. UStId') . qq|</th>
+               <th align=right>| . $locale->text('Expenses EU without UStId') . qq|</th>
                <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
              </tr>|;
 
@@ -1755,11 +1758,11 @@ sub buchungsgruppe_header {
   }
 
   $linkaccounts .= qq|       <tr>
-               <th align=right>| . $locale->text('Erlöse Ausland') . qq|</th>
+               <th align=right>| . $locale->text('Foreign Revenues') . qq|</th>
                <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
              </tr>
              <tr>
-               <th align=right>| . $locale->text('Aufwand Ausland') . qq|</th>
+               <th align=right>| . $locale->text('Foreign Expenses') . qq|</th>
                <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
              </tr>
 |;
@@ -1799,7 +1802,7 @@ sub save_buchungsgruppe {
   $form->isblank("description", $locale->text('Description missing!'));
 
   AM->save_buchungsgruppe(\%myconfig, \%$form);
-  $form->redirect($locale->text('Buchungsgruppe gespeichert!'));
+  $form->redirect($locale->text('Accounting Group saved!'));
 
   $lxdebug->leave_sub();
 }
@@ -1808,7 +1811,7 @@ sub delete_buchungsgruppe {
   $lxdebug->enter_sub();
 
   AM->delete_buchungsgruppe(\%myconfig, \%$form);
-  $form->redirect($locale->text('Buchungsgruppe gelöscht!'));
+  $form->redirect($locale->text('Accounting Group deleted!'));
 
   $lxdebug->leave_sub();
 }
@@ -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 {