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();
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}"} .=
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 if (@{ $form->{all_employees} }) {
274 $form->{selectemployee} = "";
275 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}</option>\n" }
276 (@{ $form->{all_employees} });
280 $form->{forex} = $form->{exchangerate};
282 $form->{salesman_id} = $salesman_id if ($editing);
284 $lxdebug->leave_sub();
288 $lxdebug->enter_sub();
289 $form->{formname} = $form->{type} unless $form->{formname};
292 foreach $ref (@{ $form->{form_details} }) {
293 $form->{rowcount} = ++$i;
295 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
297 for my $i (1 .. $form->{rowcount}) {
299 $form->{"discount_$i"} =
300 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
302 $form->{"discount_$i"} =
303 $form->format_amount(\%myconfig, $form->{"discount_$i"});
305 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
307 $decimalplaces = ($dec > 2) ? $dec : 2;
309 # copy reqdate from deliverydate for invoice -> order conversion
310 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
311 unless $form->{"reqdate_$i"};
313 $form->{"sellprice_$i"} =
314 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
317 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
318 $dec_qty = length $dec_qty;
320 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
322 map { $form->{"${_}_$i"} =~ s/\"/"/g }
323 qw(partnumber description unit);
326 $lxdebug->leave_sub();
330 $lxdebug->enter_sub();
332 my $checkedclosed = $form->{"closed"} ? "checked" : "";
333 my $checkeddelivered = $form->{"delivered"} ? "checked" : "";
335 map { $form->{$_} =~ s/\"/"/g }
336 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
337 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
338 shiptophone shiptofax shiptodepartment_1 shiptodepartment_2);
340 # use JavaScript Calendar or not
341 $form->{jsscript} = $form->{jscalendar};
344 $payment = qq|<option value=""></option>|;
345 foreach $item (@{ $form->{payment_terms} }) {
346 if ($form->{payment_id} eq $item->{id}) {
347 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
349 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
352 if ($form->{jsscript}) {
354 # with JavaScript Calendar
356 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\"></td>
357 <td><input type=button name=transdate id="trigger1" value=|
358 . $locale->text('button') . qq|></td>
361 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value="$form->{reqdate}" onBlur=\"check_right_date_format(this)\"></td>
362 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
363 . $locale->text('button') . qq|></td>
368 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
369 "reqdate", "BL", "trigger2");
373 # without JavaScript Calendar
375 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value="$form->{transdate}" onBlur=\"check_right_date_format(this)\"></td>|;
377 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value="$form->{reqdate}" onBlur=\"check_right_date_format(this)\"></td>|;
382 if (($form->{"type"} eq "sales_order") ||
383 ($form->{"type"} eq "purchase_order")) {
385 <input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" $checkeddelivered>
386 <label for="delivered">| . $locale->text('Delivered') . qq|</label>|);
391 <input name="closed" id="closed" type="checkbox" class="checkbox" value="1" $checkedclosed>
392 <label for="closed">| . $locale->text('Closed') . qq|</label>|);
398 <td colspan=| . (2 * scalar(@tmp)) . qq| align=center>| . join("\n", @tmp) . qq|
404 # set option selected
405 foreach $item ($form->{vc}, currency, department, employee) {
406 $form->{"select$item"} =~ s/ selected//;
407 $form->{"select$item"} =~
408 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
411 #quote select[customer|vendor] Bug 133
412 $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
414 #substitute \n and \r to \s (bug 543)
415 $form->{"select$form->{vc}"} =~ s/[\n\r]/ /g;
417 my @old_project_ids = ($form->{"globalproject_id"});
418 map({ push(@old_project_ids, $form->{"project_id_$_"})
419 if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
421 $form->get_lists("contacts" => "ALL_CONTACTS",
422 "shipto" => "ALL_SHIPTO",
423 "projects" => { "key" => "ALL_PROJECTS",
425 "old_id" => \@old_project_ids },
426 "employees" => "ALL_SALESMEN",
427 "taxzones" => "ALL_TAXZONES",
428 "currencies" => "ALL_CURRENCIES");
431 my @values = (undef);
432 foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
433 push(@values, $item->{"cp_id"});
434 $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
435 ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
438 NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values,
439 '-labels' => \%labels, '-default' => $form->{"cp_id"}));
443 foreach my $item (@{ $form->{"ALL_SHIPTO"} }) {
444 push(@values, $item->{"shipto_id"});
445 $labels{$item->{"shipto_id"}} =
446 $item->{"shiptoname"} . " " . $item->{"shiptodepartment_1"};
450 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
452 NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values,
453 '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
458 foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
459 push(@values, $item->{"id"});
460 $labels{$item->{"id"}} = $item->{"projectnumber"};
462 my $globalprojectnumber =
463 NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
464 '-labels' => \%labels,
465 '-default' => $form->{"globalproject_id"}));
468 if ($form->{type} =~ /^sales_/) {
471 foreach my $item (@{ $form->{ALL_SALESMEN} }) {
472 push(@values, $item->{id});
473 $labels{$item->{id}} = $item->{name} ne "" ? $item->{name} : $item->{login};
478 <th align="right">| . $locale->text('Salesman') . qq|</th>
480 NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id},
481 '-values' => \@values, '-labels' => \%labels))
489 foreach my $item (@{ $form->{"ALL_TAXZONES"} }) {
490 push(@values, $item->{"id"});
491 $labels{$item->{"id"}} = $item->{"description"};
496 <th align="right">| . $locale->text('Steuersatz') . qq|</th>
498 NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
499 '-values' => \@values, '-labels' => \%labels)) . qq|
506 foreach my $item (@{ $form->{"ALL_CURRENCIES"} }) {
507 push(@values, $item);
508 $labels{$item} = $item;
511 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
514 <th align="right">| . $locale->text('Currency') . qq|</th>
516 NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
517 '-values' => \@values, '-labels' => \%labels)) . qq|
522 $form->{exchangerate} =
523 $form->format_amount(\%myconfig, $form->{exchangerate});
525 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
531 $form->{creditlimit} =
532 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
533 $form->{creditremaining} =
534 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
537 <input type=hidden name=forex value=$form->{forex}>
540 if ($form->{currency} ne $form->{defaultcurrency}) {
541 if ($form->{forex}) {
544 . $locale->text('Exchangerate')
545 . qq|</th><td>$form->{exchangerate}</td>
546 <input type=hidden name=exchangerate value=$form->{exchangerate}>
551 . $locale->text('Exchangerate')
552 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
556 $vclabel = ucfirst $form->{vc};
557 $vclabel = $locale->text($vclabel);
561 if ($form->{business}) {
564 <th align=right>| . $locale->text('Business') . qq|</th>
565 <td>$form->{business}</td>
566 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
568 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
574 if ($form->{max_dunning_level}) {
580 <th align=right>| . $locale->text('Max. Dunning Level') . qq|:</th>
581 <td><b>$form->{max_dunning_level}</b></td>
582 <th align=right>| . $locale->text('Dunning Amount') . qq|:</th>
584 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
593 if ($form->{type} !~ /_quotation$/) {
596 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
597 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
600 <th width=70% align=right nowrap>|
601 . $locale->text('Quotation Number') . qq|</th>
602 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
605 <th width=70% align=right nowrap>|
606 . $locale->text('Customer Order Number') . qq|</th>
607 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
610 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
615 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
620 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
622 $creditremaining = qq|
628 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
629 <td>$form->{creditlimit}</td>
631 <th nowrap>| . $locale->text('Remaining') . qq|</th>
632 <td class="plus$n" nowrap>$form->{creditremaining}</td>
641 ($form->{type} eq 'sales_quotation')
642 ? $locale->text('Valid until')
643 : $locale->text('Required by');
644 if ($form->{type} eq 'sales_quotation') {
647 <th width=70% align=right nowrap>|
648 . $locale->text('Quotation Number') . qq|</th>
649 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
650 <input type=hidden name=ordnumber value="$form->{ordnumber}">
656 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
657 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
658 <input type=hidden name=ordnumber value="$form->{ordnumber}">
666 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
670 <th align=right nowrap=true>$reqlabel</th>
674 $creditremaining = qq| <tr>
681 ($form->{"select$form->{vc}"})
682 ? qq|<select name="$form->{vc}"
683 onchange="document.getElementById('update_button').click();">| .
684 qq|$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="| .
685 Q($form->{"select$form->{vc}"}) . qq|">|
686 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
690 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
691 <td colspan=3><select name=department>$form->{selectdepartment}</select>
692 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
695 | if $form->{selectdepartment};
698 <input type=hidden name=employee value="$form->{employee}">
701 if ($form->{type} eq 'sales_order') {
702 if ($form->{selectemployee}) {
704 <input type=hidden name=customer_klass value=$form->{customer_klass}>
706 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
707 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
708 <input type=hidden name=selectemployee value="$form->{selectemployee}">
715 <input type=hidden name=customer_klass value=$form->{customer_klass}>
717 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
718 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
719 <input type=hidden name=selectemployee value="$form->{selectemployee}">
724 if ($form->{resubmit} && ($form->{format} eq "html")) {
726 qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
727 } elsif ($form->{resubmit}) {
728 $onload = qq|document.oe.submit()|;
733 $credittext = $locale->text('Credit Limit exceeded!!!');
734 if ($creditwarning) {
735 $onload = qq|alert('$credittext')|;
738 $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
739 $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
741 $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
742 # show history button js
743 $form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
744 #/show history button js
748 <body onLoad="$onload">
750 <form method=post name=oe action=$form->{script}>
751 <script type="text/javascript" src="js/common.js"></script>
752 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
753 <script type="text/javascript" src="js/vendor_selection.js"></script>
754 <script type="text/javascript" src="js/calculate_qty.js"></script>
756 <input type=hidden name=id value=$form->{id}>
757 <input type=hidden name=action value=$form->{action}>
759 <input type=hidden name=type value=$form->{type}>
760 <input type=hidden name=formname value=$form->{formname}>
761 <input type=hidden name=media value=$form->{media}>
762 <input type=hidden name=format value=$form->{format}>
763 <input type=hidden name=proforma value=$form->{proforma}>
765 <input type=hidden name=queued value="$form->{queued}">
766 <input type=hidden name=printed value="$form->{printed}">
767 <input type=hidden name=emailed value="$form->{emailed}">
769 <input type=hidden name=vc value=$form->{vc}>
771 <input type=hidden name=title value="$form->{title}">
773 <input type=hidden name=discount value=$form->{discount}>
774 <input type=hidden name=creditlimit value=$form->{creditlimit}>
775 <input type=hidden name=creditremaining value=$form->{creditremaining}>
777 <input type=hidden name=tradediscount value=$form->{tradediscount}>
778 <input type=hidden name=business value=$form->{business}>
779 <input type=hidden name=webdav value=$webdav>
783 <th class=listtop>$form->{title}</th>
793 <th align=right>$vclabel</th>
794 <td colspan=3>$vc</td>
795 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
796 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
797 <th align=richt nowrap>|
798 . $locale->text('Contact Person') . qq|</th>
799 <td colspan=3>$contact</td>
811 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
812 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
815 <th align=right>| . $locale->text('Ship via') . qq|</th>
816 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
819 <th align="right">| . $locale->text('Transaction description') . qq|</th>
820 <td colspan="3"><input name="transaction_description" size="35" value="| . H($form->{transaction_description}) . qq|"></td>
827 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
829 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
830 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
834 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
836 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
837 # <input size=45 id=vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
851 <th width="70%" align="right" nowrap>| . $locale->text('Project Number') . qq|</th>
852 <td>$globalprojectnumber</td>
863 <!-- shipto are in hidden variables -->
865 <input type=hidden name=shiptoname value="$form->{shiptoname}">
866 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
867 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
868 <input type=hidden name=shiptocity value="$form->{shiptocity}">
869 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
870 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
871 <input type=hidden name=shiptophone value="$form->{shiptophone}">
872 <input type=hidden name=shiptofax value="$form->{shiptofax}">
873 <input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
874 <input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
875 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
877 <!-- email variables -->
878 <input type=hidden name=message value="$form->{message}">
879 <input type=hidden name=email value="$form->{email}">
880 <input type=hidden name=subject value="$form->{subject}">
881 <input type=hidden name=cc value="$form->{cc}">
882 <input type=hidden name=bcc value="$form->{bcc}">
884 <input type=hidden name=taxpart value="$form->{taxpart}">
885 <input type=hidden name=taxservice value="$form->{taxservice}">
887 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
890 foreach $item (split / /, $form->{taxaccounts}) {
892 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
893 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
896 $lxdebug->leave_sub();
900 $lxdebug->enter_sub();
902 $form->{invtotal} = $form->{invsubtotal};
904 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
907 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
910 $rows = ($rows > $introws) ? $rows : $introws;
912 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
914 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
916 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
919 if ($form->{taxaccounts}) {
921 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
922 . $locale->text('Tax Included') . qq|</b><br><br>
926 if (!$form->{taxincluded}) {
928 foreach $item (split / /, $form->{taxaccounts}) {
929 if ($form->{"${item}_base"}) {
930 $form->{invtotal} += $form->{"${item}_total"} =
932 $form->{"${item}_base"} * $form->{"${item}_rate"},
934 $form->{"${item}_total"} =
935 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
939 <th align=right>$form->{"${item}_description"} |
940 . $form->{"${item}_rate"} * 100 .qq|%</th>
941 <td align=right>$form->{"${item}_total"}</td>
947 $form->{invsubtotal} =
948 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
952 <th align=right>| . $locale->text('Subtotal') . qq|</th>
953 <td align=right>$form->{invsubtotal}</td>
959 if ($form->{taxincluded}) {
960 foreach $item (split / /, $form->{taxaccounts}) {
961 if ($form->{"${item}_base"}) {
962 $form->{"${item}_total"} =
964 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
965 (1 + $form->{"${item}_rate"})
968 $form->{"${item}_netto"} =
970 ($form->{"${item}_base"} - $form->{"${item}_total"}),
972 $form->{"${item}_total"} =
973 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
974 $form->{"${item}_netto"} =
975 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
979 <th align=right>Enthaltene $form->{"${item}_description"} |
980 . $form->{"${item}_rate"} * 100 .qq|%</th>
981 <td align=right>$form->{"${item}_total"}</td>
984 <th align=right>Nettobetrag</th>
985 <td align=right>$form->{"${item}_netto"}</td>
993 $form->{oldinvtotal} = $form->{invtotal};
995 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
1005 <th align=left>| . $locale->text('Notes') . qq|</th>
1006 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
1012 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
1013 <td><select name=payment_id>$payment
1017 <td align=right width=100%>
1023 <th align=right>| . $locale->text('Total') . qq|</th>
1024 <td align=right>$form->{invtotal}</td>
1032 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
1033 <input type=hidden name=oldtotalpaid value=$totalpaid>
1035 <td><hr size=3 noshade></td>
1043 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
1046 <td align=left width=30%><b>Dateiname</b></td>
1047 <td align=left width=70%><b>Webdavlink</b></td>
1049 foreach $file (keys %{ $form->{WEBDAV} }) {
1052 <td align=left>$file</td>
1053 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
1061 <td><hr size=3 noshade></td>
1068 <input type=hidden name=jscalendar value=$form->{jscalendar}>
1081 | . $locale->text("Edit the $form->{type}") . qq|<br>
1082 <input class=submit type=submit name=action id=update_button value="|
1083 . $locale->text('Update') . qq|">
1084 <input class=submit type=submit name=action value="|
1085 . $locale->text('Ship to') . qq|">
1086 <input class=submit type=submit name=action value="|
1087 . $locale->text('Print') . qq|">
1088 <input class=submit type=submit name=action value="|
1089 . $locale->text('E-mail') . qq|">
1090 <input class=submit type=submit name=action value="|
1091 . $locale->text('Save') . qq|">
1092 <input class=submit type=submit name=action value="|
1093 . $locale->text('Save and Close') . qq|">
1096 if (($form->{id})) {
1098 <input type="button" class="submit" onclick="set_history_window(|
1100 . qq|);" name="history" id="history" value="|
1101 . $locale->text('history')
1104 <br>| . $locale->text("Workflow $form->{type}") . qq|<br>
1105 <input class=submit type=submit name=action value="|
1106 . $locale->text('Save as new') . qq|">
1107 <input class=submit type=submit name=action value="|
1108 . $locale->text('Delete') . qq|">|;
1109 if (($form->{type} =~ /sales_quotation$/)) {
1111 <input class=submit type=submit name=action value="|
1112 . $locale->text('Sales Order') . qq|">|;
1114 if ($form->{type} =~ /request_quotation$/) {
1116 <input class=submit type=submit name=action value="|
1117 . $locale->text('Purchase Order') . qq|">|;
1121 <input class=submit type=submit name=action value="|
1122 . $locale->text('Invoice') . qq|">
1126 if ($form->{type} =~ /sales_order$/) {
1128 <br>$form->{heading} als neue Vorlage verwenden für<br>
1129 <input class=submit type=submit name=action value="|
1130 . $locale->text('Purchase Order') . qq|">
1131 <input class=submit type=submit name=action value="|
1132 . $locale->text('Quotation') . qq|">
1135 } elsif ($form->{type} =~ /purchase_order$/) {
1137 <br>$form->{heading} als neue Vorlage verwenden für<br>
1138 <input class=submit type=submit name=action value="|
1139 . $locale->text('Sales Order') . qq|">
1140 <input class=submit type=submit name=action value="|
1141 . $locale->text('Request for Quotation') . qq|">
1146 <br>$form->{heading} als neue Vorlage verwenden für<br>
1147 <input class=submit type=submit name=action value="|
1148 . $locale->text('Order') . qq|">
1151 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount} && !$form->{proforma}) {
1153 <br>Workflow $form->{heading}<br>
1154 <input class=submit type=submit name=action value="|
1155 . $locale->text('Save as new') . qq|">
1156 <input class=submit type=submit name=action value="|
1157 . $locale->text('Invoice') . qq|">
1161 $form->hide_form("saved_xyznumber");
1165 <input type=hidden name=rowcount value=$form->{rowcount}>
1167 <input name=callback type=hidden value="$form->{callback}">
1169 <input type=hidden name=login value=$form->{login}>
1170 <input type=hidden name=password value=$form->{password}>
1177 $lxdebug->leave_sub();
1181 $lxdebug->enter_sub();
1183 set_headings($form->{"id"} ? "edit" : "add");
1185 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1186 qw(exchangerate creditlimit creditremaining);
1187 $form->{update} = 1;
1189 &check_name($form->{vc});
1192 $buysell = 'sell' if ($form->{vc} eq 'vendor');
1193 $form->{exchangerate} = $exchangerate
1197 $form->check_exchangerate(
1198 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1202 $i = $form->{rowcount};
1204 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1206 if ( ($form->{"partnumber_$i"} eq "")
1207 && ($form->{"description_$i"} eq "")
1208 && ($form->{"partsgroup_$i"} eq "")) {
1210 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1215 if ( $form->{type} eq 'purchase_order'
1216 || $form->{type} eq 'request_quotation') {
1217 IR->retrieve_item(\%myconfig, \%$form);
1219 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1220 IS->retrieve_item(\%myconfig, \%$form);
1223 my $rows = scalar @{ $form->{item_list} };
1225 $form->{"discount_$i"} =
1226 $form->format_amount(\%myconfig, $form->{discount} * 100);
1229 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1238 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1239 if ($form->{"not_discountable_$i"}) {
1240 $form->{"discount_$i"} = 0;
1242 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1243 qw(partnumber description unit);
1244 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1245 keys %{ $form->{item_list}[0] };
1246 if ($form->{"part_payment_id_$i"} ne "") {
1247 $form->{payment_id} = $form->{"part_payment_id_$i"};
1250 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1252 ($dec) = ($s =~ /\.(\d+)/);
1254 $decimalplaces = ($dec > 2) ? $dec : 2;
1257 $form->{"sellprice_$i"} = $sellprice;
1260 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1262 # if there is an exchange rate adjust sellprice
1263 $form->{"sellprice_$i"} /= $exchangerate;
1267 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1268 (1 - $form->{"discount_$i"} / 100);
1269 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1270 map { $form->{"${_}_base"} += $amount }
1271 (split / /, $form->{"taxaccounts_$i"});
1272 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1273 split / /, $form->{taxaccounts}
1274 if !$form->{taxincluded};
1276 $form->{creditremaining} -= $amount;
1278 $form->{"sellprice_$i"} =
1279 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1282 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1284 # get pricegroups for parts
1285 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1287 # build up html code for prices_$i
1288 &set_pricegroup($i);
1295 # ok, so this is a new part
1296 # ask if it is a part or service item
1298 if ( $form->{"partsgroup_$i"}
1299 && ($form->{"partsnumber_$i"} eq "")
1300 && ($form->{"description_$i"} eq "")) {
1301 $form->{rowcount}--;
1302 $form->{"discount_$i"} = "";
1306 $form->{"id_$i"} = 0;
1307 $form->{"unit_$i"} = $locale->text('ea');
1315 $lxdebug->leave_sub();
1319 $lxdebug->enter_sub();
1321 if ($form->{type} eq 'purchase_order') {
1322 $form->{title} = $locale->text('Purchase Orders');
1323 $form->{vc} = 'vendor';
1324 $ordlabel = $locale->text('Order Number');
1325 $ordnumber = 'ordnumber';
1326 $employee = $locale->text('Employee');
1329 if ($form->{type} eq 'request_quotation') {
1330 $form->{title} = $locale->text('Request for Quotations');
1331 $form->{vc} = 'vendor';
1332 $ordlabel = $locale->text('RFQ Number');
1333 $ordnumber = 'quonumber';
1334 $employee = $locale->text('Employee');
1337 if ($form->{type} eq 'sales_order') {
1338 $form->{title} = $locale->text('Sales Orders');
1339 $form->{vc} = 'customer';
1340 $ordlabel = $locale->text('Order Number');
1341 $ordnumber = 'ordnumber';
1342 $employee = $locale->text('Employee');
1345 if ($form->{type} eq 'sales_quotation') {
1346 $form->{title} = $locale->text('Quotations');
1347 $form->{vc} = 'customer';
1348 $ordlabel = $locale->text('Quotation Number');
1349 $ordnumber = 'quonumber';
1350 $employee = $locale->text('Employee');
1353 # setup vendor / customer selection
1354 $form->all_vc(\%myconfig, $form->{vc},
1355 ($form->{vc} eq 'customer') ? "AR" : "AP");
1357 map { $vc .= "<option>$_->{name}--$_->{id}</option>\n" }
1358 @{ $form->{"all_$form->{vc}"} };
1360 $vclabel = ucfirst $form->{vc};
1361 $vclabel = $locale->text($vclabel);
1363 # $locale->text('Vendor')
1364 # $locale->text('Customer')
1368 ? qq|<select name=$form->{vc}><option>\n$vc</option></select>|
1369 : qq|<input name=$form->{vc} size=35>|;
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>
1460 <th align=right>$vclabel</th>
1461 <td colspan="3">$vc</td>
1465 <th align=right>$ordlabel</th>
1466 <td colspan=3><input name="$ordnumber" size=20></td>
1469 <th align="right">| . $locale->text('Transaction description') . qq|</th>
1470 <td colspan="3"><input name="transaction_description" size=20></td>
1473 <th align="right">| . $locale->text("Project Number") . qq|</th>
1474 <td colspan="3">$projectnumber</td>
1477 <th align=right>| . $locale->text('From') . qq|</th>
1479 <th align=right>| . $locale->text('Bis') . qq|</th>
1482 <input type=hidden name=sort value=transdate>
1484 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1488 <td><input type="checkbox" name="open" value="1" id="open" checked>
1489 <label for="open">| . $locale->text("Open") . qq|</td>
1490 <td><input type="checkbox" name="closed" value="1" id="closed">
1491 <label for="closed">| . $locale->text("Closed") . qq|</td>
1495 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1496 | . $locale->text('ID') . qq|</td>
1497 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1498 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1499 . $locale->text('Date') . qq|</td>
1500 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1501 . $locale->text('Required by') . qq|</td>
1504 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1505 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1506 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1507 . $locale->text('Ship via') . qq|</td>
1508 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1511 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1512 . $locale->text('Amount') . qq|</td>
1513 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1514 . $locale->text('Tax') . qq|</td>
1515 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1516 . $locale->text('Total') . qq|</td>
1519 <td><input name="l_globalprojectnumber" class=checkbox type=checkbox value=Y> |
1520 . $locale->text('Project Number') . qq|</td>
1521 <td><input name="l_transaction_description" class=checkbox type=checkbox value=Y> |
1522 . $locale->text('Transaction description') . qq|</td>
1525 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1526 . $locale->text('Subtotal') . qq|</td>
1534 <tr><td colspan=4><hr size=3 noshade></td></tr>
1540 <input type=hidden name=nextsub value=orders>
1541 <input type=hidden name=login value=$form->{login}>
1542 <input type=hidden name=password value=$form->{password}>
1543 <input type=hidden name=vc value=$form->{vc}>
1544 <input type=hidden name=type value=$form->{type}>
1546 <input class=submit type=submit name=action value="|
1547 . $locale->text('Continue') . qq|">
1554 $lxdebug->leave_sub();
1558 $lxdebug->enter_sub();
1560 # split vendor / customer
1561 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1562 split(/--/, $form->{ $form->{vc} });
1564 OE->transactions(\%myconfig, \%$form);
1566 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1570 qw(type vc login password transdatefrom transdateto
1571 open closed notdelivered delivered department
1572 transaction_description);
1573 $href = "$form->{script}?action=orders&"
1574 . join("&", map { "${_}=" . E($form->{$_}) } @fields)
1575 . "&${ordnumber}=" . E($form->{$ordnumber});
1579 "transdate", "reqdate",
1581 "name", "netamount",
1584 "shipvia", "globalprojectnumber",
1585 "transaction_description", "open",
1586 "closed", "delivered"
1589 $form->{l_open} = $form->{l_closed} = "Y"
1590 if ($form->{open} && $form->{closed});
1592 $form->{"l_delivered"} = "Y"
1593 if ($form->{"delivered"} && $form->{"notdelivered"});
1595 foreach $item (@columns) {
1596 if ($form->{"l_$item"} eq "Y") {
1597 push @column_index, $item;
1599 # add column to href and callback
1600 $callback .= "&l_$item=Y";
1601 $href .= "&l_$item=Y";
1605 # only show checkboxes if gotten here via sales_order form.
1606 if ($form->{type} =~ /sales_order/) {
1607 unshift @column_index, "ids";
1610 if ($form->{l_subtotal} eq 'Y') {
1611 $callback .= "&l_subtotal=Y";
1612 $href .= "&l_subtotal=Y";
1615 if ($form->{vc} eq 'vendor') {
1616 if ($form->{type} eq 'purchase_order') {
1617 $form->{title} = $locale->text('Purchase Orders');
1619 $form->{title} = $locale->text('Request for Quotations');
1621 $name = $locale->text('Vendor');
1622 $employee = $locale->text('Employee');
1624 if ($form->{vc} eq 'customer') {
1625 if ($form->{type} eq 'sales_order') {
1626 $form->{title} = $locale->text('Sales Orders');
1628 $form->{title} = $locale->text('Quotations');
1630 $employee = $locale->text('Employee');
1631 $name = $locale->text('Customer');
1634 $column_header{id} =
1635 qq|<th><a class=listheading href=$href&sort=id>|
1636 . $locale->text('ID')
1638 $column_header{transdate} =
1639 qq|<th><a class=listheading href=$href&sort=transdate>|
1640 . $locale->text('Date')
1642 $column_header{reqdate} =
1643 qq|<th><a class=listheading href=$href&sort=reqdate>|
1644 . $locale->text('Required by')
1646 $column_header{ordnumber} =
1647 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1648 . $locale->text('Order')
1650 $column_header{quonumber} =
1651 qq|<th><a class=listheading href=$href&sort=quonumber>|
1652 . ($form->{"type"} eq "request_quotation" ?
1653 $locale->text('RFQ') :
1654 $locale->text('Quotation'))
1656 $column_header{name} =
1657 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1658 $column_header{netamount} =
1659 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1660 $column_header{tax} =
1661 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1662 $column_header{amount} =
1663 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1664 $column_header{curr} =
1665 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1666 $column_header{shipvia} =
1667 qq|<th><a class=listheading href=$href&sort=shipvia>|
1668 . $locale->text('Ship via')
1670 $column_header{globalprojectnumber} =
1671 qq|<th class="listheading">| . $locale->text('Project Number') . qq|</th>|;
1672 $column_header{open} =
1673 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1674 $column_header{closed} =
1675 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1676 $column_header{"delivered"} =
1677 qq|<th class="listheading">| . $locale->text("Delivered") . qq|</th>|;
1679 $column_header{employee} =
1680 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1681 $column_header{transaction_description} =
1682 qq|<th><a class=listheading href="$href&sort=transaction_description">|
1683 . $locale->text("Transaction description") . qq|</a></th>|;
1685 $column_header{ids} = qq|<th></th>|;
1687 if ($form->{ $form->{vc} }) {
1688 $option = $locale->text(ucfirst $form->{vc});
1689 $option .= " : $form->{$form->{vc}}";
1691 if ($form->{department}) {
1692 $option .= "\n<br>" if ($option);
1693 ($department) = split /--/, $form->{department};
1694 $option .= $locale->text('Department') . " : $department";
1696 if ($form->{transdatefrom}) {
1698 . $locale->text('From') . " "
1699 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1701 if ($form->{transdateto}) {
1703 . $locale->text('Bis') . " "
1704 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1706 if ($form->{open}) {
1707 $option .= "\n<br>" if ($option);
1708 $option .= $locale->text('Open');
1710 if ($form->{closed}) {
1711 $option .= "\n<br>" if ($option);
1712 $option .= $locale->text('Closed');
1720 <form method="post" action="oe.pl">
1723 <th class=listtop>$form->{title}</th>
1725 <tr height="5"></tr>
1732 <tr class=listheading>|;
1734 map { print "\n$column_header{$_}" } @column_index;
1740 # add sort and escape callback
1741 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1743 if (@{ $form->{OE} }) {
1744 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1749 foreach $oe (@{ $form->{OE} }) {
1750 $form->{rowcount} = ++$j;
1752 if ($form->{l_subtotal} eq 'Y') {
1753 if ($sameitem ne $oe->{ $form->{sort} }) {
1755 $sameitem = $oe->{ $form->{sort} };
1759 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1761 $column_data{netamount} =
1763 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1765 $column_data{tax} = "<td align=right>"
1766 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1769 $column_data{amount} =
1771 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1773 $totalnetamount += $oe->{netamount};
1774 $totalamount += $oe->{amount};
1776 $subtotalnetamount += $oe->{netamount};
1777 $subtotalamount += $oe->{amount};
1780 qq|<td><input name="multi_id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1781 $column_data{id} = "<td>$oe->{id}</td>";
1782 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1783 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1785 $column_data{$ordnumber} =
1786 "<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>";
1787 $column_data{name} = "<td>$oe->{name}</td>";
1789 $column_data{employee} = "<td>$oe->{employee} </td>";
1790 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1791 $column_data{globalprojectnumber} = "<td>" . H($oe->{globalprojectnumber}) . "</td>";
1793 if ($oe->{closed}) {
1794 $column_data{closed} = "<td align=center>X</td>";
1795 $column_data{open} = "<td> </td>";
1797 $column_data{closed} = "<td> </td>";
1798 $column_data{open} = "<td align=center>X</td>";
1800 $column_data{"delivered"} = "<td>" .
1801 ($oe->{"delivered"} ? $locale->text("Yes") : $locale->text("No")) .
1803 $column_data{transaction_description} = "<td>" . H($oe->{transaction_description}) . "</td>";
1808 <tr class=listrow$i>";
1810 map { print "\n$column_data{$_}" } @column_index;
1818 if ($form->{l_subtotal} eq 'Y') {
1824 <tr class=listtotal>|;
1826 map { $column_data{$_} = "<td> </td>" } @column_index;
1828 $column_data{netamount} =
1829 "<th class=listtotal align=right>"
1830 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1831 $column_data{tax} = "<th class=listtotal align=right>"
1832 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1835 $column_data{amount} =
1836 "<th class=listtotal align=right>"
1837 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1839 map { print "\n$column_data{$_}" } @column_index;
1847 <td><hr size=3 noshade></td>
1851 # multiple invoice edit button only if gotten there via sales_order form.
1853 if ($form->{type} =~ /sales_order/) {
1855 <input class"submit" type="submit" name="action" value="|
1856 . $locale->text('Continue') . qq|">
1857 <input type="hidden" name="nextsub" value="edit">
1858 <input type="hidden" name="type" value="$form->{type}">
1859 <input type="hidden" name="vc" value="$form->{vc}">
1860 <input type="hidden" name="login" value="$form->{login}">
1861 <input type="hidden" name="password" value="$form->{password}">
1862 <input type="hidden" name="callback" value="$callback">
1863 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1870 <form method=post action=$form->{script}>
1872 <input name=callback type=hidden value="$form->{callback}">
1874 <input type=hidden name=type value=$form->{type}>
1875 <input type=hidden name=vc value=$form->{vc}>
1877 <input type=hidden name=login value=$form->{login}>
1878 <input type=hidden name=password value=$form->{password}>
1886 $lxdebug->leave_sub();
1890 $lxdebug->enter_sub();
1892 map { $column_data{$_} = "<td> </td>" } @column_index;
1894 $column_data{netamount} =
1895 "<th class=listsubtotal align=right>"
1896 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1898 $column_data{tax} = "<td class=listsubtotal align=right>"
1899 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1902 $column_data{amount} =
1903 "<th class=listsubtotal align=right>"
1904 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1906 $subtotalnetamount = 0;
1907 $subtotalamount = 0;
1910 <tr class=listsubtotal>
1913 map { print "\n$column_data{$_}" } @column_index;
1919 $lxdebug->leave_sub();
1922 sub save_and_close {
1923 $lxdebug->enter_sub();
1925 if ($form->{type} =~ /_order$/) {
1926 $form->isblank("transdate", $locale->text('Order Date missing!'));
1928 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1931 $msg = ucfirst $form->{vc};
1932 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1934 # $locale->text('Customer missing!');
1935 # $locale->text('Vendor missing!');
1937 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1938 if ($form->{currency} ne $form->{defaultcurrency});
1942 # if the name changed get new values
1943 if (&check_name($form->{vc})) {
1948 $form->{id} = 0 if $form->{saveasnew};
1950 # this is for the internal notes section for the [email] Subject
1951 if ($form->{type} =~ /_order$/) {
1952 if ($form->{type} eq 'sales_order') {
1953 $form->{label} = $locale->text('Sales Order');
1955 $numberfld = "sonumber";
1956 $ordnumber = "ordnumber";
1958 $form->{label} = $locale->text('Purchase Order');
1960 $numberfld = "ponumber";
1961 $ordnumber = "ordnumber";
1964 $err = $locale->text('Cannot save order!');
1967 if ($form->{type} eq 'sales_quotation') {
1968 $form->{label} = $locale->text('Quotation');
1970 $numberfld = "sqnumber";
1971 $ordnumber = "quonumber";
1973 $form->{label} = $locale->text('Request for Quotation');
1975 $numberfld = "rfqnumber";
1976 $ordnumber = "quonumber";
1979 $err = $locale->text('Cannot save quotation!');
1983 # get new number in sequence if no number is given or if saveasnew was requested
1984 if (!$form->{$ordnumber} || $form->{saveasnew}) {
1985 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
1990 $form->error($err) if (!OE->save(\%myconfig, \%$form));
1992 # saving the history
1993 if(!exists $form->{addition}) {
1994 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
1995 $form->{addition} = "SAVED";
1996 $form->save_history($form->dbconnect(\%myconfig));
1998 # /saving the history
2000 $form->redirect($form->{label} . " $form->{$ordnumber} " .
2001 $locale->text('saved!'));
2003 $lxdebug->leave_sub();
2007 $lxdebug->enter_sub();
2009 if ($form->{type} =~ /_order$/) {
2010 $form->isblank("transdate", $locale->text('Order Date missing!'));
2012 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2015 $msg = ucfirst $form->{vc};
2016 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
2018 # $locale->text('Customer missing!');
2019 # $locale->text('Vendor missing!');
2021 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
2022 if ($form->{currency} ne $form->{defaultcurrency});
2026 # if the name changed get new values
2027 if (&check_name($form->{vc})) {
2032 $form->{id} = 0 if $form->{saveasnew};
2034 # this is for the internal notes section for the [email] Subject
2035 if ($form->{type} =~ /_order$/) {
2036 if ($form->{type} eq 'sales_order') {
2037 $form->{label} = $locale->text('Sales Order');
2039 $numberfld = "sonumber";
2040 $ordnumber = "ordnumber";
2042 $form->{label} = $locale->text('Purchase Order');
2044 $numberfld = "ponumber";
2045 $ordnumber = "ordnumber";
2048 $err = $locale->text('Cannot save order!');
2051 if ($form->{type} eq 'sales_quotation') {
2052 $form->{label} = $locale->text('Quotation');
2054 $numberfld = "sqnumber";
2055 $ordnumber = "quonumber";
2057 $form->{label} = $locale->text('Request for Quotation');
2059 $numberfld = "rfqnumber";
2060 $ordnumber = "quonumber";
2063 $err = $locale->text('Cannot save quotation!');
2067 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
2068 unless $form->{$ordnumber};
2072 OE->save(\%myconfig, \%$form);
2074 # saving the history
2075 if(!exists $form->{addition}) {
2076 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
2077 $form->{addition} = "SAVED";
2078 $form->save_history($form->dbconnect(\%myconfig));
2080 # /saving the history
2082 $form->{simple_save} = 1;
2083 if(!$form->{print_and_save}) {
2084 set_headings("edit");
2088 $lxdebug->leave_sub();
2092 $lxdebug->enter_sub();
2096 if ($form->{type} =~ /_order$/) {
2097 $msg = $locale->text('Are you sure you want to delete Order Number');
2098 $ordnumber = 'ordnumber';
2100 $msg = $locale->text('Are you sure you want to delete Quotation Number');
2101 $ordnumber = 'quonumber';
2107 <form method=post action=$form->{script}>
2110 # delete action variable
2111 map { delete $form->{$_} } qw(action header);
2113 foreach $key (keys %$form) {
2114 $form->{$key} =~ s/\"/"/g;
2115 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2119 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
2121 <h4>$msg $form->{$ordnumber}</h4>
2123 <input name=action class=submit type=submit value="|
2124 . $locale->text('Yes') . qq|">
2131 $lxdebug->leave_sub();
2135 $lxdebug->enter_sub();
2137 if ($form->{type} =~ /_order$/) {
2138 $msg = $locale->text('Order deleted!');
2139 $err = $locale->text('Cannot delete order!');
2141 $msg = $locale->text('Quotation deleted!');
2142 $err = $locale->text('Cannot delete quotation!');
2144 if (OE->delete(\%myconfig, \%$form, $spool)){
2145 $form->redirect($msg);
2146 # saving the history
2147 if(!exists $form->{addition}) {
2148 $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
2149 $form->{addition} = "DELETED";
2150 $form->save_history($form->dbconnect(\%myconfig));
2152 # /saving the history
2156 $lxdebug->leave_sub();
2160 $lxdebug->enter_sub();
2162 if ($form->{type} =~ /_order$/) {
2164 # these checks only apply if the items don't bring their own ordnumbers/transdates.
2165 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
2166 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
2167 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }->{''});
2168 $form->isblank("transdate", $locale->text('Order Date missing!'))
2169 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }->{''});
2171 # also copy deliverydate from the order
2172 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
2173 $form->{orddate} = $form->{transdate};
2175 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
2176 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2177 $form->{ordnumber} = "";
2178 $form->{quodate} = $form->{transdate};
2181 # if the name changed get new values
2182 if (&check_name($form->{vc})) {
2187 $form->{cp_id} *= 1;
2189 for $i (1 .. $form->{rowcount}) {
2190 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
2191 $form->{"${_}_${i}"})
2192 if ($form->{"${_}_${i}"}) }
2193 qw(ship qty sellprice listprice basefactor));
2196 if ( $form->{type} =~ /_order/
2197 && $form->{currency} ne $form->{defaultcurrency}) {
2199 # check if we need a new exchangerate
2200 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
2202 $orddate = $form->current_date(\%myconfig);
2204 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
2207 if (!$exchangerate) {
2208 &backorder_exchangerate($orddate, $buysell);
2213 # close orders/quotations
2214 $form->{closed} = 1;
2216 # save order if one ordnumber has been given
2217 # if not it's most likely a collective order, which can't be saved back
2218 # so they just have to be closed
2219 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
2220 OE->close_order(\%myconfig, \%$form);
2222 OE->close_orders(\%myconfig, \%$form);
2225 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
2227 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2230 $form->{closed} = 0;
2231 $form->{rowcount}--;
2232 $form->{shipto} = 1;
2234 if ($form->{type} =~ /_order$/) {
2235 $form->{exchangerate} = $exchangerate;
2239 if ( $form->{type} eq 'purchase_order'
2240 || $form->{type} eq 'request_quotation') {
2241 $form->{title} = $locale->text('Add Vendor Invoice');
2242 $form->{script} = 'ir.pl';
2246 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
2247 $form->{title} = $locale->text('Add Sales Invoice');
2248 $form->{script} = 'is.pl';
2253 # bo creates the id, reset it
2254 map { delete $form->{$_} }
2255 qw(id subject message cc bcc printed emailed queued);
2256 $form->{ $form->{vc} } =~ s/--.*//g;
2257 $form->{type} = "invoice";
2260 $locale = new Locale "$myconfig{countrycode}", "$script";
2262 require "bin/mozilla/$form->{script}";
2264 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
2266 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2267 qw(creditlimit creditremaining);
2269 $currency = $form->{currency};
2272 $form->{currency} = $currency;
2273 $form->{exchangerate} = "";
2274 $form->{forex} = "";
2275 $form->{exchangerate} = $exchangerate
2279 $form->check_exchangerate(
2280 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
2283 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
2288 for $i (1 .. $form->{rowcount}) {
2289 $form->{"discount_$i"} =
2290 $form->format_amount(\%myconfig, $form->{"discount_$i"});
2292 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
2294 $decimalplaces = ($dec > 2) ? $dec : 2;
2296 # copy delivery date from reqdate for order -> invoice conversion
2297 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
2298 unless $form->{"deliverydate_$i"};
2300 $form->{"sellprice_$i"} =
2301 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
2304 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
2305 $dec_qty = length $dec_qty;
2307 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
2309 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2310 qw(partnumber description unit);
2316 $lxdebug->leave_sub();
2319 sub backorder_exchangerate {
2320 $lxdebug->enter_sub();
2321 my ($orddate, $buysell) = @_;
2328 <form method=post action=$form->{script}>
2331 # delete action variable
2332 map { delete $form->{$_} } qw(action header exchangerate);
2334 foreach $key (keys %$form) {
2335 $form->{$key} =~ s/\"/"/g;
2336 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2339 $form->{title} = $locale->text('Add Exchangerate');
2343 <input type=hidden name=login value=$form->{login}>
2344 <input type=hidden name=password value=$form->{password}>
2346 <input type=hidden name=exchangeratedate value=$orddate>
2347 <input type=hidden name=buysell value=$buysell>
2350 <tr><th class=listtop>$form->{title}</th></tr>
2351 <tr height="5"></tr>
2356 <th align=right>| . $locale->text('Currency') . qq|</th>
2357 <td>$form->{currency}</td>
2360 <th align=right>| . $locale->text('Date') . qq|</th>
2364 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2365 <td><input name=exchangerate size=11></td>
2375 <input type=hidden name=nextsub value=save_exchangerate>
2377 <input name=action class=submit type=submit value="|
2378 . $locale->text('Continue') . qq|">
2386 $lxdebug->leave_sub();
2389 sub save_exchangerate {
2390 $lxdebug->enter_sub();
2392 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2393 $form->{exchangerate} =
2394 $form->parse_amount(\%myconfig, $form->{exchangerate});
2395 $form->save_exchangerate(\%myconfig, $form->{currency},
2396 $form->{exchangeratedate},
2397 $form->{exchangerate}, $form->{buysell});
2401 $lxdebug->leave_sub();
2404 sub create_backorder {
2405 $lxdebug->enter_sub();
2407 $form->{shipped} = 1;
2409 # figure out if we need to create a backorder
2410 # items aren't saved if qty != 0
2412 for $i (1 .. $form->{rowcount}) {
2413 $totalqty += $qty = $form->{"qty_$i"};
2414 $totalship += $ship = $form->{"ship_$i"};
2416 $form->{"qty_$i"} = $qty - $ship;
2419 if ($totalship == 0) {
2420 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2421 $form->{ordtotal} = 0;
2422 $form->{shipped} = 0;
2426 if ($totalqty == $totalship) {
2427 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2428 $form->{ordtotal} = 0;
2433 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2436 for $i (1 .. $form->{rowcount}) {
2438 $form->{"${_}_$i"} =
2439 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2440 } qw(sellprice discount);
2445 OE->save(\%myconfig, \%$form);
2447 # rebuild rows for invoice
2451 for $i (1 .. $form->{rowcount}) {
2452 $form->{"qty_$i"} = $form->{"ship_$i"};
2454 if ($form->{"qty_$i"}) {
2457 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2462 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2463 $form->{rowcount} = $count;
2465 $lxdebug->leave_sub();
2469 $lxdebug->enter_sub();
2471 $form->{saveasnew} = 1;
2472 $form->{closed} = 0;
2473 map { delete $form->{$_} } qw(printed emailed queued);
2475 # Let Lx-Office assign a new order number if the user hasn't changed the
2476 # previous one. If it has been changed manually then use it as-is.
2477 my $idx = $form->{type} =~ /_quotation$/ ? "quonumber" : "ordnumber";
2478 if ($form->{saved_xyznumber} &&
2479 ($form->{saved_xyznumber} eq $form->{$idx})) {
2480 delete($form->{$idx});
2485 $lxdebug->leave_sub();
2488 sub purchase_order {
2489 $lxdebug->enter_sub();
2491 if ( $form->{type} eq 'sales_quotation'
2492 || $form->{type} eq 'request_quotation') {
2493 OE->close_order(\%myconfig, \%$form);
2496 if ($form->{type} =~ /^sales_/) {
2497 delete($form->{ordnumber});
2500 $form->{cp_id} *= 1;
2502 $form->{title} = $locale->text('Add Purchase Order');
2503 $form->{vc} = "vendor";
2504 $form->{type} = "purchase_order";
2508 $lxdebug->leave_sub();
2512 $lxdebug->enter_sub();
2514 if ( $form->{type} eq 'sales_quotation'
2515 || $form->{type} eq 'request_quotation') {
2516 OE->close_order(\%myconfig, $form);
2519 if ($form->{type} eq "purchase_order") {
2520 delete($form->{ordnumber});
2523 $form->{cp_id} *= 1;
2525 $form->{title} = $locale->text('Add Sales Order');
2526 $form->{vc} = "customer";
2527 $form->{type} = "sales_order";
2531 $lxdebug->leave_sub();
2535 $lxdebug->enter_sub();
2537 $form->{transdate} = $form->current_date(\%myconfig);
2538 delete $form->{duedate};
2540 $form->{closed} = 0;
2543 map { delete $form->{$_} }
2544 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2546 for $i (1 .. $form->{rowcount}) {
2547 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
2548 $form->{"${_}_${i}"})
2549 if ($form->{"${_}_${i}"}) }
2550 qw(ship qty sellprice listprice basefactor));
2558 for $i (1 .. $form->{rowcount} - 1) {
2559 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2560 qw(partnumber description unit);
2563 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2564 qw(creditlimit creditremaining);
2568 $lxdebug->leave_sub();
2572 $lxdebug->enter_sub();
2574 $form->{print_and_save} = 1;
2579 my $saved_form = save_form();
2584 map({ $saved_vars{$_} = $form->{$_}; } qw(id ordnumber quonumber));
2585 restore_form($saved_form);
2586 map({ $form->{$_} = $saved_vars{$_}; } qw(id ordnumber quonumber));
2591 $lxdebug->leave_sub();