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}";
173 if ($form->{all_departments}) {
174 $form->{selectdepartment} = "<option>\n";
175 $form->{department} = "$form->{department}--$form->{department_id}";
178 $form->{selectdepartment} .=
179 "<option>$_->{description}--$_->{id}</option>\n"
180 } (@{ $form->{all_departments} });
183 $form->{employee} = "$form->{employee}--$form->{employee_id}";
186 $form->{forex} = $form->{exchangerate};
187 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
189 foreach $key (keys %{ $form->{AR_links} }) {
190 foreach $ref (@{ $form->{AR_links}{$key} }) {
191 $form->{"select$key"} .=
192 "<option>$ref->{accno}--$ref->{description}</option>\n";
195 if ($key eq "AR_paid") {
196 for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
197 $form->{"AR_paid_$i"} =
198 "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
201 $form->{"paid_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
202 $form->{"datepaid_$i"} =
203 $form->{acc_trans}{$key}->[$i - 1]->{transdate};
204 $form->{"forex_$i"} = $form->{"exchangerate_$i"} =
205 $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
206 $form->{"source_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{source};
207 $form->{"memo_$i"} = $form->{acc_trans}{$key}->[$i - 1]->{memo};
209 $form->{paidaccounts} = $i;
213 "$form->{acc_trans}{$key}->[0]->{accno}--$form->{acc_trans}{$key}->[0]->{description}";
218 $form->{paidaccounts} = 1 unless (exists $form->{paidaccounts});
220 $form->{AR} = $form->{AR_1} unless $form->{id};
223 ($form->datetonum($form->{invdate}, \%myconfig) <=
224 $form->datetonum($form->{closedto}, \%myconfig));
226 $lxdebug->leave_sub();
229 sub prepare_invoice {
230 $lxdebug->enter_sub();
232 if ($form->{type} eq "credit_note") {
233 $form->{type} = "credit_note";
234 $form->{formname} = "credit_note";
236 $form->{type} = "invoice";
237 $form->{formname} = "invoice";
242 map { $form->{$_} =~ s/\"/"/g }
243 qw(invnumber ordnumber quonumber shippingpoint shipvia notes intnotes);
245 # # get pricegroups for parts
246 # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
250 foreach $ref (@{ $form->{invoice_details} }) {
253 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
254 $form->{"discount_$i"} =
255 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
256 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
258 $decimalplaces = ($dec > 2) ? $dec : 2;
260 $form->{"sellprice_$i"} =
261 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
264 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
265 $dec_qty = length $dec_qty;
268 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
270 map { $form->{"${_}_$i"} =~ s/\"/"/g }
271 qw(partnumber description unit partnotes);
272 $form->{rowcount} = $i;
276 $lxdebug->leave_sub();
280 $lxdebug->enter_sub();
282 if ($form->{old_employee_id}) {
283 $form->{employee_id} = $form->{old_employee_id};
285 if ($form->{old_salesman_id}) {
286 $form->{salesman_id} = $form->{old_salesman_id};
291 if ($form->{type} eq "credit_note") {
292 $form->{title} = $locale->text('Edit Credit Note');
294 if ($form->{storno}) {
295 $form->{title} = $locale->text('Edit Storno Credit Note');
298 $form->{title} = $locale->text('Edit Sales Invoice');
300 if ($form->{storno}) {
301 $form->{title} = $locale->text('Edit Storno Invoice');
305 $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
307 ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
309 $payment = qq|<option value=""></option>|;
310 foreach $item (@{ $form->{payment_terms} }) {
311 if ($form->{payment_id} eq $item->{id}) {
312 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
314 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
318 my $set_duedate_url =
319 "$form->{script}?login=$form->{login}&password=$form->{password}&action=set_duedate";
321 my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
322 push(@ { $form->{AJAX} }, $pjx);
324 my @old_project_ids = ($form->{"globalproject_id"});
325 map({ push(@old_project_ids, $form->{"project_id_$_"})
326 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
328 $form->get_lists("contacts" => "ALL_CONTACTS",
329 "shipto" => "ALL_SHIPTO",
330 "projects" => { "key" => "ALL_PROJECTS",
332 "old_id" => \@old_project_ids },
333 "employees" => "ALL_SALESMEN",
334 "taxzones" => "ALL_TAXZONES",
335 "currencies" => "ALL_CURRENCIES",
336 "customers" => "ALL_CUSTOMERS");
339 my @values = (undef);
340 foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
341 push(@values, $item->{"cp_id"});
342 $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
343 ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
346 if (scalar @values > 1) {
349 <th align="right">| . $locale->text('Contact Person') . qq|</th>
351 NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px',
352 '-labels' => \%labels, '-default' => $form->{"cp_id"}))
360 foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
361 push(@values, $item->{"id"});
362 $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
367 <th align="right">| . $locale->text('Employee') . qq|</th>
369 NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
370 '-values' => \@values, '-labels' => \%labels)) . qq|
377 foreach my $item (@{ $form->{"ALL_CUSTOMERS"} }) {
378 push(@values, $item->{name}.qq|--|.$item->{"id"});
379 $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"};
382 $form->{selectcustomer} = ($myconfig{vclimit} > scalar(@values));
385 <th align="right">| . $locale->text('Customer') . qq|</th>
387 (($myconfig{vclimit} <= scalar(@values))
388 ? qq|<input type="text" value="| . H($form->{customer}) . qq|" name="customer">|
389 : (NTI($cgi->popup_menu('-name' => 'customer', '-default' => $form->{oldcustomer},
390 '-onChange' => 'document.getElementById(\'update_button\').click();',
391 '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq|
392 <input type="button" value="?" onclick="show_vc_details('customer')">
397 foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
398 push(@values, $item->{"shipto_id"});
399 $labels{$item->{"shipto_id"}} = join "; ", grep { $_ } map { $item->{"shipto${_}" } } qw(name department_1 street city);
403 if (scalar @values > 1) {
406 <th align="right">| . $locale->text('Shipping Address') . qq|</th>
408 NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, '-style' => 'width: 250px',
409 '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
415 foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) {
416 push(@values, $item);
417 $labels{$item} = $item;
420 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
422 if (scalar @values) {
425 <th align="right">| . $locale->text('Currency') . qq|</th>
427 NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
428 '-values' => \@values, '-labels' => \%labels)) . qq|
435 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
436 push(@values, $item->{"id"});
437 $labels{$item->{"id"}} = $item->{"projectnumber"};
439 my $globalprojectnumber =
440 NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
441 '-labels' => \%labels,
442 '-default' => $form->{"globalproject_id"}));
446 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
447 push(@values, $item->{id});
448 $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
453 <th align="right">| . $locale->text('Salesman') . qq|</th>
455 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id} ? $form->{salesman_id} : $form->{employee_id},
456 '-values' => \@values, '-labels' => \%labels))
462 foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
463 push(@values, $item->{"id"});
464 $labels{$item->{"id"}} = $item->{"description"};
467 if (!$form->{"id"}) {
470 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
472 NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
473 '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px',)) . qq|
480 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
482 <input type="hidden" name="taxzone_id" value="| . H($form->{"taxzone_id"}) . qq|">
483 | . H($labels{$form->{"taxzone_id"}}) . qq|
488 # set option selected
489 foreach $item (qw(AR customer currency department employee)) {
490 $form->{"select$item"} =~ s/ selected//;
491 $form->{"select$item"} =~
492 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
495 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
501 $form->{exchangerate} =
502 $form->format_amount(\%myconfig, $form->{exchangerate});
504 $form->{creditlimit} =
505 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
506 $form->{creditremaining} =
507 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
510 if ($form->{currency} ne $form->{defaultcurrency}) {
511 if ($form->{forex}) {
513 qq|<th align="right">|
514 . $locale->text('Exchangerate')
515 . qq|</th><td>$form->{exchangerate}<input type="hidden" name="exchangerate" value="$form->{exchangerate}"></td>|;
518 qq|<th align="right">|
519 . $locale->text('Exchangerate')
520 . qq|</th><td><input name="exchangerate" size="10" value="$form->{exchangerate}"></td>|;
524 <input type="hidden" name="forex" value="$form->{forex}">
529 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
530 <td colspan="3"><select name="department" style="width: 250px">$form->{selectdepartment}</select>
531 <input type="hidden" name="selectdepartment" value="$form->{selectdepartment}">
534 | if $form->{selectdepartment};
536 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
538 if ($form->{business}) {
541 <th align="right">| . $locale->text('Customer type') . qq|</th>
542 <td>$form->{business}; | . $locale->text('Trade Discount') . qq| |
543 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
549 if ($form->{max_dunning_level}) {
552 <th align="right">| . $locale->text('Max. Dunning Level') . qq|:</th>
554 <b>$form->{max_dunning_level}</b>;
555 | . $locale->text('Dunning Amount') . qq|: <b>|
556 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
563 $form->{fokus} = "invoice.customer";
565 # use JavaScript Calendar or not
566 $form->{jsscript} = 1;
568 if ($form->{type} eq "credit_note") {
570 <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
571 <input type="button" name="invdate" id="trigger1" value="|
572 . $locale->text('button') . qq|"></td>|;
576 Form->write_trigger(\%myconfig, "1",
581 <td><input name="invdate" id="invdate" size="11" title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
582 <input type="button" name="invdate" id="trigger1" value="|
583 . $locale->text('button') . qq|"></td>
586 <td width="13"><input name="duedate" id="duedate" size="11" title="$myconfig{dateformat}" value="$form->{duedate}" onBlur=\"check_right_date_format(this)\">
587 <input type="button" name="duedate" id="trigger2" value="|
588 . $locale->text('button') . qq|"></td></td>
591 <td width="13"><input name="deliverydate" id="deliverydate" size="11" title="$myconfig{dateformat}" value="$form->{deliverydate}" onBlur=\"check_right_date_format(this)\">
592 <input type="button" name="deliverydate" id="trigger3" value="|
593 . $locale->text('button') . qq|"></td></td>
598 Form->write_trigger(\%myconfig, "3",
600 "trigger1", "duedate",
602 "deliverydate", "BL",
606 if ($form->{resubmit} && ($form->{format} eq "html")) {
608 qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|;
609 } elsif ($form->{resubmit}) {
610 $onload = qq|document.invoice.submit()|;
614 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
615 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
616 $credittext = $locale->text('Credit Limit exceeded!!!');
617 if ($creditwarning) {
618 $onload = qq|alert('$credittext')|;
621 $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
622 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
625 $form->write_trigger(\%myconfig, 2,
626 "orddate", "BL", "trigger_orddate",
627 "quodate", "BL", "trigger_quodate");
628 # show history button js
629 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
630 #/show history button js
634 <body onLoad="$onload">
635 <script type="text/javascript" src="js/common.js"></script>
636 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
637 <script type="text/javascript" src="js/vendor_selection.js"></script>
638 <script type="text/javascript" src="js/calculate_qty.js"></script>
640 <form method="post" name="invoice" action="$form->{script}">
643 $form->hide_form(qw(id action type media format queued printed emailed title vc discount
644 creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id
645 max_dunning_level dunning_amount));
646 print qq|<p>$form->{saved_message}</p>| if $form->{saved_message};
650 <input type="hidden" name="lizenzen" value="$lizenzen">
652 <div class="listtop" width="100%">$form->{title}</div>
660 <input type="hidden" name="customer_klass" value="$form->{customer_klass}">
661 <input type="hidden" name="customer_id" value="$form->{customer_id}">
662 <input type="hidden" name="oldcustomer" value="$form->{oldcustomer}">
663 <input type="hidden" name="selectcustomer" value="$form->{selectcustomer}">
668 <td align="right">| . $locale->text('Credit Limit') . qq|</td>
669 <td>$form->{creditlimit}; | . $locale->text('Remaining') . qq| <span class="plus$n">$form->{creditremaining}</span></td>
674 <th align="right" nowrap>| . $locale->text('Record in') . qq|</th>
675 <td colspan="3"><select name="AR" style="width:250px;">$form->{selectAR}</select></td>
676 <input type="hidden" name="selectAR" value="$form->{selectAR}">
682 <input type="hidden" name="fxgain_accno" value="$form->{fxgain_accno}">
683 <input type="hidden" name="fxloss_accno" value="$form->{fxloss_accno}">
687 <th align="right" nowrap>| . $locale->text('Shipping Point') . qq|</th>
689 $cgi->textfield("-name" => "shippingpoint", "-size" => 35, "-value" => $form->{shippingpoint}) .
692 <th align="right" nowrap>| . $locale->text('Ship via') . qq|</th>
693 <td colspan="3"><input name="shipvia" size="35" value="$form->{shipvia}"></td>
696 <th align="right">| . $locale->text('Transaction description') . qq|</th>
697 <td colspan="3">| . $cgi->textfield("-name" => "transaction_description", "-size" => 35, "-value" => $form->{transaction_description}) . qq|</td>
704 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
706 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
707 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
711 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
713 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
714 # <input size=45 id=delivery_vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
721 <td align="right" valign="top">
726 if ($form->{type} eq "credit_note") {
728 <th align="right" nowrap>| . $locale->text('Credit Note Number') . qq|</th>
729 <td><input name="invnumber" size="11" value="$form->{invnumber}"></td>
732 <th align="right">| . $locale->text('Credit Note Date') . qq|</th>
737 <th align="right" nowrap>| . $locale->text('Invoice Number') . qq|</th>
738 <td><input name="invnumber" size="11" value="$form->{invnumber}"></td>
741 <th align="right">| . $locale->text('Invoice Date') . qq|</th>
745 <th align="right">| . $locale->text('Due Date') . qq|</th>
749 <th align="right">| . $locale->text('Delivery Date') . qq|</th>
754 <th align="right" nowrap>| . $locale->text('Order Number') . qq|</th>
755 <td><input name="ordnumber" size="11" value="$form->{ordnumber}"></td>
758 <th align="right" nowrap>| . $locale->text('Order Date') . qq|</th>
759 <td><input name="orddate" id="orddate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{orddate}) . qq|" onBlur=\"check_right_date_format(this)\">
760 <input type="button" name="b_orddate" id="trigger_orddate" value="?"></td>
763 <th align="right" nowrap>| . $locale->text('Quotation Number') . qq|</th>
764 <td><input name="quonumber" size="11" value="$form->{quonumber}"></td>
767 <th align="right" nowrap>| . $locale->text('Quotation Date') . qq|</th>
768 <td><input name="quodate" id="quodate" size="11" title="$myconfig{dateformat}" value="| . Q($form->{quodate}) . qq|" onBlur=\"check_right_date_format(this)\">
769 <input type="button" name="b_quodate" id="trigger_quodate" value="?"></td>
772 <th align="right" nowrap>| . $locale->text('Customer Order Number') . qq|</th>
773 <td><input name="cusordnumber" size="11" value="$form->{cusordnumber}"></td>
776 <th align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
777 <td>$globalprojectnumber</td>
792 <!-- shipto are in hidden variables -->
794 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
795 qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2));
796 print qq|<!-- email variables --> |;
797 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
798 qw(message email subject cc bcc taxaccounts));
799 print qq|<input type="hidden" name="webdav" value="| . $webdav . qq|">|;
801 foreach $item (split(/ /, $form->{taxaccounts})) {
802 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); }
803 ("${item}_rate", "${item}_description", "${item}_taxnumber"));
805 $lxdebug->leave_sub();
809 $lxdebug->enter_sub();
811 $form->{invtotal} = $form->{invsubtotal};
813 if (($rows = $form->numtextrows($form->{notes}, 26, 8)) < 2) {
816 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
819 $rows = ($rows > $introws) ? $rows : $introws;
821 qq|<textarea name="notes" rows="$rows" cols="26" wrap="soft">$form->{notes}</textarea>|;
823 qq|<textarea name="intnotes" rows="$rows" cols="35" wrap="soft">$form->{intnotes}</textarea>|;
825 $form->{taxincluded} = ($form->{taxincluded} ? "checked" : "");
828 if ($form->{taxaccounts}) {
830 <input name="taxincluded" class="checkbox" type="checkbox" $form->{taxincluded}> <b>|
831 . $locale->text('Tax Included') . qq|</b><br><br>|;
834 if (!$form->{taxincluded}) {
836 foreach $item (split / /, $form->{taxaccounts}) {
837 if ($form->{"${item}_base"}) {
838 $form->{"${item}_total"} =
840 $form->{"${item}_base"} * $form->{"${item}_rate"},
842 $form->{invtotal} += $form->{"${item}_total"};
843 $form->{"${item}_total"} =
844 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
848 <th align="right">$form->{"${item}_description"} |
849 . $form->{"${item}_rate"} * 100 .qq|%</th>
850 <td align="right">$form->{"${item}_total"}</td>
856 $form->{invsubtotal} =
857 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
861 <th align="right">| . $locale->text('Subtotal') . qq|</th>
862 <td align="right">$form->{invsubtotal}</td>
868 if ($form->{taxincluded}) {
869 foreach $item (split / /, $form->{taxaccounts}) {
870 if ($form->{"${item}_base"}) {
871 $form->{"${item}_total"} =
873 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
874 (1 + $form->{"${item}_rate"})
877 $form->{"${item}_netto"} =
879 ($form->{"${item}_base"} - $form->{"${item}_total"}),
881 $form->{"${item}_total"} =
882 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
883 $form->{"${item}_netto"} =
884 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
888 <th align="right">Enthaltene $form->{"${item}_description"} |
889 . $form->{"${item}_rate"} * 100 .qq|%</th>
890 <td align="right">$form->{"${item}_total"}</td>
893 <th align="right">Nettobetrag</th>
894 <td align="right">$form->{"${item}_netto"}</td>
902 $form->{oldinvtotal} = $form->{invtotal};
904 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
914 <th align="left">| . $locale->text('Notes') . qq|</th>
915 <th align="left">| . $locale->text('Internal Notes') . qq|</th>
916 <th align="right">| . $locale->text('Payment Terms') . qq|</th>
921 <td><select name="payment_id" onChange="if (this.value) set_duedate(['payment_id__' + this.value],['duedate'])">$payment
929 <th align=left>| . $locale->text('Ertrag') . qq|</th>
930 <td>| . $form->format_amount(\%myconfig, $form->{marge_total}, 2, 0) . qq|</td>
933 <th align=left>| . $locale->text('Ertrag prozentual') . qq|</th>
934 <td>| . $form->format_amount(\%myconfig, $form->{marge_percent}, 2, 0) . qq| %</td>
936 <input type=hidden name="marge_total" value="$form->{"marge_total"}">
937 <input type=hidden name="marge_percent" value="$form->{"marge_percent"}">
946 <th align="right">| . $locale->text('Total') . qq|</th>
947 <td align="right">$form->{invtotal}</td>
959 <td><hr size="3" noshade></td>
962 <th class="listtop" align="left">Dokumente im Webdav-Repository</th>
965 <td align="left" width="30%"><b>Dateiname</b></td>
966 <td align="left" width="70%"><b>Webdavlink</b></td>
968 foreach $file (keys %{ $form->{WEBDAV} }) {
971 <td align="left">$file</td>
972 <td align="left"><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
983 if ($form->{type} eq "credit_note") {
988 <tr class="listheading">
989 <th colspan="6" class="listheading">|
990 . $locale->text('Payments') . qq|</th>
998 <tr class="listheading">
999 <th colspan="6" class="listheading">|
1000 . $locale->text('Incoming Payments') . qq|</th>
1005 if ($form->{currency} eq $form->{defaultcurrency}) {
1006 @column_index = qw(datepaid source memo paid AR_paid);
1008 @column_index = qw(datepaid source memo paid exchangerate AR_paid);
1011 $column_data{datepaid} = "<th>" . $locale->text('Date') . "</th>";
1012 $column_data{paid} = "<th>" . $locale->text('Amount') . "</th>";
1013 $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
1014 $column_data{AR_paid} = "<th>" . $locale->text('Account') . "</th>";
1015 $column_data{source} = "<th>" . $locale->text('Source') . "</th>";
1016 $column_data{memo} = "<th>" . $locale->text('Memo') . "</th>";
1021 map { print "$column_data{$_}\n" } @column_index;
1029 $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
1030 for $i (1 .. $form->{paidaccounts}) {
1035 $form->{"selectAR_paid_$i"} = $form->{selectAR_paid};
1036 $form->{"selectAR_paid_$i"} =~
1037 s/option>\Q$form->{"AR_paid_$i"}\E/option selected>$form->{"AR_paid_$i"}/;
1040 $totalpaid += $form->{"paid_$i"};
1041 if ($form->{"paid_$i"}) {
1042 $form->{"paid_$i"} =
1043 $form->format_amount(\%myconfig, $form->{"paid_$i"}, 2);
1045 $form->{"exchangerate_$i"} =
1046 $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
1048 if ($form->{"exchangerate_$i"} == 0) {
1049 $form->{"exchangerate_$i"} = "";
1051 $exchangerate = qq| |;
1052 if ($form->{currency} ne $form->{defaultcurrency}) {
1053 if ($form->{"forex_$i"}) {
1054 $exchangerate = qq|<input type="hidden" name="exchangerate_$i" value="$form->{"exchangerate_$i"}">$form->{"exchangerate_$i"}|;
1056 $exchangerate = qq|<input name="exchangerate_$i" size="10" value="$form->{"exchangerate_$i"}">|;
1060 $exchangerate .= qq|<input type="hidden" name="forex_$i" value="$form->{"forex_$i"}">|;
1062 $column_data{"paid_$i"} =
1063 qq|<td align="center"><input name="paid_$i" size="11" value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
1064 $column_data{"exchangerate_$i"} = qq|<td align="center">$exchangerate</td>|;
1065 $column_data{"AR_paid_$i"} =
1066 qq|<td align="center"><select name="AR_paid_$i">$form->{"selectAR_paid_$i"}</select></td>|;
1067 $column_data{"datepaid_$i"} =
1068 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)\">
1069 <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
1070 $column_data{"source_$i"} =
1071 qq|<td align=center><input name="source_$i" size="11" value="$form->{"source_$i"}"></td>|;
1072 $column_data{"memo_$i"} =
1073 qq|<td align="center"><input name="memo_$i" size="11" value="$form->{"memo_$i"}"></td>|;
1075 map { print qq|$column_data{"${_}_$i"}\n| } @column_index;
1078 push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
1081 my $paid_missing = $form->{oldinvtotal} - $totalpaid;
1087 <td align="center">| . $locale->text('Total') . qq|</td>
1088 <td align="center">| . H($form->format_amount(\%myconfig, $totalpaid, 2)) . qq|</td>
1093 <td align="center">| . $locale->text('Missing amount') . qq|</td>
1094 <td align="center">| . H($form->format_amount(\%myconfig, $paid_missing, 2)) . qq|</td>
1098 map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } qw(paidaccounts selectAR_paid oldinvtotal));
1099 print qq|<input type="hidden" name="oldtotalpaid" value="$totalpaid">
1104 <td><hr size="3" noshade></td>
1118 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
1119 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1122 my $show_storno = !$form->{storno} && !IS->has_storno(\%myconfig, $form, "ar");
1125 <input class="submit" type="submit" accesskey="u" name="action" id="update_button" value="|
1126 . $locale->text('Update') . qq|">
1127 <input class="submit" type="submit" name="action" value="|
1128 . $locale->text('Ship to') . qq|">
1129 <input class="submit" type="submit" name="action" value="|
1130 . $locale->text('Print') . qq|">
1131 <input class="submit" type="submit" name="action" value="|
1132 . $locale->text('E-mail') . qq|"> |;
1133 print qq|<input class="submit" type="submit" name="action" value="|
1134 . $locale->text('Storno') . qq|"> | if ($show_storno);
1135 print qq|<input class="submit" type="submit" name="action" value="|
1136 . $locale->text('Post Payment') . qq|">
1138 print qq|<input class="submit" type="submit" name="action" value="|
1139 . $locale->text('Use As Template') . qq|">
1141 if ($form->{id} && !($form->{type} eq "credit_note")) {
1143 <input class="submit" type="submit" name="action" value="|
1144 . $locale->text('Credit Note') . qq|">
1147 if ($form->{radier}) {
1149 <input class="submit" type="submit" name="action" value="|
1150 . $locale->text('Delete') . qq|">
1155 if ($invdate > $closedto) {
1157 <input class="submit" type="submit" name="action" value="|
1158 . $locale->text('Order') . qq|">
1163 if ($invdate > $closedto) {
1164 print qq|<input class="submit" type="submit" name="action" id="update_button" value="|
1165 . $locale->text('Update') . qq|">
1166 <input class="submit" type="submit" name="action" value="|
1167 . $locale->text('Ship to') . qq|">
1168 <input class="submit" type="submit" name="action" value="|
1169 . $locale->text('Preview') . qq|">
1170 <input class="submit" type="submit" name="action" value="|
1171 . $locale->text('E-mail') . qq|">
1172 <input class="submit" type="submit" name="action" value="|
1173 . $locale->text('Print and Post') . qq|">
1174 <input class="submit" type="submit" name="action" value="|
1175 . $locale->text('Post') . qq|"> | .
1176 NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'),
1177 '-class' => 'submit'));
1181 # button for saving history
1182 if($form->{id} ne "") {
1184 <input type="button" class="submit" onclick="set_history_window(|
1186 . qq|);" name="history" id="history" value="|
1187 . $locale->text('history')
1190 # /button for saving history
1192 # mark_as_paid button
1193 if($form->{id} ne "") {
1194 print qq|<input type="submit" class="submit" name="action" value="|
1195 . $locale->text('mark as paid') . qq|">|;
1197 # /mark_as_paid button
1198 print $form->write_trigger(\%myconfig, scalar(@triggers) / 3, @triggers) .
1201 <input type="hidden" name="rowcount" value="$form->{rowcount}">
1203 $cgi->hidden("-name" => "callback", "-value" => $form->{callback})
1204 . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
1205 . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
1206 map({ print $cgi->hidden("-name" => $_ , "-value" => $form->{$_});} qw(login password));
1215 $lxdebug->leave_sub();
1219 $lxdebug->enter_sub();
1220 &mark_as_paid_common(\%myconfig,"ar");
1221 $lxdebug->leave_sub();
1225 $lxdebug->enter_sub();
1227 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1228 qw(exchangerate creditlimit creditremaining);
1229 if ($form->{second_run}) {
1230 $form->{print_and_post} = 0;
1234 if($form->{taxincluded}) {
1235 $taxincluded = "checked";
1237 $form->{update} = 1;
1239 &check_name(customer);
1241 if(!$form->{taxincluded}) {
1242 $form->{taxincluded} = $taxincluded;
1246 $form->{exchangerate} = $exchangerate
1250 $form->check_exchangerate(
1251 \%myconfig, $form->{currency}, $form->{invdate}, 'buy'
1254 for $i (1 .. $form->{paidaccounts}) {
1255 if ($form->{"paid_$i"}) {
1257 $form->{"${_}_$i"} =
1258 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
1259 } qw(paid exchangerate);
1261 $form->{"exchangerate_$i"} = $exchangerate
1263 $form->{"forex_$i"} = (
1265 $form->check_exchangerate(
1266 \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'
1271 $i = $form->{rowcount};
1272 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1274 # if last row empty, check the form otherwise retrieve new item
1275 if ( ($form->{"partnumber_$i"} eq "")
1276 && ($form->{"description_$i"} eq "")
1277 && ($form->{"partsgroup_$i"} eq "")) {
1279 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1284 IS->retrieve_item(\%myconfig, \%$form);
1286 $rows = scalar @{ $form->{item_list} };
1288 $form->{"discount_$i"} =
1289 $form->format_amount(\%myconfig, $form->{discount} * 100);
1292 $form->{"qty_$i"} = ($form->{"qty_$i"} * 1) ? $form->{"qty_$i"} : 1;
1301 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1303 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1304 qw(partnumber description unit);
1305 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1306 keys %{ $form->{item_list}[0] };
1307 if ($form->{"part_payment_id_$i"} ne "") {
1308 $form->{payment_id} = $form->{"part_payment_id_$i"};
1311 if ($form->{"not_discountable_$i"}) {
1312 $form->{"discount_$i"} = 0;
1315 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1316 ($dec) = ($s =~ /\.(\d+)/);
1318 $decimalplaces = ($dec > 2) ? $dec : 2;
1321 $form->{"sellprice_$i"} = $sellprice;
1324 # if there is an exchange rate adjust sellprice
1325 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1326 $form->{"sellprice_$i"} /= $exchangerate;
1329 $form->{"listprice_$i"} /= $exchangerate;
1332 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1333 (1 - $form->{"discount_$i"} / 100);
1334 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1335 map { $form->{"${_}_base"} += $amount }
1336 (split / /, $form->{"taxaccounts_$i"});
1337 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1338 split / /, $form->{"taxaccounts_$i"}
1339 if !$form->{taxincluded};
1341 $form->{creditremaining} -= $amount;
1344 $form->{"${_}_$i"} =
1345 $form->format_amount(\%myconfig, $form->{"${_}_$i"},
1347 } qw(sellprice listprice);
1350 $form->format_amount(\%myconfig, $form->{"qty_$i"});
1353 if ($form->{"inventory_accno_$i"} ne "") {
1354 $form->{"lizenzen_$i"} = qq|<option></option>|;
1355 foreach $item (@{ $form->{LIZENZEN}{ $form->{"id_$i"} } }) {
1356 $form->{"lizenzen_$i"} .=
1357 qq|<option value="$item->{"id"}">$item->{"licensenumber"}</option>|;
1359 $form->{"lizenzen_$i"} .=
1360 qq|<option value=-1>Neue Lizenz</option>|;
1364 # get pricegroups for parts
1365 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1367 # build up html code for prices_$i
1368 &set_pricegroup($i);
1375 # ok, so this is a new part
1376 # ask if it is a part or service item
1378 if ( $form->{"partsgroup_$i"}
1379 && ($form->{"partsnumber_$i"} eq "")
1380 && ($form->{"description_$i"} eq "")) {
1381 $form->{rowcount}--;
1382 $form->{"discount_$i"} = "";
1386 $form->{"id_$i"} = 0;
1387 $form->{"unit_$i"} = $locale->text('ea');
1394 $lxdebug->leave_sub();
1398 $lxdebug->enter_sub();
1400 $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
1401 for $i (1 .. $form->{paidaccounts}) {
1402 if ($form->{"paid_$i"}) {
1403 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1405 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1407 $form->error($locale->text('Cannot post payment for a closed period!'))
1408 if ($datepaid <= $closedto);
1410 if ($form->{currency} ne $form->{defaultcurrency}) {
1411 $form->{"exchangerate_$i"} = $form->{exchangerate}
1412 if ($invdate == $datepaid);
1413 $form->isblank("exchangerate_$i",
1414 $locale->text('Exchangerate for payment missing!'));
1419 ($form->{AR}) = split /--/, $form->{AR};
1420 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1422 $form->redirect($locale->text('Payment posted!'))
1423 if (IS->post_payment(\%myconfig, \%$form));
1424 $form->error($locale->text('Cannot post payment!'));
1427 $lxdebug->leave_sub();
1431 $lxdebug->enter_sub();
1433 $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
1434 $form->isblank("invdate", $locale->text('Invoice Date missing!'));
1435 $form->isblank("customer", $locale->text('Customer missing!'));
1437 $form->{invnumber} =~ s/^\s*//g;
1438 $form->{invnumber} =~ s/\s*$//g;
1440 # if oldcustomer ne customer redo form
1441 if (&check_name(customer)) {
1445 if ($form->{second_run}) {
1446 $form->{print_and_post} = 0;
1451 $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1452 $invdate = $form->datetonum($form->{invdate}, \%myconfig);
1454 $form->error($locale->text('Cannot post invoice for a closed period!'))
1455 if ($invdate <= $closedto);
1457 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1458 if ($form->{currency} ne $form->{defaultcurrency});
1460 for $i (1 .. $form->{paidaccounts}) {
1461 if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1462 $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1464 $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1466 $form->error($locale->text('Cannot post payment for a closed period!'))
1467 if ($datepaid <= $closedto);
1469 if ($form->{currency} ne $form->{defaultcurrency}) {
1470 $form->{"exchangerate_$i"} = $form->{exchangerate}
1471 if ($invdate == $datepaid);
1472 $form->isblank("exchangerate_$i",
1473 $locale->text('Exchangerate for payment missing!'));
1478 ($form->{AR}) = split /--/, $form->{AR};
1479 ($form->{AR_paid}) = split /--/, $form->{AR_paid};
1480 $form->{storno} = 0;
1482 $form->{label} = $locale->text('Invoice');
1484 $form->{id} = 0 if $form->{postasnew};
1486 # get new invnumber in sequence if no invnumber is given or if posasnew was requested
1487 if ($form->{postasnew}) {
1488 if ($form->{type} eq "credit_note") {
1489 undef($form->{cnnumber});
1491 undef($form->{invnumber});
1496 $form->error($locale->text('Cannot post invoice!'))
1497 unless IS->post_invoice(\%myconfig, \%$form);
1498 remove_draft() if $form->{remove_draft};
1500 if(!exists $form->{addition}) {
1501 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1502 $form->{addition} = $print_post ? "PRINTED AND POSTED" :
1503 $form->{storno} ? "STORNO" :
1505 $form->save_history($form->dbconnect(\%myconfig));
1508 $form->redirect( $form->{label} . " $form->{invnumber} " . $locale->text('posted!'))
1511 $lxdebug->leave_sub();
1514 sub print_and_post {
1515 $lxdebug->enter_sub();
1517 $old_form = new Form;
1519 $form->{print_and_post} = 1;
1523 $lxdebug->leave_sub();
1527 sub use_as_template {
1528 $lxdebug->enter_sub();
1530 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);
1531 $form->{paidaccounts} = 1;
1532 $form->{rowcount}--;
1533 $form->{invdate} = $form->current_date(\%myconfig);
1536 $lxdebug->leave_sub();
1540 $lxdebug->enter_sub();
1542 if ($form->{storno}) {
1543 $form->error($locale->text('Cannot storno storno invoice!'));
1546 if (IS->has_storno(\%myconfig, $form, "ar")) {
1547 $form->error($locale->text("Invoice has already been storno'd!"));
1550 map({ my $key = $_; delete($form->{$key})
1551 unless (grep({ $key eq $_ } qw(login password id stylesheet type))); }
1558 # Payments must not be recorded for the new storno invoice.
1559 $form->{paidaccounts} = 0;
1560 map { my $key = $_; delete $form->{$key} if grep { $key =~ /^$_/ } qw(datepaid_ source_ memo_ paid_ exchangerate_ AR_paid_) } keys %{ $form };
1562 $form->{storno_id} = $form->{id};
1563 $form->{storno} = 1;
1565 $form->{invnumber} = "Storno zu " . $form->{invnumber};
1566 $form->{rowcount}++;
1569 $lxdebug->leave_sub();
1573 $lxdebug->enter_sub();
1575 $form->{preview} = 1;
1576 $old_form = new Form;
1577 for (keys %$form) { $old_form->{$_} = $form->{$_} }
1579 &print_form($old_form);
1580 $lxdebug->leave_sub();
1585 $lxdebug->enter_sub();
1586 if ($form->{second_run}) {
1587 $form->{print_and_post} = 0;
1594 <form method="post" action="$form->{script}">
1597 # delete action variable
1598 map { delete $form->{$_} } qw(action header);
1600 foreach $key (keys %$form) {
1601 $form->{$key} =~ s/\"/"/g;
1602 print qq|<input type="hidden" name="$key" value="$form->{$key}">\n|;
1606 <h2 class="confirm">| . $locale->text('Confirm!') . qq|</h2>
1609 . $locale->text('Are you sure you want to delete Invoice Number')
1610 . qq| $form->{invnumber}
1614 <input name="action" class="submit" type="submit" value="|
1615 . $locale->text('Yes') . qq|">
1619 $lxdebug->leave_sub();
1623 $lxdebug->enter_sub();
1625 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1627 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1630 $form->{rowcount}--;
1631 $form->{shipto} = 1;
1634 $form->{title} = $locale->text('Add Credit Note');
1635 $form->{script} = 'is.pl';
1640 # bo creates the id, reset it
1641 map { delete $form->{$_} }
1642 qw(id invnumber subject message cc bcc printed emailed queued);
1643 $form->{ $form->{vc} } =~ s/--.*//g;
1644 $form->{type} = "credit_note";
1647 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1649 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1650 qw(creditlimit creditremaining);
1652 $currency = $form->{currency};
1655 $form->{currency} = $currency;
1656 $form->{exchangerate} = "";
1657 $form->{forex} = "";
1658 $form->{exchangerate} = $exchangerate
1662 $form->check_exchangerate(
1663 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
1666 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1673 $lxdebug->leave_sub();
1677 $lxdebug->enter_sub();
1678 if (IS->delete_invoice(\%myconfig, \%$form, $spool)) {
1679 # saving the history
1680 if(!exists $form->{addition}) {
1681 $form->{snumbers} = qq|invnumber_| . $form->{invnumber};
1682 $form->{addition} = "DELETED";
1683 $form->save_history($form->dbconnect(\%myconfig));
1685 # /saving the history
1686 $form->redirect($locale->text('Invoice deleted!'));
1688 $form->error($locale->text('Cannot delete invoice!'));
1690 $lxdebug->leave_sub();
1694 $lxdebug->enter_sub();
1699 my $saved_form = save_form();
1704 map({ $saved_vars{$_} = $form->{$_}; } qw(id invnumber));
1705 restore_form($saved_form);
1706 map({ $form->{$_} = $saved_vars{$_}; } qw(id invnumber));
1711 $lxdebug->leave_sub();