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} }) {
419 if ($ca->{amount} > 0) {
420 $ca->{credit} = $form->format_amount(\%myconfig, $ca->{amount}, 2);
422 if ($ca->{amount} < 0) {
423 $ca->{debit} = $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2);
425 $ca->{heading} = ( $ca->{charttype} eq 'H' ) ? 1:'';
426 $ca->{link_edit_account} =
427 qq|$form->{script}?action=edit_account&id=$ca->{id}|
428 .qq|&login=$form->{login}|
429 .qq|&password=$form->{password}&callback=$callback|;
433 my $list_account_details_url =
434 "$form->{script}?login=$form->{login}"
435 ."&password=$form->{password}&action=list_account_details&";
438 my $pjx = new CGI::Ajax('list_account_details' => $list_account_details_url);
440 # Eneable AJAX debuging
444 push(@ { $form->{AJAX} }, $pjx);
446 $form->{stylesheets} = "list_accounts.css";
451 my $parameters_ref = {
452 # hidden_variables => $_hidden_variables_ref,
455 # Ausgabe des Templates
456 print($form->parse_html_template2('am/list_accounts', $parameters_ref));
458 $lxdebug->leave_sub();
463 sub list_account_details {
464 # Ajax Funktion aus list_account_details
465 $lxdebug->enter_sub();
467 my $chart_id = $form->{args};
469 CA->all_accounts(\%myconfig, \%$form, $chart_id);
471 $form->{title} = $locale->text('Chart of Accounts');
475 "$form->{script}?action=list_account&login=$form->{login}&password=$form->{password}";
480 $callback = $form->escape($callback);
482 foreach $ca (@{ $form->{CA} }) {
484 $ca->{debit} = " ";
485 $ca->{credit} = " ";
487 if ($ca->{amount} > 0) {
489 $form->format_amount(\%myconfig, $ca->{amount}, 2, " ");
491 if ($ca->{amount} < 0) {
493 $form->format_amount(\%myconfig, -1 * $ca->{amount}, 2, " ");
496 my @links = split( q{:}, $ca->{link});
500 foreach my $link (@links){
501 $link = ( $link eq 'AR') ? $locale->text('Account Link AR')
502 : ( $link eq 'AP') ? $locale->text('Account Link AP')
503 : ( $link eq 'IC') ? $locale->text('Account Link IC')
504 : ( $link eq 'AR_amount' ) ? $locale->text('Account Link AR_amount')
505 : ( $link eq 'AR_paid' ) ? $locale->text('Account Link AR_paid')
506 : ( $link eq 'AR_tax' ) ? $locale->text('Account Link AR_tax')
507 : ( $link eq 'AP_amount' ) ? $locale->text('Account Link AP_amount')
508 : ( $link eq 'AP_paid' ) ? $locale->text('Account Link AP_paid')
509 : ( $link eq 'AP_tax' ) ? $locale->text('Account Link AP_tax')
510 : ( $link eq 'IC_sale' ) ? $locale->text('Account Link IC_sale')
511 : ( $link eq 'IC_cogs' ) ? $locale->text('Account Link IC_cogs')
512 : ( $link eq 'IC_taxpart' ) ? $locale->text('Account Link IC_taxpart')
513 : ( $link eq 'IC_income' ) ? $locale->text('Account Link IC_income')
514 : ( $link eq 'IC_expense' ) ? $locale->text('Account Link IC_expense')
515 : ( $link eq 'IC_taxservice' ) ? $locale->text('Account Link IC_taxservice')
516 # : ( $link eq 'CT_tax' ) ? $locale->text('Account Link CT_tax')
517 : $locale->text('Unknown Link') . ': ' . $link;
519 $ca->{link} .= ($link ne '') ? "[$link] ":'';
522 $ca->{startdate} =~ s/,/<br>/og;
523 $ca->{tk_ustva} =~ s/,/<br>/og;
524 $ca->{taxkey} =~ s/,/<br>/og;
525 $ca->{taxaccount} =~ s/,/<br>/og;
526 $ca->{taxdescription} =~ s/,/<br>/og;
527 $ca->{datevautomatik} = ($ca->{datevautomatik}) ? $locale->text('On'):$locale->text('Off');
529 $ca->{category} = ($ca->{category} eq 'A') ? $locale->text('Account Category A')
530 : ($ca->{category} eq 'E') ? $locale->text('Account Category E')
531 : ($ca->{category} eq 'L') ? $locale->text('Account Category L')
532 : ($ca->{category} eq 'I') ? $locale->text('Account Category I')
533 : ($ca->{category} eq 'Q') ? $locale->text('Account Category Q')
534 : ($ca->{category} eq 'C') ? $locale->text('Account Category C')
535 : ($ca->{category} eq 'G') ? $locale->text('Account Category G')
536 : $locale->text('Unknown Category') . ': ' . $ca->{category};
538 $ca->{link_edit_account} =
539 qq|$form->{script}?action=edit_account&id=$ca->{id}|
540 .qq|&login=$form->{login}|
541 .qq|&password=$form->{password}&callback=$callback|;
547 my $parameters_ref = {
550 # hidden_variables => $_hidden_variables_ref,
553 # Ausgabe des Templates
555 my $result = $form->parse_html_template('am/list_account_details', $parameters_ref);
558 # print "chart_id:$chart_id, form->chartid:$form->{chart_id}, rest=$rest";
560 $lxdebug->leave_sub();
565 $lxdebug->enter_sub();
567 $form->{title} = $locale->text('Delete Account');
570 qw(inventory_accno_id income_accno_id expense_accno_id fxgain_accno_id fxloss_accno_id)
572 if ($form->{id} == $form->{$id}) {
573 $form->error($locale->text('Cannot delete default account!'));
577 $form->redirect($locale->text('Account deleted!'))
578 if (AM->delete_account(\%myconfig, \%$form));
579 $form->error($locale->text('Cannot delete account!'));
581 $lxdebug->leave_sub();
585 $lxdebug->enter_sub();
587 $form->{title} = "Add";
591 "$form->{script}?action=add_department&login=$form->{login}&password=$form->{password}"
592 unless $form->{callback};
597 $lxdebug->leave_sub();
600 sub edit_department {
601 $lxdebug->enter_sub();
603 $form->{title} = "Edit";
605 AM->get_department(\%myconfig, \%$form);
610 $lxdebug->leave_sub();
613 sub list_department {
614 $lxdebug->enter_sub();
616 AM->departments(\%myconfig, \%$form);
619 "$form->{script}?action=list_department&login=$form->{login}&password=$form->{password}";
621 $callback = $form->escape($form->{callback});
623 $form->{title} = $locale->text('Departments');
625 @column_index = qw(description cost profit);
627 $column_header{description} =
628 qq|<th class=listheading width=90%>|
629 . $locale->text('Description')
631 $column_header{cost} =
632 qq|<th class=listheading nowrap>|
633 . $locale->text('Cost Center')
635 $column_header{profit} =
636 qq|<th class=listheading nowrap>|
637 . $locale->text('Profit Center')
647 <th class=listtop>$form->{title}</th>
653 <tr class=listheading>
656 map { print "$column_header{$_}\n" } @column_index;
662 foreach $ref (@{ $form->{ALL} }) {
668 <tr valign=top class=listrow$i>
671 $costcenter = ($ref->{role} eq "C") ? "X" : "";
672 $profitcenter = ($ref->{role} eq "P") ? "X" : "";
674 $column_data{description} =
675 qq|<td><a href=$form->{script}?action=edit_department&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
676 $column_data{cost} = qq|<td align=center>$costcenter</td>|;
677 $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
679 map { print "$column_data{$_}\n" } @column_index;
691 <td><hr size=3 noshade></td>
696 <form method=post action=$form->{script}>
698 <input name=callback type=hidden value="$form->{callback}">
700 <input type=hidden name=type value=department>
702 <input type=hidden name=login value=$form->{login}>
703 <input type=hidden name=password value=$form->{password}>
705 <input class=submit type=submit name=action value="|
706 . $locale->text('Add') . qq|">
714 $lxdebug->leave_sub();
717 sub department_header {
718 $lxdebug->enter_sub();
720 $form->{title} = $locale->text("$form->{title} Department");
722 # $locale->text('Add Department')
723 # $locale->text('Edit Department')
725 $form->{description} =~ s/\"/"/g;
727 if (($rows = $form->numtextrows($form->{description}, 60)) > 1) {
729 qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
732 qq|<input name=description size=60 value="$form->{description}">|;
735 $costcenter = "checked" if $form->{role} eq "C";
736 $profitcenter = "checked" if $form->{role} eq "P";
743 <form method=post action=$form->{script}>
745 <input type=hidden name=id value=$form->{id}>
746 <input type=hidden name=type value=department>
750 <th class=listtop colspan=2>$form->{title}</th>
754 <th align=right>| . $locale->text('Description') . qq|</th>
755 <td>$description</td>
759 <td><input type=radio style=radio name=role value="C" $costcenter> |
760 . $locale->text('Cost Center') . qq|
761 <input type=radio style=radio name=role value="P" $profitcenter> |
762 . $locale->text('Profit Center') . qq|
765 <td colspan=2><hr size=3 noshade></td>
770 $lxdebug->leave_sub();
773 sub save_department {
774 $lxdebug->enter_sub();
776 $form->isblank("description", $locale->text('Description missing!'));
777 AM->save_department(\%myconfig, \%$form);
778 $form->redirect($locale->text('Department saved!'));
780 $lxdebug->leave_sub();
783 sub delete_department {
784 $lxdebug->enter_sub();
786 AM->delete_department(\%myconfig, \%$form);
787 $form->redirect($locale->text('Department deleted!'));
789 $lxdebug->leave_sub();
793 $lxdebug->enter_sub();
795 $form->{title} = "Add";
798 "$form->{script}?action=add_lead&login=$form->{login}&password=$form->{password}"
799 unless $form->{callback};
804 $lxdebug->leave_sub();
808 $lxdebug->enter_sub();
810 $form->{title} = "Edit";
812 AM->get_lead(\%myconfig, \%$form);
816 $form->{orphaned} = 1;
819 $lxdebug->leave_sub();
823 $lxdebug->enter_sub();
825 AM->lead(\%myconfig, \%$form);
828 "$form->{script}?action=list_lead&login=$form->{login}&password=$form->{password}";
830 $callback = $form->escape($form->{callback});
832 $form->{title} = $locale->text('Lead');
834 @column_index = qw(description cost profit);
836 $column_header{description} =
837 qq|<th class=listheading width=100%>|
838 . $locale->text('Description')
848 <th class=listtop>$form->{title}</th>
851 <tr class=listheading>
854 map { print "$column_header{$_}\n" } @column_index;
860 foreach $ref (@{ $form->{ALL} }) {
866 <tr valign=top class=listrow$i>
869 $lead = $ref->{lead};
871 $column_data{description} =
872 qq|<td><a href=$form->{script}?action=edit_lead&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{lead}</td>|;
874 map { print "$column_data{$_}\n" } @column_index;
883 <td><hr size=3 noshade></td>
888 <form method=post action=$form->{script}>
890 <input name=callback type=hidden value="$form->{callback}">
892 <input type=hidden name=type value=lead>
894 <input type=hidden name=login value=$form->{login}>
895 <input type=hidden name=password value=$form->{password}>
897 <input class=submit type=submit name=action value="|
898 . $locale->text('Add') . qq|">
906 $lxdebug->leave_sub();
910 $lxdebug->enter_sub();
912 $form->{title} = $locale->text("$form->{title} Lead");
914 # $locale->text('Add Lead')
915 # $locale->text('Edit Lead')
917 $form->{description} =~ s/\"/"/g;
920 qq|<input name=description size=50 value="$form->{lead}">|;
927 <form method=post action=$form->{script}>
929 <input type=hidden name=id value=$form->{id}>
930 <input type=hidden name=type value=lead>
934 <th class=listtop colspan=2>$form->{title}</th>
938 <th align=right>| . $locale->text('Description') . qq|</th>
939 <td>$description</td>
941 <td colspan=2><hr size=3 noshade></td>
946 $lxdebug->leave_sub();
950 $lxdebug->enter_sub();
952 $form->isblank("description", $locale->text('Description missing!'));
953 AM->save_lead(\%myconfig, \%$form);
954 $form->redirect($locale->text('lead saved!'));
956 $lxdebug->leave_sub();
960 $lxdebug->enter_sub();
962 AM->delete_lead(\%myconfig, \%$form);
963 $form->redirect($locale->text('lead deleted!'));
965 $lxdebug->leave_sub();
969 $lxdebug->enter_sub();
971 $form->{title} = "Add";
974 "$form->{script}?action=add_business&login=$form->{login}&password=$form->{password}"
975 unless $form->{callback};
980 $lxdebug->leave_sub();
984 $lxdebug->enter_sub();
986 $form->{title} = "Edit";
988 AM->get_business(\%myconfig, \%$form);
992 $form->{orphaned} = 1;
995 $lxdebug->leave_sub();
999 $lxdebug->enter_sub();
1001 AM->business(\%myconfig, \%$form);
1004 "$form->{script}?action=list_business&login=$form->{login}&password=$form->{password}";
1006 $callback = $form->escape($form->{callback});
1008 $form->{title} = $locale->text('Type of Business');
1010 @column_index = qw(description discount customernumberinit);
1012 $column_header{description} =
1013 qq|<th class=listheading width=60%>|
1014 . $locale->text('Description')
1016 $column_header{discount} =
1017 qq|<th class=listheading width=10%>|
1018 . $locale->text('Discount')
1020 $column_header{customernumberinit} =
1021 qq|<th class=listheading>|
1022 . $locale->text('Customernumberinit')
1032 <th class=listtop>$form->{title}</th>
1034 <tr height="5"></tr>
1038 <tr class=listheading>
1041 map { print "$column_header{$_}\n" } @column_index;
1047 foreach $ref (@{ $form->{ALL} }) {
1053 <tr valign=top class=listrow$i>
1057 $form->format_amount(\%myconfig, $ref->{discount} * 100);
1059 $ref->{description};
1060 $column_data{description} =
1061 qq|<td><a href=$form->{script}?action=edit_business&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$description</td>|;
1062 $column_data{discount} = qq|<td align=right>$discount</td>|;
1063 $column_data{customernumberinit} =
1064 qq|<td align=right>$ref->{customernumberinit}</td>|;
1066 map { print "$column_data{$_}\n" } @column_index;
1078 <td><hr size=3 noshade></td>
1083 <form method=post action=$form->{script}>
1085 <input name=callback type=hidden value="$form->{callback}">
1087 <input type=hidden name=type value=business>
1089 <input type=hidden name=login value=$form->{login}>
1090 <input type=hidden name=password value=$form->{password}>
1092 <input class=submit type=submit name=action value="|
1093 . $locale->text('Add') . qq|">
1101 $lxdebug->leave_sub();
1104 sub business_header {
1105 $lxdebug->enter_sub();
1107 $form->{title} = $locale->text("$form->{title} Business");
1109 # $locale->text('Add Business')
1110 # $locale->text('Edit Business')
1112 $form->{description} =~ s/\"/"/g;
1114 $form->format_amount(\%myconfig, $form->{discount} * 100);
1121 <form method=post action=$form->{script}>
1123 <input type=hidden name=id value=$form->{id}>
1124 <input type=hidden name=type value=business>
1128 <th class=listtop colspan=2>$form->{title}</th>
1130 <tr height="5"></tr>
1132 <th align=right>| . $locale->text('Type of Business') . qq|</th>
1133 <td><input name=description size=30 value="$form->{description}"></td>
1136 <th align=right>| . $locale->text('Discount') . qq| %</th>
1137 <td><input name=discount size=5 value=$form->{discount}></td>
1140 <th align=right>| . $locale->text('Customernumberinit') . qq|</th>
1141 <td><input name=customernumberinit size=10 value=$form->{customernumberinit}></td>
1143 <td colspan=2><hr size=3 noshade></td>
1148 $lxdebug->leave_sub();
1152 $lxdebug->enter_sub();
1154 $form->isblank("description", $locale->text('Description missing!'));
1155 $form->{discount} = $form->parse_amount(\%myconfig, $form->{discount}) / 100;
1156 AM->save_business(\%myconfig, \%$form);
1157 $form->redirect($locale->text('Business saved!'));
1159 $lxdebug->leave_sub();
1162 sub delete_business {
1163 $lxdebug->enter_sub();
1165 AM->delete_business(\%myconfig, \%$form);
1166 $form->redirect($locale->text('Business deleted!'));
1168 $lxdebug->leave_sub();
1172 $lxdebug->enter_sub();
1174 $form->{title} = "Add";
1177 "$form->{script}?action=add_language&login=$form->{login}&password=$form->{password}"
1178 unless $form->{callback};
1183 $lxdebug->leave_sub();
1187 $lxdebug->enter_sub();
1189 $form->{title} = "Edit";
1191 AM->get_language(\%myconfig, \%$form);
1195 $form->{orphaned} = 1;
1198 $lxdebug->leave_sub();
1202 $lxdebug->enter_sub();
1204 AM->language(\%myconfig, \%$form);
1207 "$form->{script}?action=list_language&login=$form->{login}&password=$form->{password}";
1209 $callback = $form->escape($form->{callback});
1211 $form->{title} = $locale->text('Languages');
1213 @column_index = qw(description template_code article_code output_numberformat output_dateformat output_longdates);
1215 $column_header{description} =
1216 qq|<th class=listheading width=60%>|
1217 . $locale->text('Description')
1219 $column_header{template_code} =
1220 qq|<th class=listheading width=10%>|
1221 . $locale->text('Template Code')
1223 $column_header{article_code} =
1224 qq|<th class=listheading>|
1225 . $locale->text('Article Code')
1227 $column_header{output_numberformat} =
1228 qq|<th class=listheading>|
1229 . $locale->text('Number Format')
1231 $column_header{output_dateformat} =
1232 qq|<th class=listheading>|
1233 . $locale->text('Date Format')
1235 $column_header{output_longdates} =
1236 qq|<th class=listheading>|
1237 . $locale->text('Long Dates')
1247 <th class=listtop>$form->{title}</th>
1249 <tr height="5"></tr>
1253 <tr class=listheading>
1256 map { print "$column_header{$_}\n" } @column_index;
1262 foreach $ref (@{ $form->{ALL} }) {
1268 <tr valign=top class=listrow$i>
1272 $column_data{description} =
1273 qq|<td><a href=$form->{script}?action=edit_language&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
1274 $column_data{template_code} = qq|<td align=right>$ref->{template_code}</td>|;
1275 $column_data{article_code} =
1276 qq|<td align=right>$ref->{article_code}</td>|;
1277 $column_data{output_numberformat} =
1279 ($ref->{output_numberformat} ? $ref->{output_numberformat} :
1280 $locale->text("use program settings")) .
1282 $column_data{output_dateformat} =
1284 ($ref->{output_dateformat} ? $ref->{output_dateformat} :
1285 $locale->text("use program settings")) .
1287 $column_data{output_longdates} =
1289 ($ref->{output_longdates} ? $locale->text("Yes") : $locale->text("No")) .
1292 map { print "$column_data{$_}\n" } @column_index;
1304 <td><hr size=3 noshade></td>
1309 <form method=post action=$form->{script}>
1311 <input name=callback type=hidden value="$form->{callback}">
1313 <input type=hidden name=type value=language>
1315 <input type=hidden name=login value=$form->{login}>
1316 <input type=hidden name=password value=$form->{password}>
1318 <input class=submit type=submit name=action value="|
1319 . $locale->text('Add') . qq|">
1327 $lxdebug->leave_sub();
1330 sub language_header {
1331 $lxdebug->enter_sub();
1333 $form->{title} = $locale->text("$form->{title} Language");
1335 # $locale->text('Add Language')
1336 # $locale->text('Edit Language')
1338 $form->{description} =~ s/\"/"/g;
1339 $form->{template_code} =~ s/\"/"/g;
1340 $form->{article_code} =~ s/\"/"/g;
1346 qq|<option value="">| . $locale->text("use program settings") .
1348 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
1350 ($item eq $form->{output_numberformat})
1351 ? "<option selected>$item"
1357 qq|<option value="">| . $locale->text("use program settings") .
1359 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
1361 ($item eq $form->{output_dateformat})
1362 ? "<option selected>$item"
1370 <form method=post action=$form->{script}>
1372 <input type=hidden name=id value=$form->{id}>
1373 <input type=hidden name=type value=language>
1377 <th class=listtop colspan=2>$form->{title}</th>
1379 <tr height="5"></tr>
1381 <th align=right>| . $locale->text('Language') . qq|</th>
1382 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1385 <th align=right>| . $locale->text('Template Code') . qq|</th>
1386 <td><input name=template_code size=5 value="| . $form->quote($form->{template_code}) . qq|"></td>
1389 <th align=right>| . $locale->text('Article Code') . qq|</th>
1390 <td><input name=article_code size=10 value="| . $form->quote($form->{article_code}) . qq|"></td>
1393 <th align=right>| . $locale->text('Number Format') . qq|</th>
1394 <td><select name="output_numberformat">$numberformat</select></td>
1397 <th align=right>| . $locale->text('Date Format') . qq|</th>
1398 <td><select name="output_dateformat">$dateformat</select></td>
1401 <th align=right>| . $locale->text('Long Dates') . qq|</th>
1402 <td><input type="radio" name="output_longdates" value="1"| .
1403 ($form->{output_longdates} ? " checked" : "") .
1404 qq|>| . $locale->text("Yes") .
1405 qq|<input type="radio" name="output_longdates" value="0"| .
1406 ($form->{output_longdates} ? "" : " checked") .
1407 qq|>| . $locale->text("No") .
1410 <td colspan=2><hr size=3 noshade></td>
1415 $lxdebug->leave_sub();
1419 $lxdebug->enter_sub();
1421 $form->isblank("description", $locale->text('Language missing!'));
1422 $form->isblank("template_code", $locale->text('Template Code missing!'));
1423 $form->isblank("article_code", $locale->text('Article Code missing!'));
1424 AM->save_language(\%myconfig, \%$form);
1425 $form->redirect($locale->text('Language saved!'));
1427 $lxdebug->leave_sub();
1430 sub delete_language {
1431 $lxdebug->enter_sub();
1433 AM->delete_language(\%myconfig, \%$form);
1434 $form->redirect($locale->text('Language deleted!'));
1436 $lxdebug->leave_sub();
1440 sub add_buchungsgruppe {
1441 $lxdebug->enter_sub();
1443 # $locale->text("Add Buchungsgruppe")
1444 # $locale->text("Edit Buchungsgruppe")
1445 $form->{title} = "Add";
1448 "$form->{script}?action=add_buchungsgruppe&login=$form->{login}&password=$form->{password}"
1449 unless $form->{callback};
1450 AM->get_buchungsgruppe(\%myconfig, \%$form);
1451 $form->{"inventory_accno_id"} = $form->{"std_inventory_accno_id"};
1452 for (my $i = 0; 4 > $i; $i++) {
1453 map({ $form->{"${_}_accno_id_$i"} = $form->{"std_${_}_accno_id"}; }
1454 qw(income expense));
1457 &buchungsgruppe_header;
1460 $lxdebug->leave_sub();
1463 sub edit_buchungsgruppe {
1464 $lxdebug->enter_sub();
1466 $form->{title} = "Edit";
1468 AM->get_buchungsgruppe(\%myconfig, \%$form);
1470 &buchungsgruppe_header;
1474 $lxdebug->leave_sub();
1477 sub list_buchungsgruppe {
1478 $lxdebug->enter_sub();
1480 AM->buchungsgruppe(\%myconfig, \%$form);
1483 "$form->{script}?action=list_buchungsgruppe&login=$form->{login}&password=$form->{password}";
1485 $callback = $form->escape($form->{callback});
1487 $form->{title} = $locale->text('Buchungsgruppen');
1489 @column_index = qw(up down description inventory_accno
1490 income_accno_0 expense_accno_0
1491 income_accno_1 expense_accno_1
1492 income_accno_2 expense_accno_2
1493 income_accno_3 expense_accno_3 );
1495 $column_header{up} =
1496 qq|<th class="listheading" width="16">|
1497 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
1499 $column_header{down} =
1500 qq|<th class="listheading" width="16">|
1501 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
1503 $column_header{description} =
1504 qq|<th class="listheading" width="40%">|
1505 . $locale->text('Description')
1507 $column_header{inventory_accno} =
1508 qq|<th class=listheading>|
1509 . $locale->text('Bestandskonto')
1511 $column_header{income_accno_0} =
1512 qq|<th class=listheading>|
1513 . $locale->text('National Revenues')
1515 $column_header{expense_accno_0} =
1516 qq|<th class=listheading>|
1517 . $locale->text('National Expenses')
1519 $column_header{income_accno_1} =
1520 qq|<th class=listheading>|
1521 . $locale->text('Revenues EU with UStId')
1523 $column_header{expense_accno_1} =
1524 qq|<th class=listheading>|
1525 . $locale->text('Expenses EU with UStId')
1527 $column_header{income_accno_2} =
1528 qq|<th class=listheading>|
1529 . $locale->text('Revenues EU without UStId')
1531 $column_header{expense_accno_2} =
1532 qq|<th class=listheading>|
1533 . $locale->text('Expenses EU without UStId')
1535 $column_header{income_accno_3} =
1536 qq|<th class=listheading>|
1537 . $locale->text('Foreign Revenues')
1539 $column_header{expense_accno_3} =
1540 qq|<th class=listheading>|
1541 . $locale->text('Foreign Expenses')
1550 <th class=listtop>$form->{title}</th>
1552 <tr height="5"></tr>
1556 <tr class=listheading>
1559 map { print "$column_header{$_}\n" } @column_index;
1565 my $swap_link = qq|$form->{script}?action=swap_buchungsgruppen&|;
1566 map({ $swap_link .= $_ . "=" . $form->escape($form->{$_}) . "&" }
1567 qw(login password));
1570 foreach $ref (@{ $form->{ALL} }) {
1576 <tr valign=top class=listrow$i>
1580 my $pref = $form->{ALL}->[$row - 1];
1582 qq|<td align="center" valign="center" width="16">| .
1583 qq|<a href="${swap_link}id1=$ref->{id}&id2=$pref->{id}">| .
1584 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
1587 $column_data{up} = qq|<td width="16"> </td>|;
1590 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
1591 $column_data{down} = qq|<td width="16"> </td>|;
1593 my $nref = $form->{ALL}->[$row + 1];
1594 $column_data{down} =
1595 qq|<td align="center" valign="center" width="16">| .
1596 qq|<a href="${swap_link}id1=$ref->{id}&id2=$nref->{id}">| .
1597 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
1601 $column_data{description} =
1602 qq|<td><a href=$form->{script}?action=edit_buchungsgruppe&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description}</td>|;
1603 $column_data{inventory_accno} = qq|<td align=right>$ref->{inventory_accno}</td>|;
1604 $column_data{income_accno_0} =
1605 qq|<td align=right>$ref->{income_accno_0}</td>|;
1606 $column_data{expense_accno_0} = qq|<td align=right>$ref->{expense_accno_0}</td>|;
1607 $column_data{income_accno_1} =
1608 qq|<td align=right>$ref->{income_accno_1}</td>|;
1609 $column_data{expense_accno_1} = qq|<td align=right>$ref->{expense_accno_1}</td>|;
1610 $column_data{income_accno_2} =
1611 qq|<td align=right>$ref->{income_accno_2}</td>|;
1612 $column_data{expense_accno_2} = qq|<td align=right>$ref->{expense_accno_2}</td>|;
1613 $column_data{income_accno_3} =
1614 qq|<td align=right>$ref->{income_accno_3}</td>|;
1615 $column_data{expense_accno_3} = qq|<td align=right>$ref->{expense_accno_3}</td>|;
1617 map { print "$column_data{$_}\n" } @column_index;
1631 <td><hr size=3 noshade></td>
1636 <form method=post action=$form->{script}>
1638 <input name=callback type=hidden value="$form->{callback}">
1640 <input type=hidden name=type value=buchungsgruppe>
1642 <input type=hidden name=login value=$form->{login}>
1643 <input type=hidden name=password value=$form->{password}>
1645 <input class=submit type=submit name=action value="|
1646 . $locale->text('Add') . qq|">
1654 $lxdebug->leave_sub();
1657 sub buchungsgruppe_header {
1658 $lxdebug->enter_sub();
1660 $form->{title} = $locale->text("$form->{title} Buchungsgruppe");
1662 # $locale->text('Add Accounting Group')
1663 # $locale->text('Edit Accounting Group')
1665 my ($acc_inventory, $acc_income, $acc_expense) = ({}, {}, {});
1666 my %acc_type_map = (
1667 "IC" => $acc_inventory,
1668 "IC_income" => $acc_income,
1669 "IC_sale" => $acc_income,
1670 "IC_expense" => $acc_expense,
1671 "IC_cogs" => $acc_expense,
1674 foreach $key (keys(%acc_type_map)) {
1675 foreach $ref (@{ $form->{IC_links}{$key} }) {
1676 $acc_type_map{$key}->{$ref->{"id"}} = $ref;
1680 foreach my $type (qw(IC IC_income IC_expense)) {
1681 $form->{"select$type"} =
1683 map({ "<option value=$_->{id} $_->{selected}>" .
1684 "$_->{accno}--" . H($_->{description}) . "</option>" }
1685 sort({ $a->{"accno"} cmp $b->{"accno"} }
1686 values(%{$acc_type_map{$type}}))));
1690 $form->{selectIC} =~ s/selected//g;
1691 $form->{selectIC} =~ s/ value=$form->{inventory_accno_id}/ value=$form->{inventory_accno_id} selected/;
1692 $form->{selectIC_income} =~ s/selected//g;
1693 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_0}/ value=$form->{income_accno_id_0} selected/;
1694 $form->{selectIC_expense} =~ s/selected//g;
1695 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_0}/ value=$form->{expense_accno_id_0} selected/;
1701 <th align=right>| . $locale->text('Inventory') . qq|</th>
1702 <td><select name=inventory_accno_id>$form->{selectIC}</select></td>
1703 <input name=selectIC type=hidden value="$form->{selectIC}">
1707 <input type=hidden name=inventory_accno_id value=$form->{inventory_accno_id}>|;
1711 $linkaccounts .= qq|
1713 <th align=right>| . $locale->text('National Revenues') . qq|</th>
1714 <td><select name=income_accno_id_0>$form->{selectIC_income}</select></td>
1717 <th align=right>| . $locale->text('National Expenses') . qq|</th>
1718 <td><select name=expense_accno_id_0>$form->{selectIC_expense}</select></td>
1721 $form->{selectIC_income} =~ s/selected//g;
1722 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_1}/ value=$form->{income_accno_id_1} selected/;
1723 $form->{selectIC_expense} =~ s/selected//g;
1724 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_1}/ value=$form->{expense_accno_id_1} selected/;
1726 $linkaccounts .= qq| <tr>
1727 <th align=right>| . $locale->text('Revenues EU with UStId') . qq|</th>
1728 <td><select name=income_accno_id_1>$form->{selectIC_income}</select></td>
1731 <th align=right>| . $locale->text('Expenses EU with UStId') . qq|</th>
1732 <td><select name=expense_accno_id_1>$form->{selectIC_expense}</select></td>
1736 $form->{selectIC_income} =~ s/selected//g;
1737 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_2}/ value=$form->{income_accno_id_2} selected/;
1738 $form->{selectIC_expense} =~ s/selected//g;
1739 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_2}/ value=$form->{expense_accno_id_2} selected/;
1742 $linkaccounts .= qq| <tr>
1743 <th align=right>| . $locale->text('Revenues EU without UStId') . qq|</th>
1744 <td><select name=income_accno_id_2>$form->{selectIC_income}</select></td>
1747 <th align=right>| . $locale->text('Expenses EU without UStId') . qq|</th>
1748 <td><select name=expense_accno_id_2>$form->{selectIC_expense}</select></td>
1752 $form->{selectIC_income} =~ s/selected//g;
1753 $form->{selectIC_income} =~ s/ value=$form->{income_accno_id_3}/ value=$form->{income_accno_id_3} selected/;
1754 $form->{selectIC_expense} =~ s/selected//g;
1755 $form->{selectIC_expense} =~ s/ value=$form->{expense_accno_id_3}/ value=$form->{expense_accno_id_3} selected/;
1758 $linkaccounts .= qq| <tr>
1759 <th align=right>| . $locale->text('Foreign Revenues') . qq|</th>
1760 <td><select name=income_accno_id_3>$form->{selectIC_income}</select></td>
1763 <th align=right>| . $locale->text('Foreign Expenses') . qq|</th>
1764 <td><select name=expense_accno_id_3>$form->{selectIC_expense}</select></td>
1774 <form method=post action=$form->{script}>
1776 <input type=hidden name=id value=$form->{id}>
1777 <input type=hidden name=type value=buchungsgruppe>
1781 <th class=listtop colspan=2>$form->{title}</th>
1783 <tr height="5"></tr>
1785 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
1786 <td><input name=description size=30 value="| . $form->quote($form->{description}) . qq|"></td>
1789 <td colspan=2><hr size=3 noshade></td>
1794 $lxdebug->leave_sub();
1797 sub save_buchungsgruppe {
1798 $lxdebug->enter_sub();
1800 $form->isblank("description", $locale->text('Description missing!'));
1802 AM->save_buchungsgruppe(\%myconfig, \%$form);
1803 $form->redirect($locale->text('Accounting Group saved!'));
1805 $lxdebug->leave_sub();
1808 sub delete_buchungsgruppe {
1809 $lxdebug->enter_sub();
1811 AM->delete_buchungsgruppe(\%myconfig, \%$form);
1812 $form->redirect($locale->text('Accounting Group deleted!'));
1814 $lxdebug->leave_sub();
1817 sub swap_buchungsgruppen {
1818 $lxdebug->enter_sub();
1820 AM->swap_sortkeys(\%myconfig, $form, "buchungsgruppen");
1821 list_buchungsgruppe();
1823 $lxdebug->leave_sub();
1828 $lxdebug->enter_sub();
1830 $form->{title} = "Add";
1833 "$form->{script}?action=add_printer&login=$form->{login}&password=$form->{password}"
1834 unless $form->{callback};
1839 $lxdebug->leave_sub();
1843 $lxdebug->enter_sub();
1845 $form->{title} = "Edit";
1847 AM->get_printer(\%myconfig, \%$form);
1851 $form->{orphaned} = 1;
1854 $lxdebug->leave_sub();
1858 $lxdebug->enter_sub();
1860 AM->printer(\%myconfig, \%$form);
1863 "$form->{script}?action=list_printer&login=$form->{login}&password=$form->{password}";
1865 $callback = $form->escape($form->{callback});
1867 $form->{title} = $locale->text('Printer');
1869 @column_index = qw(printer_description printer_command template_code);
1871 $column_header{printer_description} =
1872 qq|<th class=listheading width=60%>|
1873 . $locale->text('Printer Description')
1875 $column_header{printer_command} =
1876 qq|<th class=listheading width=10%>|
1877 . $locale->text('Printer Command')
1879 $column_header{template_code} =
1880 qq|<th class=listheading>|
1881 . $locale->text('Template Code')
1891 <th class=listtop>$form->{title}</th>
1893 <tr height="5"></tr>
1897 <tr class=listheading>
1900 map { print "$column_header{$_}\n" } @column_index;
1906 foreach $ref (@{ $form->{ALL} }) {
1912 <tr valign=top class=listrow$i>
1916 $column_data{printer_description} =
1917 qq|<td><a href=$form->{script}?action=edit_printer&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{printer_description}</td>|;
1918 $column_data{printer_command} = qq|<td align=right>$ref->{printer_command}</td>|;
1919 $column_data{template_code} =
1920 qq|<td align=right>$ref->{template_code}</td>|;
1922 map { print "$column_data{$_}\n" } @column_index;
1934 <td><hr size=3 noshade></td>
1939 <form method=post action=$form->{script}>
1941 <input name=callback type=hidden value="$form->{callback}">
1943 <input type=hidden name=type value=printer>
1945 <input type=hidden name=login value=$form->{login}>
1946 <input type=hidden name=password value=$form->{password}>
1948 <input class=submit type=submit name=action value="|
1949 . $locale->text('Add') . qq|">
1957 $lxdebug->leave_sub();
1960 sub printer_header {
1961 $lxdebug->enter_sub();
1963 $form->{title} = $locale->text("$form->{title} Printer");
1965 # $locale->text('Add Printer')
1966 # $locale->text('Edit Printer')
1968 $form->{printer_description} =~ s/\"/"/g;
1969 $form->{template_code} =~ s/\"/"/g;
1970 $form->{printer_command} =~ s/\"/"/g;
1978 <form method=post action=$form->{script}>
1980 <input type=hidden name=id value=$form->{id}>
1981 <input type=hidden name=type value=printer>
1985 <th class=listtop colspan=2>$form->{title}</th>
1987 <tr height="5"></tr>
1989 <th align=right>| . $locale->text('Printer') . qq|</th>
1990 <td><input name=printer_description size=30 value="$form->{printer_description}"></td>
1993 <th align=right>| . $locale->text('Printer Command') . qq|</th>
1994 <td><input name=printer_command size=30 value="$form->{printer_command}"></td>
1997 <th align=right>| . $locale->text('Template Code') . qq|</th>
1998 <td><input name=template_code size=5 value="$form->{template_code}"></td>
2000 <td colspan=2><hr size=3 noshade></td>
2005 $lxdebug->leave_sub();
2009 $lxdebug->enter_sub();
2011 $form->isblank("printer_description", $locale->text('Description missing!'));
2012 $form->isblank("printer_command", $locale->text('Printer Command missing!'));
2013 AM->save_printer(\%myconfig, \%$form);
2014 $form->redirect($locale->text('Printer saved!'));
2016 $lxdebug->leave_sub();
2019 sub delete_printer {
2020 $lxdebug->enter_sub();
2022 AM->delete_printer(\%myconfig, \%$form);
2023 $form->redirect($locale->text('Printer deleted!'));
2025 $lxdebug->leave_sub();
2029 $lxdebug->enter_sub();
2031 $form->{title} = "Add";
2034 "$form->{script}?action=add_payment&login=$form->{login}&password=$form->{password}"
2035 unless $form->{callback};
2037 $form->{terms_netto} = 0;
2038 $form->{terms_skonto} = 0;
2039 $form->{percent_skonto} = 0;
2040 my @languages = AM->language(\%myconfig, $form, 1);
2041 map({ $_->{"language"} = $_->{"description"};
2042 $_->{"language_id"} = $_->{"id"}; } @languages);
2043 $form->{"TRANSLATION"} = \@languages;
2047 $lxdebug->leave_sub();
2051 $lxdebug->enter_sub();
2053 $form->{title} = "Edit";
2055 AM->get_payment(\%myconfig, $form);
2056 $form->{percent_skonto} =
2057 $form->format_amount(\%myconfig, $form->{percent_skonto} * 100);
2061 $form->{orphaned} = 1;
2064 $lxdebug->leave_sub();
2068 $lxdebug->enter_sub();
2070 AM->payment(\%myconfig, \%$form);
2072 $form->{callback} = build_std_url("action=list_payment");
2074 $callback = $form->escape($form->{callback});
2076 $form->{title} = $locale->text('Payment Terms');
2078 @column_index = qw(up down description description_long terms_netto
2079 terms_skonto percent_skonto);
2081 $column_header{up} =
2082 qq|<th class="listheading" align="center" valign="center" width="16">|
2083 . qq|<img src="image/up.png" alt="| . $locale->text("up") . qq|">|
2085 $column_header{down} =
2086 qq|<th class="listheading" align="center" valign="center" width="16">|
2087 . qq|<img src="image/down.png" alt="| . $locale->text("down") . qq|">|
2089 $column_header{description} =
2090 qq|<th class=listheading>|
2091 . $locale->text('Description')
2093 $column_header{description_long} =
2094 qq|<th class=listheading>|
2095 . $locale->text('Long Description')
2097 $column_header{terms_netto} =
2098 qq|<th class=listheading>|
2099 . $locale->text('Netto Terms')
2101 $column_header{terms_skonto} =
2102 qq|<th class=listheading>|
2103 . $locale->text('Skonto Terms')
2105 $column_header{percent_skonto} =
2106 qq|<th class=listheading>|
2107 . $locale->text('Skonto')
2117 <th class=listtop>$form->{title}</th>
2119 <tr height="5"></tr>
2123 <tr class=listheading>
2126 map { print "$column_header{$_}\n" } @column_index;
2132 my $swap_link = build_std_url("action=swap_payment_terms");
2135 foreach $ref (@{ $form->{ALL} }) {
2141 <tr valign=top class=listrow$i>
2145 my $pref = $form->{ALL}->[$row - 1];
2147 qq|<td align="center" valign="center" width="16">| .
2148 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$pref->{id}">| .
2149 qq|<img border="0" src="image/up.png" alt="| . $locale->text("up") . qq|">| .
2152 $column_data{up} = qq|<td width="16"> </td>|;
2155 if ($row == (scalar(@{ $form->{ALL} }) - 1)) {
2156 $column_data{down} = qq|<td width="16"> </td>|;
2158 my $nref = $form->{ALL}->[$row + 1];
2159 $column_data{down} =
2160 qq|<td align="center" valign="center" width="16">| .
2161 qq|<a href="${swap_link}&id1=$ref->{id}&id2=$nref->{id}">| .
2162 qq|<img border="0" src="image/down.png" alt="| . $locale->text("down") . qq|">| .
2166 $column_data{description} =
2168 build_std_url("action=edit_payment", "id=$ref->{id}", "callback=$callback") .
2169 qq|">| . H($ref->{description}) . qq|</a></td>|;
2170 $column_data{description_long} =
2171 qq|<td>| . H($ref->{description_long}) . qq|</td>|;
2172 $column_data{terms_netto} =
2173 qq|<td align=right>$ref->{terms_netto}</td>|;
2174 $column_data{terms_skonto} =
2175 qq|<td align=right>$ref->{terms_skonto}</td>|;
2176 $column_data{percent_skonto} =
2177 qq|<td align=right>| .
2178 $form->format_amount(\%myconfig, $ref->{percent_skonto} * 100) .
2180 map { print "$column_data{$_}\n" } @column_index;
2193 <td><hr size=3 noshade></td>
2198 <form method=post action=$form->{script}>
2200 <input name=callback type=hidden value="$form->{callback}">
2202 <input type=hidden name=type value=payment>
2204 <input type=hidden name=login value=$form->{login}>
2205 <input type=hidden name=password value=$form->{password}>
2207 <input class=submit type=submit name=action value="|
2208 . $locale->text('Add') . qq|">
2216 $lxdebug->leave_sub();
2219 sub payment_header {
2220 $lxdebug->enter_sub();
2222 $form->{title} = $locale->text("$form->{title} Payment Terms");
2224 # $locale->text('Add Payment Terms')
2225 # $locale->text('Edit Payment Terms')
2227 $form->{description} =~ s/\"/"/g;
2236 <form method=post action=$form->{script}>
2238 <input type=hidden name=id value=$form->{id}>
2239 <input type=hidden name=type value=payment>
2243 <th class=listtop colspan=2>$form->{title}</th>
2245 <tr height="5"></tr>
2247 <th align=right>| . $locale->text('Description') . qq|</th>
2248 <td><input name=description size=30 value="$form->{description}"></td>
2251 <th align=right>| . $locale->text('Long Description') . qq|</th>
2252 <td><input name=description_long size=50 value="$form->{description_long}"></td>
2256 foreach my $language (@{ $form->{"TRANSLATION"} }) {
2259 <th align="right">| .
2260 sprintf($locale->text('Translation (%s)'),
2261 $language->{"language"})
2263 <td><input name="description_long_$language->{language_id}" size="50"
2264 value="| . Q($language->{"description_long"}) . qq|"></td>
2271 <th align=right>| . $locale->text('Netto Terms') . qq|</th>
2272 <td><input name=terms_netto size=10 value="$form->{terms_netto}"></td>
2275 <th align=right>| . $locale->text('Skonto Terms') . qq|</th>
2276 <td><input name=terms_skonto size=10 value="$form->{terms_skonto}"></td>
2279 <th align=right>| . $locale->text('Skonto') . qq| %</th>
2280 <td><input name=percent_skonto size=10 value="$form->{percent_skonto}"></td>
2282 <td colspan=2><hr size=3 noshade></td>
2286 <p>| . $locale->text("You can use the following strings in the long " .
2287 "description and all translations. They will be " .
2288 "replaced by their actual values by Lx-Office " .
2289 "before they're output.")
2293 <li>| . $locale->text("<%netto_date%> -- Date the payment is due in " .
2296 <li>| . $locale->text("<%skonto_date%> -- Date the payment is due " .
2299 <li>| . $locale->text("<%skonto_amount%> -- The deductible amount")
2301 <li>| . $locale->text("<%total%> -- Amount payable")
2303 <li>| . $locale->text("<%invtotal%> -- Invoice total")
2305 <li>| . $locale->text("<%currency%> -- The selected currency")
2307 <li>| . $locale->text("<%terms_netto%> -- The number of days for " .
2310 <li>| . $locale->text("<%account_number%> -- Your account number")
2312 <li>| . $locale->text("<%bank%> -- Your bank")
2314 <li>| . $locale->text("<%bank_code%> -- Your bank code")
2318 $lxdebug->leave_sub();
2322 $lxdebug->enter_sub();
2324 $form->isblank("description", $locale->text('Description missing!'));
2325 $form->{"percent_skonto"} =
2326 $form->parse_amount(\%myconfig, $form->{percent_skonto}) / 100;
2327 AM->save_payment(\%myconfig, \%$form);
2328 $form->redirect($locale->text('Payment Terms saved!'));
2330 $lxdebug->leave_sub();
2333 sub delete_payment {
2334 $lxdebug->enter_sub();
2336 AM->delete_payment(\%myconfig, \%$form);
2337 $form->redirect($locale->text('Payment terms deleted!'));
2339 $lxdebug->leave_sub();
2342 sub swap_payment_terms {
2343 $lxdebug->enter_sub();
2345 AM->swap_sortkeys(\%myconfig, $form, "payment_terms");
2348 $lxdebug->leave_sub();
2352 $lxdebug->enter_sub();
2354 # get defaults for account numbers and last numbers
2355 AM->defaultaccounts(\%myconfig, \%$form);
2357 foreach $item (qw(mm-dd-yy mm/dd/yy dd-mm-yy dd/mm/yy dd.mm.yy yyyy-mm-dd)) {
2359 ($item eq $myconfig{dateformat})
2360 ? "<option selected>$item\n"
2361 : "<option>$item\n";
2364 foreach $item (qw(1,000.00 1000.00 1.000,00 1000,00)) {
2366 ($item eq $myconfig{numberformat})
2367 ? "<option selected>$item\n"
2368 : "<option>$item\n";
2371 foreach $item (qw(name company address signature)) {
2372 $myconfig{$item} =~ s/\"/"/g;
2375 foreach $item (qw(address signature)) {
2376 $myconfig{$item} =~ s/\\n/\r\n/g;
2380 if ($opendocument_templates && $openofficeorg_writer_bin &&
2381 $xvfb_bin && (-x $openofficeorg_writer_bin) && (-x $xvfb_bin)) {
2382 push(@formats, { "name" => $locale->text("PDF (OpenDocument/OASIS)"),
2383 "value" => "opendocument_pdf" });
2385 if ($latex_templates) {
2386 push(@formats, { "name" => $locale->text("PDF"), "value" => "pdf" });
2388 push(@formats, { "name" => "HTML", "value" => "html" });
2389 if ($latex_templates) {
2390 push(@formats, { "name" => $locale->text("Postscript"),
2391 "value" => "postscript" });
2393 if ($opendocument_templates) {
2394 push(@formats, { "name" => $locale->text("OpenDocument/OASIS"),
2395 "value" => "opendocument" });
2398 if (!$myconfig{"template_format"}) {
2399 $myconfig{"template_format"} = "pdf";
2401 my $template_format = "";
2402 foreach $item (@formats) {
2404 "<option value=\"$item->{value}\"" .
2405 ($item->{"value"} eq $myconfig{"template_format"} ?
2407 ">" . H($item->{"name"}) . "</option>";
2410 if (!$myconfig{"default_media"}) {
2411 $myconfig{"default_media"} = "screen";
2413 my %selected = ($myconfig{"default_media"} => "selected");
2414 my $default_media = qq|
2415 <option value="screen" $selected{'screen'}>| . $locale->text("Screen") . qq|</option>
2416 <option value="printer" $selected{'printer'}>| . $locale->text("Printer") . qq|</option>
2417 <option value="queue" $selected{'queue'}>| . $locale->text("Queue") . qq|</option>
2421 $selected{$myconfig{"default_printer_id"}} = "selected"
2422 if ($myconfig{"default_printer_id"});
2423 my $default_printer = qq|<option></option>|;
2424 AM->printer(\%myconfig, $form);
2425 foreach my $printer (@{$form->{"ALL"}}) {
2426 $default_printer .= qq|<option value="| . Q($printer->{"id"}) .
2427 qq|" $selected{$printer->{'id'}}>| .
2428 H($printer->{"printer_description"}) . qq|</option>|;
2431 %countrycodes = User->country_codes;
2433 foreach $key (sort { $countrycodes{$a} cmp $countrycodes{$b} }
2437 ($myconfig{countrycode} eq $key)
2438 ? "<option selected value=$key>$countrycodes{$key}\n"
2439 : "<option value=$key>$countrycodes{$key}\n";
2441 $countrycodes = "<option>American English\n$countrycodes";
2443 foreach $key (keys %{ $form->{IC} }) {
2444 foreach $accno (sort keys %{ $form->{IC}{$key} }) {
2446 ($form->{IC}{$key}{$accno}{id} == $form->{defaults}{$key})
2447 ? "<option selected>$accno--$form->{IC}{$key}{$accno}{description}\n"
2448 : "<option>$accno--$form->{IC}{$key}{$accno}{description}\n";
2452 # opendir CSS, "css/.";
2453 # @all = grep /.*\.css$/, readdir CSS;
2456 # css dir has styles that are not intended as general layouts.
2457 # reverting to hardcoded list
2458 @all = qw(lx-office-erp.css Win2000.css);
2460 foreach $item (@all) {
2461 if ($item eq $myconfig{stylesheet}) {
2462 $selectstylesheet .= qq|<option selected>$item\n|;
2464 $selectstylesheet .= qq|<option>$item\n|;
2467 $selectstylesheet .= "<option>\n";
2469 $form->{title} = $locale->text('Edit Preferences for') . qq| $form->{login}|;
2473 if ($myconfig{menustyle} eq "old") {
2474 $menustyle_old = "checked";
2475 } elsif ($myconfig{menustyle} eq "neu") {
2476 $menustyle_neu = "checked";
2477 } elsif ($myconfig{menustyle} eq "v3") {
2478 $menustyle_v3 = "checked";
2481 my ($show_form_details, $hide_form_details);
2482 $myconfig{"show_form_details"} = 1
2483 unless (defined($myconfig{"show_form_details"}));
2484 $show_form_details = "checked" if ($myconfig{"show_form_details"});
2485 $hide_form_details = "checked" unless ($myconfig{"show_form_details"});
2490 <form method=post action=$form->{script}>
2492 <input type=hidden name=old_password value=$myconfig{password}>
2493 <input type=hidden name=type value=preferences>
2494 <input type=hidden name=role value=$myconfig{role}>
2497 <tr><th class=listtop>$form->{title}</th></tr>
2502 <th align=right>| . $locale->text('Name') . qq|</th>
2503 <td><input name=name size=15 value="$myconfig{name}"></td>
2506 <th align=right>| . $locale->text('Password') . qq|</th>
2507 <td><input type=password name=new_password size=10 value=$myconfig{password}></td>
2510 <th align=right>| . $locale->text('E-mail') . qq|</th>
2511 <td><input name=email size=30 value="$myconfig{email}"></td>
2514 <th align=right>| . $locale->text('Signature') . qq|</th>
2515 <td><textarea name=signature rows=3 cols=50>$myconfig{signature}</textarea></td>
2518 <th align=right>| . $locale->text('Phone') . qq|</th>
2519 <td><input name=tel size=14 value="$myconfig{tel}"></td>
2522 <th align=right>| . $locale->text('Fax') . qq|</th>
2523 <td><input name=fax size=14 value="$myconfig{fax}"></td>
2526 <th align=right>| . $locale->text('Company') . qq|</th>
2527 <td><input name=company size=30 value="$myconfig{company}"></td>
2530 <th align=right>| . $locale->text('Address') . qq|</th>
2531 <td><textarea name=address rows=4 cols=50>$myconfig{address}</textarea></td>
2534 <th align=right>| . $locale->text('Date Format') . qq|</th>
2535 <td><select name=dateformat>$dateformat</select></td>
2538 <th align=right>| . $locale->text('Output Number Format') . qq|</th>
2539 <td><select name=numberformat>$numberformat</select></td>
2543 <th align=right>| . $locale->text('Dropdown Limit') . qq|</th>
2544 <td><input name=vclimit size=10 value="$myconfig{vclimit}"></td>
2547 <th align=right>| . $locale->text('Language') . qq|</th>
2548 <td><select name=countrycode>$countrycodes</select></td>
2551 <th align=right>| . $locale->text('Stylesheet') . qq|</th>
2552 <td><select name=usestylesheet>$selectstylesheet</select></td>
2555 <th align=right>| . $locale->text('Setup Menu') . qq|</th>
2556 <td><input name=menustyle type=radio class=radio value=v3 $menustyle_v3> | .
2557 $locale->text("Top (CSS)") . qq|
2558 <input name=menustyle type=radio class=radio value=neu $menustyle_neu> | .
2559 $locale->text("Top (Javascript)") . qq|
2560 <input name=menustyle type=radio class=radio value=old $menustyle_old> | .
2561 $locale->text("Old (on the side)") . qq|</td>
2564 <th align=right>| . $locale->text('Form details (second row)') . qq|</th>
2565 <td><input type="radio" id="rad_show_form_details" name="show_form_details" value="1" $show_form_details>
2566 <label for="rad_show_form_details">| . $locale->text('Show by default') . qq|</label>
2567 <input type="radio" id="rad_hide_form_details" name="show_form_details" value="0" $hide_form_details>
2568 <label for="rad_hide_form_details">| . $locale->text('Hide by default') . qq|</label></td>
2570 <input name=printer type=hidden value="$myconfig{printer}">
2571 <tr class=listheading>
2572 <th colspan=2>| . $locale->text("Print options") . qq|</th>
2575 <th align=right>| . $locale->text('Default template format') . qq|</th>
2576 <td><select name="template_format">$template_format</select></td>
2579 <th align=right>| . $locale->text('Default output medium') . qq|</th>
2580 <td><select name="default_media">$default_media</select></td>
2583 <th align=right>| . $locale->text('Default printer') . qq|</th>
2584 <td><select name="default_printer_id">$default_printer</select></td>
2587 <th align=right>| . $locale->text('Number of copies') . qq|</th>
2588 <td><input name="copies" size="10" value="| .
2589 $form->quote($myconfig{"copies"}) . qq|"></td>
2593 <tr class=listheading>
2594 <th colspan=2> </th>
2597 <th align=right>| . $locale->text('Business Number') . qq|</th>
2598 <td><input name=businessnumber size=25 value="$myconfig{businessnumber}"></td>
2601 <th align=right>| . $locale->text('Year End') . qq| (mm/dd)</th>
2602 <td><input name=yearend size=5 value=$form->{defaults}{yearend}></td>
2604 <tr class=listheading>
2606 . $locale->text('Last Numbers & Default Accounts') . qq|</th>
2612 <th align=right nowrap>| . $locale->text('Inventory Account') . qq|</th>
2613 <td><select name=inventory_accno>$myconfig{IC}</select></td>
2616 <th align=right nowrap>| . $locale->text('Revenue Account') . qq|</th>
2617 <td><select name=income_accno>$myconfig{IC_income}</select></td>
2620 <th align=right nowrap>| . $locale->text('Expense Account') . qq|</th>
2621 <td><select name=expense_accno>$myconfig{IC_expense}</select></td>
2624 <th align=right nowrap>| . $locale->text('Foreign Exchange Gain') . qq|</th>
2625 <td><select name=fxgain_accno>$myconfig{FX_gain}</select></td>
2628 <th align=right nowrap>| . $locale->text('Foreign Exchange Loss') . qq|</th>
2629 <td><select name=fxloss_accno>$myconfig{FX_loss}</select></td>
2634 'Enter up to 3 letters separated by a colon (i.e CAD:USD:EUR) for your native and foreign currencies'
2636 . qq|<br><input name=curr size=40 value="$form->{defaults}{curr}"></td>
2645 <th align=right nowrap>| . $locale->text('Last Invoice Number') . qq|</th>
2646 <td><input name=invnumber size=10 value=$form->{defaults}{invnumber}></td>
2647 <th align=right nowrap>|
2648 . $locale->text('Last Customer Number') . qq|</th>
2649 <td><input name=customernumber size=10 value=$form->{defaults}{customernumber}></td>
2652 <th align=right nowrap>|
2653 . $locale->text('Last Credit Note Number') . qq|</th>
2654 <td><input name=cnnumber size=10 value=$form->{defaults}{cnnumber}></td>
2655 <th align=right nowrap>|
2656 . $locale->text('Last Vendor Number') . qq|</th>
2657 <td><input name=vendornumber size=10 value=$form->{defaults}{vendornumber}></td>
2660 <th align=right nowrap>|
2661 . $locale->text('Last Sales Order Number') . qq|</th>
2662 <td><input name=sonumber size=10 value=$form->{defaults}{sonumber}></td>
2665 <th align=right nowrap>|
2666 . $locale->text('Last Purchase Order Number') . qq|</th>
2667 <td><input name=ponumber size=10 value=$form->{defaults}{ponumber}></td>
2668 <th align=right nowrap>|
2669 . $locale->text('Last Article Number') . qq|</th>
2670 <td><input name=articlenumber size=10 value=$form->{defaults}{articlenumber}></td>
2673 <th align=right nowrap>|
2674 . $locale->text('Last Sales Quotation Number') . qq|</th>
2675 <td><input name=sqnumber size=10 value=$form->{defaults}{sqnumber}></td>
2676 <th align=right nowrap>|
2677 . $locale->text('Last Service Number') . qq|</th>
2678 <td><input name=servicenumber size=10 value=$form->{defaults}{servicenumber}></td>
2681 <th align=right nowrap>| . $locale->text('Last RFQ Number') . qq|</th>
2682 <td><input name=rfqnumber size=10 value=$form->{defaults}{rfqnumber}></td>
2683 <th align=right nowrap></th>
2689 # <tr class=listheading>
2690 # <th colspan=2>| . $locale->text('Tax Accounts') . qq|</th>
2697 # <th>| . $locale->text('Rate') . qq| (%)</th>
2698 # <th>| . $locale->text('Number') . qq|</th>
2702 # foreach $accno (sort keys %{ $form->{taxrates} }) {
2705 # <th align=right>$form->{taxrates}{$accno}{description}</th>
2706 # <td><input name=$form->{taxrates}{$accno}{id} size=6 value=$form->{taxrates}{$accno}{rate}></td>
2707 # <td><input name="taxnumber_$form->{taxrates}{$accno}{id}" value="$form->{taxrates}{$accno}{taxnumber}"></td>
2710 # $form->{taxaccounts} .= "$form->{taxrates}{$accno}{id} ";
2713 # chop $form->{taxaccounts};
2716 # <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
2725 <td><hr size=3 noshade></td>
2729 <input type=hidden name=login value=$form->{login}>
2730 <input type=hidden name=password value=$form->{password}>
2733 <input type=submit class=submit name=action value="|
2734 . $locale->text('Save') . qq|">
2742 $lxdebug->leave_sub();
2745 sub save_preferences {
2746 $lxdebug->enter_sub();
2748 $form->{stylesheet} = $form->{usestylesheet};
2750 $form->redirect($locale->text('Preferences saved!'))
2752 AM->save_preferences(\%myconfig, \%$form, $memberfile, $userspath, $webdav
2754 $form->error($locale->text('Cannot save preferences!'));
2756 $lxdebug->leave_sub();
2760 $lxdebug->enter_sub();
2762 $form->{title} = $locale->text('Audit Control');
2764 AM->closedto(\%myconfig, \%$form);
2766 if ($form->{revtrans}) {
2767 $checked{Y} = "checked";
2769 $checked{N} = "checked";
2777 <form method=post action=$form->{script}>
2779 <input type=hidden name=login value=$form->{login}>
2780 <input type=hidden name=password value=$form->{password}>
2783 <tr><th class=listtop>$form->{title}</th></tr>
2784 <tr height="5"></tr>
2790 . $locale->text('Enforce transaction reversal for all dates') . qq|</th>
2791 <td><input name=revtrans class=radio type=radio value="1" $checked{Y}> |
2792 . $locale->text('Yes')
2793 . qq| <input name=revtrans class=radio type=radio value="0" $checked{N}> |
2794 . $locale->text('No')
2798 <th>| . $locale->text('Close Books up to') . qq|</th>
2799 <td><input name=closedto size=11 title="$myconfig{dateformat}" value=$form->{closedto}></td>
2809 <input type=hidden name=nextsub value=doclose>
2811 <input type=submit class=submit name=action value="|
2812 . $locale->text('Continue') . qq|">
2820 $lxdebug->leave_sub();
2824 $lxdebug->enter_sub();
2826 AM->closebooks(\%myconfig, \%$form);
2828 if ($form->{revtrans}) {
2830 $locale->text('Transaction reversal enforced for all dates'));
2832 if ($form->{closedto}) {
2834 $locale->text('Transaction reversal enforced up to') . " "
2835 . $locale->date(\%myconfig, $form->{closedto}, 1));
2837 $form->redirect($locale->text('Books are open'));
2841 $lxdebug->leave_sub();
2845 $lxdebug->enter_sub();
2847 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
2848 AM->units_in_use(\%myconfig, $form, $units);
2849 map({ $units->{$_}->{"BASE_UNIT_DDBOX"} = AM->unit_select_data($units, $units->{$_}->{"base_unit"}, 1); } keys(%{$units}));
2851 @languages = AM->language(\%myconfig, $form, 1);
2853 @unit_list = sort({ $a->{"sortkey"} <=> $b->{"sortkey"} } values(%{$units}));
2856 foreach (@unit_list) {
2857 $_->{"factor"} = $form->format_amount(\%myconfig, $_->{"factor"} * 1) if ($_->{"factor"});
2858 $_->{"UNITLANGUAGES"} = [];
2859 foreach my $lang (@languages) {
2860 push(@{ $_->{"UNITLANGUAGES"} },
2862 "unit" => $_->{"name"},
2863 "language_id" => $lang->{"id"},
2864 "localized" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized"},
2865 "localized_plural" => $_->{"LANGUAGES"}->{$lang->{"template_code"}}->{"localized_plural"},
2871 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
2872 $ddbox = AM->unit_select_data($units, undef, 1);
2874 my $updownlink = build_std_url("action=swap_units", "unit_type");
2876 $form->{"title"} = sprintf($locale->text("Add and edit %s"), $form->{"unit_type"} eq "dimension" ? $locale->text("dimension units") : $locale->text("service units"));
2878 print($form->parse_html_template("am/edit_units",
2879 { "UNITS" => \@unit_list,
2880 "NEW_BASE_UNIT_DDBOX" => $ddbox,
2881 "LANGUAGES" => \@languages,
2882 "updownlink" => $updownlink }));
2884 $lxdebug->leave_sub();
2888 $lxdebug->enter_sub();
2890 $form->isblank("new_name", $locale->text("The name is missing."));
2891 $units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"});
2892 $all_units = AM->retrieve_units(\%myconfig, $form);
2893 $form->show_generic_error($locale->text("A unit with this name does already exist.")) if ($all_units->{$form->{"new_name"}});
2895 my ($base_unit, $factor);
2896 if ($form->{"new_base_unit"}) {
2897 $form->show_generic_error($locale->text("The base unit does not exist.")) unless (defined($units->{$form->{"new_base_unit"}}));
2899 $form->isblank("new_factor", $locale->text("The factor is missing."));
2900 $factor = $form->parse_amount(\%myconfig, $form->{"new_factor"});
2901 $form->show_generic_error($locale->text("The factor is missing.")) unless ($factor);
2902 $base_unit = $form->{"new_base_unit"};
2906 foreach my $lang (AM->language(\%myconfig, $form, 1)) {
2907 next unless ($form->{"new_localized_$lang->{id}"} || $form->{"new_localized_plural_$lang->{id}"});
2908 push(@languages, { "id" => $lang->{"id"},
2909 "localized" => $form->{"new_localized_$lang->{id}"},
2910 "localized_plural" => $form->{"new_localized_plural_$lang->{id}"},
2914 AM->add_unit(\%myconfig, $form, $form->{"new_name"}, $base_unit, $factor, $form->{"unit_type"}, \@languages);
2916 $form->{"saved_message"} = $locale->text("The unit has been saved.");
2920 $lxdebug->leave_sub();
2923 sub set_unit_languages {
2924 $lxdebug->enter_sub();
2926 my ($unit, $languages, $idx) = @_;
2928 $unit->{"LANGUAGES"} = [];
2930 foreach my $lang (@{$languages}) {
2931 push(@{ $unit->{"LANGUAGES"} },
2932 { "id" => $lang->{"id"},
2933 "localized" => $form->{"localized_${idx}_$lang->{id}"},
2934 "localized_plural" => $form->{"localized_plural_${idx}_$lang->{id}"},
2938 $lxdebug->leave_sub();
2942 $lxdebug->enter_sub();
2944 $old_units = AM->retrieve_units(\%myconfig, $form, $form->{"unit_type"}, "resolved_");
2945 AM->units_in_use(\%myconfig, $form, $old_units);
2947 @languages = AM->language(\%myconfig, $form, 1);
2951 foreach $i (1..($form->{"rowcount"} * 1)) {
2952 $old_unit = $old_units->{$form->{"old_name_$i"}};
2954 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been deleted in the meantime."), $i));
2957 if ($form->{"unchangeable_$i"}) {
2958 $new_units->{$form->{"old_name_$i"}} = $old_units->{$form->{"old_name_$i"}};
2959 $new_units->{$form->{"old_name_$i"}}->{"unchanged_unit"} = 1;
2960 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2964 if ($old_unit->{"in_use"}) {
2965 $form->show_generic_error(sprintf($locale->text("The unit in row %d has been used in the meantime and cannot be changed anymore."), $i));
2968 if ($form->{"delete_$i"}) {
2969 push(@delete_units, $old_unit->{"name"});
2973 $form->isblank("name_$i", sprintf($locale->text("The name is missing in row %d."), $i));
2975 $form->show_generic_error(sprintf($locale->text("The name in row %d has already been used before."), $i)) if ($new_units->{$form->{"name_$i"}});
2976 my %h = map({ $_ => $form->{"${_}_$i"} } qw(name base_unit factor old_name));
2977 $new_units->{$form->{"name_$i"}} = \%h;
2978 $new_units->{$form->{"name_$i"}}->{"row"} = $i;
2979 set_unit_languages($new_units->{$form->{"old_name_$i"}}, \@languages, $i);
2982 foreach $unit (values(%{$new_units})) {
2983 next unless ($unit->{"old_name"});
2984 if ($unit->{"base_unit"}) {
2985 $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"}))
2986 unless (defined($new_units->{$unit->{"base_unit"}}));
2987 $unit->{"factor"} = $form->parse_amount(\%myconfig, $unit->{"factor"});
2988 $form->show_generic_error(sprintf($locale->text("The factor is missing in row %d."), $unit->{"row"})) unless ($unit->{"factor"} >= 1.0);
2990 $unit->{"base_unit"} = undef;
2991 $unit->{"factor"} = undef;
2995 foreach $unit (values(%{$new_units})) {
2996 next if ($unit->{"unchanged_unit"});
2998 map({ $_->{"seen"} = 0; } values(%{$new_units}));
3000 while ($new_unit->{"base_unit"}) {
3001 $new_unit->{"seen"} = 1;
3002 $new_unit = $new_units->{$new_unit->{"base_unit"}};
3003 if ($new_unit->{"seen"}) {
3004 $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, " .
3005 "B's base unit is C and C's base unit is A) in row %d."), $unit->{"row"}));
3010 AM->save_units(\%myconfig, $form, $form->{"unit_type"}, $new_units, \@delete_units);
3012 $form->{"saved_message"} = $locale->text("The units have been saved.");
3016 $lxdebug->leave_sub();
3019 sub show_history_search {
3020 $lxdebug->enter_sub();
3022 $form->{title} = $locale->text("History Search");
3025 print $form->parse_html_template("/common/search_history");
3027 $lxdebug->leave_sub();
3030 sub show_am_history {
3031 $lxdebug->enter_sub();
3032 my %search = ( "Artikelnummer" => "parts",
3033 "Kundennummer" => "customer",
3034 "Lieferantennummer" => "vendor",
3035 "Projektnummer" => "project",
3036 "Buchungsnummer" => "oe",
3037 "Eingangsrechnungnummer" => "ap",
3038 "Ausgangsrechnungnummer" => "ar",
3039 "Mahnungsnummer" => "dunning"
3041 my %searchNo = ( "Artikelnummer" => "partnumber",
3042 "Kundennummer" => "customernumber",
3043 "Lieferantennummer" => "vendornumber",
3044 "Projektnummer" => "projectnummer",
3045 "Buchungsnummer" => "ordnumber",
3046 "Eingangsrechnungnummer" => "invnumber",
3047 "Ausgangsrechnungnummer" => "invnumber",
3048 "Mahnungsnummer" => "dunning_id"
3053 foreach(split(/\,/, $form->{einschraenkungen})) {
3055 $restriction .= " AND addition = '" . $_ . "'";
3059 $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|'|
3071 $restriction .= ($form->{mitarbeiter} eq "" ? ""
3072 : ($form->{mitarbeiter} =~ /^[0-9]*$/
3073 ? " AND employee_id = " . $form->{mitarbeiter}
3074 : " AND employee_id = " . &get_employee_id($form->{mitarbeiter}, $dbh)));
3076 my $dbh = $form->dbconnect(\%myconfig);
3077 my $query = qq|SELECT trans_id AS id FROM history_erp | .
3078 ($form->{'searchid'} ?
3079 qq| WHERE snumbers = '| . $searchNo{$form->{'what2search'}} . qq|_| . $form->{'searchid'} . qq|'| :
3080 qq| WHERE snumbers ~ '^| . $searchNo{$form->{'what2search'}} . qq|'|);
3082 my $sth = $dbh->prepare($query);
3084 $sth->execute() || $form->dberror($query);
3086 $form->{title} = $locale->text("History Search");
3091 while(my $hash_ref = $sth->fetchrow_hashref()){
3093 $daten .= $hash_ref->{id};
3097 $daten .= " OR trans_id = " . $hash_ref->{id};
3101 my ($sort, $sortby) = split(/\-\-/, $form->{order});
3102 $sort =~ s/.*\.(.*)$/$1/;
3104 print $form->parse_html_template("/common/show_history",
3105 {"DATEN" => $form->get_history($dbh, $daten, $restriction, $form->{order}),
3106 "SUCCESS" => ($form->get_history($dbh, $daten, $restriction, $form->{order}) ne "0"),
3109 uc($sort)."BY" => $sortby
3112 $lxdebug->leave_sub();
3115 sub get_employee_id {
3116 $lxdebug->enter_sub();
3117 my $query = qq|SELECT id FROM employee WHERE name = '| . $_[0] . qq|'|;
3118 my $sth = $_[1]->prepare($query);
3119 $sth->execute() || $form->dberror($query);
3120 my $return = $sth->fetch();
3122 return ${$return}[0];
3123 $lxdebug->leave_sub();
3127 $lxdebug->enter_sub();
3129 my $dir = $form->{"dir"} eq "down" ? "down" : "up";
3130 my $unit_type = $form->{"unit_type"} eq "dimension" ?
3131 "dimension" : "service";
3132 AM->swap_units(\%myconfig, $form, $dir, $form->{"name"}, $unit_type);
3136 $lxdebug->leave_sub();
3140 $lxdebug->enter_sub();
3142 $form->{title} = $locale->text('Add');
3145 "$form->{script}?action=add_tax&login=$form->{login}&password=$form->{password}"
3146 unless $form->{callback};
3148 _get_taxaccount_selection();
3152 my $parameters_ref = {
3153 # ChartTypeIsAccount => $ChartTypeIsAccount,
3156 # Ausgabe des Templates
3157 print($form->parse_html_template2('am/edit_tax', $parameters_ref));
3159 $lxdebug->leave_sub();
3163 $lxdebug->enter_sub();
3165 $form->{title} = $locale->text('Edit');
3167 AM->get_tax(\%myconfig, \%$form);
3168 _get_taxaccount_selection();
3170 $form->{rate} = $form->format_amount(\%myconfig, $form->{rate}, 2);
3174 my $parameters_ref = {
3177 # Ausgabe des Templates
3178 print($form->parse_html_template2('am/edit_tax', $parameters_ref));
3180 $lxdebug->leave_sub();
3184 $lxdebug->enter_sub();
3186 AM->taxes(\%myconfig, \%$form);
3188 map { $_->{rate} = $form->format_amount(\%myconfig, $_->{rate}, 2) } @{ $form->{TAX} };
3190 $form->{callback} = build_std_url('action=list_tax');
3192 $form->{title} = $locale->text('Tax-O-Matic');
3196 # Ausgabe des Templates
3197 print($form->parse_html_template2('am/list_tax', $parameters_ref));
3199 $lxdebug->leave_sub();
3202 sub _get_taxaccount_selection{
3203 $lxdebug->enter_sub();
3205 AM->get_tax_accounts(\%myconfig, \%$form);
3207 map { $_->{selected} = $form->{chart_id} == $_->{id} } @{ $form->{ACCOUNTS} };
3209 $lxdebug->leave_sub();
3213 $lxdebug->enter_sub();
3215 $form->isblank("chart_id", $locale->text('Tax-O-Matic account missing!'));
3216 $form->isblank("rate", $locale->text('Taxrate missing!'));
3217 $form->isblank("taxdescription", $locale->text('Taxdescription missing!'));
3218 $form->isblank("taxkey", $locale->text('Taxkey missing!'));
3220 $form->{rate} = $form->parse_amount(\%myconfig, $form->{rate});
3222 if ( $form->{rate} <= 0 || $form->{rate} >= 100 ) {
3223 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
3226 if ( $form->{rate} <= 0.99 && $form->{rate} >= 0 ) {
3227 $form->error($locale->text('Tax Percent is a number between 0 and 100'));
3230 AM->save_tax(\%myconfig, \%$form);
3231 $form->redirect($locale->text('Tax saved!'));
3233 $lxdebug->leave_sub();
3237 $lxdebug->enter_sub();
3239 AM->delete_tax(\%myconfig, \%$form);
3240 $form->redirect($locale->text('Tax deleted!'));
3242 $lxdebug->leave_sub();