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 #======================================================================
 
  43 require "$form->{path}/common.pl";
 
  47 sub add    { &{"add_$form->{type}"} }
 
  48 sub edit   { &{"edit_$form->{type}"} }
 
  49 sub save   { &{"save_$form->{type}"} }
 
  50 sub delete { &{"delete_$form->{type}"} }
 
  53   $lxdebug->enter_sub();
 
  55   $form->{title}     = "Add";
 
  56   $form->{charttype} = "A";
 
  57   AM->get_account(\%myconfig, \%$form);
 
  60     "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
  61     unless $form->{callback};
 
  66   $lxdebug->leave_sub();
 
  70   $lxdebug->enter_sub();
 
  72   $form->{title} = "Edit";
 
  73   AM->get_account(\%myconfig, \%$form);
 
  75   foreach my $item (split(/:/, $form->{link})) {
 
  76     $form->{$item} = "checked";
 
  82   $lxdebug->leave_sub();
 
  86   $lxdebug->enter_sub();
 
  88   $form->{title} = $locale->text("$form->{title} Account");
 
  90   $checked{ $form->{charttype} } = "checked";
 
  91   $checked{"$form->{category}_"} = "checked";
 
  92   $checked{CT_tax} = ($form->{CT_tax}) ? "" : "checked";
 
  94   $form->{description} =~ s/\"/"/g;
 
  96   if (@{ $form->{TAXKEY} }) {
 
  97     foreach $item (@{ $form->{TAXKEY} }) {
 
  98       if ($item->{tax} == $form->{tax}) {
 
  99         $form->{selecttaxkey} .=
 
 100           "<option value=$item->{tax} selected>$item->{taxdescription}\n";
 
 102         $form->{selecttaxkey} .=
 
 103           "<option value=$item->{tax}>$item->{taxdescription}\n";
 
 111                 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
 
 112                 <td><select name=tax>$form->{selecttaxkey}</select></td>
 
 113                 <th align=right>| . $locale->text('Gültig ab') . qq|</th>
 
 114                 <td><input name=startdate value="$form->{startdate}"></td>
 
 117   if (@{ $form->{NEWACCOUNT} }) {
 
 118     if (!$form->{new_chart_valid}) {
 
 119       $form->{selectnewaccount} = "<option value=></option>";
 
 121     foreach $item (@{ $form->{NEWACCOUNT} }) {
 
 122       if ($item->{id} == $form->{new_chart_id}) {
 
 123         $form->{selectnewaccount} .=
 
 124           "<option value=$item->{id} selected>$item->{accno}--$item->{description}</option>";
 
 125       } elsif (!$form->{new_chart_valid}) {
 
 126         $form->{selectnewaccount} .=
 
 127           "<option value=$item->{id}>$item->{accno}--$item->{description}</option>";
 
 138                       <th align=right>| . $locale->text('Folgekonto') . qq|</th>
 
 139                       <td><select name=new_chart_id>$form->{selectnewaccount}</select></td>
 
 140                       <th align=right>| . $locale->text('Gültig ab') . qq|</th>
 
 141                       <td><input name=valid_from value="$form->{valid_from}"></td>
 
 147   $form->{selectustva} = "<option>\n";
 
 149   %ustva = (35  => $locale->text('UStVA-Nr. 35'),
 
 150             36  => $locale->text('UStVA-Nr. 36'),
 
 151             39  => $locale->text('UStVA-Nr. 39'),
 
 152             41  => $locale->text('UStVA-Nr. 41'),
 
 153             42  => $locale->text('UStVA-Nr. 42'),
 
 154             43  => $locale->text('UStVA-Nr. 43'),
 
 155             44  => $locale->text('UStVA-Nr. 44'),
 
 156             45  => $locale->text('UStVA-Nr. 45'),
 
 157             48  => $locale->text('UStVA-Nr. 48'),
 
 158             49  => $locale->text('UStVA-Nr. 49'),
 
 159             51  => $locale->text('UStVA-Nr. 51 left'),
 
 160             511 => $locale->text('UStVA-Nr. 51 right'),
 
 161             52  => $locale->text('UStVA-Nr. 52'),
 
 162             53  => $locale->text('UStVA-Nr. 53'),
 
 163             59  => $locale->text('UStVA-Nr. 59'),
 
 164             60  => $locale->text('UStVA-Nr. 60'),
 
 165             61  => $locale->text('UStVA-Nr. 61'),
 
 166             62  => $locale->text('UStVA-Nr. 62'),
 
 167             63  => $locale->text('UStVA-Nr. 63'),
 
 168             64  => $locale->text('UStVA-Nr. 64'),
 
 169             65  => $locale->text('UStVA-Nr. 65'),
 
 170             66  => $locale->text('UStVA-Nr. 66'),
 
 171             67  => $locale->text('UStVA-Nr. 67'),
 
 172             69  => $locale->text('UStVA-Nr. 69'),
 
 173             73  => $locale->text('UStVA-Nr. 73'),
 
 174             74  => $locale->text('UStVA-Nr. 74'),
 
 175             76  => $locale->text('UStVA-Nr. 76'),
 
 176             77  => $locale->text('UStVA-Nr. 77'),
 
 177             80  => $locale->text('UStVA-Nr. 80'),
 
 178             84  => $locale->text('UStVA-Nr. 84'),
 
 179             85  => $locale->text('UStVA-Nr. 85'),
 
 180             86  => $locale->text('UStVA-Nr. 86 left'),
 
 181             861 => $locale->text('UStVA-Nr. 86 right'),
 
 182             91  => $locale->text('UStVA-Nr. 91'),
 
 183             93  => $locale->text('UStVA-Nr. 93 left'),
 
 184             931 => $locale->text('UStVA-Nr. 93 right'),
 
 185             94  => $locale->text('UStVA-Nr. 94'),
 
 186             95  => $locale->text('UStVA-Nr. 95'),
 
 187             96  => $locale->text('UStVA-Nr. 96'),
 
 188             97  => $locale->text('UStVA-Nr. 97 links'),
 
 189             971 => $locale->text('UStVA-Nr. 97 rechts'),
 
 190             98  => $locale->text('UStVA-Nr. 98'));
 
 192   foreach $item (sort({ $a cmp $b } keys %ustva)) {
 
 193     if ($item == $form->{pos_ustva}) {
 
 194       $form->{selectustva} .= "<option value=$item selected>$ustva{$item}\n";
 
 196       $form->{selectustva} .= "<option value=$item>$ustva{$item}\n";
 
 203                 <th align=right>| . $locale->text('Umsatzsteuervoranmeldung') . qq|</th>
 
 204                 <td><select name=pos_ustva>$form->{selectustva}</select></td>
 
 205                 <input type=hidden name=selectustva value="$form->{selectustva}">
 
 208   $form->{selecteur} = "<option>\n";
 
 209   %eur = (1  => "Umsatzerlöse",
 
 210           2  => "sonstige Erlöse",
 
 211           3  => "Privatanteile",
 
 213           5  => "Ausserordentliche Erträge",
 
 214           6  => "Vereinnahmte Umsatzst.",
 
 215           7  => "Umsatzsteuererstattungen",
 
 216           8  => "Wareneingänge",
 
 217           9  => "Löhne und Gehälter",
 
 218           10 => "Gesetzl. sozialer Aufw.",
 
 220           12 => "Gas, Strom, Wasser",
 
 221           13 => "Instandhaltung",
 
 222           14 => "Steuern, Versich., Beiträge",
 
 224           16 => "Kfz-Versicherungen",
 
 225           17 => "Sonst. Fahrtkosten",
 
 226           18 => "Werbe- und Reisekosten",
 
 227           19 => "Instandhaltung u. Werkzeuge",
 
 228           20 => "Fachzeitschriften, Bücher",
 
 229           21 => "Miete für Einrichtungen",
 
 230           22 => "Rechts- und Beratungskosten",
 
 231           23 => "Bürobedarf, Porto, Telefon",
 
 232           24 => "Sonstige Aufwendungen",
 
 233           25 => "Abschreibungen auf Anlagever.",
 
 234           26 => "Abschreibungen auf GWG",
 
 236           28 => "Umsatzsteuerzahlungen",
 
 238           30 => "Ausserordentlicher Aufwand",
 
 239           31 => "Betriebliche Steuern");
 
 240   foreach $item (sort({ $a <=> $b } keys(%eur))) {
 
 241     if ($item == $form->{pos_eur}) {
 
 242       $form->{selecteur} .= "<option value=$item selected>$eur{$item}\n";
 
 244       $form->{selecteur} .= "<option value=$item>$eur{$item}\n";
 
 251                 <th align=right>| . $locale->text('EUER') . qq|</th>
 
 252                 <td><select name=pos_eur>$form->{selecteur}</select></td>
 
 253                 <input type=hidden name=selecteur value="$form->{selecteur}">
 
 256   $form->{selectbwa} = "<option>\n";
 
 258   %bwapos = (1  => 'Umsatzerlöse',
 
 259              2  => 'Best.Verdg.FE/UE',
 
 260              3  => 'Aktiv.Eigenleistung',
 
 261              4  => 'Mat./Wareneinkauf',
 
 262              5  => 'So.betr.Erlöse',
 
 263              10 => 'Personalkosten',
 
 265              12 => 'Betriebl.Steuern',
 
 266              13 => 'Vers./Beiträge',
 
 267              14 => 'Kfz.Kosten o.St.',
 
 268              15 => 'Werbe-Reisek.',
 
 269              16 => 'Kosten Warenabgabe',
 
 270              17 => 'Abschreibungen',
 
 271              18 => 'Rep./instandhlt.',
 
 272              19 => 'Übrige Steuern',
 
 273              20 => 'Sonst.Kosten',
 
 275              31 => 'Sonst.neutr.Aufw.',
 
 277              33 => 'Sonst.neutr.Ertrag',
 
 278              34 => 'Verr.kalk.Kosten',
 
 279              35 => 'Steuern Eink.u.Ertr.');
 
 280   foreach $item (sort({ $a <=> $b } keys %bwapos)) {
 
 281     if ($item == $form->{pos_bwa}) {
 
 282       $form->{selectbwa} .= "<option value=$item selected>$bwapos{$item}\n";
 
 284       $form->{selectbwa} .= "<option value=$item>$bwapos{$item}\n";
 
 291                 <th align=right>| . $locale->text('BWA') . qq|</th>
 
 292                 <td><select name=pos_bwa>$form->{selectbwa}</select></td>
 
 293                 <input type=hidden name=selectbwa value="$form->{selectbwa}">
 
 296 # Entfernt bis es ordentlich umgesetzt wird (hli) 30.03.2006
 
 297 #  $form->{selectbilanz} = "<option>\n";
 
 298 #  foreach $item ((1, 2, 3, 4)) {
 
 299 #    if ($item == $form->{pos_bilanz}) {
 
 300 #      $form->{selectbilanz} .= "<option value=$item selected>$item\n";
 
 302 #      $form->{selectbilanz} .= "<option value=$item>$item\n";
 
 309 #               <th align=right>| . $locale->text('Bilanz') . qq|</th>
 
 310 #               <td><select name=pos_bilanz>$form->{selectbilanz}</select></td>
 
 311 #               <input type=hidden name=selectbilanz value="$form->{selectbilanz}">
 
 314   # this is for our parser only!
 
 315   # type=submit $locale->text('Add Account')
 
 316   # type=submit $locale->text('Edit Account')
 
 317   $form->{type} = "account";
 
 324 <form method=post action=$form->{script}>
 
 326 <input type=hidden name=id value=$form->{id}>
 
 327 <input type=hidden name=type value=account>
 
 328 <input type=hidden name=orphaned value=$form->{orphaned}>
 
 329 <input type=hidden name=new_chart_valid value=$form->{new_chart_valid}>
 
 331 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>
 
 332 <input type=hidden name=income_accno_id value=$form->{income_accno_id}>
 
 333 <input type=hidden name=expense_accno_id value=$form->{expense_accno_id}>
 
 334 <input type=hidden name=fxgain_accno_id value=$form->{fxgain_accno_id}>
 
 335 <input type=hidden name=fxloss_accno_id value=$form->{fxloss_accno_id}>
 
 337 <table border=0 width=100%>
 
 339     <th class=listtop>$form->{title}</th>
 
 346           <th align=right>| . $locale->text('Account Number') . qq|</th>
 
 347           <td><input name=accno size=20 value=$form->{accno}></td>
 
 350           <th align=right>| . $locale->text('Description') . qq|</th>
 
 351           <td><input name=description size=40 value="$form->{description}"></td>
 
 354           <th align=right>| . $locale->text('Account Type') . qq|</th>
 
 358                 <td><input name=category type=radio class=radio value=A $checked{A_}> |
 
 359     . $locale->text('Asset') . qq|\n<br>
 
 360                 <input name=category type=radio class=radio value=L $checked{L_}> |
 
 361     . $locale->text('Liability') . qq|\n<br>
 
 362                 <input name=category type=radio class=radio value=Q $checked{Q_}> |
 
 363     . $locale->text('Equity') . qq|\n<br>
 
 364                 <input name=category type=radio class=radio value=I $checked{I_}> |
 
 365     . $locale->text('Revenue') . qq|\n<br>
 
 366                 <input name=category type=radio class=radio value=E $checked{E_}> |
 
 367     . $locale->text('Expense') . qq|<br>
 
 368                 <input name=category type=radio class=radio value=C $checked{C_}> |
 
 369     . $locale->text('Costs') . qq|</td>
 
 370                 <td width=50> </td>
 
 372                 <input name=charttype type=radio class=radio value="H" $checked{H}> |
 
 373     . $locale->text('Heading') . qq|<br>
 
 374                 <input name=charttype type=radio class=radio value="A" $checked{A}> |
 
 375     . $locale->text('Account') . qq|</td>
 
 382   if ($form->{charttype} eq "A") {
 
 389       . $locale->text('Is this a summary account to record') . qq|</th>
 
 391                 <input name=AR type=checkbox class=checkbox value=AR $form->{AR}> |
 
 392       . $locale->text('AR')
 
 393       . qq| <input name=AP type=checkbox class=checkbox value=AP $form->{AP}> |
 
 394       . $locale->text('AP')
 
 395       . qq| <input name=IC type=checkbox class=checkbox value=IC $form->{IC}> |
 
 396       . $locale->text('Inventory')
 
 403           <th colspan=2>| . $locale->text('Include in drop-down menus') . qq|</th>
 
 409                 <th align=left>| . $locale->text('Receivables') . qq|</th>
 
 410                 <th align=left>| . $locale->text('Payables') . qq|</th>
 
 411                 <th align=left>| . $locale->text('Parts Inventory') . qq|</th>
 
 412                 <th align=left>| . $locale->text('Service Items') . qq|</th>
 
 416                 <input name=AR_amount type=checkbox class=checkbox value=AR_amount $form->{AR_amount}> |
 
 417       . $locale->text('Revenue') . qq|\n<br>
 
 418                 <input name=AR_paid type=checkbox class=checkbox value=AR_paid $form->{AR_paid}> |
 
 419       . $locale->text('Receipt') . qq|\n<br>
 
 420                 <input name=AR_tax type=checkbox class=checkbox value=AR_tax $form->{AR_tax}> |
 
 421       . $locale->text('Tax') . qq|
 
 424                 <input name=AP_amount type=checkbox class=checkbox value=AP_amount $form->{AP_amount}> |
 
 425       . $locale->text('Expense/Asset') . qq|\n<br>
 
 426                 <input name=AP_paid type=checkbox class=checkbox value=AP_paid $form->{AP_paid}> |
 
 427       . $locale->text('Payment') . qq|\n<br>
 
 428                 <input name=AP_tax type=checkbox class=checkbox value=AP_tax $form->{AP_tax}> |
 
 429       . $locale->text('Tax') . qq|
 
 432                 <input name=IC_sale type=checkbox class=checkbox value=IC_sale $form->{IC_sale}> |
 
 433       . $locale->text('Revenue') . qq|\n<br>
 
 434                 <input name=IC_cogs type=checkbox class=checkbox value=IC_cogs $form->{IC_cogs}> |
 
 435       . $locale->text('Expense') . qq|\n<br>
 
 436                 <input name=IC_taxpart type=checkbox class=checkbox value=IC_taxpart $form->{IC_taxpart}> |
 
 437       . $locale->text('Tax') . qq|
 
 440                 <input name=IC_income type=checkbox class=checkbox value=IC_income $form->{IC_income}> |
 
 441       . $locale->text('Revenue') . qq|\n<br>
 
 442                 <input name=IC_expense type=checkbox class=checkbox value=IC_expense $form->{IC_expense}> |
 
 443       . $locale->text('Expense') . qq|\n<br>
 
 444                 <input name=IC_taxservice type=checkbox class=checkbox value=IC_taxservice $form->{IC_taxservice}> |
 
 445       . $locale->text('Tax') . qq|
 
 465     <td><hr size=3 noshade></td>
 
 470   $lxdebug->leave_sub();
 
 474   $lxdebug->enter_sub();
 
 478 <input name=callback type=hidden value="$form->{callback}">
 
 480 <input type=hidden name=path value=$form->{path}>
 
 481 <input type=hidden name=login value=$form->{login}>
 
 482 <input type=hidden name=password value=$form->{password}>
 
 485   if ((!$form->{id}) || ($form->{id} && $form->{orphaned}) || (($form->{type} eq "account") && (!$form->{new_chart_valid}))) {
 
 487 <input type=submit class=submit name=action value="|
 
 488     . $locale->text('Save') . qq|">
 
 492   if ($form->{id} && $form->{orphaned}) {
 
 493     print qq|<input type=submit class=submit name=action value="|
 
 494       . $locale->text('Delete') . qq|">|;
 
 504   $lxdebug->leave_sub();
 
 508   $lxdebug->enter_sub();
 
 510   $form->isblank("accno",    $locale->text('Account Number missing!'));
 
 511   $form->isblank("category", $locale->text('Account Type missing!'));
 
 513   $form->redirect($locale->text('Account saved!'))
 
 514     if (AM->save_account(\%myconfig, \%$form));
 
 515   $form->error($locale->text('Cannot save account!'));
 
 517   $lxdebug->leave_sub();
 
 521   $lxdebug->enter_sub();
 
 523   CA->all_accounts(\%myconfig, \%$form);
 
 525   $form->{title} = $locale->text('Chart of Accounts');
 
 529     "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
 531   @column_index = qw(accno gifi_accno description debit credit link);
 
 533   $column_header{accno} = qq|<th>| . $locale->text('Account') . qq|</a></th>|;
 
 534   $column_header{gifi_accno} =
 
 535     qq|<th>| . $locale->text('GIFI') . qq|</a></th>|;
 
 536   $column_header{description} =
 
 537     qq|<th>| . $locale->text('Description') . qq|</a></th>|;
 
 538   $column_header{debit}  = qq|<th>| . $locale->text('Debit') . qq|</a></th>|;
 
 539   $column_header{credit} = qq|<th>| . $locale->text('Credit') . qq|</a></th>|;
 
 540   $column_header{link}   = qq|<th>| . $locale->text('Link') . qq|</a></th>|;
 
 543   $colspan = $#column_index + 1;
 
 550     <th class=listtop colspan=$colspan>$form->{title}</th>
 
 553   <tr class=listheading>
 
 556   map { print "$column_header{$_}\n" } @column_index;
 
 563   $callback = $form->escape($callback);
 
 565   foreach $ca (@{ $form->{CA} }) {
 
 567     $ca->{debit}  = " ";
 
 568     $ca->{credit} = " ";
 
 570     if ($ca->{amount} > 0) {
 
 572         $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
 
 574     if ($ca->{amount} < 0) {
 
 576         $form->format_amount(\%myconfig, -$ca->{amount}, 2, " ");
 
 579     $ca->{link} =~ s/:/<br>/og;
 
 581     if ($ca->{charttype} eq "H") {
 
 582       print qq|<tr class=listheading>|;
 
 584       $column_data{accno} =
 
 585         qq|<th><a href=$form->{script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{accno}</a></th>|;
 
 586       $column_data{gifi_accno} =
 
 587         qq|<th><a href=$form->{script}?action=edit_gifi&accno=$ca->{gifi_accno}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{gifi_accno}</a> </th>|;
 
 588       $column_data{description} = qq|<th>$ca->{description} </th>|;
 
 589       $column_data{debit}       = qq|<th> </th>|;
 
 590       $column_data{credit}      = qq| <th> </th>|;
 
 591       $column_data{link}        = qq|<th> </th>|;
 
 597 <tr valign=top class=listrow$i>|;
 
 598       $column_data{accno} =
 
 599         qq|<td><a href=$form->{script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{accno}</a></td>|;
 
 600       $column_data{gifi_accno} =
 
 601         qq|<td><a href=$form->{script}?action=edit_gifi&accno=$ca->{gifi_accno}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{gifi_accno}</a> </td>|;
 
 602       $column_data{description} = qq|<td>$ca->{description} </td>|;
 
 603       $column_data{debit}       = qq|<td align=right>$ca->{debit}</td>|;
 
 604       $column_data{credit}      = qq|<td align=right>$ca->{credit}</td>|;
 
 605       $column_data{link}        = qq|<td>$ca->{link} </td>|;
 
 609     map { print "$column_data{$_}\n" } @column_index;
 
 615   <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
 
 622   $lxdebug->leave_sub();
 
 626   $lxdebug->enter_sub();
 
 628   $form->{title} = $locale->text('Delete Account');
 
 631     qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
 
 633     if ($form->{id} == $form->{$id}) {
 
 634       $form->error($locale->text('Cannot delete default account!'));
 
 638   $form->redirect($locale->text('Account deleted!'))
 
 639     if (AM->delete_account(\%myconfig, \%$form));
 
 640   $form->error($locale->text('Cannot delete account!'));
 
 642   $lxdebug->leave_sub();
 
 646   $lxdebug->enter_sub();
 
 648   @{ $form->{fields} } = (accno, description);
 
 649   $form->{table}     = "gifi";
 
 650   $form->{sortorder} = "accno";
 
 652   AM->gifi_accounts(\%myconfig, \%$form);
 
 654   $form->{title} = $locale->text('GIFI');
 
 658     "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
 660   @column_index = qw(accno description);
 
 662   $column_header{accno} = qq|<th>| . $locale->text('GIFI') . qq|</a></th>|;
 
 663   $column_header{description} =
 
 664     qq|<th>| . $locale->text('Description') . qq|</a></th>|;
 
 667   $colspan = $#column_index + 1;
 
 674     <th class=listtop colspan=$colspan>$form->{title}</th>
 
 677   <tr class=listheading>
 
 680   map { print "$column_header{$_}\n" } @column_index;
 
 687   $callback = $form->escape($callback);
 
 689   foreach $ca (@{ $form->{ALL} }) {
 
 695 <tr valign=top class=listrow$i>|;
 
 697     $column_data{accno} =
 
 698       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>|;
 
 699     $column_data{description} = qq|<td>$ca->{description} </td>|;
 
 701     map { print "$column_data{$_}\n" } @column_index;
 
 708     <td colspan=$colspan><hr size=3 noshade></td>
 
 716   $lxdebug->leave_sub();
 
 720   $lxdebug->enter_sub();
 
 722   $form->{title} = "Add";
 
 726     "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
 733   $lxdebug->leave_sub();
 
 737   $lxdebug->enter_sub();
 
 739   $form->{title} = "Edit";
 
 741   AM->get_gifi(\%myconfig, \%$form);
 
 746   $lxdebug->leave_sub();
 
 750   $lxdebug->enter_sub();
 
 752   $form->{title} = $locale->text("$form->{title} GIFI");
 
 754   # $locale->text('Add GIFI')
 
 755   # $locale->text('Edit GIFI')
 
 757   $form->{description} =~ s/\"/"/g;
 
 764 <form method=post action=$form->{script}>
 
 766 <input type=hidden name=id value=$form->{accno}>
 
 767 <input type=hidden name=type value=gifi>
 
 771     <th class=listtop>$form->{title}</th>
 
 778           <th align=right>| . $locale->text('GIFI') . qq|</th>
 
 779           <td><input name=accno size=20 value=$form->{accno}></td>
 
 782           <th align=right>| . $locale->text('Description') . qq|</th>
 
 783           <td><input name=description size=60 value="$form->{description}"></td>
 
 789     <td colspan=2><hr size=3 noshade></td>
 
 794   $lxdebug->leave_sub();
 
 798   $lxdebug->enter_sub();
 
 802 <input name=callback type=hidden value="$form->{callback}">
 
 804 <input type=hidden name=path value=$form->{path}>
 
 805 <input type=hidden name=login value=$form->{login}>
 
 806 <input type=hidden name=password value=$form->{password}>
 
 808 <br><input type=submit class=submit name=action value="|
 
 809     . $locale->text('Save') . qq|">|;
 
 813 <input type=submit class=submit name=action value="|
 
 814       . $locale->text('Copy to COA') . qq|">
 
 817     if ($form->{accno} && $form->{orphaned}) {
 
 818       print qq|<input type=submit class=submit name=action value="|
 
 819         . $locale->text('Delete') . qq|">|;
 
 830   $lxdebug->leave_sub();
 
 834   $lxdebug->enter_sub();
 
 836   $form->isblank("accno", $locale->text('GIFI missing!'));
 
 837   AM->save_gifi(\%myconfig, \%$form);
 
 838   $form->redirect($locale->text('GIFI saved!'));
 
 840   $lxdebug->leave_sub();
 
 844   $lxdebug->enter_sub();
 
 846   $form->isblank("accno", $locale->text('GIFI missing!'));
 
 848   AM->save_gifi(\%myconfig, \%$form);
 
 851   $form->{gifi_accno} = $form->{accno};
 
 852   $form->{title}      = "Add";
 
 853   $form->{charttype}  = "A";
 
 858   $lxdebug->leave_sub();
 
 862   $lxdebug->enter_sub();
 
 864   AM->delete_gifi(\%myconfig, \%$form);
 
 865   $form->redirect($locale->text('GIFI deleted!'));
 
 867   $lxdebug->leave_sub();
 
 871   $lxdebug->enter_sub();
 
 873   $form->{title} = "Add";
 
 877     "$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
 878     unless $form->{callback};
 
 883   $lxdebug->leave_sub();
 
 886 sub edit_department {
 
 887   $lxdebug->enter_sub();
 
 889   $form->{title} = "Edit";
 
 891   AM->get_department(\%myconfig, \%$form);
 
 896   $lxdebug->leave_sub();
 
 899 sub list_department {
 
 900   $lxdebug->enter_sub();
 
 902   AM->departments(\%myconfig, \%$form);
 
 905     "$form->{script}?action=list_department&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
 907   $callback = $form->escape($form->{callback});
 
 909   $form->{title} = $locale->text('Departments');
 
 911   @column_index = qw(description cost profit);
 
 913   $column_header{description} =
 
 914       qq|<th class=listheading width=90%>|
 
 915     . $locale->text('Description')
 
 917   $column_header{cost} =
 
 918       qq|<th class=listheading nowrap>|
 
 919     . $locale->text('Cost Center')
 
 921   $column_header{profit} =
 
 922       qq|<th class=listheading nowrap>|
 
 923     . $locale->text('Profit Center')
 
 933     <th class=listtop>$form->{title}</th>
 
 939         <tr class=listheading>
 
 942   map { print "$column_header{$_}\n" } @column_index;
 
 948   foreach $ref (@{ $form->{ALL} }) {
 
 954         <tr valign=top class=listrow$i>
 
 957     $costcenter   = ($ref->{role} eq "C") ? "X" : "";
 
 958     $profitcenter = ($ref->{role} eq "P") ? "X" : "";
 
 960     $column_data{description} =
 
 961       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>|;
 
 962     $column_data{cost}   = qq|<td align=center>$costcenter</td>|;
 
 963     $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
 
 965     map { print "$column_data{$_}\n" } @column_index;
 
 977   <td><hr size=3 noshade></td>
 
 982 <form method=post action=$form->{script}>
 
 984 <input name=callback type=hidden value="$form->{callback}">
 
 986 <input type=hidden name=type value=department>
 
 988 <input type=hidden name=path value=$form->{path}>
 
 989 <input type=hidden name=login value=$form->{login}>
 
 990 <input type=hidden name=password value=$form->{password}>
 
 992 <input class=submit type=submit name=action value="|
 
 993     . $locale->text('Add') . qq|">
 
1001   $lxdebug->leave_sub();
 
1004 sub department_header {
 
1005   $lxdebug->enter_sub();
 
1007   $form->{title} = $locale->text("$form->{title} Department");
 
1009   # $locale->text('Add Department')
 
1010   # $locale->text('Edit Department')
 
1012   $form->{description} =~ s/\"/"/g;
 
1014   if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
 
1016       qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
 
1019       qq|<input name=description size=60 value="$form->{description}">|;
 
1022   $costcenter   = "checked" if $form->{role} eq "C";
 
1023   $profitcenter = "checked" if $form->{role} eq "P";
 
1030 <form method=post action=$form->{script}>
 
1032 <input type=hidden name=id value=$form->{id}>
 
1033 <input type=hidden name=type value=department>
 
1037     <th class=listtop colspan=2>$form->{title}</th>
 
1039   <tr height="5"></tr>
 
1041     <th align=right>| . $locale->text('Description') . qq|</th>
 
1042     <td>$description</td>
 
1046     <td><input type=radio style=radio name=role value="C" $costcenter> |
 
1047     . $locale->text('Cost Center') . qq|
 
1048         <input type=radio style=radio name=role value="P" $profitcenter> |
 
1049     . $locale->text('Profit Center') . qq|
 
1052     <td colspan=2><hr size=3 noshade></td>
 
1057   $lxdebug->leave_sub();
 
1060 sub save_department {
 
1061   $lxdebug->enter_sub();
 
1063   $form->isblank("description", $locale->text('Description missing!'));
 
1064   AM->save_department(\%myconfig, \%$form);
 
1065   $form->redirect($locale->text('Department saved!'));
 
1067   $lxdebug->leave_sub();
 
1070 sub delete_department {
 
1071   $lxdebug->enter_sub();
 
1073   AM->delete_department(\%myconfig, \%$form);
 
1074   $form->redirect($locale->text('Department deleted!'));
 
1076   $lxdebug->leave_sub();
 
1080   $lxdebug->enter_sub();
 
1082   $form->{title} = "Add";
 
1085     "$form->{script}?action=add_lead&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1086     unless $form->{callback};
 
1091   $lxdebug->leave_sub();
 
1095   $lxdebug->enter_sub();
 
1097   $form->{title} = "Edit";
 
1099   AM->get_lead(\%myconfig, \%$form);
 
1103   $form->{orphaned} = 1;
 
1106   $lxdebug->leave_sub();
 
1110   $lxdebug->enter_sub();
 
1112   AM->lead(\%myconfig, \%$form);
 
1115     "$form->{script}?action=list_lead&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1117   $callback = $form->escape($form->{callback});
 
1119   $form->{title} = $locale->text('Lead');
 
1121   @column_index = qw(description cost profit);
 
1123   $column_header{description} =
 
1124       qq|<th class=listheading width=100%>|
 
1125     . $locale->text('Description')
 
1135     <th class=listtop>$form->{title}</th>
 
1137   <tr height="5"></tr>
 
1138   <tr class=listheading>
 
1141   map { print "$column_header{$_}\n" } @column_index;
 
1147   foreach $ref (@{ $form->{ALL} }) {
 
1153         <tr valign=top class=listrow$i>
 
1156         $lead = $ref->{lead};
 
1158     $column_data{description} =
 
1159       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>|;
 
1161     map { print "$column_data{$_}\n" } @column_index;
 
1170   <td><hr size=3 noshade></td>
 
1175 <form method=post action=$form->{script}>
 
1177 <input name=callback type=hidden value="$form->{callback}">
 
1179 <input type=hidden name=type value=lead>
 
1181 <input type=hidden name=path value=$form->{path}>
 
1182 <input type=hidden name=login value=$form->{login}>
 
1183 <input type=hidden name=password value=$form->{password}>
 
1185 <input class=submit type=submit name=action value="|
 
1186     . $locale->text('Add') . qq|">
 
1194   $lxdebug->leave_sub();
 
1198   $lxdebug->enter_sub();
 
1200   $form->{title} = $locale->text("$form->{title} Lead");
 
1202   # $locale->text('Add Lead')
 
1203   # $locale->text('Edit Lead')
 
1205   $form->{description} =~ s/\"/"/g;
 
1208       qq|<input name=description size=50 value="$form->{lead}">|;
 
1215 <form method=post action=$form->{script}>
 
1217 <input type=hidden name=id value=$form->{id}>
 
1218 <input type=hidden name=type value=lead>
 
1222     <th class=listtop colspan=2>$form->{title}</th>
 
1224   <tr height="5"></tr>
 
1226     <th align=right>| . $locale->text('Description') . qq|</th>
 
1227     <td>$description</td>
 
1229     <td colspan=2><hr size=3 noshade></td>
 
1234   $lxdebug->leave_sub();
 
1238   $lxdebug->enter_sub();
 
1240   $form->isblank("description", $locale->text('Description missing!'));
 
1241   AM->save_lead(\%myconfig, \%$form);
 
1242   $form->redirect($locale->text('lead saved!'));
 
1244   $lxdebug->leave_sub();
 
1248   $lxdebug->enter_sub();
 
1250   AM->delete_lead(\%myconfig, \%$form);
 
1251   $form->redirect($locale->text('lead deleted!'));
 
1253   $lxdebug->leave_sub();
 
1257   $lxdebug->enter_sub();
 
1259   $form->{title} = "Add";
 
1262     "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1263     unless $form->{callback};
 
1268   $lxdebug->leave_sub();
 
1272   $lxdebug->enter_sub();
 
1274   $form->{title} = "Edit";
 
1276   AM->get_business(\%myconfig, \%$form);
 
1280   $form->{orphaned} = 1;
 
1283   $lxdebug->leave_sub();
 
1287   $lxdebug->enter_sub();
 
1289   AM->business(\%myconfig, \%$form);
 
1292     "$form->{script}?action=list_business&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1294   $callback = $form->escape($form->{callback});
 
1296   $form->{title} = $locale->text('Type of Business');
 
1298   @column_index = qw(description discount customernumberinit);
 
1300   $column_header{description} =
 
1301       qq|<th class=listheading width=60%>|
 
1302     . $locale->text('Description')
 
1304   $column_header{discount} =
 
1305       qq|<th class=listheading width=10%>|
 
1306     . $locale->text('Discount')
 
1308   $column_header{customernumberinit} =
 
1309       qq|<th class=listheading>|
 
1310     . $locale->text('Customernumberinit')
 
1320     <th class=listtop>$form->{title}</th>
 
1322   <tr height="5"></tr>
 
1326         <tr class=listheading>
 
1329   map { print "$column_header{$_}\n" } @column_index;
 
1335   foreach $ref (@{ $form->{ALL} }) {
 
1341         <tr valign=top class=listrow$i>
 
1345       $form->format_amount(\%myconfig, $ref->{discount} * 100, 1, " ");
 
1348       ? "<b>$ref->{description}</b>"
 
1349       : "$ref->{description}";
 
1350     $column_data{description} =
 
1351       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>|;
 
1352     $column_data{discount}           = qq|<td align=right>$discount</td>|;
 
1353     $column_data{customernumberinit} =
 
1354       qq|<td align=right>$ref->{customernumberinit}</td>|;
 
1356     map { print "$column_data{$_}\n" } @column_index;
 
1368   <td><hr size=3 noshade></td>
 
1373 <form method=post action=$form->{script}>
 
1375 <input name=callback type=hidden value="$form->{callback}">
 
1377 <input type=hidden name=type value=business>
 
1379 <input type=hidden name=path value=$form->{path}>
 
1380 <input type=hidden name=login value=$form->{login}>
 
1381 <input type=hidden name=password value=$form->{password}>
 
1383 <input class=submit type=submit name=action value="|
 
1384     . $locale->text('Add') . qq|">
 
1392   $lxdebug->leave_sub();
 
1395 sub business_header {
 
1396   $lxdebug->enter_sub();
 
1398   $form->{title}    = $locale->text("$form->{title} Business");
 
1399   $form->{salesman} = "checked" if $form->{salesman};
 
1401   # $locale->text('Add Business')
 
1402   # $locale->text('Edit Business')
 
1404   $form->{description} =~ s/\"/"/g;
 
1406     $form->format_amount(\%myconfig, $form->{discount} * 100);
 
1413 <form method=post action=$form->{script}>
 
1415 <input type=hidden name=id value=$form->{id}>
 
1416 <input type=hidden name=type value=business>
 
1420     <th class=listtop colspan=2>$form->{title}</th>
 
1422   <tr height="5"></tr>
 
1424     <th align=right>| . $locale->text('Type of Business') . qq|</th>
 
1425     <td><input name=description size=30 value="$form->{description}"></td>
 
1428     <th align=right>| . $locale->text('Discount') . qq| %</th>
 
1429     <td><input name=discount size=5 value=$form->{discount}></td>
 
1432     <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
 
1433     <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
 
1436     <td align=right>| . $locale->text('Salesman') . qq|</td>
 
1437     <td><input name=salesman class=checkbox type=checkbox value=1 $form->{salesman}></td>
 
1439   <td colspan=2><hr size=3 noshade></td>
 
1444   $lxdebug->leave_sub();
 
1448   $lxdebug->enter_sub();
 
1450   $form->isblank("description", $locale->text('Description missing!'));
 
1451   AM->save_business(\%myconfig, \%$form);
 
1452   $form->redirect($locale->text('Business saved!'));
 
1454   $lxdebug->leave_sub();
 
1457 sub delete_business {
 
1458   $lxdebug->enter_sub();
 
1460   AM->delete_business(\%myconfig, \%$form);
 
1461   $form->redirect($locale->text('Business deleted!'));
 
1463   $lxdebug->leave_sub();
 
1467   $lxdebug->enter_sub();
 
1469   $form->{title} = "Add";
 
1472     "$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1473     unless $form->{callback};
 
1478   $lxdebug->leave_sub();
 
1482   $lxdebug->enter_sub();
 
1484   $form->{title} = "Edit";
 
1486   AM->get_language(\%myconfig, \%$form);
 
1490   $form->{orphaned} = 1;
 
1493   $lxdebug->leave_sub();
 
1497   $lxdebug->enter_sub();
 
1499   AM->language(\%myconfig, \%$form);
 
1502     "$form->{script}?action=list_language&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1504   $callback = $form->escape($form->{callback});
 
1506   $form->{title} = $locale->text('Languages');
 
1508   @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
 
1510   $column_header{description} =
 
1511       qq|<th class=listheading width=60%>|
 
1512     . $locale->text('Description')
 
1514   $column_header{template_code} =
 
1515       qq|<th class=listheading width=10%>|
 
1516     . $locale->text('Template Code')
 
1518   $column_header{article_code} =
 
1519       qq|<th class=listheading>|
 
1520     . $locale->text('Article Code')
 
1522   $column_header{output_numberformat} =
 
1523       qq|<th class=listheading>|
 
1524     . $locale->text('Number Format')
 
1526   $column_header{output_dateformat} =
 
1527       qq|<th class=listheading>|
 
1528     . $locale->text('Date Format')
 
1530   $column_header{output_longdates} =
 
1531       qq|<th class=listheading>|
 
1532     . $locale->text('Long Dates')
 
1542     <th class=listtop>$form->{title}</th>
 
1544   <tr height="5"></tr>
 
1548         <tr class=listheading>
 
1551   map { print "$column_header{$_}\n" } @column_index;
 
1557   foreach $ref (@{ $form->{ALL} }) {
 
1563         <tr valign=top class=listrow$i>
 
1567     $column_data{description} =
 
1568       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>|;
 
1569     $column_data{template_code}           = qq|<td align=right>$ref->{template_code}</td>|;
 
1570     $column_data{article_code} =
 
1571       qq|<td align=right>$ref->{article_code}</td>|;
 
1572     $column_data{output_numberformat} =
 
1574       ($ref->{output_numberformat} ? $ref->{output_numberformat} :
 
1575        $locale->text("use program settings")) .
 
1577     $column_data{output_dateformat} =
 
1579       ($ref->{output_dateformat} ? $ref->{output_dateformat} :
 
1580        $locale->text("use program settings")) .
 
1582     $column_data{output_longdates} =
 
1584       ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
 
1587     map { print "$column_data{$_}\n" } @column_index;
 
1599   <td><hr size=3 noshade></td>
 
1604 <form method=post action=$form->{script}>
 
1606 <input name=callback type=hidden value="$form->{callback}">
 
1608 <input type=hidden name=type value=language>
 
1610 <input type=hidden name=path value=$form->{path}>
 
1611 <input type=hidden name=login value=$form->{login}>
 
1612 <input type=hidden name=password value=$form->{password}>
 
1614 <input class=submit type=submit name=action value="|
 
1615     . $locale->text('Add') . qq|">
 
1623   $lxdebug->leave_sub();
 
1626 sub language_header {
 
1627   $lxdebug->enter_sub();
 
1629   $form->{title}    = $locale->text("$form->{title} Language");
 
1631   # $locale->text('Add Language')
 
1632   # $locale->text('Edit Language')
 
1634   $form->{description} =~ s/\"/"/g;
 
1635   $form->{template_code} =~ s/\"/"/g;
 
1636   $form->{article_code} =~ s/\"/"/g;
 
1642     qq|<option value="">| . $locale->text("use program settings") .
 
1644   foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
 
1646       ($item eq $form->{output_numberformat})
 
1647       ? "<option selected>$item"
 
1653     qq|<option value="">| . $locale->text("use program settings") .
 
1655   foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
 
1657       ($item eq $form->{output_dateformat})
 
1658       ? "<option selected>$item"
 
1666 <form method=post action=$form->{script}>
 
1668 <input type=hidden name=id value=$form->{id}>
 
1669 <input type=hidden name=type value=language>
 
1673     <th class=listtop colspan=2>$form->{title}</th>
 
1675   <tr height="5"></tr>
 
1677     <th align=right>| . $locale->text('Language') . qq|</th>
 
1678     <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
 
1681     <th align=right>| . $locale->text('Template Code') . qq|</th>
 
1682     <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
 
1685     <th align=right>| . $locale->text('Article Code') . qq|</th>
 
1686     <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
 
1689     <th align=right>| . $locale->text('Number Format') . qq|</th>
 
1690     <td><select name="output_numberformat">$numberformat</select></td>
 
1693     <th align=right>| . $locale->text('Date Format') . qq|</th>
 
1694     <td><select name="output_dateformat">$dateformat</select></td>
 
1697     <th align=right>| . $locale->text('Long Dates') . qq|</th>
 
1698     <td><input type="radio" name="output_longdates" value="1"| .
 
1699     ($form->{output_longdates} ? " checked" : "") .
 
1700     qq|>| . $locale->text("Yes") .
 
1701     qq|<input type="radio" name="output_longdates" value="0"| .
 
1702     ($form->{output_longdates} ? "" : " checked") .
 
1703     qq|>| . $locale->text("No") .
 
1706   <td colspan=2><hr size=3 noshade></td>
 
1711   $lxdebug->leave_sub();
 
1715   $lxdebug->enter_sub();
 
1717   $form->isblank("description", $locale->text('Language missing!'));
 
1718   $form->isblank("template_code", $locale->text('Template Code missing!'));
 
1719   $form->isblank("article_code", $locale->text('Article Code missing!'));
 
1720   AM->save_language(\%myconfig, \%$form);
 
1721   $form->redirect($locale->text('Language saved!'));
 
1723   $lxdebug->leave_sub();
 
1726 sub delete_language {
 
1727   $lxdebug->enter_sub();
 
1729   AM->delete_language(\%myconfig, \%$form);
 
1730   $form->redirect($locale->text('Language deleted!'));
 
1732   $lxdebug->leave_sub();
 
1736 sub add_buchungsgruppe {
 
1737   $lxdebug->enter_sub();
 
1739   # $locale->text("Add Buchungsgruppe")
 
1740   # $locale->text("Edit Buchungsgruppe")
 
1741   $form->{title} = "Add";
 
1744     "$form->{script}?action=add_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
1745     unless $form->{callback};
 
1746   AM->get_buchungsgruppe(\%myconfig, \%$form);
 
1747   $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
 
1748   for (my $i = 0; 4 > $i; $i++) {
 
1749     map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
 
1750         qw(income expense));
 
1753   &buchungsgruppe_header;
 
1756   $lxdebug->leave_sub();
 
1759 sub edit_buchungsgruppe {
 
1760   $lxdebug->enter_sub();
 
1762   $form->{title} = "Edit";
 
1764   AM->get_buchungsgruppe(\%myconfig, \%$form);
 
1766   &buchungsgruppe_header;
 
1770   $lxdebug->leave_sub();
 
1773 sub list_buchungsgruppe {
 
1774   $lxdebug->enter_sub();
 
1776   AM->buchungsgruppe(\%myconfig, \%$form);
 
1779     "$form->{script}?action=list_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
1781   $callback = $form->escape($form->{callback});
 
1783   $form->{title} = $locale->text('Buchungsgruppen');
 
1785   @column_index = qw(description inventory_accno income_accno_0 expense_accno_0 income_accno_1 expense_accno_1 income_accno_2 expense_accno_2 income_accno_3 expense_accno_3 );
 
1787   $column_header{description} =
 
1788       qq|<th class=listheading width=60%>|
 
1789     . $locale->text('Description')
 
1791   $column_header{inventory_accno} =
 
1792       qq|<th class=listheading width=10%>|
 
1793     . $locale->text('Bestandskonto')
 
1795   $column_header{income_accno_0} =
 
1796       qq|<th class=listheading>|
 
1797     . $locale->text('Erlöse Inland')
 
1799   $column_header{expense_accno_0} =
 
1800       qq|<th class=listheading>|
 
1801     . $locale->text('Aufwand Inland')
 
1803   $column_header{income_accno_1} =
 
1804       qq|<th class=listheading>|
 
1805     . $locale->text('Erlöse EU m. UStId')
 
1807   $column_header{expense_accno_1} =
 
1808       qq|<th class=listheading>|
 
1809     . $locale->text('Aufwand EU m. UStId')
 
1811   $column_header{income_accno_2} =
 
1812       qq|<th class=listheading>|
 
1813     . $locale->text('Erlöse EU o. UStId')
 
1815   $column_header{expense_accno_2} =
 
1816       qq|<th class=listheading>|
 
1817     . $locale->text('Aufwand EU o. UStId')
 
1819   $column_header{income_accno_3} =
 
1820       qq|<th class=listheading>|
 
1821     . $locale->text('Erlöse Ausland')
 
1823   $column_header{expense_accno_3} =
 
1824       qq|<th class=listheading>|
 
1825     . $locale->text('Aufwand Ausland')
 
1834     <th class=listtop>$form->{title}</th>
 
1836   <tr height="5"></tr>
 
1840         <tr class=listheading>
 
1843   map { print "$column_header{$_}\n" } @column_index;
 
1849   foreach $ref (@{ $form->{ALL} }) {
 
1855         <tr valign=top class=listrow$i>
 
1859     $column_data{description} =
 
1860       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>|;
 
1861     $column_data{inventory_accno}           = qq|<td align=right>$ref->{inventory_accno}</td>|;
 
1862     $column_data{income_accno_0} =
 
1863       qq|<td align=right>$ref->{income_accno_0}</td>|;
 
1864     $column_data{expense_accno_0}           = qq|<td align=right>$ref->{expense_accno_0}</td>|;
 
1865     $column_data{income_accno_1} =
 
1866       qq|<td align=right>$ref->{income_accno_1}</td>|;
 
1867     $column_data{expense_accno_1}           = qq|<td align=right>$ref->{expense_accno_1}</td>|;
 
1868     $column_data{income_accno_2} =
 
1869       qq|<td align=right>$ref->{income_accno_2}</td>|;
 
1870     $column_data{expense_accno_2}           = qq|<td align=right>$ref->{expense_accno_2}</td>|;
 
1871     $column_data{income_accno_3} =
 
1872       qq|<td align=right>$ref->{income_accno_3}</td>|;
 
1873     $column_data{expense_accno_3}           = qq|<td align=right>$ref->{expense_accno_3}</td>|;
 
1875     map { print "$column_data{$_}\n" } @column_index;
 
1887   <td><hr size=3 noshade></td>
 
1892 <form method=post action=$form->{script}>
 
1894 <input name=callback type=hidden value="$form->{callback}">
 
1896 <input type=hidden name=type value=buchungsgruppe>
 
1898 <input type=hidden name=path value=$form->{path}>
 
1899 <input type=hidden name=login value=$form->{login}>
 
1900 <input type=hidden name=password value=$form->{password}>
 
1902 <input class=submit type=submit name=action value="|
 
1903     . $locale->text('Add') . qq|">
 
1911   $lxdebug->leave_sub();
 
1914 sub buchungsgruppe_header {
 
1915   $lxdebug->enter_sub();
 
1917   $form->{title}    = $locale->text("$form->{title} Buchungsgruppe");
 
1919   # $locale->text('Buchungsgruppe hinzufügen')
 
1920   # $locale->text('Buchungsgruppe bearbeiten')
 
1922   my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
 
1923   my %acc_type_map = (
 
1924     "IC" => $acc_inventory,
 
1925     "IC_income" => $acc_income,
 
1926     "IC_sale" => $acc_income,
 
1927     "IC_expense" => $acc_expense,
 
1928     "IC_cogs" => $acc_expense,
 
1931   foreach $key (keys(%acc_type_map)) {
 
1932     foreach $ref (@{ $form->{IC_links}{$key} }) {
 
1933       $acc_type_map{$key}->{$ref->{"id"}} = $ref;
 
1937   foreach my $type (qw(IC IC_income IC_expense)) {
 
1938     $form->{"select$type"} =
 
1940            map({ "<option value=$_->{id} $_->{selected}>" .
 
1941                    "$_->{accno}--" . H($_->{description}) . "</option>" }
 
1942                sort({ $a->{"accno"} cmp $b->{"accno"} }
 
1943                     values(%{$acc_type_map{$type}}))));
 
1947     $form->{selectIC} =~ s/selected//g;
 
1948     $form->{selectIC} =~ s/ value=$form->{inventory_accno_id}/  value=$form->{inventory_accno_id} selected/;
 
1949     $form->{selectIC_income} =~ s/selected//g;
 
1950     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_0}/  value=$form->{income_accno_id_0} selected/;
 
1951     $form->{selectIC_expense} =~ s/selected//g;
 
1952     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_0}/  value=$form->{expense_accno_id_0} selected/;
 
1958                 <th align=right>| . $locale->text('Inventory') . qq|</th>
 
1959                 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
 
1960                 <input name=selectIC type=hidden value="$form->{selectIC}">
 
1964                 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
 
1968   $linkaccounts .= qq|
 
1970                 <th align=right>| . $locale->text('Erlöse Inland') . qq|</th>
 
1971                 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
 
1974                 <th align=right>| . $locale->text('Aufwand Inland') . qq|</th>
 
1975                 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
 
1978     $form->{selectIC_income} =~ s/selected//g;
 
1979     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_1}/  value=$form->{income_accno_id_1} selected/;
 
1980     $form->{selectIC_expense} =~ s/selected//g;
 
1981     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/  value=$form->{expense_accno_id_1} selected/;
 
1983   $linkaccounts .= qq|        <tr>
 
1984                 <th align=right>| . $locale->text('Erlöse EU m. UStId') . qq|</th>
 
1985                 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
 
1988                 <th align=right>| . $locale->text('Aufwand EU m UStId') . qq|</th>
 
1989                 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
 
1993     $form->{selectIC_income} =~ s/selected//g;
 
1994     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_2}/  value=$form->{income_accno_id_2} selected/;
 
1995     $form->{selectIC_expense} =~ s/selected//g;
 
1996     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_2}/  value=$form->{expense_accno_id_2} selected/;
 
1999   $linkaccounts .= qq|        <tr>
 
2000                 <th align=right>| . $locale->text('Erlöse EU o. UStId') . qq|</th>
 
2001                 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
 
2004                 <th align=right>| . $locale->text('Aufwand EU o. UStId') . qq|</th>
 
2005                 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
 
2009     $form->{selectIC_income} =~ s/selected//g;
 
2010     $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_3}/  value=$form->{income_accno_id_3} selected/;
 
2011     $form->{selectIC_expense} =~ s/selected//g;
 
2012     $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_3}/  value=$form->{expense_accno_id_3} selected/;
 
2015   $linkaccounts .= qq|        <tr>
 
2016                 <th align=right>| . $locale->text('Erlöse Ausland') . qq|</th>
 
2017                 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
 
2020                 <th align=right>| . $locale->text('Aufwand Ausland') . qq|</th>
 
2021                 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
 
2031 <form method=post action=$form->{script}>
 
2033 <input type=hidden name=id value=$form->{id}>
 
2034 <input type=hidden name=type value=buchungsgruppe>
 
2038     <th class=listtop colspan=2>$form->{title}</th>
 
2040   <tr height="5"></tr>
 
2042     <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
 
2043     <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
 
2046   <td colspan=2><hr size=3 noshade></td>
 
2051   $lxdebug->leave_sub();
 
2054 sub save_buchungsgruppe {
 
2055   $lxdebug->enter_sub();
 
2057   $form->isblank("description", $locale->text('Description missing!'));
 
2059   AM->save_buchungsgruppe(\%myconfig, \%$form);
 
2060   $form->redirect($locale->text('Buchungsgruppe gespeichert!'));
 
2062   $lxdebug->leave_sub();
 
2065 sub delete_buchungsgruppe {
 
2066   $lxdebug->enter_sub();
 
2068   AM->delete_buchungsgruppe(\%myconfig, \%$form);
 
2069   $form->redirect($locale->text('Buchungsgruppe gelöscht!'));
 
2071   $lxdebug->leave_sub();
 
2076   $lxdebug->enter_sub();
 
2078   $form->{title} = "Add";
 
2081     "$form->{script}?action=add_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
2082     unless $form->{callback};
 
2087   $lxdebug->leave_sub();
 
2091   $lxdebug->enter_sub();
 
2093   $form->{title} = "Edit";
 
2095   AM->get_printer(\%myconfig, \%$form);
 
2099   $form->{orphaned} = 1;
 
2102   $lxdebug->leave_sub();
 
2106   $lxdebug->enter_sub();
 
2108   AM->printer(\%myconfig, \%$form);
 
2111     "$form->{script}?action=list_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
2113   $callback = $form->escape($form->{callback});
 
2115   $form->{title} = $locale->text('Printer');
 
2117   @column_index = qw(printer_description printer_command template_code);
 
2119   $column_header{printer_description} =
 
2120       qq|<th class=listheading width=60%>|
 
2121     . $locale->text('Printer Description')
 
2123   $column_header{printer_command} =
 
2124       qq|<th class=listheading width=10%>|
 
2125     . $locale->text('Printer Command')
 
2127   $column_header{template_code} =
 
2128       qq|<th class=listheading>|
 
2129     . $locale->text('Template Code')
 
2139     <th class=listtop>$form->{title}</th>
 
2141   <tr height="5"></tr>
 
2145         <tr class=listheading>
 
2148   map { print "$column_header{$_}\n" } @column_index;
 
2154   foreach $ref (@{ $form->{ALL} }) {
 
2160         <tr valign=top class=listrow$i>
 
2164     $column_data{printer_description} =
 
2165       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>|;
 
2166     $column_data{printer_command}           = qq|<td align=right>$ref->{printer_command}</td>|;
 
2167     $column_data{template_code} =
 
2168       qq|<td align=right>$ref->{template_code}</td>|;
 
2170     map { print "$column_data{$_}\n" } @column_index;
 
2182   <td><hr size=3 noshade></td>
 
2187 <form method=post action=$form->{script}>
 
2189 <input name=callback type=hidden value="$form->{callback}">
 
2191 <input type=hidden name=type value=printer>
 
2193 <input type=hidden name=path value=$form->{path}>
 
2194 <input type=hidden name=login value=$form->{login}>
 
2195 <input type=hidden name=password value=$form->{password}>
 
2197 <input class=submit type=submit name=action value="|
 
2198     . $locale->text('Add') . qq|">
 
2206   $lxdebug->leave_sub();
 
2209 sub printer_header {
 
2210   $lxdebug->enter_sub();
 
2212   $form->{title}    = $locale->text("$form->{title} Printer");
 
2214   # $locale->text('Add Printer')
 
2215   # $locale->text('Edit Printer')
 
2217   $form->{printer_description} =~ s/\"/"/g;
 
2218   $form->{template_code} =~ s/\"/"/g;
 
2219   $form->{printer_command} =~ s/\"/"/g;
 
2227 <form method=post action=$form->{script}>
 
2229 <input type=hidden name=id value=$form->{id}>
 
2230 <input type=hidden name=type value=printer>
 
2234     <th class=listtop colspan=2>$form->{title}</th>
 
2236   <tr height="5"></tr>
 
2238     <th align=right>| . $locale->text('Printer') . qq|</th>
 
2239     <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
 
2242     <th align=right>| . $locale->text('Printer Command') . qq|</th>
 
2243     <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
 
2246     <th align=right>| . $locale->text('Template Code') . qq|</th>
 
2247     <td><input name=template_code size=5 value="$form->{template_code}"></td>
 
2249   <td colspan=2><hr size=3 noshade></td>
 
2254   $lxdebug->leave_sub();
 
2258   $lxdebug->enter_sub();
 
2260   $form->isblank("printer_description", $locale->text('Description missing!'));
 
2261   $form->isblank("printer_command", $locale->text('Printer Command missing!'));
 
2262   AM->save_printer(\%myconfig, \%$form);
 
2263   $form->redirect($locale->text('Printer saved!'));
 
2265   $lxdebug->leave_sub();
 
2268 sub delete_printer {
 
2269   $lxdebug->enter_sub();
 
2271   AM->delete_printer(\%myconfig, \%$form);
 
2272   $form->redirect($locale->text('Printer deleted!'));
 
2274   $lxdebug->leave_sub();
 
2279   $lxdebug->enter_sub();
 
2281   $form->{title} = "Add";
 
2284     "$form->{script}?action=add_payment&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
2285     unless $form->{callback};
 
2287   $form->{terms_netto} = 0;
 
2288   $form->{terms_skonto} = 0;
 
2289   $form->{percent_skonto} = 0;
 
2293   $lxdebug->leave_sub();
 
2297   $lxdebug->enter_sub();
 
2299   $form->{title} = "Edit";
 
2301   AM->get_payment(\%myconfig, \%$form);
 
2305   $form->{orphaned} = 1;
 
2308   $lxdebug->leave_sub();
 
2312   $lxdebug->enter_sub();
 
2314   AM->payment(\%myconfig, \%$form);
 
2317     "$form->{script}?action=list_payment&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
2319   $callback = $form->escape($form->{callback});
 
2321   $form->{title} = $locale->text('Payment Terms');
 
2323   @column_index = qw(description description_long terms_netto terms_skonto percent_skonto);
 
2325   $column_header{description} =
 
2326       qq|<th class=listheading>|
 
2327     . $locale->text('Description')
 
2329   $column_header{description_long} =
 
2330       qq|<th class=listheading>|
 
2331     . $locale->text('Long Description')
 
2333   $column_header{terms_netto} =
 
2334       qq|<th class=listheading>|
 
2335     . $locale->text('Netto Terms')
 
2337   $column_header{terms_skonto} =
 
2338       qq|<th class=listheading>|
 
2339     . $locale->text('Skonto Terms')
 
2341   $column_header{percent_skonto} =
 
2342       qq|<th class=listheading>|
 
2343     . $locale->text('Skonto')
 
2353     <th class=listtop>$form->{title}</th>
 
2355   <tr height="5"></tr>
 
2359         <tr class=listheading>
 
2362   map { print "$column_header{$_}\n" } @column_index;
 
2368   foreach $ref (@{ $form->{ALL} }) {
 
2374         <tr valign=top class=listrow$i>
 
2378     $column_data{description} =
 
2379       qq|<td><a href=$form->{script}?action=edit_payment&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
 
2380     $column_data{description_long}           = qq|<td align=right>$ref->{description_long}</td>|;
 
2381     $column_data{terms_netto} =
 
2382       qq|<td align=right>$ref->{terms_netto}</td>|;
 
2383     $column_data{terms_skonto} =
 
2384       qq|<td align=right>$ref->{terms_skonto}</td>|;
 
2385     $column_data{percent_skonto} =
 
2386       qq|<td align=right>$ref->{percent_skonto} %</td>|;
 
2387     map { print "$column_data{$_}\n" } @column_index;
 
2399   <td><hr size=3 noshade></td>
 
2404 <form method=post action=$form->{script}>
 
2406 <input name=callback type=hidden value="$form->{callback}">
 
2408 <input type=hidden name=type value=payment>
 
2410 <input type=hidden name=path value=$form->{path}>
 
2411 <input type=hidden name=login value=$form->{login}>
 
2412 <input type=hidden name=password value=$form->{password}>
 
2414 <input class=submit type=submit name=action value="|
 
2415     . $locale->text('Add') . qq|">
 
2423   $lxdebug->leave_sub();
 
2426 sub payment_header {
 
2427   $lxdebug->enter_sub();
 
2429   $form->{title}    = $locale->text("$form->{title} Payment Terms");
 
2431   # $locale->text('Add Payment Terms')
 
2432   # $locale->text('Edit Payment Terms')
 
2434   $form->{description} =~ s/\"/"/g;
 
2443 <form method=post action=$form->{script}>
 
2445 <input type=hidden name=id value=$form->{id}>
 
2446 <input type=hidden name=type value=payment>
 
2450     <th class=listtop colspan=2>$form->{title}</th>
 
2452   <tr height="5"></tr>
 
2454     <th align=right>| . $locale->text('Description') . qq|</th>
 
2455     <td><input name=description size=30 value="$form->{description}"></td>
 
2458     <th align=right>| . $locale->text('Long Description') . qq|</th>
 
2459     <td><input name=description_long size=50 value="$form->{description_long}"></td>
 
2462     <th align=right>| . $locale->text('Netto Terms') . qq|</th>
 
2463     <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
 
2466     <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
 
2467     <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
 
2470     <th align=right>| . $locale->text('Skonto') . qq| %</th>
 
2471     <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
 
2473   <td colspan=2><hr size=3 noshade></td>
 
2478   $lxdebug->leave_sub();
 
2482   $lxdebug->enter_sub();
 
2484   $form->isblank("description", $locale->text('Language missing!'));
 
2485   AM->save_payment(\%myconfig, \%$form);
 
2486   $form->redirect($locale->text('Payment Terms saved!'));
 
2488   $lxdebug->leave_sub();
 
2491 sub delete_payment {
 
2492   $lxdebug->enter_sub();
 
2494   AM->delete_payment(\%myconfig, \%$form);
 
2495   $form->redirect($locale->text('Payment terms deleted!'));
 
2497   $lxdebug->leave_sub();
 
2501   $lxdebug->enter_sub();
 
2503   $form->{title} = "Add";
 
2506     "$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
2507     unless $form->{callback};
 
2512   $lxdebug->leave_sub();
 
2516   $lxdebug->enter_sub();
 
2518   $form->{title} = "Edit";
 
2520   AM->get_sic(\%myconfig, \%$form);
 
2524   $form->{orphaned} = 1;
 
2527   $lxdebug->leave_sub();
 
2531   $lxdebug->enter_sub();
 
2533   AM->sic(\%myconfig, \%$form);
 
2536     "$form->{script}?action=list_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
2538   $callback = $form->escape($form->{callback});
 
2540   $form->{title} = $locale->text('Standard Industrial Codes');
 
2542   @column_index = qw(code description);
 
2544   $column_header{code} =
 
2545     qq|<th class=listheading>| . $locale->text('Code') . qq|</th>|;
 
2546   $column_header{description} =
 
2547     qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
 
2556     <th class=listtop>$form->{title}</th>
 
2558   <tr height="5"></tr>
 
2562         <tr class=listheading>
 
2565   map { print "$column_header{$_}\n" } @column_index;
 
2571   foreach $ref (@{ $form->{ALL} }) {
 
2576     if ($ref->{sictype} eq 'H') {
 
2578         <tr valign=top class=listheading>
 
2580       $column_data{code} =
 
2581         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>|;
 
2582       $column_data{description} = qq|<th>$ref->{description}</th>|;
 
2586         <tr valign=top class=listrow$i>
 
2589       $column_data{code} =
 
2590         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>|;
 
2591       $column_data{description} = qq|<td>$ref->{description}</td>|;
 
2595     map { print "$column_data{$_}\n" } @column_index;
 
2607   <td><hr size=3 noshade></td>
 
2612 <form method=post action=$form->{script}>
 
2614 <input name=callback type=hidden value="$form->{callback}">
 
2616 <input type=hidden name=type value=sic>
 
2618 <input type=hidden name=path value=$form->{path}>
 
2619 <input type=hidden name=login value=$form->{login}>
 
2620 <input type=hidden name=password value=$form->{password}>
 
2622 <input class=submit type=submit name=action value="|
 
2623     . $locale->text('Add') . qq|">
 
2631   $lxdebug->leave_sub();
 
2635   $lxdebug->enter_sub();
 
2637   $form->{title} = $locale->text("$form->{title} SIC");
 
2639   # $locale->text('Add SIC')
 
2640   # $locale->text('Edit SIC')
 
2642   $form->{code}        =~ s/\"/"/g;
 
2643   $form->{description} =~ s/\"/"/g;
 
2645   $checked = ($form->{sictype} eq 'H') ? "checked" : "";
 
2652 <form method=post action=$form->{script}>
 
2654 <input type=hidden name=type value=sic>
 
2655 <input type=hidden name=id value=$form->{code}>
 
2659     <th class=listtop colspan=2>$form->{title}</th>
 
2661   <tr height="5"></tr>
 
2663     <th align=right>| . $locale->text('Code') . qq|</th>
 
2664     <td><input name=code size=10 value=$form->{code}></td>
 
2668     <th align=left><input name=sictype type=checkbox style=checkbox value="H" $checked> |
 
2669     . $locale->text('Heading') . qq|</th>
 
2672     <th align=right>| . $locale->text('Description') . qq|</th>
 
2673     <td><input name=description size=60 value="$form->{description}"></td>
 
2675     <td colspan=2><hr size=3 noshade></td>
 
2680   $lxdebug->leave_sub();
 
2684   $lxdebug->enter_sub();
 
2686   $form->isblank("code",        $locale->text('Code missing!'));
 
2687   $form->isblank("description", $locale->text('Description missing!'));
 
2688   AM->save_sic(\%myconfig, \%$form);
 
2689   $form->redirect($locale->text('SIC saved!'));
 
2691   $lxdebug->leave_sub();
 
2695   $lxdebug->enter_sub();
 
2697   AM->delete_sic(\%myconfig, \%$form);
 
2698   $form->redirect($locale->text('SIC deleted!'));
 
2700   $lxdebug->leave_sub();
 
2703 sub display_stylesheet {
 
2704   $lxdebug->enter_sub();
 
2706   $form->{file} = "css/$myconfig{stylesheet}";
 
2709   $lxdebug->leave_sub();
 
2713   $lxdebug->enter_sub();
 
2715   $form->{file} =~ s/^(.:)*?\/|\.\.\///g;
 
2716   $form->{file} =~ s/^\/*//g;
 
2717   $form->{file} =~ s/$userspath//;
 
2719   $form->error("$!: $form->{file}") unless -f $form->{file};
 
2721   AM->load_template(\%$form);
 
2723   $form->{title} = $form->{file};
 
2725   # if it is anything but html
 
2726   if ($form->{file} !~ /\.html$/) {
 
2727     $form->{body} = "<pre>\n$form->{body}\n</pre>";
 
2737 <form method=post action=$form->{script}>
 
2739 <input name=file type=hidden value=$form->{file}>
 
2740 <input name=type type=hidden value=template>
 
2742 <input type=hidden name=path value=$form->{path}>
 
2743 <input type=hidden name=login value=$form->{login}>
 
2744 <input type=hidden name=password value=$form->{password}>
 
2746 <input name=action type=submit class=submit value="|
 
2747     . $locale->text('Edit') . qq|">
 
2755   $lxdebug->leave_sub();
 
2759   $lxdebug->enter_sub();
 
2761   AM->load_template(\%$form);
 
2763   $form->{title} = $locale->text('Edit Template');
 
2765   # convert   to &nbsp;
 
2766   $form->{body} =~ s/ /&nbsp;/gi;
 
2773 <form method=post action=$form->{script}>
 
2775 <input name=file type=hidden value=$form->{file}>
 
2776 <input name=type type=hidden value=template>
 
2778 <input type=hidden name=path value=$form->{path}>
 
2779 <input type=hidden name=login value=$form->{login}>
 
2780 <input type=hidden name=password value=$form->{password}>
 
2782 <input name=callback type=hidden value="$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}&password=$form->{password}">
 
2784 <textarea name=body rows=25 cols=70>
 
2789 <input type=submit class=submit name=action value="|
 
2790     . $locale->text('Save') . qq|">
 
2799   $lxdebug->leave_sub();
 
2803   $lxdebug->enter_sub();
 
2805   AM->save_template(\%$form);
 
2806   $form->redirect($locale->text('Template saved!'));
 
2808   $lxdebug->leave_sub();
 
2812   $lxdebug->enter_sub();
 
2814   # get defaults for account numbers and last numbers
 
2815   AM->defaultaccounts(\%myconfig, \%$form);
 
2817   foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
 
2819       ($item eq $myconfig{dateformat})
 
2820       ? "<option selected>$item\n"
 
2821       : "<option>$item\n";
 
2824   foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
 
2826       ($item eq $myconfig{numberformat})
 
2827       ? "<option selected>$item\n"
 
2828       : "<option>$item\n";
 
2831   foreach $item (qw(name company address signature)) {
 
2832     $myconfig{$item} =~ s/\"/"/g;
 
2835   foreach $item (qw(address signature)) {
 
2836     $myconfig{$item} =~ s/\\n/\r\n/g;
 
2840   if ($opendocument_templates && $openofficeorg_writer_bin &&
 
2841       $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
 
2842     push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
 
2843                      "value" => "opendocument_pdf" });
 
2845   if ($latex_templates) {
 
2846     push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
 
2848   push(@formats, { "name" => "HTML", "value" => "html" });
 
2849   if ($latex_templates) {
 
2850     push(@formats, { "name" => $locale->text("Postscript"),
 
2851                      "value" => "postscript" });
 
2853   if ($opendocument_templates) {
 
2854     push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
 
2855                      "value" => "opendocument" });
 
2858   if (!$myconfig{"template_format"}) {
 
2859     $myconfig{"template_format"} = "pdf";
 
2861   $template_format = "";
 
2862   foreach $item (@formats) {
 
2864       "<option value=\"$item->{value}\"" .
 
2865       ($item->{"value"} eq $myconfig{"template_format"} ?
 
2867        ">" . H($item->{"name"}) . "</option>";
 
2870   %countrycodes = User->country_codes;
 
2872   foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
 
2876       ($myconfig{countrycode} eq $key)
 
2877       ? "<option selected value=$key>$countrycodes{$key}\n"
 
2878       : "<option value=$key>$countrycodes{$key}\n";
 
2880   $countrycodes = "<option>American English\n$countrycodes";
 
2882   # use an other input number format than output numberformat
 
2883   # look at Form.pm, sub parse_amount
 
2884   my $in_numberformat = '';
 
2885   $text1 = qq|value="0">| . $locale->text('equal Outputformat');
 
2886   $text2 = qq|value="1">| . $locale->text('1000,00 or 1000.00');
 
2887   @in_nf = ($text1, $text2);
 
2888   foreach $item (@in_nf) {
 
2890       (substr($item, 7, 1) eq $myconfig{in_numberformat})
 
2891       ? "<option selected $item\n"
 
2892       : "<option $item\n";
 
2895   foreach $key (keys %{ $form->{IC} }) {
 
2896     foreach $accno (sort keys %{ $form->{IC}{$key} }) {
 
2898         ($form->{IC}{$key}{$accno}{id} == $form->{defaults}{$key})
 
2899         ? "<option selected>$accno--$form->{IC}{$key}{$accno}{description}\n"
 
2900         : "<option>$accno--$form->{IC}{$key}{$accno}{description}\n";
 
2904   opendir CSS, "css/.";
 
2905   @all = grep /.*\.css$/, readdir CSS;
 
2908   foreach $item (@all) {
 
2909     if ($item eq $myconfig{stylesheet}) {
 
2910       $selectstylesheet .= qq|<option selected>$item\n|;
 
2912       $selectstylesheet .= qq|<option>$item\n|;
 
2915   $selectstylesheet .= "<option>\n";
 
2917   $form->{title} = $locale->text('Edit Preferences for') . qq| $form->{login}|;
 
2921   if ($myconfig{menustyle} eq "old") {
 
2922     $menustyle_old = "checked";
 
2923   } elsif ($myconfig{menustyle} eq "neu") {
 
2924     $menustyle_neu = "checked";
 
2925   } elsif ($myconfig{menustyle} eq "v3") {
 
2926     $menustyle_v3 = "checked";
 
2929   my ($show_form_details, $hide_form_details);
 
2930   $myconfig{"show_form_details"} = 1
 
2931     unless (defined($myconfig{"show_form_details"}));
 
2932   $show_form_details = "checked" if ($myconfig{"show_form_details"});
 
2933   $hide_form_details = "checked" unless ($myconfig{"show_form_details"});
 
2938 <form method=post action=$form->{script}>
 
2940 <input type=hidden name=old_password value=$myconfig{password}>
 
2941 <input type=hidden name=type value=preferences>
 
2942 <input type=hidden name=role value=$myconfig{role}>
 
2945   <tr><th class=listtop>$form->{title}</th></tr>
 
2950           <th align=right>| . $locale->text('Name') . qq|</th>
 
2951           <td><input name=name size=15 value="$myconfig{name}"></td>
 
2954           <th align=right>| . $locale->text('Password') . qq|</th>
 
2955           <td><input type=password name=new_password size=10 value=$myconfig{password}></td>
 
2958           <th align=right>| . $locale->text('E-mail') . qq|</th>
 
2959           <td><input name=email size=30 value="$myconfig{email}"></td>
 
2962           <th align=right>| . $locale->text('Signature') . qq|</th>
 
2963           <td><textarea name=signature rows=3 cols=50>$myconfig{signature}</textarea></td>
 
2966           <th align=right>| . $locale->text('Phone') . qq|</th>
 
2967           <td><input name=tel size=14 value="$myconfig{tel}"></td>
 
2970           <th align=right>| . $locale->text('Fax') . qq|</th>
 
2971           <td><input name=fax size=14 value="$myconfig{fax}"></td>
 
2974           <th align=right>| . $locale->text('Company') . qq|</th>
 
2975           <td><input name=company size=30 value="$myconfig{company}"></td>
 
2978           <th align=right>| . $locale->text('Address') . qq|</th>
 
2979           <td><textarea name=address rows=4 cols=50>$myconfig{address}</textarea></td>
 
2982           <th align=right>| . $locale->text('Date Format') . qq|</th>
 
2983           <td><select name=dateformat>$dateformat</select></td>
 
2986           <th align=right>| . $locale->text('Output Number Format') . qq|</th>
 
2987           <td><select name=numberformat>$numberformat</select></td>
 
2990           <th align=right>| . $locale->text('Input Number Format') . qq|</th>
 
2991           <td><select name=in_numberformat>$in_numberformat</select></td>
 
2995           <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
 
2996           <td><input name=vclimit size=10 value="$myconfig{vclimit}"></td>
 
2999           <th align=right>| . $locale->text('Language') . qq|</th>
 
3000           <td><select name=countrycode>$countrycodes</select></td>
 
3003           <th align=right>| . $locale->text('Stylesheet') . qq|</th>
 
3004           <td><select name=usestylesheet>$selectstylesheet</select></td>
 
3007           <th align=right>| . $locale->text('Setup Menu') . qq|</th>
 
3008           <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
 
3009     $locale->text("Top (CSS)") . qq|
 
3010           <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
 
3011     $locale->text("Top (Javascript)") . qq|
 
3012     <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
 
3013     $locale->text("Old (on the side)") . qq|</td>
 
3016     <th align=right>| . $locale->text('Form details (second row)') . qq|</th>
 
3017     <td><input type="radio" id="rad_show_form_details" name="show_form_details" value="1" $show_form_details> 
 
3018     <label for="rad_show_form_details">| . $locale->text('Show by default') . qq|</label>
 
3019     <input type="radio" id="rad_hide_form_details" name="show_form_details" value="0" $hide_form_details> 
 
3020     <label for="rad_hide_form_details">| . $locale->text('Hide by default') . qq|</label></td>
 
3022         <input name=printer type=hidden value="$myconfig{printer}">
 
3023         <tr class=listheading>
 
3024           <th colspan=2>| . $locale->text("Print options") . qq|</th>
 
3027           <th align=right>| . $locale->text('Default template format') . qq|</th>
 
3028           <td><select name="template_format">$template_format</select></td>
 
3031           <th align=right>| . $locale->text('Number of copies') . qq|</th>
 
3032           <td><input name="copies" size="10" value="| .
 
3033     $form->quote($myconfig{"copies"}) . qq|"></td>
 
3037         <tr class=listheading>
 
3038           <th colspan=2> </th>
 
3041           <th align=right>| . $locale->text('Business Number') . qq|</th>
 
3042           <td><input name=businessnumber size=25 value="$myconfig{businessnumber}"></td>
 
3045                 <th align=right>| . $locale->text('Year End') . qq| (mm/dd)</th>
 
3046                 <td><input name=yearend size=5 value=$form->{defaults}{yearend}></td>
 
3048         <tr class=listheading>
 
3050     . $locale->text('Last Numbers & Default Accounts') . qq|</th>
 
3056                 <th align=right nowrap>| . $locale->text('Inventory Account') . qq|</th>
 
3057                 <td><select name=inventory_accno>$myconfig{IC}</select></td>
 
3060                 <th align=right nowrap>| . $locale->text('Revenue Account') . qq|</th>
 
3061                 <td><select name=income_accno>$myconfig{IC_income}</select></td>
 
3064                 <th align=right nowrap>| . $locale->text('Expense Account') . qq|</th>
 
3065                 <td><select name=expense_accno>$myconfig{IC_expense}</select></td>
 
3068                 <th align=right nowrap>| . $locale->text('Foreign Exchange Gain') . qq|</th>
 
3069                 <td><select name=fxgain_accno>$myconfig{FX_gain}</select></td>
 
3072                 <th align=right nowrap>| . $locale->text('Foreign Exchange Loss') . qq|</th>
 
3073                 <td><select name=fxloss_accno>$myconfig{FX_loss}</select></td>
 
3078     'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies'
 
3080     . qq|<br><input name=curr size=40 value="$form->{defaults}{curr}"></td>
 
3089                 <th align=right nowrap>| . $locale->text('Last Invoice Number') . qq|</th>
 
3090                 <td><input name=invnumber size=10 value=$form->{defaults}{invnumber}></td>
 
3091                 <th align=right nowrap>|
 
3092     . $locale->text('Last Customer Number') . qq|</th>
 
3093                 <td><input name=customernumber size=10 value=$form->{defaults}{customernumber}></td>
 
3096                 <th align=right nowrap>|
 
3097     . $locale->text('Last Credit Note Number') . qq|</th>
 
3098                 <td><input name=cnnumber size=10 value=$form->{defaults}{cnnumber}></td>
 
3099                 <th align=right nowrap>|
 
3100     . $locale->text('Last Vendor Number') . qq|</th>
 
3101                 <td><input name=vendornumber size=10 value=$form->{defaults}{vendornumber}></td>
 
3104                 <th align=right nowrap>|
 
3105     . $locale->text('Last Sales Order Number') . qq|</th>
 
3106                 <td><input name=sonumber size=10 value=$form->{defaults}{sonumber}></td>
 
3109                 <th align=right nowrap>|
 
3110     . $locale->text('Last Purchase Order Number') . qq|</th>
 
3111                 <td><input name=ponumber size=10 value=$form->{defaults}{ponumber}></td>
 
3112                 <th align=right nowrap>|
 
3113     . $locale->text('Last Article Number') . qq|</th>
 
3114                 <td><input name=articlenumber size=10 value=$form->{defaults}{articlenumber}></td>
 
3117                 <th align=right nowrap>|
 
3118     . $locale->text('Last Sales Quotation Number') . qq|</th>
 
3119                 <td><input name=sqnumber size=10 value=$form->{defaults}{sqnumber}></td>
 
3120                 <th align=right nowrap>|
 
3121     . $locale->text('Last Service Number') . qq|</th>
 
3122                 <td><input name=servicenumber size=10 value=$form->{defaults}{servicenumber}></td>
 
3125                 <th align=right nowrap>| . $locale->text('Last RFQ Number') . qq|</th>
 
3126                 <td><input name=rfqnumber size=10 value=$form->{defaults}{rfqnumber}></td>
 
3127                 <th align=right nowrap></th>
 
3133 #       <tr class=listheading>
 
3134 #         <th colspan=2>| . $locale->text('Tax Accounts') . qq|</th>
 
3141 #               <th>| . $locale->text('Rate') . qq| (%)</th>
 
3142 #               <th>| . $locale->text('Number') . qq|</th>
 
3146 #   foreach $accno (sort keys %{ $form->{taxrates} }) {
 
3149 #               <th align=right>$form->{taxrates}{$accno}{description}</th>
 
3150 #               <td><input name=$form->{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}></td>
 
3151 #               <td><input name="taxnumber_$form->{taxrates}{$accno}{id}" value="$form->{taxrates}{$accno}{taxnumber}"></td>
 
3154 #     $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} ";
 
3157 #   chop $form->{taxaccounts};
 
3160 # <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
 
3169     <td><hr size=3 noshade></td>
 
3173 <input type=hidden name=path value=$form->{path}>
 
3174 <input type=hidden name=login value=$form->{login}>
 
3175 <input type=hidden name=password value=$form->{password}>
 
3178 <input type=submit class=submit name=action value="|
 
3179     . $locale->text('Save') . qq|">
 
3187   $lxdebug->leave_sub();
 
3190 sub save_preferences {
 
3191   $lxdebug->enter_sub();
 
3193   $form->{stylesheet} = $form->{usestylesheet};
 
3195   $form->redirect($locale->text('Preferences saved!'))
 
3197      AM->save_preferences(\%myconfig, \%$form, $memberfile, $userspath, $webdav
 
3199   $form->error($locale->text('Cannot save preferences!'));
 
3201   $lxdebug->leave_sub();
 
3205   $lxdebug->enter_sub();
 
3207   if ($form->{media} eq 'email') {
 
3208     $form->error($locale->text('No email address for') . " $myconfig{name}")
 
3209       unless ($myconfig{email});
 
3211     $form->{OUT} = "$sendmail";
 
3215   AM->backup(\%myconfig, \%$form, $userspath);
 
3217   if ($form->{media} eq 'email') {
 
3218     $form->redirect($locale->text('Backup sent to') . qq| $myconfig{email}|);
 
3221   $lxdebug->leave_sub();
 
3225   $lxdebug->enter_sub();
 
3227   $form->{title} = $locale->text('Audit Control');
 
3229   AM->closedto(\%myconfig, \%$form);
 
3231   if ($form->{revtrans}) {
 
3232     $checked{Y} = "checked";
 
3234     $checked{N} = "checked";
 
3242 <form method=post action=$form->{script}>
 
3244 <input type=hidden name=path value=$form->{path}>
 
3245 <input type=hidden name=login value=$form->{login}>
 
3246 <input type=hidden name=password value=$form->{password}>
 
3249   <tr><th class=listtop>$form->{title}</th></tr>
 
3250   <tr height="5"></tr>
 
3256     . $locale->text('Enforce transaction reversal for all dates') . qq|</th>
 
3257           <td><input name=revtrans class=radio type=radio value="1" $checked{Y}> |
 
3258     . $locale->text('Yes')
 
3259     . qq| <input name=revtrans class=radio type=radio value="0" $checked{N}> |
 
3260     . $locale->text('No')
 
3264           <th>| . $locale->text('Close Books up to') . qq|</th>
 
3265           <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
 
3275 <input type=hidden name=nextsub value=doclose>
 
3277 <input type=submit class=submit name=action value="|
 
3278     . $locale->text('Continue') . qq|">
 
3286   $lxdebug->leave_sub();
 
3290   $lxdebug->enter_sub();
 
3292   AM->closebooks(\%myconfig, \%$form);
 
3294   if ($form->{revtrans}) {
 
3296                  $locale->text('Transaction reversal enforced for all dates'));
 
3298     if ($form->{closedto}) {
 
3300                      $locale->text('Transaction reversal enforced up to') . " "
 
3301                        . $locale->date(\%myconfig, $form->{closedto}, 1));
 
3303       $form->redirect($locale->text('Books are open'));
 
3307   $lxdebug->leave_sub();
 
3311   $lxdebug->enter_sub();
 
3313   $form->{title} = "Add";
 
3316     "$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
3317     unless $form->{callback};
 
3322   $lxdebug->leave_sub();
 
3325 sub edit_warehouse {
 
3326   $lxdebug->enter_sub();
 
3328   $form->{title} = "Edit";
 
3330   AM->get_warehouse(\%myconfig, \%$form);
 
3335   $lxdebug->leave_sub();
 
3338 sub list_warehouse {
 
3339   $lxdebug->enter_sub();
 
3341   AM->warehouses(\%myconfig, \%$form);
 
3344     "$form->{script}?action=list_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
3346   $callback = $form->escape($form->{callback});
 
3348   $form->{title} = $locale->text('Warehouses');
 
3350   @column_index = qw(description);
 
3352   $column_header{description} =
 
3353       qq|<th class=listheading width=100%>|
 
3354     . $locale->text('Description')
 
3364     <th class=listtop>$form->{title}</th>
 
3366   <tr height="5"></tr>
 
3370         <tr class=listheading>
 
3373   map { print "$column_header{$_}\n" } @column_index;
 
3379   foreach $ref (@{ $form->{ALL} }) {
 
3385         <tr valign=top class=listrow$i>
 
3388     $column_data{description} =
 
3389       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>|;
 
3391     map { print "$column_data{$_}\n" } @column_index;
 
3403   <td><hr size=3 noshade></td>
 
3408 <form method=post action=$form->{script}>
 
3410 <input name=callback type=hidden value="$form->{callback}">
 
3412 <input type=hidden name=type value=warehouse>
 
3414 <input type=hidden name=path value=$form->{path}>
 
3415 <input type=hidden name=login value=$form->{login}>
 
3416 <input type=hidden name=password value=$form->{password}>
 
3418 <input class=submit type=submit name=action value="|
 
3419     . $locale->text('Add') . qq|">
 
3427   $lxdebug->leave_sub();
 
3430 sub warehouse_header {
 
3431   $lxdebug->enter_sub();
 
3433   $form->{title} = $locale->text("$form->{title} Warehouse");
 
3435   # $locale->text('Add Warehouse')
 
3436   # $locale->text('Edit Warehouse')
 
3438   $form->{description} =~ s/\"/"/g;
 
3440   if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
 
3442       qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
 
3445       qq|<input name=description size=60 value="$form->{description}">|;
 
3453 <form method=post action=$form->{script}>
 
3455 <input type=hidden name=id value=$form->{id}>
 
3456 <input type=hidden name=type value=warehouse>
 
3460     <th class=listtop colspan=2>$form->{title}</th>
 
3462   <tr height="5"></tr>
 
3464     <th align=right>| . $locale->text('Description') . qq|</th>
 
3465     <td>$description</td>
 
3468     <td colspan=2><hr size=3 noshade></td>
 
3473   $lxdebug->leave_sub();
 
3476 sub save_warehouse {
 
3477   $lxdebug->enter_sub();
 
3479   $form->isblank("description", $locale->text('Description missing!'));
 
3480   AM->save_warehouse(\%myconfig, \%$form);
 
3481   $form->redirect($locale->text('Warehouse saved!'));
 
3483   $lxdebug->leave_sub();
 
3486 sub delete_warehouse {
 
3487   $lxdebug->enter_sub();
 
3489   AM->delete_warehouse(\%myconfig, \%$form);
 
3490   $form->redirect($locale->text('Warehouse deleted!'));
 
3492   $lxdebug->leave_sub();
 
3496   $lxdebug->enter_sub();
 
3498   &{ $form->{nextsub} };
 
3500   $lxdebug->leave_sub();
 
3504   $lxdebug->enter_sub();
 
3506   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
 
3507   AM->units_in_use(\%myconfig, $form, $units);
 
3508   map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
 
3510   @languages = AM->language(\%myconfig, $form, 1);
 
3513   foreach $name (sort({ lc($a) cmp lc($b) } grep({ !$units->{$_}->{"base_unit"} } keys(%{$units})))) {
 
3514     map({ push(@unit_list, $units->{$_}); }
 
3515         sort({ ($units->{$a}->{"resolved_factor"} * 1) <=> ($units->{$b}->{"resolved_factor"} * 1) }
 
3516              grep({ $units->{$_}->{"resolved_base_unit"} eq $name } keys(%{$units}))));
 
3519   foreach (@unit_list) {
 
3520     $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"}, 5) if ($_->{"factor"});
 
3521     $_->{"UNITLANGUAGES"} = [];
 
3522     foreach my $lang (@languages) {
 
3523       push(@{ $_->{"UNITLANGUAGES"} },
 
3525              "unit" => $_->{"name"},
 
3526              "language_id" => $lang->{"id"},
 
3527              "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
 
3528              "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
 
3534   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
 
3535   $ddbox = AM->unit_select_data($units, undef, 1);
 
3537   $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
 
3539   print($form->parse_html_template("am/edit_units",
 
3540                                    { "UNITS" => \@unit_list,
 
3541                                      "NEW_BASE_UNIT_DDBOX" => $ddbox,
 
3542                                      "LANGUAGES" => \@languages }));
 
3544   $lxdebug->leave_sub();
 
3548   $lxdebug->enter_sub();
 
3550   $form->isblank("new_name", $locale->text("The name is missing."));
 
3551   $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
 
3552   $all_units = AM->retrieve_units(\%myconfig, $form);
 
3553   $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
 
3555   my ($base_unit, $factor);
 
3556   if ($form->{"new_base_unit"}) {
 
3557     $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
 
3559     $form->isblank("new_factor", $locale->text("The factor is missing."));
 
3560     $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
 
3561     $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
 
3562     $base_unit = $form->{"new_base_unit"};
 
3566   foreach my $lang (AM->language(\%myconfig, $form, 1)) {
 
3567     next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
 
3568     push(@languages, { "id" => $lang->{"id"},
 
3569                        "localized" => $form->{"new_localized_$lang->{id}"},
 
3570                        "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
 
3574   AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
 
3576   $form->{"saved_message"} = $locale->text("The unit has been saved.");
 
3580   $lxdebug->leave_sub();
 
3583 sub set_unit_languages {
 
3584   $lxdebug->enter_sub();
 
3586   my ($unit, $languages, $idx) = @_;
 
3588   $unit->{"LANGUAGES"} = [];
 
3590   foreach my $lang (@{$languages}) {
 
3591     push(@{ $unit->{"LANGUAGES"} },
 
3592          { "id" => $lang->{"id"},
 
3593            "localized" => $form->{"localized_${idx}_$lang->{id}"},
 
3594            "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
 
3598   $lxdebug->leave_sub();
 
3602   $lxdebug->enter_sub();
 
3604   $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
 
3605   AM->units_in_use(\%myconfig, $form, $old_units);
 
3607   @languages = AM->language(\%myconfig, $form, 1);
 
3611   foreach $i (1..($form->{"rowcount"} * 1)) {
 
3612     $old_unit = $old_units->{$form->{"old_name_$i"}};
 
3614       $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
 
3617     if ($form->{"unchangeable_$i"}) {
 
3618       $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
 
3619       $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
 
3620       set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
 
3624     if ($old_unit->{"in_use"}) {
 
3625       $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
 
3628     if ($form->{"delete_$i"}) {
 
3629       push(@delete_units, $old_unit->{"name"});
 
3633     $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
 
3635     $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
 
3636     my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
 
3637     $new_units->{$form->{"name_$i"}} = \%h;
 
3638     $new_units->{$form->{"name_$i"}}->{"row"} = $i;
 
3639     set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
 
3642   foreach $unit (values(%{$new_units})) {
 
3643     next unless ($unit->{"old_name"});
 
3644     if ($unit->{"base_unit"}) {
 
3645       $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"}))
 
3646         unless (defined($new_units->{$unit->{"base_unit"}}));
 
3647       $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
 
3648       $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
 
3650       $unit->{"base_unit"} = undef;
 
3651       $unit->{"factor"} = undef;
 
3655   foreach $unit (values(%{$new_units})) {
 
3656     next if ($unit->{"unchanged_unit"});
 
3658     map({ $_->{"seen"} = 0; } values(%{$new_units}));
 
3660     while ($new_unit->{"base_unit"}) {
 
3661       $new_unit->{"seen"} = 1;
 
3662       $new_unit = $new_units->{$new_unit->{"base_unit"}};
 
3663       if ($new_unit->{"seen"}) {
 
3664         $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, " .
 
3665                                                         "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
 
3670   AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
 
3672   $form->{"saved_message"} = $locale->text("The units have been saved.");
 
3676   $lxdebug->leave_sub();