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 #======================================================================
46 require "bin/mozilla/common.pl";
50 sub add { call_sub("add_$form->{type}"); }
51 sub delete { call_sub("delete_$form->{type}"); }
52 sub save { call_sub("save_$form->{type}"); }
53 sub edit { call_sub("edit_$form->{type}"); }
54 sub continue { call_sub($form->{"nextsub"}); }
57 $lxdebug->enter_sub();
59 $form->{title} = "Add";
60 $form->{charttype} = "A";
61 AM->get_account(\%myconfig, \%$form);
64 "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}"
65 unless $form->{callback};
70 $lxdebug->leave_sub();
74 $lxdebug->enter_sub();
76 $form->{title} = "Edit";
77 AM->get_account(\%myconfig, \%$form);
79 foreach my $item (split(/:/, $form->{link})) {
80 $form->{$item} = "checked";
86 $lxdebug->leave_sub();
90 $lxdebug->enter_sub();
92 if ( $form->{action} eq 'edit_account') {
93 $form->{account_exists} = '1';
96 $form->{title} = $locale->text("$form->{title} Account");
98 $form->{"$form->{charttype}_checked"} = "checked";
99 $form->{"$form->{category}_checked"} = "checked";
101 $form->{select_tax} = "";
103 my @tax_report_pos = USTVA->report_variables({
104 myconfig => \%myconfig,
107 attribute => 'position',
111 if (@{ $form->{TAXKEY} }) {
112 foreach my $item (@{ $form->{TAXKEY} }) {
113 $item->{rate} = $item->{rate} * 100 . '%';
116 # Fill in empty row for new Taxkey
122 taxdescription => '',
129 push @{ $form->{ACCOUNT_TAXKEYS} }, $newtaxkey_ref;
132 foreach my $taxkey_used (@{ $form->{ACCOUNT_TAXKEYS} } ) {
134 # Fill in a runningnumber
135 $form->{ACCOUNT_TAXKEYS}[$i]{runningnumber} = $i;
137 # Fill in the Taxkeys as select options
138 foreach my $item (@{ $form->{TAXKEY} }) {
139 if ($item->{id} == $taxkey_used->{tax_id}) {
140 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
141 qq|<option value="$item->{id}" selected="selected">|
142 . sprintf("%.2d", $item->{taxkey})
143 . qq|. $item->{taxdescription} ($item->{rate}) |
144 . $locale->text('Tax-o-matic Account')
145 . qq|: $item->{chart_accno}\n|;
148 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
149 qq|<option value="$item->{id}">|
150 . sprintf("%.2d", $item->{taxkey})
151 . qq|. $item->{taxdescription} ($item->{rate}) |
152 . $locale->text('Tax-o-matic Account')
153 . qq|: $item->{chart_accno}\n|;
158 # Fill in the USTVA Numbers as select options
159 foreach my $item ( '', sort({ $a cmp $b } @tax_report_pos) ) {
161 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="" selected="selected">-\n|;
163 elsif ( $item == $taxkey_used->{pos_ustva} ) {
164 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item" selected="selected">$item\n|;
167 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item">$item\n|;
176 # Newaccount Folgekonto
177 if (@{ $form->{NEWACCOUNT} }) {
178 if (!$form->{new_chart_valid}) {
179 $form->{selectnewaccount} = qq|<option value=""> |. $locale->text('None') .q|</option>|;
181 foreach $item (@{ $form->{NEWACCOUNT} }) {
182 if ($item->{id} == $form->{new_chart_id}) {
183 $form->{selectnewaccount} .=
184 qq|<option value="$item->{id}" selected>$item->{accno}--$item->{description}</option>|;
185 } elsif (!$form->{new_chart_valid}) {
186 $form->{selectnewaccount} .=
187 qq|<option value="$item->{id}">$item->{accno}--$item->{description}</option>|;
193 $select_eur = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
194 %eur = (1 => "Umsatzerlöse",
195 2 => "sonstige Erlöse",
196 3 => "Privatanteile",
198 5 => "Ausserordentliche Erträge",
199 6 => "Vereinnahmte Umsatzst.",
200 7 => "Umsatzsteuererstattungen",
201 8 => "Wareneingänge",
202 9 => "Löhne und Gehälter",
203 10 => "Gesetzl. sozialer Aufw.",
205 12 => "Gas, Strom, Wasser",
206 13 => "Instandhaltung",
207 14 => "Steuern, Versich., Beiträge",
209 16 => "Kfz-Versicherungen",
210 17 => "Sonst. Fahrtkosten",
211 18 => "Werbe- und Reisekosten",
212 19 => "Instandhaltung u. Werkzeuge",
213 20 => "Fachzeitschriften, Bücher",
214 21 => "Miete für Einrichtungen",
215 22 => "Rechts- und Beratungskosten",
216 23 => "Bürobedarf, Porto, Telefon",
217 24 => "Sonstige Aufwendungen",
218 25 => "Abschreibungen auf Anlagever.",
219 26 => "Abschreibungen auf GWG",
221 28 => "Umsatzsteuerzahlungen",
223 30 => "Ausserordentlicher Aufwand",
224 31 => "Betriebliche Steuern");
225 foreach $item (sort({ $a <=> $b } keys(%eur))) {
226 if ($item == $form->{pos_eur}) {
227 $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $eur{$item}</option>\n|;
229 $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $eur{$item}</option>\n|;
234 $select_bwa = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
236 %bwapos = (1 => 'Umsatzerlöse',
237 2 => 'Best.Verdg.FE/UE',
238 3 => 'Aktiv.Eigenleistung',
239 4 => 'Mat./Wareneinkauf',
240 5 => 'So.betr.Erlöse',
241 10 => 'Personalkosten',
243 12 => 'Betriebl.Steuern',
244 13 => 'Vers./Beiträge',
245 14 => 'Kfz.Kosten o.St.',
246 15 => 'Werbe-Reisek.',
247 16 => 'Kosten Warenabgabe',
248 17 => 'Abschreibungen',
249 18 => 'Rep./instandhlt.',
250 19 => 'Übrige Steuern',
251 20 => 'Sonst.Kosten',
253 31 => 'Sonst.neutr.Aufw.',
255 33 => 'Sonst.neutr.Ertrag',
256 34 => 'Verr.kalk.Kosten',
257 35 => 'Steuern Eink.u.Ertr.');
258 foreach $item (sort({ $a <=> $b } keys %bwapos)) {
259 if ($item == $form->{pos_bwa}) {
260 $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $bwapos{$item}\n|;
262 $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $bwapos{$item}\n|;
267 # Wieder hinzugefügt zu evaluationszwecken (us) 09.03.2007
268 $select_bilanz = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
269 foreach $item ((1, 2, 3, 4)) {
270 if ($item == $form->{pos_bilanz}) {
271 $select_bilanz .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|.\n|;
273 $select_bilanz .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|.\n|;
278 # this is for our parser only! Do not remove.
279 # type=submit $locale->text('Add Account')
280 # type=submit $locale->text('Edit Account')
282 $form->{type} = "account";
284 # preselections category
286 $select_category = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
289 'A' => $locale->text('Asset'),
290 'L' => $locale->text('Liability'),
291 'Q' => $locale->text('Equity'),
292 'I' => $locale->text('Revenue'),
293 'E' => $locale->text('Expense'),
294 'C' => $locale->text('Costs'),
296 foreach $item ( sort({ $a <=> $b } keys %category) ) {
297 if ($item eq $form->{category}) {
298 $select_category .= qq|<option value="$item" selected="selected">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
300 $select_category .= qq|<option value="$item">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
305 # preselection chart type
306 my $select_charttype = q{};
309 'A' => $locale->text('Account'),
310 'H' => $locale->text('Header'),
313 foreach $item ( sort({ $a <=> $b } keys %charttype) ) {
314 if ($item eq $form->{charttype}) {
315 $select_charttype .= qq|<option value="$item" selected="selected">$charttype{$item}\n|;
318 $select_charttype .= qq|<option value="$item">$charttype{$item}\n|;
323 my $ChartTypeIsAccount = ($form->{charttype} eq "A") ? "1":"";
327 my $parameters_ref = {
328 ChartTypeIsAccount => $ChartTypeIsAccount,
329 select_category => $select_category,
330 select_charttype => $select_charttype,
331 newaccount => $newaccount,
333 select_bwa => $select_bwa,
334 select_bilanz => $select_bilanz,
335 select_eur => $select_eur,
338 # Ausgabe des Templates
339 print($form->parse_html_template('am/edit_accounts', $parameters_ref));
342 $lxdebug->leave_sub();
346 $lxdebug->enter_sub();
350 <input name=callback type=hidden value="$form->{callback}">
352 <input type=hidden name=login value=$form->{login}>
353 <input type=hidden name=password value=$form->{password}>
356 if ((!$form->{id}) || ($form->{id} && $form->{orphaned}) || (($form->{type} eq "account") && (!$form->{new_chart_valid}))) {
358 <input type=submit class=submit name=action value="|
359 . $locale->text('Save') . qq|">
363 if ($form->{id} && $form->{orphaned}) {
364 print qq|<input type=submit class=submit name=action value="|
365 . $locale->text('Delete') . qq|">|;
375 $lxdebug->leave_sub();
379 $lxdebug->enter_sub();
381 $form->isblank("accno", $locale->text('Account Number missing!'));
382 $form->isblank("description", $locale->text('Account Description missing!'));
384 if ($form->{charttype} eq 'A'){
385 $form->isblank("category", $locale->text('Account Type missing!'));
388 $form->redirect($locale->text('Account saved!'))
389 if (AM->save_account(\%myconfig, \%$form));
390 $form->error($locale->text('Cannot save account!'));
392 $lxdebug->leave_sub();
396 $lxdebug->enter_sub();
398 CA->all_accounts(\%myconfig, \%$form);
400 $form->{title} = $locale->text('Chart of Accounts');
404 "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}";
409 $callback = $form->escape($callback);
411 foreach $ca (@{ $form->{CA} }) {
413 $ca->{debit} = " ";
414 $ca->{credit} = " ";
416 if ($ca->{amount} > 0) {
418 $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
420 if ($ca->{amount} < 0) {
422 $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2, " ");
424 $ca->{heading} = ( $ca->{charttype} eq 'H' ) ? 1:'';
425 $ca->{link_edit_account} =
426 qq|$form->{script}?action=edit_account&id=$ca->{id}|
427 .qq|&path=$form->{path}&login=$form->{login}|
428 .qq|&password=$form->{password}&callback=$callback|;
432 my $list_account_details_url =
433 "$form->{script}?login=$form->{login}&path=$form->{path}"
434 ."&password=$form->{password}&action=list_account_details&";
437 my $pjx = new CGI::Ajax(
438 'list_account_details' => $list_account_details_url
441 # Eneable AJAX debuging
445 push(@ { $form->{AJAX} }, $pjx);
450 my $parameters_ref = {
451 # hidden_variables => $_hidden_variables_ref,
454 # Ausgabe des Templates
455 print($form->parse_html_template('am/list_accounts', $parameters_ref));
457 $lxdebug->leave_sub();
462 sub list_account_details {
463 # Ajax Funktion aus list_account_details
464 $lxdebug->enter_sub();
466 my $chart_id = $form->{args};
468 CA->all_accounts(\%myconfig, \%$form, $chart_id);
470 $form->{title} = $locale->text('Chart of Accounts');
474 "$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&password=$form->{password}";
479 $callback = $form->escape($callback);
481 foreach $ca (@{ $form->{CA} }) {
483 $ca->{debit} = " ";
484 $ca->{credit} = " ";
486 if ($ca->{amount} > 0) {
488 $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
490 if ($ca->{amount} < 0) {
492 $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2, " ");
495 my @links = split( q{:}, $ca->{link});
499 foreach my $link (@links){
500 $link = ( $link eq 'AR') ? $locale->text('Account Link AR')
501 : ( $link eq 'AP') ? $locale->text('Account Link AP')
502 : ( $link eq 'IC') ? $locale->text('Account Link IC')
503 : ( $link eq 'AR_amount' ) ? $locale->text('Account Link AR_amount')
504 : ( $link eq 'AR_paid' ) ? $locale->text('Account Link AR_paid')
505 : ( $link eq 'AR_tax' ) ? $locale->text('Account Link AR_tax')
506 : ( $link eq 'AP_amount' ) ? $locale->text('Account Link AP_amount')
507 : ( $link eq 'AP_paid' ) ? $locale->text('Account Link AP_paid')
508 : ( $link eq 'AP_tax' ) ? $locale->text('Account Link AP_tax')
509 : ( $link eq 'IC_sale' ) ? $locale->text('Account Link IC_sale')
510 : ( $link eq 'IC_cogs' ) ? $locale->text('Account Link IC_cogs')
511 : ( $link eq 'IC_taxpart' ) ? $locale->text('Account Link IC_taxpart')
512 : ( $link eq 'IC_income' ) ? $locale->text('Account Link IC_income')
513 : ( $link eq 'IC_expense' ) ? $locale->text('Account Link IC_expense')
514 : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice')
515 # : ( $link eq 'CT_tax' ) ? $locale->text('Account Link CT_tax')
516 : $locale->text('Unknown Link') . ': ' . $link;
518 $ca->{link} .= ($link ne '') ? "[$link] ":'';
521 $ca->{startdate} =~ s/,/<br>/og;
522 $ca->{tk_ustva} =~ s/,/<br>/og;
523 $ca->{taxkey} =~ s/,/<br>/og;
524 $ca->{taxaccount} =~ s/,/<br>/og;
525 $ca->{taxdescription} =~ s/,/<br>/og;
526 $ca->{datevautomatik} = ($ca->{datevautomatik}) ? $locale->text('On'):$locale->text('Off');
528 $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
529 : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
530 : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
531 : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
532 : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
533 : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
534 : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
535 : $locale->text('Unknown Category') . ': ' . $ca->{category};
537 $ca->{link_edit_account} =
538 qq|$form->{script}?action=edit_account&id=$ca->{id}|
539 .qq|&login=$form->{login}|
540 .qq|&password=$form->{password}&callback=$callback|;
546 my $parameters_ref = {
549 # hidden_variables => $_hidden_variables_ref,
552 # Ausgabe des Templates
554 my $result = $form->parse_html_template('am/list_account_details', $parameters_ref);
557 # print "chart_id:$chart_id, form->chartid:$form->{chart_id}, rest=$rest";
559 $lxdebug->leave_sub();
564 $lxdebug->enter_sub();
566 $form->{title} = $locale->text('Delete Account');
569 qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
571 if ($form->{id} == $form->{$id}) {
572 $form->error($locale->text('Cannot delete default account!'));
576 $form->redirect($locale->text('Account deleted!'))
577 if (AM->delete_account(\%myconfig, \%$form));
578 $form->error($locale->text('Cannot delete account!'));
580 $lxdebug->leave_sub();
584 $lxdebug->enter_sub();
586 $form->{title} = "Add";
590 "$form->{script}?action=add_department&login=$form->{login}&password=$form->{password}"
591 unless $form->{callback};
596 $lxdebug->leave_sub();
599 sub edit_department {
600 $lxdebug->enter_sub();
602 $form->{title} = "Edit";
604 AM->get_department(\%myconfig, \%$form);
609 $lxdebug->leave_sub();
612 sub list_department {
613 $lxdebug->enter_sub();
615 AM->departments(\%myconfig, \%$form);
618 "$form->{script}?action=list_department&login=$form->{login}&password=$form->{password}";
620 $callback = $form->escape($form->{callback});
622 $form->{title} = $locale->text('Departments');
624 @column_index = qw(description cost profit);
626 $column_header{description} =
627 qq|<th class=listheading width=90%>|
628 . $locale->text('Description')
630 $column_header{cost} =
631 qq|<th class=listheading nowrap>|
632 . $locale->text('Cost Center')
634 $column_header{profit} =
635 qq|<th class=listheading nowrap>|
636 . $locale->text('Profit Center')
646 <th class=listtop>$form->{title}</th>
652 <tr class=listheading>
655 map { print "$column_header{$_}\n" } @column_index;
661 foreach $ref (@{ $form->{ALL} }) {
667 <tr valign=top class=listrow$i>
670 $costcenter = ($ref->{role} eq "C") ? "X" : "";
671 $profitcenter = ($ref->{role} eq "P") ? "X" : "";
673 $column_data{description} =
674 qq|<td><a href=$form->{script}?action=edit_department&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
675 $column_data{cost} = qq|<td align=center>$costcenter</td>|;
676 $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
678 map { print "$column_data{$_}\n" } @column_index;
690 <td><hr size=3 noshade></td>
695 <form method=post action=$form->{script}>
697 <input name=callback type=hidden value="$form->{callback}">
699 <input type=hidden name=type value=department>
701 <input type=hidden name=login value=$form->{login}>
702 <input type=hidden name=password value=$form->{password}>
704 <input class=submit type=submit name=action value="|
705 . $locale->text('Add') . qq|">
713 $lxdebug->leave_sub();
716 sub department_header {
717 $lxdebug->enter_sub();
719 $form->{title} = $locale->text("$form->{title} Department");
721 # $locale->text('Add Department')
722 # $locale->text('Edit Department')
724 $form->{description} =~ s/\"/"/g;
726 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
728 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
731 qq|<input name=description size=60 value="$form->{description}">|;
734 $costcenter = "checked" if $form->{role} eq "C";
735 $profitcenter = "checked" if $form->{role} eq "P";
742 <form method=post action=$form->{script}>
744 <input type=hidden name=id value=$form->{id}>
745 <input type=hidden name=type value=department>
749 <th class=listtop colspan=2>$form->{title}</th>
753 <th align=right>| . $locale->text('Description') . qq|</th>
754 <td>$description</td>
758 <td><input type=radio style=radio name=role value="C" $costcenter> |
759 . $locale->text('Cost Center') . qq|
760 <input type=radio style=radio name=role value="P" $profitcenter> |
761 . $locale->text('Profit Center') . qq|
764 <td colspan=2><hr size=3 noshade></td>
769 $lxdebug->leave_sub();
772 sub save_department {
773 $lxdebug->enter_sub();
775 $form->isblank("description", $locale->text('Description missing!'));
776 AM->save_department(\%myconfig, \%$form);
777 $form->redirect($locale->text('Department saved!'));
779 $lxdebug->leave_sub();
782 sub delete_department {
783 $lxdebug->enter_sub();
785 AM->delete_department(\%myconfig, \%$form);
786 $form->redirect($locale->text('Department deleted!'));
788 $lxdebug->leave_sub();
792 $lxdebug->enter_sub();
794 $form->{title} = "Add";
797 "$form->{script}?action=add_lead&login=$form->{login}&password=$form->{password}"
798 unless $form->{callback};
803 $lxdebug->leave_sub();
807 $lxdebug->enter_sub();
809 $form->{title} = "Edit";
811 AM->get_lead(\%myconfig, \%$form);
815 $form->{orphaned} = 1;
818 $lxdebug->leave_sub();
822 $lxdebug->enter_sub();
824 AM->lead(\%myconfig, \%$form);
827 "$form->{script}?action=list_lead&login=$form->{login}&password=$form->{password}";
829 $callback = $form->escape($form->{callback});
831 $form->{title} = $locale->text('Lead');
833 @column_index = qw(description cost profit);
835 $column_header{description} =
836 qq|<th class=listheading width=100%>|
837 . $locale->text('Description')
847 <th class=listtop>$form->{title}</th>
850 <tr class=listheading>
853 map { print "$column_header{$_}\n" } @column_index;
859 foreach $ref (@{ $form->{ALL} }) {
865 <tr valign=top class=listrow$i>
868 $lead = $ref->{lead};
870 $column_data{description} =
871 qq|<td><a href=$form->{script}?action=edit_lead&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{lead}</td>|;
873 map { print "$column_data{$_}\n" } @column_index;
882 <td><hr size=3 noshade></td>
887 <form method=post action=$form->{script}>
889 <input name=callback type=hidden value="$form->{callback}">
891 <input type=hidden name=type value=lead>
893 <input type=hidden name=login value=$form->{login}>
894 <input type=hidden name=password value=$form->{password}>
896 <input class=submit type=submit name=action value="|
897 . $locale->text('Add') . qq|">
905 $lxdebug->leave_sub();
909 $lxdebug->enter_sub();
911 $form->{title} = $locale->text("$form->{title} Lead");
913 # $locale->text('Add Lead')
914 # $locale->text('Edit Lead')
916 $form->{description} =~ s/\"/"/g;
919 qq|<input name=description size=50 value="$form->{lead}">|;
926 <form method=post action=$form->{script}>
928 <input type=hidden name=id value=$form->{id}>
929 <input type=hidden name=type value=lead>
933 <th class=listtop colspan=2>$form->{title}</th>
937 <th align=right>| . $locale->text('Description') . qq|</th>
938 <td>$description</td>
940 <td colspan=2><hr size=3 noshade></td>
945 $lxdebug->leave_sub();
949 $lxdebug->enter_sub();
951 $form->isblank("description", $locale->text('Description missing!'));
952 AM->save_lead(\%myconfig, \%$form);
953 $form->redirect($locale->text('lead saved!'));
955 $lxdebug->leave_sub();
959 $lxdebug->enter_sub();
961 AM->delete_lead(\%myconfig, \%$form);
962 $form->redirect($locale->text('lead deleted!'));
964 $lxdebug->leave_sub();
968 $lxdebug->enter_sub();
970 $form->{title} = "Add";
973 "$form->{script}?action=add_business&login=$form->{login}&password=$form->{password}"
974 unless $form->{callback};
979 $lxdebug->leave_sub();
983 $lxdebug->enter_sub();
985 $form->{title} = "Edit";
987 AM->get_business(\%myconfig, \%$form);
991 $form->{orphaned} = 1;
994 $lxdebug->leave_sub();
998 $lxdebug->enter_sub();
1000 AM->business(\%myconfig, \%$form);
1003 "$form->{script}?action=list_business&login=$form->{login}&password=$form->{password}";
1005 $callback = $form->escape($form->{callback});
1007 $form->{title} = $locale->text('Type of Business');
1009 @column_index = qw(description discount customernumberinit);
1011 $column_header{description} =
1012 qq|<th class=listheading width=60%>|
1013 . $locale->text('Description')
1015 $column_header{discount} =
1016 qq|<th class=listheading width=10%>|
1017 . $locale->text('Discount')
1019 $column_header{customernumberinit} =
1020 qq|<th class=listheading>|
1021 . $locale->text('Customernumberinit')
1031 <th class=listtop>$form->{title}</th>
1033 <tr height="5"></tr>
1037 <tr class=listheading>
1040 map { print "$column_header{$_}\n" } @column_index;
1046 foreach $ref (@{ $form->{ALL} }) {
1052 <tr valign=top class=listrow$i>
1056 $form->format_amount(\%myconfig, $ref->{discount} * 100);
1058 $ref->{description};
1059 $column_data{description} =
1060 qq|<td><a href=$form->{script}?action=edit_business&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$description</td>|;
1061 $column_data{discount} = qq|<td align=right>$discount</td>|;
1062 $column_data{customernumberinit} =
1063 qq|<td align=right>$ref->{customernumberinit}</td>|;
1065 map { print "$column_data{$_}\n" } @column_index;
1077 <td><hr size=3 noshade></td>
1082 <form method=post action=$form->{script}>
1084 <input name=callback type=hidden value="$form->{callback}">
1086 <input type=hidden name=type value=business>
1088 <input type=hidden name=login value=$form->{login}>
1089 <input type=hidden name=password value=$form->{password}>
1091 <input class=submit type=submit name=action value="|
1092 . $locale->text('Add') . qq|">
1100 $lxdebug->leave_sub();
1103 sub business_header {
1104 $lxdebug->enter_sub();
1106 $form->{title} = $locale->text("$form->{title} Business");
1108 # $locale->text('Add Business')
1109 # $locale->text('Edit Business')
1111 $form->{description} =~ s/\"/"/g;
1113 $form->format_amount(\%myconfig, $form->{discount} * 100);
1120 <form method=post action=$form->{script}>
1122 <input type=hidden name=id value=$form->{id}>
1123 <input type=hidden name=type value=business>
1127 <th class=listtop colspan=2>$form->{title}</th>
1129 <tr height="5"></tr>
1131 <th align=right>| . $locale->text('Type of Business') . qq|</th>
1132 <td><input name=description size=30 value="$form->{description}"></td>
1135 <th align=right>| . $locale->text('Discount') . qq| %</th>
1136 <td><input name=discount size=5 value=$form->{discount}></td>
1139 <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
1140 <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
1142 <td colspan=2><hr size=3 noshade></td>
1147 $lxdebug->leave_sub();
1151 $lxdebug->enter_sub();
1153 $form->isblank("description", $locale->text('Description missing!'));
1154 $form->{discount} = $form->parse_amount(\%myconfig, $form->{discount}) / 100;
1155 AM->save_business(\%myconfig, \%$form);
1156 $form->redirect($locale->text('Business saved!'));
1158 $lxdebug->leave_sub();
1161 sub delete_business {
1162 $lxdebug->enter_sub();
1164 AM->delete_business(\%myconfig, \%$form);
1165 $form->redirect($locale->text('Business deleted!'));
1167 $lxdebug->leave_sub();
1171 $lxdebug->enter_sub();
1173 $form->{title} = "Add";
1176 "$form->{script}?action=add_language&login=$form->{login}&password=$form->{password}"
1177 unless $form->{callback};
1182 $lxdebug->leave_sub();
1186 $lxdebug->enter_sub();
1188 $form->{title} = "Edit";
1190 AM->get_language(\%myconfig, \%$form);
1194 $form->{orphaned} = 1;
1197 $lxdebug->leave_sub();
1201 $lxdebug->enter_sub();
1203 AM->language(\%myconfig, \%$form);
1206 "$form->{script}?action=list_language&login=$form->{login}&password=$form->{password}";
1208 $callback = $form->escape($form->{callback});
1210 $form->{title} = $locale->text('Languages');
1212 @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
1214 $column_header{description} =
1215 qq|<th class=listheading width=60%>|
1216 . $locale->text('Description')
1218 $column_header{template_code} =
1219 qq|<th class=listheading width=10%>|
1220 . $locale->text('Template Code')
1222 $column_header{article_code} =
1223 qq|<th class=listheading>|
1224 . $locale->text('Article Code')
1226 $column_header{output_numberformat} =
1227 qq|<th class=listheading>|
1228 . $locale->text('Number Format')
1230 $column_header{output_dateformat} =
1231 qq|<th class=listheading>|
1232 . $locale->text('Date Format')
1234 $column_header{output_longdates} =
1235 qq|<th class=listheading>|
1236 . $locale->text('Long Dates')
1246 <th class=listtop>$form->{title}</th>
1248 <tr height="5"></tr>
1252 <tr class=listheading>
1255 map { print "$column_header{$_}\n" } @column_index;
1261 foreach $ref (@{ $form->{ALL} }) {
1267 <tr valign=top class=listrow$i>
1271 $column_data{description} =
1272 qq|<td><a href=$form->{script}?action=edit_language&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
1273 $column_data{template_code} = qq|<td align=right>$ref->{template_code}</td>|;
1274 $column_data{article_code} =
1275 qq|<td align=right>$ref->{article_code}</td>|;
1276 $column_data{output_numberformat} =
1278 ($ref->{output_numberformat} ? $ref->{output_numberformat} :
1279 $locale->text("use program settings")) .
1281 $column_data{output_dateformat} =
1283 ($ref->{output_dateformat} ? $ref->{output_dateformat} :
1284 $locale->text("use program settings")) .
1286 $column_data{output_longdates} =
1288 ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
1291 map { print "$column_data{$_}\n" } @column_index;
1303 <td><hr size=3 noshade></td>
1308 <form method=post action=$form->{script}>
1310 <input name=callback type=hidden value="$form->{callback}">
1312 <input type=hidden name=type value=language>
1314 <input type=hidden name=login value=$form->{login}>
1315 <input type=hidden name=password value=$form->{password}>
1317 <input class=submit type=submit name=action value="|
1318 . $locale->text('Add') . qq|">
1326 $lxdebug->leave_sub();
1329 sub language_header {
1330 $lxdebug->enter_sub();
1332 $form->{title} = $locale->text("$form->{title} Language");
1334 # $locale->text('Add Language')
1335 # $locale->text('Edit Language')
1337 $form->{description} =~ s/\"/"/g;
1338 $form->{template_code} =~ s/\"/"/g;
1339 $form->{article_code} =~ s/\"/"/g;
1345 qq|<option value="">| . $locale->text("use program settings") .
1347 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
1349 ($item eq $form->{output_numberformat})
1350 ? "<option selected>$item"
1356 qq|<option value="">| . $locale->text("use program settings") .
1358 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
1360 ($item eq $form->{output_dateformat})
1361 ? "<option selected>$item"
1369 <form method=post action=$form->{script}>
1371 <input type=hidden name=id value=$form->{id}>
1372 <input type=hidden name=type value=language>
1376 <th class=listtop colspan=2>$form->{title}</th>
1378 <tr height="5"></tr>
1380 <th align=right>| . $locale->text('Language') . qq|</th>
1381 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1384 <th align=right>| . $locale->text('Template Code') . qq|</th>
1385 <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
1388 <th align=right>| . $locale->text('Article Code') . qq|</th>
1389 <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
1392 <th align=right>| . $locale->text('Number Format') . qq|</th>
1393 <td><select name="output_numberformat">$numberformat</select></td>
1396 <th align=right>| . $locale->text('Date Format') . qq|</th>
1397 <td><select name="output_dateformat">$dateformat</select></td>
1400 <th align=right>| . $locale->text('Long Dates') . qq|</th>
1401 <td><input type="radio" name="output_longdates" value="1"| .
1402 ($form->{output_longdates} ? " checked" : "") .
1403 qq|>| . $locale->text("Yes") .
1404 qq|<input type="radio" name="output_longdates" value="0"| .
1405 ($form->{output_longdates} ? "" : " checked") .
1406 qq|>| . $locale->text("No") .
1409 <td colspan=2><hr size=3 noshade></td>
1414 $lxdebug->leave_sub();
1418 $lxdebug->enter_sub();
1420 $form->isblank("description", $locale->text('Language missing!'));
1421 $form->isblank("template_code", $locale->text('Template Code missing!'));
1422 $form->isblank("article_code", $locale->text('Article Code missing!'));
1423 AM->save_language(\%myconfig, \%$form);
1424 $form->redirect($locale->text('Language saved!'));
1426 $lxdebug->leave_sub();
1429 sub delete_language {
1430 $lxdebug->enter_sub();
1432 AM->delete_language(\%myconfig, \%$form);
1433 $form->redirect($locale->text('Language deleted!'));
1435 $lxdebug->leave_sub();
1439 sub add_buchungsgruppe {
1440 $lxdebug->enter_sub();
1442 # $locale->text("Add Buchungsgruppe")
1443 # $locale->text("Edit Buchungsgruppe")
1444 $form->{title} = "Add";
1447 "$form->{script}?action=add_buchungsgruppe&login=$form->{login}&password=$form->{password}"
1448 unless $form->{callback};
1449 AM->get_buchungsgruppe(\%myconfig, \%$form);
1450 $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
1451 for (my $i = 0; 4 > $i; $i++) {
1452 map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
1453 qw(income expense));
1456 &buchungsgruppe_header;
1459 $lxdebug->leave_sub();
1462 sub edit_buchungsgruppe {
1463 $lxdebug->enter_sub();
1465 $form->{title} = "Edit";
1467 AM->get_buchungsgruppe(\%myconfig, \%$form);
1469 &buchungsgruppe_header;
1473 $lxdebug->leave_sub();
1476 sub list_buchungsgruppe {
1477 $lxdebug->enter_sub();
1479 AM->buchungsgruppe(\%myconfig, \%$form);
1482 "$form->{script}?action=list_buchungsgruppe&login=$form->{login}&password=$form->{password}";
1484 $callback = $form->escape($form->{callback});
1486 $form->{title} = $locale->text('Buchungsgruppen');
1488 @column_index = qw(up down description inventory_accno
1489 income_accno_0 expense_accno_0
1490 income_accno_1 expense_accno_1
1491 income_accno_2 expense_accno_2
1492 income_accno_3 expense_accno_3 );
1494 $column_header{up} =
1495 qq|<th class="listheading" width="16">|
1496 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
1498 $column_header{down} =
1499 qq|<th class="listheading" width="16">|
1500 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
1502 $column_header{description} =
1503 qq|<th class="listheading" width="40%">|
1504 . $locale->text('Description')
1506 $column_header{inventory_accno} =
1507 qq|<th class=listheading>|
1508 . $locale->text('Bestandskonto')
1510 $column_header{income_accno_0} =
1511 qq|<th class=listheading>|
1512 . $locale->text('Erlöse Inland')
1514 $column_header{expense_accno_0} =
1515 qq|<th class=listheading>|
1516 . $locale->text('Aufwand Inland')
1518 $column_header{income_accno_1} =
1519 qq|<th class=listheading>|
1520 . $locale->text('Erlöse EU m. UStId')
1522 $column_header{expense_accno_1} =
1523 qq|<th class=listheading>|
1524 . $locale->text('Aufwand EU m. UStId')
1526 $column_header{income_accno_2} =
1527 qq|<th class=listheading>|
1528 . $locale->text('Erlöse EU o. UStId')
1530 $column_header{expense_accno_2} =
1531 qq|<th class=listheading>|
1532 . $locale->text('Aufwand EU o. UStId')
1534 $column_header{income_accno_3} =
1535 qq|<th class=listheading>|
1536 . $locale->text('Erlöse Ausland')
1538 $column_header{expense_accno_3} =
1539 qq|<th class=listheading>|
1540 . $locale->text('Aufwand Ausland')
1549 <th class=listtop>$form->{title}</th>
1551 <tr height="5"></tr>
1555 <tr class=listheading>
1558 map { print "$column_header{$_}\n" } @column_index;
1564 my $swap_link = qq|$form->{script}?action=swap_buchungsgruppen&|;
1565 map({ $swap_link .= $_ . "=" . $form->escape($form->{$_}) . "&" }
1566 qw(login password));
1569 foreach $ref (@{ $form->{ALL} }) {
1575 <tr valign=top class=listrow$i>
1579 my $pref = $form->{ALL}->[$row - 1];
1581 qq|<td align="center" valign="center" width="16">| .
1582 qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
1583 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
1586 $column_data{up} = qq|<td width="16"> </td>|;
1589 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
1590 $column_data{down} = qq|<td width="16"> </td>|;
1592 my $nref = $form->{ALL}->[$row + 1];
1593 $column_data{down} =
1594 qq|<td align="center" valign="center" width="16">| .
1595 qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
1596 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
1600 $column_data{description} =
1601 qq|<td><a href=$form->{script}?action=edit_buchungsgruppe&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
1602 $column_data{inventory_accno} = qq|<td align=right>$ref->{inventory_accno}</td>|;
1603 $column_data{income_accno_0} =
1604 qq|<td align=right>$ref->{income_accno_0}</td>|;
1605 $column_data{expense_accno_0} = qq|<td align=right>$ref->{expense_accno_0}</td>|;
1606 $column_data{income_accno_1} =
1607 qq|<td align=right>$ref->{income_accno_1}</td>|;
1608 $column_data{expense_accno_1} = qq|<td align=right>$ref->{expense_accno_1}</td>|;
1609 $column_data{income_accno_2} =
1610 qq|<td align=right>$ref->{income_accno_2}</td>|;
1611 $column_data{expense_accno_2} = qq|<td align=right>$ref->{expense_accno_2}</td>|;
1612 $column_data{income_accno_3} =
1613 qq|<td align=right>$ref->{income_accno_3}</td>|;
1614 $column_data{expense_accno_3} = qq|<td align=right>$ref->{expense_accno_3}</td>|;
1616 map { print "$column_data{$_}\n" } @column_index;
1630 <td><hr size=3 noshade></td>
1635 <form method=post action=$form->{script}>
1637 <input name=callback type=hidden value="$form->{callback}">
1639 <input type=hidden name=type value=buchungsgruppe>
1641 <input type=hidden name=login value=$form->{login}>
1642 <input type=hidden name=password value=$form->{password}>
1644 <input class=submit type=submit name=action value="|
1645 . $locale->text('Add') . qq|">
1653 $lxdebug->leave_sub();
1656 sub buchungsgruppe_header {
1657 $lxdebug->enter_sub();
1659 $form->{title} = $locale->text("$form->{title} Buchungsgruppe");
1661 # $locale->text('Buchungsgruppe hinzufügen')
1662 # $locale->text('Buchungsgruppe bearbeiten')
1664 my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
1665 my %acc_type_map = (
1666 "IC" => $acc_inventory,
1667 "IC_income" => $acc_income,
1668 "IC_sale" => $acc_income,
1669 "IC_expense" => $acc_expense,
1670 "IC_cogs" => $acc_expense,
1673 foreach $key (keys(%acc_type_map)) {
1674 foreach $ref (@{ $form->{IC_links}{$key} }) {
1675 $acc_type_map{$key}->{$ref->{"id"}} = $ref;
1679 foreach my $type (qw(IC IC_income IC_expense)) {
1680 $form->{"select$type"} =
1682 map({ "<option value=$_->{id} $_->{selected}>" .
1683 "$_->{accno}--" . H($_->{description}) . "</option>" }
1684 sort({ $a->{"accno"} cmp $b->{"accno"} }
1685 values(%{$acc_type_map{$type}}))));
1689 $form->{selectIC} =~ s/selected//g;
1690 $form->{selectIC} =~ s/ value=$form->{inventory_accno_id}/ value=$form->{inventory_accno_id} selected/;
1691 $form->{selectIC_income} =~ s/selected//g;
1692 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_0}/ value=$form->{income_accno_id_0} selected/;
1693 $form->{selectIC_expense} =~ s/selected//g;
1694 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_0}/ value=$form->{expense_accno_id_0} selected/;
1700 <th align=right>| . $locale->text('Inventory') . qq|</th>
1701 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
1702 <input name=selectIC type=hidden value="$form->{selectIC}">
1706 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
1710 $linkaccounts .= qq|
1712 <th align=right>| . $locale->text('Erlöse Inland') . qq|</th>
1713 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
1716 <th align=right>| . $locale->text('Aufwand Inland') . qq|</th>
1717 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
1720 $form->{selectIC_income} =~ s/selected//g;
1721 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_1}/ value=$form->{income_accno_id_1} selected/;
1722 $form->{selectIC_expense} =~ s/selected//g;
1723 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/ value=$form->{expense_accno_id_1} selected/;
1725 $linkaccounts .= qq| <tr>
1726 <th align=right>| . $locale->text('Erlöse EU m. UStId') . qq|</th>
1727 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
1730 <th align=right>| . $locale->text('Aufwand EU m UStId') . qq|</th>
1731 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
1735 $form->{selectIC_income} =~ s/selected//g;
1736 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_2}/ value=$form->{income_accno_id_2} selected/;
1737 $form->{selectIC_expense} =~ s/selected//g;
1738 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_2}/ value=$form->{expense_accno_id_2} selected/;
1741 $linkaccounts .= qq| <tr>
1742 <th align=right>| . $locale->text('Erlöse EU o. UStId') . qq|</th>
1743 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
1746 <th align=right>| . $locale->text('Aufwand EU o. UStId') . qq|</th>
1747 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
1751 $form->{selectIC_income} =~ s/selected//g;
1752 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_3}/ value=$form->{income_accno_id_3} selected/;
1753 $form->{selectIC_expense} =~ s/selected//g;
1754 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_3}/ value=$form->{expense_accno_id_3} selected/;
1757 $linkaccounts .= qq| <tr>
1758 <th align=right>| . $locale->text('Erlöse Ausland') . qq|</th>
1759 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
1762 <th align=right>| . $locale->text('Aufwand Ausland') . qq|</th>
1763 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
1773 <form method=post action=$form->{script}>
1775 <input type=hidden name=id value=$form->{id}>
1776 <input type=hidden name=type value=buchungsgruppe>
1780 <th class=listtop colspan=2>$form->{title}</th>
1782 <tr height="5"></tr>
1784 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
1785 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1788 <td colspan=2><hr size=3 noshade></td>
1793 $lxdebug->leave_sub();
1796 sub save_buchungsgruppe {
1797 $lxdebug->enter_sub();
1799 $form->isblank("description", $locale->text('Description missing!'));
1801 AM->save_buchungsgruppe(\%myconfig, \%$form);
1802 $form->redirect($locale->text('Buchungsgruppe gespeichert!'));
1804 $lxdebug->leave_sub();
1807 sub delete_buchungsgruppe {
1808 $lxdebug->enter_sub();
1810 AM->delete_buchungsgruppe(\%myconfig, \%$form);
1811 $form->redirect($locale->text('Buchungsgruppe gelöscht!'));
1813 $lxdebug->leave_sub();
1816 sub swap_buchungsgruppen {
1817 $lxdebug->enter_sub();
1819 AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
1820 list_buchungsgruppe();
1822 $lxdebug->leave_sub();
1827 $lxdebug->enter_sub();
1829 $form->{title} = "Add";
1832 "$form->{script}?action=add_printer&login=$form->{login}&password=$form->{password}"
1833 unless $form->{callback};
1838 $lxdebug->leave_sub();
1842 $lxdebug->enter_sub();
1844 $form->{title} = "Edit";
1846 AM->get_printer(\%myconfig, \%$form);
1850 $form->{orphaned} = 1;
1853 $lxdebug->leave_sub();
1857 $lxdebug->enter_sub();
1859 AM->printer(\%myconfig, \%$form);
1862 "$form->{script}?action=list_printer&login=$form->{login}&password=$form->{password}";
1864 $callback = $form->escape($form->{callback});
1866 $form->{title} = $locale->text('Printer');
1868 @column_index = qw(printer_description printer_command template_code);
1870 $column_header{printer_description} =
1871 qq|<th class=listheading width=60%>|
1872 . $locale->text('Printer Description')
1874 $column_header{printer_command} =
1875 qq|<th class=listheading width=10%>|
1876 . $locale->text('Printer Command')
1878 $column_header{template_code} =
1879 qq|<th class=listheading>|
1880 . $locale->text('Template Code')
1890 <th class=listtop>$form->{title}</th>
1892 <tr height="5"></tr>
1896 <tr class=listheading>
1899 map { print "$column_header{$_}\n" } @column_index;
1905 foreach $ref (@{ $form->{ALL} }) {
1911 <tr valign=top class=listrow$i>
1915 $column_data{printer_description} =
1916 qq|<td><a href=$form->{script}?action=edit_printer&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{printer_description}</td>|;
1917 $column_data{printer_command} = qq|<td align=right>$ref->{printer_command}</td>|;
1918 $column_data{template_code} =
1919 qq|<td align=right>$ref->{template_code}</td>|;
1921 map { print "$column_data{$_}\n" } @column_index;
1933 <td><hr size=3 noshade></td>
1938 <form method=post action=$form->{script}>
1940 <input name=callback type=hidden value="$form->{callback}">
1942 <input type=hidden name=type value=printer>
1944 <input type=hidden name=login value=$form->{login}>
1945 <input type=hidden name=password value=$form->{password}>
1947 <input class=submit type=submit name=action value="|
1948 . $locale->text('Add') . qq|">
1956 $lxdebug->leave_sub();
1959 sub printer_header {
1960 $lxdebug->enter_sub();
1962 $form->{title} = $locale->text("$form->{title} Printer");
1964 # $locale->text('Add Printer')
1965 # $locale->text('Edit Printer')
1967 $form->{printer_description} =~ s/\"/"/g;
1968 $form->{template_code} =~ s/\"/"/g;
1969 $form->{printer_command} =~ s/\"/"/g;
1977 <form method=post action=$form->{script}>
1979 <input type=hidden name=id value=$form->{id}>
1980 <input type=hidden name=type value=printer>
1984 <th class=listtop colspan=2>$form->{title}</th>
1986 <tr height="5"></tr>
1988 <th align=right>| . $locale->text('Printer') . qq|</th>
1989 <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
1992 <th align=right>| . $locale->text('Printer Command') . qq|</th>
1993 <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
1996 <th align=right>| . $locale->text('Template Code') . qq|</th>
1997 <td><input name=template_code size=5 value="$form->{template_code}"></td>
1999 <td colspan=2><hr size=3 noshade></td>
2004 $lxdebug->leave_sub();
2008 $lxdebug->enter_sub();
2010 $form->isblank("printer_description", $locale->text('Description missing!'));
2011 $form->isblank("printer_command", $locale->text('Printer Command missing!'));
2012 AM->save_printer(\%myconfig, \%$form);
2013 $form->redirect($locale->text('Printer saved!'));
2015 $lxdebug->leave_sub();
2018 sub delete_printer {
2019 $lxdebug->enter_sub();
2021 AM->delete_printer(\%myconfig, \%$form);
2022 $form->redirect($locale->text('Printer deleted!'));
2024 $lxdebug->leave_sub();
2028 $lxdebug->enter_sub();
2030 $form->{title} = "Add";
2033 "$form->{script}?action=add_payment&login=$form->{login}&password=$form->{password}"
2034 unless $form->{callback};
2036 $form->{terms_netto} = 0;
2037 $form->{terms_skonto} = 0;
2038 $form->{percent_skonto} = 0;
2039 my @languages = AM->language(\%myconfig, $form, 1);
2040 map({ $_->{"language"} = $_->{"description"};
2041 $_->{"language_id"} = $_->{"id"}; } @languages);
2042 $form->{"TRANSLATION"} = \@languages;
2046 $lxdebug->leave_sub();
2050 $lxdebug->enter_sub();
2052 $form->{title} = "Edit";
2054 AM->get_payment(\%myconfig, $form);
2055 $form->{percent_skonto} =
2056 $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
2060 $form->{orphaned} = 1;
2063 $lxdebug->leave_sub();
2067 $lxdebug->enter_sub();
2069 AM->payment(\%myconfig, \%$form);
2071 $form->{callback} = build_std_url("action=list_payment");
2073 $callback = $form->escape($form->{callback});
2075 $form->{title} = $locale->text('Payment Terms');
2077 @column_index = qw(up down description description_long terms_netto
2078 terms_skonto percent_skonto);
2080 $column_header{up} =
2081 qq|<th class="listheading" align="center" valign="center" width="16">|
2082 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
2084 $column_header{down} =
2085 qq|<th class="listheading" align="center" valign="center" width="16">|
2086 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
2088 $column_header{description} =
2089 qq|<th class=listheading>|
2090 . $locale->text('Description')
2092 $column_header{description_long} =
2093 qq|<th class=listheading>|
2094 . $locale->text('Long Description')
2096 $column_header{terms_netto} =
2097 qq|<th class=listheading>|
2098 . $locale->text('Netto Terms')
2100 $column_header{terms_skonto} =
2101 qq|<th class=listheading>|
2102 . $locale->text('Skonto Terms')
2104 $column_header{percent_skonto} =
2105 qq|<th class=listheading>|
2106 . $locale->text('Skonto')
2116 <th class=listtop>$form->{title}</th>
2118 <tr height="5"></tr>
2122 <tr class=listheading>
2125 map { print "$column_header{$_}\n" } @column_index;
2131 my $swap_link = build_std_url("action=swap_payment_terms");
2134 foreach $ref (@{ $form->{ALL} }) {
2140 <tr valign=top class=listrow$i>
2144 my $pref = $form->{ALL}->[$row - 1];
2146 qq|<td align="center" valign="center" width="16">| .
2147 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
2148 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
2151 $column_data{up} = qq|<td width="16"> </td>|;
2154 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
2155 $column_data{down} = qq|<td width="16"> </td>|;
2157 my $nref = $form->{ALL}->[$row + 1];
2158 $column_data{down} =
2159 qq|<td align="center" valign="center" width="16">| .
2160 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
2161 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
2165 $column_data{description} =
2167 build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
2168 qq|">| . H($ref->{description}) . qq|</a></td>|;
2169 $column_data{description_long} =
2170 qq|<td>| . H($ref->{description_long}) . qq|</td>|;
2171 $column_data{terms_netto} =
2172 qq|<td align=right>$ref->{terms_netto}</td>|;
2173 $column_data{terms_skonto} =
2174 qq|<td align=right>$ref->{terms_skonto}</td>|;
2175 $column_data{percent_skonto} =
2176 qq|<td align=right>| .
2177 $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
2179 map { print "$column_data{$_}\n" } @column_index;
2192 <td><hr size=3 noshade></td>
2197 <form method=post action=$form->{script}>
2199 <input name=callback type=hidden value="$form->{callback}">
2201 <input type=hidden name=type value=payment>
2203 <input type=hidden name=login value=$form->{login}>
2204 <input type=hidden name=password value=$form->{password}>
2206 <input class=submit type=submit name=action value="|
2207 . $locale->text('Add') . qq|">
2215 $lxdebug->leave_sub();
2218 sub payment_header {
2219 $lxdebug->enter_sub();
2221 $form->{title} = $locale->text("$form->{title} Payment Terms");
2223 # $locale->text('Add Payment Terms')
2224 # $locale->text('Edit Payment Terms')
2226 $form->{description} =~ s/\"/"/g;
2235 <form method=post action=$form->{script}>
2237 <input type=hidden name=id value=$form->{id}>
2238 <input type=hidden name=type value=payment>
2242 <th class=listtop colspan=2>$form->{title}</th>
2244 <tr height="5"></tr>
2246 <th align=right>| . $locale->text('Description') . qq|</th>
2247 <td><input name=description size=30 value="$form->{description}"></td>
2250 <th align=right>| . $locale->text('Long Description') . qq|</th>
2251 <td><input name=description_long size=50 value="$form->{description_long}"></td>
2255 foreach my $language (@{ $form->{"TRANSLATION"} }) {
2258 <th align="right">| .
2259 sprintf($locale->text('Translation (%s)'),
2260 $language->{"language"})
2262 <td><input name="description_long_$language->{language_id}" size="50"
2263 value="| . Q($language->{"description_long"}) . qq|"></td>
2270 <th align=right>| . $locale->text('Netto Terms') . qq|</th>
2271 <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
2274 <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
2275 <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
2278 <th align=right>| . $locale->text('Skonto') . qq| %</th>
2279 <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
2281 <td colspan=2><hr size=3 noshade></td>
2285 <p>| . $locale->text("You can use the following strings in the long " .
2286 "description and all translations. They will be " .
2287 "replaced by their actual values by Lx-Office " .
2288 "before they're output.")
2292 <li>| . $locale->text("<%netto_date%> -- Date the payment is due in " .
2295 <li>| . $locale->text("<%skonto_date%> -- Date the payment is due " .
2298 <li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
2300 <li>| . $locale->text("<%total%> -- Amount payable")
2302 <li>| . $locale->text("<%invtotal%> -- Invoice total")
2304 <li>| . $locale->text("<%currency%> -- The selected currency")
2306 <li>| . $locale->text("<%terms_netto%> -- The number of days for " .
2309 <li>| . $locale->text("<%account_number%> -- Your account number")
2311 <li>| . $locale->text("<%bank%> -- Your bank")
2313 <li>| . $locale->text("<%bank_code%> -- Your bank code")
2317 $lxdebug->leave_sub();
2321 $lxdebug->enter_sub();
2323 $form->isblank("description", $locale->text('Description missing!'));
2324 $form->{"percent_skonto"} =
2325 $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
2326 AM->save_payment(\%myconfig, \%$form);
2327 $form->redirect($locale->text('Payment Terms saved!'));
2329 $lxdebug->leave_sub();
2332 sub delete_payment {
2333 $lxdebug->enter_sub();
2335 AM->delete_payment(\%myconfig, \%$form);
2336 $form->redirect($locale->text('Payment terms deleted!'));
2338 $lxdebug->leave_sub();
2341 sub swap_payment_terms {
2342 $lxdebug->enter_sub();
2344 AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
2347 $lxdebug->leave_sub();
2351 $lxdebug->enter_sub();
2353 # get defaults for account numbers and last numbers
2354 AM->defaultaccounts(\%myconfig, \%$form);
2356 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
2358 ($item eq $myconfig{dateformat})
2359 ? "<option selected>$item\n"
2360 : "<option>$item\n";
2363 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
2365 ($item eq $myconfig{numberformat})
2366 ? "<option selected>$item\n"
2367 : "<option>$item\n";
2370 foreach $item (qw(name company address signature)) {
2371 $myconfig{$item} =~ s/\"/"/g;
2374 foreach $item (qw(address signature)) {
2375 $myconfig{$item} =~ s/\\n/\r\n/g;
2379 if ($opendocument_templates && $openofficeorg_writer_bin &&
2380 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
2381 push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
2382 "value" => "opendocument_pdf" });
2384 if ($latex_templates) {
2385 push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
2387 push(@formats, { "name" => "HTML", "value" => "html" });
2388 if ($latex_templates) {
2389 push(@formats, { "name" => $locale->text("Postscript"),
2390 "value" => "postscript" });
2392 if ($opendocument_templates) {
2393 push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
2394 "value" => "opendocument" });
2397 if (!$myconfig{"template_format"}) {
2398 $myconfig{"template_format"} = "pdf";
2400 my $template_format = "";
2401 foreach $item (@formats) {
2403 "<option value=\"$item->{value}\"" .
2404 ($item->{"value"} eq $myconfig{"template_format"} ?
2406 ">" . H($item->{"name"}) . "</option>";
2409 if (!$myconfig{"default_media"}) {
2410 $myconfig{"default_media"} = "screen";
2412 my %selected = ($myconfig{"default_media"} => "selected");
2413 my $default_media = qq|
2414 <option value="screen" $selected{'screen'}>| . $locale->text("Screen") . qq|</option>
2415 <option value="printer" $selected{'printer'}>| . $locale->text("Printer") . qq|</option>
2416 <option value="queue" $selected{'queue'}>| . $locale->text("Queue") . qq|</option>
2420 $selected{$myconfig{"default_printer_id"}} = "selected"
2421 if ($myconfig{"default_printer_id"});
2422 my $default_printer = qq|<option></option>|;
2423 AM->printer(\%myconfig, $form);
2424 foreach my $printer (@{$form->{"ALL"}}) {
2425 $default_printer .= qq|<option value="| . Q($printer->{"id"}) .
2426 qq|" $selected{$printer->{'id'}}>| .
2427 H($printer->{"printer_description"}) . qq|</option>|;
2430 %countrycodes = User->country_codes;
2432 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
2436 ($myconfig{countrycode} eq $key)
2437 ? "<option selected value=$key>$countrycodes{$key}\n"
2438 : "<option value=$key>$countrycodes{$key}\n";
2440 $countrycodes = "<option>American English\n$countrycodes";
2442 foreach $key (keys %{ $form->{IC} }) {
2443 foreach $accno (sort keys %{ $form->{IC}{$key} }) {
2445 ($form->{IC}{$key}{$accno}{id} == $form->{defaults}{$key})
2446 ? "<option selected>$accno--$form->{IC}{$key}{$accno}{description}\n"
2447 : "<option>$accno--$form->{IC}{$key}{$accno}{description}\n";
2451 # opendir CSS, "css/.";
2452 # @all = grep /.*\.css$/, readdir CSS;
2455 # css dir has styles that are not intended as general layouts.
2456 # reverting to hardcoded list
2457 @all = qw(lx-office-erp.css Win2000.css);
2459 foreach $item (@all) {
2460 if ($item eq $myconfig{stylesheet}) {
2461 $selectstylesheet .= qq|<option selected>$item\n|;
2463 $selectstylesheet .= qq|<option>$item\n|;
2466 $selectstylesheet .= "<option>\n";
2468 $form->{title} = $locale->text('Edit Preferences for') . qq| $form->{login}|;
2472 if ($myconfig{menustyle} eq "old") {
2473 $menustyle_old = "checked";
2474 } elsif ($myconfig{menustyle} eq "neu") {
2475 $menustyle_neu = "checked";
2476 } elsif ($myconfig{menustyle} eq "v3") {
2477 $menustyle_v3 = "checked";
2480 my ($show_form_details, $hide_form_details);
2481 $myconfig{"show_form_details"} = 1
2482 unless (defined($myconfig{"show_form_details"}));
2483 $show_form_details = "checked" if ($myconfig{"show_form_details"});
2484 $hide_form_details = "checked" unless ($myconfig{"show_form_details"});
2489 <form method=post action=$form->{script}>
2491 <input type=hidden name=old_password value=$myconfig{password}>
2492 <input type=hidden name=type value=preferences>
2493 <input type=hidden name=role value=$myconfig{role}>
2496 <tr><th class=listtop>$form->{title}</th></tr>
2501 <th align=right>| . $locale->text('Name') . qq|</th>
2502 <td><input name=name size=15 value="$myconfig{name}"></td>
2505 <th align=right>| . $locale->text('Password') . qq|</th>
2506 <td><input type=password name=new_password size=10 value=$myconfig{password}></td>
2509 <th align=right>| . $locale->text('E-mail') . qq|</th>
2510 <td><input name=email size=30 value="$myconfig{email}"></td>
2513 <th align=right>| . $locale->text('Signature') . qq|</th>
2514 <td><textarea name=signature rows=3 cols=50>$myconfig{signature}</textarea></td>
2517 <th align=right>| . $locale->text('Phone') . qq|</th>
2518 <td><input name=tel size=14 value="$myconfig{tel}"></td>
2521 <th align=right>| . $locale->text('Fax') . qq|</th>
2522 <td><input name=fax size=14 value="$myconfig{fax}"></td>
2525 <th align=right>| . $locale->text('Company') . qq|</th>
2526 <td><input name=company size=30 value="$myconfig{company}"></td>
2529 <th align=right>| . $locale->text('Address') . qq|</th>
2530 <td><textarea name=address rows=4 cols=50>$myconfig{address}</textarea></td>
2533 <th align=right>| . $locale->text('Date Format') . qq|</th>
2534 <td><select name=dateformat>$dateformat</select></td>
2537 <th align=right>| . $locale->text('Output Number Format') . qq|</th>
2538 <td><select name=numberformat>$numberformat</select></td>
2542 <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
2543 <td><input name=vclimit size=10 value="$myconfig{vclimit}"></td>
2546 <th align=right>| . $locale->text('Language') . qq|</th>
2547 <td><select name=countrycode>$countrycodes</select></td>
2550 <th align=right>| . $locale->text('Stylesheet') . qq|</th>
2551 <td><select name=usestylesheet>$selectstylesheet</select></td>
2554 <th align=right>| . $locale->text('Setup Menu') . qq|</th>
2555 <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
2556 $locale->text("Top (CSS)") . qq|
2557 <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
2558 $locale->text("Top (Javascript)") . qq|
2559 <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
2560 $locale->text("Old (on the side)") . qq|</td>
2563 <th align=right>| . $locale->text('Form details (second row)') . qq|</th>
2564 <td><input type="radio" id="rad_show_form_details" name="show_form_details" value="1" $show_form_details>
2565 <label for="rad_show_form_details">| . $locale->text('Show by default') . qq|</label>
2566 <input type="radio" id="rad_hide_form_details" name="show_form_details" value="0" $hide_form_details>
2567 <label for="rad_hide_form_details">| . $locale->text('Hide by default') . qq|</label></td>
2569 <input name=printer type=hidden value="$myconfig{printer}">
2570 <tr class=listheading>
2571 <th colspan=2>| . $locale->text("Print options") . qq|</th>
2574 <th align=right>| . $locale->text('Default template format') . qq|</th>
2575 <td><select name="template_format">$template_format</select></td>
2578 <th align=right>| . $locale->text('Default output medium') . qq|</th>
2579 <td><select name="default_media">$default_media</select></td>
2582 <th align=right>| . $locale->text('Default printer') . qq|</th>
2583 <td><select name="default_printer_id">$default_printer</select></td>
2586 <th align=right>| . $locale->text('Number of copies') . qq|</th>
2587 <td><input name="copies" size="10" value="| .
2588 $form->quote($myconfig{"copies"}) . qq|"></td>
2592 <tr class=listheading>
2593 <th colspan=2> </th>
2596 <th align=right>| . $locale->text('Business Number') . qq|</th>
2597 <td><input name=businessnumber size=25 value="$myconfig{businessnumber}"></td>
2600 <th align=right>| . $locale->text('Year End') . qq| (mm/dd)</th>
2601 <td><input name=yearend size=5 value=$form->{defaults}{yearend}></td>
2603 <tr class=listheading>
2605 . $locale->text('Last Numbers & Default Accounts') . qq|</th>
2611 <th align=right nowrap>| . $locale->text('Inventory Account') . qq|</th>
2612 <td><select name=inventory_accno>$myconfig{IC}</select></td>
2615 <th align=right nowrap>| . $locale->text('Revenue Account') . qq|</th>
2616 <td><select name=income_accno>$myconfig{IC_income}</select></td>
2619 <th align=right nowrap>| . $locale->text('Expense Account') . qq|</th>
2620 <td><select name=expense_accno>$myconfig{IC_expense}</select></td>
2623 <th align=right nowrap>| . $locale->text('Foreign Exchange Gain') . qq|</th>
2624 <td><select name=fxgain_accno>$myconfig{FX_gain}</select></td>
2627 <th align=right nowrap>| . $locale->text('Foreign Exchange Loss') . qq|</th>
2628 <td><select name=fxloss_accno>$myconfig{FX_loss}</select></td>
2633 'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies'
2635 . qq|<br><input name=curr size=40 value="$form->{defaults}{curr}"></td>
2644 <th align=right nowrap>| . $locale->text('Last Invoice Number') . qq|</th>
2645 <td><input name=invnumber size=10 value=$form->{defaults}{invnumber}></td>
2646 <th align=right nowrap>|
2647 . $locale->text('Last Customer Number') . qq|</th>
2648 <td><input name=customernumber size=10 value=$form->{defaults}{customernumber}></td>
2651 <th align=right nowrap>|
2652 . $locale->text('Last Credit Note Number') . qq|</th>
2653 <td><input name=cnnumber size=10 value=$form->{defaults}{cnnumber}></td>
2654 <th align=right nowrap>|
2655 . $locale->text('Last Vendor Number') . qq|</th>
2656 <td><input name=vendornumber size=10 value=$form->{defaults}{vendornumber}></td>
2659 <th align=right nowrap>|
2660 . $locale->text('Last Sales Order Number') . qq|</th>
2661 <td><input name=sonumber size=10 value=$form->{defaults}{sonumber}></td>
2664 <th align=right nowrap>|
2665 . $locale->text('Last Purchase Order Number') . qq|</th>
2666 <td><input name=ponumber size=10 value=$form->{defaults}{ponumber}></td>
2667 <th align=right nowrap>|
2668 . $locale->text('Last Article Number') . qq|</th>
2669 <td><input name=articlenumber size=10 value=$form->{defaults}{articlenumber}></td>
2672 <th align=right nowrap>|
2673 . $locale->text('Last Sales Quotation Number') . qq|</th>
2674 <td><input name=sqnumber size=10 value=$form->{defaults}{sqnumber}></td>
2675 <th align=right nowrap>|
2676 . $locale->text('Last Service Number') . qq|</th>
2677 <td><input name=servicenumber size=10 value=$form->{defaults}{servicenumber}></td>
2680 <th align=right nowrap>| . $locale->text('Last RFQ Number') . qq|</th>
2681 <td><input name=rfqnumber size=10 value=$form->{defaults}{rfqnumber}></td>
2682 <th align=right nowrap></th>
2688 # <tr class=listheading>
2689 # <th colspan=2>| . $locale->text('Tax Accounts') . qq|</th>
2696 # <th>| . $locale->text('Rate') . qq| (%)</th>
2697 # <th>| . $locale->text('Number') . qq|</th>
2701 # foreach $accno (sort keys %{ $form->{taxrates} }) {
2704 # <th align=right>$form->{taxrates}{$accno}{description}</th>
2705 # <td><input name=$form->{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}></td>
2706 # <td><input name="taxnumber_$form->{taxrates}{$accno}{id}" value="$form->{taxrates}{$accno}{taxnumber}"></td>
2709 # $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} ";
2712 # chop $form->{taxaccounts};
2715 # <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
2724 <td><hr size=3 noshade></td>
2728 <input type=hidden name=login value=$form->{login}>
2729 <input type=hidden name=password value=$form->{password}>
2732 <input type=submit class=submit name=action value="|
2733 . $locale->text('Save') . qq|">
2741 $lxdebug->leave_sub();
2744 sub save_preferences {
2745 $lxdebug->enter_sub();
2747 $form->{stylesheet} = $form->{usestylesheet};
2749 $form->redirect($locale->text('Preferences saved!'))
2751 AM->save_preferences(\%myconfig, \%$form, $memberfile, $userspath, $webdav
2753 $form->error($locale->text('Cannot save preferences!'));
2755 $lxdebug->leave_sub();
2759 $lxdebug->enter_sub();
2761 $form->{title} = $locale->text('Audit Control');
2763 AM->closedto(\%myconfig, \%$form);
2765 if ($form->{revtrans}) {
2766 $checked{Y} = "checked";
2768 $checked{N} = "checked";
2776 <form method=post action=$form->{script}>
2778 <input type=hidden name=login value=$form->{login}>
2779 <input type=hidden name=password value=$form->{password}>
2782 <tr><th class=listtop>$form->{title}</th></tr>
2783 <tr height="5"></tr>
2789 . $locale->text('Enforce transaction reversal for all dates') . qq|</th>
2790 <td><input name=revtrans class=radio type=radio value="1" $checked{Y}> |
2791 . $locale->text('Yes')
2792 . qq| <input name=revtrans class=radio type=radio value="0" $checked{N}> |
2793 . $locale->text('No')
2797 <th>| . $locale->text('Close Books up to') . qq|</th>
2798 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
2808 <input type=hidden name=nextsub value=doclose>
2810 <input type=submit class=submit name=action value="|
2811 . $locale->text('Continue') . qq|">
2819 $lxdebug->leave_sub();
2823 $lxdebug->enter_sub();
2825 AM->closebooks(\%myconfig, \%$form);
2827 if ($form->{revtrans}) {
2829 $locale->text('Transaction reversal enforced for all dates'));
2831 if ($form->{closedto}) {
2833 $locale->text('Transaction reversal enforced up to') . " "
2834 . $locale->date(\%myconfig, $form->{closedto}, 1));
2836 $form->redirect($locale->text('Books are open'));
2840 $lxdebug->leave_sub();
2844 $lxdebug->enter_sub();
2846 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
2847 AM->units_in_use(\%myconfig, $form, $units);
2848 map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
2850 @languages = AM->language(\%myconfig, $form, 1);
2852 @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units}));
2855 foreach (@unit_list) {
2856 $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"});
2857 $_->{"UNITLANGUAGES"} = [];
2858 foreach my $lang (@languages) {
2859 push(@{ $_->{"UNITLANGUAGES"} },
2861 "unit" => $_->{"name"},
2862 "language_id" => $lang->{"id"},
2863 "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
2864 "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
2870 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
2871 $ddbox = AM->unit_select_data($units, undef, 1);
2873 my $updownlink = build_std_url("action=swap_units", "unit_type");
2875 $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
2877 print($form->parse_html_template("am/edit_units",
2878 { "UNITS" => \@unit_list,
2879 "NEW_BASE_UNIT_DDBOX" => $ddbox,
2880 "LANGUAGES" => \@languages,
2881 "updownlink" => $updownlink }));
2883 $lxdebug->leave_sub();
2887 $lxdebug->enter_sub();
2889 $form->isblank("new_name", $locale->text("The name is missing."));
2890 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
2891 $all_units = AM->retrieve_units(\%myconfig, $form);
2892 $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
2894 my ($base_unit, $factor);
2895 if ($form->{"new_base_unit"}) {
2896 $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
2898 $form->isblank("new_factor", $locale->text("The factor is missing."));
2899 $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
2900 $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
2901 $base_unit = $form->{"new_base_unit"};
2905 foreach my $lang (AM->language(\%myconfig, $form, 1)) {
2906 next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
2907 push(@languages, { "id" => $lang->{"id"},
2908 "localized" => $form->{"new_localized_$lang->{id}"},
2909 "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
2913 AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
2915 $form->{"saved_message"} = $locale->text("The unit has been saved.");
2919 $lxdebug->leave_sub();
2922 sub set_unit_languages {
2923 $lxdebug->enter_sub();
2925 my ($unit, $languages, $idx) = @_;
2927 $unit->{"LANGUAGES"} = [];
2929 foreach my $lang (@{$languages}) {
2930 push(@{ $unit->{"LANGUAGES"} },
2931 { "id" => $lang->{"id"},
2932 "localized" => $form->{"localized_${idx}_$lang->{id}"},
2933 "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
2937 $lxdebug->leave_sub();
2941 $lxdebug->enter_sub();
2943 $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
2944 AM->units_in_use(\%myconfig, $form, $old_units);
2946 @languages = AM->language(\%myconfig, $form, 1);
2950 foreach $i (1..($form->{"rowcount"} * 1)) {
2951 $old_unit = $old_units->{$form->{"old_name_$i"}};
2953 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
2956 if ($form->{"unchangeable_$i"}) {
2957 $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
2958 $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
2959 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2963 if ($old_unit->{"in_use"}) {
2964 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
2967 if ($form->{"delete_$i"}) {
2968 push(@delete_units, $old_unit->{"name"});
2972 $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
2974 $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
2975 my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
2976 $new_units->{$form->{"name_$i"}} = \%h;
2977 $new_units->{$form->{"name_$i"}}->{"row"} = $i;
2978 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2981 foreach $unit (values(%{$new_units})) {
2982 next unless ($unit->{"old_name"});
2983 if ($unit->{"base_unit"}) {
2984 $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"}))
2985 unless (defined($new_units->{$unit->{"base_unit"}}));
2986 $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
2987 $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
2989 $unit->{"base_unit"} = undef;
2990 $unit->{"factor"} = undef;
2994 foreach $unit (values(%{$new_units})) {
2995 next if ($unit->{"unchanged_unit"});
2997 map({ $_->{"seen"} = 0; } values(%{$new_units}));
2999 while ($new_unit->{"base_unit"}) {
3000 $new_unit->{"seen"} = 1;
3001 $new_unit = $new_units->{$new_unit->{"base_unit"}};
3002 if ($new_unit->{"seen"}) {
3003 $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, " .
3004 "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
3009 AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
3011 $form->{"saved_message"} = $locale->text("The units have been saved.");
3015 $lxdebug->leave_sub();
3018 sub show_history_search {
3019 $lxdebug->enter_sub();
3021 $form->{title} = $locale->text("History Search");
3024 print $form->parse_html_template("/common/search_history");
3026 $lxdebug->leave_sub();
3029 sub show_am_history {
3030 $lxdebug->enter_sub();
3031 my %search = ( "Artikelnummer" => "parts",
3032 "Kundennummer" => "customer",
3033 "Lieferantennummer" => "vendor",
3034 "Projektnummer" => "project",
3035 "Buchungsnummer" => "oe",
3036 "Eingangsrechnungnummer" => "ap",
3037 "Ausgangsrechnungnummer" => "ar",
3038 "Mahnungsnummer" => "dunning"
3040 my %searchNo = ( "Artikelnummer" => "partnumber",
3041 "Kundennummer" => "customernumber",
3042 "Lieferantennummer" => "vendornumber",
3043 "Projektnummer" => "projectnummer",
3044 "Buchungsnummer" => "ordnumber",
3045 "Eingangsrechnungnummer" => "invnumber",
3046 "Ausgangsrechnungnummer" => "invnumber",
3047 "Mahnungsnummer" => "dunning_id"
3052 foreach(split(/\,/, $form->{einschraenkungen})) {
3054 $restriction .= " AND addition = '" . $_ . "'";
3058 $restriction .= " OR addition = '" . $_ . "'";
3062 $restriction .= (($form->{transdate} ne "" && $form->{reqdate} ne "")
3063 ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|' AND st.itime::date <= '| . $form->{reqdate} . qq|'|
3064 : (($form->{transdate} ne "" && $form->{reqdate} eq "")
3065 ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|'|
3066 : ($form->{transdate} eq "" && $form->{reqdate} ne "")
3067 ? qq| AND st.itime::date <= '| . $form->{reqdate} . qq|'|
3072 my $dbh = $form->dbconnect(\%myconfig);
3073 my $searchSNumber = $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'};
3074 $restriction .= ($form->{mitarbeiter} eq "" ? ""
3075 : ($form->{mitarbeiter} =~ /^[0-9]*$/
3076 ? " AND employee_id = " . $form->{mitarbeiter}
3077 : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
3078 my $query = qq|SELECT trans_id AS id FROM history_erp WHERE sNumbers = '$searchSNumber' |;
3080 my $sth = $dbh->prepare($query);
3082 $sth->execute() || $form->dberror($query);
3084 if($sth->fetch() <= 0) {
3086 my $query = qq|SELECT id FROM $search{$form->{what2search}}
3087 WHERE $searchNo{$form->{'what2search'}} ILIKE '$form->{"searchid"}'
3090 $sth->execute() || $form->dberror($query);
3091 $form->{title} = $locale->text("History Search");
3094 while(my $hash_ref = $sth->fetchrow_hashref()){
3095 $daten = $form->get_history($dbh,$hash_ref->{id},$restriction);
3098 print $form->parse_html_template("/common/show_history",
3100 "SUCCESS" => ($daten != 0 ? 1 : 0),
3103 $lxdebug->leave_sub();
3106 sub get_employee_id {
3107 $lxdebug->enter_sub();
3108 my $query = qq|SELECT id FROM employee WHERE name = '| . $_[0] . qq|'|;
3109 my $sth = $_[1]->prepare($query);
3110 $sth->execute() || $form->dberror($query);
3111 my $return = $sth->fetch();
3113 return ${$return}[0];
3114 $lxdebug->leave_sub();
3118 $lxdebug->enter_sub();
3120 my $dir = $form->{"dir"} eq "down" ? "down" : "up";
3121 my $unit_type = $form->{"unit_type"} eq "dimension" ?
3122 "dimension" : "service";
3123 AM->swap_units(\%myconfig, $form, $dir, $form->{"name"}, $unit_type);
3127 $lxdebug->leave_sub();