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 #======================================================================
49 require "bin/mozilla/common.pl";
53 sub add { call_sub("add_$form->{type}"); }
54 sub delete { call_sub("delete_$form->{type}"); }
55 sub save { call_sub("save_$form->{type}"); }
56 sub edit { call_sub("edit_$form->{type}"); }
57 sub continue { call_sub($form->{"nextsub"}); }
58 sub save_as_new { call_sub("save_as_new_$form->{type}"); }
61 $lxdebug->enter_sub();
63 $auth->assert('config');
65 $form->{title} = "Add";
66 $form->{charttype} = "A";
67 AM->get_account(\%myconfig, \%$form);
69 $form->{callback} = "am.pl?action=list_account" unless $form->{callback};
74 $lxdebug->leave_sub();
78 $lxdebug->enter_sub();
80 $auth->assert('config');
82 $form->{title} = "Edit";
83 AM->get_account(\%myconfig, \%$form);
85 foreach my $item (split(/:/, $form->{link})) {
86 $form->{$item} = "checked";
92 $lxdebug->leave_sub();
96 $lxdebug->enter_sub();
98 $auth->assert('config');
100 if ( $form->{action} eq 'edit_account') {
101 $form->{account_exists} = '1';
104 $form->{title} = $locale->text("$form->{title} Account");
106 $form->{"$form->{charttype}_checked"} = "checked";
107 $form->{"$form->{category}_checked"} = "checked";
109 $form->{select_tax} = "";
111 my @tax_report_pos = USTVA->report_variables({
112 myconfig => \%myconfig,
115 attribute => 'position',
119 if (@{ $form->{TAXKEY} }) {
120 foreach my $item (@{ $form->{TAXKEY} }) {
121 $item->{rate} = $item->{rate} * 100 . '%';
124 # Fill in empty row for new Taxkey
130 taxdescription => '',
137 push @{ $form->{ACCOUNT_TAXKEYS} }, $newtaxkey_ref;
140 foreach my $taxkey_used (@{ $form->{ACCOUNT_TAXKEYS} } ) {
142 # Fill in a runningnumber
143 $form->{ACCOUNT_TAXKEYS}[$i]{runningnumber} = $i;
145 # Fill in the Taxkeys as select options
146 foreach my $item (@{ $form->{TAXKEY} }) {
147 if ($item->{id} == $taxkey_used->{tax_id}) {
148 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
149 qq|<option value="$item->{id}" selected="selected">|
150 . sprintf("%.2d", $item->{taxkey})
151 . qq|. $item->{taxdescription} ($item->{rate}) |
152 . $locale->text('Tax-o-matic Account')
153 . qq|: $item->{chart_accno}\n|;
156 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
157 qq|<option value="$item->{id}">|
158 . sprintf("%.2d", $item->{taxkey})
159 . qq|. $item->{taxdescription} ($item->{rate}) |
160 . $locale->text('Tax-o-matic Account')
161 . qq|: $item->{chart_accno}\n|;
166 # Fill in the USTVA Numbers as select options
167 foreach my $item ( '', sort({ $a cmp $b } @tax_report_pos) ) {
169 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="" selected="selected">-\n|;
171 elsif ( $item eq $taxkey_used->{pos_ustva} ) {
172 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item" selected="selected">$item\n|;
175 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item">$item\n|;
184 # Newaccount Folgekonto
185 if (@{ $form->{NEWACCOUNT} }) {
186 if (!$form->{new_chart_valid}) {
187 $form->{selectnewaccount} = qq|<option value=""> |. $locale->text('None') .q|</option>|;
189 foreach $item (@{ $form->{NEWACCOUNT} }) {
190 if ($item->{id} == $form->{new_chart_id}) {
191 $form->{selectnewaccount} .=
192 qq|<option value="$item->{id}" selected>$item->{accno}--$item->{description}</option>|;
193 } elsif (!$form->{new_chart_valid}) {
194 $form->{selectnewaccount} .=
195 qq|<option value="$item->{id}">$item->{accno}--$item->{description}</option>|;
201 $select_eur = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
202 %eur = (1 => "Umsatzerlöse",
203 2 => "sonstige Erlöse",
204 3 => "Privatanteile",
206 5 => "Ausserordentliche Erträge",
207 6 => "Vereinnahmte Umsatzst.",
208 7 => "Umsatzsteuererstattungen",
209 8 => "Wareneingänge",
210 9 => "Löhne und Gehälter",
211 10 => "Gesetzl. sozialer Aufw.",
213 12 => "Gas, Strom, Wasser",
214 13 => "Instandhaltung",
215 14 => "Steuern, Versich., Beiträge",
217 16 => "Kfz-Versicherungen",
218 17 => "Sonst. Fahrzeugkosten",
219 18 => "Werbe- und Reisekosten",
220 19 => "Instandhaltung u. Werkzeuge",
221 20 => "Fachzeitschriften, Bücher",
222 21 => "Miete für Einrichtungen",
223 22 => "Rechts- und Beratungskosten",
224 23 => "Bürobedarf, Porto, Telefon",
225 24 => "Sonstige Aufwendungen",
226 25 => "Abschreibungen auf Anlagever.",
227 26 => "Abschreibungen auf GWG",
229 28 => "Umsatzsteuerzahlungen",
231 30 => "Ausserordentlicher Aufwand",
232 31 => "Betriebliche Steuern");
233 foreach $item (sort({ $a <=> $b } keys(%eur))) {
234 my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $eur{$item}));
235 if ($item == $form->{pos_eur}) {
236 $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
238 $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
243 $select_bwa = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
245 %bwapos = (1 => 'Umsatzerlöse',
246 2 => 'Best.Verdg.FE/UE',
247 3 => 'Aktiv.Eigenleistung',
248 4 => 'Mat./Wareneinkauf',
249 5 => 'So.betr.Erlöse',
250 10 => 'Personalkosten',
252 12 => 'Betriebl.Steuern',
253 13 => 'Vers./Beiträge',
254 14 => 'Kfz.Kosten o.St.',
255 15 => 'Werbe-Reisek.',
256 16 => 'Kosten Warenabgabe',
257 17 => 'Abschreibungen',
258 18 => 'Rep./instandhlt.',
259 19 => 'Übrige Steuern',
260 20 => 'Sonst.Kosten',
262 31 => 'Sonst.neutr.Aufw.',
264 33 => 'Sonst.neutr.Ertrag',
265 34 => 'Verr.kalk.Kosten',
266 35 => 'Steuern Eink.u.Ertr.');
267 foreach $item (sort({ $a <=> $b } keys %bwapos)) {
268 my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $bwapos{$item}));
269 if ($item == $form->{pos_bwa}) {
270 $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $text\n|;
272 $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $text\n|;
277 # Wieder hinzugefügt zu evaluationszwecken (us) 09.03.2007
278 $select_bilanz = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
279 foreach $item ((1, 2, 3, 4)) {
280 if ($item == $form->{pos_bilanz}) {
281 $select_bilanz .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|.\n|;
283 $select_bilanz .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|.\n|;
288 # this is for our parser only! Do not remove.
289 # type=submit $locale->text('Add Account')
290 # type=submit $locale->text('Edit Account')
292 $form->{type} = "account";
294 # preselections category
296 $select_category = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
299 'A' => $locale->text('Asset'),
300 'L' => $locale->text('Liability'),
301 'Q' => $locale->text('Equity'),
302 'I' => $locale->text('Revenue'),
303 'E' => $locale->text('Expense'),
304 'C' => $locale->text('Costs'),
306 foreach $item ( sort({ $a <=> $b } keys %category) ) {
307 if ($item eq $form->{category}) {
308 $select_category .= qq|<option value="$item" selected="selected">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
310 $select_category .= qq|<option value="$item">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
315 # preselection chart type
316 my $select_charttype = q{};
319 'A' => $locale->text('Account'),
320 'H' => $locale->text('Header'),
323 foreach $item ( sort({ $a <=> $b } keys %charttype) ) {
324 if ($item eq $form->{charttype}) {
325 $select_charttype .= qq|<option value="$item" selected="selected">$charttype{$item}\n|;
328 $select_charttype .= qq|<option value="$item">$charttype{$item}\n|;
333 my $ChartTypeIsAccount = ($form->{charttype} eq "A") ? "1":"";
337 my $parameters_ref = {
338 ChartTypeIsAccount => $ChartTypeIsAccount,
339 select_category => $select_category,
340 select_charttype => $select_charttype,
341 newaccount => $newaccount,
343 select_bwa => $select_bwa,
344 select_bilanz => $select_bilanz,
345 select_eur => $select_eur,
348 # Ausgabe des Templates
349 print($form->parse_html_template('am/edit_accounts', $parameters_ref));
352 $lxdebug->leave_sub();
356 $lxdebug->enter_sub();
358 $auth->assert('config');
362 <input name=callback type=hidden value="| . H($form->{callback}) . qq|">
365 if ((!$form->{id}) || ($form->{id} && $form->{orphaned}) || (($form->{type} eq "account") && (!$form->{new_chart_valid}))) {
367 <input type=submit class=submit name=action value="|
368 . $locale->text('Save') . qq|">
372 if ($form->{id} && $form->{orphaned}) {
373 print qq|<input type=submit class=submit name=action value="|
374 . $locale->text('Delete') . qq|">|;
377 if ($form->{id} && $form->{type} eq "account") {
379 <input class=submit type=submit name=action value="|
380 . $locale->text('Save as new') . qq|">|;
390 $lxdebug->leave_sub();
394 $lxdebug->enter_sub();
396 $auth->assert('config');
398 $form->isblank("accno", $locale->text('Account Number missing!'));
399 $form->isblank("description", $locale->text('Account Description missing!'));
401 if ($form->{charttype} eq 'A'){
402 $form->isblank("category", $locale->text('Account Type missing!'));
405 $form->redirect($locale->text('Account saved!'))
406 if (AM->save_account(\%myconfig, \%$form));
407 $form->error($locale->text('Cannot save account!'));
409 $lxdebug->leave_sub();
412 sub save_as_new_account {
413 $lxdebug->enter_sub();
415 $auth->assert('config');
417 $form->isblank("accno", $locale->text('Account Number missing!'));
418 $form->isblank("description", $locale->text('Account Description missing!'));
420 if ($form->{charttype} eq 'A'){
421 $form->isblank("category", $locale->text('Account Type missing!'));
424 for my $taxkey (0 .. 9) {
425 if ($form->{"taxkey_id_$taxkey"}) {
426 $form->{"taxkey_id_$taxkey"} = "NEW";
431 if ($form->{"original_accno"} &&
432 ($form->{"accno"} eq $form->{"original_accno"})) {
433 $form->error($locale->text('Account Number already used!'));
435 $form->redirect($locale->text('Account saved!'))
436 if (AM->save_account(\%myconfig, \%$form));
437 $form->error($locale->text('Cannot save account!'));
439 $lxdebug->leave_sub();
443 $lxdebug->enter_sub();
445 $auth->assert('config');
447 $form->{callback} = build_std_url('action=list_account');
448 my $link_edit_account = build_std_url('action=edit_account', 'callback');
450 CA->all_accounts(\%myconfig, \%$form);
452 foreach $ca (@{ $form->{CA} }) {
457 if ($ca->{amount} > 0) {
458 $ca->{credit} = $form->format_amount(\%myconfig, $ca->{amount}, 2);
460 if ($ca->{amount} < 0) {
461 $ca->{debit} = $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2);
463 $ca->{heading} = ( $ca->{charttype} eq 'H' ) ? 1:'';
464 $ca->{link_edit_account} = $link_edit_account . '&id=' . E($ca->{id});
468 my $pjx = new CGI::Ajax('list_account_details' => build_std_url('action=list_account_details'));
470 # Eneable AJAX debuging
474 push(@ { $form->{AJAX} }, $pjx);
476 $form->{stylesheets} = "list_accounts.css";
477 $form->{title} = $locale->text('Chart of Accounts');
482 my $parameters_ref = {
483 # hidden_variables => $_hidden_variables_ref,
486 # Ausgabe des Templates
487 print($form->parse_html_template('am/list_accounts', $parameters_ref));
489 $lxdebug->leave_sub();
494 sub list_account_details {
495 # Ajax Funktion aus list_account_details
496 $lxdebug->enter_sub();
498 $auth->assert('config');
500 my $chart_id = $form->{args};
502 CA->all_accounts(\%myconfig, \%$form, $chart_id);
504 foreach $ca (@{ $form->{CA} }) {
506 $ca->{debit} = " ";
507 $ca->{credit} = " ";
509 if ($ca->{amount} > 0) {
511 $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
513 if ($ca->{amount} < 0) {
515 $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2, " ");
518 my @links = split( q{:}, $ca->{link});
522 foreach my $link (@links){
523 $link = ( $link eq 'AR') ? $locale->text('Account Link AR')
524 : ( $link eq 'AP') ? $locale->text('Account Link AP')
525 : ( $link eq 'IC') ? $locale->text('Account Link IC')
526 : ( $link eq 'AR_amount' ) ? $locale->text('Account Link AR_amount')
527 : ( $link eq 'AR_paid' ) ? $locale->text('Account Link AR_paid')
528 : ( $link eq 'AR_tax' ) ? $locale->text('Account Link AR_tax')
529 : ( $link eq 'AP_amount' ) ? $locale->text('Account Link AP_amount')
530 : ( $link eq 'AP_paid' ) ? $locale->text('Account Link AP_paid')
531 : ( $link eq 'AP_tax' ) ? $locale->text('Account Link AP_tax')
532 : ( $link eq 'IC_sale' ) ? $locale->text('Account Link IC_sale')
533 : ( $link eq 'IC_cogs' ) ? $locale->text('Account Link IC_cogs')
534 : ( $link eq 'IC_taxpart' ) ? $locale->text('Account Link IC_taxpart')
535 : ( $link eq 'IC_income' ) ? $locale->text('Account Link IC_income')
536 : ( $link eq 'IC_expense' ) ? $locale->text('Account Link IC_expense')
537 : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice')
538 # : ( $link eq 'CT_tax' ) ? $locale->text('Account Link CT_tax')
539 : $locale->text('Unknown Link') . ': ' . $link;
540 $ca->{link} .= ($link ne '') ? "[$link] ":'';
543 $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
544 : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
545 : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
546 : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
547 : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
548 : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
549 : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
550 : $locale->text('Unknown Category') . ': ' . $ca->{category};
553 $form->{title} = $locale->text('Chart of Accounts');
556 print $form->parse_html_template('am/list_account_details');
558 $lxdebug->leave_sub();
563 $lxdebug->enter_sub();
565 $auth->assert('config');
567 $form->{title} = $locale->text('Delete Account');
570 qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
572 if ($form->{id} == $form->{$id}) {
573 $form->error($locale->text('Cannot delete default account!'));
577 $form->redirect($locale->text('Account deleted!'))
578 if (AM->delete_account(\%myconfig, \%$form));
579 $form->error($locale->text('Cannot delete account!'));
581 $lxdebug->leave_sub();
585 $lxdebug->enter_sub();
587 $auth->assert('config');
589 $form->{title} = "Add";
592 $form->{callback} = "am.pl?action=add_department" unless $form->{callback};
597 $lxdebug->leave_sub();
600 sub edit_department {
601 $lxdebug->enter_sub();
603 $auth->assert('config');
605 $form->{title} = "Edit";
607 AM->get_department(\%myconfig, \%$form);
612 $lxdebug->leave_sub();
615 sub list_department {
616 $lxdebug->enter_sub();
618 $auth->assert('config');
620 AM->departments(\%myconfig, \%$form);
622 $form->{callback} = "am.pl?action=list_department";
624 $callback = $form->escape($form->{callback});
626 $form->{title} = $locale->text('Departments');
628 @column_index = qw(description cost profit);
630 $column_header{description} =
631 qq|<th class=listheading width=90%>|
632 . $locale->text('Description')
634 $column_header{cost} =
635 qq|<th class=listheading nowrap>|
636 . $locale->text('Cost Center')
638 $column_header{profit} =
639 qq|<th class=listheading nowrap>|
640 . $locale->text('Profit Center')
650 <th class=listtop>$form->{title}</th>
656 <tr class=listheading>
659 map { print "$column_header{$_}\n" } @column_index;
665 foreach $ref (@{ $form->{ALL} }) {
671 <tr valign=top class=listrow$i>
674 $costcenter = ($ref->{role} eq "C") ? "X" : "";
675 $profitcenter = ($ref->{role} eq "P") ? "X" : "";
677 $column_data{description} =
678 qq|<td><a href="am.pl?action=edit_department&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
679 $column_data{cost} = qq|<td align=center>$costcenter</td>|;
680 $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
682 map { print "$column_data{$_}\n" } @column_index;
694 <td><hr size=3 noshade></td>
699 <form method=post action=am.pl>
701 <input name=callback type=hidden value="$form->{callback}">
703 <input type=hidden name=type value=department>
705 <input class=submit type=submit name=action value="|
706 . $locale->text('Add') . qq|">
714 $lxdebug->leave_sub();
717 sub department_header {
718 $lxdebug->enter_sub();
720 $auth->assert('config');
722 $form->{title} = $locale->text("$form->{title} Department");
724 # $locale->text('Add Department')
725 # $locale->text('Edit Department')
727 $form->{description} =~ s/\"/"/g;
729 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
731 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
734 qq|<input name=description size=60 value="$form->{description}">|;
737 $costcenter = "checked" if $form->{role} eq "C";
738 $profitcenter = "checked" if $form->{role} eq "P";
745 <form method=post action=am.pl>
747 <input type=hidden name=id value=$form->{id}>
748 <input type=hidden name=type value=department>
752 <th class=listtop colspan=2>$form->{title}</th>
756 <th align=right>| . $locale->text('Description') . qq|</th>
757 <td>$description</td>
761 <td><input type=radio style=radio name=role value="C" $costcenter> |
762 . $locale->text('Cost Center') . qq|
763 <input type=radio style=radio name=role value="P" $profitcenter> |
764 . $locale->text('Profit Center') . qq|
767 <td colspan=2><hr size=3 noshade></td>
772 $lxdebug->leave_sub();
775 sub save_department {
776 $lxdebug->enter_sub();
778 $auth->assert('config');
780 $form->isblank("description", $locale->text('Description missing!'));
781 AM->save_department(\%myconfig, \%$form);
782 $form->redirect($locale->text('Department saved!'));
784 $lxdebug->leave_sub();
787 sub delete_department {
788 $lxdebug->enter_sub();
790 $auth->assert('config');
792 AM->delete_department(\%myconfig, \%$form);
793 $form->redirect($locale->text('Department deleted!'));
795 $lxdebug->leave_sub();
799 $lxdebug->enter_sub();
801 $auth->assert('config');
803 $form->{title} = "Add";
805 $form->{callback} = "am.pl?action=add_lead" unless $form->{callback};
810 $lxdebug->leave_sub();
814 $lxdebug->enter_sub();
816 $auth->assert('config');
818 $form->{title} = "Edit";
820 AM->get_lead(\%myconfig, \%$form);
824 $form->{orphaned} = 1;
827 $lxdebug->leave_sub();
831 $lxdebug->enter_sub();
833 $auth->assert('config');
835 AM->lead(\%myconfig, \%$form);
837 $form->{callback} = "am.pl?action=list_lead";
839 $callback = $form->escape($form->{callback});
841 $form->{title} = $locale->text('Lead');
843 @column_index = qw(description cost profit);
845 $column_header{description} =
846 qq|<th class=listheading width=100%>|
847 . $locale->text('Description')
857 <th class=listtop>$form->{title}</th>
860 <tr class=listheading>
863 map { print "$column_header{$_}\n" } @column_index;
869 foreach $ref (@{ $form->{ALL} }) {
875 <tr valign=top class=listrow$i>
878 $lead = $ref->{lead};
880 $column_data{description} = qq|<td><a href="am.pl?action=edit_lead&id=$ref->{id}&callback=$callback">$ref->{lead}</td>|;
882 map { print "$column_data{$_}\n" } @column_index;
891 <td><hr size=3 noshade></td>
896 <form method=post action=am.pl>
898 <input name=callback type=hidden value="$form->{callback}">
900 <input type=hidden name=type value=lead>
902 <input class=submit type=submit name=action value="|
903 . $locale->text('Add') . qq|">
911 $lxdebug->leave_sub();
915 $lxdebug->enter_sub();
917 $auth->assert('config');
919 $form->{title} = $locale->text("$form->{title} Lead");
921 # $locale->text('Add Lead')
922 # $locale->text('Edit Lead')
924 $form->{description} =~ s/\"/"/g;
927 qq|<input name=description size=50 value="$form->{lead}">|;
934 <form method=post action=am.pl>
936 <input type=hidden name=id value=$form->{id}>
937 <input type=hidden name=type value=lead>
941 <th class=listtop colspan=2>$form->{title}</th>
945 <th align=right>| . $locale->text('Description') . qq|</th>
946 <td>$description</td>
948 <td colspan=2><hr size=3 noshade></td>
953 $lxdebug->leave_sub();
957 $lxdebug->enter_sub();
959 $auth->assert('config');
961 $form->isblank("description", $locale->text('Description missing!'));
962 AM->save_lead(\%myconfig, \%$form);
963 $form->redirect($locale->text('lead saved!'));
965 $lxdebug->leave_sub();
969 $lxdebug->enter_sub();
971 $auth->assert('config');
973 AM->delete_lead(\%myconfig, \%$form);
974 $form->redirect($locale->text('lead deleted!'));
976 $lxdebug->leave_sub();
980 $lxdebug->enter_sub();
982 $auth->assert('config');
984 $form->{title} = "Add";
986 $form->{callback} = "am.pl?action=add_business" unless $form->{callback};
991 $lxdebug->leave_sub();
995 $lxdebug->enter_sub();
997 $form->{title} = "Edit";
999 AM->get_business(\%myconfig, \%$form);
1003 $form->{orphaned} = 1;
1006 $lxdebug->leave_sub();
1010 $lxdebug->enter_sub();
1012 $auth->assert('config');
1014 AM->business(\%myconfig, \%$form);
1016 $form->{callback} = "am.pl?action=list_business";
1018 $callback = $form->escape($form->{callback});
1020 $form->{title} = $locale->text('Type of Business');
1022 @column_index = qw(description discount customernumberinit);
1024 $column_header{description} =
1025 qq|<th class=listheading width=60%>|
1026 . $locale->text('Description')
1028 $column_header{discount} =
1029 qq|<th class=listheading width=10%>|
1030 . $locale->text('Discount')
1032 $column_header{customernumberinit} =
1033 qq|<th class=listheading>|
1034 . $locale->text('Customernumberinit')
1044 <th class=listtop>$form->{title}</th>
1046 <tr height="5"></tr>
1050 <tr class=listheading>
1053 map { print "$column_header{$_}\n" } @column_index;
1059 foreach $ref (@{ $form->{ALL} }) {
1065 <tr valign=top class=listrow$i>
1069 $form->format_amount(\%myconfig, $ref->{discount} * 100);
1071 $ref->{description};
1072 $column_data{description} = qq|<td><a href="am.pl?action=edit_business&id=$ref->{id}&callback=$callback">$description</td>|;
1073 $column_data{discount} = qq|<td align=right>$discount</td>|;
1074 $column_data{customernumberinit} =
1075 qq|<td align=right>$ref->{customernumberinit}</td>|;
1077 map { print "$column_data{$_}\n" } @column_index;
1089 <td><hr size=3 noshade></td>
1094 <form method=post action=am.pl>
1096 <input name=callback type=hidden value="$form->{callback}">
1098 <input type=hidden name=type value=business>
1100 <input class=submit type=submit name=action value="|
1101 . $locale->text('Add') . qq|">
1109 $lxdebug->leave_sub();
1112 sub business_header {
1113 $lxdebug->enter_sub();
1115 $auth->assert('config');
1117 $form->{title} = $locale->text("$form->{title} Business");
1119 # $locale->text('Add Business')
1120 # $locale->text('Edit Business')
1122 $form->{description} =~ s/\"/"/g;
1124 $form->format_amount(\%myconfig, $form->{discount} * 100);
1131 <form method=post action=am.pl>
1133 <input type=hidden name=id value=$form->{id}>
1134 <input type=hidden name=type value=business>
1138 <th class=listtop colspan=2>$form->{title}</th>
1140 <tr height="5"></tr>
1142 <th align=right>| . $locale->text('Type of Business') . qq|</th>
1143 <td><input name=description size=30 value="$form->{description}"></td>
1146 <th align=right>| . $locale->text('Discount') . qq| %</th>
1147 <td><input name=discount size=5 value=$form->{discount}></td>
1150 <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
1151 <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
1153 <td colspan=2><hr size=3 noshade></td>
1158 $lxdebug->leave_sub();
1162 $lxdebug->enter_sub();
1164 $auth->assert('config');
1166 $form->isblank("description", $locale->text('Description missing!'));
1167 $form->{discount} = $form->parse_amount(\%myconfig, $form->{discount}) / 100;
1168 AM->save_business(\%myconfig, \%$form);
1169 $form->redirect($locale->text('Business saved!'));
1171 $lxdebug->leave_sub();
1174 sub delete_business {
1175 $lxdebug->enter_sub();
1177 $auth->assert('config');
1179 AM->delete_business(\%myconfig, \%$form);
1180 $form->redirect($locale->text('Business deleted!'));
1182 $lxdebug->leave_sub();
1186 $lxdebug->enter_sub();
1188 $auth->assert('config');
1190 $form->{title} = "Add";
1192 $form->{callback} = "am.pl?action=add_language" unless $form->{callback};
1197 $lxdebug->leave_sub();
1201 $lxdebug->enter_sub();
1203 $auth->assert('config');
1205 $form->{title} = "Edit";
1207 AM->get_language(\%myconfig, \%$form);
1211 $form->{orphaned} = 1;
1214 $lxdebug->leave_sub();
1218 $lxdebug->enter_sub();
1220 $auth->assert('config');
1222 AM->language(\%myconfig, \%$form);
1224 $form->{callback} = "am.pl?action=list_language";
1226 $callback = $form->escape($form->{callback});
1228 $form->{title} = $locale->text('Languages');
1230 @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
1232 $column_header{description} =
1233 qq|<th class=listheading width=60%>|
1234 . $locale->text('Description')
1236 $column_header{template_code} =
1237 qq|<th class=listheading width=10%>|
1238 . $locale->text('Template Code')
1240 $column_header{article_code} =
1241 qq|<th class=listheading>|
1242 . $locale->text('Article Code')
1244 $column_header{output_numberformat} =
1245 qq|<th class=listheading>|
1246 . $locale->text('Number Format')
1248 $column_header{output_dateformat} =
1249 qq|<th class=listheading>|
1250 . $locale->text('Date Format')
1252 $column_header{output_longdates} =
1253 qq|<th class=listheading>|
1254 . $locale->text('Long Dates')
1264 <th class=listtop>$form->{title}</th>
1266 <tr height="5"></tr>
1270 <tr class=listheading>
1273 map { print "$column_header{$_}\n" } @column_index;
1279 foreach $ref (@{ $form->{ALL} }) {
1285 <tr valign=top class=listrow$i>
1289 $column_data{description} =
1290 qq|<td><a href="am.pl?action=edit_language&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
1291 $column_data{template_code} = qq|<td align=right>$ref->{template_code}</td>|;
1292 $column_data{article_code} =
1293 qq|<td align=right>$ref->{article_code}</td>|;
1294 $column_data{output_numberformat} =
1296 ($ref->{output_numberformat} ? $ref->{output_numberformat} :
1297 $locale->text("use program settings")) .
1299 $column_data{output_dateformat} =
1301 ($ref->{output_dateformat} ? $ref->{output_dateformat} :
1302 $locale->text("use program settings")) .
1304 $column_data{output_longdates} =
1306 ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
1309 map { print "$column_data{$_}\n" } @column_index;
1321 <td><hr size=3 noshade></td>
1326 <form method=post action=am.pl>
1328 <input name=callback type=hidden value="$form->{callback}">
1330 <input type=hidden name=type value=language>
1332 <input class=submit type=submit name=action value="|
1333 . $locale->text('Add') . qq|">
1341 $lxdebug->leave_sub();
1344 sub language_header {
1345 $lxdebug->enter_sub();
1347 $auth->assert('config');
1349 $form->{title} = $locale->text("$form->{title} Language");
1351 # $locale->text('Add Language')
1352 # $locale->text('Edit Language')
1354 $form->{description} =~ s/\"/"/g;
1355 $form->{template_code} =~ s/\"/"/g;
1356 $form->{article_code} =~ s/\"/"/g;
1362 qq|<option value="">| . $locale->text("use program settings") .
1364 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
1366 ($item eq $form->{output_numberformat})
1367 ? "<option selected>$item"
1373 qq|<option value="">| . $locale->text("use program settings") .
1375 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
1377 ($item eq $form->{output_dateformat})
1378 ? "<option selected>$item"
1386 <form method=post action=am.pl>
1388 <input type=hidden name=id value=$form->{id}>
1389 <input type=hidden name=type value=language>
1393 <th class=listtop colspan=2>$form->{title}</th>
1395 <tr height="5"></tr>
1397 <th align=right>| . $locale->text('Language') . qq|</th>
1398 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1401 <th align=right>| . $locale->text('Template Code') . qq|</th>
1402 <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
1405 <th align=right>| . $locale->text('Article Code') . qq|</th>
1406 <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
1409 <th align=right>| . $locale->text('Number Format') . qq|</th>
1410 <td><select name="output_numberformat">$numberformat</select></td>
1413 <th align=right>| . $locale->text('Date Format') . qq|</th>
1414 <td><select name="output_dateformat">$dateformat</select></td>
1417 <th align=right>| . $locale->text('Long Dates') . qq|</th>
1418 <td><input type="radio" name="output_longdates" value="1"| .
1419 ($form->{output_longdates} ? " checked" : "") .
1420 qq|>| . $locale->text("Yes") .
1421 qq|<input type="radio" name="output_longdates" value="0"| .
1422 ($form->{output_longdates} ? "" : " checked") .
1423 qq|>| . $locale->text("No") .
1426 <td colspan=2><hr size=3 noshade></td>
1431 $lxdebug->leave_sub();
1435 $lxdebug->enter_sub();
1437 $auth->assert('config');
1439 $form->isblank("description", $locale->text('Language missing!'));
1440 $form->isblank("template_code", $locale->text('Template Code missing!'));
1441 $form->isblank("article_code", $locale->text('Article Code missing!'));
1442 AM->save_language(\%myconfig, \%$form);
1443 $form->redirect($locale->text('Language saved!'));
1445 $lxdebug->leave_sub();
1448 sub delete_language {
1449 $lxdebug->enter_sub();
1451 $auth->assert('config');
1453 AM->delete_language(\%myconfig, \%$form);
1454 $form->redirect($locale->text('Language deleted!'));
1456 $lxdebug->leave_sub();
1460 sub add_buchungsgruppe {
1461 $lxdebug->enter_sub();
1463 $auth->assert('config');
1465 # $locale->text("Add Buchungsgruppe")
1466 # $locale->text("Edit Buchungsgruppe")
1467 $form->{title} = "Add";
1469 $form->{callback} = "am.pl?action=add_buchungsgruppe" unless $form->{callback};
1471 AM->get_buchungsgruppe(\%myconfig, \%$form);
1472 $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
1473 for (my $i = 0; 4 > $i; $i++) {
1474 map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
1475 qw(income expense));
1478 &buchungsgruppe_header;
1481 $lxdebug->leave_sub();
1484 sub edit_buchungsgruppe {
1485 $lxdebug->enter_sub();
1487 $auth->assert('config');
1489 $form->{title} = "Edit";
1491 AM->get_buchungsgruppe(\%myconfig, \%$form);
1493 &buchungsgruppe_header;
1497 $lxdebug->leave_sub();
1500 sub list_buchungsgruppe {
1501 $lxdebug->enter_sub();
1503 $auth->assert('config');
1505 AM->buchungsgruppe(\%myconfig, \%$form);
1507 $form->{callback} = "am.pl?action=list_buchungsgruppe";
1509 $callback = $form->escape($form->{callback});
1511 $form->{title} = $locale->text('Buchungsgruppen');
1513 @column_index = qw(up down description inventory_accno
1514 income_accno_0 expense_accno_0
1515 income_accno_1 expense_accno_1
1516 income_accno_2 expense_accno_2
1517 income_accno_3 expense_accno_3 );
1519 $column_header{up} =
1520 qq|<th class="listheading" width="16">|
1521 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
1523 $column_header{down} =
1524 qq|<th class="listheading" width="16">|
1525 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
1527 $column_header{description} =
1528 qq|<th class="listheading" width="40%">|
1529 . $locale->text('Description')
1531 $column_header{inventory_accno} =
1532 qq|<th class=listheading>|
1533 . $locale->text('Bestandskonto')
1535 $column_header{income_accno_0} =
1536 qq|<th class=listheading>|
1537 . $locale->text('National Revenues')
1539 $column_header{expense_accno_0} =
1540 qq|<th class=listheading>|
1541 . $locale->text('National Expenses')
1543 $column_header{income_accno_1} =
1544 qq|<th class=listheading>|
1545 . $locale->text('Revenues EU with UStId')
1547 $column_header{expense_accno_1} =
1548 qq|<th class=listheading>|
1549 . $locale->text('Expenses EU with UStId')
1551 $column_header{income_accno_2} =
1552 qq|<th class=listheading>|
1553 . $locale->text('Revenues EU without UStId')
1555 $column_header{expense_accno_2} =
1556 qq|<th class=listheading>|
1557 . $locale->text('Expenses EU without UStId')
1559 $column_header{income_accno_3} =
1560 qq|<th class=listheading>|
1561 . $locale->text('Foreign Revenues')
1563 $column_header{expense_accno_3} =
1564 qq|<th class=listheading>|
1565 . $locale->text('Foreign Expenses')
1574 <th class=listtop>$form->{title}</th>
1576 <tr height="5"></tr>
1580 <tr class=listheading>
1583 map { print "$column_header{$_}\n" } @column_index;
1589 my $swap_link = qq|am.pl?action=swap_buchungsgruppen&|;
1592 foreach $ref (@{ $form->{ALL} }) {
1598 <tr valign=top class=listrow$i>
1602 my $pref = $form->{ALL}->[$row - 1];
1604 qq|<td align="center" valign="center" width="16">| .
1605 qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
1606 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
1609 $column_data{up} = qq|<td width="16"> </td>|;
1612 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
1613 $column_data{down} = qq|<td width="16"> </td>|;
1615 my $nref = $form->{ALL}->[$row + 1];
1616 $column_data{down} =
1617 qq|<td align="center" valign="center" width="16">| .
1618 qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
1619 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
1623 $column_data{description} = qq|<td><a href="am.pl?action=edit_buchungsgruppe&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
1624 $column_data{inventory_accno} = qq|<td align=right>$ref->{inventory_accno}</td>|;
1625 $column_data{income_accno_0} =
1626 qq|<td align=right>$ref->{income_accno_0}</td>|;
1627 $column_data{expense_accno_0} = qq|<td align=right>$ref->{expense_accno_0}</td>|;
1628 $column_data{income_accno_1} =
1629 qq|<td align=right>$ref->{income_accno_1}</td>|;
1630 $column_data{expense_accno_1} = qq|<td align=right>$ref->{expense_accno_1}</td>|;
1631 $column_data{income_accno_2} =
1632 qq|<td align=right>$ref->{income_accno_2}</td>|;
1633 $column_data{expense_accno_2} = qq|<td align=right>$ref->{expense_accno_2}</td>|;
1634 $column_data{income_accno_3} =
1635 qq|<td align=right>$ref->{income_accno_3}</td>|;
1636 $column_data{expense_accno_3} = qq|<td align=right>$ref->{expense_accno_3}</td>|;
1638 map { print "$column_data{$_}\n" } @column_index;
1652 <td><hr size=3 noshade></td>
1657 <form method=post action=am.pl>
1659 <input name=callback type=hidden value="$form->{callback}">
1661 <input type=hidden name=type value=buchungsgruppe>
1663 <input class=submit type=submit name=action value="|
1664 . $locale->text('Add') . qq|">
1672 $lxdebug->leave_sub();
1675 sub buchungsgruppe_header {
1676 $lxdebug->enter_sub();
1678 $auth->assert('config');
1680 $form->{title} = $locale->text("$form->{title} Buchungsgruppe");
1682 # $locale->text('Add Accounting Group')
1683 # $locale->text('Edit Accounting Group')
1685 my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
1686 my %acc_type_map = (
1687 "IC" => $acc_inventory,
1688 "IC_income" => $acc_income,
1689 "IC_sale" => $acc_income,
1690 "IC_expense" => $acc_expense,
1691 "IC_cogs" => $acc_expense,
1694 foreach $key (keys(%acc_type_map)) {
1695 foreach $ref (@{ $form->{IC_links}{$key} }) {
1696 $acc_type_map{$key}->{$ref->{"id"}} = $ref;
1700 foreach my $type (qw(IC IC_income IC_expense)) {
1701 $form->{"select$type"} =
1703 map({ "<option value=$_->{id} $_->{selected}>" .
1704 "$_->{accno}--" . H($_->{description}) . "</option>" }
1705 sort({ $a->{"accno"} cmp $b->{"accno"} }
1706 values(%{$acc_type_map{$type}}))));
1710 $form->{selectIC} =~ s/selected//g;
1711 $form->{selectIC} =~ s/ value=\Q$form->{inventory_accno_id}\E/ value=$form->{inventory_accno_id} selected/;
1712 $form->{selectIC_income} =~ s/selected//g;
1713 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_0}\E/ value=$form->{income_accno_id_0} selected/;
1714 $form->{selectIC_expense} =~ s/selected//g;
1715 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_0}\E/ value=$form->{expense_accno_id_0} selected/;
1721 <th align=right>| . $locale->text('Inventory') . qq|</th>
1722 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
1723 <input name=selectIC type=hidden value="$form->{selectIC}">
1727 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
1731 $linkaccounts .= qq|
1733 <th align=right>| . $locale->text('National Revenues') . qq|</th>
1734 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
1737 <th align=right>| . $locale->text('National Expenses') . qq|</th>
1738 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
1741 $form->{selectIC_income} =~ s/selected//g;
1742 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_1}\E/ value=$form->{income_accno_id_1} selected/;
1743 $form->{selectIC_expense} =~ s/selected//g;
1744 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_1}\E/ value=$form->{expense_accno_id_1} selected/;
1746 $linkaccounts .= qq| <tr>
1747 <th align=right>| . $locale->text('Revenues EU with UStId') . qq|</th>
1748 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
1751 <th align=right>| . $locale->text('Expenses EU with UStId') . qq|</th>
1752 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
1756 $form->{selectIC_income} =~ s/selected//g;
1757 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_2}\E/ value=$form->{income_accno_id_2} selected/;
1758 $form->{selectIC_expense} =~ s/selected//g;
1759 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_2}\E/ value=$form->{expense_accno_id_2} selected/;
1762 $linkaccounts .= qq| <tr>
1763 <th align=right>| . $locale->text('Revenues EU without UStId') . qq|</th>
1764 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
1767 <th align=right>| . $locale->text('Expenses EU without UStId') . qq|</th>
1768 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
1772 $form->{selectIC_income} =~ s/selected//g;
1773 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_3}\E/ value=$form->{income_accno_id_3} selected/;
1774 $form->{selectIC_expense} =~ s/selected//g;
1775 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_3}\E/ value=$form->{expense_accno_id_3} selected/;
1778 $linkaccounts .= qq| <tr>
1779 <th align=right>| . $locale->text('Foreign Revenues') . qq|</th>
1780 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
1783 <th align=right>| . $locale->text('Foreign Expenses') . qq|</th>
1784 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
1794 <form method=post action=am.pl>
1796 <input type=hidden name=id value=$form->{id}>
1797 <input type=hidden name=type value=buchungsgruppe>
1801 <th class=listtop colspan=2>$form->{title}</th>
1803 <tr height="5"></tr>
1805 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
1806 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1809 <td colspan=2><hr size=3 noshade></td>
1814 $lxdebug->leave_sub();
1817 sub save_buchungsgruppe {
1818 $lxdebug->enter_sub();
1820 $auth->assert('config');
1822 $form->isblank("description", $locale->text('Description missing!'));
1824 AM->save_buchungsgruppe(\%myconfig, \%$form);
1825 $form->redirect($locale->text('Accounting Group saved!'));
1827 $lxdebug->leave_sub();
1830 sub delete_buchungsgruppe {
1831 $lxdebug->enter_sub();
1833 $auth->assert('config');
1835 AM->delete_buchungsgruppe(\%myconfig, \%$form);
1836 $form->redirect($locale->text('Accounting Group deleted!'));
1838 $lxdebug->leave_sub();
1841 sub swap_buchungsgruppen {
1842 $lxdebug->enter_sub();
1844 $auth->assert('config');
1846 AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
1847 list_buchungsgruppe();
1849 $lxdebug->leave_sub();
1854 $lxdebug->enter_sub();
1856 $auth->assert('config');
1858 $form->{title} = "Add";
1860 $form->{callback} = "am.pl?action=add_printer" unless $form->{callback};
1865 $lxdebug->leave_sub();
1869 $lxdebug->enter_sub();
1871 $auth->assert('config');
1873 $form->{title} = "Edit";
1875 AM->get_printer(\%myconfig, \%$form);
1879 $form->{orphaned} = 1;
1882 $lxdebug->leave_sub();
1886 $lxdebug->enter_sub();
1888 $auth->assert('config');
1890 AM->printer(\%myconfig, \%$form);
1892 $form->{callback} = "am.pl?action=list_printer";
1894 $callback = $form->escape($form->{callback});
1896 $form->{title} = $locale->text('Printer');
1898 @column_index = qw(printer_description printer_command template_code);
1900 $column_header{printer_description} =
1901 qq|<th class=listheading width=60%>|
1902 . $locale->text('Printer Description')
1904 $column_header{printer_command} =
1905 qq|<th class=listheading width=10%>|
1906 . $locale->text('Printer Command')
1908 $column_header{template_code} =
1909 qq|<th class=listheading>|
1910 . $locale->text('Template Code')
1920 <th class=listtop>$form->{title}</th>
1922 <tr height="5"></tr>
1926 <tr class=listheading>
1929 map { print "$column_header{$_}\n" } @column_index;
1935 foreach $ref (@{ $form->{ALL} }) {
1941 <tr valign=top class=listrow$i>
1945 $column_data{printer_description} = qq|<td><a href="am.pl?action=edit_printer&id=$ref->{id}&callback=$callback">$ref->{printer_description}</td>|;
1946 $column_data{printer_command} = qq|<td align=right>$ref->{printer_command}</td>|;
1947 $column_data{template_code} =
1948 qq|<td align=right>$ref->{template_code}</td>|;
1950 map { print "$column_data{$_}\n" } @column_index;
1962 <td><hr size=3 noshade></td>
1967 <form method=post action=am.pl>
1969 <input name=callback type=hidden value="$form->{callback}">
1971 <input type=hidden name=type value=printer>
1973 <input class=submit type=submit name=action value="|
1974 . $locale->text('Add') . qq|">
1982 $lxdebug->leave_sub();
1985 sub printer_header {
1986 $lxdebug->enter_sub();
1988 $auth->assert('config');
1990 $form->{title} = $locale->text("$form->{title} Printer");
1992 # $locale->text('Add Printer')
1993 # $locale->text('Edit Printer')
1995 $form->{printer_description} =~ s/\"/"/g;
1996 $form->{template_code} =~ s/\"/"/g;
1997 $form->{printer_command} =~ s/\"/"/g;
2005 <form method=post action=am.pl>
2007 <input type=hidden name=id value=$form->{id}>
2008 <input type=hidden name=type value=printer>
2012 <th class=listtop colspan=2>$form->{title}</th>
2014 <tr height="5"></tr>
2016 <th align=right>| . $locale->text('Printer') . qq|</th>
2017 <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
2020 <th align=right>| . $locale->text('Printer Command') . qq|</th>
2021 <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
2024 <th align=right>| . $locale->text('Template Code') . qq|</th>
2025 <td><input name=template_code size=5 value="$form->{template_code}"></td>
2027 <td colspan=2><hr size=3 noshade></td>
2032 $lxdebug->leave_sub();
2036 $lxdebug->enter_sub();
2038 $auth->assert('config');
2040 $form->isblank("printer_description", $locale->text('Description missing!'));
2041 $form->isblank("printer_command", $locale->text('Printer Command missing!'));
2042 AM->save_printer(\%myconfig, \%$form);
2043 $form->redirect($locale->text('Printer saved!'));
2045 $lxdebug->leave_sub();
2048 sub delete_printer {
2049 $lxdebug->enter_sub();
2051 $auth->assert('config');
2053 AM->delete_printer(\%myconfig, \%$form);
2054 $form->redirect($locale->text('Printer deleted!'));
2056 $lxdebug->leave_sub();
2060 $lxdebug->enter_sub();
2062 $auth->assert('config');
2064 $form->{title} = "Add";
2066 $form->{callback} = "am.pl?action=add_payment" unless $form->{callback};
2068 $form->{terms_netto} = 0;
2069 $form->{terms_skonto} = 0;
2070 $form->{percent_skonto} = 0;
2071 my @languages = AM->language(\%myconfig, $form, 1);
2072 map({ $_->{"language"} = $_->{"description"};
2073 $_->{"language_id"} = $_->{"id"}; } @languages);
2074 $form->{"TRANSLATION"} = \@languages;
2078 $lxdebug->leave_sub();
2082 $lxdebug->enter_sub();
2084 $auth->assert('config');
2086 $form->{title} = "Edit";
2088 AM->get_payment(\%myconfig, $form);
2089 $form->{percent_skonto} =
2090 $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
2094 $form->{orphaned} = 1;
2097 $lxdebug->leave_sub();
2101 $lxdebug->enter_sub();
2103 $auth->assert('config');
2105 AM->payment(\%myconfig, \%$form);
2107 $form->{callback} = build_std_url("action=list_payment");
2109 $callback = $form->escape($form->{callback});
2111 $form->{title} = $locale->text('Payment Terms');
2113 @column_index = qw(up down description description_long terms_netto
2114 terms_skonto percent_skonto);
2116 $column_header{up} =
2117 qq|<th class="listheading" align="center" valign="center" width="16">|
2118 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
2120 $column_header{down} =
2121 qq|<th class="listheading" align="center" valign="center" width="16">|
2122 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
2124 $column_header{description} =
2125 qq|<th class=listheading>|
2126 . $locale->text('Description')
2128 $column_header{description_long} =
2129 qq|<th class=listheading>|
2130 . $locale->text('Long Description')
2132 $column_header{terms_netto} =
2133 qq|<th class=listheading>|
2134 . $locale->text('Netto Terms')
2136 $column_header{terms_skonto} =
2137 qq|<th class=listheading>|
2138 . $locale->text('Skonto Terms')
2140 $column_header{percent_skonto} =
2141 qq|<th class=listheading>|
2142 . $locale->text('Skonto')
2152 <th class=listtop>$form->{title}</th>
2154 <tr height="5"></tr>
2158 <tr class=listheading>
2161 map { print "$column_header{$_}\n" } @column_index;
2167 my $swap_link = build_std_url("action=swap_payment_terms");
2170 foreach $ref (@{ $form->{ALL} }) {
2176 <tr valign=top class=listrow$i>
2180 my $pref = $form->{ALL}->[$row - 1];
2182 qq|<td align="center" valign="center" width="16">| .
2183 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
2184 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
2187 $column_data{up} = qq|<td width="16"> </td>|;
2190 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
2191 $column_data{down} = qq|<td width="16"> </td>|;
2193 my $nref = $form->{ALL}->[$row + 1];
2194 $column_data{down} =
2195 qq|<td align="center" valign="center" width="16">| .
2196 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
2197 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
2201 $column_data{description} =
2203 build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
2204 qq|">| . H($ref->{description}) . qq|</a></td>|;
2205 $column_data{description_long} =
2206 qq|<td>| . H($ref->{description_long}) . qq|</td>|;
2207 $column_data{terms_netto} =
2208 qq|<td align=right>$ref->{terms_netto}</td>|;
2209 $column_data{terms_skonto} =
2210 qq|<td align=right>$ref->{terms_skonto}</td>|;
2211 $column_data{percent_skonto} =
2212 qq|<td align=right>| .
2213 $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
2215 map { print "$column_data{$_}\n" } @column_index;
2228 <td><hr size=3 noshade></td>
2233 <form method=post action=am.pl>
2235 <input name=callback type=hidden value="$form->{callback}">
2237 <input type=hidden name=type value=payment>
2239 <input class=submit type=submit name=action value="|
2240 . $locale->text('Add') . qq|">
2248 $lxdebug->leave_sub();
2251 sub payment_header {
2252 $lxdebug->enter_sub();
2254 $auth->assert('config');
2256 $form->{title} = $locale->text("$form->{title} Payment Terms");
2258 # $locale->text('Add Payment Terms')
2259 # $locale->text('Edit Payment Terms')
2261 $form->{description} =~ s/\"/"/g;
2270 <form method=post action=am.pl>
2272 <input type=hidden name=id value=$form->{id}>
2273 <input type=hidden name=type value=payment>
2277 <th class=listtop colspan=2>$form->{title}</th>
2279 <tr height="5"></tr>
2281 <th align=right>| . $locale->text('Description') . qq|</th>
2282 <td><input name=description size=30 value="$form->{description}"></td>
2285 <th align=right>| . $locale->text('Long Description') . qq|</th>
2286 <td><input name=description_long size=50 value="$form->{description_long}"></td>
2290 foreach my $language (@{ $form->{"TRANSLATION"} }) {
2293 <th align="right">| .
2294 sprintf($locale->text('Translation (%s)'),
2295 $language->{"language"})
2297 <td><input name="description_long_$language->{language_id}" size="50"
2298 value="| . Q($language->{"description_long"}) . qq|"></td>
2305 <th align=right>| . $locale->text('Netto Terms') . qq|</th>
2306 <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
2309 <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
2310 <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
2313 <th align=right>| . $locale->text('Skonto') . qq| %</th>
2314 <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
2316 <td colspan=2><hr size=3 noshade></td>
2320 <p>| . $locale->text("You can use the following strings in the long " .
2321 "description and all translations. They will be " .
2322 "replaced by their actual values by Lx-Office " .
2323 "before they're output.")
2327 <li>| . $locale->text("<%netto_date%> -- Date the payment is due in " .
2330 <li>| . $locale->text("<%skonto_date%> -- Date the payment is due " .
2333 <li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
2335 <li>| . $locale->text("<%total%> -- Amount payable")
2337 <li>| . $locale->text("<%total_wo_skonto%> -- Amount payable less discount")
2339 <li>| . $locale->text("<%invtotal%> -- Invoice total")
2341 <li>| . $locale->text("<%invtotal_wo_skonto%> -- Invoice total less discount")
2343 <li>| . $locale->text("<%currency%> -- The selected currency")
2345 <li>| . $locale->text("<%terms_netto%> -- The number of days for " .
2348 <li>| . $locale->text("<%account_number%> -- Your account number")
2350 <li>| . $locale->text("<%bank%> -- Your bank")
2352 <li>| . $locale->text("<%bank_code%> -- Your bank code")
2356 $lxdebug->leave_sub();
2360 $lxdebug->enter_sub();
2362 $auth->assert('config');
2364 $form->isblank("description", $locale->text('Description missing!'));
2365 $form->{"percent_skonto"} =
2366 $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
2367 AM->save_payment(\%myconfig, \%$form);
2368 $form->redirect($locale->text('Payment Terms saved!'));
2370 $lxdebug->leave_sub();
2373 sub delete_payment {
2374 $lxdebug->enter_sub();
2376 $auth->assert('config');
2378 AM->delete_payment(\%myconfig, \%$form);
2379 $form->redirect($locale->text('Payment terms deleted!'));
2381 $lxdebug->leave_sub();
2384 sub swap_payment_terms {
2385 $lxdebug->enter_sub();
2387 $auth->assert('config');
2389 AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
2392 $lxdebug->leave_sub();
2396 $lxdebug->enter_sub();
2398 # get defaults for account numbers and last numbers
2399 AM->defaultaccounts(\%myconfig, \%$form);
2400 $form->{ALL_UNITS} = AM->convertible_units(AM->retrieve_all_units(), 'g');
2402 map { $form->{"defaults_${_}"} = $form->{defaults}->{$_} } keys %{ $form->{defaults} };
2404 foreach $key (keys %{ $form->{IC} }) {
2405 foreach $accno (sort keys %{ $form->{IC}->{$key} }) {
2406 my $array = "ACCNOS_" . uc($key);
2407 $form->{$array} ||= [];
2409 my $value = "${accno}--" . $form->{IC}->{$key}->{$accno}->{description};
2410 push @{ $form->{$array} }, {
2413 'selected' => $form->{IC}->{$key}->{$accno}->{id} == $form->{defaults}->{$key},
2418 $form->{title} = $locale->text('Ranges of numbers and default accounts');
2421 print $form->parse_html_template('am/edit_defaults');
2423 $lxdebug->leave_sub();
2427 $lxdebug->enter_sub();
2429 AM->save_defaults();
2431 $form->redirect($locale->text('Defaults saved.'));
2433 $lxdebug->leave_sub();
2436 sub _build_cfg_options {
2438 my $array = uc($idx) . 'S';
2440 $form->{$array} = [];
2441 foreach my $item (@_) {
2442 push @{ $form->{$array} }, {
2445 'selected' => $item eq $myconfig{$idx},
2451 $lxdebug->enter_sub();
2453 _build_cfg_options('dateformat', qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd));
2454 _build_cfg_options('numberformat', qw(1,000.00 1000.00 1.000,00 1000,00));
2457 if ($opendocument_templates && $openofficeorg_writer_bin &&
2458 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
2459 push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
2460 "value" => "opendocument_pdf" });
2462 if ($latex_templates) {
2463 push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
2465 push(@formats, { "name" => "HTML", "value" => "html" });
2466 if ($latex_templates) {
2467 push(@formats, { "name" => $locale->text("Postscript"),
2468 "value" => "postscript" });
2470 if ($opendocument_templates) {
2471 push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
2472 "value" => "opendocument" });
2475 if (!$myconfig{"template_format"}) {
2476 $myconfig{"template_format"} = "pdf";
2478 $form->{TEMPLATE_FORMATS} = [];
2479 foreach $item (@formats) {
2480 push @{ $form->{TEMPLATE_FORMATS} }, {
2481 'name' => $item->{name},
2482 'value' => $item->{value},
2483 'selected' => $item->{value} eq $myconfig{template_format},
2487 if (!$myconfig{"default_media"}) {
2488 $myconfig{"default_media"} = "screen";
2491 my %selected = ($myconfig{"default_media"} => "selected");
2493 { 'name' => $locale->text('Screen'), 'value' => 'screen', 'selected' => $selected{screen}, },
2494 { 'name' => $locale->text('Printer'), 'value' => 'printer', 'selected' => $selected{printer}, },
2495 { 'name' => $locale->text('Queue'), 'value' => 'queue', 'selected' => $selected{queue}, },
2498 AM->printer(\%myconfig, $form);
2500 $form->{PRINTERS} = [];
2501 foreach my $printer (@{$form->{"ALL"}}) {
2502 push @{ $form->{PRINTERS} }, {
2503 'name' => $printer->{printer_description},
2504 'value' => $printer->{id},
2505 'selected' => $printer->{id} == $myconfig{default_printer_id},
2509 %countrycodes = User->country_codes;
2511 $form->{COUNTRYCODES} = [];
2512 foreach $countrycode (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
2513 push @{ $form->{COUNTRYCODES} }, {
2514 'name' => $countrycodes{$countrycode},
2515 'value' => $countrycode,
2516 'selected' => $countrycode eq $myconfig{countrycode},
2520 $form->{STYLESHEETS} = [];
2521 foreach $item (qw(lx-office-erp.css Win2000.css)) {
2522 push @{ $form->{STYLESHEETS} }, {
2525 'selected' => $item eq $myconfig{stylesheet},
2529 $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details}));
2530 $form->{CAN_CHANGE_PASSWORD} = $auth->can_change_password();
2531 $form->{todo_cfg} = { TODO->get_user_config('login' => $form->{login}) };
2533 $form->{title} = $locale->text('Edit Preferences for #1', $form->{login});
2536 print $form->parse_html_template('am/config');
2538 $lxdebug->leave_sub();
2541 sub save_preferences {
2542 $lxdebug->enter_sub();
2544 $form->{stylesheet} = $form->{usestylesheet};
2546 TODO->save_user_config('login' => $form->{login}, %{ $form->{todo_cfg} || { } });
2548 $form->redirect($locale->text('Preferences saved!')) if (AM->save_preferences(\%myconfig, \%$form, 0));
2549 $form->error($locale->text('Cannot save preferences!'));
2551 $lxdebug->leave_sub();
2555 $lxdebug->enter_sub();
2557 $auth->assert('config');
2559 $form->{title} = $locale->text('Audit Control');
2561 AM->closedto(\%myconfig, \%$form);
2568 <form method=post action=am.pl>
2571 <tr><th class=listtop>$form->{title}</th></tr>
2572 <tr height="5"></tr>
2577 <th>| . $locale->text('Close Books up to') . qq|</th>
2578 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
2588 <input type=hidden name=nextsub value=doclose>
2590 <input type=submit class=submit name=action value="|
2591 . $locale->text('Continue') . qq|">
2599 $lxdebug->leave_sub();
2603 $lxdebug->enter_sub();
2605 $auth->assert('config');
2607 AM->closebooks(\%myconfig, \%$form);
2609 if ($form->{closedto}) {
2611 $locale->text('Books closed up to') . " "
2612 . $locale->date(\%myconfig, $form->{closedto}, 1));
2614 $form->redirect($locale->text('Books are open'));
2617 $lxdebug->leave_sub();
2621 $lxdebug->enter_sub();
2623 $auth->assert('config');
2625 $units = AM->retrieve_units(\%myconfig, $form, "resolved_");
2626 AM->units_in_use(\%myconfig, $form, $units);
2627 map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
2629 @languages = AM->language(\%myconfig, $form, 1);
2631 @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units}));
2634 foreach (@unit_list) {
2635 $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"});
2636 $_->{"UNITLANGUAGES"} = [];
2637 foreach my $lang (@languages) {
2638 push(@{ $_->{"UNITLANGUAGES"} },
2640 "unit" => $_->{"name"},
2641 "language_id" => $lang->{"id"},
2642 "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
2643 "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
2649 $units = AM->retrieve_units(\%myconfig, $form);
2650 $ddbox = AM->unit_select_data($units, undef, 1);
2652 my $updownlink = build_std_url("action=swap_units");
2654 $form->{"title"} = $locale->text("Add and edit units");
2656 print($form->parse_html_template("am/edit_units",
2657 { "UNITS" => \@unit_list,
2658 "NEW_BASE_UNIT_DDBOX" => $ddbox,
2659 "LANGUAGES" => \@languages,
2660 "updownlink" => $updownlink }));
2662 $lxdebug->leave_sub();
2666 $lxdebug->enter_sub();
2668 $auth->assert('config');
2670 $form->isblank("new_name", $locale->text("The name is missing."));
2671 $units = AM->retrieve_units(\%myconfig, $form);
2672 $all_units = AM->retrieve_units(\%myconfig, $form);
2673 $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
2675 my ($base_unit, $factor);
2676 if ($form->{"new_base_unit"}) {
2677 $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
2679 $form->isblank("new_factor", $locale->text("The factor is missing."));
2680 $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
2681 $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
2682 $base_unit = $form->{"new_base_unit"};
2686 foreach my $lang (AM->language(\%myconfig, $form, 1)) {
2687 next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
2688 push(@languages, { "id" => $lang->{"id"},
2689 "localized" => $form->{"new_localized_$lang->{id}"},
2690 "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
2694 AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, \@languages);
2696 $form->{"saved_message"} = $locale->text("The unit has been saved.");
2700 $lxdebug->leave_sub();
2703 sub set_unit_languages {
2704 $lxdebug->enter_sub();
2706 $auth->assert('config');
2708 my ($unit, $languages, $idx) = @_;
2710 $unit->{"LANGUAGES"} = [];
2712 foreach my $lang (@{$languages}) {
2713 push(@{ $unit->{"LANGUAGES"} },
2714 { "id" => $lang->{"id"},
2715 "localized" => $form->{"localized_${idx}_$lang->{id}"},
2716 "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
2720 $lxdebug->leave_sub();
2724 $lxdebug->enter_sub();
2726 $auth->assert('config');
2728 $old_units = AM->retrieve_units(\%myconfig, $form, "resolved_");
2729 AM->units_in_use(\%myconfig, $form, $old_units);
2731 @languages = AM->language(\%myconfig, $form, 1);
2735 foreach $i (1..($form->{"rowcount"} * 1)) {
2736 $old_unit = $old_units->{$form->{"old_name_$i"}};
2738 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
2741 if ($form->{"unchangeable_$i"}) {
2742 $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
2743 $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
2744 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2748 if ($old_unit->{"in_use"}) {
2749 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
2752 if ($form->{"delete_$i"}) {
2753 push(@delete_units, $old_unit->{"name"});
2757 $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
2759 $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
2760 my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
2761 $new_units->{$form->{"name_$i"}} = \%h;
2762 $new_units->{$form->{"name_$i"}}->{"row"} = $i;
2763 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2766 foreach $unit (values(%{$new_units})) {
2767 next unless ($unit->{"old_name"});
2768 if ($unit->{"base_unit"}) {
2769 $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"}))
2770 unless (defined($new_units->{$unit->{"base_unit"}}));
2771 $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
2772 $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
2774 $unit->{"base_unit"} = undef;
2775 $unit->{"factor"} = undef;
2779 foreach $unit (values(%{$new_units})) {
2780 next if ($unit->{"unchanged_unit"});
2782 map({ $_->{"seen"} = 0; } values(%{$new_units}));
2784 while ($new_unit->{"base_unit"}) {
2785 $new_unit->{"seen"} = 1;
2786 $new_unit = $new_units->{$new_unit->{"base_unit"}};
2787 if ($new_unit->{"seen"}) {
2788 $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, " .
2789 "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
2794 AM->save_units(\%myconfig, $form, $new_units, \@delete_units);
2796 $form->{"saved_message"} = $locale->text("The units have been saved.");
2800 $lxdebug->leave_sub();
2803 sub show_history_search {
2804 $lxdebug->enter_sub();
2806 $auth->assert('config');
2808 $form->{title} = $locale->text("History Search");
2811 print $form->parse_html_template("common/search_history");
2813 $lxdebug->leave_sub();
2816 sub show_am_history {
2817 $lxdebug->enter_sub();
2819 $auth->assert('config');
2821 my $callback = build_std_url(qw(action einschraenkungen fromdate todate mitarbeiter searchid what2search));
2822 $form->{order} ||= 'h.itime--1';
2824 my %search = ( "Artikelnummer" => "parts",
2825 "Kundennummer" => "customer",
2826 "Lieferantennummer" => "vendor",
2827 "Projektnummer" => "project",
2828 "Buchungsnummer" => "oe",
2829 "Eingangsrechnungnummer" => "ap",
2830 "Ausgangsrechnungnummer" => "ar",
2831 "Mahnungsnummer" => "dunning"
2833 my %searchNo = ( "Artikelnummer" => "partnumber",
2834 "Kundennummer" => "customernumber",
2835 "Lieferantennummer" => "vendornumber",
2836 "Projektnummer" => "projectnummer",
2837 "Buchungsnummer" => "ordnumber",
2838 "Eingangsrechnungnummer" => "invnumber",
2839 "Ausgangsrechnungnummer" => "invnumber",
2840 "Mahnungsnummer" => "dunning_id"
2843 my $dbh = $form->dbconnect(\%myconfig);
2845 my $restriction = qq| AND (| . join(' OR ', map { " addition = " . $dbh->quote($_) } split(m/\,/, $form->{einschraenkungen})) . qq|)| if $form->{einschraenkungen};
2846 $restriction .= qq| AND h.itime::date >= | . conv_dateq($form->{fromdate}) if $form->{fromdate};
2847 $restriction .= qq| AND h.itime::date <= | . conv_dateq($form->{todate}) if $form->{todate};
2848 if ($form->{mitarbeiter} =~ m/^\d+$/) {
2849 $restriction .= qq| AND employee_id = | . $form->{mitarbeiter};
2850 } elsif ($form->{mitarbeiter}) {
2851 $restriction .= qq| AND employee_id = (SELECT id FROM employee WHERE name ILIKE | . $dbh->quote('%' . $form->{mitarbeiter} . '%') . qq|)|;
2854 my $query = qq|SELECT trans_id AS id FROM history_erp | .
2855 ( $form->{'searchid'} ? qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'|
2856 : qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
2858 my @ids = grep { $_ * 1 } selectall_array_query($form, $dbh, $query);
2859 my $daten .= shift @ids;
2860 $daten .= join '', map { " OR trans_id = $_" } @ids;
2862 my ($sort, $sortby) = split(/\-\-/, $form->{order});
2863 $sort =~ s/.*\.(.*)$/$1/;
2865 $form->{title} = $locale->text("History Search");
2868 print $form->parse_html_template("common/show_history",
2869 { "DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}),
2870 "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
2873 uc($sort) . "BY" => $sortby,
2874 'callback' => $callback,
2878 $lxdebug->leave_sub();
2882 $lxdebug->enter_sub();
2884 $auth->assert('config');
2886 my $dir = $form->{"dir"} eq "down" ? "down" : "up";
2887 AM->swap_units(\%myconfig, $form, $dir, $form->{"name"});
2891 $lxdebug->leave_sub();
2895 $lxdebug->enter_sub();
2897 $auth->assert('config');
2899 $form->{title} = $locale->text('Add');
2901 $form->{callback} ||= "am.pl?action=add_tax";
2903 _get_taxaccount_selection();
2907 my $parameters_ref = {
2908 # ChartTypeIsAccount => $ChartTypeIsAccount,
2911 # Ausgabe des Templates
2912 print($form->parse_html_template('am/edit_tax', $parameters_ref));
2914 $lxdebug->leave_sub();
2918 $lxdebug->enter_sub();
2920 $auth->assert('config');
2922 $form->{title} = $locale->text('Edit');
2924 AM->get_tax(\%myconfig, \%$form);
2925 _get_taxaccount_selection();
2927 $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
2931 my $parameters_ref = {
2934 # Ausgabe des Templates
2935 print($form->parse_html_template('am/edit_tax', $parameters_ref));
2937 $lxdebug->leave_sub();
2941 $lxdebug->enter_sub();
2943 $auth->assert('config');
2945 AM->taxes(\%myconfig, \%$form);
2947 map { $_->{rate} = $form->format_amount(\%myconfig, $_->{rate}, 2) } @{ $form->{TAX} };
2949 $form->{callback} = build_std_url('action=list_tax');
2951 $form->{title} = $locale->text('Tax-O-Matic');
2955 # Ausgabe des Templates
2956 print($form->parse_html_template('am/list_tax', $parameters_ref));
2958 $lxdebug->leave_sub();
2961 sub _get_taxaccount_selection{
2962 $lxdebug->enter_sub();
2964 $auth->assert('config');
2966 AM->get_tax_accounts(\%myconfig, \%$form);
2968 map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} };
2970 $lxdebug->leave_sub();
2974 $lxdebug->enter_sub();
2976 $auth->assert('config');
2978 $form->isblank("rate", $locale->text('Taxrate missing!'));
2979 $form->isblank("taxdescription", $locale->text('Taxdescription missing!'));
2980 $form->isblank("taxkey", $locale->text('Taxkey missing!'));
2982 $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate});
2984 if ( $form->{rate} < 0 || $form->{rate} >= 100 ) {
2985 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
2988 if ( $form->{rate} <= 0.99 && $form->{rate} > 0 ) {
2989 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
2992 AM->save_tax(\%myconfig, \%$form);
2993 $form->redirect($locale->text('Tax saved!'));
2995 $lxdebug->leave_sub();
2999 $lxdebug->enter_sub();
3001 $auth->assert('config');
3003 AM->delete_tax(\%myconfig, \%$form);
3004 $form->redirect($locale->text('Tax deleted!'));
3006 $lxdebug->leave_sub();
3009 sub add_price_factor {
3010 $lxdebug->enter_sub();
3012 $auth->assert('config');
3014 $form->{title} = $locale->text('Add Price Factor');
3015 $form->{callback} ||= build_std_url('action=add_price_factor');
3016 $form->{fokus} = 'description';
3019 print $form->parse_html_template('am/edit_price_factor');
3021 $lxdebug->leave_sub();
3024 sub edit_price_factor {
3025 $lxdebug->enter_sub();
3027 $auth->assert('config');
3029 $form->{title} = $locale->text('Edit Price Factor');
3030 $form->{callback} ||= build_std_url('action=add_price_factor');
3031 $form->{fokus} = 'description';
3033 AM->get_price_factor(\%myconfig, $form);
3035 $form->{factor} = $form->format_amount(\%myconfig, $form->{factor} * 1);
3038 print $form->parse_html_template('am/edit_price_factor');
3040 $lxdebug->leave_sub();
3043 sub list_price_factors {
3044 $lxdebug->enter_sub();
3046 $auth->assert('config');
3048 AM->get_all_price_factors(\%myconfig, \%$form);
3051 foreach my $current (@{ $form->{PRICE_FACTORS} }) {
3053 $previous->{next_id} = $current->{id};
3054 $current->{previous_id} = $previous->{id};
3057 $current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1);
3059 $previous = $current;
3062 $form->{callback} = build_std_url('action=list_price_factors');
3063 $form->{title} = $locale->text('Price Factors');
3064 $form->{url_base} = build_std_url('callback');
3067 print $form->parse_html_template('am/list_price_factors');
3069 $lxdebug->leave_sub();
3072 sub save_price_factor {
3073 $lxdebug->enter_sub();
3075 $auth->assert('config');
3077 $form->isblank("description", $locale->text('Description missing!'));
3078 $form->isblank("factor", $locale->text('Factor missing!'));
3080 $form->{factor} = $form->parse_amount(\%myconfig, $form->{factor});
3082 AM->save_price_factor(\%myconfig, $form);
3084 $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor saved!')) if ($form->{callback});
3086 $form->redirect($locale->text('Price factor saved!'));
3088 $lxdebug->leave_sub();
3091 sub delete_price_factor {
3092 $lxdebug->enter_sub();
3094 $auth->assert('config');
3096 AM->delete_price_factor(\%myconfig, \%$form);
3098 $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor deleted!')) if ($form->{callback});
3100 $form->redirect($locale->text('Price factor deleted!'));
3102 $lxdebug->leave_sub();
3105 sub swap_price_factors {
3106 $lxdebug->enter_sub();
3108 $auth->assert('config');
3110 AM->swap_sortkeys(\%myconfig, $form, 'price_factors');
3111 list_price_factors();
3113 $lxdebug->leave_sub();
3117 $lxdebug->enter_sub();
3119 $auth->assert('config');
3121 $form->{title} = $locale->text('Add Warehouse');
3122 $form->{callback} ||= build_std_url('action=add_warehouse');
3123 $form->{fokus} = 'description';
3126 print $form->parse_html_template('am/edit_warehouse');
3128 $lxdebug->leave_sub();
3131 sub edit_warehouse {
3132 $lxdebug->enter_sub();
3134 $auth->assert('config');
3136 AM->get_warehouse(\%myconfig, $form);
3138 $form->get_lists('employees' => 'EMPLOYEES');
3140 $form->{title} = $locale->text('Edit Warehouse');
3141 $form->{callback} ||= build_std_url('action=list_warehouses');
3142 $form->{fokus} = 'description';
3145 print $form->parse_html_template('am/edit_warehouse');
3147 $lxdebug->leave_sub();
3150 sub list_warehouses {
3151 $lxdebug->enter_sub();
3153 $auth->assert('config');
3155 AM->get_all_warehouses(\%myconfig, $form);
3158 foreach my $current (@{ $form->{WAREHOUSES} }) {
3160 $previous->{next_id} = $current->{id};
3161 $current->{previous_id} = $previous->{id};
3164 $previous = $current;
3167 $form->{callback} = build_std_url('action=list_warehouses');
3168 $form->{title} = $locale->text('Warehouses');
3169 $form->{url_base} = build_std_url('callback');
3172 print $form->parse_html_template('am/list_warehouses');
3174 $lxdebug->leave_sub();
3177 sub save_warehouse {
3178 $lxdebug->enter_sub();
3180 $auth->assert('config');
3182 $form->isblank("description", $locale->text('Description missing!'));
3184 $form->{number_of_new_bins} = $form->parse_amount(\%myconfig, $form->{number_of_new_bins});
3186 AM->save_warehouse(\%myconfig, $form);
3188 $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse saved.')) if ($form->{callback});
3190 $form->redirect($locale->text('Warehouse saved.'));
3192 $lxdebug->leave_sub();
3195 sub swap_warehouses {
3196 $lxdebug->enter_sub();
3198 $auth->assert('config');
3200 AM->swap_sortkeys(\%myconfig, $form, 'warehouse');
3203 $lxdebug->leave_sub();
3206 sub delete_warehouse {
3207 $lxdebug->enter_sub();
3209 $auth->assert('config');
3211 if (!$form->{confirmed}) {
3212 $form->{title} = $locale->text('Confirmation');
3215 print $form->parse_html_template('am/confirm_delete_warehouse');
3219 if (AM->delete_warehouse(\%myconfig, $form)) {
3220 $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse deleted.')) if ($form->{callback});
3221 $form->redirect($locale->text('Warehouse deleted.'));
3224 $form->error($locale->text('The warehouse could not be deleted because it has already been used.'));
3227 $lxdebug->leave_sub();
3231 $lxdebug->enter_sub();
3233 $auth->assert('config');
3235 AM->save_bins(\%myconfig, $form);
3237 $form->{callback} .= '&saved_message=' . E($locale->text('Bins saved.')) if ($form->{callback});
3239 $form->redirect($locale->text('Bins saved.'));
3241 $lxdebug->leave_sub();