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 #======================================================================
 
  45 require "$form->{path}/common.pl";
 
  49 sub add    { &{"add_$form->{type}"} }
 
  50 sub edit   { &{"edit_$form->{type}"} }
 
  51 sub save   { &{"save_$form->{type}"} }
 
  52 sub delete { &{"delete_$form->{type}"} }
 
  55   $lxdebug->enter_sub();
 
  57   $form->{title}     = "Add";
 
  58   $form->{charttype} = "A";
 
  59   AM->get_account(\%myconfig, \%$form);
 
  62     "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
  63     unless $form->{callback};
 
  68   $lxdebug->leave_sub();
 
  72   $lxdebug->enter_sub();
 
  74   $form->{title} = "Edit";
 
  75   AM->get_account(\%myconfig, \%$form);
 
  77   foreach my $item (split(/:/, $form->{link})) {
 
  78     $form->{$item} = "checked";
 
  84   $lxdebug->leave_sub();
 
  88   $lxdebug->enter_sub();
 
  90   $form->{title} = $locale->text("$form->{title} Account");
 
  92   $checked{ $form->{charttype} } = "checked";
 
  93   $checked{"$form->{category}_"} = "checked";
 
  94   $checked{CT_tax} = ($form->{CT_tax}) ? "" : "checked";
 
  96   $form->{description} =~ s/\"/"/g;
 
  98   if (@{ $form->{TAXKEY} }) {
 
  99     foreach $item (@{ $form->{TAXKEY} }) {
 
 100       if ($item->{tax} == $form->{tax}) {
 
 101         $form->{selecttaxkey} .=
 
 102           "<option value=$item->{tax} selected>$item->{taxdescription}\n";
 
 104         $form->{selecttaxkey} .=
 
 105           "<option value=$item->{tax}>$item->{taxdescription}\n";
 
 113                 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
 
 114                 <td><select name=tax>$form->{selecttaxkey}</select></td>
 
 115                 <th align=right>| . $locale->text('Gültig ab') . qq|</th>
 
 116                 <td><input name=startdate value="$form->{startdate}"></td>
 
 119   if (@{ $form->{NEWACCOUNT} }) {
 
 120     if (!$form->{new_chart_valid}) {
 
 121       $form->{selectnewaccount} = "<option value=></option>";
 
 123     foreach $item (@{ $form->{NEWACCOUNT} }) {
 
 124       if ($item->{id} == $form->{new_chart_id}) {
 
 125         $form->{selectnewaccount} .=
 
 126           "<option value=$item->{id} selected>$item->{accno}--$item->{description}</option>";
 
 127       } elsif (!$form->{new_chart_valid}) {
 
 128         $form->{selectnewaccount} .=
 
 129           "<option value=$item->{id}>$item->{accno}--$item->{description}</option>";
 
 140                       <th align=right>| . $locale->text('Folgekonto') . qq|</th>
 
 141                       <td><select name=new_chart_id>$form->{selectnewaccount}</select></td>
 
 142                       <th align=right>| . $locale->text('Gültig ab') . qq|</th>
 
 143                       <td><input name=valid_from value="$form->{valid_from}"></td>
 
 149   $form->{selectustva} = "<option>\n";
 
 151   %ustva = (35  => $locale->text('UStVA-Nr. 35'),
 
 152             36  => $locale->text('UStVA-Nr. 36'),
 
 153             39  => $locale->text('UStVA-Nr. 39'),
 
 154             41  => $locale->text('UStVA-Nr. 41'),
 
 155             42  => $locale->text('UStVA-Nr. 42'),
 
 156             43  => $locale->text('UStVA-Nr. 43'),
 
 157             44  => $locale->text('UStVA-Nr. 44'),
 
 158             45  => $locale->text('UStVA-Nr. 45'),
 
 159             48  => $locale->text('UStVA-Nr. 48'),
 
 160             49  => $locale->text('UStVA-Nr. 49'),
 
 161             51  => $locale->text('UStVA-Nr. 51 left'),
 
 162             511 => $locale->text('UStVA-Nr. 51 right'),
 
 163             52  => $locale->text('UStVA-Nr. 52'),
 
 164             53  => $locale->text('UStVA-Nr. 53'),
 
 165             59  => $locale->text('UStVA-Nr. 59'),
 
 166             60  => $locale->text('UStVA-Nr. 60'),
 
 167             61  => $locale->text('UStVA-Nr. 61'),
 
 168             62  => $locale->text('UStVA-Nr. 62'),
 
 169             63  => $locale->text('UStVA-Nr. 63'),
 
 170             64  => $locale->text('UStVA-Nr. 64'),
 
 171             65  => $locale->text('UStVA-Nr. 65'),
 
 172             66  => $locale->text('UStVA-Nr. 66'),
 
 173             67  => $locale->text('UStVA-Nr. 67'),
 
 174             69  => $locale->text('UStVA-Nr. 69'),
 
 175             73  => $locale->text('UStVA-Nr. 73'),
 
 176             74  => $locale->text('UStVA-Nr. 74'),
 
 177             76  => $locale->text('UStVA-Nr. 76'),
 
 178             77  => $locale->text('UStVA-Nr. 77'),
 
 179             80  => $locale->text('UStVA-Nr. 80'),
 
 180             81  => $locale->text('UStVA-Nr. 81 left'),
 
 181             811 => $locale->text('UStVA-Nr. 81 right'),
 
 182             84  => $locale->text('UStVA-Nr. 84'),
 
 183             85  => $locale->text('UStVA-Nr. 85'),
 
 184             86  => $locale->text('UStVA-Nr. 86 left'),
 
 185             861 => $locale->text('UStVA-Nr. 86 right'),
 
 186             89  => $locale->text('UStVA-Nr. 89 left'),
 
 187             891 => $locale->text('UStVA-Nr. 89 right'),
 
 188             91  => $locale->text('UStVA-Nr. 91'),
 
 189             93  => $locale->text('UStVA-Nr. 93 left'),
 
 190             931 => $locale->text('UStVA-Nr. 93 right'),
 
 191             94  => $locale->text('UStVA-Nr. 94'),
 
 192             95  => $locale->text('UStVA-Nr. 95'),
 
 193             96  => $locale->text('UStVA-Nr. 96'),
 
 194             97  => $locale->text('UStVA-Nr. 97 links'),
 
 195             971 => $locale->text('UStVA-Nr. 97 rechts'),
 
 196             98  => $locale->text('UStVA-Nr. 98'));
 
 198   foreach $item (sort({ $a cmp $b } keys %ustva)) {
 
 199     if ($item == $form->{pos_ustva}) {
 
 200       $form->{selectustva} .= "<option value=$item selected>$ustva{$item}\n";
 
 202       $form->{selectustva} .= "<option value=$item>$ustva{$item}\n";
 
 209                 <th align=right>| . $locale->text('Umsatzsteuervoranmeldung') . qq|</th>
 
 210                 <td><select name=pos_ustva>$form->{selectustva}</select></td>
 
 211                 <input type=hidden name=selectustva value="$form->{selectustva}">
 
 214   $form->{selecteur} = "<option>\n";
 
 215   %eur = (1  => "Umsatzerlöse",
 
 216           2  => "sonstige Erlöse",
 
 217           3  => "Privatanteile",
 
 219           5  => "Ausserordentliche Erträge",
 
 220           6  => "Vereinnahmte Umsatzst.",
 
 221           7  => "Umsatzsteuererstattungen",
 
 222           8  => "Wareneingänge",
 
 223           9  => "Löhne und Gehälter",
 
 224           10 => "Gesetzl. sozialer Aufw.",
 
 226           12 => "Gas, Strom, Wasser",
 
 227           13 => "Instandhaltung",
 
 228           14 => "Steuern, Versich., Beiträge",
 
 230           16 => "Kfz-Versicherungen",
 
 231           17 => "Sonst. Fahrtkosten",
 
 232           18 => "Werbe- und Reisekosten",
 
 233           19 => "Instandhaltung u. Werkzeuge",
 
 234           20 => "Fachzeitschriften, Bücher",
 
 235           21 => "Miete für Einrichtungen",
 
 236           22 => "Rechts- und Beratungskosten",
 
 237           23 => "Bürobedarf, Porto, Telefon",
 
 238           24 => "Sonstige Aufwendungen",
 
 239           25 => "Abschreibungen auf Anlagever.",
 
 240           26 => "Abschreibungen auf GWG",
 
 242           28 => "Umsatzsteuerzahlungen",
 
 244           30 => "Ausserordentlicher Aufwand",
 
 245           31 => "Betriebliche Steuern");
 
 246   foreach $item (sort({ $a <=> $b } keys(%eur))) {
 
 247     if ($item == $form->{pos_eur}) {
 
 248       $form->{selecteur} .= "<option value=$item selected>$eur{$item}\n";
 
 250       $form->{selecteur} .= "<option value=$item>$eur{$item}\n";
 
 257                 <th align=right>| . $locale->text('EUER') . qq|</th>
 
 258                 <td><select name=pos_eur>$form->{selecteur}</select></td>
 
 259                 <input type=hidden name=selecteur value="$form->{selecteur}">
 
 262   $form->{selectbwa} = "<option>\n";
 
 264   %bwapos = (1  => 'Umsatzerlöse',
 
 265              2  => 'Best.Verdg.FE/UE',
 
 266              3  => 'Aktiv.Eigenleistung',
 
 267              4  => 'Mat./Wareneinkauf',
 
 268              5  => 'So.betr.Erlöse',
 
 269              10 => 'Personalkosten',
 
 271              12 => 'Betriebl.Steuern',
 
 272              13 => 'Vers./Beiträge',
 
 273              14 => 'Kfz.Kosten o.St.',
 
 274              15 => 'Werbe-Reisek.',
 
 275              16 => 'Kosten Warenabgabe',
 
 276              17 => 'Abschreibungen',
 
 277              18 => 'Rep./instandhlt.',
 
 278              19 => 'Übrige Steuern',
 
 279              20 => 'Sonst.Kosten',
 
 281              31 => 'Sonst.neutr.Aufw.',
 
 283              33 => 'Sonst.neutr.Ertrag',
 
 284              34 => 'Verr.kalk.Kosten',
 
 285              35 => 'Steuern Eink.u.Ertr.');
 
 286   foreach $item (sort({ $a <=> $b } keys %bwapos)) {
 
 287     if ($item == $form->{pos_bwa}) {
 
 288       $form->{selectbwa} .= "<option value=$item selected>$bwapos{$item}\n";
 
 290       $form->{selectbwa} .= "<option value=$item>$bwapos{$item}\n";
 
 297                 <th align=right>| . $locale->text('BWA') . qq|</th>
 
 298                 <td><select name=pos_bwa>$form->{selectbwa}</select></td>
 
 299                 <input type=hidden name=selectbwa value="$form->{selectbwa}">
 
 302 # Entfernt bis es ordentlich umgesetzt wird (hli) 30.03.2006
 
 303 #  $form->{selectbilanz} = "<option>\n";
 
 304 #  foreach $item ((1, 2, 3, 4)) {
 
 305 #    if ($item == $form->{pos_bilanz}) {
 
 306 #      $form->{selectbilanz} .= "<option value=$item selected>$item\n";
 
 308 #      $form->{selectbilanz} .= "<option value=$item>$item\n";
 
 315 #               <th align=right>| . $locale->text('Bilanz') . qq|</th>
 
 316 #               <td><select name=pos_bilanz>$form->{selectbilanz}</select></td>
 
 317 #               <input type=hidden name=selectbilanz value="$form->{selectbilanz}">
 
 320   # this is for our parser only!
 
 321   # type=submit $locale->text('Add Account')
 
 322   # type=submit $locale->text('Edit Account')
 
 323   $form->{type} = "account";
 
 330 <form method=post action=$form->{script}>
 
 332 <input type=hidden name=id value=$form->{id}>
 
 333 <input type=hidden name=type value=account>
 
 334 <input type=hidden name=orphaned value=$form->{orphaned}>
 
 335 <input type=hidden name=new_chart_valid value=$form->{new_chart_valid}>
 
 337 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>
 
 338 <input type=hidden name=income_accno_id value=$form->{income_accno_id}>
 
 339 <input type=hidden name=expense_accno_id value=$form->{expense_accno_id}>
 
 340 <input type=hidden name=fxgain_accno_id value=$form->{fxgain_accno_id}>
 
 341 <input type=hidden name=fxloss_accno_id value=$form->{fxloss_accno_id}>
 
 343 <table border=0 width=100%>
 
 345     <th class=listtop>$form->{title}</th>
 
 352           <th align=right>| . $locale->text('Account Number') . qq|</th>
 
 353           <td><input name=accno size=20 value=$form->{accno}></td>
 
 356           <th align=right>| . $locale->text('Description') . qq|</th>
 
 357           <td><input name=description size=40 value="$form->{description}"></td>
 
 360           <th align=right>| . $locale->text('Account Type') . qq|</th>
 
 364                 <td><input name=category type=radio class=radio value=A $checked{A_}> |
 
 365     . $locale->text('Asset') . qq|\n<br>
 
 366                 <input name=category type=radio class=radio value=L $checked{L_}> |
 
 367     . $locale->text('Liability') . qq|\n<br>
 
 368                 <input name=category type=radio class=radio value=Q $checked{Q_}> |
 
 369     . $locale->text('Equity') . qq|\n<br>
 
 370                 <input name=category type=radio class=radio value=I $checked{I_}> |
 
 371     . $locale->text('Revenue') . qq|\n<br>
 
 372                 <input name=category type=radio class=radio value=E $checked{E_}> |
 
 373     . $locale->text('Expense') . qq|<br>
 
 374                 <input name=category type=radio class=radio value=C $checked{C_}> |
 
 375     . $locale->text('Costs') . qq|</td>
 
 376                 <td width=50> </td>
 
 378                 <input name=charttype type=radio class=radio value="H" $checked{H}> |
 
 379     . $locale->text('Heading') . qq|<br>
 
 380                 <input name=charttype type=radio class=radio value="A" $checked{A}> |
 
 381     . $locale->text('Account') . qq|</td>
 
 388   if ($form->{charttype} eq "A") {
 
 395       . $locale->text('Is this a summary account to record') . qq|</th>
 
 397                 <input name=AR type=checkbox class=checkbox value=AR $form->{AR}> |
 
 398       . $locale->text('AR')
 
 399       . qq| <input name=AP type=checkbox class=checkbox value=AP $form->{AP}> |
 
 400       . $locale->text('AP')
 
 401       . qq| <input name=IC type=checkbox class=checkbox value=IC $form->{IC}> |
 
 402       . $locale->text('Inventory')
 
 409           <th colspan=2>| . $locale->text('Include in drop-down menus') . qq|</th>
 
 415                 <th align=left>| . $locale->text('Receivables') . qq|</th>
 
 416                 <th align=left>| . $locale->text('Payables') . qq|</th>
 
 417                 <th align=left>| . $locale->text('Parts Inventory') . qq|</th>
 
 418                 <th align=left>| . $locale->text('Service Items') . qq|</th>
 
 422                 <input name=AR_amount type=checkbox class=checkbox value=AR_amount $form->{AR_amount}> |
 
 423       . $locale->text('Revenue') . qq|\n<br>
 
 424                 <input name=AR_paid type=checkbox class=checkbox value=AR_paid $form->{AR_paid}> |
 
 425       . $locale->text('Receipt') . qq|\n<br>
 
 426                 <input name=AR_tax type=checkbox class=checkbox value=AR_tax $form->{AR_tax}> |
 
 427       . $locale->text('Tax') . qq|
 
 430                 <input name=AP_amount type=checkbox class=checkbox value=AP_amount $form->{AP_amount}> |
 
 431       . $locale->text('Expense/Asset') . qq|\n<br>
 
 432                 <input name=AP_paid type=checkbox class=checkbox value=AP_paid $form->{AP_paid}> |
 
 433       . $locale->text('Payment') . qq|\n<br>
 
 434                 <input name=AP_tax type=checkbox class=checkbox value=AP_tax $form->{AP_tax}> |
 
 435       . $locale->text('Tax') . qq|
 
 438                 <input name=IC_sale type=checkbox class=checkbox value=IC_sale $form->{IC_sale}> |
 
 439       . $locale->text('Revenue') . qq|\n<br>
 
 440                 <input name=IC_cogs type=checkbox class=checkbox value=IC_cogs $form->{IC_cogs}> |
 
 441       . $locale->text('Expense') . qq|\n<br>
 
 442                 <input name=IC_taxpart type=checkbox class=checkbox value=IC_taxpart $form->{IC_taxpart}> |
 
 443       . $locale->text('Tax') . qq|
 
 446                 <input name=IC_income type=checkbox class=checkbox value=IC_income $form->{IC_income}> |
 
 447       . $locale->text('Revenue') . qq|\n<br>
 
 448                 <input name=IC_expense type=checkbox class=checkbox value=IC_expense $form->{IC_expense}> |
 
 449       . $locale->text('Expense') . qq|\n<br>
 
 450                 <input name=IC_taxservice type=checkbox class=checkbox value=IC_taxservice $form->{IC_taxservice}> |
 
 451       . $locale->text('Tax') . qq|
 
 471     <td><hr size=3 noshade></td>
 
 476   $lxdebug->leave_sub();
 
 480   $lxdebug->enter_sub();
 
 484 <input name=callback type=hidden value="$form->{callback}">
 
 486 <input type=hidden name=path value=$form->{path}>
 
 487 <input type=hidden name=login value=$form->{login}>
 
 488 <input type=hidden name=password value=$form->{password}>
 
 491   if ((!$form->{id}) || ($form->{id} && $form->{orphaned}) || (($form->{type} eq "account") && (!$form->{new_chart_valid}))) {
 
 493 <input type=submit class=submit name=action value="|
 
 494     . $locale->text('Save') . qq|">
 
 498   if ($form->{id} && $form->{orphaned}) {
 
 499     print qq|<input type=submit class=submit name=action value="|
 
 500       . $locale->text('Delete') . qq|">|;
 
 510   $lxdebug->leave_sub();
 
 514   $lxdebug->enter_sub();
 
 516   $form->isblank("accno",    $locale->text('Account Number missing!'));
 
 517   $form->isblank("category", $locale->text('Account Type missing!'));
 
 519   $form->redirect($locale->text('Account saved!'))
 
 520     if (AM->save_account(\%myconfig, \%$form));
 
 521   $form->error($locale->text('Cannot save account!'));
 
 523   $lxdebug->leave_sub();
 
 527   $lxdebug->enter_sub();
 
 529   CA->all_accounts(\%myconfig, \%$form);
 
 531   $form->{title} = $locale->text('Chart of Accounts');
 
 535     "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
 540   $callback = $form->escape($callback);
 
 542   foreach $ca (@{ $form->{CA} }) {
 
 544     $ca->{debit}  = " ";
 
 545     $ca->{credit} = " ";
 
 547     if ($ca->{amount} > 0) {
 
 549         $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
 
 551     if ($ca->{amount} < 0) {
 
 553         $form->format_amount(\%myconfig, -$ca->{amount}, 2, " ");
 
 556     my @links = split( q{:}, $ca->{link});
 
 560     foreach my $link (@links){
 
 561       $link = ( $link eq 'AR')             ? $locale->text('Account Link AR')
 
 562                : ( $link eq 'AP')             ? $locale->text('Account Link AP')
 
 563                : ( $link eq 'IC')             ? $locale->text('Account Link IC')
 
 564                : ( $link eq 'AR_amount' )     ? $locale->text('Account Link AR_amount')
 
 565                : ( $link eq 'AR_paid' )       ? $locale->text('Account Link AR_paid')
 
 566                : ( $link eq 'AR_tax' )        ? $locale->text('Account Link AR_tax')
 
 567                : ( $link eq 'AP_amount' )     ? $locale->text('Account Link AP_amount')
 
 568                : ( $link eq 'AP_paid' )       ? $locale->text('Account Link AP_paid')
 
 569                : ( $link eq 'AP_tax' )        ? $locale->text('Account Link AP_tax')
 
 570                : ( $link eq 'IC_sale' )       ? $locale->text('Account Link IC_sale')
 
 571                : ( $link eq 'IC_cogs' )       ? $locale->text('Account Link IC_cogs')
 
 572                : ( $link eq 'IC_taxpart' )    ? $locale->text('Account Link IC_taxpart')
 
 573                : ( $link eq 'IC_income' )     ? $locale->text('Account Link IC_income')
 
 574                : ( $link eq 'IC_expense' )    ? $locale->text('Account Link IC_expense')
 
 575                : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice')
 
 576                : ( $link eq 'CT_tax' )        ? $locale->text('Account Link CT_tax')
 
 577                : $locale->text('Unknown Link') . ': ' . $link;
 
 579       $ca->{link} .= qq|[| . $link . qq|] |;
 
 582     $ca->{startdate}      =~ s/,/<br>/og;
 
 583     $ca->{tk_ustva}       =~ s/,/<br>/og;
 
 584     $ca->{taxkey}         =~ s/,/<br>/og;
 
 585     $ca->{taxaccount}     =~ s/,/<br>/og;
 
 586     $ca->{taxdescription} =~ s/,/<br>/og;
 
 587     $ca->{datevautomatik} = ($ca->{datevautomatik}) ? $locale->text('On'):q{};
 
 589     $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
 
 590                     : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
 
 591                     : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
 
 592                     : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
 
 593                     : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
 
 594                     : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
 
 595                     : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
 
 596                     : $locale->text('Unknown Category') . ': ' . $ca->{category};
 
 598     $ca->{link_edit_account} = 
 
 599         qq|$form->{script}?action=edit_account&id=$ca->{id}|
 
 600        .qq|&path=$form->{path}&login=$form->{login}|
 
 601        .qq|&password=$form->{password}&callback=$callback|;
 
 604   my $parameters_ref = {
 
 607   #   hidden_variables                => $_hidden_variables_ref,
 
 610   # Ausgabe des Templates
 
 611   print($form->parse_html_template('am/list_accounts', $parameters_ref));
 
 613   $lxdebug->leave_sub();
 
 619   $lxdebug->enter_sub();
 
 621   $form->{title} = $locale->text('Delete Account');
 
 624     qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
 
 626     if ($form->{id} == $form->{$id}) {
 
 627       $form->error($locale->text('Cannot delete default account!'));
 
 631   $form->redirect($locale->text('Account deleted!'))
 
 632     if (AM->delete_account(\%myconfig, \%$form));
 
 633   $form->error($locale->text('Cannot delete account!'));
 
 635   $lxdebug->leave_sub();
 
 639   $lxdebug->enter_sub();
 
 641   $form->{title} = "Add";
 
 645     "$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
 646     unless $form->{callback};
 
 651   $lxdebug->leave_sub();
 
 654 sub edit_department {
 
 655   $lxdebug->enter_sub();
 
 657   $form->{title} = "Edit";
 
 659   AM->get_department(\%myconfig, \%$form);
 
 664   $lxdebug->leave_sub();
 
 667 sub list_department {
 
 668   $lxdebug->enter_sub();
 
 670   AM->departments(\%myconfig, \%$form);
 
 673     "$form->{script}?action=list_department&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
 675   $callback = $form->escape($form->{callback});
 
 677   $form->{title} = $locale->text('Departments');
 
 679   @column_index = qw(description cost profit);
 
 681   $column_header{description} =
 
 682       qq|<th class=listheading width=90%>|
 
 683     . $locale->text('Description')
 
 685   $column_header{cost} =
 
 686       qq|<th class=listheading nowrap>|
 
 687     . $locale->text('Cost Center')
 
 689   $column_header{profit} =
 
 690       qq|<th class=listheading nowrap>|
 
 691     . $locale->text('Profit Center')
 
 701     <th class=listtop>$form->{title}</th>
 
 707         <tr class=listheading>
 
 710   map { print "$column_header{$_}\n" } @column_index;
 
 716   foreach $ref (@{ $form->{ALL} }) {
 
 722         <tr valign=top class=listrow$i>
 
 725     $costcenter   = ($ref->{role} eq "C") ? "X" : "";
 
 726     $profitcenter = ($ref->{role} eq "P") ? "X" : "";
 
 728     $column_data{description} =
 
 729       qq|<td><a href=$form->{script}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
 
 730     $column_data{cost}   = qq|<td align=center>$costcenter</td>|;
 
 731     $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
 
 733     map { print "$column_data{$_}\n" } @column_index;
 
 745   <td><hr size=3 noshade></td>
 
 750 <form method=post action=$form->{script}>
 
 752 <input name=callback type=hidden value="$form->{callback}">
 
 754 <input type=hidden name=type value=department>
 
 756 <input type=hidden name=path value=$form->{path}>
 
 757 <input type=hidden name=login value=$form->{login}>
 
 758 <input type=hidden name=password value=$form->{password}>
 
 760 <input class=submit type=submit name=action value="|
 
 761     . $locale->text('Add') . qq|">
 
 769   $lxdebug->leave_sub();
 
 772 sub department_header {
 
 773   $lxdebug->enter_sub();
 
 775   $form->{title} = $locale->text("$form->{title} Department");
 
 777   # $locale->text('Add Department')
 
 778   # $locale->text('Edit Department')
 
 780   $form->{description} =~ s/\"/"/g;
 
 782   if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
 
 784       qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
 
 787       qq|<input name=description size=60 value="$form->{description}">|;
 
 790   $costcenter   = "checked" if $form->{role} eq "C";
 
 791   $profitcenter = "checked" if $form->{role} eq "P";
 
 798 <form method=post action=$form->{script}>
 
 800 <input type=hidden name=id value=$form->{id}>
 
 801 <input type=hidden name=type value=department>
 
 805     <th class=listtop colspan=2>$form->{title}</th>
 
 809     <th align=right>| . $locale->text('Description') . qq|</th>
 
 810     <td>$description</td>
 
 814     <td><input type=radio style=radio name=role value="C" $costcenter> |
 
 815     . $locale->text('Cost Center') . qq|
 
 816         <input type=radio style=radio name=role value="P" $profitcenter> |
 
 817     . $locale->text('Profit Center') . qq|
 
 820     <td colspan=2><hr size=3 noshade></td>
 
 825   $lxdebug->leave_sub();
 
 828 sub save_department {
 
 829   $lxdebug->enter_sub();
 
 831   $form->isblank("description", $locale->text('Description missing!'));
 
 832   AM->save_department(\%myconfig, \%$form);
 
 833   $form->redirect($locale->text('Department saved!'));
 
 835   $lxdebug->leave_sub();
 
 838 sub delete_department {
 
 839   $lxdebug->enter_sub();
 
 841   AM->delete_department(\%myconfig, \%$form);
 
 842   $form->redirect($locale->text('Department deleted!'));
 
 844   $lxdebug->leave_sub();
 
 848   $lxdebug->enter_sub();
 
 850   $form->{title} = "Add";
 
 853     "$form->{script}?action=add_lead&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
 854     unless $form->{callback};
 
 859   $lxdebug->leave_sub();
 
 863   $lxdebug->enter_sub();
 
 865   $form->{title} = "Edit";
 
 867   AM->get_lead(\%myconfig, \%$form);
 
 871   $form->{orphaned} = 1;
 
 874   $lxdebug->leave_sub();
 
 878   $lxdebug->enter_sub();
 
 880   AM->lead(\%myconfig, \%$form);
 
 883     "$form->{script}?action=list_lead&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
 885   $callback = $form->escape($form->{callback});
 
 887   $form->{title} = $locale->text('Lead');
 
 889   @column_index = qw(description cost profit);
 
 891   $column_header{description} =
 
 892       qq|<th class=listheading width=100%>|
 
 893     . $locale->text('Description')
 
 903     <th class=listtop>$form->{title}</th>
 
 906   <tr class=listheading>
 
 909   map { print "$column_header{$_}\n" } @column_index;
 
 915   foreach $ref (@{ $form->{ALL} }) {
 
 921         <tr valign=top class=listrow$i>
 
 924         $lead = $ref->{lead};
 
 926     $column_data{description} =
 
 927       qq|<td><a href=$form->{script}?action=edit_lead&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{lead}</td>|;
 
 929     map { print "$column_data{$_}\n" } @column_index;
 
 938   <td><hr size=3 noshade></td>
 
 943 <form method=post action=$form->{script}>
 
 945 <input name=callback type=hidden value="$form->{callback}">
 
 947 <input type=hidden name=type value=lead>
 
 949 <input type=hidden name=path value=$form->{path}>
 
 950 <input type=hidden name=login value=$form->{login}>
 
 951 <input type=hidden name=password value=$form->{password}>
 
 953 <input class=submit type=submit name=action value="|
 
 954     . $locale->text('Add') . qq|">
 
 962   $lxdebug->leave_sub();
 
 966   $lxdebug->enter_sub();
 
 968   $form->{title} = $locale->text("$form->{title} Lead");
 
 970   # $locale->text('Add Lead')
 
 971   # $locale->text('Edit Lead')
 
 973   $form->{description} =~ s/\"/"/g;
 
 976       qq|<input name=description size=50 value="$form->{lead}">|;
 
 983 <form method=post action=$form->{script}>
 
 985 <input type=hidden name=id value=$form->{id}>
 
 986 <input type=hidden name=type value=lead>
 
 990     <th class=listtop colspan=2>$form->{title}</th>
 
 994     <th align=right>| . $locale->text('Description') . qq|</th>
 
 995     <td>$description</td>
 
 997     <td colspan=2><hr size=3 noshade></td>
 
1002   $lxdebug->leave_sub();
 
1006   $lxdebug->enter_sub();
 
1008   $form->isblank("description", $locale->text('Description missing!'));
 
1009   AM->save_lead(\%myconfig, \%$form);
 
1010   $form->redirect($locale->text('lead saved!'));
 
1012   $lxdebug->leave_sub();
 
1016   $lxdebug->enter_sub();
 
1018   AM->delete_lead(\%myconfig, \%$form);
 
1019   $form->redirect($locale->text('lead deleted!'));
 
1021   $lxdebug->leave_sub();
 
1025   $lxdebug->enter_sub();
 
1027   $form->{title} = "Add";
 
1030     "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1031     unless $form->{callback};
 
1036   $lxdebug->leave_sub();
 
1040   $lxdebug->enter_sub();
 
1042   $form->{title} = "Edit";
 
1044   AM->get_business(\%myconfig, \%$form);
 
1048   $form->{orphaned} = 1;
 
1051   $lxdebug->leave_sub();
 
1055   $lxdebug->enter_sub();
 
1057   AM->business(\%myconfig, \%$form);
 
1060     "$form->{script}?action=list_business&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1062   $callback = $form->escape($form->{callback});
 
1064   $form->{title} = $locale->text('Type of Business');
 
1066   @column_index = qw(description discount customernumberinit);
 
1068   $column_header{description} =
 
1069       qq|<th class=listheading width=60%>|
 
1070     . $locale->text('Description')
 
1072   $column_header{discount} =
 
1073       qq|<th class=listheading width=10%>|
 
1074     . $locale->text('Discount')
 
1076   $column_header{customernumberinit} =
 
1077       qq|<th class=listheading>|
 
1078     . $locale->text('Customernumberinit')
 
1088     <th class=listtop>$form->{title}</th>
 
1090   <tr height="5"></tr>
 
1094         <tr class=listheading>
 
1097   map { print "$column_header{$_}\n" } @column_index;
 
1103   foreach $ref (@{ $form->{ALL} }) {
 
1109         <tr valign=top class=listrow$i>
 
1113       $form->format_amount(\%myconfig, $ref->{discount} * 100);
 
1116       ? "<b>$ref->{description}</b>"
 
1117       : "$ref->{description}";
 
1118     $column_data{description} =
 
1119       qq|<td><a href=$form->{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$description</td>|;
 
1120     $column_data{discount}           = qq|<td align=right>$discount</td>|;
 
1121     $column_data{customernumberinit} =
 
1122       qq|<td align=right>$ref->{customernumberinit}</td>|;
 
1124     map { print "$column_data{$_}\n" } @column_index;
 
1136   <td><hr size=3 noshade></td>
 
1141 <form method=post action=$form->{script}>
 
1143 <input name=callback type=hidden value="$form->{callback}">
 
1145 <input type=hidden name=type value=business>
 
1147 <input type=hidden name=path value=$form->{path}>
 
1148 <input type=hidden name=login value=$form->{login}>
 
1149 <input type=hidden name=password value=$form->{password}>
 
1151 <input class=submit type=submit name=action value="|
 
1152     . $locale->text('Add') . qq|">
 
1160   $lxdebug->leave_sub();
 
1163 sub business_header {
 
1164   $lxdebug->enter_sub();
 
1166   $form->{title}    = $locale->text("$form->{title} Business");
 
1167   $form->{salesman} = "checked" if $form->{salesman};
 
1169   # $locale->text('Add Business')
 
1170   # $locale->text('Edit Business')
 
1172   $form->{description} =~ s/\"/"/g;
 
1174     $form->format_amount(\%myconfig, $form->{discount} * 100);
 
1181 <form method=post action=$form->{script}>
 
1183 <input type=hidden name=id value=$form->{id}>
 
1184 <input type=hidden name=type value=business>
 
1188     <th class=listtop colspan=2>$form->{title}</th>
 
1190   <tr height="5"></tr>
 
1192     <th align=right>| . $locale->text('Type of Business') . qq|</th>
 
1193     <td><input name=description size=30 value="$form->{description}"></td>
 
1196     <th align=right>| . $locale->text('Discount') . qq| %</th>
 
1197     <td><input name=discount size=5 value=$form->{discount}></td>
 
1200     <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
 
1201     <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
 
1204     <td align=right>| . $locale->text('Salesman') . qq|</td>
 
1205     <td><input name=salesman class=checkbox type=checkbox value=1 $form->{salesman}></td>
 
1207   <td colspan=2><hr size=3 noshade></td>
 
1212   $lxdebug->leave_sub();
 
1216   $lxdebug->enter_sub();
 
1218   $form->isblank("description", $locale->text('Description missing!'));
 
1219   $form->{discount} = $form->parse_amount(\%myconfig, $form->{discount}) / 100;
 
1220   AM->save_business(\%myconfig, \%$form);
 
1221   $form->redirect($locale->text('Business saved!'));
 
1223   $lxdebug->leave_sub();
 
1226 sub delete_business {
 
1227   $lxdebug->enter_sub();
 
1229   AM->delete_business(\%myconfig, \%$form);
 
1230   $form->redirect($locale->text('Business deleted!'));
 
1232   $lxdebug->leave_sub();
 
1236   $lxdebug->enter_sub();
 
1238   $form->{title} = "Add";
 
1241     "$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1242     unless $form->{callback};
 
1247   $lxdebug->leave_sub();
 
1251   $lxdebug->enter_sub();
 
1253   $form->{title} = "Edit";
 
1255   AM->get_language(\%myconfig, \%$form);
 
1259   $form->{orphaned} = 1;
 
1262   $lxdebug->leave_sub();
 
1266   $lxdebug->enter_sub();
 
1268   AM->language(\%myconfig, \%$form);
 
1271     "$form->{script}?action=list_language&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1273   $callback = $form->escape($form->{callback});
 
1275   $form->{title} = $locale->text('Languages');
 
1277   @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
 
1279   $column_header{description} =
 
1280       qq|<th class=listheading width=60%>|
 
1281     . $locale->text('Description')
 
1283   $column_header{template_code} =
 
1284       qq|<th class=listheading width=10%>|
 
1285     . $locale->text('Template Code')
 
1287   $column_header{article_code} =
 
1288       qq|<th class=listheading>|
 
1289     . $locale->text('Article Code')
 
1291   $column_header{output_numberformat} =
 
1292       qq|<th class=listheading>|
 
1293     . $locale->text('Number Format')
 
1295   $column_header{output_dateformat} =
 
1296       qq|<th class=listheading>|
 
1297     . $locale->text('Date Format')
 
1299   $column_header{output_longdates} =
 
1300       qq|<th class=listheading>|
 
1301     . $locale->text('Long Dates')
 
1311     <th class=listtop>$form->{title}</th>
 
1313   <tr height="5"></tr>
 
1317         <tr class=listheading>
 
1320   map { print "$column_header{$_}\n" } @column_index;
 
1326   foreach $ref (@{ $form->{ALL} }) {
 
1332         <tr valign=top class=listrow$i>
 
1336     $column_data{description} =
 
1337       qq|<td><a href=$form->{script}?action=edit_language&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
 
1338     $column_data{template_code}           = qq|<td align=right>$ref->{template_code}</td>|;
 
1339     $column_data{article_code} =
 
1340       qq|<td align=right>$ref->{article_code}</td>|;
 
1341     $column_data{output_numberformat} =
 
1343       ($ref->{output_numberformat} ? $ref->{output_numberformat} :
 
1344        $locale->text("use program settings")) .
 
1346     $column_data{output_dateformat} =
 
1348       ($ref->{output_dateformat} ? $ref->{output_dateformat} :
 
1349        $locale->text("use program settings")) .
 
1351     $column_data{output_longdates} =
 
1353       ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
 
1356     map { print "$column_data{$_}\n" } @column_index;
 
1368   <td><hr size=3 noshade></td>
 
1373 <form method=post action=$form->{script}>
 
1375 <input name=callback type=hidden value="$form->{callback}">
 
1377 <input type=hidden name=type value=language>
 
1379 <input type=hidden name=path value=$form->{path}>
 
1380 <input type=hidden name=login value=$form->{login}>
 
1381 <input type=hidden name=password value=$form->{password}>
 
1383 <input class=submit type=submit name=action value="|
 
1384     . $locale->text('Add') . qq|">
 
1392   $lxdebug->leave_sub();
 
1395 sub language_header {
 
1396   $lxdebug->enter_sub();
 
1398   $form->{title}    = $locale->text("$form->{title} Language");
 
1400   # $locale->text('Add Language')
 
1401   # $locale->text('Edit Language')
 
1403   $form->{description} =~ s/\"/"/g;
 
1404   $form->{template_code} =~ s/\"/"/g;
 
1405   $form->{article_code} =~ s/\"/"/g;
 
1411     qq|<option value="">| . $locale->text("use program settings") .
 
1413   foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
 
1415       ($item eq $form->{output_numberformat})
 
1416       ? "<option selected>$item"
 
1422     qq|<option value="">| . $locale->text("use program settings") .
 
1424   foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
 
1426       ($item eq $form->{output_dateformat})
 
1427       ? "<option selected>$item"
 
1435 <form method=post action=$form->{script}>
 
1437 <input type=hidden name=id value=$form->{id}>
 
1438 <input type=hidden name=type value=language>
 
1442     <th class=listtop colspan=2>$form->{title}</th>
 
1444   <tr height="5"></tr>
 
1446     <th align=right>| . $locale->text('Language') . qq|</th>
 
1447     <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
 
1450     <th align=right>| . $locale->text('Template Code') . qq|</th>
 
1451     <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
 
1454     <th align=right>| . $locale->text('Article Code') . qq|</th>
 
1455     <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
 
1458     <th align=right>| . $locale->text('Number Format') . qq|</th>
 
1459     <td><select name="output_numberformat">$numberformat</select></td>
 
1462     <th align=right>| . $locale->text('Date Format') . qq|</th>
 
1463     <td><select name="output_dateformat">$dateformat</select></td>
 
1466     <th align=right>| . $locale->text('Long Dates') . qq|</th>
 
1467     <td><input type="radio" name="output_longdates" value="1"| .
 
1468     ($form->{output_longdates} ? " checked" : "") .
 
1469     qq|>| . $locale->text("Yes") .
 
1470     qq|<input type="radio" name="output_longdates" value="0"| .
 
1471     ($form->{output_longdates} ? "" : " checked") .
 
1472     qq|>| . $locale->text("No") .
 
1475   <td colspan=2><hr size=3 noshade></td>
 
1480   $lxdebug->leave_sub();
 
1484   $lxdebug->enter_sub();
 
1486   $form->isblank("description", $locale->text('Language missing!'));
 
1487   $form->isblank("template_code", $locale->text('Template Code missing!'));
 
1488   $form->isblank("article_code", $locale->text('Article Code missing!'));
 
1489   AM->save_language(\%myconfig, \%$form);
 
1490   $form->redirect($locale->text('Language saved!'));
 
1492   $lxdebug->leave_sub();
 
1495 sub delete_language {
 
1496   $lxdebug->enter_sub();
 
1498   AM->delete_language(\%myconfig, \%$form);
 
1499   $form->redirect($locale->text('Language deleted!'));
 
1501   $lxdebug->leave_sub();
 
1505 sub add_buchungsgruppe {
 
1506   $lxdebug->enter_sub();
 
1508   # $locale->text("Add Buchungsgruppe")
 
1509   # $locale->text("Edit Buchungsgruppe")
 
1510   $form->{title} = "Add";
 
1513     "$form->{script}?action=add_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1514     unless $form->{callback};
 
1515   AM->get_buchungsgruppe(\%myconfig, \%$form);
 
1516   $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
 
1517   for (my $i = 0; 4 > $i; $i++) {
 
1518     map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
 
1519         qw(income expense));
 
1522   &buchungsgruppe_header;
 
1525   $lxdebug->leave_sub();
 
1528 sub edit_buchungsgruppe {
 
1529   $lxdebug->enter_sub();
 
1531   $form->{title} = "Edit";
 
1533   AM->get_buchungsgruppe(\%myconfig, \%$form);
 
1535   &buchungsgruppe_header;
 
1539   $lxdebug->leave_sub();
 
1542 sub list_buchungsgruppe {
 
1543   $lxdebug->enter_sub();
 
1545   AM->buchungsgruppe(\%myconfig, \%$form);
 
1548     "$form->{script}?action=list_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1550   $callback = $form->escape($form->{callback});
 
1552   $form->{title} = $locale->text('Buchungsgruppen');
 
1554   @column_index = qw(up down description inventory_accno
 
1555                      income_accno_0 expense_accno_0
 
1556                      income_accno_1 expense_accno_1
 
1557                      income_accno_2 expense_accno_2
 
1558                      income_accno_3 expense_accno_3 );
 
1560   $column_header{up} =
 
1561       qq|<th class="listheading" width="16">|
 
1562     . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
 
1564   $column_header{down} =
 
1565       qq|<th class="listheading" width="16">|
 
1566     . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
 
1568   $column_header{description} =
 
1569       qq|<th class="listheading" width="40%">|
 
1570     . $locale->text('Description')
 
1572   $column_header{inventory_accno} =
 
1573       qq|<th class=listheading>|
 
1574     . $locale->text('Bestandskonto')
 
1576   $column_header{income_accno_0} =
 
1577       qq|<th class=listheading>|
 
1578     . $locale->text('Erlöse Inland')
 
1580   $column_header{expense_accno_0} =
 
1581       qq|<th class=listheading>|
 
1582     . $locale->text('Aufwand Inland')
 
1584   $column_header{income_accno_1} =
 
1585       qq|<th class=listheading>|
 
1586     . $locale->text('Erlöse EU m. UStId')
 
1588   $column_header{expense_accno_1} =
 
1589       qq|<th class=listheading>|
 
1590     . $locale->text('Aufwand EU m. UStId')
 
1592   $column_header{income_accno_2} =
 
1593       qq|<th class=listheading>|
 
1594     . $locale->text('Erlöse EU o. UStId')
 
1596   $column_header{expense_accno_2} =
 
1597       qq|<th class=listheading>|
 
1598     . $locale->text('Aufwand EU o. UStId')
 
1600   $column_header{income_accno_3} =
 
1601       qq|<th class=listheading>|
 
1602     . $locale->text('Erlöse Ausland')
 
1604   $column_header{expense_accno_3} =
 
1605       qq|<th class=listheading>|
 
1606     . $locale->text('Aufwand Ausland')
 
1615     <th class=listtop>$form->{title}</th>
 
1617   <tr height="5"></tr>
 
1621         <tr class=listheading>
 
1624   map { print "$column_header{$_}\n" } @column_index;
 
1630   my $swap_link = qq|$form->{script}?action=swap_buchungsgruppen&|;
 
1631   map({ $swap_link .= $_ . "=" . $form->escape($form->{$_}) . "&" }
 
1632       qw(login password path));
 
1635   foreach $ref (@{ $form->{ALL} }) {
 
1641         <tr valign=top class=listrow$i>
 
1645       my $pref = $form->{ALL}->[$row - 1];
 
1647         qq|<td align="center" valign="center" width="16">| .
 
1648         qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
 
1649         qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">| .
 
1652       $column_data{up} = qq|<td width="16"> </td>|;
 
1655     if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
 
1656       $column_data{down} = qq|<td width="16"> </td>|;
 
1658       my $nref = $form->{ALL}->[$row + 1];
 
1659       $column_data{down} =
 
1660         qq|<td align="center" valign="center" width="16">| .
 
1661         qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
 
1662         qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">| .
 
1666     $column_data{description} =
 
1667       qq|<td><a href=$form->{script}?action=edit_buchungsgruppe&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
 
1668     $column_data{inventory_accno}           = qq|<td align=right>$ref->{inventory_accno}</td>|;
 
1669     $column_data{income_accno_0} =
 
1670       qq|<td align=right>$ref->{income_accno_0}</td>|;
 
1671     $column_data{expense_accno_0}           = qq|<td align=right>$ref->{expense_accno_0}</td>|;
 
1672     $column_data{income_accno_1} =
 
1673       qq|<td align=right>$ref->{income_accno_1}</td>|;
 
1674     $column_data{expense_accno_1}           = qq|<td align=right>$ref->{expense_accno_1}</td>|;
 
1675     $column_data{income_accno_2} =
 
1676       qq|<td align=right>$ref->{income_accno_2}</td>|;
 
1677     $column_data{expense_accno_2}           = qq|<td align=right>$ref->{expense_accno_2}</td>|;
 
1678     $column_data{income_accno_3} =
 
1679       qq|<td align=right>$ref->{income_accno_3}</td>|;
 
1680     $column_data{expense_accno_3}           = qq|<td align=right>$ref->{expense_accno_3}</td>|;
 
1682     map { print "$column_data{$_}\n" } @column_index;
 
1696   <td><hr size=3 noshade></td>
 
1701 <form method=post action=$form->{script}>
 
1703 <input name=callback type=hidden value="$form->{callback}">
 
1705 <input type=hidden name=type value=buchungsgruppe>
 
1707 <input type=hidden name=path value=$form->{path}>
 
1708 <input type=hidden name=login value=$form->{login}>
 
1709 <input type=hidden name=password value=$form->{password}>
 
1711 <input class=submit type=submit name=action value="|
 
1712     . $locale->text('Add') . qq|">
 
1720   $lxdebug->leave_sub();
 
1723 sub buchungsgruppe_header {
 
1724   $lxdebug->enter_sub();
 
1726   $form->{title}    = $locale->text("$form->{title} Buchungsgruppe");
 
1728   # $locale->text('Buchungsgruppe hinzufügen')
 
1729   # $locale->text('Buchungsgruppe bearbeiten')
 
1731   my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
 
1732   my %acc_type_map = (
 
1733     "IC" => $acc_inventory,
 
1734     "IC_income" => $acc_income,
 
1735     "IC_sale" => $acc_income,
 
1736     "IC_expense" => $acc_expense,
 
1737     "IC_cogs" => $acc_expense,
 
1740   foreach $key (keys(%acc_type_map)) {
 
1741     foreach $ref (@{ $form->{IC_links}{$key} }) {
 
1742       $acc_type_map{$key}->{$ref->{"id"}} = $ref;
 
1746   foreach my $type (qw(IC IC_income IC_expense)) {
 
1747     $form->{"select$type"} =
 
1749            map({ "<option value=$_->{id} $_->{selected}>" .
 
1750                    "$_->{accno}--" . H($_->{description}) . "</option>" }
 
1751                sort({ $a->{"accno"} cmp $b->{"accno"} }
 
1752                     values(%{$acc_type_map{$type}}))));
 
1756     $form->{selectIC} =~ s/selected//g;
 
1757     $form->{selectIC} =~ s/ value=$form->{inventory_accno_id}/  value=$form->{inventory_accno_id} selected/;
 
1758     $form->{selectIC_income} =~ s/selected//g;
 
1759     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_0}/  value=$form->{income_accno_id_0} selected/;
 
1760     $form->{selectIC_expense} =~ s/selected//g;
 
1761     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_0}/  value=$form->{expense_accno_id_0} selected/;
 
1767                 <th align=right>| . $locale->text('Inventory') . qq|</th>
 
1768                 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
 
1769                 <input name=selectIC type=hidden value="$form->{selectIC}">
 
1773                 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
 
1777   $linkaccounts .= qq|
 
1779                 <th align=right>| . $locale->text('Erlöse Inland') . qq|</th>
 
1780                 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
 
1783                 <th align=right>| . $locale->text('Aufwand Inland') . qq|</th>
 
1784                 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
 
1787     $form->{selectIC_income} =~ s/selected//g;
 
1788     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_1}/  value=$form->{income_accno_id_1} selected/;
 
1789     $form->{selectIC_expense} =~ s/selected//g;
 
1790     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/  value=$form->{expense_accno_id_1} selected/;
 
1792   $linkaccounts .= qq|        <tr>
 
1793                 <th align=right>| . $locale->text('Erlöse EU m. UStId') . qq|</th>
 
1794                 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
 
1797                 <th align=right>| . $locale->text('Aufwand EU m UStId') . qq|</th>
 
1798                 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
 
1802     $form->{selectIC_income} =~ s/selected//g;
 
1803     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_2}/  value=$form->{income_accno_id_2} selected/;
 
1804     $form->{selectIC_expense} =~ s/selected//g;
 
1805     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_2}/  value=$form->{expense_accno_id_2} selected/;
 
1808   $linkaccounts .= qq|        <tr>
 
1809                 <th align=right>| . $locale->text('Erlöse EU o. UStId') . qq|</th>
 
1810                 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
 
1813                 <th align=right>| . $locale->text('Aufwand EU o. UStId') . qq|</th>
 
1814                 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
 
1818     $form->{selectIC_income} =~ s/selected//g;
 
1819     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_3}/  value=$form->{income_accno_id_3} selected/;
 
1820     $form->{selectIC_expense} =~ s/selected//g;
 
1821     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_3}/  value=$form->{expense_accno_id_3} selected/;
 
1824   $linkaccounts .= qq|        <tr>
 
1825                 <th align=right>| . $locale->text('Erlöse Ausland') . qq|</th>
 
1826                 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
 
1829                 <th align=right>| . $locale->text('Aufwand Ausland') . qq|</th>
 
1830                 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
 
1840 <form method=post action=$form->{script}>
 
1842 <input type=hidden name=id value=$form->{id}>
 
1843 <input type=hidden name=type value=buchungsgruppe>
 
1847     <th class=listtop colspan=2>$form->{title}</th>
 
1849   <tr height="5"></tr>
 
1851     <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
 
1852     <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
 
1855   <td colspan=2><hr size=3 noshade></td>
 
1860   $lxdebug->leave_sub();
 
1863 sub save_buchungsgruppe {
 
1864   $lxdebug->enter_sub();
 
1866   $form->isblank("description", $locale->text('Description missing!'));
 
1868   AM->save_buchungsgruppe(\%myconfig, \%$form);
 
1869   $form->redirect($locale->text('Buchungsgruppe gespeichert!'));
 
1871   $lxdebug->leave_sub();
 
1874 sub delete_buchungsgruppe {
 
1875   $lxdebug->enter_sub();
 
1877   AM->delete_buchungsgruppe(\%myconfig, \%$form);
 
1878   $form->redirect($locale->text('Buchungsgruppe gelöscht!'));
 
1880   $lxdebug->leave_sub();
 
1883 sub swap_buchungsgruppen {
 
1884   $lxdebug->enter_sub();
 
1886   AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
 
1887   list_buchungsgruppe();
 
1889   $lxdebug->leave_sub();
 
1894   $lxdebug->enter_sub();
 
1896   $form->{title} = "Add";
 
1899     "$form->{script}?action=add_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1900     unless $form->{callback};
 
1905   $lxdebug->leave_sub();
 
1909   $lxdebug->enter_sub();
 
1911   $form->{title} = "Edit";
 
1913   AM->get_printer(\%myconfig, \%$form);
 
1917   $form->{orphaned} = 1;
 
1920   $lxdebug->leave_sub();
 
1924   $lxdebug->enter_sub();
 
1926   AM->printer(\%myconfig, \%$form);
 
1929     "$form->{script}?action=list_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1931   $callback = $form->escape($form->{callback});
 
1933   $form->{title} = $locale->text('Printer');
 
1935   @column_index = qw(printer_description printer_command template_code);
 
1937   $column_header{printer_description} =
 
1938       qq|<th class=listheading width=60%>|
 
1939     . $locale->text('Printer Description')
 
1941   $column_header{printer_command} =
 
1942       qq|<th class=listheading width=10%>|
 
1943     . $locale->text('Printer Command')
 
1945   $column_header{template_code} =
 
1946       qq|<th class=listheading>|
 
1947     . $locale->text('Template Code')
 
1957     <th class=listtop>$form->{title}</th>
 
1959   <tr height="5"></tr>
 
1963         <tr class=listheading>
 
1966   map { print "$column_header{$_}\n" } @column_index;
 
1972   foreach $ref (@{ $form->{ALL} }) {
 
1978         <tr valign=top class=listrow$i>
 
1982     $column_data{printer_description} =
 
1983       qq|<td><a href=$form->{script}?action=edit_printer&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{printer_description}</td>|;
 
1984     $column_data{printer_command}           = qq|<td align=right>$ref->{printer_command}</td>|;
 
1985     $column_data{template_code} =
 
1986       qq|<td align=right>$ref->{template_code}</td>|;
 
1988     map { print "$column_data{$_}\n" } @column_index;
 
2000   <td><hr size=3 noshade></td>
 
2005 <form method=post action=$form->{script}>
 
2007 <input name=callback type=hidden value="$form->{callback}">
 
2009 <input type=hidden name=type value=printer>
 
2011 <input type=hidden name=path value=$form->{path}>
 
2012 <input type=hidden name=login value=$form->{login}>
 
2013 <input type=hidden name=password value=$form->{password}>
 
2015 <input class=submit type=submit name=action value="|
 
2016     . $locale->text('Add') . qq|">
 
2024   $lxdebug->leave_sub();
 
2027 sub printer_header {
 
2028   $lxdebug->enter_sub();
 
2030   $form->{title}    = $locale->text("$form->{title} Printer");
 
2032   # $locale->text('Add Printer')
 
2033   # $locale->text('Edit Printer')
 
2035   $form->{printer_description} =~ s/\"/"/g;
 
2036   $form->{template_code} =~ s/\"/"/g;
 
2037   $form->{printer_command} =~ s/\"/"/g;
 
2045 <form method=post action=$form->{script}>
 
2047 <input type=hidden name=id value=$form->{id}>
 
2048 <input type=hidden name=type value=printer>
 
2052     <th class=listtop colspan=2>$form->{title}</th>
 
2054   <tr height="5"></tr>
 
2056     <th align=right>| . $locale->text('Printer') . qq|</th>
 
2057     <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
 
2060     <th align=right>| . $locale->text('Printer Command') . qq|</th>
 
2061     <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
 
2064     <th align=right>| . $locale->text('Template Code') . qq|</th>
 
2065     <td><input name=template_code size=5 value="$form->{template_code}"></td>
 
2067   <td colspan=2><hr size=3 noshade></td>
 
2072   $lxdebug->leave_sub();
 
2076   $lxdebug->enter_sub();
 
2078   $form->isblank("printer_description", $locale->text('Description missing!'));
 
2079   $form->isblank("printer_command", $locale->text('Printer Command missing!'));
 
2080   AM->save_printer(\%myconfig, \%$form);
 
2081   $form->redirect($locale->text('Printer saved!'));
 
2083   $lxdebug->leave_sub();
 
2086 sub delete_printer {
 
2087   $lxdebug->enter_sub();
 
2089   AM->delete_printer(\%myconfig, \%$form);
 
2090   $form->redirect($locale->text('Printer deleted!'));
 
2092   $lxdebug->leave_sub();
 
2096   $lxdebug->enter_sub();
 
2098   $form->{title} = "Add";
 
2101     "$form->{script}?action=add_payment&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
2102     unless $form->{callback};
 
2104   $form->{terms_netto} = 0;
 
2105   $form->{terms_skonto} = 0;
 
2106   $form->{percent_skonto} = 0;
 
2107   my @languages = AM->language(\%myconfig, $form, 1);
 
2108   map({ $_->{"language"} = $_->{"description"};
 
2109         $_->{"language_id"} = $_->{"id"}; } @languages);
 
2110   $form->{"TRANSLATION"} = \@languages;
 
2114   $lxdebug->leave_sub();
 
2118   $lxdebug->enter_sub();
 
2120   $form->{title} = "Edit";
 
2122   AM->get_payment(\%myconfig, $form);
 
2123   $form->{percent_skonto} =
 
2124     $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
 
2128   $form->{orphaned} = 1;
 
2131   $lxdebug->leave_sub();
 
2135   $lxdebug->enter_sub();
 
2137   AM->payment(\%myconfig, \%$form);
 
2139   $form->{callback} = build_std_url("action=list_payment");
 
2141   $callback = $form->escape($form->{callback});
 
2143   $form->{title} = $locale->text('Payment Terms');
 
2145   @column_index = qw(up down description description_long terms_netto
 
2146                      terms_skonto percent_skonto);
 
2148   $column_header{up} =
 
2149       qq|<th class="listheading" align="center" valign="center" width="16">|
 
2150     . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
 
2152   $column_header{down} =
 
2153       qq|<th class="listheading" align="center" valign="center" width="16">|
 
2154     . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
 
2156   $column_header{description} =
 
2157       qq|<th class=listheading>|
 
2158     . $locale->text('Description')
 
2160   $column_header{description_long} =
 
2161       qq|<th class=listheading>|
 
2162     . $locale->text('Long Description')
 
2164   $column_header{terms_netto} =
 
2165       qq|<th class=listheading>|
 
2166     . $locale->text('Netto Terms')
 
2168   $column_header{terms_skonto} =
 
2169       qq|<th class=listheading>|
 
2170     . $locale->text('Skonto Terms')
 
2172   $column_header{percent_skonto} =
 
2173       qq|<th class=listheading>|
 
2174     . $locale->text('Skonto')
 
2184     <th class=listtop>$form->{title}</th>
 
2186   <tr height="5"></tr>
 
2190         <tr class=listheading>
 
2193   map { print "$column_header{$_}\n" } @column_index;
 
2199   my $swap_link = build_std_url("action=swap_payment_terms");
 
2202   foreach $ref (@{ $form->{ALL} }) {
 
2208         <tr valign=top class=listrow$i>
 
2212       my $pref = $form->{ALL}->[$row - 1];
 
2214         qq|<td align="center" valign="center" width="16">| .
 
2215         qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
 
2216         qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">| .
 
2219       $column_data{up} = qq|<td width="16"> </td>|;
 
2222     if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
 
2223       $column_data{down} = qq|<td width="16"> </td>|;
 
2225       my $nref = $form->{ALL}->[$row + 1];
 
2226       $column_data{down} =
 
2227         qq|<td align="center" valign="center" width="16">| .
 
2228         qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
 
2229         qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">| .
 
2233     $column_data{description} =
 
2235       build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
 
2236       qq|">| . H($ref->{description}) . qq|</a></td>|;
 
2237     $column_data{description_long} =
 
2238       qq|<td>| . H($ref->{description_long}) . qq|</td>|;
 
2239     $column_data{terms_netto} =
 
2240       qq|<td align=right>$ref->{terms_netto}</td>|;
 
2241     $column_data{terms_skonto} =
 
2242       qq|<td align=right>$ref->{terms_skonto}</td>|;
 
2243     $column_data{percent_skonto} =
 
2244       qq|<td align=right>| .
 
2245       $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
 
2247     map { print "$column_data{$_}\n" } @column_index;
 
2260   <td><hr size=3 noshade></td>
 
2265 <form method=post action=$form->{script}>
 
2267 <input name=callback type=hidden value="$form->{callback}">
 
2269 <input type=hidden name=type value=payment>
 
2271 <input type=hidden name=path value=$form->{path}>
 
2272 <input type=hidden name=login value=$form->{login}>
 
2273 <input type=hidden name=password value=$form->{password}>
 
2275 <input class=submit type=submit name=action value="|
 
2276     . $locale->text('Add') . qq|">
 
2284   $lxdebug->leave_sub();
 
2287 sub payment_header {
 
2288   $lxdebug->enter_sub();
 
2290   $form->{title}    = $locale->text("$form->{title} Payment Terms");
 
2292   # $locale->text('Add Payment Terms')
 
2293   # $locale->text('Edit Payment Terms')
 
2295   $form->{description} =~ s/\"/"/g;
 
2304 <form method=post action=$form->{script}>
 
2306 <input type=hidden name=id value=$form->{id}>
 
2307 <input type=hidden name=type value=payment>
 
2311     <th class=listtop colspan=2>$form->{title}</th>
 
2313   <tr height="5"></tr>
 
2315     <th align=right>| . $locale->text('Description') . qq|</th>
 
2316     <td><input name=description size=30 value="$form->{description}"></td>
 
2319     <th align=right>| . $locale->text('Long Description') . qq|</th>
 
2320     <td><input name=description_long size=50 value="$form->{description_long}"></td>
 
2324   foreach my $language (@{ $form->{"TRANSLATION"} }) {
 
2327     <th align="right">| .
 
2328     sprintf($locale->text('Translation (%s)'),
 
2329             $language->{"language"})
 
2331     <td><input name="description_long_$language->{language_id}" size="50"
 
2332          value="| . Q($language->{"description_long"}) . qq|"></td>
 
2339     <th align=right>| . $locale->text('Netto Terms') . qq|</th>
 
2340     <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
 
2343     <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
 
2344     <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
 
2347     <th align=right>| . $locale->text('Skonto') . qq| %</th>
 
2348     <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
 
2350   <td colspan=2><hr size=3 noshade></td>
 
2354 <p>| . $locale->text("You can use the following strings in the long " .
 
2355                      "description and all translations. They will be " .
 
2356                      "replaced by their actual values by Lx-Office " .
 
2357                      "before they're output.")
 
2361   <li>| . $locale->text("<%netto_date%> -- Date the payment is due in " .
 
2364   <li>| . $locale->text("<%skonto_date%> -- Date the payment is due " .
 
2367   <li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
 
2369   <li>| . $locale->text("<%total%> -- Amount payable")
 
2371   <li>| . $locale->text("<%invtotal%> -- Invoice total")
 
2373   <li>| . $locale->text("<%currency%> -- The selected currency")
 
2375   <li>| . $locale->text("<%terms_netto%> -- The number of days for " .
 
2378   <li>| . $locale->text("<%account_number%> -- Your account number")
 
2380   <li>| . $locale->text("<%bank%> -- Your bank")
 
2382   <li>| . $locale->text("<%bank_code%> -- Your bank code")
 
2386   $lxdebug->leave_sub();
 
2390   $lxdebug->enter_sub();
 
2392   $form->isblank("description", $locale->text('Description missing!'));
 
2393   $form->{"percent_skonto"} =
 
2394     $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
 
2395   AM->save_payment(\%myconfig, \%$form);
 
2396   $form->redirect($locale->text('Payment Terms saved!'));
 
2398   $lxdebug->leave_sub();
 
2401 sub delete_payment {
 
2402   $lxdebug->enter_sub();
 
2404   AM->delete_payment(\%myconfig, \%$form);
 
2405   $form->redirect($locale->text('Payment terms deleted!'));
 
2407   $lxdebug->leave_sub();
 
2410 sub swap_payment_terms {
 
2411   $lxdebug->enter_sub();
 
2413   AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
 
2416   $lxdebug->leave_sub();
 
2419 sub display_stylesheet {
 
2420   $lxdebug->enter_sub();
 
2422   $form->{file} = "css/$myconfig{stylesheet}";
 
2425   $lxdebug->leave_sub();
 
2429   $lxdebug->enter_sub();
 
2431   $form->{file} =~ s/^(.:)*?\/|\.\.\///g;
 
2432   $form->{file} =~ s/^\/*//g;
 
2433   $form->{file} =~ s/$userspath//;
 
2435   $form->error("$!: $form->{file}") unless -f $form->{file};
 
2437   AM->load_template(\%$form);
 
2439   $form->{title} = $form->{file};
 
2441   # if it is anything but html
 
2442   if ($form->{file} !~ /\.html$/) {
 
2443     $form->{body} = "<pre>\n$form->{body}\n</pre>";
 
2453 <form method=post action=$form->{script}>
 
2455 <input name=file type=hidden value=$form->{file}>
 
2456 <input name=type type=hidden value=template>
 
2458 <input type=hidden name=path value=$form->{path}>
 
2459 <input type=hidden name=login value=$form->{login}>
 
2460 <input type=hidden name=password value=$form->{password}>
 
2462 <input name=action type=submit class=submit value="|
 
2463     . $locale->text('Edit') . qq|">
 
2471   $lxdebug->leave_sub();
 
2475   $lxdebug->enter_sub();
 
2477   AM->load_template(\%$form);
 
2479   $form->{title} = $locale->text('Edit Template');
 
2481   # convert   to &nbsp;
 
2482   $form->{body} =~ s/ /&nbsp;/gi;
 
2489 <form method=post action=$form->{script}>
 
2491 <input name=file type=hidden value=$form->{file}>
 
2492 <input name=type type=hidden value=template>
 
2494 <input type=hidden name=path value=$form->{path}>
 
2495 <input type=hidden name=login value=$form->{login}>
 
2496 <input type=hidden name=password value=$form->{password}>
 
2498 <input name=callback type=hidden value="$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}&password=$form->{password}">
 
2500 <textarea name=body rows=25 cols=70>
 
2505 <input type=submit class=submit name=action value="|
 
2506     . $locale->text('Save') . qq|">
 
2515   $lxdebug->leave_sub();
 
2519   $lxdebug->enter_sub();
 
2521   AM->save_template(\%$form);
 
2522   $form->redirect($locale->text('Template saved!'));
 
2524   $lxdebug->leave_sub();
 
2528   $lxdebug->enter_sub();
 
2530   # get defaults for account numbers and last numbers
 
2531   AM->defaultaccounts(\%myconfig, \%$form);
 
2533   foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
 
2535       ($item eq $myconfig{dateformat})
 
2536       ? "<option selected>$item\n"
 
2537       : "<option>$item\n";
 
2540   foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
 
2542       ($item eq $myconfig{numberformat})
 
2543       ? "<option selected>$item\n"
 
2544       : "<option>$item\n";
 
2547   foreach $item (qw(name company address signature)) {
 
2548     $myconfig{$item} =~ s/\"/"/g;
 
2551   foreach $item (qw(address signature)) {
 
2552     $myconfig{$item} =~ s/\\n/\r\n/g;
 
2556   if ($opendocument_templates && $openofficeorg_writer_bin &&
 
2557       $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
 
2558     push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
 
2559                      "value" => "opendocument_pdf" });
 
2561   if ($latex_templates) {
 
2562     push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
 
2564   push(@formats, { "name" => "HTML", "value" => "html" });
 
2565   if ($latex_templates) {
 
2566     push(@formats, { "name" => $locale->text("Postscript"),
 
2567                      "value" => "postscript" });
 
2569   if ($opendocument_templates) {
 
2570     push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
 
2571                      "value" => "opendocument" });
 
2574   if (!$myconfig{"template_format"}) {
 
2575     $myconfig{"template_format"} = "pdf";
 
2577   my $template_format = "";
 
2578   foreach $item (@formats) {
 
2580       "<option value=\"$item->{value}\"" .
 
2581       ($item->{"value"} eq $myconfig{"template_format"} ?
 
2583        ">" . H($item->{"name"}) . "</option>";
 
2586   if (!$myconfig{"default_media"}) {
 
2587     $myconfig{"default_media"} = "screen";
 
2589   my %selected = ($myconfig{"default_media"} => "selected");
 
2590   my $default_media = qq|
 
2591   <option value="screen" $selected{'screen'}>| . $locale->text("Screen") . qq|</option>
 
2592   <option value="printer" $selected{'printer'}>| . $locale->text("Printer") . qq|</option>
 
2593   <option value="queue" $selected{'queue'}>| . $locale->text("Queue") . qq|</option>
 
2597   $selected{$myconfig{"default_printer_id"}} = "selected"
 
2598     if ($myconfig{"default_printer_id"});
 
2599   my $default_printer = qq|<option></option>|;
 
2600   AM->printer(\%myconfig, $form);
 
2601   foreach my $printer (@{$form->{"ALL"}}) {
 
2602     $default_printer .= qq|<option value="| . Q($printer->{"id"}) .
 
2603       qq|" $selected{$printer->{'id'}}>| .
 
2604       H($printer->{"printer_description"}) . qq|</option>|;
 
2607   %countrycodes = User->country_codes;
 
2609   foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
 
2613       ($myconfig{countrycode} eq $key)
 
2614       ? "<option selected value=$key>$countrycodes{$key}\n"
 
2615       : "<option value=$key>$countrycodes{$key}\n";
 
2617   $countrycodes = "<option>American English\n$countrycodes";
 
2619   foreach $key (keys %{ $form->{IC} }) {
 
2620     foreach $accno (sort keys %{ $form->{IC}{$key} }) {
 
2622         ($form->{IC}{$key}{$accno}{id} == $form->{defaults}{$key})
 
2623         ? "<option selected>$accno--$form->{IC}{$key}{$accno}{description}\n"
 
2624         : "<option>$accno--$form->{IC}{$key}{$accno}{description}\n";
 
2628 #  opendir CSS, "css/.";
 
2629 #  @all = grep /.*\.css$/, readdir CSS;
 
2632 # css dir has styles that are not intended as general layouts.
 
2633 # reverting to hardcoded list
 
2634   @all = qw(lx-office-erp.css Win2000.css);
 
2636   foreach $item (@all) {
 
2637     if ($item eq $myconfig{stylesheet}) {
 
2638       $selectstylesheet .= qq|<option selected>$item\n|;
 
2640       $selectstylesheet .= qq|<option>$item\n|;
 
2643   $selectstylesheet .= "<option>\n";
 
2645   $form->{title} = $locale->text('Edit Preferences for') . qq| $form->{login}|;
 
2649   if ($myconfig{menustyle} eq "old") {
 
2650     $menustyle_old = "checked";
 
2651   } elsif ($myconfig{menustyle} eq "neu") {
 
2652     $menustyle_neu = "checked";
 
2653   } elsif ($myconfig{menustyle} eq "v3") {
 
2654     $menustyle_v3 = "checked";
 
2657   my ($show_form_details, $hide_form_details);
 
2658   $myconfig{"show_form_details"} = 1
 
2659     unless (defined($myconfig{"show_form_details"}));
 
2660   $show_form_details = "checked" if ($myconfig{"show_form_details"});
 
2661   $hide_form_details = "checked" unless ($myconfig{"show_form_details"});
 
2666 <form method=post action=$form->{script}>
 
2668 <input type=hidden name=old_password value=$myconfig{password}>
 
2669 <input type=hidden name=type value=preferences>
 
2670 <input type=hidden name=role value=$myconfig{role}>
 
2673   <tr><th class=listtop>$form->{title}</th></tr>
 
2678           <th align=right>| . $locale->text('Name') . qq|</th>
 
2679           <td><input name=name size=15 value="$myconfig{name}"></td>
 
2682           <th align=right>| . $locale->text('Password') . qq|</th>
 
2683           <td><input type=password name=new_password size=10 value=$myconfig{password}></td>
 
2686           <th align=right>| . $locale->text('E-mail') . qq|</th>
 
2687           <td><input name=email size=30 value="$myconfig{email}"></td>
 
2690           <th align=right>| . $locale->text('Signature') . qq|</th>
 
2691           <td><textarea name=signature rows=3 cols=50>$myconfig{signature}</textarea></td>
 
2694           <th align=right>| . $locale->text('Phone') . qq|</th>
 
2695           <td><input name=tel size=14 value="$myconfig{tel}"></td>
 
2698           <th align=right>| . $locale->text('Fax') . qq|</th>
 
2699           <td><input name=fax size=14 value="$myconfig{fax}"></td>
 
2702           <th align=right>| . $locale->text('Company') . qq|</th>
 
2703           <td><input name=company size=30 value="$myconfig{company}"></td>
 
2706           <th align=right>| . $locale->text('Address') . qq|</th>
 
2707           <td><textarea name=address rows=4 cols=50>$myconfig{address}</textarea></td>
 
2710           <th align=right>| . $locale->text('Date Format') . qq|</th>
 
2711           <td><select name=dateformat>$dateformat</select></td>
 
2714           <th align=right>| . $locale->text('Output Number Format') . qq|</th>
 
2715           <td><select name=numberformat>$numberformat</select></td>
 
2719           <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
 
2720           <td><input name=vclimit size=10 value="$myconfig{vclimit}"></td>
 
2723           <th align=right>| . $locale->text('Language') . qq|</th>
 
2724           <td><select name=countrycode>$countrycodes</select></td>
 
2727           <th align=right>| . $locale->text('Stylesheet') . qq|</th>
 
2728           <td><select name=usestylesheet>$selectstylesheet</select></td>
 
2731           <th align=right>| . $locale->text('Setup Menu') . qq|</th>
 
2732           <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
 
2733     $locale->text("Top (CSS)") . qq|
 
2734           <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
 
2735     $locale->text("Top (Javascript)") . qq|
 
2736     <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
 
2737     $locale->text("Old (on the side)") . qq|</td>
 
2740     <th align=right>| . $locale->text('Form details (second row)') . qq|</th>
 
2741     <td><input type="radio" id="rad_show_form_details" name="show_form_details" value="1" $show_form_details> 
 
2742     <label for="rad_show_form_details">| . $locale->text('Show by default') . qq|</label>
 
2743     <input type="radio" id="rad_hide_form_details" name="show_form_details" value="0" $hide_form_details> 
 
2744     <label for="rad_hide_form_details">| . $locale->text('Hide by default') . qq|</label></td>
 
2746         <input name=printer type=hidden value="$myconfig{printer}">
 
2747         <tr class=listheading>
 
2748           <th colspan=2>| . $locale->text("Print options") . qq|</th>
 
2751           <th align=right>| . $locale->text('Default template format') . qq|</th>
 
2752           <td><select name="template_format">$template_format</select></td>
 
2755           <th align=right>| . $locale->text('Default output medium') . qq|</th>
 
2756           <td><select name="default_media">$default_media</select></td>
 
2759           <th align=right>| . $locale->text('Default printer') . qq|</th>
 
2760           <td><select name="default_printer_id">$default_printer</select></td>
 
2763           <th align=right>| . $locale->text('Number of copies') . qq|</th>
 
2764           <td><input name="copies" size="10" value="| .
 
2765     $form->quote($myconfig{"copies"}) . qq|"></td>
 
2769         <tr class=listheading>
 
2770           <th colspan=2> </th>
 
2773           <th align=right>| . $locale->text('Business Number') . qq|</th>
 
2774           <td><input name=businessnumber size=25 value="$myconfig{businessnumber}"></td>
 
2777                 <th align=right>| . $locale->text('Year End') . qq| (mm/dd)</th>
 
2778                 <td><input name=yearend size=5 value=$form->{defaults}{yearend}></td>
 
2780         <tr class=listheading>
 
2782     . $locale->text('Last Numbers & Default Accounts') . qq|</th>
 
2788                 <th align=right nowrap>| . $locale->text('Inventory Account') . qq|</th>
 
2789                 <td><select name=inventory_accno>$myconfig{IC}</select></td>
 
2792                 <th align=right nowrap>| . $locale->text('Revenue Account') . qq|</th>
 
2793                 <td><select name=income_accno>$myconfig{IC_income}</select></td>
 
2796                 <th align=right nowrap>| . $locale->text('Expense Account') . qq|</th>
 
2797                 <td><select name=expense_accno>$myconfig{IC_expense}</select></td>
 
2800                 <th align=right nowrap>| . $locale->text('Foreign Exchange Gain') . qq|</th>
 
2801                 <td><select name=fxgain_accno>$myconfig{FX_gain}</select></td>
 
2804                 <th align=right nowrap>| . $locale->text('Foreign Exchange Loss') . qq|</th>
 
2805                 <td><select name=fxloss_accno>$myconfig{FX_loss}</select></td>
 
2810     'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies'
 
2812     . qq|<br><input name=curr size=40 value="$form->{defaults}{curr}"></td>
 
2821                 <th align=right nowrap>| . $locale->text('Last Invoice Number') . qq|</th>
 
2822                 <td><input name=invnumber size=10 value=$form->{defaults}{invnumber}></td>
 
2823                 <th align=right nowrap>|
 
2824     . $locale->text('Last Customer Number') . qq|</th>
 
2825                 <td><input name=customernumber size=10 value=$form->{defaults}{customernumber}></td>
 
2828                 <th align=right nowrap>|
 
2829     . $locale->text('Last Credit Note Number') . qq|</th>
 
2830                 <td><input name=cnnumber size=10 value=$form->{defaults}{cnnumber}></td>
 
2831                 <th align=right nowrap>|
 
2832     . $locale->text('Last Vendor Number') . qq|</th>
 
2833                 <td><input name=vendornumber size=10 value=$form->{defaults}{vendornumber}></td>
 
2836                 <th align=right nowrap>|
 
2837     . $locale->text('Last Sales Order Number') . qq|</th>
 
2838                 <td><input name=sonumber size=10 value=$form->{defaults}{sonumber}></td>
 
2841                 <th align=right nowrap>|
 
2842     . $locale->text('Last Purchase Order Number') . qq|</th>
 
2843                 <td><input name=ponumber size=10 value=$form->{defaults}{ponumber}></td>
 
2844                 <th align=right nowrap>|
 
2845     . $locale->text('Last Article Number') . qq|</th>
 
2846                 <td><input name=articlenumber size=10 value=$form->{defaults}{articlenumber}></td>
 
2849                 <th align=right nowrap>|
 
2850     . $locale->text('Last Sales Quotation Number') . qq|</th>
 
2851                 <td><input name=sqnumber size=10 value=$form->{defaults}{sqnumber}></td>
 
2852                 <th align=right nowrap>|
 
2853     . $locale->text('Last Service Number') . qq|</th>
 
2854                 <td><input name=servicenumber size=10 value=$form->{defaults}{servicenumber}></td>
 
2857                 <th align=right nowrap>| . $locale->text('Last RFQ Number') . qq|</th>
 
2858                 <td><input name=rfqnumber size=10 value=$form->{defaults}{rfqnumber}></td>
 
2859                 <th align=right nowrap></th>
 
2865 #       <tr class=listheading>
 
2866 #         <th colspan=2>| . $locale->text('Tax Accounts') . qq|</th>
 
2873 #               <th>| . $locale->text('Rate') . qq| (%)</th>
 
2874 #               <th>| . $locale->text('Number') . qq|</th>
 
2878 #   foreach $accno (sort keys %{ $form->{taxrates} }) {
 
2881 #               <th align=right>$form->{taxrates}{$accno}{description}</th>
 
2882 #               <td><input name=$form->{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}></td>
 
2883 #               <td><input name="taxnumber_$form->{taxrates}{$accno}{id}" value="$form->{taxrates}{$accno}{taxnumber}"></td>
 
2886 #     $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} ";
 
2889 #   chop $form->{taxaccounts};
 
2892 # <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
 
2901     <td><hr size=3 noshade></td>
 
2905 <input type=hidden name=path value=$form->{path}>
 
2906 <input type=hidden name=login value=$form->{login}>
 
2907 <input type=hidden name=password value=$form->{password}>
 
2910 <input type=submit class=submit name=action value="|
 
2911     . $locale->text('Save') . qq|">
 
2919   $lxdebug->leave_sub();
 
2922 sub save_preferences {
 
2923   $lxdebug->enter_sub();
 
2925   $form->{stylesheet} = $form->{usestylesheet};
 
2927   $form->redirect($locale->text('Preferences saved!'))
 
2929      AM->save_preferences(\%myconfig, \%$form, $memberfile, $userspath, $webdav
 
2931   $form->error($locale->text('Cannot save preferences!'));
 
2933   $lxdebug->leave_sub();
 
2937   $lxdebug->enter_sub();
 
2939   $form->{title} = $locale->text('Audit Control');
 
2941   AM->closedto(\%myconfig, \%$form);
 
2943   if ($form->{revtrans}) {
 
2944     $checked{Y} = "checked";
 
2946     $checked{N} = "checked";
 
2954 <form method=post action=$form->{script}>
 
2956 <input type=hidden name=path value=$form->{path}>
 
2957 <input type=hidden name=login value=$form->{login}>
 
2958 <input type=hidden name=password value=$form->{password}>
 
2961   <tr><th class=listtop>$form->{title}</th></tr>
 
2962   <tr height="5"></tr>
 
2968     . $locale->text('Enforce transaction reversal for all dates') . qq|</th>
 
2969           <td><input name=revtrans class=radio type=radio value="1" $checked{Y}> |
 
2970     . $locale->text('Yes')
 
2971     . qq| <input name=revtrans class=radio type=radio value="0" $checked{N}> |
 
2972     . $locale->text('No')
 
2976           <th>| . $locale->text('Close Books up to') . qq|</th>
 
2977           <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
 
2987 <input type=hidden name=nextsub value=doclose>
 
2989 <input type=submit class=submit name=action value="|
 
2990     . $locale->text('Continue') . qq|">
 
2998   $lxdebug->leave_sub();
 
3002   $lxdebug->enter_sub();
 
3004   AM->closebooks(\%myconfig, \%$form);
 
3006   if ($form->{revtrans}) {
 
3008                  $locale->text('Transaction reversal enforced for all dates'));
 
3010     if ($form->{closedto}) {
 
3012                      $locale->text('Transaction reversal enforced up to') . " "
 
3013                        . $locale->date(\%myconfig, $form->{closedto}, 1));
 
3015       $form->redirect($locale->text('Books are open'));
 
3019   $lxdebug->leave_sub();
 
3023   $lxdebug->enter_sub();
 
3025   &{ $form->{nextsub} };
 
3027   $lxdebug->leave_sub();
 
3031   $lxdebug->enter_sub();
 
3033   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
 
3034   AM->units_in_use(\%myconfig, $form, $units);
 
3035   map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
 
3037   @languages = AM->language(\%myconfig, $form, 1);
 
3039   @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units}));
 
3042   foreach (@unit_list) {
 
3043     $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"});
 
3044     $_->{"UNITLANGUAGES"} = [];
 
3045     foreach my $lang (@languages) {
 
3046       push(@{ $_->{"UNITLANGUAGES"} },
 
3048              "unit" => $_->{"name"},
 
3049              "language_id" => $lang->{"id"},
 
3050              "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
 
3051              "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
 
3057   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
 
3058   $ddbox = AM->unit_select_data($units, undef, 1);
 
3060   my $updownlink = build_std_url("action=swap_units", "unit_type");
 
3062   $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
 
3064   print($form->parse_html_template("am/edit_units",
 
3065                                    { "UNITS" => \@unit_list,
 
3066                                      "NEW_BASE_UNIT_DDBOX" => $ddbox,
 
3067                                      "LANGUAGES" => \@languages,
 
3068                                      "updownlink" => $updownlink }));
 
3070   $lxdebug->leave_sub();
 
3074   $lxdebug->enter_sub();
 
3076   $form->isblank("new_name", $locale->text("The name is missing."));
 
3077   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
 
3078   $all_units = AM->retrieve_units(\%myconfig, $form);
 
3079   $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
 
3081   my ($base_unit, $factor);
 
3082   if ($form->{"new_base_unit"}) {
 
3083     $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
 
3085     $form->isblank("new_factor", $locale->text("The factor is missing."));
 
3086     $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
 
3087     $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
 
3088     $base_unit = $form->{"new_base_unit"};
 
3092   foreach my $lang (AM->language(\%myconfig, $form, 1)) {
 
3093     next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
 
3094     push(@languages, { "id" => $lang->{"id"},
 
3095                        "localized" => $form->{"new_localized_$lang->{id}"},
 
3096                        "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
 
3100   AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
 
3102   $form->{"saved_message"} = $locale->text("The unit has been saved.");
 
3106   $lxdebug->leave_sub();
 
3109 sub set_unit_languages {
 
3110   $lxdebug->enter_sub();
 
3112   my ($unit, $languages, $idx) = @_;
 
3114   $unit->{"LANGUAGES"} = [];
 
3116   foreach my $lang (@{$languages}) {
 
3117     push(@{ $unit->{"LANGUAGES"} },
 
3118          { "id" => $lang->{"id"},
 
3119            "localized" => $form->{"localized_${idx}_$lang->{id}"},
 
3120            "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
 
3124   $lxdebug->leave_sub();
 
3128   $lxdebug->enter_sub();
 
3130   $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
 
3131   AM->units_in_use(\%myconfig, $form, $old_units);
 
3133   @languages = AM->language(\%myconfig, $form, 1);
 
3137   foreach $i (1..($form->{"rowcount"} * 1)) {
 
3138     $old_unit = $old_units->{$form->{"old_name_$i"}};
 
3140       $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
 
3143     if ($form->{"unchangeable_$i"}) {
 
3144       $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
 
3145       $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
 
3146       set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
 
3150     if ($old_unit->{"in_use"}) {
 
3151       $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
 
3154     if ($form->{"delete_$i"}) {
 
3155       push(@delete_units, $old_unit->{"name"});
 
3159     $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
 
3161     $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
 
3162     my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
 
3163     $new_units->{$form->{"name_$i"}} = \%h;
 
3164     $new_units->{$form->{"name_$i"}}->{"row"} = $i;
 
3165     set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
 
3168   foreach $unit (values(%{$new_units})) {
 
3169     next unless ($unit->{"old_name"});
 
3170     if ($unit->{"base_unit"}) {
 
3171       $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"}))
 
3172         unless (defined($new_units->{$unit->{"base_unit"}}));
 
3173       $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
 
3174       $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
 
3176       $unit->{"base_unit"} = undef;
 
3177       $unit->{"factor"} = undef;
 
3181   foreach $unit (values(%{$new_units})) {
 
3182     next if ($unit->{"unchanged_unit"});
 
3184     map({ $_->{"seen"} = 0; } values(%{$new_units}));
 
3186     while ($new_unit->{"base_unit"}) {
 
3187       $new_unit->{"seen"} = 1;
 
3188       $new_unit = $new_units->{$new_unit->{"base_unit"}};
 
3189       if ($new_unit->{"seen"}) {
 
3190         $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, " .
 
3191                                                         "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
 
3196   AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
 
3198   $form->{"saved_message"} = $locale->text("The units have been saved.");
 
3202   $lxdebug->leave_sub();
 
3205 sub show_history_search {
 
3206         $lxdebug->enter_sub();
 
3208         $form->{title} = $locale->text("History Search");
 
3211     print $form->parse_html_template("/common/search_history");
 
3213         $lxdebug->leave_sub();
 
3216 sub show_am_history {
 
3217         $lxdebug->enter_sub();
 
3218         my %search = ( "Artikelnummer" => "parts",
 
3219                                    "Kundennummer"  => "customer",
 
3220                                    "Lieferantennummer" => "vendor",
 
3221                                    "Projektnummer" => "project",
 
3222                                    "Buchungsnummer" => "oe",
 
3223                                    "Eingangsrechnungnummer" => "ap",
 
3224                                    "Ausgangsrechnungnummer" => "ar"
 
3226         my %searchNo = ( "Artikelnummer" => "partnumber",
 
3227                                      "Kundennummer"  => "customernumber",
 
3228                                      "Lieferantennummer" => "vendornumber",
 
3229                                      "Projektnummer" => "projectnummer",
 
3230                                      "Buchungsnummer" => "ordnumber",
 
3231                                      "Eingangsrechnungnummer" => "invnumber",
 
3232                                      "Ausgangsrechnungnummer" => "invnumber"
 
3237         foreach(split(/\,/, $form->{einschraenkungen})) {
 
3239                         $restriction .= " AND addition = '" . $_ . "'";
 
3243                         $restriction .= " OR addition = '" . $_ . "'";
 
3247         $restriction .= (($form->{transdate} ne "" && $form->{reqdate} ne "") 
 
3248                                                 ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|' AND st.itime::date <= '| . $form->{reqdate} . qq|'|
 
3249                                                 : (($form->{transdate} ne "" && $form->{reqdate} eq "") 
 
3250                                                         ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|'|
 
3251                                                         : ($form->{transdate} eq "" && $form->{reqdate} ne "") 
 
3252                                                                 ? qq| AND st.itime::date <= '| . $form->{reqdate} . qq|'|
 
3257         my $dbh = $form->dbconnect(\%myconfig);
 
3259         $restriction .= ($form->{mitarbeiter} eq "" ? "" 
 
3260                                         : ($form->{mitarbeiter} =~ /^[0-9]*$/  
 
3261                                                 ? " AND employee_id = " . $form->{mitarbeiter} 
 
3262                                                 : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
 
3264         my $query = qq|SELECT id FROM $search{$form->{what2search}} 
 
3265                                    WHERE $searchNo{$form->{'what2search'}} ILIKE '$form->{"searchid"}' 
 
3268         my $sth = $dbh->prepare($query);
 
3270         $sth->execute() || $form->dberror($query);
 
3272         $form->{title} = $locale->text("History Search");
 
3275         while(my $hash_ref = $sth->fetchrow_hashref()){
 
3276                 print $form->parse_html_template("/common/show_history", 
 
3277                         {"DATEN" => $form->get_history($dbh,$hash_ref->{id},$restriction),
 
3278                          "SUCCESS" => ($form->get_history($dbh,$hash_ref->{id},$restriction) != 0),
 
3279                          "NONEWWINDOW" => "1"   
 
3285         $lxdebug->leave_sub();
 
3288 sub get_employee_id {
 
3289         $lxdebug->enter_sub();
 
3290         my $query = qq|SELECT id FROM employee WHERE name = '| . $_[0] . qq|'|;
 
3291         my $sth = $_[1]->prepare($query);
 
3292         $sth->execute() || $form->dberror($query);
 
3293         my $return = $sth->fetch();
 
3295         return ${$return}[0];
 
3296         $lxdebug->leave_sub();
 
3300   $lxdebug->enter_sub();
 
3302   my $dir = $form->{"dir"} eq "down" ? "down" : "up";
 
3303   my $unit_type = $form->{"unit_type"} eq "dimension" ?
 
3304     "dimension" : "service";
 
3305   AM->swap_units(\%myconfig, $form, $dir, $form->{"name"}, $unit_type);
 
3309   $lxdebug->leave_sub();