Lx-Office kann ohne Rose::DB::Object nicht betrieben werden, also Konfigurationsoptio...
[kivitendo-erp.git] / bin / mozilla / common.pl
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2004
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 ######################################################################
7 #
8 # Stuff that can be used from other modules
9 #
10 ######################################################################
11
12 use Carp;
13 use SL::Common;
14 use SL::DB::Helper::Mappings;
15 use SL::DBUtils;
16 use SL::Form;
17 use SL::MoreCommon;
18 use SL::Helper::Flash;
19
20 use strict;
21
22 sub build_std_url {
23   $main::lxdebug->enter_sub(2);
24
25   my $form     = $main::form;
26
27   my $script = $form->{script};
28
29   my @parts;
30
31   foreach my $key (@_) {
32     next unless ($key);
33
34     if ($key =~ /(.*?)=(.*)/) {
35       if ($1 eq 'script') {
36         $script = $2;
37       } else {
38         push @parts, $key;
39       }
40
41     } else {
42       foreach my $var ($form->flatten_variables($key)) {
43         push @parts, E($var->{key}) . '=' . E($var->{value});
44       }
45     }
46   }
47
48   my $url = "${script}?" . join('&', @parts);
49
50   $main::lxdebug->leave_sub(2);
51
52   return $url;
53 }
54
55 # -------------------------------------------------------------------------
56
57 sub select_part {
58   $main::lxdebug->enter_sub();
59
60   my ($callback_sub, @parts) = @_;
61
62   my $form     = $main::form;
63   my $locale   = $main::locale;
64
65   my $remap_parts_id = 0;
66   if (defined($parts[0]->{parts_id}) && !defined($parts[0]->{id})) {
67     $remap_parts_id = 1;
68     map { $_->{id} = $_->{parts_id}; } @parts;
69   }
70
71   my $remap_partnumber = 0;
72   if (defined($parts[0]->{partnumber}) && !defined($parts[0]->{number})) {
73     $remap_partnumber = 1;
74     map { $_->{number} = $_->{partnumber}; } @parts;
75   }
76
77   my $has_charge = 0;
78   if (defined($parts[0]->{chargenumber})) {
79     $has_charge = 1;
80     map { $_->{has_charge} = 1; } @parts;
81   }
82   my $has_bestbefore = 0;
83   if (defined($parts[0]->{bestbefore})) {
84     $has_bestbefore = 1;
85     map { $_->{has_bestbefore} = 1; } @parts;
86   }
87   my $has_ean = 0;
88   if (defined($parts[0]->{ean})) {
89     $has_ean = 1;
90     map { $_->{has_ean} = 1; } @parts;
91   }
92
93   my $old_form = save_form();
94
95   $form->header();
96   print $form->parse_html_template("generic/select_part",
97                                    { "PARTS"            => \@parts,
98                                      "old_form"         => $old_form,
99                                      "title"            => $locale->text("Select a part"),
100                                      "nextsub"          => "select_part_internal",
101                                      "callback_sub"     => $callback_sub,
102                                      "has_charge"       => $has_charge,
103                                      "has_bestbefore"   => $has_bestbefore,
104                                      "has_ean"          => $has_ean,
105                                      "remap_parts_id"   => $remap_parts_id,
106                                      "remap_partnumber" => $remap_partnumber });
107
108   $main::lxdebug->leave_sub();
109 }
110
111 sub select_part_internal {
112   $main::lxdebug->enter_sub();
113
114   my $form     = $main::form;
115
116   my ($new_item, $callback_sub);
117
118   my $re = "^new_.*_$form->{selection}\$";
119
120   foreach (grep /$re/, keys %{ $form }) {
121     my $new_key           =  $_;
122     $new_key              =~ s/^new_//;
123     $new_key              =~ s/_\d+$//;
124     $new_item->{$new_key} =  $form->{$_};
125   }
126
127   if ($form->{remap_parts_id}) {
128     $new_item->{parts_id} = $new_item->{id};
129     delete $new_item->{id};
130   }
131
132   if ($form->{remap_partnumber}) {
133     $new_item->{partnumber} = $new_item->{number};
134     delete $new_item->{number};
135   }
136
137   $callback_sub = $form->{callback_sub};
138
139   restore_form($form->{old_form});
140
141   call_sub($callback_sub, $new_item);
142
143   $main::lxdebug->leave_sub();
144 }
145
146 sub part_selection_internal {
147   $main::lxdebug->enter_sub();
148
149   my $form     = $main::form;
150   my %myconfig = %main::myconfig;
151   my $locale   = $main::locale;
152
153   my $order_by  = "description";
154   $order_by  = $form->{"order_by"} if (defined($form->{"order_by"}));
155   my $order_dir = 1;
156   $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
157
158   my %options;
159
160   foreach my $opt (split m/:/, $form->{options}) {
161     if ($opt =~ /=/) {
162       my ($key, $value) = split m/=/, $opt, 2;
163       $options{$key} = $value;
164
165     } else {
166       $options{$opt} = 1;
167     }
168   }
169
170   map { $form->{$_} = $options{$_} if ($options{$_}) } qw(no_services no_assemblies assemblies click_button);
171
172   my $parts = Common->retrieve_parts(\%myconfig, $form, $order_by, $order_dir);
173   my $onload;
174
175   if (0 == scalar(@{$parts})) {
176     $form->show_generic_information($locale->text("No part was found matching the search parameters."));
177   } elsif (1 == scalar(@{$parts})) {
178     $onload = "part_selected('1')";
179   }
180
181   map { $parts->[$_]->{selected} = $_ ? 0 : 1; } (0..$#{$parts});
182
183   my $callback = build_std_url('action=part_selection_internal', qw(partnumber description input_partnumber input_description input_partsid),
184                                grep({ /^[fl]_/ } keys %{ $form }));
185
186   my @header_sort  = qw(partnumber description);
187   my %header_title = ( "partnumber"  => $locale->text("Part Number"),
188                        "description" => $locale->text("Part Description"),
189                        );
190
191   my @header =
192     map(+{ "column_title" => $header_title{$_},
193            "column"       => $_,
194            "callback"     => $callback . "order_by=${_}&order_dir=" . ($order_by eq $_ ? 1 - $order_dir : $order_dir),
195          },
196         @header_sort);
197
198   $form->{formname} ||= 'Form';
199
200   $form->{title} = $locale->text("Select a part");
201   $form->header();
202   print $form->parse_html_template("generic/part_selection", { "HEADER" => \@header,
203                                                                "PARTS"  => $parts,
204                                                                "onload" => $onload });
205
206   $main::lxdebug->leave_sub();
207 }
208
209 # -------------------------------------------------------------------------
210
211 sub delivery_customer_selection {
212   $main::lxdebug->enter_sub();
213
214   my $form     = $main::form;
215   my %myconfig = %main::myconfig;
216   my $locale   = $main::locale;
217
218   my $order_by = "name";
219   $order_by = $form->{"order_by"} if (defined($form->{"order_by"}));
220   my $order_dir = 1;
221   $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
222
223   my $delivery = Common->retrieve_delivery_customer(\%myconfig, $form, $order_by, $order_dir);
224   map({ $delivery->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$delivery}));
225
226   my $onload;
227   if (0 == scalar(@{$delivery})) {
228     $form->show_generic_information($locale->text("No Customer was found matching the search parameters."));
229   } elsif (1 == scalar(@{$delivery})) {
230     $onload = "customer_selected('1')";
231   }
232
233   my $callback = "$form->{script}?action=delivery_customer_selection&";
234   map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
235       (qw(name input_name input_id), grep({ /^[fl]_/ } keys %$form)));
236
237   my @header_sort = qw(name customernumber address);
238   my %header_title = ( "name" => $locale->text("Name"),
239                        "customernumber" => $locale->text("Customer Number"),
240                        "address" => $locale->text("Address"),
241                      );
242
243   my @header =
244     map(+{ "column_title" => $header_title{$_},
245            "column" => $_,
246            "callback" => $callback . "order_by=${_}&order_dir=" . ($order_by eq $_ ? 1 - $order_dir : $order_dir),
247          },
248         @header_sort);
249
250   $form->{"title"} = $locale->text("Select a Customer");
251   $form->header();
252   print $form->parse_html_template("generic/select_delivery_customer", { "HEADER"   => \@header,
253                                                                          "DELIVERY" => $delivery,
254                                                                          "onload"   => $onload });
255
256   $main::lxdebug->leave_sub();
257 }
258
259 # -------------------------------------------------------------------------
260
261 sub vendor_selection {
262   $main::lxdebug->enter_sub();
263
264   my $form     = $main::form;
265   my %myconfig = %main::myconfig;
266   my $locale   = $main::locale;
267
268   my $order_by = "name";
269   $order_by = $form->{"order_by"} if (defined($form->{"order_by"}));
270   my $order_dir = 1;
271   $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
272
273   my $vendor = Common->retrieve_vendor(\%myconfig, $form, $order_by, $order_dir);
274   map({ $vendor->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$vendor}));
275
276   my $onload;
277   if (0 == scalar(@{$vendor})) {
278     $form->show_generic_information($locale->text("No Vendor was found matching the search parameters."));
279   } elsif (1 == scalar(@{$vendor})) {
280     $onload = "vendor_selected('1')";
281   }
282
283   my $callback = "$form->{script}?action=vendor_selection&";
284   map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
285       (qw(name input_name input_id), grep({ /^[fl]_/ } keys %$form)));
286
287   my @header_sort = qw(name customernumber address);
288   my %header_title = ( "name" => $locale->text("Name"),
289                        "customernumber" => $locale->text("Customer Number"),
290                        "address" => $locale->text("Address"),
291                      );
292
293   my @header =
294     map(+{ "column_title" => $header_title{$_},
295            "column" => $_,
296            "callback" => $callback . "order_by=${_}&order_dir=" . ($order_by eq $_ ? 1 - $order_dir : $order_dir),
297          },
298         @header_sort);
299
300   $form->{"title"} = $locale->text("Select a Customer");
301   $form->header();
302   print $form->parse_html_template("generic/select_vendor", { "HEADER" => \@header,
303                                                               "VENDOR" => $vendor,
304                                                               "onload" => $onload });
305
306   $main::lxdebug->leave_sub();
307 }
308
309 # -------------------------------------------------------------------------
310
311 sub calculate_qty {
312   $main::lxdebug->enter_sub();
313
314   my $form     = $main::form;
315   my $locale   = $main::locale;
316
317   $form->{formel} =~ s/\r\n//g;
318
319   my ($variable_string, $formel) = split /###/,$form->{formel};
320   my @variable;
321   my $onload; # note! this sub is mostly called over a javascript invocation, and it's unlikey that onload is set.
322
323   foreach my $item (split m/;/, $variable_string) {
324     next unless $item =~ m/^ \s* (\w+) \s* = \s* (\w+) \s* (\w+) \s* $/x;
325     push @variable, {
326       description => $1,
327       name        => $2,
328       unit        => $3,
329     };
330   }
331
332   my @header_sort = qw(variable value unit);
333   my %header_title = (
334     variable => $locale->text("Variable"),
335     value    => $locale->text("Value"),
336     unit     => $locale->text("Unit"),
337   );
338   my @header = map +{
339     column_title => $header_title{$_},
340     column       => $_,
341   }, @header_sort;
342
343   $form->{formel} = $formel;
344   $form->{title}  = $locale->text("Please enter values");
345   $form->header();
346   print $form->parse_html_template("generic/calculate_qty", { "HEADER"    => \@header,
347                                                               "VARIABLES" => \@variable,
348                                                               "onload"    => $onload });
349
350   $main::lxdebug->leave_sub();
351 }
352
353 # -------------------------------------------------------------------------
354
355 sub set_longdescription {
356   $main::lxdebug->enter_sub();
357
358   my $form     = $main::form;
359   my $locale   = $main::locale;
360
361   $form->{title} = $locale->text("Enter longdescription");
362   $form->header();
363   print $form->parse_html_template("generic/set_longdescription");
364
365   $main::lxdebug->leave_sub();
366 }
367
368 # -------------------------------------------------------------------------
369
370 sub H {
371   return $main::locale->quote_special_chars('HTML', $_[0]);
372 }
373
374 sub Q {
375   return $main::locale->quote_special_chars('URL@HTML', $_[0]);
376 }
377
378 sub E {
379   return $main::form->escape($_[0]);
380 }
381
382 sub NTI {
383   my ($element) = @_;
384
385   $element =~ s/tabindex\s*=\s*"\d+"//;
386   return $element;
387 }
388
389 sub format_dates {
390   $main::lxdebug->enter_sub();
391
392   my ($dateformat, $longformat, @indices) = @_;
393
394   my $form     = $main::form;
395   my %myconfig = %main::myconfig;
396   my $locale   = $main::locale;
397
398   $dateformat = $myconfig{"dateformat"} unless ($dateformat);
399
400   foreach my $idx (@indices) {
401     if ($form->{TEMPLATE_ARRAYS} && (ref($form->{TEMPLATE_ARRAYS}->{$idx}) eq "ARRAY")) {
402       for (my $i = 0; $i < scalar(@{$form->{TEMPLATE_ARRAYS}->{$idx}}); $i++) {
403         $form->{TEMPLATE_ARRAYS}->{$idx}->[$i] =
404           $locale->reformat_date(\%myconfig, $form->{TEMPLATE_ARRAYS}->{$idx}->[$i],
405                                  $dateformat, $longformat);
406       }
407     }
408
409     next unless (defined($form->{$idx}));
410
411     if (!ref($form->{$idx})) {
412       $form->{$idx} = $locale->reformat_date(\%myconfig, $form->{$idx},
413                                              $dateformat, $longformat);
414
415     } elsif (ref($form->{$idx}) eq "ARRAY") {
416       for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) {
417         $form->{$idx}->[$i] =
418           $locale->reformat_date(\%myconfig, $form->{$idx}->[$i],
419                                  $dateformat, $longformat);
420       }
421     }
422   }
423
424   $main::lxdebug->leave_sub();
425 }
426
427 sub reformat_numbers {
428   $main::lxdebug->enter_sub();
429
430   my ($numberformat, $places, @indices) = @_;
431
432   my $form     = $main::form;
433   my %myconfig = %main::myconfig;
434
435   return $main::lxdebug->leave_sub()
436     if (!$numberformat || ($numberformat eq $myconfig{"numberformat"}));
437
438   foreach my $idx (@indices) {
439     if ($form->{TEMPLATE_ARRAYS} && (ref($form->{TEMPLATE_ARRAYS}->{$idx}) eq "ARRAY")) {
440       for (my $i = 0; $i < scalar(@{$form->{TEMPLATE_ARRAYS}->{$idx}}); $i++) {
441         $form->{TEMPLATE_ARRAYS}->{$idx}->[$i] = $form->parse_amount(\%myconfig, $form->{TEMPLATE_ARRAYS}->{$idx}->[$i]);
442       }
443     }
444
445     next unless (defined($form->{$idx}));
446
447     if (!ref($form->{$idx})) {
448       $form->{$idx} = $form->parse_amount(\%myconfig, $form->{$idx});
449
450     } elsif (ref($form->{$idx}) eq "ARRAY") {
451       for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) {
452         $form->{$idx}->[$i] =
453           $form->parse_amount(\%myconfig, $form->{$idx}->[$i]);
454       }
455     }
456   }
457
458   my $saved_numberformat = $myconfig{"numberformat"};
459   $myconfig{"numberformat"} = $numberformat;
460
461   foreach my $idx (@indices) {
462     if ($form->{TEMPLATE_ARRAYS} && (ref($form->{TEMPLATE_ARRAYS}->{$idx}) eq "ARRAY")) {
463       for (my $i = 0; $i < scalar(@{$form->{TEMPLATE_ARRAYS}->{$idx}}); $i++) {
464         $form->{TEMPLATE_ARRAYS}->{$idx}->[$i] = $form->format_amount(\%myconfig, $form->{TEMPLATE_ARRAYS}->{$idx}->[$i], $places);
465       }
466     }
467
468     next unless (defined($form->{$idx}));
469
470     if (!ref($form->{$idx})) {
471       $form->{$idx} = $form->format_amount(\%myconfig, $form->{$idx}, $places);
472
473     } elsif (ref($form->{$idx}) eq "ARRAY") {
474       for (my $i = 0; $i < scalar(@{$form->{$idx}}); $i++) {
475         $form->{$idx}->[$i] =
476           $form->format_amount(\%myconfig, $form->{$idx}->[$i], $places);
477       }
478     }
479   }
480
481   $myconfig{"numberformat"} = $saved_numberformat;
482
483   $main::lxdebug->leave_sub();
484 }
485
486 # -------------------------------------------------------------------------
487
488 sub show_history {
489   $main::lxdebug->enter_sub();
490
491   my $form     = $main::form;
492   my %myconfig = %main::myconfig;
493   my $locale   = $main::locale;
494
495   my $dbh = $form->dbconnect(\%myconfig);
496   my ($sort, $sortby) = split(/\-\-/, $form->{order});
497   $sort =~ s/.*\.(.*)/$1/;
498
499   $form->{title} = $locale->text("History");
500   $form->header();
501   print $form->parse_html_template( "common/show_history", {
502     "DATEN"        => $form->get_history($dbh,$form->{input_name},"",$form->{order}),
503     "SUCCESS"      => ($form->get_history($dbh,$form->{input_name}) ne "0"),
504     uc($sort)      => 1,
505     uc($sort)."BY" => $sortby
506   } );
507
508   $dbh->disconnect();
509   $main::lxdebug->leave_sub();
510 }
511
512 # -------------------------------------------------------------------------
513
514 sub call_sub {
515   $main::lxdebug->enter_sub();
516
517   my $name = shift;
518
519   my $form     = $main::form;
520   my $locale   = $main::locale;
521
522   if (!$name) {
523     $form->error($locale->text("Trying to call a sub without a name"));
524   }
525
526   $name =~ s/[^a-zA-Z0-9_]//g;
527
528   if (!defined(&{ $name })) {
529     $form->error(sprintf($locale->text("Attempt to call an undefined sub named '%s'"), $name));
530   }
531
532   $::called_subs{$name}++;
533   confess "RECURSION DETECTION: call_sub($name) called " . $::called_subs{$name} . " time(s)" if $::called_subs{$name} > 10;
534
535   {
536     no strict "refs";
537     &{ $name }(@_);
538   }
539
540   $main::lxdebug->leave_sub();
541 }
542
543 # -------------------------------------------------------------------------
544
545 sub show_vc_details {
546   $main::lxdebug->enter_sub();
547
548   my $form     = $main::form;
549   my %myconfig = %main::myconfig;
550   my $locale   = $main::locale;
551
552   $form->{vc} = $form->{vc} eq "customer" ? "customer" : "vendor";
553   $form->isblank("vc_id",
554                  $form->{vc} eq "customer" ?
555                  $locale->text("No customer has been selected yet.") :
556                  $locale->text("No vendor has been selected yet."));
557
558   Common->get_vc_details(\%myconfig, $form, $form->{vc}, $form->{vc_id});
559
560   $form->{title} = $form->{vc} eq "customer" ?
561     $locale->text("Customer details") : $locale->text("Vendor details");
562   $form->header();
563   print $form->parse_html_template("common/show_vc_details", { "is_customer" => $form->{vc} eq "customer" });
564
565   $main::lxdebug->leave_sub();
566 }
567
568 # -------------------------------------------------------------------------
569
570 sub retrieve_partunits {
571   $main::lxdebug->enter_sub();
572
573   my $form     = $main::form;
574
575   my @part_ids = grep { $_ } map { $form->{"id_${_}"} } (1..$form->{rowcount});
576
577   if (@part_ids) {
578     my %partunits = IO->retrieve_partunits('part_ids' => \@part_ids);
579
580     foreach my $i (1..$form->{rowcount}) {
581       next unless ($form->{"id_${i}"});
582       $form->{"partunit_${i}"} = $partunits{$form->{"id_${i}"}};
583     }
584   }
585
586   $main::lxdebug->leave_sub();
587 }
588
589 # -------------------------------------------------------------------------
590
591 sub mark_as_paid_common {
592   $main::lxdebug->enter_sub();
593
594   my ($myconfig, $db_name) = @_;
595
596   my $form     = $main::form;
597   my $locale   = $main::locale;
598
599   if($form->{mark_as_paid}) {
600     my $dbh ||= $form->get_standard_dbh($myconfig);
601     my $query = qq|UPDATE $db_name SET paid = amount, datepaid = current_date WHERE id = ?|;
602     do_query($form, $dbh, $query, $form->{id});
603     $dbh->commit();
604     $form->redirect($locale->text("Marked as paid"));
605
606   } else {
607     my $referer = $ENV{HTTP_REFERER};
608     my $script;
609     my $callback;
610     if ($referer =~ /action/) {
611       $referer =~ /^(.*)\?action\=[^\&]*(\&.*)$/;
612       $script = $1;
613       $callback = $2;
614     } else {
615       $script = $referer;
616       $callback = "";
617     }
618     $referer = $script . "?action=mark_as_paid&mark_as_paid=1&id=$form->{id}" . $callback;
619     $form->header();
620     print qq|<body>|;
621     print qq|<p><b>|.$locale->text('Mark as paid?').qq|</b></p>|;
622     print qq|<input type="button" value="|.$locale->text('yes').qq|" onclick="document.location.href='|.$referer.qq|'">&nbsp;|;
623     print qq|<input type="button" value="|.$locale->text('no').qq|" onclick="javascript:history.back();">|;
624     print qq|</body></html>|;
625   }
626
627   $main::lxdebug->leave_sub();
628 }
629
630 sub cov_selection_internal {
631   $main::lxdebug->enter_sub();
632
633   my $form     = $main::form;
634   my %myconfig = %main::myconfig;
635   my $locale   = $main::locale;
636
637   my $order_by = "name";
638   $order_by = $form->{"order_by"} if (defined($form->{"order_by"}));
639   my $order_dir = 1;
640   $order_dir = $form->{"order_dir"} if (defined($form->{"order_dir"}));
641
642   my $type = $form->{"is_vendor"} ? $locale->text("vendor") : $locale->text("customer");
643
644   my $covs = Common->retrieve_customers_or_vendors(\%myconfig, $form, $order_by, $order_dir, $form->{"is_vendor"}, $form->{"allow_both"});
645   map({ $covs->[$_]->{"selected"} = $_ ? 0 : 1; } (0..$#{$covs}));
646
647   my $onload;
648   if (0 == scalar(@{$covs})) {
649     $form->show_generic_information(sprintf($locale->text("No %s was found matching the search parameters."), $type));
650   } elsif (1 == scalar(@{$covs})) {
651     $onload = "cov_selected('1')";
652   }
653
654   my $callback = "$form->{script}?action=cov_selection_internal&";
655   map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
656       (qw(name input_name input_id is_vendor allow_both), grep({ /^[fl]_/ } keys %$form)));
657
658   my @header_sort = qw(name address contact);
659   my %header_title = ( "name" => $locale->text("Name"),
660                        "address" => $locale->text("Address"),
661                        "contact" => $locale->text("Contact"),
662                        );
663
664   my @header =
665     map(+{ "column_title" => $header_title{$_},
666            "column" => $_,
667            "callback" => $callback . "order_by=${_}&order_dir=" . ($order_by eq $_ ? 1 - $order_dir : $order_dir),
668          },
669         @header_sort);
670
671   foreach my $cov (@{ $covs }) {
672     $cov->{address} = "$cov->{street}, $cov->{zipcode} $cov->{city}";
673     $cov->{address} =~ s{^,}{}x;
674     $cov->{address} =~ s{\ +}{\ }gx;
675
676     $cov->{contact} = join " ", map { $cov->{$_} } qw(cp_gender cp_title cp_givenname cp_name);
677     $cov->{contact} =~ s{\ +}{\ }gx;
678   }
679
680   $form->{"title"} = $form->{is_vendor} ? $locale->text("Select a vendor") : $locale->text("Select a customer");
681   $form->header();
682   print($form->parse_html_template("generic/cov_selection", { "HEADER" => \@header,
683                                                               "COVS" => $covs,
684                                                               "onload" => $onload }));
685
686   $main::lxdebug->leave_sub();
687 }
688
689
690 # Functions to call add routines beneath different reports
691
692 sub sales_invoice {
693   $main::lxdebug->enter_sub();
694
695   print $::form->redirect_header('is.pl?action=add&type=invoice');
696
697   $main::lxdebug->leave_sub();
698 }
699
700 sub ar_transaction {
701   $main::lxdebug->enter_sub();
702
703   print $::form->redirect_header('ar.pl?action=add');
704
705   $main::lxdebug->leave_sub();
706 }
707
708 sub vendor_invoice {
709   $main::lxdebug->enter_sub();
710
711   print $::form->redirect_header('ir.pl?action=add&type=invoice');
712
713   $main::lxdebug->leave_sub();
714 }
715
716 sub ap_transaction {
717   $main::lxdebug->enter_sub();
718
719   print $::form->redirect_header('ap.pl?action=add');
720
721   $main::lxdebug->leave_sub();
722 }
723
724 sub gl_transaction {
725   $main::lxdebug->enter_sub();
726
727   print $::form->redirect_header('gl.pl?action=add');
728
729   $main::lxdebug->leave_sub();
730 }
731
732 sub db {
733   goto &SL::DB::Helper::Mappings::db;
734 }
735
736 1;