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-2003
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
32 #======================================================================
40 require "$form->{path}/io.pl";
41 require "$form->{path}/arap.pl";
48 # $locale->text('Edit the purchase_order');
49 # $locale->text('Edit the sales_order');
50 # $locale->text('Edit the request_quotation');
51 # $locale->text('Edit the sales_quotation');
53 # $locale->text('Workflow purchase_order');
54 # $locale->text('Workflow sales_order');
55 # $locale->text('Workflow request_quotation');
56 # $locale->text('Workflow sales_quotation');
59 $lxdebug->enter_sub();
63 if ($form->{type} eq 'purchase_order') {
64 $form->{title} = $action eq "edit" ?
65 $locale->text('Edit Purchase Order') :
66 $locale->text('Add Purchase Order');
67 $form->{heading} = $locale->text('Purchase Order');
68 $form->{vc} = 'vendor';
70 if ($form->{type} eq 'sales_order') {
71 $form->{title} = $action eq "edit" ?
72 $locale->text('Edit Sales Order') :
73 $locale->text('Add Sales Order');
74 $form->{heading} = $locale->text('Sales Order');
75 $form->{vc} = 'customer';
77 if ($form->{type} eq 'request_quotation') {
78 $form->{title} = $action eq "edit" ?
79 $locale->text('Edit Request for Quotation') :
80 $locale->text('Add Request for Quotation');
81 $form->{heading} = $locale->text('Request for Quotation');
82 $form->{vc} = 'vendor';
84 if ($form->{type} eq 'sales_quotation') {
85 $form->{title} = $action eq "edit" ?
86 $locale->text('Edit Quotation') :
87 $locale->text('Add Quotation');
88 $form->{heading} = $locale->text('Quotation');
89 $form->{vc} = 'customer';
92 $lxdebug->leave_sub();
96 $lxdebug->enter_sub();
101 "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&password=$form->{password}"
102 unless $form->{callback};
108 $lxdebug->leave_sub();
112 $lxdebug->enter_sub();
113 # show history button
114 $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
115 #/show hhistory button
117 $form->{simple_save} = 0;
119 set_headings("edit");
121 # editing without stuff to edit? try adding it first
122 if ($form->{rowcount}) {
123 map { $id++ if $form->{"multi_id_$_"} } (1 .. $form->{rowcount});
127 undef $form->{rowcount};
129 $lxdebug->leave_sub();
132 } elsif (!$form->{id}) {
134 $lxdebug->leave_sub();
138 if ($form->{print_and_save}) {
139 $form->{action} = "print";
140 $form->{resubmit} = 1;
141 $language_id = $form->{language_id};
142 $printer_id = $form->{printer_id};
145 set_headings("edit");
149 if ($form->{print_and_save}) {
150 $form->{language_id} = $language_id;
151 $form->{printer_id} = $printer_id;
155 $lxdebug->leave_sub();
159 $lxdebug->enter_sub();
161 # get customer/vendor
162 $form->all_vc(\%myconfig, $form->{vc},
163 ($form->{vc} eq 'customer') ? "AR" : "AP");
165 # retrieve order/quotation
166 $form->{webdav} = $webdav;
168 $form->{jscalendar} = $jscalendar;
170 my $editing = $form->{id};
172 OE->retrieve(\%myconfig, \%$form);
174 if ($form->{payment_id}) {
175 $payment_id = $form->{payment_id};
177 if ($form->{language_id}) {
178 $language_id = $form->{language_id};
180 if ($form->{taxzone_id}) {
181 $taxzone_id = $form->{taxzone_id};
184 $salesman_id = $form->{salesman_id} if ($editing);
187 # if multiple rowcounts (== collective order) then check if the
188 # there were more than one customer (in that case OE::retrieve removes
189 # the content from the field)
190 if ( $form->{rowcount}
191 && $form->{type} eq 'sales_order'
192 && defined $form->{customer}
193 && $form->{customer} eq '') {
195 # $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
198 'Collective Orders only work for orders from one customer!')
202 $taxincluded = $form->{taxincluded};
203 $form->{shipto} = 1 if $form->{id};
205 if ($form->{"all_$form->{vc}"}) {
206 unless ($form->{"$form->{vc}_id"}) {
207 $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
211 $cp_id = $form->{cp_id};
212 $intnotes = $form->{intnotes};
214 # get customer / vendor
215 if ($form->{type} =~ /(purchase_order|request_quotation)/) {
216 IR->get_vendor(\%myconfig, \%$form);
218 #quote all_vendor Bug 133
219 foreach $ref (@{ $form->{all_vendor} }) {
220 $ref->{name} = $form->quote($ref->{name});
224 if ($form->{type} =~ /sales_(order|quotation)/) {
225 IS->get_customer(\%myconfig, \%$form);
227 #quote all_vendor Bug 133
228 foreach $ref (@{ $form->{all_customer} }) {
229 $ref->{name} = $form->quote($ref->{name});
233 $form->{cp_id} = $cp_id;
235 $form->{payment_id} = $payment_id;
238 $form->{language_id} = $language_id;
241 $form->{taxzone_id} = $taxzone_id;
243 $form->{intnotes} = $intnotes if $intnotes;
244 ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
245 $form->{"old$form->{vc}"} =
246 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
248 # build the popup menus
249 if (@{ $form->{"all_$form->{vc}"} }) {
250 $form->{ $form->{vc} } =
251 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
252 map { $form->{"select$form->{vc}"} .= "<option>$_->{name}--$_->{id}\n" }
253 (@{ $form->{"all_$form->{vc}"} });
257 @curr = split(/:/, $form->{currencies});
259 $form->{defaultcurrency} = $curr[0];
260 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
262 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
264 $form->{taxincluded} = $taxincluded if ($form->{id});
267 if (@{ $form->{all_departments} }) {
268 $form->{selectdepartment} = "<option>\n";
269 $form->{department} = "$form->{department}--$form->{department_id}";
272 $form->{selectdepartment} .=
273 "<option>$_->{description}--$_->{id}\n"
274 } (@{ $form->{all_departments} });
277 $form->{employee} = "$form->{employee}--$form->{employee_id}";
280 if (@{ $form->{all_employees} }) {
281 $form->{selectemployee} = "";
282 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
283 (@{ $form->{all_employees} });
287 $form->{forex} = $form->{exchangerate};
289 $form->{salesman_id} = $salesman_id if ($editing);
291 $lxdebug->leave_sub();
295 $lxdebug->enter_sub();
296 $form->{formname} = $form->{type} unless $form->{formname};
299 foreach $ref (@{ $form->{form_details} }) {
300 $form->{rowcount} = ++$i;
302 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
304 for my $i (1 .. $form->{rowcount}) {
306 $form->{"discount_$i"} =
307 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
309 $form->{"discount_$i"} =
310 $form->format_amount(\%myconfig, $form->{"discount_$i"});
312 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
314 $decimalplaces = ($dec > 2) ? $dec : 2;
316 # copy reqdate from deliverydate for invoice -> order conversion
317 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
318 unless $form->{"reqdate_$i"};
320 $form->{"sellprice_$i"} =
321 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
324 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
325 $dec_qty = length $dec_qty;
327 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
329 map { $form->{"${_}_$i"} =~ s/\"/"/g }
330 qw(partnumber description unit);
333 $lxdebug->leave_sub();
337 $lxdebug->enter_sub();
339 my $checkedclosed = $form->{"closed"} ? "checked" : "";
340 my $checkeddelivered = $form->{"delivered"} ? "checked" : "";
342 map { $form->{$_} =~ s/\"/"/g }
343 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
344 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
345 shiptophone shiptofax shiptodepartment_1 shiptodepartment_2);
347 # use JavaScript Calendar or not
348 $form->{jsscript} = $form->{jscalendar};
351 $payment = qq|<option value=""></option>|;
352 foreach $item (@{ $form->{payment_terms} }) {
353 if ($form->{payment_id} eq $item->{id}) {
354 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
356 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
359 if ($form->{jsscript}) {
361 # with JavaScript Calendar
363 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
364 <td><input type=button name=transdate id="trigger1" value=|
365 . $locale->text('button') . qq|></td>
368 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
369 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
370 . $locale->text('button') . qq|></td>
375 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
376 "reqdate", "BL", "trigger2");
380 # without JavaScript Calendar
382 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
384 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
390 <td colspan=2 align=center>
391 <input name="closed" id="closed" type="checkbox" class="checkbox" value="1" $checkedclosed>
392 <label for="closed">| . $locale->text('Closed') . qq|</label>
395 if (($form->{"type"} eq "sales_order") ||
396 ($form->{"type"} eq "purchase_order")) {
398 <input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" $checkeddelivered>
399 <label for="delivered">| . $locale->text('Delivered') . qq|</label>
409 # set option selected
410 foreach $item ($form->{vc}, currency, department, employee) {
411 $form->{"select$item"} =~ s/ selected//;
412 $form->{"select$item"} =~
413 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
416 #quote select[customer|vendor] Bug 133
417 $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
419 my @old_project_ids = ($form->{"globalproject_id"});
420 map({ push(@old_project_ids, $form->{"project_id_$_"})
421 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
423 $form->get_lists("contacts" => "ALL_CONTACTS",
424 "shipto" => "ALL_SHIPTO",
425 "projects" => { "key" => "ALL_PROJECTS",
427 "old_id" => \@old_project_ids },
428 "employees" => "ALL_SALESMEN");
430 my (%labels, @values);
431 foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
432 push(@values, $item->{"cp_id"});
433 $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
434 ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
437 NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
438 '-labels' => \%labels, '-default' => $form->{"cp_id"}));
442 foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
443 push(@values, $item->{"shipto_id"});
444 $labels{$item->{"shipto_id"}} =
445 $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"};
449 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
451 NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
452 '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
457 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
458 push(@values, $item->{"id"});
459 $labels{$item->{"id"}} = $item->{"projectnumber"};
461 my $globalprojectnumber =
462 NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
463 '-labels' => \%labels,
464 '-default' => $form->{"globalproject_id"}));
467 if ($form->{type} =~ /^sales_/) {
470 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
471 push(@values, $item->{id});
472 $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
477 <th align="right">| . $locale->text('Salesman') . qq|</th>
479 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
480 '-values' => \@values, '-labels' => \%labels))
485 $form->{exchangerate} =
486 $form->format_amount(\%myconfig, $form->{exchangerate});
488 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
494 $form->{creditlimit} =
495 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
496 $form->{creditremaining} =
497 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
500 <input type=hidden name=forex value=$form->{forex}>
503 if ($form->{currency} ne $form->{defaultcurrency}) {
504 if ($form->{forex}) {
507 . $locale->text('Exchangerate')
508 . qq|</th><td>$form->{exchangerate}</td>
509 <input type=hidden name=exchangerate value=$form->{exchangerate}>
514 . $locale->text('Exchangerate')
515 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
519 $vclabel = ucfirst $form->{vc};
520 $vclabel = $locale->text($vclabel);
524 if ($form->{business}) {
527 <th align=right>| . $locale->text('Business') . qq|</th>
528 <td>$form->{business}</td>
529 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
531 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
537 if ($form->{max_dunning_level}) {
543 <th align=right>| . $locale->text('Max. Dunning Level') . qq|:</th>
544 <td><b>$form->{max_dunning_level}</b></td>
545 <th align=right>| . $locale->text('Dunning Amount') . qq|:</th>
547 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
556 if (@{ $form->{TAXZONE} }) {
557 $form->{selecttaxzone} = "";
558 foreach $item (@{ $form->{TAXZONE} }) {
559 if ($item->{id} == $form->{taxzone_id}) {
560 $form->{selecttaxzone} .=
561 "<option value=$item->{id} selected>" . H($item->{description}) .
564 $form->{selecttaxzone} .=
565 "<option value=$item->{id}>" . H($item->{description}) . "</option>";
570 $form->{selecttaxzone} =~ s/ selected//g;
571 if ($form->{taxzone_id} ne "") {
572 $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}>/value=$form->{taxzone_id} selected>/;
578 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
579 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
580 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
584 if ($form->{type} !~ /_quotation$/) {
587 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
588 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
591 <th width=70% align=right nowrap>|
592 . $locale->text('Quotation Number') . qq|</th>
593 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
596 <th width=70% align=right nowrap>|
597 . $locale->text('Customer Order Number') . qq|</th>
598 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
601 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
606 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
611 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
613 $creditremaining = qq|
619 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
620 <td>$form->{creditlimit}</td>
622 <th nowrap>| . $locale->text('Remaining') . qq|</th>
623 <td class="plus$n" nowrap>$form->{creditremaining}</td>
632 ($form->{type} eq 'sales_quotation')
633 ? $locale->text('Valid until')
634 : $locale->text('Required by');
635 if ($form->{type} eq 'sales_quotation') {
638 <th width=70% align=right nowrap>|
639 . $locale->text('Quotation Number') . qq|</th>
640 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
641 <input type=hidden name=ordnumber value="$form->{ordnumber}">
647 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
648 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
649 <input type=hidden name=ordnumber value="$form->{ordnumber}">
657 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
661 <th align=right nowrap=true>$reqlabel</th>
665 $creditremaining = qq| <tr>
672 ($form->{"select$form->{vc}"})
673 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
674 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
678 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
679 <td colspan=3><select name=department>$form->{selectdepartment}</select>
680 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
683 | if $form->{selectdepartment};
686 <input type=hidden name=employee value="$form->{employee}">
689 if ($form->{type} eq 'sales_order') {
690 if ($form->{selectemployee}) {
692 <input type=hidden name=customer_klass value=$form->{customer_klass}>
694 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
695 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
696 <input type=hidden name=selectemployee value="$form->{selectemployee}">
703 <input type=hidden name=customer_klass value=$form->{customer_klass}>
705 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
706 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
707 <input type=hidden name=selectemployee value="$form->{selectemployee}">
712 if ($form->{resubmit} && ($form->{format} eq "html")) {
714 qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
715 } elsif ($form->{resubmit}) {
716 $onload = qq|document.oe.submit()|;
721 $credittext = $locale->text('Credit Limit exceeded!!!');
722 if ($creditwarning) {
723 $onload = qq|alert('$credittext')|;
726 $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
727 # show history button js
728 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
729 #/show history button js
733 <body onLoad="$onload">
735 <form method=post name=oe action=$form->{script}>
736 <script type="text/javascript" src="js/common.js"></script>
737 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
738 <script type="text/javascript" src="js/vendor_selection.js"></script>
739 <script type="text/javascript" src="js/calculate_qty.js"></script>
741 <input type=hidden name=id value=$form->{id}>
742 <input type=hidden name=action value=$form->{action}>
744 <input type=hidden name=type value=$form->{type}>
745 <input type=hidden name=formname value=$form->{formname}>
746 <input type=hidden name=media value=$form->{media}>
747 <input type=hidden name=format value=$form->{format}>
748 <input type=hidden name=proforma value=$form->{proforma}>
750 <input type=hidden name=queued value="$form->{queued}">
751 <input type=hidden name=printed value="$form->{printed}">
752 <input type=hidden name=emailed value="$form->{emailed}">
754 <input type=hidden name=vc value=$form->{vc}>
756 <input type=hidden name=title value="$form->{title}">
758 <input type=hidden name=discount value=$form->{discount}>
759 <input type=hidden name=creditlimit value=$form->{creditlimit}>
760 <input type=hidden name=creditremaining value=$form->{creditremaining}>
762 <input type=hidden name=tradediscount value=$form->{tradediscount}>
763 <input type=hidden name=business value=$form->{business}>
764 <input type=hidden name=webdav value=$webdav>
768 <th class=listtop>$form->{title}</th>
778 <th align=right>$vclabel</th>
779 <td colspan=3>$vc</td>
780 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
781 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
782 <th align=richt nowrap>|
783 . $locale->text('Contact Person') . qq|</th>
784 <td colspan=3>$contact</td>
792 <th align=right>| . $locale->text('Currency') . qq|</th>
793 <td><select name=currency>$form->{selectcurrency}</select></td>
794 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
795 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
799 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
800 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
803 <th align=right>| . $locale->text('Ship via') . qq|</th>
804 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
811 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
813 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
814 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
818 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
820 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
821 # <input size=45 id=vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
835 <th width="70%" align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
836 <td>$globalprojectnumber</td>
847 <!-- shipto are in hidden variables -->
849 <input type=hidden name=shiptoname value="$form->{shiptoname}">
850 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
851 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
852 <input type=hidden name=shiptocity value="$form->{shiptocity}">
853 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
854 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
855 <input type=hidden name=shiptophone value="$form->{shiptophone}">
856 <input type=hidden name=shiptofax value="$form->{shiptofax}">
857 <input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
858 <input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
859 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
861 <!-- email variables -->
862 <input type=hidden name=message value="$form->{message}">
863 <input type=hidden name=email value="$form->{email}">
864 <input type=hidden name=subject value="$form->{subject}">
865 <input type=hidden name=cc value="$form->{cc}">
866 <input type=hidden name=bcc value="$form->{bcc}">
868 <input type=hidden name=taxpart value="$form->{taxpart}">
869 <input type=hidden name=taxservice value="$form->{taxservice}">
871 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
874 foreach $item (split / /, $form->{taxaccounts}) {
876 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
877 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
880 $lxdebug->leave_sub();
884 $lxdebug->enter_sub();
886 $form->{invtotal} = $form->{invsubtotal};
888 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
891 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
894 $rows = ($rows > $introws) ? $rows : $introws;
896 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
898 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
900 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
903 if ($form->{taxaccounts}) {
905 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
906 . $locale->text('Tax Included') . qq|</b><br><br>
910 if (!$form->{taxincluded}) {
912 foreach $item (split / /, $form->{taxaccounts}) {
913 if ($form->{"${item}_base"}) {
914 $form->{invtotal} += $form->{"${item}_total"} =
916 $form->{"${item}_base"} * $form->{"${item}_rate"},
918 $form->{"${item}_total"} =
919 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
923 <th align=right>$form->{"${item}_description"} |
924 . $form->{"${item}_rate"} * 100 .qq|%</th>
925 <td align=right>$form->{"${item}_total"}</td>
931 $form->{invsubtotal} =
932 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
936 <th align=right>| . $locale->text('Subtotal') . qq|</th>
937 <td align=right>$form->{invsubtotal}</td>
943 if ($form->{taxincluded}) {
944 foreach $item (split / /, $form->{taxaccounts}) {
945 if ($form->{"${item}_base"}) {
946 $form->{"${item}_total"} =
948 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
949 (1 + $form->{"${item}_rate"})
952 $form->{"${item}_netto"} =
954 ($form->{"${item}_base"} - $form->{"${item}_total"}),
956 $form->{"${item}_total"} =
957 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
958 $form->{"${item}_netto"} =
959 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
963 <th align=right>Enthaltene $form->{"${item}_description"} |
964 . $form->{"${item}_rate"} * 100 .qq|%</th>
965 <td align=right>$form->{"${item}_total"}</td>
968 <th align=right>Nettobetrag</th>
969 <td align=right>$form->{"${item}_netto"}</td>
977 $form->{oldinvtotal} = $form->{invtotal};
979 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
989 <th align=left>| . $locale->text('Notes') . qq|</th>
990 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
996 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
997 <td><select name=payment_id>$payment
1001 <td align=right width=100%>
1007 <th align=right>| . $locale->text('Total') . qq|</th>
1008 <td align=right>$form->{invtotal}</td>
1016 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
1017 <input type=hidden name=oldtotalpaid value=$totalpaid>
1019 <td><hr size=3 noshade></td>
1027 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
1030 <td align=left width=30%><b>Dateiname</b></td>
1031 <td align=left width=70%><b>Webdavlink</b></td>
1033 foreach $file (keys %{ $form->{WEBDAV} }) {
1036 <td align=left>$file</td>
1037 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
1045 <td><hr size=3 noshade></td>
1052 <input type=hidden name=jscalendar value=$form->{jscalendar}>
1065 | . $locale->text("Edit the $form->{type}") . qq|<br>
1066 <input class=submit type=submit name=action id=update_button value="|
1067 . $locale->text('Update') . qq|">
1068 <input class=submit type=submit name=action value="|
1069 . $locale->text('Ship to') . qq|">
1070 <input class=submit type=submit name=action value="|
1071 . $locale->text('Print') . qq|">
1072 <input class=submit type=submit name=action value="|
1073 . $locale->text('E-mail') . qq|">
1074 <input class=submit type=submit name=action value="|
1075 . $locale->text('Save') . qq|">
1076 <input class=submit type=submit name=action value="|
1077 . $locale->text('Save and Close') . qq|">
1080 if (($form->{id})) {
1082 <input type="button" class="submit" onclick="set_history_window(|
1084 . qq|);" name="history" id="history" value="|
1085 . $locale->text('history')
1088 <br>| . $locale->text("Workflow $form->{type}") . qq|<br>
1089 <input class=submit type=submit name=action value="|
1090 . $locale->text('Save as new') . qq|">
1091 <input class=submit type=submit name=action value="|
1092 . $locale->text('Delete') . qq|">|;
1093 if (($form->{type} =~ /sales_quotation$/)) {
1095 <input class=submit type=submit name=action value="|
1096 . $locale->text('Sales Order') . qq|">|;
1098 if ($form->{type} =~ /request_quotation$/) {
1100 <input class=submit type=submit name=action value="|
1101 . $locale->text('Purchase Order') . qq|">|;
1105 <input class=submit type=submit name=action value="|
1106 . $locale->text('Invoice') . qq|">
1110 if ($form->{type} =~ /sales_order$/) {
1112 <br>$form->{heading} als neue Vorlage verwenden für<br>
1113 <input class=submit type=submit name=action value="|
1114 . $locale->text('Purchase Order') . qq|">
1115 <input class=submit type=submit name=action value="|
1116 . $locale->text('Quotation') . qq|">
1119 } elsif ($form->{type} =~ /purchase_order$/) {
1121 <br>$form->{heading} als neue Vorlage verwenden für<br>
1122 <input class=submit type=submit name=action value="|
1123 . $locale->text('Sales Order') . qq|">
1124 <input class=submit type=submit name=action value="|
1125 . $locale->text('Request for Quotation') . qq|">
1130 <br>$form->{heading} als neue Vorlage verwenden für<br>
1131 <input class=submit type=submit name=action value="|
1132 . $locale->text('Order') . qq|">
1135 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount} && !$form->{proforma}) {
1137 <br>Workflow $form->{heading}<br>
1138 <input class=submit type=submit name=action value="|
1139 . $locale->text('Save as new') . qq|">
1140 <input class=submit type=submit name=action value="|
1141 . $locale->text('Invoice') . qq|">
1145 $form->hide_form("saved_xyznumber");
1149 <input type=hidden name=rowcount value=$form->{rowcount}>
1151 <input name=callback type=hidden value="$form->{callback}">
1153 <input type=hidden name=path value=$form->{path}>
1154 <input type=hidden name=login value=$form->{login}>
1155 <input type=hidden name=password value=$form->{password}>
1162 $lxdebug->leave_sub();
1166 $lxdebug->enter_sub();
1168 set_headings($form->{"id"} ? "edit" : "add");
1170 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1171 qw(exchangerate creditlimit creditremaining);
1172 $form->{update} = 1;
1174 &check_name($form->{vc});
1177 $buysell = 'sell' if ($form->{vc} eq 'vendor');
1178 $form->{exchangerate} = $exchangerate
1182 $form->check_exchangerate(
1183 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1187 $i = $form->{rowcount};
1189 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1191 if ( ($form->{"partnumber_$i"} eq "")
1192 && ($form->{"description_$i"} eq "")
1193 && ($form->{"partsgroup_$i"} eq "")) {
1195 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1200 if ( $form->{type} eq 'purchase_order'
1201 || $form->{type} eq 'request_quotation') {
1202 IR->retrieve_item(\%myconfig, \%$form);
1204 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1205 IS->retrieve_item(\%myconfig, \%$form);
1208 my $rows = scalar @{ $form->{item_list} };
1210 $form->{"discount_$i"} =
1211 $form->format_amount(\%myconfig, $form->{discount} * 100);
1214 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1223 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1224 if ($form->{"not_discountable_$i"}) {
1225 $form->{"discount_$i"} = 0;
1227 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1228 qw(partnumber description unit);
1229 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1230 keys %{ $form->{item_list}[0] };
1231 if ($form->{"part_payment_id_$i"} ne "") {
1232 $form->{payment_id} = $form->{"part_payment_id_$i"};
1235 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1237 ($dec) = ($s =~ /\.(\d+)/);
1239 $decimalplaces = ($dec > 2) ? $dec : 2;
1242 $form->{"sellprice_$i"} = $sellprice;
1245 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1247 # if there is an exchange rate adjust sellprice
1248 $form->{"sellprice_$i"} /= $exchangerate;
1252 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1253 (1 - $form->{"discount_$i"} / 100);
1254 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1255 map { $form->{"${_}_base"} += $amount }
1256 (split / /, $form->{"taxaccounts_$i"});
1257 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1258 split / /, $form->{taxaccounts}
1259 if !$form->{taxincluded};
1261 $form->{creditremaining} -= $amount;
1263 $form->{"sellprice_$i"} =
1264 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1267 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1269 # get pricegroups for parts
1270 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1272 # build up html code for prices_$i
1273 &set_pricegroup($i);
1280 # ok, so this is a new part
1281 # ask if it is a part or service item
1283 if ( $form->{"partsgroup_$i"}
1284 && ($form->{"partsnumber_$i"} eq "")
1285 && ($form->{"description_$i"} eq "")) {
1286 $form->{rowcount}--;
1287 $form->{"discount_$i"} = "";
1291 $form->{"id_$i"} = 0;
1292 $form->{"unit_$i"} = $locale->text('ea');
1300 $lxdebug->leave_sub();
1304 $lxdebug->enter_sub();
1306 if ($form->{type} eq 'purchase_order') {
1307 $form->{title} = $locale->text('Purchase Orders');
1308 $form->{vc} = 'vendor';
1309 $ordlabel = $locale->text('Order Number');
1310 $ordnumber = 'ordnumber';
1311 $employee = $locale->text('Employee');
1314 if ($form->{type} eq 'request_quotation') {
1315 $form->{title} = $locale->text('Request for Quotations');
1316 $form->{vc} = 'vendor';
1317 $ordlabel = $locale->text('RFQ Number');
1318 $ordnumber = 'quonumber';
1319 $employee = $locale->text('Employee');
1322 if ($form->{type} eq 'sales_order') {
1323 $form->{title} = $locale->text('Sales Orders');
1324 $form->{vc} = 'customer';
1325 $ordlabel = $locale->text('Order Number');
1326 $ordnumber = 'ordnumber';
1327 $employee = $locale->text('Employee');
1330 if ($form->{type} eq 'sales_quotation') {
1331 $form->{title} = $locale->text('Quotations');
1332 $form->{vc} = 'customer';
1333 $ordlabel = $locale->text('Quotation Number');
1334 $ordnumber = 'quonumber';
1335 $employee = $locale->text('Employee');
1338 # setup vendor / customer selection
1339 $form->all_vc(\%myconfig, $form->{vc},
1340 ($form->{vc} eq 'customer') ? "AR" : "AP");
1342 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1343 @{ $form->{"all_$form->{vc}"} };
1345 $vclabel = ucfirst $form->{vc};
1346 $vclabel = $locale->text($vclabel);
1348 # $locale->text('Vendor')
1349 # $locale->text('Customer')
1353 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1354 : qq|<input name=$form->{vc} size=35>|;
1357 if (@{ $form->{all_departments} }) {
1358 $form->{selectdepartment} = "<option>\n";
1361 $form->{selectdepartment} .=
1362 "<option>$_->{description}--$_->{id}\n"
1363 } (@{ $form->{all_departments} });
1368 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1369 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1371 | if $form->{selectdepartment};
1374 if (($form->{"type"} eq "sales_order") ||
1375 ($form->{"type"} eq "purchase_order")) {
1378 <td><input name="notdelivered" id="notdelivered" class="checkbox" type="checkbox" value="1" checked>
1379 <label for="notdelivered">|. $locale->text('Not delivered') . qq|</label></td>
1380 <td><input name="delivered" id="delivered" class="checkbox" type="checkbox" value="1" checked>
1381 <label for="delivered">| . $locale->text('Delivered') . qq|</label></td>
1386 # use JavaScript Calendar or not
1387 $form->{jsscript} = $jscalendar;
1389 if ($form->{jsscript}) {
1391 # with JavaScript Calendar
1393 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1394 <input type=button name=transdatefrom id="trigger3" value=|
1395 . $locale->text('button') . qq|></td>
1398 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1399 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1400 . $locale->text('button') . qq|></td>
1405 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1406 "transdateto", "BL", "trigger4");
1409 # without JavaScript Calendar
1411 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1413 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1416 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1421 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1422 push(@values, $item->{"id"});
1423 $labels{$item->{"id"}} = $item->{"projectnumber"};
1426 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1427 '-labels' => \%labels));
1434 <form method=post action=$form->{script}>
1438 <th class=listtop>$form->{title}</th>
1440 <tr height="5"></tr>
1445 <th align=right>$vclabel</th>
1446 <td colspan=3>$vc</td>
1450 <th align=right>$ordlabel</th>
1451 <td colspan=3><input name="$ordnumber" size=20></td>
1454 <th align="right">| . $locale->text("Project Number") . qq|</th>
1455 <td colspan="3">$projectnumber</td>
1458 <th align=right>| . $locale->text('From') . qq|</th>
1460 <th align=right>| . $locale->text('Bis') . qq|</th>
1463 <input type=hidden name=sort value=transdate>
1465 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1469 <td><input type="checkbox" name="open" value="1" id="open" checked>
1470 <label for="open">| . $locale->text("Open") . qq|</td>
1471 <td><input type="checkbox" name="closed" value="1" id="closed">
1472 <label for="closed">| . $locale->text("Closed") . qq|</td>
1476 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1477 | . $locale->text('ID') . qq|</td>
1478 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1479 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1480 . $locale->text('Date') . qq|</td>
1481 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1482 . $locale->text('Required by') . qq|</td>
1485 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1486 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1487 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1488 . $locale->text('Ship via') . qq|</td>
1489 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1492 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1493 . $locale->text('Amount') . qq|</td>
1494 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1495 . $locale->text('Tax') . qq|</td>
1496 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1497 . $locale->text('Total') . qq|</td>
1498 <td><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y> |
1499 . $locale->text('Project Number') . qq|</td>
1502 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1503 . $locale->text('Subtotal') . qq|</td>
1511 <tr><td colspan=4><hr size=3 noshade></td></tr>
1517 <input type=hidden name=nextsub value=orders>
1518 <input type=hidden name=path value=$form->{path}>
1519 <input type=hidden name=login value=$form->{login}>
1520 <input type=hidden name=password value=$form->{password}>
1521 <input type=hidden name=vc value=$form->{vc}>
1522 <input type=hidden name=type value=$form->{type}>
1524 <input class=submit type=submit name=action value="|
1525 . $locale->text('Continue') . qq|">
1532 $lxdebug->leave_sub();
1536 $lxdebug->enter_sub();
1538 # split vendor / customer
1539 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1540 split(/--/, $form->{ $form->{vc} });
1542 OE->transactions(\%myconfig, \%$form);
1544 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1546 $number = $form->escape($form->{$ordnumber});
1547 $name = $form->escape($form->{ $form->{vc} });
1548 $department = $form->escape($form->{department});
1552 "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}¬delivered=$form->{notdelivered}&delivered=$form->{delivered}&$ordnumber=$number&$form->{vc}=$name&department=$department";
1554 # construct callback
1555 $number = $form->escape($form->{$ordnumber}, 1);
1556 $name = $form->escape($form->{ $form->{vc} }, 1);
1557 $department = $form->escape($form->{department}, 1);
1560 "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}¬delivered=$form->{notdelivered}&delivered=$form->{delivered}&$ordnumber=$number&$form->{vc}=$name&department=$department";
1563 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1564 "name", "netamount", "tax", "amount",
1565 "curr", "employee", "shipvia", "globalprojectnumber",
1566 "open", "closed", "delivered");
1568 $form->{l_open} = $form->{l_closed} = "Y"
1569 if ($form->{open} && $form->{closed});
1571 $form->{"l_delivered"} = "Y"
1572 if ($form->{"delivered"} && $form->{"notdelivered"});
1574 foreach $item (@columns) {
1575 if ($form->{"l_$item"} eq "Y") {
1576 push @column_index, $item;
1578 # add column to href and callback
1579 $callback .= "&l_$item=Y";
1580 $href .= "&l_$item=Y";
1584 # only show checkboxes if gotten here via sales_order form.
1585 if ($form->{type} =~ /sales_order/) {
1586 unshift @column_index, "ids";
1589 if ($form->{l_subtotal} eq 'Y') {
1590 $callback .= "&l_subtotal=Y";
1591 $href .= "&l_subtotal=Y";
1594 if ($form->{vc} eq 'vendor') {
1595 if ($form->{type} eq 'purchase_order') {
1596 $form->{title} = $locale->text('Purchase Orders');
1598 $form->{title} = $locale->text('Request for Quotations');
1600 $name = $locale->text('Vendor');
1601 $employee = $locale->text('Employee');
1603 if ($form->{vc} eq 'customer') {
1604 if ($form->{type} eq 'sales_order') {
1605 $form->{title} = $locale->text('Sales Orders');
1607 $form->{title} = $locale->text('Quotations');
1609 $employee = $locale->text('Employee');
1610 $name = $locale->text('Customer');
1613 $column_header{id} =
1614 qq|<th><a class=listheading href=$href&sort=id>|
1615 . $locale->text('ID')
1617 $column_header{transdate} =
1618 qq|<th><a class=listheading href=$href&sort=transdate>|
1619 . $locale->text('Date')
1621 $column_header{reqdate} =
1622 qq|<th><a class=listheading href=$href&sort=reqdate>|
1623 . $locale->text('Required by')
1625 $column_header{ordnumber} =
1626 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1627 . $locale->text('Order')
1629 $column_header{quonumber} =
1630 qq|<th><a class=listheading href=$href&sort=quonumber>|
1631 . ($form->{"type"} eq "request_quotation" ?
1632 $locale->text('RFQ') :
1633 $locale->text('Quotation'))
1635 $column_header{name} =
1636 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1637 $column_header{netamount} =
1638 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1639 $column_header{tax} =
1640 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1641 $column_header{amount} =
1642 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1643 $column_header{curr} =
1644 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1645 $column_header{shipvia} =
1646 qq|<th><a class=listheading href=$href&sort=shipvia>|
1647 . $locale->text('Ship via')
1649 $column_header{globalprojectnumber} =
1650 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1651 $column_header{open} =
1652 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1653 $column_header{closed} =
1654 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1655 $column_header{"delivered"} =
1656 qq|<th class="listheading">| . $locale->text("Delivered") . qq|</th>|;
1658 $column_header{employee} =
1659 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1661 $column_header{ids} = qq|<th></th>|;
1663 if ($form->{ $form->{vc} }) {
1664 $option = $locale->text(ucfirst $form->{vc});
1665 $option .= " : $form->{$form->{vc}}";
1667 if ($form->{department}) {
1668 $option .= "\n<br>" if ($option);
1669 ($department) = split /--/, $form->{department};
1670 $option .= $locale->text('Department') . " : $department";
1672 if ($form->{transdatefrom}) {
1674 . $locale->text('From') . " "
1675 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1677 if ($form->{transdateto}) {
1679 . $locale->text('Bis') . " "
1680 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1682 if ($form->{open}) {
1683 $option .= "\n<br>" if ($option);
1684 $option .= $locale->text('Open');
1686 if ($form->{closed}) {
1687 $option .= "\n<br>" if ($option);
1688 $option .= $locale->text('Closed');
1696 <form method="post" action="oe.pl">
1699 <th class=listtop>$form->{title}</th>
1701 <tr height="5"></tr>
1708 <tr class=listheading>|;
1710 map { print "\n$column_header{$_}" } @column_index;
1716 # add sort and escape callback
1717 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1719 if (@{ $form->{OE} }) {
1720 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1725 foreach $oe (@{ $form->{OE} }) {
1726 $form->{rowcount} = ++$j;
1728 if ($form->{l_subtotal} eq 'Y') {
1729 if ($sameitem ne $oe->{ $form->{sort} }) {
1731 $sameitem = $oe->{ $form->{sort} };
1735 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1737 $column_data{netamount} =
1739 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1741 $column_data{tax} = "<td align=right>"
1742 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1745 $column_data{amount} =
1747 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1749 $totalnetamount += $oe->{netamount};
1750 $totalamount += $oe->{amount};
1752 $subtotalnetamount += $oe->{netamount};
1753 $subtotalamount += $oe->{amount};
1756 qq|<td><input name="multi_id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1757 $column_data{id} = "<td>$oe->{id}</td>";
1758 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1759 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1761 $column_data{$ordnumber} =
1762 "<td><a href=oe.pl?path=$form->{path}&action=$action&type=$form->{type}&id=$oe->{id}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&callback=$callback_escaped>$oe->{$ordnumber}</a></td>";
1763 $column_data{name} = "<td>$oe->{name}</td>";
1765 $column_data{employee} = "<td>$oe->{employee} </td>";
1766 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1767 $column_data{globalprojectnumber} = "<td>" . H($oe->{globalprojectnumber}) . "</td>";
1769 if ($oe->{closed}) {
1770 $column_data{closed} = "<td align=center>X</td>";
1771 $column_data{open} = "<td> </td>";
1773 $column_data{closed} = "<td> </td>";
1774 $column_data{open} = "<td align=center>X</td>";
1776 $column_data{"delivered"} = "<td>" .
1777 ($oe->{"delivered"} ? $locale->text("Yes") : $locale->text("No")) .
1783 <tr class=listrow$i>";
1785 map { print "\n$column_data{$_}" } @column_index;
1793 if ($form->{l_subtotal} eq 'Y') {
1799 <tr class=listtotal>|;
1801 map { $column_data{$_} = "<td> </td>" } @column_index;
1803 $column_data{netamount} =
1804 "<th class=listtotal align=right>"
1805 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1806 $column_data{tax} = "<th class=listtotal align=right>"
1807 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1810 $column_data{amount} =
1811 "<th class=listtotal align=right>"
1812 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1814 map { print "\n$column_data{$_}" } @column_index;
1822 <td><hr size=3 noshade></td>
1826 # multiple invoice edit button only if gotten there via sales_order form.
1828 if ($form->{type} =~ /sales_order/) {
1830 <input type="hidden" name="path" value="$form->{path}">
1831 <input class"submit" type="submit" name="action" value="|
1832 . $locale->text('Continue') . qq|">
1833 <input type="hidden" name="nextsub" value="edit">
1834 <input type="hidden" name="type" value="$form->{type}">
1835 <input type="hidden" name="vc" value="$form->{vc}">
1836 <input type="hidden" name="login" value="$form->{login}">
1837 <input type="hidden" name="password" value="$form->{password}">
1838 <input type="hidden" name="callback" value="$callback">
1839 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1846 <form method=post action=$form->{script}>
1848 <input name=callback type=hidden value="$form->{callback}">
1850 <input type=hidden name=type value=$form->{type}>
1851 <input type=hidden name=vc value=$form->{vc}>
1853 <input type=hidden name=path value=$form->{path}>
1854 <input type=hidden name=login value=$form->{login}>
1855 <input type=hidden name=password value=$form->{password}>
1863 $lxdebug->leave_sub();
1867 $lxdebug->enter_sub();
1869 map { $column_data{$_} = "<td> </td>" } @column_index;
1871 $column_data{netamount} =
1872 "<th class=listsubtotal align=right>"
1873 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1875 $column_data{tax} = "<td class=listsubtotal align=right>"
1876 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1879 $column_data{amount} =
1880 "<th class=listsubtotal align=right>"
1881 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1883 $subtotalnetamount = 0;
1884 $subtotalamount = 0;
1887 <tr class=listsubtotal>
1890 map { print "\n$column_data{$_}" } @column_index;
1896 $lxdebug->leave_sub();
1899 sub save_and_close {
1900 $lxdebug->enter_sub();
1902 if ($form->{type} =~ /_order$/) {
1903 $form->isblank("transdate", $locale->text('Order Date missing!'));
1905 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1908 $msg = ucfirst $form->{vc};
1909 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1911 # $locale->text('Customer missing!');
1912 # $locale->text('Vendor missing!');
1914 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1915 if ($form->{currency} ne $form->{defaultcurrency});
1919 # if the name changed get new values
1920 if (&check_name($form->{vc})) {
1925 $form->{id} = 0 if $form->{saveasnew};
1927 # this is for the internal notes section for the [email] Subject
1928 if ($form->{type} =~ /_order$/) {
1929 if ($form->{type} eq 'sales_order') {
1930 $form->{label} = $locale->text('Sales Order');
1932 $numberfld = "sonumber";
1933 $ordnumber = "ordnumber";
1935 $form->{label} = $locale->text('Purchase Order');
1937 $numberfld = "ponumber";
1938 $ordnumber = "ordnumber";
1941 $err = $locale->text('Cannot save order!');
1944 if ($form->{type} eq 'sales_quotation') {
1945 $form->{label} = $locale->text('Quotation');
1947 $numberfld = "sqnumber";
1948 $ordnumber = "quonumber";
1950 $form->{label} = $locale->text('Request for Quotation');
1952 $numberfld = "rfqnumber";
1953 $ordnumber = "quonumber";
1956 $err = $locale->text('Cannot save quotation!');
1960 # get new number in sequence if no number is given or if saveasnew was requested
1961 if (!$form->{$ordnumber} || $form->{saveasnew}) {
1962 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
1967 $form->error($err) if (!OE->save(\%myconfig, \%$form));
1969 # saving the history
1970 if(!exists $form->{addition}) {
1971 $form->{addition} = "SAVED";
1972 $form->save_history($form->dbconnect(\%myconfig));
1974 # /saving the history
1976 $form->redirect($form->{label} . " $form->{$ordnumber} " .
1977 $locale->text('saved!'));
1979 $lxdebug->leave_sub();
1983 $lxdebug->enter_sub();
1985 if ($form->{type} =~ /_order$/) {
1986 $form->isblank("transdate", $locale->text('Order Date missing!'));
1988 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1991 $msg = ucfirst $form->{vc};
1992 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1994 # $locale->text('Customer missing!');
1995 # $locale->text('Vendor missing!');
1997 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1998 if ($form->{currency} ne $form->{defaultcurrency});
2002 # if the name changed get new values
2003 if (&check_name($form->{vc})) {
2008 $form->{id} = 0 if $form->{saveasnew};
2010 # this is for the internal notes section for the [email] Subject
2011 if ($form->{type} =~ /_order$/) {
2012 if ($form->{type} eq 'sales_order') {
2013 $form->{label} = $locale->text('Sales Order');
2015 $numberfld = "sonumber";
2016 $ordnumber = "ordnumber";
2018 $form->{label} = $locale->text('Purchase Order');
2020 $numberfld = "ponumber";
2021 $ordnumber = "ordnumber";
2024 $err = $locale->text('Cannot save order!');
2027 if ($form->{type} eq 'sales_quotation') {
2028 $form->{label} = $locale->text('Quotation');
2030 $numberfld = "sqnumber";
2031 $ordnumber = "quonumber";
2033 $form->{label} = $locale->text('Request for Quotation');
2035 $numberfld = "rfqnumber";
2036 $ordnumber = "quonumber";
2039 $err = $locale->text('Cannot save quotation!');
2043 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
2044 unless $form->{$ordnumber};
2048 OE->save(\%myconfig, \%$form);
2050 # saving the history
2051 if(!exists $form->{addition}) {
2052 $form->{addition} = "SAVED";
2053 $form->save_history($form->dbconnect(\%myconfig));
2055 # /saving the history
2057 $form->{simple_save} = 1;
2058 if(!$form->{print_and_save}) {
2059 set_headings("edit");
2063 $lxdebug->leave_sub();
2067 $lxdebug->enter_sub();
2071 if ($form->{type} =~ /_order$/) {
2072 $msg = $locale->text('Are you sure you want to delete Order Number');
2073 $ordnumber = 'ordnumber';
2075 $msg = $locale->text('Are you sure you want to delete Quotation Number');
2076 $ordnumber = 'quonumber';
2082 <form method=post action=$form->{script}>
2085 # delete action variable
2086 map { delete $form->{$_} } qw(action header);
2088 foreach $key (keys %$form) {
2089 $form->{$key} =~ s/\"/"/g;
2090 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2094 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
2096 <h4>$msg $form->{$ordnumber}</h4>
2098 <input name=action class=submit type=submit value="|
2099 . $locale->text('Yes') . qq|">
2106 $lxdebug->leave_sub();
2110 $lxdebug->enter_sub();
2112 if ($form->{type} =~ /_order$/) {
2113 $msg = $locale->text('Order deleted!');
2114 $err = $locale->text('Cannot delete order!');
2116 $msg = $locale->text('Quotation deleted!');
2117 $err = $locale->text('Cannot delete quotation!');
2119 if (OE->delete(\%myconfig, \%$form, $spool)){
2120 $form->redirect($msg);
2121 # saving the history
2122 if(!exists $form->{addition}) {
2123 $form->{addition} = "DELETED";
2124 $form->save_history($form->dbconnect(\%myconfig));
2126 # /saving the history
2130 $lxdebug->leave_sub();
2134 $lxdebug->enter_sub();
2136 if ($form->{type} =~ /_order$/) {
2138 # these checks only apply if the items don't bring their own ordnumbers/transdates.
2139 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
2140 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
2141 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }->{''});
2142 $form->isblank("transdate", $locale->text('Order Date missing!'))
2143 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }->{''});
2145 # also copy deliverydate from the order
2146 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
2147 $form->{orddate} = $form->{transdate};
2149 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
2150 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2151 $form->{ordnumber} = "";
2152 $form->{quodate} = $form->{transdate};
2155 # if the name changed get new values
2156 if (&check_name($form->{vc})) {
2161 $form->{cp_id} *= 1;
2163 for $i (1 .. $form->{rowcount}) {
2164 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
2165 $form->{"${_}_${i}"})
2166 if ($form->{"${_}_${i}"}) }
2167 qw(ship qty sellprice listprice basefactor));
2170 if ( $form->{type} =~ /_order/
2171 && $form->{currency} ne $form->{defaultcurrency}) {
2173 # check if we need a new exchangerate
2174 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
2176 $orddate = $form->current_date(\%myconfig);
2178 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
2181 if (!$exchangerate) {
2182 &backorder_exchangerate($orddate, $buysell);
2187 # close orders/quotations
2188 $form->{closed} = 1;
2190 # save order if one ordnumber has been given
2191 # if not it's most likely a collective order, which can't be saved back
2192 # so they just have to be closed
2193 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
2194 OE->close_order(\%myconfig, \%$form);
2196 OE->close_orders(\%myconfig, \%$form);
2199 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
2201 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2204 $form->{closed} = 0;
2205 $form->{rowcount}--;
2206 $form->{shipto} = 1;
2208 if ($form->{type} =~ /_order$/) {
2209 $form->{exchangerate} = $exchangerate;
2213 if ( $form->{type} eq 'purchase_order'
2214 || $form->{type} eq 'request_quotation') {
2215 $form->{title} = $locale->text('Add Vendor Invoice');
2216 $form->{script} = 'ir.pl';
2220 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
2221 $form->{title} = $locale->text('Add Sales Invoice');
2222 $form->{script} = 'is.pl';
2227 # bo creates the id, reset it
2228 map { delete $form->{$_} }
2229 qw(id subject message cc bcc printed emailed queued);
2230 $form->{ $form->{vc} } =~ s/--.*//g;
2231 $form->{type} = "invoice";
2234 $locale = new Locale "$myconfig{countrycode}", "$script";
2236 require "$form->{path}/$form->{script}";
2238 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
2240 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2241 qw(creditlimit creditremaining);
2243 $currency = $form->{currency};
2246 $form->{currency} = $currency;
2247 $form->{exchangerate} = "";
2248 $form->{forex} = "";
2249 $form->{exchangerate} = $exchangerate
2253 $form->check_exchangerate(
2254 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
2257 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
2262 for $i (1 .. $form->{rowcount}) {
2263 $form->{"discount_$i"} =
2264 $form->format_amount(\%myconfig, $form->{"discount_$i"});
2266 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
2268 $decimalplaces = ($dec > 2) ? $dec : 2;
2270 # copy delivery date from reqdate for order -> invoice conversion
2271 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
2272 unless $form->{"deliverydate_$i"};
2274 $form->{"sellprice_$i"} =
2275 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
2278 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
2279 $dec_qty = length $dec_qty;
2281 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
2283 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2284 qw(partnumber description unit);
2290 $lxdebug->leave_sub();
2293 sub backorder_exchangerate {
2294 $lxdebug->enter_sub();
2295 my ($orddate, $buysell) = @_;
2302 <form method=post action=$form->{script}>
2305 # delete action variable
2306 map { delete $form->{$_} } qw(action header exchangerate);
2308 foreach $key (keys %$form) {
2309 $form->{$key} =~ s/\"/"/g;
2310 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2313 $form->{title} = $locale->text('Add Exchangerate');
2317 <input type=hidden name=path value=$form->{path}>
2318 <input type=hidden name=login value=$form->{login}>
2319 <input type=hidden name=password value=$form->{password}>
2321 <input type=hidden name=exchangeratedate value=$orddate>
2322 <input type=hidden name=buysell value=$buysell>
2325 <tr><th class=listtop>$form->{title}</th></tr>
2326 <tr height="5"></tr>
2331 <th align=right>| . $locale->text('Currency') . qq|</th>
2332 <td>$form->{currency}</td>
2335 <th align=right>| . $locale->text('Date') . qq|</th>
2339 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2340 <td><input name=exchangerate size=11></td>
2350 <input type=hidden name=nextsub value=save_exchangerate>
2352 <input name=action class=submit type=submit value="|
2353 . $locale->text('Continue') . qq|">
2361 $lxdebug->leave_sub();
2364 sub save_exchangerate {
2365 $lxdebug->enter_sub();
2367 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2368 $form->{exchangerate} =
2369 $form->parse_amount(\%myconfig, $form->{exchangerate});
2370 $form->save_exchangerate(\%myconfig, $form->{currency},
2371 $form->{exchangeratedate},
2372 $form->{exchangerate}, $form->{buysell});
2376 $lxdebug->leave_sub();
2379 sub create_backorder {
2380 $lxdebug->enter_sub();
2382 $form->{shipped} = 1;
2384 # figure out if we need to create a backorder
2385 # items aren't saved if qty != 0
2387 for $i (1 .. $form->{rowcount}) {
2388 $totalqty += $qty = $form->{"qty_$i"};
2389 $totalship += $ship = $form->{"ship_$i"};
2391 $form->{"qty_$i"} = $qty - $ship;
2394 if ($totalship == 0) {
2395 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2396 $form->{ordtotal} = 0;
2397 $form->{shipped} = 0;
2401 if ($totalqty == $totalship) {
2402 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2403 $form->{ordtotal} = 0;
2408 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2411 for $i (1 .. $form->{rowcount}) {
2413 $form->{"${_}_$i"} =
2414 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2415 } qw(sellprice discount);
2420 OE->save(\%myconfig, \%$form);
2422 # rebuild rows for invoice
2426 for $i (1 .. $form->{rowcount}) {
2427 $form->{"qty_$i"} = $form->{"ship_$i"};
2429 if ($form->{"qty_$i"}) {
2432 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2437 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2438 $form->{rowcount} = $count;
2440 $lxdebug->leave_sub();
2444 $lxdebug->enter_sub();
2446 $form->{saveasnew} = 1;
2447 $form->{closed} = 0;
2448 map { delete $form->{$_} } qw(printed emailed queued);
2450 # Let Lx-Office assign a new order number if the user hasn't changed the
2451 # previous one. If it has been changed manually then use it as-is.
2452 my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
2453 if ($form->{saved_xyznumber} &&
2454 ($form->{saved_xyznumber} eq $form->{$idx})) {
2455 delete($form->{$idx});
2460 $lxdebug->leave_sub();
2463 sub purchase_order {
2464 $lxdebug->enter_sub();
2466 if ( $form->{type} eq 'sales_quotation'
2467 || $form->{type} eq 'request_quotation') {
2468 OE->close_order(\%myconfig, \%$form);
2471 $form->{cp_id} *= 1;
2473 $form->{title} = $locale->text('Add Purchase Order');
2474 $form->{vc} = "vendor";
2475 $form->{type} = "purchase_order";
2479 $lxdebug->leave_sub();
2483 $lxdebug->enter_sub();
2485 if ( $form->{type} eq 'sales_quotation'
2486 || $form->{type} eq 'request_quotation') {
2487 OE->close_order(\%myconfig, $form);
2490 $form->{cp_id} *= 1;
2492 $form->{title} = $locale->text('Add Sales Order');
2493 $form->{vc} = "customer";
2494 $form->{type} = "sales_order";
2498 $lxdebug->leave_sub();
2502 $lxdebug->enter_sub();
2504 $form->{transdate} = $form->current_date(\%myconfig);
2505 delete $form->{duedate};
2507 $form->{closed} = 0;
2510 map { delete $form->{$_} }
2511 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2513 for $i (1 .. $form->{rowcount}) {
2514 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
2515 $form->{"${_}_${i}"})
2516 if ($form->{"${_}_${i}"}) }
2517 qw(ship qty sellprice listprice basefactor));
2525 for $i (1 .. $form->{rowcount} - 1) {
2526 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2527 qw(partnumber description unit);
2530 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2531 qw(creditlimit creditremaining);
2535 $lxdebug->leave_sub();
2539 $lxdebug->enter_sub();
2541 $form->{saveasnew} = 1;
2542 $form->{closed} = 0;
2543 $form->{print_and_save} = 1;
2544 map { delete $form->{$_} } qw(printed emailed queued);
2546 # Let Lx-Office assign a new order number if the user hasn't changed the
2547 # previous one. If it has been changed manually then use it as-is.
2548 my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
2549 if ($form->{saved_xyznumber} &&
2550 ($form->{saved_xyznumber} eq $form->{$idx})) {
2551 delete($form->{$idx});
2558 $lxdebug->leave_sub();