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";
632 $form->{callback} = "am.pl?action=add_lead" unless $form->{callback};
637 $main::lxdebug->leave_sub();
641 $main::lxdebug->enter_sub();
643 my $form = $main::form;
644 my %myconfig = %main::myconfig;
646 $main::auth->assert('config');
648 $form->{title} = "Edit";
650 AM->get_lead(\%myconfig, \%$form);
654 $form->{orphaned} = 1;
657 $main::lxdebug->leave_sub();
661 $main::lxdebug->enter_sub();
663 my $form = $main::form;
664 my %myconfig = %main::myconfig;
665 my $locale = $main::locale;
667 $main::auth->assert('config');
669 AM->lead(\%myconfig, \%$form);
671 $form->{callback} = "am.pl?action=list_lead";
673 my $callback = $form->escape($form->{callback});
675 $form->{title} = $locale->text('Lead');
677 my @column_index = qw(description cost profit);
679 $column_header{description} =
680 qq|<th class=listheading width=100%>|
681 . $locale->text('Description')
691 <th class=listtop>$form->{title}</th>
694 <tr class=listheading>
697 map { print "$column_header{$_}\n" } @column_index;
703 my ($i, %column_data);
704 foreach my $ref (@{ $form->{ALL} }) {
710 <tr valign=top class=listrow$i>
713 # $lead = $ref->{lead};
715 $column_data{description} = qq|<td><a href="am.pl?action=edit_lead&id=$ref->{id}&callback=$callback">$ref->{lead}</td>|;
717 map { print "$column_data{$_}\n" } @column_index;
726 <td><hr size=3 noshade></td>
731 <form method=post action=am.pl>
733 <input name=callback type=hidden value="$form->{callback}">
735 <input type=hidden name=type value=lead>
737 <input class=submit type=submit name=action value="|
738 . $locale->text('Add') . qq|">
746 $main::lxdebug->leave_sub();
750 $main::lxdebug->enter_sub();
752 my $form = $main::form;
753 my $locale = $main::locale;
755 $main::auth->assert('config');
757 $form->{title} = $locale->text("$form->{title} Lead");
759 # $locale->text('Add Lead')
760 # $locale->text('Edit Lead')
762 $form->{description} =~ s/\"/"/g;
765 qq|<input name=description size=50 value="$form->{lead}">|;
772 <form method=post action=am.pl>
774 <input type=hidden name=id value=$form->{id}>
775 <input type=hidden name=type value=lead>
779 <th class=listtop colspan=2>$form->{title}</th>
783 <th align=right>| . $locale->text('Description') . qq|</th>
784 <td>$description</td>
786 <td colspan=2><hr size=3 noshade></td>
791 $main::lxdebug->leave_sub();
795 $main::lxdebug->enter_sub();
797 my $form = $main::form;
798 my %myconfig = %main::myconfig;
799 my $locale = $main::locale;
801 $main::auth->assert('config');
803 $form->isblank("description", $locale->text('Description missing!'));
804 AM->save_lead(\%myconfig, \%$form);
805 $form->redirect($locale->text('lead saved!'));
807 $main::lxdebug->leave_sub();
811 $main::lxdebug->enter_sub();
813 my $form = $main::form;
814 my %myconfig = %main::myconfig;
815 my $locale = $main::locale;
817 $main::auth->assert('config');
819 AM->delete_lead(\%myconfig, \%$form);
820 $form->redirect($locale->text('lead deleted!'));
822 $main::lxdebug->leave_sub();
826 $main::lxdebug->enter_sub();
828 my $form = $main::form;
830 $main::auth->assert('config');
832 $form->{title} = "Add";
834 $form->{callback} = "am.pl?action=add_business" unless $form->{callback};
839 $main::lxdebug->leave_sub();
843 $main::lxdebug->enter_sub();
845 my $form = $main::form;
846 my %myconfig = %main::myconfig;
848 $form->{title} = "Edit";
850 AM->get_business(\%myconfig, \%$form);
854 $form->{orphaned} = 1;
857 $main::lxdebug->leave_sub();
861 $main::lxdebug->enter_sub();
863 my $form = $main::form;
864 my %myconfig = %main::myconfig;
865 my $locale = $main::locale;
867 $main::auth->assert('config');
869 AM->business(\%myconfig, \%$form);
871 $form->{callback} = "am.pl?action=list_business";
873 my $callback = $form->escape($form->{callback});
875 $form->{title} = $locale->text('Type of Business');
877 my @column_index = qw(description discount customernumberinit);
878 push @column_index, 'salesman' if $::lx_office_conf{features}->{vertreter};
880 $column_header{description} =
881 qq|<th class=listheading width=60%>|
882 . $locale->text('Description')
884 $column_header{discount} =
885 qq|<th class=listheading width=10%>|
886 . $locale->text('Discount')
888 $column_header{customernumberinit} =
889 qq|<th class=listheading>|
890 . $locale->text('Customernumberinit')
892 $column_header{salesman} =
893 qq|<th class=listheading>|
894 . $locale->text('Representative')
904 <th class=listtop>$form->{title}</th>
910 <tr class=listheading>
913 map { print "$column_header{$_}\n" } @column_index;
919 my ($i, %column_data);
920 foreach my $ref (@{ $form->{ALL} }) {
926 <tr valign=top class=listrow$i>
929 my $discount = $form->format_amount(\%myconfig, $ref->{discount} * 100);
930 my $description = $ref->{description};
931 $column_data{description} = qq|<td><a href="am.pl?action=edit_business&id=$ref->{id}&callback=$callback">$description</td>|;
932 $column_data{discount} = qq|<td align=right>$discount</td>|;
933 $column_data{customernumberinit} =
934 qq|<td align=right>$ref->{customernumberinit}</td>|;
935 $column_data{salesman} = '<td>' . ($ref->{salesman} ? $::locale->text('Yes') : $::locale->text('No')) . '</td>';
937 map { print "$column_data{$_}\n" } @column_index;
949 <td><hr size=3 noshade></td>
954 <form method=post action=am.pl>
956 <input name=callback type=hidden value="$form->{callback}">
958 <input type=hidden name=type value=business>
960 <input class=submit type=submit name=action value="|
961 . $locale->text('Add') . qq|">
969 $main::lxdebug->leave_sub();
972 sub business_header {
973 $main::lxdebug->enter_sub();
975 my $form = $main::form;
976 my %myconfig = %main::myconfig;
977 my $locale = $main::locale;
979 $main::auth->assert('config');
981 $form->{title} = $locale->text("$form->{title} Business");
983 # $locale->text('Add Business')
984 # $locale->text('Edit Business')
986 $form->{description} =~ s/\"/"/g;
988 $form->format_amount(\%myconfig, $form->{discount} * 100);
991 if ($::lx_office_conf{features}->{vertreter}) {
994 <th align="right">| . $locale->text('Representative') . qq|</th>
995 <td>| . $::cgi->checkbox(-name => "salesman", -value => 1, -label => '', 'checked' => $form->{salesman} ? 1 : 0) . qq|</td>
999 $salesman_code = $::cgi->hidden(-name => 'salesman', -value => $form->{salesman} ? 1 : 0);
1007 <form method=post action=am.pl>
1009 <input type=hidden name=id value=$form->{id}>
1010 <input type=hidden name=type value=business>
1014 <th class=listtop colspan=2>$form->{title}</th>
1016 <tr height="5"></tr>
1018 <th align=right>| . $locale->text('Type of Business') . qq|</th>
1019 <td><input name=description size=30 value="$form->{description}"></td>
1022 <th align=right>| . $locale->text('Discount') . qq| %</th>
1023 <td><input name=discount size=5 value=$form->{discount}></td>
1026 <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
1027 <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
1030 <td colspan=2><hr size=3 noshade></td>
1035 $main::lxdebug->leave_sub();
1039 $main::lxdebug->enter_sub();
1041 my $form = $main::form;
1042 my %myconfig = %main::myconfig;
1043 my $locale = $main::locale;
1045 $main::auth->assert('config');
1047 $form->isblank("description", $locale->text('Description missing!'));
1048 $form->{discount} = $form->parse_amount(\%myconfig, $form->{discount}) / 100;
1049 AM->save_business(\%myconfig, \%$form);
1050 $form->redirect($locale->text('Business saved!'));
1052 $main::lxdebug->leave_sub();
1055 sub delete_business {
1056 $main::lxdebug->enter_sub();
1058 my $form = $main::form;
1059 my %myconfig = %main::myconfig;
1060 my $locale = $main::locale;
1062 $main::auth->assert('config');
1064 AM->delete_business(\%myconfig, \%$form);
1065 $form->redirect($locale->text('Business deleted!'));
1067 $main::lxdebug->leave_sub();
1071 $main::lxdebug->enter_sub();
1073 my $form = $main::form;
1075 $main::auth->assert('config');
1077 $form->{title} = "Add";
1079 $form->{callback} = "am.pl?action=add_language" unless $form->{callback};
1084 $main::lxdebug->leave_sub();
1088 $main::lxdebug->enter_sub();
1090 my $form = $main::form;
1091 my %myconfig = %main::myconfig;
1093 $main::auth->assert('config');
1095 $form->{title} = "Edit";
1097 AM->get_language(\%myconfig, \%$form);
1101 $form->{orphaned} = 1;
1104 $main::lxdebug->leave_sub();
1108 $main::lxdebug->enter_sub();
1110 my $form = $main::form;
1111 my %myconfig = %main::myconfig;
1112 my $locale = $main::locale;
1114 $main::auth->assert('config');
1116 AM->language(\%myconfig, \%$form);
1118 $form->{callback} = "am.pl?action=list_language";
1120 my $callback = $form->escape($form->{callback});
1122 $form->{title} = $locale->text('Languages');
1124 my @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
1126 $column_header{description} =
1127 qq|<th class=listheading width=60%>|
1128 . $locale->text('Description')
1130 $column_header{template_code} =
1131 qq|<th class=listheading width=10%>|
1132 . $locale->text('Template Code')
1134 $column_header{article_code} =
1135 qq|<th class=listheading>|
1136 . $locale->text('Article Code')
1138 $column_header{output_numberformat} =
1139 qq|<th class=listheading>|
1140 . $locale->text('Number Format')
1142 $column_header{output_dateformat} =
1143 qq|<th class=listheading>|
1144 . $locale->text('Date Format')
1146 $column_header{output_longdates} =
1147 qq|<th class=listheading>|
1148 . $locale->text('Long Dates')
1158 <th class=listtop>$form->{title}</th>
1160 <tr height="5"></tr>
1164 <tr class=listheading>
1167 map { print "$column_header{$_}\n" } @column_index;
1173 my ($i, %column_data);
1174 foreach my $ref (@{ $form->{ALL} }) {
1180 <tr valign=top class=listrow$i>
1184 $column_data{description} =
1185 qq|<td><a href="am.pl?action=edit_language&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
1186 $column_data{template_code} = qq|<td align=right>$ref->{template_code}</td>|;
1187 $column_data{article_code} =
1188 qq|<td align=right>$ref->{article_code}</td>|;
1189 $column_data{output_numberformat} =
1191 ($ref->{output_numberformat} ? $ref->{output_numberformat} :
1192 $locale->text("use program settings")) .
1194 $column_data{output_dateformat} =
1196 ($ref->{output_dateformat} ? $ref->{output_dateformat} :
1197 $locale->text("use program settings")) .
1199 $column_data{output_longdates} =
1201 ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
1204 map { print "$column_data{$_}\n" } @column_index;
1216 <td><hr size=3 noshade></td>
1221 <form method=post action=am.pl>
1223 <input name=callback type=hidden value="$form->{callback}">
1225 <input type=hidden name=type value=language>
1227 <input class=submit type=submit name=action value="|
1228 . $locale->text('Add') . qq|">
1236 $main::lxdebug->leave_sub();
1239 sub language_header {
1240 $main::lxdebug->enter_sub();
1242 my $form = $main::form;
1243 my $locale = $main::locale;
1245 $main::auth->assert('config');
1247 $form->{title} = $locale->text("$form->{title} Language");
1249 # $locale->text('Add Language')
1250 # $locale->text('Edit Language')
1252 $form->{description} =~ s/\"/"/g;
1253 $form->{template_code} =~ s/\"/"/g;
1254 $form->{article_code} =~ s/\"/"/g;
1260 qq|<option value="">| . $locale->text("use program settings") .
1262 foreach my $item (('1,000.00', '1000.00', '1.000,00', '1000,00')) {
1264 ($item eq $form->{output_numberformat})
1265 ? "<option selected>$item"
1271 qq|<option value="">| . $locale->text("use program settings") .
1273 foreach my $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
1275 ($item eq $form->{output_dateformat})
1276 ? "<option selected>$item"
1284 <form method=post action=am.pl>
1286 <input type=hidden name=id value=$form->{id}>
1287 <input type=hidden name=type value=language>
1291 <th class=listtop colspan=2>$form->{title}</th>
1293 <tr height="5"></tr>
1295 <th align=right>| . $locale->text('Language') . qq|</th>
1296 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1299 <th align=right>| . $locale->text('Template Code') . qq|</th>
1300 <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
1303 <th align=right>| . $locale->text('Article Code') . qq|</th>
1304 <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
1307 <th align=right>| . $locale->text('Number Format') . qq|</th>
1308 <td><select name="output_numberformat">$numberformat</select></td>
1311 <th align=right>| . $locale->text('Date Format') . qq|</th>
1312 <td><select name="output_dateformat">$dateformat</select></td>
1315 <th align=right>| . $locale->text('Long Dates') . qq|</th>
1316 <td><input type="radio" name="output_longdates" value="1"| .
1317 ($form->{output_longdates} ? " checked" : "") .
1318 qq|>| . $locale->text("Yes") .
1319 qq|<input type="radio" name="output_longdates" value="0"| .
1320 ($form->{output_longdates} ? "" : " checked") .
1321 qq|>| . $locale->text("No") .
1324 <td colspan=2><hr size=3 noshade></td>
1329 $main::lxdebug->leave_sub();
1333 $main::lxdebug->enter_sub();
1335 my $form = $main::form;
1336 my %myconfig = %main::myconfig;
1337 my $locale = $main::locale;
1339 $main::auth->assert('config');
1341 $form->isblank("description", $locale->text('Language missing!'));
1342 $form->isblank("template_code", $locale->text('Template Code missing!'));
1343 $form->isblank("article_code", $locale->text('Article Code missing!'));
1344 AM->save_language(\%myconfig, \%$form);
1345 $form->redirect($locale->text('Language saved!'));
1347 $main::lxdebug->leave_sub();
1350 sub delete_language {
1351 $main::lxdebug->enter_sub();
1353 my $form = $main::form;
1354 my %myconfig = %main::myconfig;
1355 my $locale = $main::locale;
1357 $main::auth->assert('config');
1359 AM->delete_language(\%myconfig, \%$form);
1360 $form->redirect($locale->text('Language deleted!'));
1362 $main::lxdebug->leave_sub();
1366 sub add_buchungsgruppe {
1367 $main::lxdebug->enter_sub();
1369 my $form = $main::form;
1370 my %myconfig = %main::myconfig;
1371 my $locale = $main::locale;
1373 $main::auth->assert('config');
1375 # $locale->text("Add Buchungsgruppe")
1376 # $locale->text("Edit Buchungsgruppe")
1377 $form->{title} = "Add";
1379 $form->{callback} = "am.pl?action=add_buchungsgruppe" unless $form->{callback};
1381 AM->get_buchungsgruppe(\%myconfig, \%$form);
1382 $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
1383 for (my $i = 0; 4 > $i; $i++) {
1384 map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
1385 qw(income expense));
1388 &buchungsgruppe_header;
1391 $main::lxdebug->leave_sub();
1394 sub edit_buchungsgruppe {
1395 $main::lxdebug->enter_sub();
1397 my $form = $main::form;
1398 my %myconfig = %main::myconfig;
1400 $main::auth->assert('config');
1402 $form->{title} = "Edit";
1404 AM->get_buchungsgruppe(\%myconfig, \%$form);
1406 &buchungsgruppe_header;
1410 $main::lxdebug->leave_sub();
1413 sub list_buchungsgruppe {
1414 $main::lxdebug->enter_sub();
1416 my $form = $main::form;
1417 my %myconfig = %main::myconfig;
1418 my $locale = $main::locale;
1420 $main::auth->assert('config');
1422 AM->buchungsgruppe(\%myconfig, \%$form);
1424 $form->{callback} = "am.pl?action=list_buchungsgruppe";
1426 my $callback = $form->escape($form->{callback});
1428 $form->{title} = $locale->text('Buchungsgruppen');
1430 my @column_index = qw(up down description inventory_accno
1431 income_accno_0 expense_accno_0
1432 income_accno_1 expense_accno_1
1433 income_accno_2 expense_accno_2
1434 income_accno_3 expense_accno_3 );
1436 $column_header{up} =
1437 qq|<th class="listheading" width="16">|
1438 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
1440 $column_header{down} =
1441 qq|<th class="listheading" width="16">|
1442 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
1444 $column_header{description} =
1445 qq|<th class="listheading" width="40%">|
1446 . $locale->text('Description')
1448 $column_header{inventory_accno} =
1449 qq|<th class=listheading>|
1450 . $locale->text('Bestandskonto')
1452 $column_header{income_accno_0} =
1453 qq|<th class=listheading>|
1454 . $locale->text('National Revenues')
1456 $column_header{expense_accno_0} =
1457 qq|<th class=listheading>|
1458 . $locale->text('National Expenses')
1460 $column_header{income_accno_1} =
1461 qq|<th class=listheading>|
1462 . $locale->text('Revenues EU with UStId')
1464 $column_header{expense_accno_1} =
1465 qq|<th class=listheading>|
1466 . $locale->text('Expenses EU with UStId')
1468 $column_header{income_accno_2} =
1469 qq|<th class=listheading>|
1470 . $locale->text('Revenues EU without UStId')
1472 $column_header{expense_accno_2} =
1473 qq|<th class=listheading>|
1474 . $locale->text('Expenses EU without UStId')
1476 $column_header{income_accno_3} =
1477 qq|<th class=listheading>|
1478 . $locale->text('Foreign Revenues')
1480 $column_header{expense_accno_3} =
1481 qq|<th class=listheading>|
1482 . $locale->text('Foreign Expenses')
1491 <th class=listtop>$form->{title}</th>
1493 <tr height="5"></tr>
1497 <tr class=listheading>
1500 map { print "$column_header{$_}\n" } @column_index;
1506 my $swap_link = qq|am.pl?action=swap_buchungsgruppen&|;
1509 my ($i, %column_data);
1510 foreach my $ref (@{ $form->{ALL} }) {
1516 <tr valign=top class=listrow$i>
1520 my $pref = $form->{ALL}->[$row - 1];
1522 qq|<td align="center" valign="center" width="16">| .
1523 qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
1524 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
1527 $column_data{up} = qq|<td width="16"> </td>|;
1530 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
1531 $column_data{down} = qq|<td width="16"> </td>|;
1533 my $nref = $form->{ALL}->[$row + 1];
1534 $column_data{down} =
1535 qq|<td align="center" valign="center" width="16">| .
1536 qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
1537 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
1541 $column_data{description} = qq|<td><a href="am.pl?action=edit_buchungsgruppe&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
1542 $column_data{inventory_accno} = qq|<td align=right>$ref->{inventory_accno}</td>|;
1543 $column_data{income_accno_0} =
1544 qq|<td align=right>$ref->{income_accno_0}</td>|;
1545 $column_data{expense_accno_0} = qq|<td align=right>$ref->{expense_accno_0}</td>|;
1546 $column_data{income_accno_1} =
1547 qq|<td align=right>$ref->{income_accno_1}</td>|;
1548 $column_data{expense_accno_1} = qq|<td align=right>$ref->{expense_accno_1}</td>|;
1549 $column_data{income_accno_2} =
1550 qq|<td align=right>$ref->{income_accno_2}</td>|;
1551 $column_data{expense_accno_2} = qq|<td align=right>$ref->{expense_accno_2}</td>|;
1552 $column_data{income_accno_3} =
1553 qq|<td align=right>$ref->{income_accno_3}</td>|;
1554 $column_data{expense_accno_3} = qq|<td align=right>$ref->{expense_accno_3}</td>|;
1556 map { print "$column_data{$_}\n" } @column_index;
1570 <td><hr size=3 noshade></td>
1575 <form method=post action=am.pl>
1577 <input name=callback type=hidden value="$form->{callback}">
1579 <input type=hidden name=type value=buchungsgruppe>
1581 <input class=submit type=submit name=action value="|
1582 . $locale->text('Add') . qq|">
1590 $main::lxdebug->leave_sub();
1593 sub buchungsgruppe_header {
1594 $main::lxdebug->enter_sub();
1596 my $form = $main::form;
1597 my $locale = $main::locale;
1599 $main::auth->assert('config');
1601 $form->{title} = $locale->text("$form->{title} Buchungsgruppe");
1603 # $locale->text('Add Accounting Group')
1604 # $locale->text('Edit Accounting Group')
1606 my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
1607 my %acc_type_map = (
1608 "IC" => $acc_inventory,
1609 "IC_income" => $acc_income,
1610 "IC_sale" => $acc_income,
1611 "IC_expense" => $acc_expense,
1612 "IC_cogs" => $acc_expense,
1615 foreach my $key (keys(%acc_type_map)) {
1616 foreach my $ref (@{ $form->{IC_links}{$key} }) {
1617 $acc_type_map{$key}->{$ref->{"id"}} = $ref;
1621 foreach my $type (qw(IC IC_income IC_expense)) {
1622 $form->{"select$type"} =
1624 map({ "<option value=$_->{id} $_->{selected}>" .
1625 "$_->{accno}--" . H($_->{description}) . "</option>" }
1626 sort({ $a->{"accno"} cmp $b->{"accno"} }
1627 values(%{$acc_type_map{$type}}))));
1631 $form->{selectIC} =~ s/selected//g;
1632 $form->{selectIC} =~ s/ value=\Q$form->{inventory_accno_id}\E/ value=$form->{inventory_accno_id} selected/;
1633 $form->{selectIC_income} =~ s/selected//g;
1634 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_0}\E/ value=$form->{income_accno_id_0} selected/;
1635 $form->{selectIC_expense} =~ s/selected//g;
1636 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_0}\E/ value=$form->{expense_accno_id_0} selected/;
1640 if (!$::lx_office_conf{system}->{eur}) {
1643 <th align=right>| . $locale->text('Inventory') . qq|</th>
1644 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
1645 <input name=selectIC type=hidden value="$form->{selectIC}">
1649 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
1653 $linkaccounts .= qq|
1655 <th align=right>| . $locale->text('National Revenues') . qq|</th>
1656 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
1659 <th align=right>| . $locale->text('National Expenses') . qq|</th>
1660 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
1663 $form->{selectIC_income} =~ s/selected//g;
1664 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_1}\E/ value=$form->{income_accno_id_1} selected/;
1665 $form->{selectIC_expense} =~ s/selected//g;
1666 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_1}\E/ value=$form->{expense_accno_id_1} selected/;
1668 $linkaccounts .= qq| <tr>
1669 <th align=right>| . $locale->text('Revenues EU with UStId') . qq|</th>
1670 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
1673 <th align=right>| . $locale->text('Expenses EU with UStId') . qq|</th>
1674 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
1678 $form->{selectIC_income} =~ s/selected//g;
1679 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_2}\E/ value=$form->{income_accno_id_2} selected/;
1680 $form->{selectIC_expense} =~ s/selected//g;
1681 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_2}\E/ value=$form->{expense_accno_id_2} selected/;
1684 $linkaccounts .= qq| <tr>
1685 <th align=right>| . $locale->text('Revenues EU without UStId') . qq|</th>
1686 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
1689 <th align=right>| . $locale->text('Expenses EU without UStId') . qq|</th>
1690 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
1694 $form->{selectIC_income} =~ s/selected//g;
1695 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_3}\E/ value=$form->{income_accno_id_3} selected/;
1696 $form->{selectIC_expense} =~ s/selected//g;
1697 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_3}\E/ value=$form->{expense_accno_id_3} selected/;
1700 $linkaccounts .= qq| <tr>
1701 <th align=right>| . $locale->text('Foreign Revenues') . qq|</th>
1702 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
1705 <th align=right>| . $locale->text('Foreign Expenses') . qq|</th>
1706 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
1716 <form method=post action=am.pl>
1718 <input type=hidden name=id value=$form->{id}>
1719 <input type=hidden name=type value=buchungsgruppe>
1723 <th class=listtop colspan=2>$form->{title}</th>
1725 <tr height="5"></tr>
1727 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
1728 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1731 <td colspan=2><hr size=3 noshade></td>
1736 $main::lxdebug->leave_sub();
1739 sub save_buchungsgruppe {
1740 $main::lxdebug->enter_sub();
1742 my $form = $main::form;
1743 my %myconfig = %main::myconfig;
1744 my $locale = $main::locale;
1746 $main::auth->assert('config');
1748 $form->isblank("description", $locale->text('Description missing!'));
1750 AM->save_buchungsgruppe(\%myconfig, \%$form);
1751 $form->redirect($locale->text('Accounting Group saved!'));
1753 $main::lxdebug->leave_sub();
1756 sub delete_buchungsgruppe {
1757 $main::lxdebug->enter_sub();
1759 my $form = $main::form;
1760 my %myconfig = %main::myconfig;
1761 my $locale = $main::locale;
1763 $main::auth->assert('config');
1765 AM->delete_buchungsgruppe(\%myconfig, \%$form);
1766 $form->redirect($locale->text('Accounting Group deleted!'));
1768 $main::lxdebug->leave_sub();
1771 sub swap_buchungsgruppen {
1772 $main::lxdebug->enter_sub();
1774 my $form = $main::form;
1775 my %myconfig = %main::myconfig;
1777 $main::auth->assert('config');
1779 AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
1780 list_buchungsgruppe();
1782 $main::lxdebug->leave_sub();
1786 $main::lxdebug->enter_sub();
1788 my $form = $main::form;
1789 my %myconfig = %main::myconfig;
1790 my $locale = $main::locale;
1792 # get defaults for account numbers and last numbers
1793 AM->defaultaccounts(\%myconfig, \%$form);
1794 $form->{ALL_UNITS} = AM->convertible_units(AM->retrieve_all_units(), 'g');
1796 map { $form->{"defaults_${_}"} = $form->{defaults}->{$_} } keys %{ $form->{defaults} };
1798 foreach my $key (keys %{ $form->{IC} }) {
1799 foreach my $accno (sort keys %{ $form->{IC}->{$key} }) {
1800 my $array = "ACCNOS_" . uc($key);
1801 $form->{$array} ||= [];
1803 my $value = "${accno}--" . $form->{IC}->{$key}->{$accno}->{description};
1804 push @{ $form->{$array} }, {
1807 'selected' => $form->{IC}->{$key}->{$accno}->{id} == $form->{defaults}->{$key},
1812 $form->{title} = $locale->text('Ranges of numbers and default accounts');
1815 print $form->parse_html_template('am/edit_defaults');
1817 $main::lxdebug->leave_sub();
1821 $main::lxdebug->enter_sub();
1823 my $form = $main::form;
1824 my $locale = $main::locale;
1826 AM->save_defaults();
1828 $form->redirect($locale->text('Defaults saved.'));
1830 $main::lxdebug->leave_sub();
1833 sub _build_cfg_options {
1834 my $form = $main::form;
1835 my %myconfig = %main::myconfig;
1838 my $array = uc($idx) . 'S';
1840 $form->{$array} = [];
1841 foreach my $item (@_) {
1842 push @{ $form->{$array} }, {
1845 'selected' => $item eq $myconfig{$idx},
1851 $main::lxdebug->enter_sub();
1853 my $form = $main::form;
1854 my %myconfig = %main::myconfig;
1855 my $locale = $main::locale;
1857 _build_cfg_options('dateformat', qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd));
1858 _build_cfg_options('numberformat', ('1,000.00', '1000.00', '1.000,00', '1000,00'));
1861 if ($::lx_office_conf{print_templates}->{opendocument}
1862 && $::lx_office_conf{applications}->{openofficeorg_writer} && (-x $::lx_office_conf{applications}->{openofficeorg_writer})
1863 && $::lx_office_conf{applications}->{xvfb} && (-x $::lx_office_conf{applications}->{xvfb})) {
1864 push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
1865 "value" => "opendocument_pdf" });
1867 if ($::lx_office_conf{print_templates}->{latex}) {
1868 push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
1870 push(@formats, { "name" => "HTML", "value" => "html" });
1871 if ($::lx_office_conf{print_templates}->{latex}) {
1872 push(@formats, { "name" => $locale->text("Postscript"),
1873 "value" => "postscript" });
1875 if ($::lx_office_conf{print_templates}->{opendocument}) {
1876 push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
1877 "value" => "opendocument" });
1880 if (!$myconfig{"template_format"}) {
1881 $myconfig{"template_format"} = "pdf";
1883 $form->{TEMPLATE_FORMATS} = [];
1884 foreach my $item (@formats) {
1885 push @{ $form->{TEMPLATE_FORMATS} }, {
1886 'name' => $item->{name},
1887 'value' => $item->{value},
1888 'selected' => $item->{value} eq $myconfig{template_format},
1892 if (!$myconfig{"default_media"}) {
1893 $myconfig{"default_media"} = "screen";
1896 my %selected = ($myconfig{"default_media"} => "selected");
1898 { 'name' => $locale->text('Screen'), 'value' => 'screen', 'selected' => $selected{screen}, },
1899 { 'name' => $locale->text('Printer'), 'value' => 'printer', 'selected' => $selected{printer}, },
1900 { 'name' => $locale->text('Queue'), 'value' => 'queue', 'selected' => $selected{queue}, },
1903 $form->{PRINTERS} = [];
1904 foreach my $printer (SL::Printer->all_printers(%::myconfig)) {
1905 push @{ $form->{PRINTERS} }, {
1906 'name' => $printer->{printer_description},
1907 'value' => $printer->{id},
1908 'selected' => $printer->{id} == $myconfig{default_printer_id},
1912 my %countrycodes = User->country_codes;
1914 $form->{COUNTRYCODES} = [];
1915 foreach my $countrycode (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
1916 push @{ $form->{COUNTRYCODES} }, {
1917 'name' => $countrycodes{$countrycode},
1918 'value' => $countrycode,
1919 'selected' => $countrycode eq $myconfig{countrycode},
1923 $form->{STYLESHEETS} = [];
1924 foreach my $item (qw(lx-office-erp.css Win2000.css Mobile.css)) {
1925 push @{ $form->{STYLESHEETS} }, {
1928 'selected' => $item eq $myconfig{stylesheet},
1932 $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details}));
1933 $form->{CAN_CHANGE_PASSWORD} = $main::auth->can_change_password();
1934 $form->{todo_cfg} = { TODO->get_user_config('login' => $form->{login}) };
1936 $form->{title} = $locale->text('Edit Preferences for #1', $form->{login});
1939 print $form->parse_html_template('am/config');
1941 $main::lxdebug->leave_sub();
1944 sub save_preferences {
1945 $main::lxdebug->enter_sub();
1947 my $form = $main::form;
1948 my %myconfig = %main::myconfig;
1949 my $locale = $main::locale;
1951 $form->{stylesheet} = $form->{usestylesheet};
1953 TODO->save_user_config('login' => $form->{login}, %{ $form->{todo_cfg} || { } });
1955 if (AM->save_preferences(\%myconfig, $form)) {
1956 if ($::auth->can_change_password()
1957 && defined $form->{new_password}
1958 && ($form->{new_password} ne '********')) {
1959 my $verifier = SL::Auth::PasswordPolicy->new;
1960 my $result = $verifier->verify($form->{new_password});
1962 if ($result != SL::Auth::PasswordPolicy->OK()) {
1963 $form->error($::locale->text('The settings were saved, but the password was not changed.') . ' ' . join(' ', $verifier->errors($result)));
1966 $::auth->change_password($form->{login}, $form->{new_password});
1968 $form->{password} = $form->{new_password};
1969 $::auth->set_session_value('password', $form->{password});
1970 $::auth->create_or_refresh_session();
1973 $form->redirect($locale->text('Preferences saved!'));
1976 $form->error($locale->text('Cannot save preferences!'));
1978 $main::lxdebug->leave_sub();
1982 $main::lxdebug->enter_sub();
1984 my $form = $main::form;
1985 my %myconfig = %main::myconfig;
1986 my $locale = $main::locale;
1988 $main::auth->assert('config');
1990 $form->{title} = $locale->text('Audit Control');
1992 AM->closedto(\%myconfig, \%$form);
1999 <form method=post action=am.pl>
2002 <tr><th class=listtop>$form->{title}</th></tr>
2003 <tr height="5"></tr>
2008 <th>| . $locale->text('Close Books up to') . qq|</th>
2009 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
2019 <input type=hidden name=nextsub value=doclose>
2021 <input type=submit class=submit name=action value="|
2022 . $locale->text('Continue') . qq|">
2030 $main::lxdebug->leave_sub();
2034 $main::lxdebug->enter_sub();
2036 my $form = $main::form;
2037 my %myconfig = %main::myconfig;
2038 my $locale = $main::locale;
2040 $main::auth->assert('config');
2042 AM->closebooks(\%myconfig, \%$form);
2044 if ($form->{closedto}) {
2046 $locale->text('Books closed up to') . " "
2047 . $locale->date(\%myconfig, $form->{closedto}, 1));
2049 $form->redirect($locale->text('Books are open'));
2052 $main::lxdebug->leave_sub();
2056 $main::lxdebug->enter_sub();
2058 my $form = $main::form;
2059 my %myconfig = %main::myconfig;
2060 my $locale = $main::locale;
2062 $main::auth->assert('config');
2064 my $units = AM->retrieve_units(\%myconfig, $form, "resolved_");
2065 AM->units_in_use(\%myconfig, $form, $units);
2066 map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
2068 my @languages = AM->language(\%myconfig, $form, 1);
2070 my @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units}));
2073 foreach (@unit_list) {
2074 $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"});
2075 $_->{"UNITLANGUAGES"} = [];
2076 foreach my $lang (@languages) {
2077 push(@{ $_->{"UNITLANGUAGES"} },
2079 "unit" => $_->{"name"},
2080 "language_id" => $lang->{"id"},
2081 "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
2082 "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
2088 $units = AM->retrieve_units(\%myconfig, $form);
2089 my $ddbox = AM->unit_select_data($units, undef, 1);
2091 $form->{"title"} = $locale->text("Add and edit units");
2093 print($form->parse_html_template("am/edit_units",
2094 { "UNITS" => \@unit_list,
2095 "NEW_BASE_UNIT_DDBOX" => $ddbox,
2096 "LANGUAGES" => \@languages,
2099 $main::lxdebug->leave_sub();
2103 $main::lxdebug->enter_sub();
2105 my $form = $main::form;
2106 my %myconfig = %main::myconfig;
2107 my $locale = $main::locale;
2109 $main::auth->assert('config');
2111 $form->isblank("new_name", $locale->text("The name is missing."));
2112 my $units = AM->retrieve_units(\%myconfig, $form);
2113 my $all_units = AM->retrieve_units(\%myconfig, $form);
2114 $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
2116 my ($base_unit, $factor);
2117 if ($form->{"new_base_unit"}) {
2118 $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
2120 $form->isblank("new_factor", $locale->text("The factor is missing."));
2121 $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
2122 $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
2123 $base_unit = $form->{"new_base_unit"};
2127 foreach my $lang (AM->language(\%myconfig, $form, 1)) {
2128 next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
2129 push(@languages, { "id" => $lang->{"id"},
2130 "localized" => $form->{"new_localized_$lang->{id}"},
2131 "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
2135 AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, \@languages);
2137 $form->{"saved_message"} = $locale->text("The unit has been saved.");
2141 $main::lxdebug->leave_sub();
2144 sub set_unit_languages {
2145 $main::lxdebug->enter_sub();
2147 my $form = $main::form;
2149 $main::auth->assert('config');
2151 my ($unit, $languages, $idx) = @_;
2153 $unit->{"LANGUAGES"} = [];
2155 foreach my $lang (@{$languages}) {
2156 push(@{ $unit->{"LANGUAGES"} },
2157 { "id" => $lang->{"id"},
2158 "localized" => $form->{"localized_${idx}_$lang->{id}"},
2159 "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
2163 $main::lxdebug->leave_sub();
2167 $main::lxdebug->enter_sub();
2169 my $form = $main::form;
2170 my %myconfig = %main::myconfig;
2171 my $locale = $main::locale;
2173 $main::auth->assert('config');
2175 my $old_units = AM->retrieve_units(\%myconfig, $form, "resolved_");
2176 AM->units_in_use(\%myconfig, $form, $old_units);
2178 my @languages = AM->language(\%myconfig, $form, 1);
2181 my @delete_units = ();
2182 foreach my $i (1..($form->{"rowcount"} * 1)) {
2183 my $old_unit = $old_units->{$form->{"old_name_$i"}};
2185 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
2188 if ($form->{"unchangeable_$i"}) {
2189 $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
2190 $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
2191 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2195 if ($old_unit->{"in_use"}) {
2196 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
2199 if ($form->{"delete_$i"}) {
2200 push(@delete_units, $old_unit->{"name"});
2204 $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
2206 $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
2207 my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
2208 $new_units->{$form->{"name_$i"}} = \%h;
2209 $new_units->{$form->{"name_$i"}}->{"row"} = $i;
2210 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2213 foreach my $unit (values(%{$new_units})) {
2214 next unless ($unit->{"old_name"});
2215 if ($unit->{"base_unit"}) {
2216 $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"}))
2217 unless (defined($new_units->{$unit->{"base_unit"}}));
2218 $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
2219 $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
2221 $unit->{"base_unit"} = undef;
2222 $unit->{"factor"} = undef;
2226 foreach my $unit (values(%{$new_units})) {
2227 next if ($unit->{"unchanged_unit"});
2229 map({ $_->{"seen"} = 0; } values(%{$new_units}));
2230 my $new_unit = $unit;
2231 while ($new_unit->{"base_unit"}) {
2232 $new_unit->{"seen"} = 1;
2233 $new_unit = $new_units->{$new_unit->{"base_unit"}};
2234 if ($new_unit->{"seen"}) {
2235 $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, " .
2236 "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
2241 AM->save_units(\%myconfig, $form, $new_units, \@delete_units);
2243 $form->{"saved_message"} = $locale->text("The units have been saved.");
2247 $main::lxdebug->leave_sub();
2250 sub show_history_search {
2251 $main::lxdebug->enter_sub();
2253 my $form = $main::form;
2254 my $locale = $main::locale;
2256 $main::auth->assert('config');
2258 $form->{title} = $locale->text("History Search");
2261 print $form->parse_html_template("common/search_history");
2263 $main::lxdebug->leave_sub();
2266 sub show_am_history {
2267 $main::lxdebug->enter_sub();
2269 my $form = $main::form;
2270 my %myconfig = %main::myconfig;
2271 my $locale = $main::locale;
2273 $main::auth->assert('config');
2275 my $callback = build_std_url(qw(action einschraenkungen fromdate todate mitarbeiter searchid what2search));
2276 $form->{order} ||= 'h.itime--1';
2278 my %search = ( "Artikelnummer" => "parts",
2279 "Kundennummer" => "customer",
2280 "Lieferantennummer" => "vendor",
2281 "Projektnummer" => "project",
2282 "Buchungsnummer" => "oe",
2283 "Eingangsrechnungnummer" => "ap",
2284 "Ausgangsrechnungnummer" => "ar",
2285 "Mahnungsnummer" => "dunning"
2287 my %searchNo = ( "Artikelnummer" => "partnumber",
2288 "Kundennummer" => "customernumber",
2289 "Lieferantennummer" => "vendornumber",
2290 "Projektnummer" => "projectnumber",
2291 "Buchungsnummer" => "ordnumber",
2292 "Eingangsrechnungnummer" => "invnumber",
2293 "Ausgangsrechnungnummer" => "invnumber",
2294 "Mahnungsnummer" => "dunning_id"
2297 my $dbh = $form->dbconnect(\%myconfig);
2299 my $restriction = qq| AND (| . join(' OR ', map { " addition = " . $dbh->quote($_) } split(m/\,/, $form->{einschraenkungen})) . qq|)| if $form->{einschraenkungen};
2300 $restriction .= qq| AND h.itime::date >= | . conv_dateq($form->{fromdate}) if $form->{fromdate};
2301 $restriction .= qq| AND h.itime::date <= | . conv_dateq($form->{todate}) if $form->{todate};
2302 if ($form->{mitarbeiter} =~ m/^\d+$/) {
2303 $restriction .= qq| AND employee_id = | . $form->{mitarbeiter};
2304 } elsif ($form->{mitarbeiter}) {
2305 $restriction .= qq| AND employee_id = (SELECT id FROM employee WHERE name ILIKE | . $dbh->quote('%' . $form->{mitarbeiter} . '%') . qq|)|;
2308 my $query = qq|SELECT trans_id AS id FROM history_erp | .
2309 ( $form->{'searchid'} ? qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'|
2310 : qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
2312 my @ids = grep { $_ * 1 } selectall_array_query($form, $dbh, $query);
2313 my $daten .= shift @ids;
2314 $daten .= join '', map { " OR trans_id = $_" } @ids;
2316 my ($sort, $sortby) = split(/\-\-/, $form->{order});
2317 $sort =~ s/.*\.(.*)$/$1/;
2319 $form->{title} = $locale->text("History Search");
2322 print $form->parse_html_template("common/show_history",
2323 { "DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}),
2324 "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
2327 uc($sort) . "BY" => $sortby,
2328 'callback' => $callback,
2332 $main::lxdebug->leave_sub();
2336 $main::lxdebug->enter_sub();
2338 my $form = $main::form;
2339 my $locale = $main::locale;
2341 $main::auth->assert('config');
2343 $form->{title} = $locale->text('Add');
2345 $form->{callback} ||= "am.pl?action=add_tax";
2347 _get_taxaccount_selection();
2351 my $parameters_ref = {
2352 # ChartTypeIsAccount => $ChartTypeIsAccount,
2355 # Ausgabe des Templates
2356 print($form->parse_html_template('am/edit_tax', $parameters_ref));
2358 $main::lxdebug->leave_sub();
2362 $main::lxdebug->enter_sub();
2364 my $form = $main::form;
2365 my %myconfig = %main::myconfig;
2366 my $locale = $main::locale;
2368 $main::auth->assert('config');
2370 $form->{title} = $locale->text('Edit');
2372 AM->get_tax(\%myconfig, \%$form);
2373 _get_taxaccount_selection();
2375 $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
2379 my $parameters_ref = {
2382 # Ausgabe des Templates
2383 print($form->parse_html_template('am/edit_tax', $parameters_ref));
2385 $main::lxdebug->leave_sub();
2389 $main::lxdebug->enter_sub();
2391 my $form = $main::form;
2392 my %myconfig = %main::myconfig;
2393 my $locale = $main::locale;
2395 $main::auth->assert('config');
2397 AM->taxes(\%myconfig, \%$form);
2399 map { $_->{rate} = $form->format_amount(\%myconfig, $_->{rate}, 2) } @{ $form->{TAX} };
2401 $form->{callback} = build_std_url('action=list_tax');
2403 $form->{title} = $locale->text('Tax-O-Matic');
2407 my $parameters_ref = {
2410 # Ausgabe des Templates
2411 print($form->parse_html_template('am/list_tax', $parameters_ref));
2413 $main::lxdebug->leave_sub();
2416 sub _get_taxaccount_selection{
2417 $main::lxdebug->enter_sub();
2419 my $form = $main::form;
2420 my %myconfig = %main::myconfig;
2422 $main::auth->assert('config');
2424 AM->get_tax_accounts(\%myconfig, \%$form);
2426 map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} };
2428 $main::lxdebug->leave_sub();
2432 $main::lxdebug->enter_sub();
2434 my $form = $main::form;
2435 my %myconfig = %main::myconfig;
2436 my $locale = $main::locale;
2438 $main::auth->assert('config');
2440 $form->isblank("rate", $locale->text('Taxrate missing!'));
2441 $form->isblank("taxdescription", $locale->text('Taxdescription missing!'));
2442 $form->isblank("taxkey", $locale->text('Taxkey missing!'));
2444 $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate});
2446 if ( $form->{rate} < 0 || $form->{rate} >= 100 ) {
2447 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
2450 if ( $form->{rate} <= 0.99 && $form->{rate} > 0 ) {
2451 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
2454 AM->save_tax(\%myconfig, \%$form);
2455 $form->redirect($locale->text('Tax saved!'));
2457 $main::lxdebug->leave_sub();
2461 $main::lxdebug->enter_sub();
2463 my $form = $main::form;
2464 my %myconfig = %main::myconfig;
2465 my $locale = $main::locale;
2467 $main::auth->assert('config');
2469 AM->delete_tax(\%myconfig, \%$form);
2470 $form->redirect($locale->text('Tax deleted!'));
2472 $main::lxdebug->leave_sub();
2475 sub add_price_factor {
2476 $main::lxdebug->enter_sub();
2478 my $form = $main::form;
2479 my $locale = $main::locale;
2481 $main::auth->assert('config');
2483 $form->{title} = $locale->text('Add Price Factor');
2484 $form->{callback} ||= build_std_url('action=add_price_factor');
2485 $form->{fokus} = 'description';
2488 print $form->parse_html_template('am/edit_price_factor');
2490 $main::lxdebug->leave_sub();
2493 sub edit_price_factor {
2494 $main::lxdebug->enter_sub();
2496 my $form = $main::form;
2497 my %myconfig = %main::myconfig;
2498 my $locale = $main::locale;
2500 $main::auth->assert('config');
2502 $form->{title} = $locale->text('Edit Price Factor');
2503 $form->{callback} ||= build_std_url('action=add_price_factor');
2504 $form->{fokus} = 'description';
2506 AM->get_price_factor(\%myconfig, $form);
2508 $form->{factor} = $form->format_amount(\%myconfig, $form->{factor} * 1);
2511 print $form->parse_html_template('am/edit_price_factor');
2513 $main::lxdebug->leave_sub();
2516 sub list_price_factors {
2517 $main::lxdebug->enter_sub();
2519 my $form = $main::form;
2520 my %myconfig = %main::myconfig;
2521 my $locale = $main::locale;
2523 $main::auth->assert('config');
2525 AM->get_all_price_factors(\%myconfig, \%$form);
2527 foreach my $current (@{ $form->{PRICE_FACTORS} }) {
2528 $current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1);
2531 $form->{callback} = build_std_url('action=list_price_factors');
2532 $form->{title} = $locale->text('Price Factors');
2533 $form->{url_base} = build_std_url('callback');
2536 print $form->parse_html_template('am/list_price_factors');
2538 $main::lxdebug->leave_sub();
2541 sub save_price_factor {
2542 $main::lxdebug->enter_sub();
2544 my $form = $main::form;
2545 my %myconfig = %main::myconfig;
2546 my $locale = $main::locale;
2548 $main::auth->assert('config');
2550 $form->isblank("description", $locale->text('Description missing!'));
2551 $form->isblank("factor", $locale->text('Factor missing!'));
2553 $form->{factor} = $form->parse_amount(\%myconfig, $form->{factor});
2555 AM->save_price_factor(\%myconfig, $form);
2557 $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor saved!')) if ($form->{callback});
2559 $form->redirect($locale->text('Price factor saved!'));
2561 $main::lxdebug->leave_sub();
2564 sub delete_price_factor {
2565 $main::lxdebug->enter_sub();
2567 my $form = $main::form;
2568 my %myconfig = %main::myconfig;
2569 my $locale = $main::locale;
2571 $main::auth->assert('config');
2573 AM->delete_price_factor(\%myconfig, \%$form);
2575 $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor deleted!')) if ($form->{callback});
2577 $form->redirect($locale->text('Price factor deleted!'));
2579 $main::lxdebug->leave_sub();
2583 $main::lxdebug->enter_sub();
2585 my $form = $main::form;
2586 my $locale = $main::locale;
2588 $main::auth->assert('config');
2590 $form->{title} = $locale->text('Add Warehouse');
2591 $form->{callback} ||= build_std_url('action=add_warehouse');
2592 $form->{fokus} = 'description';
2595 print $form->parse_html_template('am/edit_warehouse');
2597 $main::lxdebug->leave_sub();
2600 sub edit_warehouse {
2601 $main::lxdebug->enter_sub();
2603 my $form = $main::form;
2604 my %myconfig = %main::myconfig;
2605 my $locale = $main::locale;
2607 $main::auth->assert('config');
2609 AM->get_warehouse(\%myconfig, $form);
2611 $form->get_lists('employees' => 'EMPLOYEES');
2613 $form->{title} = $locale->text('Edit Warehouse');
2614 $form->{callback} ||= build_std_url('action=list_warehouses');
2615 $form->{fokus} = 'description';
2618 print $form->parse_html_template('am/edit_warehouse');
2620 $main::lxdebug->leave_sub();
2623 sub list_warehouses {
2624 $main::lxdebug->enter_sub();
2626 my $form = $main::form;
2627 my %myconfig = %main::myconfig;
2628 my $locale = $main::locale;
2630 $main::auth->assert('config');
2632 AM->get_all_warehouses(\%myconfig, $form);
2634 $form->{callback} = build_std_url('action=list_warehouses');
2635 $form->{title} = $locale->text('Warehouses');
2636 $form->{url_base} = build_std_url('callback');
2639 print $form->parse_html_template('am/list_warehouses');
2641 $main::lxdebug->leave_sub();
2644 sub save_warehouse {
2645 $main::lxdebug->enter_sub();
2647 my $form = $main::form;
2648 my %myconfig = %main::myconfig;
2649 my $locale = $main::locale;
2651 $main::auth->assert('config');
2653 $form->isblank("description", $locale->text('Description missing!'));
2655 $form->{number_of_new_bins} = $form->parse_amount(\%myconfig, $form->{number_of_new_bins});
2657 AM->save_warehouse(\%myconfig, $form);
2659 $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse saved.')) if ($form->{callback});
2661 $form->redirect($locale->text('Warehouse saved.'));
2663 $main::lxdebug->leave_sub();
2666 sub delete_warehouse {
2667 $main::lxdebug->enter_sub();
2669 my $form = $main::form;
2670 my %myconfig = %main::myconfig;
2671 my $locale = $main::locale;
2673 $main::auth->assert('config');
2675 if (!$form->{confirmed}) {
2676 $form->{title} = $locale->text('Confirmation');
2679 print $form->parse_html_template('am/confirm_delete_warehouse');
2683 if (AM->delete_warehouse(\%myconfig, $form)) {
2684 $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse deleted.')) if ($form->{callback});
2685 $form->redirect($locale->text('Warehouse deleted.'));
2688 $form->error($locale->text('The warehouse could not be deleted because it has already been used.'));
2691 $main::lxdebug->leave_sub();
2695 $main::lxdebug->enter_sub();
2697 my $form = $main::form;
2698 my %myconfig = %main::myconfig;
2699 my $locale = $main::locale;
2701 $main::auth->assert('config');
2703 AM->save_bins(\%myconfig, $form);
2705 $form->{callback} .= '&saved_message=' . E($locale->text('Bins saved.')) if ($form->{callback});
2707 $form->redirect($locale->text('Bins saved.'));
2709 $main::lxdebug->leave_sub();