1 # #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger, Accounting
9 # Copyright (c) 1998-2003
11 # Author: Dieter Simader
12 # Email: dsimader@sql-ledger.org
13 # Web: http://www.sql-ledger.org
16 # This program is free software; you can redistribute it and/or modify
17 # it under the terms of the GNU General Public License as published by
18 # the Free Software Foundation; either version 2 of the License, or
19 # (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software
27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #======================================================================
32 #======================================================================
40 require "$form->{path}/io.pl";
41 require "$form->{path}/arap.pl";
48 # $locale->text('Edit the purchase_order');
49 # $locale->text('Edit the sales_order');
50 # $locale->text('Edit the request_quotation');
51 # $locale->text('Edit the sales_quotation');
53 # $locale->text('Workflow purchase_order');
54 # $locale->text('Workflow sales_order');
55 # $locale->text('Workflow request_quotation');
56 # $locale->text('Workflow sales_quotation');
59 $lxdebug->enter_sub();
63 if ($form->{type} eq 'purchase_order') {
64 $form->{title} = $action eq "edit" ?
65 $locale->text('Edit Purchase Order') :
66 $locale->text('Add Purchase Order');
67 $form->{heading} = $locale->text('Purchase Order');
68 $form->{vc} = 'vendor';
70 if ($form->{type} eq 'sales_order') {
71 $form->{title} = $action eq "edit" ?
72 $locale->text('Edit Sales Order') :
73 $locale->text('Add Sales Order');
74 $form->{heading} = $locale->text('Sales Order');
75 $form->{vc} = 'customer';
77 if ($form->{type} eq 'request_quotation') {
78 $form->{title} = $action eq "edit" ?
79 $locale->text('Edit Request for Quotation') :
80 $locale->text('Add Request for Quotation');
81 $form->{heading} = $locale->text('Request for Quotation');
82 $form->{vc} = 'vendor';
84 if ($form->{type} eq 'sales_quotation') {
85 $form->{title} = $action eq "edit" ?
86 $locale->text('Edit Quotation') :
87 $locale->text('Add Quotation');
88 $form->{heading} = $locale->text('Quotation');
89 $form->{vc} = 'customer';
92 $lxdebug->leave_sub();
96 $lxdebug->enter_sub();
101 "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&password=$form->{password}"
102 unless $form->{callback};
108 $lxdebug->leave_sub();
112 $lxdebug->enter_sub();
114 set_headings("edit");
116 # editing without stuff to edit? try adding it first
117 if ($form->{rowcount}) {
118 map { $id++ if $form->{"id_$_"} } (1 .. $form->{rowcount});
122 undef $form->{rowcount};
133 if ($form->{print_and_save}) {
134 $form->{action} = "print";
135 $form->{resubmit} = 1;
136 $language_id = $form->{language_id};
137 $printer_id = $form->{printer_id};
140 set_headings("edit");
144 if ($form->{print_and_save}) {
145 $form->{language_id} = $language_id;
146 $form->{printer_id} = $printer_id;
150 $lxdebug->leave_sub();
154 $lxdebug->enter_sub();
156 # get customer/vendor
157 $form->all_vc(\%myconfig, $form->{vc},
158 ($form->{vc} eq 'customer') ? "AR" : "AP");
160 # retrieve order/quotation
161 $form->{webdav} = $webdav;
163 $form->{jscalendar} = $jscalendar;
165 OE->retrieve(\%myconfig, \%$form);
167 if ($form->{payment_id}) {
168 $payment_id = $form->{payment_id};
170 if ($form->{language_id}) {
171 $language_id = $form->{language_id};
173 if ($form->{taxzone_id}) {
174 $taxzone_id = $form->{taxzone_id};
178 # if multiple rowcounts (== collective order) then check if the
179 # there were more than one customer (in that case OE::retrieve removes
180 # the content from the field)
181 if ( $form->{rowcount}
182 && $form->{type} eq 'sales_order'
183 && defined $form->{customer}
184 && $form->{customer} eq '') {
186 # $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
189 'Collective Orders only work for orders from one customer!')
193 $taxincluded = $form->{taxincluded};
194 $form->{shipto} = 1 if $form->{id};
196 if ($form->{"all_$form->{vc}"}) {
197 unless ($form->{"$form->{vc}_id"}) {
198 $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
202 $cp_id = $form->{cp_id};
203 $intnotes = $form->{intnotes};
205 # get customer / vendor
206 if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/) {
207 IR->get_vendor(\%myconfig, \%$form);
209 #quote all_vendor Bug 133
210 foreach $ref (@{ $form->{all_vendor} }) {
211 $ref->{name} = $form->quote($ref->{name});
215 if ($form->{type} =~ /(sales|ship)_(order|quotation)/) {
216 IS->get_customer(\%myconfig, \%$form);
218 #quote all_vendor Bug 133
219 foreach $ref (@{ $form->{all_customer} }) {
220 $ref->{name} = $form->quote($ref->{name});
224 $form->{cp_id} = $cp_id;
226 $form->{payment_id} = $payment_id;
229 $form->{language_id} = $language_id;
232 $form->{taxzone_id} = $taxzone_id;
234 $form->{intnotes} = $intnotes;
235 ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
236 $form->{"old$form->{vc}"} =
237 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
239 # build the popup menus
240 if (@{ $form->{"all_$form->{vc}"} }) {
241 $form->{ $form->{vc} } =
242 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
243 map { $form->{"select$form->{vc}"} .= "<option>$_->{name}--$_->{id}\n" }
244 (@{ $form->{"all_$form->{vc}"} });
248 @curr = split(/:/, $form->{currencies});
250 $form->{defaultcurrency} = $curr[0];
251 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
253 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
255 $form->{taxincluded} = $taxincluded if ($form->{id});
258 if (@{ $form->{all_departments} }) {
259 $form->{selectdepartment} = "<option>\n";
260 $form->{department} = "$form->{department}--$form->{department_id}";
263 $form->{selectdepartment} .=
264 "<option>$_->{description}--$_->{id}\n"
265 } (@{ $form->{all_departments} });
268 $form->{employee} = "$form->{employee}--$form->{employee_id}";
271 if (@{ $form->{all_employees} }) {
272 $form->{selectemployee} = "";
273 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
274 (@{ $form->{all_employees} });
278 $form->{forex} = $form->{exchangerate};
280 $lxdebug->leave_sub();
284 $lxdebug->enter_sub();
285 $form->{format} = "pdf" unless ($form->{print_and_save} && $form->{format});
286 $form->{media} = "screen";
287 $form->{formname} = $form->{type} unless $form->{formname};
289 map { $form->{$_} =~ s/\"/"/g }
290 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
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 $checkedopen = ($form->{closed}) ? "" : "checked";
333 $checkedclosed = ($form->{closed}) ? "checked" : "";
335 # use JavaScript Calendar or not
336 $form->{jsscript} = $form->{jscalendar};
339 $payment = qq|<option value=""></option>|;
340 foreach $item (@{ $form->{payment_terms} }) {
341 if ($form->{payment_id} eq $item->{id}) {
342 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
344 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
347 if ($form->{jsscript}) {
349 # with JavaScript Calendar
351 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
352 <td><input type=button name=transdate id="trigger1" value=|
353 . $locale->text('button') . qq|></td>
356 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
357 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
358 . $locale->text('button') . qq|></td>
363 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
364 "reqdate", "BL", "trigger2");
368 # without JavaScript Calendar
370 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
372 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
378 <td colspan=2 align=center>
381 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
382 . $locale->text('Open') . qq|</th>
383 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
384 . $locale->text('Closed') . qq|</th>
392 # set option selected
393 foreach $item ($form->{vc}, currency, department, employee) {
394 $form->{"select$item"} =~ s/ selected//;
395 $form->{"select$item"} =~
396 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
399 #quote select[customer|vendor] Bug 133
400 $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
403 if ($form->{all_contacts}) {
405 $form->{selectcontact} = "<option></option>";
406 foreach $item (@{ $form->{all_contacts} }) {
407 my $department = ($item->{cp_abteilung}) ? "--$item->{cp_abteilung}" : "";
408 if ($form->{cp_id} == $item->{cp_id}) {
409 $form->{selectcontact} .=
410 "<option value=$item->{cp_id} selected>$item->{cp_name}$department</option>";
412 $form->{selectcontact} .= "<option value=$item->{cp_id}>$item->{cp_name}$department</option>";
416 $form->{selectcontact} =~ s/ selected//g;
417 if ($form->{cp_id} ne "") {
418 $form->{selectcontact} =~ s/value=$form->{cp_id}/value=$form->{cp_id} selected/;
423 if (@{ $form->{SHIPTO} }) {
424 $form->{selectshipto} = "<option value=0></option>";
425 foreach $item (@{ $form->{SHIPTO} }) {
426 if ($item->{id} == $form->{shipto_id}) {
427 $form->{selectshipto} .=
428 "<option value=$item->{id} selected>$item->{shiptoname}</option>";
430 $form->{selectshipto} .=
431 "<option value=$item->{id}>$item->{shiptoname}</option>";
436 $form->{selectshipto} =~ s/ selected//g;
437 if ($form->{shipto_id} ne "") {
438 $form->{selectshipto} =~ s/value=$form->{shipto_id}/value=$form->{shipto_id} selected/;
443 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
444 <td><select name=shipto_id>$form->{selectshipto}</select></td>
445 <input type=hidden name=selectshipto value="$form->{selectshipto}">|;
450 $form->{exchangerate} =
451 $form->format_amount(\%myconfig, $form->{exchangerate});
453 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
459 $form->{creditlimit} =
460 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
461 $form->{creditremaining} =
462 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
465 ($form->{selectcontact})
466 ? qq|<select name=cp_id>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
467 : qq|<input name=contact value="$form->{contact}" size=35>|;
470 <input type=hidden name=forex value=$form->{forex}>
473 if ($form->{currency} ne $form->{defaultcurrency}) {
474 if ($form->{forex}) {
477 . $locale->text('Exchangerate')
478 . qq|</th><td>$form->{exchangerate}</td>
479 <input type=hidden name=exchangerate value=$form->{exchangerate}>
484 . $locale->text('Exchangerate')
485 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
489 $vclabel = ucfirst $form->{vc};
490 $vclabel = $locale->text($vclabel);
494 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
495 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
496 . $locale->text('days') . qq|</td>
500 if ($form->{business}) {
503 <th align=right>| . $locale->text('Business') . qq|</th>
504 <td>$form->{business}</td>
505 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
507 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
513 if ($form->{max_dunning_level}) {
519 <th align=right>| . $locale->text('Max. Dunning Level') . qq|:</th>
520 <td><b>$form->{max_dunning_level}</b></td>
521 <th align=right>| . $locale->text('Dunning Amount') . qq|:</th>
523 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
532 if (@{ $form->{TAXZONE} }) {
533 $form->{selecttaxzone} = "";
534 foreach $item (@{ $form->{TAXZONE} }) {
535 if ($item->{id} == $form->{taxzone_id}) {
536 $form->{selecttaxzone} .=
537 "<option value=$item->{id} selected>$item->{description}</option>";
539 $form->{selecttaxzone} .=
540 "<option value=$item->{id}>$item->{description}</option>";
545 $form->{selecttaxzone} =~ s/ selected//g;
546 if ($form->{taxzone_id} ne "") {
547 $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/;
551 if ($form->{rowcount} >0) {
552 $form->{selecttaxzone} =~ /<option value=\d+ selected>.*?<\/option>/;
553 $form->{selecttaxzone} = $&;
559 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
560 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
561 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
565 if ($form->{type} !~ /_quotation$/) {
568 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
569 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
572 <th width=70% align=right nowrap>|
573 . $locale->text('Quotation Number') . qq|</th>
574 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
577 <th width=70% align=right nowrap>|
578 . $locale->text('Customer Order Number') . qq|</th>
579 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
582 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
587 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
592 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
594 $creditremaining = qq|
600 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
601 <td>$form->{creditlimit}</td>
603 <th nowrap>| . $locale->text('Remaining') . qq|</th>
604 <td class="plus$n">$form->{creditremaining}</td>
613 ($form->{type} eq 'sales_quotation')
614 ? $locale->text('Valid until')
615 : $locale->text('Required by');
616 if ($form->{type} eq 'sales_quotation') {
619 <th width=70% align=right nowrap>|
620 . $locale->text('Quotation Number') . qq|</th>
621 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
622 <input type=hidden name=ordnumber value="$form->{ordnumber}">
628 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
629 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
630 <input type=hidden name=ordnumber value="$form->{ordnumber}">
639 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
643 <th align=right nowrap=true>$reqlabel</th>
647 $creditremaining = qq| <tr>
654 ($form->{"select$form->{vc}"})
655 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
656 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
660 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
661 <td colspan=3><select name=department>$form->{selectdepartment}</select>
662 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
665 | if $form->{selectdepartment};
668 <input type=hidden name=employee value="$form->{employee}">
671 if ($form->{type} eq 'sales_order') {
672 if ($form->{selectemployee}) {
674 <input type=hidden name=customer_klass value=$form->{customer_klass}>
676 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
677 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
678 <input type=hidden name=selectemployee value="$form->{selectemployee}">
685 <input type=hidden name=customer_klass value=$form->{customer_klass}>
687 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
688 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
689 <input type=hidden name=selectemployee value="$form->{selectemployee}">
694 if ($form->{resubmit} && ($form->{format} eq "html")) {
696 qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
697 } elsif ($form->{resubmit}) {
698 $onload = qq|document.oe.submit()|;
703 $credittext = $locale->text('Credit Limit exceeded!!!');
704 if ($creditwarning) {
705 $onload = qq|alert('$credittext')|;
711 <body onLoad="$onload">
713 <form method=post name=oe action=$form->{script}>
714 <script type="text/javascript" src="js/common.js"></script>
715 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
716 <script type="text/javascript" src="js/vendor_selection.js"></script>
717 <script type="text/javascript" src="js/calculate_qty.js"></script>
719 <input type=hidden name=id value=$form->{id}>
720 <input type=hidden name=action value=$form->{action}>
722 <input type=hidden name=type value=$form->{type}>
723 <input type=hidden name=formname value=$form->{formname}>
724 <input type=hidden name=media value=$form->{media}>
725 <input type=hidden name=format value=$form->{format}>
726 <input type=hidden name=proforma value=$form->{proforma}>
728 <input type=hidden name=queued value="$form->{queued}">
729 <input type=hidden name=printed value="$form->{printed}">
730 <input type=hidden name=emailed value="$form->{emailed}">
732 <input type=hidden name=vc value=$form->{vc}>
734 <input type=hidden name=title value="$form->{title}">
736 <input type=hidden name=discount value=$form->{discount}>
737 <input type=hidden name=creditlimit value=$form->{creditlimit}>
738 <input type=hidden name=creditremaining value=$form->{creditremaining}>
740 <input type=hidden name=tradediscount value=$form->{tradediscount}>
741 <input type=hidden name=business value=$form->{business}>
742 <input type=hidden name=webdav value=$webdav>
746 <th class=listtop>$form->{title}</th>
756 <th align=right>$vclabel</th>
757 <td colspan=3>$vc</td>
758 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
759 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
760 <th align=richt nowrap>|
761 . $locale->text('Contact Person') . qq|</th>
762 <td colspan=3>$contact</td>
770 <th align=right>| . $locale->text('Currency') . qq|</th>
771 <td><select name=currency>$form->{selectcurrency}</select></td>
772 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
773 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
777 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
778 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
781 <th align=right>| . $locale->text('Ship via') . qq|</th>
782 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
789 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
791 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
792 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
796 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
798 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
799 # <input size=45 id=vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
821 <!-- shipto are in hidden variables -->
823 <input type=hidden name=shiptoname value="$form->{shiptoname}">
824 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
825 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
826 <input type=hidden name=shiptocity value="$form->{shiptocity}">
827 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
828 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
829 <input type=hidden name=shiptophone value="$form->{shiptophone}">
830 <input type=hidden name=shiptofax value="$form->{shiptofax}">
831 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
833 <!-- email variables -->
834 <input type=hidden name=message value="$form->{message}">
835 <input type=hidden name=email value="$form->{email}">
836 <input type=hidden name=subject value="$form->{subject}">
837 <input type=hidden name=cc value="$form->{cc}">
838 <input type=hidden name=bcc value="$form->{bcc}">
840 <input type=hidden name=taxpart value="$form->{taxpart}">
841 <input type=hidden name=taxservice value="$form->{taxservice}">
843 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
846 foreach $item (split / /, $form->{taxaccounts}) {
848 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
849 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
852 $lxdebug->leave_sub();
856 $lxdebug->enter_sub();
858 $form->{invtotal} = $form->{invsubtotal};
860 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
863 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
866 $rows = ($rows > $introws) ? $rows : $introws;
868 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
870 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
872 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
875 if ($form->{taxaccounts}) {
877 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
878 . $locale->text('Tax Included') . qq|</b><br><br>
882 if (!$form->{taxincluded}) {
884 foreach $item (split / /, $form->{taxaccounts}) {
885 if ($form->{"${item}_base"}) {
886 $form->{invtotal} += $form->{"${item}_total"} =
888 $form->{"${item}_base"} * $form->{"${item}_rate"},
890 $form->{"${item}_total"} =
891 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
895 <th align=right>$form->{"${item}_description"}</th>
896 <td align=right>$form->{"${item}_total"}</td>
902 $form->{invsubtotal} =
903 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
907 <th align=right>| . $locale->text('Subtotal') . qq|</th>
908 <td align=right>$form->{invsubtotal}</td>
914 if ($form->{taxincluded}) {
915 foreach $item (split / /, $form->{taxaccounts}) {
916 if ($form->{"${item}_base"}) {
917 $form->{"${item}_total"} =
919 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
920 (1 + $form->{"${item}_rate"})
923 $form->{"${item}_netto"} =
925 ($form->{"${item}_base"} - $form->{"${item}_total"}),
927 $form->{"${item}_total"} =
928 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
929 $form->{"${item}_netto"} =
930 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
934 <th align=right>Enthaltene $form->{"${item}_description"}</th>
935 <td align=right>$form->{"${item}_total"}</td>
938 <th align=right>Nettobetrag</th>
939 <td align=right>$form->{"${item}_netto"}</td>
947 $form->{oldinvtotal} = $form->{invtotal};
949 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
959 <th align=left>| . $locale->text('Notes') . qq|</th>
960 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
966 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
967 <td><select name=payment_id tabindex=24>$payment
971 <td align=right width=100%>
977 <th align=right>| . $locale->text('Total') . qq|</th>
978 <td align=right>$form->{invtotal}</td>
986 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
987 <input type=hidden name=oldtotalpaid value=$totalpaid>
989 <td><hr size=3 noshade></td>
997 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
1000 <td align=left width=30%><b>Dateiname</b></td>
1001 <td align=left width=70%><b>Webdavlink</b></td>
1003 foreach $file (keys %{ $form->{WEBDAV} }) {
1006 <td align=left>$file</td>
1007 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
1015 <td><hr size=3 noshade></td>
1022 <input type=hidden name=jscalendar value=$form->{jscalendar}>
1035 | . $locale->text("Edit the $form->{type}") . qq|<br>
1036 <input class=submit type=submit name=action value="|
1037 . $locale->text('Update') . qq|">
1038 <input class=submit type=submit name=action value="|
1039 . $locale->text('Ship to') . qq|">
1040 <input class=submit type=submit name=action value="|
1041 . $locale->text('Print') . qq|">
1042 <input class=submit type=submit name=action value="|
1043 . $locale->text('E-mail') . qq|">
1044 <input class=submit type=submit name=action value="|
1045 . $locale->text('Save') . qq|">
1046 <input class=submit type=submit name=action value="|
1047 . $locale->text('Save and Close') . qq|">
1050 if (($form->{id})) {
1052 <br>| . $locale->text("Workflow $form->{type}") . qq|<br>
1053 <input class=submit type=submit name=action value="|
1054 . $locale->text('Save as new') . qq|">
1055 <input class=submit type=submit name=action value="|
1056 . $locale->text('Delete') . qq|">|;
1057 if (($form->{type} =~ /sales_quotation$/)) {
1059 <input class=submit type=submit name=action value="|
1060 . $locale->text('Sales Order') . qq|">|;
1062 if ($form->{type} =~ /request_quotation$/) {
1064 <input class=submit type=submit name=action value="|
1065 . $locale->text('Purchase Order') . qq|">|;
1069 <input class=submit type=submit name=action value="|
1070 . $locale->text('Invoice') . qq|">
1074 if ($form->{type} =~ /sales_order$/) {
1076 <br>$form->{heading} als neue Vorlage verwenden für<br>
1077 <input class=submit type=submit name=action value="|
1078 . $locale->text('Purchase Order') . qq|">
1079 <input class=submit type=submit name=action value="|
1080 . $locale->text('Quotation') . qq|">
1083 } elsif ($form->{type} =~ /purchase_order$/) {
1085 <br>$form->{heading} als neue Vorlage verwenden für<br>
1086 <input class=submit type=submit name=action value="|
1087 . $locale->text('Sales Order') . qq|">
1088 <input class=submit type=submit name=action value="|
1089 . $locale->text('Quotation') . qq|">
1094 <br>$form->{heading} als neue Vorlage verwenden für<br>
1095 <input class=submit type=submit name=action value="|
1096 . $locale->text('Order') . qq|">
1099 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount} && !$form->{proforma}) {
1101 <br>Workflow $form->{heading}<br>
1102 <input class=submit type=submit name=action value="|
1103 . $locale->text('Save as new') . qq|">
1104 <input class=submit type=submit name=action value="|
1105 . $locale->text('Invoice') . qq|">
1109 if ($form->{menubar}) {
1110 require "$form->{path}/menu.pl";
1116 <input type=hidden name=rowcount value=$form->{rowcount}>
1118 <input name=callback type=hidden value="$form->{callback}">
1120 <input type=hidden name=path value=$form->{path}>
1121 <input type=hidden name=login value=$form->{login}>
1122 <input type=hidden name=password value=$form->{password}>
1129 $lxdebug->leave_sub();
1133 $lxdebug->enter_sub();
1135 set_headings($form->{"id"} ? "edit" : "add");
1137 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1138 qw(exchangerate creditlimit creditremaining);
1139 $form->{update} = 1;
1141 &check_name($form->{vc});
1146 $buysell = 'sell' if ($form->{vc} eq 'vendor');
1147 $form->{exchangerate} = $exchangerate
1151 $form->check_exchangerate(
1152 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1156 $i = $form->{rowcount};
1158 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1160 if ( ($form->{"partnumber_$i"} eq "")
1161 && ($form->{"description_$i"} eq "")
1162 && ($form->{"partsgroup_$i"} eq "")) {
1164 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1169 $form->{"selected_unit_$i"} = $form->{"unit_$i"};
1171 if ( $form->{type} eq 'purchase_order'
1172 || $form->{type} eq 'request_quotation') {
1173 IR->retrieve_item(\%myconfig, \%$form);
1175 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1176 IS->retrieve_item(\%myconfig, \%$form);
1179 my $rows = scalar @{ $form->{item_list} };
1181 $form->{"discount_$i"} =
1182 $form->format_amount(\%myconfig, $form->{discount} * 100);
1185 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1194 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1195 if ($form->{"not_discountable_$i"}) {
1196 $form->{"discount_$i"} = 0;
1198 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1199 qw(partnumber description unit);
1200 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1201 keys %{ $form->{item_list}[0] };
1202 if ($form->{"part_payment_id_$i"} ne "") {
1203 $form->{payment_id} = $form->{"part_payment_id_$i"};
1206 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1208 ($dec) = ($s =~ /\.(\d+)/);
1210 $decimalplaces = ($dec > 2) ? $dec : 2;
1213 $form->{"sellprice_$i"} = $sellprice;
1216 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1218 # if there is an exchange rate adjust sellprice
1219 $form->{"sellprice_$i"} /= $exchangerate;
1223 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1224 (1 - $form->{"discount_$i"} / 100);
1225 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1226 map { $form->{"${_}_base"} += $amount }
1227 (split / /, $form->{"taxaccounts_$i"});
1228 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1229 split / /, $form->{taxaccounts}
1230 if !$form->{taxincluded};
1232 $form->{creditremaining} -= $amount;
1234 $form->{"sellprice_$i"} =
1235 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1238 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1240 # get pricegroups for parts
1241 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1243 # build up html code for prices_$i
1244 &set_pricegroup($i);
1251 # ok, so this is a new part
1252 # ask if it is a part or service item
1254 if ( $form->{"partsgroup_$i"}
1255 && ($form->{"partsnumber_$i"} eq "")
1256 && ($form->{"description_$i"} eq "")) {
1257 $form->{rowcount}--;
1258 $form->{"discount_$i"} = "";
1262 $form->{"id_$i"} = 0;
1263 $form->{"unit_$i"} = $locale->text('ea');
1271 $lxdebug->leave_sub();
1275 $lxdebug->enter_sub();
1277 if ($form->{type} eq 'purchase_order') {
1278 $form->{title} = $locale->text('Purchase Orders');
1279 $form->{vc} = 'vendor';
1280 $ordlabel = $locale->text('Order Number');
1281 $ordnumber = 'ordnumber';
1282 $employee = $locale->text('Employee');
1284 if ($form->{type} eq 'request_quotation') {
1285 $form->{title} = $locale->text('Request for Quotations');
1286 $form->{vc} = 'vendor';
1287 $ordlabel = $locale->text('RFQ Number');
1288 $ordnumber = 'quonumber';
1289 $employee = $locale->text('Employee');
1291 if ($form->{type} eq 'receive_order') {
1292 $form->{title} = $locale->text('Receive Merchandise');
1293 $form->{vc} = 'vendor';
1294 $ordlabel = $locale->text('Order Number');
1295 $ordnumber = 'ordnumber';
1296 $employee = $locale->text('Employee');
1298 if ($form->{type} eq 'sales_order') {
1299 $form->{title} = $locale->text('Sales Orders');
1300 $form->{vc} = 'customer';
1301 $ordlabel = $locale->text('Order Number');
1302 $ordnumber = 'ordnumber';
1303 $employee = $locale->text('Salesperson');
1305 if ($form->{type} eq 'ship_order') {
1306 $form->{title} = $locale->text('Ship Merchandise');
1307 $form->{vc} = 'customer';
1308 $ordlabel = $locale->text('Order Number');
1309 $ordnumber = 'ordnumber';
1310 $employee = $locale->text('Salesperson');
1314 if ($form->{type} eq 'sales_quotation') {
1315 $form->{title} = $locale->text('Quotations');
1316 $form->{vc} = 'customer';
1317 $ordlabel = $locale->text('Quotation Number');
1318 $ordnumber = 'quonumber';
1319 $employee = $locale->text('Employee');
1322 if ($form->{type} =~ /(ship|receive)_order/) {
1323 OE->get_warehouses(\%myconfig, \%$form);
1326 if (@{ $form->{all_warehouses} }) {
1327 $form->{selectwarehouse} = "<option>\n";
1328 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1331 $form->{selectwarehouse} .=
1332 "<option>$_->{description}--$_->{id}\n"
1333 } (@{ $form->{all_warehouses} });
1337 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1338 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1339 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1346 # setup vendor / customer selection
1347 $form->all_vc(\%myconfig, $form->{vc},
1348 ($form->{vc} eq 'customer') ? "AR" : "AP");
1350 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1351 @{ $form->{"all_$form->{vc}"} };
1353 $vclabel = ucfirst $form->{vc};
1354 $vclabel = $locale->text($vclabel);
1356 # $locale->text('Vendor')
1357 # $locale->text('Customer')
1361 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1362 : qq|<input name=$form->{vc} size=35>|;
1365 if (@{ $form->{all_departments} }) {
1366 $form->{selectdepartment} = "<option>\n";
1369 $form->{selectdepartment} .=
1370 "<option>$_->{description}--$_->{id}\n"
1371 } (@{ $form->{all_departments} });
1376 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1377 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1379 | if $form->{selectdepartment};
1381 if ($form->{type} !~ /(ship_order|receive_order)/) {
1384 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1385 . $locale->text('Open') . qq|</td>
1386 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1387 . $locale->text('Closed') . qq|</td>
1393 <input type=hidden name="open" value=1>
1397 # use JavaScript Calendar or not
1398 $form->{jsscript} = $jscalendar;
1400 if ($form->{jsscript}) {
1402 # with JavaScript Calendar
1404 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1405 <input type=button name=transdatefrom id="trigger3" value=|
1406 . $locale->text('button') . qq|></td>
1409 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1410 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1411 . $locale->text('button') . qq|></td>
1416 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1417 "transdateto", "BL", "trigger4");
1420 # without JavaScript Calendar
1422 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1424 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1432 <form method=post action=$form->{script}>
1436 <th class=listtop>$form->{title}</th>
1438 <tr height="5"></tr>
1443 <th align=right>$vclabel</th>
1444 <td colspan=3>$vc</td>
1449 <th align=right>$ordlabel</th>
1450 <td colspan=3><input name="$ordnumber" size=20></td>
1453 <th align=right>| . $locale->text('From') . qq|</th>
1455 <th align=right>| . $locale->text('Bis') . qq|</th>
1458 <input type=hidden name=sort value=transdate>
1460 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1465 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1466 | . $locale->text('ID') . qq|</td>
1467 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1468 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1469 . $locale->text('Date') . qq|</td>
1470 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1471 . $locale->text('Required by') . qq|</td>
1474 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1475 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1476 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1477 . $locale->text('Ship via') . qq|</td>
1480 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1481 . $locale->text('Amount') . qq|</td>
1482 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1483 . $locale->text('Tax') . qq|</td>
1484 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1485 . $locale->text('Total') . qq|</td>
1488 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1489 . $locale->text('Subtotal') . qq|</td>
1497 <tr><td colspan=4><hr size=3 noshade></td></tr>
1503 <input type=hidden name=nextsub value=orders>
1504 <input type=hidden name=path value=$form->{path}>
1505 <input type=hidden name=login value=$form->{login}>
1506 <input type=hidden name=password value=$form->{password}>
1507 <input type=hidden name=vc value=$form->{vc}>
1508 <input type=hidden name=type value=$form->{type}>
1510 <input class=submit type=submit name=action value="|
1511 . $locale->text('Continue') . qq|">
1518 $lxdebug->leave_sub();
1522 $lxdebug->enter_sub();
1524 # split vendor / customer
1525 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1526 split(/--/, $form->{ $form->{vc} });
1528 OE->transactions(\%myconfig, \%$form);
1530 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1532 $number = $form->escape($form->{$ordnumber});
1533 $name = $form->escape($form->{ $form->{vc} });
1534 $department = $form->escape($form->{department});
1535 $warehouse = $form->escape($form->{warehouse});
1539 "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}&$ordnumber=$number&$form->{vc}=$name&department=$department&warehouse=$warehouse";
1541 # construct callback
1542 $number = $form->escape($form->{$ordnumber}, 1);
1543 $name = $form->escape($form->{ $form->{vc} }, 1);
1544 $department = $form->escape($form->{department}, 1);
1545 $warehouse = $form->escape($form->{warehouse}, 1);
1548 "$form->{script}?path=$form->{path}&action=orders&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&transdatefrom=$form->{transdatefrom}&transdateto=$form->{transdateto}&open=$form->{open}&closed=$form->{closed}&$ordnumber=$number&$form->{vc}=$name&department=$department&warehouse=$warehouse";
1551 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1552 "name", "netamount", "tax", "amount",
1553 "curr", "employee", "shipvia", "open",
1556 $form->{l_open} = $form->{l_closed} = "Y"
1557 if ($form->{open} && $form->{closed});
1559 foreach $item (@columns) {
1560 if ($form->{"l_$item"} eq "Y") {
1561 push @column_index, $item;
1563 # add column to href and callback
1564 $callback .= "&l_$item=Y";
1565 $href .= "&l_$item=Y";
1569 # only show checkboxes if gotten here via sales_order form.
1570 if ($form->{type} =~ /sales_order/) {
1571 unshift @column_index, "ids";
1574 if ($form->{l_subtotal} eq 'Y') {
1575 $callback .= "&l_subtotal=Y";
1576 $href .= "&l_subtotal=Y";
1579 if ($form->{vc} eq 'vendor') {
1580 if ($form->{type} eq 'receive_order') {
1581 $form->{title} = $locale->text('Receive Merchandise');
1582 } elsif ($form->{type} eq 'purchase_order') {
1583 $form->{title} = $locale->text('Purchase Orders');
1585 $form->{title} = $locale->text('Request for Quotations');
1587 $name = $locale->text('Vendor');
1588 $employee = $locale->text('Employee');
1590 if ($form->{vc} eq 'customer') {
1591 if ($form->{type} eq 'sales_order') {
1592 $form->{title} = $locale->text('Sales Orders');
1593 $employee = $locale->text('Salesperson');
1594 } elsif ($form->{type} eq 'ship_order') {
1595 $form->{title} = $locale->text('Ship Merchandise');
1596 $employee = $locale->text('Salesperson');
1598 $form->{title} = $locale->text('Quotations');
1599 $employee = $locale->text('Employee');
1601 $name = $locale->text('Customer');
1604 $column_header{id} =
1605 qq|<th><a class=listheading href=$href&sort=id>|
1606 . $locale->text('ID')
1608 $column_header{transdate} =
1609 qq|<th><a class=listheading href=$href&sort=transdate>|
1610 . $locale->text('Date')
1612 $column_header{reqdate} =
1613 qq|<th><a class=listheading href=$href&sort=reqdate>|
1614 . $locale->text('Required by')
1616 $column_header{ordnumber} =
1617 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1618 . $locale->text('Order')
1620 $column_header{quonumber} =
1621 qq|<th><a class=listheading href=$href&sort=quonumber>|
1622 . $locale->text('Quotation')
1624 $column_header{name} =
1625 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1626 $column_header{netamount} =
1627 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1628 $column_header{tax} =
1629 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1630 $column_header{amount} =
1631 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1632 $column_header{curr} =
1633 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1634 $column_header{shipvia} =
1635 qq|<th><a class=listheading href=$href&sort=shipvia>|
1636 . $locale->text('Ship via')
1638 $column_header{open} =
1639 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1640 $column_header{closed} =
1641 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1643 $column_header{employee} =
1644 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1646 $column_header{ids} = qq|<th></th>|;
1648 if ($form->{ $form->{vc} }) {
1649 $option = $locale->text(ucfirst $form->{vc});
1650 $option .= " : $form->{$form->{vc}}";
1652 if ($form->{warehouse}) {
1653 ($warehouse) = split /--/, $form->{warehouse};
1654 $option .= "\n<br>" if ($option);
1655 $option .= $locale->text('Warehouse');
1656 $option .= " : $warehouse";
1658 if ($form->{department}) {
1659 $option .= "\n<br>" if ($option);
1660 ($department) = split /--/, $form->{department};
1661 $option .= $locale->text('Department') . " : $department";
1663 if ($form->{transdatefrom}) {
1665 . $locale->text('From') . " "
1666 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1668 if ($form->{transdateto}) {
1670 . $locale->text('Bis') . " "
1671 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1673 if ($form->{open}) {
1674 $option .= "\n<br>" if ($option);
1675 $option .= $locale->text('Open');
1677 if ($form->{closed}) {
1678 $option .= "\n<br>" if ($option);
1679 $option .= $locale->text('Closed');
1687 <form method="post" action="oe.pl">
1690 <th class=listtop>$form->{title}</th>
1692 <tr height="5"></tr>
1699 <tr class=listheading>|;
1701 map { print "\n$column_header{$_}" } @column_index;
1707 # add sort and escape callback
1708 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1710 if (@{ $form->{OE} }) {
1711 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1715 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1717 $warehouse = $form->escape($form->{warehouse});
1719 foreach $oe (@{ $form->{OE} }) {
1720 $form->{rowcount} = ++$j;
1722 if ($form->{l_subtotal} eq 'Y') {
1723 if ($sameitem ne $oe->{ $form->{sort} }) {
1725 $sameitem = $oe->{ $form->{sort} };
1729 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1731 $column_data{netamount} =
1733 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1735 $column_data{tax} = "<td align=right>"
1736 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1739 $column_data{amount} =
1741 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1743 $totalnetamount += $oe->{netamount};
1744 $totalamount += $oe->{amount};
1746 $subtotalnetamount += $oe->{netamount};
1747 $subtotalamount += $oe->{amount};
1750 qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1751 $column_data{id} = "<td>$oe->{id}</td>";
1752 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1753 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1755 $column_data{$ordnumber} =
1756 "<td><a href=oe.pl?path=$form->{path}&action=$action&type=$form->{type}&id=$oe->{id}&warehouse=$warehouse&vc=$form->{vc}&login=$form->{login}&password=$form->{password}&callback=$callback_escaped>$oe->{$ordnumber}</a></td>";
1757 $column_data{name} = "<td>$oe->{name}</td>";
1759 $column_data{employee} = "<td>$oe->{employee} </td>";
1760 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1762 if ($oe->{closed}) {
1763 $column_data{closed} = "<td align=center>X</td>";
1764 $column_data{open} = "<td> </td>";
1766 $column_data{closed} = "<td> </td>";
1767 $column_data{open} = "<td align=center>X</td>";
1773 <tr class=listrow$i>";
1775 map { print "\n$column_data{$_}" } @column_index;
1783 if ($form->{l_subtotal} eq 'Y') {
1789 <tr class=listtotal>|;
1791 map { $column_data{$_} = "<td> </td>" } @column_index;
1793 $column_data{netamount} =
1794 "<th class=listtotal align=right>"
1795 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1796 $column_data{tax} = "<th class=listtotal align=right>"
1797 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1800 $column_data{amount} =
1801 "<th class=listtotal align=right>"
1802 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1804 map { print "\n$column_data{$_}" } @column_index;
1812 <td><hr size=3 noshade></td>
1816 # multiple invoice edit button only if gotten there via sales_order form.
1818 if ($form->{type} =~ /sales_order/) {
1820 <input type="hidden" name="path" value="$form->{path}">
1821 <input class"submit" type="submit" name="action" value="|
1822 . $locale->text('Continue') . qq|">
1823 <input type="hidden" name="nextsub" value="edit">
1824 <input type="hidden" name="type" value="$form->{type}">
1825 <input type="hidden" name="warehouse" value="$warehouse">
1826 <input type="hidden" name="vc" value="$form->{vc}">
1827 <input type="hidden" name="login" value="$form->{login}">
1828 <input type="hidden" name="password" value="$form->{password}">
1829 <input type="hidden" name="callback" value="$callback">
1830 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1837 <form method=post action=$form->{script}>
1839 <input name=callback type=hidden value="$form->{callback}">
1841 <input type=hidden name=type value=$form->{type}>
1842 <input type=hidden name=vc value=$form->{vc}>
1844 <input type=hidden name=path value=$form->{path}>
1845 <input type=hidden name=login value=$form->{login}>
1846 <input type=hidden name=password value=$form->{password}>
1849 if ($form->{type} !~ /(ship|receive)_order/) {
1851 <input class=submit type=submit name=action value="|
1852 . $locale->text('Add') . qq|">|;
1855 if ($form->{menubar}) {
1856 require "$form->{path}/menu.pl";
1867 $lxdebug->leave_sub();
1871 $lxdebug->enter_sub();
1873 map { $column_data{$_} = "<td> </td>" } @column_index;
1875 $column_data{netamount} =
1876 "<th class=listsubtotal align=right>"
1877 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1879 $column_data{tax} = "<td class=listsubtotal align=right>"
1880 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1883 $column_data{amount} =
1884 "<th class=listsubtotal align=right>"
1885 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1887 $subtotalnetamount = 0;
1888 $subtotalamount = 0;
1891 <tr class=listsubtotal>
1894 map { print "\n$column_data{$_}" } @column_index;
1900 $lxdebug->leave_sub();
1903 sub save_and_close {
1904 $lxdebug->enter_sub();
1906 if ($form->{type} =~ /_order$/) {
1907 $form->isblank("transdate", $locale->text('Order Date missing!'));
1909 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1912 $msg = ucfirst $form->{vc};
1913 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1915 # $locale->text('Customer missing!');
1916 # $locale->text('Vendor missing!');
1918 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1919 if ($form->{currency} ne $form->{defaultcurrency});
1923 # if the name changed get new values
1924 if (&check_name($form->{vc})) {
1929 $form->{id} = 0 if $form->{saveasnew};
1931 # this is for the internal notes section for the [email] Subject
1932 if ($form->{type} =~ /_order$/) {
1933 if ($form->{type} eq 'sales_order') {
1934 $form->{label} = $locale->text('Sales Order');
1936 $numberfld = "sonumber";
1937 $ordnumber = "ordnumber";
1939 $form->{label} = $locale->text('Purchase Order');
1941 $numberfld = "ponumber";
1942 $ordnumber = "ordnumber";
1945 $err = $locale->text('Cannot save order!');
1948 if ($form->{type} eq 'sales_quotation') {
1949 $form->{label} = $locale->text('Quotation');
1951 $numberfld = "sqnumber";
1952 $ordnumber = "quonumber";
1954 $form->{label} = $locale->text('Request for Quotation');
1956 $numberfld = "rfqnumber";
1957 $ordnumber = "quonumber";
1960 $err = $locale->text('Cannot save quotation!');
1964 # get new number in sequence if no number is given or if saveasnew was requested
1965 if (!$form->{$ordumber} || $form->{saveasnew}) {
1966 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
1970 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1971 if (OE->save(\%myconfig, \%$form));
1974 $lxdebug->leave_sub();
1978 $lxdebug->enter_sub();
1980 if ($form->{type} =~ /_order$/) {
1981 $form->isblank("transdate", $locale->text('Order Date missing!'));
1983 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1986 $msg = ucfirst $form->{vc};
1987 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1989 # $locale->text('Customer missing!');
1990 # $locale->text('Vendor missing!');
1992 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1993 if ($form->{currency} ne $form->{defaultcurrency});
1997 # if the name changed get new values
1998 if (&check_name($form->{vc})) {
2003 $form->{id} = 0 if $form->{saveasnew};
2005 # this is for the internal notes section for the [email] Subject
2006 if ($form->{type} =~ /_order$/) {
2007 if ($form->{type} eq 'sales_order') {
2008 $form->{label} = $locale->text('Sales Order');
2010 $numberfld = "sonumber";
2011 $ordnumber = "ordnumber";
2013 $form->{label} = $locale->text('Purchase Order');
2015 $numberfld = "ponumber";
2016 $ordnumber = "ordnumber";
2019 $err = $locale->text('Cannot save order!');
2022 if ($form->{type} eq 'sales_quotation') {
2023 $form->{label} = $locale->text('Quotation');
2025 $numberfld = "sqnumber";
2026 $ordnumber = "quonumber";
2028 $form->{label} = $locale->text('Request for Quotation');
2030 $numberfld = "rfqnumber";
2031 $ordnumber = "quonumber";
2034 $err = $locale->text('Cannot save quotation!');
2038 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
2039 unless $form->{$ordnumber};
2042 OE->save(\%myconfig, \%$form);
2043 $form->{simple_save} = 1;
2044 if(!$form->{print_and_save}) {
2045 set_headings("edit");
2049 $lxdebug->leave_sub();
2053 $lxdebug->enter_sub();
2057 if ($form->{type} =~ /_order$/) {
2058 $msg = $locale->text('Are you sure you want to delete Order Number');
2059 $ordnumber = 'ordnumber';
2061 $msg = $locale->text('Are you sure you want to delete Quotation Number');
2062 $ordnumber = 'quonumber';
2068 <form method=post action=$form->{script}>
2071 # delete action variable
2072 map { delete $form->{$_} } qw(action header);
2074 foreach $key (keys %$form) {
2075 $form->{$key} =~ s/\"/"/g;
2076 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2080 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
2082 <h4>$msg $form->{$ordnumber}</h4>
2084 <input name=action class=submit type=submit value="|
2085 . $locale->text('Yes') . qq|">
2092 $lxdebug->leave_sub();
2096 $lxdebug->enter_sub();
2098 if ($form->{type} =~ /_order$/) {
2099 $msg = $locale->text('Order deleted!');
2100 $err = $locale->text('Cannot delete order!');
2102 $msg = $locale->text('Quotation deleted!');
2103 $err = $locale->text('Cannot delete quotation!');
2106 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
2109 $lxdebug->leave_sub();
2113 $lxdebug->enter_sub();
2115 if ($form->{type} =~ /_order$/) {
2117 # these checks only apply if the items don't bring their own ordnumbers/transdates.
2118 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
2119 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
2120 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2122 $form->isblank("transdate", $locale->text('Order Date missing!'))
2123 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2126 # also copy deliverydate from the order
2127 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
2129 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
2130 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2131 $form->{ordnumber} = "";
2134 # if the name changed get new values
2135 if (&check_name($form->{vc})) {
2140 $form->{cp_id} *= 1;
2142 if ( $form->{type} =~ /_order/
2143 && $form->{currency} ne $form->{defaultcurrency}) {
2145 # check if we need a new exchangerate
2146 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
2148 $orddate = $form->current_date(\%myconfig);
2150 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
2153 if (!$exchangerate) {
2154 &backorder_exchangerate($orddate, $buysell);
2159 # close orders/quotations
2160 $form->{closed} = 1;
2162 # save order if one ordnumber has been given
2163 # if not it's most likely a collective order, which can't be saved back
2164 # so they just have to be closed
2165 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
2166 OE->save(\%myconfig, \%$form);
2168 OE->close_orders(\%myconfig, \%$form);
2171 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
2173 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2176 $form->{closed} = 0;
2177 $form->{rowcount}--;
2178 $form->{shipto} = 1;
2180 if ($form->{type} =~ /_order$/) {
2181 $form->{exchangerate} = $exchangerate;
2185 if ( $form->{type} eq 'purchase_order'
2186 || $form->{type} eq 'request_quotation') {
2187 $form->{title} = $locale->text('Add Vendor Invoice');
2188 $form->{script} = 'ir.pl';
2192 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
2193 $form->{title} = $locale->text('Add Sales Invoice');
2194 $form->{script} = 'is.pl';
2199 # bo creates the id, reset it
2200 map { delete $form->{$_} }
2201 qw(id subject message cc bcc printed emailed queued);
2202 $form->{ $form->{vc} } =~ s/--.*//g;
2203 $form->{type} = "invoice";
2206 $locale = new Locale "$myconfig{countrycode}", "$script";
2208 require "$form->{path}/$form->{script}";
2210 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
2212 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2213 qw(creditlimit creditremaining);
2215 $currency = $form->{currency};
2218 $form->{currency} = $currency;
2219 $form->{exchangerate} = "";
2220 $form->{forex} = "";
2221 $form->{exchangerate} = $exchangerate
2225 $form->check_exchangerate(
2226 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
2229 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
2234 for $i (1 .. $form->{rowcount}) {
2235 $form->{"discount_$i"} =
2236 $form->format_amount(\%myconfig, $form->{"discount_$i"});
2238 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
2240 $decimalplaces = ($dec > 2) ? $dec : 2;
2242 # copy delivery date from reqdate for order -> invoice conversion
2243 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
2244 unless $form->{"deliverydate_$i"};
2246 $form->{"sellprice_$i"} =
2247 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
2250 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
2251 $dec_qty = length $dec_qty;
2253 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
2255 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2256 qw(partnumber description unit);
2262 $lxdebug->leave_sub();
2265 sub backorder_exchangerate {
2266 $lxdebug->enter_sub();
2267 my ($orddate, $buysell) = @_;
2274 <form method=post action=$form->{script}>
2277 # delete action variable
2278 map { delete $form->{$_} } qw(action header exchangerate);
2280 foreach $key (keys %$form) {
2281 $form->{$key} =~ s/\"/"/g;
2282 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2285 $form->{title} = $locale->text('Add Exchangerate');
2289 <input type=hidden name=path value=$form->{path}>
2290 <input type=hidden name=login value=$form->{login}>
2291 <input type=hidden name=password value=$form->{password}>
2293 <input type=hidden name=exchangeratedate value=$orddate>
2294 <input type=hidden name=buysell value=$buysell>
2297 <tr><th class=listtop>$form->{title}</th></tr>
2298 <tr height="5"></tr>
2303 <th align=right>| . $locale->text('Currency') . qq|</th>
2304 <td>$form->{currency}</td>
2307 <th align=right>| . $locale->text('Date') . qq|</th>
2311 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2312 <td><input name=exchangerate size=11></td>
2322 <input type=hidden name=nextsub value=save_exchangerate>
2324 <input name=action class=submit type=submit value="|
2325 . $locale->text('Continue') . qq|">
2333 $lxdebug->leave_sub();
2336 sub save_exchangerate {
2337 $lxdebug->enter_sub();
2339 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2340 $form->{exchangerate} =
2341 $form->parse_amount(\%myconfig, $form->{exchangerate});
2342 $form->save_exchangerate(\%myconfig, $form->{currency},
2343 $form->{exchangeratedate},
2344 $form->{exchangerate}, $form->{buysell});
2348 $lxdebug->leave_sub();
2351 sub create_backorder {
2352 $lxdebug->enter_sub();
2354 $form->{shipped} = 1;
2356 # figure out if we need to create a backorder
2357 # items aren't saved if qty != 0
2359 for $i (1 .. $form->{rowcount}) {
2360 $totalqty += $qty = $form->{"qty_$i"};
2361 $totalship += $ship = $form->{"ship_$i"};
2363 $form->{"qty_$i"} = $qty - $ship;
2366 if ($totalship == 0) {
2367 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2368 $form->{ordtotal} = 0;
2369 $form->{shipped} = 0;
2373 if ($totalqty == $totalship) {
2374 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2375 $form->{ordtotal} = 0;
2380 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2383 for $i (1 .. $form->{rowcount}) {
2385 $form->{"${_}_$i"} =
2386 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2387 } qw(sellprice discount);
2390 OE->save(\%myconfig, \%$form);
2392 # rebuild rows for invoice
2396 for $i (1 .. $form->{rowcount}) {
2397 $form->{"qty_$i"} = $form->{"ship_$i"};
2399 if ($form->{"qty_$i"}) {
2402 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2407 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2408 $form->{rowcount} = $count;
2410 $lxdebug->leave_sub();
2414 $lxdebug->enter_sub();
2416 $form->{saveasnew} = 1;
2417 $form->{closed} = 0;
2418 map { delete $form->{$_} } qw(printed emailed queued ordnumber quonumber);
2422 $lxdebug->leave_sub();
2425 sub purchase_order {
2426 $lxdebug->enter_sub();
2428 if ( $form->{type} eq 'sales_quotation'
2429 || $form->{type} eq 'request_quotation') {
2430 $form->{closed} = 1;
2431 OE->save(\%myconfig, \%$form);
2434 $form->{cp_id} *= 1;
2436 $form->{title} = $locale->text('Add Purchase Order');
2437 $form->{vc} = "vendor";
2438 $form->{type} = "purchase_order";
2442 $lxdebug->leave_sub();
2446 $lxdebug->enter_sub();
2448 if ( $form->{type} eq 'sales_quotation'
2449 || $form->{type} eq 'request_quotation') {
2450 $form->{closed} = 1;
2451 OE->save(\%myconfig, \%$form);
2454 $form->{cp_id} *= 1;
2456 $form->{title} = $locale->text('Add Sales Order');
2457 $form->{vc} = "customer";
2458 $form->{type} = "sales_order";
2462 $lxdebug->leave_sub();
2466 $lxdebug->enter_sub();
2468 $form->{transdate} = $form->current_date(\%myconfig);
2469 delete $form->{duedate};
2471 $form->{closed} = 0;
2474 map { delete $form->{$_} }
2475 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2482 for $i (1 .. $form->{rowcount} - 1) {
2483 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2484 qw(partnumber description unit);
2487 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2488 qw(creditlimit creditremaining);
2492 $lxdebug->leave_sub();
2496 $lxdebug->enter_sub();
2502 OE->get_warehouses(\%myconfig, \%$form);
2505 if (@{ $form->{all_warehouses} }) {
2506 $form->{selectwarehouse} = "<option>\n";
2508 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2509 (@{ $form->{all_warehouses} });
2511 if ($form->{warehouse}) {
2512 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2516 $form->{shippingdate} = $form->current_date(\%myconfig);
2517 $form->{"$form->{vc}"} =~ s/--.*//;
2522 foreach $key (keys %$form) {
2523 if ($key =~ /_1$/) {
2529 for $i (1 .. $form->{rowcount}) {
2531 # undo formatting from prepare_order
2533 $form->{"${_}_$i"} =
2534 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2536 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2538 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2539 $form->{"ship_$i"} = "";
2540 $form->{"serialnumber_$i"} = "";
2545 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2550 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2551 $form->{rowcount} = $count;
2553 &display_ship_receive;
2555 $lxdebug->leave_sub();
2558 sub display_ship_receive {
2559 $lxdebug->enter_sub();
2561 $vclabel = ucfirst $form->{vc};
2562 $vclabel = $locale->text($vclabel);
2564 $form->{rowcount}++;
2566 if ($form->{vc} eq 'customer') {
2567 $form->{title} = $locale->text('Ship Merchandise');
2568 $shipped = $locale->text('Shipping Date');
2570 $form->{title} = $locale->text('Receive Merchandise');
2571 $shipped = $locale->text('Date Received');
2574 # set option selected
2575 foreach $item (warehouse, employee) {
2576 $form->{"select$item"} =~ s/ selected//;
2577 $form->{"select$item"} =~
2578 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2583 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2584 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2585 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2587 | if $form->{selectwarehouse};
2591 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2592 <td><select name=employee>$form->{selectemployee}</select></td>
2593 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2602 <form method=post action=$form->{script}>
2604 <input type=hidden name=id value=$form->{id}>
2606 <input type=hidden name=display_form value=display_ship_receive>
2608 <input type=hidden name=type value=$form->{type}>
2609 <input type=hidden name=media value=$form->{media}>
2610 <input type=hidden name=format value=$form->{format}>
2612 <input type=hidden name=queued value="$form->{queued}">
2613 <input type=hidden name=printed value="$form->{printed}">
2614 <input type=hidden name=emailed value="$form->{emailed}">
2616 <input type=hidden name=vc value=$form->{vc}>
2620 <th class=listtop>$form->{title}</th>
2622 <tr height="5"></tr>
2625 <table width="100%">
2630 <th align=right>$vclabel</th>
2631 <td colspan=3>$form->{$form->{vc}}</td>
2632 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2633 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2637 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2639 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2642 <th align=right>| . $locale->text('Ship via') . qq|</th>
2644 <input name=shipvia size=35 value="$form->{shipvia}">
2653 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2654 <td>$form->{ordnumber}</td>
2655 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2658 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2659 <td>$form->{transdate}</td>
2660 <input type=hidden name=transdate value=$form->{transdate}>
2663 <th align=right nowrap>$shipped</th>
2664 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2673 <!-- shipto are in hidden variables -->
2675 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2676 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2677 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2678 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2679 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2680 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2681 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2682 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2683 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2685 <!-- email variables -->
2686 <input type=hidden name=message value="$form->{message}">
2687 <input type=hidden name=email value="$form->{email}">
2688 <input type=hidden name=subject value="$form->{subject}">
2689 <input type=hidden name=cc value="$form->{cc}">
2690 <input type=hidden name=bcc value="$form->{bcc}">
2695 (partnumber, description, qty, ship, unit, bin, serialnumber);
2697 if ($form->{type} eq "ship_order") {
2698 $column_data{ship} =
2699 qq|<th class=listheading align=center width="auto">|
2700 . $locale->text('Ship')
2703 if ($form->{type} eq "receive_order") {
2704 $column_data{ship} =
2705 qq|<th class=listheading align=center width="auto">|
2706 . $locale->text('Recd')
2710 my $colspan = $#column_index + 1;
2712 $column_data{partnumber} =
2713 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2714 $column_data{description} =
2715 qq|<th class=listheading nowrap>|
2716 . $locale->text('Description')
2719 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2720 $column_data{unit} =
2721 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2723 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2724 $column_data{serialnumber} =
2725 qq|<th class=listheading nowrap>|
2726 . $locale->text('Serial No.')
2733 <tr class=listheading>|;
2735 map { print "\n$column_data{$_}" } @column_index;
2741 for $i (1 .. $form->{rowcount} - 1) {
2744 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2746 # convert " to "
2747 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2748 qw(partnumber description unit bin serialnumber);
2750 $description = $form->{"description_$i"};
2751 $description =~ s/\n/<br>/g;
2753 $column_data{partnumber} =
2754 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2755 $column_data{description} =
2756 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2758 qq|<td align=right>|
2759 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2760 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2761 $column_data{ship} =
2762 qq|<td align=right><input name="ship_$i" size=5 value=|
2763 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2765 $column_data{unit} =
2766 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2768 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2770 $column_data{serialnumber} =
2771 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2776 map { print "\n$column_data{$_}" } @column_index;
2781 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2782 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2783 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2784 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2795 <td><hr size=3 noshade></td>
2801 $form->{copies} = 1;
2810 <input class=submit type=submit name=action value="|
2811 . $locale->text('Update') . qq|">
2812 <input class=submit type=submit name=action value="|
2813 . $locale->text('Print') . qq|">
2816 if ($form->{type} eq 'ship_order') {
2818 <input class=submit type=submit name=action value="|
2819 . $locale->text('Ship to') . qq|">
2820 <input class=submit type=submit name=action value="|
2821 . $locale->text('E-mail') . qq|">
2827 <input class=submit type=submit name=action value="|
2828 . $locale->text('Done') . qq|">
2831 if ($form->{menubar}) {
2832 require "$form->{path}/menu.pl";
2838 <input type=hidden name=rowcount value=$form->{rowcount}>
2840 <input name=callback type=hidden value="$callback">
2842 <input type=hidden name=path value=$form->{path}>
2843 <input type=hidden name=login value=$form->{login}>
2844 <input type=hidden name=password value=$form->{password}>
2852 $lxdebug->leave_sub();
2856 $lxdebug->enter_sub();
2858 if ($form->{type} eq 'ship_order') {
2859 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2861 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2866 $total += $form->{"ship_$_"} =
2867 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2868 } (1 .. $form->{rowcount} - 1);
2870 $form->error($locale->text('Nothing entered!')) unless $total;
2872 $form->redirect($locale->text('Inventory saved!'))
2873 if OE->save_inventory(\%myconfig, \%$form);
2874 $form->error($locale->text('Could not save!'));
2876 $lxdebug->leave_sub();
2879 sub search_transfer {
2880 $lxdebug->enter_sub();
2882 OE->get_warehouses(\%myconfig, \%$form);
2885 if (@{ $form->{all_warehouses} }) {
2886 $form->{selectwarehouse} = "<option>\n";
2887 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2889 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2890 (@{ $form->{all_warehouses} });
2892 $form->error($locale->text('Nothing to transfer!'));
2895 $form->{title} = $locale->text('Transfer Inventory');
2902 <form method=post action=$form->{script}>
2906 <th class=listtop>$form->{title}</th>
2908 <tr height="5"></tr>
2913 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2914 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2917 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2918 <td><input name=partnumber size=20></td>
2921 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2922 <td><input name=description size=40></td>
2925 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2926 <td><input name=partsgroup size=20></td>
2932 <td><hr size=3 noshade></td>
2937 <input type=hidden name=sort value=partnumber>
2938 <input type=hidden name=nextsub value=list_transfer>
2940 <input type=hidden name=path value=$form->{path}>
2941 <input type=hidden name=login value=$form->{login}>
2942 <input type=hidden name=password value=$form->{password}>
2944 <input class=submit type=submit name=action value="|
2945 . $locale->text('Continue') . qq|">
2952 $lxdebug->leave_sub();
2956 $lxdebug->enter_sub();
2958 OE->get_inventory(\%myconfig, \%$form);
2960 $partnumber = $form->escape($form->{partnumber});
2961 $warehouse = $form->escape($form->{warehouse});
2962 $description = $form->escape($form->{description});
2963 $partsgroup = $form->escape($form->{partsgroup});
2967 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2969 # construct callback
2970 $partnumber = $form->escape($form->{partnumber}, 1);
2971 $warehouse = $form->escape($form->{warehouse}, 1);
2972 $description = $form->escape($form->{description}, 1);
2973 $partsgroup = $form->escape($form->{partsgroup}, 1);
2976 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2979 $form->sort_columns(
2980 qw(partnumber description partsgroup make model warehouse qty transfer));
2982 $column_header{partnumber} =
2983 qq|<th><a class=listheading href=$href&sort=partnumber>|
2984 . $locale->text('Part Number')
2986 $column_header{description} =
2987 qq|<th><a class=listheading href=$href&sort=description>|
2988 . $locale->text('Description')
2990 $column_header{partsgroup} =
2991 qq|<th><a class=listheading href=$href&sort=partsgroup>|
2992 . $locale->text('Group')
2994 $column_header{warehouse} =
2995 qq|<th><a class=listheading href=$href&sort=warehouse>|
2996 . $locale->text('From')
2998 $column_header{qty} =
2999 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
3000 $column_header{transfer} =
3001 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
3003 $option = $locale->text('Transfer to');
3005 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
3007 if ($form->{warehouse}) {
3008 $option .= " : $warehouse";
3010 if ($form->{partnumber}) {
3011 $option .= "\n<br>" if ($option);
3012 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
3014 if ($form->{description}) {
3015 $option .= "\n<br>" if ($option);
3016 $option .= $locale->text('Description') . " : $form->{description}";
3018 if ($form->{partsgroup}) {
3019 $option .= "\n<br>" if ($option);
3020 $option .= $locale->text('Group') . " : $form->{partsgroup}";
3023 $form->{title} = $locale->text('Transfer Inventory');
3030 <form method=post action=$form->{script}>
3032 <input type=hidden name=warehouse_id value=$warehouse_id>
3036 <th class=listtop>$form->{title}</th>
3038 <tr height="5"></tr>
3045 <tr class=listheading>|;
3047 map { print "\n$column_header{$_}" } @column_index;
3053 if (@{ $form->{all_inventory} }) {
3054 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
3058 foreach $ref (@{ $form->{all_inventory} }) {
3062 $column_data{partnumber} =
3063 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
3064 $column_data{description} = "<td>$ref->{description} </td>";
3065 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
3066 $column_data{warehouse} =
3067 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
3069 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
3070 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
3072 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
3077 <tr class=listrow$j>";
3079 map { print "\n$column_data{$_}" } @column_index;
3093 <td><hr size=3 noshade></td>
3099 <input name=callback type=hidden value="$callback">
3101 <input type=hidden name=rowcount value=$i>
3103 <input type=hidden name=path value=$form->{path}>
3104 <input type=hidden name=login value=$form->{login}>
3105 <input type=hidden name=password value=$form->{password}>
3107 <input class=submit type=submit name=action value="|
3108 . $locale->text('Transfer') . qq|">|;
3110 if ($form->{menubar}) {
3111 require "$form->{path}/menu.pl";
3122 $lxdebug->leave_sub();
3126 $lxdebug->enter_sub();
3128 $form->redirect($locale->text('Inventory transferred!'))
3129 if OE->transfer(\%myconfig, \%$form);
3130 $form->error($locale->text('Could not transfer Inventory!'));
3132 $lxdebug->leave_sub();