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             84  => $locale->text('UStVA-Nr. 84'),
 
 181             85  => $locale->text('UStVA-Nr. 85'),
 
 182             86  => $locale->text('UStVA-Nr. 86 left'),
 
 183             861 => $locale->text('UStVA-Nr. 86 right'),
 
 184             91  => $locale->text('UStVA-Nr. 91'),
 
 185             93  => $locale->text('UStVA-Nr. 93 left'),
 
 186             931 => $locale->text('UStVA-Nr. 93 right'),
 
 187             94  => $locale->text('UStVA-Nr. 94'),
 
 188             95  => $locale->text('UStVA-Nr. 95'),
 
 189             96  => $locale->text('UStVA-Nr. 96'),
 
 190             97  => $locale->text('UStVA-Nr. 97 links'),
 
 191             971 => $locale->text('UStVA-Nr. 97 rechts'),
 
 192             98  => $locale->text('UStVA-Nr. 98'));
 
 194   foreach $item (sort({ $a cmp $b } keys %ustva)) {
 
 195     if ($item == $form->{pos_ustva}) {
 
 196       $form->{selectustva} .= "<option value=$item selected>$ustva{$item}\n";
 
 198       $form->{selectustva} .= "<option value=$item>$ustva{$item}\n";
 
 205                 <th align=right>| . $locale->text('Umsatzsteuervoranmeldung') . qq|</th>
 
 206                 <td><select name=pos_ustva>$form->{selectustva}</select></td>
 
 207                 <input type=hidden name=selectustva value="$form->{selectustva}">
 
 210   $form->{selecteur} = "<option>\n";
 
 211   %eur = (1  => "Umsatzerlöse",
 
 212           2  => "sonstige Erlöse",
 
 213           3  => "Privatanteile",
 
 215           5  => "Ausserordentliche Erträge",
 
 216           6  => "Vereinnahmte Umsatzst.",
 
 217           7  => "Umsatzsteuererstattungen",
 
 218           8  => "Wareneingänge",
 
 219           9  => "Löhne und Gehälter",
 
 220           10 => "Gesetzl. sozialer Aufw.",
 
 222           12 => "Gas, Strom, Wasser",
 
 223           13 => "Instandhaltung",
 
 224           14 => "Steuern, Versich., Beiträge",
 
 226           16 => "Kfz-Versicherungen",
 
 227           17 => "Sonst. Fahrtkosten",
 
 228           18 => "Werbe- und Reisekosten",
 
 229           19 => "Instandhaltung u. Werkzeuge",
 
 230           20 => "Fachzeitschriften, Bücher",
 
 231           21 => "Miete für Einrichtungen",
 
 232           22 => "Rechts- und Beratungskosten",
 
 233           23 => "Bürobedarf, Porto, Telefon",
 
 234           24 => "Sonstige Aufwendungen",
 
 235           25 => "Abschreibungen auf Anlagever.",
 
 236           26 => "Abschreibungen auf GWG",
 
 238           28 => "Umsatzsteuerzahlungen",
 
 240           30 => "Ausserordentlicher Aufwand",
 
 241           31 => "Betriebliche Steuern");
 
 242   foreach $item (sort({ $a <=> $b } keys(%eur))) {
 
 243     if ($item == $form->{pos_eur}) {
 
 244       $form->{selecteur} .= "<option value=$item selected>$eur{$item}\n";
 
 246       $form->{selecteur} .= "<option value=$item>$eur{$item}\n";
 
 253                 <th align=right>| . $locale->text('EUER') . qq|</th>
 
 254                 <td><select name=pos_eur>$form->{selecteur}</select></td>
 
 255                 <input type=hidden name=selecteur value="$form->{selecteur}">
 
 258   $form->{selectbwa} = "<option>\n";
 
 260   %bwapos = (1  => 'Umsatzerlöse',
 
 261              2  => 'Best.Verdg.FE/UE',
 
 262              3  => 'Aktiv.Eigenleistung',
 
 263              4  => 'Mat./Wareneinkauf',
 
 264              5  => 'So.betr.Erlöse',
 
 265              10 => 'Personalkosten',
 
 267              12 => 'Betriebl.Steuern',
 
 268              13 => 'Vers./Beiträge',
 
 269              14 => 'Kfz.Kosten o.St.',
 
 270              15 => 'Werbe-Reisek.',
 
 271              16 => 'Kosten Warenabgabe',
 
 272              17 => 'Abschreibungen',
 
 273              18 => 'Rep./instandhlt.',
 
 274              19 => 'Übrige Steuern',
 
 275              20 => 'Sonst.Kosten',
 
 277              31 => 'Sonst.neutr.Aufw.',
 
 279              33 => 'Sonst.neutr.Ertrag',
 
 280              34 => 'Verr.kalk.Kosten',
 
 281              35 => 'Steuern Eink.u.Ertr.');
 
 282   foreach $item (sort({ $a <=> $b } keys %bwapos)) {
 
 283     if ($item == $form->{pos_bwa}) {
 
 284       $form->{selectbwa} .= "<option value=$item selected>$bwapos{$item}\n";
 
 286       $form->{selectbwa} .= "<option value=$item>$bwapos{$item}\n";
 
 293                 <th align=right>| . $locale->text('BWA') . qq|</th>
 
 294                 <td><select name=pos_bwa>$form->{selectbwa}</select></td>
 
 295                 <input type=hidden name=selectbwa value="$form->{selectbwa}">
 
 298 # Entfernt bis es ordentlich umgesetzt wird (hli) 30.03.2006
 
 299 #  $form->{selectbilanz} = "<option>\n";
 
 300 #  foreach $item ((1, 2, 3, 4)) {
 
 301 #    if ($item == $form->{pos_bilanz}) {
 
 302 #      $form->{selectbilanz} .= "<option value=$item selected>$item\n";
 
 304 #      $form->{selectbilanz} .= "<option value=$item>$item\n";
 
 311 #               <th align=right>| . $locale->text('Bilanz') . qq|</th>
 
 312 #               <td><select name=pos_bilanz>$form->{selectbilanz}</select></td>
 
 313 #               <input type=hidden name=selectbilanz value="$form->{selectbilanz}">
 
 316   # this is for our parser only!
 
 317   # type=submit $locale->text('Add Account')
 
 318   # type=submit $locale->text('Edit Account')
 
 319   $form->{type} = "account";
 
 326 <form method=post action=$form->{script}>
 
 328 <input type=hidden name=id value=$form->{id}>
 
 329 <input type=hidden name=type value=account>
 
 330 <input type=hidden name=orphaned value=$form->{orphaned}>
 
 331 <input type=hidden name=new_chart_valid value=$form->{new_chart_valid}>
 
 333 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>
 
 334 <input type=hidden name=income_accno_id value=$form->{income_accno_id}>
 
 335 <input type=hidden name=expense_accno_id value=$form->{expense_accno_id}>
 
 336 <input type=hidden name=fxgain_accno_id value=$form->{fxgain_accno_id}>
 
 337 <input type=hidden name=fxloss_accno_id value=$form->{fxloss_accno_id}>
 
 339 <table border=0 width=100%>
 
 341     <th class=listtop>$form->{title}</th>
 
 348           <th align=right>| . $locale->text('Account Number') . qq|</th>
 
 349           <td><input name=accno size=20 value=$form->{accno}></td>
 
 352           <th align=right>| . $locale->text('Description') . qq|</th>
 
 353           <td><input name=description size=40 value="$form->{description}"></td>
 
 356           <th align=right>| . $locale->text('Account Type') . qq|</th>
 
 360                 <td><input name=category type=radio class=radio value=A $checked{A_}> |
 
 361     . $locale->text('Asset') . qq|\n<br>
 
 362                 <input name=category type=radio class=radio value=L $checked{L_}> |
 
 363     . $locale->text('Liability') . qq|\n<br>
 
 364                 <input name=category type=radio class=radio value=Q $checked{Q_}> |
 
 365     . $locale->text('Equity') . qq|\n<br>
 
 366                 <input name=category type=radio class=radio value=I $checked{I_}> |
 
 367     . $locale->text('Revenue') . qq|\n<br>
 
 368                 <input name=category type=radio class=radio value=E $checked{E_}> |
 
 369     . $locale->text('Expense') . qq|<br>
 
 370                 <input name=category type=radio class=radio value=C $checked{C_}> |
 
 371     . $locale->text('Costs') . qq|</td>
 
 372                 <td width=50> </td>
 
 374                 <input name=charttype type=radio class=radio value="H" $checked{H}> |
 
 375     . $locale->text('Heading') . qq|<br>
 
 376                 <input name=charttype type=radio class=radio value="A" $checked{A}> |
 
 377     . $locale->text('Account') . qq|</td>
 
 384   if ($form->{charttype} eq "A") {
 
 391       . $locale->text('Is this a summary account to record') . qq|</th>
 
 393                 <input name=AR type=checkbox class=checkbox value=AR $form->{AR}> |
 
 394       . $locale->text('AR')
 
 395       . qq| <input name=AP type=checkbox class=checkbox value=AP $form->{AP}> |
 
 396       . $locale->text('AP')
 
 397       . qq| <input name=IC type=checkbox class=checkbox value=IC $form->{IC}> |
 
 398       . $locale->text('Inventory')
 
 405           <th colspan=2>| . $locale->text('Include in drop-down menus') . qq|</th>
 
 411                 <th align=left>| . $locale->text('Receivables') . qq|</th>
 
 412                 <th align=left>| . $locale->text('Payables') . qq|</th>
 
 413                 <th align=left>| . $locale->text('Parts Inventory') . qq|</th>
 
 414                 <th align=left>| . $locale->text('Service Items') . qq|</th>
 
 418                 <input name=AR_amount type=checkbox class=checkbox value=AR_amount $form->{AR_amount}> |
 
 419       . $locale->text('Revenue') . qq|\n<br>
 
 420                 <input name=AR_paid type=checkbox class=checkbox value=AR_paid $form->{AR_paid}> |
 
 421       . $locale->text('Receipt') . qq|\n<br>
 
 422                 <input name=AR_tax type=checkbox class=checkbox value=AR_tax $form->{AR_tax}> |
 
 423       . $locale->text('Tax') . qq|
 
 426                 <input name=AP_amount type=checkbox class=checkbox value=AP_amount $form->{AP_amount}> |
 
 427       . $locale->text('Expense/Asset') . qq|\n<br>
 
 428                 <input name=AP_paid type=checkbox class=checkbox value=AP_paid $form->{AP_paid}> |
 
 429       . $locale->text('Payment') . qq|\n<br>
 
 430                 <input name=AP_tax type=checkbox class=checkbox value=AP_tax $form->{AP_tax}> |
 
 431       . $locale->text('Tax') . qq|
 
 434                 <input name=IC_sale type=checkbox class=checkbox value=IC_sale $form->{IC_sale}> |
 
 435       . $locale->text('Revenue') . qq|\n<br>
 
 436                 <input name=IC_cogs type=checkbox class=checkbox value=IC_cogs $form->{IC_cogs}> |
 
 437       . $locale->text('Expense') . qq|\n<br>
 
 438                 <input name=IC_taxpart type=checkbox class=checkbox value=IC_taxpart $form->{IC_taxpart}> |
 
 439       . $locale->text('Tax') . qq|
 
 442                 <input name=IC_income type=checkbox class=checkbox value=IC_income $form->{IC_income}> |
 
 443       . $locale->text('Revenue') . qq|\n<br>
 
 444                 <input name=IC_expense type=checkbox class=checkbox value=IC_expense $form->{IC_expense}> |
 
 445       . $locale->text('Expense') . qq|\n<br>
 
 446                 <input name=IC_taxservice type=checkbox class=checkbox value=IC_taxservice $form->{IC_taxservice}> |
 
 447       . $locale->text('Tax') . qq|
 
 467     <td><hr size=3 noshade></td>
 
 472   $lxdebug->leave_sub();
 
 476   $lxdebug->enter_sub();
 
 480 <input name=callback type=hidden value="$form->{callback}">
 
 482 <input type=hidden name=path value=$form->{path}>
 
 483 <input type=hidden name=login value=$form->{login}>
 
 484 <input type=hidden name=password value=$form->{password}>
 
 487   if ((!$form->{id}) || ($form->{id} && $form->{orphaned}) || (($form->{type} eq "account") && (!$form->{new_chart_valid}))) {
 
 489 <input type=submit class=submit name=action value="|
 
 490     . $locale->text('Save') . qq|">
 
 494   if ($form->{id} && $form->{orphaned}) {
 
 495     print qq|<input type=submit class=submit name=action value="|
 
 496       . $locale->text('Delete') . qq|">|;
 
 506   $lxdebug->leave_sub();
 
 510   $lxdebug->enter_sub();
 
 512   $form->isblank("accno",    $locale->text('Account Number missing!'));
 
 513   $form->isblank("category", $locale->text('Account Type missing!'));
 
 515   $form->redirect($locale->text('Account saved!'))
 
 516     if (AM->save_account(\%myconfig, \%$form));
 
 517   $form->error($locale->text('Cannot save account!'));
 
 519   $lxdebug->leave_sub();
 
 523   $lxdebug->enter_sub();
 
 525   CA->all_accounts(\%myconfig, \%$form);
 
 527   $form->{title} = $locale->text('Chart of Accounts');
 
 531     "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
 536   $callback = $form->escape($callback);
 
 538   foreach $ca (@{ $form->{CA} }) {
 
 540     $ca->{debit}  = " ";
 
 541     $ca->{credit} = " ";
 
 543     if ($ca->{amount} > 0) {
 
 545         $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
 
 547     if ($ca->{amount} < 0) {
 
 549         $form->format_amount(\%myconfig, -$ca->{amount}, 2, " ");
 
 552     my @links = split( q{:}, $ca->{link});
 
 556     foreach my $link (@links){
 
 557       $link = ( $link eq 'AR')             ? $locale->text('Account Link AR')
 
 558                : ( $link eq 'AP')             ? $locale->text('Account Link AP')
 
 559                : ( $link eq 'IC')             ? $locale->text('Account Link IC')
 
 560                : ( $link eq 'AR_amount' )     ? $locale->text('Account Link AR_amount')
 
 561                : ( $link eq 'AR_paid' )       ? $locale->text('Account Link AR_paid')
 
 562                : ( $link eq 'AR_tax' )        ? $locale->text('Account Link AR_tax')
 
 563                : ( $link eq 'AP_amount' )     ? $locale->text('Account Link AP_amount')
 
 564                : ( $link eq 'AP_paid' )       ? $locale->text('Account Link AP_paid')
 
 565                : ( $link eq 'AP_tax' )        ? $locale->text('Account Link AP_tax')
 
 566                : ( $link eq 'IC_sale' )       ? $locale->text('Account Link IC_sale')
 
 567                : ( $link eq 'IC_cogs' )       ? $locale->text('Account Link IC_cogs')
 
 568                : ( $link eq 'IC_taxpart' )    ? $locale->text('Account Link IC_taxpart')
 
 569                : ( $link eq 'IC_income' )     ? $locale->text('Account Link IC_income')
 
 570                : ( $link eq 'IC_expense' )    ? $locale->text('Account Link IC_expense')
 
 571                : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice')
 
 572                : ( $link eq 'CT_tax' )        ? $locale->text('Account Link CT_tax')
 
 573                : $locale->text('Unknown Link') . ': ' . $link;
 
 575       $ca->{link} .= qq|[| . $link . qq|] |;
 
 578     $ca->{startdate} =~ s/,/<br>/og;
 
 579     $ca->{tk_ustva}  =~ s/,/<br>/og;
 
 581     $ca->{taxkey_id}  =~ s/,/<br>/og;
 
 582     $ca->{taxdescription}  =~ s/,/<br>/og;
 
 584     $ca->{datevautomatik} = ($ca->{datevautomatik}) ? $locale->text('On'):q{};
 
 586     $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
 
 587                     : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
 
 588                     : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
 
 589                     : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
 
 590                     : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
 
 591                     : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
 
 592                     : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
 
 593                     : $locale->text('Unknown Category') . ': ' . $ca->{category};
 
 595     $ca->{link_edit_account} = 
 
 596         qq|$form->{script}?action=edit_account&id=$ca->{id}|
 
 597        .qq|&path=$form->{path}&login=$form->{login}|
 
 598        .qq|&password=$form->{password}&callback=$callback>$ca->{accno}|;
 
 601   my $parameters_ref = {
 
 604   #   hidden_variables                => $_hidden_variables_ref,
 
 607   # Ausgabe des Templates
 
 608   print($form->parse_html_template('am/list_accounts', $parameters_ref));
 
 610   $lxdebug->leave_sub();
 
 616   $lxdebug->enter_sub();
 
 618   $form->{title} = $locale->text('Delete Account');
 
 621     qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
 
 623     if ($form->{id} == $form->{$id}) {
 
 624       $form->error($locale->text('Cannot delete default account!'));
 
 628   $form->redirect($locale->text('Account deleted!'))
 
 629     if (AM->delete_account(\%myconfig, \%$form));
 
 630   $form->error($locale->text('Cannot delete account!'));
 
 632   $lxdebug->leave_sub();
 
 636   $lxdebug->enter_sub();
 
 638   @{ $form->{fields} } = (accno, description);
 
 639   $form->{table}     = "gifi";
 
 640   $form->{sortorder} = "accno";
 
 642   AM->gifi_accounts(\%myconfig, \%$form);
 
 644   $form->{title} = $locale->text('GIFI');
 
 648     "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
 650   @column_index = qw(accno description);
 
 652   $column_header{accno} = qq|<th>| . $locale->text('GIFI') . qq|</a></th>|;
 
 653   $column_header{description} =
 
 654     qq|<th>| . $locale->text('Description') . qq|</a></th>|;
 
 657   $colspan = $#column_index + 1;
 
 664     <th class=listtop colspan=$colspan>$form->{title}</th>
 
 667   <tr class=listheading>
 
 670   map { print "$column_header{$_}\n" } @column_index;
 
 677   $callback = $form->escape($callback);
 
 679   foreach $ca (@{ $form->{ALL} }) {
 
 685 <tr valign=top class=listrow$i>|;
 
 687     $column_data{accno} =
 
 688       qq|<td><a href=$form->{script}?action=edit_gifi&coa=1&accno=$ca->{accno}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{accno}</td>|;
 
 689     $column_data{description} = qq|<td>$ca->{description} </td>|;
 
 691     map { print "$column_data{$_}\n" } @column_index;
 
 698     <td colspan=$colspan><hr size=3 noshade></td>
 
 706   $lxdebug->leave_sub();
 
 710   $lxdebug->enter_sub();
 
 712   $form->{title} = "Add";
 
 716     "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
 723   $lxdebug->leave_sub();
 
 727   $lxdebug->enter_sub();
 
 729   $form->{title} = "Edit";
 
 731   AM->get_gifi(\%myconfig, \%$form);
 
 736   $lxdebug->leave_sub();
 
 740   $lxdebug->enter_sub();
 
 742   $form->{title} = $locale->text("$form->{title} GIFI");
 
 744   # $locale->text('Add GIFI')
 
 745   # $locale->text('Edit GIFI')
 
 747   $form->{description} =~ s/\"/"/g;
 
 754 <form method=post action=$form->{script}>
 
 756 <input type=hidden name=id value=$form->{accno}>
 
 757 <input type=hidden name=type value=gifi>
 
 761     <th class=listtop>$form->{title}</th>
 
 768           <th align=right>| . $locale->text('GIFI') . qq|</th>
 
 769           <td><input name=accno size=20 value=$form->{accno}></td>
 
 772           <th align=right>| . $locale->text('Description') . qq|</th>
 
 773           <td><input name=description size=60 value="$form->{description}"></td>
 
 779     <td colspan=2><hr size=3 noshade></td>
 
 784   $lxdebug->leave_sub();
 
 788   $lxdebug->enter_sub();
 
 792 <input name=callback type=hidden value="$form->{callback}">
 
 794 <input type=hidden name=path value=$form->{path}>
 
 795 <input type=hidden name=login value=$form->{login}>
 
 796 <input type=hidden name=password value=$form->{password}>
 
 798 <br><input type=submit class=submit name=action value="|
 
 799     . $locale->text('Save') . qq|">|;
 
 803 <input type=submit class=submit name=action value="|
 
 804       . $locale->text('Copy to COA') . qq|">
 
 807     if ($form->{accno} && $form->{orphaned}) {
 
 808       print qq|<input type=submit class=submit name=action value="|
 
 809         . $locale->text('Delete') . qq|">|;
 
 820   $lxdebug->leave_sub();
 
 824   $lxdebug->enter_sub();
 
 826   $form->isblank("accno", $locale->text('GIFI missing!'));
 
 827   AM->save_gifi(\%myconfig, \%$form);
 
 828   $form->redirect($locale->text('GIFI saved!'));
 
 830   $lxdebug->leave_sub();
 
 834   $lxdebug->enter_sub();
 
 836   $form->isblank("accno", $locale->text('GIFI missing!'));
 
 838   AM->save_gifi(\%myconfig, \%$form);
 
 841   $form->{gifi_accno} = $form->{accno};
 
 842   $form->{title}      = "Add";
 
 843   $form->{charttype}  = "A";
 
 848   $lxdebug->leave_sub();
 
 852   $lxdebug->enter_sub();
 
 854   AM->delete_gifi(\%myconfig, \%$form);
 
 855   $form->redirect($locale->text('GIFI deleted!'));
 
 857   $lxdebug->leave_sub();
 
 861   $lxdebug->enter_sub();
 
 863   $form->{title} = "Add";
 
 867     "$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
 868     unless $form->{callback};
 
 873   $lxdebug->leave_sub();
 
 876 sub edit_department {
 
 877   $lxdebug->enter_sub();
 
 879   $form->{title} = "Edit";
 
 881   AM->get_department(\%myconfig, \%$form);
 
 886   $lxdebug->leave_sub();
 
 889 sub list_department {
 
 890   $lxdebug->enter_sub();
 
 892   AM->departments(\%myconfig, \%$form);
 
 895     "$form->{script}?action=list_department&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
 897   $callback = $form->escape($form->{callback});
 
 899   $form->{title} = $locale->text('Departments');
 
 901   @column_index = qw(description cost profit);
 
 903   $column_header{description} =
 
 904       qq|<th class=listheading width=90%>|
 
 905     . $locale->text('Description')
 
 907   $column_header{cost} =
 
 908       qq|<th class=listheading nowrap>|
 
 909     . $locale->text('Cost Center')
 
 911   $column_header{profit} =
 
 912       qq|<th class=listheading nowrap>|
 
 913     . $locale->text('Profit Center')
 
 923     <th class=listtop>$form->{title}</th>
 
 929         <tr class=listheading>
 
 932   map { print "$column_header{$_}\n" } @column_index;
 
 938   foreach $ref (@{ $form->{ALL} }) {
 
 944         <tr valign=top class=listrow$i>
 
 947     $costcenter   = ($ref->{role} eq "C") ? "X" : "";
 
 948     $profitcenter = ($ref->{role} eq "P") ? "X" : "";
 
 950     $column_data{description} =
 
 951       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>|;
 
 952     $column_data{cost}   = qq|<td align=center>$costcenter</td>|;
 
 953     $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
 
 955     map { print "$column_data{$_}\n" } @column_index;
 
 967   <td><hr size=3 noshade></td>
 
 972 <form method=post action=$form->{script}>
 
 974 <input name=callback type=hidden value="$form->{callback}">
 
 976 <input type=hidden name=type value=department>
 
 978 <input type=hidden name=path value=$form->{path}>
 
 979 <input type=hidden name=login value=$form->{login}>
 
 980 <input type=hidden name=password value=$form->{password}>
 
 982 <input class=submit type=submit name=action value="|
 
 983     . $locale->text('Add') . qq|">
 
 991   $lxdebug->leave_sub();
 
 994 sub department_header {
 
 995   $lxdebug->enter_sub();
 
 997   $form->{title} = $locale->text("$form->{title} Department");
 
 999   # $locale->text('Add Department')
 
1000   # $locale->text('Edit Department')
 
1002   $form->{description} =~ s/\"/"/g;
 
1004   if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
 
1006       qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
 
1009       qq|<input name=description size=60 value="$form->{description}">|;
 
1012   $costcenter   = "checked" if $form->{role} eq "C";
 
1013   $profitcenter = "checked" if $form->{role} eq "P";
 
1020 <form method=post action=$form->{script}>
 
1022 <input type=hidden name=id value=$form->{id}>
 
1023 <input type=hidden name=type value=department>
 
1027     <th class=listtop colspan=2>$form->{title}</th>
 
1029   <tr height="5"></tr>
 
1031     <th align=right>| . $locale->text('Description') . qq|</th>
 
1032     <td>$description</td>
 
1036     <td><input type=radio style=radio name=role value="C" $costcenter> |
 
1037     . $locale->text('Cost Center') . qq|
 
1038         <input type=radio style=radio name=role value="P" $profitcenter> |
 
1039     . $locale->text('Profit Center') . qq|
 
1042     <td colspan=2><hr size=3 noshade></td>
 
1047   $lxdebug->leave_sub();
 
1050 sub save_department {
 
1051   $lxdebug->enter_sub();
 
1053   $form->isblank("description", $locale->text('Description missing!'));
 
1054   AM->save_department(\%myconfig, \%$form);
 
1055   $form->redirect($locale->text('Department saved!'));
 
1057   $lxdebug->leave_sub();
 
1060 sub delete_department {
 
1061   $lxdebug->enter_sub();
 
1063   AM->delete_department(\%myconfig, \%$form);
 
1064   $form->redirect($locale->text('Department deleted!'));
 
1066   $lxdebug->leave_sub();
 
1070   $lxdebug->enter_sub();
 
1072   $form->{title} = "Add";
 
1075     "$form->{script}?action=add_lead&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1076     unless $form->{callback};
 
1081   $lxdebug->leave_sub();
 
1085   $lxdebug->enter_sub();
 
1087   $form->{title} = "Edit";
 
1089   AM->get_lead(\%myconfig, \%$form);
 
1093   $form->{orphaned} = 1;
 
1096   $lxdebug->leave_sub();
 
1100   $lxdebug->enter_sub();
 
1102   AM->lead(\%myconfig, \%$form);
 
1105     "$form->{script}?action=list_lead&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1107   $callback = $form->escape($form->{callback});
 
1109   $form->{title} = $locale->text('Lead');
 
1111   @column_index = qw(description cost profit);
 
1113   $column_header{description} =
 
1114       qq|<th class=listheading width=100%>|
 
1115     . $locale->text('Description')
 
1125     <th class=listtop>$form->{title}</th>
 
1127   <tr height="5"></tr>
 
1128   <tr class=listheading>
 
1131   map { print "$column_header{$_}\n" } @column_index;
 
1137   foreach $ref (@{ $form->{ALL} }) {
 
1143         <tr valign=top class=listrow$i>
 
1146         $lead = $ref->{lead};
 
1148     $column_data{description} =
 
1149       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>|;
 
1151     map { print "$column_data{$_}\n" } @column_index;
 
1160   <td><hr size=3 noshade></td>
 
1165 <form method=post action=$form->{script}>
 
1167 <input name=callback type=hidden value="$form->{callback}">
 
1169 <input type=hidden name=type value=lead>
 
1171 <input type=hidden name=path value=$form->{path}>
 
1172 <input type=hidden name=login value=$form->{login}>
 
1173 <input type=hidden name=password value=$form->{password}>
 
1175 <input class=submit type=submit name=action value="|
 
1176     . $locale->text('Add') . qq|">
 
1184   $lxdebug->leave_sub();
 
1188   $lxdebug->enter_sub();
 
1190   $form->{title} = $locale->text("$form->{title} Lead");
 
1192   # $locale->text('Add Lead')
 
1193   # $locale->text('Edit Lead')
 
1195   $form->{description} =~ s/\"/"/g;
 
1198       qq|<input name=description size=50 value="$form->{lead}">|;
 
1205 <form method=post action=$form->{script}>
 
1207 <input type=hidden name=id value=$form->{id}>
 
1208 <input type=hidden name=type value=lead>
 
1212     <th class=listtop colspan=2>$form->{title}</th>
 
1214   <tr height="5"></tr>
 
1216     <th align=right>| . $locale->text('Description') . qq|</th>
 
1217     <td>$description</td>
 
1219     <td colspan=2><hr size=3 noshade></td>
 
1224   $lxdebug->leave_sub();
 
1228   $lxdebug->enter_sub();
 
1230   $form->isblank("description", $locale->text('Description missing!'));
 
1231   AM->save_lead(\%myconfig, \%$form);
 
1232   $form->redirect($locale->text('lead saved!'));
 
1234   $lxdebug->leave_sub();
 
1238   $lxdebug->enter_sub();
 
1240   AM->delete_lead(\%myconfig, \%$form);
 
1241   $form->redirect($locale->text('lead deleted!'));
 
1243   $lxdebug->leave_sub();
 
1247   $lxdebug->enter_sub();
 
1249   $form->{title} = "Add";
 
1252     "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1253     unless $form->{callback};
 
1258   $lxdebug->leave_sub();
 
1262   $lxdebug->enter_sub();
 
1264   $form->{title} = "Edit";
 
1266   AM->get_business(\%myconfig, \%$form);
 
1270   $form->{orphaned} = 1;
 
1273   $lxdebug->leave_sub();
 
1277   $lxdebug->enter_sub();
 
1279   AM->business(\%myconfig, \%$form);
 
1282     "$form->{script}?action=list_business&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1284   $callback = $form->escape($form->{callback});
 
1286   $form->{title} = $locale->text('Type of Business');
 
1288   @column_index = qw(description discount customernumberinit);
 
1290   $column_header{description} =
 
1291       qq|<th class=listheading width=60%>|
 
1292     . $locale->text('Description')
 
1294   $column_header{discount} =
 
1295       qq|<th class=listheading width=10%>|
 
1296     . $locale->text('Discount')
 
1298   $column_header{customernumberinit} =
 
1299       qq|<th class=listheading>|
 
1300     . $locale->text('Customernumberinit')
 
1310     <th class=listtop>$form->{title}</th>
 
1312   <tr height="5"></tr>
 
1316         <tr class=listheading>
 
1319   map { print "$column_header{$_}\n" } @column_index;
 
1325   foreach $ref (@{ $form->{ALL} }) {
 
1331         <tr valign=top class=listrow$i>
 
1335       $form->format_amount(\%myconfig, $ref->{discount} * 100, 1, " ");
 
1338       ? "<b>$ref->{description}</b>"
 
1339       : "$ref->{description}";
 
1340     $column_data{description} =
 
1341       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>|;
 
1342     $column_data{discount}           = qq|<td align=right>$discount</td>|;
 
1343     $column_data{customernumberinit} =
 
1344       qq|<td align=right>$ref->{customernumberinit}</td>|;
 
1346     map { print "$column_data{$_}\n" } @column_index;
 
1358   <td><hr size=3 noshade></td>
 
1363 <form method=post action=$form->{script}>
 
1365 <input name=callback type=hidden value="$form->{callback}">
 
1367 <input type=hidden name=type value=business>
 
1369 <input type=hidden name=path value=$form->{path}>
 
1370 <input type=hidden name=login value=$form->{login}>
 
1371 <input type=hidden name=password value=$form->{password}>
 
1373 <input class=submit type=submit name=action value="|
 
1374     . $locale->text('Add') . qq|">
 
1382   $lxdebug->leave_sub();
 
1385 sub business_header {
 
1386   $lxdebug->enter_sub();
 
1388   $form->{title}    = $locale->text("$form->{title} Business");
 
1389   $form->{salesman} = "checked" if $form->{salesman};
 
1391   # $locale->text('Add Business')
 
1392   # $locale->text('Edit Business')
 
1394   $form->{description} =~ s/\"/"/g;
 
1396     $form->format_amount(\%myconfig, $form->{discount} * 100);
 
1403 <form method=post action=$form->{script}>
 
1405 <input type=hidden name=id value=$form->{id}>
 
1406 <input type=hidden name=type value=business>
 
1410     <th class=listtop colspan=2>$form->{title}</th>
 
1412   <tr height="5"></tr>
 
1414     <th align=right>| . $locale->text('Type of Business') . qq|</th>
 
1415     <td><input name=description size=30 value="$form->{description}"></td>
 
1418     <th align=right>| . $locale->text('Discount') . qq| %</th>
 
1419     <td><input name=discount size=5 value=$form->{discount}></td>
 
1422     <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
 
1423     <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
 
1426     <td align=right>| . $locale->text('Salesman') . qq|</td>
 
1427     <td><input name=salesman class=checkbox type=checkbox value=1 $form->{salesman}></td>
 
1429   <td colspan=2><hr size=3 noshade></td>
 
1434   $lxdebug->leave_sub();
 
1438   $lxdebug->enter_sub();
 
1440   $form->isblank("description", $locale->text('Description missing!'));
 
1441   AM->save_business(\%myconfig, \%$form);
 
1442   $form->redirect($locale->text('Business saved!'));
 
1444   $lxdebug->leave_sub();
 
1447 sub delete_business {
 
1448   $lxdebug->enter_sub();
 
1450   AM->delete_business(\%myconfig, \%$form);
 
1451   $form->redirect($locale->text('Business deleted!'));
 
1453   $lxdebug->leave_sub();
 
1457   $lxdebug->enter_sub();
 
1459   $form->{title} = "Add";
 
1462     "$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1463     unless $form->{callback};
 
1468   $lxdebug->leave_sub();
 
1472   $lxdebug->enter_sub();
 
1474   $form->{title} = "Edit";
 
1476   AM->get_language(\%myconfig, \%$form);
 
1480   $form->{orphaned} = 1;
 
1483   $lxdebug->leave_sub();
 
1487   $lxdebug->enter_sub();
 
1489   AM->language(\%myconfig, \%$form);
 
1492     "$form->{script}?action=list_language&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1494   $callback = $form->escape($form->{callback});
 
1496   $form->{title} = $locale->text('Languages');
 
1498   @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
 
1500   $column_header{description} =
 
1501       qq|<th class=listheading width=60%>|
 
1502     . $locale->text('Description')
 
1504   $column_header{template_code} =
 
1505       qq|<th class=listheading width=10%>|
 
1506     . $locale->text('Template Code')
 
1508   $column_header{article_code} =
 
1509       qq|<th class=listheading>|
 
1510     . $locale->text('Article Code')
 
1512   $column_header{output_numberformat} =
 
1513       qq|<th class=listheading>|
 
1514     . $locale->text('Number Format')
 
1516   $column_header{output_dateformat} =
 
1517       qq|<th class=listheading>|
 
1518     . $locale->text('Date Format')
 
1520   $column_header{output_longdates} =
 
1521       qq|<th class=listheading>|
 
1522     . $locale->text('Long Dates')
 
1532     <th class=listtop>$form->{title}</th>
 
1534   <tr height="5"></tr>
 
1538         <tr class=listheading>
 
1541   map { print "$column_header{$_}\n" } @column_index;
 
1547   foreach $ref (@{ $form->{ALL} }) {
 
1553         <tr valign=top class=listrow$i>
 
1557     $column_data{description} =
 
1558       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>|;
 
1559     $column_data{template_code}           = qq|<td align=right>$ref->{template_code}</td>|;
 
1560     $column_data{article_code} =
 
1561       qq|<td align=right>$ref->{article_code}</td>|;
 
1562     $column_data{output_numberformat} =
 
1564       ($ref->{output_numberformat} ? $ref->{output_numberformat} :
 
1565        $locale->text("use program settings")) .
 
1567     $column_data{output_dateformat} =
 
1569       ($ref->{output_dateformat} ? $ref->{output_dateformat} :
 
1570        $locale->text("use program settings")) .
 
1572     $column_data{output_longdates} =
 
1574       ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
 
1577     map { print "$column_data{$_}\n" } @column_index;
 
1589   <td><hr size=3 noshade></td>
 
1594 <form method=post action=$form->{script}>
 
1596 <input name=callback type=hidden value="$form->{callback}">
 
1598 <input type=hidden name=type value=language>
 
1600 <input type=hidden name=path value=$form->{path}>
 
1601 <input type=hidden name=login value=$form->{login}>
 
1602 <input type=hidden name=password value=$form->{password}>
 
1604 <input class=submit type=submit name=action value="|
 
1605     . $locale->text('Add') . qq|">
 
1613   $lxdebug->leave_sub();
 
1616 sub language_header {
 
1617   $lxdebug->enter_sub();
 
1619   $form->{title}    = $locale->text("$form->{title} Language");
 
1621   # $locale->text('Add Language')
 
1622   # $locale->text('Edit Language')
 
1624   $form->{description} =~ s/\"/"/g;
 
1625   $form->{template_code} =~ s/\"/"/g;
 
1626   $form->{article_code} =~ s/\"/"/g;
 
1632     qq|<option value="">| . $locale->text("use program settings") .
 
1634   foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
 
1636       ($item eq $form->{output_numberformat})
 
1637       ? "<option selected>$item"
 
1643     qq|<option value="">| . $locale->text("use program settings") .
 
1645   foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
 
1647       ($item eq $form->{output_dateformat})
 
1648       ? "<option selected>$item"
 
1656 <form method=post action=$form->{script}>
 
1658 <input type=hidden name=id value=$form->{id}>
 
1659 <input type=hidden name=type value=language>
 
1663     <th class=listtop colspan=2>$form->{title}</th>
 
1665   <tr height="5"></tr>
 
1667     <th align=right>| . $locale->text('Language') . qq|</th>
 
1668     <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
 
1671     <th align=right>| . $locale->text('Template Code') . qq|</th>
 
1672     <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
 
1675     <th align=right>| . $locale->text('Article Code') . qq|</th>
 
1676     <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
 
1679     <th align=right>| . $locale->text('Number Format') . qq|</th>
 
1680     <td><select name="output_numberformat">$numberformat</select></td>
 
1683     <th align=right>| . $locale->text('Date Format') . qq|</th>
 
1684     <td><select name="output_dateformat">$dateformat</select></td>
 
1687     <th align=right>| . $locale->text('Long Dates') . qq|</th>
 
1688     <td><input type="radio" name="output_longdates" value="1"| .
 
1689     ($form->{output_longdates} ? " checked" : "") .
 
1690     qq|>| . $locale->text("Yes") .
 
1691     qq|<input type="radio" name="output_longdates" value="0"| .
 
1692     ($form->{output_longdates} ? "" : " checked") .
 
1693     qq|>| . $locale->text("No") .
 
1696   <td colspan=2><hr size=3 noshade></td>
 
1701   $lxdebug->leave_sub();
 
1705   $lxdebug->enter_sub();
 
1707   $form->isblank("description", $locale->text('Language missing!'));
 
1708   $form->isblank("template_code", $locale->text('Template Code missing!'));
 
1709   $form->isblank("article_code", $locale->text('Article Code missing!'));
 
1710   AM->save_language(\%myconfig, \%$form);
 
1711   $form->redirect($locale->text('Language saved!'));
 
1713   $lxdebug->leave_sub();
 
1716 sub delete_language {
 
1717   $lxdebug->enter_sub();
 
1719   AM->delete_language(\%myconfig, \%$form);
 
1720   $form->redirect($locale->text('Language deleted!'));
 
1722   $lxdebug->leave_sub();
 
1726 sub add_buchungsgruppe {
 
1727   $lxdebug->enter_sub();
 
1729   # $locale->text("Add Buchungsgruppe")
 
1730   # $locale->text("Edit Buchungsgruppe")
 
1731   $form->{title} = "Add";
 
1734     "$form->{script}?action=add_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1735     unless $form->{callback};
 
1736   AM->get_buchungsgruppe(\%myconfig, \%$form);
 
1737   $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
 
1738   for (my $i = 0; 4 > $i; $i++) {
 
1739     map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
 
1740         qw(income expense));
 
1743   &buchungsgruppe_header;
 
1746   $lxdebug->leave_sub();
 
1749 sub edit_buchungsgruppe {
 
1750   $lxdebug->enter_sub();
 
1752   $form->{title} = "Edit";
 
1754   AM->get_buchungsgruppe(\%myconfig, \%$form);
 
1756   &buchungsgruppe_header;
 
1760   $lxdebug->leave_sub();
 
1763 sub list_buchungsgruppe {
 
1764   $lxdebug->enter_sub();
 
1766   AM->buchungsgruppe(\%myconfig, \%$form);
 
1769     "$form->{script}?action=list_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1771   $callback = $form->escape($form->{callback});
 
1773   $form->{title} = $locale->text('Buchungsgruppen');
 
1775   @column_index = qw(up down description inventory_accno
 
1776                      income_accno_0 expense_accno_0
 
1777                      income_accno_1 expense_accno_1
 
1778                      income_accno_2 expense_accno_2
 
1779                      income_accno_3 expense_accno_3 );
 
1781   $column_header{up} =
 
1782       qq|<th class="listheading">|
 
1783     . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
 
1785   $column_header{down} =
 
1786       qq|<th class="listheading">|
 
1787     . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
 
1789   $column_header{description} =
 
1790       qq|<th class="listheading" width="40%">|
 
1791     . $locale->text('Description')
 
1793   $column_header{inventory_accno} =
 
1794       qq|<th class=listheading>|
 
1795     . $locale->text('Bestandskonto')
 
1797   $column_header{income_accno_0} =
 
1798       qq|<th class=listheading>|
 
1799     . $locale->text('Erlöse Inland')
 
1801   $column_header{expense_accno_0} =
 
1802       qq|<th class=listheading>|
 
1803     . $locale->text('Aufwand Inland')
 
1805   $column_header{income_accno_1} =
 
1806       qq|<th class=listheading>|
 
1807     . $locale->text('Erlöse EU m. UStId')
 
1809   $column_header{expense_accno_1} =
 
1810       qq|<th class=listheading>|
 
1811     . $locale->text('Aufwand EU m. UStId')
 
1813   $column_header{income_accno_2} =
 
1814       qq|<th class=listheading>|
 
1815     . $locale->text('Erlöse EU o. UStId')
 
1817   $column_header{expense_accno_2} =
 
1818       qq|<th class=listheading>|
 
1819     . $locale->text('Aufwand EU o. UStId')
 
1821   $column_header{income_accno_3} =
 
1822       qq|<th class=listheading>|
 
1823     . $locale->text('Erlöse Ausland')
 
1825   $column_header{expense_accno_3} =
 
1826       qq|<th class=listheading>|
 
1827     . $locale->text('Aufwand Ausland')
 
1836     <th class=listtop>$form->{title}</th>
 
1838   <tr height="5"></tr>
 
1842         <tr class=listheading>
 
1845   map { print "$column_header{$_}\n" } @column_index;
 
1851   my $swap_link = qq|$form->{script}?action=swap_buchungsgruppen&|;
 
1852   map({ $swap_link .= $_ . "=" . $form->escape($form->{$_}) . "&" }
 
1853       qw(login password path));
 
1856   foreach $ref (@{ $form->{ALL} }) {
 
1862         <tr valign=top class=listrow$i>
 
1866       my $pref = $form->{ALL}->[$row - 1];
 
1868         qq|<td align="center" valign="center">| .
 
1869         qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
 
1870         qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">| .
 
1873       $column_data{up} = qq|<td> </td>|;
 
1876     if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
 
1877       $column_data{down} = qq|<td> </td>|;
 
1879       my $nref = $form->{ALL}->[$row + 1];
 
1880       $column_data{down} =
 
1881         qq|<td align="center" valign="center">| .
 
1882         qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
 
1883         qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">| .
 
1887     $column_data{description} =
 
1888       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>|;
 
1889     $column_data{inventory_accno}           = qq|<td align=right>$ref->{inventory_accno}</td>|;
 
1890     $column_data{income_accno_0} =
 
1891       qq|<td align=right>$ref->{income_accno_0}</td>|;
 
1892     $column_data{expense_accno_0}           = qq|<td align=right>$ref->{expense_accno_0}</td>|;
 
1893     $column_data{income_accno_1} =
 
1894       qq|<td align=right>$ref->{income_accno_1}</td>|;
 
1895     $column_data{expense_accno_1}           = qq|<td align=right>$ref->{expense_accno_1}</td>|;
 
1896     $column_data{income_accno_2} =
 
1897       qq|<td align=right>$ref->{income_accno_2}</td>|;
 
1898     $column_data{expense_accno_2}           = qq|<td align=right>$ref->{expense_accno_2}</td>|;
 
1899     $column_data{income_accno_3} =
 
1900       qq|<td align=right>$ref->{income_accno_3}</td>|;
 
1901     $column_data{expense_accno_3}           = qq|<td align=right>$ref->{expense_accno_3}</td>|;
 
1903     map { print "$column_data{$_}\n" } @column_index;
 
1917   <td><hr size=3 noshade></td>
 
1922 <form method=post action=$form->{script}>
 
1924 <input name=callback type=hidden value="$form->{callback}">
 
1926 <input type=hidden name=type value=buchungsgruppe>
 
1928 <input type=hidden name=path value=$form->{path}>
 
1929 <input type=hidden name=login value=$form->{login}>
 
1930 <input type=hidden name=password value=$form->{password}>
 
1932 <input class=submit type=submit name=action value="|
 
1933     . $locale->text('Add') . qq|">
 
1941   $lxdebug->leave_sub();
 
1944 sub buchungsgruppe_header {
 
1945   $lxdebug->enter_sub();
 
1947   $form->{title}    = $locale->text("$form->{title} Buchungsgruppe");
 
1949   # $locale->text('Buchungsgruppe hinzufügen')
 
1950   # $locale->text('Buchungsgruppe bearbeiten')
 
1952   my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
 
1953   my %acc_type_map = (
 
1954     "IC" => $acc_inventory,
 
1955     "IC_income" => $acc_income,
 
1956     "IC_sale" => $acc_income,
 
1957     "IC_expense" => $acc_expense,
 
1958     "IC_cogs" => $acc_expense,
 
1961   foreach $key (keys(%acc_type_map)) {
 
1962     foreach $ref (@{ $form->{IC_links}{$key} }) {
 
1963       $acc_type_map{$key}->{$ref->{"id"}} = $ref;
 
1967   foreach my $type (qw(IC IC_income IC_expense)) {
 
1968     $form->{"select$type"} =
 
1970            map({ "<option value=$_->{id} $_->{selected}>" .
 
1971                    "$_->{accno}--" . H($_->{description}) . "</option>" }
 
1972                sort({ $a->{"accno"} cmp $b->{"accno"} }
 
1973                     values(%{$acc_type_map{$type}}))));
 
1977     $form->{selectIC} =~ s/selected//g;
 
1978     $form->{selectIC} =~ s/ value=$form->{inventory_accno_id}/  value=$form->{inventory_accno_id} selected/;
 
1979     $form->{selectIC_income} =~ s/selected//g;
 
1980     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_0}/  value=$form->{income_accno_id_0} selected/;
 
1981     $form->{selectIC_expense} =~ s/selected//g;
 
1982     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_0}/  value=$form->{expense_accno_id_0} selected/;
 
1988                 <th align=right>| . $locale->text('Inventory') . qq|</th>
 
1989                 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
 
1990                 <input name=selectIC type=hidden value="$form->{selectIC}">
 
1994                 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
 
1998   $linkaccounts .= qq|
 
2000                 <th align=right>| . $locale->text('Erlöse Inland') . qq|</th>
 
2001                 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
 
2004                 <th align=right>| . $locale->text('Aufwand Inland') . qq|</th>
 
2005                 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
 
2008     $form->{selectIC_income} =~ s/selected//g;
 
2009     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_1}/  value=$form->{income_accno_id_1} selected/;
 
2010     $form->{selectIC_expense} =~ s/selected//g;
 
2011     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/  value=$form->{expense_accno_id_1} selected/;
 
2013   $linkaccounts .= qq|        <tr>
 
2014                 <th align=right>| . $locale->text('Erlöse EU m. UStId') . qq|</th>
 
2015                 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
 
2018                 <th align=right>| . $locale->text('Aufwand EU m UStId') . qq|</th>
 
2019                 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
 
2023     $form->{selectIC_income} =~ s/selected//g;
 
2024     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_2}/  value=$form->{income_accno_id_2} selected/;
 
2025     $form->{selectIC_expense} =~ s/selected//g;
 
2026     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_2}/  value=$form->{expense_accno_id_2} selected/;
 
2029   $linkaccounts .= qq|        <tr>
 
2030                 <th align=right>| . $locale->text('Erlöse EU o. UStId') . qq|</th>
 
2031                 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
 
2034                 <th align=right>| . $locale->text('Aufwand EU o. UStId') . qq|</th>
 
2035                 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
 
2039     $form->{selectIC_income} =~ s/selected//g;
 
2040     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_3}/  value=$form->{income_accno_id_3} selected/;
 
2041     $form->{selectIC_expense} =~ s/selected//g;
 
2042     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_3}/  value=$form->{expense_accno_id_3} selected/;
 
2045   $linkaccounts .= qq|        <tr>
 
2046                 <th align=right>| . $locale->text('Erlöse Ausland') . qq|</th>
 
2047                 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
 
2050                 <th align=right>| . $locale->text('Aufwand Ausland') . qq|</th>
 
2051                 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
 
2061 <form method=post action=$form->{script}>
 
2063 <input type=hidden name=id value=$form->{id}>
 
2064 <input type=hidden name=type value=buchungsgruppe>
 
2068     <th class=listtop colspan=2>$form->{title}</th>
 
2070   <tr height="5"></tr>
 
2072     <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
 
2073     <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
 
2076   <td colspan=2><hr size=3 noshade></td>
 
2081   $lxdebug->leave_sub();
 
2084 sub save_buchungsgruppe {
 
2085   $lxdebug->enter_sub();
 
2087   $form->isblank("description", $locale->text('Description missing!'));
 
2089   AM->save_buchungsgruppe(\%myconfig, \%$form);
 
2090   $form->redirect($locale->text('Buchungsgruppe gespeichert!'));
 
2092   $lxdebug->leave_sub();
 
2095 sub delete_buchungsgruppe {
 
2096   $lxdebug->enter_sub();
 
2098   AM->delete_buchungsgruppe(\%myconfig, \%$form);
 
2099   $form->redirect($locale->text('Buchungsgruppe gelöscht!'));
 
2101   $lxdebug->leave_sub();
 
2104 sub swap_buchungsgruppen {
 
2105   $lxdebug->enter_sub();
 
2107   AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
 
2108   list_buchungsgruppe();
 
2110   $lxdebug->leave_sub();
 
2115   $lxdebug->enter_sub();
 
2117   $form->{title} = "Add";
 
2120     "$form->{script}?action=add_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
2121     unless $form->{callback};
 
2126   $lxdebug->leave_sub();
 
2130   $lxdebug->enter_sub();
 
2132   $form->{title} = "Edit";
 
2134   AM->get_printer(\%myconfig, \%$form);
 
2138   $form->{orphaned} = 1;
 
2141   $lxdebug->leave_sub();
 
2145   $lxdebug->enter_sub();
 
2147   AM->printer(\%myconfig, \%$form);
 
2150     "$form->{script}?action=list_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
2152   $callback = $form->escape($form->{callback});
 
2154   $form->{title} = $locale->text('Printer');
 
2156   @column_index = qw(printer_description printer_command template_code);
 
2158   $column_header{printer_description} =
 
2159       qq|<th class=listheading width=60%>|
 
2160     . $locale->text('Printer Description')
 
2162   $column_header{printer_command} =
 
2163       qq|<th class=listheading width=10%>|
 
2164     . $locale->text('Printer Command')
 
2166   $column_header{template_code} =
 
2167       qq|<th class=listheading>|
 
2168     . $locale->text('Template Code')
 
2178     <th class=listtop>$form->{title}</th>
 
2180   <tr height="5"></tr>
 
2184         <tr class=listheading>
 
2187   map { print "$column_header{$_}\n" } @column_index;
 
2193   foreach $ref (@{ $form->{ALL} }) {
 
2199         <tr valign=top class=listrow$i>
 
2203     $column_data{printer_description} =
 
2204       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>|;
 
2205     $column_data{printer_command}           = qq|<td align=right>$ref->{printer_command}</td>|;
 
2206     $column_data{template_code} =
 
2207       qq|<td align=right>$ref->{template_code}</td>|;
 
2209     map { print "$column_data{$_}\n" } @column_index;
 
2221   <td><hr size=3 noshade></td>
 
2226 <form method=post action=$form->{script}>
 
2228 <input name=callback type=hidden value="$form->{callback}">
 
2230 <input type=hidden name=type value=printer>
 
2232 <input type=hidden name=path value=$form->{path}>
 
2233 <input type=hidden name=login value=$form->{login}>
 
2234 <input type=hidden name=password value=$form->{password}>
 
2236 <input class=submit type=submit name=action value="|
 
2237     . $locale->text('Add') . qq|">
 
2245   $lxdebug->leave_sub();
 
2248 sub printer_header {
 
2249   $lxdebug->enter_sub();
 
2251   $form->{title}    = $locale->text("$form->{title} Printer");
 
2253   # $locale->text('Add Printer')
 
2254   # $locale->text('Edit Printer')
 
2256   $form->{printer_description} =~ s/\"/"/g;
 
2257   $form->{template_code} =~ s/\"/"/g;
 
2258   $form->{printer_command} =~ s/\"/"/g;
 
2266 <form method=post action=$form->{script}>
 
2268 <input type=hidden name=id value=$form->{id}>
 
2269 <input type=hidden name=type value=printer>
 
2273     <th class=listtop colspan=2>$form->{title}</th>
 
2275   <tr height="5"></tr>
 
2277     <th align=right>| . $locale->text('Printer') . qq|</th>
 
2278     <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
 
2281     <th align=right>| . $locale->text('Printer Command') . qq|</th>
 
2282     <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
 
2285     <th align=right>| . $locale->text('Template Code') . qq|</th>
 
2286     <td><input name=template_code size=5 value="$form->{template_code}"></td>
 
2288   <td colspan=2><hr size=3 noshade></td>
 
2293   $lxdebug->leave_sub();
 
2297   $lxdebug->enter_sub();
 
2299   $form->isblank("printer_description", $locale->text('Description missing!'));
 
2300   $form->isblank("printer_command", $locale->text('Printer Command missing!'));
 
2301   AM->save_printer(\%myconfig, \%$form);
 
2302   $form->redirect($locale->text('Printer saved!'));
 
2304   $lxdebug->leave_sub();
 
2307 sub delete_printer {
 
2308   $lxdebug->enter_sub();
 
2310   AM->delete_printer(\%myconfig, \%$form);
 
2311   $form->redirect($locale->text('Printer deleted!'));
 
2313   $lxdebug->leave_sub();
 
2318   $lxdebug->enter_sub();
 
2320   $form->{title} = "Add";
 
2323     "$form->{script}?action=add_payment&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
2324     unless $form->{callback};
 
2326   $form->{terms_netto} = 0;
 
2327   $form->{terms_skonto} = 0;
 
2328   $form->{percent_skonto} = 0;
 
2332   $lxdebug->leave_sub();
 
2336   $lxdebug->enter_sub();
 
2338   $form->{title} = "Edit";
 
2340   AM->get_payment(\%myconfig, \%$form);
 
2341   $form->{percent_skonto} =
 
2342     $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
 
2346   $form->{orphaned} = 1;
 
2349   $lxdebug->leave_sub();
 
2353   $lxdebug->enter_sub();
 
2355   AM->payment(\%myconfig, \%$form);
 
2357   $form->{callback} = build_std_url("action=list_payment");
 
2359   $callback = $form->escape($form->{callback});
 
2361   $form->{title} = $locale->text('Payment Terms');
 
2363   @column_index = qw(up down description description_long terms_netto
 
2364                      terms_skonto percent_skonto);
 
2366   $column_header{up} =
 
2367       qq|<th class="listheading" align="center" valign="center">|
 
2368     . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
 
2370   $column_header{down} =
 
2371       qq|<th class="listheading" align="center" valign="center">|
 
2372     . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
 
2374   $column_header{description} =
 
2375       qq|<th class=listheading>|
 
2376     . $locale->text('Description')
 
2378   $column_header{description_long} =
 
2379       qq|<th class=listheading>|
 
2380     . $locale->text('Long Description')
 
2382   $column_header{terms_netto} =
 
2383       qq|<th class=listheading>|
 
2384     . $locale->text('Netto Terms')
 
2386   $column_header{terms_skonto} =
 
2387       qq|<th class=listheading>|
 
2388     . $locale->text('Skonto Terms')
 
2390   $column_header{percent_skonto} =
 
2391       qq|<th class=listheading>|
 
2392     . $locale->text('Skonto')
 
2402     <th class=listtop>$form->{title}</th>
 
2404   <tr height="5"></tr>
 
2408         <tr class=listheading>
 
2411   map { print "$column_header{$_}\n" } @column_index;
 
2417   my $swap_link = build_std_url("action=swap_payment_terms");
 
2420   foreach $ref (@{ $form->{ALL} }) {
 
2426         <tr valign=top class=listrow$i>
 
2430       my $pref = $form->{ALL}->[$row - 1];
 
2432         qq|<td align="center" valign="center">| .
 
2433         qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
 
2434         qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">| .
 
2437       $column_data{up} = qq|<td> </td>|;
 
2440     if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
 
2441       $column_data{down} = qq|<td> </td>|;
 
2443       my $nref = $form->{ALL}->[$row + 1];
 
2444       $column_data{down} =
 
2445         qq|<td align="center" valign="center">| .
 
2446         qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
 
2447         qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">| .
 
2451     $column_data{description} =
 
2453       build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
 
2454       qq|">| . H($ref->{description}) . qq|</a></td>|;
 
2455     $column_data{description_long} =
 
2456       qq|<td align=right>| . H($ref->{description_long}) . qq|</td>|;
 
2457     $column_data{terms_netto} =
 
2458       qq|<td align=right>$ref->{terms_netto}</td>|;
 
2459     $column_data{terms_skonto} =
 
2460       qq|<td align=right>$ref->{terms_skonto}</td>|;
 
2461     $column_data{percent_skonto} =
 
2462       qq|<td align=right>| .
 
2463       $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
 
2465     map { print "$column_data{$_}\n" } @column_index;
 
2478   <td><hr size=3 noshade></td>
 
2483 <form method=post action=$form->{script}>
 
2485 <input name=callback type=hidden value="$form->{callback}">
 
2487 <input type=hidden name=type value=payment>
 
2489 <input type=hidden name=path value=$form->{path}>
 
2490 <input type=hidden name=login value=$form->{login}>
 
2491 <input type=hidden name=password value=$form->{password}>
 
2493 <input class=submit type=submit name=action value="|
 
2494     . $locale->text('Add') . qq|">
 
2502   $lxdebug->leave_sub();
 
2505 sub payment_header {
 
2506   $lxdebug->enter_sub();
 
2508   $form->{title}    = $locale->text("$form->{title} Payment Terms");
 
2510   # $locale->text('Add Payment Terms')
 
2511   # $locale->text('Edit Payment Terms')
 
2513   $form->{description} =~ s/\"/"/g;
 
2522 <form method=post action=$form->{script}>
 
2524 <input type=hidden name=id value=$form->{id}>
 
2525 <input type=hidden name=type value=payment>
 
2529     <th class=listtop colspan=2>$form->{title}</th>
 
2531   <tr height="5"></tr>
 
2533     <th align=right>| . $locale->text('Description') . qq|</th>
 
2534     <td><input name=description size=30 value="$form->{description}"></td>
 
2537     <th align=right>| . $locale->text('Long Description') . qq|</th>
 
2538     <td><input name=description_long size=50 value="$form->{description_long}"></td>
 
2541     <th align=right>| . $locale->text('Netto Terms') . qq|</th>
 
2542     <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
 
2545     <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
 
2546     <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
 
2549     <th align=right>| . $locale->text('Skonto') . qq| %</th>
 
2550     <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
 
2552   <td colspan=2><hr size=3 noshade></td>
 
2557   $lxdebug->leave_sub();
 
2561   $lxdebug->enter_sub();
 
2563   $form->isblank("description", $locale->text('Description missing!'));
 
2564   $form->{"percent_skonto"} =
 
2565     $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
 
2566   AM->save_payment(\%myconfig, \%$form);
 
2567   $form->redirect($locale->text('Payment Terms saved!'));
 
2569   $lxdebug->leave_sub();
 
2572 sub delete_payment {
 
2573   $lxdebug->enter_sub();
 
2575   AM->delete_payment(\%myconfig, \%$form);
 
2576   $form->redirect($locale->text('Payment terms deleted!'));
 
2578   $lxdebug->leave_sub();
 
2581 sub swap_payment_terms {
 
2582   $lxdebug->enter_sub();
 
2584   AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
 
2587   $lxdebug->leave_sub();
 
2591   $lxdebug->enter_sub();
 
2593   $form->{title} = "Add";
 
2596     "$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
2597     unless $form->{callback};
 
2602   $lxdebug->leave_sub();
 
2606   $lxdebug->enter_sub();
 
2608   $form->{title} = "Edit";
 
2610   AM->get_sic(\%myconfig, \%$form);
 
2614   $form->{orphaned} = 1;
 
2617   $lxdebug->leave_sub();
 
2621   $lxdebug->enter_sub();
 
2623   AM->sic(\%myconfig, \%$form);
 
2626     "$form->{script}?action=list_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
2628   $callback = $form->escape($form->{callback});
 
2630   $form->{title} = $locale->text('Standard Industrial Codes');
 
2632   @column_index = qw(code description);
 
2634   $column_header{code} =
 
2635     qq|<th class=listheading>| . $locale->text('Code') . qq|</th>|;
 
2636   $column_header{description} =
 
2637     qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
 
2646     <th class=listtop>$form->{title}</th>
 
2648   <tr height="5"></tr>
 
2652         <tr class=listheading>
 
2655   map { print "$column_header{$_}\n" } @column_index;
 
2661   foreach $ref (@{ $form->{ALL} }) {
 
2666     if ($ref->{sictype} eq 'H') {
 
2668         <tr valign=top class=listheading>
 
2670       $column_data{code} =
 
2671         qq|<th><a href=$form->{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{code}</th>|;
 
2672       $column_data{description} = qq|<th>$ref->{description}</th>|;
 
2676         <tr valign=top class=listrow$i>
 
2679       $column_data{code} =
 
2680         qq|<td><a href=$form->{script}?action=edit_sic&code=$ref->{code}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{code}</td>|;
 
2681       $column_data{description} = qq|<td>$ref->{description}</td>|;
 
2685     map { print "$column_data{$_}\n" } @column_index;
 
2697   <td><hr size=3 noshade></td>
 
2702 <form method=post action=$form->{script}>
 
2704 <input name=callback type=hidden value="$form->{callback}">
 
2706 <input type=hidden name=type value=sic>
 
2708 <input type=hidden name=path value=$form->{path}>
 
2709 <input type=hidden name=login value=$form->{login}>
 
2710 <input type=hidden name=password value=$form->{password}>
 
2712 <input class=submit type=submit name=action value="|
 
2713     . $locale->text('Add') . qq|">
 
2721   $lxdebug->leave_sub();
 
2725   $lxdebug->enter_sub();
 
2727   $form->{title} = $locale->text("$form->{title} SIC");
 
2729   # $locale->text('Add SIC')
 
2730   # $locale->text('Edit SIC')
 
2732   $form->{code}        =~ s/\"/"/g;
 
2733   $form->{description} =~ s/\"/"/g;
 
2735   $checked = ($form->{sictype} eq 'H') ? "checked" : "";
 
2742 <form method=post action=$form->{script}>
 
2744 <input type=hidden name=type value=sic>
 
2745 <input type=hidden name=id value=$form->{code}>
 
2749     <th class=listtop colspan=2>$form->{title}</th>
 
2751   <tr height="5"></tr>
 
2753     <th align=right>| . $locale->text('Code') . qq|</th>
 
2754     <td><input name=code size=10 value=$form->{code}></td>
 
2758     <th align=left><input name=sictype type=checkbox style=checkbox value="H" $checked> |
 
2759     . $locale->text('Heading') . qq|</th>
 
2762     <th align=right>| . $locale->text('Description') . qq|</th>
 
2763     <td><input name=description size=60 value="$form->{description}"></td>
 
2765     <td colspan=2><hr size=3 noshade></td>
 
2770   $lxdebug->leave_sub();
 
2774   $lxdebug->enter_sub();
 
2776   $form->isblank("code",        $locale->text('Code missing!'));
 
2777   $form->isblank("description", $locale->text('Description missing!'));
 
2778   AM->save_sic(\%myconfig, \%$form);
 
2779   $form->redirect($locale->text('SIC saved!'));
 
2781   $lxdebug->leave_sub();
 
2785   $lxdebug->enter_sub();
 
2787   AM->delete_sic(\%myconfig, \%$form);
 
2788   $form->redirect($locale->text('SIC deleted!'));
 
2790   $lxdebug->leave_sub();
 
2793 sub display_stylesheet {
 
2794   $lxdebug->enter_sub();
 
2796   $form->{file} = "css/$myconfig{stylesheet}";
 
2799   $lxdebug->leave_sub();
 
2803   $lxdebug->enter_sub();
 
2805   $form->{file} =~ s/^(.:)*?\/|\.\.\///g;
 
2806   $form->{file} =~ s/^\/*//g;
 
2807   $form->{file} =~ s/$userspath//;
 
2809   $form->error("$!: $form->{file}") unless -f $form->{file};
 
2811   AM->load_template(\%$form);
 
2813   $form->{title} = $form->{file};
 
2815   # if it is anything but html
 
2816   if ($form->{file} !~ /\.html$/) {
 
2817     $form->{body} = "<pre>\n$form->{body}\n</pre>";
 
2827 <form method=post action=$form->{script}>
 
2829 <input name=file type=hidden value=$form->{file}>
 
2830 <input name=type type=hidden value=template>
 
2832 <input type=hidden name=path value=$form->{path}>
 
2833 <input type=hidden name=login value=$form->{login}>
 
2834 <input type=hidden name=password value=$form->{password}>
 
2836 <input name=action type=submit class=submit value="|
 
2837     . $locale->text('Edit') . qq|">
 
2845   $lxdebug->leave_sub();
 
2849   $lxdebug->enter_sub();
 
2851   AM->load_template(\%$form);
 
2853   $form->{title} = $locale->text('Edit Template');
 
2855   # convert   to &nbsp;
 
2856   $form->{body} =~ s/ /&nbsp;/gi;
 
2863 <form method=post action=$form->{script}>
 
2865 <input name=file type=hidden value=$form->{file}>
 
2866 <input name=type type=hidden value=template>
 
2868 <input type=hidden name=path value=$form->{path}>
 
2869 <input type=hidden name=login value=$form->{login}>
 
2870 <input type=hidden name=password value=$form->{password}>
 
2872 <input name=callback type=hidden value="$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}&password=$form->{password}">
 
2874 <textarea name=body rows=25 cols=70>
 
2879 <input type=submit class=submit name=action value="|
 
2880     . $locale->text('Save') . qq|">
 
2889   $lxdebug->leave_sub();
 
2893   $lxdebug->enter_sub();
 
2895   AM->save_template(\%$form);
 
2896   $form->redirect($locale->text('Template saved!'));
 
2898   $lxdebug->leave_sub();
 
2902   $lxdebug->enter_sub();
 
2904   # get defaults for account numbers and last numbers
 
2905   AM->defaultaccounts(\%myconfig, \%$form);
 
2907   foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
 
2909       ($item eq $myconfig{dateformat})
 
2910       ? "<option selected>$item\n"
 
2911       : "<option>$item\n";
 
2914   foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
 
2916       ($item eq $myconfig{numberformat})
 
2917       ? "<option selected>$item\n"
 
2918       : "<option>$item\n";
 
2921   foreach $item (qw(name company address signature)) {
 
2922     $myconfig{$item} =~ s/\"/"/g;
 
2925   foreach $item (qw(address signature)) {
 
2926     $myconfig{$item} =~ s/\\n/\r\n/g;
 
2930   if ($opendocument_templates && $openofficeorg_writer_bin &&
 
2931       $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
 
2932     push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
 
2933                      "value" => "opendocument_pdf" });
 
2935   if ($latex_templates) {
 
2936     push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
 
2938   push(@formats, { "name" => "HTML", "value" => "html" });
 
2939   if ($latex_templates) {
 
2940     push(@formats, { "name" => $locale->text("Postscript"),
 
2941                      "value" => "postscript" });
 
2943   if ($opendocument_templates) {
 
2944     push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
 
2945                      "value" => "opendocument" });
 
2948   if (!$myconfig{"template_format"}) {
 
2949     $myconfig{"template_format"} = "pdf";
 
2951   my $template_format = "";
 
2952   foreach $item (@formats) {
 
2954       "<option value=\"$item->{value}\"" .
 
2955       ($item->{"value"} eq $myconfig{"template_format"} ?
 
2957        ">" . H($item->{"name"}) . "</option>";
 
2960   if (!$myconfig{"default_media"}) {
 
2961     $myconfig{"default_media"} = "screen";
 
2963   my %selected = ($myconfig{"default_media"} => "selected");
 
2964   my $default_media = qq|
 
2965   <option value="screen" $selected{'screen'}>| . $locale->text("Screen") . qq|</option>
 
2966   <option value="printer" $selected{'printer'}>| . $locale->text("Printer") . qq|</option>
 
2967   <option value="queue" $selected{'queue'}>| . $locale->text("Queue") . qq|</option>
 
2971   $selected{$myconfig{"default_printer_id"}} = "selected"
 
2972     if ($myconfig{"default_printer_id"});
 
2973   my $default_printer = qq|<option></option>|;
 
2974   AM->printer(\%myconfig, $form);
 
2975   foreach my $printer (@{$form->{"ALL"}}) {
 
2976     $default_printer .= qq|<option value="| . Q($printer->{"id"}) .
 
2977       qq|" $selected{$printer->{'id'}}>| .
 
2978       H($printer->{"printer_description"}) . qq|</option>|;
 
2981   %countrycodes = User->country_codes;
 
2983   foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
 
2987       ($myconfig{countrycode} eq $key)
 
2988       ? "<option selected value=$key>$countrycodes{$key}\n"
 
2989       : "<option value=$key>$countrycodes{$key}\n";
 
2991   $countrycodes = "<option>American English\n$countrycodes";
 
2993   # use an other input number format than output numberformat
 
2994   # look at Form.pm, sub parse_amount
 
2995   my $in_numberformat = '';
 
2996   $text1 = qq|value="0">| . $locale->text('equal Outputformat');
 
2997   $text2 = qq|value="1">| . $locale->text('1000,00 or 1000.00');
 
2998   @in_nf = ($text1, $text2);
 
2999   foreach $item (@in_nf) {
 
3001       (substr($item, 7, 1) eq $myconfig{in_numberformat})
 
3002       ? "<option selected $item\n"
 
3003       : "<option $item\n";
 
3006   foreach $key (keys %{ $form->{IC} }) {
 
3007     foreach $accno (sort keys %{ $form->{IC}{$key} }) {
 
3009         ($form->{IC}{$key}{$accno}{id} == $form->{defaults}{$key})
 
3010         ? "<option selected>$accno--$form->{IC}{$key}{$accno}{description}\n"
 
3011         : "<option>$accno--$form->{IC}{$key}{$accno}{description}\n";
 
3015   opendir CSS, "css/.";
 
3016   @all = grep /.*\.css$/, readdir CSS;
 
3019   foreach $item (@all) {
 
3020     if ($item eq $myconfig{stylesheet}) {
 
3021       $selectstylesheet .= qq|<option selected>$item\n|;
 
3023       $selectstylesheet .= qq|<option>$item\n|;
 
3026   $selectstylesheet .= "<option>\n";
 
3028   $form->{title} = $locale->text('Edit Preferences for') . qq| $form->{login}|;
 
3032   if ($myconfig{menustyle} eq "old") {
 
3033     $menustyle_old = "checked";
 
3034   } elsif ($myconfig{menustyle} eq "neu") {
 
3035     $menustyle_neu = "checked";
 
3036   } elsif ($myconfig{menustyle} eq "v3") {
 
3037     $menustyle_v3 = "checked";
 
3040   my ($show_form_details, $hide_form_details);
 
3041   $myconfig{"show_form_details"} = 1
 
3042     unless (defined($myconfig{"show_form_details"}));
 
3043   $show_form_details = "checked" if ($myconfig{"show_form_details"});
 
3044   $hide_form_details = "checked" unless ($myconfig{"show_form_details"});
 
3049 <form method=post action=$form->{script}>
 
3051 <input type=hidden name=old_password value=$myconfig{password}>
 
3052 <input type=hidden name=type value=preferences>
 
3053 <input type=hidden name=role value=$myconfig{role}>
 
3056   <tr><th class=listtop>$form->{title}</th></tr>
 
3061           <th align=right>| . $locale->text('Name') . qq|</th>
 
3062           <td><input name=name size=15 value="$myconfig{name}"></td>
 
3065           <th align=right>| . $locale->text('Password') . qq|</th>
 
3066           <td><input type=password name=new_password size=10 value=$myconfig{password}></td>
 
3069           <th align=right>| . $locale->text('E-mail') . qq|</th>
 
3070           <td><input name=email size=30 value="$myconfig{email}"></td>
 
3073           <th align=right>| . $locale->text('Signature') . qq|</th>
 
3074           <td><textarea name=signature rows=3 cols=50>$myconfig{signature}</textarea></td>
 
3077           <th align=right>| . $locale->text('Phone') . qq|</th>
 
3078           <td><input name=tel size=14 value="$myconfig{tel}"></td>
 
3081           <th align=right>| . $locale->text('Fax') . qq|</th>
 
3082           <td><input name=fax size=14 value="$myconfig{fax}"></td>
 
3085           <th align=right>| . $locale->text('Company') . qq|</th>
 
3086           <td><input name=company size=30 value="$myconfig{company}"></td>
 
3089           <th align=right>| . $locale->text('Address') . qq|</th>
 
3090           <td><textarea name=address rows=4 cols=50>$myconfig{address}</textarea></td>
 
3093           <th align=right>| . $locale->text('Date Format') . qq|</th>
 
3094           <td><select name=dateformat>$dateformat</select></td>
 
3097           <th align=right>| . $locale->text('Output Number Format') . qq|</th>
 
3098           <td><select name=numberformat>$numberformat</select></td>
 
3101           <th align=right>| . $locale->text('Input Number Format') . qq|</th>
 
3102           <td><select name=in_numberformat>$in_numberformat</select></td>
 
3106           <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
 
3107           <td><input name=vclimit size=10 value="$myconfig{vclimit}"></td>
 
3110           <th align=right>| . $locale->text('Language') . qq|</th>
 
3111           <td><select name=countrycode>$countrycodes</select></td>
 
3114           <th align=right>| . $locale->text('Stylesheet') . qq|</th>
 
3115           <td><select name=usestylesheet>$selectstylesheet</select></td>
 
3118           <th align=right>| . $locale->text('Setup Menu') . qq|</th>
 
3119           <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
 
3120     $locale->text("Top (CSS)") . qq|
 
3121           <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
 
3122     $locale->text("Top (Javascript)") . qq|
 
3123     <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
 
3124     $locale->text("Old (on the side)") . qq|</td>
 
3127     <th align=right>| . $locale->text('Form details (second row)') . qq|</th>
 
3128     <td><input type="radio" id="rad_show_form_details" name="show_form_details" value="1" $show_form_details> 
 
3129     <label for="rad_show_form_details">| . $locale->text('Show by default') . qq|</label>
 
3130     <input type="radio" id="rad_hide_form_details" name="show_form_details" value="0" $hide_form_details> 
 
3131     <label for="rad_hide_form_details">| . $locale->text('Hide by default') . qq|</label></td>
 
3133         <input name=printer type=hidden value="$myconfig{printer}">
 
3134         <tr class=listheading>
 
3135           <th colspan=2>| . $locale->text("Print options") . qq|</th>
 
3138           <th align=right>| . $locale->text('Default template format') . qq|</th>
 
3139           <td><select name="template_format">$template_format</select></td>
 
3142           <th align=right>| . $locale->text('Default output medium') . qq|</th>
 
3143           <td><select name="default_media">$default_media</select></td>
 
3146           <th align=right>| . $locale->text('Default printer') . qq|</th>
 
3147           <td><select name="default_printer_id">$default_printer</select></td>
 
3150           <th align=right>| . $locale->text('Number of copies') . qq|</th>
 
3151           <td><input name="copies" size="10" value="| .
 
3152     $form->quote($myconfig{"copies"}) . qq|"></td>
 
3156         <tr class=listheading>
 
3157           <th colspan=2> </th>
 
3160           <th align=right>| . $locale->text('Business Number') . qq|</th>
 
3161           <td><input name=businessnumber size=25 value="$myconfig{businessnumber}"></td>
 
3164                 <th align=right>| . $locale->text('Year End') . qq| (mm/dd)</th>
 
3165                 <td><input name=yearend size=5 value=$form->{defaults}{yearend}></td>
 
3167         <tr class=listheading>
 
3169     . $locale->text('Last Numbers & Default Accounts') . qq|</th>
 
3175                 <th align=right nowrap>| . $locale->text('Inventory Account') . qq|</th>
 
3176                 <td><select name=inventory_accno>$myconfig{IC}</select></td>
 
3179                 <th align=right nowrap>| . $locale->text('Revenue Account') . qq|</th>
 
3180                 <td><select name=income_accno>$myconfig{IC_income}</select></td>
 
3183                 <th align=right nowrap>| . $locale->text('Expense Account') . qq|</th>
 
3184                 <td><select name=expense_accno>$myconfig{IC_expense}</select></td>
 
3187                 <th align=right nowrap>| . $locale->text('Foreign Exchange Gain') . qq|</th>
 
3188                 <td><select name=fxgain_accno>$myconfig{FX_gain}</select></td>
 
3191                 <th align=right nowrap>| . $locale->text('Foreign Exchange Loss') . qq|</th>
 
3192                 <td><select name=fxloss_accno>$myconfig{FX_loss}</select></td>
 
3197     'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies'
 
3199     . qq|<br><input name=curr size=40 value="$form->{defaults}{curr}"></td>
 
3208                 <th align=right nowrap>| . $locale->text('Last Invoice Number') . qq|</th>
 
3209                 <td><input name=invnumber size=10 value=$form->{defaults}{invnumber}></td>
 
3210                 <th align=right nowrap>|
 
3211     . $locale->text('Last Customer Number') . qq|</th>
 
3212                 <td><input name=customernumber size=10 value=$form->{defaults}{customernumber}></td>
 
3215                 <th align=right nowrap>|
 
3216     . $locale->text('Last Credit Note Number') . qq|</th>
 
3217                 <td><input name=cnnumber size=10 value=$form->{defaults}{cnnumber}></td>
 
3218                 <th align=right nowrap>|
 
3219     . $locale->text('Last Vendor Number') . qq|</th>
 
3220                 <td><input name=vendornumber size=10 value=$form->{defaults}{vendornumber}></td>
 
3223                 <th align=right nowrap>|
 
3224     . $locale->text('Last Sales Order Number') . qq|</th>
 
3225                 <td><input name=sonumber size=10 value=$form->{defaults}{sonumber}></td>
 
3228                 <th align=right nowrap>|
 
3229     . $locale->text('Last Purchase Order Number') . qq|</th>
 
3230                 <td><input name=ponumber size=10 value=$form->{defaults}{ponumber}></td>
 
3231                 <th align=right nowrap>|
 
3232     . $locale->text('Last Article Number') . qq|</th>
 
3233                 <td><input name=articlenumber size=10 value=$form->{defaults}{articlenumber}></td>
 
3236                 <th align=right nowrap>|
 
3237     . $locale->text('Last Sales Quotation Number') . qq|</th>
 
3238                 <td><input name=sqnumber size=10 value=$form->{defaults}{sqnumber}></td>
 
3239                 <th align=right nowrap>|
 
3240     . $locale->text('Last Service Number') . qq|</th>
 
3241                 <td><input name=servicenumber size=10 value=$form->{defaults}{servicenumber}></td>
 
3244                 <th align=right nowrap>| . $locale->text('Last RFQ Number') . qq|</th>
 
3245                 <td><input name=rfqnumber size=10 value=$form->{defaults}{rfqnumber}></td>
 
3246                 <th align=right nowrap></th>
 
3252 #       <tr class=listheading>
 
3253 #         <th colspan=2>| . $locale->text('Tax Accounts') . qq|</th>
 
3260 #               <th>| . $locale->text('Rate') . qq| (%)</th>
 
3261 #               <th>| . $locale->text('Number') . qq|</th>
 
3265 #   foreach $accno (sort keys %{ $form->{taxrates} }) {
 
3268 #               <th align=right>$form->{taxrates}{$accno}{description}</th>
 
3269 #               <td><input name=$form->{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}></td>
 
3270 #               <td><input name="taxnumber_$form->{taxrates}{$accno}{id}" value="$form->{taxrates}{$accno}{taxnumber}"></td>
 
3273 #     $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} ";
 
3276 #   chop $form->{taxaccounts};
 
3279 # <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
 
3288     <td><hr size=3 noshade></td>
 
3292 <input type=hidden name=path value=$form->{path}>
 
3293 <input type=hidden name=login value=$form->{login}>
 
3294 <input type=hidden name=password value=$form->{password}>
 
3297 <input type=submit class=submit name=action value="|
 
3298     . $locale->text('Save') . qq|">
 
3306   $lxdebug->leave_sub();
 
3309 sub save_preferences {
 
3310   $lxdebug->enter_sub();
 
3312   $form->{stylesheet} = $form->{usestylesheet};
 
3314   $form->redirect($locale->text('Preferences saved!'))
 
3316      AM->save_preferences(\%myconfig, \%$form, $memberfile, $userspath, $webdav
 
3318   $form->error($locale->text('Cannot save preferences!'));
 
3320   $lxdebug->leave_sub();
 
3324   $lxdebug->enter_sub();
 
3326   if ($form->{media} eq 'email') {
 
3327     $form->error($locale->text('No email address for') . " $myconfig{name}")
 
3328       unless ($myconfig{email});
 
3330     $form->{OUT} = "$sendmail";
 
3334   AM->backup(\%myconfig, \%$form, $userspath);
 
3336   if ($form->{media} eq 'email') {
 
3337     $form->redirect($locale->text('Backup sent to') . qq| $myconfig{email}|);
 
3340   $lxdebug->leave_sub();
 
3344   $lxdebug->enter_sub();
 
3346   $form->{title} = $locale->text('Audit Control');
 
3348   AM->closedto(\%myconfig, \%$form);
 
3350   if ($form->{revtrans}) {
 
3351     $checked{Y} = "checked";
 
3353     $checked{N} = "checked";
 
3361 <form method=post action=$form->{script}>
 
3363 <input type=hidden name=path value=$form->{path}>
 
3364 <input type=hidden name=login value=$form->{login}>
 
3365 <input type=hidden name=password value=$form->{password}>
 
3368   <tr><th class=listtop>$form->{title}</th></tr>
 
3369   <tr height="5"></tr>
 
3375     . $locale->text('Enforce transaction reversal for all dates') . qq|</th>
 
3376           <td><input name=revtrans class=radio type=radio value="1" $checked{Y}> |
 
3377     . $locale->text('Yes')
 
3378     . qq| <input name=revtrans class=radio type=radio value="0" $checked{N}> |
 
3379     . $locale->text('No')
 
3383           <th>| . $locale->text('Close Books up to') . qq|</th>
 
3384           <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
 
3394 <input type=hidden name=nextsub value=doclose>
 
3396 <input type=submit class=submit name=action value="|
 
3397     . $locale->text('Continue') . qq|">
 
3405   $lxdebug->leave_sub();
 
3409   $lxdebug->enter_sub();
 
3411   AM->closebooks(\%myconfig, \%$form);
 
3413   if ($form->{revtrans}) {
 
3415                  $locale->text('Transaction reversal enforced for all dates'));
 
3417     if ($form->{closedto}) {
 
3419                      $locale->text('Transaction reversal enforced up to') . " "
 
3420                        . $locale->date(\%myconfig, $form->{closedto}, 1));
 
3422       $form->redirect($locale->text('Books are open'));
 
3426   $lxdebug->leave_sub();
 
3430   $lxdebug->enter_sub();
 
3432   $form->{title} = "Add";
 
3435     "$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
3436     unless $form->{callback};
 
3441   $lxdebug->leave_sub();
 
3444 sub edit_warehouse {
 
3445   $lxdebug->enter_sub();
 
3447   $form->{title} = "Edit";
 
3449   AM->get_warehouse(\%myconfig, \%$form);
 
3454   $lxdebug->leave_sub();
 
3457 sub list_warehouse {
 
3458   $lxdebug->enter_sub();
 
3460   AM->warehouses(\%myconfig, \%$form);
 
3463     "$form->{script}?action=list_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
3465   $callback = $form->escape($form->{callback});
 
3467   $form->{title} = $locale->text('Warehouses');
 
3469   @column_index = qw(description);
 
3471   $column_header{description} =
 
3472       qq|<th class=listheading width=100%>|
 
3473     . $locale->text('Description')
 
3483     <th class=listtop>$form->{title}</th>
 
3485   <tr height="5"></tr>
 
3489         <tr class=listheading>
 
3492   map { print "$column_header{$_}\n" } @column_index;
 
3498   foreach $ref (@{ $form->{ALL} }) {
 
3504         <tr valign=top class=listrow$i>
 
3507     $column_data{description} =
 
3508       qq|<td><a href=$form->{script}?action=edit_warehouse&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
 
3510     map { print "$column_data{$_}\n" } @column_index;
 
3522   <td><hr size=3 noshade></td>
 
3527 <form method=post action=$form->{script}>
 
3529 <input name=callback type=hidden value="$form->{callback}">
 
3531 <input type=hidden name=type value=warehouse>
 
3533 <input type=hidden name=path value=$form->{path}>
 
3534 <input type=hidden name=login value=$form->{login}>
 
3535 <input type=hidden name=password value=$form->{password}>
 
3537 <input class=submit type=submit name=action value="|
 
3538     . $locale->text('Add') . qq|">
 
3546   $lxdebug->leave_sub();
 
3549 sub warehouse_header {
 
3550   $lxdebug->enter_sub();
 
3552   $form->{title} = $locale->text("$form->{title} Warehouse");
 
3554   # $locale->text('Add Warehouse')
 
3555   # $locale->text('Edit Warehouse')
 
3557   $form->{description} =~ s/\"/"/g;
 
3559   if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
 
3561       qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
 
3564       qq|<input name=description size=60 value="$form->{description}">|;
 
3572 <form method=post action=$form->{script}>
 
3574 <input type=hidden name=id value=$form->{id}>
 
3575 <input type=hidden name=type value=warehouse>
 
3579     <th class=listtop colspan=2>$form->{title}</th>
 
3581   <tr height="5"></tr>
 
3583     <th align=right>| . $locale->text('Description') . qq|</th>
 
3584     <td>$description</td>
 
3587     <td colspan=2><hr size=3 noshade></td>
 
3592   $lxdebug->leave_sub();
 
3595 sub save_warehouse {
 
3596   $lxdebug->enter_sub();
 
3598   $form->isblank("description", $locale->text('Description missing!'));
 
3599   AM->save_warehouse(\%myconfig, \%$form);
 
3600   $form->redirect($locale->text('Warehouse saved!'));
 
3602   $lxdebug->leave_sub();
 
3605 sub delete_warehouse {
 
3606   $lxdebug->enter_sub();
 
3608   AM->delete_warehouse(\%myconfig, \%$form);
 
3609   $form->redirect($locale->text('Warehouse deleted!'));
 
3611   $lxdebug->leave_sub();
 
3615   $lxdebug->enter_sub();
 
3617   &{ $form->{nextsub} };
 
3619   $lxdebug->leave_sub();
 
3623   $lxdebug->enter_sub();
 
3625   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
 
3626   AM->units_in_use(\%myconfig, $form, $units);
 
3627   map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
 
3629   @languages = AM->language(\%myconfig, $form, 1);
 
3632   foreach $name (sort({ lc($a) cmp lc($b) } grep({ !$units->{$_}->{"base_unit"} } keys(%{$units})))) {
 
3633     map({ push(@unit_list, $units->{$_}); }
 
3634         sort({ ($units->{$a}->{"resolved_factor"} * 1) <=> ($units->{$b}->{"resolved_factor"} * 1) }
 
3635              grep({ $units->{$_}->{"resolved_base_unit"} eq $name } keys(%{$units}))));
 
3638   foreach (@unit_list) {
 
3639     $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"}, 5) if ($_->{"factor"});
 
3640     $_->{"UNITLANGUAGES"} = [];
 
3641     foreach my $lang (@languages) {
 
3642       push(@{ $_->{"UNITLANGUAGES"} },
 
3644              "unit" => $_->{"name"},
 
3645              "language_id" => $lang->{"id"},
 
3646              "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
 
3647              "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
 
3653   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
 
3654   $ddbox = AM->unit_select_data($units, undef, 1);
 
3656   $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
 
3658   print($form->parse_html_template("am/edit_units",
 
3659                                    { "UNITS" => \@unit_list,
 
3660                                      "NEW_BASE_UNIT_DDBOX" => $ddbox,
 
3661                                      "LANGUAGES" => \@languages }));
 
3663   $lxdebug->leave_sub();
 
3667   $lxdebug->enter_sub();
 
3669   $form->isblank("new_name", $locale->text("The name is missing."));
 
3670   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
 
3671   $all_units = AM->retrieve_units(\%myconfig, $form);
 
3672   $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
 
3674   my ($base_unit, $factor);
 
3675   if ($form->{"new_base_unit"}) {
 
3676     $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
 
3678     $form->isblank("new_factor", $locale->text("The factor is missing."));
 
3679     $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
 
3680     $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
 
3681     $base_unit = $form->{"new_base_unit"};
 
3685   foreach my $lang (AM->language(\%myconfig, $form, 1)) {
 
3686     next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
 
3687     push(@languages, { "id" => $lang->{"id"},
 
3688                        "localized" => $form->{"new_localized_$lang->{id}"},
 
3689                        "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
 
3693   AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
 
3695   $form->{"saved_message"} = $locale->text("The unit has been saved.");
 
3699   $lxdebug->leave_sub();
 
3702 sub set_unit_languages {
 
3703   $lxdebug->enter_sub();
 
3705   my ($unit, $languages, $idx) = @_;
 
3707   $unit->{"LANGUAGES"} = [];
 
3709   foreach my $lang (@{$languages}) {
 
3710     push(@{ $unit->{"LANGUAGES"} },
 
3711          { "id" => $lang->{"id"},
 
3712            "localized" => $form->{"localized_${idx}_$lang->{id}"},
 
3713            "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
 
3717   $lxdebug->leave_sub();
 
3721   $lxdebug->enter_sub();
 
3723   $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
 
3724   AM->units_in_use(\%myconfig, $form, $old_units);
 
3726   @languages = AM->language(\%myconfig, $form, 1);
 
3730   foreach $i (1..($form->{"rowcount"} * 1)) {
 
3731     $old_unit = $old_units->{$form->{"old_name_$i"}};
 
3733       $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
 
3736     if ($form->{"unchangeable_$i"}) {
 
3737       $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
 
3738       $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
 
3739       set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
 
3743     if ($old_unit->{"in_use"}) {
 
3744       $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
 
3747     if ($form->{"delete_$i"}) {
 
3748       push(@delete_units, $old_unit->{"name"});
 
3752     $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
 
3754     $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
 
3755     my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
 
3756     $new_units->{$form->{"name_$i"}} = \%h;
 
3757     $new_units->{$form->{"name_$i"}}->{"row"} = $i;
 
3758     set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
 
3761   foreach $unit (values(%{$new_units})) {
 
3762     next unless ($unit->{"old_name"});
 
3763     if ($unit->{"base_unit"}) {
 
3764       $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"}))
 
3765         unless (defined($new_units->{$unit->{"base_unit"}}));
 
3766       $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
 
3767       $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
 
3769       $unit->{"base_unit"} = undef;
 
3770       $unit->{"factor"} = undef;
 
3774   foreach $unit (values(%{$new_units})) {
 
3775     next if ($unit->{"unchanged_unit"});
 
3777     map({ $_->{"seen"} = 0; } values(%{$new_units}));
 
3779     while ($new_unit->{"base_unit"}) {
 
3780       $new_unit->{"seen"} = 1;
 
3781       $new_unit = $new_units->{$new_unit->{"base_unit"}};
 
3782       if ($new_unit->{"seen"}) {
 
3783         $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, " .
 
3784                                                         "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
 
3789   AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
 
3791   $form->{"saved_message"} = $locale->text("The units have been saved.");
 
3795   $lxdebug->leave_sub();