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>
2577 $lxdebug->leave_sub();
2581 $lxdebug->enter_sub();
2583 $form->isblank("description", $locale->text('Description missing!'));
2584 $form->{"percent_skonto"} =
2585 $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
2586 AM->save_payment(\%myconfig, \%$form);
2587 $form->redirect($locale->text('Payment Terms saved!'));
2589 $lxdebug->leave_sub();
2592 sub delete_payment {
2593 $lxdebug->enter_sub();
2595 AM->delete_payment(\%myconfig, \%$form);
2596 $form->redirect($locale->text('Payment terms deleted!'));
2598 $lxdebug->leave_sub();
2601 sub swap_payment_terms {
2602 $lxdebug->enter_sub();
2604 AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
2607 $lxdebug->leave_sub();
2611 $lxdebug->enter_sub();
2613 $form->{title} = "Add";
2616 "$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}"
2617 unless $form->{callback};
2622 $lxdebug->leave_sub();
2626 $lxdebug->enter_sub();
2628 $form->{title} = "Edit";
2630 AM->get_sic(\%myconfig, \%$form);
2634 $form->{orphaned} = 1;
2637 $lxdebug->leave_sub();
2641 $lxdebug->enter_sub();
2643 AM->sic(\%myconfig, \%$form);
2646 "$form->{script}?action=list_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}";
2648 $callback = $form->escape($form->{callback});
2650 $form->{title} = $locale->text('Standard Industrial Codes');
2652 @column_index = qw(code description);
2654 $column_header{code} =
2655 qq|<th class=listheading>| . $locale->text('Code') . qq|</th>|;
2656 $column_header{description} =
2657 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
2666 <th class=listtop>$form->{title}</th>
2668 <tr height="5"></tr>
2672 <tr class=listheading>
2675 map { print "$column_header{$_}\n" } @column_index;
2681 foreach $ref (@{ $form->{ALL} }) {
2686 if ($ref->{sictype} eq 'H') {
2688 <tr valign=top class=listheading>
2690 $column_data{code} =
2691 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>|;
2692 $column_data{description} = qq|<th>$ref->{description}</th>|;
2696 <tr valign=top class=listrow$i>
2699 $column_data{code} =
2700 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>|;
2701 $column_data{description} = qq|<td>$ref->{description}</td>|;
2705 map { print "$column_data{$_}\n" } @column_index;
2717 <td><hr size=3 noshade></td>
2722 <form method=post action=$form->{script}>
2724 <input name=callback type=hidden value="$form->{callback}">
2726 <input type=hidden name=type value=sic>
2728 <input type=hidden name=path value=$form->{path}>
2729 <input type=hidden name=login value=$form->{login}>
2730 <input type=hidden name=password value=$form->{password}>
2732 <input class=submit type=submit name=action value="|
2733 . $locale->text('Add') . qq|">
2741 $lxdebug->leave_sub();
2745 $lxdebug->enter_sub();
2747 $form->{title} = $locale->text("$form->{title} SIC");
2749 # $locale->text('Add SIC')
2750 # $locale->text('Edit SIC')
2752 $form->{code} =~ s/\"/"/g;
2753 $form->{description} =~ s/\"/"/g;
2755 $checked = ($form->{sictype} eq 'H') ? "checked" : "";
2762 <form method=post action=$form->{script}>
2764 <input type=hidden name=type value=sic>
2765 <input type=hidden name=id value=$form->{code}>
2769 <th class=listtop colspan=2>$form->{title}</th>
2771 <tr height="5"></tr>
2773 <th align=right>| . $locale->text('Code') . qq|</th>
2774 <td><input name=code size=10 value=$form->{code}></td>
2778 <th align=left><input name=sictype type=checkbox style=checkbox value="H" $checked> |
2779 . $locale->text('Heading') . qq|</th>
2782 <th align=right>| . $locale->text('Description') . qq|</th>
2783 <td><input name=description size=60 value="$form->{description}"></td>
2785 <td colspan=2><hr size=3 noshade></td>
2790 $lxdebug->leave_sub();
2794 $lxdebug->enter_sub();
2796 $form->isblank("code", $locale->text('Code missing!'));
2797 $form->isblank("description", $locale->text('Description missing!'));
2798 AM->save_sic(\%myconfig, \%$form);
2799 $form->redirect($locale->text('SIC saved!'));
2801 $lxdebug->leave_sub();
2805 $lxdebug->enter_sub();
2807 AM->delete_sic(\%myconfig, \%$form);
2808 $form->redirect($locale->text('SIC deleted!'));
2810 $lxdebug->leave_sub();
2813 sub display_stylesheet {
2814 $lxdebug->enter_sub();
2816 $form->{file} = "css/$myconfig{stylesheet}";
2819 $lxdebug->leave_sub();
2823 $lxdebug->enter_sub();
2825 $form->{file} =~ s/^(.:)*?\/|\.\.\///g;
2826 $form->{file} =~ s/^\/*//g;
2827 $form->{file} =~ s/$userspath//;
2829 $form->error("$!: $form->{file}") unless -f $form->{file};
2831 AM->load_template(\%$form);
2833 $form->{title} = $form->{file};
2835 # if it is anything but html
2836 if ($form->{file} !~ /\.html$/) {
2837 $form->{body} = "<pre>\n$form->{body}\n</pre>";
2847 <form method=post action=$form->{script}>
2849 <input name=file type=hidden value=$form->{file}>
2850 <input name=type type=hidden value=template>
2852 <input type=hidden name=path value=$form->{path}>
2853 <input type=hidden name=login value=$form->{login}>
2854 <input type=hidden name=password value=$form->{password}>
2856 <input name=action type=submit class=submit value="|
2857 . $locale->text('Edit') . qq|">
2865 $lxdebug->leave_sub();
2869 $lxdebug->enter_sub();
2871 AM->load_template(\%$form);
2873 $form->{title} = $locale->text('Edit Template');
2875 # convert   to &nbsp;
2876 $form->{body} =~ s/ /&nbsp;/gi;
2883 <form method=post action=$form->{script}>
2885 <input name=file type=hidden value=$form->{file}>
2886 <input name=type type=hidden value=template>
2888 <input type=hidden name=path value=$form->{path}>
2889 <input type=hidden name=login value=$form->{login}>
2890 <input type=hidden name=password value=$form->{password}>
2892 <input name=callback type=hidden value="$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}&password=$form->{password}">
2894 <textarea name=body rows=25 cols=70>
2899 <input type=submit class=submit name=action value="|
2900 . $locale->text('Save') . qq|">
2909 $lxdebug->leave_sub();
2913 $lxdebug->enter_sub();
2915 AM->save_template(\%$form);
2916 $form->redirect($locale->text('Template saved!'));
2918 $lxdebug->leave_sub();
2922 $lxdebug->enter_sub();
2924 # get defaults for account numbers and last numbers
2925 AM->defaultaccounts(\%myconfig, \%$form);
2927 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
2929 ($item eq $myconfig{dateformat})
2930 ? "<option selected>$item\n"
2931 : "<option>$item\n";
2934 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
2936 ($item eq $myconfig{numberformat})
2937 ? "<option selected>$item\n"
2938 : "<option>$item\n";
2941 foreach $item (qw(name company address signature)) {
2942 $myconfig{$item} =~ s/\"/"/g;
2945 foreach $item (qw(address signature)) {
2946 $myconfig{$item} =~ s/\\n/\r\n/g;
2950 if ($opendocument_templates && $openofficeorg_writer_bin &&
2951 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
2952 push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
2953 "value" => "opendocument_pdf" });
2955 if ($latex_templates) {
2956 push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
2958 push(@formats, { "name" => "HTML", "value" => "html" });
2959 if ($latex_templates) {
2960 push(@formats, { "name" => $locale->text("Postscript"),
2961 "value" => "postscript" });
2963 if ($opendocument_templates) {
2964 push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
2965 "value" => "opendocument" });
2968 if (!$myconfig{"template_format"}) {
2969 $myconfig{"template_format"} = "pdf";
2971 my $template_format = "";
2972 foreach $item (@formats) {
2974 "<option value=\"$item->{value}\"" .
2975 ($item->{"value"} eq $myconfig{"template_format"} ?
2977 ">" . H($item->{"name"}) . "</option>";
2980 if (!$myconfig{"default_media"}) {
2981 $myconfig{"default_media"} = "screen";
2983 my %selected = ($myconfig{"default_media"} => "selected");
2984 my $default_media = qq|
2985 <option value="screen" $selected{'screen'}>| . $locale->text("Screen") . qq|</option>
2986 <option value="printer" $selected{'printer'}>| . $locale->text("Printer") . qq|</option>
2987 <option value="queue" $selected{'queue'}>| . $locale->text("Queue") . qq|</option>
2991 $selected{$myconfig{"default_printer_id"}} = "selected"
2992 if ($myconfig{"default_printer_id"});
2993 my $default_printer = qq|<option></option>|;
2994 AM->printer(\%myconfig, $form);
2995 foreach my $printer (@{$form->{"ALL"}}) {
2996 $default_printer .= qq|<option value="| . Q($printer->{"id"}) .
2997 qq|" $selected{$printer->{'id'}}>| .
2998 H($printer->{"printer_description"}) . qq|</option>|;
3001 %countrycodes = User->country_codes;
3003 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
3007 ($myconfig{countrycode} eq $key)
3008 ? "<option selected value=$key>$countrycodes{$key}\n"
3009 : "<option value=$key>$countrycodes{$key}\n";
3011 $countrycodes = "<option>American English\n$countrycodes";
3013 # use an other input number format than output numberformat
3014 # look at Form.pm, sub parse_amount
3015 my $in_numberformat = '';
3016 $text1 = qq|value="0">| . $locale->text('equal Outputformat');
3017 $text2 = qq|value="1">| . $locale->text('1000,00 or 1000.00');
3018 @in_nf = ($text1, $text2);
3019 foreach $item (@in_nf) {
3021 (substr($item, 7, 1) eq $myconfig{in_numberformat})
3022 ? "<option selected $item\n"
3023 : "<option $item\n";
3026 foreach $key (keys %{ $form->{IC} }) {
3027 foreach $accno (sort keys %{ $form->{IC}{$key} }) {
3029 ($form->{IC}{$key}{$accno}{id} == $form->{defaults}{$key})
3030 ? "<option selected>$accno--$form->{IC}{$key}{$accno}{description}\n"
3031 : "<option>$accno--$form->{IC}{$key}{$accno}{description}\n";
3035 opendir CSS, "css/.";
3036 @all = grep /.*\.css$/, readdir CSS;
3039 foreach $item (@all) {
3040 if ($item eq $myconfig{stylesheet}) {
3041 $selectstylesheet .= qq|<option selected>$item\n|;
3043 $selectstylesheet .= qq|<option>$item\n|;
3046 $selectstylesheet .= "<option>\n";
3048 $form->{title} = $locale->text('Edit Preferences for') . qq| $form->{login}|;
3052 if ($myconfig{menustyle} eq "old") {
3053 $menustyle_old = "checked";
3054 } elsif ($myconfig{menustyle} eq "neu") {
3055 $menustyle_neu = "checked";
3056 } elsif ($myconfig{menustyle} eq "v3") {
3057 $menustyle_v3 = "checked";
3060 my ($show_form_details, $hide_form_details);
3061 $myconfig{"show_form_details"} = 1
3062 unless (defined($myconfig{"show_form_details"}));
3063 $show_form_details = "checked" if ($myconfig{"show_form_details"});
3064 $hide_form_details = "checked" unless ($myconfig{"show_form_details"});
3069 <form method=post action=$form->{script}>
3071 <input type=hidden name=old_password value=$myconfig{password}>
3072 <input type=hidden name=type value=preferences>
3073 <input type=hidden name=role value=$myconfig{role}>
3076 <tr><th class=listtop>$form->{title}</th></tr>
3081 <th align=right>| . $locale->text('Name') . qq|</th>
3082 <td><input name=name size=15 value="$myconfig{name}"></td>
3085 <th align=right>| . $locale->text('Password') . qq|</th>
3086 <td><input type=password name=new_password size=10 value=$myconfig{password}></td>
3089 <th align=right>| . $locale->text('E-mail') . qq|</th>
3090 <td><input name=email size=30 value="$myconfig{email}"></td>
3093 <th align=right>| . $locale->text('Signature') . qq|</th>
3094 <td><textarea name=signature rows=3 cols=50>$myconfig{signature}</textarea></td>
3097 <th align=right>| . $locale->text('Phone') . qq|</th>
3098 <td><input name=tel size=14 value="$myconfig{tel}"></td>
3101 <th align=right>| . $locale->text('Fax') . qq|</th>
3102 <td><input name=fax size=14 value="$myconfig{fax}"></td>
3105 <th align=right>| . $locale->text('Company') . qq|</th>
3106 <td><input name=company size=30 value="$myconfig{company}"></td>
3109 <th align=right>| . $locale->text('Address') . qq|</th>
3110 <td><textarea name=address rows=4 cols=50>$myconfig{address}</textarea></td>
3113 <th align=right>| . $locale->text('Date Format') . qq|</th>
3114 <td><select name=dateformat>$dateformat</select></td>
3117 <th align=right>| . $locale->text('Output Number Format') . qq|</th>
3118 <td><select name=numberformat>$numberformat</select></td>
3121 <th align=right>| . $locale->text('Input Number Format') . qq|</th>
3122 <td><select name=in_numberformat>$in_numberformat</select></td>
3126 <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
3127 <td><input name=vclimit size=10 value="$myconfig{vclimit}"></td>
3130 <th align=right>| . $locale->text('Language') . qq|</th>
3131 <td><select name=countrycode>$countrycodes</select></td>
3134 <th align=right>| . $locale->text('Stylesheet') . qq|</th>
3135 <td><select name=usestylesheet>$selectstylesheet</select></td>
3138 <th align=right>| . $locale->text('Setup Menu') . qq|</th>
3139 <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
3140 $locale->text("Top (CSS)") . qq|
3141 <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
3142 $locale->text("Top (Javascript)") . qq|
3143 <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
3144 $locale->text("Old (on the side)") . qq|</td>
3147 <th align=right>| . $locale->text('Form details (second row)') . qq|</th>
3148 <td><input type="radio" id="rad_show_form_details" name="show_form_details" value="1" $show_form_details>
3149 <label for="rad_show_form_details">| . $locale->text('Show by default') . qq|</label>
3150 <input type="radio" id="rad_hide_form_details" name="show_form_details" value="0" $hide_form_details>
3151 <label for="rad_hide_form_details">| . $locale->text('Hide by default') . qq|</label></td>
3153 <input name=printer type=hidden value="$myconfig{printer}">
3154 <tr class=listheading>
3155 <th colspan=2>| . $locale->text("Print options") . qq|</th>
3158 <th align=right>| . $locale->text('Default template format') . qq|</th>
3159 <td><select name="template_format">$template_format</select></td>
3162 <th align=right>| . $locale->text('Default output medium') . qq|</th>
3163 <td><select name="default_media">$default_media</select></td>
3166 <th align=right>| . $locale->text('Default printer') . qq|</th>
3167 <td><select name="default_printer_id">$default_printer</select></td>
3170 <th align=right>| . $locale->text('Number of copies') . qq|</th>
3171 <td><input name="copies" size="10" value="| .
3172 $form->quote($myconfig{"copies"}) . qq|"></td>
3176 <tr class=listheading>
3177 <th colspan=2> </th>
3180 <th align=right>| . $locale->text('Business Number') . qq|</th>
3181 <td><input name=businessnumber size=25 value="$myconfig{businessnumber}"></td>
3184 <th align=right>| . $locale->text('Year End') . qq| (mm/dd)</th>
3185 <td><input name=yearend size=5 value=$form->{defaults}{yearend}></td>
3187 <tr class=listheading>
3189 . $locale->text('Last Numbers & Default Accounts') . qq|</th>
3195 <th align=right nowrap>| . $locale->text('Inventory Account') . qq|</th>
3196 <td><select name=inventory_accno>$myconfig{IC}</select></td>
3199 <th align=right nowrap>| . $locale->text('Revenue Account') . qq|</th>
3200 <td><select name=income_accno>$myconfig{IC_income}</select></td>
3203 <th align=right nowrap>| . $locale->text('Expense Account') . qq|</th>
3204 <td><select name=expense_accno>$myconfig{IC_expense}</select></td>
3207 <th align=right nowrap>| . $locale->text('Foreign Exchange Gain') . qq|</th>
3208 <td><select name=fxgain_accno>$myconfig{FX_gain}</select></td>
3211 <th align=right nowrap>| . $locale->text('Foreign Exchange Loss') . qq|</th>
3212 <td><select name=fxloss_accno>$myconfig{FX_loss}</select></td>
3217 'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies'
3219 . qq|<br><input name=curr size=40 value="$form->{defaults}{curr}"></td>
3228 <th align=right nowrap>| . $locale->text('Last Invoice Number') . qq|</th>
3229 <td><input name=invnumber size=10 value=$form->{defaults}{invnumber}></td>
3230 <th align=right nowrap>|
3231 . $locale->text('Last Customer Number') . qq|</th>
3232 <td><input name=customernumber size=10 value=$form->{defaults}{customernumber}></td>
3235 <th align=right nowrap>|
3236 . $locale->text('Last Credit Note Number') . qq|</th>
3237 <td><input name=cnnumber size=10 value=$form->{defaults}{cnnumber}></td>
3238 <th align=right nowrap>|
3239 . $locale->text('Last Vendor Number') . qq|</th>
3240 <td><input name=vendornumber size=10 value=$form->{defaults}{vendornumber}></td>
3243 <th align=right nowrap>|
3244 . $locale->text('Last Sales Order Number') . qq|</th>
3245 <td><input name=sonumber size=10 value=$form->{defaults}{sonumber}></td>
3248 <th align=right nowrap>|
3249 . $locale->text('Last Purchase Order Number') . qq|</th>
3250 <td><input name=ponumber size=10 value=$form->{defaults}{ponumber}></td>
3251 <th align=right nowrap>|
3252 . $locale->text('Last Article Number') . qq|</th>
3253 <td><input name=articlenumber size=10 value=$form->{defaults}{articlenumber}></td>
3256 <th align=right nowrap>|
3257 . $locale->text('Last Sales Quotation Number') . qq|</th>
3258 <td><input name=sqnumber size=10 value=$form->{defaults}{sqnumber}></td>
3259 <th align=right nowrap>|
3260 . $locale->text('Last Service Number') . qq|</th>
3261 <td><input name=servicenumber size=10 value=$form->{defaults}{servicenumber}></td>
3264 <th align=right nowrap>| . $locale->text('Last RFQ Number') . qq|</th>
3265 <td><input name=rfqnumber size=10 value=$form->{defaults}{rfqnumber}></td>
3266 <th align=right nowrap></th>
3272 # <tr class=listheading>
3273 # <th colspan=2>| . $locale->text('Tax Accounts') . qq|</th>
3280 # <th>| . $locale->text('Rate') . qq| (%)</th>
3281 # <th>| . $locale->text('Number') . qq|</th>
3285 # foreach $accno (sort keys %{ $form->{taxrates} }) {
3288 # <th align=right>$form->{taxrates}{$accno}{description}</th>
3289 # <td><input name=$form->{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}></td>
3290 # <td><input name="taxnumber_$form->{taxrates}{$accno}{id}" value="$form->{taxrates}{$accno}{taxnumber}"></td>
3293 # $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} ";
3296 # chop $form->{taxaccounts};
3299 # <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
3308 <td><hr size=3 noshade></td>
3312 <input type=hidden name=path value=$form->{path}>
3313 <input type=hidden name=login value=$form->{login}>
3314 <input type=hidden name=password value=$form->{password}>
3317 <input type=submit class=submit name=action value="|
3318 . $locale->text('Save') . qq|">
3326 $lxdebug->leave_sub();
3329 sub save_preferences {
3330 $lxdebug->enter_sub();
3332 $form->{stylesheet} = $form->{usestylesheet};
3334 $form->redirect($locale->text('Preferences saved!'))
3336 AM->save_preferences(\%myconfig, \%$form, $memberfile, $userspath, $webdav
3338 $form->error($locale->text('Cannot save preferences!'));
3340 $lxdebug->leave_sub();
3344 $lxdebug->enter_sub();
3346 if ($form->{media} eq 'email') {
3347 $form->error($locale->text('No email address for') . " $myconfig{name}")
3348 unless ($myconfig{email});
3350 $form->{OUT} = "$sendmail";
3354 AM->backup(\%myconfig, \%$form, $userspath);
3356 if ($form->{media} eq 'email') {
3357 $form->redirect($locale->text('Backup sent to') . qq| $myconfig{email}|);
3360 $lxdebug->leave_sub();
3364 $lxdebug->enter_sub();
3366 $form->{title} = $locale->text('Audit Control');
3368 AM->closedto(\%myconfig, \%$form);
3370 if ($form->{revtrans}) {
3371 $checked{Y} = "checked";
3373 $checked{N} = "checked";
3381 <form method=post action=$form->{script}>
3383 <input type=hidden name=path value=$form->{path}>
3384 <input type=hidden name=login value=$form->{login}>
3385 <input type=hidden name=password value=$form->{password}>
3388 <tr><th class=listtop>$form->{title}</th></tr>
3389 <tr height="5"></tr>
3395 . $locale->text('Enforce transaction reversal for all dates') . qq|</th>
3396 <td><input name=revtrans class=radio type=radio value="1" $checked{Y}> |
3397 . $locale->text('Yes')
3398 . qq| <input name=revtrans class=radio type=radio value="0" $checked{N}> |
3399 . $locale->text('No')
3403 <th>| . $locale->text('Close Books up to') . qq|</th>
3404 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
3414 <input type=hidden name=nextsub value=doclose>
3416 <input type=submit class=submit name=action value="|
3417 . $locale->text('Continue') . qq|">
3425 $lxdebug->leave_sub();
3429 $lxdebug->enter_sub();
3431 AM->closebooks(\%myconfig, \%$form);
3433 if ($form->{revtrans}) {
3435 $locale->text('Transaction reversal enforced for all dates'));
3437 if ($form->{closedto}) {
3439 $locale->text('Transaction reversal enforced up to') . " "
3440 . $locale->date(\%myconfig, $form->{closedto}, 1));
3442 $form->redirect($locale->text('Books are open'));
3446 $lxdebug->leave_sub();
3450 $lxdebug->enter_sub();
3452 $form->{title} = "Add";
3455 "$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}"
3456 unless $form->{callback};
3461 $lxdebug->leave_sub();
3464 sub edit_warehouse {
3465 $lxdebug->enter_sub();
3467 $form->{title} = "Edit";
3469 AM->get_warehouse(\%myconfig, \%$form);
3474 $lxdebug->leave_sub();
3477 sub list_warehouse {
3478 $lxdebug->enter_sub();
3480 AM->warehouses(\%myconfig, \%$form);
3483 "$form->{script}?action=list_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}";
3485 $callback = $form->escape($form->{callback});
3487 $form->{title} = $locale->text('Warehouses');
3489 @column_index = qw(description);
3491 $column_header{description} =
3492 qq|<th class=listheading width=100%>|
3493 . $locale->text('Description')
3503 <th class=listtop>$form->{title}</th>
3505 <tr height="5"></tr>
3509 <tr class=listheading>
3512 map { print "$column_header{$_}\n" } @column_index;
3518 foreach $ref (@{ $form->{ALL} }) {
3524 <tr valign=top class=listrow$i>
3527 $column_data{description} =
3528 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>|;
3530 map { print "$column_data{$_}\n" } @column_index;
3542 <td><hr size=3 noshade></td>
3547 <form method=post action=$form->{script}>
3549 <input name=callback type=hidden value="$form->{callback}">
3551 <input type=hidden name=type value=warehouse>
3553 <input type=hidden name=path value=$form->{path}>
3554 <input type=hidden name=login value=$form->{login}>
3555 <input type=hidden name=password value=$form->{password}>
3557 <input class=submit type=submit name=action value="|
3558 . $locale->text('Add') . qq|">
3566 $lxdebug->leave_sub();
3569 sub warehouse_header {
3570 $lxdebug->enter_sub();
3572 $form->{title} = $locale->text("$form->{title} Warehouse");
3574 # $locale->text('Add Warehouse')
3575 # $locale->text('Edit Warehouse')
3577 $form->{description} =~ s/\"/"/g;
3579 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
3581 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
3584 qq|<input name=description size=60 value="$form->{description}">|;
3592 <form method=post action=$form->{script}>
3594 <input type=hidden name=id value=$form->{id}>
3595 <input type=hidden name=type value=warehouse>
3599 <th class=listtop colspan=2>$form->{title}</th>
3601 <tr height="5"></tr>
3603 <th align=right>| . $locale->text('Description') . qq|</th>
3604 <td>$description</td>
3607 <td colspan=2><hr size=3 noshade></td>
3612 $lxdebug->leave_sub();
3615 sub save_warehouse {
3616 $lxdebug->enter_sub();
3618 $form->isblank("description", $locale->text('Description missing!'));
3619 AM->save_warehouse(\%myconfig, \%$form);
3620 $form->redirect($locale->text('Warehouse saved!'));
3622 $lxdebug->leave_sub();
3625 sub delete_warehouse {
3626 $lxdebug->enter_sub();
3628 AM->delete_warehouse(\%myconfig, \%$form);
3629 $form->redirect($locale->text('Warehouse deleted!'));
3631 $lxdebug->leave_sub();
3635 $lxdebug->enter_sub();
3637 &{ $form->{nextsub} };
3639 $lxdebug->leave_sub();
3643 $lxdebug->enter_sub();
3645 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
3646 AM->units_in_use(\%myconfig, $form, $units);
3647 map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
3649 @languages = AM->language(\%myconfig, $form, 1);
3652 foreach $name (sort({ lc($a) cmp lc($b) } grep({ !$units->{$_}->{"base_unit"} } keys(%{$units})))) {
3653 map({ push(@unit_list, $units->{$_}); }
3654 sort({ ($units->{$a}->{"resolved_factor"} * 1) <=> ($units->{$b}->{"resolved_factor"} * 1) }
3655 grep({ $units->{$_}->{"resolved_base_unit"} eq $name } keys(%{$units}))));
3658 foreach (@unit_list) {
3659 $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"}, 5) if ($_->{"factor"});
3660 $_->{"UNITLANGUAGES"} = [];
3661 foreach my $lang (@languages) {
3662 push(@{ $_->{"UNITLANGUAGES"} },
3664 "unit" => $_->{"name"},
3665 "language_id" => $lang->{"id"},
3666 "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
3667 "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
3673 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
3674 $ddbox = AM->unit_select_data($units, undef, 1);
3676 $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
3678 print($form->parse_html_template("am/edit_units",
3679 { "UNITS" => \@unit_list,
3680 "NEW_BASE_UNIT_DDBOX" => $ddbox,
3681 "LANGUAGES" => \@languages }));
3683 $lxdebug->leave_sub();
3687 $lxdebug->enter_sub();
3689 $form->isblank("new_name", $locale->text("The name is missing."));
3690 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
3691 $all_units = AM->retrieve_units(\%myconfig, $form);
3692 $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
3694 my ($base_unit, $factor);
3695 if ($form->{"new_base_unit"}) {
3696 $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
3698 $form->isblank("new_factor", $locale->text("The factor is missing."));
3699 $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
3700 $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
3701 $base_unit = $form->{"new_base_unit"};
3705 foreach my $lang (AM->language(\%myconfig, $form, 1)) {
3706 next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
3707 push(@languages, { "id" => $lang->{"id"},
3708 "localized" => $form->{"new_localized_$lang->{id}"},
3709 "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
3713 AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
3715 $form->{"saved_message"} = $locale->text("The unit has been saved.");
3719 $lxdebug->leave_sub();
3722 sub set_unit_languages {
3723 $lxdebug->enter_sub();
3725 my ($unit, $languages, $idx) = @_;
3727 $unit->{"LANGUAGES"} = [];
3729 foreach my $lang (@{$languages}) {
3730 push(@{ $unit->{"LANGUAGES"} },
3731 { "id" => $lang->{"id"},
3732 "localized" => $form->{"localized_${idx}_$lang->{id}"},
3733 "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
3737 $lxdebug->leave_sub();
3741 $lxdebug->enter_sub();
3743 $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
3744 AM->units_in_use(\%myconfig, $form, $old_units);
3746 @languages = AM->language(\%myconfig, $form, 1);
3750 foreach $i (1..($form->{"rowcount"} * 1)) {
3751 $old_unit = $old_units->{$form->{"old_name_$i"}};
3753 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
3756 if ($form->{"unchangeable_$i"}) {
3757 $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
3758 $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
3759 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
3763 if ($old_unit->{"in_use"}) {
3764 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
3767 if ($form->{"delete_$i"}) {
3768 push(@delete_units, $old_unit->{"name"});
3772 $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
3774 $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
3775 my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
3776 $new_units->{$form->{"name_$i"}} = \%h;
3777 $new_units->{$form->{"name_$i"}}->{"row"} = $i;
3778 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
3781 foreach $unit (values(%{$new_units})) {
3782 next unless ($unit->{"old_name"});
3783 if ($unit->{"base_unit"}) {
3784 $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"}))
3785 unless (defined($new_units->{$unit->{"base_unit"}}));
3786 $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
3787 $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
3789 $unit->{"base_unit"} = undef;
3790 $unit->{"factor"} = undef;
3794 foreach $unit (values(%{$new_units})) {
3795 next if ($unit->{"unchanged_unit"});
3797 map({ $_->{"seen"} = 0; } values(%{$new_units}));
3799 while ($new_unit->{"base_unit"}) {
3800 $new_unit->{"seen"} = 1;
3801 $new_unit = $new_units->{$new_unit->{"base_unit"}};
3802 if ($new_unit->{"seen"}) {
3803 $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, " .
3804 "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
3809 AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
3811 $form->{"saved_message"} = $locale->text("The units have been saved.");
3815 $lxdebug->leave_sub();