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 "bin/mozilla/io.pl";
41 require "bin/mozilla/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}&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();
160 # get customer/vendor
161 $form->all_vc(\%myconfig, $form->{vc},
162 ($form->{vc} eq 'customer') ? "AR" : "AP");
164 # retrieve order/quotation
165 $form->{webdav} = $webdav;
167 $form->{jscalendar} = $jscalendar;
169 my $editing = $form->{id};
171 OE->retrieve(\%myconfig, \%$form);
173 if ($form->{payment_id}) {
174 $payment_id = $form->{payment_id};
176 if ($form->{language_id}) {
177 $language_id = $form->{language_id};
179 if ($form->{taxzone_id}) {
180 $taxzone_id = $form->{taxzone_id};
183 $salesman_id = $form->{salesman_id} if ($editing);
186 # if multiple rowcounts (== collective order) then check if the
187 # there were more than one customer (in that case OE::retrieve removes
188 # the content from the field)
189 if ( $form->{rowcount}
190 && $form->{type} eq 'sales_order'
191 && defined $form->{customer}
192 && $form->{customer} eq '') {
194 # $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
197 'Collective Orders only work for orders from one customer!')
201 $taxincluded = $form->{taxincluded};
202 $form->{shipto} = 1 if $form->{id};
204 if ($form->{"all_$form->{vc}"}) {
205 unless ($form->{"$form->{vc}_id"}) {
206 $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
210 $cp_id = $form->{cp_id};
211 $intnotes = $form->{intnotes};
213 # get customer / vendor
214 if ($form->{type} =~ /(purchase_order|request_quotation)/) {
215 IR->get_vendor(\%myconfig, \%$form);
217 #quote all_vendor Bug 133
218 foreach $ref (@{ $form->{all_vendor} }) {
219 $ref->{name} = $form->quote($ref->{name});
223 if ($form->{type} =~ /sales_(order|quotation)/) {
224 IS->get_customer(\%myconfig, \%$form);
226 #quote all_vendor Bug 133
227 foreach $ref (@{ $form->{all_customer} }) {
228 $ref->{name} = $form->quote($ref->{name});
232 $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}"} .=
253 "<option>$_->{name}--$_->{id}</option>\n" }
254 (@{ $form->{"all_$form->{vc}"} });
257 $form->{taxincluded} = $taxincluded if ($form->{id});
260 if (@{ $form->{all_departments} }) {
261 $form->{selectdepartment} = "<option>\n";
262 $form->{department} = "$form->{department}--$form->{department_id}";
265 $form->{selectdepartment} .=
266 "<option>$_->{description}--$_->{id}</option>\n"
267 } (@{ $form->{all_departments} });
270 $form->{employee} = "$form->{employee}--$form->{employee_id}";
273 $form->{forex} = $form->{exchangerate};
275 $form->{salesman_id} = $salesman_id if ($editing);
277 $lxdebug->leave_sub();
281 $lxdebug->enter_sub();
282 $form->{formname} = $form->{type} unless $form->{formname};
285 foreach $ref (@{ $form->{form_details} }) {
286 $form->{rowcount} = ++$i;
288 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
290 for my $i (1 .. $form->{rowcount}) {
292 $form->{"discount_$i"} =
293 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
295 $form->{"discount_$i"} =
296 $form->format_amount(\%myconfig, $form->{"discount_$i"});
298 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
300 $decimalplaces = ($dec > 2) ? $dec : 2;
302 # copy reqdate from deliverydate for invoice -> order conversion
303 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
304 unless $form->{"reqdate_$i"};
306 $form->{"sellprice_$i"} =
307 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
310 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
311 $dec_qty = length $dec_qty;
313 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
315 map { $form->{"${_}_$i"} =~ s/\"/"/g }
316 qw(partnumber description unit);
319 $lxdebug->leave_sub();
323 $lxdebug->enter_sub();
325 my $checkedclosed = $form->{"closed"} ? "checked" : "";
326 my $checkeddelivered = $form->{"delivered"} ? "checked" : "";
328 map { $form->{$_} =~ s/\"/"/g }
329 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
330 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
331 shiptophone shiptofax shiptodepartment_1 shiptodepartment_2);
333 # use JavaScript Calendar or not
334 $form->{jsscript} = $form->{jscalendar};
337 if ($form->{jsscript}) {
339 # with JavaScript Calendar
341 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\"></td>
342 <td><input type=button name=transdate id="trigger1" value=|
343 . $locale->text('button') . qq|></td>
346 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value="$form->{reqdate}" onBlur=\"check_right_date_format(this)\"></td>
347 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
348 . $locale->text('button') . qq|></td>
353 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
354 "reqdate", "BL", "trigger2");
358 # without JavaScript Calendar
360 <td><input name="transdate" id="transdate" size="11" title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\"></td>|;
362 <td width="13"><input name="reqdate" id="reqdate" size="11" title="$myconfig{dateformat}" value="$form->{reqdate}" onBlur=\"check_right_date_format(this)\"></td>|;
367 if (($form->{"type"} eq "sales_order") ||
368 ($form->{"type"} eq "purchase_order")) {
370 <input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" $checkeddelivered>
371 <label for="delivered">| . $locale->text('Delivered') . qq|</label>|);
376 <input name="closed" id="closed" type="checkbox" class="checkbox" value="1" $checkedclosed>
377 <label for="closed">| . $locale->text('Closed') . qq|</label>|);
383 <td colspan=| . (2 * scalar(@tmp)) . qq| align=center>| . join("\n", @tmp) . qq|
389 # set option selected
390 foreach $item ($form->{vc}, currency, department, employee, ($form->{vc} eq "customer" ? customer : vendor)) {
391 $form->{"select$item"} =~ s/ selected//;
392 $form->{"select$item"} =~
393 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
396 #quote select[customer|vendor] Bug 133
397 $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
399 #substitute \n and \r to \s (bug 543)
400 $form->{"select$form->{vc}"} =~ s/[\n\r]/ /g;
402 my @old_project_ids = ($form->{"globalproject_id"});
403 map({ push(@old_project_ids, $form->{"project_id_$_"})
404 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
406 $form->get_lists("contacts" => "ALL_CONTACTS",
407 "shipto" => "ALL_SHIPTO",
408 "projects" => { "key" => "ALL_PROJECTS",
410 "old_id" => \@old_project_ids },
411 "employees" => "ALL_SALESMEN",
412 "taxzones" => "ALL_TAXZONES",
413 "payments" => "ALL_PAYMENTS",
414 "currencies" => "ALL_CURRENCIES");
415 ($form->{vc} eq "customer"
416 ? $form->get_lists("customers" => "ALL_CUSTOMERS")
417 : $form->get_lists("vendors" => "ALL_VENDORS"));
420 my @values = (undef);
421 foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
422 push(@values, $item->{"cp_id"});
423 $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
424 ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
427 NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
428 '-labels' => \%labels, '-default' => $form->{"cp_id"}));
433 foreach my $item (@{ $form->{($form->{vc} eq "customer" ? "ALL_CUSTOMERS" : "ALL_VENDORS")}}) {
434 push(@values, $item->{name}.qq|--|.$item->{"id"});
435 $labels{$item->{"id"}} = $item->{name}.qq|--|.$item->{"id"};
439 <th align="right">| . $locale->text(ucfirst($form->{vc})) . qq|</th>
441 (($myconfig{vclimit} == 1 )
442 ? qq|<input type="text" value="$form->{old$form->{vc}}" name="$form->{vc}">|
443 : (NTI($cgi->popup_menu('-name' => "$form->{vc}", '-default' => $form->{"old$form->{vc}"},
444 '-onChange' => 'document.getElementById(\'update_button\').click();',
445 '-values' => \@values, '-labels' => \%labels)))) . qq|
446 </td><input type=hidden name="select$form->{vc}" value="| .
447 Q($form->{"select$form->{vc}"}) . qq|">|;
451 foreach my $item (@{ $form->{"ALL_PAYMENTS"} }) {
452 push(@values, $item->{"id"});
453 $labels{$item->{"id"}} = $item->{"description"};
457 <th align="right">| . $locale->text('Payment Terms') . qq|</th>
459 NTI($cgi->popup_menu('-name' => 'payment_id', '-values' => \@values,
460 '-labels' => \%labels, '-default' => $form->{payment_id}))
465 foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
466 push(@values, $item->{"shipto_id"});
467 $labels{$item->{"shipto_id"}} =
468 $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"};
472 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
474 NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
475 '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
480 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
481 push(@values, $item->{"id"});
482 $labels{$item->{"id"}} = $item->{"projectnumber"};
484 my $globalprojectnumber =
485 NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
486 '-labels' => \%labels,
487 '-default' => $form->{"globalproject_id"}));
490 if ($form->{type} =~ /^sales_/) {
493 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
494 push(@values, $item->{id});
495 $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
500 <th align="right">| . $locale->text('Salesman') . qq|</th>
502 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
503 '-values' => \@values, '-labels' => \%labels))
510 foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
511 push(@values, $item->{"id"});
512 $labels{$item->{"id"}} = $item->{"name"};
517 <th align="right">| . $locale->text('Employee') . qq|</th>
519 NTI($cgi->popup_menu('-name' => 'employee', '-default' => $form->{"employee"},
520 '-values' => \@values, '-labels' => \%labels)) . qq|
526 foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
527 push(@values, $item->{"id"});
528 $labels{$item->{"id"}} = $item->{"description"};
533 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
535 NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
536 '-values' => \@values, '-labels' => \%labels)) . qq|
543 foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) {
544 push(@values, $item);
545 $labels{$item} = $item;
548 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
551 <th align="right">| . $locale->text('Currency') . qq|</th>
553 NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
554 '-values' => \@values, '-labels' => \%labels)) . qq|
559 $form->{exchangerate} =
560 $form->format_amount(\%myconfig, $form->{exchangerate});
562 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
568 $form->{creditlimit} =
569 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
570 $form->{creditremaining} =
571 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
574 <input type=hidden name=forex value=$form->{forex}>
577 if ($form->{currency} ne $form->{defaultcurrency}) {
578 if ($form->{forex}) {
581 . $locale->text('Exchangerate')
582 . qq|</th><td>$form->{exchangerate}</td>
583 <input type=hidden name=exchangerate value=$form->{exchangerate}>
588 . $locale->text('Exchangerate')
589 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
593 if ($form->{business}) {
596 <th align=right>| . $locale->text('Business') . qq|</th>
597 <td>$form->{business}</td>
598 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
600 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
606 if ($form->{max_dunning_level}) {
612 <th align=right>| . $locale->text('Max. Dunning Level') . qq|:</th>
613 <td><b>$form->{max_dunning_level}</b></td>
614 <th align=right>| . $locale->text('Dunning Amount') . qq|:</th>
616 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
625 if ($form->{type} !~ /_quotation$/) {
628 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
629 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
632 <th width=70% align=right nowrap>|
633 . $locale->text('Quotation Number') . qq|</th>
634 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
637 <th width=70% align=right nowrap>|
638 . $locale->text('Customer Order Number') . qq|</th>
639 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
642 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
647 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
652 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
654 $creditremaining = qq|
660 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
661 <td>$form->{creditlimit}</td>
663 <th nowrap>| . $locale->text('Remaining') . qq|</th>
664 <td class="plus$n" nowrap>$form->{creditremaining}</td>
673 ($form->{type} eq 'sales_quotation')
674 ? $locale->text('Valid until')
675 : $locale->text('Required by');
676 if ($form->{type} eq 'sales_quotation') {
679 <th width=70% align=right nowrap>|
680 . $locale->text('Quotation Number') . qq|</th>
681 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
682 <input type=hidden name=ordnumber value="$form->{ordnumber}">
688 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
689 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
690 <input type=hidden name=ordnumber value="$form->{ordnumber}">
698 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
702 <th align=right nowrap=true>$reqlabel</th>
706 $creditremaining = qq| <tr>
714 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
715 <td colspan=3><select name=department>$form->{selectdepartment}</select>
716 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
718 </tr> | if $form->{selectdepartment};
720 if ($form->{type} eq 'sales_order') {
721 if ($form->{selectemployee}) {
723 <input type=hidden name=customer_klass value=$form->{customer_klass}>
729 <input type=hidden name=customer_klass value=$form->{customer_klass}>
733 if ($form->{resubmit} && ($form->{format} eq "html")) {
735 qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
736 } elsif ($form->{resubmit}) {
737 $onload = qq|document.oe.submit()|;
742 $credittext = $locale->text('Credit Limit exceeded!!!');
743 if ($creditwarning) {
744 $onload = qq|alert('$credittext')|;
747 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
748 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
750 $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
751 # show history button js
752 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
753 #/show history button js
757 <body onLoad="$onload">
759 <form method=post name=oe action=$form->{script}>
760 <script type="text/javascript" src="js/common.js"></script>
761 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
762 <script type="text/javascript" src="js/vendor_selection.js"></script>
763 <script type="text/javascript" src="js/calculate_qty.js"></script>
765 <input type=hidden name=id value=$form->{id}>
766 <input type=hidden name=action value=$form->{action}>
768 <input type=hidden name=type value=$form->{type}>
769 <input type=hidden name=formname value=$form->{formname}>
770 <input type=hidden name=media value=$form->{media}>
771 <input type=hidden name=format value=$form->{format}>
772 <input type=hidden name=proforma value=$form->{proforma}>
774 <input type=hidden name=queued value="$form->{queued}">
775 <input type=hidden name=printed value="$form->{printed}">
776 <input type=hidden name=emailed value="$form->{emailed}">
778 <input type=hidden name=vc value=$form->{vc}>
780 <input type=hidden name=title value="$form->{title}">
782 <input type=hidden name=discount value=$form->{discount}>
783 <input type=hidden name=creditlimit value=$form->{creditlimit}>
784 <input type=hidden name=creditremaining value=$form->{creditremaining}>
786 <input type=hidden name=tradediscount value=$form->{tradediscount}>
787 <input type=hidden name=business value=$form->{business}>
788 <input type=hidden name=webdav value=$webdav>
792 <th class=listtop>$form->{title}</th>
803 <th align=richt nowrap>|
804 . $locale->text('Contact Person') . qq|</th>
805 <td colspan=3>$contact</td>
817 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
818 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
821 <th align=right>| . $locale->text('Ship via') . qq|</th>
822 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
825 <th align="right">| . $locale->text('Transaction description') . qq|</th>
826 <td colspan="3"><input name="transaction_description" size="35" value="| . H($form->{transaction_description}) . qq|"></td>
833 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
835 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
836 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
840 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
842 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
843 # <input size=45 id=vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
857 <th width="70%" align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
858 <td>$globalprojectnumber</td>
869 <!-- shipto are in hidden variables -->
871 <input type=hidden name=shiptoname value="$form->{shiptoname}">
872 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
873 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
874 <input type=hidden name=shiptocity value="$form->{shiptocity}">
875 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
876 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
877 <input type=hidden name=shiptophone value="$form->{shiptophone}">
878 <input type=hidden name=shiptofax value="$form->{shiptofax}">
879 <input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
880 <input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
881 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
883 <!-- email variables -->
884 <input type=hidden name=message value="$form->{message}">
885 <input type=hidden name=email value="$form->{email}">
886 <input type=hidden name=subject value="$form->{subject}">
887 <input type=hidden name=cc value="$form->{cc}">
888 <input type=hidden name=bcc value="$form->{bcc}">
890 <input type=hidden name=taxpart value="$form->{taxpart}">
891 <input type=hidden name=taxservice value="$form->{taxservice}">
893 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
896 foreach $item (split / /, $form->{taxaccounts}) {
898 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
899 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
902 $lxdebug->leave_sub();
906 $lxdebug->enter_sub();
908 $form->{invtotal} = $form->{invsubtotal};
910 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
913 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
916 $rows = ($rows > $introws) ? $rows : $introws;
918 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
920 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
922 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
925 if ($form->{taxaccounts}) {
927 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
928 . $locale->text('Tax Included') . qq|</b><br><br>
932 if (!$form->{taxincluded}) {
934 foreach $item (split / /, $form->{taxaccounts}) {
935 if ($form->{"${item}_base"}) {
936 $form->{invtotal} += $form->{"${item}_total"} =
938 $form->{"${item}_base"} * $form->{"${item}_rate"},
940 $form->{"${item}_total"} =
941 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
945 <th align=right>$form->{"${item}_description"} |
946 . $form->{"${item}_rate"} * 100 .qq|%</th>
947 <td align=right>$form->{"${item}_total"}</td>
953 $form->{invsubtotal} =
954 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
958 <th align=right>| . $locale->text('Subtotal') . qq|</th>
959 <td align=right>$form->{invsubtotal}</td>
965 if ($form->{taxincluded}) {
966 foreach $item (split / /, $form->{taxaccounts}) {
967 if ($form->{"${item}_base"}) {
968 $form->{"${item}_total"} =
970 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
971 (1 + $form->{"${item}_rate"})
974 $form->{"${item}_netto"} =
976 ($form->{"${item}_base"} - $form->{"${item}_total"}),
978 $form->{"${item}_total"} =
979 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
980 $form->{"${item}_netto"} =
981 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
985 <th align=right>Enthaltene $form->{"${item}_description"} |
986 . $form->{"${item}_rate"} * 100 .qq|%</th>
987 <td align=right>$form->{"${item}_total"}</td>
990 <th align=right>Nettobetrag</th>
991 <td align=right>$form->{"${item}_netto"}</td>
999 $form->{oldinvtotal} = $form->{invtotal};
1001 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
1011 <th align=left>| . $locale->text('Notes') . qq|</th>
1012 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
1023 <td align=right width=100%>
1029 <th align=right>| . $locale->text('Total') . qq|</th>
1030 <td align=right>$form->{invtotal}</td>
1038 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
1039 <input type=hidden name=oldtotalpaid value=$totalpaid>
1041 <td><hr size=3 noshade></td>
1049 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
1052 <td align=left width=30%><b>Dateiname</b></td>
1053 <td align=left width=70%><b>Webdavlink</b></td>
1055 foreach $file (keys %{ $form->{WEBDAV} }) {
1058 <td align=left>$file</td>
1059 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
1067 <td><hr size=3 noshade></td>
1074 <input type=hidden name=jscalendar value=$form->{jscalendar}>
1087 | . $locale->text("Edit the $form->{type}") . qq|<br>
1088 <input class=submit type=submit name=action id=update_button value="|
1089 . $locale->text('Update') . qq|">
1090 <input class=submit type=submit name=action value="|
1091 . $locale->text('Ship to') . qq|">
1092 <input class=submit type=submit name=action value="|
1093 . $locale->text('Print') . qq|">
1094 <input class=submit type=submit name=action value="|
1095 . $locale->text('E-mail') . qq|">
1096 <input class=submit type=submit name=action value="|
1097 . $locale->text('Save') . qq|">
1098 <input class=submit type=submit name=action value="|
1099 . $locale->text('Save and Close') . qq|">
1102 if (($form->{id})) {
1104 <input type="button" class="submit" onclick="set_history_window(|
1106 . qq|);" name="history" id="history" value="|
1107 . $locale->text('history')
1110 <br>| . $locale->text("Workflow $form->{type}") . qq|<br>
1111 <input class=submit type=submit name=action value="|
1112 . $locale->text('Save as new') . qq|">
1113 <input class=submit type=submit name=action value="|
1114 . $locale->text('Delete') . qq|">|;
1115 if (($form->{type} =~ /sales_quotation$/)) {
1117 <input class=submit type=submit name=action value="|
1118 . $locale->text('Sales Order') . qq|">|;
1120 if ($form->{type} =~ /request_quotation$/) {
1122 <input class=submit type=submit name=action value="|
1123 . $locale->text('Purchase Order') . qq|">|;
1127 <input class=submit type=submit name=action value="|
1128 . $locale->text('Invoice') . qq|">
1132 if ($form->{type} =~ /sales_order$/) {
1134 <br>$form->{heading} als neue Vorlage verwenden für<br>
1135 <input class=submit type=submit name=action value="|
1136 . $locale->text('Purchase Order') . qq|">
1137 <input class=submit type=submit name=action value="|
1138 . $locale->text('Quotation') . qq|">
1141 } elsif ($form->{type} =~ /purchase_order$/) {
1143 <br>$form->{heading} als neue Vorlage verwenden für<br>
1144 <input class=submit type=submit name=action value="|
1145 . $locale->text('Sales Order') . qq|">
1146 <input class=submit type=submit name=action value="|
1147 . $locale->text('Request for Quotation') . qq|">
1152 <br>$form->{heading} als neue Vorlage verwenden für<br>
1153 <input class=submit type=submit name=action value="|
1154 . $locale->text('Order') . qq|">
1157 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount} && !$form->{proforma}) {
1159 <br>Workflow $form->{heading}<br>
1160 <input class=submit type=submit name=action value="|
1161 . $locale->text('Save as new') . qq|">
1162 <input class=submit type=submit name=action value="|
1163 . $locale->text('Invoice') . qq|">
1167 $form->hide_form("saved_xyznumber");
1171 <input type=hidden name=rowcount value=$form->{rowcount}>
1173 <input name=callback type=hidden value="$form->{callback}">
1175 <input type=hidden name=login value=$form->{login}>
1176 <input type=hidden name=password value=$form->{password}>
1183 $lxdebug->leave_sub();
1187 $lxdebug->enter_sub();
1189 set_headings($form->{"id"} ? "edit" : "add");
1191 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1192 qw(exchangerate creditlimit creditremaining);
1193 $form->{update} = 1;
1195 if($form->{payment_id}) {
1196 $payment_id = $form->{payment_id};
1199 &check_name($form->{vc});
1201 if($form->{payment_id} eq "") {
1202 $form->{payment_id} = $payment_id;
1206 $buysell = 'sell' if ($form->{vc} eq 'vendor');
1207 $form->{exchangerate} = $exchangerate
1211 $form->check_exchangerate(
1212 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1216 $i = $form->{rowcount};
1218 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1220 if ( ($form->{"partnumber_$i"} eq "")
1221 && ($form->{"description_$i"} eq "")
1222 && ($form->{"partsgroup_$i"} eq "")) {
1224 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1229 if ( $form->{type} eq 'purchase_order'
1230 || $form->{type} eq 'request_quotation') {
1231 IR->retrieve_item(\%myconfig, \%$form);
1233 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1234 IS->retrieve_item(\%myconfig, \%$form);
1237 my $rows = scalar @{ $form->{item_list} };
1239 $form->{"discount_$i"} =
1240 $form->format_amount(\%myconfig, $form->{discount} * 100);
1243 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1252 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1253 if ($form->{"not_discountable_$i"}) {
1254 $form->{"discount_$i"} = 0;
1256 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1257 qw(partnumber description unit);
1258 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1259 keys %{ $form->{item_list}[0] };
1260 if ($form->{"part_payment_id_$i"} ne "") {
1261 $form->{payment_id} = $form->{"part_payment_id_$i"};
1264 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1266 ($dec) = ($s =~ /\.(\d+)/);
1268 $decimalplaces = ($dec > 2) ? $dec : 2;
1271 $form->{"sellprice_$i"} = $sellprice;
1274 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1276 # if there is an exchange rate adjust sellprice
1277 $form->{"sellprice_$i"} /= $exchangerate;
1281 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1282 (1 - $form->{"discount_$i"} / 100);
1283 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1284 map { $form->{"${_}_base"} += $amount }
1285 (split / /, $form->{"taxaccounts_$i"});
1286 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1287 split / /, $form->{taxaccounts}
1288 if !$form->{taxincluded};
1290 $form->{creditremaining} -= $amount;
1292 $form->{"sellprice_$i"} =
1293 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1296 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1298 # get pricegroups for parts
1299 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1301 # build up html code for prices_$i
1302 &set_pricegroup($i);
1309 # ok, so this is a new part
1310 # ask if it is a part or service item
1312 if ( $form->{"partsgroup_$i"}
1313 && ($form->{"partsnumber_$i"} eq "")
1314 && ($form->{"description_$i"} eq "")) {
1315 $form->{rowcount}--;
1316 $form->{"discount_$i"} = "";
1320 $form->{"id_$i"} = 0;
1321 $form->{"unit_$i"} = $locale->text('ea');
1329 $lxdebug->leave_sub();
1333 $lxdebug->enter_sub();
1335 if ($form->{type} eq 'purchase_order') {
1336 $form->{title} = $locale->text('Purchase Orders');
1337 $form->{vc} = 'vendor';
1338 $ordlabel = $locale->text('Order Number');
1339 $ordnumber = 'ordnumber';
1340 $employee = $locale->text('Employee');
1343 if ($form->{type} eq 'request_quotation') {
1344 $form->{title} = $locale->text('Request for Quotations');
1345 $form->{vc} = 'vendor';
1346 $ordlabel = $locale->text('RFQ Number');
1347 $ordnumber = 'quonumber';
1348 $employee = $locale->text('Employee');
1351 if ($form->{type} eq 'sales_order') {
1352 $form->{title} = $locale->text('Sales Orders');
1353 $form->{vc} = 'customer';
1354 $ordlabel = $locale->text('Order Number');
1355 $ordnumber = 'ordnumber';
1356 $employee = $locale->text('Employee');
1359 if ($form->{type} eq 'sales_quotation') {
1360 $form->{title} = $locale->text('Quotations');
1361 $form->{vc} = 'customer';
1362 $ordlabel = $locale->text('Quotation Number');
1363 $ordnumber = 'quonumber';
1364 $employee = $locale->text('Employee');
1367 # setup vendor / customer selection
1368 $form->all_vc(\%myconfig, $form->{vc},
1369 ($form->{vc} eq 'customer') ? "AR" : "AP");
1372 if (@{ $form->{all_departments} }) {
1373 $form->{selectdepartment} = "<option>\n";
1376 $form->{selectdepartment} .=
1377 "<option>$_->{description}--$_->{id}</option>\n"
1378 } (@{ $form->{all_departments} });
1383 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1384 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1386 | if $form->{selectdepartment};
1389 if (($form->{"type"} eq "sales_order") ||
1390 ($form->{"type"} eq "purchase_order")) {
1393 <td><input name="notdelivered" id="notdelivered" class="checkbox" type="checkbox" value="1" checked>
1394 <label for="notdelivered">|. $locale->text('Not delivered') . qq|</label></td>
1395 <td><input name="delivered" id="delivered" class="checkbox" type="checkbox" value="1" checked>
1396 <label for="delivered">| . $locale->text('Delivered') . qq|</label></td>
1401 # use JavaScript Calendar or not
1402 $form->{jsscript} = $jscalendar;
1404 if ($form->{jsscript}) {
1406 # with JavaScript Calendar
1408 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
1409 <input type=button name=transdatefrom id="trigger3" value=|
1410 . $locale->text('button') . qq|></td>
1413 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\">
1414 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1415 . $locale->text('button') . qq|></td>
1420 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1421 "transdateto", "BL", "trigger4");
1424 # without JavaScript Calendar
1426 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\"></td>|;
1428 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}" onBlur=\"check_right_date_format(this)\></td>|;
1431 $form->get_lists("projects" => { "key" => "ALL_PROJECTS",
1436 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
1437 push(@values, $item->{"id"});
1438 $labels{$item->{"id"}} = $item->{"projectnumber"};
1441 NTI($cgi->popup_menu('-name' => 'project_id', '-values' => \@values,
1442 '-labels' => \%labels));
1449 <form method=post action=$form->{script}>
1453 <th class=listtop>$form->{title}</th>
1455 <tr height="5"></tr>
1464 <th align=right>$ordlabel</th>
1465 <td colspan=3><input name="$ordnumber" size=20></td>
1468 <th align="right">| . $locale->text('Transaction description') . qq|</th>
1469 <td colspan="3"><input name="transaction_description" size=20></td>
1472 <th align="right">| . $locale->text("Project Number") . qq|</th>
1473 <td colspan="3">$projectnumber</td>
1476 <th align=right>| . $locale->text('From') . qq|</th>
1478 <th align=right>| . $locale->text('Bis') . qq|</th>
1481 <input type=hidden name=sort value=transdate>
1483 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1487 <td><input type="checkbox" name="open" value="1" id="open" checked>
1488 <label for="open">| . $locale->text("Open") . qq|</td>
1489 <td><input type="checkbox" name="closed" value="1" id="closed">
1490 <label for="closed">| . $locale->text("Closed") . qq|</td>
1494 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1495 | . $locale->text('ID') . qq|</td>
1496 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1497 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1498 . $locale->text('Date') . qq|</td>
1499 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1500 . $locale->text('Required by') . qq|</td>
1503 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> ucfirst($form->{vc})</td>
1504 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1505 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1506 . $locale->text('Ship via') . qq|</td>
1507 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1510 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1511 . $locale->text('Amount') . qq|</td>
1512 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1513 . $locale->text('Tax') . qq|</td>
1514 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1515 . $locale->text('Total') . qq|</td>
1518 <td><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y> |
1519 . $locale->text('Project Number') . qq|</td>
1520 <td><input name="l_transaction_description" class=checkbox type=checkbox value=Y> |
1521 . $locale->text('Transaction description') . qq|</td>
1524 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1525 . $locale->text('Subtotal') . qq|</td>
1533 <tr><td colspan=4><hr size=3 noshade></td></tr>
1539 <input type=hidden name=nextsub value=orders>
1540 <input type=hidden name=login value=$form->{login}>
1541 <input type=hidden name=password value=$form->{password}>
1542 <input type=hidden name=vc value=$form->{vc}>
1543 <input type=hidden name=type value=$form->{type}>
1545 <input class=submit type=submit name=action value="|
1546 . $locale->text('Continue') . qq|">
1553 $lxdebug->leave_sub();
1557 $lxdebug->enter_sub();
1559 # split vendor / customer
1560 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1561 split(/--/, $form->{ $form->{vc} });
1563 OE->transactions(\%myconfig, \%$form);
1565 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1569 qw(type vc login password transdatefrom transdateto
1570 open closed notdelivered delivered department
1571 transaction_description);
1572 $href = "$form->{script}?action=orders&"
1573 . join("&", map { "${_}=" . E($form->{$_}) } @fields)
1574 . "&${ordnumber}=" . E($form->{$ordnumber});
1578 "transdate", "reqdate",
1580 "name", "netamount",
1583 "shipvia", "globalprojectnumber",
1584 "transaction_description", "open",
1585 "closed", "delivered"
1588 $form->{l_open} = $form->{l_closed} = "Y"
1589 if ($form->{open} && $form->{closed});
1591 $form->{"l_delivered"} = "Y"
1592 if ($form->{"delivered"} && $form->{"notdelivered"});
1594 foreach $item (@columns) {
1595 if ($form->{"l_$item"} eq "Y") {
1596 push @column_index, $item;
1598 # add column to href and callback
1599 $callback .= "&l_$item=Y";
1600 $href .= "&l_$item=Y";
1604 # only show checkboxes if gotten here via sales_order form.
1605 if ($form->{type} =~ /sales_order/) {
1606 unshift @column_index, "ids";
1609 if ($form->{l_subtotal} eq 'Y') {
1610 $callback .= "&l_subtotal=Y";
1611 $href .= "&l_subtotal=Y";
1614 if ($form->{vc} eq 'vendor') {
1615 if ($form->{type} eq 'purchase_order') {
1616 $form->{title} = $locale->text('Purchase Orders');
1618 $form->{title} = $locale->text('Request for Quotations');
1620 $name = $locale->text('Vendor');
1621 $employee = $locale->text('Employee');
1623 if ($form->{vc} eq 'customer') {
1624 if ($form->{type} eq 'sales_order') {
1625 $form->{title} = $locale->text('Sales Orders');
1627 $form->{title} = $locale->text('Quotations');
1629 $employee = $locale->text('Employee');
1630 $name = $locale->text('Customer');
1633 $column_header{id} =
1634 qq|<th><a class=listheading href=$href&sort=id>|
1635 . $locale->text('ID')
1637 $column_header{transdate} =
1638 qq|<th><a class=listheading href=$href&sort=transdate>|
1639 . $locale->text('Date')
1641 $column_header{reqdate} =
1642 qq|<th><a class=listheading href=$href&sort=reqdate>|
1643 . $locale->text('Required by')
1645 $column_header{ordnumber} =
1646 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1647 . $locale->text('Order')
1649 $column_header{quonumber} =
1650 qq|<th><a class=listheading href=$href&sort=quonumber>|
1651 . ($form->{"type"} eq "request_quotation" ?
1652 $locale->text('RFQ') :
1653 $locale->text('Quotation'))
1655 $column_header{name} =
1656 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1657 $column_header{netamount} =
1658 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1659 $column_header{tax} =
1660 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1661 $column_header{amount} =
1662 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1663 $column_header{curr} =
1664 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1665 $column_header{shipvia} =
1666 qq|<th><a class=listheading href=$href&sort=shipvia>|
1667 . $locale->text('Ship via')
1669 $column_header{globalprojectnumber} =
1670 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1671 $column_header{open} =
1672 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1673 $column_header{closed} =
1674 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1675 $column_header{"delivered"} =
1676 qq|<th class="listheading">| . $locale->text("Delivered") . qq|</th>|;
1678 $column_header{employee} =
1679 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1680 $column_header{transaction_description} =
1681 qq|<th><a class=listheading href="$href&sort=transaction_description">|
1682 . $locale->text("Transaction description") . qq|</a></th>|;
1684 $column_header{ids} = qq|<th></th>|;
1686 if ($form->{ $form->{vc} }) {
1687 $option = $locale->text(ucfirst $form->{vc});
1688 $option .= " : $form->{$form->{vc}}";
1690 if ($form->{department}) {
1691 $option .= "\n<br>" if ($option);
1692 ($department) = split /--/, $form->{department};
1693 $option .= $locale->text('Department') . " : $department";
1695 if ($form->{transdatefrom}) {
1697 . $locale->text('From') . " "
1698 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1700 if ($form->{transdateto}) {
1702 . $locale->text('Bis') . " "
1703 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1705 if ($form->{open}) {
1706 $option .= "\n<br>" if ($option);
1707 $option .= $locale->text('Open');
1709 if ($form->{closed}) {
1710 $option .= "\n<br>" if ($option);
1711 $option .= $locale->text('Closed');
1719 <form method="post" action="oe.pl">
1722 <th class=listtop>$form->{title}</th>
1724 <tr height="5"></tr>
1731 <tr class=listheading>|;
1733 map { print "\n$column_header{$_}" } @column_index;
1739 # add sort and escape callback
1740 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1742 if (@{ $form->{OE} }) {
1743 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1748 foreach $oe (@{ $form->{OE} }) {
1749 $form->{rowcount} = ++$j;
1751 if ($form->{l_subtotal} eq 'Y') {
1752 if ($sameitem ne $oe->{ $form->{sort} }) {
1754 $sameitem = $oe->{ $form->{sort} };
1758 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1760 $column_data{netamount} =
1762 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1764 $column_data{tax} = "<td align=right>"
1765 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1768 $column_data{amount} =
1770 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1772 $totalnetamount += $oe->{netamount};
1773 $totalamount += $oe->{amount};
1775 $subtotalnetamount += $oe->{netamount};
1776 $subtotalamount += $oe->{amount};
1779 qq|<td><input name="multi_id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1780 $column_data{id} = "<td>$oe->{id}</td>";
1781 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1782 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1784 $column_data{$ordnumber} =
1785 "<td><a href=oe.pl?action=$action&type=$form->{type}&id=$oe->{id}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&callback=$callback_escaped>$oe->{$ordnumber}</a></td>";
1786 $column_data{name} = "<td>$oe->{name}</td>";
1788 $column_data{employee} = "<td>$oe->{employee} </td>";
1789 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1790 $column_data{globalprojectnumber} = "<td>" . H($oe->{globalprojectnumber}) . "</td>";
1792 if ($oe->{closed}) {
1793 $column_data{closed} = "<td align=center>X</td>";
1794 $column_data{open} = "<td> </td>";
1796 $column_data{closed} = "<td> </td>";
1797 $column_data{open} = "<td align=center>X</td>";
1799 $column_data{"delivered"} = "<td>" .
1800 ($oe->{"delivered"} ? $locale->text("Yes") : $locale->text("No")) .
1802 $column_data{transaction_description} = "<td>" . H($oe->{transaction_description}) . "</td>";
1807 <tr class=listrow$i>";
1809 map { print "\n$column_data{$_}" } @column_index;
1817 if ($form->{l_subtotal} eq 'Y') {
1823 <tr class=listtotal>|;
1825 map { $column_data{$_} = "<td> </td>" } @column_index;
1827 $column_data{netamount} =
1828 "<th class=listtotal align=right>"
1829 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1830 $column_data{tax} = "<th class=listtotal align=right>"
1831 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1834 $column_data{amount} =
1835 "<th class=listtotal align=right>"
1836 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1838 map { print "\n$column_data{$_}" } @column_index;
1846 <td><hr size=3 noshade></td>
1850 # multiple invoice edit button only if gotten there via sales_order form.
1852 if ($form->{type} =~ /sales_order/) {
1854 <input class"submit" type="submit" name="action" value="|
1855 . $locale->text('Continue') . qq|">
1856 <input type="hidden" name="nextsub" value="edit">
1857 <input type="hidden" name="type" value="$form->{type}">
1858 <input type="hidden" name="vc" value="$form->{vc}">
1859 <input type="hidden" name="login" value="$form->{login}">
1860 <input type="hidden" name="password" value="$form->{password}">
1861 <input type="hidden" name="callback" value="$callback">
1862 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1869 <form method=post action=$form->{script}>
1871 <input name=callback type=hidden value="$form->{callback}">
1873 <input type=hidden name=type value=$form->{type}>
1874 <input type=hidden name=vc value=$form->{vc}>
1876 <input type=hidden name=login value=$form->{login}>
1877 <input type=hidden name=password value=$form->{password}>
1885 $lxdebug->leave_sub();
1889 $lxdebug->enter_sub();
1891 map { $column_data{$_} = "<td> </td>" } @column_index;
1893 $column_data{netamount} =
1894 "<th class=listsubtotal align=right>"
1895 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1897 $column_data{tax} = "<td class=listsubtotal align=right>"
1898 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1901 $column_data{amount} =
1902 "<th class=listsubtotal align=right>"
1903 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1905 $subtotalnetamount = 0;
1906 $subtotalamount = 0;
1909 <tr class=listsubtotal>
1912 map { print "\n$column_data{$_}" } @column_index;
1918 $lxdebug->leave_sub();
1921 sub save_and_close {
1922 $lxdebug->enter_sub();
1924 if ($form->{type} =~ /_order$/) {
1925 $form->isblank("transdate", $locale->text('Order Date missing!'));
1927 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1930 $msg = ucfirst $form->{vc};
1931 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1933 # $locale->text('Customer missing!');
1934 # $locale->text('Vendor missing!');
1936 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1937 if ($form->{currency} ne $form->{defaultcurrency});
1941 if($form->{payment_id}) {
1942 $payment_id = $form->{payment_id};
1945 # if the name changed get new values
1946 if (&check_name($form->{vc})) {
1947 if($form->{payment_id} eq "") {
1948 $form->{payment_id} = $payment_id;
1954 $form->{id} = 0 if $form->{saveasnew};
1956 # this is for the internal notes section for the [email] Subject
1957 if ($form->{type} =~ /_order$/) {
1958 if ($form->{type} eq 'sales_order') {
1959 $form->{label} = $locale->text('Sales Order');
1961 $numberfld = "sonumber";
1962 $ordnumber = "ordnumber";
1964 $form->{label} = $locale->text('Purchase Order');
1966 $numberfld = "ponumber";
1967 $ordnumber = "ordnumber";
1970 $err = $locale->text('Cannot save order!');
1973 if ($form->{type} eq 'sales_quotation') {
1974 $form->{label} = $locale->text('Quotation');
1976 $numberfld = "sqnumber";
1977 $ordnumber = "quonumber";
1979 $form->{label} = $locale->text('Request for Quotation');
1981 $numberfld = "rfqnumber";
1982 $ordnumber = "quonumber";
1985 $err = $locale->text('Cannot save quotation!');
1989 # get new number in sequence if no number is given or if saveasnew was requested
1990 if (!$form->{$ordnumber} || $form->{saveasnew}) {
1991 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
1996 $form->error($err) if (!OE->save(\%myconfig, \%$form));
1998 # saving the history
1999 if(!exists $form->{addition}) {
2000 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
2001 $form->{addition} = "SAVED";
2002 $form->save_history($form->dbconnect(\%myconfig));
2004 # /saving the history
2006 $form->redirect($form->{label} . " $form->{$ordnumber} " .
2007 $locale->text('saved!'));
2009 $lxdebug->leave_sub();
2013 $lxdebug->enter_sub();
2015 if ($form->{type} =~ /_order$/) {
2016 $form->isblank("transdate", $locale->text('Order Date missing!'));
2018 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2021 $msg = ucfirst $form->{vc};
2022 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
2024 # $locale->text('Customer missing!');
2025 # $locale->text('Vendor missing!');
2027 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
2028 if ($form->{currency} ne $form->{defaultcurrency});
2032 if($form->{payment_id}) {
2033 $payment_id = $form->{payment_id};
2036 # if the name changed get new values
2037 if (&check_name($form->{vc})) {
2038 if($form->{payment_id} eq "") {
2039 $form->{payment_id} = $payment_id;
2045 $form->{id} = 0 if $form->{saveasnew};
2047 # this is for the internal notes section for the [email] Subject
2048 if ($form->{type} =~ /_order$/) {
2049 if ($form->{type} eq 'sales_order') {
2050 $form->{label} = $locale->text('Sales Order');
2052 $numberfld = "sonumber";
2053 $ordnumber = "ordnumber";
2055 $form->{label} = $locale->text('Purchase Order');
2057 $numberfld = "ponumber";
2058 $ordnumber = "ordnumber";
2061 $err = $locale->text('Cannot save order!');
2064 if ($form->{type} eq 'sales_quotation') {
2065 $form->{label} = $locale->text('Quotation');
2067 $numberfld = "sqnumber";
2068 $ordnumber = "quonumber";
2070 $form->{label} = $locale->text('Request for Quotation');
2072 $numberfld = "rfqnumber";
2073 $ordnumber = "quonumber";
2076 $err = $locale->text('Cannot save quotation!');
2080 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
2081 unless $form->{$ordnumber};
2085 OE->save(\%myconfig, \%$form);
2087 # saving the history
2088 if(!exists $form->{addition}) {
2089 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
2090 $form->{addition} = "SAVED";
2091 $form->save_history($form->dbconnect(\%myconfig));
2093 # /saving the history
2095 $form->{simple_save} = 1;
2096 if(!$form->{print_and_save}) {
2097 set_headings("edit");
2101 $lxdebug->leave_sub();
2105 $lxdebug->enter_sub();
2109 if ($form->{type} =~ /_order$/) {
2110 $msg = $locale->text('Are you sure you want to delete Order Number');
2111 $ordnumber = 'ordnumber';
2113 $msg = $locale->text('Are you sure you want to delete Quotation Number');
2114 $ordnumber = 'quonumber';
2120 <form method=post action=$form->{script}>
2123 # delete action variable
2124 map { delete $form->{$_} } qw(action header);
2126 foreach $key (keys %$form) {
2127 $form->{$key} =~ s/\"/"/g;
2128 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2132 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
2134 <h4>$msg $form->{$ordnumber}</h4>
2136 <input name=action class=submit type=submit value="|
2137 . $locale->text('Yes') . qq|">
2144 $lxdebug->leave_sub();
2148 $lxdebug->enter_sub();
2150 if ($form->{type} =~ /_order$/) {
2151 $msg = $locale->text('Order deleted!');
2152 $err = $locale->text('Cannot delete order!');
2154 $msg = $locale->text('Quotation deleted!');
2155 $err = $locale->text('Cannot delete quotation!');
2157 if (OE->delete(\%myconfig, \%$form, $spool)){
2158 $form->redirect($msg);
2159 # saving the history
2160 if(!exists $form->{addition}) {
2161 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
2162 $form->{addition} = "DELETED";
2163 $form->save_history($form->dbconnect(\%myconfig));
2165 # /saving the history
2169 $lxdebug->leave_sub();
2173 $lxdebug->enter_sub();
2175 if ($form->{type} =~ /_order$/) {
2177 # these checks only apply if the items don't bring their own ordnumbers/transdates.
2178 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
2179 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
2180 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }->{''});
2181 $form->isblank("transdate", $locale->text('Order Date missing!'))
2182 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }->{''});
2184 # also copy deliverydate from the order
2185 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
2186 $form->{orddate} = $form->{transdate};
2188 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
2189 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2190 $form->{ordnumber} = "";
2191 $form->{quodate} = $form->{transdate};
2194 if($form->{payment_id}) {
2195 $payment_id = $form->{payment_id};
2198 # if the name changed get new values
2199 if (&check_name($form->{vc})) {
2200 if($form->{payment_id} eq "") {
2201 $form->{payment_id} = $payment_id;
2207 $form->{cp_id} *= 1;
2209 for $i (1 .. $form->{rowcount}) {
2210 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
2211 $form->{"${_}_${i}"})
2212 if ($form->{"${_}_${i}"}) }
2213 qw(ship qty sellprice listprice basefactor));
2216 if ( $form->{type} =~ /_order/
2217 && $form->{currency} ne $form->{defaultcurrency}) {
2219 # check if we need a new exchangerate
2220 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
2222 $orddate = $form->current_date(\%myconfig);
2224 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
2227 if (!$exchangerate) {
2228 &backorder_exchangerate($orddate, $buysell);
2233 # close orders/quotations
2234 $form->{closed} = 1;
2236 # save order if one ordnumber has been given
2237 # if not it's most likely a collective order, which can't be saved back
2238 # so they just have to be closed
2239 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
2240 OE->close_order(\%myconfig, \%$form);
2242 OE->close_orders(\%myconfig, \%$form);
2245 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
2247 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2250 $form->{closed} = 0;
2251 $form->{rowcount}--;
2252 $form->{shipto} = 1;
2254 if ($form->{type} =~ /_order$/) {
2255 $form->{exchangerate} = $exchangerate;
2259 if ( $form->{type} eq 'purchase_order'
2260 || $form->{type} eq 'request_quotation') {
2261 $form->{title} = $locale->text('Add Vendor Invoice');
2262 $form->{script} = 'ir.pl';
2266 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
2267 $form->{title} = $locale->text('Add Sales Invoice');
2268 $form->{script} = 'is.pl';
2273 # bo creates the id, reset it
2274 map { delete $form->{$_} }
2275 qw(id subject message cc bcc printed emailed queued);
2276 $form->{ $form->{vc} } =~ s/--.*//g;
2277 $form->{type} = "invoice";
2280 $locale = new Locale "$myconfig{countrycode}", "$script";
2282 require "bin/mozilla/$form->{script}";
2284 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
2286 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2287 qw(creditlimit creditremaining);
2289 $currency = $form->{currency};
2292 $form->{currency} = $currency;
2293 $form->{exchangerate} = "";
2294 $form->{forex} = "";
2295 $form->{exchangerate} = $exchangerate
2299 $form->check_exchangerate(
2300 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
2303 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
2308 for $i (1 .. $form->{rowcount}) {
2309 $form->{"discount_$i"} =
2310 $form->format_amount(\%myconfig, $form->{"discount_$i"});
2312 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
2314 $decimalplaces = ($dec > 2) ? $dec : 2;
2316 # copy delivery date from reqdate for order -> invoice conversion
2317 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
2318 unless $form->{"deliverydate_$i"};
2320 $form->{"sellprice_$i"} =
2321 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
2324 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
2325 $dec_qty = length $dec_qty;
2327 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
2329 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2330 qw(partnumber description unit);
2336 $lxdebug->leave_sub();
2339 sub backorder_exchangerate {
2340 $lxdebug->enter_sub();
2341 my ($orddate, $buysell) = @_;
2348 <form method=post action=$form->{script}>
2351 # delete action variable
2352 map { delete $form->{$_} } qw(action header exchangerate);
2354 foreach $key (keys %$form) {
2355 $form->{$key} =~ s/\"/"/g;
2356 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2359 $form->{title} = $locale->text('Add Exchangerate');
2363 <input type=hidden name=login value=$form->{login}>
2364 <input type=hidden name=password value=$form->{password}>
2366 <input type=hidden name=exchangeratedate value=$orddate>
2367 <input type=hidden name=buysell value=$buysell>
2370 <tr><th class=listtop>$form->{title}</th></tr>
2371 <tr height="5"></tr>
2376 <th align=right>| . $locale->text('Currency') . qq|</th>
2377 <td>$form->{currency}</td>
2380 <th align=right>| . $locale->text('Date') . qq|</th>
2384 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2385 <td><input name=exchangerate size=11></td>
2395 <input type=hidden name=nextsub value=save_exchangerate>
2397 <input name=action class=submit type=submit value="|
2398 . $locale->text('Continue') . qq|">
2406 $lxdebug->leave_sub();
2409 sub save_exchangerate {
2410 $lxdebug->enter_sub();
2412 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2413 $form->{exchangerate} =
2414 $form->parse_amount(\%myconfig, $form->{exchangerate});
2415 $form->save_exchangerate(\%myconfig, $form->{currency},
2416 $form->{exchangeratedate},
2417 $form->{exchangerate}, $form->{buysell});
2421 $lxdebug->leave_sub();
2424 sub create_backorder {
2425 $lxdebug->enter_sub();
2427 $form->{shipped} = 1;
2429 # figure out if we need to create a backorder
2430 # items aren't saved if qty != 0
2432 for $i (1 .. $form->{rowcount}) {
2433 $totalqty += $qty = $form->{"qty_$i"};
2434 $totalship += $ship = $form->{"ship_$i"};
2436 $form->{"qty_$i"} = $qty - $ship;
2439 if ($totalship == 0) {
2440 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2441 $form->{ordtotal} = 0;
2442 $form->{shipped} = 0;
2446 if ($totalqty == $totalship) {
2447 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2448 $form->{ordtotal} = 0;
2453 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2456 for $i (1 .. $form->{rowcount}) {
2458 $form->{"${_}_$i"} =
2459 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2460 } qw(sellprice discount);
2465 OE->save(\%myconfig, \%$form);
2467 # rebuild rows for invoice
2471 for $i (1 .. $form->{rowcount}) {
2472 $form->{"qty_$i"} = $form->{"ship_$i"};
2474 if ($form->{"qty_$i"}) {
2477 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2482 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2483 $form->{rowcount} = $count;
2485 $lxdebug->leave_sub();
2489 $lxdebug->enter_sub();
2491 $form->{saveasnew} = 1;
2492 $form->{closed} = 0;
2493 map { delete $form->{$_} } qw(printed emailed queued);
2495 # Let Lx-Office assign a new order number if the user hasn't changed the
2496 # previous one. If it has been changed manually then use it as-is.
2497 my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
2498 if ($form->{saved_xyznumber} &&
2499 ($form->{saved_xyznumber} eq $form->{$idx})) {
2500 delete($form->{$idx});
2505 $lxdebug->leave_sub();
2508 sub purchase_order {
2509 $lxdebug->enter_sub();
2511 if ( $form->{type} eq 'sales_quotation'
2512 || $form->{type} eq 'request_quotation') {
2513 OE->close_order(\%myconfig, \%$form);
2516 if ($form->{type} =~ /^sales_/) {
2517 delete($form->{ordnumber});
2520 $form->{cp_id} *= 1;
2522 $form->{title} = $locale->text('Add Purchase Order');
2523 $form->{vc} = "vendor";
2524 $form->{type} = "purchase_order";
2528 $lxdebug->leave_sub();
2532 $lxdebug->enter_sub();
2534 if ( $form->{type} eq 'sales_quotation'
2535 || $form->{type} eq 'request_quotation') {
2536 OE->close_order(\%myconfig, $form);
2539 if ($form->{type} eq "purchase_order") {
2540 delete($form->{ordnumber});
2543 $form->{cp_id} *= 1;
2545 $form->{title} = $locale->text('Add Sales Order');
2546 $form->{vc} = "customer";
2547 $form->{type} = "sales_order";
2551 $lxdebug->leave_sub();
2555 $lxdebug->enter_sub();
2557 $form->{transdate} = $form->current_date(\%myconfig);
2558 delete $form->{duedate};
2560 $form->{closed} = 0;
2563 map { delete $form->{$_} }
2564 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2566 for $i (1 .. $form->{rowcount}) {
2567 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
2568 $form->{"${_}_${i}"})
2569 if ($form->{"${_}_${i}"}) }
2570 qw(ship qty sellprice listprice basefactor));
2578 for $i (1 .. $form->{rowcount} - 1) {
2579 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2580 qw(partnumber description unit);
2583 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2584 qw(creditlimit creditremaining);
2588 $lxdebug->leave_sub();
2592 $lxdebug->enter_sub();
2594 $form->{print_and_save} = 1;
2599 my $saved_form = save_form();
2604 map({ $saved_vars{$_} = $form->{$_}; } qw(id ordnumber quonumber));
2605 restore_form($saved_form);
2606 map({ $form->{$_} = $saved_vars{$_}; } qw(id ordnumber quonumber));
2611 $lxdebug->leave_sub();