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 #======================================================================
47 require "bin/mozilla/common.pl";
51 sub add { call_sub("add_$form->{type}"); }
52 sub delete { call_sub("delete_$form->{type}"); }
53 sub save { call_sub("save_$form->{type}"); }
54 sub edit { call_sub("edit_$form->{type}"); }
55 sub continue { call_sub($form->{"nextsub"}); }
58 $lxdebug->enter_sub();
60 $form->{title} = "Add";
61 $form->{charttype} = "A";
62 AM->get_account(\%myconfig, \%$form);
65 "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}"
66 unless $form->{callback};
71 $lxdebug->leave_sub();
75 $lxdebug->enter_sub();
77 $form->{title} = "Edit";
78 AM->get_account(\%myconfig, \%$form);
80 foreach my $item (split(/:/, $form->{link})) {
81 $form->{$item} = "checked";
87 $lxdebug->leave_sub();
91 $lxdebug->enter_sub();
93 if ( $form->{action} eq 'edit_account') {
94 $form->{account_exists} = '1';
97 $form->{title} = $locale->text("$form->{title} Account");
99 $form->{"$form->{charttype}_checked"} = "checked";
100 $form->{"$form->{category}_checked"} = "checked";
102 $form->{select_tax} = "";
104 my @tax_report_pos = USTVA->report_variables({
105 myconfig => \%myconfig,
108 attribute => 'position',
112 if (@{ $form->{TAXKEY} }) {
113 foreach my $item (@{ $form->{TAXKEY} }) {
114 $item->{rate} = $item->{rate} * 100 . '%';
117 # Fill in empty row for new Taxkey
123 taxdescription => '',
130 push @{ $form->{ACCOUNT_TAXKEYS} }, $newtaxkey_ref;
133 foreach my $taxkey_used (@{ $form->{ACCOUNT_TAXKEYS} } ) {
135 # Fill in a runningnumber
136 $form->{ACCOUNT_TAXKEYS}[$i]{runningnumber} = $i;
138 # Fill in the Taxkeys as select options
139 foreach my $item (@{ $form->{TAXKEY} }) {
140 if ($item->{id} == $taxkey_used->{tax_id}) {
141 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
142 qq|<option value="$item->{id}" selected="selected">|
143 . sprintf("%.2d", $item->{taxkey})
144 . qq|. $item->{taxdescription} ($item->{rate}) |
145 . $locale->text('Tax-o-matic Account')
146 . qq|: $item->{chart_accno}\n|;
149 $form->{ACCOUNT_TAXKEYS}[$i]{selecttaxkey} .=
150 qq|<option value="$item->{id}">|
151 . sprintf("%.2d", $item->{taxkey})
152 . qq|. $item->{taxdescription} ($item->{rate}) |
153 . $locale->text('Tax-o-matic Account')
154 . qq|: $item->{chart_accno}\n|;
159 # Fill in the USTVA Numbers as select options
160 foreach my $item ( '', sort({ $a cmp $b } @tax_report_pos) ) {
162 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="" selected="selected">-\n|;
164 elsif ( $item == $taxkey_used->{pos_ustva} ) {
165 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item" selected="selected">$item\n|;
168 $form->{ACCOUNT_TAXKEYS}[$i]{select_tax} .= qq|<option value="$item">$item\n|;
177 # Newaccount Folgekonto
178 if (@{ $form->{NEWACCOUNT} }) {
179 if (!$form->{new_chart_valid}) {
180 $form->{selectnewaccount} = qq|<option value=""> |. $locale->text('None') .q|</option>|;
182 foreach $item (@{ $form->{NEWACCOUNT} }) {
183 if ($item->{id} == $form->{new_chart_id}) {
184 $form->{selectnewaccount} .=
185 qq|<option value="$item->{id}" selected>$item->{accno}--$item->{description}</option>|;
186 } elsif (!$form->{new_chart_valid}) {
187 $form->{selectnewaccount} .=
188 qq|<option value="$item->{id}">$item->{accno}--$item->{description}</option>|;
194 $select_eur = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
195 %eur = (1 => "Umsatzerlöse",
196 2 => "sonstige Erlöse",
197 3 => "Privatanteile",
199 5 => "Ausserordentliche Erträge",
200 6 => "Vereinnahmte Umsatzst.",
201 7 => "Umsatzsteuererstattungen",
202 8 => "Wareneingänge",
203 9 => "Löhne und Gehälter",
204 10 => "Gesetzl. sozialer Aufw.",
206 12 => "Gas, Strom, Wasser",
207 13 => "Instandhaltung",
208 14 => "Steuern, Versich., Beiträge",
210 16 => "Kfz-Versicherungen",
211 17 => "Sonst. Fahrtkosten",
212 18 => "Werbe- und Reisekosten",
213 19 => "Instandhaltung u. Werkzeuge",
214 20 => "Fachzeitschriften, Bücher",
215 21 => "Miete für Einrichtungen",
216 22 => "Rechts- und Beratungskosten",
217 23 => "Bürobedarf, Porto, Telefon",
218 24 => "Sonstige Aufwendungen",
219 25 => "Abschreibungen auf Anlagever.",
220 26 => "Abschreibungen auf GWG",
222 28 => "Umsatzsteuerzahlungen",
224 30 => "Ausserordentlicher Aufwand",
225 31 => "Betriebliche Steuern");
226 foreach $item (sort({ $a <=> $b } keys(%eur))) {
227 my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $eur{$item}));
228 if ($item == $form->{pos_eur}) {
229 $select_eur .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
231 $select_eur .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|. $text</option>\n|;
236 $select_bwa = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
238 %bwapos = (1 => 'Umsatzerlöse',
239 2 => 'Best.Verdg.FE/UE',
240 3 => 'Aktiv.Eigenleistung',
241 4 => 'Mat./Wareneinkauf',
242 5 => 'So.betr.Erlöse',
243 10 => 'Personalkosten',
245 12 => 'Betriebl.Steuern',
246 13 => 'Vers./Beiträge',
247 14 => 'Kfz.Kosten o.St.',
248 15 => 'Werbe-Reisek.',
249 16 => 'Kosten Warenabgabe',
250 17 => 'Abschreibungen',
251 18 => 'Rep./instandhlt.',
252 19 => 'Übrige Steuern',
253 20 => 'Sonst.Kosten',
255 31 => 'Sonst.neutr.Aufw.',
257 33 => 'Sonst.neutr.Ertrag',
258 34 => 'Verr.kalk.Kosten',
259 35 => 'Steuern Eink.u.Ertr.');
260 foreach $item (sort({ $a <=> $b } keys %bwapos)) {
261 my $text = H(SL::Iconv::convert("ISO-8859-15", $dbcharset, $bwapos{$item}));
262 if ($item == $form->{pos_bwa}) {
263 $select_bwa .= qq|<option value="$item" selected>|. sprintf("%.2d", $item) .qq|. $text\n|;
265 $select_bwa .= qq|<option value="$item">|. sprintf("%.2d", $item) .qq|. $text\n|;
270 # Wieder hinzugefügt zu evaluationszwecken (us) 09.03.2007
271 $select_bilanz = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
272 foreach $item ((1, 2, 3, 4)) {
273 if ($item == $form->{pos_bilanz}) {
274 $select_bilanz .= qq|<option value=$item selected>|. sprintf("%.2d", $item) .qq|.\n|;
276 $select_bilanz .= qq|<option value=$item>|. sprintf("%.2d", $item) .qq|.\n|;
281 # this is for our parser only! Do not remove.
282 # type=submit $locale->text('Add Account')
283 # type=submit $locale->text('Edit Account')
285 $form->{type} = "account";
287 # preselections category
289 $select_category = q|<option value=""> |. $locale->text('None') .q|</option>\n|;
292 'A' => $locale->text('Asset'),
293 'L' => $locale->text('Liability'),
294 'Q' => $locale->text('Equity'),
295 'I' => $locale->text('Revenue'),
296 'E' => $locale->text('Expense'),
297 'C' => $locale->text('Costs'),
299 foreach $item ( sort({ $a <=> $b } keys %category) ) {
300 if ($item eq $form->{category}) {
301 $select_category .= qq|<option value="$item" selected="selected">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
303 $select_category .= qq|<option value="$item">$category{$item} (|. sprintf("%s", $item) .qq|)\n|;
308 # preselection chart type
309 my $select_charttype = q{};
312 'A' => $locale->text('Account'),
313 'H' => $locale->text('Header'),
316 foreach $item ( sort({ $a <=> $b } keys %charttype) ) {
317 if ($item eq $form->{charttype}) {
318 $select_charttype .= qq|<option value="$item" selected="selected">$charttype{$item}\n|;
321 $select_charttype .= qq|<option value="$item">$charttype{$item}\n|;
326 my $ChartTypeIsAccount = ($form->{charttype} eq "A") ? "1":"";
330 my $parameters_ref = {
331 ChartTypeIsAccount => $ChartTypeIsAccount,
332 select_category => $select_category,
333 select_charttype => $select_charttype,
334 newaccount => $newaccount,
336 select_bwa => $select_bwa,
337 select_bilanz => $select_bilanz,
338 select_eur => $select_eur,
341 # Ausgabe des Templates
342 print($form->parse_html_template('am/edit_accounts', $parameters_ref));
345 $lxdebug->leave_sub();
349 $lxdebug->enter_sub();
353 <input name=callback type=hidden value="$form->{callback}">
355 <input type=hidden name=login value=$form->{login}>
356 <input type=hidden name=password value=$form->{password}>
359 if ((!$form->{id}) || ($form->{id} && $form->{orphaned}) || (($form->{type} eq "account") && (!$form->{new_chart_valid}))) {
361 <input type=submit class=submit name=action value="|
362 . $locale->text('Save') . qq|">
366 if ($form->{id} && $form->{orphaned}) {
367 print qq|<input type=submit class=submit name=action value="|
368 . $locale->text('Delete') . qq|">|;
378 $lxdebug->leave_sub();
382 $lxdebug->enter_sub();
384 $form->isblank("accno", $locale->text('Account Number missing!'));
385 $form->isblank("description", $locale->text('Account Description missing!'));
387 if ($form->{charttype} eq 'A'){
388 $form->isblank("category", $locale->text('Account Type missing!'));
391 $form->redirect($locale->text('Account saved!'))
392 if (AM->save_account(\%myconfig, \%$form));
393 $form->error($locale->text('Cannot save account!'));
395 $lxdebug->leave_sub();
399 $lxdebug->enter_sub();
401 CA->all_accounts(\%myconfig, \%$form);
403 $form->{title} = $locale->text('Chart of Accounts');
407 "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}";
412 $callback = $form->escape($callback);
414 foreach $ca (@{ $form->{CA} }) {
416 $ca->{debit} = " ";
417 $ca->{credit} = " ";
419 if ($ca->{amount} > 0) {
421 $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
423 if ($ca->{amount} < 0) {
425 $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2, " ");
427 $ca->{heading} = ( $ca->{charttype} eq 'H' ) ? 1:'';
428 $ca->{link_edit_account} =
429 qq|$form->{script}?action=edit_account&id=$ca->{id}|
430 .qq|&login=$form->{login}|
431 .qq|&password=$form->{password}&callback=$callback|;
435 my $list_account_details_url =
436 "$form->{script}?login=$form->{login}"
437 ."&password=$form->{password}&action=list_account_details&";
440 my $pjx = new CGI::Ajax(
441 'list_account_details' => $list_account_details_url
444 # Eneable AJAX debuging
448 push(@ { $form->{AJAX} }, $pjx);
453 my $parameters_ref = {
454 # hidden_variables => $_hidden_variables_ref,
457 # Ausgabe des Templates
458 print($form->parse_html_template('am/list_accounts', $parameters_ref));
460 $lxdebug->leave_sub();
465 sub list_account_details {
466 # Ajax Funktion aus list_account_details
467 $lxdebug->enter_sub();
469 my $chart_id = $form->{args};
471 CA->all_accounts(\%myconfig, \%$form, $chart_id);
473 $form->{title} = $locale->text('Chart of Accounts');
477 "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}";
482 $callback = $form->escape($callback);
484 foreach $ca (@{ $form->{CA} }) {
486 $ca->{debit} = " ";
487 $ca->{credit} = " ";
489 if ($ca->{amount} > 0) {
491 $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
493 if ($ca->{amount} < 0) {
495 $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2, " ");
498 my @links = split( q{:}, $ca->{link});
502 foreach my $link (@links){
503 $link = ( $link eq 'AR') ? $locale->text('Account Link AR')
504 : ( $link eq 'AP') ? $locale->text('Account Link AP')
505 : ( $link eq 'IC') ? $locale->text('Account Link IC')
506 : ( $link eq 'AR_amount' ) ? $locale->text('Account Link AR_amount')
507 : ( $link eq 'AR_paid' ) ? $locale->text('Account Link AR_paid')
508 : ( $link eq 'AR_tax' ) ? $locale->text('Account Link AR_tax')
509 : ( $link eq 'AP_amount' ) ? $locale->text('Account Link AP_amount')
510 : ( $link eq 'AP_paid' ) ? $locale->text('Account Link AP_paid')
511 : ( $link eq 'AP_tax' ) ? $locale->text('Account Link AP_tax')
512 : ( $link eq 'IC_sale' ) ? $locale->text('Account Link IC_sale')
513 : ( $link eq 'IC_cogs' ) ? $locale->text('Account Link IC_cogs')
514 : ( $link eq 'IC_taxpart' ) ? $locale->text('Account Link IC_taxpart')
515 : ( $link eq 'IC_income' ) ? $locale->text('Account Link IC_income')
516 : ( $link eq 'IC_expense' ) ? $locale->text('Account Link IC_expense')
517 : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice')
518 # : ( $link eq 'CT_tax' ) ? $locale->text('Account Link CT_tax')
519 : $locale->text('Unknown Link') . ': ' . $link;
521 $ca->{link} .= ($link ne '') ? "[$link] ":'';
524 $ca->{startdate} =~ s/,/<br>/og;
525 $ca->{tk_ustva} =~ s/,/<br>/og;
526 $ca->{taxkey} =~ s/,/<br>/og;
527 $ca->{taxaccount} =~ s/,/<br>/og;
528 $ca->{taxdescription} =~ s/,/<br>/og;
529 $ca->{datevautomatik} = ($ca->{datevautomatik}) ? $locale->text('On'):$locale->text('Off');
531 $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
532 : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
533 : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
534 : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
535 : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
536 : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
537 : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
538 : $locale->text('Unknown Category') . ': ' . $ca->{category};
540 $ca->{link_edit_account} =
541 qq|$form->{script}?action=edit_account&id=$ca->{id}|
542 .qq|&login=$form->{login}|
543 .qq|&password=$form->{password}&callback=$callback|;
549 my $parameters_ref = {
552 # hidden_variables => $_hidden_variables_ref,
555 # Ausgabe des Templates
557 my $result = $form->parse_html_template('am/list_account_details', $parameters_ref);
560 # print "chart_id:$chart_id, form->chartid:$form->{chart_id}, rest=$rest";
562 $lxdebug->leave_sub();
567 $lxdebug->enter_sub();
569 $form->{title} = $locale->text('Delete Account');
572 qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
574 if ($form->{id} == $form->{$id}) {
575 $form->error($locale->text('Cannot delete default account!'));
579 $form->redirect($locale->text('Account deleted!'))
580 if (AM->delete_account(\%myconfig, \%$form));
581 $form->error($locale->text('Cannot delete account!'));
583 $lxdebug->leave_sub();
587 $lxdebug->enter_sub();
589 $form->{title} = "Add";
593 "$form->{script}?action=add_department&login=$form->{login}&password=$form->{password}"
594 unless $form->{callback};
599 $lxdebug->leave_sub();
602 sub edit_department {
603 $lxdebug->enter_sub();
605 $form->{title} = "Edit";
607 AM->get_department(\%myconfig, \%$form);
612 $lxdebug->leave_sub();
615 sub list_department {
616 $lxdebug->enter_sub();
618 AM->departments(\%myconfig, \%$form);
621 "$form->{script}?action=list_department&login=$form->{login}&password=$form->{password}";
623 $callback = $form->escape($form->{callback});
625 $form->{title} = $locale->text('Departments');
627 @column_index = qw(description cost profit);
629 $column_header{description} =
630 qq|<th class=listheading width=90%>|
631 . $locale->text('Description')
633 $column_header{cost} =
634 qq|<th class=listheading nowrap>|
635 . $locale->text('Cost Center')
637 $column_header{profit} =
638 qq|<th class=listheading nowrap>|
639 . $locale->text('Profit Center')
649 <th class=listtop>$form->{title}</th>
655 <tr class=listheading>
658 map { print "$column_header{$_}\n" } @column_index;
664 foreach $ref (@{ $form->{ALL} }) {
670 <tr valign=top class=listrow$i>
673 $costcenter = ($ref->{role} eq "C") ? "X" : "";
674 $profitcenter = ($ref->{role} eq "P") ? "X" : "";
676 $column_data{description} =
677 qq|<td><a href=$form->{script}?action=edit_department&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
678 $column_data{cost} = qq|<td align=center>$costcenter</td>|;
679 $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
681 map { print "$column_data{$_}\n" } @column_index;
693 <td><hr size=3 noshade></td>
698 <form method=post action=$form->{script}>
700 <input name=callback type=hidden value="$form->{callback}">
702 <input type=hidden name=type value=department>
704 <input type=hidden name=login value=$form->{login}>
705 <input type=hidden name=password value=$form->{password}>
707 <input class=submit type=submit name=action value="|
708 . $locale->text('Add') . qq|">
716 $lxdebug->leave_sub();
719 sub department_header {
720 $lxdebug->enter_sub();
722 $form->{title} = $locale->text("$form->{title} Department");
724 # $locale->text('Add Department')
725 # $locale->text('Edit Department')
727 $form->{description} =~ s/\"/"/g;
729 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
731 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
734 qq|<input name=description size=60 value="$form->{description}">|;
737 $costcenter = "checked" if $form->{role} eq "C";
738 $profitcenter = "checked" if $form->{role} eq "P";
745 <form method=post action=$form->{script}>
747 <input type=hidden name=id value=$form->{id}>
748 <input type=hidden name=type value=department>
752 <th class=listtop colspan=2>$form->{title}</th>
756 <th align=right>| . $locale->text('Description') . qq|</th>
757 <td>$description</td>
761 <td><input type=radio style=radio name=role value="C" $costcenter> |
762 . $locale->text('Cost Center') . qq|
763 <input type=radio style=radio name=role value="P" $profitcenter> |
764 . $locale->text('Profit Center') . qq|
767 <td colspan=2><hr size=3 noshade></td>
772 $lxdebug->leave_sub();
775 sub save_department {
776 $lxdebug->enter_sub();
778 $form->isblank("description", $locale->text('Description missing!'));
779 AM->save_department(\%myconfig, \%$form);
780 $form->redirect($locale->text('Department saved!'));
782 $lxdebug->leave_sub();
785 sub delete_department {
786 $lxdebug->enter_sub();
788 AM->delete_department(\%myconfig, \%$form);
789 $form->redirect($locale->text('Department deleted!'));
791 $lxdebug->leave_sub();
795 $lxdebug->enter_sub();
797 $form->{title} = "Add";
800 "$form->{script}?action=add_lead&login=$form->{login}&password=$form->{password}"
801 unless $form->{callback};
806 $lxdebug->leave_sub();
810 $lxdebug->enter_sub();
812 $form->{title} = "Edit";
814 AM->get_lead(\%myconfig, \%$form);
818 $form->{orphaned} = 1;
821 $lxdebug->leave_sub();
825 $lxdebug->enter_sub();
827 AM->lead(\%myconfig, \%$form);
830 "$form->{script}?action=list_lead&login=$form->{login}&password=$form->{password}";
832 $callback = $form->escape($form->{callback});
834 $form->{title} = $locale->text('Lead');
836 @column_index = qw(description cost profit);
838 $column_header{description} =
839 qq|<th class=listheading width=100%>|
840 . $locale->text('Description')
850 <th class=listtop>$form->{title}</th>
853 <tr class=listheading>
856 map { print "$column_header{$_}\n" } @column_index;
862 foreach $ref (@{ $form->{ALL} }) {
868 <tr valign=top class=listrow$i>
871 $lead = $ref->{lead};
873 $column_data{description} =
874 qq|<td><a href=$form->{script}?action=edit_lead&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{lead}</td>|;
876 map { print "$column_data{$_}\n" } @column_index;
885 <td><hr size=3 noshade></td>
890 <form method=post action=$form->{script}>
892 <input name=callback type=hidden value="$form->{callback}">
894 <input type=hidden name=type value=lead>
896 <input type=hidden name=login value=$form->{login}>
897 <input type=hidden name=password value=$form->{password}>
899 <input class=submit type=submit name=action value="|
900 . $locale->text('Add') . qq|">
908 $lxdebug->leave_sub();
912 $lxdebug->enter_sub();
914 $form->{title} = $locale->text("$form->{title} Lead");
916 # $locale->text('Add Lead')
917 # $locale->text('Edit Lead')
919 $form->{description} =~ s/\"/"/g;
922 qq|<input name=description size=50 value="$form->{lead}">|;
929 <form method=post action=$form->{script}>
931 <input type=hidden name=id value=$form->{id}>
932 <input type=hidden name=type value=lead>
936 <th class=listtop colspan=2>$form->{title}</th>
940 <th align=right>| . $locale->text('Description') . qq|</th>
941 <td>$description</td>
943 <td colspan=2><hr size=3 noshade></td>
948 $lxdebug->leave_sub();
952 $lxdebug->enter_sub();
954 $form->isblank("description", $locale->text('Description missing!'));
955 AM->save_lead(\%myconfig, \%$form);
956 $form->redirect($locale->text('lead saved!'));
958 $lxdebug->leave_sub();
962 $lxdebug->enter_sub();
964 AM->delete_lead(\%myconfig, \%$form);
965 $form->redirect($locale->text('lead deleted!'));
967 $lxdebug->leave_sub();
971 $lxdebug->enter_sub();
973 $form->{title} = "Add";
976 "$form->{script}?action=add_business&login=$form->{login}&password=$form->{password}"
977 unless $form->{callback};
982 $lxdebug->leave_sub();
986 $lxdebug->enter_sub();
988 $form->{title} = "Edit";
990 AM->get_business(\%myconfig, \%$form);
994 $form->{orphaned} = 1;
997 $lxdebug->leave_sub();
1001 $lxdebug->enter_sub();
1003 AM->business(\%myconfig, \%$form);
1006 "$form->{script}?action=list_business&login=$form->{login}&password=$form->{password}";
1008 $callback = $form->escape($form->{callback});
1010 $form->{title} = $locale->text('Type of Business');
1012 @column_index = qw(description discount customernumberinit);
1014 $column_header{description} =
1015 qq|<th class=listheading width=60%>|
1016 . $locale->text('Description')
1018 $column_header{discount} =
1019 qq|<th class=listheading width=10%>|
1020 . $locale->text('Discount')
1022 $column_header{customernumberinit} =
1023 qq|<th class=listheading>|
1024 . $locale->text('Customernumberinit')
1034 <th class=listtop>$form->{title}</th>
1036 <tr height="5"></tr>
1040 <tr class=listheading>
1043 map { print "$column_header{$_}\n" } @column_index;
1049 foreach $ref (@{ $form->{ALL} }) {
1055 <tr valign=top class=listrow$i>
1059 $form->format_amount(\%myconfig, $ref->{discount} * 100);
1061 $ref->{description};
1062 $column_data{description} =
1063 qq|<td><a href=$form->{script}?action=edit_business&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$description</td>|;
1064 $column_data{discount} = qq|<td align=right>$discount</td>|;
1065 $column_data{customernumberinit} =
1066 qq|<td align=right>$ref->{customernumberinit}</td>|;
1068 map { print "$column_data{$_}\n" } @column_index;
1080 <td><hr size=3 noshade></td>
1085 <form method=post action=$form->{script}>
1087 <input name=callback type=hidden value="$form->{callback}">
1089 <input type=hidden name=type value=business>
1091 <input type=hidden name=login value=$form->{login}>
1092 <input type=hidden name=password value=$form->{password}>
1094 <input class=submit type=submit name=action value="|
1095 . $locale->text('Add') . qq|">
1103 $lxdebug->leave_sub();
1106 sub business_header {
1107 $lxdebug->enter_sub();
1109 $form->{title} = $locale->text("$form->{title} Business");
1111 # $locale->text('Add Business')
1112 # $locale->text('Edit Business')
1114 $form->{description} =~ s/\"/"/g;
1116 $form->format_amount(\%myconfig, $form->{discount} * 100);
1123 <form method=post action=$form->{script}>
1125 <input type=hidden name=id value=$form->{id}>
1126 <input type=hidden name=type value=business>
1130 <th class=listtop colspan=2>$form->{title}</th>
1132 <tr height="5"></tr>
1134 <th align=right>| . $locale->text('Type of Business') . qq|</th>
1135 <td><input name=description size=30 value="$form->{description}"></td>
1138 <th align=right>| . $locale->text('Discount') . qq| %</th>
1139 <td><input name=discount size=5 value=$form->{discount}></td>
1142 <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
1143 <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
1145 <td colspan=2><hr size=3 noshade></td>
1150 $lxdebug->leave_sub();
1154 $lxdebug->enter_sub();
1156 $form->isblank("description", $locale->text('Description missing!'));
1157 $form->{discount} = $form->parse_amount(\%myconfig, $form->{discount}) / 100;
1158 AM->save_business(\%myconfig, \%$form);
1159 $form->redirect($locale->text('Business saved!'));
1161 $lxdebug->leave_sub();
1164 sub delete_business {
1165 $lxdebug->enter_sub();
1167 AM->delete_business(\%myconfig, \%$form);
1168 $form->redirect($locale->text('Business deleted!'));
1170 $lxdebug->leave_sub();
1174 $lxdebug->enter_sub();
1176 $form->{title} = "Add";
1179 "$form->{script}?action=add_language&login=$form->{login}&password=$form->{password}"
1180 unless $form->{callback};
1185 $lxdebug->leave_sub();
1189 $lxdebug->enter_sub();
1191 $form->{title} = "Edit";
1193 AM->get_language(\%myconfig, \%$form);
1197 $form->{orphaned} = 1;
1200 $lxdebug->leave_sub();
1204 $lxdebug->enter_sub();
1206 AM->language(\%myconfig, \%$form);
1209 "$form->{script}?action=list_language&login=$form->{login}&password=$form->{password}";
1211 $callback = $form->escape($form->{callback});
1213 $form->{title} = $locale->text('Languages');
1215 @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
1217 $column_header{description} =
1218 qq|<th class=listheading width=60%>|
1219 . $locale->text('Description')
1221 $column_header{template_code} =
1222 qq|<th class=listheading width=10%>|
1223 . $locale->text('Template Code')
1225 $column_header{article_code} =
1226 qq|<th class=listheading>|
1227 . $locale->text('Article Code')
1229 $column_header{output_numberformat} =
1230 qq|<th class=listheading>|
1231 . $locale->text('Number Format')
1233 $column_header{output_dateformat} =
1234 qq|<th class=listheading>|
1235 . $locale->text('Date Format')
1237 $column_header{output_longdates} =
1238 qq|<th class=listheading>|
1239 . $locale->text('Long Dates')
1249 <th class=listtop>$form->{title}</th>
1251 <tr height="5"></tr>
1255 <tr class=listheading>
1258 map { print "$column_header{$_}\n" } @column_index;
1264 foreach $ref (@{ $form->{ALL} }) {
1270 <tr valign=top class=listrow$i>
1274 $column_data{description} =
1275 qq|<td><a href=$form->{script}?action=edit_language&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
1276 $column_data{template_code} = qq|<td align=right>$ref->{template_code}</td>|;
1277 $column_data{article_code} =
1278 qq|<td align=right>$ref->{article_code}</td>|;
1279 $column_data{output_numberformat} =
1281 ($ref->{output_numberformat} ? $ref->{output_numberformat} :
1282 $locale->text("use program settings")) .
1284 $column_data{output_dateformat} =
1286 ($ref->{output_dateformat} ? $ref->{output_dateformat} :
1287 $locale->text("use program settings")) .
1289 $column_data{output_longdates} =
1291 ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
1294 map { print "$column_data{$_}\n" } @column_index;
1306 <td><hr size=3 noshade></td>
1311 <form method=post action=$form->{script}>
1313 <input name=callback type=hidden value="$form->{callback}">
1315 <input type=hidden name=type value=language>
1317 <input type=hidden name=login value=$form->{login}>
1318 <input type=hidden name=password value=$form->{password}>
1320 <input class=submit type=submit name=action value="|
1321 . $locale->text('Add') . qq|">
1329 $lxdebug->leave_sub();
1332 sub language_header {
1333 $lxdebug->enter_sub();
1335 $form->{title} = $locale->text("$form->{title} Language");
1337 # $locale->text('Add Language')
1338 # $locale->text('Edit Language')
1340 $form->{description} =~ s/\"/"/g;
1341 $form->{template_code} =~ s/\"/"/g;
1342 $form->{article_code} =~ s/\"/"/g;
1348 qq|<option value="">| . $locale->text("use program settings") .
1350 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
1352 ($item eq $form->{output_numberformat})
1353 ? "<option selected>$item"
1359 qq|<option value="">| . $locale->text("use program settings") .
1361 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
1363 ($item eq $form->{output_dateformat})
1364 ? "<option selected>$item"
1372 <form method=post action=$form->{script}>
1374 <input type=hidden name=id value=$form->{id}>
1375 <input type=hidden name=type value=language>
1379 <th class=listtop colspan=2>$form->{title}</th>
1381 <tr height="5"></tr>
1383 <th align=right>| . $locale->text('Language') . qq|</th>
1384 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1387 <th align=right>| . $locale->text('Template Code') . qq|</th>
1388 <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
1391 <th align=right>| . $locale->text('Article Code') . qq|</th>
1392 <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
1395 <th align=right>| . $locale->text('Number Format') . qq|</th>
1396 <td><select name="output_numberformat">$numberformat</select></td>
1399 <th align=right>| . $locale->text('Date Format') . qq|</th>
1400 <td><select name="output_dateformat">$dateformat</select></td>
1403 <th align=right>| . $locale->text('Long Dates') . qq|</th>
1404 <td><input type="radio" name="output_longdates" value="1"| .
1405 ($form->{output_longdates} ? " checked" : "") .
1406 qq|>| . $locale->text("Yes") .
1407 qq|<input type="radio" name="output_longdates" value="0"| .
1408 ($form->{output_longdates} ? "" : " checked") .
1409 qq|>| . $locale->text("No") .
1412 <td colspan=2><hr size=3 noshade></td>
1417 $lxdebug->leave_sub();
1421 $lxdebug->enter_sub();
1423 $form->isblank("description", $locale->text('Language missing!'));
1424 $form->isblank("template_code", $locale->text('Template Code missing!'));
1425 $form->isblank("article_code", $locale->text('Article Code missing!'));
1426 AM->save_language(\%myconfig, \%$form);
1427 $form->redirect($locale->text('Language saved!'));
1429 $lxdebug->leave_sub();
1432 sub delete_language {
1433 $lxdebug->enter_sub();
1435 AM->delete_language(\%myconfig, \%$form);
1436 $form->redirect($locale->text('Language deleted!'));
1438 $lxdebug->leave_sub();
1442 sub add_buchungsgruppe {
1443 $lxdebug->enter_sub();
1445 # $locale->text("Add Buchungsgruppe")
1446 # $locale->text("Edit Buchungsgruppe")
1447 $form->{title} = "Add";
1450 "$form->{script}?action=add_buchungsgruppe&login=$form->{login}&password=$form->{password}"
1451 unless $form->{callback};
1452 AM->get_buchungsgruppe(\%myconfig, \%$form);
1453 $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
1454 for (my $i = 0; 4 > $i; $i++) {
1455 map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
1456 qw(income expense));
1459 &buchungsgruppe_header;
1462 $lxdebug->leave_sub();
1465 sub edit_buchungsgruppe {
1466 $lxdebug->enter_sub();
1468 $form->{title} = "Edit";
1470 AM->get_buchungsgruppe(\%myconfig, \%$form);
1472 &buchungsgruppe_header;
1476 $lxdebug->leave_sub();
1479 sub list_buchungsgruppe {
1480 $lxdebug->enter_sub();
1482 AM->buchungsgruppe(\%myconfig, \%$form);
1485 "$form->{script}?action=list_buchungsgruppe&login=$form->{login}&password=$form->{password}";
1487 $callback = $form->escape($form->{callback});
1489 $form->{title} = $locale->text('Buchungsgruppen');
1491 @column_index = qw(up down description inventory_accno
1492 income_accno_0 expense_accno_0
1493 income_accno_1 expense_accno_1
1494 income_accno_2 expense_accno_2
1495 income_accno_3 expense_accno_3 );
1497 $column_header{up} =
1498 qq|<th class="listheading" width="16">|
1499 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
1501 $column_header{down} =
1502 qq|<th class="listheading" width="16">|
1503 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
1505 $column_header{description} =
1506 qq|<th class="listheading" width="40%">|
1507 . $locale->text('Description')
1509 $column_header{inventory_accno} =
1510 qq|<th class=listheading>|
1511 . $locale->text('Bestandskonto')
1513 $column_header{income_accno_0} =
1514 qq|<th class=listheading>|
1515 . $locale->text('National Revenues')
1517 $column_header{expense_accno_0} =
1518 qq|<th class=listheading>|
1519 . $locale->text('National Expenses')
1521 $column_header{income_accno_1} =
1522 qq|<th class=listheading>|
1523 . $locale->text('Revenues EU with UStId')
1525 $column_header{expense_accno_1} =
1526 qq|<th class=listheading>|
1527 . $locale->text('Expenses EU with UStId')
1529 $column_header{income_accno_2} =
1530 qq|<th class=listheading>|
1531 . $locale->text('Revenues EU without UStId')
1533 $column_header{expense_accno_2} =
1534 qq|<th class=listheading>|
1535 . $locale->text('Expenses EU without UStId')
1537 $column_header{income_accno_3} =
1538 qq|<th class=listheading>|
1539 . $locale->text('Foreign Revenues')
1541 $column_header{expense_accno_3} =
1542 qq|<th class=listheading>|
1543 . $locale->text('Foreign Expenses')
1552 <th class=listtop>$form->{title}</th>
1554 <tr height="5"></tr>
1558 <tr class=listheading>
1561 map { print "$column_header{$_}\n" } @column_index;
1567 my $swap_link = qq|$form->{script}?action=swap_buchungsgruppen&|;
1568 map({ $swap_link .= $_ . "=" . $form->escape($form->{$_}) . "&" }
1569 qw(login password));
1572 foreach $ref (@{ $form->{ALL} }) {
1578 <tr valign=top class=listrow$i>
1582 my $pref = $form->{ALL}->[$row - 1];
1584 qq|<td align="center" valign="center" width="16">| .
1585 qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
1586 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
1589 $column_data{up} = qq|<td width="16"> </td>|;
1592 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
1593 $column_data{down} = qq|<td width="16"> </td>|;
1595 my $nref = $form->{ALL}->[$row + 1];
1596 $column_data{down} =
1597 qq|<td align="center" valign="center" width="16">| .
1598 qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
1599 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
1603 $column_data{description} =
1604 qq|<td><a href=$form->{script}?action=edit_buchungsgruppe&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
1605 $column_data{inventory_accno} = qq|<td align=right>$ref->{inventory_accno}</td>|;
1606 $column_data{income_accno_0} =
1607 qq|<td align=right>$ref->{income_accno_0}</td>|;
1608 $column_data{expense_accno_0} = qq|<td align=right>$ref->{expense_accno_0}</td>|;
1609 $column_data{income_accno_1} =
1610 qq|<td align=right>$ref->{income_accno_1}</td>|;
1611 $column_data{expense_accno_1} = qq|<td align=right>$ref->{expense_accno_1}</td>|;
1612 $column_data{income_accno_2} =
1613 qq|<td align=right>$ref->{income_accno_2}</td>|;
1614 $column_data{expense_accno_2} = qq|<td align=right>$ref->{expense_accno_2}</td>|;
1615 $column_data{income_accno_3} =
1616 qq|<td align=right>$ref->{income_accno_3}</td>|;
1617 $column_data{expense_accno_3} = qq|<td align=right>$ref->{expense_accno_3}</td>|;
1619 map { print "$column_data{$_}\n" } @column_index;
1633 <td><hr size=3 noshade></td>
1638 <form method=post action=$form->{script}>
1640 <input name=callback type=hidden value="$form->{callback}">
1642 <input type=hidden name=type value=buchungsgruppe>
1644 <input type=hidden name=login value=$form->{login}>
1645 <input type=hidden name=password value=$form->{password}>
1647 <input class=submit type=submit name=action value="|
1648 . $locale->text('Add') . qq|">
1656 $lxdebug->leave_sub();
1659 sub buchungsgruppe_header {
1660 $lxdebug->enter_sub();
1662 $form->{title} = $locale->text("$form->{title} Buchungsgruppe");
1664 # $locale->text('Add Accounting Group')
1665 # $locale->text('Edit Accounting Group')
1667 my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
1668 my %acc_type_map = (
1669 "IC" => $acc_inventory,
1670 "IC_income" => $acc_income,
1671 "IC_sale" => $acc_income,
1672 "IC_expense" => $acc_expense,
1673 "IC_cogs" => $acc_expense,
1676 foreach $key (keys(%acc_type_map)) {
1677 foreach $ref (@{ $form->{IC_links}{$key} }) {
1678 $acc_type_map{$key}->{$ref->{"id"}} = $ref;
1682 foreach my $type (qw(IC IC_income IC_expense)) {
1683 $form->{"select$type"} =
1685 map({ "<option value=$_->{id} $_->{selected}>" .
1686 "$_->{accno}--" . H($_->{description}) . "</option>" }
1687 sort({ $a->{"accno"} cmp $b->{"accno"} }
1688 values(%{$acc_type_map{$type}}))));
1692 $form->{selectIC} =~ s/selected//g;
1693 $form->{selectIC} =~ s/ value=$form->{inventory_accno_id}/ value=$form->{inventory_accno_id} selected/;
1694 $form->{selectIC_income} =~ s/selected//g;
1695 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_0}/ value=$form->{income_accno_id_0} selected/;
1696 $form->{selectIC_expense} =~ s/selected//g;
1697 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_0}/ value=$form->{expense_accno_id_0} selected/;
1703 <th align=right>| . $locale->text('Inventory') . qq|</th>
1704 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
1705 <input name=selectIC type=hidden value="$form->{selectIC}">
1709 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
1713 $linkaccounts .= qq|
1715 <th align=right>| . $locale->text('National Revenues') . qq|</th>
1716 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
1719 <th align=right>| . $locale->text('National Expenses') . qq|</th>
1720 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
1723 $form->{selectIC_income} =~ s/selected//g;
1724 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_1}/ value=$form->{income_accno_id_1} selected/;
1725 $form->{selectIC_expense} =~ s/selected//g;
1726 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/ value=$form->{expense_accno_id_1} selected/;
1728 $linkaccounts .= qq| <tr>
1729 <th align=right>| . $locale->text('Revenues EU with UStId') . qq|</th>
1730 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
1733 <th align=right>| . $locale->text('Expenses EU with UStId') . qq|</th>
1734 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
1738 $form->{selectIC_income} =~ s/selected//g;
1739 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_2}/ value=$form->{income_accno_id_2} selected/;
1740 $form->{selectIC_expense} =~ s/selected//g;
1741 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_2}/ value=$form->{expense_accno_id_2} selected/;
1744 $linkaccounts .= qq| <tr>
1745 <th align=right>| . $locale->text('Revenues EU without UStId') . qq|</th>
1746 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
1749 <th align=right>| . $locale->text('Expenses EU without UStId') . qq|</th>
1750 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
1754 $form->{selectIC_income} =~ s/selected//g;
1755 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_3}/ value=$form->{income_accno_id_3} selected/;
1756 $form->{selectIC_expense} =~ s/selected//g;
1757 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_3}/ value=$form->{expense_accno_id_3} selected/;
1760 $linkaccounts .= qq| <tr>
1761 <th align=right>| . $locale->text('Foreign Revenues') . qq|</th>
1762 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
1765 <th align=right>| . $locale->text('Foreign Expenses') . qq|</th>
1766 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
1776 <form method=post action=$form->{script}>
1778 <input type=hidden name=id value=$form->{id}>
1779 <input type=hidden name=type value=buchungsgruppe>
1783 <th class=listtop colspan=2>$form->{title}</th>
1785 <tr height="5"></tr>
1787 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
1788 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1791 <td colspan=2><hr size=3 noshade></td>
1796 $lxdebug->leave_sub();
1799 sub save_buchungsgruppe {
1800 $lxdebug->enter_sub();
1802 $form->isblank("description", $locale->text('Description missing!'));
1804 AM->save_buchungsgruppe(\%myconfig, \%$form);
1805 $form->redirect($locale->text('Accounting Group saved!'));
1807 $lxdebug->leave_sub();
1810 sub delete_buchungsgruppe {
1811 $lxdebug->enter_sub();
1813 AM->delete_buchungsgruppe(\%myconfig, \%$form);
1814 $form->redirect($locale->text('Accounting Group deleted!'));
1816 $lxdebug->leave_sub();
1819 sub swap_buchungsgruppen {
1820 $lxdebug->enter_sub();
1822 AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
1823 list_buchungsgruppe();
1825 $lxdebug->leave_sub();
1830 $lxdebug->enter_sub();
1832 $form->{title} = "Add";
1835 "$form->{script}?action=add_printer&login=$form->{login}&password=$form->{password}"
1836 unless $form->{callback};
1841 $lxdebug->leave_sub();
1845 $lxdebug->enter_sub();
1847 $form->{title} = "Edit";
1849 AM->get_printer(\%myconfig, \%$form);
1853 $form->{orphaned} = 1;
1856 $lxdebug->leave_sub();
1860 $lxdebug->enter_sub();
1862 AM->printer(\%myconfig, \%$form);
1865 "$form->{script}?action=list_printer&login=$form->{login}&password=$form->{password}";
1867 $callback = $form->escape($form->{callback});
1869 $form->{title} = $locale->text('Printer');
1871 @column_index = qw(printer_description printer_command template_code);
1873 $column_header{printer_description} =
1874 qq|<th class=listheading width=60%>|
1875 . $locale->text('Printer Description')
1877 $column_header{printer_command} =
1878 qq|<th class=listheading width=10%>|
1879 . $locale->text('Printer Command')
1881 $column_header{template_code} =
1882 qq|<th class=listheading>|
1883 . $locale->text('Template Code')
1893 <th class=listtop>$form->{title}</th>
1895 <tr height="5"></tr>
1899 <tr class=listheading>
1902 map { print "$column_header{$_}\n" } @column_index;
1908 foreach $ref (@{ $form->{ALL} }) {
1914 <tr valign=top class=listrow$i>
1918 $column_data{printer_description} =
1919 qq|<td><a href=$form->{script}?action=edit_printer&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{printer_description}</td>|;
1920 $column_data{printer_command} = qq|<td align=right>$ref->{printer_command}</td>|;
1921 $column_data{template_code} =
1922 qq|<td align=right>$ref->{template_code}</td>|;
1924 map { print "$column_data{$_}\n" } @column_index;
1936 <td><hr size=3 noshade></td>
1941 <form method=post action=$form->{script}>
1943 <input name=callback type=hidden value="$form->{callback}">
1945 <input type=hidden name=type value=printer>
1947 <input type=hidden name=login value=$form->{login}>
1948 <input type=hidden name=password value=$form->{password}>
1950 <input class=submit type=submit name=action value="|
1951 . $locale->text('Add') . qq|">
1959 $lxdebug->leave_sub();
1962 sub printer_header {
1963 $lxdebug->enter_sub();
1965 $form->{title} = $locale->text("$form->{title} Printer");
1967 # $locale->text('Add Printer')
1968 # $locale->text('Edit Printer')
1970 $form->{printer_description} =~ s/\"/"/g;
1971 $form->{template_code} =~ s/\"/"/g;
1972 $form->{printer_command} =~ s/\"/"/g;
1980 <form method=post action=$form->{script}>
1982 <input type=hidden name=id value=$form->{id}>
1983 <input type=hidden name=type value=printer>
1987 <th class=listtop colspan=2>$form->{title}</th>
1989 <tr height="5"></tr>
1991 <th align=right>| . $locale->text('Printer') . qq|</th>
1992 <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
1995 <th align=right>| . $locale->text('Printer Command') . qq|</th>
1996 <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
1999 <th align=right>| . $locale->text('Template Code') . qq|</th>
2000 <td><input name=template_code size=5 value="$form->{template_code}"></td>
2002 <td colspan=2><hr size=3 noshade></td>
2007 $lxdebug->leave_sub();
2011 $lxdebug->enter_sub();
2013 $form->isblank("printer_description", $locale->text('Description missing!'));
2014 $form->isblank("printer_command", $locale->text('Printer Command missing!'));
2015 AM->save_printer(\%myconfig, \%$form);
2016 $form->redirect($locale->text('Printer saved!'));
2018 $lxdebug->leave_sub();
2021 sub delete_printer {
2022 $lxdebug->enter_sub();
2024 AM->delete_printer(\%myconfig, \%$form);
2025 $form->redirect($locale->text('Printer deleted!'));
2027 $lxdebug->leave_sub();
2031 $lxdebug->enter_sub();
2033 $form->{title} = "Add";
2036 "$form->{script}?action=add_payment&login=$form->{login}&password=$form->{password}"
2037 unless $form->{callback};
2039 $form->{terms_netto} = 0;
2040 $form->{terms_skonto} = 0;
2041 $form->{percent_skonto} = 0;
2042 my @languages = AM->language(\%myconfig, $form, 1);
2043 map({ $_->{"language"} = $_->{"description"};
2044 $_->{"language_id"} = $_->{"id"}; } @languages);
2045 $form->{"TRANSLATION"} = \@languages;
2049 $lxdebug->leave_sub();
2053 $lxdebug->enter_sub();
2055 $form->{title} = "Edit";
2057 AM->get_payment(\%myconfig, $form);
2058 $form->{percent_skonto} =
2059 $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
2063 $form->{orphaned} = 1;
2066 $lxdebug->leave_sub();
2070 $lxdebug->enter_sub();
2072 AM->payment(\%myconfig, \%$form);
2074 $form->{callback} = build_std_url("action=list_payment");
2076 $callback = $form->escape($form->{callback});
2078 $form->{title} = $locale->text('Payment Terms');
2080 @column_index = qw(up down description description_long terms_netto
2081 terms_skonto percent_skonto);
2083 $column_header{up} =
2084 qq|<th class="listheading" align="center" valign="center" width="16">|
2085 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
2087 $column_header{down} =
2088 qq|<th class="listheading" align="center" valign="center" width="16">|
2089 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
2091 $column_header{description} =
2092 qq|<th class=listheading>|
2093 . $locale->text('Description')
2095 $column_header{description_long} =
2096 qq|<th class=listheading>|
2097 . $locale->text('Long Description')
2099 $column_header{terms_netto} =
2100 qq|<th class=listheading>|
2101 . $locale->text('Netto Terms')
2103 $column_header{terms_skonto} =
2104 qq|<th class=listheading>|
2105 . $locale->text('Skonto Terms')
2107 $column_header{percent_skonto} =
2108 qq|<th class=listheading>|
2109 . $locale->text('Skonto')
2119 <th class=listtop>$form->{title}</th>
2121 <tr height="5"></tr>
2125 <tr class=listheading>
2128 map { print "$column_header{$_}\n" } @column_index;
2134 my $swap_link = build_std_url("action=swap_payment_terms");
2137 foreach $ref (@{ $form->{ALL} }) {
2143 <tr valign=top class=listrow$i>
2147 my $pref = $form->{ALL}->[$row - 1];
2149 qq|<td align="center" valign="center" width="16">| .
2150 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
2151 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
2154 $column_data{up} = qq|<td width="16"> </td>|;
2157 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
2158 $column_data{down} = qq|<td width="16"> </td>|;
2160 my $nref = $form->{ALL}->[$row + 1];
2161 $column_data{down} =
2162 qq|<td align="center" valign="center" width="16">| .
2163 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
2164 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
2168 $column_data{description} =
2170 build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
2171 qq|">| . H($ref->{description}) . qq|</a></td>|;
2172 $column_data{description_long} =
2173 qq|<td>| . H($ref->{description_long}) . qq|</td>|;
2174 $column_data{terms_netto} =
2175 qq|<td align=right>$ref->{terms_netto}</td>|;
2176 $column_data{terms_skonto} =
2177 qq|<td align=right>$ref->{terms_skonto}</td>|;
2178 $column_data{percent_skonto} =
2179 qq|<td align=right>| .
2180 $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
2182 map { print "$column_data{$_}\n" } @column_index;
2195 <td><hr size=3 noshade></td>
2200 <form method=post action=$form->{script}>
2202 <input name=callback type=hidden value="$form->{callback}">
2204 <input type=hidden name=type value=payment>
2206 <input type=hidden name=login value=$form->{login}>
2207 <input type=hidden name=password value=$form->{password}>
2209 <input class=submit type=submit name=action value="|
2210 . $locale->text('Add') . qq|">
2218 $lxdebug->leave_sub();
2221 sub payment_header {
2222 $lxdebug->enter_sub();
2224 $form->{title} = $locale->text("$form->{title} Payment Terms");
2226 # $locale->text('Add Payment Terms')
2227 # $locale->text('Edit Payment Terms')
2229 $form->{description} =~ s/\"/"/g;
2238 <form method=post action=$form->{script}>
2240 <input type=hidden name=id value=$form->{id}>
2241 <input type=hidden name=type value=payment>
2245 <th class=listtop colspan=2>$form->{title}</th>
2247 <tr height="5"></tr>
2249 <th align=right>| . $locale->text('Description') . qq|</th>
2250 <td><input name=description size=30 value="$form->{description}"></td>
2253 <th align=right>| . $locale->text('Long Description') . qq|</th>
2254 <td><input name=description_long size=50 value="$form->{description_long}"></td>
2258 foreach my $language (@{ $form->{"TRANSLATION"} }) {
2261 <th align="right">| .
2262 sprintf($locale->text('Translation (%s)'),
2263 $language->{"language"})
2265 <td><input name="description_long_$language->{language_id}" size="50"
2266 value="| . Q($language->{"description_long"}) . qq|"></td>
2273 <th align=right>| . $locale->text('Netto Terms') . qq|</th>
2274 <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
2277 <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
2278 <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
2281 <th align=right>| . $locale->text('Skonto') . qq| %</th>
2282 <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
2284 <td colspan=2><hr size=3 noshade></td>
2288 <p>| . $locale->text("You can use the following strings in the long " .
2289 "description and all translations. They will be " .
2290 "replaced by their actual values by Lx-Office " .
2291 "before they're output.")
2295 <li>| . $locale->text("<%netto_date%> -- Date the payment is due in " .
2298 <li>| . $locale->text("<%skonto_date%> -- Date the payment is due " .
2301 <li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
2303 <li>| . $locale->text("<%total%> -- Amount payable")
2305 <li>| . $locale->text("<%invtotal%> -- Invoice total")
2307 <li>| . $locale->text("<%currency%> -- The selected currency")
2309 <li>| . $locale->text("<%terms_netto%> -- The number of days for " .
2312 <li>| . $locale->text("<%account_number%> -- Your account number")
2314 <li>| . $locale->text("<%bank%> -- Your bank")
2316 <li>| . $locale->text("<%bank_code%> -- Your bank code")
2320 $lxdebug->leave_sub();
2324 $lxdebug->enter_sub();
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 AM->delete_payment(\%myconfig, \%$form);
2339 $form->redirect($locale->text('Payment terms deleted!'));
2341 $lxdebug->leave_sub();
2344 sub swap_payment_terms {
2345 $lxdebug->enter_sub();
2347 AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
2350 $lxdebug->leave_sub();
2354 $lxdebug->enter_sub();
2356 # get defaults for account numbers and last numbers
2357 AM->defaultaccounts(\%myconfig, \%$form);
2359 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
2361 ($item eq $myconfig{dateformat})
2362 ? "<option selected>$item\n"
2363 : "<option>$item\n";
2366 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
2368 ($item eq $myconfig{numberformat})
2369 ? "<option selected>$item\n"
2370 : "<option>$item\n";
2373 foreach $item (qw(name company address signature)) {
2374 $myconfig{$item} =~ s/\"/"/g;
2377 foreach $item (qw(address signature)) {
2378 $myconfig{$item} =~ s/\\n/\r\n/g;
2382 if ($opendocument_templates && $openofficeorg_writer_bin &&
2383 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
2384 push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
2385 "value" => "opendocument_pdf" });
2387 if ($latex_templates) {
2388 push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
2390 push(@formats, { "name" => "HTML", "value" => "html" });
2391 if ($latex_templates) {
2392 push(@formats, { "name" => $locale->text("Postscript"),
2393 "value" => "postscript" });
2395 if ($opendocument_templates) {
2396 push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
2397 "value" => "opendocument" });
2400 if (!$myconfig{"template_format"}) {
2401 $myconfig{"template_format"} = "pdf";
2403 my $template_format = "";
2404 foreach $item (@formats) {
2406 "<option value=\"$item->{value}\"" .
2407 ($item->{"value"} eq $myconfig{"template_format"} ?
2409 ">" . H($item->{"name"}) . "</option>";
2412 if (!$myconfig{"default_media"}) {
2413 $myconfig{"default_media"} = "screen";
2415 my %selected = ($myconfig{"default_media"} => "selected");
2416 my $default_media = qq|
2417 <option value="screen" $selected{'screen'}>| . $locale->text("Screen") . qq|</option>
2418 <option value="printer" $selected{'printer'}>| . $locale->text("Printer") . qq|</option>
2419 <option value="queue" $selected{'queue'}>| . $locale->text("Queue") . qq|</option>
2423 $selected{$myconfig{"default_printer_id"}} = "selected"
2424 if ($myconfig{"default_printer_id"});
2425 my $default_printer = qq|<option></option>|;
2426 AM->printer(\%myconfig, $form);
2427 foreach my $printer (@{$form->{"ALL"}}) {
2428 $default_printer .= qq|<option value="| . Q($printer->{"id"}) .
2429 qq|" $selected{$printer->{'id'}}>| .
2430 H($printer->{"printer_description"}) . qq|</option>|;
2433 %countrycodes = User->country_codes;
2435 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
2439 ($myconfig{countrycode} eq $key)
2440 ? "<option selected value=$key>$countrycodes{$key}\n"
2441 : "<option value=$key>$countrycodes{$key}\n";
2443 $countrycodes = "<option>American English\n$countrycodes";
2445 foreach $key (keys %{ $form->{IC} }) {
2446 foreach $accno (sort keys %{ $form->{IC}{$key} }) {
2448 ($form->{IC}{$key}{$accno}{id} == $form->{defaults}{$key})
2449 ? "<option selected>$accno--$form->{IC}{$key}{$accno}{description}\n"
2450 : "<option>$accno--$form->{IC}{$key}{$accno}{description}\n";
2454 # opendir CSS, "css/.";
2455 # @all = grep /.*\.css$/, readdir CSS;
2458 # css dir has styles that are not intended as general layouts.
2459 # reverting to hardcoded list
2460 @all = qw(lx-office-erp.css Win2000.css);
2462 foreach $item (@all) {
2463 if ($item eq $myconfig{stylesheet}) {
2464 $selectstylesheet .= qq|<option selected>$item\n|;
2466 $selectstylesheet .= qq|<option>$item\n|;
2469 $selectstylesheet .= "<option>\n";
2471 $form->{title} = $locale->text('Edit Preferences for') . qq| $form->{login}|;
2475 if ($myconfig{menustyle} eq "old") {
2476 $menustyle_old = "checked";
2477 } elsif ($myconfig{menustyle} eq "neu") {
2478 $menustyle_neu = "checked";
2479 } elsif ($myconfig{menustyle} eq "v3") {
2480 $menustyle_v3 = "checked";
2483 my ($show_form_details, $hide_form_details);
2484 $myconfig{"show_form_details"} = 1
2485 unless (defined($myconfig{"show_form_details"}));
2486 $show_form_details = "checked" if ($myconfig{"show_form_details"});
2487 $hide_form_details = "checked" unless ($myconfig{"show_form_details"});
2492 <form method=post action=$form->{script}>
2494 <input type=hidden name=old_password value=$myconfig{password}>
2495 <input type=hidden name=type value=preferences>
2496 <input type=hidden name=role value=$myconfig{role}>
2499 <tr><th class=listtop>$form->{title}</th></tr>
2504 <th align=right>| . $locale->text('Name') . qq|</th>
2505 <td><input name=name size=15 value="$myconfig{name}"></td>
2508 <th align=right>| . $locale->text('Password') . qq|</th>
2509 <td><input type=password name=new_password size=10 value=$myconfig{password}></td>
2512 <th align=right>| . $locale->text('E-mail') . qq|</th>
2513 <td><input name=email size=30 value="$myconfig{email}"></td>
2516 <th align=right>| . $locale->text('Signature') . qq|</th>
2517 <td><textarea name=signature rows=3 cols=50>$myconfig{signature}</textarea></td>
2520 <th align=right>| . $locale->text('Phone') . qq|</th>
2521 <td><input name=tel size=14 value="$myconfig{tel}"></td>
2524 <th align=right>| . $locale->text('Fax') . qq|</th>
2525 <td><input name=fax size=14 value="$myconfig{fax}"></td>
2528 <th align=right>| . $locale->text('Company') . qq|</th>
2529 <td><input name=company size=30 value="$myconfig{company}"></td>
2532 <th align=right>| . $locale->text('Address') . qq|</th>
2533 <td><textarea name=address rows=4 cols=50>$myconfig{address}</textarea></td>
2536 <th align=right>| . $locale->text('Date Format') . qq|</th>
2537 <td><select name=dateformat>$dateformat</select></td>
2540 <th align=right>| . $locale->text('Output Number Format') . qq|</th>
2541 <td><select name=numberformat>$numberformat</select></td>
2545 <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
2546 <td><input name=vclimit size=10 value="$myconfig{vclimit}"></td>
2549 <th align=right>| . $locale->text('Language') . qq|</th>
2550 <td><select name=countrycode>$countrycodes</select></td>
2553 <th align=right>| . $locale->text('Stylesheet') . qq|</th>
2554 <td><select name=usestylesheet>$selectstylesheet</select></td>
2557 <th align=right>| . $locale->text('Setup Menu') . qq|</th>
2558 <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
2559 $locale->text("Top (CSS)") . qq|
2560 <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
2561 $locale->text("Top (Javascript)") . qq|
2562 <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
2563 $locale->text("Old (on the side)") . qq|</td>
2566 <th align=right>| . $locale->text('Form details (second row)') . qq|</th>
2567 <td><input type="radio" id="rad_show_form_details" name="show_form_details" value="1" $show_form_details>
2568 <label for="rad_show_form_details">| . $locale->text('Show by default') . qq|</label>
2569 <input type="radio" id="rad_hide_form_details" name="show_form_details" value="0" $hide_form_details>
2570 <label for="rad_hide_form_details">| . $locale->text('Hide by default') . qq|</label></td>
2572 <input name=printer type=hidden value="$myconfig{printer}">
2573 <tr class=listheading>
2574 <th colspan=2>| . $locale->text("Print options") . qq|</th>
2577 <th align=right>| . $locale->text('Default template format') . qq|</th>
2578 <td><select name="template_format">$template_format</select></td>
2581 <th align=right>| . $locale->text('Default output medium') . qq|</th>
2582 <td><select name="default_media">$default_media</select></td>
2585 <th align=right>| . $locale->text('Default printer') . qq|</th>
2586 <td><select name="default_printer_id">$default_printer</select></td>
2589 <th align=right>| . $locale->text('Number of copies') . qq|</th>
2590 <td><input name="copies" size="10" value="| .
2591 $form->quote($myconfig{"copies"}) . qq|"></td>
2595 <tr class=listheading>
2596 <th colspan=2> </th>
2599 <th align=right>| . $locale->text('Business Number') . qq|</th>
2600 <td><input name=businessnumber size=25 value="$myconfig{businessnumber}"></td>
2603 <th align=right>| . $locale->text('Year End') . qq| (mm/dd)</th>
2604 <td><input name=yearend size=5 value=$form->{defaults}{yearend}></td>
2606 <tr class=listheading>
2608 . $locale->text('Last Numbers & Default Accounts') . qq|</th>
2614 <th align=right nowrap>| . $locale->text('Inventory Account') . qq|</th>
2615 <td><select name=inventory_accno>$myconfig{IC}</select></td>
2618 <th align=right nowrap>| . $locale->text('Revenue Account') . qq|</th>
2619 <td><select name=income_accno>$myconfig{IC_income}</select></td>
2622 <th align=right nowrap>| . $locale->text('Expense Account') . qq|</th>
2623 <td><select name=expense_accno>$myconfig{IC_expense}</select></td>
2626 <th align=right nowrap>| . $locale->text('Foreign Exchange Gain') . qq|</th>
2627 <td><select name=fxgain_accno>$myconfig{FX_gain}</select></td>
2630 <th align=right nowrap>| . $locale->text('Foreign Exchange Loss') . qq|</th>
2631 <td><select name=fxloss_accno>$myconfig{FX_loss}</select></td>
2636 'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies'
2638 . qq|<br><input name=curr size=40 value="$form->{defaults}{curr}"></td>
2647 <th align=right nowrap>| . $locale->text('Last Invoice Number') . qq|</th>
2648 <td><input name=invnumber size=10 value=$form->{defaults}{invnumber}></td>
2649 <th align=right nowrap>|
2650 . $locale->text('Last Customer Number') . qq|</th>
2651 <td><input name=customernumber size=10 value=$form->{defaults}{customernumber}></td>
2654 <th align=right nowrap>|
2655 . $locale->text('Last Credit Note Number') . qq|</th>
2656 <td><input name=cnnumber size=10 value=$form->{defaults}{cnnumber}></td>
2657 <th align=right nowrap>|
2658 . $locale->text('Last Vendor Number') . qq|</th>
2659 <td><input name=vendornumber size=10 value=$form->{defaults}{vendornumber}></td>
2662 <th align=right nowrap>|
2663 . $locale->text('Last Sales Order Number') . qq|</th>
2664 <td><input name=sonumber size=10 value=$form->{defaults}{sonumber}></td>
2667 <th align=right nowrap>|
2668 . $locale->text('Last Purchase Order Number') . qq|</th>
2669 <td><input name=ponumber size=10 value=$form->{defaults}{ponumber}></td>
2670 <th align=right nowrap>|
2671 . $locale->text('Last Article Number') . qq|</th>
2672 <td><input name=articlenumber size=10 value=$form->{defaults}{articlenumber}></td>
2675 <th align=right nowrap>|
2676 . $locale->text('Last Sales Quotation Number') . qq|</th>
2677 <td><input name=sqnumber size=10 value=$form->{defaults}{sqnumber}></td>
2678 <th align=right nowrap>|
2679 . $locale->text('Last Service Number') . qq|</th>
2680 <td><input name=servicenumber size=10 value=$form->{defaults}{servicenumber}></td>
2683 <th align=right nowrap>| . $locale->text('Last RFQ Number') . qq|</th>
2684 <td><input name=rfqnumber size=10 value=$form->{defaults}{rfqnumber}></td>
2685 <th align=right nowrap></th>
2691 # <tr class=listheading>
2692 # <th colspan=2>| . $locale->text('Tax Accounts') . qq|</th>
2699 # <th>| . $locale->text('Rate') . qq| (%)</th>
2700 # <th>| . $locale->text('Number') . qq|</th>
2704 # foreach $accno (sort keys %{ $form->{taxrates} }) {
2707 # <th align=right>$form->{taxrates}{$accno}{description}</th>
2708 # <td><input name=$form->{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}></td>
2709 # <td><input name="taxnumber_$form->{taxrates}{$accno}{id}" value="$form->{taxrates}{$accno}{taxnumber}"></td>
2712 # $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} ";
2715 # chop $form->{taxaccounts};
2718 # <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
2727 <td><hr size=3 noshade></td>
2731 <input type=hidden name=login value=$form->{login}>
2732 <input type=hidden name=password value=$form->{password}>
2735 <input type=submit class=submit name=action value="|
2736 . $locale->text('Save') . qq|">
2744 $lxdebug->leave_sub();
2747 sub save_preferences {
2748 $lxdebug->enter_sub();
2750 $form->{stylesheet} = $form->{usestylesheet};
2752 $form->redirect($locale->text('Preferences saved!'))
2754 AM->save_preferences(\%myconfig, \%$form, $memberfile, $userspath, $webdav
2756 $form->error($locale->text('Cannot save preferences!'));
2758 $lxdebug->leave_sub();
2762 $lxdebug->enter_sub();
2764 $form->{title} = $locale->text('Audit Control');
2766 AM->closedto(\%myconfig, \%$form);
2768 if ($form->{revtrans}) {
2769 $checked{Y} = "checked";
2771 $checked{N} = "checked";
2779 <form method=post action=$form->{script}>
2781 <input type=hidden name=login value=$form->{login}>
2782 <input type=hidden name=password value=$form->{password}>
2785 <tr><th class=listtop>$form->{title}</th></tr>
2786 <tr height="5"></tr>
2792 . $locale->text('Enforce transaction reversal for all dates') . qq|</th>
2793 <td><input name=revtrans class=radio type=radio value="1" $checked{Y}> |
2794 . $locale->text('Yes')
2795 . qq| <input name=revtrans class=radio type=radio value="0" $checked{N}> |
2796 . $locale->text('No')
2800 <th>| . $locale->text('Close Books up to') . qq|</th>
2801 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
2811 <input type=hidden name=nextsub value=doclose>
2813 <input type=submit class=submit name=action value="|
2814 . $locale->text('Continue') . qq|">
2822 $lxdebug->leave_sub();
2826 $lxdebug->enter_sub();
2828 AM->closebooks(\%myconfig, \%$form);
2830 if ($form->{revtrans}) {
2832 $locale->text('Transaction reversal enforced for all dates'));
2834 if ($form->{closedto}) {
2836 $locale->text('Transaction reversal enforced up to') . " "
2837 . $locale->date(\%myconfig, $form->{closedto}, 1));
2839 $form->redirect($locale->text('Books are open'));
2843 $lxdebug->leave_sub();
2847 $lxdebug->enter_sub();
2849 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
2850 AM->units_in_use(\%myconfig, $form, $units);
2851 map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
2853 @languages = AM->language(\%myconfig, $form, 1);
2855 @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units}));
2858 foreach (@unit_list) {
2859 $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"});
2860 $_->{"UNITLANGUAGES"} = [];
2861 foreach my $lang (@languages) {
2862 push(@{ $_->{"UNITLANGUAGES"} },
2864 "unit" => $_->{"name"},
2865 "language_id" => $lang->{"id"},
2866 "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
2867 "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
2873 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
2874 $ddbox = AM->unit_select_data($units, undef, 1);
2876 my $updownlink = build_std_url("action=swap_units", "unit_type");
2878 $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
2880 print($form->parse_html_template("am/edit_units",
2881 { "UNITS" => \@unit_list,
2882 "NEW_BASE_UNIT_DDBOX" => $ddbox,
2883 "LANGUAGES" => \@languages,
2884 "updownlink" => $updownlink }));
2886 $lxdebug->leave_sub();
2890 $lxdebug->enter_sub();
2892 $form->isblank("new_name", $locale->text("The name is missing."));
2893 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
2894 $all_units = AM->retrieve_units(\%myconfig, $form);
2895 $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
2897 my ($base_unit, $factor);
2898 if ($form->{"new_base_unit"}) {
2899 $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
2901 $form->isblank("new_factor", $locale->text("The factor is missing."));
2902 $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
2903 $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
2904 $base_unit = $form->{"new_base_unit"};
2908 foreach my $lang (AM->language(\%myconfig, $form, 1)) {
2909 next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
2910 push(@languages, { "id" => $lang->{"id"},
2911 "localized" => $form->{"new_localized_$lang->{id}"},
2912 "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
2916 AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
2918 $form->{"saved_message"} = $locale->text("The unit has been saved.");
2922 $lxdebug->leave_sub();
2925 sub set_unit_languages {
2926 $lxdebug->enter_sub();
2928 my ($unit, $languages, $idx) = @_;
2930 $unit->{"LANGUAGES"} = [];
2932 foreach my $lang (@{$languages}) {
2933 push(@{ $unit->{"LANGUAGES"} },
2934 { "id" => $lang->{"id"},
2935 "localized" => $form->{"localized_${idx}_$lang->{id}"},
2936 "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
2940 $lxdebug->leave_sub();
2944 $lxdebug->enter_sub();
2946 $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
2947 AM->units_in_use(\%myconfig, $form, $old_units);
2949 @languages = AM->language(\%myconfig, $form, 1);
2953 foreach $i (1..($form->{"rowcount"} * 1)) {
2954 $old_unit = $old_units->{$form->{"old_name_$i"}};
2956 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
2959 if ($form->{"unchangeable_$i"}) {
2960 $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
2961 $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
2962 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2966 if ($old_unit->{"in_use"}) {
2967 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
2970 if ($form->{"delete_$i"}) {
2971 push(@delete_units, $old_unit->{"name"});
2975 $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
2977 $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
2978 my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
2979 $new_units->{$form->{"name_$i"}} = \%h;
2980 $new_units->{$form->{"name_$i"}}->{"row"} = $i;
2981 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2984 foreach $unit (values(%{$new_units})) {
2985 next unless ($unit->{"old_name"});
2986 if ($unit->{"base_unit"}) {
2987 $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"}))
2988 unless (defined($new_units->{$unit->{"base_unit"}}));
2989 $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
2990 $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
2992 $unit->{"base_unit"} = undef;
2993 $unit->{"factor"} = undef;
2997 foreach $unit (values(%{$new_units})) {
2998 next if ($unit->{"unchanged_unit"});
3000 map({ $_->{"seen"} = 0; } values(%{$new_units}));
3002 while ($new_unit->{"base_unit"}) {
3003 $new_unit->{"seen"} = 1;
3004 $new_unit = $new_units->{$new_unit->{"base_unit"}};
3005 if ($new_unit->{"seen"}) {
3006 $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, " .
3007 "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
3012 AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
3014 $form->{"saved_message"} = $locale->text("The units have been saved.");
3018 $lxdebug->leave_sub();
3021 sub show_history_search {
3022 $lxdebug->enter_sub();
3024 $form->{title} = $locale->text("History Search");
3027 print $form->parse_html_template("/common/search_history");
3029 $lxdebug->leave_sub();
3032 sub show_am_history {
3033 $lxdebug->enter_sub();
3034 my %search = ( "Artikelnummer" => "parts",
3035 "Kundennummer" => "customer",
3036 "Lieferantennummer" => "vendor",
3037 "Projektnummer" => "project",
3038 "Buchungsnummer" => "oe",
3039 "Eingangsrechnungnummer" => "ap",
3040 "Ausgangsrechnungnummer" => "ar",
3041 "Mahnungsnummer" => "dunning"
3043 my %searchNo = ( "Artikelnummer" => "partnumber",
3044 "Kundennummer" => "customernumber",
3045 "Lieferantennummer" => "vendornumber",
3046 "Projektnummer" => "projectnummer",
3047 "Buchungsnummer" => "ordnumber",
3048 "Eingangsrechnungnummer" => "invnumber",
3049 "Ausgangsrechnungnummer" => "invnumber",
3050 "Mahnungsnummer" => "dunning_id"
3055 foreach(split(/\,/, $form->{einschraenkungen})) {
3057 $restriction .= " AND addition = '" . $_ . "'";
3061 $restriction .= " OR addition = '" . $_ . "'";
3064 $restriction .= (($form->{transdate} ne "" && $form->{reqdate} ne "")
3065 ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|' AND st.itime::date <= '| . $form->{reqdate} . qq|'|
3066 : (($form->{transdate} ne "" && $form->{reqdate} eq "")
3067 ? qq| AND st.itime::date >= '| . $form->{transdate} . qq|'|
3068 : ($form->{transdate} eq "" && $form->{reqdate} ne "")
3069 ? qq| AND st.itime::date <= '| . $form->{reqdate} . qq|'|
3073 $restriction .= ($form->{mitarbeiter} eq "" ? ""
3074 : ($form->{mitarbeiter} =~ /^[0-9]*$/
3075 ? " AND employee_id = " . $form->{mitarbeiter}
3076 : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
3078 my $dbh = $form->dbconnect(\%myconfig);
3079 my $query = qq|SELECT trans_id AS id FROM history_erp | .
3080 ($form->{'searchid'} ?
3081 qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'| :
3082 qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
3084 my $sth = $dbh->prepare($query);
3086 $sth->execute() || $form->dberror($query);
3088 $form->{title} = $locale->text("History Search");
3093 while(my $hash_ref = $sth->fetchrow_hashref()){
3095 $daten .= $hash_ref->{id};
3099 $daten .= " OR trans_id = " . $hash_ref->{id};
3103 my ($sort, $sortby) = split(/\-\-/, $form->{order});
3104 $sort =~ s/.*\.(.*)$/$1/;
3106 print $form->parse_html_template("/common/show_history",
3107 {"DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}),
3108 "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
3111 uc($sort)."BY" => $sortby
3114 $lxdebug->leave_sub();
3117 sub get_employee_id {
3118 $lxdebug->enter_sub();
3119 my $query = qq|SELECT id FROM employee WHERE name = '| . $_[0] . qq|'|;
3120 my $sth = $_[1]->prepare($query);
3121 $sth->execute() || $form->dberror($query);
3122 my $return = $sth->fetch();
3124 return ${$return}[0];
3125 $lxdebug->leave_sub();
3129 $lxdebug->enter_sub();
3131 my $dir = $form->{"dir"} eq "down" ? "down" : "up";
3132 my $unit_type = $form->{"unit_type"} eq "dimension" ?
3133 "dimension" : "service";
3134 AM->swap_units(\%myconfig, $form, $dir, $form->{"name"}, $unit_type);
3138 $lxdebug->leave_sub();
3142 $lxdebug->enter_sub();
3144 $form->{title} = $locale->text('Add');
3147 "$form->{script}?action=add_tax&login=$form->{login}&password=$form->{password}"
3148 unless $form->{callback};
3150 _get_taxaccount_selection();
3154 my $parameters_ref = {
3155 # ChartTypeIsAccount => $ChartTypeIsAccount,
3158 # Ausgabe des Templates
3159 print($form->parse_html_template('am/edit_tax', $parameters_ref));
3161 $lxdebug->leave_sub();
3165 $lxdebug->enter_sub();
3167 $form->{title} = $locale->text('Edit');
3169 AM->get_tax(\%myconfig, \%$form);
3170 _get_taxaccount_selection();
3174 my $parameters_ref = {
3177 # Ausgabe des Templates
3178 print($form->parse_html_template('am/edit_tax', $parameters_ref));
3180 $lxdebug->leave_sub();
3184 $lxdebug->enter_sub();
3186 AM->taxes(\%myconfig, \%$form);
3189 "$form->{script}?action=list_tax&login=$form->{login}&password=$form->{password}";
3191 $form->{title} = $locale->text('Tax-O-Matic');
3195 # Ausgabe des Templates
3196 print($form->parse_html_template('am/list_tax', $parameters_ref));
3198 $lxdebug->leave_sub();
3201 sub _get_taxaccount_selection{
3202 $lxdebug->enter_sub();
3204 AM->get_tax_accounts(\%myconfig, \%$form);
3207 foreach my $taxaccount (@{ $form->{ACCOUNTS} } ) {
3209 # Fill in the Taxaxxounts as select options
3210 if ($form->{chart_id} == $taxaccount->{id}) {
3211 $form->{ACCOUNTS}[$i]{select_taxaccount} .=
3212 qq|<option value="$taxaccount->{id}" selected="selected">
3213 $form->{ACCOUNTS}[$i]{_taxaccount}\n|;
3216 $form->{ACCOUNTS}[$i]{select_taxaccount} .=
3217 qq|<option value="$taxaccount->{id}">
3218 $form->{ACCOUNTS}[$i]{_taxaccount}<!-- hallo-->\n|;
3224 $lxdebug->leave_sub();
3228 $lxdebug->enter_sub();
3230 $form->isblank("chart_id", $locale->text('Tax-O-Matic account missing!'));
3231 $form->isblank("rate", $locale->text('Taxrate missing!'));
3232 $form->isblank("taxdescription", $locale->text('Taxdescription missing!'));
3233 $form->isblank("taxkey", $locale->text('Taxkey missing!'));
3235 if ( $form->{rate} <= 0 || $form->{rate} >= 100 ) {
3236 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
3239 if ( $form->{rate} <= 0.99 && $form->{rate} >= 0 ) {
3240 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
3243 AM->save_tax(\%myconfig, \%$form);
3244 $form->redirect($locale->text('Tax saved!'));
3246 $lxdebug->leave_sub();
3250 $lxdebug->enter_sub();
3252 AM->delete_tax(\%myconfig, \%$form);
3253 $form->redirect($locale->text('Tax deleted!'));
3255 $lxdebug->leave_sub();