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 #======================================================================
37 use SL::Auth::PasswordPolicy;
51 require "bin/mozilla/common.pl";
59 sub add { call_sub("add_$main::form->{type}"); }
60 sub delete { call_sub("delete_$main::form->{type}"); }
61 sub save { call_sub("save_$main::form->{type}"); }
62 sub edit { call_sub("edit_$main::form->{type}"); }
63 sub continue { call_sub($main::form->{"nextsub"}); }
64 sub save_as_new { call_sub("save_as_new_$main::form->{type}"); }
67 $main::lxdebug->enter_sub();
69 my $form = $main::form;
70 my %myconfig = %main::myconfig;
72 $main::auth->assert('config');
74 $form->{title} = "Add";
75 $form->{charttype} = "A";
76 AM->get_account(\%myconfig, \%$form);
78 $form->{callback} = "am.pl?action=list_account" unless $form->{callback};
83 $main::lxdebug->leave_sub();
87 $main::lxdebug->enter_sub();
89 my $form = $main::form;
90 my %myconfig = %main::myconfig;
92 $main::auth->assert('config');
94 $form->{title} = "Edit";
95 AM->get_account(\%myconfig, \%$form);
97 foreach my $item (split(/:/, $form->{link})) {
98 $form->{$item} = "checked";
104 $main::lxdebug->leave_sub();
108 $main::lxdebug->enter_sub();
110 my $form = $main::form;
111 my %myconfig = %main::myconfig;
112 my $locale = $main::locale;
114 $main::auth->assert('config');
116 if ( $form->{action} eq 'edit_account') {
117 $form->{account_exists} = '1';
120 $form->{title} = $locale->text("$form->{title} Account");
122 $form->{"$form->{charttype}_checked"} = "checked";
123 $form->{"$form->{category}_checked"} = "checked";
125 $form->{select_tax} = "";
127 my @tax_report_pos = USTVA->report_variables({
128 myconfig => \%myconfig,
131 attribute => 'position',
135 if (@{ $form->{TAXKEY} }) {
136 foreach my $item (@{ $form->{TAXKEY} }) {
137 $item->{rate} = $item->{rate} * 100 . '%';
140 # Fill in empty row for new Taxkey
141 my $newtaxkey_ref = {
146 taxdescription => '',
153 push @{ $form->{ACCOUNT_TAXKEYS} }, $newtaxkey_ref;
156 foreach my $taxkey_used (@{ $form->{ACCOUNT_TAXKEYS} } ) {
158 # Fill in a runningnumber
159 $form->{ACCOUNT_TAXKEYS}[$i]{runningnumber} = $i;
161 # Fill in the Taxkeys as select options
162 foreach my $item (@{ $form->{TAXKEY} }) {
163 if ($item->{id} == $taxkey_used->{tax_id}) {
164 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
165 qq|<option value="$item->{id}" selected="selected">|
166 . sprintf("%.2d", $item->{taxkey})
167 . qq|. $item->{taxdescription} ($item->{rate}) |
168 . $locale->text('Tax-o-matic Account')
169 . qq|: $item->{chart_accno}\n|;
172 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
173 qq|<option value="$item->{id}">|
174 . sprintf("%.2d", $item->{taxkey})
175 . qq|. $item->{taxdescription} ($item->{rate}) |
176 . $locale->text('Tax-o-matic Account')
177 . qq|: $item->{chart_accno}\n|;
182 # Fill in the USTVA Numbers as select options
183 foreach my $item ( '', sort({ $a cmp $b } @tax_report_pos) ) {
185 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="" selected="selected">-\n|;
187 elsif ( $item eq $taxkey_used->{pos_ustva} ) {
188 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item" selected="selected">$item\n|;
191 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item">$item\n|;
200 # Newaccount Folgekonto
201 if (@{ $form->{NEWACCOUNT} || [] }) {
202 if (!$form->{new_chart_valid}) {
203 $form->{selectnewaccount} = qq|<option value=""> |. $locale->text('None') .q|</option>|;
205 foreach my $item (@{ $form->{NEWACCOUNT} }) {
206 if ($item->{id} == $form->{new_chart_id}) {
207 $form->{selectnewaccount} .=
208 qq|<option value="$item->{id}" selected>$item->{accno}--$item->{description}</option>|;
209 } elsif (!$form->{new_chart_valid}) {
210 $form->{selectnewaccount} .=
211 qq|<option value="$item->{id}">$item->{accno}--$item->{description}</option>|;
217 my $select_eur = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
220 2 => "sonstige Erlöse",
221 3 => "Privatanteile",
223 5 => "Ausserordentliche Erträge",
224 6 => "Vereinnahmte Umsatzst.",
225 7 => "Umsatzsteuererstattungen",
226 8 => "Wareneingänge",
227 9 => "Löhne und Gehälter",
228 10 => "Gesetzl. sozialer Aufw.",
230 12 => "Gas, Strom, Wasser",
231 13 => "Instandhaltung",
232 14 => "Steuern, Versich., Beiträge",
234 16 => "Kfz-Versicherungen",
235 17 => "Sonst. Fahrzeugkosten",
236 18 => "Werbe- und Reisekosten",
237 19 => "Instandhaltung u. Werkzeuge",
238 20 => "Fachzeitschriften, Bücher",
239 21 => "Miete für Einrichtungen",
240 22 => "Rechts- und Beratungskosten",
241 23 => "Bürobedarf, Porto, Telefon",
242 24 => "Sonstige Aufwendungen",
243 25 => "Abschreibungen auf Anlagever.",
244 26 => "Abschreibungen auf GWG",
246 28 => "Umsatzsteuerzahlungen",
248 30 => "Ausserordentlicher Aufwand",
249 31 => "Betriebliche Steuern");
250 foreach my $item (sort({ $a <=> $b } keys(%eur))) {
251 my $text = H($::locale->{iconv_utf8}->convert($eur{$item}));
252 if ($item == $form->{pos_eur}) {
253 $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
255 $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
260 my $select_bwa = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
264 2 => 'Best.Verdg.FE/UE',
265 3 => 'Aktiv.Eigenleistung',
266 4 => 'Mat./Wareneinkauf',
267 5 => 'So.betr.Erlöse',
268 10 => 'Personalkosten',
270 12 => 'Betriebl.Steuern',
271 13 => 'Vers./Beiträge',
272 14 => 'Kfz.Kosten o.St.',
273 15 => 'Werbe-Reisek.',
274 16 => 'Kosten Warenabgabe',
275 17 => 'Abschreibungen',
276 18 => 'Rep./instandhlt.',
277 19 => 'Übrige Steuern',
278 20 => 'Sonst.Kosten',
280 31 => 'Sonst.neutr.Aufw.',
282 33 => 'Sonst.neutr.Ertrag',
283 34 => 'Verr.kalk.Kosten',
284 35 => 'Steuern Eink.u.Ertr.');
285 foreach my $item (sort({ $a <=> $b } keys %bwapos)) {
286 my $text = H($::locale->{iconv_utf8}->convert($bwapos{$item}));
287 if ($item == $form->{pos_bwa}) {
288 $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $text\n|;
290 $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $text\n|;
295 # Wieder hinzugefügt zu evaluationszwecken (us) 09.03.2007
296 my $select_bilanz = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
297 foreach my $item ((1, 2, 3, 4)) {
298 if ($item == $form->{pos_bilanz}) {
299 $select_bilanz .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|.\n|;
301 $select_bilanz .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|.\n|;
306 # this is for our parser only! Do not remove.
307 # type=submit $locale->text('Add Account')
308 # type=submit $locale->text('Edit Account')
310 $form->{type} = "account";
312 # preselections category
314 my $select_category = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
317 'A' => $locale->text('Asset'),
318 'L' => $locale->text('Liability'),
319 'Q' => $locale->text('Equity'),
320 'I' => $locale->text('Revenue'),
321 'E' => $locale->text('Expense'),
322 'C' => $locale->text('Costs'),
324 foreach my $item ( sort({ $a <=> $b } keys %category) ) {
325 if ($item eq $form->{category}) {
326 $select_category .= qq|<option value="$item" selected="selected">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
328 $select_category .= qq|<option value="$item">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
333 # preselection chart type
334 my $select_charttype = q{};
337 'A' => $locale->text('Account'),
338 'H' => $locale->text('Heading'),
341 foreach my $item ( sort({ $a <=> $b } keys %charttype) ) {
342 if ($item eq $form->{charttype}) {
343 $select_charttype .= qq|<option value="$item" selected="selected">$charttype{$item}\n|;
346 $select_charttype .= qq|<option value="$item">$charttype{$item}\n|;
351 my $ChartTypeIsAccount = ($form->{charttype} eq "A") ? "1":"";
355 my $parameters_ref = {
356 ChartTypeIsAccount => $ChartTypeIsAccount,
357 select_category => $select_category,
358 select_charttype => $select_charttype,
359 select_bwa => $select_bwa,
360 select_bilanz => $select_bilanz,
361 select_eur => $select_eur,
364 # Ausgabe des Templates
365 print($form->parse_html_template('am/edit_accounts', $parameters_ref));
368 $main::lxdebug->leave_sub();
372 $main::lxdebug->enter_sub();
374 my $form = $main::form;
375 my $locale = $main::locale;
377 $main::auth->assert('config');
381 <input name=callback type=hidden value="| . H($form->{callback}) . qq|">
384 if ((!$form->{id}) || ($form->{id} && $form->{orphaned}) || (($form->{type} eq "account") && (!$form->{new_chart_valid}))) {
386 <input type=submit class=submit name=action value="|
387 . $locale->text('Save') . qq|">
391 if ($form->{id} && $form->{orphaned}) {
392 print qq|<input type=submit class=submit name=action value="|
393 . $locale->text('Delete') . qq|">|;
396 if ($form->{id} && $form->{type} eq "account") {
398 <input class=submit type=submit name=action value="|
399 . $locale->text('Save as new') . qq|">|;
409 $main::lxdebug->leave_sub();
413 $main::lxdebug->enter_sub();
415 my $form = $main::form;
416 my %myconfig = %main::myconfig;
417 my $locale = $main::locale;
419 $main::auth->assert('config');
421 $form->isblank("accno", $locale->text('Account Number missing!'));
422 $form->isblank("description", $locale->text('Account Description missing!'));
424 if ($form->{charttype} eq 'A'){
425 $form->isblank("category", $locale->text('Account Type missing!'));
428 $form->redirect($locale->text('Account saved!'))
429 if (AM->save_account(\%myconfig, \%$form));
430 $form->error($locale->text('Cannot save account!'));
432 $main::lxdebug->leave_sub();
435 sub save_as_new_account {
436 $main::lxdebug->enter_sub();
438 my $form = $main::form;
439 my %myconfig = %main::myconfig;
440 my $locale = $main::locale;
442 $main::auth->assert('config');
444 $form->isblank("accno", $locale->text('Account Number missing!'));
445 $form->isblank("description", $locale->text('Account Description missing!'));
447 if ($form->{charttype} eq 'A'){
448 $form->isblank("category", $locale->text('Account Type missing!'));
451 for my $taxkey (0 .. 9) {
452 if ($form->{"taxkey_id_$taxkey"}) {
453 $form->{"taxkey_id_$taxkey"} = "NEW";
458 if ($form->{"original_accno"} &&
459 ($form->{"accno"} eq $form->{"original_accno"})) {
460 $form->error($locale->text('Account Number already used!'));
462 $form->redirect($locale->text('Account saved!'))
463 if (AM->save_account(\%myconfig, \%$form));
464 $form->error($locale->text('Cannot save account!'));
466 $main::lxdebug->leave_sub();
470 $main::lxdebug->enter_sub();
472 my $form = $main::form;
473 my %myconfig = %main::myconfig;
474 my $locale = $main::locale;
476 $main::auth->assert('config');
478 $form->{callback} = build_std_url('action=list_account');
479 my $link_edit_account = build_std_url('action=edit_account', 'callback');
481 CA->all_accounts(\%myconfig, \%$form);
483 foreach my $ca (@{ $form->{CA} }) {
488 if ($ca->{amount} > 0) {
489 $ca->{credit} = $form->format_amount(\%myconfig, $ca->{amount}, 2);
491 if ($ca->{amount} < 0) {
492 $ca->{debit} = $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2);
494 $ca->{heading} = ( $ca->{charttype} eq 'H' ) ? 1:'';
495 $ca->{link_edit_account} = $link_edit_account . '&id=' . E($ca->{id});
499 my $pjx = new CGI::Ajax('list_account_details' => build_std_url('action=list_account_details'));
501 # Eneable AJAX debuging
505 push(@ { $form->{AJAX} }, $pjx);
507 $form->use_stylesheet("list_accounts.css");
508 $form->{title} = $locale->text('Chart of Accounts');
513 my $parameters_ref = {
514 # hidden_variables => $_hidden_variables_ref,
517 # Ausgabe des Templates
518 print($form->parse_html_template('am/list_accounts', $parameters_ref));
520 $main::lxdebug->leave_sub();
525 sub list_account_details {
526 # Ajax Funktion aus list_account_details
527 $main::lxdebug->enter_sub();
529 my $form = $main::form;
530 my %myconfig = %main::myconfig;
531 my $locale = $main::locale;
533 $main::auth->assert('config');
535 my $chart_id = $form->{args};
537 CA->all_accounts(\%myconfig, \%$form, $chart_id);
539 foreach my $ca (@{ $form->{CA} }) {
541 $ca->{debit} = " ";
542 $ca->{credit} = " ";
544 if ($ca->{amount} > 0) {
546 $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
548 if ($ca->{amount} < 0) {
550 $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2, " ");
553 my @links = split( q{:}, $ca->{link});
557 foreach my $link (@links){
558 $link = ( $link eq 'AR') ? $locale->text('Account Link AR')
559 : ( $link eq 'AP') ? $locale->text('Account Link AP')
560 : ( $link eq 'IC') ? $locale->text('Account Link IC')
561 : ( $link eq 'AR_amount' ) ? $locale->text('Account Link AR_amount')
562 : ( $link eq 'AR_paid' ) ? $locale->text('Account Link AR_paid')
563 : ( $link eq 'AR_tax' ) ? $locale->text('Account Link AR_tax')
564 : ( $link eq 'AP_amount' ) ? $locale->text('Account Link AP_amount')
565 : ( $link eq 'AP_paid' ) ? $locale->text('Account Link AP_paid')
566 : ( $link eq 'AP_tax' ) ? $locale->text('Account Link AP_tax')
567 : ( $link eq 'IC_sale' ) ? $locale->text('Account Link IC_sale')
568 : ( $link eq 'IC_cogs' ) ? $locale->text('Account Link IC_cogs')
569 : ( $link eq 'IC_taxpart' ) ? $locale->text('Account Link IC_taxpart')
570 : ( $link eq 'IC_income' ) ? $locale->text('Account Link IC_income')
571 : ( $link eq 'IC_expense' ) ? $locale->text('Account Link IC_expense')
572 : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice')
573 # : ( $link eq 'CT_tax' ) ? $locale->text('Account Link CT_tax')
574 : $locale->text('Unknown Link') . ': ' . $link;
575 $ca->{link} .= ($link ne '') ? "[$link] ":'';
578 $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
579 : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
580 : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
581 : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
582 : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
583 : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
584 : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
585 : $locale->text('Unknown Category') . ': ' . $ca->{category};
588 $form->{title} = $locale->text('Chart of Accounts');
591 print $form->parse_html_template('am/list_account_details');
593 $main::lxdebug->leave_sub();
598 $main::lxdebug->enter_sub();
600 my $form = $main::form;
601 my %myconfig = %main::myconfig;
602 my $locale = $main::locale;
604 $main::auth->assert('config');
606 $form->{title} = $locale->text('Delete Account');
609 qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
611 if ($form->{id} == $form->{$id}) {
612 $form->error($locale->text('Cannot delete default account!'));
616 $form->redirect($locale->text('Account deleted!'))
617 if (AM->delete_account(\%myconfig, \%$form));
618 $form->error($locale->text('Cannot delete account!'));
620 $main::lxdebug->leave_sub();
624 $main::lxdebug->enter_sub();
626 my $form = $main::form;
628 $main::auth->assert('config');
630 $form->{title} = "Add";
633 $form->{callback} = "am.pl?action=add_department" unless $form->{callback};
638 $main::lxdebug->leave_sub();
641 sub edit_department {
642 $main::lxdebug->enter_sub();
644 my $form = $main::form;
645 my %myconfig = %main::myconfig;
647 $main::auth->assert('config');
649 $form->{title} = "Edit";
651 AM->get_department(\%myconfig, \%$form);
656 $main::lxdebug->leave_sub();
659 sub list_department {
660 $main::lxdebug->enter_sub();
662 my $form = $main::form;
663 my %myconfig = %main::myconfig;
664 my $locale = $main::locale;
666 $main::auth->assert('config');
668 AM->departments(\%myconfig, \%$form);
670 $form->{callback} = "am.pl?action=list_department";
672 my $callback = $form->escape($form->{callback});
674 $form->{title} = $locale->text('Departments');
676 my @column_index = qw(description cost profit);
678 $column_header{description} =
679 qq|<th class=listheading width=90%>|
680 . $locale->text('Description')
682 $column_header{cost} =
683 qq|<th class=listheading nowrap>|
684 . $locale->text('Cost Center')
686 $column_header{profit} =
687 qq|<th class=listheading nowrap>|
688 . $locale->text('Profit Center')
698 <th class=listtop>$form->{title}</th>
704 <tr class=listheading>
707 map { print "$column_header{$_}\n" } @column_index;
713 my ($i, %column_data);
714 foreach my $ref (@{ $form->{ALL} }) {
720 <tr valign=top class=listrow$i>
723 my $costcenter = ($ref->{role} eq "C") ? "X" : "";
724 my $profitcenter = ($ref->{role} eq "P") ? "X" : "";
726 $column_data{description} =
727 qq|<td><a href="am.pl?action=edit_department&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
728 $column_data{cost} = qq|<td align=center>$costcenter</td>|;
729 $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
731 map { print "$column_data{$_}\n" } @column_index;
743 <td><hr size=3 noshade></td>
748 <form method=post action=am.pl>
750 <input name=callback type=hidden value="$form->{callback}">
752 <input type=hidden name=type value=department>
754 <input class=submit type=submit name=action value="|
755 . $locale->text('Add') . qq|">
763 $main::lxdebug->leave_sub();
766 sub department_header {
767 $main::lxdebug->enter_sub();
769 my $form = $main::form;
770 my $locale = $main::locale;
772 $main::auth->assert('config');
774 $form->{title} = $locale->text("$form->{title} Department");
776 # $locale->text('Add Department')
777 # $locale->text('Edit Department')
779 $form->{description} =~ s/\"/"/g;
781 my ($rows, $description);
782 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
784 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
787 qq|<input name=description size=60 value="$form->{description}">|;
790 my $costcenter = "checked" if $form->{role} eq "C";
791 my $profitcenter = "checked" if $form->{role} eq "P";
798 <form method=post action=am.pl>
800 <input type=hidden name=id value=$form->{id}>
801 <input type=hidden name=type value=department>
805 <th class=listtop colspan=2>$form->{title}</th>
809 <th align=right>| . $locale->text('Description') . qq|</th>
810 <td>$description</td>
814 <td><input type=radio style=radio name=role value="C" $costcenter> |
815 . $locale->text('Cost Center') . qq|
816 <input type=radio style=radio name=role value="P" $profitcenter> |
817 . $locale->text('Profit Center') . qq|
820 <td colspan=2><hr size=3 noshade></td>
825 $main::lxdebug->leave_sub();
828 sub save_department {
829 $main::lxdebug->enter_sub();
831 my $form = $main::form;
832 my %myconfig = %main::myconfig;
833 my $locale = $main::locale;
835 $main::auth->assert('config');
837 $form->isblank("description", $locale->text('Description missing!'));
838 AM->save_department(\%myconfig, \%$form);
839 $form->redirect($locale->text('Department saved!'));
841 $main::lxdebug->leave_sub();
844 sub delete_department {
845 $main::lxdebug->enter_sub();
847 my $form = $main::form;
848 my %myconfig = %main::myconfig;
849 my $locale = $main::locale;
851 $main::auth->assert('config');
853 AM->delete_department(\%myconfig, \%$form);
854 $form->redirect($locale->text('Department deleted!'));
856 $main::lxdebug->leave_sub();
860 $main::lxdebug->enter_sub();
862 my $form = $main::form;
864 $main::auth->assert('config');
866 $form->{title} = "Add";
868 $form->{callback} = "am.pl?action=add_lead" unless $form->{callback};
873 $main::lxdebug->leave_sub();
877 $main::lxdebug->enter_sub();
879 my $form = $main::form;
880 my %myconfig = %main::myconfig;
882 $main::auth->assert('config');
884 $form->{title} = "Edit";
886 AM->get_lead(\%myconfig, \%$form);
890 $form->{orphaned} = 1;
893 $main::lxdebug->leave_sub();
897 $main::lxdebug->enter_sub();
899 my $form = $main::form;
900 my %myconfig = %main::myconfig;
901 my $locale = $main::locale;
903 $main::auth->assert('config');
905 AM->lead(\%myconfig, \%$form);
907 $form->{callback} = "am.pl?action=list_lead";
909 my $callback = $form->escape($form->{callback});
911 $form->{title} = $locale->text('Lead');
913 my @column_index = qw(description cost profit);
915 $column_header{description} =
916 qq|<th class=listheading width=100%>|
917 . $locale->text('Description')
927 <th class=listtop>$form->{title}</th>
930 <tr class=listheading>
933 map { print "$column_header{$_}\n" } @column_index;
939 my ($i, %column_data);
940 foreach my $ref (@{ $form->{ALL} }) {
946 <tr valign=top class=listrow$i>
949 # $lead = $ref->{lead};
951 $column_data{description} = qq|<td><a href="am.pl?action=edit_lead&id=$ref->{id}&callback=$callback">$ref->{lead}</td>|;
953 map { print "$column_data{$_}\n" } @column_index;
962 <td><hr size=3 noshade></td>
967 <form method=post action=am.pl>
969 <input name=callback type=hidden value="$form->{callback}">
971 <input type=hidden name=type value=lead>
973 <input class=submit type=submit name=action value="|
974 . $locale->text('Add') . qq|">
982 $main::lxdebug->leave_sub();
986 $main::lxdebug->enter_sub();
988 my $form = $main::form;
989 my $locale = $main::locale;
991 $main::auth->assert('config');
993 $form->{title} = $locale->text("$form->{title} Lead");
995 # $locale->text('Add Lead')
996 # $locale->text('Edit Lead')
998 $form->{description} =~ s/\"/"/g;
1001 qq|<input name=description size=50 value="$form->{lead}">|;
1008 <form method=post action=am.pl>
1010 <input type=hidden name=id value=$form->{id}>
1011 <input type=hidden name=type value=lead>
1015 <th class=listtop colspan=2>$form->{title}</th>
1017 <tr height="5"></tr>
1019 <th align=right>| . $locale->text('Description') . qq|</th>
1020 <td>$description</td>
1022 <td colspan=2><hr size=3 noshade></td>
1027 $main::lxdebug->leave_sub();
1031 $main::lxdebug->enter_sub();
1033 my $form = $main::form;
1034 my %myconfig = %main::myconfig;
1035 my $locale = $main::locale;
1037 $main::auth->assert('config');
1039 $form->isblank("description", $locale->text('Description missing!'));
1040 AM->save_lead(\%myconfig, \%$form);
1041 $form->redirect($locale->text('lead saved!'));
1043 $main::lxdebug->leave_sub();
1047 $main::lxdebug->enter_sub();
1049 my $form = $main::form;
1050 my %myconfig = %main::myconfig;
1051 my $locale = $main::locale;
1053 $main::auth->assert('config');
1055 AM->delete_lead(\%myconfig, \%$form);
1056 $form->redirect($locale->text('lead deleted!'));
1058 $main::lxdebug->leave_sub();
1062 $main::lxdebug->enter_sub();
1064 my $form = $main::form;
1066 $main::auth->assert('config');
1068 $form->{title} = "Add";
1070 $form->{callback} = "am.pl?action=add_business" unless $form->{callback};
1075 $main::lxdebug->leave_sub();
1079 $main::lxdebug->enter_sub();
1081 my $form = $main::form;
1082 my %myconfig = %main::myconfig;
1084 $form->{title} = "Edit";
1086 AM->get_business(\%myconfig, \%$form);
1090 $form->{orphaned} = 1;
1093 $main::lxdebug->leave_sub();
1097 $main::lxdebug->enter_sub();
1099 my $form = $main::form;
1100 my %myconfig = %main::myconfig;
1101 my $locale = $main::locale;
1103 $main::auth->assert('config');
1105 AM->business(\%myconfig, \%$form);
1107 $form->{callback} = "am.pl?action=list_business";
1109 my $callback = $form->escape($form->{callback});
1111 $form->{title} = $locale->text('Type of Business');
1113 my @column_index = qw(description discount customernumberinit);
1114 push @column_index, 'salesman' if $::lx_office_conf{features}->{vertreter};
1116 $column_header{description} =
1117 qq|<th class=listheading width=60%>|
1118 . $locale->text('Description')
1120 $column_header{discount} =
1121 qq|<th class=listheading width=10%>|
1122 . $locale->text('Discount')
1124 $column_header{customernumberinit} =
1125 qq|<th class=listheading>|
1126 . $locale->text('Customernumberinit')
1128 $column_header{salesman} =
1129 qq|<th class=listheading>|
1130 . $locale->text('Representative')
1140 <th class=listtop>$form->{title}</th>
1142 <tr height="5"></tr>
1146 <tr class=listheading>
1149 map { print "$column_header{$_}\n" } @column_index;
1155 my ($i, %column_data);
1156 foreach my $ref (@{ $form->{ALL} }) {
1162 <tr valign=top class=listrow$i>
1165 my $discount = $form->format_amount(\%myconfig, $ref->{discount} * 100);
1166 my $description = $ref->{description};
1167 $column_data{description} = qq|<td><a href="am.pl?action=edit_business&id=$ref->{id}&callback=$callback">$description</td>|;
1168 $column_data{discount} = qq|<td align=right>$discount</td>|;
1169 $column_data{customernumberinit} =
1170 qq|<td align=right>$ref->{customernumberinit}</td>|;
1171 $column_data{salesman} = '<td>' . ($ref->{salesman} ? $::locale->text('Yes') : $::locale->text('No')) . '</td>';
1173 map { print "$column_data{$_}\n" } @column_index;
1185 <td><hr size=3 noshade></td>
1190 <form method=post action=am.pl>
1192 <input name=callback type=hidden value="$form->{callback}">
1194 <input type=hidden name=type value=business>
1196 <input class=submit type=submit name=action value="|
1197 . $locale->text('Add') . qq|">
1205 $main::lxdebug->leave_sub();
1208 sub business_header {
1209 $main::lxdebug->enter_sub();
1211 my $form = $main::form;
1212 my %myconfig = %main::myconfig;
1213 my $locale = $main::locale;
1215 $main::auth->assert('config');
1217 $form->{title} = $locale->text("$form->{title} Business");
1219 # $locale->text('Add Business')
1220 # $locale->text('Edit Business')
1222 $form->{description} =~ s/\"/"/g;
1224 $form->format_amount(\%myconfig, $form->{discount} * 100);
1227 if ($::lx_office_conf{features}->{vertreter}) {
1228 $salesman_code = qq|
1230 <th align="right">| . $locale->text('Representative') . qq|</th>
1231 <td>| . $::cgi->checkbox(-name => "salesman", -value => 1, -label => '', 'checked' => $form->{salesman} ? 1 : 0) . qq|</td>
1235 $salesman_code = $::cgi->hidden(-name => 'salesman', -value => $form->{salesman} ? 1 : 0);
1243 <form method=post action=am.pl>
1245 <input type=hidden name=id value=$form->{id}>
1246 <input type=hidden name=type value=business>
1250 <th class=listtop colspan=2>$form->{title}</th>
1252 <tr height="5"></tr>
1254 <th align=right>| . $locale->text('Type of Business') . qq|</th>
1255 <td><input name=description size=30 value="$form->{description}"></td>
1258 <th align=right>| . $locale->text('Discount') . qq| %</th>
1259 <td><input name=discount size=5 value=$form->{discount}></td>
1262 <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
1263 <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
1266 <td colspan=2><hr size=3 noshade></td>
1271 $main::lxdebug->leave_sub();
1275 $main::lxdebug->enter_sub();
1277 my $form = $main::form;
1278 my %myconfig = %main::myconfig;
1279 my $locale = $main::locale;
1281 $main::auth->assert('config');
1283 $form->isblank("description", $locale->text('Description missing!'));
1284 $form->{discount} = $form->parse_amount(\%myconfig, $form->{discount}) / 100;
1285 AM->save_business(\%myconfig, \%$form);
1286 $form->redirect($locale->text('Business saved!'));
1288 $main::lxdebug->leave_sub();
1291 sub delete_business {
1292 $main::lxdebug->enter_sub();
1294 my $form = $main::form;
1295 my %myconfig = %main::myconfig;
1296 my $locale = $main::locale;
1298 $main::auth->assert('config');
1300 AM->delete_business(\%myconfig, \%$form);
1301 $form->redirect($locale->text('Business deleted!'));
1303 $main::lxdebug->leave_sub();
1307 $main::lxdebug->enter_sub();
1309 my $form = $main::form;
1311 $main::auth->assert('config');
1313 $form->{title} = "Add";
1315 $form->{callback} = "am.pl?action=add_language" unless $form->{callback};
1320 $main::lxdebug->leave_sub();
1324 $main::lxdebug->enter_sub();
1326 my $form = $main::form;
1327 my %myconfig = %main::myconfig;
1329 $main::auth->assert('config');
1331 $form->{title} = "Edit";
1333 AM->get_language(\%myconfig, \%$form);
1337 $form->{orphaned} = 1;
1340 $main::lxdebug->leave_sub();
1344 $main::lxdebug->enter_sub();
1346 my $form = $main::form;
1347 my %myconfig = %main::myconfig;
1348 my $locale = $main::locale;
1350 $main::auth->assert('config');
1352 AM->language(\%myconfig, \%$form);
1354 $form->{callback} = "am.pl?action=list_language";
1356 my $callback = $form->escape($form->{callback});
1358 $form->{title} = $locale->text('Languages');
1360 my @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
1362 $column_header{description} =
1363 qq|<th class=listheading width=60%>|
1364 . $locale->text('Description')
1366 $column_header{template_code} =
1367 qq|<th class=listheading width=10%>|
1368 . $locale->text('Template Code')
1370 $column_header{article_code} =
1371 qq|<th class=listheading>|
1372 . $locale->text('Article Code')
1374 $column_header{output_numberformat} =
1375 qq|<th class=listheading>|
1376 . $locale->text('Number Format')
1378 $column_header{output_dateformat} =
1379 qq|<th class=listheading>|
1380 . $locale->text('Date Format')
1382 $column_header{output_longdates} =
1383 qq|<th class=listheading>|
1384 . $locale->text('Long Dates')
1394 <th class=listtop>$form->{title}</th>
1396 <tr height="5"></tr>
1400 <tr class=listheading>
1403 map { print "$column_header{$_}\n" } @column_index;
1409 my ($i, %column_data);
1410 foreach my $ref (@{ $form->{ALL} }) {
1416 <tr valign=top class=listrow$i>
1420 $column_data{description} =
1421 qq|<td><a href="am.pl?action=edit_language&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
1422 $column_data{template_code} = qq|<td align=right>$ref->{template_code}</td>|;
1423 $column_data{article_code} =
1424 qq|<td align=right>$ref->{article_code}</td>|;
1425 $column_data{output_numberformat} =
1427 ($ref->{output_numberformat} ? $ref->{output_numberformat} :
1428 $locale->text("use program settings")) .
1430 $column_data{output_dateformat} =
1432 ($ref->{output_dateformat} ? $ref->{output_dateformat} :
1433 $locale->text("use program settings")) .
1435 $column_data{output_longdates} =
1437 ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
1440 map { print "$column_data{$_}\n" } @column_index;
1452 <td><hr size=3 noshade></td>
1457 <form method=post action=am.pl>
1459 <input name=callback type=hidden value="$form->{callback}">
1461 <input type=hidden name=type value=language>
1463 <input class=submit type=submit name=action value="|
1464 . $locale->text('Add') . qq|">
1472 $main::lxdebug->leave_sub();
1475 sub language_header {
1476 $main::lxdebug->enter_sub();
1478 my $form = $main::form;
1479 my $locale = $main::locale;
1481 $main::auth->assert('config');
1483 $form->{title} = $locale->text("$form->{title} Language");
1485 # $locale->text('Add Language')
1486 # $locale->text('Edit Language')
1488 $form->{description} =~ s/\"/"/g;
1489 $form->{template_code} =~ s/\"/"/g;
1490 $form->{article_code} =~ s/\"/"/g;
1496 qq|<option value="">| . $locale->text("use program settings") .
1498 foreach my $item (('1,000.00', '1000.00', '1.000,00', '1000,00')) {
1500 ($item eq $form->{output_numberformat})
1501 ? "<option selected>$item"
1507 qq|<option value="">| . $locale->text("use program settings") .
1509 foreach my $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
1511 ($item eq $form->{output_dateformat})
1512 ? "<option selected>$item"
1520 <form method=post action=am.pl>
1522 <input type=hidden name=id value=$form->{id}>
1523 <input type=hidden name=type value=language>
1527 <th class=listtop colspan=2>$form->{title}</th>
1529 <tr height="5"></tr>
1531 <th align=right>| . $locale->text('Language') . qq|</th>
1532 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1535 <th align=right>| . $locale->text('Template Code') . qq|</th>
1536 <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
1539 <th align=right>| . $locale->text('Article Code') . qq|</th>
1540 <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
1543 <th align=right>| . $locale->text('Number Format') . qq|</th>
1544 <td><select name="output_numberformat">$numberformat</select></td>
1547 <th align=right>| . $locale->text('Date Format') . qq|</th>
1548 <td><select name="output_dateformat">$dateformat</select></td>
1551 <th align=right>| . $locale->text('Long Dates') . qq|</th>
1552 <td><input type="radio" name="output_longdates" value="1"| .
1553 ($form->{output_longdates} ? " checked" : "") .
1554 qq|>| . $locale->text("Yes") .
1555 qq|<input type="radio" name="output_longdates" value="0"| .
1556 ($form->{output_longdates} ? "" : " checked") .
1557 qq|>| . $locale->text("No") .
1560 <td colspan=2><hr size=3 noshade></td>
1565 $main::lxdebug->leave_sub();
1569 $main::lxdebug->enter_sub();
1571 my $form = $main::form;
1572 my %myconfig = %main::myconfig;
1573 my $locale = $main::locale;
1575 $main::auth->assert('config');
1577 $form->isblank("description", $locale->text('Language missing!'));
1578 $form->isblank("template_code", $locale->text('Template Code missing!'));
1579 $form->isblank("article_code", $locale->text('Article Code missing!'));
1580 AM->save_language(\%myconfig, \%$form);
1581 $form->redirect($locale->text('Language saved!'));
1583 $main::lxdebug->leave_sub();
1586 sub delete_language {
1587 $main::lxdebug->enter_sub();
1589 my $form = $main::form;
1590 my %myconfig = %main::myconfig;
1591 my $locale = $main::locale;
1593 $main::auth->assert('config');
1595 AM->delete_language(\%myconfig, \%$form);
1596 $form->redirect($locale->text('Language deleted!'));
1598 $main::lxdebug->leave_sub();
1602 sub add_buchungsgruppe {
1603 $main::lxdebug->enter_sub();
1605 my $form = $main::form;
1606 my %myconfig = %main::myconfig;
1607 my $locale = $main::locale;
1609 $main::auth->assert('config');
1611 # $locale->text("Add Buchungsgruppe")
1612 # $locale->text("Edit Buchungsgruppe")
1613 $form->{title} = "Add";
1615 $form->{callback} = "am.pl?action=add_buchungsgruppe" unless $form->{callback};
1617 AM->get_buchungsgruppe(\%myconfig, \%$form);
1618 $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
1619 for (my $i = 0; 4 > $i; $i++) {
1620 map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
1621 qw(income expense));
1624 &buchungsgruppe_header;
1627 $main::lxdebug->leave_sub();
1630 sub edit_buchungsgruppe {
1631 $main::lxdebug->enter_sub();
1633 my $form = $main::form;
1634 my %myconfig = %main::myconfig;
1636 $main::auth->assert('config');
1638 $form->{title} = "Edit";
1640 AM->get_buchungsgruppe(\%myconfig, \%$form);
1642 &buchungsgruppe_header;
1646 $main::lxdebug->leave_sub();
1649 sub list_buchungsgruppe {
1650 $main::lxdebug->enter_sub();
1652 my $form = $main::form;
1653 my %myconfig = %main::myconfig;
1654 my $locale = $main::locale;
1656 $main::auth->assert('config');
1658 AM->buchungsgruppe(\%myconfig, \%$form);
1660 $form->{callback} = "am.pl?action=list_buchungsgruppe";
1662 my $callback = $form->escape($form->{callback});
1664 $form->{title} = $locale->text('Buchungsgruppen');
1666 my @column_index = qw(up down description inventory_accno
1667 income_accno_0 expense_accno_0
1668 income_accno_1 expense_accno_1
1669 income_accno_2 expense_accno_2
1670 income_accno_3 expense_accno_3 );
1672 $column_header{up} =
1673 qq|<th class="listheading" width="16">|
1674 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
1676 $column_header{down} =
1677 qq|<th class="listheading" width="16">|
1678 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
1680 $column_header{description} =
1681 qq|<th class="listheading" width="40%">|
1682 . $locale->text('Description')
1684 $column_header{inventory_accno} =
1685 qq|<th class=listheading>|
1686 . $locale->text('Bestandskonto')
1688 $column_header{income_accno_0} =
1689 qq|<th class=listheading>|
1690 . $locale->text('National Revenues')
1692 $column_header{expense_accno_0} =
1693 qq|<th class=listheading>|
1694 . $locale->text('National Expenses')
1696 $column_header{income_accno_1} =
1697 qq|<th class=listheading>|
1698 . $locale->text('Revenues EU with UStId')
1700 $column_header{expense_accno_1} =
1701 qq|<th class=listheading>|
1702 . $locale->text('Expenses EU with UStId')
1704 $column_header{income_accno_2} =
1705 qq|<th class=listheading>|
1706 . $locale->text('Revenues EU without UStId')
1708 $column_header{expense_accno_2} =
1709 qq|<th class=listheading>|
1710 . $locale->text('Expenses EU without UStId')
1712 $column_header{income_accno_3} =
1713 qq|<th class=listheading>|
1714 . $locale->text('Foreign Revenues')
1716 $column_header{expense_accno_3} =
1717 qq|<th class=listheading>|
1718 . $locale->text('Foreign Expenses')
1727 <th class=listtop>$form->{title}</th>
1729 <tr height="5"></tr>
1733 <tr class=listheading>
1736 map { print "$column_header{$_}\n" } @column_index;
1742 my $swap_link = qq|am.pl?action=swap_buchungsgruppen&|;
1745 my ($i, %column_data);
1746 foreach my $ref (@{ $form->{ALL} }) {
1752 <tr valign=top class=listrow$i>
1756 my $pref = $form->{ALL}->[$row - 1];
1758 qq|<td align="center" valign="center" width="16">| .
1759 qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
1760 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
1763 $column_data{up} = qq|<td width="16"> </td>|;
1766 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
1767 $column_data{down} = qq|<td width="16"> </td>|;
1769 my $nref = $form->{ALL}->[$row + 1];
1770 $column_data{down} =
1771 qq|<td align="center" valign="center" width="16">| .
1772 qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
1773 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
1777 $column_data{description} = qq|<td><a href="am.pl?action=edit_buchungsgruppe&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
1778 $column_data{inventory_accno} = qq|<td align=right>$ref->{inventory_accno}</td>|;
1779 $column_data{income_accno_0} =
1780 qq|<td align=right>$ref->{income_accno_0}</td>|;
1781 $column_data{expense_accno_0} = qq|<td align=right>$ref->{expense_accno_0}</td>|;
1782 $column_data{income_accno_1} =
1783 qq|<td align=right>$ref->{income_accno_1}</td>|;
1784 $column_data{expense_accno_1} = qq|<td align=right>$ref->{expense_accno_1}</td>|;
1785 $column_data{income_accno_2} =
1786 qq|<td align=right>$ref->{income_accno_2}</td>|;
1787 $column_data{expense_accno_2} = qq|<td align=right>$ref->{expense_accno_2}</td>|;
1788 $column_data{income_accno_3} =
1789 qq|<td align=right>$ref->{income_accno_3}</td>|;
1790 $column_data{expense_accno_3} = qq|<td align=right>$ref->{expense_accno_3}</td>|;
1792 map { print "$column_data{$_}\n" } @column_index;
1806 <td><hr size=3 noshade></td>
1811 <form method=post action=am.pl>
1813 <input name=callback type=hidden value="$form->{callback}">
1815 <input type=hidden name=type value=buchungsgruppe>
1817 <input class=submit type=submit name=action value="|
1818 . $locale->text('Add') . qq|">
1826 $main::lxdebug->leave_sub();
1829 sub buchungsgruppe_header {
1830 $main::lxdebug->enter_sub();
1832 my $form = $main::form;
1833 my $locale = $main::locale;
1835 $main::auth->assert('config');
1837 $form->{title} = $locale->text("$form->{title} Buchungsgruppe");
1839 # $locale->text('Add Accounting Group')
1840 # $locale->text('Edit Accounting Group')
1842 my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
1843 my %acc_type_map = (
1844 "IC" => $acc_inventory,
1845 "IC_income" => $acc_income,
1846 "IC_sale" => $acc_income,
1847 "IC_expense" => $acc_expense,
1848 "IC_cogs" => $acc_expense,
1851 foreach my $key (keys(%acc_type_map)) {
1852 foreach my $ref (@{ $form->{IC_links}{$key} }) {
1853 $acc_type_map{$key}->{$ref->{"id"}} = $ref;
1857 foreach my $type (qw(IC IC_income IC_expense)) {
1858 $form->{"select$type"} =
1860 map({ "<option value=$_->{id} $_->{selected}>" .
1861 "$_->{accno}--" . H($_->{description}) . "</option>" }
1862 sort({ $a->{"accno"} cmp $b->{"accno"} }
1863 values(%{$acc_type_map{$type}}))));
1867 $form->{selectIC} =~ s/selected//g;
1868 $form->{selectIC} =~ s/ value=\Q$form->{inventory_accno_id}\E/ value=$form->{inventory_accno_id} selected/;
1869 $form->{selectIC_income} =~ s/selected//g;
1870 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_0}\E/ value=$form->{income_accno_id_0} selected/;
1871 $form->{selectIC_expense} =~ s/selected//g;
1872 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_0}\E/ value=$form->{expense_accno_id_0} selected/;
1876 if (!$::lx_office_conf{system}->{eur}) {
1879 <th align=right>| . $locale->text('Inventory') . qq|</th>
1880 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
1881 <input name=selectIC type=hidden value="$form->{selectIC}">
1885 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
1889 $linkaccounts .= qq|
1891 <th align=right>| . $locale->text('National Revenues') . qq|</th>
1892 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
1895 <th align=right>| . $locale->text('National Expenses') . qq|</th>
1896 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
1899 $form->{selectIC_income} =~ s/selected//g;
1900 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_1}\E/ value=$form->{income_accno_id_1} selected/;
1901 $form->{selectIC_expense} =~ s/selected//g;
1902 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_1}\E/ value=$form->{expense_accno_id_1} selected/;
1904 $linkaccounts .= qq| <tr>
1905 <th align=right>| . $locale->text('Revenues EU with UStId') . qq|</th>
1906 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
1909 <th align=right>| . $locale->text('Expenses EU with UStId') . qq|</th>
1910 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
1914 $form->{selectIC_income} =~ s/selected//g;
1915 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_2}\E/ value=$form->{income_accno_id_2} selected/;
1916 $form->{selectIC_expense} =~ s/selected//g;
1917 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_2}\E/ value=$form->{expense_accno_id_2} selected/;
1920 $linkaccounts .= qq| <tr>
1921 <th align=right>| . $locale->text('Revenues EU without UStId') . qq|</th>
1922 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
1925 <th align=right>| . $locale->text('Expenses EU without UStId') . qq|</th>
1926 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
1930 $form->{selectIC_income} =~ s/selected//g;
1931 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_3}\E/ value=$form->{income_accno_id_3} selected/;
1932 $form->{selectIC_expense} =~ s/selected//g;
1933 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_3}\E/ value=$form->{expense_accno_id_3} selected/;
1936 $linkaccounts .= qq| <tr>
1937 <th align=right>| . $locale->text('Foreign Revenues') . qq|</th>
1938 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
1941 <th align=right>| . $locale->text('Foreign Expenses') . qq|</th>
1942 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
1952 <form method=post action=am.pl>
1954 <input type=hidden name=id value=$form->{id}>
1955 <input type=hidden name=type value=buchungsgruppe>
1959 <th class=listtop colspan=2>$form->{title}</th>
1961 <tr height="5"></tr>
1963 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
1964 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1967 <td colspan=2><hr size=3 noshade></td>
1972 $main::lxdebug->leave_sub();
1975 sub save_buchungsgruppe {
1976 $main::lxdebug->enter_sub();
1978 my $form = $main::form;
1979 my %myconfig = %main::myconfig;
1980 my $locale = $main::locale;
1982 $main::auth->assert('config');
1984 $form->isblank("description", $locale->text('Description missing!'));
1986 AM->save_buchungsgruppe(\%myconfig, \%$form);
1987 $form->redirect($locale->text('Accounting Group saved!'));
1989 $main::lxdebug->leave_sub();
1992 sub delete_buchungsgruppe {
1993 $main::lxdebug->enter_sub();
1995 my $form = $main::form;
1996 my %myconfig = %main::myconfig;
1997 my $locale = $main::locale;
1999 $main::auth->assert('config');
2001 AM->delete_buchungsgruppe(\%myconfig, \%$form);
2002 $form->redirect($locale->text('Accounting Group deleted!'));
2004 $main::lxdebug->leave_sub();
2007 sub swap_buchungsgruppen {
2008 $main::lxdebug->enter_sub();
2010 my $form = $main::form;
2011 my %myconfig = %main::myconfig;
2013 $main::auth->assert('config');
2015 AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
2016 list_buchungsgruppe();
2018 $main::lxdebug->leave_sub();
2022 $main::lxdebug->enter_sub();
2024 my $form = $main::form;
2025 my %myconfig = %main::myconfig;
2026 my $locale = $main::locale;
2028 # get defaults for account numbers and last numbers
2029 AM->defaultaccounts(\%myconfig, \%$form);
2030 $form->{ALL_UNITS} = AM->convertible_units(AM->retrieve_all_units(), 'g');
2032 map { $form->{"defaults_${_}"} = $form->{defaults}->{$_} } keys %{ $form->{defaults} };
2034 foreach my $key (keys %{ $form->{IC} }) {
2035 foreach my $accno (sort keys %{ $form->{IC}->{$key} }) {
2036 my $array = "ACCNOS_" . uc($key);
2037 $form->{$array} ||= [];
2039 my $value = "${accno}--" . $form->{IC}->{$key}->{$accno}->{description};
2040 push @{ $form->{$array} }, {
2043 'selected' => $form->{IC}->{$key}->{$accno}->{id} == $form->{defaults}->{$key},
2048 $form->{title} = $locale->text('Ranges of numbers and default accounts');
2051 print $form->parse_html_template('am/edit_defaults');
2053 $main::lxdebug->leave_sub();
2057 $main::lxdebug->enter_sub();
2059 my $form = $main::form;
2060 my $locale = $main::locale;
2062 AM->save_defaults();
2064 $form->redirect($locale->text('Defaults saved.'));
2066 $main::lxdebug->leave_sub();
2069 sub _build_cfg_options {
2070 my $form = $main::form;
2071 my %myconfig = %main::myconfig;
2074 my $array = uc($idx) . 'S';
2076 $form->{$array} = [];
2077 foreach my $item (@_) {
2078 push @{ $form->{$array} }, {
2081 'selected' => $item eq $myconfig{$idx},
2087 $main::lxdebug->enter_sub();
2089 my $form = $main::form;
2090 my %myconfig = %main::myconfig;
2091 my $locale = $main::locale;
2093 _build_cfg_options('dateformat', qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd));
2094 _build_cfg_options('numberformat', ('1,000.00', '1000.00', '1.000,00', '1000,00'));
2097 if ($::lx_office_conf{print_templates}->{opendocument}
2098 && $::lx_office_conf{applications}->{openofficeorg_writer} && (-x $::lx_office_conf{applications}->{openofficeorg_writer})
2099 && $::lx_office_conf{applications}->{xvfb} && (-x $::lx_office_conf{applications}->{xvfb})) {
2100 push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
2101 "value" => "opendocument_pdf" });
2103 if ($::lx_office_conf{print_templates}->{latex}) {
2104 push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
2106 push(@formats, { "name" => "HTML", "value" => "html" });
2107 if ($::lx_office_conf{print_templates}->{latex}) {
2108 push(@formats, { "name" => $locale->text("Postscript"),
2109 "value" => "postscript" });
2111 if ($::lx_office_conf{print_templates}->{opendocument}) {
2112 push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
2113 "value" => "opendocument" });
2116 if (!$myconfig{"template_format"}) {
2117 $myconfig{"template_format"} = "pdf";
2119 $form->{TEMPLATE_FORMATS} = [];
2120 foreach my $item (@formats) {
2121 push @{ $form->{TEMPLATE_FORMATS} }, {
2122 'name' => $item->{name},
2123 'value' => $item->{value},
2124 'selected' => $item->{value} eq $myconfig{template_format},
2128 if (!$myconfig{"default_media"}) {
2129 $myconfig{"default_media"} = "screen";
2132 my %selected = ($myconfig{"default_media"} => "selected");
2134 { 'name' => $locale->text('Screen'), 'value' => 'screen', 'selected' => $selected{screen}, },
2135 { 'name' => $locale->text('Printer'), 'value' => 'printer', 'selected' => $selected{printer}, },
2136 { 'name' => $locale->text('Queue'), 'value' => 'queue', 'selected' => $selected{queue}, },
2139 $form->{PRINTERS} = [];
2140 foreach my $printer (SL::Printer->all_printers(%::myconfig)) {
2141 push @{ $form->{PRINTERS} }, {
2142 'name' => $printer->{printer_description},
2143 'value' => $printer->{id},
2144 'selected' => $printer->{id} == $myconfig{default_printer_id},
2148 my %countrycodes = User->country_codes;
2150 $form->{COUNTRYCODES} = [];
2151 foreach my $countrycode (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
2152 push @{ $form->{COUNTRYCODES} }, {
2153 'name' => $countrycodes{$countrycode},
2154 'value' => $countrycode,
2155 'selected' => $countrycode eq $myconfig{countrycode},
2159 $form->{STYLESHEETS} = [];
2160 foreach my $item (qw(lx-office-erp.css Win2000.css Mobile.css)) {
2161 push @{ $form->{STYLESHEETS} }, {
2164 'selected' => $item eq $myconfig{stylesheet},
2168 $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details}));
2169 $form->{CAN_CHANGE_PASSWORD} = $main::auth->can_change_password();
2170 $form->{todo_cfg} = { TODO->get_user_config('login' => $form->{login}) };
2172 $form->{title} = $locale->text('Edit Preferences for #1', $form->{login});
2175 print $form->parse_html_template('am/config');
2177 $main::lxdebug->leave_sub();
2180 sub save_preferences {
2181 $main::lxdebug->enter_sub();
2183 my $form = $main::form;
2184 my %myconfig = %main::myconfig;
2185 my $locale = $main::locale;
2187 $form->{stylesheet} = $form->{usestylesheet};
2189 TODO->save_user_config('login' => $form->{login}, %{ $form->{todo_cfg} || { } });
2191 if (AM->save_preferences(\%myconfig, $form)) {
2192 if ($::auth->can_change_password()
2193 && defined $form->{new_password}
2194 && ($form->{new_password} ne '********')) {
2195 my $verifier = SL::Auth::PasswordPolicy->new;
2196 my $result = $verifier->verify($form->{new_password});
2198 if ($result != SL::Auth::PasswordPolicy->OK()) {
2199 $form->error($::locale->text('The settings were saved, but the password was not changed.') . ' ' . join(' ', $verifier->errors($result)));
2202 $::auth->change_password($form->{login}, $form->{new_password});
2204 $form->{password} = $form->{new_password};
2205 $::auth->set_session_value('password', $form->{password});
2206 $::auth->create_or_refresh_session();
2209 $form->redirect($locale->text('Preferences saved!'));
2212 $form->error($locale->text('Cannot save preferences!'));
2214 $main::lxdebug->leave_sub();
2218 $main::lxdebug->enter_sub();
2220 my $form = $main::form;
2221 my %myconfig = %main::myconfig;
2222 my $locale = $main::locale;
2224 $main::auth->assert('config');
2226 $form->{title} = $locale->text('Audit Control');
2228 AM->closedto(\%myconfig, \%$form);
2235 <form method=post action=am.pl>
2238 <tr><th class=listtop>$form->{title}</th></tr>
2239 <tr height="5"></tr>
2244 <th>| . $locale->text('Close Books up to') . qq|</th>
2245 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
2255 <input type=hidden name=nextsub value=doclose>
2257 <input type=submit class=submit name=action value="|
2258 . $locale->text('Continue') . qq|">
2266 $main::lxdebug->leave_sub();
2270 $main::lxdebug->enter_sub();
2272 my $form = $main::form;
2273 my %myconfig = %main::myconfig;
2274 my $locale = $main::locale;
2276 $main::auth->assert('config');
2278 AM->closebooks(\%myconfig, \%$form);
2280 if ($form->{closedto}) {
2282 $locale->text('Books closed up to') . " "
2283 . $locale->date(\%myconfig, $form->{closedto}, 1));
2285 $form->redirect($locale->text('Books are open'));
2288 $main::lxdebug->leave_sub();
2292 $main::lxdebug->enter_sub();
2294 my $form = $main::form;
2295 my %myconfig = %main::myconfig;
2296 my $locale = $main::locale;
2298 $main::auth->assert('config');
2300 my $units = AM->retrieve_units(\%myconfig, $form, "resolved_");
2301 AM->units_in_use(\%myconfig, $form, $units);
2302 map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
2304 my @languages = AM->language(\%myconfig, $form, 1);
2306 my @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units}));
2309 foreach (@unit_list) {
2310 $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"});
2311 $_->{"UNITLANGUAGES"} = [];
2312 foreach my $lang (@languages) {
2313 push(@{ $_->{"UNITLANGUAGES"} },
2315 "unit" => $_->{"name"},
2316 "language_id" => $lang->{"id"},
2317 "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
2318 "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
2324 $units = AM->retrieve_units(\%myconfig, $form);
2325 my $ddbox = AM->unit_select_data($units, undef, 1);
2327 $form->{"title"} = $locale->text("Add and edit units");
2329 print($form->parse_html_template("am/edit_units",
2330 { "UNITS" => \@unit_list,
2331 "NEW_BASE_UNIT_DDBOX" => $ddbox,
2332 "LANGUAGES" => \@languages,
2335 $main::lxdebug->leave_sub();
2339 $main::lxdebug->enter_sub();
2341 my $form = $main::form;
2342 my %myconfig = %main::myconfig;
2343 my $locale = $main::locale;
2345 $main::auth->assert('config');
2347 $form->isblank("new_name", $locale->text("The name is missing."));
2348 my $units = AM->retrieve_units(\%myconfig, $form);
2349 my $all_units = AM->retrieve_units(\%myconfig, $form);
2350 $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
2352 my ($base_unit, $factor);
2353 if ($form->{"new_base_unit"}) {
2354 $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
2356 $form->isblank("new_factor", $locale->text("The factor is missing."));
2357 $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
2358 $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
2359 $base_unit = $form->{"new_base_unit"};
2363 foreach my $lang (AM->language(\%myconfig, $form, 1)) {
2364 next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
2365 push(@languages, { "id" => $lang->{"id"},
2366 "localized" => $form->{"new_localized_$lang->{id}"},
2367 "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
2371 AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, \@languages);
2373 $form->{"saved_message"} = $locale->text("The unit has been saved.");
2377 $main::lxdebug->leave_sub();
2380 sub set_unit_languages {
2381 $main::lxdebug->enter_sub();
2383 my $form = $main::form;
2385 $main::auth->assert('config');
2387 my ($unit, $languages, $idx) = @_;
2389 $unit->{"LANGUAGES"} = [];
2391 foreach my $lang (@{$languages}) {
2392 push(@{ $unit->{"LANGUAGES"} },
2393 { "id" => $lang->{"id"},
2394 "localized" => $form->{"localized_${idx}_$lang->{id}"},
2395 "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
2399 $main::lxdebug->leave_sub();
2403 $main::lxdebug->enter_sub();
2405 my $form = $main::form;
2406 my %myconfig = %main::myconfig;
2407 my $locale = $main::locale;
2409 $main::auth->assert('config');
2411 my $old_units = AM->retrieve_units(\%myconfig, $form, "resolved_");
2412 AM->units_in_use(\%myconfig, $form, $old_units);
2414 my @languages = AM->language(\%myconfig, $form, 1);
2417 my @delete_units = ();
2418 foreach my $i (1..($form->{"rowcount"} * 1)) {
2419 my $old_unit = $old_units->{$form->{"old_name_$i"}};
2421 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
2424 if ($form->{"unchangeable_$i"}) {
2425 $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
2426 $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
2427 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2431 if ($old_unit->{"in_use"}) {
2432 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
2435 if ($form->{"delete_$i"}) {
2436 push(@delete_units, $old_unit->{"name"});
2440 $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
2442 $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
2443 my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
2444 $new_units->{$form->{"name_$i"}} = \%h;
2445 $new_units->{$form->{"name_$i"}}->{"row"} = $i;
2446 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2449 foreach my $unit (values(%{$new_units})) {
2450 next unless ($unit->{"old_name"});
2451 if ($unit->{"base_unit"}) {
2452 $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"}))
2453 unless (defined($new_units->{$unit->{"base_unit"}}));
2454 $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
2455 $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
2457 $unit->{"base_unit"} = undef;
2458 $unit->{"factor"} = undef;
2462 foreach my $unit (values(%{$new_units})) {
2463 next if ($unit->{"unchanged_unit"});
2465 map({ $_->{"seen"} = 0; } values(%{$new_units}));
2466 my $new_unit = $unit;
2467 while ($new_unit->{"base_unit"}) {
2468 $new_unit->{"seen"} = 1;
2469 $new_unit = $new_units->{$new_unit->{"base_unit"}};
2470 if ($new_unit->{"seen"}) {
2471 $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, " .
2472 "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
2477 AM->save_units(\%myconfig, $form, $new_units, \@delete_units);
2479 $form->{"saved_message"} = $locale->text("The units have been saved.");
2483 $main::lxdebug->leave_sub();
2486 sub show_history_search {
2487 $main::lxdebug->enter_sub();
2489 my $form = $main::form;
2490 my $locale = $main::locale;
2492 $main::auth->assert('config');
2494 $form->{title} = $locale->text("History Search");
2497 print $form->parse_html_template("common/search_history");
2499 $main::lxdebug->leave_sub();
2502 sub show_am_history {
2503 $main::lxdebug->enter_sub();
2505 my $form = $main::form;
2506 my %myconfig = %main::myconfig;
2507 my $locale = $main::locale;
2509 $main::auth->assert('config');
2511 my $callback = build_std_url(qw(action einschraenkungen fromdate todate mitarbeiter searchid what2search));
2512 $form->{order} ||= 'h.itime--1';
2514 my %search = ( "Artikelnummer" => "parts",
2515 "Kundennummer" => "customer",
2516 "Lieferantennummer" => "vendor",
2517 "Projektnummer" => "project",
2518 "Buchungsnummer" => "oe",
2519 "Eingangsrechnungnummer" => "ap",
2520 "Ausgangsrechnungnummer" => "ar",
2521 "Mahnungsnummer" => "dunning"
2523 my %searchNo = ( "Artikelnummer" => "partnumber",
2524 "Kundennummer" => "customernumber",
2525 "Lieferantennummer" => "vendornumber",
2526 "Projektnummer" => "projectnumber",
2527 "Buchungsnummer" => "ordnumber",
2528 "Eingangsrechnungnummer" => "invnumber",
2529 "Ausgangsrechnungnummer" => "invnumber",
2530 "Mahnungsnummer" => "dunning_id"
2533 my $dbh = $form->dbconnect(\%myconfig);
2535 my $restriction = qq| AND (| . join(' OR ', map { " addition = " . $dbh->quote($_) } split(m/\,/, $form->{einschraenkungen})) . qq|)| if $form->{einschraenkungen};
2536 $restriction .= qq| AND h.itime::date >= | . conv_dateq($form->{fromdate}) if $form->{fromdate};
2537 $restriction .= qq| AND h.itime::date <= | . conv_dateq($form->{todate}) if $form->{todate};
2538 if ($form->{mitarbeiter} =~ m/^\d+$/) {
2539 $restriction .= qq| AND employee_id = | . $form->{mitarbeiter};
2540 } elsif ($form->{mitarbeiter}) {
2541 $restriction .= qq| AND employee_id = (SELECT id FROM employee WHERE name ILIKE | . $dbh->quote('%' . $form->{mitarbeiter} . '%') . qq|)|;
2544 my $query = qq|SELECT trans_id AS id FROM history_erp | .
2545 ( $form->{'searchid'} ? qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'|
2546 : qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
2548 my @ids = grep { $_ * 1 } selectall_array_query($form, $dbh, $query);
2549 my $daten .= shift @ids;
2550 $daten .= join '', map { " OR trans_id = $_" } @ids;
2552 my ($sort, $sortby) = split(/\-\-/, $form->{order});
2553 $sort =~ s/.*\.(.*)$/$1/;
2555 $form->{title} = $locale->text("History Search");
2558 print $form->parse_html_template("common/show_history",
2559 { "DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}),
2560 "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
2563 uc($sort) . "BY" => $sortby,
2564 'callback' => $callback,
2568 $main::lxdebug->leave_sub();
2572 $main::lxdebug->enter_sub();
2574 my $form = $main::form;
2575 my $locale = $main::locale;
2577 $main::auth->assert('config');
2579 $form->{title} = $locale->text('Add');
2581 $form->{callback} ||= "am.pl?action=add_tax";
2583 _get_taxaccount_selection();
2587 my $parameters_ref = {
2588 # ChartTypeIsAccount => $ChartTypeIsAccount,
2591 # Ausgabe des Templates
2592 print($form->parse_html_template('am/edit_tax', $parameters_ref));
2594 $main::lxdebug->leave_sub();
2598 $main::lxdebug->enter_sub();
2600 my $form = $main::form;
2601 my %myconfig = %main::myconfig;
2602 my $locale = $main::locale;
2604 $main::auth->assert('config');
2606 $form->{title} = $locale->text('Edit');
2608 AM->get_tax(\%myconfig, \%$form);
2609 _get_taxaccount_selection();
2611 $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
2615 my $parameters_ref = {
2618 # Ausgabe des Templates
2619 print($form->parse_html_template('am/edit_tax', $parameters_ref));
2621 $main::lxdebug->leave_sub();
2625 $main::lxdebug->enter_sub();
2627 my $form = $main::form;
2628 my %myconfig = %main::myconfig;
2629 my $locale = $main::locale;
2631 $main::auth->assert('config');
2633 AM->taxes(\%myconfig, \%$form);
2635 map { $_->{rate} = $form->format_amount(\%myconfig, $_->{rate}, 2) } @{ $form->{TAX} };
2637 $form->{callback} = build_std_url('action=list_tax');
2639 $form->{title} = $locale->text('Tax-O-Matic');
2643 my $parameters_ref = {
2646 # Ausgabe des Templates
2647 print($form->parse_html_template('am/list_tax', $parameters_ref));
2649 $main::lxdebug->leave_sub();
2652 sub _get_taxaccount_selection{
2653 $main::lxdebug->enter_sub();
2655 my $form = $main::form;
2656 my %myconfig = %main::myconfig;
2658 $main::auth->assert('config');
2660 AM->get_tax_accounts(\%myconfig, \%$form);
2662 map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} };
2664 $main::lxdebug->leave_sub();
2668 $main::lxdebug->enter_sub();
2670 my $form = $main::form;
2671 my %myconfig = %main::myconfig;
2672 my $locale = $main::locale;
2674 $main::auth->assert('config');
2676 $form->isblank("rate", $locale->text('Taxrate missing!'));
2677 $form->isblank("taxdescription", $locale->text('Taxdescription missing!'));
2678 $form->isblank("taxkey", $locale->text('Taxkey missing!'));
2680 $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate});
2682 if ( $form->{rate} < 0 || $form->{rate} >= 100 ) {
2683 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
2686 if ( $form->{rate} <= 0.99 && $form->{rate} > 0 ) {
2687 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
2690 AM->save_tax(\%myconfig, \%$form);
2691 $form->redirect($locale->text('Tax saved!'));
2693 $main::lxdebug->leave_sub();
2697 $main::lxdebug->enter_sub();
2699 my $form = $main::form;
2700 my %myconfig = %main::myconfig;
2701 my $locale = $main::locale;
2703 $main::auth->assert('config');
2705 AM->delete_tax(\%myconfig, \%$form);
2706 $form->redirect($locale->text('Tax deleted!'));
2708 $main::lxdebug->leave_sub();
2711 sub add_price_factor {
2712 $main::lxdebug->enter_sub();
2714 my $form = $main::form;
2715 my $locale = $main::locale;
2717 $main::auth->assert('config');
2719 $form->{title} = $locale->text('Add Price Factor');
2720 $form->{callback} ||= build_std_url('action=add_price_factor');
2721 $form->{fokus} = 'description';
2724 print $form->parse_html_template('am/edit_price_factor');
2726 $main::lxdebug->leave_sub();
2729 sub edit_price_factor {
2730 $main::lxdebug->enter_sub();
2732 my $form = $main::form;
2733 my %myconfig = %main::myconfig;
2734 my $locale = $main::locale;
2736 $main::auth->assert('config');
2738 $form->{title} = $locale->text('Edit Price Factor');
2739 $form->{callback} ||= build_std_url('action=add_price_factor');
2740 $form->{fokus} = 'description';
2742 AM->get_price_factor(\%myconfig, $form);
2744 $form->{factor} = $form->format_amount(\%myconfig, $form->{factor} * 1);
2747 print $form->parse_html_template('am/edit_price_factor');
2749 $main::lxdebug->leave_sub();
2752 sub list_price_factors {
2753 $main::lxdebug->enter_sub();
2755 my $form = $main::form;
2756 my %myconfig = %main::myconfig;
2757 my $locale = $main::locale;
2759 $main::auth->assert('config');
2761 AM->get_all_price_factors(\%myconfig, \%$form);
2763 foreach my $current (@{ $form->{PRICE_FACTORS} }) {
2764 $current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1);
2767 $form->{callback} = build_std_url('action=list_price_factors');
2768 $form->{title} = $locale->text('Price Factors');
2769 $form->{url_base} = build_std_url('callback');
2772 print $form->parse_html_template('am/list_price_factors');
2774 $main::lxdebug->leave_sub();
2777 sub save_price_factor {
2778 $main::lxdebug->enter_sub();
2780 my $form = $main::form;
2781 my %myconfig = %main::myconfig;
2782 my $locale = $main::locale;
2784 $main::auth->assert('config');
2786 $form->isblank("description", $locale->text('Description missing!'));
2787 $form->isblank("factor", $locale->text('Factor missing!'));
2789 $form->{factor} = $form->parse_amount(\%myconfig, $form->{factor});
2791 AM->save_price_factor(\%myconfig, $form);
2793 $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor saved!')) if ($form->{callback});
2795 $form->redirect($locale->text('Price factor saved!'));
2797 $main::lxdebug->leave_sub();
2800 sub delete_price_factor {
2801 $main::lxdebug->enter_sub();
2803 my $form = $main::form;
2804 my %myconfig = %main::myconfig;
2805 my $locale = $main::locale;
2807 $main::auth->assert('config');
2809 AM->delete_price_factor(\%myconfig, \%$form);
2811 $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor deleted!')) if ($form->{callback});
2813 $form->redirect($locale->text('Price factor deleted!'));
2815 $main::lxdebug->leave_sub();
2819 $main::lxdebug->enter_sub();
2821 my $form = $main::form;
2822 my $locale = $main::locale;
2824 $main::auth->assert('config');
2826 $form->{title} = $locale->text('Add Warehouse');
2827 $form->{callback} ||= build_std_url('action=add_warehouse');
2828 $form->{fokus} = 'description';
2831 print $form->parse_html_template('am/edit_warehouse');
2833 $main::lxdebug->leave_sub();
2836 sub edit_warehouse {
2837 $main::lxdebug->enter_sub();
2839 my $form = $main::form;
2840 my %myconfig = %main::myconfig;
2841 my $locale = $main::locale;
2843 $main::auth->assert('config');
2845 AM->get_warehouse(\%myconfig, $form);
2847 $form->get_lists('employees' => 'EMPLOYEES');
2849 $form->{title} = $locale->text('Edit Warehouse');
2850 $form->{callback} ||= build_std_url('action=list_warehouses');
2851 $form->{fokus} = 'description';
2854 print $form->parse_html_template('am/edit_warehouse');
2856 $main::lxdebug->leave_sub();
2859 sub list_warehouses {
2860 $main::lxdebug->enter_sub();
2862 my $form = $main::form;
2863 my %myconfig = %main::myconfig;
2864 my $locale = $main::locale;
2866 $main::auth->assert('config');
2868 AM->get_all_warehouses(\%myconfig, $form);
2870 $form->{callback} = build_std_url('action=list_warehouses');
2871 $form->{title} = $locale->text('Warehouses');
2872 $form->{url_base} = build_std_url('callback');
2875 print $form->parse_html_template('am/list_warehouses');
2877 $main::lxdebug->leave_sub();
2880 sub save_warehouse {
2881 $main::lxdebug->enter_sub();
2883 my $form = $main::form;
2884 my %myconfig = %main::myconfig;
2885 my $locale = $main::locale;
2887 $main::auth->assert('config');
2889 $form->isblank("description", $locale->text('Description missing!'));
2891 $form->{number_of_new_bins} = $form->parse_amount(\%myconfig, $form->{number_of_new_bins});
2893 AM->save_warehouse(\%myconfig, $form);
2895 $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse saved.')) if ($form->{callback});
2897 $form->redirect($locale->text('Warehouse saved.'));
2899 $main::lxdebug->leave_sub();
2902 sub delete_warehouse {
2903 $main::lxdebug->enter_sub();
2905 my $form = $main::form;
2906 my %myconfig = %main::myconfig;
2907 my $locale = $main::locale;
2909 $main::auth->assert('config');
2911 if (!$form->{confirmed}) {
2912 $form->{title} = $locale->text('Confirmation');
2915 print $form->parse_html_template('am/confirm_delete_warehouse');
2919 if (AM->delete_warehouse(\%myconfig, $form)) {
2920 $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse deleted.')) if ($form->{callback});
2921 $form->redirect($locale->text('Warehouse deleted.'));
2924 $form->error($locale->text('The warehouse could not be deleted because it has already been used.'));
2927 $main::lxdebug->leave_sub();
2931 $main::lxdebug->enter_sub();
2933 my $form = $main::form;
2934 my %myconfig = %main::myconfig;
2935 my $locale = $main::locale;
2937 $main::auth->assert('config');
2939 AM->save_bins(\%myconfig, $form);
2941 $form->{callback} .= '&saved_message=' . E($locale->text('Bins saved.')) if ($form->{callback});
2943 $form->redirect($locale->text('Bins saved.'));
2945 $main::lxdebug->leave_sub();