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 #======================================================================
48 require "bin/mozilla/common.pl";
52 sub add { call_sub("add_$form->{type}"); }
53 sub delete { call_sub("delete_$form->{type}"); }
54 sub save { call_sub("save_$form->{type}"); }
55 sub edit { call_sub("edit_$form->{type}"); }
56 sub continue { call_sub($form->{"nextsub"}); }
59 $lxdebug->enter_sub();
61 $auth->assert('config');
63 $form->{title} = "Add";
64 $form->{charttype} = "A";
65 AM->get_account(\%myconfig, \%$form);
67 $form->{callback} = "am.pl?action=list_account" unless $form->{callback};
72 $lxdebug->leave_sub();
76 $lxdebug->enter_sub();
78 $auth->assert('config');
80 $form->{title} = "Edit";
81 AM->get_account(\%myconfig, \%$form);
83 foreach my $item (split(/:/, $form->{link})) {
84 $form->{$item} = "checked";
90 $lxdebug->leave_sub();
94 $lxdebug->enter_sub();
96 $auth->assert('config');
98 if ( $form->{action} eq 'edit_account') {
99 $form->{account_exists} = '1';
102 $form->{title} = $locale->text("$form->{title} Account");
104 $form->{"$form->{charttype}_checked"} = "checked";
105 $form->{"$form->{category}_checked"} = "checked";
107 $form->{select_tax} = "";
109 my @tax_report_pos = USTVA->report_variables({
110 myconfig => \%myconfig,
113 attribute => 'position',
117 if (@{ $form->{TAXKEY} }) {
118 foreach my $item (@{ $form->{TAXKEY} }) {
119 $item->{rate} = $item->{rate} * 100 . '%';
122 # Fill in empty row for new Taxkey
128 taxdescription => '',
135 push @{ $form->{ACCOUNT_TAXKEYS} }, $newtaxkey_ref;
138 foreach my $taxkey_used (@{ $form->{ACCOUNT_TAXKEYS} } ) {
140 # Fill in a runningnumber
141 $form->{ACCOUNT_TAXKEYS}[$i]{runningnumber} = $i;
143 # Fill in the Taxkeys as select options
144 foreach my $item (@{ $form->{TAXKEY} }) {
145 if ($item->{id} == $taxkey_used->{tax_id}) {
146 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
147 qq|<option value="$item->{id}" selected="selected">|
148 . sprintf("%.2d", $item->{taxkey})
149 . qq|. $item->{taxdescription} ($item->{rate}) |
150 . $locale->text('Tax-o-matic Account')
151 . qq|: $item->{chart_accno}\n|;
154 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
155 qq|<option value="$item->{id}">|
156 . sprintf("%.2d", $item->{taxkey})
157 . qq|. $item->{taxdescription} ($item->{rate}) |
158 . $locale->text('Tax-o-matic Account')
159 . qq|: $item->{chart_accno}\n|;
164 # Fill in the USTVA Numbers as select options
165 foreach my $item ( '', sort({ $a cmp $b } @tax_report_pos) ) {
167 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="" selected="selected">-\n|;
169 elsif ( $item eq $taxkey_used->{pos_ustva} ) {
170 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item" selected="selected">$item\n|;
173 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item">$item\n|;
182 # Newaccount Folgekonto
183 if (@{ $form->{NEWACCOUNT} }) {
184 if (!$form->{new_chart_valid}) {
185 $form->{selectnewaccount} = qq|<option value=""> |. $locale->text('None') .q|</option>|;
187 foreach $item (@{ $form->{NEWACCOUNT} }) {
188 if ($item->{id} == $form->{new_chart_id}) {
189 $form->{selectnewaccount} .=
190 qq|<option value="$item->{id}" selected>$item->{accno}--$item->{description}</option>|;
191 } elsif (!$form->{new_chart_valid}) {
192 $form->{selectnewaccount} .=
193 qq|<option value="$item->{id}">$item->{accno}--$item->{description}</option>|;
199 $select_eur = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
200 %eur = (1 => "Umsatzerlöse",
201 2 => "sonstige Erlöse",
202 3 => "Privatanteile",
204 5 => "Ausserordentliche Erträge",
205 6 => "Vereinnahmte Umsatzst.",
206 7 => "Umsatzsteuererstattungen",
207 8 => "Wareneingänge",
208 9 => "Löhne und Gehälter",
209 10 => "Gesetzl. sozialer Aufw.",
211 12 => "Gas, Strom, Wasser",
212 13 => "Instandhaltung",
213 14 => "Steuern, Versich., Beiträge",
215 16 => "Kfz-Versicherungen",
216 17 => "Sonst. Fahrtkosten",
217 18 => "Werbe- und Reisekosten",
218 19 => "Instandhaltung u. Werkzeuge",
219 20 => "Fachzeitschriften, Bücher",
220 21 => "Miete für Einrichtungen",
221 22 => "Rechts- und Beratungskosten",
222 23 => "Bürobedarf, Porto, Telefon",
223 24 => "Sonstige Aufwendungen",
224 25 => "Abschreibungen auf Anlagever.",
225 26 => "Abschreibungen auf GWG",
227 28 => "Umsatzsteuerzahlungen",
229 30 => "Ausserordentlicher Aufwand",
230 31 => "Betriebliche Steuern");
231 foreach $item (sort({ $a <=> $b } keys(%eur))) {
232 my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $eur{$item}));
233 if ($item == $form->{pos_eur}) {
234 $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
236 $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
241 $select_bwa = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
243 %bwapos = (1 => 'Umsatzerlöse',
244 2 => 'Best.Verdg.FE/UE',
245 3 => 'Aktiv.Eigenleistung',
246 4 => 'Mat./Wareneinkauf',
247 5 => 'So.betr.Erlöse',
248 10 => 'Personalkosten',
250 12 => 'Betriebl.Steuern',
251 13 => 'Vers./Beiträge',
252 14 => 'Kfz.Kosten o.St.',
253 15 => 'Werbe-Reisek.',
254 16 => 'Kosten Warenabgabe',
255 17 => 'Abschreibungen',
256 18 => 'Rep./instandhlt.',
257 19 => 'Übrige Steuern',
258 20 => 'Sonst.Kosten',
260 31 => 'Sonst.neutr.Aufw.',
262 33 => 'Sonst.neutr.Ertrag',
263 34 => 'Verr.kalk.Kosten',
264 35 => 'Steuern Eink.u.Ertr.');
265 foreach $item (sort({ $a <=> $b } keys %bwapos)) {
266 my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $bwapos{$item}));
267 if ($item == $form->{pos_bwa}) {
268 $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $text\n|;
270 $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $text\n|;
275 # Wieder hinzugefügt zu evaluationszwecken (us) 09.03.2007
276 $select_bilanz = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
277 foreach $item ((1, 2, 3, 4)) {
278 if ($item == $form->{pos_bilanz}) {
279 $select_bilanz .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|.\n|;
281 $select_bilanz .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|.\n|;
286 # this is for our parser only! Do not remove.
287 # type=submit $locale->text('Add Account')
288 # type=submit $locale->text('Edit Account')
290 $form->{type} = "account";
292 # preselections category
294 $select_category = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
297 'A' => $locale->text('Asset'),
298 'L' => $locale->text('Liability'),
299 'Q' => $locale->text('Equity'),
300 'I' => $locale->text('Revenue'),
301 'E' => $locale->text('Expense'),
302 'C' => $locale->text('Costs'),
304 foreach $item ( sort({ $a <=> $b } keys %category) ) {
305 if ($item eq $form->{category}) {
306 $select_category .= qq|<option value="$item" selected="selected">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
308 $select_category .= qq|<option value="$item">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
313 # preselection chart type
314 my $select_charttype = q{};
317 'A' => $locale->text('Account'),
318 'H' => $locale->text('Header'),
321 foreach $item ( sort({ $a <=> $b } keys %charttype) ) {
322 if ($item eq $form->{charttype}) {
323 $select_charttype .= qq|<option value="$item" selected="selected">$charttype{$item}\n|;
326 $select_charttype .= qq|<option value="$item">$charttype{$item}\n|;
331 my $ChartTypeIsAccount = ($form->{charttype} eq "A") ? "1":"";
335 my $parameters_ref = {
336 ChartTypeIsAccount => $ChartTypeIsAccount,
337 select_category => $select_category,
338 select_charttype => $select_charttype,
339 newaccount => $newaccount,
341 select_bwa => $select_bwa,
342 select_bilanz => $select_bilanz,
343 select_eur => $select_eur,
346 # Ausgabe des Templates
347 print($form->parse_html_template('am/edit_accounts', $parameters_ref));
350 $lxdebug->leave_sub();
354 $lxdebug->enter_sub();
356 $auth->assert('config');
360 <input name=callback type=hidden value="| . H($form->{callback}) . qq|">
363 if ((!$form->{id}) || ($form->{id} && $form->{orphaned}) || (($form->{type} eq "account") && (!$form->{new_chart_valid}))) {
365 <input type=submit class=submit name=action value="|
366 . $locale->text('Save') . qq|">
370 if ($form->{id} && $form->{orphaned}) {
371 print qq|<input type=submit class=submit name=action value="|
372 . $locale->text('Delete') . qq|">|;
382 $lxdebug->leave_sub();
386 $lxdebug->enter_sub();
388 $auth->assert('config');
390 $form->isblank("accno", $locale->text('Account Number missing!'));
391 $form->isblank("description", $locale->text('Account Description missing!'));
393 if ($form->{charttype} eq 'A'){
394 $form->isblank("category", $locale->text('Account Type missing!'));
397 $form->redirect($locale->text('Account saved!'))
398 if (AM->save_account(\%myconfig, \%$form));
399 $form->error($locale->text('Cannot save account!'));
401 $lxdebug->leave_sub();
405 $lxdebug->enter_sub();
407 $auth->assert('config');
409 $form->{callback} = build_std_url('action=list_account');
410 my $link_edit_account = build_std_url('action=edit_account', 'callback');
412 CA->all_accounts(\%myconfig, \%$form);
414 foreach $ca (@{ $form->{CA} }) {
419 if ($ca->{amount} > 0) {
420 $ca->{credit} = $form->format_amount(\%myconfig, $ca->{amount}, 2);
422 if ($ca->{amount} < 0) {
423 $ca->{debit} = $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2);
425 $ca->{heading} = ( $ca->{charttype} eq 'H' ) ? 1:'';
426 $ca->{link_edit_account} = $link_edit_account . '&id=' . E($ca->{id});
430 my $pjx = new CGI::Ajax('list_account_details' => build_std_url('action=list_account_details'));
432 # Eneable AJAX debuging
436 push(@ { $form->{AJAX} }, $pjx);
438 $form->{stylesheets} = "list_accounts.css";
439 $form->{title} = $locale->text('Chart of Accounts');
444 my $parameters_ref = {
445 # hidden_variables => $_hidden_variables_ref,
448 # Ausgabe des Templates
449 print($form->parse_html_template('am/list_accounts', $parameters_ref));
451 $lxdebug->leave_sub();
456 sub list_account_details {
457 # Ajax Funktion aus list_account_details
458 $lxdebug->enter_sub();
460 $auth->assert('config');
462 my $chart_id = $form->{args};
464 CA->all_accounts(\%myconfig, \%$form, $chart_id);
466 foreach $ca (@{ $form->{CA} }) {
468 $ca->{debit} = " ";
469 $ca->{credit} = " ";
471 if ($ca->{amount} > 0) {
473 $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
475 if ($ca->{amount} < 0) {
477 $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2, " ");
480 my @links = split( q{:}, $ca->{link});
484 foreach my $link (@links){
485 $link = ( $link eq 'AR') ? $locale->text('Account Link AR')
486 : ( $link eq 'AP') ? $locale->text('Account Link AP')
487 : ( $link eq 'IC') ? $locale->text('Account Link IC')
488 : ( $link eq 'AR_amount' ) ? $locale->text('Account Link AR_amount')
489 : ( $link eq 'AR_paid' ) ? $locale->text('Account Link AR_paid')
490 : ( $link eq 'AR_tax' ) ? $locale->text('Account Link AR_tax')
491 : ( $link eq 'AP_amount' ) ? $locale->text('Account Link AP_amount')
492 : ( $link eq 'AP_paid' ) ? $locale->text('Account Link AP_paid')
493 : ( $link eq 'AP_tax' ) ? $locale->text('Account Link AP_tax')
494 : ( $link eq 'IC_sale' ) ? $locale->text('Account Link IC_sale')
495 : ( $link eq 'IC_cogs' ) ? $locale->text('Account Link IC_cogs')
496 : ( $link eq 'IC_taxpart' ) ? $locale->text('Account Link IC_taxpart')
497 : ( $link eq 'IC_income' ) ? $locale->text('Account Link IC_income')
498 : ( $link eq 'IC_expense' ) ? $locale->text('Account Link IC_expense')
499 : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice')
500 # : ( $link eq 'CT_tax' ) ? $locale->text('Account Link CT_tax')
501 : $locale->text('Unknown Link') . ': ' . $link;
502 $ca->{link} .= ($link ne '') ? "[$link] ":'';
505 $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
506 : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
507 : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
508 : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
509 : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
510 : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
511 : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
512 : $locale->text('Unknown Category') . ': ' . $ca->{category};
515 $form->{title} = $locale->text('Chart of Accounts');
518 print $form->parse_html_template('am/list_account_details');
520 $lxdebug->leave_sub();
525 $lxdebug->enter_sub();
527 $auth->assert('config');
529 $form->{title} = $locale->text('Delete Account');
532 qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
534 if ($form->{id} == $form->{$id}) {
535 $form->error($locale->text('Cannot delete default account!'));
539 $form->redirect($locale->text('Account deleted!'))
540 if (AM->delete_account(\%myconfig, \%$form));
541 $form->error($locale->text('Cannot delete account!'));
543 $lxdebug->leave_sub();
547 $lxdebug->enter_sub();
549 $auth->assert('config');
551 $form->{title} = "Add";
554 $form->{callback} = "am.pl?action=add_department" unless $form->{callback};
559 $lxdebug->leave_sub();
562 sub edit_department {
563 $lxdebug->enter_sub();
565 $auth->assert('config');
567 $form->{title} = "Edit";
569 AM->get_department(\%myconfig, \%$form);
574 $lxdebug->leave_sub();
577 sub list_department {
578 $lxdebug->enter_sub();
580 $auth->assert('config');
582 AM->departments(\%myconfig, \%$form);
584 $form->{callback} = "am.pl?action=list_department";
586 $callback = $form->escape($form->{callback});
588 $form->{title} = $locale->text('Departments');
590 @column_index = qw(description cost profit);
592 $column_header{description} =
593 qq|<th class=listheading width=90%>|
594 . $locale->text('Description')
596 $column_header{cost} =
597 qq|<th class=listheading nowrap>|
598 . $locale->text('Cost Center')
600 $column_header{profit} =
601 qq|<th class=listheading nowrap>|
602 . $locale->text('Profit Center')
612 <th class=listtop>$form->{title}</th>
618 <tr class=listheading>
621 map { print "$column_header{$_}\n" } @column_index;
627 foreach $ref (@{ $form->{ALL} }) {
633 <tr valign=top class=listrow$i>
636 $costcenter = ($ref->{role} eq "C") ? "X" : "";
637 $profitcenter = ($ref->{role} eq "P") ? "X" : "";
639 $column_data{description} =
640 qq|<td><a href="am.pl?action=edit_department&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
641 $column_data{cost} = qq|<td align=center>$costcenter</td>|;
642 $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
644 map { print "$column_data{$_}\n" } @column_index;
656 <td><hr size=3 noshade></td>
661 <form method=post action=am.pl>
663 <input name=callback type=hidden value="$form->{callback}">
665 <input type=hidden name=type value=department>
667 <input class=submit type=submit name=action value="|
668 . $locale->text('Add') . qq|">
676 $lxdebug->leave_sub();
679 sub department_header {
680 $lxdebug->enter_sub();
682 $auth->assert('config');
684 $form->{title} = $locale->text("$form->{title} Department");
686 # $locale->text('Add Department')
687 # $locale->text('Edit Department')
689 $form->{description} =~ s/\"/"/g;
691 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
693 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
696 qq|<input name=description size=60 value="$form->{description}">|;
699 $costcenter = "checked" if $form->{role} eq "C";
700 $profitcenter = "checked" if $form->{role} eq "P";
707 <form method=post action=am.pl>
709 <input type=hidden name=id value=$form->{id}>
710 <input type=hidden name=type value=department>
714 <th class=listtop colspan=2>$form->{title}</th>
718 <th align=right>| . $locale->text('Description') . qq|</th>
719 <td>$description</td>
723 <td><input type=radio style=radio name=role value="C" $costcenter> |
724 . $locale->text('Cost Center') . qq|
725 <input type=radio style=radio name=role value="P" $profitcenter> |
726 . $locale->text('Profit Center') . qq|
729 <td colspan=2><hr size=3 noshade></td>
734 $lxdebug->leave_sub();
737 sub save_department {
738 $lxdebug->enter_sub();
740 $auth->assert('config');
742 $form->isblank("description", $locale->text('Description missing!'));
743 AM->save_department(\%myconfig, \%$form);
744 $form->redirect($locale->text('Department saved!'));
746 $lxdebug->leave_sub();
749 sub delete_department {
750 $lxdebug->enter_sub();
752 $auth->assert('config');
754 AM->delete_department(\%myconfig, \%$form);
755 $form->redirect($locale->text('Department deleted!'));
757 $lxdebug->leave_sub();
761 $lxdebug->enter_sub();
763 $auth->assert('config');
765 $form->{title} = "Add";
767 $form->{callback} = "am.pl?action=add_lead" unless $form->{callback};
772 $lxdebug->leave_sub();
776 $lxdebug->enter_sub();
778 $auth->assert('config');
780 $form->{title} = "Edit";
782 AM->get_lead(\%myconfig, \%$form);
786 $form->{orphaned} = 1;
789 $lxdebug->leave_sub();
793 $lxdebug->enter_sub();
795 $auth->assert('config');
797 AM->lead(\%myconfig, \%$form);
799 $form->{callback} = "am.pl?action=list_lead";
801 $callback = $form->escape($form->{callback});
803 $form->{title} = $locale->text('Lead');
805 @column_index = qw(description cost profit);
807 $column_header{description} =
808 qq|<th class=listheading width=100%>|
809 . $locale->text('Description')
819 <th class=listtop>$form->{title}</th>
822 <tr class=listheading>
825 map { print "$column_header{$_}\n" } @column_index;
831 foreach $ref (@{ $form->{ALL} }) {
837 <tr valign=top class=listrow$i>
840 $lead = $ref->{lead};
842 $column_data{description} = qq|<td><a href="am.pl?action=edit_lead&id=$ref->{id}&callback=$callback">$ref->{lead}</td>|;
844 map { print "$column_data{$_}\n" } @column_index;
853 <td><hr size=3 noshade></td>
858 <form method=post action=am.pl>
860 <input name=callback type=hidden value="$form->{callback}">
862 <input type=hidden name=type value=lead>
864 <input class=submit type=submit name=action value="|
865 . $locale->text('Add') . qq|">
873 $lxdebug->leave_sub();
877 $lxdebug->enter_sub();
879 $auth->assert('config');
881 $form->{title} = $locale->text("$form->{title} Lead");
883 # $locale->text('Add Lead')
884 # $locale->text('Edit Lead')
886 $form->{description} =~ s/\"/"/g;
889 qq|<input name=description size=50 value="$form->{lead}">|;
896 <form method=post action=am.pl>
898 <input type=hidden name=id value=$form->{id}>
899 <input type=hidden name=type value=lead>
903 <th class=listtop colspan=2>$form->{title}</th>
907 <th align=right>| . $locale->text('Description') . qq|</th>
908 <td>$description</td>
910 <td colspan=2><hr size=3 noshade></td>
915 $lxdebug->leave_sub();
919 $lxdebug->enter_sub();
921 $auth->assert('config');
923 $form->isblank("description", $locale->text('Description missing!'));
924 AM->save_lead(\%myconfig, \%$form);
925 $form->redirect($locale->text('lead saved!'));
927 $lxdebug->leave_sub();
931 $lxdebug->enter_sub();
933 $auth->assert('config');
935 AM->delete_lead(\%myconfig, \%$form);
936 $form->redirect($locale->text('lead deleted!'));
938 $lxdebug->leave_sub();
942 $lxdebug->enter_sub();
944 $auth->assert('config');
946 $form->{title} = "Add";
948 $form->{callback} = "am.pl?action=add_business" unless $form->{callback};
953 $lxdebug->leave_sub();
957 $lxdebug->enter_sub();
959 $form->{title} = "Edit";
961 AM->get_business(\%myconfig, \%$form);
965 $form->{orphaned} = 1;
968 $lxdebug->leave_sub();
972 $lxdebug->enter_sub();
974 $auth->assert('config');
976 AM->business(\%myconfig, \%$form);
978 $form->{callback} = "am.pl?action=list_business";
980 $callback = $form->escape($form->{callback});
982 $form->{title} = $locale->text('Type of Business');
984 @column_index = qw(description discount customernumberinit);
986 $column_header{description} =
987 qq|<th class=listheading width=60%>|
988 . $locale->text('Description')
990 $column_header{discount} =
991 qq|<th class=listheading width=10%>|
992 . $locale->text('Discount')
994 $column_header{customernumberinit} =
995 qq|<th class=listheading>|
996 . $locale->text('Customernumberinit')
1006 <th class=listtop>$form->{title}</th>
1008 <tr height="5"></tr>
1012 <tr class=listheading>
1015 map { print "$column_header{$_}\n" } @column_index;
1021 foreach $ref (@{ $form->{ALL} }) {
1027 <tr valign=top class=listrow$i>
1031 $form->format_amount(\%myconfig, $ref->{discount} * 100);
1033 $ref->{description};
1034 $column_data{description} = qq|<td><a href="am.pl?action=edit_business&id=$ref->{id}&callback=$callback">$description</td>|;
1035 $column_data{discount} = qq|<td align=right>$discount</td>|;
1036 $column_data{customernumberinit} =
1037 qq|<td align=right>$ref->{customernumberinit}</td>|;
1039 map { print "$column_data{$_}\n" } @column_index;
1051 <td><hr size=3 noshade></td>
1056 <form method=post action=am.pl>
1058 <input name=callback type=hidden value="$form->{callback}">
1060 <input type=hidden name=type value=business>
1062 <input class=submit type=submit name=action value="|
1063 . $locale->text('Add') . qq|">
1071 $lxdebug->leave_sub();
1074 sub business_header {
1075 $lxdebug->enter_sub();
1077 $auth->assert('config');
1079 $form->{title} = $locale->text("$form->{title} Business");
1081 # $locale->text('Add Business')
1082 # $locale->text('Edit Business')
1084 $form->{description} =~ s/\"/"/g;
1086 $form->format_amount(\%myconfig, $form->{discount} * 100);
1093 <form method=post action=am.pl>
1095 <input type=hidden name=id value=$form->{id}>
1096 <input type=hidden name=type value=business>
1100 <th class=listtop colspan=2>$form->{title}</th>
1102 <tr height="5"></tr>
1104 <th align=right>| . $locale->text('Type of Business') . qq|</th>
1105 <td><input name=description size=30 value="$form->{description}"></td>
1108 <th align=right>| . $locale->text('Discount') . qq| %</th>
1109 <td><input name=discount size=5 value=$form->{discount}></td>
1112 <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
1113 <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
1115 <td colspan=2><hr size=3 noshade></td>
1120 $lxdebug->leave_sub();
1124 $lxdebug->enter_sub();
1126 $auth->assert('config');
1128 $form->isblank("description", $locale->text('Description missing!'));
1129 $form->{discount} = $form->parse_amount(\%myconfig, $form->{discount}) / 100;
1130 AM->save_business(\%myconfig, \%$form);
1131 $form->redirect($locale->text('Business saved!'));
1133 $lxdebug->leave_sub();
1136 sub delete_business {
1137 $lxdebug->enter_sub();
1139 $auth->assert('config');
1141 AM->delete_business(\%myconfig, \%$form);
1142 $form->redirect($locale->text('Business deleted!'));
1144 $lxdebug->leave_sub();
1148 $lxdebug->enter_sub();
1150 $auth->assert('config');
1152 $form->{title} = "Add";
1154 $form->{callback} = "am.pl?action=add_language" unless $form->{callback};
1159 $lxdebug->leave_sub();
1163 $lxdebug->enter_sub();
1165 $auth->assert('config');
1167 $form->{title} = "Edit";
1169 AM->get_language(\%myconfig, \%$form);
1173 $form->{orphaned} = 1;
1176 $lxdebug->leave_sub();
1180 $lxdebug->enter_sub();
1182 $auth->assert('config');
1184 AM->language(\%myconfig, \%$form);
1186 $form->{callback} = "am.pl?action=list_language";
1188 $callback = $form->escape($form->{callback});
1190 $form->{title} = $locale->text('Languages');
1192 @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
1194 $column_header{description} =
1195 qq|<th class=listheading width=60%>|
1196 . $locale->text('Description')
1198 $column_header{template_code} =
1199 qq|<th class=listheading width=10%>|
1200 . $locale->text('Template Code')
1202 $column_header{article_code} =
1203 qq|<th class=listheading>|
1204 . $locale->text('Article Code')
1206 $column_header{output_numberformat} =
1207 qq|<th class=listheading>|
1208 . $locale->text('Number Format')
1210 $column_header{output_dateformat} =
1211 qq|<th class=listheading>|
1212 . $locale->text('Date Format')
1214 $column_header{output_longdates} =
1215 qq|<th class=listheading>|
1216 . $locale->text('Long Dates')
1226 <th class=listtop>$form->{title}</th>
1228 <tr height="5"></tr>
1232 <tr class=listheading>
1235 map { print "$column_header{$_}\n" } @column_index;
1241 foreach $ref (@{ $form->{ALL} }) {
1247 <tr valign=top class=listrow$i>
1251 $column_data{description} =
1252 qq|<td><a href="am.pl?action=edit_language&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
1253 $column_data{template_code} = qq|<td align=right>$ref->{template_code}</td>|;
1254 $column_data{article_code} =
1255 qq|<td align=right>$ref->{article_code}</td>|;
1256 $column_data{output_numberformat} =
1258 ($ref->{output_numberformat} ? $ref->{output_numberformat} :
1259 $locale->text("use program settings")) .
1261 $column_data{output_dateformat} =
1263 ($ref->{output_dateformat} ? $ref->{output_dateformat} :
1264 $locale->text("use program settings")) .
1266 $column_data{output_longdates} =
1268 ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
1271 map { print "$column_data{$_}\n" } @column_index;
1283 <td><hr size=3 noshade></td>
1288 <form method=post action=am.pl>
1290 <input name=callback type=hidden value="$form->{callback}">
1292 <input type=hidden name=type value=language>
1294 <input class=submit type=submit name=action value="|
1295 . $locale->text('Add') . qq|">
1303 $lxdebug->leave_sub();
1306 sub language_header {
1307 $lxdebug->enter_sub();
1309 $auth->assert('config');
1311 $form->{title} = $locale->text("$form->{title} Language");
1313 # $locale->text('Add Language')
1314 # $locale->text('Edit Language')
1316 $form->{description} =~ s/\"/"/g;
1317 $form->{template_code} =~ s/\"/"/g;
1318 $form->{article_code} =~ s/\"/"/g;
1324 qq|<option value="">| . $locale->text("use program settings") .
1326 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
1328 ($item eq $form->{output_numberformat})
1329 ? "<option selected>$item"
1335 qq|<option value="">| . $locale->text("use program settings") .
1337 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
1339 ($item eq $form->{output_dateformat})
1340 ? "<option selected>$item"
1348 <form method=post action=am.pl>
1350 <input type=hidden name=id value=$form->{id}>
1351 <input type=hidden name=type value=language>
1355 <th class=listtop colspan=2>$form->{title}</th>
1357 <tr height="5"></tr>
1359 <th align=right>| . $locale->text('Language') . qq|</th>
1360 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1363 <th align=right>| . $locale->text('Template Code') . qq|</th>
1364 <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
1367 <th align=right>| . $locale->text('Article Code') . qq|</th>
1368 <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
1371 <th align=right>| . $locale->text('Number Format') . qq|</th>
1372 <td><select name="output_numberformat">$numberformat</select></td>
1375 <th align=right>| . $locale->text('Date Format') . qq|</th>
1376 <td><select name="output_dateformat">$dateformat</select></td>
1379 <th align=right>| . $locale->text('Long Dates') . qq|</th>
1380 <td><input type="radio" name="output_longdates" value="1"| .
1381 ($form->{output_longdates} ? " checked" : "") .
1382 qq|>| . $locale->text("Yes") .
1383 qq|<input type="radio" name="output_longdates" value="0"| .
1384 ($form->{output_longdates} ? "" : " checked") .
1385 qq|>| . $locale->text("No") .
1388 <td colspan=2><hr size=3 noshade></td>
1393 $lxdebug->leave_sub();
1397 $lxdebug->enter_sub();
1399 $auth->assert('config');
1401 $form->isblank("description", $locale->text('Language missing!'));
1402 $form->isblank("template_code", $locale->text('Template Code missing!'));
1403 $form->isblank("article_code", $locale->text('Article Code missing!'));
1404 AM->save_language(\%myconfig, \%$form);
1405 $form->redirect($locale->text('Language saved!'));
1407 $lxdebug->leave_sub();
1410 sub delete_language {
1411 $lxdebug->enter_sub();
1413 $auth->assert('config');
1415 AM->delete_language(\%myconfig, \%$form);
1416 $form->redirect($locale->text('Language deleted!'));
1418 $lxdebug->leave_sub();
1422 sub add_buchungsgruppe {
1423 $lxdebug->enter_sub();
1425 $auth->assert('config');
1427 # $locale->text("Add Buchungsgruppe")
1428 # $locale->text("Edit Buchungsgruppe")
1429 $form->{title} = "Add";
1431 $form->{callback} = "am.pl?action=add_buchungsgruppe" unless $form->{callback};
1433 AM->get_buchungsgruppe(\%myconfig, \%$form);
1434 $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
1435 for (my $i = 0; 4 > $i; $i++) {
1436 map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
1437 qw(income expense));
1440 &buchungsgruppe_header;
1443 $lxdebug->leave_sub();
1446 sub edit_buchungsgruppe {
1447 $lxdebug->enter_sub();
1449 $auth->assert('config');
1451 $form->{title} = "Edit";
1453 AM->get_buchungsgruppe(\%myconfig, \%$form);
1455 &buchungsgruppe_header;
1459 $lxdebug->leave_sub();
1462 sub list_buchungsgruppe {
1463 $lxdebug->enter_sub();
1465 $auth->assert('config');
1467 AM->buchungsgruppe(\%myconfig, \%$form);
1469 $form->{callback} = "am.pl?action=list_buchungsgruppe";
1471 $callback = $form->escape($form->{callback});
1473 $form->{title} = $locale->text('Buchungsgruppen');
1475 @column_index = qw(up down description inventory_accno
1476 income_accno_0 expense_accno_0
1477 income_accno_1 expense_accno_1
1478 income_accno_2 expense_accno_2
1479 income_accno_3 expense_accno_3 );
1481 $column_header{up} =
1482 qq|<th class="listheading" width="16">|
1483 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
1485 $column_header{down} =
1486 qq|<th class="listheading" width="16">|
1487 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
1489 $column_header{description} =
1490 qq|<th class="listheading" width="40%">|
1491 . $locale->text('Description')
1493 $column_header{inventory_accno} =
1494 qq|<th class=listheading>|
1495 . $locale->text('Bestandskonto')
1497 $column_header{income_accno_0} =
1498 qq|<th class=listheading>|
1499 . $locale->text('National Revenues')
1501 $column_header{expense_accno_0} =
1502 qq|<th class=listheading>|
1503 . $locale->text('National Expenses')
1505 $column_header{income_accno_1} =
1506 qq|<th class=listheading>|
1507 . $locale->text('Revenues EU with UStId')
1509 $column_header{expense_accno_1} =
1510 qq|<th class=listheading>|
1511 . $locale->text('Expenses EU with UStId')
1513 $column_header{income_accno_2} =
1514 qq|<th class=listheading>|
1515 . $locale->text('Revenues EU without UStId')
1517 $column_header{expense_accno_2} =
1518 qq|<th class=listheading>|
1519 . $locale->text('Expenses EU without UStId')
1521 $column_header{income_accno_3} =
1522 qq|<th class=listheading>|
1523 . $locale->text('Foreign Revenues')
1525 $column_header{expense_accno_3} =
1526 qq|<th class=listheading>|
1527 . $locale->text('Foreign Expenses')
1536 <th class=listtop>$form->{title}</th>
1538 <tr height="5"></tr>
1542 <tr class=listheading>
1545 map { print "$column_header{$_}\n" } @column_index;
1551 my $swap_link = qq|am.pl?action=swap_buchungsgruppen&|;
1554 foreach $ref (@{ $form->{ALL} }) {
1560 <tr valign=top class=listrow$i>
1564 my $pref = $form->{ALL}->[$row - 1];
1566 qq|<td align="center" valign="center" width="16">| .
1567 qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
1568 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
1571 $column_data{up} = qq|<td width="16"> </td>|;
1574 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
1575 $column_data{down} = qq|<td width="16"> </td>|;
1577 my $nref = $form->{ALL}->[$row + 1];
1578 $column_data{down} =
1579 qq|<td align="center" valign="center" width="16">| .
1580 qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
1581 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
1585 $column_data{description} = qq|<td><a href="am.pl?action=edit_buchungsgruppe&id=$ref->{id}&callback=$callback">$ref->{description}</td>|;
1586 $column_data{inventory_accno} = qq|<td align=right>$ref->{inventory_accno}</td>|;
1587 $column_data{income_accno_0} =
1588 qq|<td align=right>$ref->{income_accno_0}</td>|;
1589 $column_data{expense_accno_0} = qq|<td align=right>$ref->{expense_accno_0}</td>|;
1590 $column_data{income_accno_1} =
1591 qq|<td align=right>$ref->{income_accno_1}</td>|;
1592 $column_data{expense_accno_1} = qq|<td align=right>$ref->{expense_accno_1}</td>|;
1593 $column_data{income_accno_2} =
1594 qq|<td align=right>$ref->{income_accno_2}</td>|;
1595 $column_data{expense_accno_2} = qq|<td align=right>$ref->{expense_accno_2}</td>|;
1596 $column_data{income_accno_3} =
1597 qq|<td align=right>$ref->{income_accno_3}</td>|;
1598 $column_data{expense_accno_3} = qq|<td align=right>$ref->{expense_accno_3}</td>|;
1600 map { print "$column_data{$_}\n" } @column_index;
1614 <td><hr size=3 noshade></td>
1619 <form method=post action=am.pl>
1621 <input name=callback type=hidden value="$form->{callback}">
1623 <input type=hidden name=type value=buchungsgruppe>
1625 <input class=submit type=submit name=action value="|
1626 . $locale->text('Add') . qq|">
1634 $lxdebug->leave_sub();
1637 sub buchungsgruppe_header {
1638 $lxdebug->enter_sub();
1640 $auth->assert('config');
1642 $form->{title} = $locale->text("$form->{title} Buchungsgruppe");
1644 # $locale->text('Add Accounting Group')
1645 # $locale->text('Edit Accounting Group')
1647 my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
1648 my %acc_type_map = (
1649 "IC" => $acc_inventory,
1650 "IC_income" => $acc_income,
1651 "IC_sale" => $acc_income,
1652 "IC_expense" => $acc_expense,
1653 "IC_cogs" => $acc_expense,
1656 foreach $key (keys(%acc_type_map)) {
1657 foreach $ref (@{ $form->{IC_links}{$key} }) {
1658 $acc_type_map{$key}->{$ref->{"id"}} = $ref;
1662 foreach my $type (qw(IC IC_income IC_expense)) {
1663 $form->{"select$type"} =
1665 map({ "<option value=$_->{id} $_->{selected}>" .
1666 "$_->{accno}--" . H($_->{description}) . "</option>" }
1667 sort({ $a->{"accno"} cmp $b->{"accno"} }
1668 values(%{$acc_type_map{$type}}))));
1672 $form->{selectIC} =~ s/selected//g;
1673 $form->{selectIC} =~ s/ value=\Q$form->{inventory_accno_id}\E/ value=$form->{inventory_accno_id} selected/;
1674 $form->{selectIC_income} =~ s/selected//g;
1675 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_0}\E/ value=$form->{income_accno_id_0} selected/;
1676 $form->{selectIC_expense} =~ s/selected//g;
1677 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_0}\E/ value=$form->{expense_accno_id_0} selected/;
1683 <th align=right>| . $locale->text('Inventory') . qq|</th>
1684 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
1685 <input name=selectIC type=hidden value="$form->{selectIC}">
1689 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
1693 $linkaccounts .= qq|
1695 <th align=right>| . $locale->text('National Revenues') . qq|</th>
1696 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
1699 <th align=right>| . $locale->text('National Expenses') . qq|</th>
1700 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
1703 $form->{selectIC_income} =~ s/selected//g;
1704 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_1}\E/ value=$form->{income_accno_id_1} selected/;
1705 $form->{selectIC_expense} =~ s/selected//g;
1706 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_1}\E/ value=$form->{expense_accno_id_1} selected/;
1708 $linkaccounts .= qq| <tr>
1709 <th align=right>| . $locale->text('Revenues EU with UStId') . qq|</th>
1710 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
1713 <th align=right>| . $locale->text('Expenses EU with UStId') . qq|</th>
1714 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
1718 $form->{selectIC_income} =~ s/selected//g;
1719 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_2}\E/ value=$form->{income_accno_id_2} selected/;
1720 $form->{selectIC_expense} =~ s/selected//g;
1721 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_2}\E/ value=$form->{expense_accno_id_2} selected/;
1724 $linkaccounts .= qq| <tr>
1725 <th align=right>| . $locale->text('Revenues EU without UStId') . qq|</th>
1726 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
1729 <th align=right>| . $locale->text('Expenses EU without UStId') . qq|</th>
1730 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
1734 $form->{selectIC_income} =~ s/selected//g;
1735 $form->{selectIC_income} =~ s/ value=\Q$form->{income_accno_id_3}\E/ value=$form->{income_accno_id_3} selected/;
1736 $form->{selectIC_expense} =~ s/selected//g;
1737 $form->{selectIC_expense} =~ s/ value=\Q$form->{expense_accno_id_3}\E/ value=$form->{expense_accno_id_3} selected/;
1740 $linkaccounts .= qq| <tr>
1741 <th align=right>| . $locale->text('Foreign Revenues') . qq|</th>
1742 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
1745 <th align=right>| . $locale->text('Foreign Expenses') . qq|</th>
1746 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
1756 <form method=post action=am.pl>
1758 <input type=hidden name=id value=$form->{id}>
1759 <input type=hidden name=type value=buchungsgruppe>
1763 <th class=listtop colspan=2>$form->{title}</th>
1765 <tr height="5"></tr>
1767 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
1768 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1771 <td colspan=2><hr size=3 noshade></td>
1776 $lxdebug->leave_sub();
1779 sub save_buchungsgruppe {
1780 $lxdebug->enter_sub();
1782 $auth->assert('config');
1784 $form->isblank("description", $locale->text('Description missing!'));
1786 AM->save_buchungsgruppe(\%myconfig, \%$form);
1787 $form->redirect($locale->text('Accounting Group saved!'));
1789 $lxdebug->leave_sub();
1792 sub delete_buchungsgruppe {
1793 $lxdebug->enter_sub();
1795 $auth->assert('config');
1797 AM->delete_buchungsgruppe(\%myconfig, \%$form);
1798 $form->redirect($locale->text('Accounting Group deleted!'));
1800 $lxdebug->leave_sub();
1803 sub swap_buchungsgruppen {
1804 $lxdebug->enter_sub();
1806 $auth->assert('config');
1808 AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
1809 list_buchungsgruppe();
1811 $lxdebug->leave_sub();
1816 $lxdebug->enter_sub();
1818 $auth->assert('config');
1820 $form->{title} = "Add";
1822 $form->{callback} = "am.pl?action=add_printer" unless $form->{callback};
1827 $lxdebug->leave_sub();
1831 $lxdebug->enter_sub();
1833 $auth->assert('config');
1835 $form->{title} = "Edit";
1837 AM->get_printer(\%myconfig, \%$form);
1841 $form->{orphaned} = 1;
1844 $lxdebug->leave_sub();
1848 $lxdebug->enter_sub();
1850 $auth->assert('config');
1852 AM->printer(\%myconfig, \%$form);
1854 $form->{callback} = "am.pl?action=list_printer";
1856 $callback = $form->escape($form->{callback});
1858 $form->{title} = $locale->text('Printer');
1860 @column_index = qw(printer_description printer_command template_code);
1862 $column_header{printer_description} =
1863 qq|<th class=listheading width=60%>|
1864 . $locale->text('Printer Description')
1866 $column_header{printer_command} =
1867 qq|<th class=listheading width=10%>|
1868 . $locale->text('Printer Command')
1870 $column_header{template_code} =
1871 qq|<th class=listheading>|
1872 . $locale->text('Template Code')
1882 <th class=listtop>$form->{title}</th>
1884 <tr height="5"></tr>
1888 <tr class=listheading>
1891 map { print "$column_header{$_}\n" } @column_index;
1897 foreach $ref (@{ $form->{ALL} }) {
1903 <tr valign=top class=listrow$i>
1907 $column_data{printer_description} = qq|<td><a href="am.pl?action=edit_printer&id=$ref->{id}&callback=$callback">$ref->{printer_description}"</td>|;
1908 $column_data{printer_command} = qq|<td align=right>$ref->{printer_command}</td>|;
1909 $column_data{template_code} =
1910 qq|<td align=right>$ref->{template_code}</td>|;
1912 map { print "$column_data{$_}\n" } @column_index;
1924 <td><hr size=3 noshade></td>
1929 <form method=post action=am.pl>
1931 <input name=callback type=hidden value="$form->{callback}">
1933 <input type=hidden name=type value=printer>
1935 <input class=submit type=submit name=action value="|
1936 . $locale->text('Add') . qq|">
1944 $lxdebug->leave_sub();
1947 sub printer_header {
1948 $lxdebug->enter_sub();
1950 $auth->assert('config');
1952 $form->{title} = $locale->text("$form->{title} Printer");
1954 # $locale->text('Add Printer')
1955 # $locale->text('Edit Printer')
1957 $form->{printer_description} =~ s/\"/"/g;
1958 $form->{template_code} =~ s/\"/"/g;
1959 $form->{printer_command} =~ s/\"/"/g;
1967 <form method=post action=am.pl>
1969 <input type=hidden name=id value=$form->{id}>
1970 <input type=hidden name=type value=printer>
1974 <th class=listtop colspan=2>$form->{title}</th>
1976 <tr height="5"></tr>
1978 <th align=right>| . $locale->text('Printer') . qq|</th>
1979 <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
1982 <th align=right>| . $locale->text('Printer Command') . qq|</th>
1983 <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
1986 <th align=right>| . $locale->text('Template Code') . qq|</th>
1987 <td><input name=template_code size=5 value="$form->{template_code}"></td>
1989 <td colspan=2><hr size=3 noshade></td>
1994 $lxdebug->leave_sub();
1998 $lxdebug->enter_sub();
2000 $auth->assert('config');
2002 $form->isblank("printer_description", $locale->text('Description missing!'));
2003 $form->isblank("printer_command", $locale->text('Printer Command missing!'));
2004 AM->save_printer(\%myconfig, \%$form);
2005 $form->redirect($locale->text('Printer saved!'));
2007 $lxdebug->leave_sub();
2010 sub delete_printer {
2011 $lxdebug->enter_sub();
2013 $auth->assert('config');
2015 AM->delete_printer(\%myconfig, \%$form);
2016 $form->redirect($locale->text('Printer deleted!'));
2018 $lxdebug->leave_sub();
2022 $lxdebug->enter_sub();
2024 $auth->assert('config');
2026 $form->{title} = "Add";
2028 $form->{callback} = "am.pl?action=add_payment" unless $form->{callback};
2030 $form->{terms_netto} = 0;
2031 $form->{terms_skonto} = 0;
2032 $form->{percent_skonto} = 0;
2033 my @languages = AM->language(\%myconfig, $form, 1);
2034 map({ $_->{"language"} = $_->{"description"};
2035 $_->{"language_id"} = $_->{"id"}; } @languages);
2036 $form->{"TRANSLATION"} = \@languages;
2040 $lxdebug->leave_sub();
2044 $lxdebug->enter_sub();
2046 $auth->assert('config');
2048 $form->{title} = "Edit";
2050 AM->get_payment(\%myconfig, $form);
2051 $form->{percent_skonto} =
2052 $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
2056 $form->{orphaned} = 1;
2059 $lxdebug->leave_sub();
2063 $lxdebug->enter_sub();
2065 $auth->assert('config');
2067 AM->payment(\%myconfig, \%$form);
2069 $form->{callback} = build_std_url("action=list_payment");
2071 $callback = $form->escape($form->{callback});
2073 $form->{title} = $locale->text('Payment Terms');
2075 @column_index = qw(up down description description_long terms_netto
2076 terms_skonto percent_skonto);
2078 $column_header{up} =
2079 qq|<th class="listheading" align="center" valign="center" width="16">|
2080 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
2082 $column_header{down} =
2083 qq|<th class="listheading" align="center" valign="center" width="16">|
2084 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
2086 $column_header{description} =
2087 qq|<th class=listheading>|
2088 . $locale->text('Description')
2090 $column_header{description_long} =
2091 qq|<th class=listheading>|
2092 . $locale->text('Long Description')
2094 $column_header{terms_netto} =
2095 qq|<th class=listheading>|
2096 . $locale->text('Netto Terms')
2098 $column_header{terms_skonto} =
2099 qq|<th class=listheading>|
2100 . $locale->text('Skonto Terms')
2102 $column_header{percent_skonto} =
2103 qq|<th class=listheading>|
2104 . $locale->text('Skonto')
2114 <th class=listtop>$form->{title}</th>
2116 <tr height="5"></tr>
2120 <tr class=listheading>
2123 map { print "$column_header{$_}\n" } @column_index;
2129 my $swap_link = build_std_url("action=swap_payment_terms");
2132 foreach $ref (@{ $form->{ALL} }) {
2138 <tr valign=top class=listrow$i>
2142 my $pref = $form->{ALL}->[$row - 1];
2144 qq|<td align="center" valign="center" width="16">| .
2145 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
2146 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
2149 $column_data{up} = qq|<td width="16"> </td>|;
2152 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
2153 $column_data{down} = qq|<td width="16"> </td>|;
2155 my $nref = $form->{ALL}->[$row + 1];
2156 $column_data{down} =
2157 qq|<td align="center" valign="center" width="16">| .
2158 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
2159 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
2163 $column_data{description} =
2165 build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
2166 qq|">| . H($ref->{description}) . qq|</a></td>|;
2167 $column_data{description_long} =
2168 qq|<td>| . H($ref->{description_long}) . qq|</td>|;
2169 $column_data{terms_netto} =
2170 qq|<td align=right>$ref->{terms_netto}</td>|;
2171 $column_data{terms_skonto} =
2172 qq|<td align=right>$ref->{terms_skonto}</td>|;
2173 $column_data{percent_skonto} =
2174 qq|<td align=right>| .
2175 $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
2177 map { print "$column_data{$_}\n" } @column_index;
2190 <td><hr size=3 noshade></td>
2195 <form method=post action=am.pl>
2197 <input name=callback type=hidden value="$form->{callback}">
2199 <input type=hidden name=type value=payment>
2201 <input class=submit type=submit name=action value="|
2202 . $locale->text('Add') . qq|">
2210 $lxdebug->leave_sub();
2213 sub payment_header {
2214 $lxdebug->enter_sub();
2216 $auth->assert('config');
2218 $form->{title} = $locale->text("$form->{title} Payment Terms");
2220 # $locale->text('Add Payment Terms')
2221 # $locale->text('Edit Payment Terms')
2223 $form->{description} =~ s/\"/"/g;
2232 <form method=post action=am.pl>
2234 <input type=hidden name=id value=$form->{id}>
2235 <input type=hidden name=type value=payment>
2239 <th class=listtop colspan=2>$form->{title}</th>
2241 <tr height="5"></tr>
2243 <th align=right>| . $locale->text('Description') . qq|</th>
2244 <td><input name=description size=30 value="$form->{description}"></td>
2247 <th align=right>| . $locale->text('Long Description') . qq|</th>
2248 <td><input name=description_long size=50 value="$form->{description_long}"></td>
2252 foreach my $language (@{ $form->{"TRANSLATION"} }) {
2255 <th align="right">| .
2256 sprintf($locale->text('Translation (%s)'),
2257 $language->{"language"})
2259 <td><input name="description_long_$language->{language_id}" size="50"
2260 value="| . Q($language->{"description_long"}) . qq|"></td>
2267 <th align=right>| . $locale->text('Netto Terms') . qq|</th>
2268 <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
2271 <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
2272 <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
2275 <th align=right>| . $locale->text('Skonto') . qq| %</th>
2276 <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
2278 <td colspan=2><hr size=3 noshade></td>
2282 <p>| . $locale->text("You can use the following strings in the long " .
2283 "description and all translations. They will be " .
2284 "replaced by their actual values by Lx-Office " .
2285 "before they're output.")
2289 <li>| . $locale->text("<%netto_date%> -- Date the payment is due in " .
2292 <li>| . $locale->text("<%skonto_date%> -- Date the payment is due " .
2295 <li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
2297 <li>| . $locale->text("<%total%> -- Amount payable")
2299 <li>| . $locale->text("<%total_wo_skonto%> -- Amount payable less discount")
2301 <li>| . $locale->text("<%invtotal%> -- Invoice total")
2303 <li>| . $locale->text("<%invtotal_wo_skonto%> -- Invoice total less discount")
2305 <li>| . $locale->text("<%currency%> -- The selected currency")
2307 <li>| . $locale->text("<%terms_netto%> -- The number of days for " .
2310 <li>| . $locale->text("<%account_number%> -- Your account number")
2312 <li>| . $locale->text("<%bank%> -- Your bank")
2314 <li>| . $locale->text("<%bank_code%> -- Your bank code")
2318 $lxdebug->leave_sub();
2322 $lxdebug->enter_sub();
2324 $auth->assert('config');
2326 $form->isblank("description", $locale->text('Description missing!'));
2327 $form->{"percent_skonto"} =
2328 $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
2329 AM->save_payment(\%myconfig, \%$form);
2330 $form->redirect($locale->text('Payment Terms saved!'));
2332 $lxdebug->leave_sub();
2335 sub delete_payment {
2336 $lxdebug->enter_sub();
2338 $auth->assert('config');
2340 AM->delete_payment(\%myconfig, \%$form);
2341 $form->redirect($locale->text('Payment terms deleted!'));
2343 $lxdebug->leave_sub();
2346 sub swap_payment_terms {
2347 $lxdebug->enter_sub();
2349 $auth->assert('config');
2351 AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
2354 $lxdebug->leave_sub();
2358 $lxdebug->enter_sub();
2360 # get defaults for account numbers and last numbers
2361 AM->defaultaccounts(\%myconfig, \%$form);
2363 map { $form->{"defaults_${_}"} = $form->{defaults}->{$_} } keys %{ $form->{defaults} };
2365 foreach $key (keys %{ $form->{IC} }) {
2366 foreach $accno (sort keys %{ $form->{IC}->{$key} }) {
2367 my $array = "ACCNOS_" . uc($key);
2368 $form->{$array} ||= [];
2370 my $value = "${accno}--" . $form->{IC}->{$key}->{$accno}->{description};
2371 push @{ $form->{$array} }, {
2374 'selected' => $form->{IC}->{$key}->{$accno}->{id} == $form->{defaults}->{$key},
2379 $form->{title} = $locale->text('Ranges of numbers and default accounts');
2382 print $form->parse_html_template('am/edit_defaults');
2384 $lxdebug->leave_sub();
2388 $lxdebug->enter_sub();
2390 AM->save_defaults();
2392 $form->redirect($locale->text('Defaults saved.'));
2394 $lxdebug->leave_sub();
2397 sub _build_cfg_options {
2399 my $array = uc($idx) . 'S';
2401 $form->{$array} = [];
2402 foreach my $item (@_) {
2403 push @{ $form->{$array} }, {
2406 'selected' => $item eq $myconfig{$idx},
2412 $lxdebug->enter_sub();
2414 _build_cfg_options('dateformat', qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd));
2415 _build_cfg_options('numberformat', qw(1,000.00 1000.00 1.000,00 1000,00));
2418 if ($opendocument_templates && $openofficeorg_writer_bin &&
2419 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
2420 push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
2421 "value" => "opendocument_pdf" });
2423 if ($latex_templates) {
2424 push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
2426 push(@formats, { "name" => "HTML", "value" => "html" });
2427 if ($latex_templates) {
2428 push(@formats, { "name" => $locale->text("Postscript"),
2429 "value" => "postscript" });
2431 if ($opendocument_templates) {
2432 push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
2433 "value" => "opendocument" });
2436 if (!$myconfig{"template_format"}) {
2437 $myconfig{"template_format"} = "pdf";
2439 $form->{TEMPLATE_FORMATS} = [];
2440 foreach $item (@formats) {
2441 push @{ $form->{TEMPLATE_FORMATS} }, {
2442 'name' => $item->{name},
2443 'value' => $item->{value},
2444 'selected' => $item->{value} eq $myconfig{template_format},
2448 if (!$myconfig{"default_media"}) {
2449 $myconfig{"default_media"} = "screen";
2452 my %selected = ($myconfig{"default_media"} => "selected");
2454 { 'name' => $locale->text('Screen'), 'value' => 'screen', 'selected' => $selected{screen}, },
2455 { 'name' => $locale->text('Printer'), 'value' => 'printer', 'selected' => $selected{printer}, },
2456 { 'name' => $locale->text('Queue'), 'value' => 'queue', 'selected' => $selected{queue}, },
2459 AM->printer(\%myconfig, $form);
2461 $form->{PRINTERS} = [];
2462 foreach my $printer (@{$form->{"ALL"}}) {
2463 push @{ $form->{PRINTERS} }, {
2464 'name' => $printer->{printer_description},
2465 'value' => $printer->{id},
2466 'selected' => $printer->{id} == $myconfig{default_printer_id},
2470 %countrycodes = User->country_codes;
2472 $countrycodes{""} = "American English";
2473 $form->{COUNTRYCODES} = [];
2474 foreach $countrycode (sort { $countrycodes{$a} cmp $countrycodes{$b} } keys %countrycodes) {
2475 push @{ $form->{COUNTRYCODES} }, {
2476 'name' => $countrycodes{$countrycode},
2477 'value' => $countrycode,
2478 'selected' => $countrycode eq $myconfig{countrycode},
2482 $form->{STYLESHEETS} = [];
2483 foreach $item (qw(lx-office-erp.css Win2000.css)) {
2484 push @{ $form->{STYLESHEETS} }, {
2487 'selected' => $item eq $myconfig{stylesheet},
2491 $myconfig{show_form_details} = 1 unless (defined($myconfig{show_form_details}));
2492 $form->{"menustyle_$myconfig{menustyle}"} = 1;
2493 $form->{CAN_CHANGE_PASSWORD} = $auth->can_change_password();
2495 $form->{title} = $locale->text('Edit Preferences for #1', $form->{login});
2498 print $form->parse_html_template('am/config');
2500 $lxdebug->leave_sub();
2503 sub save_preferences {
2504 $lxdebug->enter_sub();
2506 $form->{stylesheet} = $form->{usestylesheet};
2508 $form->redirect($locale->text('Preferences saved!')) if (AM->save_preferences(\%myconfig, \%$form, $webdav));
2509 $form->error($locale->text('Cannot save preferences!'));
2511 $lxdebug->leave_sub();
2515 $lxdebug->enter_sub();
2517 $auth->assert('config');
2519 $form->{title} = $locale->text('Audit Control');
2521 AM->closedto(\%myconfig, \%$form);
2523 if ($form->{revtrans}) {
2524 $checked{Y} = "checked";
2526 $checked{N} = "checked";
2534 <form method=post action=am.pl>
2537 <tr><th class=listtop>$form->{title}</th></tr>
2538 <tr height="5"></tr>
2544 . $locale->text('Enforce transaction reversal for all dates') . qq|</th>
2545 <td><input name=revtrans class=radio type=radio value="1" $checked{Y}> |
2546 . $locale->text('Yes')
2547 . qq| <input name=revtrans class=radio type=radio value="0" $checked{N}> |
2548 . $locale->text('No')
2552 <th>| . $locale->text('Close Books up to') . qq|</th>
2553 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
2563 <input type=hidden name=nextsub value=doclose>
2565 <input type=submit class=submit name=action value="|
2566 . $locale->text('Continue') . qq|">
2574 $lxdebug->leave_sub();
2578 $lxdebug->enter_sub();
2580 $auth->assert('config');
2582 AM->closebooks(\%myconfig, \%$form);
2584 if ($form->{revtrans}) {
2586 $locale->text('Transaction reversal enforced for all dates'));
2588 if ($form->{closedto}) {
2590 $locale->text('Transaction reversal enforced up to') . " "
2591 . $locale->date(\%myconfig, $form->{closedto}, 1));
2593 $form->redirect($locale->text('Books are open'));
2597 $lxdebug->leave_sub();
2601 $lxdebug->enter_sub();
2603 $auth->assert('config');
2605 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
2606 AM->units_in_use(\%myconfig, $form, $units);
2607 map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
2609 @languages = AM->language(\%myconfig, $form, 1);
2611 @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units}));
2614 foreach (@unit_list) {
2615 $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"});
2616 $_->{"UNITLANGUAGES"} = [];
2617 foreach my $lang (@languages) {
2618 push(@{ $_->{"UNITLANGUAGES"} },
2620 "unit" => $_->{"name"},
2621 "language_id" => $lang->{"id"},
2622 "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
2623 "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
2629 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
2630 $ddbox = AM->unit_select_data($units, undef, 1);
2632 my $updownlink = build_std_url("action=swap_units", "unit_type");
2634 $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
2636 print($form->parse_html_template("am/edit_units",
2637 { "UNITS" => \@unit_list,
2638 "NEW_BASE_UNIT_DDBOX" => $ddbox,
2639 "LANGUAGES" => \@languages,
2640 "updownlink" => $updownlink }));
2642 $lxdebug->leave_sub();
2646 $lxdebug->enter_sub();
2648 $auth->assert('config');
2650 $form->isblank("new_name", $locale->text("The name is missing."));
2651 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
2652 $all_units = AM->retrieve_units(\%myconfig, $form);
2653 $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
2655 my ($base_unit, $factor);
2656 if ($form->{"new_base_unit"}) {
2657 $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
2659 $form->isblank("new_factor", $locale->text("The factor is missing."));
2660 $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
2661 $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
2662 $base_unit = $form->{"new_base_unit"};
2666 foreach my $lang (AM->language(\%myconfig, $form, 1)) {
2667 next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
2668 push(@languages, { "id" => $lang->{"id"},
2669 "localized" => $form->{"new_localized_$lang->{id}"},
2670 "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
2674 AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
2676 $form->{"saved_message"} = $locale->text("The unit has been saved.");
2680 $lxdebug->leave_sub();
2683 sub set_unit_languages {
2684 $lxdebug->enter_sub();
2686 $auth->assert('config');
2688 my ($unit, $languages, $idx) = @_;
2690 $unit->{"LANGUAGES"} = [];
2692 foreach my $lang (@{$languages}) {
2693 push(@{ $unit->{"LANGUAGES"} },
2694 { "id" => $lang->{"id"},
2695 "localized" => $form->{"localized_${idx}_$lang->{id}"},
2696 "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
2700 $lxdebug->leave_sub();
2704 $lxdebug->enter_sub();
2706 $auth->assert('config');
2708 $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
2709 AM->units_in_use(\%myconfig, $form, $old_units);
2711 @languages = AM->language(\%myconfig, $form, 1);
2715 foreach $i (1..($form->{"rowcount"} * 1)) {
2716 $old_unit = $old_units->{$form->{"old_name_$i"}};
2718 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
2721 if ($form->{"unchangeable_$i"}) {
2722 $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
2723 $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
2724 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2728 if ($old_unit->{"in_use"}) {
2729 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
2732 if ($form->{"delete_$i"}) {
2733 push(@delete_units, $old_unit->{"name"});
2737 $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
2739 $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
2740 my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
2741 $new_units->{$form->{"name_$i"}} = \%h;
2742 $new_units->{$form->{"name_$i"}}->{"row"} = $i;
2743 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2746 foreach $unit (values(%{$new_units})) {
2747 next unless ($unit->{"old_name"});
2748 if ($unit->{"base_unit"}) {
2749 $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"}))
2750 unless (defined($new_units->{$unit->{"base_unit"}}));
2751 $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
2752 $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
2754 $unit->{"base_unit"} = undef;
2755 $unit->{"factor"} = undef;
2759 foreach $unit (values(%{$new_units})) {
2760 next if ($unit->{"unchanged_unit"});
2762 map({ $_->{"seen"} = 0; } values(%{$new_units}));
2764 while ($new_unit->{"base_unit"}) {
2765 $new_unit->{"seen"} = 1;
2766 $new_unit = $new_units->{$new_unit->{"base_unit"}};
2767 if ($new_unit->{"seen"}) {
2768 $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, " .
2769 "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
2774 AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
2776 $form->{"saved_message"} = $locale->text("The units have been saved.");
2780 $lxdebug->leave_sub();
2783 sub show_history_search {
2784 $lxdebug->enter_sub();
2786 $auth->assert('config');
2788 $form->{title} = $locale->text("History Search");
2791 print $form->parse_html_template("common/search_history");
2793 $lxdebug->leave_sub();
2796 sub show_am_history {
2797 $lxdebug->enter_sub();
2799 $auth->assert('config');
2801 my %search = ( "Artikelnummer" => "parts",
2802 "Kundennummer" => "customer",
2803 "Lieferantennummer" => "vendor",
2804 "Projektnummer" => "project",
2805 "Buchungsnummer" => "oe",
2806 "Eingangsrechnungnummer" => "ap",
2807 "Ausgangsrechnungnummer" => "ar",
2808 "Mahnungsnummer" => "dunning"
2810 my %searchNo = ( "Artikelnummer" => "partnumber",
2811 "Kundennummer" => "customernumber",
2812 "Lieferantennummer" => "vendornumber",
2813 "Projektnummer" => "projectnummer",
2814 "Buchungsnummer" => "ordnumber",
2815 "Eingangsrechnungnummer" => "invnumber",
2816 "Ausgangsrechnungnummer" => "invnumber",
2817 "Mahnungsnummer" => "dunning_id"
2822 foreach(split(/\,/, $form->{einschraenkungen})) {
2824 $restriction .= " AND addition = '" . $_ . "'";
2828 $restriction .= " OR addition = '" . $_ . "'";
2831 $restriction .= (($form->{transdate} ne "" && $form->{reqdate} ne "")
2832 ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|' AND st.itime::date <= '| . $form->{reqdate} . qq|'|
2833 : (($form->{transdate} ne "" && $form->{reqdate} eq "")
2834 ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|'|
2835 : ($form->{transdate} eq "" && $form->{reqdate} ne "")
2836 ? qq| AND st.itime::date <= '| . $form->{reqdate} . qq|'|
2840 $restriction .= ($form->{mitarbeiter} eq "" ? ""
2841 : ($form->{mitarbeiter} =~ /^[0-9]*$/
2842 ? " AND employee_id = " . $form->{mitarbeiter}
2843 : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
2845 my $dbh = $form->dbconnect(\%myconfig);
2846 my $query = qq|SELECT trans_id AS id FROM history_erp | .
2847 ($form->{'searchid'} ?
2848 qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'| :
2849 qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
2851 my $sth = $dbh->prepare($query);
2853 $sth->execute() || $form->dberror($query);
2855 $form->{title} = $locale->text("History Search");
2860 while(my $hash_ref = $sth->fetchrow_hashref()){
2862 $daten .= $hash_ref->{id};
2866 $daten .= " OR trans_id = " . $hash_ref->{id};
2870 my ($sort, $sortby) = split(/\-\-/, $form->{order});
2871 $sort =~ s/.*\.(.*)$/$1/;
2873 print $form->parse_html_template("common/show_history",
2874 {"DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}),
2875 "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
2878 uc($sort)."BY" => $sortby
2881 $lxdebug->leave_sub();
2884 sub get_employee_id {
2885 $lxdebug->enter_sub();
2887 $auth->assert('config');
2889 my $query = qq|SELECT id FROM employee WHERE name = '| . $_[0] . qq|'|;
2890 my $sth = $_[1]->prepare($query);
2891 $sth->execute() || $form->dberror($query);
2892 my $return = $sth->fetch();
2894 return ${$return}[0];
2895 $lxdebug->leave_sub();
2899 $lxdebug->enter_sub();
2901 $auth->assert('config');
2903 my $dir = $form->{"dir"} eq "down" ? "down" : "up";
2904 my $unit_type = $form->{"unit_type"} eq "dimension" ?
2905 "dimension" : "service";
2906 AM->swap_units(\%myconfig, $form, $dir, $form->{"name"}, $unit_type);
2910 $lxdebug->leave_sub();
2914 $lxdebug->enter_sub();
2916 $auth->assert('config');
2918 $form->{title} = $locale->text('Add');
2920 $form->{callback} ||= "am.pl?action=add_tax";
2922 _get_taxaccount_selection();
2926 my $parameters_ref = {
2927 # ChartTypeIsAccount => $ChartTypeIsAccount,
2930 # Ausgabe des Templates
2931 print($form->parse_html_template('am/edit_tax', $parameters_ref));
2933 $lxdebug->leave_sub();
2937 $lxdebug->enter_sub();
2939 $auth->assert('config');
2941 $form->{title} = $locale->text('Edit');
2943 AM->get_tax(\%myconfig, \%$form);
2944 _get_taxaccount_selection();
2946 $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
2950 my $parameters_ref = {
2953 # Ausgabe des Templates
2954 print($form->parse_html_template('am/edit_tax', $parameters_ref));
2956 $lxdebug->leave_sub();
2960 $lxdebug->enter_sub();
2962 $auth->assert('config');
2964 AM->taxes(\%myconfig, \%$form);
2966 map { $_->{rate} = $form->format_amount(\%myconfig, $_->{rate}, 2) } @{ $form->{TAX} };
2968 $form->{callback} = build_std_url('action=list_tax');
2970 $form->{title} = $locale->text('Tax-O-Matic');
2974 # Ausgabe des Templates
2975 print($form->parse_html_template('am/list_tax', $parameters_ref));
2977 $lxdebug->leave_sub();
2980 sub _get_taxaccount_selection{
2981 $lxdebug->enter_sub();
2983 $auth->assert('config');
2985 AM->get_tax_accounts(\%myconfig, \%$form);
2987 map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} };
2989 $lxdebug->leave_sub();
2993 $lxdebug->enter_sub();
2995 $auth->assert('config');
2997 $form->isblank("rate", $locale->text('Taxrate missing!'));
2998 $form->isblank("taxdescription", $locale->text('Taxdescription missing!'));
2999 $form->isblank("taxkey", $locale->text('Taxkey missing!'));
3001 $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate});
3003 if ( $form->{rate} < 0 || $form->{rate} >= 100 ) {
3004 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
3007 if ( $form->{rate} <= 0.99 && $form->{rate} > 0 ) {
3008 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
3011 AM->save_tax(\%myconfig, \%$form);
3012 $form->redirect($locale->text('Tax saved!'));
3014 $lxdebug->leave_sub();
3018 $lxdebug->enter_sub();
3020 $auth->assert('config');
3022 AM->delete_tax(\%myconfig, \%$form);
3023 $form->redirect($locale->text('Tax deleted!'));
3025 $lxdebug->leave_sub();
3028 sub add_price_factor {
3029 $lxdebug->enter_sub();
3031 $auth->assert('config');
3033 $form->{title} = $locale->text('Add Price Factor');
3034 $form->{callback} ||= build_std_url('action=add_price_factor');
3035 $form->{fokus} = 'description';
3038 print $form->parse_html_template('am/edit_price_factor');
3040 $lxdebug->leave_sub();
3043 sub edit_price_factor {
3044 $lxdebug->enter_sub();
3046 $auth->assert('config');
3048 $form->{title} = $locale->text('Edit Price Factor');
3049 $form->{callback} ||= build_std_url('action=add_price_factor');
3050 $form->{fokus} = 'description';
3052 AM->get_price_factor(\%myconfig, $form);
3054 $form->{factor} = $form->format_amount(\%myconfig, $form->{factor} * 1);
3057 print $form->parse_html_template('am/edit_price_factor');
3059 $lxdebug->leave_sub();
3062 sub list_price_factors {
3063 $lxdebug->enter_sub();
3065 $auth->assert('config');
3067 AM->get_all_price_factors(\%myconfig, \%$form);
3070 foreach my $current (@{ $form->{PRICE_FACTORS} }) {
3072 $previous->{next_id} = $current->{id};
3073 $current->{previous_id} = $previous->{id};
3076 $current->{factor} = $form->format_amount(\%myconfig, $current->{factor} * 1);
3078 $previous = $current;
3081 $form->{callback} = build_std_url('action=list_price_factors');
3082 $form->{title} = $locale->text('Price Factors');
3083 $form->{url_base} = build_std_url('callback');
3086 print $form->parse_html_template('am/list_price_factors');
3088 $lxdebug->leave_sub();
3091 sub save_price_factor {
3092 $lxdebug->enter_sub();
3094 $auth->assert('config');
3096 $form->isblank("description", $locale->text('Description missing!'));
3097 $form->isblank("factor", $locale->text('Factor missing!'));
3099 $form->{factor} = $form->parse_amount(\%myconfig, $form->{factor});
3101 AM->save_price_factor(\%myconfig, $form);
3103 $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor saved!')) if ($form->{callback});
3105 $form->redirect($locale->text('Price factor saved!'));
3107 $lxdebug->leave_sub();
3110 sub delete_price_factor {
3111 $lxdebug->enter_sub();
3113 $auth->assert('config');
3115 AM->delete_price_factor(\%myconfig, \%$form);
3117 $form->{callback} .= '&MESSAGE=' . $form->escape($locale->text('Price factor deleted!')) if ($form->{callback});
3119 $form->redirect($locale->text('Price factor deleted!'));
3121 $lxdebug->leave_sub();
3124 sub swap_price_factors {
3125 $lxdebug->enter_sub();
3127 $auth->assert('config');
3129 AM->swap_sortkeys(\%myconfig, $form, 'price_factors');
3130 list_price_factors();
3132 $lxdebug->leave_sub();