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;
580 $ca->{taxkey} =~ s/,/<br>/og;
581 $ca->{taxaccount} =~ s/,/<br>/og;
582 $ca->{taxdescription} =~ s/,/<br>/og;
583 $ca->{datevautomatik} = ($ca->{datevautomatik}) ? $locale->text('On'):q{};
585 $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
586 : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
587 : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
588 : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
589 : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
590 : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
591 : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
592 : $locale->text('Unknown Category') . ': ' . $ca->{category};
594 $ca->{link_edit_account} =
595 qq|$form->{script}?action=edit_account&id=$ca->{id}|
596 .qq|&path=$form->{path}&login=$form->{login}|
597 .qq|&password=$form->{password}&callback=$callback>$ca->{accno}|;
600 my $parameters_ref = {
603 # hidden_variables => $_hidden_variables_ref,
606 # Ausgabe des Templates
607 print($form->parse_html_template('am/list_accounts', $parameters_ref));
609 $lxdebug->leave_sub();
615 $lxdebug->enter_sub();
617 $form->{title} = $locale->text('Delete Account');
620 qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
622 if ($form->{id} == $form->{$id}) {
623 $form->error($locale->text('Cannot delete default account!'));
627 $form->redirect($locale->text('Account deleted!'))
628 if (AM->delete_account(\%myconfig, \%$form));
629 $form->error($locale->text('Cannot delete account!'));
631 $lxdebug->leave_sub();
635 $lxdebug->enter_sub();
637 @{ $form->{fields} } = (accno, description);
638 $form->{table} = "gifi";
639 $form->{sortorder} = "accno";
641 AM->gifi_accounts(\%myconfig, \%$form);
643 $form->{title} = $locale->text('GIFI');
647 "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&password=$form->{password}";
649 @column_index = qw(accno description);
651 $column_header{accno} = qq|<th>| . $locale->text('GIFI') . qq|</a></th>|;
652 $column_header{description} =
653 qq|<th>| . $locale->text('Description') . qq|</a></th>|;
656 $colspan = $#column_index + 1;
663 <th class=listtop colspan=$colspan>$form->{title}</th>
666 <tr class=listheading>
669 map { print "$column_header{$_}\n" } @column_index;
676 $callback = $form->escape($callback);
678 foreach $ca (@{ $form->{ALL} }) {
684 <tr valign=top class=listrow$i>|;
686 $column_data{accno} =
687 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>|;
688 $column_data{description} = qq|<td>$ca->{description} </td>|;
690 map { print "$column_data{$_}\n" } @column_index;
697 <td colspan=$colspan><hr size=3 noshade></td>
705 $lxdebug->leave_sub();
709 $lxdebug->enter_sub();
711 $form->{title} = "Add";
715 "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&password=$form->{password}";
722 $lxdebug->leave_sub();
726 $lxdebug->enter_sub();
728 $form->{title} = "Edit";
730 AM->get_gifi(\%myconfig, \%$form);
735 $lxdebug->leave_sub();
739 $lxdebug->enter_sub();
741 $form->{title} = $locale->text("$form->{title} GIFI");
743 # $locale->text('Add GIFI')
744 # $locale->text('Edit GIFI')
746 $form->{description} =~ s/\"/"/g;
753 <form method=post action=$form->{script}>
755 <input type=hidden name=id value=$form->{accno}>
756 <input type=hidden name=type value=gifi>
760 <th class=listtop>$form->{title}</th>
767 <th align=right>| . $locale->text('GIFI') . qq|</th>
768 <td><input name=accno size=20 value=$form->{accno}></td>
771 <th align=right>| . $locale->text('Description') . qq|</th>
772 <td><input name=description size=60 value="$form->{description}"></td>
778 <td colspan=2><hr size=3 noshade></td>
783 $lxdebug->leave_sub();
787 $lxdebug->enter_sub();
791 <input name=callback type=hidden value="$form->{callback}">
793 <input type=hidden name=path value=$form->{path}>
794 <input type=hidden name=login value=$form->{login}>
795 <input type=hidden name=password value=$form->{password}>
797 <br><input type=submit class=submit name=action value="|
798 . $locale->text('Save') . qq|">|;
802 <input type=submit class=submit name=action value="|
803 . $locale->text('Copy to COA') . qq|">
806 if ($form->{accno} && $form->{orphaned}) {
807 print qq|<input type=submit class=submit name=action value="|
808 . $locale->text('Delete') . qq|">|;
819 $lxdebug->leave_sub();
823 $lxdebug->enter_sub();
825 $form->isblank("accno", $locale->text('GIFI missing!'));
826 AM->save_gifi(\%myconfig, \%$form);
827 $form->redirect($locale->text('GIFI saved!'));
829 $lxdebug->leave_sub();
833 $lxdebug->enter_sub();
835 $form->isblank("accno", $locale->text('GIFI missing!'));
837 AM->save_gifi(\%myconfig, \%$form);
840 $form->{gifi_accno} = $form->{accno};
841 $form->{title} = "Add";
842 $form->{charttype} = "A";
847 $lxdebug->leave_sub();
851 $lxdebug->enter_sub();
853 AM->delete_gifi(\%myconfig, \%$form);
854 $form->redirect($locale->text('GIFI deleted!'));
856 $lxdebug->leave_sub();
860 $lxdebug->enter_sub();
862 $form->{title} = "Add";
866 "$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}&password=$form->{password}"
867 unless $form->{callback};
872 $lxdebug->leave_sub();
875 sub edit_department {
876 $lxdebug->enter_sub();
878 $form->{title} = "Edit";
880 AM->get_department(\%myconfig, \%$form);
885 $lxdebug->leave_sub();
888 sub list_department {
889 $lxdebug->enter_sub();
891 AM->departments(\%myconfig, \%$form);
894 "$form->{script}?action=list_department&path=$form->{path}&login=$form->{login}&password=$form->{password}";
896 $callback = $form->escape($form->{callback});
898 $form->{title} = $locale->text('Departments');
900 @column_index = qw(description cost profit);
902 $column_header{description} =
903 qq|<th class=listheading width=90%>|
904 . $locale->text('Description')
906 $column_header{cost} =
907 qq|<th class=listheading nowrap>|
908 . $locale->text('Cost Center')
910 $column_header{profit} =
911 qq|<th class=listheading nowrap>|
912 . $locale->text('Profit Center')
922 <th class=listtop>$form->{title}</th>
928 <tr class=listheading>
931 map { print "$column_header{$_}\n" } @column_index;
937 foreach $ref (@{ $form->{ALL} }) {
943 <tr valign=top class=listrow$i>
946 $costcenter = ($ref->{role} eq "C") ? "X" : "";
947 $profitcenter = ($ref->{role} eq "P") ? "X" : "";
949 $column_data{description} =
950 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>|;
951 $column_data{cost} = qq|<td align=center>$costcenter</td>|;
952 $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
954 map { print "$column_data{$_}\n" } @column_index;
966 <td><hr size=3 noshade></td>
971 <form method=post action=$form->{script}>
973 <input name=callback type=hidden value="$form->{callback}">
975 <input type=hidden name=type value=department>
977 <input type=hidden name=path value=$form->{path}>
978 <input type=hidden name=login value=$form->{login}>
979 <input type=hidden name=password value=$form->{password}>
981 <input class=submit type=submit name=action value="|
982 . $locale->text('Add') . qq|">
990 $lxdebug->leave_sub();
993 sub department_header {
994 $lxdebug->enter_sub();
996 $form->{title} = $locale->text("$form->{title} Department");
998 # $locale->text('Add Department')
999 # $locale->text('Edit Department')
1001 $form->{description} =~ s/\"/"/g;
1003 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
1005 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
1008 qq|<input name=description size=60 value="$form->{description}">|;
1011 $costcenter = "checked" if $form->{role} eq "C";
1012 $profitcenter = "checked" if $form->{role} eq "P";
1019 <form method=post action=$form->{script}>
1021 <input type=hidden name=id value=$form->{id}>
1022 <input type=hidden name=type value=department>
1026 <th class=listtop colspan=2>$form->{title}</th>
1028 <tr height="5"></tr>
1030 <th align=right>| . $locale->text('Description') . qq|</th>
1031 <td>$description</td>
1035 <td><input type=radio style=radio name=role value="C" $costcenter> |
1036 . $locale->text('Cost Center') . qq|
1037 <input type=radio style=radio name=role value="P" $profitcenter> |
1038 . $locale->text('Profit Center') . qq|
1041 <td colspan=2><hr size=3 noshade></td>
1046 $lxdebug->leave_sub();
1049 sub save_department {
1050 $lxdebug->enter_sub();
1052 $form->isblank("description", $locale->text('Description missing!'));
1053 AM->save_department(\%myconfig, \%$form);
1054 $form->redirect($locale->text('Department saved!'));
1056 $lxdebug->leave_sub();
1059 sub delete_department {
1060 $lxdebug->enter_sub();
1062 AM->delete_department(\%myconfig, \%$form);
1063 $form->redirect($locale->text('Department deleted!'));
1065 $lxdebug->leave_sub();
1069 $lxdebug->enter_sub();
1071 $form->{title} = "Add";
1074 "$form->{script}?action=add_lead&path=$form->{path}&login=$form->{login}&password=$form->{password}"
1075 unless $form->{callback};
1080 $lxdebug->leave_sub();
1084 $lxdebug->enter_sub();
1086 $form->{title} = "Edit";
1088 AM->get_lead(\%myconfig, \%$form);
1092 $form->{orphaned} = 1;
1095 $lxdebug->leave_sub();
1099 $lxdebug->enter_sub();
1101 AM->lead(\%myconfig, \%$form);
1104 "$form->{script}?action=list_lead&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1106 $callback = $form->escape($form->{callback});
1108 $form->{title} = $locale->text('Lead');
1110 @column_index = qw(description cost profit);
1112 $column_header{description} =
1113 qq|<th class=listheading width=100%>|
1114 . $locale->text('Description')
1124 <th class=listtop>$form->{title}</th>
1126 <tr height="5"></tr>
1127 <tr class=listheading>
1130 map { print "$column_header{$_}\n" } @column_index;
1136 foreach $ref (@{ $form->{ALL} }) {
1142 <tr valign=top class=listrow$i>
1145 $lead = $ref->{lead};
1147 $column_data{description} =
1148 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>|;
1150 map { print "$column_data{$_}\n" } @column_index;
1159 <td><hr size=3 noshade></td>
1164 <form method=post action=$form->{script}>
1166 <input name=callback type=hidden value="$form->{callback}">
1168 <input type=hidden name=type value=lead>
1170 <input type=hidden name=path value=$form->{path}>
1171 <input type=hidden name=login value=$form->{login}>
1172 <input type=hidden name=password value=$form->{password}>
1174 <input class=submit type=submit name=action value="|
1175 . $locale->text('Add') . qq|">
1183 $lxdebug->leave_sub();
1187 $lxdebug->enter_sub();
1189 $form->{title} = $locale->text("$form->{title} Lead");
1191 # $locale->text('Add Lead')
1192 # $locale->text('Edit Lead')
1194 $form->{description} =~ s/\"/"/g;
1197 qq|<input name=description size=50 value="$form->{lead}">|;
1204 <form method=post action=$form->{script}>
1206 <input type=hidden name=id value=$form->{id}>
1207 <input type=hidden name=type value=lead>
1211 <th class=listtop colspan=2>$form->{title}</th>
1213 <tr height="5"></tr>
1215 <th align=right>| . $locale->text('Description') . qq|</th>
1216 <td>$description</td>
1218 <td colspan=2><hr size=3 noshade></td>
1223 $lxdebug->leave_sub();
1227 $lxdebug->enter_sub();
1229 $form->isblank("description", $locale->text('Description missing!'));
1230 AM->save_lead(\%myconfig, \%$form);
1231 $form->redirect($locale->text('lead saved!'));
1233 $lxdebug->leave_sub();
1237 $lxdebug->enter_sub();
1239 AM->delete_lead(\%myconfig, \%$form);
1240 $form->redirect($locale->text('lead deleted!'));
1242 $lxdebug->leave_sub();
1246 $lxdebug->enter_sub();
1248 $form->{title} = "Add";
1251 "$form->{script}?action=add_business&path=$form->{path}&login=$form->{login}&password=$form->{password}"
1252 unless $form->{callback};
1257 $lxdebug->leave_sub();
1261 $lxdebug->enter_sub();
1263 $form->{title} = "Edit";
1265 AM->get_business(\%myconfig, \%$form);
1269 $form->{orphaned} = 1;
1272 $lxdebug->leave_sub();
1276 $lxdebug->enter_sub();
1278 AM->business(\%myconfig, \%$form);
1281 "$form->{script}?action=list_business&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1283 $callback = $form->escape($form->{callback});
1285 $form->{title} = $locale->text('Type of Business');
1287 @column_index = qw(description discount customernumberinit);
1289 $column_header{description} =
1290 qq|<th class=listheading width=60%>|
1291 . $locale->text('Description')
1293 $column_header{discount} =
1294 qq|<th class=listheading width=10%>|
1295 . $locale->text('Discount')
1297 $column_header{customernumberinit} =
1298 qq|<th class=listheading>|
1299 . $locale->text('Customernumberinit')
1309 <th class=listtop>$form->{title}</th>
1311 <tr height="5"></tr>
1315 <tr class=listheading>
1318 map { print "$column_header{$_}\n" } @column_index;
1324 foreach $ref (@{ $form->{ALL} }) {
1330 <tr valign=top class=listrow$i>
1334 $form->format_amount(\%myconfig, $ref->{discount} * 100, 1, " ");
1337 ? "<b>$ref->{description}</b>"
1338 : "$ref->{description}";
1339 $column_data{description} =
1340 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>|;
1341 $column_data{discount} = qq|<td align=right>$discount</td>|;
1342 $column_data{customernumberinit} =
1343 qq|<td align=right>$ref->{customernumberinit}</td>|;
1345 map { print "$column_data{$_}\n" } @column_index;
1357 <td><hr size=3 noshade></td>
1362 <form method=post action=$form->{script}>
1364 <input name=callback type=hidden value="$form->{callback}">
1366 <input type=hidden name=type value=business>
1368 <input type=hidden name=path value=$form->{path}>
1369 <input type=hidden name=login value=$form->{login}>
1370 <input type=hidden name=password value=$form->{password}>
1372 <input class=submit type=submit name=action value="|
1373 . $locale->text('Add') . qq|">
1381 $lxdebug->leave_sub();
1384 sub business_header {
1385 $lxdebug->enter_sub();
1387 $form->{title} = $locale->text("$form->{title} Business");
1388 $form->{salesman} = "checked" if $form->{salesman};
1390 # $locale->text('Add Business')
1391 # $locale->text('Edit Business')
1393 $form->{description} =~ s/\"/"/g;
1395 $form->format_amount(\%myconfig, $form->{discount} * 100);
1402 <form method=post action=$form->{script}>
1404 <input type=hidden name=id value=$form->{id}>
1405 <input type=hidden name=type value=business>
1409 <th class=listtop colspan=2>$form->{title}</th>
1411 <tr height="5"></tr>
1413 <th align=right>| . $locale->text('Type of Business') . qq|</th>
1414 <td><input name=description size=30 value="$form->{description}"></td>
1417 <th align=right>| . $locale->text('Discount') . qq| %</th>
1418 <td><input name=discount size=5 value=$form->{discount}></td>
1421 <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
1422 <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
1425 <td align=right>| . $locale->text('Salesman') . qq|</td>
1426 <td><input name=salesman class=checkbox type=checkbox value=1 $form->{salesman}></td>
1428 <td colspan=2><hr size=3 noshade></td>
1433 $lxdebug->leave_sub();
1437 $lxdebug->enter_sub();
1439 $form->isblank("description", $locale->text('Description missing!'));
1440 AM->save_business(\%myconfig, \%$form);
1441 $form->redirect($locale->text('Business saved!'));
1443 $lxdebug->leave_sub();
1446 sub delete_business {
1447 $lxdebug->enter_sub();
1449 AM->delete_business(\%myconfig, \%$form);
1450 $form->redirect($locale->text('Business deleted!'));
1452 $lxdebug->leave_sub();
1456 $lxdebug->enter_sub();
1458 $form->{title} = "Add";
1461 "$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}&password=$form->{password}"
1462 unless $form->{callback};
1467 $lxdebug->leave_sub();
1471 $lxdebug->enter_sub();
1473 $form->{title} = "Edit";
1475 AM->get_language(\%myconfig, \%$form);
1479 $form->{orphaned} = 1;
1482 $lxdebug->leave_sub();
1486 $lxdebug->enter_sub();
1488 AM->language(\%myconfig, \%$form);
1491 "$form->{script}?action=list_language&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1493 $callback = $form->escape($form->{callback});
1495 $form->{title} = $locale->text('Languages');
1497 @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
1499 $column_header{description} =
1500 qq|<th class=listheading width=60%>|
1501 . $locale->text('Description')
1503 $column_header{template_code} =
1504 qq|<th class=listheading width=10%>|
1505 . $locale->text('Template Code')
1507 $column_header{article_code} =
1508 qq|<th class=listheading>|
1509 . $locale->text('Article Code')
1511 $column_header{output_numberformat} =
1512 qq|<th class=listheading>|
1513 . $locale->text('Number Format')
1515 $column_header{output_dateformat} =
1516 qq|<th class=listheading>|
1517 . $locale->text('Date Format')
1519 $column_header{output_longdates} =
1520 qq|<th class=listheading>|
1521 . $locale->text('Long Dates')
1531 <th class=listtop>$form->{title}</th>
1533 <tr height="5"></tr>
1537 <tr class=listheading>
1540 map { print "$column_header{$_}\n" } @column_index;
1546 foreach $ref (@{ $form->{ALL} }) {
1552 <tr valign=top class=listrow$i>
1556 $column_data{description} =
1557 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>|;
1558 $column_data{template_code} = qq|<td align=right>$ref->{template_code}</td>|;
1559 $column_data{article_code} =
1560 qq|<td align=right>$ref->{article_code}</td>|;
1561 $column_data{output_numberformat} =
1563 ($ref->{output_numberformat} ? $ref->{output_numberformat} :
1564 $locale->text("use program settings")) .
1566 $column_data{output_dateformat} =
1568 ($ref->{output_dateformat} ? $ref->{output_dateformat} :
1569 $locale->text("use program settings")) .
1571 $column_data{output_longdates} =
1573 ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
1576 map { print "$column_data{$_}\n" } @column_index;
1588 <td><hr size=3 noshade></td>
1593 <form method=post action=$form->{script}>
1595 <input name=callback type=hidden value="$form->{callback}">
1597 <input type=hidden name=type value=language>
1599 <input type=hidden name=path value=$form->{path}>
1600 <input type=hidden name=login value=$form->{login}>
1601 <input type=hidden name=password value=$form->{password}>
1603 <input class=submit type=submit name=action value="|
1604 . $locale->text('Add') . qq|">
1612 $lxdebug->leave_sub();
1615 sub language_header {
1616 $lxdebug->enter_sub();
1618 $form->{title} = $locale->text("$form->{title} Language");
1620 # $locale->text('Add Language')
1621 # $locale->text('Edit Language')
1623 $form->{description} =~ s/\"/"/g;
1624 $form->{template_code} =~ s/\"/"/g;
1625 $form->{article_code} =~ s/\"/"/g;
1631 qq|<option value="">| . $locale->text("use program settings") .
1633 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
1635 ($item eq $form->{output_numberformat})
1636 ? "<option selected>$item"
1642 qq|<option value="">| . $locale->text("use program settings") .
1644 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
1646 ($item eq $form->{output_dateformat})
1647 ? "<option selected>$item"
1655 <form method=post action=$form->{script}>
1657 <input type=hidden name=id value=$form->{id}>
1658 <input type=hidden name=type value=language>
1662 <th class=listtop colspan=2>$form->{title}</th>
1664 <tr height="5"></tr>
1666 <th align=right>| . $locale->text('Language') . qq|</th>
1667 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1670 <th align=right>| . $locale->text('Template Code') . qq|</th>
1671 <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
1674 <th align=right>| . $locale->text('Article Code') . qq|</th>
1675 <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
1678 <th align=right>| . $locale->text('Number Format') . qq|</th>
1679 <td><select name="output_numberformat">$numberformat</select></td>
1682 <th align=right>| . $locale->text('Date Format') . qq|</th>
1683 <td><select name="output_dateformat">$dateformat</select></td>
1686 <th align=right>| . $locale->text('Long Dates') . qq|</th>
1687 <td><input type="radio" name="output_longdates" value="1"| .
1688 ($form->{output_longdates} ? " checked" : "") .
1689 qq|>| . $locale->text("Yes") .
1690 qq|<input type="radio" name="output_longdates" value="0"| .
1691 ($form->{output_longdates} ? "" : " checked") .
1692 qq|>| . $locale->text("No") .
1695 <td colspan=2><hr size=3 noshade></td>
1700 $lxdebug->leave_sub();
1704 $lxdebug->enter_sub();
1706 $form->isblank("description", $locale->text('Language missing!'));
1707 $form->isblank("template_code", $locale->text('Template Code missing!'));
1708 $form->isblank("article_code", $locale->text('Article Code missing!'));
1709 AM->save_language(\%myconfig, \%$form);
1710 $form->redirect($locale->text('Language saved!'));
1712 $lxdebug->leave_sub();
1715 sub delete_language {
1716 $lxdebug->enter_sub();
1718 AM->delete_language(\%myconfig, \%$form);
1719 $form->redirect($locale->text('Language deleted!'));
1721 $lxdebug->leave_sub();
1725 sub add_buchungsgruppe {
1726 $lxdebug->enter_sub();
1728 # $locale->text("Add Buchungsgruppe")
1729 # $locale->text("Edit Buchungsgruppe")
1730 $form->{title} = "Add";
1733 "$form->{script}?action=add_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}"
1734 unless $form->{callback};
1735 AM->get_buchungsgruppe(\%myconfig, \%$form);
1736 $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
1737 for (my $i = 0; 4 > $i; $i++) {
1738 map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
1739 qw(income expense));
1742 &buchungsgruppe_header;
1745 $lxdebug->leave_sub();
1748 sub edit_buchungsgruppe {
1749 $lxdebug->enter_sub();
1751 $form->{title} = "Edit";
1753 AM->get_buchungsgruppe(\%myconfig, \%$form);
1755 &buchungsgruppe_header;
1759 $lxdebug->leave_sub();
1762 sub list_buchungsgruppe {
1763 $lxdebug->enter_sub();
1765 AM->buchungsgruppe(\%myconfig, \%$form);
1768 "$form->{script}?action=list_buchungsgruppe&path=$form->{path}&login=$form->{login}&password=$form->{password}";
1770 $callback = $form->escape($form->{callback});
1772 $form->{title} = $locale->text('Buchungsgruppen');
1774 @column_index = qw(up down description inventory_accno
1775 income_accno_0 expense_accno_0
1776 income_accno_1 expense_accno_1
1777 income_accno_2 expense_accno_2
1778 income_accno_3 expense_accno_3 );
1780 $column_header{up} =
1781 qq|<th class="listheading">|
1782 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
1784 $column_header{down} =
1785 qq|<th class="listheading">|
1786 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
1788 $column_header{description} =
1789 qq|<th class="listheading" width="40%">|
1790 . $locale->text('Description')
1792 $column_header{inventory_accno} =
1793 qq|<th class=listheading>|
1794 . $locale->text('Bestandskonto')
1796 $column_header{income_accno_0} =
1797 qq|<th class=listheading>|
1798 . $locale->text('Erlöse Inland')
1800 $column_header{expense_accno_0} =
1801 qq|<th class=listheading>|
1802 . $locale->text('Aufwand Inland')
1804 $column_header{income_accno_1} =
1805 qq|<th class=listheading>|
1806 . $locale->text('Erlöse EU m. UStId')
1808 $column_header{expense_accno_1} =
1809 qq|<th class=listheading>|
1810 . $locale->text('Aufwand EU m. UStId')
1812 $column_header{income_accno_2} =
1813 qq|<th class=listheading>|
1814 . $locale->text('Erlöse EU o. UStId')
1816 $column_header{expense_accno_2} =
1817 qq|<th class=listheading>|
1818 . $locale->text('Aufwand EU o. UStId')
1820 $column_header{income_accno_3} =
1821 qq|<th class=listheading>|
1822 . $locale->text('Erlöse Ausland')
1824 $column_header{expense_accno_3} =
1825 qq|<th class=listheading>|
1826 . $locale->text('Aufwand Ausland')
1835 <th class=listtop>$form->{title}</th>
1837 <tr height="5"></tr>
1841 <tr class=listheading>
1844 map { print "$column_header{$_}\n" } @column_index;
1850 my $swap_link = qq|$form->{script}?action=swap_buchungsgruppen&|;
1851 map({ $swap_link .= $_ . "=" . $form->escape($form->{$_}) . "&" }
1852 qw(login password path));
1855 foreach $ref (@{ $form->{ALL} }) {
1861 <tr valign=top class=listrow$i>
1865 my $pref = $form->{ALL}->[$row - 1];
1867 qq|<td align="center" valign="center">| .
1868 qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
1869 qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">| .
1872 $column_data{up} = qq|<td> </td>|;
1875 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
1876 $column_data{down} = qq|<td> </td>|;
1878 my $nref = $form->{ALL}->[$row + 1];
1879 $column_data{down} =
1880 qq|<td align="center" valign="center">| .
1881 qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
1882 qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">| .
1886 $column_data{description} =
1887 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>|;
1888 $column_data{inventory_accno} = qq|<td align=right>$ref->{inventory_accno}</td>|;
1889 $column_data{income_accno_0} =
1890 qq|<td align=right>$ref->{income_accno_0}</td>|;
1891 $column_data{expense_accno_0} = qq|<td align=right>$ref->{expense_accno_0}</td>|;
1892 $column_data{income_accno_1} =
1893 qq|<td align=right>$ref->{income_accno_1}</td>|;
1894 $column_data{expense_accno_1} = qq|<td align=right>$ref->{expense_accno_1}</td>|;
1895 $column_data{income_accno_2} =
1896 qq|<td align=right>$ref->{income_accno_2}</td>|;
1897 $column_data{expense_accno_2} = qq|<td align=right>$ref->{expense_accno_2}</td>|;
1898 $column_data{income_accno_3} =
1899 qq|<td align=right>$ref->{income_accno_3}</td>|;
1900 $column_data{expense_accno_3} = qq|<td align=right>$ref->{expense_accno_3}</td>|;
1902 map { print "$column_data{$_}\n" } @column_index;
1916 <td><hr size=3 noshade></td>
1921 <form method=post action=$form->{script}>
1923 <input name=callback type=hidden value="$form->{callback}">
1925 <input type=hidden name=type value=buchungsgruppe>
1927 <input type=hidden name=path value=$form->{path}>
1928 <input type=hidden name=login value=$form->{login}>
1929 <input type=hidden name=password value=$form->{password}>
1931 <input class=submit type=submit name=action value="|
1932 . $locale->text('Add') . qq|">
1940 $lxdebug->leave_sub();
1943 sub buchungsgruppe_header {
1944 $lxdebug->enter_sub();
1946 $form->{title} = $locale->text("$form->{title} Buchungsgruppe");
1948 # $locale->text('Buchungsgruppe hinzufügen')
1949 # $locale->text('Buchungsgruppe bearbeiten')
1951 my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
1952 my %acc_type_map = (
1953 "IC" => $acc_inventory,
1954 "IC_income" => $acc_income,
1955 "IC_sale" => $acc_income,
1956 "IC_expense" => $acc_expense,
1957 "IC_cogs" => $acc_expense,
1960 foreach $key (keys(%acc_type_map)) {
1961 foreach $ref (@{ $form->{IC_links}{$key} }) {
1962 $acc_type_map{$key}->{$ref->{"id"}} = $ref;
1966 foreach my $type (qw(IC IC_income IC_expense)) {
1967 $form->{"select$type"} =
1969 map({ "<option value=$_->{id} $_->{selected}>" .
1970 "$_->{accno}--" . H($_->{description}) . "</option>" }
1971 sort({ $a->{"accno"} cmp $b->{"accno"} }
1972 values(%{$acc_type_map{$type}}))));
1976 $form->{selectIC} =~ s/selected//g;
1977 $form->{selectIC} =~ s/ value=$form->{inventory_accno_id}/ value=$form->{inventory_accno_id} selected/;
1978 $form->{selectIC_income} =~ s/selected//g;
1979 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_0}/ value=$form->{income_accno_id_0} selected/;
1980 $form->{selectIC_expense} =~ s/selected//g;
1981 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_0}/ value=$form->{expense_accno_id_0} selected/;
1987 <th align=right>| . $locale->text('Inventory') . qq|</th>
1988 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
1989 <input name=selectIC type=hidden value="$form->{selectIC}">
1993 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
1997 $linkaccounts .= qq|
1999 <th align=right>| . $locale->text('Erlöse Inland') . qq|</th>
2000 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
2003 <th align=right>| . $locale->text('Aufwand Inland') . qq|</th>
2004 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
2007 $form->{selectIC_income} =~ s/selected//g;
2008 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_1}/ value=$form->{income_accno_id_1} selected/;
2009 $form->{selectIC_expense} =~ s/selected//g;
2010 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/ value=$form->{expense_accno_id_1} selected/;
2012 $linkaccounts .= qq| <tr>
2013 <th align=right>| . $locale->text('Erlöse EU m. UStId') . qq|</th>
2014 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
2017 <th align=right>| . $locale->text('Aufwand EU m UStId') . qq|</th>
2018 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
2022 $form->{selectIC_income} =~ s/selected//g;
2023 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_2}/ value=$form->{income_accno_id_2} selected/;
2024 $form->{selectIC_expense} =~ s/selected//g;
2025 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_2}/ value=$form->{expense_accno_id_2} selected/;
2028 $linkaccounts .= qq| <tr>
2029 <th align=right>| . $locale->text('Erlöse EU o. UStId') . qq|</th>
2030 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
2033 <th align=right>| . $locale->text('Aufwand EU o. UStId') . qq|</th>
2034 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
2038 $form->{selectIC_income} =~ s/selected//g;
2039 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_3}/ value=$form->{income_accno_id_3} selected/;
2040 $form->{selectIC_expense} =~ s/selected//g;
2041 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_3}/ value=$form->{expense_accno_id_3} selected/;
2044 $linkaccounts .= qq| <tr>
2045 <th align=right>| . $locale->text('Erlöse Ausland') . qq|</th>
2046 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
2049 <th align=right>| . $locale->text('Aufwand Ausland') . qq|</th>
2050 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
2060 <form method=post action=$form->{script}>
2062 <input type=hidden name=id value=$form->{id}>
2063 <input type=hidden name=type value=buchungsgruppe>
2067 <th class=listtop colspan=2>$form->{title}</th>
2069 <tr height="5"></tr>
2071 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
2072 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
2075 <td colspan=2><hr size=3 noshade></td>
2080 $lxdebug->leave_sub();
2083 sub save_buchungsgruppe {
2084 $lxdebug->enter_sub();
2086 $form->isblank("description", $locale->text('Description missing!'));
2088 AM->save_buchungsgruppe(\%myconfig, \%$form);
2089 $form->redirect($locale->text('Buchungsgruppe gespeichert!'));
2091 $lxdebug->leave_sub();
2094 sub delete_buchungsgruppe {
2095 $lxdebug->enter_sub();
2097 AM->delete_buchungsgruppe(\%myconfig, \%$form);
2098 $form->redirect($locale->text('Buchungsgruppe gelöscht!'));
2100 $lxdebug->leave_sub();
2103 sub swap_buchungsgruppen {
2104 $lxdebug->enter_sub();
2106 AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
2107 list_buchungsgruppe();
2109 $lxdebug->leave_sub();
2114 $lxdebug->enter_sub();
2116 $form->{title} = "Add";
2119 "$form->{script}?action=add_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}"
2120 unless $form->{callback};
2125 $lxdebug->leave_sub();
2129 $lxdebug->enter_sub();
2131 $form->{title} = "Edit";
2133 AM->get_printer(\%myconfig, \%$form);
2137 $form->{orphaned} = 1;
2140 $lxdebug->leave_sub();
2144 $lxdebug->enter_sub();
2146 AM->printer(\%myconfig, \%$form);
2149 "$form->{script}?action=list_printer&path=$form->{path}&login=$form->{login}&password=$form->{password}";
2151 $callback = $form->escape($form->{callback});
2153 $form->{title} = $locale->text('Printer');
2155 @column_index = qw(printer_description printer_command template_code);
2157 $column_header{printer_description} =
2158 qq|<th class=listheading width=60%>|
2159 . $locale->text('Printer Description')
2161 $column_header{printer_command} =
2162 qq|<th class=listheading width=10%>|
2163 . $locale->text('Printer Command')
2165 $column_header{template_code} =
2166 qq|<th class=listheading>|
2167 . $locale->text('Template Code')
2177 <th class=listtop>$form->{title}</th>
2179 <tr height="5"></tr>
2183 <tr class=listheading>
2186 map { print "$column_header{$_}\n" } @column_index;
2192 foreach $ref (@{ $form->{ALL} }) {
2198 <tr valign=top class=listrow$i>
2202 $column_data{printer_description} =
2203 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>|;
2204 $column_data{printer_command} = qq|<td align=right>$ref->{printer_command}</td>|;
2205 $column_data{template_code} =
2206 qq|<td align=right>$ref->{template_code}</td>|;
2208 map { print "$column_data{$_}\n" } @column_index;
2220 <td><hr size=3 noshade></td>
2225 <form method=post action=$form->{script}>
2227 <input name=callback type=hidden value="$form->{callback}">
2229 <input type=hidden name=type value=printer>
2231 <input type=hidden name=path value=$form->{path}>
2232 <input type=hidden name=login value=$form->{login}>
2233 <input type=hidden name=password value=$form->{password}>
2235 <input class=submit type=submit name=action value="|
2236 . $locale->text('Add') . qq|">
2244 $lxdebug->leave_sub();
2247 sub printer_header {
2248 $lxdebug->enter_sub();
2250 $form->{title} = $locale->text("$form->{title} Printer");
2252 # $locale->text('Add Printer')
2253 # $locale->text('Edit Printer')
2255 $form->{printer_description} =~ s/\"/"/g;
2256 $form->{template_code} =~ s/\"/"/g;
2257 $form->{printer_command} =~ s/\"/"/g;
2265 <form method=post action=$form->{script}>
2267 <input type=hidden name=id value=$form->{id}>
2268 <input type=hidden name=type value=printer>
2272 <th class=listtop colspan=2>$form->{title}</th>
2274 <tr height="5"></tr>
2276 <th align=right>| . $locale->text('Printer') . qq|</th>
2277 <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
2280 <th align=right>| . $locale->text('Printer Command') . qq|</th>
2281 <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
2284 <th align=right>| . $locale->text('Template Code') . qq|</th>
2285 <td><input name=template_code size=5 value="$form->{template_code}"></td>
2287 <td colspan=2><hr size=3 noshade></td>
2292 $lxdebug->leave_sub();
2296 $lxdebug->enter_sub();
2298 $form->isblank("printer_description", $locale->text('Description missing!'));
2299 $form->isblank("printer_command", $locale->text('Printer Command missing!'));
2300 AM->save_printer(\%myconfig, \%$form);
2301 $form->redirect($locale->text('Printer saved!'));
2303 $lxdebug->leave_sub();
2306 sub delete_printer {
2307 $lxdebug->enter_sub();
2309 AM->delete_printer(\%myconfig, \%$form);
2310 $form->redirect($locale->text('Printer deleted!'));
2312 $lxdebug->leave_sub();
2317 $lxdebug->enter_sub();
2319 $form->{title} = "Add";
2322 "$form->{script}?action=add_payment&path=$form->{path}&login=$form->{login}&password=$form->{password}"
2323 unless $form->{callback};
2325 $form->{terms_netto} = 0;
2326 $form->{terms_skonto} = 0;
2327 $form->{percent_skonto} = 0;
2328 my @languages = AM->language(\%myconfig, $form, 1);
2329 map({ $_->{"language"} = $_->{"description"};
2330 $_->{"language_id"} = $_->{"id"}; } @languages);
2331 $form->{"TRANSLATION"} = \@languages;
2335 $lxdebug->leave_sub();
2339 $lxdebug->enter_sub();
2341 $form->{title} = "Edit";
2343 AM->get_payment(\%myconfig, $form);
2344 $form->{percent_skonto} =
2345 $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
2349 $form->{orphaned} = 1;
2352 $lxdebug->leave_sub();
2356 $lxdebug->enter_sub();
2358 AM->payment(\%myconfig, \%$form);
2360 $form->{callback} = build_std_url("action=list_payment");
2362 $callback = $form->escape($form->{callback});
2364 $form->{title} = $locale->text('Payment Terms');
2366 @column_index = qw(up down description description_long terms_netto
2367 terms_skonto percent_skonto);
2369 $column_header{up} =
2370 qq|<th class="listheading" align="center" valign="center">|
2371 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
2373 $column_header{down} =
2374 qq|<th class="listheading" align="center" valign="center">|
2375 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
2377 $column_header{description} =
2378 qq|<th class=listheading>|
2379 . $locale->text('Description')
2381 $column_header{description_long} =
2382 qq|<th class=listheading>|
2383 . $locale->text('Long Description')
2385 $column_header{terms_netto} =
2386 qq|<th class=listheading>|
2387 . $locale->text('Netto Terms')
2389 $column_header{terms_skonto} =
2390 qq|<th class=listheading>|
2391 . $locale->text('Skonto Terms')
2393 $column_header{percent_skonto} =
2394 qq|<th class=listheading>|
2395 . $locale->text('Skonto')
2405 <th class=listtop>$form->{title}</th>
2407 <tr height="5"></tr>
2411 <tr class=listheading>
2414 map { print "$column_header{$_}\n" } @column_index;
2420 my $swap_link = build_std_url("action=swap_payment_terms");
2423 foreach $ref (@{ $form->{ALL} }) {
2429 <tr valign=top class=listrow$i>
2433 my $pref = $form->{ALL}->[$row - 1];
2435 qq|<td align="center" valign="center">| .
2436 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
2437 qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">| .
2440 $column_data{up} = qq|<td> </td>|;
2443 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
2444 $column_data{down} = qq|<td> </td>|;
2446 my $nref = $form->{ALL}->[$row + 1];
2447 $column_data{down} =
2448 qq|<td align="center" valign="center">| .
2449 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
2450 qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">| .
2454 $column_data{description} =
2456 build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
2457 qq|">| . H($ref->{description}) . qq|</a></td>|;
2458 $column_data{description_long} =
2459 qq|<td>| . H($ref->{description_long}) . qq|</td>|;
2460 $column_data{terms_netto} =
2461 qq|<td align=right>$ref->{terms_netto}</td>|;
2462 $column_data{terms_skonto} =
2463 qq|<td align=right>$ref->{terms_skonto}</td>|;
2464 $column_data{percent_skonto} =
2465 qq|<td align=right>| .
2466 $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
2468 map { print "$column_data{$_}\n" } @column_index;
2481 <td><hr size=3 noshade></td>
2486 <form method=post action=$form->{script}>
2488 <input name=callback type=hidden value="$form->{callback}">
2490 <input type=hidden name=type value=payment>
2492 <input type=hidden name=path value=$form->{path}>
2493 <input type=hidden name=login value=$form->{login}>
2494 <input type=hidden name=password value=$form->{password}>
2496 <input class=submit type=submit name=action value="|
2497 . $locale->text('Add') . qq|">
2505 $lxdebug->leave_sub();
2508 sub payment_header {
2509 $lxdebug->enter_sub();
2511 $form->{title} = $locale->text("$form->{title} Payment Terms");
2513 # $locale->text('Add Payment Terms')
2514 # $locale->text('Edit Payment Terms')
2516 $form->{description} =~ s/\"/"/g;
2525 <form method=post action=$form->{script}>
2527 <input type=hidden name=id value=$form->{id}>
2528 <input type=hidden name=type value=payment>
2532 <th class=listtop colspan=2>$form->{title}</th>
2534 <tr height="5"></tr>
2536 <th align=right>| . $locale->text('Description') . qq|</th>
2537 <td><input name=description size=30 value="$form->{description}"></td>
2540 <th align=right>| . $locale->text('Long Description') . qq|</th>
2541 <td><input name=description_long size=50 value="$form->{description_long}"></td>
2545 foreach my $language (@{ $form->{"TRANSLATION"} }) {
2548 <th align="right">| .
2549 sprintf($locale->text('Translation (%s)'),
2550 $language->{"language"})
2552 <td><input name="description_long_$language->{language_id}" size="50"
2553 value="| . Q($language->{"description_long"}) . qq|"></td>
2560 <th align=right>| . $locale->text('Netto Terms') . qq|</th>
2561 <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
2564 <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
2565 <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
2568 <th align=right>| . $locale->text('Skonto') . qq| %</th>
2569 <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
2571 <td colspan=2><hr size=3 noshade></td>
2575 <p>| . $locale->text("You can use the following strings in the long " .
2576 "description and all translations. They will be " .
2577 "replaced by their actual values by Lx-Office " .
2578 "before they're output.")
2582 <li>| . $locale->text("<%netto_date%> -- Date the payment is due in " .
2585 <li>| . $locale->text("<%skonto_date%> -- Date the payment is due " .
2588 <li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
2590 <li>| . $locale->text("<%total%> -- Amount payable")
2592 <li>| . $locale->text("<%invtotal%> -- Invoice total")
2594 <li>| . $locale->text("<%currency%> -- The selected currency")
2596 <li>| . $locale->text("<%terms_netto%> -- The number of days for " .
2599 <li>| . $locale->text("<%account_number%> -- Your account number")
2601 <li>| . $locale->text("<%bank%> -- Your bank")
2603 <li>| . $locale->text("<%bank_code%> -- Your bank code")
2607 $lxdebug->leave_sub();
2611 $lxdebug->enter_sub();
2613 $form->isblank("description", $locale->text('Description missing!'));
2614 $form->{"percent_skonto"} =
2615 $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
2616 AM->save_payment(\%myconfig, \%$form);
2617 $form->redirect($locale->text('Payment Terms saved!'));
2619 $lxdebug->leave_sub();
2622 sub delete_payment {
2623 $lxdebug->enter_sub();
2625 AM->delete_payment(\%myconfig, \%$form);
2626 $form->redirect($locale->text('Payment terms deleted!'));
2628 $lxdebug->leave_sub();
2631 sub swap_payment_terms {
2632 $lxdebug->enter_sub();
2634 AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
2637 $lxdebug->leave_sub();
2641 $lxdebug->enter_sub();
2643 $form->{title} = "Add";
2646 "$form->{script}?action=add_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}"
2647 unless $form->{callback};
2652 $lxdebug->leave_sub();
2656 $lxdebug->enter_sub();
2658 $form->{title} = "Edit";
2660 AM->get_sic(\%myconfig, \%$form);
2664 $form->{orphaned} = 1;
2667 $lxdebug->leave_sub();
2671 $lxdebug->enter_sub();
2673 AM->sic(\%myconfig, \%$form);
2676 "$form->{script}?action=list_sic&path=$form->{path}&login=$form->{login}&password=$form->{password}";
2678 $callback = $form->escape($form->{callback});
2680 $form->{title} = $locale->text('Standard Industrial Codes');
2682 @column_index = qw(code description);
2684 $column_header{code} =
2685 qq|<th class=listheading>| . $locale->text('Code') . qq|</th>|;
2686 $column_header{description} =
2687 qq|<th class=listheading>| . $locale->text('Description') . qq|</th>|;
2696 <th class=listtop>$form->{title}</th>
2698 <tr height="5"></tr>
2702 <tr class=listheading>
2705 map { print "$column_header{$_}\n" } @column_index;
2711 foreach $ref (@{ $form->{ALL} }) {
2716 if ($ref->{sictype} eq 'H') {
2718 <tr valign=top class=listheading>
2720 $column_data{code} =
2721 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>|;
2722 $column_data{description} = qq|<th>$ref->{description}</th>|;
2726 <tr valign=top class=listrow$i>
2729 $column_data{code} =
2730 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>|;
2731 $column_data{description} = qq|<td>$ref->{description}</td>|;
2735 map { print "$column_data{$_}\n" } @column_index;
2747 <td><hr size=3 noshade></td>
2752 <form method=post action=$form->{script}>
2754 <input name=callback type=hidden value="$form->{callback}">
2756 <input type=hidden name=type value=sic>
2758 <input type=hidden name=path value=$form->{path}>
2759 <input type=hidden name=login value=$form->{login}>
2760 <input type=hidden name=password value=$form->{password}>
2762 <input class=submit type=submit name=action value="|
2763 . $locale->text('Add') . qq|">
2771 $lxdebug->leave_sub();
2775 $lxdebug->enter_sub();
2777 $form->{title} = $locale->text("$form->{title} SIC");
2779 # $locale->text('Add SIC')
2780 # $locale->text('Edit SIC')
2782 $form->{code} =~ s/\"/"/g;
2783 $form->{description} =~ s/\"/"/g;
2785 $checked = ($form->{sictype} eq 'H') ? "checked" : "";
2792 <form method=post action=$form->{script}>
2794 <input type=hidden name=type value=sic>
2795 <input type=hidden name=id value=$form->{code}>
2799 <th class=listtop colspan=2>$form->{title}</th>
2801 <tr height="5"></tr>
2803 <th align=right>| . $locale->text('Code') . qq|</th>
2804 <td><input name=code size=10 value=$form->{code}></td>
2808 <th align=left><input name=sictype type=checkbox style=checkbox value="H" $checked> |
2809 . $locale->text('Heading') . qq|</th>
2812 <th align=right>| . $locale->text('Description') . qq|</th>
2813 <td><input name=description size=60 value="$form->{description}"></td>
2815 <td colspan=2><hr size=3 noshade></td>
2820 $lxdebug->leave_sub();
2824 $lxdebug->enter_sub();
2826 $form->isblank("code", $locale->text('Code missing!'));
2827 $form->isblank("description", $locale->text('Description missing!'));
2828 AM->save_sic(\%myconfig, \%$form);
2829 $form->redirect($locale->text('SIC saved!'));
2831 $lxdebug->leave_sub();
2835 $lxdebug->enter_sub();
2837 AM->delete_sic(\%myconfig, \%$form);
2838 $form->redirect($locale->text('SIC deleted!'));
2840 $lxdebug->leave_sub();
2843 sub display_stylesheet {
2844 $lxdebug->enter_sub();
2846 $form->{file} = "css/$myconfig{stylesheet}";
2849 $lxdebug->leave_sub();
2853 $lxdebug->enter_sub();
2855 $form->{file} =~ s/^(.:)*?\/|\.\.\///g;
2856 $form->{file} =~ s/^\/*//g;
2857 $form->{file} =~ s/$userspath//;
2859 $form->error("$!: $form->{file}") unless -f $form->{file};
2861 AM->load_template(\%$form);
2863 $form->{title} = $form->{file};
2865 # if it is anything but html
2866 if ($form->{file} !~ /\.html$/) {
2867 $form->{body} = "<pre>\n$form->{body}\n</pre>";
2877 <form method=post action=$form->{script}>
2879 <input name=file type=hidden value=$form->{file}>
2880 <input name=type type=hidden value=template>
2882 <input type=hidden name=path value=$form->{path}>
2883 <input type=hidden name=login value=$form->{login}>
2884 <input type=hidden name=password value=$form->{password}>
2886 <input name=action type=submit class=submit value="|
2887 . $locale->text('Edit') . qq|">
2895 $lxdebug->leave_sub();
2899 $lxdebug->enter_sub();
2901 AM->load_template(\%$form);
2903 $form->{title} = $locale->text('Edit Template');
2905 # convert   to &nbsp;
2906 $form->{body} =~ s/ /&nbsp;/gi;
2913 <form method=post action=$form->{script}>
2915 <input name=file type=hidden value=$form->{file}>
2916 <input name=type type=hidden value=template>
2918 <input type=hidden name=path value=$form->{path}>
2919 <input type=hidden name=login value=$form->{login}>
2920 <input type=hidden name=password value=$form->{password}>
2922 <input name=callback type=hidden value="$form->{script}?action=display_form&file=$form->{file}&path=$form->{path}&login=$form->{login}&password=$form->{password}">
2924 <textarea name=body rows=25 cols=70>
2929 <input type=submit class=submit name=action value="|
2930 . $locale->text('Save') . qq|">
2939 $lxdebug->leave_sub();
2943 $lxdebug->enter_sub();
2945 AM->save_template(\%$form);
2946 $form->redirect($locale->text('Template saved!'));
2948 $lxdebug->leave_sub();
2952 $lxdebug->enter_sub();
2954 # get defaults for account numbers and last numbers
2955 AM->defaultaccounts(\%myconfig, \%$form);
2957 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
2959 ($item eq $myconfig{dateformat})
2960 ? "<option selected>$item\n"
2961 : "<option>$item\n";
2964 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
2966 ($item eq $myconfig{numberformat})
2967 ? "<option selected>$item\n"
2968 : "<option>$item\n";
2971 foreach $item (qw(name company address signature)) {
2972 $myconfig{$item} =~ s/\"/"/g;
2975 foreach $item (qw(address signature)) {
2976 $myconfig{$item} =~ s/\\n/\r\n/g;
2980 if ($opendocument_templates && $openofficeorg_writer_bin &&
2981 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
2982 push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
2983 "value" => "opendocument_pdf" });
2985 if ($latex_templates) {
2986 push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
2988 push(@formats, { "name" => "HTML", "value" => "html" });
2989 if ($latex_templates) {
2990 push(@formats, { "name" => $locale->text("Postscript"),
2991 "value" => "postscript" });
2993 if ($opendocument_templates) {
2994 push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
2995 "value" => "opendocument" });
2998 if (!$myconfig{"template_format"}) {
2999 $myconfig{"template_format"} = "pdf";
3001 my $template_format = "";
3002 foreach $item (@formats) {
3004 "<option value=\"$item->{value}\"" .
3005 ($item->{"value"} eq $myconfig{"template_format"} ?
3007 ">" . H($item->{"name"}) . "</option>";
3010 if (!$myconfig{"default_media"}) {
3011 $myconfig{"default_media"} = "screen";
3013 my %selected = ($myconfig{"default_media"} => "selected");
3014 my $default_media = qq|
3015 <option value="screen" $selected{'screen'}>| . $locale->text("Screen") . qq|</option>
3016 <option value="printer" $selected{'printer'}>| . $locale->text("Printer") . qq|</option>
3017 <option value="queue" $selected{'queue'}>| . $locale->text("Queue") . qq|</option>
3021 $selected{$myconfig{"default_printer_id"}} = "selected"
3022 if ($myconfig{"default_printer_id"});
3023 my $default_printer = qq|<option></option>|;
3024 AM->printer(\%myconfig, $form);
3025 foreach my $printer (@{$form->{"ALL"}}) {
3026 $default_printer .= qq|<option value="| . Q($printer->{"id"}) .
3027 qq|" $selected{$printer->{'id'}}>| .
3028 H($printer->{"printer_description"}) . qq|</option>|;
3031 %countrycodes = User->country_codes;
3033 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
3037 ($myconfig{countrycode} eq $key)
3038 ? "<option selected value=$key>$countrycodes{$key}\n"
3039 : "<option value=$key>$countrycodes{$key}\n";
3041 $countrycodes = "<option>American English\n$countrycodes";
3043 # use an other input number format than output numberformat
3044 # look at Form.pm, sub parse_amount
3045 my $in_numberformat = '';
3046 $text1 = qq|value="0">| . $locale->text('equal Outputformat');
3047 $text2 = qq|value="1">| . $locale->text('1000,00 or 1000.00');
3048 @in_nf = ($text1, $text2);
3049 foreach $item (@in_nf) {
3051 (substr($item, 7, 1) eq $myconfig{in_numberformat})
3052 ? "<option selected $item\n"
3053 : "<option $item\n";
3056 foreach $key (keys %{ $form->{IC} }) {
3057 foreach $accno (sort keys %{ $form->{IC}{$key} }) {
3059 ($form->{IC}{$key}{$accno}{id} == $form->{defaults}{$key})
3060 ? "<option selected>$accno--$form->{IC}{$key}{$accno}{description}\n"
3061 : "<option>$accno--$form->{IC}{$key}{$accno}{description}\n";
3065 opendir CSS, "css/.";
3066 @all = grep /.*\.css$/, readdir CSS;
3069 foreach $item (@all) {
3070 if ($item eq $myconfig{stylesheet}) {
3071 $selectstylesheet .= qq|<option selected>$item\n|;
3073 $selectstylesheet .= qq|<option>$item\n|;
3076 $selectstylesheet .= "<option>\n";
3078 $form->{title} = $locale->text('Edit Preferences for') . qq| $form->{login}|;
3082 if ($myconfig{menustyle} eq "old") {
3083 $menustyle_old = "checked";
3084 } elsif ($myconfig{menustyle} eq "neu") {
3085 $menustyle_neu = "checked";
3086 } elsif ($myconfig{menustyle} eq "v3") {
3087 $menustyle_v3 = "checked";
3090 my ($show_form_details, $hide_form_details);
3091 $myconfig{"show_form_details"} = 1
3092 unless (defined($myconfig{"show_form_details"}));
3093 $show_form_details = "checked" if ($myconfig{"show_form_details"});
3094 $hide_form_details = "checked" unless ($myconfig{"show_form_details"});
3099 <form method=post action=$form->{script}>
3101 <input type=hidden name=old_password value=$myconfig{password}>
3102 <input type=hidden name=type value=preferences>
3103 <input type=hidden name=role value=$myconfig{role}>
3106 <tr><th class=listtop>$form->{title}</th></tr>
3111 <th align=right>| . $locale->text('Name') . qq|</th>
3112 <td><input name=name size=15 value="$myconfig{name}"></td>
3115 <th align=right>| . $locale->text('Password') . qq|</th>
3116 <td><input type=password name=new_password size=10 value=$myconfig{password}></td>
3119 <th align=right>| . $locale->text('E-mail') . qq|</th>
3120 <td><input name=email size=30 value="$myconfig{email}"></td>
3123 <th align=right>| . $locale->text('Signature') . qq|</th>
3124 <td><textarea name=signature rows=3 cols=50>$myconfig{signature}</textarea></td>
3127 <th align=right>| . $locale->text('Phone') . qq|</th>
3128 <td><input name=tel size=14 value="$myconfig{tel}"></td>
3131 <th align=right>| . $locale->text('Fax') . qq|</th>
3132 <td><input name=fax size=14 value="$myconfig{fax}"></td>
3135 <th align=right>| . $locale->text('Company') . qq|</th>
3136 <td><input name=company size=30 value="$myconfig{company}"></td>
3139 <th align=right>| . $locale->text('Address') . qq|</th>
3140 <td><textarea name=address rows=4 cols=50>$myconfig{address}</textarea></td>
3143 <th align=right>| . $locale->text('Date Format') . qq|</th>
3144 <td><select name=dateformat>$dateformat</select></td>
3147 <th align=right>| . $locale->text('Output Number Format') . qq|</th>
3148 <td><select name=numberformat>$numberformat</select></td>
3151 <th align=right>| . $locale->text('Input Number Format') . qq|</th>
3152 <td><select name=in_numberformat>$in_numberformat</select></td>
3156 <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
3157 <td><input name=vclimit size=10 value="$myconfig{vclimit}"></td>
3160 <th align=right>| . $locale->text('Language') . qq|</th>
3161 <td><select name=countrycode>$countrycodes</select></td>
3164 <th align=right>| . $locale->text('Stylesheet') . qq|</th>
3165 <td><select name=usestylesheet>$selectstylesheet</select></td>
3168 <th align=right>| . $locale->text('Setup Menu') . qq|</th>
3169 <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
3170 $locale->text("Top (CSS)") . qq|
3171 <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
3172 $locale->text("Top (Javascript)") . qq|
3173 <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
3174 $locale->text("Old (on the side)") . qq|</td>
3177 <th align=right>| . $locale->text('Form details (second row)') . qq|</th>
3178 <td><input type="radio" id="rad_show_form_details" name="show_form_details" value="1" $show_form_details>
3179 <label for="rad_show_form_details">| . $locale->text('Show by default') . qq|</label>
3180 <input type="radio" id="rad_hide_form_details" name="show_form_details" value="0" $hide_form_details>
3181 <label for="rad_hide_form_details">| . $locale->text('Hide by default') . qq|</label></td>
3183 <input name=printer type=hidden value="$myconfig{printer}">
3184 <tr class=listheading>
3185 <th colspan=2>| . $locale->text("Print options") . qq|</th>
3188 <th align=right>| . $locale->text('Default template format') . qq|</th>
3189 <td><select name="template_format">$template_format</select></td>
3192 <th align=right>| . $locale->text('Default output medium') . qq|</th>
3193 <td><select name="default_media">$default_media</select></td>
3196 <th align=right>| . $locale->text('Default printer') . qq|</th>
3197 <td><select name="default_printer_id">$default_printer</select></td>
3200 <th align=right>| . $locale->text('Number of copies') . qq|</th>
3201 <td><input name="copies" size="10" value="| .
3202 $form->quote($myconfig{"copies"}) . qq|"></td>
3206 <tr class=listheading>
3207 <th colspan=2> </th>
3210 <th align=right>| . $locale->text('Business Number') . qq|</th>
3211 <td><input name=businessnumber size=25 value="$myconfig{businessnumber}"></td>
3214 <th align=right>| . $locale->text('Year End') . qq| (mm/dd)</th>
3215 <td><input name=yearend size=5 value=$form->{defaults}{yearend}></td>
3217 <tr class=listheading>
3219 . $locale->text('Last Numbers & Default Accounts') . qq|</th>
3225 <th align=right nowrap>| . $locale->text('Inventory Account') . qq|</th>
3226 <td><select name=inventory_accno>$myconfig{IC}</select></td>
3229 <th align=right nowrap>| . $locale->text('Revenue Account') . qq|</th>
3230 <td><select name=income_accno>$myconfig{IC_income}</select></td>
3233 <th align=right nowrap>| . $locale->text('Expense Account') . qq|</th>
3234 <td><select name=expense_accno>$myconfig{IC_expense}</select></td>
3237 <th align=right nowrap>| . $locale->text('Foreign Exchange Gain') . qq|</th>
3238 <td><select name=fxgain_accno>$myconfig{FX_gain}</select></td>
3241 <th align=right nowrap>| . $locale->text('Foreign Exchange Loss') . qq|</th>
3242 <td><select name=fxloss_accno>$myconfig{FX_loss}</select></td>
3247 'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies'
3249 . qq|<br><input name=curr size=40 value="$form->{defaults}{curr}"></td>
3258 <th align=right nowrap>| . $locale->text('Last Invoice Number') . qq|</th>
3259 <td><input name=invnumber size=10 value=$form->{defaults}{invnumber}></td>
3260 <th align=right nowrap>|
3261 . $locale->text('Last Customer Number') . qq|</th>
3262 <td><input name=customernumber size=10 value=$form->{defaults}{customernumber}></td>
3265 <th align=right nowrap>|
3266 . $locale->text('Last Credit Note Number') . qq|</th>
3267 <td><input name=cnnumber size=10 value=$form->{defaults}{cnnumber}></td>
3268 <th align=right nowrap>|
3269 . $locale->text('Last Vendor Number') . qq|</th>
3270 <td><input name=vendornumber size=10 value=$form->{defaults}{vendornumber}></td>
3273 <th align=right nowrap>|
3274 . $locale->text('Last Sales Order Number') . qq|</th>
3275 <td><input name=sonumber size=10 value=$form->{defaults}{sonumber}></td>
3278 <th align=right nowrap>|
3279 . $locale->text('Last Purchase Order Number') . qq|</th>
3280 <td><input name=ponumber size=10 value=$form->{defaults}{ponumber}></td>
3281 <th align=right nowrap>|
3282 . $locale->text('Last Article Number') . qq|</th>
3283 <td><input name=articlenumber size=10 value=$form->{defaults}{articlenumber}></td>
3286 <th align=right nowrap>|
3287 . $locale->text('Last Sales Quotation Number') . qq|</th>
3288 <td><input name=sqnumber size=10 value=$form->{defaults}{sqnumber}></td>
3289 <th align=right nowrap>|
3290 . $locale->text('Last Service Number') . qq|</th>
3291 <td><input name=servicenumber size=10 value=$form->{defaults}{servicenumber}></td>
3294 <th align=right nowrap>| . $locale->text('Last RFQ Number') . qq|</th>
3295 <td><input name=rfqnumber size=10 value=$form->{defaults}{rfqnumber}></td>
3296 <th align=right nowrap></th>
3302 # <tr class=listheading>
3303 # <th colspan=2>| . $locale->text('Tax Accounts') . qq|</th>
3310 # <th>| . $locale->text('Rate') . qq| (%)</th>
3311 # <th>| . $locale->text('Number') . qq|</th>
3315 # foreach $accno (sort keys %{ $form->{taxrates} }) {
3318 # <th align=right>$form->{taxrates}{$accno}{description}</th>
3319 # <td><input name=$form->{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}></td>
3320 # <td><input name="taxnumber_$form->{taxrates}{$accno}{id}" value="$form->{taxrates}{$accno}{taxnumber}"></td>
3323 # $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} ";
3326 # chop $form->{taxaccounts};
3329 # <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
3338 <td><hr size=3 noshade></td>
3342 <input type=hidden name=path value=$form->{path}>
3343 <input type=hidden name=login value=$form->{login}>
3344 <input type=hidden name=password value=$form->{password}>
3347 <input type=submit class=submit name=action value="|
3348 . $locale->text('Save') . qq|">
3356 $lxdebug->leave_sub();
3359 sub save_preferences {
3360 $lxdebug->enter_sub();
3362 $form->{stylesheet} = $form->{usestylesheet};
3364 $form->redirect($locale->text('Preferences saved!'))
3366 AM->save_preferences(\%myconfig, \%$form, $memberfile, $userspath, $webdav
3368 $form->error($locale->text('Cannot save preferences!'));
3370 $lxdebug->leave_sub();
3374 $lxdebug->enter_sub();
3376 if ($form->{media} eq 'email') {
3377 $form->error($locale->text('No email address for') . " $myconfig{name}")
3378 unless ($myconfig{email});
3380 $form->{OUT} = "$sendmail";
3384 AM->backup(\%myconfig, \%$form, $userspath);
3386 if ($form->{media} eq 'email') {
3387 $form->redirect($locale->text('Backup sent to') . qq| $myconfig{email}|);
3390 $lxdebug->leave_sub();
3394 $lxdebug->enter_sub();
3396 $form->{title} = $locale->text('Audit Control');
3398 AM->closedto(\%myconfig, \%$form);
3400 if ($form->{revtrans}) {
3401 $checked{Y} = "checked";
3403 $checked{N} = "checked";
3411 <form method=post action=$form->{script}>
3413 <input type=hidden name=path value=$form->{path}>
3414 <input type=hidden name=login value=$form->{login}>
3415 <input type=hidden name=password value=$form->{password}>
3418 <tr><th class=listtop>$form->{title}</th></tr>
3419 <tr height="5"></tr>
3425 . $locale->text('Enforce transaction reversal for all dates') . qq|</th>
3426 <td><input name=revtrans class=radio type=radio value="1" $checked{Y}> |
3427 . $locale->text('Yes')
3428 . qq| <input name=revtrans class=radio type=radio value="0" $checked{N}> |
3429 . $locale->text('No')
3433 <th>| . $locale->text('Close Books up to') . qq|</th>
3434 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
3444 <input type=hidden name=nextsub value=doclose>
3446 <input type=submit class=submit name=action value="|
3447 . $locale->text('Continue') . qq|">
3455 $lxdebug->leave_sub();
3459 $lxdebug->enter_sub();
3461 AM->closebooks(\%myconfig, \%$form);
3463 if ($form->{revtrans}) {
3465 $locale->text('Transaction reversal enforced for all dates'));
3467 if ($form->{closedto}) {
3469 $locale->text('Transaction reversal enforced up to') . " "
3470 . $locale->date(\%myconfig, $form->{closedto}, 1));
3472 $form->redirect($locale->text('Books are open'));
3476 $lxdebug->leave_sub();
3480 $lxdebug->enter_sub();
3482 $form->{title} = "Add";
3485 "$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}"
3486 unless $form->{callback};
3491 $lxdebug->leave_sub();
3494 sub edit_warehouse {
3495 $lxdebug->enter_sub();
3497 $form->{title} = "Edit";
3499 AM->get_warehouse(\%myconfig, \%$form);
3504 $lxdebug->leave_sub();
3507 sub list_warehouse {
3508 $lxdebug->enter_sub();
3510 AM->warehouses(\%myconfig, \%$form);
3513 "$form->{script}?action=list_warehouse&path=$form->{path}&login=$form->{login}&password=$form->{password}";
3515 $callback = $form->escape($form->{callback});
3517 $form->{title} = $locale->text('Warehouses');
3519 @column_index = qw(description);
3521 $column_header{description} =
3522 qq|<th class=listheading width=100%>|
3523 . $locale->text('Description')
3533 <th class=listtop>$form->{title}</th>
3535 <tr height="5"></tr>
3539 <tr class=listheading>
3542 map { print "$column_header{$_}\n" } @column_index;
3548 foreach $ref (@{ $form->{ALL} }) {
3554 <tr valign=top class=listrow$i>
3557 $column_data{description} =
3558 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>|;
3560 map { print "$column_data{$_}\n" } @column_index;
3572 <td><hr size=3 noshade></td>
3577 <form method=post action=$form->{script}>
3579 <input name=callback type=hidden value="$form->{callback}">
3581 <input type=hidden name=type value=warehouse>
3583 <input type=hidden name=path value=$form->{path}>
3584 <input type=hidden name=login value=$form->{login}>
3585 <input type=hidden name=password value=$form->{password}>
3587 <input class=submit type=submit name=action value="|
3588 . $locale->text('Add') . qq|">
3596 $lxdebug->leave_sub();
3599 sub warehouse_header {
3600 $lxdebug->enter_sub();
3602 $form->{title} = $locale->text("$form->{title} Warehouse");
3604 # $locale->text('Add Warehouse')
3605 # $locale->text('Edit Warehouse')
3607 $form->{description} =~ s/\"/"/g;
3609 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
3611 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
3614 qq|<input name=description size=60 value="$form->{description}">|;
3622 <form method=post action=$form->{script}>
3624 <input type=hidden name=id value=$form->{id}>
3625 <input type=hidden name=type value=warehouse>
3629 <th class=listtop colspan=2>$form->{title}</th>
3631 <tr height="5"></tr>
3633 <th align=right>| . $locale->text('Description') . qq|</th>
3634 <td>$description</td>
3637 <td colspan=2><hr size=3 noshade></td>
3642 $lxdebug->leave_sub();
3645 sub save_warehouse {
3646 $lxdebug->enter_sub();
3648 $form->isblank("description", $locale->text('Description missing!'));
3649 AM->save_warehouse(\%myconfig, \%$form);
3650 $form->redirect($locale->text('Warehouse saved!'));
3652 $lxdebug->leave_sub();
3655 sub delete_warehouse {
3656 $lxdebug->enter_sub();
3658 AM->delete_warehouse(\%myconfig, \%$form);
3659 $form->redirect($locale->text('Warehouse deleted!'));
3661 $lxdebug->leave_sub();
3665 $lxdebug->enter_sub();
3667 &{ $form->{nextsub} };
3669 $lxdebug->leave_sub();
3673 $lxdebug->enter_sub();
3675 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
3676 AM->units_in_use(\%myconfig, $form, $units);
3677 map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
3679 @languages = AM->language(\%myconfig, $form, 1);
3682 foreach $name (sort({ lc($a) cmp lc($b) } grep({ !$units->{$_}->{"base_unit"} } keys(%{$units})))) {
3683 map({ push(@unit_list, $units->{$_}); }
3684 sort({ ($units->{$a}->{"resolved_factor"} * 1) <=> ($units->{$b}->{"resolved_factor"} * 1) }
3685 grep({ $units->{$_}->{"resolved_base_unit"} eq $name } keys(%{$units}))));
3688 foreach (@unit_list) {
3689 $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"}, 5) if ($_->{"factor"});
3690 $_->{"UNITLANGUAGES"} = [];
3691 foreach my $lang (@languages) {
3692 push(@{ $_->{"UNITLANGUAGES"} },
3694 "unit" => $_->{"name"},
3695 "language_id" => $lang->{"id"},
3696 "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
3697 "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
3703 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
3704 $ddbox = AM->unit_select_data($units, undef, 1);
3706 $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
3708 print($form->parse_html_template("am/edit_units",
3709 { "UNITS" => \@unit_list,
3710 "NEW_BASE_UNIT_DDBOX" => $ddbox,
3711 "LANGUAGES" => \@languages }));
3713 $lxdebug->leave_sub();
3717 $lxdebug->enter_sub();
3719 $form->isblank("new_name", $locale->text("The name is missing."));
3720 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
3721 $all_units = AM->retrieve_units(\%myconfig, $form);
3722 $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
3724 my ($base_unit, $factor);
3725 if ($form->{"new_base_unit"}) {
3726 $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
3728 $form->isblank("new_factor", $locale->text("The factor is missing."));
3729 $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
3730 $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
3731 $base_unit = $form->{"new_base_unit"};
3735 foreach my $lang (AM->language(\%myconfig, $form, 1)) {
3736 next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
3737 push(@languages, { "id" => $lang->{"id"},
3738 "localized" => $form->{"new_localized_$lang->{id}"},
3739 "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
3743 AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
3745 $form->{"saved_message"} = $locale->text("The unit has been saved.");
3749 $lxdebug->leave_sub();
3752 sub set_unit_languages {
3753 $lxdebug->enter_sub();
3755 my ($unit, $languages, $idx) = @_;
3757 $unit->{"LANGUAGES"} = [];
3759 foreach my $lang (@{$languages}) {
3760 push(@{ $unit->{"LANGUAGES"} },
3761 { "id" => $lang->{"id"},
3762 "localized" => $form->{"localized_${idx}_$lang->{id}"},
3763 "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
3767 $lxdebug->leave_sub();
3771 $lxdebug->enter_sub();
3773 $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
3774 AM->units_in_use(\%myconfig, $form, $old_units);
3776 @languages = AM->language(\%myconfig, $form, 1);
3780 foreach $i (1..($form->{"rowcount"} * 1)) {
3781 $old_unit = $old_units->{$form->{"old_name_$i"}};
3783 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
3786 if ($form->{"unchangeable_$i"}) {
3787 $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
3788 $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
3789 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
3793 if ($old_unit->{"in_use"}) {
3794 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
3797 if ($form->{"delete_$i"}) {
3798 push(@delete_units, $old_unit->{"name"});
3802 $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
3804 $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
3805 my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
3806 $new_units->{$form->{"name_$i"}} = \%h;
3807 $new_units->{$form->{"name_$i"}}->{"row"} = $i;
3808 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
3811 foreach $unit (values(%{$new_units})) {
3812 next unless ($unit->{"old_name"});
3813 if ($unit->{"base_unit"}) {
3814 $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"}))
3815 unless (defined($new_units->{$unit->{"base_unit"}}));
3816 $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
3817 $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
3819 $unit->{"base_unit"} = undef;
3820 $unit->{"factor"} = undef;
3824 foreach $unit (values(%{$new_units})) {
3825 next if ($unit->{"unchanged_unit"});
3827 map({ $_->{"seen"} = 0; } values(%{$new_units}));
3829 while ($new_unit->{"base_unit"}) {
3830 $new_unit->{"seen"} = 1;
3831 $new_unit = $new_units->{$new_unit->{"base_unit"}};
3832 if ($new_unit->{"seen"}) {
3833 $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, " .
3834 "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
3839 AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
3841 $form->{"saved_message"} = $locale->text("The units have been saved.");
3845 $lxdebug->leave_sub();