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 $form->{selectcustomer} = "$form->{customer}--$form->{customer_id}";
178 if ($form->{all_departments}) {
179 $form->{selectdepartment} = "<option>\n";
180 $form->{department} = "$form->{department}--$form->{department_id}";
183 $form->{selectdepartment} .=
184 "<option>$_->{description}--$_->{id}</option>\n"
185 } (@{ $form->{all_departments} });
188 $form->{employee} = "$form->{employee}--$form->{employee_id}";
191 $form->{forex} = $form->{exchangerate};
192 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
194 foreach $key (keys %{ $form->{AR_links} }) {
195 foreach $ref (@{ $form->{AR_links}{$key} }) {
196 $form->{"select$key"} .=
197 "<option>$ref->{accno}--$ref->{description}</option>\n";
200 if ($key eq "AR_paid") {
201 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
202 $form->{"AR_paid_$i"} =
203 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
206 $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
207 $form->{"datepaid_$i"} =
208 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
209 $form->{"forex_$i"} = $form->{"exchangerate_$i"} =
210 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
211 $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
212 $form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
214 $form->{paidaccounts} = $i;
218 "$form->{acc_trans}{$key}->[0]->{accno}--$form->{acc_trans}{$key}->[0]->{description}";
223 $form->{paidaccounts} = 1 unless (exists $form->{paidaccounts});
225 $form->{AR} = $form->{AR_1} unless $form->{id};
228 ($form->datetonum($form->{invdate}, \%myconfig) <=
229 $form->datetonum($form->{closedto}, \%myconfig));
231 $lxdebug->leave_sub();
234 sub prepare_invoice {
235 $lxdebug->enter_sub();
237 if ($form->{type} eq "credit_note") {
238 $form->{type} = "credit_note";
239 $form->{formname} = "credit_note";
241 $form->{type} = "invoice";
242 $form->{formname} = "invoice";
247 map { $form->{$_} =~ s/\"/"/g }
248 qw(invnumber ordnumber quonumber shippingpoint shipvia notes intnotes);
250 # # get pricegroups for parts
251 # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
255 foreach $ref (@{ $form->{invoice_details} }) {
258 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
259 $form->{"discount_$i"} =
260 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
261 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
263 $decimalplaces = ($dec > 2) ? $dec : 2;
265 $form->{"sellprice_$i"} =
266 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
269 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
270 $dec_qty = length $dec_qty;
273 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
275 map { $form->{"${_}_$i"} =~ s/\"/"/g }
276 qw(partnumber description unit partnotes);
277 $form->{rowcount} = $i;
281 $lxdebug->leave_sub();
285 $lxdebug->enter_sub();
289 if ($form->{type} eq "credit_note") {
290 $form->{title} = $locale->text('Edit Credit Note');
292 if ($form->{storno}) {
293 $form->{title} = $locale->text('Edit Storno Credit Note');
296 $form->{title} = $locale->text('Edit Sales Invoice');
298 if ($form->{storno}) {
299 $form->{title} = $locale->text('Edit Storno Invoice');
305 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
307 $payment = qq|<option value=""></option>|;
308 foreach $item (@{ $form->{payment_terms} }) {
309 if ($form->{payment_id} eq $item->{id}) {
310 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
312 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
316 my $set_duedate_url =
317 "$form->{script}?login=$form->{login}&password=$form->{password}&action=set_duedate";
319 my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
320 push(@ { $form->{AJAX} }, $pjx);
322 my @old_project_ids = ($form->{"globalproject_id"});
323 map({ push(@old_project_ids, $form->{"project_id_$_"})
324 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
326 $form->get_lists("contacts" => "ALL_CONTACTS",
327 "shipto" => "ALL_SHIPTO",
328 "projects" => { "key" => "ALL_PROJECTS",
330 "old_id" => \@old_project_ids },
331 "employees" => "ALL_SALESMEN",
332 "taxzones" => "ALL_TAXZONES",
333 "currencies" => "ALL_CURRENCIES",
334 "customers" => "ALL_CUSTOMERS");
337 my @values = (undef);
338 foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
339 push(@values, $item->{"cp_id"});
340 $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
341 ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
344 if (scalar @values > 1) {
347 <th align="right">| . $locale->text('Contact Person') . qq|</th>
349 NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
350 '-labels' => \%labels, '-default' => $form->{"cp_id"}))
358 foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
359 push(@values, $item->{"id"});
360 $labels{$item->{"id"}} = $item->{"name"};
365 <th align="right">| . $locale->text('Employee') . qq|</th>
367 NTI($cgi->popup_menu('-name' => 'employee', '-default' => $form->{"employee_id"},
368 '-values' => \@values, '-labels' => \%labels)) . qq|
375 foreach my $item (@{ $form->{"ALL_CUSTOMERS"} }) {
376 push(@values, $item->{name}.qq|--|.$item->{"id"});
377 $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"};
381 <th align="right">| . $locale->text('Customer') . qq|</th>
383 (($myconfig{vclimit} <= scalar(@values))
384 ? qq|<input type="text" value="| . H($form->{"oldcustomer"}) . qq|" name="customer">|
385 : (NTI($cgi->popup_menu('-name' => 'customer', '-default' => $form->{oldcustomer},
386 '-onChange' => 'document.getElementById(\'update_button\').click();',
387 '-values' => \@values, '-labels' => \%labels)))) . qq|
392 foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
393 push(@values, $item->{"shipto_id"});
394 $labels{$item->{"shipto_id"}} =
395 $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"};
399 if (scalar @values > 1) {
402 <th align="right">| . $locale->text('Shipping Address') . qq|</th>
404 NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
405 '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
411 foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) {
412 push(@values, $item);
413 $labels{$item} = $item;
416 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
418 if (scalar @values) {
421 <th align="right">| . $locale->text('Currency') . qq|</th>
423 NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
424 '-values' => \@values, '-labels' => \%labels)) . qq|
431 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
432 push(@values, $item->{"id"});
433 $labels{$item->{"id"}} = $item->{"projectnumber"};
435 my $globalprojectnumber =
436 NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
437 '-labels' => \%labels,
438 '-default' => $form->{"globalproject_id"}));
442 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
443 push(@values, $item->{id});
444 $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
449 <th align="right">| . $locale->text('Salesman') . qq|</th>
451 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
452 '-values' => \@values, '-labels' => \%labels))
458 foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
459 push(@values, $item->{"id"});
460 $labels{$item->{"id"}} = $item->{"description"};
463 if (!$form->{"id"}) {
466 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
468 NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
469 '-values' => \@values, '-labels' => \%labels)) . qq|
476 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
478 <input type="hidden" name="taxzone_id" value="| . H($form->{"taxzone_id"}) . qq|">
479 | . H($labels{$form->{"taxzone_id"}}) . qq|
484 # set option selected
485 foreach $item (qw(AR customer currency department employee)) {
486 $form->{"select$item"} =~ s/ selected//;
487 $form->{"select$item"} =~
488 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
491 #quote customer Bug 133
492 $form->{selectcustomer} = $form->quote($form->{selectcustomer});
494 #substitute \n and \r to \s (bug 543)
495 $form->{selectcustomer} =~ s/[\n\r]/ /g;
497 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
503 $form->{exchangerate} =
504 $form->format_amount(\%myconfig, $form->{exchangerate});
506 $form->{creditlimit} =
507 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
508 $form->{creditremaining} =
509 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
512 if ($form->{currency} ne $form->{defaultcurrency}) {
513 if ($form->{forex}) {
515 qq|<th align="right">|
516 . $locale->text('Exchangerate')
517 . qq|</th><td>$form->{exchangerate}<input type="hidden" name="exchangerate" value="$form->{exchangerate}"></td>|;
520 qq|<th align="right">|
521 . $locale->text('Exchangerate')
522 . qq|</th><td><input name="exchangerate" size="10" value="$form->{exchangerate}"></td>|;
526 <input type="hidden" name="forex" value="$form->{forex}">
531 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
532 <td colspan="3"><select name="department">$form->{selectdepartment}</select>
533 <input type="hidden" name="selectdepartment" value="$form->{selectdepartment}">
536 | if $form->{selectdepartment};
538 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
540 if ($form->{business}) {
543 <th align="right">| . $locale->text('Business') . qq|</th>
544 <td>$form->{business}</td>
545 <th align="right">| . $locale->text('Trade Discount') . qq|</th>
547 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
553 if ($form->{max_dunning_level}) {
556 <th align="right">| . $locale->text('Max. Dunning Level') . qq|:</th>
558 <b>$form->{max_dunning_level}</b>;
559 | . $locale->text('Dunning Amount') . qq|: <b>|
560 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
567 $form->{fokus} = "invoice.customer";
569 # use JavaScript Calendar or not
570 $form->{jsscript} = 1;
572 if ($form->{type} eq "credit_note") {
574 <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
575 <input type="button" name="invdate" id="trigger1" value="|
576 . $locale->text('button') . qq|"></td>|;
580 Form->write_trigger(\%myconfig, "1",
585 <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
586 <input type="button" name="invdate" id="trigger1" value="|
587 . $locale->text('button') . qq|"></td>
590 <td width="13"><input name="duedate" id="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\">
591 <input type="button" name="duedate" id="trigger2" value="|
592 . $locale->text('button') . qq|"></td></td>
595 <td width="13"><input name="deliverydate" id="deliverydate" size="11" title="$myconfig{dateformat}" value="$form->{deliverydate}" onBlur=\"check_right_date_format(this)\">
596 <input type="button" name="deliverydate" id="trigger3" value="|
597 . $locale->text('button') . qq|"></td></td>
602 Form->write_trigger(\%myconfig, "3",
604 "trigger1", "duedate",
606 "deliverydate", "BL",
610 if ($form->{resubmit} && ($form->{format} eq "html")) {
612 qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|;
613 } elsif ($form->{resubmit}) {
614 $onload = qq|document.invoice.submit()|;
618 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
619 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
620 $credittext = $locale->text('Credit Limit exceeded!!!');
621 if ($creditwarning) {
622 $onload = qq|alert('$credittext')|;
625 $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
628 $form->write_trigger(\%myconfig, 2,
629 "orddate", "BL", "trigger_orddate",
630 "quodate", "BL", "trigger_quodate");
631 # show history button js
632 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
633 #/show history button js
637 <body onLoad="$onload">
638 <script type="text/javascript" src="js/common.js"></script>
639 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
640 <script type="text/javascript" src="js/vendor_selection.js"></script>
641 <script type="text/javascript" src="js/calculate_qty.js"></script>
643 <form method="post" name="invoice" action="$form->{script}">
645 map({print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});}
646 qw(id action type media format queued printed emailed title vc discount
647 creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id)) ;
648 print ($form->{saved_message} ? qq|<p>$form->{saved_message}</p>| : "") ;
651 <input type="hidden" name="lizenzen" value="$lizenzen">
653 <div class="listtop" width="100%">$form->{title}</div>
661 <input type="hidden" name="customer_klass" value="$form->{customer_klass}">
662 <input type="hidden" name="customer_id" value="$form->{customer_id}">
663 <input type="hidden" name="oldcustomer" value="$form->{oldcustomer}">
664 <input type="hidden" name="selectcustomer" value="1">
669 <td align="right">| . $locale->text('Credit Limit') . qq|</td>
670 <td>$form->{creditlimit}; | . $locale->text('Remaining') . qq| <span class="plus$n">$form->{creditremaining}</span></td>
675 <th align="right" nowrap>| . $locale->text('Record in') . qq|</th>
676 <td colspan="3"><select name="AR" style="width:280px;">$form->{selectAR}</select></td>
677 <input type="hidden" name="selectAR" value="$form->{selectAR}">
683 <input type="hidden" name="fxgain_accno" value="$form->{fxgain_accno}">
684 <input type="hidden" name="fxloss_accno" value="$form->{fxloss_accno}">
688 <th align="right" nowrap>| . $locale->text('Shipping Point') . qq|</th>
690 $cgi->textfield("-name" => "shippingpoint", "-size" => 35, "-value" => $form->{shippingpoint}) .
693 <th align="right" nowrap>| . $locale->text('Ship via') . qq|</th>
694 <td colspan="3"><input name="shipvia" size="35" value="$form->{shipvia}"></td>
697 <th align="right">| . $locale->text('Transaction description') . qq|</th>
698 <td colspan="3">| . $cgi->textfield("-name" => "transaction_description", "-size" => 35, "-value" => $form->{transaction_description}) . qq|</td>
705 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
707 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
708 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
712 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
714 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
715 # <input size=45 id=delivery_vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
722 <td align="right" valign="top">
727 if ($form->{type} eq "credit_note") {
729 <th align="right" nowrap>| . $locale->text('Credit Note Number') . qq|</th>
730 <td><input name="invnumber" size="11" value="$form->{invnumber}"></td>
733 <th align="right">| . $locale->text('Credit Note Date') . qq|</th>
738 <th align="right" nowrap>| . $locale->text('Invoice Number') . qq|</th>
739 <td><input name="invnumber" size="11" value="$form->{invnumber}"></td>
742 <th align="right">| . $locale->text('Invoice Date') . qq|</th>
746 <th align="right">| . $locale->text('Due Date') . qq|</th>
750 <th align="right">| . $locale->text('Delivery Date') . qq|</th>
755 <th align="right" nowrap>| . $locale->text('Order Number') . qq|</th>
756 <td><input name="ordnumber" size="11" value="$form->{ordnumber}"></td>
759 <th align="right" nowrap>| . $locale->text('Order Date') . qq|</th>
760 <td><input name="orddate" id="orddate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{orddate}) . qq|" onBlur=\"check_right_date_format(this)\">
761 <input type="button" name="b_orddate" id="trigger_orddate" value="?"></td>
764 <th align="right" nowrap>| . $locale->text('Quotation Number') . qq|</th>
765 <td><input name="quonumber" size="11" value="$form->{quonumber}"></td>
768 <th align="right" nowrap>| . $locale->text('Quotation Date') . qq|</th>
769 <td><input name="quodate" id="quodate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{quodate}) . qq|" onBlur=\"check_right_date_format(this)\">
770 <input type="button" name="b_quodate" id="trigger_quodate" value="?"></td>
773 <th align="right" nowrap>| . $locale->text('Customer Order Number') . qq|</th>
774 <td><input name="cusordnumber" size="11" value="$form->{cusordnumber}"></td>
777 <th align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
778 <td>$globalprojectnumber</td>
793 <!-- shipto are in hidden variables -->
795 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
796 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2));
797 print qq|<!-- email variables --> |;
798 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
799 qw(message email subject cc bcc taxaccounts));
800 print qq|<input type="hidden" name="webdav" value="| . $webdav . qq|">|;
802 foreach $item (split(/ /, $form->{taxaccounts})) {
803 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
804 ("${item}_rate", "${item}_description", "${item}_taxnumber"));
806 $lxdebug->leave_sub();
810 $lxdebug->enter_sub();
812 $form->{invtotal} = $form->{invsubtotal};
814 if (($rows = $form->numtextrows($form->{notes}, 26, 8)) < 2) {
817 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
820 $rows = ($rows > $introws) ? $rows : $introws;
822 qq|<textarea name="notes" rows="$rows" cols="26" wrap="soft">$form->{notes}</textarea>|;
824 qq|<textarea name="intnotes" rows="$rows" cols="35" wrap="soft">$form->{intnotes}</textarea>|;
826 $form->{taxincluded} = ($form->{taxincluded} ? "checked" : "");
829 if ($form->{taxaccounts}) {
831 <input name="taxincluded" class="checkbox" type="checkbox" $form->{taxincluded}> <b>|
832 . $locale->text('Tax Included') . qq|</b><br><br>|;
835 if (!$form->{taxincluded}) {
837 foreach $item (split / /, $form->{taxaccounts}) {
838 if ($form->{"${item}_base"}) {
839 $form->{"${item}_total"} =
841 $form->{"${item}_base"} * $form->{"${item}_rate"},
843 $form->{invtotal} += $form->{"${item}_total"};
844 $form->{"${item}_total"} =
845 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
849 <th align="right">$form->{"${item}_description"} |
850 . $form->{"${item}_rate"} * 100 .qq|%</th>
851 <td align="right">$form->{"${item}_total"}</td>
857 $form->{invsubtotal} =
858 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
862 <th align="right">| . $locale->text('Subtotal') . qq|</th>
863 <td align="right">$form->{invsubtotal}</td>
869 if ($form->{taxincluded}) {
870 foreach $item (split / /, $form->{taxaccounts}) {
871 if ($form->{"${item}_base"}) {
872 $form->{"${item}_total"} =
874 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
875 (1 + $form->{"${item}_rate"})
878 $form->{"${item}_netto"} =
880 ($form->{"${item}_base"} - $form->{"${item}_total"}),
882 $form->{"${item}_total"} =
883 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
884 $form->{"${item}_netto"} =
885 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
889 <th align="right">Enthaltene $form->{"${item}_description"} |
890 . $form->{"${item}_rate"} * 100 .qq|%</th>
891 <td align="right">$form->{"${item}_total"}</td>
894 <th align="right">Nettobetrag</th>
895 <td align="right">$form->{"${item}_netto"}</td>
903 $form->{oldinvtotal} = $form->{invtotal};
905 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
915 <th align="left">| . $locale->text('Notes') . qq|</th>
916 <th align="left">| . $locale->text('Internal Notes') . qq|</th>
917 <th align="right">| . $locale->text('Payment Terms') . qq|</th>
922 <td><select name="payment_id" onChange="if (this.value) set_duedate(['payment_id__' + this.value],['duedate'])">$payment
927 <td align="right" width="100%">
933 <th align="right">| . $locale->text('Total') . qq|</th>
934 <td align="right">$form->{invtotal}</td>
946 <td><hr size="3" noshade></td>
949 <th class="listtop" align="left">Dokumente im Webdav-Repository</th>
952 <td align="left" width="30%"><b>Dateiname</b></td>
953 <td align="left" width="70%"><b>Webdavlink</b></td>
955 foreach $file (keys %{ $form->{WEBDAV} }) {
958 <td align="left">$file</td>
959 <td align="left"><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
970 if ($form->{type} eq "credit_note") {
975 <tr class="listheading">
976 <th colspan="6" class="listheading">|
977 . $locale->text('Payments') . qq|</th>
985 <tr class="listheading">
986 <th colspan="6" class="listheading">|
987 . $locale->text('Incoming Payments') . qq|</th>
992 if ($form->{currency} eq $form->{defaultcurrency}) {
993 @column_index = qw(datepaid source memo paid AR_paid);
995 @column_index = qw(datepaid source memo paid exchangerate AR_paid);
998 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
999 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
1000 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
1001 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
1002 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
1003 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
1008 map { print "$column_data{$_}\n" } @column_index;
1015 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
1016 for $i (1 .. $form->{paidaccounts}) {
1021 $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
1022 $form->{"selectAR_paid_$i"} =~
1023 s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/;
1026 $totalpaid += $form->{"paid_$i"};
1027 if ($form->{"paid_$i"}) {
1028 $form->{"paid_$i"} =
1029 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
1031 $form->{"exchangerate_$i"} =
1032 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
1034 $exchangerate = qq| |;
1035 if ($form->{currency} ne $form->{defaultcurrency}) {
1036 if ($form->{"forex_$i"}) {
1037 $exchangerate = qq|<input type="hidden" name="exchangerate_$i" value="$form->{"exchangerate_$i"}">$form->{"exchangerate_$i"}|;
1039 $exchangerate = qq|<input name="exchangerate_$i" size="10" value="$form->{"exchangerate_$i"}">|;
1043 $exchangerate .= qq|<input type="hidden" name="forex_$i" value="$form->{"forex_$i"}">|;
1045 $column_data{"paid_$i"} =
1046 qq|<td align="center"><input name="paid_$i" size="11" value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
1047 $column_data{"exchangerate_$i"} = qq|<td align="center">$exchangerate</td>|;
1048 $column_data{"AR_paid_$i"} =
1049 qq|<td align="center"><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
1050 $column_data{"datepaid_$i"} =
1051 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)\">
1052 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
1053 $column_data{"source_$i"} =
1054 qq|<td align=center><input name="source_$i" size="11" value="$form->{"source_$i"}"></td>|;
1055 $column_data{"memo_$i"} =
1056 qq|<td align="center"><input name="memo_$i" size="11" value="$form->{"memo_$i"}"></td>|;
1058 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
1061 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
1064 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal));
1065 print qq|<input type="hidden" name="oldtotalpaid" value="$totalpaid">
1070 <td><hr size="3" noshade></td>
1084 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
1085 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1088 my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ar");
1091 <input class="submit" type="submit" accesskey="u" name="action" id="update_button" value="|
1092 . $locale->text('Update') . qq|">
1093 <input class="submit" type="submit" name="action" value="|
1094 . $locale->text('Ship to') . qq|">
1095 <input class="submit" type="submit" name="action" value="|
1096 . $locale->text('Print') . qq|">
1097 <input class="submit" type="submit" name="action" value="|
1098 . $locale->text('E-mail') . qq|"> |;
1099 print qq|<input class="submit" type="submit" name="action" value="|
1100 . $locale->text('Storno') . qq|"> | if ($show_storno);
1101 print qq|<input class="submit" type="submit" name="action" value="|
1102 . $locale->text('Post Payment') . qq|">
1104 print qq|<input class="submit" type="submit" name="action" value="|
1105 . $locale->text('Use As Template') . qq|">
1107 if ($form->{id} && !($form->{type} eq "credit_note")) {
1109 <input class="submit" type="submit" name="action" value="|
1110 . $locale->text('Credit Note') . qq|">
1113 if ($form->{radier}) {
1115 <input class="submit" type="submit" name="action" value="|
1116 . $locale->text('Delete') . qq|">
1121 if ($invdate > $closedto) {
1123 <input class="submit" type="submit" name="action" value="|
1124 . $locale->text('Order') . qq|">
1129 if ($invdate > $closedto) {
1130 print qq|<input class="submit" type="submit" name="action" id="update_button" value="|
1131 . $locale->text('Update') . qq|">
1132 <input class="submit" type="submit" name="action" value="|
1133 . $locale->text('Ship to') . qq|">
1134 <input class="submit" type="submit" name="action" value="|
1135 . $locale->text('Preview') . qq|">
1136 <input class="submit" type="submit" name="action" value="|
1137 . $locale->text('E-mail') . qq|">
1138 <input class="submit" type="submit" name="action" value="|
1139 . $locale->text('Print and Post') . qq|">
1140 <input class="submit" type="submit" name="action" value="|
1141 . $locale->text('Post') . qq|"> | .
1142 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
1143 '-class' => 'submit'));
1147 # button for saving history
1148 if($form->{id} ne "") {
1150 <input type="button" class="submit" onclick="set_history_window(|
1152 . qq|);" name="history" id="history" value="|
1153 . $locale->text('history')
1156 # /button for saving history
1159 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
1162 <input type="hidden" name="rowcount" value="$form->{rowcount}">
1164 $cgi->hidden("-name" => "callback", "-value" => $form->{callback})
1165 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
1166 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
1167 map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(login password));
1176 $lxdebug->leave_sub();
1180 $lxdebug->enter_sub();
1182 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1183 qw(exchangerate creditlimit creditremaining);
1184 if ($form->{second_run}) {
1185 $form->{print_and_post} = 0;
1189 if($form->{taxincluded}) {
1190 $taxincluded = "checked";
1192 $form->{update} = 1;
1194 &check_name(customer);
1196 if(!$form->{taxincluded}) {
1197 $form->{taxincluded} = $taxincluded;
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 $form->{invnumber} =~ s/^\s*//g;
1389 $form->{invnumber} =~ s/\s*$//g;
1391 # if oldcustomer ne customer redo form
1392 if (&check_name(customer)) {
1396 if ($form->{second_run}) {
1397 $form->{print_and_post} = 0;
1402 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1403 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
1405 $form->error($locale->text('Cannot post invoice for a closed period!'))
1406 if ($invdate <= $closedto);
1408 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1409 if ($form->{currency} ne $form->{defaultcurrency});
1411 for $i (1 .. $form->{paidaccounts}) {
1412 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1413 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1415 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1417 $form->error($locale->text('Cannot post payment for a closed period!'))
1418 if ($datepaid <= $closedto);
1420 if ($form->{currency} ne $form->{defaultcurrency}) {
1421 $form->{"exchangerate_$i"} = $form->{exchangerate}
1422 if ($invdate == $datepaid);
1423 $form->isblank("exchangerate_$i",
1424 $locale->text('Exchangerate for payment missing!'));
1429 ($form->{AR}) = split /--/, $form->{AR};
1430 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1432 $form->{label} = $locale->text('Invoice');
1434 $form->{id} = 0 if $form->{postasnew};
1436 # get new invnumber in sequence if no invnumber is given or if posasnew was requested
1437 if ($form->{postasnew}) {
1438 if ($form->{type} eq "credit_note") {
1439 undef($form->{cnnumber});
1441 undef($form->{invnumber});
1446 $form->error($locale->text('Cannot post invoice!'))
1447 unless IS->post_invoice(\%myconfig, \%$form);
1448 remove_draft() if $form->{remove_draft};
1450 if(!exists $form->{addition}) {
1451 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1452 $form->{addition} = $print_post ? "PRINTED AND POSTED" :
1453 $form->{storno} ? "STORNO" :
1455 $form->save_history($form->dbconnect(\%myconfig));
1458 $form->redirect( $form->{label} . " $form->{invnumber} " . $locale->text('posted!'))
1461 $lxdebug->leave_sub();
1464 sub print_and_post {
1465 $lxdebug->enter_sub();
1467 $old_form = new Form;
1469 $form->{print_and_post} = 1;
1473 $lxdebug->leave_sub();
1477 sub use_as_template {
1478 $lxdebug->enter_sub();
1480 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);
1481 $form->{paidaccounts} = 1;
1482 $form->{rowcount}--;
1483 $form->{invdate} = $form->current_date(\%myconfig);
1486 $lxdebug->leave_sub();
1490 $lxdebug->enter_sub();
1492 if ($form->{storno}) {
1493 $form->error($locale->text('Cannot storno storno invoice!'));
1496 if (IS->has_storno(\%myconfig, $form, "ar")) {
1497 $form->error($locale->text("Invoice has already been storno'd!"));
1500 map({ my $key = $_; delete($form->{$key})
1501 unless (grep({ $key eq $_ } qw(login password id stylesheet type))); }
1508 # Payments must not be recorded for the new storno invoice.
1509 $form->{paidaccounts} = 0;
1510 map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form };
1512 $form->{storno_id} = $form->{id};
1513 $form->{storno} = 1;
1515 $form->{invnumber} = "Storno zu " . $form->{invnumber};
1516 $form->{rowcount}++;
1519 $lxdebug->leave_sub();
1523 $lxdebug->enter_sub();
1525 $form->{preview} = 1;
1526 $old_form = new Form;
1527 for (keys %$form) { $old_form->{$_} = $form->{$_} }
1528 $old_form->{rowcount}++;
1530 &print_form($old_form);
1531 $lxdebug->leave_sub();
1536 $lxdebug->enter_sub();
1537 if ($form->{second_run}) {
1538 $form->{print_and_post} = 0;
1545 <form method="post" action="$form->{script}">
1548 # delete action variable
1549 map { delete $form->{$_} } qw(action header);
1551 foreach $key (keys %$form) {
1552 $form->{$key} =~ s/\"/"/g;
1553 print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|;
1557 <h2 class="confirm">| . $locale->text('Confirm!') . qq|</h2>
1560 . $locale->text('Are you sure you want to delete Invoice Number')
1561 . qq| $form->{invnumber}
1565 <input name="action" class="submit" type="submit" value="|
1566 . $locale->text('Yes') . qq|">
1570 $lxdebug->leave_sub();
1574 $lxdebug->enter_sub();
1576 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1578 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1581 $form->{rowcount}--;
1582 $form->{shipto} = 1;
1585 $form->{title} = $locale->text('Add Credit Note');
1586 $form->{script} = 'is.pl';
1591 # bo creates the id, reset it
1592 map { delete $form->{$_} }
1593 qw(id invnumber subject message cc bcc printed emailed queued);
1594 $form->{ $form->{vc} } =~ s/--.*//g;
1595 $form->{type} = "credit_note";
1598 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1600 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1601 qw(creditlimit creditremaining);
1603 $currency = $form->{currency};
1606 $form->{currency} = $currency;
1607 $form->{exchangerate} = "";
1608 $form->{forex} = "";
1609 $form->{exchangerate} = $exchangerate
1613 $form->check_exchangerate(
1614 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
1617 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1624 $lxdebug->leave_sub();
1628 $lxdebug->enter_sub();
1629 if (IS->delete_invoice(\%myconfig, \%$form, $spool)) {
1630 # saving the history
1631 if(!exists $form->{addition}) {
1632 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1633 $form->{addition} = "DELETED";
1634 $form->save_history($form->dbconnect(\%myconfig));
1636 # /saving the history
1637 $form->redirect($locale->text('Invoice deleted!'));
1639 $form->error($locale->text('Cannot delete invoice!'));
1641 $lxdebug->leave_sub();
1645 $lxdebug->enter_sub();
1650 my $saved_form = save_form();
1655 map({ $saved_vars{$_} = $form->{$_}; } qw(id invnumber));
1656 restore_form($saved_form);
1657 map({ $form->{$_} = $saved_vars{$_}; } qw(id invnumber));
1662 $lxdebug->leave_sub();