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 #======================================================================
30 # Inventory invoicing module
32 #======================================================================
38 require "bin/mozilla/io.pl";
39 require "bin/mozilla/arap.pl";
40 require "bin/mozilla/drafts.pl";
47 $lxdebug->enter_sub();
49 return $lxdebug->leave_sub() if (load_draft_maybe());
51 if ($form->{type} eq "credit_note") {
52 $form->{title} = $locale->text('Add Credit Note');
54 if ($form->{storno}) {
55 $form->{title} = $locale->text('Add Storno Credit Note');
58 $form->{title} = $locale->text('Add Sales Invoice');
64 "$form->{script}?action=add&type=$form->{type}&login=$form->{login}&password=$form->{password}"
65 unless $form->{callback};
67 $form{jsscript} = "date";
69 if ($myconfig{acs} =~ "AR--Add Sales Invoice" || $myconfig{acs} =~ "AR--AR")
71 $form->error("Access Denied");
77 $lxdebug->leave_sub();
81 $lxdebug->enter_sub();
84 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
85 #/show hhistory button
87 if ($myconfig{acs} =~ "AR--Add Sales Invoice" || $myconfig{acs} =~ "AR--AR")
89 $form->error("Access Denied");
92 if ($form->{print_and_post}) {
93 $form->{action} = "print";
94 $form->{resubmit} = 1;
95 $language_id = $form->{language_id};
96 $printer_id = $form->{printer_id};
100 if ($form->{print_and_post}) {
101 $form->{language_id} = $language_id;
102 $form->{printer_id} = $printer_id;
107 $lxdebug->leave_sub();
111 $lxdebug->enter_sub();
113 $form->{vc} = 'customer';
116 $form->{webdav} = $webdav;
117 $form->{lizenzen} = $lizenzen;
119 $form->create_links("AR", \%myconfig, "customer");
121 if ($form->{all_customer}) {
122 unless ($form->{customer_id}) {
123 $form->{customer_id} = $form->{all_customer}->[0]->{id};
124 $form->{salesman_id} = $form->{all_customer}->[0]->{salesman_id};
128 if ($form->{payment_id}) {
129 $payment_id = $form->{payment_id};
131 if ($form->{language_id}) {
132 $language_id = $form->{language_id};
134 if ($form->{taxzone_id}) {
135 $taxzone_id = $form->{taxzone_id};
140 if ($form->{shipto_id}) {
141 $shipto_id = $form->{shipto_id};
144 $cp_id = $form->{cp_id};
145 IS->get_customer(\%myconfig, \%$form);
147 #quote all_customer Bug 133
148 foreach $ref (@{ $form->{all_customer} }) {
149 $ref->{name} = $form->quote($ref->{name});
154 IS->retrieve_invoice(\%myconfig, \%$form);
155 $form->{cp_id} = $cp_id;
158 $form->{payment_id} = $payment_id;
161 $form->{language_id} = $language_id;
164 $form->{taxzone_id} = $taxzone_id;
167 $form->{shipto_id} = $shipto_id;
170 $form->{oldcustomer} = "$form->{customer}--$form->{customer_id}";
172 if (@{ $form->{all_customer} }) {
173 $form->{customer} = "$form->{customer}--$form->{customer_id}";
174 map { $form->{selectcustomer} .= "<option>$_->{name}--$_->{id}</option>\n" }
175 (@{ $form->{all_customer} });
179 if ($form->{all_departments}) {
180 $form->{selectdepartment} = "<option>\n";
181 $form->{department} = "$form->{department}--$form->{department_id}";
184 $form->{selectdepartment} .=
185 "<option>$_->{description}--$_->{id}</option>\n"
186 } (@{ $form->{all_departments} });
189 $form->{employee} = "$form->{employee}--$form->{employee_id}";
192 if ($form->{all_employees}) {
193 $form->{selectemployee} = "";
194 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}</option>\n" }
195 (@{ $form->{all_employees} });
199 $form->{forex} = $form->{exchangerate};
200 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
202 foreach $key (keys %{ $form->{AR_links} }) {
203 foreach $ref (@{ $form->{AR_links}{$key} }) {
204 $form->{"select$key"} .=
205 "<option>$ref->{accno}--$ref->{description}</option>\n";
208 if ($key eq "AR_paid") {
209 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
210 $form->{"AR_paid_$i"} =
211 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
214 $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
215 $form->{"datepaid_$i"} =
216 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
217 $form->{"forex_$i"} = $form->{"exchangerate_$i"} =
218 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
219 $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
220 $form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
222 $form->{paidaccounts} = $i;
226 "$form->{acc_trans}{$key}->[0]->{accno}--$form->{acc_trans}{$key}->[0]->{description}";
231 $form->{paidaccounts} = 1 unless (exists $form->{paidaccounts});
233 $form->{AR} = $form->{AR_1} unless $form->{id};
236 ($form->datetonum($form->{invdate}, \%myconfig) <=
237 $form->datetonum($form->{closedto}, \%myconfig));
239 $lxdebug->leave_sub();
242 sub prepare_invoice {
243 $lxdebug->enter_sub();
245 if ($form->{type} eq "credit_note") {
246 $form->{type} = "credit_note";
247 $form->{formname} = "credit_note";
249 $form->{type} = "invoice";
250 $form->{formname} = "invoice";
255 map { $form->{$_} =~ s/\"/"/g }
256 qw(invnumber ordnumber quonumber shippingpoint shipvia notes intnotes);
258 # # get pricegroups for parts
259 # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
263 foreach $ref (@{ $form->{invoice_details} }) {
266 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
267 $form->{"discount_$i"} =
268 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
269 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
271 $decimalplaces = ($dec > 2) ? $dec : 2;
273 $form->{"sellprice_$i"} =
274 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
277 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
278 $dec_qty = length $dec_qty;
281 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
283 map { $form->{"${_}_$i"} =~ s/\"/"/g }
284 qw(partnumber description unit partnotes);
285 $form->{rowcount} = $i;
289 $lxdebug->leave_sub();
293 $lxdebug->enter_sub();
297 if ($form->{type} eq "credit_note") {
298 $form->{title} = $locale->text('Edit Credit Note');
300 if ($form->{storno}) {
301 $form->{title} = $locale->text('Edit Storno Credit Note');
304 $form->{title} = $locale->text('Edit Sales Invoice');
306 if ($form->{storno}) {
307 $form->{title} = $locale->text('Edit Storno Invoice');
313 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
315 $payment = qq|<option value=""></option>|;
316 foreach $item (@{ $form->{payment_terms} }) {
317 if ($form->{payment_id} eq $item->{id}) {
318 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
320 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
324 my $set_duedate_url =
325 "$form->{script}?login=$form->{login}&password=$form->{password}&action=set_duedate";
327 my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
328 push(@ { $form->{AJAX} }, $pjx);
330 my @old_project_ids = ($form->{"globalproject_id"});
331 map({ push(@old_project_ids, $form->{"project_id_$_"})
332 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
334 $form->get_lists("contacts" => "ALL_CONTACTS",
335 "shipto" => "ALL_SHIPTO",
336 "projects" => { "key" => "ALL_PROJECTS",
338 "old_id" => \@old_project_ids },
339 "employees" => "ALL_SALESMEN",
340 "taxzones" => "ALL_TAXZONES",
341 "currencies" => "ALL_CURRENCIES");
344 my @values = (undef);
345 foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
346 push(@values, $item->{"cp_id"});
347 $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
348 ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
351 NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
352 '-labels' => \%labels, '-default' => $form->{"cp_id"}));
356 foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
357 push(@values, $item->{"shipto_id"});
358 $labels{$item->{"shipto_id"}} =
359 $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"};
363 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
365 NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
366 '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
371 foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) {
372 push(@values, $item);
373 $labels{$item} = $item;
376 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
379 <th align="right">| . $locale->text('Currency') . qq|</th>
381 NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
382 '-values' => \@values, '-labels' => \%labels)) . qq|
388 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
389 push(@values, $item->{"id"});
390 $labels{$item->{"id"}} = $item->{"projectnumber"};
392 my $globalprojectnumber =
393 NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
394 '-labels' => \%labels,
395 '-default' => $form->{"globalproject_id"}));
399 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
400 push(@values, $item->{id});
401 $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
406 <th align="right">| . $locale->text('Salesman') . qq|</th>
408 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
409 '-values' => \@values, '-labels' => \%labels))
415 foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
416 push(@values, $item->{"id"});
417 $labels{$item->{"id"}} = $item->{"description"};
420 if (!$form->{"id"}) {
423 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
425 NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
426 '-values' => \@values, '-labels' => \%labels)) . qq|
433 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
435 <input type="hidden" name="taxzone_id" value="| . H($form->{"taxzone_id"}) . qq|">
436 | . H($labels{$form->{"taxzone_id"}}) . qq|
441 # set option selected
442 foreach $item (qw(AR customer currency department employee)) {
443 $form->{"select$item"} =~ s/ selected//;
444 $form->{"select$item"} =~
445 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
448 #quote customer Bug 133
449 $form->{selectcustomer} = $form->quote($form->{selectcustomer});
451 #substitute \n and \r to \s (bug 543)
452 $form->{selectcustomer} =~ s/[\n\r]/ /g;
454 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
460 $form->{exchangerate} =
461 $form->format_amount(\%myconfig, $form->{exchangerate});
463 $form->{creditlimit} =
464 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
465 $form->{creditremaining} =
466 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
469 if ($form->{currency} ne $form->{defaultcurrency}) {
470 if ($form->{forex}) {
472 qq|<th align="right">|
473 . $locale->text('Exchangerate')
474 . qq|</th><td>$form->{exchangerate}<input type="hidden" name="exchangerate" value="$form->{exchangerate}"></td>|;
477 qq|<th align="right">|
478 . $locale->text('Exchangerate')
479 . qq|</th><td><input name="exchangerate" size="10" value="$form->{exchangerate}"></td>|;
483 <input type="hidden" name="forex" value="$form->{forex}">
487 ($form->{selectcustomer})
488 ? qq|<select name="customer"
489 onchange="document.getElementById('update_button').click();">| .
490 qq|$form->{selectcustomer}</select>\n<input type="hidden" name="selectcustomer" value="| .
491 Q($form->{selectcustomer}) . qq|">|
492 : qq|<input name="customer" value="$form->{customer}" size="35">|;
496 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
497 <td colspan="3"><select name="department">$form->{selectdepartment}</select>
498 <input type="hidden" name="selectdepartment" value="$form->{selectdepartment}">
501 | if $form->{selectdepartment};
503 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
505 if ($form->{business}) {
508 <th align="right">| . $locale->text('Business') . qq|</th>
509 <td>$form->{business}</td>
510 <th align="right">| . $locale->text('Trade Discount') . qq|</th>
512 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
518 if ($form->{max_dunning_level}) {
524 <th align="right">| . $locale->text('Max. Dunning Level') . qq|:</th>
525 <td><b>$form->{max_dunning_level}</b></td>
526 <th align="right">| . $locale->text('Dunning Amount') . qq|:</th>
528 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
537 $form->{fokus} = "invoice.customer";
539 # use JavaScript Calendar or not
540 $form->{jsscript} = $jscalendar;
542 if ($form->{type} eq "credit_note") {
543 if ($form->{jsscript}) {
545 # with JavaScript Calendar
547 <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>
548 <td><input type="button" name="invdate" id="trigger1" value="|
549 . $locale->text('button') . qq|"></td>|;
553 Form->write_trigger(\%myconfig, "1",
558 # without JavaScript Calendar
560 qq|<td><input name="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>|;
562 qq|<td width="13"><input name="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}"></td>|;
565 if ($form->{jsscript}) {
567 # with JavaScript Calendar
569 <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>
570 <td><input type="button" name="invdate" id="trigger1" value="|
571 . $locale->text('button') . qq|"></td>
574 <td width="13"><input name="duedate" id="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\"></td>
575 <td width="4"><input type="button" name="duedate" id="trigger2" value="|
576 . $locale->text('button') . qq|"></td></td>
579 <td width="13"><input name="deliverydate" id="deliverydate" size="11" title="$myconfig{dateformat}" value="$form->{deliverydate}" onBlur=\"check_right_date_format(this)\"></td>
580 <td width="4"><input type="button" name="deliverydate" id="trigger3" value="|
581 . $locale->text('button') . qq|"></td></td>
586 Form->write_trigger(\%myconfig, "3",
588 "trigger1", "duedate",
590 "deliverydate", "BL",
594 # without JavaScript Calendar
596 qq|<td><input name="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"></td>|;
598 qq|<td width="13"><input name=duedate size=11 title="$myconfig{dateformat}" value=$form->{duedate} onBlur=\"check_right_date_format(this)\"></td>|;
601 if ($form->{resubmit} && ($form->{format} eq "html")) {
603 qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|;
604 } elsif ($form->{resubmit}) {
605 $onload = qq|document.invoice.submit()|;
609 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
610 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
611 $credittext = $locale->text('Credit Limit exceeded!!!');
612 if ($creditwarning) {
613 $onload = qq|alert('$credittext')|;
616 $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
619 $form->write_trigger(\%myconfig, 2,
620 "orddate", "BL", "trigger_orddate",
621 "quodate", "BL", "trigger_quodate");
622 # show history button js
623 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
624 #/show history button js
628 <body onLoad="$onload">
629 <script type="text/javascript" src="js/common.js"></script>
630 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
631 <script type="text/javascript" src="js/vendor_selection.js"></script>
632 <script type="text/javascript" src="js/calculate_qty.js"></script>
634 <form method="post" name="invoice" action="$form->{script}">
636 map({print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});}
637 qw(id action type media format queued printed emailed title vc discount
638 creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id)) ;
639 print ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") ;
642 <input type="hidden" name="lizenzen" value="$lizenzen">
646 <th class="listtop">$form->{title}</th>
656 <th align="right" nowrap>| . $locale->text('Customer') . qq|</th>
657 <td colspan="3">$customer</td>
658 <input type="hidden" name="customer_klass" value="$form->{customer_klass}">
659 <input type="hidden" name="customer_id" value="$form->{customer_id}">
660 <input type="hidden" name="oldcustomer" value="$form->{oldcustomer}">
661 <th align="right" nowrap>|
662 . $locale->text('Contact Person') . qq|</th>
663 <td colspan="3">$contact</td>
670 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
671 <td>$form->{creditlimit}</td>
672 <td width="20%"></td>
673 <th nowrap>| . $locale->text('Remaining') . qq|</th>
674 <td class="plus$n">$form->{creditremaining}</td>
683 <th align="right" nowrap>| . $locale->text('Record in') . qq|</th>
684 <td colspan="3"><select name="AR" style="width:280px;">$form->{selectAR}</select></td>
685 <input type="hidden" name="selectAR" value="$form->{selectAR}">
691 <input type="hidden" name="fxgain_accno" value="$form->{fxgain_accno}">
692 <input type="hidden" name="fxloss_accno" value="$form->{fxloss_accno}">
696 <th align="right" nowrap>| . $locale->text('Shipping Point') . qq|</th>
698 $cgi->textfield("-name" => "shippingpoint", "-size" => 35, "-value" => $form->{shippingpoint}) .
701 <th align="right" nowrap>| . $locale->text('Ship via') . qq|</th>
702 <td colspan="3"><input name="shipvia" size="35" value="$form->{shipvia}"></td>
709 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
711 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
712 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
716 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
718 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
719 # <input size=45 id=delivery_vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
729 <th align="right" nowrap>| . $locale->text('Employee') . qq|</th>
730 <td colspan="2"><select name="employee">$form->{selectemployee}</select></td>
731 <input type="hidden" name="selectemployee" value="$form->{selectemployee}">
736 if ($form->{type} eq "credit_note") {
738 <th align="right" nowrap>| . $locale->text('Credit Note Number') . qq|</th>
739 <td><input name="invnumber" size="11" value="$form->{invnumber}"></td>
742 <th align="right">| . $locale->text('Credit Note Date') . qq|</th>
747 <th align="right" nowrap>| . $locale->text('Invoice Number') . qq|</th>
748 <td><input name="invnumber" size="11" value="$form->{invnumber}"></td>
751 <th align="right">| . $locale->text('Invoice Date') . qq|</th>
755 <th align="right">| . $locale->text('Due Date') . qq|</th>
759 <th align="right">| . $locale->text('Delivery Date') . qq|</th>
764 <th align="right" nowrap>| . $locale->text('Order Number') . qq|</th>
765 <td><input name="ordnumber" size="11" value="$form->{ordnumber}"></td>
768 <th align="right" nowrap>| . $locale->text('Order Date') . qq|</th>
769 <td><input name="orddate" id="orddate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{orddate}) . qq|" onBlur=\"check_right_date_format(this)\"></td>
770 <td><input type="button" name="b_orddate" id="trigger_orddate" value="?"></td>
773 <th align="right" nowrap>| . $locale->text('Quotation Number') . qq|</th>
774 <td><input name="quonumber" size="11" value="$form->{quonumber}"></td>
777 <th align="right" nowrap>| . $locale->text('Quotation Date') . qq|</th>
778 <td><input name="quodate" id="quodate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{quodate}) . qq|" onBlur=\"check_right_date_format(this)\"></td>
779 <td><input type="button" name="b_quodate" id="trigger_quodate" value="?"></td>
782 <th align="right" nowrap>| . $locale->text('Customer Order Number') . qq|</th>
783 <td><input name="cusordnumber" size="11" value="$form->{cusordnumber}"></td>
786 <th align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
787 <td>$globalprojectnumber</td>
802 <!-- shipto are in hidden variables -->
804 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
805 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2));
806 print qq|<!-- email variables --> |;
807 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
808 qw(message email subject cc bcc taxaccounts));
809 print qq|<input type="hidden" name="webdav" value="| . $webdav . qq|">|;
811 foreach $item (split(/ /, $form->{taxaccounts})) {
812 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
813 ("${item}_rate", "${item}_description", "${item}_taxnumber"));
815 $lxdebug->leave_sub();
819 $lxdebug->enter_sub();
821 $form->{invtotal} = $form->{invsubtotal};
823 if (($rows = $form->numtextrows($form->{notes}, 26, 8)) < 2) {
826 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
829 $rows = ($rows > $introws) ? $rows : $introws;
831 qq|<textarea name="notes" rows="$rows" cols="26" wrap="soft">$form->{notes}</textarea>|;
833 qq|<textarea name="intnotes" rows="$rows" cols="35" wrap="soft">$form->{intnotes}</textarea>|;
835 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
838 if ($form->{taxaccounts}) {
840 <input name="taxincluded" class="checkbox" type="checkbox" value=$form->{taxincluded}> <b>|
841 . $locale->text('Tax Included') . qq|</b><br><br>|;
844 if (!$form->{taxincluded}) {
846 foreach $item (split / /, $form->{taxaccounts}) {
847 if ($form->{"${item}_base"}) {
848 $form->{"${item}_total"} =
850 $form->{"${item}_base"} * $form->{"${item}_rate"},
852 $form->{invtotal} += $form->{"${item}_total"};
853 $form->{"${item}_total"} =
854 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
858 <th align="right">$form->{"${item}_description"} |
859 . $form->{"${item}_rate"} * 100 .qq|%</th>
860 <td align="right">$form->{"${item}_total"}</td>
866 $form->{invsubtotal} =
867 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
871 <th align="right">| . $locale->text('Subtotal') . qq|</th>
872 <td align="right">$form->{invsubtotal}</td>
878 if ($form->{taxincluded}) {
879 foreach $item (split / /, $form->{taxaccounts}) {
880 if ($form->{"${item}_base"}) {
881 $form->{"${item}_total"} =
883 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
884 (1 + $form->{"${item}_rate"})
887 $form->{"${item}_netto"} =
889 ($form->{"${item}_base"} - $form->{"${item}_total"}),
891 $form->{"${item}_total"} =
892 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
893 $form->{"${item}_netto"} =
894 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
898 <th align="right">Enthaltene $form->{"${item}_description"} |
899 . $form->{"${item}_rate"} * 100 .qq|%</th>
900 <td align="right">$form->{"${item}_total"}</td>
903 <th align="right">Nettobetrag</th>
904 <td align="right">$form->{"${item}_netto"}</td>
912 $form->{oldinvtotal} = $form->{invtotal};
914 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
924 <th align="left">| . $locale->text('Notes') . qq|</th>
925 <th align="left">| . $locale->text('Internal Notes') . qq|</th>
926 <th align="right">| . $locale->text('Payment Terms') . qq|</th>
931 <td><select name="payment_id" onChange="if (this.value) set_duedate(['payment_id__' + this.value],['duedate'])">$payment
936 <td align="right" width="100%">
942 <th align="right">| . $locale->text('Total') . qq|</th>
943 <td align="right">$form->{invtotal}</td>
955 <td><hr size="3" noshade></td>
958 <th class="listtop" align="left">Dokumente im Webdav-Repository</th>
961 <td align="left" width="30%"><b>Dateiname</b></td>
962 <td align="left" width="70%"><b>Webdavlink</b></td>
964 foreach $file (keys %{ $form->{WEBDAV} }) {
967 <td align="left">$file</td>
968 <td align="left"><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
979 if ($form->{type} eq "credit_note") {
984 <tr class="listheading">
985 <th colspan="6" class="listheading">|
986 . $locale->text('Payments') . qq|</th>
994 <tr class="listheading">
995 <th colspan="6" class="listheading">|
996 . $locale->text('Incoming Payments') . qq|</th>
1001 if ($form->{currency} eq $form->{defaultcurrency}) {
1002 @column_index = qw(datepaid source memo paid AR_paid);
1004 @column_index = qw(datepaid source memo paid exchangerate AR_paid);
1007 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
1008 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
1009 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
1010 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
1011 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
1012 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
1017 map { print "$column_data{$_}\n" } @column_index;
1024 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
1025 for $i (1 .. $form->{paidaccounts}) {
1030 $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
1031 $form->{"selectAR_paid_$i"} =~
1032 s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/;
1035 $totalpaid += $form->{"paid_$i"};
1036 if ($form->{"paid_$i"}) {
1037 $form->{"paid_$i"} =
1038 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
1040 $form->{"exchangerate_$i"} =
1041 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
1043 $exchangerate = qq| |;
1044 if ($form->{currency} ne $form->{defaultcurrency}) {
1045 if ($form->{"forex_$i"}) {
1046 $exchangerate = qq|<input type="hidden" name="exchangerate_$i" value="$form->{"exchangerate_$i"}">$form->{"exchangerate_$i"}|;
1048 $exchangerate = qq|<input name="exchangerate_$i" size="10" value="$form->{"exchangerate_$i"}">|;
1052 $exchangerate .= qq|<input type="hidden" name="forex_$i" value="$form->{"forex_$i"}">|;
1054 $column_data{"paid_$i"} =
1055 qq|<td align="center"><input name="paid_$i" size="11" value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
1056 $column_data{"exchangerate_$i"} = qq|<td align="center">$exchangerate</td>|;
1057 $column_data{"AR_paid_$i"} =
1058 qq|<td align="center"><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
1059 $column_data{"datepaid_$i"} =
1060 qq|<td align="center"><input id="datepaid_$i" name="datepaid_$i" size="11" title="$myconfig{dateformat}" value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
1061 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
1062 $column_data{"source_$i"} =
1063 qq|<td align=center><input name="source_$i" size="11" value="$form->{"source_$i"}"></td>|;
1064 $column_data{"memo_$i"} =
1065 qq|<td align="center"><input name="memo_$i" size="11" value="$form->{"memo_$i"}"></td>|;
1067 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
1070 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
1073 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal));
1074 print qq|<input type="hidden" name="oldtotalpaid" value="$totalpaid">
1079 <td><hr size="3" noshade></td>
1093 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
1094 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1097 my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ar");
1100 <input class="submit" type="submit" accesskey="u" name="action" id="update_button" value="|
1101 . $locale->text('Update') . qq|">
1102 <input class="submit" type="submit" name="action" value="|
1103 . $locale->text('Ship to') . qq|">
1104 <input class="submit" type="submit" name="action" value="|
1105 . $locale->text('Print') . qq|">
1106 <input class="submit" type="submit" name="action" value="|
1107 . $locale->text('E-mail') . qq|"> |;
1108 print qq|<input class="submit" type="submit" name="action" value="|
1109 . $locale->text('Storno') . qq|"> | if ($show_storno);
1110 print qq|<input class="submit" type="submit" name="action" value="|
1111 . $locale->text('Post Payment') . qq|">
1113 print qq|<input class="submit" type="submit" name="action" value="|
1114 . $locale->text('Use As Template') . qq|">
1116 if ($form->{id} && !($form->{type} eq "credit_note")) {
1118 <input class="submit" type="submit" name="action" value="|
1119 . $locale->text('Credit Note') . qq|">
1122 if ($form->{radier}) {
1124 <input class="submit" type="submit" name="action" value="|
1125 . $locale->text('Delete') . qq|">
1130 if ($invdate > $closedto) {
1132 <input class="submit" type="submit" name="action" value="|
1133 . $locale->text('Order') . qq|">
1138 if ($invdate > $closedto) {
1139 print qq|<input class="submit" type="submit" name="action" id="update_button" value="|
1140 . $locale->text('Update') . qq|">
1141 <input class="submit" type="submit" name="action" value="|
1142 . $locale->text('Ship to') . qq|">
1143 <input class="submit" type="submit" name="action" value="|
1144 . $locale->text('Preview') . qq|">
1145 <input class="submit" type="submit" name="action" value="|
1146 . $locale->text('E-mail') . qq|">
1147 <input class="submit" type="submit" name="action" value="|
1148 . $locale->text('Print and Post') . qq|">
1149 <input class="submit" type="submit" name="action" value="|
1150 . $locale->text('Post') . qq|"> | .
1151 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
1152 '-class' => 'submit'));
1156 # button for saving history
1157 if($form->{id} ne "") {
1159 <input type="button" class="submit" onclick="set_history_window(|
1161 . qq|);" name="history" id="history" value="|
1162 . $locale->text('history')
1165 # /button for saving history
1168 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
1171 <input type="hidden" name="rowcount" value="$form->{rowcount}">
1173 $cgi->hidden("-name" => "callback", "-value" => $form->{callback})
1174 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
1175 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
1176 map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(login password));
1185 $lxdebug->leave_sub();
1189 $lxdebug->enter_sub();
1191 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1192 qw(exchangerate creditlimit creditremaining);
1193 if ($form->{second_run}) {
1194 $form->{print_and_post} = 0;
1197 $form->{update} = 1;
1199 &check_name(customer);
1201 $form->{exchangerate} = $exchangerate
1205 $form->check_exchangerate(
1206 \%myconfig, $form->{currency}, $form->{invdate}, 'buy'
1209 for $i (1 .. $form->{paidaccounts}) {
1210 if ($form->{"paid_$i"}) {
1212 $form->{"${_}_$i"} =
1213 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
1214 } qw(paid exchangerate);
1216 $form->{"exchangerate_$i"} = $exchangerate
1218 $form->{"forex_$i"} = (
1220 $form->check_exchangerate(
1221 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
1226 $i = $form->{rowcount};
1227 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1229 # if last row empty, check the form otherwise retrieve new item
1230 if ( ($form->{"partnumber_$i"} eq "")
1231 && ($form->{"description_$i"} eq "")
1232 && ($form->{"partsgroup_$i"} eq "")) {
1234 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1239 IS->retrieve_item(\%myconfig, \%$form);
1241 $rows = scalar @{ $form->{item_list} };
1243 $form->{"discount_$i"} =
1244 $form->format_amount(\%myconfig, $form->{discount} * 100);
1247 $form->{"qty_$i"} = ($form->{"qty_$i"} * 1) ? $form->{"qty_$i"} : 1;
1256 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1258 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1259 qw(partnumber description unit);
1260 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1261 keys %{ $form->{item_list}[0] };
1262 if ($form->{"part_payment_id_$i"} ne "") {
1263 $form->{payment_id} = $form->{"part_payment_id_$i"};
1266 if ($form->{"not_discountable_$i"}) {
1267 $form->{"discount_$i"} = 0;
1270 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1271 ($dec) = ($s =~ /\.(\d+)/);
1273 $decimalplaces = ($dec > 2) ? $dec : 2;
1276 $form->{"sellprice_$i"} = $sellprice;
1279 # if there is an exchange rate adjust sellprice
1280 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1281 $form->{"sellprice_$i"} /= $exchangerate;
1284 $form->{"listprice_$i"} /= $exchangerate;
1287 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1288 (1 - $form->{"discount_$i"} / 100);
1289 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1290 map { $form->{"${_}_base"} += $amount }
1291 (split / /, $form->{"taxaccounts_$i"});
1292 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1293 split / /, $form->{"taxaccounts_$i"}
1294 if !$form->{taxincluded};
1296 $form->{creditremaining} -= $amount;
1299 $form->{"${_}_$i"} =
1300 $form->format_amount(\%myconfig, $form->{"${_}_$i"},
1302 } qw(sellprice listprice);
1305 $form->format_amount(\%myconfig, $form->{"qty_$i"});
1308 if ($form->{"inventory_accno_$i"} ne "") {
1309 $form->{"lizenzen_$i"} = qq|<option></option>|;
1310 foreach $item (@{ $form->{LIZENZEN}{ $form->{"id_$i"} } }) {
1311 $form->{"lizenzen_$i"} .=
1312 qq|<option value="$item->{"id"}">$item->{"licensenumber"}</option>|;
1314 $form->{"lizenzen_$i"} .=
1315 qq|<option value=-1>Neue Lizenz</option>|;
1319 # get pricegroups for parts
1320 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1322 # build up html code for prices_$i
1323 &set_pricegroup($i);
1330 # ok, so this is a new part
1331 # ask if it is a part or service item
1333 if ( $form->{"partsgroup_$i"}
1334 && ($form->{"partsnumber_$i"} eq "")
1335 && ($form->{"description_$i"} eq "")) {
1336 $form->{rowcount}--;
1337 $form->{"discount_$i"} = "";
1341 $form->{"id_$i"} = 0;
1342 $form->{"unit_$i"} = $locale->text('ea');
1349 $lxdebug->leave_sub();
1353 $lxdebug->enter_sub();
1354 for $i (1 .. $form->{paidaccounts}) {
1355 if ($form->{"paid_$i"}) {
1356 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1358 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1360 $form->error($locale->text('Cannot post payment for a closed period!'))
1361 if ($datepaid <= $closedto);
1363 if ($form->{currency} ne $form->{defaultcurrency}) {
1364 $form->{"exchangerate_$i"} = $form->{exchangerate}
1365 if ($invdate == $datepaid);
1366 $form->isblank("exchangerate_$i",
1367 $locale->text('Exchangerate for payment missing!'));
1372 ($form->{AR}) = split /--/, $form->{AR};
1373 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1375 $form->redirect($locale->text(' Payment posted!'))
1376 if (IS->post_payment(\%myconfig, \%$form));
1377 $form->error($locale->text('Cannot post payment!'));
1380 $lxdebug->leave_sub();
1384 $lxdebug->enter_sub();
1385 $form->isblank("invdate", $locale->text('Invoice Date missing!'));
1386 $form->isblank("customer", $locale->text('Customer missing!'));
1388 # if oldcustomer ne customer redo form
1389 if (&check_name(customer)) {
1393 if ($form->{second_run}) {
1394 $form->{print_and_post} = 0;
1399 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1400 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
1402 $form->error($locale->text('Cannot post invoice for a closed period!'))
1403 if ($invdate <= $closedto);
1405 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1406 if ($form->{currency} ne $form->{defaultcurrency});
1408 for $i (1 .. $form->{paidaccounts}) {
1409 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1410 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1412 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1414 $form->error($locale->text('Cannot post payment for a closed period!'))
1415 if ($datepaid <= $closedto);
1417 if ($form->{currency} ne $form->{defaultcurrency}) {
1418 $form->{"exchangerate_$i"} = $form->{exchangerate}
1419 if ($invdate == $datepaid);
1420 $form->isblank("exchangerate_$i",
1421 $locale->text('Exchangerate for payment missing!'));
1426 ($form->{AR}) = split /--/, $form->{AR};
1427 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1429 $form->{label} = $locale->text('Invoice');
1431 $form->{id} = 0 if $form->{postasnew};
1433 # get new invnumber in sequence if no invnumber is given or if posasnew was requested
1434 if ($form->{postasnew}) {
1435 if ($form->{type} eq "credit_note") {
1436 undef($form->{cnnumber});
1438 undef($form->{invnumber});
1443 $form->error($locale->text('Cannot post invoice!'))
1444 unless IS->post_invoice(\%myconfig, \%$form);
1445 remove_draft() if $form->{remove_draft};
1447 if(!exists $form->{addition}) {
1448 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1449 $form->{addition} = $print_post ? "PRINTED AND POSTED" :
1450 $form->{storno} ? "STORNO" :
1452 $form->save_history($form->dbconnect(\%myconfig));
1455 $form->redirect( $form->{label} . " $form->{invnumber} " . $locale->text('posted!'))
1458 $lxdebug->leave_sub();
1461 sub print_and_post {
1462 $lxdebug->enter_sub();
1464 $old_form = new Form;
1466 $form->{print_and_post} = 1;
1470 $lxdebug->leave_sub();
1474 sub use_as_template {
1475 $lxdebug->enter_sub();
1477 map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
1478 $form->{paidaccounts} = 1;
1479 $form->{rowcount}--;
1480 $form->{invdate} = $form->current_date(\%myconfig);
1483 $lxdebug->leave_sub();
1487 $lxdebug->enter_sub();
1489 if ($form->{storno}) {
1490 $form->error($locale->text('Cannot storno storno invoice!'));
1493 if (IS->has_storno(\%myconfig, $form, "ar")) {
1494 $form->error($locale->text("Invoice has already been storno'd!"));
1497 map({ my $key = $_; delete($form->{$key})
1498 unless (grep({ $key eq $_ } qw(login password id type))); }
1505 $form->{storno_id} = $form->{id};
1506 $form->{storno} = 1;
1508 $form->{invnumber} = "Storno zu " . $form->{invnumber};
1511 $lxdebug->leave_sub();
1516 $lxdebug->enter_sub();
1518 $form->{preview} = 1;
1519 $old_form = new Form;
1520 for (keys %$form) { $old_form->{$_} = $form->{$_} }
1521 $old_form->{rowcount}++;
1523 &print_form($old_form);
1524 $lxdebug->leave_sub();
1529 $lxdebug->enter_sub();
1530 if ($form->{second_run}) {
1531 $form->{print_and_post} = 0;
1538 <form method="post" action="$form->{script}">
1541 # delete action variable
1542 map { delete $form->{$_} } qw(action header);
1544 foreach $key (keys %$form) {
1545 $form->{$key} =~ s/\"/"/g;
1546 print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|;
1550 <h2 class="confirm">| . $locale->text('Confirm!') . qq|</h2>
1553 . $locale->text('Are you sure you want to delete Invoice Number')
1554 . qq| $form->{invnumber}
1558 <input name="action" class="submit" type="submit" value="|
1559 . $locale->text('Yes') . qq|">
1563 $lxdebug->leave_sub();
1567 $lxdebug->enter_sub();
1569 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1571 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1574 $form->{rowcount}--;
1575 $form->{shipto} = 1;
1578 $form->{title} = $locale->text('Add Credit Note');
1579 $form->{script} = 'is.pl';
1584 # bo creates the id, reset it
1585 map { delete $form->{$_} }
1586 qw(id invnumber subject message cc bcc printed emailed queued);
1587 $form->{ $form->{vc} } =~ s/--.*//g;
1588 $form->{type} = "credit_note";
1591 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1593 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1594 qw(creditlimit creditremaining);
1596 $currency = $form->{currency};
1599 $form->{currency} = $currency;
1600 $form->{exchangerate} = "";
1601 $form->{forex} = "";
1602 $form->{exchangerate} = $exchangerate
1606 $form->check_exchangerate(
1607 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
1610 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1617 $lxdebug->leave_sub();
1621 $lxdebug->enter_sub();
1622 if (IS->delete_invoice(\%myconfig, \%$form, $spool)) {
1623 # saving the history
1624 if(!exists $form->{addition}) {
1625 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1626 $form->{addition} = "DELETED";
1627 $form->save_history($form->dbconnect(\%myconfig));
1629 # /saving the history
1630 $form->redirect($locale->text('Invoice deleted!'));
1632 $form->error($locale->text('Cannot delete invoice!'));
1634 $lxdebug->leave_sub();
1638 $lxdebug->enter_sub();
1643 my $saved_form = save_form();
1648 map({ $saved_vars{$_} = $form->{$_}; } qw(id invnumber));
1649 restore_form($saved_form);
1650 map({ $form->{$_} = $saved_vars{$_}; } qw(id invnumber));
1655 $lxdebug->leave_sub();