1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger Accounting
9 # Copyright (c) 1998-2002
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
32 #======================================================================
45 require "$form->{path}/common.pl";
49 sub add { &{"add_$form->{type}"} }
50 sub edit { &{"edit_$form->{type}"} }
51 sub save { &{"save_$form->{type}"} }
52 sub delete { &{"delete_$form->{type}"} }
55 $lxdebug->enter_sub();
57 $form->{title} = "Add";
58 $form->{charttype} = "A";
59 AM->get_account(\%myconfig, \%$form);
62 "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}"
63 unless $form->{callback};
68 $lxdebug->leave_sub();
72 $lxdebug->enter_sub();
74 $form->{title} = "Edit";
75 AM->get_account(\%myconfig, \%$form);
77 foreach my $item (split(/:/, $form->{link})) {
78 $form->{$item} = "checked";
84 $lxdebug->leave_sub();
88 $lxdebug->enter_sub();
90 $form->{title} = $locale->text("$form->{title} Account");
92 $checked{ $form->{charttype} } = "checked";
93 $checked{"$form->{category}_"} = "checked";
94 $checked{CT_tax} = ($form->{CT_tax}) ? "" : "checked";
96 $form->{description} =~ s/\"/"/g;
98 if (@{ $form->{TAXKEY} }) {
99 foreach $item (@{ $form->{TAXKEY} }) {
100 if ($item->{tax} == $form->{tax}) {
101 $form->{selecttaxkey} .=
102 "<option value=$item->{tax} selected>$item->{taxdescription}\n";
104 $form->{selecttaxkey} .=
105 "<option value=$item->{tax}>$item->{taxdescription}\n";
113 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
114 <td><select name=tax>$form->{selecttaxkey}</select></td>
115 <th align=right>| . $locale->text('Gültig ab') . qq|</th>
116 <td><input name=startdate value="$form->{startdate}"></td>
119 if (@{ $form->{NEWACCOUNT} }) {
120 if (!$form->{new_chart_valid}) {
121 $form->{selectnewaccount} = "<option value=></option>";
123 foreach $item (@{ $form->{NEWACCOUNT} }) {
124 if ($item->{id} == $form->{new_chart_id}) {
125 $form->{selectnewaccount} .=
126 "<option value=$item->{id} selected>$item->{accno}--$item->{description}</option>";
127 } elsif (!$form->{new_chart_valid}) {
128 $form->{selectnewaccount} .=
129 "<option value=$item->{id}>$item->{accno}--$item->{description}</option>";
140 <th align=right>| . $locale->text('Folgekonto') . qq|</th>
141 <td><select name=new_chart_id>$form->{selectnewaccount}</select></td>
142 <th align=right>| . $locale->text('Gültig ab') . qq|</th>
143 <td><input name=valid_from value="$form->{valid_from}"></td>
149 $form->{selectustva} = "<option>\n";
151 %ustva = (35 => $locale->text('UStVA-Nr. 35'),
152 36 => $locale->text('UStVA-Nr. 36'),
153 39 => $locale->text('UStVA-Nr. 39'),
154 41 => $locale->text('UStVA-Nr. 41'),
155 42 => $locale->text('UStVA-Nr. 42'),
156 43 => $locale->text('UStVA-Nr. 43'),
157 44 => $locale->text('UStVA-Nr. 44'),
158 45 => $locale->text('UStVA-Nr. 45'),
159 48 => $locale->text('UStVA-Nr. 48'),
160 49 => $locale->text('UStVA-Nr. 49'),
161 51 => $locale->text('UStVA-Nr. 51 left'),
162 511 => $locale->text('UStVA-Nr. 51 right'),
163 52 => $locale->text('UStVA-Nr. 52'),
164 53 => $locale->text('UStVA-Nr. 53'),
165 59 => $locale->text('UStVA-Nr. 59'),
166 60 => $locale->text('UStVA-Nr. 60'),
167 61 => $locale->text('UStVA-Nr. 61'),
168 62 => $locale->text('UStVA-Nr. 62'),
169 63 => $locale->text('UStVA-Nr. 63'),
170 64 => $locale->text('UStVA-Nr. 64'),
171 65 => $locale->text('UStVA-Nr. 65'),
172 66 => $locale->text('UStVA-Nr. 66'),
173 67 => $locale->text('UStVA-Nr. 67'),
174 69 => $locale->text('UStVA-Nr. 69'),
175 73 => $locale->text('UStVA-Nr. 73'),
176 74 => $locale->text('UStVA-Nr. 74'),
177 76 => $locale->text('UStVA-Nr. 76'),
178 77 => $locale->text('UStVA-Nr. 77'),
179 80 => $locale->text('UStVA-Nr. 80'),
180 84 => $locale->text('UStVA-Nr. 84'),
181 85 => $locale->text('UStVA-Nr. 85'),
182 86 => $locale->text('UStVA-Nr. 86 left'),
183 861 => $locale->text('UStVA-Nr. 86 right'),
184 91 => $locale->text('UStVA-Nr. 91'),
185 93 => $locale->text('UStVA-Nr. 93 left'),
186 931 => $locale->text('UStVA-Nr. 93 right'),
187 94 => $locale->text('UStVA-Nr. 94'),
188 95 => $locale->text('UStVA-Nr. 95'),
189 96 => $locale->text('UStVA-Nr. 96'),
190 97 => $locale->text('UStVA-Nr. 97 links'),
191 971 => $locale->text('UStVA-Nr. 97 rechts'),
192 98 => $locale->text('UStVA-Nr. 98'));
194 foreach $item (sort({ $a cmp $b } keys %ustva)) {
195 if ($item == $form->{pos_ustva}) {
196 $form->{selectustva} .= "<option value=$item selected>$ustva{$item}\n";
198 $form->{selectustva} .= "<option value=$item>$ustva{$item}\n";
205 <th align=right>| . $locale->text('Umsatzsteuervoranmeldung') . qq|</th>
206 <td><select name=pos_ustva>$form->{selectustva}</select></td>
207 <input type=hidden name=selectustva value="$form->{selectustva}">
210 $form->{selecteur} = "<option>\n";
211 %eur = (1 => "Umsatzerlöse",
212 2 => "sonstige Erlöse",
213 3 => "Privatanteile",
215 5 => "Ausserordentliche Erträge",
216 6 => "Vereinnahmte Umsatzst.",
217 7 => "Umsatzsteuererstattungen",
218 8 => "Wareneingänge",
219 9 => "Löhne und Gehälter",
220 10 => "Gesetzl. sozialer Aufw.",
222 12 => "Gas, Strom, Wasser",
223 13 => "Instandhaltung",
224 14 => "Steuern, Versich., Beiträge",
226 16 => "Kfz-Versicherungen",
227 17 => "Sonst. Fahrtkosten",
228 18 => "Werbe- und Reisekosten",
229 19 => "Instandhaltung u. Werkzeuge",
230 20 => "Fachzeitschriften, Bücher",
231 21 => "Miete für Einrichtungen",
232 22 => "Rechts- und Beratungskosten",
233 23 => "Bürobedarf, Porto, Telefon",
234 24 => "Sonstige Aufwendungen",
235 25 => "Abschreibungen auf Anlagever.",
236 26 => "Abschreibungen auf GWG",
238 28 => "Umsatzsteuerzahlungen",
240 30 => "Ausserordentlicher Aufwand",
241 31 => "Betriebliche Steuern");
242 foreach $item (sort({ $a <=> $b } keys(%eur))) {
243 if ($item == $form->{pos_eur}) {
244 $form->{selecteur} .= "<option value=$item selected>$eur{$item}\n";
246 $form->{selecteur} .= "<option value=$item>$eur{$item}\n";
253 <th align=right>| . $locale->text('EUER') . qq|</th>
254 <td><select name=pos_eur>$form->{selecteur}</select></td>
255 <input type=hidden name=selecteur value="$form->{selecteur}">
258 $form->{selectbwa} = "<option>\n";
260 %bwapos = (1 => 'Umsatzerlöse',
261 2 => 'Best.Verdg.FE/UE',
262 3 => 'Aktiv.Eigenleistung',
263 4 => 'Mat./Wareneinkauf',
264 5 => 'So.betr.Erlöse',
265 10 => 'Personalkosten',
267 12 => 'Betriebl.Steuern',
268 13 => 'Vers./Beiträge',
269 14 => 'Kfz.Kosten o.St.',
270 15 => 'Werbe-Reisek.',
271 16 => 'Kosten Warenabgabe',
272 17 => 'Abschreibungen',
273 18 => 'Rep./instandhlt.',
274 19 => 'Übrige Steuern',
275 20 => 'Sonst.Kosten',
277 31 => 'Sonst.neutr.Aufw.',
279 33 => 'Sonst.neutr.Ertrag',
280 34 => 'Verr.kalk.Kosten',
281 35 => 'Steuern Eink.u.Ertr.');
282 foreach $item (sort({ $a <=> $b } keys %bwapos)) {
283 if ($item == $form->{pos_bwa}) {
284 $form->{selectbwa} .= "<option value=$item selected>$bwapos{$item}\n";
286 $form->{selectbwa} .= "<option value=$item>$bwapos{$item}\n";
293 <th align=right>| . $locale->text('BWA') . qq|</th>
294 <td><select name=pos_bwa>$form->{selectbwa}</select></td>
295 <input type=hidden name=selectbwa value="$form->{selectbwa}">
298 # Entfernt bis es ordentlich umgesetzt wird (hli) 30.03.2006
299 # $form->{selectbilanz} = "<option>\n";
300 # foreach $item ((1, 2, 3, 4)) {
301 # if ($item == $form->{pos_bilanz}) {
302 # $form->{selectbilanz} .= "<option value=$item selected>$item\n";
304 # $form->{selectbilanz} .= "<option value=$item>$item\n";
311 # <th align=right>| . $locale->text('Bilanz') . qq|</th>
312 # <td><select name=pos_bilanz>$form->{selectbilanz}</select></td>
313 # <input type=hidden name=selectbilanz value="$form->{selectbilanz}">
316 # this is for our parser only!
317 # type=submit $locale->text('Add Account')
318 # type=submit $locale->text('Edit Account')
319 $form->{type} = "account";
326 <form method=post action=$form->{script}>
328 <input type=hidden name=id value=$form->{id}>
329 <input type=hidden name=type value=account>
330 <input type=hidden name=orphaned value=$form->{orphaned}>
331 <input type=hidden name=new_chart_valid value=$form->{new_chart_valid}>
333 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>
334 <input type=hidden name=income_accno_id value=$form->{income_accno_id}>
335 <input type=hidden name=expense_accno_id value=$form->{expense_accno_id}>
336 <input type=hidden name=fxgain_accno_id value=$form->{fxgain_accno_id}>
337 <input type=hidden name=fxloss_accno_id value=$form->{fxloss_accno_id}>
339 <table border=0 width=100%>
341 <th class=listtop>$form->{title}</th>
348 <th align=right>| . $locale->text('Account Number') . qq|</th>
349 <td><input name=accno size=20 value=$form->{accno}></td>
352 <th align=right>| . $locale->text('Description') . qq|</th>
353 <td><input name=description size=40 value="$form->{description}"></td>
356 <th align=right>| . $locale->text('Account Type') . qq|</th>
360 <td><input name=category type=radio class=radio value=A $checked{A_}> |
361 . $locale->text('Asset') . qq|\n<br>
362 <input name=category type=radio class=radio value=L $checked{L_}> |
363 . $locale->text('Liability') . qq|\n<br>
364 <input name=category type=radio class=radio value=Q $checked{Q_}> |
365 . $locale->text('Equity') . qq|\n<br>
366 <input name=category type=radio class=radio value=I $checked{I_}> |
367 . $locale->text('Revenue') . qq|\n<br>
368 <input name=category type=radio class=radio value=E $checked{E_}> |
369 . $locale->text('Expense') . qq|<br>
370 <input name=category type=radio class=radio value=C $checked{C_}> |
371 . $locale->text('Costs') . qq|</td>
372 <td width=50> </td>
374 <input name=charttype type=radio class=radio value="H" $checked{H}> |
375 . $locale->text('Heading') . qq|<br>
376 <input name=charttype type=radio class=radio value="A" $checked{A}> |
377 . $locale->text('Account') . qq|</td>
384 if ($form->{charttype} eq "A") {
391 . $locale->text('Is this a summary account to record') . qq|</th>
393 <input name=AR type=checkbox class=checkbox value=AR $form->{AR}> |
394 . $locale->text('AR')
395 . qq| <input name=AP type=checkbox class=checkbox value=AP $form->{AP}> |
396 . $locale->text('AP')
397 . qq| <input name=IC type=checkbox class=checkbox value=IC $form->{IC}> |
398 . $locale->text('Inventory')
405 <th colspan=2>| . $locale->text('Include in drop-down menus') . qq|</th>
411 <th align=left>| . $locale->text('Receivables') . qq|</th>
412 <th align=left>| . $locale->text('Payables') . qq|</th>
413 <th align=left>| . $locale->text('Parts Inventory') . qq|</th>
414 <th align=left>| . $locale->text('Service Items') . qq|</th>
418 <input name=AR_amount type=checkbox class=checkbox value=AR_amount $form->{AR_amount}> |
419 . $locale->text('Revenue') . qq|\n<br>
420 <input name=AR_paid type=checkbox class=checkbox value=AR_paid $form->{AR_paid}> |
421 . $locale->text('Receipt') . qq|\n<br>
422 <input name=AR_tax type=checkbox class=checkbox value=AR_tax $form->{AR_tax}> |
423 . $locale->text('Tax') . qq|
426 <input name=AP_amount type=checkbox class=checkbox value=AP_amount $form->{AP_amount}> |
427 . $locale->text('Expense/Asset') . qq|\n<br>
428 <input name=AP_paid type=checkbox class=checkbox value=AP_paid $form->{AP_paid}> |
429 . $locale->text('Payment') . qq|\n<br>
430 <input name=AP_tax type=checkbox class=checkbox value=AP_tax $form->{AP_tax}> |
431 . $locale->text('Tax') . qq|
434 <input name=IC_sale type=checkbox class=checkbox value=IC_sale $form->{IC_sale}> |
435 . $locale->text('Revenue') . qq|\n<br>
436 <input name=IC_cogs type=checkbox class=checkbox value=IC_cogs $form->{IC_cogs}> |
437 . $locale->text('Expense') . qq|\n<br>
438 <input name=IC_taxpart type=checkbox class=checkbox value=IC_taxpart $form->{IC_taxpart}> |
439 . $locale->text('Tax') . qq|
442 <input name=IC_income type=checkbox class=checkbox value=IC_income $form->{IC_income}> |
443 . $locale->text('Revenue') . qq|\n<br>
444 <input name=IC_expense type=checkbox class=checkbox value=IC_expense $form->{IC_expense}> |
445 . $locale->text('Expense') . qq|\n<br>
446 <input name=IC_taxservice type=checkbox class=checkbox value=IC_taxservice $form->{IC_taxservice}> |
447 . $locale->text('Tax') . qq|
467 <td><hr size=3 noshade></td>
472 $lxdebug->leave_sub();
476 $lxdebug->enter_sub();
480 <input name=callback type=hidden value="$form->{callback}">
482 <input type=hidden name=path value=$form->{path}>
483 <input type=hidden name=login value=$form->{login}>
484 <input type=hidden name=password value=$form->{password}>
487 if ((!$form->{id}) || ($form->{id} && $form->{orphaned}) || (($form->{type} eq "account") && (!$form->{new_chart_valid}))) {
489 <input type=submit class=submit name=action value="|
490 . $locale->text('Save') . qq|">
494 if ($form->{id} && $form->{orphaned}) {
495 print qq|<input type=submit class=submit name=action value="|
496 . $locale->text('Delete') . qq|">|;
506 $lxdebug->leave_sub();
510 $lxdebug->enter_sub();
512 $form->isblank("accno", $locale->text('Account Number missing!'));
513 $form->isblank("category", $locale->text('Account Type missing!'));
515 $form->redirect($locale->text('Account saved!'))
516 if (AM->save_account(\%myconfig, \%$form));
517 $form->error($locale->text('Cannot save account!'));
519 $lxdebug->leave_sub();
523 $lxdebug->enter_sub();
525 CA->all_accounts(\%myconfig, \%$form);
527 $form->{title} = $locale->text('Chart of Accounts');
531 "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}";
536 $callback = $form->escape($callback);
538 foreach $ca (@{ $form->{CA} }) {
540 $ca->{debit} = " ";
541 $ca->{credit} = " ";
543 if ($ca->{amount} > 0) {
545 $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
547 if ($ca->{amount} < 0) {
549 $form->format_amount(\%myconfig, -$ca->{amount}, 2, " ");
552 my @links = split( q{:}, $ca->{link});
556 foreach my $link (@links){
557 $link = ( $link eq 'AR') ? $locale->text('Account Link AR')
558 : ( $link eq 'AP') ? $locale->text('Account Link AP')
559 : ( $link eq 'IC') ? $locale->text('Account Link IC')
560 : ( $link eq 'AR_amount' ) ? $locale->text('Account Link AR_amount')
561 : ( $link eq 'AR_paid' ) ? $locale->text('Account Link AR_paid')
562 : ( $link eq 'AR_tax' ) ? $locale->text('Account Link AR_tax')
563 : ( $link eq 'AP_amount' ) ? $locale->text('Account Link AP_amount')
564 : ( $link eq 'AP_paid' ) ? $locale->text('Account Link AP_paid')
565 : ( $link eq 'AP_tax' ) ? $locale->text('Account Link AP_tax')
566 : ( $link eq 'IC_sale' ) ? $locale->text('Account Link IC_sale')
567 : ( $link eq 'IC_cogs' ) ? $locale->text('Account Link IC_cogs')
568 : ( $link eq 'IC_taxpart' ) ? $locale->text('Account Link IC_taxpart')
569 : ( $link eq 'IC_income' ) ? $locale->text('Account Link IC_income')
570 : ( $link eq 'IC_expense' ) ? $locale->text('Account Link IC_expense')
571 : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice')
572 : ( $link eq 'CT_tax' ) ? $locale->text('Account Link CT_tax')
573 : $locale->text('Unknown Link') . ': ' . $link;
575 $ca->{link} .= qq|[| . $link . qq|] |;
578 $ca->{startdate} =~ s/,/<br>/og;
579 $ca->{tk_ustva} =~ s/,/<br>/og;
581 $ca->{taxkey_id} =~ s/,/<br>/og;
582 $ca->{taxdescription} =~ s/,/<br>/og;
584 $ca->{datevautomatik} = ($ca->{datevautomatik}) ? $locale->text('On'):q{};
586 $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
587 : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
588 : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
589 : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
590 : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
591 : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
592 : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
593 : $locale->text('Unknown Category') . ': ' . $ca->{category};
595 $ca->{link_edit_account} =
596 qq|$form->{script}?action=edit_account&id=$ca->{id}|
597 .qq|&path=$form->{path}&login=$form->{login}|
598 .qq|&password=$form->{password}&callback=$callback>$ca->{accno}|;
601 my $parameters_ref = {
604 # hidden_variables => $_hidden_variables_ref,
607 # Ausgabe des Templates
608 print($form->parse_html_template('am/list_accounts', $parameters_ref));
610 $lxdebug->leave_sub();
616 $lxdebug->enter_sub();
618 $form->{title} = $locale->text('Delete Account');
621 qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
623 if ($form->{id} == $form->{$id}) {
624 $form->error($locale->text('Cannot delete default account!'));
628 $form->redirect($locale->text('Account deleted!'))
629 if (AM->delete_account(\%myconfig, \%$form));
630 $form->error($locale->text('Cannot delete account!'));
632 $lxdebug->leave_sub();
636 $lxdebug->enter_sub();
638 @{ $form->{fields} } = (accno, description);
639 $form->{table} = "gifi";
640 $form->{sortorder} = "accno";
642 AM->gifi_accounts(\%myconfig, \%$form);
644 $form->{title} = $locale->text('GIFI');
648 "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&password=$form->{password}";
650 @column_index = qw(accno description);
652 $column_header{accno} = qq|<th>| . $locale->text('GIFI') . qq|</a></th>|;
653 $column_header{description} =
654 qq|<th>| . $locale->text('Description') . qq|</a></th>|;
657 $colspan = $#column_index + 1;
664 <th class=listtop colspan=$colspan>$form->{title}</th>
667 <tr class=listheading>
670 map { print "$column_header{$_}\n" } @column_index;
677 $callback = $form->escape($callback);
679 foreach $ca (@{ $form->{ALL} }) {
685 <tr valign=top class=listrow$i>|;
687 $column_data{accno} =
688 qq|<td><a href=$form->{script}?action=edit_gifi&coa=1&accno=$ca->{accno}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ca->{accno}</td>|;
689 $column_data{description} = qq|<td>$ca->{description} </td>|;
691 map { print "$column_data{$_}\n" } @column_index;
698 <td colspan=$colspan><hr size=3 noshade></td>
706 $lxdebug->leave_sub();
710 $lxdebug->enter_sub();
712 $form->{title} = "Add";
716 "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&password=$form->{password}";
723 $lxdebug->leave_sub();
727 $lxdebug->enter_sub();
729 $form->{title} = "Edit";
731 AM->get_gifi(\%myconfig, \%$form);
736 $lxdebug->leave_sub();
740 $lxdebug->enter_sub();
742 $form->{title} = $locale->text("$form->{title} GIFI");
744 # $locale->text('Add GIFI')
745 # $locale->text('Edit GIFI')
747 $form->{description} =~ s/\"/"/g;
754 <form method=post action=$form->{script}>
756 <input type=hidden name=id value=$form->{accno}>
757 <input type=hidden name=type value=gifi>
761 <th class=listtop>$form->{title}</th>
768 <th align=right>| . $locale->text('GIFI') . qq|</th>
769 <td><input name=accno size=20 value=$form->{accno}></td>
772 <th align=right>| . $locale->text('Description') . qq|</th>
773 <td><input name=description size=60 value="$form->{description}"></td>
779 <td colspan=2><hr size=3 noshade></td>
784 $lxdebug->leave_sub();
788 $lxdebug->enter_sub();
792 <input name=callback type=hidden value="$form->{callback}">
794 <input type=hidden name=path value=$form->{path}>
795 <input type=hidden name=login value=$form->{login}>
796 <input type=hidden name=password value=$form->{password}>
798 <br><input type=submit class=submit name=action value="|
799 . $locale->text('Save') . qq|">|;
803 <input type=submit class=submit name=action value="|
804 . $locale->text('Copy to COA') . qq|">
807 if ($form->{accno} && $form->{orphaned}) {
808 print qq|<input type=submit class=submit name=action value="|
809 . $locale->text('Delete') . qq|">|;
820 $lxdebug->leave_sub();
824 $lxdebug->enter_sub();
826 $form->isblank("accno", $locale->text('GIFI missing!'));
827 AM->save_gifi(\%myconfig, \%$form);
828 $form->redirect($locale->text('GIFI saved!'));
830 $lxdebug->leave_sub();
834 $lxdebug->enter_sub();
836 $form->isblank("accno", $locale->text('GIFI missing!'));
838 AM->save_gifi(\%myconfig, \%$form);
841 $form->{gifi_accno} = $form->{accno};
842 $form->{title} = "Add";
843 $form->{charttype} = "A";
848 $lxdebug->leave_sub();
852 $lxdebug->enter_sub();
854 AM->delete_gifi(\%myconfig, \%$form);
855 $form->redirect($locale->text('GIFI deleted!'));
857 $lxdebug->leave_sub();
861 $lxdebug->enter_sub();
863 $form->{title} = "Add";
867 "$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}&password=$form->{password}"
868 unless $form->{callback};
873 $lxdebug->leave_sub();
876 sub edit_department {
877 $lxdebug->enter_sub();
879 $form->{title} = "Edit";
881 AM->get_department(\%myconfig, \%$form);
886 $lxdebug->leave_sub();
889 sub list_department {
890 $lxdebug->enter_sub();
892 AM->departments(\%myconfig, \%$form);
895 "$form->{script}?action=list_department&path=$form->{path}&login=$form->{login}&password=$form->{password}";
897 $callback = $form->escape($form->{callback});
899 $form->{title} = $locale->text('Departments');
901 @column_index = qw(description cost profit);
903 $column_header{description} =
904 qq|<th class=listheading width=90%>|
905 . $locale->text('Description')
907 $column_header{cost} =
908 qq|<th class=listheading nowrap>|
909 . $locale->text('Cost Center')
911 $column_header{profit} =
912 qq|<th class=listheading nowrap>|
913 . $locale->text('Profit Center')
923 <th class=listtop>$form->{title}</th>
929 <tr class=listheading>
932 map { print "$column_header{$_}\n" } @column_index;
938 foreach $ref (@{ $form->{ALL} }) {
944 <tr valign=top class=listrow$i>
947 $costcenter = ($ref->{role} eq "C") ? "X" : "";
948 $profitcenter = ($ref->{role} eq "P") ? "X" : "";
950 $column_data{description} =
951 qq|<td><a href=$form->{script}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
952 $column_data{cost} = qq|<td align=center>$costcenter</td>|;
953 $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
955 map { print "$column_data{$_}\n" } @column_index;
967 <td><hr size=3 noshade></td>
972 <form method=post action=$form->{script}>
974 <input name=callback type=hidden value="$form->{callback}">
976 <input type=hidden name=type value=department>
978 <input type=hidden name=path value=$form->{path}>
979 <input type=hidden name=login value=$form->{login}>
980 <input type=hidden name=password value=$form->{password}>
982 <input class=submit type=submit name=action value="|
983 . $locale->text('Add') . qq|">
991 $lxdebug->leave_sub();
994 sub department_header {
995 $lxdebug->enter_sub();
997 $form->{title} = $locale->text("$form->{title} Department");
999 # $locale->text('Add Department')
1000 # $locale->text('Edit Department')
1002 $form->{description} =~ s/\"/"/g;
1004 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
1006 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
1009 qq|<input name=description size=60 value="$form->{description}">|;
1012 $costcenter = "checked" if $form->{role} eq "C";
1013 $profitcenter = "checked" if $form->{role} eq "P";
1020 <form method=post action=$form->{script}>
1022 <input type=hidden name=id value=$form->{id}>
1023 <input type=hidden name=type value=department>
1027 <th class=listtop colspan=2>$form->{title}</th>
1029 <tr height="5"></tr>
1031 <th align=right>| . $locale->text('Description') . qq|</th>
1032 <td>$description</td>
1036 <td><input type=radio style=radio name=role value="C" $costcenter> |
1037 . $locale->text('Cost Center') . qq|
1038 <input type=radio style=radio name=role value="P" $profitcenter> |
1039 . $locale->text('Profit Center') . qq|
1042 <td colspan=2><hr size=3 noshade></td>
1047 $lxdebug->leave_sub();
1050 sub save_department {
1051 $lxdebug->enter_sub();
1053 $form->isblank("description", $locale->text('Description missing!'));
1054 AM->save_department(\%myconfig, \%$form);
1055 $form->redirect($locale->text('Department saved!'));
1057 $lxdebug->leave_sub();
1060 sub delete_department {
1061 $lxdebug->enter_sub();
1063 AM->delete_department(\%myconfig, \%$form);
1064 $form->redirect($locale->text('Department deleted!'));
1066 $lxdebug->leave_sub();
1070 $lxdebug->enter_sub();
1072 $form->{title} = "Add";
1075 "$form->{script}?action=add_lead&path=$form->{path}&login=$form->{login}&password=$form->{password}"
1076 unless $form->{callback};
1081 $lxdebug->leave_sub();
1085 $lxdebug->enter_sub();
1087 $form->{title} = "Edit";
1089 AM->get_lead(\%myconfig, \%$form);
1093 $form->{orphaned} = 1;
1096 $lxdebug->leave_sub();
1100 $lxdebug->enter_sub();
1102 AM->lead(\%myconfig, \%$form);
1105 "$form->{script}?action=list_lead&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1107 $callback = $form->escape($form->{callback});
1109 $form->{title} = $locale->text('Lead');
1111 @column_index = qw(description cost profit);
1113 $column_header{description} =
1114 qq|<th class=listheading width=100%>|
1115 . $locale->text('Description')
1125 <th class=listtop>$form->{title}</th>
1127 <tr height="5"></tr>
1128 <tr class=listheading>
1131 map { print "$column_header{$_}\n" } @column_index;
1137 foreach $ref (@{ $form->{ALL} }) {
1143 <tr valign=top class=listrow$i>
1146 $lead = $ref->{lead};
1148 $column_data{description} =
1149 qq|<td><a href=$form->{script}?action=edit_lead&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{lead}</td>|;
1151 map { print "$column_data{$_}\n" } @column_index;
1160 <td><hr size=3 noshade></td>
1165 <form method=post action=$form->{script}>
1167 <input name=callback type=hidden value="$form->{callback}">
1169 <input type=hidden name=type value=lead>
1171 <input type=hidden name=path value=$form->{path}>
1172 <input type=hidden name=login value=$form->{login}>
1173 <input type=hidden name=password value=$form->{password}>
1175 <input class=submit type=submit name=action value="|
1176 . $locale->text('Add') . qq|">
1184 $lxdebug->leave_sub();
1188 $lxdebug->enter_sub();
1190 $form->{title} = $locale->text("$form->{title} Lead");
1192 # $locale->text('Add Lead')
1193 # $locale->text('Edit Lead')
1195 $form->{description} =~ s/\"/"/g;
1198 qq|<input name=description size=50 value="$form->{lead}">|;
1205 <form method=post action=$form->{script}>
1207 <input type=hidden name=id value=$form->{id}>
1208 <input type=hidden name=type value=lead>
1212 <th class=listtop colspan=2>$form->{title}</th>
1214 <tr height="5"></tr>
1216 <th align=right>| . $locale->text('Description') . qq|</th>
1217 <td>$description</td>
1219 <td colspan=2><hr size=3 noshade></td>
1224 $lxdebug->leave_sub();
1228 $lxdebug->enter_sub();
1230 $form->isblank("description", $locale->text('Description missing!'));
1231 AM->save_lead(\%myconfig, \%$form);
1232 $form->redirect($locale->text('lead saved!'));
1234 $lxdebug->leave_sub();
1238 $lxdebug->enter_sub();
1240 AM->delete_lead(\%myconfig, \%$form);
1241 $form->redirect($locale->text('lead deleted!'));
1243 $lxdebug->leave_sub();
1247 $lxdebug->enter_sub();
1249 $form->{title} = "Add";
1252 "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&password=$form->{password}"
1253 unless $form->{callback};
1258 $lxdebug->leave_sub();
1262 $lxdebug->enter_sub();
1264 $form->{title} = "Edit";
1266 AM->get_business(\%myconfig, \%$form);
1270 $form->{orphaned} = 1;
1273 $lxdebug->leave_sub();
1277 $lxdebug->enter_sub();
1279 AM->business(\%myconfig, \%$form);
1282 "$form->{script}?action=list_business&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1284 $callback = $form->escape($form->{callback});
1286 $form->{title} = $locale->text('Type of Business');
1288 @column_index = qw(description discount customernumberinit);
1290 $column_header{description} =
1291 qq|<th class=listheading width=60%>|
1292 . $locale->text('Description')
1294 $column_header{discount} =
1295 qq|<th class=listheading width=10%>|
1296 . $locale->text('Discount')
1298 $column_header{customernumberinit} =
1299 qq|<th class=listheading>|
1300 . $locale->text('Customernumberinit')
1310 <th class=listtop>$form->{title}</th>
1312 <tr height="5"></tr>
1316 <tr class=listheading>
1319 map { print "$column_header{$_}\n" } @column_index;
1325 foreach $ref (@{ $form->{ALL} }) {
1331 <tr valign=top class=listrow$i>
1335 $form->format_amount(\%myconfig, $ref->{discount} * 100, 1, " ");
1338 ? "<b>$ref->{description}</b>"
1339 : "$ref->{description}";
1340 $column_data{description} =
1341 qq|<td><a href=$form->{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$description</td>|;
1342 $column_data{discount} = qq|<td align=right>$discount</td>|;
1343 $column_data{customernumberinit} =
1344 qq|<td align=right>$ref->{customernumberinit}</td>|;
1346 map { print "$column_data{$_}\n" } @column_index;
1358 <td><hr size=3 noshade></td>
1363 <form method=post action=$form->{script}>
1365 <input name=callback type=hidden value="$form->{callback}">
1367 <input type=hidden name=type value=business>
1369 <input type=hidden name=path value=$form->{path}>
1370 <input type=hidden name=login value=$form->{login}>
1371 <input type=hidden name=password value=$form->{password}>
1373 <input class=submit type=submit name=action value="|
1374 . $locale->text('Add') . qq|">
1382 $lxdebug->leave_sub();
1385 sub business_header {
1386 $lxdebug->enter_sub();
1388 $form->{title} = $locale->text("$form->{title} Business");
1389 $form->{salesman} = "checked" if $form->{salesman};
1391 # $locale->text('Add Business')
1392 # $locale->text('Edit Business')
1394 $form->{description} =~ s/\"/"/g;
1396 $form->format_amount(\%myconfig, $form->{discount} * 100);
1403 <form method=post action=$form->{script}>
1405 <input type=hidden name=id value=$form->{id}>
1406 <input type=hidden name=type value=business>
1410 <th class=listtop colspan=2>$form->{title}</th>
1412 <tr height="5"></tr>
1414 <th align=right>| . $locale->text('Type of Business') . qq|</th>
1415 <td><input name=description size=30 value="$form->{description}"></td>
1418 <th align=right>| . $locale->text('Discount') . qq| %</th>
1419 <td><input name=discount size=5 value=$form->{discount}></td>
1422 <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
1423 <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
1426 <td align=right>| . $locale->text('Salesman') . qq|</td>
1427 <td><input name=salesman class=checkbox type=checkbox value=1 $form->{salesman}></td>
1429 <td colspan=2><hr size=3 noshade></td>
1434 $lxdebug->leave_sub();
1438 $lxdebug->enter_sub();
1440 $form->isblank("description", $locale->text('Description missing!'));
1441 AM->save_business(\%myconfig, \%$form);
1442 $form->redirect($locale->text('Business saved!'));
1444 $lxdebug->leave_sub();
1447 sub delete_business {
1448 $lxdebug->enter_sub();
1450 AM->delete_business(\%myconfig, \%$form);
1451 $form->redirect($locale->text('Business deleted!'));
1453 $lxdebug->leave_sub();
1457 $lxdebug->enter_sub();
1459 $form->{title} = "Add";
1462 "$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}&password=$form->{password}"
1463 unless $form->{callback};
1468 $lxdebug->leave_sub();
1472 $lxdebug->enter_sub();
1474 $form->{title} = "Edit";
1476 AM->get_language(\%myconfig, \%$form);
1480 $form->{orphaned} = 1;
1483 $lxdebug->leave_sub();
1487 $lxdebug->enter_sub();
1489 AM->language(\%myconfig, \%$form);
1492 "$form->{script}?action=list_language&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1494 $callback = $form->escape($form->{callback});
1496 $form->{title} = $locale->text('Languages');
1498 @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
1500 $column_header{description} =
1501 qq|<th class=listheading width=60%>|
1502 . $locale->text('Description')
1504 $column_header{template_code} =
1505 qq|<th class=listheading width=10%>|
1506 . $locale->text('Template Code')
1508 $column_header{article_code} =
1509 qq|<th class=listheading>|
1510 . $locale->text('Article Code')
1512 $column_header{output_numberformat} =
1513 qq|<th class=listheading>|
1514 . $locale->text('Number Format')
1516 $column_header{output_dateformat} =
1517 qq|<th class=listheading>|
1518 . $locale->text('Date Format')
1520 $column_header{output_longdates} =
1521 qq|<th class=listheading>|
1522 . $locale->text('Long Dates')
1532 <th class=listtop>$form->{title}</th>
1534 <tr height="5"></tr>
1538 <tr class=listheading>
1541 map { print "$column_header{$_}\n" } @column_index;
1547 foreach $ref (@{ $form->{ALL} }) {
1553 <tr valign=top class=listrow$i>
1557 $column_data{description} =
1558 qq|<td><a href=$form->{script}?action=edit_language&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
1559 $column_data{template_code} = qq|<td align=right>$ref->{template_code}</td>|;
1560 $column_data{article_code} =
1561 qq|<td align=right>$ref->{article_code}</td>|;
1562 $column_data{output_numberformat} =
1564 ($ref->{output_numberformat} ? $ref->{output_numberformat} :
1565 $locale->text("use program settings")) .
1567 $column_data{output_dateformat} =
1569 ($ref->{output_dateformat} ? $ref->{output_dateformat} :
1570 $locale->text("use program settings")) .
1572 $column_data{output_longdates} =
1574 ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
1577 map { print "$column_data{$_}\n" } @column_index;
1589 <td><hr size=3 noshade></td>
1594 <form method=post action=$form->{script}>
1596 <input name=callback type=hidden value="$form->{callback}">
1598 <input type=hidden name=type value=language>
1600 <input type=hidden name=path value=$form->{path}>
1601 <input type=hidden name=login value=$form->{login}>
1602 <input type=hidden name=password value=$form->{password}>
1604 <input class=submit type=submit name=action value="|
1605 . $locale->text('Add') . qq|">
1613 $lxdebug->leave_sub();
1616 sub language_header {
1617 $lxdebug->enter_sub();
1619 $form->{title} = $locale->text("$form->{title} Language");
1621 # $locale->text('Add Language')
1622 # $locale->text('Edit Language')
1624 $form->{description} =~ s/\"/"/g;
1625 $form->{template_code} =~ s/\"/"/g;
1626 $form->{article_code} =~ s/\"/"/g;
1632 qq|<option value="">| . $locale->text("use program settings") .
1634 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
1636 ($item eq $form->{output_numberformat})
1637 ? "<option selected>$item"
1643 qq|<option value="">| . $locale->text("use program settings") .
1645 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
1647 ($item eq $form->{output_dateformat})
1648 ? "<option selected>$item"
1656 <form method=post action=$form->{script}>
1658 <input type=hidden name=id value=$form->{id}>
1659 <input type=hidden name=type value=language>
1663 <th class=listtop colspan=2>$form->{title}</th>
1665 <tr height="5"></tr>
1667 <th align=right>| . $locale->text('Language') . qq|</th>
1668 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1671 <th align=right>| . $locale->text('Template Code') . qq|</th>
1672 <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
1675 <th align=right>| . $locale->text('Article Code') . qq|</th>
1676 <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
1679 <th align=right>| . $locale->text('Number Format') . qq|</th>
1680 <td><select name="output_numberformat">$numberformat</select></td>
1683 <th align=right>| . $locale->text('Date Format') . qq|</th>
1684 <td><select name="output_dateformat">$dateformat</select></td>
1687 <th align=right>| . $locale->text('Long Dates') . qq|</th>
1688 <td><input type="radio" name="output_longdates" value="1"| .
1689 ($form->{output_longdates} ? " checked" : "") .
1690 qq|>| . $locale->text("Yes") .
1691 qq|<input type="radio" name="output_longdates" value="0"| .
1692 ($form->{output_longdates} ? "" : " checked") .
1693 qq|>| . $locale->text("No") .
1696 <td colspan=2><hr size=3 noshade></td>
1701 $lxdebug->leave_sub();
1705 $lxdebug->enter_sub();
1707 $form->isblank("description", $locale->text('Language missing!'));
1708 $form->isblank("template_code", $locale->text('Template Code missing!'));
1709 $form->isblank("article_code", $locale->text('Article Code missing!'));
1710 AM->save_language(\%myconfig, \%$form);
1711 $form->redirect($locale->text('Language saved!'));
1713 $lxdebug->leave_sub();
1716 sub delete_language {
1717 $lxdebug->enter_sub();
1719 AM->delete_language(\%myconfig, \%$form);
1720 $form->redirect($locale->text('Language deleted!'));
1722 $lxdebug->leave_sub();
1726 sub add_buchungsgruppe {
1727 $lxdebug->enter_sub();
1729 # $locale->text("Add Buchungsgruppe")
1730 # $locale->text("Edit Buchungsgruppe")
1731 $form->{title} = "Add";
1734 "$form->{script}?action=add_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}"
1735 unless $form->{callback};
1736 AM->get_buchungsgruppe(\%myconfig, \%$form);
1737 $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
1738 for (my $i = 0; 4 > $i; $i++) {
1739 map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
1740 qw(income expense));
1743 &buchungsgruppe_header;
1746 $lxdebug->leave_sub();
1749 sub edit_buchungsgruppe {
1750 $lxdebug->enter_sub();
1752 $form->{title} = "Edit";
1754 AM->get_buchungsgruppe(\%myconfig, \%$form);
1756 &buchungsgruppe_header;
1760 $lxdebug->leave_sub();
1763 sub list_buchungsgruppe {
1764 $lxdebug->enter_sub();
1766 AM->buchungsgruppe(\%myconfig, \%$form);
1769 "$form->{script}?action=list_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1771 $callback = $form->escape($form->{callback});
1773 $form->{title} = $locale->text('Buchungsgruppen');
1775 @column_index = qw(up down description inventory_accno
1776 income_accno_0 expense_accno_0
1777 income_accno_1 expense_accno_1
1778 income_accno_2 expense_accno_2
1779 income_accno_3 expense_accno_3 );
1781 $column_header{up} =
1782 qq|<th class="listheading">|
1783 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
1785 $column_header{down} =
1786 qq|<th class="listheading">|
1787 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
1789 $column_header{description} =
1790 qq|<th class="listheading" width="40%">|
1791 . $locale->text('Description')
1793 $column_header{inventory_accno} =
1794 qq|<th class=listheading>|
1795 . $locale->text('Bestandskonto')
1797 $column_header{income_accno_0} =
1798 qq|<th class=listheading>|
1799 . $locale->text('Erlöse Inland')
1801 $column_header{expense_accno_0} =
1802 qq|<th class=listheading>|
1803 . $locale->text('Aufwand Inland')
1805 $column_header{income_accno_1} =
1806 qq|<th class=listheading>|
1807 . $locale->text('Erlöse EU m. UStId')
1809 $column_header{expense_accno_1} =
1810 qq|<th class=listheading>|
1811 . $locale->text('Aufwand EU m. UStId')
1813 $column_header{income_accno_2} =
1814 qq|<th class=listheading>|
1815 . $locale->text('Erlöse EU o. UStId')
1817 $column_header{expense_accno_2} =
1818 qq|<th class=listheading>|
1819 . $locale->text('Aufwand EU o. UStId')
1821 $column_header{income_accno_3} =
1822 qq|<th class=listheading>|
1823 . $locale->text('Erlöse Ausland')
1825 $column_header{expense_accno_3} =
1826 qq|<th class=listheading>|
1827 . $locale->text('Aufwand Ausland')
1836 <th class=listtop>$form->{title}</th>
1838 <tr height="5"></tr>
1842 <tr class=listheading>
1845 map { print "$column_header{$_}\n" } @column_index;
1851 my $swap_link = qq|$form->{script}?action=swap_buchungsgruppen&|;
1852 map({ $swap_link .= $_ . "=" . $form->escape($form->{$_}) . "&" }
1853 qw(login password path));
1856 foreach $ref (@{ $form->{ALL} }) {
1862 <tr valign=top class=listrow$i>
1866 my $pref = $form->{ALL}->[$row - 1];
1868 qq|<td align="center" valign="center">| .
1869 qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
1870 qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">| .
1873 $column_data{up} = qq|<td> </td>|;
1876 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
1877 $column_data{down} = qq|<td> </td>|;
1879 my $nref = $form->{ALL}->[$row + 1];
1880 $column_data{down} =
1881 qq|<td align="center" valign="center">| .
1882 qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
1883 qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">| .
1887 $column_data{description} =
1888 qq|<td><a href=$form->{script}?action=edit_buchungsgruppe&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
1889 $column_data{inventory_accno} = qq|<td align=right>$ref->{inventory_accno}</td>|;
1890 $column_data{income_accno_0} =
1891 qq|<td align=right>$ref->{income_accno_0}</td>|;
1892 $column_data{expense_accno_0} = qq|<td align=right>$ref->{expense_accno_0}</td>|;
1893 $column_data{income_accno_1} =
1894 qq|<td align=right>$ref->{income_accno_1}</td>|;
1895 $column_data{expense_accno_1} = qq|<td align=right>$ref->{expense_accno_1}</td>|;
1896 $column_data{income_accno_2} =
1897 qq|<td align=right>$ref->{income_accno_2}</td>|;
1898 $column_data{expense_accno_2} = qq|<td align=right>$ref->{expense_accno_2}</td>|;
1899 $column_data{income_accno_3} =
1900 qq|<td align=right>$ref->{income_accno_3}</td>|;
1901 $column_data{expense_accno_3} = qq|<td align=right>$ref->{expense_accno_3}</td>|;
1903 map { print "$column_data{$_}\n" } @column_index;
1917 <td><hr size=3 noshade></td>
1922 <form method=post action=$form->{script}>
1924 <input name=callback type=hidden value="$form->{callback}">
1926 <input type=hidden name=type value=buchungsgruppe>
1928 <input type=hidden name=path value=$form->{path}>
1929 <input type=hidden name=login value=$form->{login}>
1930 <input type=hidden name=password value=$form->{password}>
1932 <input class=submit type=submit name=action value="|
1933 . $locale->text('Add') . qq|">
1941 $lxdebug->leave_sub();
1944 sub buchungsgruppe_header {
1945 $lxdebug->enter_sub();
1947 $form->{title} = $locale->text("$form->{title} Buchungsgruppe");
1949 # $locale->text('Buchungsgruppe hinzufügen')
1950 # $locale->text('Buchungsgruppe bearbeiten')
1952 my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
1953 my %acc_type_map = (
1954 "IC" => $acc_inventory,
1955 "IC_income" => $acc_income,
1956 "IC_sale" => $acc_income,
1957 "IC_expense" => $acc_expense,
1958 "IC_cogs" => $acc_expense,
1961 foreach $key (keys(%acc_type_map)) {
1962 foreach $ref (@{ $form->{IC_links}{$key} }) {
1963 $acc_type_map{$key}->{$ref->{"id"}} = $ref;
1967 foreach my $type (qw(IC IC_income IC_expense)) {
1968 $form->{"select$type"} =
1970 map({ "<option value=$_->{id} $_->{selected}>" .
1971 "$_->{accno}--" . H($_->{description}) . "</option>" }
1972 sort({ $a->{"accno"} cmp $b->{"accno"} }
1973 values(%{$acc_type_map{$type}}))));
1977 $form->{selectIC} =~ s/selected//g;
1978 $form->{selectIC} =~ s/ value=$form->{inventory_accno_id}/ value=$form->{inventory_accno_id} selected/;
1979 $form->{selectIC_income} =~ s/selected//g;
1980 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_0}/ value=$form->{income_accno_id_0} selected/;
1981 $form->{selectIC_expense} =~ s/selected//g;
1982 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_0}/ value=$form->{expense_accno_id_0} selected/;
1988 <th align=right>| . $locale->text('Inventory') . qq|</th>
1989 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
1990 <input name=selectIC type=hidden value="$form->{selectIC}">
1994 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
1998 $linkaccounts .= qq|
2000 <th align=right>| . $locale->text('Erlöse Inland') . qq|</th>
2001 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
2004 <th align=right>| . $locale->text('Aufwand Inland') . qq|</th>
2005 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
2008 $form->{selectIC_income} =~ s/selected//g;
2009 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_1}/ value=$form->{income_accno_id_1} selected/;
2010 $form->{selectIC_expense} =~ s/selected//g;
2011 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/ value=$form->{expense_accno_id_1} selected/;
2013 $linkaccounts .= qq| <tr>
2014 <th align=right>| . $locale->text('Erlöse EU m. UStId') . qq|</th>
2015 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
2018 <th align=right>| . $locale->text('Aufwand EU m UStId') . qq|</th>
2019 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
2023 $form->{selectIC_income} =~ s/selected//g;
2024 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_2}/ value=$form->{income_accno_id_2} selected/;
2025 $form->{selectIC_expense} =~ s/selected//g;
2026 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_2}/ value=$form->{expense_accno_id_2} selected/;
2029 $linkaccounts .= qq| <tr>
2030 <th align=right>| . $locale->text('Erlöse EU o. UStId') . qq|</th>
2031 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
2034 <th align=right>| . $locale->text('Aufwand EU o. UStId') . qq|</th>
2035 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
2039 $form->{selectIC_income} =~ s/selected//g;
2040 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_3}/ value=$form->{income_accno_id_3} selected/;
2041 $form->{selectIC_expense} =~ s/selected//g;
2042 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_3}/ value=$form->{expense_accno_id_3} selected/;
2045 $linkaccounts .= qq| <tr>
2046 <th align=right>| . $locale->text('Erlöse Ausland') . qq|</th>
2047 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
2050 <th align=right>| . $locale->text('Aufwand Ausland') . qq|</th>
2051 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
2061 <form method=post action=$form->{script}>
2063 <input type=hidden name=id value=$form->{id}>
2064 <input type=hidden name=type value=buchungsgruppe>
2068 <th class=listtop colspan=2>$form->{title}</th>
2070 <tr height="5"></tr>
2072 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
2073 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
2076 <td colspan=2><hr size=3 noshade></td>
2081 $lxdebug->leave_sub();
2084 sub save_buchungsgruppe {
2085 $lxdebug->enter_sub();
2087 $form->isblank("description", $locale->text('Description missing!'));
2089 AM->save_buchungsgruppe(\%myconfig, \%$form);
2090 $form->redirect($locale->text('Buchungsgruppe gespeichert!'));
2092 $lxdebug->leave_sub();
2095 sub delete_buchungsgruppe {
2096 $lxdebug->enter_sub();
2098 AM->delete_buchungsgruppe(\%myconfig, \%$form);
2099 $form->redirect($locale->text('Buchungsgruppe gelöscht!'));
2101 $lxdebug->leave_sub();
2104 sub swap_buchungsgruppen {
2105 $lxdebug->enter_sub();
2107 AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
2108 list_buchungsgruppe();
2110 $lxdebug->leave_sub();
2115 $lxdebug->enter_sub();
2117 $form->{title} = "Add";
2120 "$form->{script}?action=add_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}"
2121 unless $form->{callback};
2126 $lxdebug->leave_sub();
2130 $lxdebug->enter_sub();
2132 $form->{title} = "Edit";
2134 AM->get_printer(\%myconfig, \%$form);
2138 $form->{orphaned} = 1;
2141 $lxdebug->leave_sub();
2145 $lxdebug->enter_sub();
2147 AM->printer(\%myconfig, \%$form);
2150 "$form->{script}?action=list_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}";
2152 $callback = $form->escape($form->{callback});
2154 $form->{title} = $locale->text('Printer');
2156 @column_index = qw(printer_description printer_command template_code);
2158 $column_header{printer_description} =
2159 qq|<th class=listheading width=60%>|
2160 . $locale->text('Printer Description')
2162 $column_header{printer_command} =
2163 qq|<th class=listheading width=10%>|
2164 . $locale->text('Printer Command')
2166 $column_header{template_code} =
2167 qq|<th class=listheading>|
2168 . $locale->text('Template Code')
2178 <th class=listtop>$form->{title}</th>
2180 <tr height="5"></tr>
2184 <tr class=listheading>
2187 map { print "$column_header{$_}\n" } @column_index;
2193 foreach $ref (@{ $form->{ALL} }) {
2199 <tr valign=top class=listrow$i>
2203 $column_data{printer_description} =
2204 qq|<td><a href=$form->{script}?action=edit_printer&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{printer_description}</td>|;
2205 $column_data{printer_command} = qq|<td align=right>$ref->{printer_command}</td>|;
2206 $column_data{template_code} =
2207 qq|<td align=right>$ref->{template_code}</td>|;
2209 map { print "$column_data{$_}\n" } @column_index;
2221 <td><hr size=3 noshade></td>
2226 <form method=post action=$form->{script}>
2228 <input name=callback type=hidden value="$form->{callback}">
2230 <input type=hidden name=type value=printer>
2232 <input type=hidden name=path value=$form->{path}>
2233 <input type=hidden name=login value=$form->{login}>
2234 <input type=hidden name=password value=$form->{password}>
2236 <input class=submit type=submit name=action value="|
2237 . $locale->text('Add') . qq|">
2245 $lxdebug->leave_sub();
2248 sub printer_header {
2249 $lxdebug->enter_sub();
2251 $form->{title} = $locale->text("$form->{title} Printer");
2253 # $locale->text('Add Printer')
2254 # $locale->text('Edit Printer')
2256 $form->{printer_description} =~ s/\"/"/g;
2257 $form->{template_code} =~ s/\"/"/g;
2258 $form->{printer_command} =~ s/\"/"/g;
2266 <form method=post action=$form->{script}>
2268 <input type=hidden name=id value=$form->{id}>
2269 <input type=hidden name=type value=printer>
2273 <th class=listtop colspan=2>$form->{title}</th>
2275 <tr height="5"></tr>
2277 <th align=right>| . $locale->text('Printer') . qq|</th>
2278 <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
2281 <th align=right>| . $locale->text('Printer Command') . qq|</th>
2282 <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
2285 <th align=right>| . $locale->text('Template Code') . qq|</th>
2286 <td><input name=template_code size=5 value="$form->{template_code}"></td>
2288 <td colspan=2><hr size=3 noshade></td>
2293 $lxdebug->leave_sub();
2297 $lxdebug->enter_sub();
2299 $form->isblank("printer_description", $locale->text('Description missing!'));
2300 $form->isblank("printer_command", $locale->text('Printer Command missing!'));
2301 AM->save_printer(\%myconfig, \%$form);
2302 $form->redirect($locale->text('Printer saved!'));
2304 $lxdebug->leave_sub();
2307 sub delete_printer {
2308 $lxdebug->enter_sub();
2310 AM->delete_printer(\%myconfig, \%$form);
2311 $form->redirect($locale->text('Printer deleted!'));
2313 $lxdebug->leave_sub();
2318 $lxdebug->enter_sub();
2320 $form->{title} = "Add";
2323 "$form->{script}?action=add_payment&path=$form->{path}&login=$form->{login}&password=$form->{password}"
2324 unless $form->{callback};
2326 $form->{terms_netto} = 0;
2327 $form->{terms_skonto} = 0;
2328 $form->{percent_skonto} = 0;
2329 my @languages = AM->language(\%myconfig, $form, 1);
2330 map({ $_->{"language"} = $_->{"description"};
2331 $_->{"language_id"} = $_->{"id"}; } @languages);
2332 $form->{"TRANSLATION"} = \@languages;
2336 $lxdebug->leave_sub();
2340 $lxdebug->enter_sub();
2342 $form->{title} = "Edit";
2344 AM->get_payment(\%myconfig, $form);
2345 $form->{percent_skonto} =
2346 $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
2350 $form->{orphaned} = 1;
2353 $lxdebug->leave_sub();
2357 $lxdebug->enter_sub();
2359 AM->payment(\%myconfig, \%$form);
2361 $form->{callback} = build_std_url("action=list_payment");
2363 $callback = $form->escape($form->{callback});
2365 $form->{title} = $locale->text('Payment Terms');
2367 @column_index = qw(up down description description_long terms_netto
2368 terms_skonto percent_skonto);
2370 $column_header{up} =
2371 qq|<th class="listheading" align="center" valign="center">|
2372 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
2374 $column_header{down} =
2375 qq|<th class="listheading" align="center" valign="center">|
2376 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
2378 $column_header{description} =
2379 qq|<th class=listheading>|
2380 . $locale->text('Description')
2382 $column_header{description_long} =
2383 qq|<th class=listheading>|
2384 . $locale->text('Long Description')
2386 $column_header{terms_netto} =
2387 qq|<th class=listheading>|
2388 . $locale->text('Netto Terms')
2390 $column_header{terms_skonto} =
2391 qq|<th class=listheading>|
2392 . $locale->text('Skonto Terms')
2394 $column_header{percent_skonto} =
2395 qq|<th class=listheading>|
2396 . $locale->text('Skonto')
2406 <th class=listtop>$form->{title}</th>
2408 <tr height="5"></tr>
2412 <tr class=listheading>
2415 map { print "$column_header{$_}\n" } @column_index;
2421 my $swap_link = build_std_url("action=swap_payment_terms");
2424 foreach $ref (@{ $form->{ALL} }) {
2430 <tr valign=top class=listrow$i>
2434 my $pref = $form->{ALL}->[$row - 1];
2436 qq|<td align="center" valign="center">| .
2437 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
2438 qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">| .
2441 $column_data{up} = qq|<td> </td>|;
2444 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
2445 $column_data{down} = qq|<td> </td>|;
2447 my $nref = $form->{ALL}->[$row + 1];
2448 $column_data{down} =
2449 qq|<td align="center" valign="center">| .
2450 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
2451 qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">| .
2455 $column_data{description} =
2457 build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
2458 qq|">| . H($ref->{description}) . qq|</a></td>|;
2459 $column_data{description_long} =
2460 qq|<td align=right>| . H($ref->{description_long}) . qq|</td>|;
2461 $column_data{terms_netto} =
2462 qq|<td align=right>$ref->{terms_netto}</td>|;
2463 $column_data{terms_skonto} =
2464 qq|<td align=right>$ref->{terms_skonto}</td>|;
2465 $column_data{percent_skonto} =
2466 qq|<td align=right>| .
2467 $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
2469 map { print "$column_data{$_}\n" } @column_index;
2482 <td><hr size=3 noshade></td>
2487 <form method=post action=$form->{script}>
2489 <input name=callback type=hidden value="$form->{callback}">
2491 <input type=hidden name=type value=payment>
2493 <input type=hidden name=path value=$form->{path}>
2494 <input type=hidden name=login value=$form->{login}>
2495 <input type=hidden name=password value=$form->{password}>
2497 <input class=submit type=submit name=action value="|
2498 . $locale->text('Add') . qq|">
2506 $lxdebug->leave_sub();
2509 sub payment_header {
2510 $lxdebug->enter_sub();
2512 $form->{title} = $locale->text("$form->{title} Payment Terms");
2514 # $locale->text('Add Payment Terms')
2515 # $locale->text('Edit Payment Terms')
2517 $form->{description} =~ s/\"/"/g;
2526 <form method=post action=$form->{script}>
2528 <input type=hidden name=id value=$form->{id}>
2529 <input type=hidden name=type value=payment>
2533 <th class=listtop colspan=2>$form->{title}</th>
2535 <tr height="5"></tr>
2537 <th align=right>| . $locale->text('Description') . qq|</th>
2538 <td><input name=description size=30 value="$form->{description}"></td>
2541 <th align=right>| . $locale->text('Long Description') . qq|</th>
2542 <td><input name=description_long size=50 value="$form->{description_long}"></td>
2546 foreach my $language (@{ $form->{"TRANSLATION"} }) {
2549 <th align="right">| .
2550 sprintf($locale->text('Translation (%s)'),
2551 $language->{"language"})
2553 <td><input name="description_long_$language->{language_id}" size="50"
2554 value="| . Q($language->{"description_long"}) . qq|"></td>
2561 <th align=right>| . $locale->text('Netto Terms') . qq|</th>
2562 <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
2565 <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
2566 <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
2569 <th align=right>| . $locale->text('Skonto') . qq| %</th>
2570 <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
2572 <td colspan=2><hr size=3 noshade></td>
2576 <p>| . $locale->text("You can use the following strings in the long " .
2577 "description and all translations. They will be " .
2578 "replaced by their actual values by Lx-Office " .
2579 "before they're output.")
2583 <li>| . $locale->text("<%netto_date%> -- Date the payment is due in " .
2586 <li>| . $locale->text("<%skonto_date%> -- Date the payment is due " .
2589 <li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
2591 <li>| . $locale->text("<%total%> -- Amount payable")
2593 <li>| . $locale->text("<%invtotal%> -- Invoice total")
2595 <li>| . $locale->text("<%currency%> -- The selected currency")
2597 <li>| . $locale->text("<%terms_netto%> -- The number of days for " .
2600 <li>| . $locale->text("<%account_number%> -- Your account number")
2602 <li>| . $locale->text("<%bank%> -- Your bank")
2604 <li>| . $locale->text("<%bank_code%> -- Your bank code")
2608 $lxdebug->leave_sub();
2612 $lxdebug->enter_sub();
2614 $form->isblank("description", $locale->text('Description missing!'));
2615 $form->{"percent_skonto"} =
2616 $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
2617 AM->save_payment(\%myconfig, \%$form);
2618 $form->redirect($locale->text('Payment Terms saved!'));
2620 $lxdebug->leave_sub();
2623 sub delete_payment {
2624 $lxdebug->enter_sub();
2626 AM->delete_payment(\%myconfig, \%$form);
2627 $form->redirect($locale->text('Payment terms deleted!'));
2629 $lxdebug->leave_sub();
2632 sub swap_payment_terms {
2633 $lxdebug->enter_sub();
2635 AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
2638 $lxdebug->leave_sub();
2642 $lxdebug->enter_sub();
2644 $form->{title} = "Add";
2647 "$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}"
2648 unless $form->{callback};
2653 $lxdebug->leave_sub();
2657 $lxdebug->enter_sub();
2659 $form->{title} = "Edit";
2661 AM->get_sic(\%myconfig, \%$form);
2665 $form->{orphaned} = 1;
2668 $lxdebug->leave_sub();
2672 $lxdebug->enter_sub();
2674 AM->sic(\%myconfig, \%$form);
2677 "$form->{script}?action=list_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}";
2679 $callback = $form->escape($form->{callback});
2681 $form->{title} = $locale->text('Standard Industrial Codes');
2683 @column_index = qw(code description);
2685 $column_header{code} =
2686 qq|<th class=listheading>| . $locale->text('Code') . qq|</th>|;
2687 $column_header{description} =
2688 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
2697 <th class=listtop>$form->{title}</th>
2699 <tr height="5"></tr>
2703 <tr class=listheading>
2706 map { print "$column_header{$_}\n" } @column_index;
2712 foreach $ref (@{ $form->{ALL} }) {
2717 if ($ref->{sictype} eq 'H') {
2719 <tr valign=top class=listheading>
2721 $column_data{code} =
2722 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>|;
2723 $column_data{description} = qq|<th>$ref->{description}</th>|;
2727 <tr valign=top class=listrow$i>
2730 $column_data{code} =
2731 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>|;
2732 $column_data{description} = qq|<td>$ref->{description}</td>|;
2736 map { print "$column_data{$_}\n" } @column_index;
2748 <td><hr size=3 noshade></td>
2753 <form method=post action=$form->{script}>
2755 <input name=callback type=hidden value="$form->{callback}">
2757 <input type=hidden name=type value=sic>
2759 <input type=hidden name=path value=$form->{path}>
2760 <input type=hidden name=login value=$form->{login}>
2761 <input type=hidden name=password value=$form->{password}>
2763 <input class=submit type=submit name=action value="|
2764 . $locale->text('Add') . qq|">
2772 $lxdebug->leave_sub();
2776 $lxdebug->enter_sub();
2778 $form->{title} = $locale->text("$form->{title} SIC");
2780 # $locale->text('Add SIC')
2781 # $locale->text('Edit SIC')
2783 $form->{code} =~ s/\"/"/g;
2784 $form->{description} =~ s/\"/"/g;
2786 $checked = ($form->{sictype} eq 'H') ? "checked" : "";
2793 <form method=post action=$form->{script}>
2795 <input type=hidden name=type value=sic>
2796 <input type=hidden name=id value=$form->{code}>
2800 <th class=listtop colspan=2>$form->{title}</th>
2802 <tr height="5"></tr>
2804 <th align=right>| . $locale->text('Code') . qq|</th>
2805 <td><input name=code size=10 value=$form->{code}></td>
2809 <th align=left><input name=sictype type=checkbox style=checkbox value="H" $checked> |
2810 . $locale->text('Heading') . qq|</th>
2813 <th align=right>| . $locale->text('Description') . qq|</th>
2814 <td><input name=description size=60 value="$form->{description}"></td>
2816 <td colspan=2><hr size=3 noshade></td>
2821 $lxdebug->leave_sub();
2825 $lxdebug->enter_sub();
2827 $form->isblank("code", $locale->text('Code missing!'));
2828 $form->isblank("description", $locale->text('Description missing!'));
2829 AM->save_sic(\%myconfig, \%$form);
2830 $form->redirect($locale->text('SIC saved!'));
2832 $lxdebug->leave_sub();
2836 $lxdebug->enter_sub();
2838 AM->delete_sic(\%myconfig, \%$form);
2839 $form->redirect($locale->text('SIC deleted!'));
2841 $lxdebug->leave_sub();
2844 sub display_stylesheet {
2845 $lxdebug->enter_sub();
2847 $form->{file} = "css/$myconfig{stylesheet}";
2850 $lxdebug->leave_sub();
2854 $lxdebug->enter_sub();
2856 $form->{file} =~ s/^(.:)*?\/|\.\.\///g;
2857 $form->{file} =~ s/^\/*//g;
2858 $form->{file} =~ s/$userspath//;
2860 $form->error("$!: $form->{file}") unless -f $form->{file};
2862 AM->load_template(\%$form);
2864 $form->{title} = $form->{file};
2866 # if it is anything but html
2867 if ($form->{file} !~ /\.html$/) {
2868 $form->{body} = "<pre>\n$form->{body}\n</pre>";
2878 <form method=post action=$form->{script}>
2880 <input name=file type=hidden value=$form->{file}>
2881 <input name=type type=hidden value=template>
2883 <input type=hidden name=path value=$form->{path}>
2884 <input type=hidden name=login value=$form->{login}>
2885 <input type=hidden name=password value=$form->{password}>
2887 <input name=action type=submit class=submit value="|
2888 . $locale->text('Edit') . qq|">
2896 $lxdebug->leave_sub();
2900 $lxdebug->enter_sub();
2902 AM->load_template(\%$form);
2904 $form->{title} = $locale->text('Edit Template');
2906 # convert   to &nbsp;
2907 $form->{body} =~ s/ /&nbsp;/gi;
2914 <form method=post action=$form->{script}>
2916 <input name=file type=hidden value=$form->{file}>
2917 <input name=type type=hidden value=template>
2919 <input type=hidden name=path value=$form->{path}>
2920 <input type=hidden name=login value=$form->{login}>
2921 <input type=hidden name=password value=$form->{password}>
2923 <input name=callback type=hidden value="$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}&password=$form->{password}">
2925 <textarea name=body rows=25 cols=70>
2930 <input type=submit class=submit name=action value="|
2931 . $locale->text('Save') . qq|">
2940 $lxdebug->leave_sub();
2944 $lxdebug->enter_sub();
2946 AM->save_template(\%$form);
2947 $form->redirect($locale->text('Template saved!'));
2949 $lxdebug->leave_sub();
2953 $lxdebug->enter_sub();
2955 # get defaults for account numbers and last numbers
2956 AM->defaultaccounts(\%myconfig, \%$form);
2958 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
2960 ($item eq $myconfig{dateformat})
2961 ? "<option selected>$item\n"
2962 : "<option>$item\n";
2965 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
2967 ($item eq $myconfig{numberformat})
2968 ? "<option selected>$item\n"
2969 : "<option>$item\n";
2972 foreach $item (qw(name company address signature)) {
2973 $myconfig{$item} =~ s/\"/"/g;
2976 foreach $item (qw(address signature)) {
2977 $myconfig{$item} =~ s/\\n/\r\n/g;
2981 if ($opendocument_templates && $openofficeorg_writer_bin &&
2982 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
2983 push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
2984 "value" => "opendocument_pdf" });
2986 if ($latex_templates) {
2987 push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
2989 push(@formats, { "name" => "HTML", "value" => "html" });
2990 if ($latex_templates) {
2991 push(@formats, { "name" => $locale->text("Postscript"),
2992 "value" => "postscript" });
2994 if ($opendocument_templates) {
2995 push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
2996 "value" => "opendocument" });
2999 if (!$myconfig{"template_format"}) {
3000 $myconfig{"template_format"} = "pdf";
3002 my $template_format = "";
3003 foreach $item (@formats) {
3005 "<option value=\"$item->{value}\"" .
3006 ($item->{"value"} eq $myconfig{"template_format"} ?
3008 ">" . H($item->{"name"}) . "</option>";
3011 if (!$myconfig{"default_media"}) {
3012 $myconfig{"default_media"} = "screen";
3014 my %selected = ($myconfig{"default_media"} => "selected");
3015 my $default_media = qq|
3016 <option value="screen" $selected{'screen'}>| . $locale->text("Screen") . qq|</option>
3017 <option value="printer" $selected{'printer'}>| . $locale->text("Printer") . qq|</option>
3018 <option value="queue" $selected{'queue'}>| . $locale->text("Queue") . qq|</option>
3022 $selected{$myconfig{"default_printer_id"}} = "selected"
3023 if ($myconfig{"default_printer_id"});
3024 my $default_printer = qq|<option></option>|;
3025 AM->printer(\%myconfig, $form);
3026 foreach my $printer (@{$form->{"ALL"}}) {
3027 $default_printer .= qq|<option value="| . Q($printer->{"id"}) .
3028 qq|" $selected{$printer->{'id'}}>| .
3029 H($printer->{"printer_description"}) . qq|</option>|;
3032 %countrycodes = User->country_codes;
3034 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
3038 ($myconfig{countrycode} eq $key)
3039 ? "<option selected value=$key>$countrycodes{$key}\n"
3040 : "<option value=$key>$countrycodes{$key}\n";
3042 $countrycodes = "<option>American English\n$countrycodes";
3044 # use an other input number format than output numberformat
3045 # look at Form.pm, sub parse_amount
3046 my $in_numberformat = '';
3047 $text1 = qq|value="0">| . $locale->text('equal Outputformat');
3048 $text2 = qq|value="1">| . $locale->text('1000,00 or 1000.00');
3049 @in_nf = ($text1, $text2);
3050 foreach $item (@in_nf) {
3052 (substr($item, 7, 1) eq $myconfig{in_numberformat})
3053 ? "<option selected $item\n"
3054 : "<option $item\n";
3057 foreach $key (keys %{ $form->{IC} }) {
3058 foreach $accno (sort keys %{ $form->{IC}{$key} }) {
3060 ($form->{IC}{$key}{$accno}{id} == $form->{defaults}{$key})
3061 ? "<option selected>$accno--$form->{IC}{$key}{$accno}{description}\n"
3062 : "<option>$accno--$form->{IC}{$key}{$accno}{description}\n";
3066 opendir CSS, "css/.";
3067 @all = grep /.*\.css$/, readdir CSS;
3070 foreach $item (@all) {
3071 if ($item eq $myconfig{stylesheet}) {
3072 $selectstylesheet .= qq|<option selected>$item\n|;
3074 $selectstylesheet .= qq|<option>$item\n|;
3077 $selectstylesheet .= "<option>\n";
3079 $form->{title} = $locale->text('Edit Preferences for') . qq| $form->{login}|;
3083 if ($myconfig{menustyle} eq "old") {
3084 $menustyle_old = "checked";
3085 } elsif ($myconfig{menustyle} eq "neu") {
3086 $menustyle_neu = "checked";
3087 } elsif ($myconfig{menustyle} eq "v3") {
3088 $menustyle_v3 = "checked";
3091 my ($show_form_details, $hide_form_details);
3092 $myconfig{"show_form_details"} = 1
3093 unless (defined($myconfig{"show_form_details"}));
3094 $show_form_details = "checked" if ($myconfig{"show_form_details"});
3095 $hide_form_details = "checked" unless ($myconfig{"show_form_details"});
3100 <form method=post action=$form->{script}>
3102 <input type=hidden name=old_password value=$myconfig{password}>
3103 <input type=hidden name=type value=preferences>
3104 <input type=hidden name=role value=$myconfig{role}>
3107 <tr><th class=listtop>$form->{title}</th></tr>
3112 <th align=right>| . $locale->text('Name') . qq|</th>
3113 <td><input name=name size=15 value="$myconfig{name}"></td>
3116 <th align=right>| . $locale->text('Password') . qq|</th>
3117 <td><input type=password name=new_password size=10 value=$myconfig{password}></td>
3120 <th align=right>| . $locale->text('E-mail') . qq|</th>
3121 <td><input name=email size=30 value="$myconfig{email}"></td>
3124 <th align=right>| . $locale->text('Signature') . qq|</th>
3125 <td><textarea name=signature rows=3 cols=50>$myconfig{signature}</textarea></td>
3128 <th align=right>| . $locale->text('Phone') . qq|</th>
3129 <td><input name=tel size=14 value="$myconfig{tel}"></td>
3132 <th align=right>| . $locale->text('Fax') . qq|</th>
3133 <td><input name=fax size=14 value="$myconfig{fax}"></td>
3136 <th align=right>| . $locale->text('Company') . qq|</th>
3137 <td><input name=company size=30 value="$myconfig{company}"></td>
3140 <th align=right>| . $locale->text('Address') . qq|</th>
3141 <td><textarea name=address rows=4 cols=50>$myconfig{address}</textarea></td>
3144 <th align=right>| . $locale->text('Date Format') . qq|</th>
3145 <td><select name=dateformat>$dateformat</select></td>
3148 <th align=right>| . $locale->text('Output Number Format') . qq|</th>
3149 <td><select name=numberformat>$numberformat</select></td>
3152 <th align=right>| . $locale->text('Input Number Format') . qq|</th>
3153 <td><select name=in_numberformat>$in_numberformat</select></td>
3157 <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
3158 <td><input name=vclimit size=10 value="$myconfig{vclimit}"></td>
3161 <th align=right>| . $locale->text('Language') . qq|</th>
3162 <td><select name=countrycode>$countrycodes</select></td>
3165 <th align=right>| . $locale->text('Stylesheet') . qq|</th>
3166 <td><select name=usestylesheet>$selectstylesheet</select></td>
3169 <th align=right>| . $locale->text('Setup Menu') . qq|</th>
3170 <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
3171 $locale->text("Top (CSS)") . qq|
3172 <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
3173 $locale->text("Top (Javascript)") . qq|
3174 <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
3175 $locale->text("Old (on the side)") . qq|</td>
3178 <th align=right>| . $locale->text('Form details (second row)') . qq|</th>
3179 <td><input type="radio" id="rad_show_form_details" name="show_form_details" value="1" $show_form_details>
3180 <label for="rad_show_form_details">| . $locale->text('Show by default') . qq|</label>
3181 <input type="radio" id="rad_hide_form_details" name="show_form_details" value="0" $hide_form_details>
3182 <label for="rad_hide_form_details">| . $locale->text('Hide by default') . qq|</label></td>
3184 <input name=printer type=hidden value="$myconfig{printer}">
3185 <tr class=listheading>
3186 <th colspan=2>| . $locale->text("Print options") . qq|</th>
3189 <th align=right>| . $locale->text('Default template format') . qq|</th>
3190 <td><select name="template_format">$template_format</select></td>
3193 <th align=right>| . $locale->text('Default output medium') . qq|</th>
3194 <td><select name="default_media">$default_media</select></td>
3197 <th align=right>| . $locale->text('Default printer') . qq|</th>
3198 <td><select name="default_printer_id">$default_printer</select></td>
3201 <th align=right>| . $locale->text('Number of copies') . qq|</th>
3202 <td><input name="copies" size="10" value="| .
3203 $form->quote($myconfig{"copies"}) . qq|"></td>
3207 <tr class=listheading>
3208 <th colspan=2> </th>
3211 <th align=right>| . $locale->text('Business Number') . qq|</th>
3212 <td><input name=businessnumber size=25 value="$myconfig{businessnumber}"></td>
3215 <th align=right>| . $locale->text('Year End') . qq| (mm/dd)</th>
3216 <td><input name=yearend size=5 value=$form->{defaults}{yearend}></td>
3218 <tr class=listheading>
3220 . $locale->text('Last Numbers & Default Accounts') . qq|</th>
3226 <th align=right nowrap>| . $locale->text('Inventory Account') . qq|</th>
3227 <td><select name=inventory_accno>$myconfig{IC}</select></td>
3230 <th align=right nowrap>| . $locale->text('Revenue Account') . qq|</th>
3231 <td><select name=income_accno>$myconfig{IC_income}</select></td>
3234 <th align=right nowrap>| . $locale->text('Expense Account') . qq|</th>
3235 <td><select name=expense_accno>$myconfig{IC_expense}</select></td>
3238 <th align=right nowrap>| . $locale->text('Foreign Exchange Gain') . qq|</th>
3239 <td><select name=fxgain_accno>$myconfig{FX_gain}</select></td>
3242 <th align=right nowrap>| . $locale->text('Foreign Exchange Loss') . qq|</th>
3243 <td><select name=fxloss_accno>$myconfig{FX_loss}</select></td>
3248 'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies'
3250 . qq|<br><input name=curr size=40 value="$form->{defaults}{curr}"></td>
3259 <th align=right nowrap>| . $locale->text('Last Invoice Number') . qq|</th>
3260 <td><input name=invnumber size=10 value=$form->{defaults}{invnumber}></td>
3261 <th align=right nowrap>|
3262 . $locale->text('Last Customer Number') . qq|</th>
3263 <td><input name=customernumber size=10 value=$form->{defaults}{customernumber}></td>
3266 <th align=right nowrap>|
3267 . $locale->text('Last Credit Note Number') . qq|</th>
3268 <td><input name=cnnumber size=10 value=$form->{defaults}{cnnumber}></td>
3269 <th align=right nowrap>|
3270 . $locale->text('Last Vendor Number') . qq|</th>
3271 <td><input name=vendornumber size=10 value=$form->{defaults}{vendornumber}></td>
3274 <th align=right nowrap>|
3275 . $locale->text('Last Sales Order Number') . qq|</th>
3276 <td><input name=sonumber size=10 value=$form->{defaults}{sonumber}></td>
3279 <th align=right nowrap>|
3280 . $locale->text('Last Purchase Order Number') . qq|</th>
3281 <td><input name=ponumber size=10 value=$form->{defaults}{ponumber}></td>
3282 <th align=right nowrap>|
3283 . $locale->text('Last Article Number') . qq|</th>
3284 <td><input name=articlenumber size=10 value=$form->{defaults}{articlenumber}></td>
3287 <th align=right nowrap>|
3288 . $locale->text('Last Sales Quotation Number') . qq|</th>
3289 <td><input name=sqnumber size=10 value=$form->{defaults}{sqnumber}></td>
3290 <th align=right nowrap>|
3291 . $locale->text('Last Service Number') . qq|</th>
3292 <td><input name=servicenumber size=10 value=$form->{defaults}{servicenumber}></td>
3295 <th align=right nowrap>| . $locale->text('Last RFQ Number') . qq|</th>
3296 <td><input name=rfqnumber size=10 value=$form->{defaults}{rfqnumber}></td>
3297 <th align=right nowrap></th>
3303 # <tr class=listheading>
3304 # <th colspan=2>| . $locale->text('Tax Accounts') . qq|</th>
3311 # <th>| . $locale->text('Rate') . qq| (%)</th>
3312 # <th>| . $locale->text('Number') . qq|</th>
3316 # foreach $accno (sort keys %{ $form->{taxrates} }) {
3319 # <th align=right>$form->{taxrates}{$accno}{description}</th>
3320 # <td><input name=$form->{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}></td>
3321 # <td><input name="taxnumber_$form->{taxrates}{$accno}{id}" value="$form->{taxrates}{$accno}{taxnumber}"></td>
3324 # $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} ";
3327 # chop $form->{taxaccounts};
3330 # <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
3339 <td><hr size=3 noshade></td>
3343 <input type=hidden name=path value=$form->{path}>
3344 <input type=hidden name=login value=$form->{login}>
3345 <input type=hidden name=password value=$form->{password}>
3348 <input type=submit class=submit name=action value="|
3349 . $locale->text('Save') . qq|">
3357 $lxdebug->leave_sub();
3360 sub save_preferences {
3361 $lxdebug->enter_sub();
3363 $form->{stylesheet} = $form->{usestylesheet};
3365 $form->redirect($locale->text('Preferences saved!'))
3367 AM->save_preferences(\%myconfig, \%$form, $memberfile, $userspath, $webdav
3369 $form->error($locale->text('Cannot save preferences!'));
3371 $lxdebug->leave_sub();
3375 $lxdebug->enter_sub();
3377 if ($form->{media} eq 'email') {
3378 $form->error($locale->text('No email address for') . " $myconfig{name}")
3379 unless ($myconfig{email});
3381 $form->{OUT} = "$sendmail";
3385 AM->backup(\%myconfig, \%$form, $userspath);
3387 if ($form->{media} eq 'email') {
3388 $form->redirect($locale->text('Backup sent to') . qq| $myconfig{email}|);
3391 $lxdebug->leave_sub();
3395 $lxdebug->enter_sub();
3397 $form->{title} = $locale->text('Audit Control');
3399 AM->closedto(\%myconfig, \%$form);
3401 if ($form->{revtrans}) {
3402 $checked{Y} = "checked";
3404 $checked{N} = "checked";
3412 <form method=post action=$form->{script}>
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}>
3419 <tr><th class=listtop>$form->{title}</th></tr>
3420 <tr height="5"></tr>
3426 . $locale->text('Enforce transaction reversal for all dates') . qq|</th>
3427 <td><input name=revtrans class=radio type=radio value="1" $checked{Y}> |
3428 . $locale->text('Yes')
3429 . qq| <input name=revtrans class=radio type=radio value="0" $checked{N}> |
3430 . $locale->text('No')
3434 <th>| . $locale->text('Close Books up to') . qq|</th>
3435 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
3445 <input type=hidden name=nextsub value=doclose>
3447 <input type=submit class=submit name=action value="|
3448 . $locale->text('Continue') . qq|">
3456 $lxdebug->leave_sub();
3460 $lxdebug->enter_sub();
3462 AM->closebooks(\%myconfig, \%$form);
3464 if ($form->{revtrans}) {
3466 $locale->text('Transaction reversal enforced for all dates'));
3468 if ($form->{closedto}) {
3470 $locale->text('Transaction reversal enforced up to') . " "
3471 . $locale->date(\%myconfig, $form->{closedto}, 1));
3473 $form->redirect($locale->text('Books are open'));
3477 $lxdebug->leave_sub();
3481 $lxdebug->enter_sub();
3483 $form->{title} = "Add";
3486 "$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}"
3487 unless $form->{callback};
3492 $lxdebug->leave_sub();
3495 sub edit_warehouse {
3496 $lxdebug->enter_sub();
3498 $form->{title} = "Edit";
3500 AM->get_warehouse(\%myconfig, \%$form);
3505 $lxdebug->leave_sub();
3508 sub list_warehouse {
3509 $lxdebug->enter_sub();
3511 AM->warehouses(\%myconfig, \%$form);
3514 "$form->{script}?action=list_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}";
3516 $callback = $form->escape($form->{callback});
3518 $form->{title} = $locale->text('Warehouses');
3520 @column_index = qw(description);
3522 $column_header{description} =
3523 qq|<th class=listheading width=100%>|
3524 . $locale->text('Description')
3534 <th class=listtop>$form->{title}</th>
3536 <tr height="5"></tr>
3540 <tr class=listheading>
3543 map { print "$column_header{$_}\n" } @column_index;
3549 foreach $ref (@{ $form->{ALL} }) {
3555 <tr valign=top class=listrow$i>
3558 $column_data{description} =
3559 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>|;
3561 map { print "$column_data{$_}\n" } @column_index;
3573 <td><hr size=3 noshade></td>
3578 <form method=post action=$form->{script}>
3580 <input name=callback type=hidden value="$form->{callback}">
3582 <input type=hidden name=type value=warehouse>
3584 <input type=hidden name=path value=$form->{path}>
3585 <input type=hidden name=login value=$form->{login}>
3586 <input type=hidden name=password value=$form->{password}>
3588 <input class=submit type=submit name=action value="|
3589 . $locale->text('Add') . qq|">
3597 $lxdebug->leave_sub();
3600 sub warehouse_header {
3601 $lxdebug->enter_sub();
3603 $form->{title} = $locale->text("$form->{title} Warehouse");
3605 # $locale->text('Add Warehouse')
3606 # $locale->text('Edit Warehouse')
3608 $form->{description} =~ s/\"/"/g;
3610 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
3612 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
3615 qq|<input name=description size=60 value="$form->{description}">|;
3623 <form method=post action=$form->{script}>
3625 <input type=hidden name=id value=$form->{id}>
3626 <input type=hidden name=type value=warehouse>
3630 <th class=listtop colspan=2>$form->{title}</th>
3632 <tr height="5"></tr>
3634 <th align=right>| . $locale->text('Description') . qq|</th>
3635 <td>$description</td>
3638 <td colspan=2><hr size=3 noshade></td>
3643 $lxdebug->leave_sub();
3646 sub save_warehouse {
3647 $lxdebug->enter_sub();
3649 $form->isblank("description", $locale->text('Description missing!'));
3650 AM->save_warehouse(\%myconfig, \%$form);
3651 $form->redirect($locale->text('Warehouse saved!'));
3653 $lxdebug->leave_sub();
3656 sub delete_warehouse {
3657 $lxdebug->enter_sub();
3659 AM->delete_warehouse(\%myconfig, \%$form);
3660 $form->redirect($locale->text('Warehouse deleted!'));
3662 $lxdebug->leave_sub();
3666 $lxdebug->enter_sub();
3668 &{ $form->{nextsub} };
3670 $lxdebug->leave_sub();
3674 $lxdebug->enter_sub();
3676 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
3677 AM->units_in_use(\%myconfig, $form, $units);
3678 map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
3680 @languages = AM->language(\%myconfig, $form, 1);
3683 foreach $name (sort({ lc($a) cmp lc($b) } grep({ !$units->{$_}->{"base_unit"} } keys(%{$units})))) {
3684 map({ push(@unit_list, $units->{$_}); }
3685 sort({ ($units->{$a}->{"resolved_factor"} * 1) <=> ($units->{$b}->{"resolved_factor"} * 1) }
3686 grep({ $units->{$_}->{"resolved_base_unit"} eq $name } keys(%{$units}))));
3689 foreach (@unit_list) {
3690 $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"}, 5) if ($_->{"factor"});
3691 $_->{"UNITLANGUAGES"} = [];
3692 foreach my $lang (@languages) {
3693 push(@{ $_->{"UNITLANGUAGES"} },
3695 "unit" => $_->{"name"},
3696 "language_id" => $lang->{"id"},
3697 "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
3698 "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
3704 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
3705 $ddbox = AM->unit_select_data($units, undef, 1);
3707 $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
3709 print($form->parse_html_template("am/edit_units",
3710 { "UNITS" => \@unit_list,
3711 "NEW_BASE_UNIT_DDBOX" => $ddbox,
3712 "LANGUAGES" => \@languages }));
3714 $lxdebug->leave_sub();
3718 $lxdebug->enter_sub();
3720 $form->isblank("new_name", $locale->text("The name is missing."));
3721 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
3722 $all_units = AM->retrieve_units(\%myconfig, $form);
3723 $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
3725 my ($base_unit, $factor);
3726 if ($form->{"new_base_unit"}) {
3727 $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
3729 $form->isblank("new_factor", $locale->text("The factor is missing."));
3730 $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
3731 $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
3732 $base_unit = $form->{"new_base_unit"};
3736 foreach my $lang (AM->language(\%myconfig, $form, 1)) {
3737 next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
3738 push(@languages, { "id" => $lang->{"id"},
3739 "localized" => $form->{"new_localized_$lang->{id}"},
3740 "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
3744 AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
3746 $form->{"saved_message"} = $locale->text("The unit has been saved.");
3750 $lxdebug->leave_sub();
3753 sub set_unit_languages {
3754 $lxdebug->enter_sub();
3756 my ($unit, $languages, $idx) = @_;
3758 $unit->{"LANGUAGES"} = [];
3760 foreach my $lang (@{$languages}) {
3761 push(@{ $unit->{"LANGUAGES"} },
3762 { "id" => $lang->{"id"},
3763 "localized" => $form->{"localized_${idx}_$lang->{id}"},
3764 "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
3768 $lxdebug->leave_sub();
3772 $lxdebug->enter_sub();
3774 $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
3775 AM->units_in_use(\%myconfig, $form, $old_units);
3777 @languages = AM->language(\%myconfig, $form, 1);
3781 foreach $i (1..($form->{"rowcount"} * 1)) {
3782 $old_unit = $old_units->{$form->{"old_name_$i"}};
3784 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
3787 if ($form->{"unchangeable_$i"}) {
3788 $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
3789 $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
3790 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
3794 if ($old_unit->{"in_use"}) {
3795 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
3798 if ($form->{"delete_$i"}) {
3799 push(@delete_units, $old_unit->{"name"});
3803 $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
3805 $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
3806 my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
3807 $new_units->{$form->{"name_$i"}} = \%h;
3808 $new_units->{$form->{"name_$i"}}->{"row"} = $i;
3809 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
3812 foreach $unit (values(%{$new_units})) {
3813 next unless ($unit->{"old_name"});
3814 if ($unit->{"base_unit"}) {
3815 $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"}))
3816 unless (defined($new_units->{$unit->{"base_unit"}}));
3817 $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
3818 $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
3820 $unit->{"base_unit"} = undef;
3821 $unit->{"factor"} = undef;
3825 foreach $unit (values(%{$new_units})) {
3826 next if ($unit->{"unchanged_unit"});
3828 map({ $_->{"seen"} = 0; } values(%{$new_units}));
3830 while ($new_unit->{"base_unit"}) {
3831 $new_unit->{"seen"} = 1;
3832 $new_unit = $new_units->{$new_unit->{"base_unit"}};
3833 if ($new_unit->{"seen"}) {
3834 $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, " .
3835 "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
3840 AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
3842 $form->{"saved_message"} = $locale->text("The units have been saved.");
3846 $lxdebug->leave_sub();