1 #=====================================================================
 
   4 # Based on SQL-Ledger Version 2.1.9
 
   5 # Web http://www.lx-office.org
 
   7 #=====================================================================
 
   8 # SQL-Ledger Accounting
 
   9 # Copyright (c) 1998-2002
 
  11 #  Author: Dieter Simader
 
  12 #   Email: dsimader@sql-ledger.org
 
  13 #     Web: http://www.sql-ledger.org
 
  16 # This program is free software; you can redistribute it and/or modify
 
  17 # it under the terms of the GNU General Public License as published by
 
  18 # the Free Software Foundation; either version 2 of the License, or
 
  19 # (at your option) any later version.
 
  21 # This program is distributed in the hope that it will be useful,
 
  22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  24 # GNU General Public License for more details.
 
  25 # You should have received a copy of the GNU General Public License
 
  26 # along with this program; if not, write to the Free Software
 
  27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
  28 #======================================================================
 
  32 #======================================================================
 
  47 require "bin/mozilla/common.pl";
 
  51 sub add      { call_sub("add_$form->{type}"); }
 
  52 sub delete   { call_sub("delete_$form->{type}"); }
 
  53 sub save     { call_sub("save_$form->{type}"); }
 
  54 sub edit     { call_sub("edit_$form->{type}"); }
 
  55 sub continue { call_sub($form->{"nextsub"}); }
 
  58   $lxdebug->enter_sub();
 
  60   $form->{title}     = "Add";
 
  61   $form->{charttype} = "A";
 
  62   AM->get_account(\%myconfig, \%$form);
 
  65     "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}"
 
  66     unless $form->{callback};
 
  71   $lxdebug->leave_sub();
 
  75   $lxdebug->enter_sub();
 
  77   $form->{title} = "Edit";
 
  78   AM->get_account(\%myconfig, \%$form);
 
  80   foreach my $item (split(/:/, $form->{link})) {
 
  81     $form->{$item} = "checked";
 
  87   $lxdebug->leave_sub();
 
  91   $lxdebug->enter_sub();
 
  93   if ( $form->{action} eq 'edit_account') {
 
  94     $form->{account_exists} = '1';
 
  97   $form->{title} = $locale->text("$form->{title} Account");
 
  99   $form->{"$form->{charttype}_checked"} = "checked";
 
 100   $form->{"$form->{category}_checked"}  = "checked";
 
 102   $form->{select_tax} = "";
 
 104   my @tax_report_pos = USTVA->report_variables({
 
 105       myconfig   => \%myconfig, 
 
 108       attribute  => 'position',
 
 112   if (@{ $form->{TAXKEY} }) {
 
 113     foreach my $item (@{ $form->{TAXKEY} }) {
 
 114       $item->{rate} = $item->{rate} * 100 . '%';
 
 117     # Fill in empty row for new Taxkey
 
 123       taxdescription => '',
 
 130     push @{ $form->{ACCOUNT_TAXKEYS} }, $newtaxkey_ref;
 
 133     foreach my $taxkey_used (@{ $form->{ACCOUNT_TAXKEYS} } ) {
 
 135       # Fill in a runningnumber
 
 136       $form->{ACCOUNT_TAXKEYS}[$i]{runningnumber} = $i;
 
 138       # Fill in the Taxkeys as select options
 
 139       foreach my $item (@{ $form->{TAXKEY} }) {
 
 140         if ($item->{id} == $taxkey_used->{tax_id}) {
 
 141           $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
 
 142             qq|<option value="$item->{id}" selected="selected">|
 
 143             . sprintf("%.2d", $item->{taxkey}) 
 
 144             . qq|. $item->{taxdescription} ($item->{rate}) |
 
 145             . $locale->text('Tax-o-matic Account') 
 
 146             . qq|: $item->{chart_accno}\n|;
 
 149           $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
 
 150             qq|<option value="$item->{id}">|
 
 151             . sprintf("%.2d", $item->{taxkey}) 
 
 152             . qq|. $item->{taxdescription} ($item->{rate}) |
 
 153             . $locale->text('Tax-o-matic Account')
 
 154             . qq|: $item->{chart_accno}\n|;
 
 159       # Fill in the USTVA Numbers as select options
 
 160       foreach my $item ( '', sort({ $a cmp $b } @tax_report_pos) ) {
 
 162           $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="" selected="selected">-\n|;
 
 164         elsif ( $item == $taxkey_used->{pos_ustva} ) {
 
 165           $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item" selected="selected">$item\n|;
 
 168           $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item">$item\n|;
 
 177   # Newaccount Folgekonto 
 
 178   if (@{ $form->{NEWACCOUNT} }) {
 
 179     if (!$form->{new_chart_valid}) {
 
 180       $form->{selectnewaccount} = qq|<option value=""> |. $locale->text('None') .q|</option>|;
 
 182     foreach $item (@{ $form->{NEWACCOUNT} }) {
 
 183       if ($item->{id} == $form->{new_chart_id}) {
 
 184         $form->{selectnewaccount} .=
 
 185           qq|<option value="$item->{id}" selected>$item->{accno}--$item->{description}</option>|;
 
 186       } elsif (!$form->{new_chart_valid}) {
 
 187         $form->{selectnewaccount} .=
 
 188           qq|<option value="$item->{id}">$item->{accno}--$item->{description}</option>|;
 
 194   $select_eur = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
 
 195   %eur = (1  => "Umsatzerlöse",
 
 196           2  => "sonstige Erlöse",
 
 197           3  => "Privatanteile",
 
 199           5  => "Ausserordentliche Erträge",
 
 200           6  => "Vereinnahmte Umsatzst.",
 
 201           7  => "Umsatzsteuererstattungen",
 
 202           8  => "Wareneingänge",
 
 203           9  => "Löhne und Gehälter",
 
 204           10 => "Gesetzl. sozialer Aufw.",
 
 206           12 => "Gas, Strom, Wasser",
 
 207           13 => "Instandhaltung",
 
 208           14 => "Steuern, Versich., Beiträge",
 
 210           16 => "Kfz-Versicherungen",
 
 211           17 => "Sonst. Fahrtkosten",
 
 212           18 => "Werbe- und Reisekosten",
 
 213           19 => "Instandhaltung u. Werkzeuge",
 
 214           20 => "Fachzeitschriften, Bücher",
 
 215           21 => "Miete für Einrichtungen",
 
 216           22 => "Rechts- und Beratungskosten",
 
 217           23 => "Bürobedarf, Porto, Telefon",
 
 218           24 => "Sonstige Aufwendungen",
 
 219           25 => "Abschreibungen auf Anlagever.",
 
 220           26 => "Abschreibungen auf GWG",
 
 222           28 => "Umsatzsteuerzahlungen",
 
 224           30 => "Ausserordentlicher Aufwand",
 
 225           31 => "Betriebliche Steuern");
 
 226   foreach $item (sort({ $a <=> $b } keys(%eur))) {
 
 227     my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $eur{$item}));
 
 228     if ($item == $form->{pos_eur}) {
 
 229       $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
 
 231       $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
 
 236   $select_bwa = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
 
 238   %bwapos = (1  => 'Umsatzerlöse',
 
 239              2  => 'Best.Verdg.FE/UE',
 
 240              3  => 'Aktiv.Eigenleistung',
 
 241              4  => 'Mat./Wareneinkauf',
 
 242              5  => 'So.betr.Erlöse',
 
 243              10 => 'Personalkosten',
 
 245              12 => 'Betriebl.Steuern',
 
 246              13 => 'Vers./Beiträge',
 
 247              14 => 'Kfz.Kosten o.St.',
 
 248              15 => 'Werbe-Reisek.',
 
 249              16 => 'Kosten Warenabgabe',
 
 250              17 => 'Abschreibungen',
 
 251              18 => 'Rep./instandhlt.',
 
 252              19 => 'Übrige Steuern',
 
 253              20 => 'Sonst.Kosten',
 
 255              31 => 'Sonst.neutr.Aufw.',
 
 257              33 => 'Sonst.neutr.Ertrag',
 
 258              34 => 'Verr.kalk.Kosten',
 
 259              35 => 'Steuern Eink.u.Ertr.');
 
 260   foreach $item (sort({ $a <=> $b } keys %bwapos)) {
 
 261     my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $bwapos{$item}));
 
 262     if ($item == $form->{pos_bwa}) {
 
 263       $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $text\n|;
 
 265       $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $text\n|;
 
 270 # Wieder hinzugefügt zu evaluationszwecken (us) 09.03.2007
 
 271   $select_bilanz = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
 
 272   foreach $item ((1, 2, 3, 4)) {
 
 273     if ($item == $form->{pos_bilanz}) {
 
 274       $select_bilanz .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|.\n|;
 
 276       $select_bilanz .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|.\n|;
 
 281   # this is for our parser only! Do not remove.
 
 282   # type=submit $locale->text('Add Account')
 
 283   # type=submit $locale->text('Edit Account')
 
 285   $form->{type} = "account";
 
 287   # preselections category
 
 289   $select_category = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
 
 292       'A'  => $locale->text('Asset'),
 
 293       'L'  => $locale->text('Liability'),
 
 294       'Q'  => $locale->text('Equity'),
 
 295       'I'  => $locale->text('Revenue'),      
 
 296       'E'  => $locale->text('Expense'),
 
 297       'C'  => $locale->text('Costs'),
 
 299   foreach $item ( sort({ $a <=> $b } keys %category) ) {
 
 300     if ($item eq $form->{category}) {
 
 301       $select_category .= qq|<option value="$item" selected="selected">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
 
 303       $select_category .= qq|<option value="$item">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
 
 308   # preselection chart type
 
 309   my $select_charttype = q{};
 
 312       'A'  => $locale->text('Account'),
 
 313       'H'  => $locale->text('Header'),
 
 316   foreach $item ( sort({ $a <=> $b } keys %charttype) ) {
 
 317     if ($item eq $form->{charttype}) {
 
 318       $select_charttype .= qq|<option value="$item" selected="selected">$charttype{$item}\n|;
 
 321       $select_charttype .= qq|<option value="$item">$charttype{$item}\n|;
 
 326   my $ChartTypeIsAccount = ($form->{charttype} eq "A") ? "1":"";
 
 330   my $parameters_ref = {
 
 331     ChartTypeIsAccount         => $ChartTypeIsAccount,
 
 332     select_category            => $select_category,
 
 333     select_charttype           => $select_charttype,
 
 334     newaccount                 => $newaccount,
 
 336     select_bwa                 => $select_bwa,
 
 337     select_bilanz              => $select_bilanz,
 
 338     select_eur                 => $select_eur,
 
 341   # Ausgabe des Templates
 
 342   print($form->parse_html_template('am/edit_accounts', $parameters_ref));
 
 345   $lxdebug->leave_sub();
 
 349   $lxdebug->enter_sub();
 
 353 <input name=callback type=hidden value="$form->{callback}">
 
 355 <input type=hidden name=login value=$form->{login}>
 
 356 <input type=hidden name=password value=$form->{password}>
 
 359   if ((!$form->{id}) || ($form->{id} && $form->{orphaned}) || (($form->{type} eq "account") && (!$form->{new_chart_valid}))) {
 
 361 <input type=submit class=submit name=action value="|
 
 362     . $locale->text('Save') . qq|">
 
 366   if ($form->{id} && $form->{orphaned}) {
 
 367     print qq|<input type=submit class=submit name=action value="|
 
 368       . $locale->text('Delete') . qq|">|;
 
 378   $lxdebug->leave_sub();
 
 382   $lxdebug->enter_sub();
 
 384   $form->isblank("accno",       $locale->text('Account Number missing!'));
 
 385   $form->isblank("description", $locale->text('Account Description missing!'));
 
 387   if ($form->{charttype} eq 'A'){
 
 388     $form->isblank("category",  $locale->text('Account Type missing!'));
 
 391   $form->redirect($locale->text('Account saved!'))
 
 392     if (AM->save_account(\%myconfig, \%$form));
 
 393   $form->error($locale->text('Cannot save account!'));
 
 395   $lxdebug->leave_sub();
 
 399   $lxdebug->enter_sub();
 
 401   CA->all_accounts(\%myconfig, \%$form);
 
 403   $form->{title} = $locale->text('Chart of Accounts');
 
 407     "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}";
 
 412   $callback = $form->escape($callback);
 
 414   foreach $ca (@{ $form->{CA} }) {
 
 419     if ($ca->{amount} > 0) {
 
 420       $ca->{credit} = $form->format_amount(\%myconfig, $ca->{amount}, 2);
 
 422     if ($ca->{amount} < 0) {
 
 423       $ca->{debit} = $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2);
 
 425     $ca->{heading}   = ( $ca->{charttype} eq 'H' ) ? 1:''; 
 
 426     $ca->{link_edit_account} = 
 
 427         qq|$form->{script}?action=edit_account&id=$ca->{id}|
 
 428        .qq|&login=$form->{login}|
 
 429        .qq|&password=$form->{password}&callback=$callback|;
 
 433   my $list_account_details_url = 
 
 434               "$form->{script}?login=$form->{login}"
 
 435              ."&password=$form->{password}&action=list_account_details&";
 
 438   my $pjx = new CGI::Ajax('list_account_details' => $list_account_details_url);
 
 440   # Eneable AJAX debuging
 
 444   push(@ { $form->{AJAX} }, $pjx);
 
 446   $form->{stylesheets} = "list_accounts.css";
 
 451   my $parameters_ref = {
 
 452   #   hidden_variables                => $_hidden_variables_ref,
 
 455   # Ausgabe des Templates
 
 456   print($form->parse_html_template2('am/list_accounts', $parameters_ref));
 
 458   $lxdebug->leave_sub();
 
 463 sub list_account_details {
 
 464 # Ajax Funktion aus list_account_details  
 
 465   $lxdebug->enter_sub();
 
 467   my $chart_id = $form->{args};
 
 469   CA->all_accounts(\%myconfig, \%$form, $chart_id);
 
 471   $form->{title} = $locale->text('Chart of Accounts');
 
 475     "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}";
 
 480   $callback = $form->escape($callback);
 
 482   foreach $ca (@{ $form->{CA} }) {
 
 484     $ca->{debit}  = " ";
 
 485     $ca->{credit} = " ";
 
 487     if ($ca->{amount} > 0) {
 
 489         $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
 
 491     if ($ca->{amount} < 0) {
 
 493         $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2, " ");
 
 496     my @links = split( q{:}, $ca->{link});
 
 500     foreach my $link (@links){
 
 501       $link = ( $link eq 'AR')             ? $locale->text('Account Link AR')
 
 502                : ( $link eq 'AP')             ? $locale->text('Account Link AP')
 
 503                : ( $link eq 'IC')             ? $locale->text('Account Link IC')
 
 504                : ( $link eq 'AR_amount' )     ? $locale->text('Account Link AR_amount')
 
 505                : ( $link eq 'AR_paid' )       ? $locale->text('Account Link AR_paid')
 
 506                : ( $link eq 'AR_tax' )        ? $locale->text('Account Link AR_tax')
 
 507                : ( $link eq 'AP_amount' )     ? $locale->text('Account Link AP_amount')
 
 508                : ( $link eq 'AP_paid' )       ? $locale->text('Account Link AP_paid')
 
 509                : ( $link eq 'AP_tax' )        ? $locale->text('Account Link AP_tax')
 
 510                : ( $link eq 'IC_sale' )       ? $locale->text('Account Link IC_sale')
 
 511                : ( $link eq 'IC_cogs' )       ? $locale->text('Account Link IC_cogs')
 
 512                : ( $link eq 'IC_taxpart' )    ? $locale->text('Account Link IC_taxpart')
 
 513                : ( $link eq 'IC_income' )     ? $locale->text('Account Link IC_income')
 
 514                : ( $link eq 'IC_expense' )    ? $locale->text('Account Link IC_expense')
 
 515                : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice')
 
 516 #               : ( $link eq 'CT_tax' )        ? $locale->text('Account Link CT_tax')
 
 517                : $locale->text('Unknown Link') . ': ' . $link;
 
 519       $ca->{link} .= ($link ne '') ?  "[$link] ":'';
 
 522     $ca->{startdate}      =~ s/,/<br>/og;
 
 523     $ca->{tk_ustva}       =~ s/,/<br>/og;
 
 524     $ca->{taxkey}         =~ s/,/<br>/og;
 
 525     $ca->{taxaccount}     =~ s/,/<br>/og;
 
 526     $ca->{taxdescription} =~ s/,/<br>/og;
 
 527     $ca->{datevautomatik} = ($ca->{datevautomatik}) ? $locale->text('On'):$locale->text('Off');
 
 529     $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
 
 530                     : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
 
 531                     : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
 
 532                     : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
 
 533                     : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
 
 534                     : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
 
 535                     : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
 
 536                     : $locale->text('Unknown Category') . ': ' . $ca->{category};
 
 538     $ca->{link_edit_account} = 
 
 539         qq|$form->{script}?action=edit_account&id=$ca->{id}|
 
 540        .qq|&login=$form->{login}|
 
 541        .qq|&password=$form->{password}&callback=$callback|;
 
 547   my $parameters_ref = {
 
 550   #   hidden_variables                => $_hidden_variables_ref,
 
 553   # Ausgabe des Templates
 
 555   my $result = $form->parse_html_template('am/list_account_details', $parameters_ref);
 
 558 #  print "chart_id:$chart_id, form->chartid:$form->{chart_id}, rest=$rest";
 
 560   $lxdebug->leave_sub();
 
 565   $lxdebug->enter_sub();
 
 567   $form->{title} = $locale->text('Delete Account');
 
 570     qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
 
 572     if ($form->{id} == $form->{$id}) {
 
 573       $form->error($locale->text('Cannot delete default account!'));
 
 577   $form->redirect($locale->text('Account deleted!'))
 
 578     if (AM->delete_account(\%myconfig, \%$form));
 
 579   $form->error($locale->text('Cannot delete account!'));
 
 581   $lxdebug->leave_sub();
 
 585   $lxdebug->enter_sub();
 
 587   $form->{title} = "Add";
 
 591     "$form->{script}?action=add_department&login=$form->{login}&password=$form->{password}"
 
 592     unless $form->{callback};
 
 597   $lxdebug->leave_sub();
 
 600 sub edit_department {
 
 601   $lxdebug->enter_sub();
 
 603   $form->{title} = "Edit";
 
 605   AM->get_department(\%myconfig, \%$form);
 
 610   $lxdebug->leave_sub();
 
 613 sub list_department {
 
 614   $lxdebug->enter_sub();
 
 616   AM->departments(\%myconfig, \%$form);
 
 619     "$form->{script}?action=list_department&login=$form->{login}&password=$form->{password}";
 
 621   $callback = $form->escape($form->{callback});
 
 623   $form->{title} = $locale->text('Departments');
 
 625   @column_index = qw(description cost profit);
 
 627   $column_header{description} =
 
 628       qq|<th class=listheading width=90%>|
 
 629     . $locale->text('Description')
 
 631   $column_header{cost} =
 
 632       qq|<th class=listheading nowrap>|
 
 633     . $locale->text('Cost Center')
 
 635   $column_header{profit} =
 
 636       qq|<th class=listheading nowrap>|
 
 637     . $locale->text('Profit Center')
 
 647     <th class=listtop>$form->{title}</th>
 
 653         <tr class=listheading>
 
 656   map { print "$column_header{$_}\n" } @column_index;
 
 662   foreach $ref (@{ $form->{ALL} }) {
 
 668         <tr valign=top class=listrow$i>
 
 671     $costcenter   = ($ref->{role} eq "C") ? "X" : "";
 
 672     $profitcenter = ($ref->{role} eq "P") ? "X" : "";
 
 674     $column_data{description} =
 
 675       qq|<td><a href=$form->{script}?action=edit_department&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
 
 676     $column_data{cost}   = qq|<td align=center>$costcenter</td>|;
 
 677     $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
 
 679     map { print "$column_data{$_}\n" } @column_index;
 
 691   <td><hr size=3 noshade></td>
 
 696 <form method=post action=$form->{script}>
 
 698 <input name=callback type=hidden value="$form->{callback}">
 
 700 <input type=hidden name=type value=department>
 
 702 <input type=hidden name=login value=$form->{login}>
 
 703 <input type=hidden name=password value=$form->{password}>
 
 705 <input class=submit type=submit name=action value="|
 
 706     . $locale->text('Add') . qq|">
 
 714   $lxdebug->leave_sub();
 
 717 sub department_header {
 
 718   $lxdebug->enter_sub();
 
 720   $form->{title} = $locale->text("$form->{title} Department");
 
 722   # $locale->text('Add Department')
 
 723   # $locale->text('Edit Department')
 
 725   $form->{description} =~ s/\"/"/g;
 
 727   if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
 
 729       qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
 
 732       qq|<input name=description size=60 value="$form->{description}">|;
 
 735   $costcenter   = "checked" if $form->{role} eq "C";
 
 736   $profitcenter = "checked" if $form->{role} eq "P";
 
 743 <form method=post action=$form->{script}>
 
 745 <input type=hidden name=id value=$form->{id}>
 
 746 <input type=hidden name=type value=department>
 
 750     <th class=listtop colspan=2>$form->{title}</th>
 
 754     <th align=right>| . $locale->text('Description') . qq|</th>
 
 755     <td>$description</td>
 
 759     <td><input type=radio style=radio name=role value="C" $costcenter> |
 
 760     . $locale->text('Cost Center') . qq|
 
 761         <input type=radio style=radio name=role value="P" $profitcenter> |
 
 762     . $locale->text('Profit Center') . qq|
 
 765     <td colspan=2><hr size=3 noshade></td>
 
 770   $lxdebug->leave_sub();
 
 773 sub save_department {
 
 774   $lxdebug->enter_sub();
 
 776   $form->isblank("description", $locale->text('Description missing!'));
 
 777   AM->save_department(\%myconfig, \%$form);
 
 778   $form->redirect($locale->text('Department saved!'));
 
 780   $lxdebug->leave_sub();
 
 783 sub delete_department {
 
 784   $lxdebug->enter_sub();
 
 786   AM->delete_department(\%myconfig, \%$form);
 
 787   $form->redirect($locale->text('Department deleted!'));
 
 789   $lxdebug->leave_sub();
 
 793   $lxdebug->enter_sub();
 
 795   $form->{title} = "Add";
 
 798     "$form->{script}?action=add_lead&login=$form->{login}&password=$form->{password}"
 
 799     unless $form->{callback};
 
 804   $lxdebug->leave_sub();
 
 808   $lxdebug->enter_sub();
 
 810   $form->{title} = "Edit";
 
 812   AM->get_lead(\%myconfig, \%$form);
 
 816   $form->{orphaned} = 1;
 
 819   $lxdebug->leave_sub();
 
 823   $lxdebug->enter_sub();
 
 825   AM->lead(\%myconfig, \%$form);
 
 828     "$form->{script}?action=list_lead&login=$form->{login}&password=$form->{password}";
 
 830   $callback = $form->escape($form->{callback});
 
 832   $form->{title} = $locale->text('Lead');
 
 834   @column_index = qw(description cost profit);
 
 836   $column_header{description} =
 
 837       qq|<th class=listheading width=100%>|
 
 838     . $locale->text('Description')
 
 848     <th class=listtop>$form->{title}</th>
 
 851   <tr class=listheading>
 
 854   map { print "$column_header{$_}\n" } @column_index;
 
 860   foreach $ref (@{ $form->{ALL} }) {
 
 866         <tr valign=top class=listrow$i>
 
 869         $lead = $ref->{lead};
 
 871     $column_data{description} =
 
 872       qq|<td><a href=$form->{script}?action=edit_lead&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{lead}</td>|;
 
 874     map { print "$column_data{$_}\n" } @column_index;
 
 883   <td><hr size=3 noshade></td>
 
 888 <form method=post action=$form->{script}>
 
 890 <input name=callback type=hidden value="$form->{callback}">
 
 892 <input type=hidden name=type value=lead>
 
 894 <input type=hidden name=login value=$form->{login}>
 
 895 <input type=hidden name=password value=$form->{password}>
 
 897 <input class=submit type=submit name=action value="|
 
 898     . $locale->text('Add') . qq|">
 
 906   $lxdebug->leave_sub();
 
 910   $lxdebug->enter_sub();
 
 912   $form->{title} = $locale->text("$form->{title} Lead");
 
 914   # $locale->text('Add Lead')
 
 915   # $locale->text('Edit Lead')
 
 917   $form->{description} =~ s/\"/"/g;
 
 920       qq|<input name=description size=50 value="$form->{lead}">|;
 
 927 <form method=post action=$form->{script}>
 
 929 <input type=hidden name=id value=$form->{id}>
 
 930 <input type=hidden name=type value=lead>
 
 934     <th class=listtop colspan=2>$form->{title}</th>
 
 938     <th align=right>| . $locale->text('Description') . qq|</th>
 
 939     <td>$description</td>
 
 941     <td colspan=2><hr size=3 noshade></td>
 
 946   $lxdebug->leave_sub();
 
 950   $lxdebug->enter_sub();
 
 952   $form->isblank("description", $locale->text('Description missing!'));
 
 953   AM->save_lead(\%myconfig, \%$form);
 
 954   $form->redirect($locale->text('lead saved!'));
 
 956   $lxdebug->leave_sub();
 
 960   $lxdebug->enter_sub();
 
 962   AM->delete_lead(\%myconfig, \%$form);
 
 963   $form->redirect($locale->text('lead deleted!'));
 
 965   $lxdebug->leave_sub();
 
 969   $lxdebug->enter_sub();
 
 971   $form->{title} = "Add";
 
 974     "$form->{script}?action=add_business&login=$form->{login}&password=$form->{password}"
 
 975     unless $form->{callback};
 
 980   $lxdebug->leave_sub();
 
 984   $lxdebug->enter_sub();
 
 986   $form->{title} = "Edit";
 
 988   AM->get_business(\%myconfig, \%$form);
 
 992   $form->{orphaned} = 1;
 
 995   $lxdebug->leave_sub();
 
 999   $lxdebug->enter_sub();
 
1001   AM->business(\%myconfig, \%$form);
 
1004     "$form->{script}?action=list_business&login=$form->{login}&password=$form->{password}";
 
1006   $callback = $form->escape($form->{callback});
 
1008   $form->{title} = $locale->text('Type of Business');
 
1010   @column_index = qw(description discount customernumberinit);
 
1012   $column_header{description} =
 
1013       qq|<th class=listheading width=60%>|
 
1014     . $locale->text('Description')
 
1016   $column_header{discount} =
 
1017       qq|<th class=listheading width=10%>|
 
1018     . $locale->text('Discount')
 
1020   $column_header{customernumberinit} =
 
1021       qq|<th class=listheading>|
 
1022     . $locale->text('Customernumberinit')
 
1032     <th class=listtop>$form->{title}</th>
 
1034   <tr height="5"></tr>
 
1038         <tr class=listheading>
 
1041   map { print "$column_header{$_}\n" } @column_index;
 
1047   foreach $ref (@{ $form->{ALL} }) {
 
1053         <tr valign=top class=listrow$i>
 
1057       $form->format_amount(\%myconfig, $ref->{discount} * 100);
 
1059       $ref->{description};
 
1060     $column_data{description} =
 
1061       qq|<td><a href=$form->{script}?action=edit_business&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$description</td>|;
 
1062     $column_data{discount}           = qq|<td align=right>$discount</td>|;
 
1063     $column_data{customernumberinit} =
 
1064       qq|<td align=right>$ref->{customernumberinit}</td>|;
 
1066     map { print "$column_data{$_}\n" } @column_index;
 
1078   <td><hr size=3 noshade></td>
 
1083 <form method=post action=$form->{script}>
 
1085 <input name=callback type=hidden value="$form->{callback}">
 
1087 <input type=hidden name=type value=business>
 
1089 <input type=hidden name=login value=$form->{login}>
 
1090 <input type=hidden name=password value=$form->{password}>
 
1092 <input class=submit type=submit name=action value="|
 
1093     . $locale->text('Add') . qq|">
 
1101   $lxdebug->leave_sub();
 
1104 sub business_header {
 
1105   $lxdebug->enter_sub();
 
1107   $form->{title}    = $locale->text("$form->{title} Business");
 
1109   # $locale->text('Add Business')
 
1110   # $locale->text('Edit Business')
 
1112   $form->{description} =~ s/\"/"/g;
 
1114     $form->format_amount(\%myconfig, $form->{discount} * 100);
 
1121 <form method=post action=$form->{script}>
 
1123 <input type=hidden name=id value=$form->{id}>
 
1124 <input type=hidden name=type value=business>
 
1128     <th class=listtop colspan=2>$form->{title}</th>
 
1130   <tr height="5"></tr>
 
1132     <th align=right>| . $locale->text('Type of Business') . qq|</th>
 
1133     <td><input name=description size=30 value="$form->{description}"></td>
 
1136     <th align=right>| . $locale->text('Discount') . qq| %</th>
 
1137     <td><input name=discount size=5 value=$form->{discount}></td>
 
1140     <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
 
1141     <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
 
1143   <td colspan=2><hr size=3 noshade></td>
 
1148   $lxdebug->leave_sub();
 
1152   $lxdebug->enter_sub();
 
1154   $form->isblank("description", $locale->text('Description missing!'));
 
1155   $form->{discount} = $form->parse_amount(\%myconfig, $form->{discount}) / 100;
 
1156   AM->save_business(\%myconfig, \%$form);
 
1157   $form->redirect($locale->text('Business saved!'));
 
1159   $lxdebug->leave_sub();
 
1162 sub delete_business {
 
1163   $lxdebug->enter_sub();
 
1165   AM->delete_business(\%myconfig, \%$form);
 
1166   $form->redirect($locale->text('Business deleted!'));
 
1168   $lxdebug->leave_sub();
 
1172   $lxdebug->enter_sub();
 
1174   $form->{title} = "Add";
 
1177     "$form->{script}?action=add_language&login=$form->{login}&password=$form->{password}"
 
1178     unless $form->{callback};
 
1183   $lxdebug->leave_sub();
 
1187   $lxdebug->enter_sub();
 
1189   $form->{title} = "Edit";
 
1191   AM->get_language(\%myconfig, \%$form);
 
1195   $form->{orphaned} = 1;
 
1198   $lxdebug->leave_sub();
 
1202   $lxdebug->enter_sub();
 
1204   AM->language(\%myconfig, \%$form);
 
1207     "$form->{script}?action=list_language&login=$form->{login}&password=$form->{password}";
 
1209   $callback = $form->escape($form->{callback});
 
1211   $form->{title} = $locale->text('Languages');
 
1213   @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
 
1215   $column_header{description} =
 
1216       qq|<th class=listheading width=60%>|
 
1217     . $locale->text('Description')
 
1219   $column_header{template_code} =
 
1220       qq|<th class=listheading width=10%>|
 
1221     . $locale->text('Template Code')
 
1223   $column_header{article_code} =
 
1224       qq|<th class=listheading>|
 
1225     . $locale->text('Article Code')
 
1227   $column_header{output_numberformat} =
 
1228       qq|<th class=listheading>|
 
1229     . $locale->text('Number Format')
 
1231   $column_header{output_dateformat} =
 
1232       qq|<th class=listheading>|
 
1233     . $locale->text('Date Format')
 
1235   $column_header{output_longdates} =
 
1236       qq|<th class=listheading>|
 
1237     . $locale->text('Long Dates')
 
1247     <th class=listtop>$form->{title}</th>
 
1249   <tr height="5"></tr>
 
1253         <tr class=listheading>
 
1256   map { print "$column_header{$_}\n" } @column_index;
 
1262   foreach $ref (@{ $form->{ALL} }) {
 
1268         <tr valign=top class=listrow$i>
 
1272     $column_data{description} =
 
1273       qq|<td><a href=$form->{script}?action=edit_language&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
 
1274     $column_data{template_code}           = qq|<td align=right>$ref->{template_code}</td>|;
 
1275     $column_data{article_code} =
 
1276       qq|<td align=right>$ref->{article_code}</td>|;
 
1277     $column_data{output_numberformat} =
 
1279       ($ref->{output_numberformat} ? $ref->{output_numberformat} :
 
1280        $locale->text("use program settings")) .
 
1282     $column_data{output_dateformat} =
 
1284       ($ref->{output_dateformat} ? $ref->{output_dateformat} :
 
1285        $locale->text("use program settings")) .
 
1287     $column_data{output_longdates} =
 
1289       ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
 
1292     map { print "$column_data{$_}\n" } @column_index;
 
1304   <td><hr size=3 noshade></td>
 
1309 <form method=post action=$form->{script}>
 
1311 <input name=callback type=hidden value="$form->{callback}">
 
1313 <input type=hidden name=type value=language>
 
1315 <input type=hidden name=login value=$form->{login}>
 
1316 <input type=hidden name=password value=$form->{password}>
 
1318 <input class=submit type=submit name=action value="|
 
1319     . $locale->text('Add') . qq|">
 
1327   $lxdebug->leave_sub();
 
1330 sub language_header {
 
1331   $lxdebug->enter_sub();
 
1333   $form->{title}    = $locale->text("$form->{title} Language");
 
1335   # $locale->text('Add Language')
 
1336   # $locale->text('Edit Language')
 
1338   $form->{description} =~ s/\"/"/g;
 
1339   $form->{template_code} =~ s/\"/"/g;
 
1340   $form->{article_code} =~ s/\"/"/g;
 
1346     qq|<option value="">| . $locale->text("use program settings") .
 
1348   foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
 
1350       ($item eq $form->{output_numberformat})
 
1351       ? "<option selected>$item"
 
1357     qq|<option value="">| . $locale->text("use program settings") .
 
1359   foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
 
1361       ($item eq $form->{output_dateformat})
 
1362       ? "<option selected>$item"
 
1370 <form method=post action=$form->{script}>
 
1372 <input type=hidden name=id value=$form->{id}>
 
1373 <input type=hidden name=type value=language>
 
1377     <th class=listtop colspan=2>$form->{title}</th>
 
1379   <tr height="5"></tr>
 
1381     <th align=right>| . $locale->text('Language') . qq|</th>
 
1382     <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
 
1385     <th align=right>| . $locale->text('Template Code') . qq|</th>
 
1386     <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
 
1389     <th align=right>| . $locale->text('Article Code') . qq|</th>
 
1390     <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
 
1393     <th align=right>| . $locale->text('Number Format') . qq|</th>
 
1394     <td><select name="output_numberformat">$numberformat</select></td>
 
1397     <th align=right>| . $locale->text('Date Format') . qq|</th>
 
1398     <td><select name="output_dateformat">$dateformat</select></td>
 
1401     <th align=right>| . $locale->text('Long Dates') . qq|</th>
 
1402     <td><input type="radio" name="output_longdates" value="1"| .
 
1403     ($form->{output_longdates} ? " checked" : "") .
 
1404     qq|>| . $locale->text("Yes") .
 
1405     qq|<input type="radio" name="output_longdates" value="0"| .
 
1406     ($form->{output_longdates} ? "" : " checked") .
 
1407     qq|>| . $locale->text("No") .
 
1410   <td colspan=2><hr size=3 noshade></td>
 
1415   $lxdebug->leave_sub();
 
1419   $lxdebug->enter_sub();
 
1421   $form->isblank("description", $locale->text('Language missing!'));
 
1422   $form->isblank("template_code", $locale->text('Template Code missing!'));
 
1423   $form->isblank("article_code", $locale->text('Article Code missing!'));
 
1424   AM->save_language(\%myconfig, \%$form);
 
1425   $form->redirect($locale->text('Language saved!'));
 
1427   $lxdebug->leave_sub();
 
1430 sub delete_language {
 
1431   $lxdebug->enter_sub();
 
1433   AM->delete_language(\%myconfig, \%$form);
 
1434   $form->redirect($locale->text('Language deleted!'));
 
1436   $lxdebug->leave_sub();
 
1440 sub add_buchungsgruppe {
 
1441   $lxdebug->enter_sub();
 
1443   # $locale->text("Add Buchungsgruppe")
 
1444   # $locale->text("Edit Buchungsgruppe")
 
1445   $form->{title} = "Add";
 
1448     "$form->{script}?action=add_buchungsgruppe&login=$form->{login}&password=$form->{password}"
 
1449     unless $form->{callback};
 
1450   AM->get_buchungsgruppe(\%myconfig, \%$form);
 
1451   $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
 
1452   for (my $i = 0; 4 > $i; $i++) {
 
1453     map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
 
1454         qw(income expense));
 
1457   &buchungsgruppe_header;
 
1460   $lxdebug->leave_sub();
 
1463 sub edit_buchungsgruppe {
 
1464   $lxdebug->enter_sub();
 
1466   $form->{title} = "Edit";
 
1468   AM->get_buchungsgruppe(\%myconfig, \%$form);
 
1470   &buchungsgruppe_header;
 
1474   $lxdebug->leave_sub();
 
1477 sub list_buchungsgruppe {
 
1478   $lxdebug->enter_sub();
 
1480   AM->buchungsgruppe(\%myconfig, \%$form);
 
1483     "$form->{script}?action=list_buchungsgruppe&login=$form->{login}&password=$form->{password}";
 
1485   $callback = $form->escape($form->{callback});
 
1487   $form->{title} = $locale->text('Buchungsgruppen');
 
1489   @column_index = qw(up down description inventory_accno
 
1490                      income_accno_0 expense_accno_0
 
1491                      income_accno_1 expense_accno_1
 
1492                      income_accno_2 expense_accno_2
 
1493                      income_accno_3 expense_accno_3 );
 
1495   $column_header{up} =
 
1496       qq|<th class="listheading" width="16">|
 
1497     . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
 
1499   $column_header{down} =
 
1500       qq|<th class="listheading" width="16">|
 
1501     . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
 
1503   $column_header{description} =
 
1504       qq|<th class="listheading" width="40%">|
 
1505     . $locale->text('Description')
 
1507   $column_header{inventory_accno} =
 
1508       qq|<th class=listheading>|
 
1509     . $locale->text('Bestandskonto')
 
1511   $column_header{income_accno_0} =
 
1512       qq|<th class=listheading>|
 
1513     . $locale->text('National Revenues')
 
1515   $column_header{expense_accno_0} =
 
1516       qq|<th class=listheading>|
 
1517     . $locale->text('National Expenses')
 
1519   $column_header{income_accno_1} =
 
1520       qq|<th class=listheading>|
 
1521     . $locale->text('Revenues EU with UStId')
 
1523   $column_header{expense_accno_1} =
 
1524       qq|<th class=listheading>|
 
1525     . $locale->text('Expenses EU with UStId')
 
1527   $column_header{income_accno_2} =
 
1528       qq|<th class=listheading>|
 
1529     . $locale->text('Revenues EU without UStId')
 
1531   $column_header{expense_accno_2} =
 
1532       qq|<th class=listheading>|
 
1533     . $locale->text('Expenses EU without UStId')
 
1535   $column_header{income_accno_3} =
 
1536       qq|<th class=listheading>|
 
1537     . $locale->text('Foreign Revenues')
 
1539   $column_header{expense_accno_3} =
 
1540       qq|<th class=listheading>|
 
1541     . $locale->text('Foreign Expenses')
 
1550     <th class=listtop>$form->{title}</th>
 
1552   <tr height="5"></tr>
 
1556         <tr class=listheading>
 
1559   map { print "$column_header{$_}\n" } @column_index;
 
1565   my $swap_link = qq|$form->{script}?action=swap_buchungsgruppen&|;
 
1566   map({ $swap_link .= $_ . "=" . $form->escape($form->{$_}) . "&" }
 
1567       qw(login password));
 
1570   foreach $ref (@{ $form->{ALL} }) {
 
1576         <tr valign=top class=listrow$i>
 
1580       my $pref = $form->{ALL}->[$row - 1];
 
1582         qq|<td align="center" valign="center" width="16">| .
 
1583         qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
 
1584         qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
 
1587       $column_data{up} = qq|<td width="16"> </td>|;
 
1590     if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
 
1591       $column_data{down} = qq|<td width="16"> </td>|;
 
1593       my $nref = $form->{ALL}->[$row + 1];
 
1594       $column_data{down} =
 
1595         qq|<td align="center" valign="center" width="16">| .
 
1596         qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
 
1597         qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
 
1601     $column_data{description} =
 
1602       qq|<td><a href=$form->{script}?action=edit_buchungsgruppe&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
 
1603     $column_data{inventory_accno}           = qq|<td align=right>$ref->{inventory_accno}</td>|;
 
1604     $column_data{income_accno_0} =
 
1605       qq|<td align=right>$ref->{income_accno_0}</td>|;
 
1606     $column_data{expense_accno_0}           = qq|<td align=right>$ref->{expense_accno_0}</td>|;
 
1607     $column_data{income_accno_1} =
 
1608       qq|<td align=right>$ref->{income_accno_1}</td>|;
 
1609     $column_data{expense_accno_1}           = qq|<td align=right>$ref->{expense_accno_1}</td>|;
 
1610     $column_data{income_accno_2} =
 
1611       qq|<td align=right>$ref->{income_accno_2}</td>|;
 
1612     $column_data{expense_accno_2}           = qq|<td align=right>$ref->{expense_accno_2}</td>|;
 
1613     $column_data{income_accno_3} =
 
1614       qq|<td align=right>$ref->{income_accno_3}</td>|;
 
1615     $column_data{expense_accno_3}           = qq|<td align=right>$ref->{expense_accno_3}</td>|;
 
1617     map { print "$column_data{$_}\n" } @column_index;
 
1631   <td><hr size=3 noshade></td>
 
1636 <form method=post action=$form->{script}>
 
1638 <input name=callback type=hidden value="$form->{callback}">
 
1640 <input type=hidden name=type value=buchungsgruppe>
 
1642 <input type=hidden name=login value=$form->{login}>
 
1643 <input type=hidden name=password value=$form->{password}>
 
1645 <input class=submit type=submit name=action value="|
 
1646     . $locale->text('Add') . qq|">
 
1654   $lxdebug->leave_sub();
 
1657 sub buchungsgruppe_header {
 
1658   $lxdebug->enter_sub();
 
1660   $form->{title}    = $locale->text("$form->{title} Buchungsgruppe");
 
1662   # $locale->text('Add Accounting Group')
 
1663   # $locale->text('Edit Accounting Group')
 
1665   my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
 
1666   my %acc_type_map = (
 
1667     "IC" => $acc_inventory,
 
1668     "IC_income" => $acc_income,
 
1669     "IC_sale" => $acc_income,
 
1670     "IC_expense" => $acc_expense,
 
1671     "IC_cogs" => $acc_expense,
 
1674   foreach $key (keys(%acc_type_map)) {
 
1675     foreach $ref (@{ $form->{IC_links}{$key} }) {
 
1676       $acc_type_map{$key}->{$ref->{"id"}} = $ref;
 
1680   foreach my $type (qw(IC IC_income IC_expense)) {
 
1681     $form->{"select$type"} =
 
1683            map({ "<option value=$_->{id} $_->{selected}>" .
 
1684                    "$_->{accno}--" . H($_->{description}) . "</option>" }
 
1685                sort({ $a->{"accno"} cmp $b->{"accno"} }
 
1686                     values(%{$acc_type_map{$type}}))));
 
1690     $form->{selectIC} =~ s/selected//g;
 
1691     $form->{selectIC} =~ s/ value=$form->{inventory_accno_id}/  value=$form->{inventory_accno_id} selected/;
 
1692     $form->{selectIC_income} =~ s/selected//g;
 
1693     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_0}/  value=$form->{income_accno_id_0} selected/;
 
1694     $form->{selectIC_expense} =~ s/selected//g;
 
1695     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_0}/  value=$form->{expense_accno_id_0} selected/;
 
1701                 <th align=right>| . $locale->text('Inventory') . qq|</th>
 
1702                 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
 
1703                 <input name=selectIC type=hidden value="$form->{selectIC}">
 
1707                 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
 
1711   $linkaccounts .= qq|
 
1713                 <th align=right>| . $locale->text('National Revenues') . qq|</th>
 
1714                 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
 
1717                 <th align=right>| . $locale->text('National Expenses') . qq|</th>
 
1718                 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
 
1721     $form->{selectIC_income} =~ s/selected//g;
 
1722     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_1}/  value=$form->{income_accno_id_1} selected/;
 
1723     $form->{selectIC_expense} =~ s/selected//g;
 
1724     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/  value=$form->{expense_accno_id_1} selected/;
 
1726   $linkaccounts .= qq|        <tr>
 
1727                 <th align=right>| . $locale->text('Revenues EU with UStId') . qq|</th>
 
1728                 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
 
1731                 <th align=right>| . $locale->text('Expenses EU with UStId') . qq|</th>
 
1732                 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
 
1736     $form->{selectIC_income} =~ s/selected//g;
 
1737     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_2}/  value=$form->{income_accno_id_2} selected/;
 
1738     $form->{selectIC_expense} =~ s/selected//g;
 
1739     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_2}/  value=$form->{expense_accno_id_2} selected/;
 
1742   $linkaccounts .= qq|        <tr>
 
1743                 <th align=right>| . $locale->text('Revenues EU without UStId') . qq|</th>
 
1744                 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
 
1747                 <th align=right>| . $locale->text('Expenses EU without UStId') . qq|</th>
 
1748                 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
 
1752     $form->{selectIC_income} =~ s/selected//g;
 
1753     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_3}/  value=$form->{income_accno_id_3} selected/;
 
1754     $form->{selectIC_expense} =~ s/selected//g;
 
1755     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_3}/  value=$form->{expense_accno_id_3} selected/;
 
1758   $linkaccounts .= qq|        <tr>
 
1759                 <th align=right>| . $locale->text('Foreign Revenues') . qq|</th>
 
1760                 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
 
1763                 <th align=right>| . $locale->text('Foreign Expenses') . qq|</th>
 
1764                 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
 
1774 <form method=post action=$form->{script}>
 
1776 <input type=hidden name=id value=$form->{id}>
 
1777 <input type=hidden name=type value=buchungsgruppe>
 
1781     <th class=listtop colspan=2>$form->{title}</th>
 
1783   <tr height="5"></tr>
 
1785     <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
 
1786     <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
 
1789   <td colspan=2><hr size=3 noshade></td>
 
1794   $lxdebug->leave_sub();
 
1797 sub save_buchungsgruppe {
 
1798   $lxdebug->enter_sub();
 
1800   $form->isblank("description", $locale->text('Description missing!'));
 
1802   AM->save_buchungsgruppe(\%myconfig, \%$form);
 
1803   $form->redirect($locale->text('Accounting Group saved!'));
 
1805   $lxdebug->leave_sub();
 
1808 sub delete_buchungsgruppe {
 
1809   $lxdebug->enter_sub();
 
1811   AM->delete_buchungsgruppe(\%myconfig, \%$form);
 
1812   $form->redirect($locale->text('Accounting Group deleted!'));
 
1814   $lxdebug->leave_sub();
 
1817 sub swap_buchungsgruppen {
 
1818   $lxdebug->enter_sub();
 
1820   AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
 
1821   list_buchungsgruppe();
 
1823   $lxdebug->leave_sub();
 
1828   $lxdebug->enter_sub();
 
1830   $form->{title} = "Add";
 
1833     "$form->{script}?action=add_printer&login=$form->{login}&password=$form->{password}"
 
1834     unless $form->{callback};
 
1839   $lxdebug->leave_sub();
 
1843   $lxdebug->enter_sub();
 
1845   $form->{title} = "Edit";
 
1847   AM->get_printer(\%myconfig, \%$form);
 
1851   $form->{orphaned} = 1;
 
1854   $lxdebug->leave_sub();
 
1858   $lxdebug->enter_sub();
 
1860   AM->printer(\%myconfig, \%$form);
 
1863     "$form->{script}?action=list_printer&login=$form->{login}&password=$form->{password}";
 
1865   $callback = $form->escape($form->{callback});
 
1867   $form->{title} = $locale->text('Printer');
 
1869   @column_index = qw(printer_description printer_command template_code);
 
1871   $column_header{printer_description} =
 
1872       qq|<th class=listheading width=60%>|
 
1873     . $locale->text('Printer Description')
 
1875   $column_header{printer_command} =
 
1876       qq|<th class=listheading width=10%>|
 
1877     . $locale->text('Printer Command')
 
1879   $column_header{template_code} =
 
1880       qq|<th class=listheading>|
 
1881     . $locale->text('Template Code')
 
1891     <th class=listtop>$form->{title}</th>
 
1893   <tr height="5"></tr>
 
1897         <tr class=listheading>
 
1900   map { print "$column_header{$_}\n" } @column_index;
 
1906   foreach $ref (@{ $form->{ALL} }) {
 
1912         <tr valign=top class=listrow$i>
 
1916     $column_data{printer_description} =
 
1917       qq|<td><a href=$form->{script}?action=edit_printer&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{printer_description}</td>|;
 
1918     $column_data{printer_command}           = qq|<td align=right>$ref->{printer_command}</td>|;
 
1919     $column_data{template_code} =
 
1920       qq|<td align=right>$ref->{template_code}</td>|;
 
1922     map { print "$column_data{$_}\n" } @column_index;
 
1934   <td><hr size=3 noshade></td>
 
1939 <form method=post action=$form->{script}>
 
1941 <input name=callback type=hidden value="$form->{callback}">
 
1943 <input type=hidden name=type value=printer>
 
1945 <input type=hidden name=login value=$form->{login}>
 
1946 <input type=hidden name=password value=$form->{password}>
 
1948 <input class=submit type=submit name=action value="|
 
1949     . $locale->text('Add') . qq|">
 
1957   $lxdebug->leave_sub();
 
1960 sub printer_header {
 
1961   $lxdebug->enter_sub();
 
1963   $form->{title}    = $locale->text("$form->{title} Printer");
 
1965   # $locale->text('Add Printer')
 
1966   # $locale->text('Edit Printer')
 
1968   $form->{printer_description} =~ s/\"/"/g;
 
1969   $form->{template_code} =~ s/\"/"/g;
 
1970   $form->{printer_command} =~ s/\"/"/g;
 
1978 <form method=post action=$form->{script}>
 
1980 <input type=hidden name=id value=$form->{id}>
 
1981 <input type=hidden name=type value=printer>
 
1985     <th class=listtop colspan=2>$form->{title}</th>
 
1987   <tr height="5"></tr>
 
1989     <th align=right>| . $locale->text('Printer') . qq|</th>
 
1990     <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
 
1993     <th align=right>| . $locale->text('Printer Command') . qq|</th>
 
1994     <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
 
1997     <th align=right>| . $locale->text('Template Code') . qq|</th>
 
1998     <td><input name=template_code size=5 value="$form->{template_code}"></td>
 
2000   <td colspan=2><hr size=3 noshade></td>
 
2005   $lxdebug->leave_sub();
 
2009   $lxdebug->enter_sub();
 
2011   $form->isblank("printer_description", $locale->text('Description missing!'));
 
2012   $form->isblank("printer_command", $locale->text('Printer Command missing!'));
 
2013   AM->save_printer(\%myconfig, \%$form);
 
2014   $form->redirect($locale->text('Printer saved!'));
 
2016   $lxdebug->leave_sub();
 
2019 sub delete_printer {
 
2020   $lxdebug->enter_sub();
 
2022   AM->delete_printer(\%myconfig, \%$form);
 
2023   $form->redirect($locale->text('Printer deleted!'));
 
2025   $lxdebug->leave_sub();
 
2029   $lxdebug->enter_sub();
 
2031   $form->{title} = "Add";
 
2034     "$form->{script}?action=add_payment&login=$form->{login}&password=$form->{password}"
 
2035     unless $form->{callback};
 
2037   $form->{terms_netto} = 0;
 
2038   $form->{terms_skonto} = 0;
 
2039   $form->{percent_skonto} = 0;
 
2040   my @languages = AM->language(\%myconfig, $form, 1);
 
2041   map({ $_->{"language"} = $_->{"description"};
 
2042         $_->{"language_id"} = $_->{"id"}; } @languages);
 
2043   $form->{"TRANSLATION"} = \@languages;
 
2047   $lxdebug->leave_sub();
 
2051   $lxdebug->enter_sub();
 
2053   $form->{title} = "Edit";
 
2055   AM->get_payment(\%myconfig, $form);
 
2056   $form->{percent_skonto} =
 
2057     $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
 
2061   $form->{orphaned} = 1;
 
2064   $lxdebug->leave_sub();
 
2068   $lxdebug->enter_sub();
 
2070   AM->payment(\%myconfig, \%$form);
 
2072   $form->{callback} = build_std_url("action=list_payment");
 
2074   $callback = $form->escape($form->{callback});
 
2076   $form->{title} = $locale->text('Payment Terms');
 
2078   @column_index = qw(up down description description_long terms_netto
 
2079                      terms_skonto percent_skonto);
 
2081   $column_header{up} =
 
2082       qq|<th class="listheading" align="center" valign="center" width="16">|
 
2083     . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
 
2085   $column_header{down} =
 
2086       qq|<th class="listheading" align="center" valign="center" width="16">|
 
2087     . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
 
2089   $column_header{description} =
 
2090       qq|<th class=listheading>|
 
2091     . $locale->text('Description')
 
2093   $column_header{description_long} =
 
2094       qq|<th class=listheading>|
 
2095     . $locale->text('Long Description')
 
2097   $column_header{terms_netto} =
 
2098       qq|<th class=listheading>|
 
2099     . $locale->text('Netto Terms')
 
2101   $column_header{terms_skonto} =
 
2102       qq|<th class=listheading>|
 
2103     . $locale->text('Skonto Terms')
 
2105   $column_header{percent_skonto} =
 
2106       qq|<th class=listheading>|
 
2107     . $locale->text('Skonto')
 
2117     <th class=listtop>$form->{title}</th>
 
2119   <tr height="5"></tr>
 
2123         <tr class=listheading>
 
2126   map { print "$column_header{$_}\n" } @column_index;
 
2132   my $swap_link = build_std_url("action=swap_payment_terms");
 
2135   foreach $ref (@{ $form->{ALL} }) {
 
2141         <tr valign=top class=listrow$i>
 
2145       my $pref = $form->{ALL}->[$row - 1];
 
2147         qq|<td align="center" valign="center" width="16">| .
 
2148         qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
 
2149         qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
 
2152       $column_data{up} = qq|<td width="16"> </td>|;
 
2155     if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
 
2156       $column_data{down} = qq|<td width="16"> </td>|;
 
2158       my $nref = $form->{ALL}->[$row + 1];
 
2159       $column_data{down} =
 
2160         qq|<td align="center" valign="center" width="16">| .
 
2161         qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
 
2162         qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
 
2166     $column_data{description} =
 
2168       build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
 
2169       qq|">| . H($ref->{description}) . qq|</a></td>|;
 
2170     $column_data{description_long} =
 
2171       qq|<td>| . H($ref->{description_long}) . qq|</td>|;
 
2172     $column_data{terms_netto} =
 
2173       qq|<td align=right>$ref->{terms_netto}</td>|;
 
2174     $column_data{terms_skonto} =
 
2175       qq|<td align=right>$ref->{terms_skonto}</td>|;
 
2176     $column_data{percent_skonto} =
 
2177       qq|<td align=right>| .
 
2178       $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
 
2180     map { print "$column_data{$_}\n" } @column_index;
 
2193   <td><hr size=3 noshade></td>
 
2198 <form method=post action=$form->{script}>
 
2200 <input name=callback type=hidden value="$form->{callback}">
 
2202 <input type=hidden name=type value=payment>
 
2204 <input type=hidden name=login value=$form->{login}>
 
2205 <input type=hidden name=password value=$form->{password}>
 
2207 <input class=submit type=submit name=action value="|
 
2208     . $locale->text('Add') . qq|">
 
2216   $lxdebug->leave_sub();
 
2219 sub payment_header {
 
2220   $lxdebug->enter_sub();
 
2222   $form->{title}    = $locale->text("$form->{title} Payment Terms");
 
2224   # $locale->text('Add Payment Terms')
 
2225   # $locale->text('Edit Payment Terms')
 
2227   $form->{description} =~ s/\"/"/g;
 
2236 <form method=post action=$form->{script}>
 
2238 <input type=hidden name=id value=$form->{id}>
 
2239 <input type=hidden name=type value=payment>
 
2243     <th class=listtop colspan=2>$form->{title}</th>
 
2245   <tr height="5"></tr>
 
2247     <th align=right>| . $locale->text('Description') . qq|</th>
 
2248     <td><input name=description size=30 value="$form->{description}"></td>
 
2251     <th align=right>| . $locale->text('Long Description') . qq|</th>
 
2252     <td><input name=description_long size=50 value="$form->{description_long}"></td>
 
2256   foreach my $language (@{ $form->{"TRANSLATION"} }) {
 
2259     <th align="right">| .
 
2260     sprintf($locale->text('Translation (%s)'),
 
2261             $language->{"language"})
 
2263     <td><input name="description_long_$language->{language_id}" size="50"
 
2264          value="| . Q($language->{"description_long"}) . qq|"></td>
 
2271     <th align=right>| . $locale->text('Netto Terms') . qq|</th>
 
2272     <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
 
2275     <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
 
2276     <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
 
2279     <th align=right>| . $locale->text('Skonto') . qq| %</th>
 
2280     <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
 
2282   <td colspan=2><hr size=3 noshade></td>
 
2286 <p>| . $locale->text("You can use the following strings in the long " .
 
2287                      "description and all translations. They will be " .
 
2288                      "replaced by their actual values by Lx-Office " .
 
2289                      "before they're output.")
 
2293   <li>| . $locale->text("<%netto_date%> -- Date the payment is due in " .
 
2296   <li>| . $locale->text("<%skonto_date%> -- Date the payment is due " .
 
2299   <li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
 
2301   <li>| . $locale->text("<%total%> -- Amount payable")
 
2303   <li>| . $locale->text("<%total_wo_skonto%> -- Amount payable less discount")
 
2305   <li>| . $locale->text("<%invtotal%> -- Invoice total")
 
2307   <li>| . $locale->text("<%invtotal_wo_skonto%> -- Invoice total less discount")
 
2309   <li>| . $locale->text("<%currency%> -- The selected currency")
 
2311   <li>| . $locale->text("<%terms_netto%> -- The number of days for " .
 
2314   <li>| . $locale->text("<%account_number%> -- Your account number")
 
2316   <li>| . $locale->text("<%bank%> -- Your bank")
 
2318   <li>| . $locale->text("<%bank_code%> -- Your bank code")
 
2322   $lxdebug->leave_sub();
 
2326   $lxdebug->enter_sub();
 
2328   $form->isblank("description", $locale->text('Description missing!'));
 
2329   $form->{"percent_skonto"} =
 
2330     $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
 
2331   AM->save_payment(\%myconfig, \%$form);
 
2332   $form->redirect($locale->text('Payment Terms saved!'));
 
2334   $lxdebug->leave_sub();
 
2337 sub delete_payment {
 
2338   $lxdebug->enter_sub();
 
2340   AM->delete_payment(\%myconfig, \%$form);
 
2341   $form->redirect($locale->text('Payment terms deleted!'));
 
2343   $lxdebug->leave_sub();
 
2346 sub swap_payment_terms {
 
2347   $lxdebug->enter_sub();
 
2349   AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
 
2352   $lxdebug->leave_sub();
 
2356   $lxdebug->enter_sub();
 
2358   # get defaults for account numbers and last numbers
 
2359   AM->defaultaccounts(\%myconfig, \%$form);
 
2361   foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
 
2363       ($item eq $myconfig{dateformat})
 
2364       ? "<option selected>$item\n"
 
2365       : "<option>$item\n";
 
2368   foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
 
2370       ($item eq $myconfig{numberformat})
 
2371       ? "<option selected>$item\n"
 
2372       : "<option>$item\n";
 
2375   foreach $item (qw(name company address signature)) {
 
2376     $myconfig{$item} =~ s/\"/"/g;
 
2379   foreach $item (qw(address signature)) {
 
2380     $myconfig{$item} =~ s/\\n/\r\n/g;
 
2384   if ($opendocument_templates && $openofficeorg_writer_bin &&
 
2385       $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
 
2386     push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
 
2387                      "value" => "opendocument_pdf" });
 
2389   if ($latex_templates) {
 
2390     push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
 
2392   push(@formats, { "name" => "HTML", "value" => "html" });
 
2393   if ($latex_templates) {
 
2394     push(@formats, { "name" => $locale->text("Postscript"),
 
2395                      "value" => "postscript" });
 
2397   if ($opendocument_templates) {
 
2398     push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
 
2399                      "value" => "opendocument" });
 
2402   if (!$myconfig{"template_format"}) {
 
2403     $myconfig{"template_format"} = "pdf";
 
2405   my $template_format = "";
 
2406   foreach $item (@formats) {
 
2408       "<option value=\"$item->{value}\"" .
 
2409       ($item->{"value"} eq $myconfig{"template_format"} ?
 
2411        ">" . H($item->{"name"}) . "</option>";
 
2414   if (!$myconfig{"default_media"}) {
 
2415     $myconfig{"default_media"} = "screen";
 
2417   my %selected = ($myconfig{"default_media"} => "selected");
 
2418   my $default_media = qq|
 
2419   <option value="screen" $selected{'screen'}>| . $locale->text("Screen") . qq|</option>
 
2420   <option value="printer" $selected{'printer'}>| . $locale->text("Printer") . qq|</option>
 
2421   <option value="queue" $selected{'queue'}>| . $locale->text("Queue") . qq|</option>
 
2425   $selected{$myconfig{"default_printer_id"}} = "selected"
 
2426     if ($myconfig{"default_printer_id"});
 
2427   my $default_printer = qq|<option></option>|;
 
2428   AM->printer(\%myconfig, $form);
 
2429   foreach my $printer (@{$form->{"ALL"}}) {
 
2430     $default_printer .= qq|<option value="| . Q($printer->{"id"}) .
 
2431       qq|" $selected{$printer->{'id'}}>| .
 
2432       H($printer->{"printer_description"}) . qq|</option>|;
 
2435   %countrycodes = User->country_codes;
 
2437   foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
 
2441       ($myconfig{countrycode} eq $key)
 
2442       ? "<option selected value=$key>$countrycodes{$key}\n"
 
2443       : "<option value=$key>$countrycodes{$key}\n";
 
2445   $countrycodes = "<option>American English\n$countrycodes";
 
2447   foreach $key (keys %{ $form->{IC} }) {
 
2448     foreach $accno (sort keys %{ $form->{IC}{$key} }) {
 
2450         ($form->{IC}{$key}{$accno}{id} == $form->{defaults}{$key})
 
2451         ? "<option selected>$accno--$form->{IC}{$key}{$accno}{description}\n"
 
2452         : "<option>$accno--$form->{IC}{$key}{$accno}{description}\n";
 
2456 #  opendir CSS, "css/.";
 
2457 #  @all = grep /.*\.css$/, readdir CSS;
 
2460 # css dir has styles that are not intended as general layouts.
 
2461 # reverting to hardcoded list
 
2462   @all = qw(lx-office-erp.css Win2000.css);
 
2464   foreach $item (@all) {
 
2465     if ($item eq $myconfig{stylesheet}) {
 
2466       $selectstylesheet .= qq|<option selected>$item\n|;
 
2468       $selectstylesheet .= qq|<option>$item\n|;
 
2471   $selectstylesheet .= "<option>\n";
 
2473   $form->{title} = $locale->text('Edit Preferences for') . qq| $form->{login}|;
 
2477   if ($myconfig{menustyle} eq "old") {
 
2478     $menustyle_old = "checked";
 
2479   } elsif ($myconfig{menustyle} eq "neu") {
 
2480     $menustyle_neu = "checked";
 
2481   } elsif ($myconfig{menustyle} eq "v3") {
 
2482     $menustyle_v3 = "checked";
 
2485   my ($show_form_details, $hide_form_details);
 
2486   $myconfig{"show_form_details"} = 1
 
2487     unless (defined($myconfig{"show_form_details"}));
 
2488   $show_form_details = "checked" if ($myconfig{"show_form_details"});
 
2489   $hide_form_details = "checked" unless ($myconfig{"show_form_details"});
 
2494 <form method=post action=$form->{script}>
 
2496 <input type=hidden name=old_password value=$myconfig{password}>
 
2497 <input type=hidden name=type value=preferences>
 
2498 <input type=hidden name=role value=$myconfig{role}>
 
2501   <tr><th class=listtop>$form->{title}</th></tr>
 
2506           <th align=right>| . $locale->text('Name') . qq|</th>
 
2507           <td><input name=name size=15 value="$myconfig{name}"></td>
 
2510           <th align=right>| . $locale->text('Password') . qq|</th>
 
2511           <td><input type=password name=new_password size=10 value=$myconfig{password}></td>
 
2514           <th align=right>| . $locale->text('E-mail') . qq|</th>
 
2515           <td><input name=email size=30 value="$myconfig{email}"></td>
 
2518           <th align=right>| . $locale->text('Signature') . qq|</th>
 
2519           <td><textarea name=signature rows=3 cols=50>$myconfig{signature}</textarea></td>
 
2522           <th align=right>| . $locale->text('Phone') . qq|</th>
 
2523           <td><input name=tel size=14 value="$myconfig{tel}"></td>
 
2526           <th align=right>| . $locale->text('Fax') . qq|</th>
 
2527           <td><input name=fax size=14 value="$myconfig{fax}"></td>
 
2530           <th align=right>| . $locale->text('Company') . qq|</th>
 
2531           <td><input name=company size=30 value="$myconfig{company}"></td>
 
2534           <th align=right>| . $locale->text('Address') . qq|</th>
 
2535           <td><textarea name=address rows=4 cols=50>$myconfig{address}</textarea></td>
 
2538           <th align=right>| . $locale->text('Date Format') . qq|</th>
 
2539           <td><select name=dateformat>$dateformat</select></td>
 
2542           <th align=right>| . $locale->text('Output Number Format') . qq|</th>
 
2543           <td><select name=numberformat>$numberformat</select></td>
 
2547           <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
 
2548           <td><input name=vclimit size=10 value="$myconfig{vclimit}"></td>
 
2551           <th align=right>| . $locale->text('Language') . qq|</th>
 
2552           <td><select name=countrycode>$countrycodes</select></td>
 
2555           <th align=right>| . $locale->text('Stylesheet') . qq|</th>
 
2556           <td><select name=usestylesheet>$selectstylesheet</select></td>
 
2559           <th align=right>| . $locale->text('Setup Menu') . qq|</th>
 
2560           <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
 
2561     $locale->text("Top (CSS)") . qq|
 
2562           <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
 
2563     $locale->text("Top (Javascript)") . qq|
 
2564     <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
 
2565     $locale->text("Old (on the side)") . qq|</td>
 
2568     <th align=right>| . $locale->text('Form details (second row)') . qq|</th>
 
2569     <td><input type="radio" id="rad_show_form_details" name="show_form_details" value="1" $show_form_details> 
 
2570     <label for="rad_show_form_details">| . $locale->text('Show by default') . qq|</label>
 
2571     <input type="radio" id="rad_hide_form_details" name="show_form_details" value="0" $hide_form_details> 
 
2572     <label for="rad_hide_form_details">| . $locale->text('Hide by default') . qq|</label></td>
 
2574         <input name=printer type=hidden value="$myconfig{printer}">
 
2575         <tr class=listheading>
 
2576           <th colspan=2>| . $locale->text("Print options") . qq|</th>
 
2579           <th align=right>| . $locale->text('Default template format') . qq|</th>
 
2580           <td><select name="template_format">$template_format</select></td>
 
2583           <th align=right>| . $locale->text('Default output medium') . qq|</th>
 
2584           <td><select name="default_media">$default_media</select></td>
 
2587           <th align=right>| . $locale->text('Default printer') . qq|</th>
 
2588           <td><select name="default_printer_id">$default_printer</select></td>
 
2591           <th align=right>| . $locale->text('Number of copies') . qq|</th>
 
2592           <td><input name="copies" size="10" value="| .
 
2593     $form->quote($myconfig{"copies"}) . qq|"></td>
 
2597         <tr class=listheading>
 
2598           <th colspan=2> </th>
 
2601           <th align=right>| . $locale->text('Business Number') . qq|</th>
 
2602           <td><input name=businessnumber size=25 value="$myconfig{businessnumber}"></td>
 
2605                 <th align=right>| . $locale->text('Year End') . qq| (mm/dd)</th>
 
2606                 <td><input name=yearend size=5 value=$form->{defaults}{yearend}></td>
 
2608         <tr class=listheading>
 
2610     . $locale->text('Last Numbers & Default Accounts') . qq|</th>
 
2616                 <th align=right nowrap>| . $locale->text('Inventory Account') . qq|</th>
 
2617                 <td><select name=inventory_accno>$myconfig{IC}</select></td>
 
2620                 <th align=right nowrap>| . $locale->text('Revenue Account') . qq|</th>
 
2621                 <td><select name=income_accno>$myconfig{IC_income}</select></td>
 
2624                 <th align=right nowrap>| . $locale->text('Expense Account') . qq|</th>
 
2625                 <td><select name=expense_accno>$myconfig{IC_expense}</select></td>
 
2628                 <th align=right nowrap>| . $locale->text('Foreign Exchange Gain') . qq|</th>
 
2629                 <td><select name=fxgain_accno>$myconfig{FX_gain}</select></td>
 
2632                 <th align=right nowrap>| . $locale->text('Foreign Exchange Loss') . qq|</th>
 
2633                 <td><select name=fxloss_accno>$myconfig{FX_loss}</select></td>
 
2638     'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies'
 
2640     . qq|<br><input name=curr size=40 value="$form->{defaults}{curr}"></td>
 
2649                 <th align=right nowrap>| . $locale->text('Last Invoice Number') . qq|</th>
 
2650                 <td><input name=invnumber size=10 value=$form->{defaults}{invnumber}></td>
 
2651                 <th align=right nowrap>|
 
2652     . $locale->text('Last Customer Number') . qq|</th>
 
2653                 <td><input name=customernumber size=10 value=$form->{defaults}{customernumber}></td>
 
2656                 <th align=right nowrap>|
 
2657     . $locale->text('Last Credit Note Number') . qq|</th>
 
2658                 <td><input name=cnnumber size=10 value=$form->{defaults}{cnnumber}></td>
 
2659                 <th align=right nowrap>|
 
2660     . $locale->text('Last Vendor Number') . qq|</th>
 
2661                 <td><input name=vendornumber size=10 value=$form->{defaults}{vendornumber}></td>
 
2664                 <th align=right nowrap>|
 
2665     . $locale->text('Last Sales Order Number') . qq|</th>
 
2666                 <td><input name=sonumber size=10 value=$form->{defaults}{sonumber}></td>
 
2669                 <th align=right nowrap>|
 
2670     . $locale->text('Last Purchase Order Number') . qq|</th>
 
2671                 <td><input name=ponumber size=10 value=$form->{defaults}{ponumber}></td>
 
2672                 <th align=right nowrap>|
 
2673     . $locale->text('Last Article Number') . qq|</th>
 
2674                 <td><input name=articlenumber size=10 value=$form->{defaults}{articlenumber}></td>
 
2677                 <th align=right nowrap>|
 
2678     . $locale->text('Last Sales Quotation Number') . qq|</th>
 
2679                 <td><input name=sqnumber size=10 value=$form->{defaults}{sqnumber}></td>
 
2680                 <th align=right nowrap>|
 
2681     . $locale->text('Last Service Number') . qq|</th>
 
2682                 <td><input name=servicenumber size=10 value=$form->{defaults}{servicenumber}></td>
 
2685                 <th align=right nowrap>| . $locale->text('Last RFQ Number') . qq|</th>
 
2686                 <td><input name=rfqnumber size=10 value=$form->{defaults}{rfqnumber}></td>
 
2687                 <th align=right nowrap></th>
 
2693 #       <tr class=listheading>
 
2694 #         <th colspan=2>| . $locale->text('Tax Accounts') . qq|</th>
 
2701 #               <th>| . $locale->text('Rate') . qq| (%)</th>
 
2702 #               <th>| . $locale->text('Number') . qq|</th>
 
2706 #   foreach $accno (sort keys %{ $form->{taxrates} }) {
 
2709 #               <th align=right>$form->{taxrates}{$accno}{description}</th>
 
2710 #               <td><input name=$form->{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}></td>
 
2711 #               <td><input name="taxnumber_$form->{taxrates}{$accno}{id}" value="$form->{taxrates}{$accno}{taxnumber}"></td>
 
2714 #     $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} ";
 
2717 #   chop $form->{taxaccounts};
 
2720 # <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
 
2729     <td><hr size=3 noshade></td>
 
2733 <input type=hidden name=login value=$form->{login}>
 
2734 <input type=hidden name=password value=$form->{password}>
 
2737 <input type=submit class=submit name=action value="|
 
2738     . $locale->text('Save') . qq|">
 
2746   $lxdebug->leave_sub();
 
2749 sub save_preferences {
 
2750   $lxdebug->enter_sub();
 
2752   $form->{stylesheet} = $form->{usestylesheet};
 
2754   $form->redirect($locale->text('Preferences saved!'))
 
2756      AM->save_preferences(\%myconfig, \%$form, $memberfile, $userspath, $webdav
 
2758   $form->error($locale->text('Cannot save preferences!'));
 
2760   $lxdebug->leave_sub();
 
2764   $lxdebug->enter_sub();
 
2766   $form->{title} = $locale->text('Audit Control');
 
2768   AM->closedto(\%myconfig, \%$form);
 
2770   if ($form->{revtrans}) {
 
2771     $checked{Y} = "checked";
 
2773     $checked{N} = "checked";
 
2781 <form method=post action=$form->{script}>
 
2783 <input type=hidden name=login value=$form->{login}>
 
2784 <input type=hidden name=password value=$form->{password}>
 
2787   <tr><th class=listtop>$form->{title}</th></tr>
 
2788   <tr height="5"></tr>
 
2794     . $locale->text('Enforce transaction reversal for all dates') . qq|</th>
 
2795           <td><input name=revtrans class=radio type=radio value="1" $checked{Y}> |
 
2796     . $locale->text('Yes')
 
2797     . qq| <input name=revtrans class=radio type=radio value="0" $checked{N}> |
 
2798     . $locale->text('No')
 
2802           <th>| . $locale->text('Close Books up to') . qq|</th>
 
2803           <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
 
2813 <input type=hidden name=nextsub value=doclose>
 
2815 <input type=submit class=submit name=action value="|
 
2816     . $locale->text('Continue') . qq|">
 
2824   $lxdebug->leave_sub();
 
2828   $lxdebug->enter_sub();
 
2830   AM->closebooks(\%myconfig, \%$form);
 
2832   if ($form->{revtrans}) {
 
2834                  $locale->text('Transaction reversal enforced for all dates'));
 
2836     if ($form->{closedto}) {
 
2838                      $locale->text('Transaction reversal enforced up to') . " "
 
2839                        . $locale->date(\%myconfig, $form->{closedto}, 1));
 
2841       $form->redirect($locale->text('Books are open'));
 
2845   $lxdebug->leave_sub();
 
2849   $lxdebug->enter_sub();
 
2851   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
 
2852   AM->units_in_use(\%myconfig, $form, $units);
 
2853   map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
 
2855   @languages = AM->language(\%myconfig, $form, 1);
 
2857   @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units}));
 
2860   foreach (@unit_list) {
 
2861     $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"});
 
2862     $_->{"UNITLANGUAGES"} = [];
 
2863     foreach my $lang (@languages) {
 
2864       push(@{ $_->{"UNITLANGUAGES"} },
 
2866              "unit" => $_->{"name"},
 
2867              "language_id" => $lang->{"id"},
 
2868              "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
 
2869              "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
 
2875   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
 
2876   $ddbox = AM->unit_select_data($units, undef, 1);
 
2878   my $updownlink = build_std_url("action=swap_units", "unit_type");
 
2880   $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
 
2882   print($form->parse_html_template("am/edit_units",
 
2883                                    { "UNITS" => \@unit_list,
 
2884                                      "NEW_BASE_UNIT_DDBOX" => $ddbox,
 
2885                                      "LANGUAGES" => \@languages,
 
2886                                      "updownlink" => $updownlink }));
 
2888   $lxdebug->leave_sub();
 
2892   $lxdebug->enter_sub();
 
2894   $form->isblank("new_name", $locale->text("The name is missing."));
 
2895   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
 
2896   $all_units = AM->retrieve_units(\%myconfig, $form);
 
2897   $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
 
2899   my ($base_unit, $factor);
 
2900   if ($form->{"new_base_unit"}) {
 
2901     $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
 
2903     $form->isblank("new_factor", $locale->text("The factor is missing."));
 
2904     $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
 
2905     $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
 
2906     $base_unit = $form->{"new_base_unit"};
 
2910   foreach my $lang (AM->language(\%myconfig, $form, 1)) {
 
2911     next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
 
2912     push(@languages, { "id" => $lang->{"id"},
 
2913                        "localized" => $form->{"new_localized_$lang->{id}"},
 
2914                        "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
 
2918   AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
 
2920   $form->{"saved_message"} = $locale->text("The unit has been saved.");
 
2924   $lxdebug->leave_sub();
 
2927 sub set_unit_languages {
 
2928   $lxdebug->enter_sub();
 
2930   my ($unit, $languages, $idx) = @_;
 
2932   $unit->{"LANGUAGES"} = [];
 
2934   foreach my $lang (@{$languages}) {
 
2935     push(@{ $unit->{"LANGUAGES"} },
 
2936          { "id" => $lang->{"id"},
 
2937            "localized" => $form->{"localized_${idx}_$lang->{id}"},
 
2938            "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
 
2942   $lxdebug->leave_sub();
 
2946   $lxdebug->enter_sub();
 
2948   $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
 
2949   AM->units_in_use(\%myconfig, $form, $old_units);
 
2951   @languages = AM->language(\%myconfig, $form, 1);
 
2955   foreach $i (1..($form->{"rowcount"} * 1)) {
 
2956     $old_unit = $old_units->{$form->{"old_name_$i"}};
 
2958       $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
 
2961     if ($form->{"unchangeable_$i"}) {
 
2962       $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
 
2963       $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
 
2964       set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
 
2968     if ($old_unit->{"in_use"}) {
 
2969       $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
 
2972     if ($form->{"delete_$i"}) {
 
2973       push(@delete_units, $old_unit->{"name"});
 
2977     $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
 
2979     $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
 
2980     my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
 
2981     $new_units->{$form->{"name_$i"}} = \%h;
 
2982     $new_units->{$form->{"name_$i"}}->{"row"} = $i;
 
2983     set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
 
2986   foreach $unit (values(%{$new_units})) {
 
2987     next unless ($unit->{"old_name"});
 
2988     if ($unit->{"base_unit"}) {
 
2989       $form->show_generic_error(sprintf($locale->text("The base unit does not exist or it is about to be deleted in row %d."), $unit->{"row"}))
 
2990         unless (defined($new_units->{$unit->{"base_unit"}}));
 
2991       $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
 
2992       $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
 
2994       $unit->{"base_unit"} = undef;
 
2995       $unit->{"factor"} = undef;
 
2999   foreach $unit (values(%{$new_units})) {
 
3000     next if ($unit->{"unchanged_unit"});
 
3002     map({ $_->{"seen"} = 0; } values(%{$new_units}));
 
3004     while ($new_unit->{"base_unit"}) {
 
3005       $new_unit->{"seen"} = 1;
 
3006       $new_unit = $new_units->{$new_unit->{"base_unit"}};
 
3007       if ($new_unit->{"seen"}) {
 
3008         $form->show_generic_error(sprintf($locale->text("The base unit relations must not contain loops (e.g. by saying that unit A's base unit is B, " .
 
3009                                                         "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
 
3014   AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
 
3016   $form->{"saved_message"} = $locale->text("The units have been saved.");
 
3020   $lxdebug->leave_sub();
 
3023 sub show_history_search {
 
3024         $lxdebug->enter_sub();
 
3026         $form->{title} = $locale->text("History Search");
 
3029     print $form->parse_html_template("/common/search_history");
 
3031         $lxdebug->leave_sub();
 
3034 sub show_am_history {
 
3035         $lxdebug->enter_sub();
 
3036         my %search = ( "Artikelnummer" => "parts",
 
3037                                    "Kundennummer"  => "customer",
 
3038                                    "Lieferantennummer" => "vendor",
 
3039                                    "Projektnummer" => "project",
 
3040                                    "Buchungsnummer" => "oe",
 
3041                                    "Eingangsrechnungnummer" => "ap",
 
3042                                    "Ausgangsrechnungnummer" => "ar",
 
3043            "Mahnungsnummer" => "dunning"
 
3045         my %searchNo = ( "Artikelnummer" => "partnumber",
 
3046                                      "Kundennummer"  => "customernumber",
 
3047                                      "Lieferantennummer" => "vendornumber",
 
3048                                      "Projektnummer" => "projectnummer",
 
3049                                      "Buchungsnummer" => "ordnumber",
 
3050                                      "Eingangsrechnungnummer" => "invnumber",
 
3051                                      "Ausgangsrechnungnummer" => "invnumber",
 
3052              "Mahnungsnummer" => "dunning_id"
 
3057         foreach(split(/\,/, $form->{einschraenkungen})) {
 
3059                         $restriction .= " AND addition = '" . $_ . "'";
 
3063                         $restriction .= " OR addition = '" . $_ . "'";
 
3066         $restriction .= (($form->{transdate} ne "" && $form->{reqdate} ne "") 
 
3067                                                 ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|' AND st.itime::date <= '| . $form->{reqdate} . qq|'|
 
3068                                                 : (($form->{transdate} ne "" && $form->{reqdate} eq "") 
 
3069                                                         ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|'|
 
3070                                                         : ($form->{transdate} eq "" && $form->{reqdate} ne "") 
 
3071                                                                 ? qq| AND st.itime::date <= '| . $form->{reqdate} . qq|'|
 
3075   $restriction .= ($form->{mitarbeiter} eq "" ? "" 
 
3076           : ($form->{mitarbeiter} =~ /^[0-9]*$/  
 
3077             ? " AND employee_id = " . $form->{mitarbeiter} 
 
3078             : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
 
3080         my $dbh = $form->dbconnect(\%myconfig);
 
3081         my $query = qq|SELECT trans_id AS id FROM history_erp | . 
 
3082                 ($form->{'searchid'} ? 
 
3083                   qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'| : 
 
3084                   qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
 
3086   my $sth = $dbh->prepare($query);
 
3088         $sth->execute() || $form->dberror($query);
 
3090   $form->{title} = $locale->text("History Search");
 
3095   while(my $hash_ref = $sth->fetchrow_hashref()){
 
3097       $daten .= $hash_ref->{id};
 
3101       $daten .= " OR trans_id = " . $hash_ref->{id};
 
3105   my ($sort, $sortby) = split(/\-\-/, $form->{order});
 
3106   $sort =~ s/.*\.(.*)$/$1/;
 
3108         print $form->parse_html_template("/common/show_history", 
 
3109     {"DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}),
 
3110      "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
 
3113      uc($sort)."BY" => $sortby
 
3116   $lxdebug->leave_sub();
 
3119 sub get_employee_id {
 
3120         $lxdebug->enter_sub();
 
3121         my $query = qq|SELECT id FROM employee WHERE name = '| . $_[0] . qq|'|;
 
3122         my $sth = $_[1]->prepare($query);
 
3123         $sth->execute() || $form->dberror($query);
 
3124         my $return = $sth->fetch();
 
3126         return ${$return}[0];
 
3127         $lxdebug->leave_sub();
 
3131   $lxdebug->enter_sub();
 
3133   my $dir = $form->{"dir"} eq "down" ? "down" : "up";
 
3134   my $unit_type = $form->{"unit_type"} eq "dimension" ?
 
3135     "dimension" : "service";
 
3136   AM->swap_units(\%myconfig, $form, $dir, $form->{"name"}, $unit_type);
 
3140   $lxdebug->leave_sub();
 
3144   $lxdebug->enter_sub();
 
3146   $form->{title} =  $locale->text('Add');
 
3149     "$form->{script}?action=add_tax&login=$form->{login}&password=$form->{password}"
 
3150     unless $form->{callback};
 
3152   _get_taxaccount_selection();
 
3156   my $parameters_ref = {
 
3157 #    ChartTypeIsAccount         => $ChartTypeIsAccount,
 
3160   # Ausgabe des Templates
 
3161   print($form->parse_html_template2('am/edit_tax', $parameters_ref));
 
3163   $lxdebug->leave_sub();
 
3167   $lxdebug->enter_sub();
 
3169   $form->{title} =  $locale->text('Edit');
 
3171   AM->get_tax(\%myconfig, \%$form);
 
3172   _get_taxaccount_selection();
 
3174   $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
 
3178   my $parameters_ref = {
 
3181   # Ausgabe des Templates
 
3182   print($form->parse_html_template2('am/edit_tax', $parameters_ref));
 
3184   $lxdebug->leave_sub();
 
3188   $lxdebug->enter_sub();
 
3190   AM->taxes(\%myconfig, \%$form);
 
3192   map { $_->{rate} = $form->format_amount(\%myconfig, $_->{rate}, 2) } @{ $form->{TAX} };
 
3194   $form->{callback} = build_std_url('action=list_tax');
 
3196   $form->{title} = $locale->text('Tax-O-Matic');
 
3200   # Ausgabe des Templates
 
3201   print($form->parse_html_template2('am/list_tax', $parameters_ref));
 
3203   $lxdebug->leave_sub();
 
3206 sub _get_taxaccount_selection{
 
3207   $lxdebug->enter_sub();
 
3209   AM->get_tax_accounts(\%myconfig, \%$form);
 
3211   map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} };
 
3213   $lxdebug->leave_sub();
 
3217   $lxdebug->enter_sub();
 
3219   $form->isblank("chart_id", $locale->text('Tax-O-Matic account missing!'));
 
3220   $form->isblank("rate", $locale->text('Taxrate missing!'));
 
3221   $form->isblank("taxdescription", $locale->text('Taxdescription  missing!'));
 
3222   $form->isblank("taxkey", $locale->text('Taxkey  missing!'));
 
3224   $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate});
 
3226   if ( $form->{rate} <= 0 || $form->{rate} >= 100 ) {
 
3227     $form->error($locale->text('Tax Percent is a number between 0 and 100'));
 
3230   if ( $form->{rate} <= 0.99 && $form->{rate} >= 0 ) {
 
3231     $form->error($locale->text('Tax Percent is a number between 0 and 100'));
 
3234   AM->save_tax(\%myconfig, \%$form);
 
3235   $form->redirect($locale->text('Tax saved!'));
 
3237   $lxdebug->leave_sub();
 
3241   $lxdebug->enter_sub();
 
3243   AM->delete_tax(\%myconfig, \%$form);
 
3244   $form->redirect($locale->text('Tax deleted!'));
 
3246   $lxdebug->leave_sub();