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"}); }
60 $lxdebug->enter_sub();
62 $auth->assert('config');
64 $form->{title} = "Add";
65 $form->{charttype} = "A";
66 AM->get_account(\%myconfig, \%$form);
68 $form->{callback} = "am.pl?action=list_account" unless $form->{callback};
73 $lxdebug->leave_sub();
77 $lxdebug->enter_sub();
79 $auth->assert('config');
81 $form->{title} = "Edit";
82 AM->get_account(\%myconfig, \%$form);
84 foreach my $item (split(/:/, $form->{link})) {
85 $form->{$item} = "checked";
91 $lxdebug->leave_sub();
95 $lxdebug->enter_sub();
97 $auth->assert('config');
99 if ( $form->{action} eq 'edit_account') {
100 $form->{account_exists} = '1';
103 $form->{title} = $locale->text("$form->{title} Account");
105 $form->{"$form->{charttype}_checked"} = "checked";
106 $form->{"$form->{category}_checked"} = "checked";
108 $form->{select_tax} = "";
110 my @tax_report_pos = USTVA->report_variables({
111 myconfig => \%myconfig,
114 attribute => 'position',
118 if (@{ $form->{TAXKEY} }) {
119 foreach my $item (@{ $form->{TAXKEY} }) {
120 $item->{rate} = $item->{rate} * 100 . '%';
123 # Fill in empty row for new Taxkey
129 taxdescription => '',
136 push @{ $form->{ACCOUNT_TAXKEYS} }, $newtaxkey_ref;
139 foreach my $taxkey_used (@{ $form->{ACCOUNT_TAXKEYS} } ) {
141 # Fill in a runningnumber
142 $form->{ACCOUNT_TAXKEYS}[$i]{runningnumber} = $i;
144 # Fill in the Taxkeys as select options
145 foreach my $item (@{ $form->{TAXKEY} }) {
146 if ($item->{id} == $taxkey_used->{tax_id}) {
147 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
148 qq|<option value="$item->{id}" selected="selected">|
149 . sprintf("%.2d", $item->{taxkey})
150 . qq|. $item->{taxdescription} ($item->{rate}) |
151 . $locale->text('Tax-o-matic Account')
152 . qq|: $item->{chart_accno}\n|;
155 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
156 qq|<option value="$item->{id}">|
157 . sprintf("%.2d", $item->{taxkey})
158 . qq|. $item->{taxdescription} ($item->{rate}) |
159 . $locale->text('Tax-o-matic Account')
160 . qq|: $item->{chart_accno}\n|;
165 # Fill in the USTVA Numbers as select options
166 foreach my $item ( '', sort({ $a cmp $b } @tax_report_pos) ) {
168 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="" selected="selected">-\n|;
170 elsif ( $item eq $taxkey_used->{pos_ustva} ) {
171 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item" selected="selected">$item\n|;
174 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item">$item\n|;
183 # Newaccount Folgekonto
184 if (@{ $form->{NEWACCOUNT} }) {
185 if (!$form->{new_chart_valid}) {
186 $form->{selectnewaccount} = qq|<option value=""> |. $locale->text('None') .q|</option>|;
188 foreach $item (@{ $form->{NEWACCOUNT} }) {
189 if ($item->{id} == $form->{new_chart_id}) {
190 $form->{selectnewaccount} .=
191 qq|<option value="$item->{id}" selected>$item->{accno}--$item->{description}</option>|;
192 } elsif (!$form->{new_chart_valid}) {
193 $form->{selectnewaccount} .=
194 qq|<option value="$item->{id}">$item->{accno}--$item->{description}</option>|;
200 $select_eur = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
201 %eur = (1 => "Umsatzerlöse",
202 2 => "sonstige Erlöse",
203 3 => "Privatanteile",
205 5 => "Ausserordentliche Erträge",
206 6 => "Vereinnahmte Umsatzst.",
207 7 => "Umsatzsteuererstattungen",
208 8 => "Wareneingänge",
209 9 => "Löhne und Gehälter",
210 10 => "Gesetzl. sozialer Aufw.",
212 12 => "Gas, Strom, Wasser",
213 13 => "Instandhaltung",
214 14 => "Steuern, Versich., Beiträge",
216 16 => "Kfz-Versicherungen",
217 17 => "Sonst. Fahrtkosten",
218 18 => "Werbe- und Reisekosten",
219 19 => "Instandhaltung u. Werkzeuge",
220 20 => "Fachzeitschriften, Bücher",
221 21 => "Miete für Einrichtungen",
222 22 => "Rechts- und Beratungskosten",
223 23 => "Bürobedarf, Porto, Telefon",
224 24 => "Sonstige Aufwendungen",
225 25 => "Abschreibungen auf Anlagever.",
226 26 => "Abschreibungen auf GWG",
228 28 => "Umsatzsteuerzahlungen",
230 30 => "Ausserordentlicher Aufwand",
231 31 => "Betriebliche Steuern");
232 foreach $item (sort({ $a <=> $b } keys(%eur))) {
233 my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $eur{$item}));
234 if ($item == $form->{pos_eur}) {
235 $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
237 $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
242 $select_bwa = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
244 %bwapos = (1 => 'Umsatzerlöse',
245 2 => 'Best.Verdg.FE/UE',
246 3 => 'Aktiv.Eigenleistung',
247 4 => 'Mat./Wareneinkauf',
248 5 => 'So.betr.Erlöse',
249 10 => 'Personalkosten',
251 12 => 'Betriebl.Steuern',
252 13 => 'Vers./Beiträge',
253 14 => 'Kfz.Kosten o.St.',
254 15 => 'Werbe-Reisek.',
255 16 => 'Kosten Warenabgabe',
256 17 => 'Abschreibungen',
257 18 => 'Rep./instandhlt.',
258 19 => 'Übrige Steuern',
259 20 => 'Sonst.Kosten',
261 31 => 'Sonst.neutr.Aufw.',
263 33 => 'Sonst.neutr.Ertrag',
264 34 => 'Verr.kalk.Kosten',
265 35 => 'Steuern Eink.u.Ertr.');
266 foreach $item (sort({ $a <=> $b } keys %bwapos)) {
267 my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $bwapos{$item}));
268 if ($item == $form->{pos_bwa}) {
269 $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $text\n|;
271 $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $text\n|;
276 # Wieder hinzugefügt zu evaluationszwecken (us) 09.03.2007
277 $select_bilanz = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
278 foreach $item ((1, 2, 3, 4)) {
279 if ($item == $form->{pos_bilanz}) {
280 $select_bilanz .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|.\n|;
282 $select_bilanz .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|.\n|;
287 # this is for our parser only! Do not remove.
288 # type=submit $locale->text('Add Account')
289 # type=submit $locale->text('Edit Account')
291 $form->{type} = "account";
293 # preselections category
295 $select_category = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
298 'A' => $locale->text('Asset'),
299 'L' => $locale->text('Liability'),
300 'Q' => $locale->text('Equity'),
301 'I' => $locale->text('Revenue'),
302 'E' => $locale->text('Expense'),
303 'C' => $locale->text('Costs'),
305 foreach $item ( sort({ $a <=> $b } keys %category) ) {
306 if ($item eq $form->{category}) {
307 $select_category .= qq|<option value="$item" selected="selected">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
309 $select_category .= qq|<option value="$item">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
314 # preselection chart type
315 my $select_charttype = q{};
318 'A' => $locale->text('Account'),
319 'H' => $locale->text('Header'),
322 foreach $item ( sort({ $a <=> $b } keys %charttype) ) {
323 if ($item eq $form->{charttype}) {
324 $select_charttype .= qq|<option value="$item" selected="selected">$charttype{$item}\n|;
327 $select_charttype .= qq|<option value="$item">$charttype{$item}\n|;
332 my $ChartTypeIsAccount = ($form->{charttype} eq "A") ? "1":"";
336 my $parameters_ref = {
337 ChartTypeIsAccount => $ChartTypeIsAccount,
338 select_category => $select_category,
339 select_charttype => $select_charttype,
340 newaccount => $newaccount,
342 select_bwa => $select_bwa,
343 select_bilanz => $select_bilanz,
344 select_eur => $select_eur,
347 # Ausgabe des Templates
348 print($form->parse_html_template('am/edit_accounts', $parameters_ref));
351 $lxdebug->leave_sub();
355 $lxdebug->enter_sub();
357 $auth->assert('config');
361 <input name=callback type=hidden value="| . H($form->{callback}) . qq|">
364 if ((!$form->{id}) || ($form->{id} && $form->{orphaned}) || (($form->{type} eq "account") && (!$form->{new_chart_valid}))) {
366 <input type=submit class=submit name=action value="|
367 . $locale->text('Save') . qq|">
371 if ($form->{id} && $form->{orphaned}) {
372 print qq|<input type=submit class=submit name=action value="|
373 . $locale->text('Delete') . qq|">|;
383 $lxdebug->leave_sub();
387 $lxdebug->enter_sub();
389 $auth->assert('config');
391 $form->isblank("accno", $locale->text('Account Number missing!'));
392 $form->isblank("description", $locale->text('Account Description missing!'));
394 if ($form->{charttype} eq 'A'){
395 $form->isblank("category", $locale->text('Account Type missing!'));
398 $form->redirect($locale->text('Account saved!'))
399 if (AM->save_account(\%myconfig, \%$form));
400 $form->error($locale->text('Cannot save account!'));
402 $lxdebug->leave_sub();
406 $lxdebug->enter_sub();
408 $auth->assert('config');
410 $form->{callback} = build_std_url('action=list_account');
411 my $link_edit_account = build_std_url('action=edit_account', 'callback');
413 CA->all_accounts(\%myconfig, \%$form);
415 foreach $ca (@{ $form->{CA} }) {
420 if ($ca->{amount} > 0) {
421 $ca->{credit} = $form->format_amount(\%myconfig, $ca->{amount}, 2);
423 if ($ca->{amount} < 0) {
424 $ca->{debit} = $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2);
426 $ca->{heading} = ( $ca->{charttype} eq 'H' ) ? 1:'';
427 $ca->{link_edit_account} = $link_edit_account . '&id=' . E($ca->{id});
431 my $pjx = new CGI::Ajax('list_account_details' => build_std_url('action=list_account_details'));
433 # Eneable AJAX debuging
437 push(@ { $form->{AJAX} }, $pjx);
439 $form->{stylesheets} = "list_accounts.css";
440 $form->{title} = $locale->text('Chart of Accounts');
445 my $parameters_ref = {
446 # hidden_variables => $_hidden_variables_ref,
449 # Ausgabe des Templates
450 print($form->parse_html_template('am/list_accounts', $parameters_ref));
452 $lxdebug->leave_sub();
457 sub list_account_details {
458 # Ajax Funktion aus list_account_details
459 $lxdebug->enter_sub();
461 $auth->assert('config');
463 my $chart_id = $form->{args};
465 CA->all_accounts(\%myconfig, \%$form, $chart_id);
467 foreach $ca (@{ $form->{CA} }) {
469 $ca->{debit} = " ";
470 $ca->{credit} = " ";
472 if ($ca->{amount} > 0) {
474 $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
476 if ($ca->{amount} < 0) {
478 $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2, " ");
481 my @links = split( q{:}, $ca->{link});
485 foreach my $link (@links){
486 $link = ( $link eq 'AR') ? $locale->text('Account Link AR')
487 : ( $link eq 'AP') ? $locale->text('Account Link AP')
488 : ( $link eq 'IC') ? $locale->text('Account Link IC')
489 : ( $link eq 'AR_amount' ) ? $locale->text('Account Link AR_amount')
490 : ( $link eq 'AR_paid' ) ? $locale->text('Account Link AR_paid')
491 : ( $link eq 'AR_tax' ) ? $locale->text('Account Link AR_tax')
492 : ( $link eq 'AP_amount' ) ? $locale->text('Account Link AP_amount')
493 : ( $link eq 'AP_paid' ) ? $locale->text('Account Link AP_paid')
494 : ( $link eq 'AP_tax' ) ? $locale->text('Account Link AP_tax')
495 : ( $link eq 'IC_sale' ) ? $locale->text('Account Link IC_sale')
496 : ( $link eq 'IC_cogs' ) ? $locale->text('Account Link IC_cogs')
497 : ( $link eq 'IC_taxpart' ) ? $locale->text('Account Link IC_taxpart')
498 : ( $link eq 'IC_income' ) ? $locale->text('Account Link IC_income')
499 : ( $link eq 'IC_expense' ) ? $locale->text('Account Link IC_expense')
500 : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice')
501 # : ( $link eq 'CT_tax' ) ? $locale->text('Account Link CT_tax')
502 : $locale->text('Unknown Link') . ': ' . $link;
503 $ca->{link} .= ($link ne '') ? "[$link] ":'';
506 $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
507 : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
508 : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
509 : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
510 : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
511 : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
512 : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
513 : $locale->text('Unknown Category') . ': ' . $ca->{category};
516 $form->{title} = $locale->text('Chart of Accounts');
519 print $form->parse_html_template('am/list_account_details');
521 $lxdebug->leave_sub();
526 $lxdebug->enter_sub();
528 $auth->assert('config');
530 $form->{title} = $locale->text('Delete Account');
533 qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
535 if ($form->{id} == $form->{$id}) {
536 $form->error($locale->text('Cannot delete default account!'));
540 $form->redirect($locale->text('Account deleted!'))
541 if (AM->delete_account(\%myconfig, \%$form));
542 $form->error($locale->text('Cannot delete account!'));
544 $lxdebug->leave_sub();
548 $lxdebug->enter_sub();
550 $auth->assert('config');
552 $form->{title} = "Add";
555 $form->{callback} = "am.pl?action=add_department" unless $form->{callback};
560 $lxdebug->leave_sub();
563 sub edit_department {
564 $lxdebug->enter_sub();
566 $auth->assert('config');
568 $form->{title} = "Edit";
570 AM->get_department(\%myconfig, \%$form);
575 $lxdebug->leave_sub();
578 sub list_department {
579 $lxdebug->enter_sub();
581 $auth->assert('config');
583 AM->departments(\%myconfig, \%$form);
585 $form->{callback} = "am.pl?action=list_department";
587 $callback = $form->escape($form->{callback});
589 $form->{title} = $locale->text('Departments');
591 @column_index = qw(description cost profit);
593 $column_header{description} =
594 qq|<th class=listheading width=90%>|
595 . $locale->text('Description')
597 $column_header{cost} =
598 qq|<th class=listheading nowrap>|
599 . $locale->text('Cost Center')
601 $column_header{profit} =
602 qq|<th class=listheading nowrap>|
603 . $locale->text('Profit Center')
613 <th class=listtop>$form->{title}</th>
619 <tr class=listheading>
622 map { print "$column_header{$_}\n" } @column_index;
628 foreach $ref (@{ $form->{ALL} }) {
634 <tr valign=top class=listrow$i>
637 $costcenter = ($ref->{role} eq "C") ? "X" : "";
638 $profitcenter = ($ref->{role} eq "P") ? "X" : "";
640 $column_data{description} =
641 qq|<td><a href="am.pl?action=edit_department&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
642 $column_data{cost} = qq|<td align=center>$costcenter</td>|;
643 $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
645 map { print "$column_data{$_}\n" } @column_index;
657 <td><hr size=3 noshade></td>
662 <form method=post action=am.pl>
664 <input name=callback type=hidden value="$form->{callback}">
666 <input type=hidden name=type value=department>
668 <input class=submit type=submit name=action value="|
669 . $locale->text('Add') . qq|">
677 $lxdebug->leave_sub();
680 sub department_header {
681 $lxdebug->enter_sub();
683 $auth->assert('config');
685 $form->{title} = $locale->text("$form->{title} Department");
687 # $locale->text('Add Department')
688 # $locale->text('Edit Department')
690 $form->{description} =~ s/\"/"/g;
692 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
694 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
697 qq|<input name=description size=60 value="$form->{description}">|;
700 $costcenter = "checked" if $form->{role} eq "C";
701 $profitcenter = "checked" if $form->{role} eq "P";
708 <form method=post action=am.pl>
710 <input type=hidden name=id value=$form->{id}>
711 <input type=hidden name=type value=department>
715 <th class=listtop colspan=2>$form->{title}</th>
719 <th align=right>| . $locale->text('Description') . qq|</th>
720 <td>$description</td>
724 <td><input type=radio style=radio name=role value="C" $costcenter> |
725 . $locale->text('Cost Center') . qq|
726 <input type=radio style=radio name=role value="P" $profitcenter> |
727 . $locale->text('Profit Center') . qq|
730 <td colspan=2><hr size=3 noshade></td>
735 $lxdebug->leave_sub();
738 sub save_department {
739 $lxdebug->enter_sub();
741 $auth->assert('config');
743 $form->isblank("description", $locale->text('Description missing!'));
744 AM->save_department(\%myconfig, \%$form);
745 $form->redirect($locale->text('Department saved!'));
747 $lxdebug->leave_sub();
750 sub delete_department {
751 $lxdebug->enter_sub();
753 $auth->assert('config');
755 AM->delete_department(\%myconfig, \%$form);
756 $form->redirect($locale->text('Department deleted!'));
758 $lxdebug->leave_sub();
762 $lxdebug->enter_sub();
764 $auth->assert('config');
766 $form->{title} = "Add";
768 $form->{callback} = "am.pl?action=add_lead" unless $form->{callback};
773 $lxdebug->leave_sub();
777 $lxdebug->enter_sub();
779 $auth->assert('config');
781 $form->{title} = "Edit";
783 AM->get_lead(\%myconfig, \%$form);
787 $form->{orphaned} = 1;
790 $lxdebug->leave_sub();
794 $lxdebug->enter_sub();
796 $auth->assert('config');
798 AM->lead(\%myconfig, \%$form);
800 $form->{callback} = "am.pl?action=list_lead";
802 $callback = $form->escape($form->{callback});
804 $form->{title} = $locale->text('Lead');
806 @column_index = qw(description cost profit);
808 $column_header{description} =
809 qq|<th class=listheading width=100%>|
810 . $locale->text('Description')
820 <th class=listtop>$form->{title}</th>
823 <tr class=listheading>
826 map { print "$column_header{$_}\n" } @column_index;
832 foreach $ref (@{ $form->{ALL} }) {
838 <tr valign=top class=listrow$i>
841 $lead = $ref->{lead};
843 $column_data{description} = qq|<td><a href="am.pl?action=edit_lead&id=$ref->{id}&callback=$callback">$ref->{lead}</td>|;
845 map { print "$column_data{$_}\n" } @column_index;
854 <td><hr size=3 noshade></td>
859 <form method=post action=am.pl>
861 <input name=callback type=hidden value="$form->{callback}">
863 <input type=hidden name=type value=lead>
865 <input class=submit type=submit name=action value="|
866 . $locale->text('Add') . qq|">
874 $lxdebug->leave_sub();
878 $lxdebug->enter_sub();
880 $auth->assert('config');
882 $form->{title} = $locale->text("$form->{title} Lead");
884 # $locale->text('Add Lead')
885 # $locale->text('Edit Lead')
887 $form->{description} =~ s/\"/"/g;
890 qq|<input name=description size=50 value="$form->{lead}">|;
897 <form method=post action=am.pl>
899 <input type=hidden name=id value=$form->{id}>
900 <input type=hidden name=type value=lead>
904 <th class=listtop colspan=2>$form->{title}</th>
908 <th align=right>| . $locale->text('Description') . qq|</th>
909 <td>$description</td>
911 <td colspan=2><hr size=3 noshade></td>
916 $lxdebug->leave_sub();
920 $lxdebug->enter_sub();
922 $auth->assert('config');
924 $form->isblank("description", $locale->text('Description missing!'));
925 AM->save_lead(\%myconfig, \%$form);
926 $form->redirect($locale->text('lead saved!'));
928 $lxdebug->leave_sub();
932 $lxdebug->enter_sub();
934 $auth->assert('config');
936 AM->delete_lead(\%myconfig, \%$form);
937 $form->redirect($locale->text('lead deleted!'));
939 $lxdebug->leave_sub();
943 $lxdebug->enter_sub();
945 $auth->assert('config');
947 $form->{title} = "Add";
949 $form->{callback} = "am.pl?action=add_business" unless $form->{callback};
954 $lxdebug->leave_sub();
958 $lxdebug->enter_sub();
960 $form->{title} = "Edit";
962 AM->get_business(\%myconfig, \%$form);
966 $form->{orphaned} = 1;
969 $lxdebug->leave_sub();
973 $lxdebug->enter_sub();
975 $auth->assert('config');
977 AM->business(\%myconfig, \%$form);
979 $form->{callback} = "am.pl?action=list_business";
981 $callback = $form->escape($form->{callback});
983 $form->{title} = $locale->text('Type of Business');
985 @column_index = qw(description discount customernumberinit);
987 $column_header{description} =
988 qq|<th class=listheading width=60%>|
989 . $locale->text('Description')
991 $column_header{discount} =
992 qq|<th class=listheading width=10%>|
993 . $locale->text('Discount')
995 $column_header{customernumberinit} =
996 qq|<th class=listheading>|
997 . $locale->text('Customernumberinit')
1007 <th class=listtop>$form->{title}</th>
1009 <tr height="5"></tr>
1013 <tr class=listheading>
1016 map { print "$column_header{$_}\n" } @column_index;
1022 foreach $ref (@{ $form->{ALL} }) {
1028 <tr valign=top class=listrow$i>
1032 $form->format_amount(\%myconfig, $ref->{discount} * 100);
1034 $ref->{description};
1035 $column_data{description} = qq|<td><a href="am.pl?action=edit_business&id=$ref->{id}&callback=$callback">$description</td>|;
1036 $column_data{discount} = qq|<td align=right>$discount</td>|;
1037 $column_data{customernumberinit} =
1038 qq|<td align=right>$ref->{customernumberinit}</td>|;
1040 map { print "$column_data{$_}\n" } @column_index;
1052 <td><hr size=3 noshade></td>
1057 <form method=post action=am.pl>
1059 <input name=callback type=hidden value="$form->{callback}">
1061 <input type=hidden name=type value=business>
1063 <input class=submit type=submit name=action value="|
1064 . $locale->text('Add') . qq|">
1072 $lxdebug->leave_sub();
1075 sub business_header {
1076 $lxdebug->enter_sub();
1078 $auth->assert('config');
1080 $form->{title} = $locale->text("$form->{title} Business");
1082 # $locale->text('Add Business')
1083 # $locale->text('Edit Business')
1085 $form->{description} =~ s/\"/"/g;
1087 $form->format_amount(\%myconfig, $form->{discount} * 100);
1094 <form method=post action=am.pl>
1096 <input type=hidden name=id value=$form->{id}>
1097 <input type=hidden name=type value=business>
1101 <th class=listtop colspan=2>$form->{title}</th>
1103 <tr height="5"></tr>
1105 <th align=right>| . $locale->text('Type of Business') . qq|</th>
1106 <td><input name=description size=30 value="$form->{description}"></td>
1109 <th align=right>| . $locale->text('Discount') . qq| %</th>
1110 <td><input name=discount size=5 value=$form->{discount}></td>
1113 <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
1114 <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
1116 <td colspan=2><hr size=3 noshade></td>
1121 $lxdebug->leave_sub();
1125 $lxdebug->enter_sub();
1127 $auth->assert('config');
1129 $form->isblank("description", $locale->text('Description missing!'));
1130 $form->{discount} = $form->parse_amount(\%myconfig, $form->{discount}) / 100;
1131 AM->save_business(\%myconfig, \%$form);
1132 $form->redirect($locale->text('Business saved!'));
1134 $lxdebug->leave_sub();
1137 sub delete_business {
1138 $lxdebug->enter_sub();
1140 $auth->assert('config');
1142 AM->delete_business(\%myconfig, \%$form);
1143 $form->redirect($locale->text('Business deleted!'));
1145 $lxdebug->leave_sub();
1149 $lxdebug->enter_sub();
1151 $auth->assert('config');
1153 $form->{title} = "Add";
1155 $form->{callback} = "am.pl?action=add_language" unless $form->{callback};
1160 $lxdebug->leave_sub();
1164 $lxdebug->enter_sub();
1166 $auth->assert('config');
1168 $form->{title} = "Edit";
1170 AM->get_language(\%myconfig, \%$form);
1174 $form->{orphaned} = 1;
1177 $lxdebug->leave_sub();
1181 $lxdebug->enter_sub();
1183 $auth->assert('config');
1185 AM->language(\%myconfig, \%$form);
1187 $form->{callback} = "am.pl?action=list_language";
1189 $callback = $form->escape($form->{callback});
1191 $form->{title} = $locale->text('Languages');
1193 @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
1195 $column_header{description} =
1196 qq|<th class=listheading width=60%>|
1197 . $locale->text('Description')
1199 $column_header{template_code} =
1200 qq|<th class=listheading width=10%>|
1201 . $locale->text('Template Code')
1203 $column_header{article_code} =
1204 qq|<th class=listheading>|
1205 . $locale->text('Article Code')
1207 $column_header{output_numberformat} =
1208 qq|<th class=listheading>|
1209 . $locale->text('Number Format')
1211 $column_header{output_dateformat} =
1212 qq|<th class=listheading>|
1213 . $locale->text('Date Format')
1215 $column_header{output_longdates} =
1216 qq|<th class=listheading>|
1217 . $locale->text('Long Dates')
1227 <th class=listtop>$form->{title}</th>
1229 <tr height="5"></tr>
1233 <tr class=listheading>
1236 map { print "$column_header{$_}\n" } @column_index;
1242 foreach $ref (@{ $form->{ALL} }) {
1248 <tr valign=top class=listrow$i>
1252 $column_data{description} =
1253 qq|<td><a href="am.pl?action=edit_language&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
1254 $column_data{template_code} = qq|<td align=right>$ref->{template_code}</td>|;
1255 $column_data{article_code} =
1256 qq|<td align=right>$ref->{article_code}</td>|;
1257 $column_data{output_numberformat} =
1259 ($ref->{output_numberformat} ? $ref->{output_numberformat} :
1260 $locale->text("use program settings")) .
1262 $column_data{output_dateformat} =
1264 ($ref->{output_dateformat} ? $ref->{output_dateformat} :
1265 $locale->text("use program settings")) .
1267 $column_data{output_longdates} =
1269 ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
1272 map { print "$column_data{$_}\n" } @column_index;
1284 <td><hr size=3 noshade></td>
1289 <form method=post action=am.pl>
1291 <input name=callback type=hidden value="$form->{callback}">
1293 <input type=hidden name=type value=language>
1295 <input class=submit type=submit name=action value="|
1296 . $locale->text('Add') . qq|">
1304 $lxdebug->leave_sub();
1307 sub language_header {
1308 $lxdebug->enter_sub();
1310 $auth->assert('config');
1312 $form->{title} = $locale->text("$form->{title} Language");
1314 # $locale->text('Add Language')
1315 # $locale->text('Edit Language')
1317 $form->{description} =~ s/\"/"/g;
1318 $form->{template_code} =~ s/\"/"/g;
1319 $form->{article_code} =~ s/\"/"/g;
1325 qq|<option value="">| . $locale->text("use program settings") .
1327 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
1329 ($item eq $form->{output_numberformat})
1330 ? "<option selected>$item"
1336 qq|<option value="">| . $locale->text("use program settings") .
1338 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
1340 ($item eq $form->{output_dateformat})
1341 ? "<option selected>$item"
1349 <form method=post action=am.pl>
1351 <input type=hidden name=id value=$form->{id}>
1352 <input type=hidden name=type value=language>
1356 <th class=listtop colspan=2>$form->{title}</th>
1358 <tr height="5"></tr>
1360 <th align=right>| . $locale->text('Language') . qq|</th>
1361 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1364 <th align=right>| . $locale->text('Template Code') . qq|</th>
1365 <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
1368 <th align=right>| . $locale->text('Article Code') . qq|</th>
1369 <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
1372 <th align=right>| . $locale->text('Number Format') . qq|</th>
1373 <td><select name="output_numberformat">$numberformat</select></td>
1376 <th align=right>| . $locale->text('Date Format') . qq|</th>
1377 <td><select name="output_dateformat">$dateformat</select></td>
1380 <th align=right>| . $locale->text('Long Dates') . qq|</th>
1381 <td><input type="radio" name="output_longdates" value="1"| .
1382 ($form->{output_longdates} ? " checked" : "") .
1383 qq|>| . $locale->text("Yes") .
1384 qq|<input type="radio" name="output_longdates" value="0"| .
1385 ($form->{output_longdates} ? "" : " checked") .
1386 qq|>| . $locale->text("No") .
1389 <td colspan=2><hr size=3 noshade></td>
1394 $lxdebug->leave_sub();
1398 $lxdebug->enter_sub();
1400 $auth->assert('config');
1402 $form->isblank("description", $locale->text('Language missing!'));
1403 $form->isblank("template_code", $locale->text('Template Code missing!'));
1404 $form->isblank("article_code", $locale->text('Article Code missing!'));
1405 AM->save_language(\%myconfig, \%$form);
1406 $form->redirect($locale->text('Language saved!'));
1408 $lxdebug->leave_sub();
1411 sub delete_language {
1412 $lxdebug->enter_sub();
1414 $auth->assert('config');
1416 AM->delete_language(\%myconfig, \%$form);
1417 $form->redirect($locale->text('Language deleted!'));
1419 $lxdebug->leave_sub();
1423 sub add_buchungsgruppe {
1424 $lxdebug->enter_sub();
1426 $auth->assert('config');
1428 # $locale->text("Add Buchungsgruppe")
1429 # $locale->text("Edit Buchungsgruppe")
1430 $form->{title} = "Add";
1432 $form->{callback} = "am.pl?action=add_buchungsgruppe" unless $form->{callback};
1434 AM->get_buchungsgruppe(\%myconfig, \%$form);
1435 $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
1436 for (my $i = 0; 4 > $i; $i++) {
1437 map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
1438 qw(income expense));
1441 &buchungsgruppe_header;
1444 $lxdebug->leave_sub();
1447 sub edit_buchungsgruppe {
1448 $lxdebug->enter_sub();
1450 $auth->assert('config');
1452 $form->{title} = "Edit";
1454 AM->get_buchungsgruppe(\%myconfig, \%$form);
1456 &buchungsgruppe_header;
1460 $lxdebug->leave_sub();
1463 sub list_buchungsgruppe {
1464 $lxdebug->enter_sub();
1466 $auth->assert('config');
1468 AM->buchungsgruppe(\%myconfig, \%$form);
1470 $form->{callback} = "am.pl?action=list_buchungsgruppe";
1472 $callback = $form->escape($form->{callback});
1474 $form->{title} = $locale->text('Buchungsgruppen');
1476 @column_index = qw(up down description inventory_accno
1477 income_accno_0 expense_accno_0
1478 income_accno_1 expense_accno_1
1479 income_accno_2 expense_accno_2
1480 income_accno_3 expense_accno_3 );
1482 $column_header{up} =
1483 qq|<th class="listheading" width="16">|
1484 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
1486 $column_header{down} =
1487 qq|<th class="listheading" width="16">|
1488 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
1490 $column_header{description} =
1491 qq|<th class="listheading" width="40%">|
1492 . $locale->text('Description')
1494 $column_header{inventory_accno} =
1495 qq|<th class=listheading>|
1496 . $locale->text('Bestandskonto')
1498 $column_header{income_accno_0} =
1499 qq|<th class=listheading>|
1500 . $locale->text('National Revenues')
1502 $column_header{expense_accno_0} =
1503 qq|<th class=listheading>|
1504 . $locale->text('National Expenses')
1506 $column_header{income_accno_1} =
1507 qq|<th class=listheading>|
1508 . $locale->text('Revenues EU with UStId')
1510 $column_header{expense_accno_1} =
1511 qq|<th class=listheading>|
1512 . $locale->text('Expenses EU with UStId')
1514 $column_header{income_accno_2} =
1515 qq|<th class=listheading>|
1516 . $locale->text('Revenues EU without UStId')
1518 $column_header{expense_accno_2} =
1519 qq|<th class=listheading>|
1520 . $locale->text('Expenses EU without UStId')
1522 $column_header{income_accno_3} =
1523 qq|<th class=listheading>|
1524 . $locale->text('Foreign Revenues')
1526 $column_header{expense_accno_3} =
1527 qq|<th class=listheading>|
1528 . $locale->text('Foreign Expenses')
1537 <th class=listtop>$form->{title}</th>
1539 <tr height="5"></tr>
1543 <tr class=listheading>
1546 map { print "$column_header{$_}\n" } @column_index;
1552 my $swap_link = qq|am.pl?action=swap_buchungsgruppen&|;
1555 foreach $ref (@{ $form->{ALL} }) {
1561 <tr valign=top class=listrow$i>
1565 my $pref = $form->{ALL}->[$row - 1];
1567 qq|<td align="center" valign="center" width="16">| .
1568 qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
1569 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
1572 $column_data{up} = qq|<td width="16"> </td>|;
1575 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
1576 $column_data{down} = qq|<td width="16"> </td>|;
1578 my $nref = $form->{ALL}->[$row + 1];
1579 $column_data{down} =
1580 qq|<td align="center" valign="center" width="16">| .
1581 qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
1582 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
1586 $column_data{description} = qq|<td><a href="am.pl?action=edit_buchungsgruppe&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
1587 $column_data{inventory_accno} = qq|<td align=right>$ref->{inventory_accno}</td>|;
1588 $column_data{income_accno_0} =
1589 qq|<td align=right>$ref->{income_accno_0}</td>|;
1590 $column_data{expense_accno_0} = qq|<td align=right>$ref->{expense_accno_0}</td>|;
1591 $column_data{income_accno_1} =
1592 qq|<td align=right>$ref->{income_accno_1}</td>|;
1593 $column_data{expense_accno_1} = qq|<td align=right>$ref->{expense_accno_1}</td>|;
1594 $column_data{income_accno_2} =
1595 qq|<td align=right>$ref->{income_accno_2}</td>|;
1596 $column_data{expense_accno_2} = qq|<td align=right>$ref->{expense_accno_2}</td>|;
1597 $column_data{income_accno_3} =
1598 qq|<td align=right>$ref->{income_accno_3}</td>|;
1599 $column_data{expense_accno_3} = qq|<td align=right>$ref->{expense_accno_3}</td>|;
1601 map { print "$column_data{$_}\n" } @column_index;
1615 <td><hr size=3 noshade></td>
1620 <form method=post action=am.pl>
1622 <input name=callback type=hidden value="$form->{callback}">
1624 <input type=hidden name=type value=buchungsgruppe>
1626 <input class=submit type=submit name=action value="|
1627 . $locale->text('Add') . qq|">
1635 $lxdebug->leave_sub();
1638 sub buchungsgruppe_header {
1639 $lxdebug->enter_sub();
1641 $auth->assert('config');
1643 $form->{title} = $locale->text("$form->{title} Buchungsgruppe");
1645 # $locale->text('Add Accounting Group')
1646 # $locale->text('Edit Accounting Group')
1648 my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
1649 my %acc_type_map = (
1650 "IC" => $acc_inventory,
1651 "IC_income" => $acc_income,
1652 "IC_sale" => $acc_income,
1653 "IC_expense" => $acc_expense,
1654 "IC_cogs" => $acc_expense,
1657 foreach $key (keys(%acc_type_map)) {
1658 foreach $ref (@{ $form->{IC_links}{$key} }) {
1659 $acc_type_map{$key}->{$ref->{"id"}} = $ref;
1663 foreach my $type (qw(IC IC_income IC_expense)) {
1664 $form->{"select$type"} =
1666 map({ "<option value=$_->{id} $_->{selected}>" .
1667 "$_->{accno}--" . H($_->{description}) . "</option>" }
1668 sort({ $a->{"accno"} cmp $b->{"accno"} }
1669 values(%{$acc_type_map{$type}}))));
1673 $form->{selectIC} =~ s/selected//g;
1674 $form->{selectIC} =~ s/ value=\Q$form->{inventory_accno_id}\E/ value=$form->{inventory_accno_id} selected/;
1675 $form->{selectIC_income} =~ s/selected//g;
1676 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_0}\E/ value=$form->{income_accno_id_0} selected/;
1677 $form->{selectIC_expense} =~ s/selected//g;
1678 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_0}\E/ value=$form->{expense_accno_id_0} selected/;
1684 <th align=right>| . $locale->text('Inventory') . qq|</th>
1685 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
1686 <input name=selectIC type=hidden value="$form->{selectIC}">
1690 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
1694 $linkaccounts .= qq|
1696 <th align=right>| . $locale->text('National Revenues') . qq|</th>
1697 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
1700 <th align=right>| . $locale->text('National Expenses') . qq|</th>
1701 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
1704 $form->{selectIC_income} =~ s/selected//g;
1705 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_1}\E/ value=$form->{income_accno_id_1} selected/;
1706 $form->{selectIC_expense} =~ s/selected//g;
1707 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_1}\E/ value=$form->{expense_accno_id_1} selected/;
1709 $linkaccounts .= qq| <tr>
1710 <th align=right>| . $locale->text('Revenues EU with UStId') . qq|</th>
1711 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
1714 <th align=right>| . $locale->text('Expenses EU with UStId') . qq|</th>
1715 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
1719 $form->{selectIC_income} =~ s/selected//g;
1720 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_2}\E/ value=$form->{income_accno_id_2} selected/;
1721 $form->{selectIC_expense} =~ s/selected//g;
1722 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_2}\E/ value=$form->{expense_accno_id_2} selected/;
1725 $linkaccounts .= qq| <tr>
1726 <th align=right>| . $locale->text('Revenues EU without UStId') . qq|</th>
1727 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
1730 <th align=right>| . $locale->text('Expenses EU without UStId') . qq|</th>
1731 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
1735 $form->{selectIC_income} =~ s/selected//g;
1736 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_3}\E/ value=$form->{income_accno_id_3} selected/;
1737 $form->{selectIC_expense} =~ s/selected//g;
1738 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_3}\E/ value=$form->{expense_accno_id_3} selected/;
1741 $linkaccounts .= qq| <tr>
1742 <th align=right>| . $locale->text('Foreign Revenues') . qq|</th>
1743 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
1746 <th align=right>| . $locale->text('Foreign Expenses') . qq|</th>
1747 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
1757 <form method=post action=am.pl>
1759 <input type=hidden name=id value=$form->{id}>
1760 <input type=hidden name=type value=buchungsgruppe>
1764 <th class=listtop colspan=2>$form->{title}</th>
1766 <tr height="5"></tr>
1768 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
1769 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1772 <td colspan=2><hr size=3 noshade></td>
1777 $lxdebug->leave_sub();
1780 sub save_buchungsgruppe {
1781 $lxdebug->enter_sub();
1783 $auth->assert('config');
1785 $form->isblank("description", $locale->text('Description missing!'));
1787 AM->save_buchungsgruppe(\%myconfig, \%$form);
1788 $form->redirect($locale->text('Accounting Group saved!'));
1790 $lxdebug->leave_sub();
1793 sub delete_buchungsgruppe {
1794 $lxdebug->enter_sub();
1796 $auth->assert('config');
1798 AM->delete_buchungsgruppe(\%myconfig, \%$form);
1799 $form->redirect($locale->text('Accounting Group deleted!'));
1801 $lxdebug->leave_sub();
1804 sub swap_buchungsgruppen {
1805 $lxdebug->enter_sub();
1807 $auth->assert('config');
1809 AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
1810 list_buchungsgruppe();
1812 $lxdebug->leave_sub();
1817 $lxdebug->enter_sub();
1819 $auth->assert('config');
1821 $form->{title} = "Add";
1823 $form->{callback} = "am.pl?action=add_printer" unless $form->{callback};
1828 $lxdebug->leave_sub();
1832 $lxdebug->enter_sub();
1834 $auth->assert('config');
1836 $form->{title} = "Edit";
1838 AM->get_printer(\%myconfig, \%$form);
1842 $form->{orphaned} = 1;
1845 $lxdebug->leave_sub();
1849 $lxdebug->enter_sub();
1851 $auth->assert('config');
1853 AM->printer(\%myconfig, \%$form);
1855 $form->{callback} = "am.pl?action=list_printer";
1857 $callback = $form->escape($form->{callback});
1859 $form->{title} = $locale->text('Printer');
1861 @column_index = qw(printer_description printer_command template_code);
1863 $column_header{printer_description} =
1864 qq|<th class=listheading width=60%>|
1865 . $locale->text('Printer Description')
1867 $column_header{printer_command} =
1868 qq|<th class=listheading width=10%>|
1869 . $locale->text('Printer Command')
1871 $column_header{template_code} =
1872 qq|<th class=listheading>|
1873 . $locale->text('Template Code')
1883 <th class=listtop>$form->{title}</th>
1885 <tr height="5"></tr>
1889 <tr class=listheading>
1892 map { print "$column_header{$_}\n" } @column_index;
1898 foreach $ref (@{ $form->{ALL} }) {
1904 <tr valign=top class=listrow$i>
1908 $column_data{printer_description} = qq|<td><a href="am.pl?action=edit_printer&id=$ref->{id}&callback=$callback">$ref->{printer_description}</td>|;
1909 $column_data{printer_command} = qq|<td align=right>$ref->{printer_command}</td>|;
1910 $column_data{template_code} =
1911 qq|<td align=right>$ref->{template_code}</td>|;
1913 map { print "$column_data{$_}\n" } @column_index;
1925 <td><hr size=3 noshade></td>
1930 <form method=post action=am.pl>
1932 <input name=callback type=hidden value="$form->{callback}">
1934 <input type=hidden name=type value=printer>
1936 <input class=submit type=submit name=action value="|
1937 . $locale->text('Add') . qq|">
1945 $lxdebug->leave_sub();
1948 sub printer_header {
1949 $lxdebug->enter_sub();
1951 $auth->assert('config');
1953 $form->{title} = $locale->text("$form->{title} Printer");
1955 # $locale->text('Add Printer')
1956 # $locale->text('Edit Printer')
1958 $form->{printer_description} =~ s/\"/"/g;
1959 $form->{template_code} =~ s/\"/"/g;
1960 $form->{printer_command} =~ s/\"/"/g;
1968 <form method=post action=am.pl>
1970 <input type=hidden name=id value=$form->{id}>
1971 <input type=hidden name=type value=printer>
1975 <th class=listtop colspan=2>$form->{title}</th>
1977 <tr height="5"></tr>
1979 <th align=right>| . $locale->text('Printer') . qq|</th>
1980 <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
1983 <th align=right>| . $locale->text('Printer Command') . qq|</th>
1984 <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
1987 <th align=right>| . $locale->text('Template Code') . qq|</th>
1988 <td><input name=template_code size=5 value="$form->{template_code}"></td>
1990 <td colspan=2><hr size=3 noshade></td>
1995 $lxdebug->leave_sub();
1999 $lxdebug->enter_sub();
2001 $auth->assert('config');
2003 $form->isblank("printer_description", $locale->text('Description missing!'));
2004 $form->isblank("printer_command", $locale->text('Printer Command missing!'));
2005 AM->save_printer(\%myconfig, \%$form);
2006 $form->redirect($locale->text('Printer saved!'));
2008 $lxdebug->leave_sub();
2011 sub delete_printer {
2012 $lxdebug->enter_sub();
2014 $auth->assert('config');
2016 AM->delete_printer(\%myconfig, \%$form);
2017 $form->redirect($locale->text('Printer deleted!'));
2019 $lxdebug->leave_sub();
2023 $lxdebug->enter_sub();
2025 $auth->assert('config');
2027 $form->{title} = "Add";
2029 $form->{callback} = "am.pl?action=add_payment" unless $form->{callback};
2031 $form->{terms_netto} = 0;
2032 $form->{terms_skonto} = 0;
2033 $form->{percent_skonto} = 0;
2034 my @languages = AM->language(\%myconfig, $form, 1);
2035 map({ $_->{"language"} = $_->{"description"};
2036 $_->{"language_id"} = $_->{"id"}; } @languages);
2037 $form->{"TRANSLATION"} = \@languages;
2041 $lxdebug->leave_sub();
2045 $lxdebug->enter_sub();
2047 $auth->assert('config');
2049 $form->{title} = "Edit";
2051 AM->get_payment(\%myconfig, $form);
2052 $form->{percent_skonto} =
2053 $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
2057 $form->{orphaned} = 1;
2060 $lxdebug->leave_sub();
2064 $lxdebug->enter_sub();
2066 $auth->assert('config');
2068 AM->payment(\%myconfig, \%$form);
2070 $form->{callback} = build_std_url("action=list_payment");
2072 $callback = $form->escape($form->{callback});
2074 $form->{title} = $locale->text('Payment Terms');
2076 @column_index = qw(up down description description_long terms_netto
2077 terms_skonto percent_skonto);
2079 $column_header{up} =
2080 qq|<th class="listheading" align="center" valign="center" width="16">|
2081 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
2083 $column_header{down} =
2084 qq|<th class="listheading" align="center" valign="center" width="16">|
2085 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
2087 $column_header{description} =
2088 qq|<th class=listheading>|
2089 . $locale->text('Description')
2091 $column_header{description_long} =
2092 qq|<th class=listheading>|
2093 . $locale->text('Long Description')
2095 $column_header{terms_netto} =
2096 qq|<th class=listheading>|
2097 . $locale->text('Netto Terms')
2099 $column_header{terms_skonto} =
2100 qq|<th class=listheading>|
2101 . $locale->text('Skonto Terms')
2103 $column_header{percent_skonto} =
2104 qq|<th class=listheading>|
2105 . $locale->text('Skonto')
2115 <th class=listtop>$form->{title}</th>
2117 <tr height="5"></tr>
2121 <tr class=listheading>
2124 map { print "$column_header{$_}\n" } @column_index;
2130 my $swap_link = build_std_url("action=swap_payment_terms");
2133 foreach $ref (@{ $form->{ALL} }) {
2139 <tr valign=top class=listrow$i>
2143 my $pref = $form->{ALL}->[$row - 1];
2145 qq|<td align="center" valign="center" width="16">| .
2146 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
2147 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
2150 $column_data{up} = qq|<td width="16"> </td>|;
2153 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
2154 $column_data{down} = qq|<td width="16"> </td>|;
2156 my $nref = $form->{ALL}->[$row + 1];
2157 $column_data{down} =
2158 qq|<td align="center" valign="center" width="16">| .
2159 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
2160 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
2164 $column_data{description} =
2166 build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
2167 qq|">| . H($ref->{description}) . qq|</a></td>|;
2168 $column_data{description_long} =
2169 qq|<td>| . H($ref->{description_long}) . qq|</td>|;
2170 $column_data{terms_netto} =
2171 qq|<td align=right>$ref->{terms_netto}</td>|;
2172 $column_data{terms_skonto} =
2173 qq|<td align=right>$ref->{terms_skonto}</td>|;
2174 $column_data{percent_skonto} =
2175 qq|<td align=right>| .
2176 $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
2178 map { print "$column_data{$_}\n" } @column_index;
2191 <td><hr size=3 noshade></td>
2196 <form method=post action=am.pl>
2198 <input name=callback type=hidden value="$form->{callback}">
2200 <input type=hidden name=type value=payment>
2202 <input class=submit type=submit name=action value="|
2203 . $locale->text('Add') . qq|">
2211 $lxdebug->leave_sub();
2214 sub payment_header {
2215 $lxdebug->enter_sub();
2217 $auth->assert('config');
2219 $form->{title} = $locale->text("$form->{title} Payment Terms");
2221 # $locale->text('Add Payment Terms')
2222 # $locale->text('Edit Payment Terms')
2224 $form->{description} =~ s/\"/"/g;
2233 <form method=post action=am.pl>
2235 <input type=hidden name=id value=$form->{id}>
2236 <input type=hidden name=type value=payment>
2240 <th class=listtop colspan=2>$form->{title}</th>
2242 <tr height="5"></tr>
2244 <th align=right>| . $locale->text('Description') . qq|</th>
2245 <td><input name=description size=30 value="$form->{description}"></td>
2248 <th align=right>| . $locale->text('Long Description') . qq|</th>
2249 <td><input name=description_long size=50 value="$form->{description_long}"></td>
2253 foreach my $language (@{ $form->{"TRANSLATION"} }) {
2256 <th align="right">| .
2257 sprintf($locale->text('Translation (%s)'),
2258 $language->{"language"})
2260 <td><input name="description_long_$language->{language_id}" size="50"
2261 value="| . Q($language->{"description_long"}) . qq|"></td>
2268 <th align=right>| . $locale->text('Netto Terms') . qq|</th>
2269 <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
2272 <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
2273 <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
2276 <th align=right>| . $locale->text('Skonto') . qq| %</th>
2277 <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
2279 <td colspan=2><hr size=3 noshade></td>
2283 <p>| . $locale->text("You can use the following strings in the long " .
2284 "description and all translations. They will be " .
2285 "replaced by their actual values by Lx-Office " .
2286 "before they're output.")
2290 <li>| . $locale->text("<%netto_date%> -- Date the payment is due in " .
2293 <li>| . $locale->text("<%skonto_date%> -- Date the payment is due " .
2296 <li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
2298 <li>| . $locale->text("<%total%> -- Amount payable")
2300 <li>| . $locale->text("<%total_wo_skonto%> -- Amount payable less discount")
2302 <li>| . $locale->text("<%invtotal%> -- Invoice total")
2304 <li>| . $locale->text("<%invtotal_wo_skonto%> -- Invoice total less discount")
2306 <li>| . $locale->text("<%currency%> -- The selected currency")
2308 <li>| . $locale->text("<%terms_netto%> -- The number of days for " .
2311 <li>| . $locale->text("<%account_number%> -- Your account number")
2313 <li>| . $locale->text("<%bank%> -- Your bank")
2315 <li>| . $locale->text("<%bank_code%> -- Your bank code")
2319 $lxdebug->leave_sub();
2323 $lxdebug->enter_sub();
2325 $auth->assert('config');
2327 $form->isblank("description", $locale->text('Description missing!'));
2328 $form->{"percent_skonto"} =
2329 $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
2330 AM->save_payment(\%myconfig, \%$form);
2331 $form->redirect($locale->text('Payment Terms saved!'));
2333 $lxdebug->leave_sub();
2336 sub delete_payment {
2337 $lxdebug->enter_sub();
2339 $auth->assert('config');
2341 AM->delete_payment(\%myconfig, \%$form);
2342 $form->redirect($locale->text('Payment terms deleted!'));
2344 $lxdebug->leave_sub();
2347 sub swap_payment_terms {
2348 $lxdebug->enter_sub();
2350 $auth->assert('config');
2352 AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
2355 $lxdebug->leave_sub();
2359 $lxdebug->enter_sub();
2361 # get defaults for account numbers and last numbers
2362 AM->defaultaccounts(\%myconfig, \%$form);
2364 map { $form->{"defaults_${_}"} = $form->{defaults}->{$_} } keys %{ $form->{defaults} };
2366 foreach $key (keys %{ $form->{IC} }) {
2367 foreach $accno (sort keys %{ $form->{IC}->{$key} }) {
2368 my $array = "ACCNOS_" . uc($key);
2369 $form->{$array} ||= [];
2371 my $value = "${accno}--" . $form->{IC}->{$key}->{$accno}->{description};
2372 push @{ $form->{$array} }, {
2375 'selected' => $form->{IC}->{$key}->{$accno}->{id} == $form->{defaults}->{$key},
2380 $form->{title} = $locale->text('Ranges of numbers and default accounts');
2383 print $form->parse_html_template('am/edit_defaults');
2385 $lxdebug->leave_sub();
2389 $lxdebug->enter_sub();
2391 AM->save_defaults();
2393 $form->redirect($locale->text('Defaults saved.'));
2395 $lxdebug->leave_sub();
2398 sub _build_cfg_options {
2400 my $array = uc($idx) . 'S';
2402 $form->{$array} = [];
2403 foreach my $item (@_) {
2404 push @{ $form->{$array} }, {
2407 'selected' => $item eq $myconfig{$idx},
2413 $lxdebug->enter_sub();
2415 _build_cfg_options('dateformat', qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd));
2416 _build_cfg_options('numberformat', qw(1,000.00 1000.00 1.000,00 1000,00));
2419 if ($opendocument_templates && $openofficeorg_writer_bin &&
2420 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
2421 push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
2422 "value" => "opendocument_pdf" });
2424 if ($latex_templates) {
2425 push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
2427 push(@formats, { "name" => "HTML", "value" => "html" });
2428 if ($latex_templates) {
2429 push(@formats, { "name" => $locale->text("Postscript"),
2430 "value" => "postscript" });
2432 if ($opendocument_templates) {
2433 push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
2434 "value" => "opendocument" });
2437 if (!$myconfig{"template_format"}) {
2438 $myconfig{"template_format"} = "pdf";
2440 $form->{TEMPLATE_FORMATS} = [];
2441 foreach $item (@formats) {
2442 push @{ $form->{TEMPLATE_FORMATS} }, {
2443 'name' => $item->{name},
2444 'value' => $item->{value},
2445 'selected' => $item->{value} eq $myconfig{template_format},
2449 if (!$myconfig{"default_media"}) {
2450 $myconfig{"default_media"} = "screen";
2453 my %selected = ($myconfig{"default_media"} => "selected");
2455 { 'name' => $locale->text('Screen'), 'value' => 'screen', 'selected' => $selected{screen}, },
2456 { 'name' => $locale->text('Printer'), 'value' => 'printer', 'selected' => $selected{printer}, },
2457 { 'name' => $locale->text('Queue'), 'value' => 'queue', 'selected' => $selected{queue}, },
2460 AM->printer(\%myconfig, $form);
2462 $form->{PRINTERS} = [];
2463 foreach my $printer (@{$form->{"ALL"}}) {
2464 push @{ $form->{PRINTERS} }, {
2465 'name' => $printer->{printer_description},
2466 'value' => $printer->{id},
2467 'selected' => $printer->{id} == $myconfig{default_printer_id},
2471 %countrycodes = User->country_codes;
2473 $countrycodes{""} = "American English";
2474 $form->{COUNTRYCODES} = [];
2475 foreach $countrycode (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
2476 push @{ $form->{COUNTRYCODES} }, {
2477 'name' => $countrycodes{$countrycode},
2478 'value' => $countrycode,
2479 'selected' => $countrycode eq $myconfig{countrycode},
2483 $form->{STYLESHEETS} = [];
2484 foreach $item (qw(lx-office-erp.css Win2000.css)) {
2485 push @{ $form->{STYLESHEETS} }, {
2488 'selected' => $item eq $myconfig{stylesheet},
2492 $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details}));
2493 $form->{"menustyle_$myconfig{menustyle}"} = 1;
2494 $form->{CAN_CHANGE_PASSWORD} = $auth->can_change_password();
2495 $form->{todo_cfg} = { TODO->get_user_config('login' => $form->{login}) };
2497 $form->{title} = $locale->text('Edit Preferences for #1', $form->{login});
2500 print $form->parse_html_template('am/config');
2502 $lxdebug->leave_sub();
2505 sub save_preferences {
2506 $lxdebug->enter_sub();
2508 $form->{stylesheet} = $form->{usestylesheet};
2510 TODO->save_user_config('login' => $form->{login}, %{ $form->{todo_cfg} || { } });
2512 $form->redirect($locale->text('Preferences saved!')) if (AM->save_preferences(\%myconfig, \%$form, $webdav));
2513 $form->error($locale->text('Cannot save preferences!'));
2515 $lxdebug->leave_sub();
2519 $lxdebug->enter_sub();
2521 $auth->assert('config');
2523 $form->{title} = $locale->text('Audit Control');
2525 AM->closedto(\%myconfig, \%$form);
2532 <form method=post action=am.pl>
2535 <tr><th class=listtop>$form->{title}</th></tr>
2536 <tr height="5"></tr>
2541 <th>| . $locale->text('Close Books up to') . qq|</th>
2542 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
2552 <input type=hidden name=nextsub value=doclose>
2554 <input type=submit class=submit name=action value="|
2555 . $locale->text('Continue') . qq|">
2563 $lxdebug->leave_sub();
2567 $lxdebug->enter_sub();
2569 $auth->assert('config');
2571 AM->closebooks(\%myconfig, \%$form);
2573 if ($form->{closedto}) {
2575 $locale->text('Books closed up to') . " "
2576 . $locale->date(\%myconfig, $form->{closedto}, 1));
2578 $form->redirect($locale->text('Books are open'));
2581 $lxdebug->leave_sub();
2585 $lxdebug->enter_sub();
2587 $auth->assert('config');
2589 $units = AM->retrieve_units(\%myconfig, $form, "resolved_");
2590 AM->units_in_use(\%myconfig, $form, $units);
2591 map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
2593 @languages = AM->language(\%myconfig, $form, 1);
2595 @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units}));
2598 foreach (@unit_list) {
2599 $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"});
2600 $_->{"UNITLANGUAGES"} = [];
2601 foreach my $lang (@languages) {
2602 push(@{ $_->{"UNITLANGUAGES"} },
2604 "unit" => $_->{"name"},
2605 "language_id" => $lang->{"id"},
2606 "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
2607 "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
2613 $units = AM->retrieve_units(\%myconfig, $form);
2614 $ddbox = AM->unit_select_data($units, undef, 1);
2616 my $updownlink = build_std_url("action=swap_units");
2618 $form->{"title"} = $locale->text("Add and edit units");
2620 print($form->parse_html_template("am/edit_units",
2621 { "UNITS" => \@unit_list,
2622 "NEW_BASE_UNIT_DDBOX" => $ddbox,
2623 "LANGUAGES" => \@languages,
2624 "updownlink" => $updownlink }));
2626 $lxdebug->leave_sub();
2630 $lxdebug->enter_sub();
2632 $auth->assert('config');
2634 $form->isblank("new_name", $locale->text("The name is missing."));
2635 $units = AM->retrieve_units(\%myconfig, $form);
2636 $all_units = AM->retrieve_units(\%myconfig, $form);
2637 $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
2639 my ($base_unit, $factor);
2640 if ($form->{"new_base_unit"}) {
2641 $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
2643 $form->isblank("new_factor", $locale->text("The factor is missing."));
2644 $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
2645 $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
2646 $base_unit = $form->{"new_base_unit"};
2650 foreach my $lang (AM->language(\%myconfig, $form, 1)) {
2651 next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
2652 push(@languages, { "id" => $lang->{"id"},
2653 "localized" => $form->{"new_localized_$lang->{id}"},
2654 "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
2658 AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, \@languages);
2660 $form->{"saved_message"} = $locale->text("The unit has been saved.");
2664 $lxdebug->leave_sub();
2667 sub set_unit_languages {
2668 $lxdebug->enter_sub();
2670 $auth->assert('config');
2672 my ($unit, $languages, $idx) = @_;
2674 $unit->{"LANGUAGES"} = [];
2676 foreach my $lang (@{$languages}) {
2677 push(@{ $unit->{"LANGUAGES"} },
2678 { "id" => $lang->{"id"},
2679 "localized" => $form->{"localized_${idx}_$lang->{id}"},
2680 "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
2684 $lxdebug->leave_sub();
2688 $lxdebug->enter_sub();
2690 $auth->assert('config');
2692 $old_units = AM->retrieve_units(\%myconfig, $form, "resolved_");
2693 AM->units_in_use(\%myconfig, $form, $old_units);
2695 @languages = AM->language(\%myconfig, $form, 1);
2699 foreach $i (1..($form->{"rowcount"} * 1)) {
2700 $old_unit = $old_units->{$form->{"old_name_$i"}};
2702 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
2705 if ($form->{"unchangeable_$i"}) {
2706 $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
2707 $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
2708 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2712 if ($old_unit->{"in_use"}) {
2713 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
2716 if ($form->{"delete_$i"}) {
2717 push(@delete_units, $old_unit->{"name"});
2721 $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
2723 $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
2724 my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
2725 $new_units->{$form->{"name_$i"}} = \%h;
2726 $new_units->{$form->{"name_$i"}}->{"row"} = $i;
2727 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2730 foreach $unit (values(%{$new_units})) {
2731 next unless ($unit->{"old_name"});
2732 if ($unit->{"base_unit"}) {
2733 $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"}))
2734 unless (defined($new_units->{$unit->{"base_unit"}}));
2735 $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
2736 $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
2738 $unit->{"base_unit"} = undef;
2739 $unit->{"factor"} = undef;
2743 foreach $unit (values(%{$new_units})) {
2744 next if ($unit->{"unchanged_unit"});
2746 map({ $_->{"seen"} = 0; } values(%{$new_units}));
2748 while ($new_unit->{"base_unit"}) {
2749 $new_unit->{"seen"} = 1;
2750 $new_unit = $new_units->{$new_unit->{"base_unit"}};
2751 if ($new_unit->{"seen"}) {
2752 $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, " .
2753 "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
2758 AM->save_units(\%myconfig, $form, $new_units, \@delete_units);
2760 $form->{"saved_message"} = $locale->text("The units have been saved.");
2764 $lxdebug->leave_sub();
2767 sub show_history_search {
2768 $lxdebug->enter_sub();
2770 $auth->assert('config');
2772 $form->{title} = $locale->text("History Search");
2775 print $form->parse_html_template("common/search_history");
2777 $lxdebug->leave_sub();
2780 sub show_am_history {
2781 $lxdebug->enter_sub();
2783 $auth->assert('config');
2785 my %search = ( "Artikelnummer" => "parts",
2786 "Kundennummer" => "customer",
2787 "Lieferantennummer" => "vendor",
2788 "Projektnummer" => "project",
2789 "Buchungsnummer" => "oe",
2790 "Eingangsrechnungnummer" => "ap",
2791 "Ausgangsrechnungnummer" => "ar",
2792 "Mahnungsnummer" => "dunning"
2794 my %searchNo = ( "Artikelnummer" => "partnumber",
2795 "Kundennummer" => "customernumber",
2796 "Lieferantennummer" => "vendornumber",
2797 "Projektnummer" => "projectnummer",
2798 "Buchungsnummer" => "ordnumber",
2799 "Eingangsrechnungnummer" => "invnumber",
2800 "Ausgangsrechnungnummer" => "invnumber",
2801 "Mahnungsnummer" => "dunning_id"
2806 foreach(split(/\,/, $form->{einschraenkungen})) {
2808 $restriction .= " AND addition = '" . $_ . "'";
2812 $restriction .= " OR addition = '" . $_ . "'";
2815 $restriction .= (($form->{transdate} ne "" && $form->{reqdate} ne "")
2816 ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|' AND st.itime::date <= '| . $form->{reqdate} . qq|'|
2817 : (($form->{transdate} ne "" && $form->{reqdate} eq "")
2818 ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|'|
2819 : ($form->{transdate} eq "" && $form->{reqdate} ne "")
2820 ? qq| AND st.itime::date <= '| . $form->{reqdate} . qq|'|
2824 $restriction .= ($form->{mitarbeiter} eq "" ? ""
2825 : ($form->{mitarbeiter} =~ /^[0-9]*$/
2826 ? " AND employee_id = " . $form->{mitarbeiter}
2827 : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
2829 my $dbh = $form->dbconnect(\%myconfig);
2830 my $query = qq|SELECT trans_id AS id FROM history_erp | .
2831 ($form->{'searchid'} ?
2832 qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'| :
2833 qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
2835 my $sth = $dbh->prepare($query);
2837 $sth->execute() || $form->dberror($query);
2839 $form->{title} = $locale->text("History Search");
2844 while(my $hash_ref = $sth->fetchrow_hashref()){
2846 $daten .= $hash_ref->{id};
2850 $daten .= " OR trans_id = " . $hash_ref->{id};
2854 my ($sort, $sortby) = split(/\-\-/, $form->{order});
2855 $sort =~ s/.*\.(.*)$/$1/;
2857 print $form->parse_html_template("common/show_history",
2858 {"DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}),
2859 "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
2862 uc($sort)."BY" => $sortby
2865 $lxdebug->leave_sub();
2868 sub get_employee_id {
2869 $lxdebug->enter_sub();
2871 $auth->assert('config');
2873 my $query = qq|SELECT id FROM employee WHERE name = '| . $_[0] . qq|'|;
2874 my $sth = $_[1]->prepare($query);
2875 $sth->execute() || $form->dberror($query);
2876 my $return = $sth->fetch();
2878 return ${$return}[0];
2879 $lxdebug->leave_sub();
2883 $lxdebug->enter_sub();
2885 $auth->assert('config');
2887 my $dir = $form->{"dir"} eq "down" ? "down" : "up";
2888 AM->swap_units(\%myconfig, $form, $dir, $form->{"name"});
2892 $lxdebug->leave_sub();
2896 $lxdebug->enter_sub();
2898 $auth->assert('config');
2900 $form->{title} = $locale->text('Add');
2902 $form->{callback} ||= "am.pl?action=add_tax";
2904 _get_taxaccount_selection();
2908 my $parameters_ref = {
2909 # ChartTypeIsAccount => $ChartTypeIsAccount,
2912 # Ausgabe des Templates
2913 print($form->parse_html_template('am/edit_tax', $parameters_ref));
2915 $lxdebug->leave_sub();
2919 $lxdebug->enter_sub();
2921 $auth->assert('config');
2923 $form->{title} = $locale->text('Edit');
2925 AM->get_tax(\%myconfig, \%$form);
2926 _get_taxaccount_selection();
2928 $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
2932 my $parameters_ref = {
2935 # Ausgabe des Templates
2936 print($form->parse_html_template('am/edit_tax', $parameters_ref));
2938 $lxdebug->leave_sub();
2942 $lxdebug->enter_sub();
2944 $auth->assert('config');
2946 AM->taxes(\%myconfig, \%$form);
2948 map { $_->{rate} = $form->format_amount(\%myconfig, $_->{rate}, 2) } @{ $form->{TAX} };
2950 $form->{callback} = build_std_url('action=list_tax');
2952 $form->{title} = $locale->text('Tax-O-Matic');
2956 # Ausgabe des Templates
2957 print($form->parse_html_template('am/list_tax', $parameters_ref));
2959 $lxdebug->leave_sub();
2962 sub _get_taxaccount_selection{
2963 $lxdebug->enter_sub();
2965 $auth->assert('config');
2967 AM->get_tax_accounts(\%myconfig, \%$form);
2969 map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} };
2971 $lxdebug->leave_sub();
2975 $lxdebug->enter_sub();
2977 $auth->assert('config');
2979 $form->isblank("rate", $locale->text('Taxrate missing!'));
2980 $form->isblank("taxdescription", $locale->text('Taxdescription missing!'));
2981 $form->isblank("taxkey", $locale->text('Taxkey missing!'));
2983 $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate});
2985 if ( $form->{rate} < 0 || $form->{rate} >= 100 ) {
2986 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
2989 if ( $form->{rate} <= 0.99 && $form->{rate} > 0 ) {
2990 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
2993 AM->save_tax(\%myconfig, \%$form);
2994 $form->redirect($locale->text('Tax saved!'));
2996 $lxdebug->leave_sub();
3000 $lxdebug->enter_sub();
3002 $auth->assert('config');
3004 AM->delete_tax(\%myconfig, \%$form);
3005 $form->redirect($locale->text('Tax deleted!'));
3007 $lxdebug->leave_sub();
3010 sub add_price_factor {
3011 $lxdebug->enter_sub();
3013 $auth->assert('config');
3015 $form->{title} = $locale->text('Add Price Factor');
3016 $form->{callback} ||= build_std_url('action=add_price_factor');
3017 $form->{fokus} = 'description';
3020 print $form->parse_html_template('am/edit_price_factor');
3022 $lxdebug->leave_sub();
3025 sub edit_price_factor {
3026 $lxdebug->enter_sub();
3028 $auth->assert('config');
3030 $form->{title} = $locale->text('Edit Price Factor');
3031 $form->{callback} ||= build_std_url('action=add_price_factor');
3032 $form->{fokus} = 'description';
3034 AM->get_price_factor(\%myconfig, $form);
3036 $form->{factor} = $form->format_amount(\%myconfig, $form->{factor} * 1);
3039 print $form->parse_html_template('am/edit_price_factor');
3041 $lxdebug->leave_sub();
3044 sub list_price_factors {
3045 $lxdebug->enter_sub();
3047 $auth->assert('config');
3049 AM->get_all_price_factors(\%myconfig, \%$form);
3052 foreach my $current (@{ $form->{PRICE_FACTORS} }) {
3054 $previous->{next_id} = $current->{id};
3055 $current->{previous_id} = $previous->{id};
3058 $current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1);
3060 $previous = $current;
3063 $form->{callback} = build_std_url('action=list_price_factors');
3064 $form->{title} = $locale->text('Price Factors');
3065 $form->{url_base} = build_std_url('callback');
3068 print $form->parse_html_template('am/list_price_factors');
3070 $lxdebug->leave_sub();
3073 sub save_price_factor {
3074 $lxdebug->enter_sub();
3076 $auth->assert('config');
3078 $form->isblank("description", $locale->text('Description missing!'));
3079 $form->isblank("factor", $locale->text('Factor missing!'));
3081 $form->{factor} = $form->parse_amount(\%myconfig, $form->{factor});
3083 AM->save_price_factor(\%myconfig, $form);
3085 $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor saved!')) if ($form->{callback});
3087 $form->redirect($locale->text('Price factor saved!'));
3089 $lxdebug->leave_sub();
3092 sub delete_price_factor {
3093 $lxdebug->enter_sub();
3095 $auth->assert('config');
3097 AM->delete_price_factor(\%myconfig, \%$form);
3099 $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor deleted!')) if ($form->{callback});
3101 $form->redirect($locale->text('Price factor deleted!'));
3103 $lxdebug->leave_sub();
3106 sub swap_price_factors {
3107 $lxdebug->enter_sub();
3109 $auth->assert('config');
3111 AM->swap_sortkeys(\%myconfig, $form, 'price_factors');
3112 list_price_factors();
3114 $lxdebug->leave_sub();
3118 $lxdebug->enter_sub();
3120 $auth->assert('config');
3122 $form->{title} = $locale->text('Add Warehouse');
3123 $form->{callback} ||= build_std_url('action=add_warehouse');
3124 $form->{fokus} = 'description';
3127 print $form->parse_html_template('am/edit_warehouse');
3129 $lxdebug->leave_sub();
3132 sub edit_warehouse {
3133 $lxdebug->enter_sub();
3135 $auth->assert('config');
3137 AM->get_warehouse(\%myconfig, $form);
3139 $form->get_lists('employees' => 'EMPLOYEES');
3141 $form->{title} = $locale->text('Edit Warehouse');
3142 $form->{callback} ||= build_std_url('action=list_warehouses');
3143 $form->{fokus} = 'description';
3146 print $form->parse_html_template('am/edit_warehouse');
3148 $lxdebug->leave_sub();
3151 sub list_warehouses {
3152 $lxdebug->enter_sub();
3154 $auth->assert('config');
3156 AM->get_all_warehouses(\%myconfig, $form);
3159 foreach my $current (@{ $form->{WAREHOUSES} }) {
3161 $previous->{next_id} = $current->{id};
3162 $current->{previous_id} = $previous->{id};
3165 $previous = $current;
3168 $form->{callback} = build_std_url('action=list_warehouses');
3169 $form->{title} = $locale->text('Warehouses');
3170 $form->{url_base} = build_std_url('callback');
3173 print $form->parse_html_template('am/list_warehouses');
3175 $lxdebug->leave_sub();
3178 sub save_warehouse {
3179 $lxdebug->enter_sub();
3181 $auth->assert('config');
3183 $form->isblank("description", $locale->text('Description missing!'));
3185 $form->{number_of_new_bins} = $form->parse_amount(\%myconfig, $form->{number_of_new_bins});
3187 AM->save_warehouse(\%myconfig, $form);
3189 $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse saved.')) if ($form->{callback});
3191 $form->redirect($locale->text('Warehouse saved.'));
3193 $lxdebug->leave_sub();
3196 sub swap_warehouses {
3197 $lxdebug->enter_sub();
3199 $auth->assert('config');
3201 AM->swap_sortkeys(\%myconfig, $form, 'warehouse');
3204 $lxdebug->leave_sub();
3207 sub delete_warehouse {
3208 $lxdebug->enter_sub();
3210 $auth->assert('config');
3212 if (!$form->{confirmed}) {
3213 $form->{title} = $locale->text('Confirmation');
3216 print $form->parse_html_template('am/confirm_delete_warehouse');
3220 if (AM->delete_warehouse(\%myconfig, $form)) {
3221 $form->{callback} .= '&saved_message=' . E($locale->text('Warehouse deleted.')) if ($form->{callback});
3222 $form->redirect($locale->text('Warehouse deleted.'));
3225 $form->error($locale->text('The warehouse could not be deleted because it has already been used.'));
3228 $lxdebug->leave_sub();
3232 $lxdebug->enter_sub();
3234 $auth->assert('config');
3236 AM->save_bins(\%myconfig, $form);
3238 $form->{callback} .= '&saved_message=' . E($locale->text('Bins saved.')) if ($form->{callback});
3240 $form->redirect($locale->text('Bins saved.'));
3242 $lxdebug->leave_sub();