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 $form->{simple_save} = 0;
116 set_headings("edit");
118 # editing without stuff to edit? try adding it first
119 if ($form->{rowcount}) {
120 map { $id++ if $form->{"id_$_"} } (1 .. $form->{rowcount});
124 undef $form->{rowcount};
135 if ($form->{print_and_save}) {
136 $form->{action} = "print";
137 $form->{resubmit} = 1;
138 $language_id = $form->{language_id};
139 $printer_id = $form->{printer_id};
142 set_headings("edit");
146 if ($form->{print_and_save}) {
147 $form->{language_id} = $language_id;
148 $form->{printer_id} = $printer_id;
152 $lxdebug->leave_sub();
156 $lxdebug->enter_sub();
158 # get customer/vendor
159 $form->all_vc(\%myconfig, $form->{vc},
160 ($form->{vc} eq 'customer') ? "AR" : "AP");
162 # retrieve order/quotation
163 $form->{webdav} = $webdav;
165 $form->{jscalendar} = $jscalendar;
167 OE->retrieve(\%myconfig, \%$form);
169 if ($form->{payment_id}) {
170 $payment_id = $form->{payment_id};
172 if ($form->{language_id}) {
173 $language_id = $form->{language_id};
175 if ($form->{taxzone_id}) {
176 $taxzone_id = $form->{taxzone_id};
180 # if multiple rowcounts (== collective order) then check if the
181 # there were more than one customer (in that case OE::retrieve removes
182 # the content from the field)
183 if ( $form->{rowcount}
184 && $form->{type} eq 'sales_order'
185 && defined $form->{customer}
186 && $form->{customer} eq '') {
188 # $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
191 'Collective Orders only work for orders from one customer!')
195 $taxincluded = $form->{taxincluded};
196 $form->{shipto} = 1 if $form->{id};
198 if ($form->{"all_$form->{vc}"}) {
199 unless ($form->{"$form->{vc}_id"}) {
200 $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
204 $cp_id = $form->{cp_id};
205 $intnotes = $form->{intnotes};
207 # get customer / vendor
208 if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/) {
209 IR->get_vendor(\%myconfig, \%$form);
211 #quote all_vendor Bug 133
212 foreach $ref (@{ $form->{all_vendor} }) {
213 $ref->{name} = $form->quote($ref->{name});
217 if ($form->{type} =~ /(sales|ship)_(order|quotation)/) {
218 IS->get_customer(\%myconfig, \%$form);
220 #quote all_vendor Bug 133
221 foreach $ref (@{ $form->{all_customer} }) {
222 $ref->{name} = $form->quote($ref->{name});
226 $form->{cp_id} = $cp_id;
228 $form->{payment_id} = $payment_id;
231 $form->{language_id} = $language_id;
234 $form->{taxzone_id} = $taxzone_id;
236 $form->{intnotes} = $intnotes;
237 ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
238 $form->{"old$form->{vc}"} =
239 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
241 # build the popup menus
242 if (@{ $form->{"all_$form->{vc}"} }) {
243 $form->{ $form->{vc} } =
244 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
245 map { $form->{"select$form->{vc}"} .= "<option>$_->{name}--$_->{id}\n" }
246 (@{ $form->{"all_$form->{vc}"} });
250 @curr = split(/:/, $form->{currencies});
252 $form->{defaultcurrency} = $curr[0];
253 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
255 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
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}\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}\n" }
276 (@{ $form->{all_employees} });
280 $form->{forex} = $form->{exchangerate};
282 $lxdebug->leave_sub();
286 $lxdebug->enter_sub();
287 $form->{format} = "pdf" unless ($form->{print_and_save} && $form->{format});
288 $form->{media} = "screen";
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 $checkedopen = ($form->{closed}) ? "" : "checked";
333 $checkedclosed = ($form->{closed}) ? "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}></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}></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}></td>|;
377 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
383 <td colspan=2 align=center>
386 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
387 . $locale->text('Open') . qq|</th>
388 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
389 . $locale->text('Closed') . qq|</th>
397 # set option selected
398 foreach $item ($form->{vc}, currency, department, employee) {
399 $form->{"select$item"} =~ s/ selected//;
400 $form->{"select$item"} =~
401 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
404 #quote select[customer|vendor] Bug 133
405 $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
408 if ($form->{all_contacts}) {
410 $form->{selectcontact} = "<option></option>";
411 foreach $item (@{ $form->{all_contacts} }) {
412 my $department = ($item->{cp_abteilung}) ? "--$item->{cp_abteilung}" : "";
413 if ($form->{cp_id} == $item->{cp_id}) {
414 $form->{selectcontact} .=
415 "<option value=$item->{cp_id} selected>$item->{cp_name}$department</option>";
417 $form->{selectcontact} .= "<option value=$item->{cp_id}>$item->{cp_name}$department</option>";
421 $form->{selectcontact} =~ s/ selected//g;
422 if ($form->{cp_id} ne "") {
423 $form->{selectcontact} =~ s/value=$form->{cp_id}/value=$form->{cp_id} selected/;
428 if (@{ $form->{SHIPTO} }) {
429 $form->{selectshipto} = "<option value=0></option>";
430 foreach $item (@{ $form->{SHIPTO} }) {
431 if ($item->{shipto_id} == $form->{shipto_id}) {
432 $form->{selectshipto} .=
433 "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}</option>";
435 $form->{selectshipto} .=
436 "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment_1}</option>";
441 $form->{selectshipto} =~ s/ selected//g;
442 if ($form->{shipto_id} ne "") {
443 $form->{selectshipto} =~ s/value=$form->{shipto_id}/value=$form->{shipto_id} selected/;
448 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
449 <td><select name=shipto_id>$form->{selectshipto}</select></td>
450 <input type=hidden name=selectshipto value="$form->{selectshipto}">|;
455 $form->{exchangerate} =
456 $form->format_amount(\%myconfig, $form->{exchangerate});
458 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
464 $form->{creditlimit} =
465 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
466 $form->{creditremaining} =
467 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
470 ($form->{selectcontact})
471 ? qq|<select name=cp_id>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
472 : qq|<input name=contact value="$form->{contact}" size=35>|;
475 <input type=hidden name=forex value=$form->{forex}>
478 if ($form->{currency} ne $form->{defaultcurrency}) {
479 if ($form->{forex}) {
482 . $locale->text('Exchangerate')
483 . qq|</th><td>$form->{exchangerate}</td>
484 <input type=hidden name=exchangerate value=$form->{exchangerate}>
489 . $locale->text('Exchangerate')
490 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
494 $vclabel = ucfirst $form->{vc};
495 $vclabel = $locale->text($vclabel);
499 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
500 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
501 . $locale->text('days') . qq|</td>
505 if ($form->{business}) {
508 <th align=right>| . $locale->text('Business') . qq|</th>
509 <td>$form->{business}</td>
510 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
512 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
518 if ($form->{max_dunning_level}) {
524 <th align=right>| . $locale->text('Max. Dunning Level') . qq|:</th>
525 <td><b>$form->{max_dunning_level}</b></td>
526 <th align=right>| . $locale->text('Dunning Amount') . qq|:</th>
528 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
537 if (@{ $form->{TAXZONE} }) {
538 $form->{selecttaxzone} = "";
539 foreach $item (@{ $form->{TAXZONE} }) {
540 if ($item->{id} == $form->{taxzone_id}) {
541 $form->{selecttaxzone} .=
542 "<option value=$item->{id} selected>" . H($item->{description}) .
545 $form->{selecttaxzone} .=
546 "<option value=$item->{id}>" . H($item->{description}) . "</option>";
551 $form->{selecttaxzone} =~ s/ selected//g;
552 if ($form->{taxzone_id} ne "") {
553 $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}>/value=$form->{taxzone_id} selected>/;
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=shiptodepartment_1 value="$form->{shiptodepartment_1}">
832 <input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
833 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
835 <!-- email variables -->
836 <input type=hidden name=message value="$form->{message}">
837 <input type=hidden name=email value="$form->{email}">
838 <input type=hidden name=subject value="$form->{subject}">
839 <input type=hidden name=cc value="$form->{cc}">
840 <input type=hidden name=bcc value="$form->{bcc}">
842 <input type=hidden name=taxpart value="$form->{taxpart}">
843 <input type=hidden name=taxservice value="$form->{taxservice}">
845 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
848 foreach $item (split / /, $form->{taxaccounts}) {
850 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
851 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
854 $lxdebug->leave_sub();
858 $lxdebug->enter_sub();
860 $form->{invtotal} = $form->{invsubtotal};
862 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
865 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
868 $rows = ($rows > $introws) ? $rows : $introws;
870 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
872 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
874 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
877 if ($form->{taxaccounts}) {
879 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
880 . $locale->text('Tax Included') . qq|</b><br><br>
884 if (!$form->{taxincluded}) {
886 foreach $item (split / /, $form->{taxaccounts}) {
887 if ($form->{"${item}_base"}) {
888 $form->{invtotal} += $form->{"${item}_total"} =
890 $form->{"${item}_base"} * $form->{"${item}_rate"},
892 $form->{"${item}_total"} =
893 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
897 <th align=right>$form->{"${item}_description"}</th>
898 <td align=right>$form->{"${item}_total"}</td>
904 $form->{invsubtotal} =
905 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
909 <th align=right>| . $locale->text('Subtotal') . qq|</th>
910 <td align=right>$form->{invsubtotal}</td>
916 if ($form->{taxincluded}) {
917 foreach $item (split / /, $form->{taxaccounts}) {
918 if ($form->{"${item}_base"}) {
919 $form->{"${item}_total"} =
921 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
922 (1 + $form->{"${item}_rate"})
925 $form->{"${item}_netto"} =
927 ($form->{"${item}_base"} - $form->{"${item}_total"}),
929 $form->{"${item}_total"} =
930 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
931 $form->{"${item}_netto"} =
932 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
936 <th align=right>Enthaltene $form->{"${item}_description"}</th>
937 <td align=right>$form->{"${item}_total"}</td>
940 <th align=right>Nettobetrag</th>
941 <td align=right>$form->{"${item}_netto"}</td>
949 $form->{oldinvtotal} = $form->{invtotal};
951 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
961 <th align=left>| . $locale->text('Notes') . qq|</th>
962 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
968 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
969 <td><select name=payment_id tabindex=24>$payment
973 <td align=right width=100%>
979 <th align=right>| . $locale->text('Total') . qq|</th>
980 <td align=right>$form->{invtotal}</td>
988 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
989 <input type=hidden name=oldtotalpaid value=$totalpaid>
991 <td><hr size=3 noshade></td>
999 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
1002 <td align=left width=30%><b>Dateiname</b></td>
1003 <td align=left width=70%><b>Webdavlink</b></td>
1005 foreach $file (keys %{ $form->{WEBDAV} }) {
1008 <td align=left>$file</td>
1009 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
1017 <td><hr size=3 noshade></td>
1024 <input type=hidden name=jscalendar value=$form->{jscalendar}>
1037 | . $locale->text("Edit the $form->{type}") . qq|<br>
1038 <input class=submit type=submit name=action value="|
1039 . $locale->text('Update') . qq|">
1040 <input class=submit type=submit name=action value="|
1041 . $locale->text('Ship to') . qq|">
1042 <input class=submit type=submit name=action value="|
1043 . $locale->text('Print') . qq|">
1044 <input class=submit type=submit name=action value="|
1045 . $locale->text('E-mail') . qq|">
1046 <input class=submit type=submit name=action value="|
1047 . $locale->text('Save') . qq|">
1048 <input class=submit type=submit name=action value="|
1049 . $locale->text('Save and Close') . qq|">
1052 if (($form->{id})) {
1054 <br>| . $locale->text("Workflow $form->{type}") . qq|<br>
1055 <input class=submit type=submit name=action value="|
1056 . $locale->text('Save as new') . qq|">
1057 <input class=submit type=submit name=action value="|
1058 . $locale->text('Delete') . qq|">|;
1059 if (($form->{type} =~ /sales_quotation$/)) {
1061 <input class=submit type=submit name=action value="|
1062 . $locale->text('Sales Order') . qq|">|;
1064 if ($form->{type} =~ /request_quotation$/) {
1066 <input class=submit type=submit name=action value="|
1067 . $locale->text('Purchase Order') . qq|">|;
1071 <input class=submit type=submit name=action value="|
1072 . $locale->text('Invoice') . qq|">
1076 if ($form->{type} =~ /sales_order$/) {
1078 <br>$form->{heading} als neue Vorlage verwenden für<br>
1079 <input class=submit type=submit name=action value="|
1080 . $locale->text('Purchase Order') . qq|">
1081 <input class=submit type=submit name=action value="|
1082 . $locale->text('Quotation') . qq|">
1085 } elsif ($form->{type} =~ /purchase_order$/) {
1087 <br>$form->{heading} als neue Vorlage verwenden für<br>
1088 <input class=submit type=submit name=action value="|
1089 . $locale->text('Sales Order') . qq|">
1090 <input class=submit type=submit name=action value="|
1091 . $locale->text('Request for Quotation') . qq|">
1096 <br>$form->{heading} als neue Vorlage verwenden für<br>
1097 <input class=submit type=submit name=action value="|
1098 . $locale->text('Order') . qq|">
1101 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount} && !$form->{proforma}) {
1103 <br>Workflow $form->{heading}<br>
1104 <input class=submit type=submit name=action value="|
1105 . $locale->text('Save as new') . qq|">
1106 <input class=submit type=submit name=action value="|
1107 . $locale->text('Invoice') . qq|">
1111 if ($form->{menubar}) {
1112 require "$form->{path}/menu.pl";
1118 <input type=hidden name=rowcount value=$form->{rowcount}>
1120 <input name=callback type=hidden value="$form->{callback}">
1122 <input type=hidden name=path value=$form->{path}>
1123 <input type=hidden name=login value=$form->{login}>
1124 <input type=hidden name=password value=$form->{password}>
1131 $lxdebug->leave_sub();
1135 $lxdebug->enter_sub();
1137 set_headings($form->{"id"} ? "edit" : "add");
1139 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1140 qw(exchangerate creditlimit creditremaining);
1141 $form->{update} = 1;
1143 &check_name($form->{vc});
1148 $buysell = 'sell' if ($form->{vc} eq 'vendor');
1149 $form->{exchangerate} = $exchangerate
1153 $form->check_exchangerate(
1154 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1158 $i = $form->{rowcount};
1160 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1162 if ( ($form->{"partnumber_$i"} eq "")
1163 && ($form->{"description_$i"} eq "")
1164 && ($form->{"partsgroup_$i"} eq "")) {
1166 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
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->{$ordnumber} || $form->{saveasnew}) {
1966 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
1972 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1973 if (OE->save(\%myconfig, \%$form));
1976 $lxdebug->leave_sub();
1980 $lxdebug->enter_sub();
1982 if ($form->{type} =~ /_order$/) {
1983 $form->isblank("transdate", $locale->text('Order Date missing!'));
1985 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1988 $msg = ucfirst $form->{vc};
1989 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1991 # $locale->text('Customer missing!');
1992 # $locale->text('Vendor missing!');
1994 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1995 if ($form->{currency} ne $form->{defaultcurrency});
1999 # if the name changed get new values
2000 if (&check_name($form->{vc})) {
2005 $form->{id} = 0 if $form->{saveasnew};
2007 # this is for the internal notes section for the [email] Subject
2008 if ($form->{type} =~ /_order$/) {
2009 if ($form->{type} eq 'sales_order') {
2010 $form->{label} = $locale->text('Sales Order');
2012 $numberfld = "sonumber";
2013 $ordnumber = "ordnumber";
2015 $form->{label} = $locale->text('Purchase Order');
2017 $numberfld = "ponumber";
2018 $ordnumber = "ordnumber";
2021 $err = $locale->text('Cannot save order!');
2024 if ($form->{type} eq 'sales_quotation') {
2025 $form->{label} = $locale->text('Quotation');
2027 $numberfld = "sqnumber";
2028 $ordnumber = "quonumber";
2030 $form->{label} = $locale->text('Request for Quotation');
2032 $numberfld = "rfqnumber";
2033 $ordnumber = "quonumber";
2036 $err = $locale->text('Cannot save quotation!');
2040 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
2041 unless $form->{$ordnumber};
2045 OE->save(\%myconfig, \%$form);
2046 $form->{simple_save} = 1;
2047 if(!$form->{print_and_save}) {
2048 set_headings("edit");
2052 $lxdebug->leave_sub();
2056 $lxdebug->enter_sub();
2060 if ($form->{type} =~ /_order$/) {
2061 $msg = $locale->text('Are you sure you want to delete Order Number');
2062 $ordnumber = 'ordnumber';
2064 $msg = $locale->text('Are you sure you want to delete Quotation Number');
2065 $ordnumber = 'quonumber';
2071 <form method=post action=$form->{script}>
2074 # delete action variable
2075 map { delete $form->{$_} } qw(action header);
2077 foreach $key (keys %$form) {
2078 $form->{$key} =~ s/\"/"/g;
2079 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2083 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
2085 <h4>$msg $form->{$ordnumber}</h4>
2087 <input name=action class=submit type=submit value="|
2088 . $locale->text('Yes') . qq|">
2095 $lxdebug->leave_sub();
2099 $lxdebug->enter_sub();
2101 if ($form->{type} =~ /_order$/) {
2102 $msg = $locale->text('Order deleted!');
2103 $err = $locale->text('Cannot delete order!');
2105 $msg = $locale->text('Quotation deleted!');
2106 $err = $locale->text('Cannot delete quotation!');
2109 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
2112 $lxdebug->leave_sub();
2116 $lxdebug->enter_sub();
2118 if ($form->{type} =~ /_order$/) {
2120 # these checks only apply if the items don't bring their own ordnumbers/transdates.
2121 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
2122 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
2123 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2125 $form->isblank("transdate", $locale->text('Order Date missing!'))
2126 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2129 # also copy deliverydate from the order
2130 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
2132 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
2133 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2134 $form->{ordnumber} = "";
2137 # if the name changed get new values
2138 if (&check_name($form->{vc})) {
2143 $form->{cp_id} *= 1;
2145 if ( $form->{type} =~ /_order/
2146 && $form->{currency} ne $form->{defaultcurrency}) {
2148 # check if we need a new exchangerate
2149 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
2151 $orddate = $form->current_date(\%myconfig);
2153 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
2156 if (!$exchangerate) {
2157 &backorder_exchangerate($orddate, $buysell);
2162 # close orders/quotations
2163 $form->{closed} = 1;
2165 # save order if one ordnumber has been given
2166 # if not it's most likely a collective order, which can't be saved back
2167 # so they just have to be closed
2168 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
2170 OE->save(\%myconfig, \%$form);
2172 OE->close_orders(\%myconfig, \%$form);
2175 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
2177 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2180 $form->{closed} = 0;
2181 $form->{rowcount}--;
2182 $form->{shipto} = 1;
2184 if ($form->{type} =~ /_order$/) {
2185 $form->{exchangerate} = $exchangerate;
2189 if ( $form->{type} eq 'purchase_order'
2190 || $form->{type} eq 'request_quotation') {
2191 $form->{title} = $locale->text('Add Vendor Invoice');
2192 $form->{script} = 'ir.pl';
2196 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
2197 $form->{title} = $locale->text('Add Sales Invoice');
2198 $form->{script} = 'is.pl';
2203 # bo creates the id, reset it
2204 map { delete $form->{$_} }
2205 qw(id subject message cc bcc printed emailed queued);
2206 $form->{ $form->{vc} } =~ s/--.*//g;
2207 $form->{type} = "invoice";
2210 $locale = new Locale "$myconfig{countrycode}", "$script";
2212 require "$form->{path}/$form->{script}";
2214 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
2216 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2217 qw(creditlimit creditremaining);
2219 $currency = $form->{currency};
2222 $form->{currency} = $currency;
2223 $form->{exchangerate} = "";
2224 $form->{forex} = "";
2225 $form->{exchangerate} = $exchangerate
2229 $form->check_exchangerate(
2230 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
2233 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
2238 for $i (1 .. $form->{rowcount}) {
2239 $form->{"discount_$i"} =
2240 $form->format_amount(\%myconfig, $form->{"discount_$i"});
2242 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
2244 $decimalplaces = ($dec > 2) ? $dec : 2;
2246 # copy delivery date from reqdate for order -> invoice conversion
2247 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
2248 unless $form->{"deliverydate_$i"};
2250 $form->{"sellprice_$i"} =
2251 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
2254 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
2255 $dec_qty = length $dec_qty;
2257 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
2259 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2260 qw(partnumber description unit);
2266 $lxdebug->leave_sub();
2269 sub backorder_exchangerate {
2270 $lxdebug->enter_sub();
2271 my ($orddate, $buysell) = @_;
2278 <form method=post action=$form->{script}>
2281 # delete action variable
2282 map { delete $form->{$_} } qw(action header exchangerate);
2284 foreach $key (keys %$form) {
2285 $form->{$key} =~ s/\"/"/g;
2286 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2289 $form->{title} = $locale->text('Add Exchangerate');
2293 <input type=hidden name=path value=$form->{path}>
2294 <input type=hidden name=login value=$form->{login}>
2295 <input type=hidden name=password value=$form->{password}>
2297 <input type=hidden name=exchangeratedate value=$orddate>
2298 <input type=hidden name=buysell value=$buysell>
2301 <tr><th class=listtop>$form->{title}</th></tr>
2302 <tr height="5"></tr>
2307 <th align=right>| . $locale->text('Currency') . qq|</th>
2308 <td>$form->{currency}</td>
2311 <th align=right>| . $locale->text('Date') . qq|</th>
2315 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2316 <td><input name=exchangerate size=11></td>
2326 <input type=hidden name=nextsub value=save_exchangerate>
2328 <input name=action class=submit type=submit value="|
2329 . $locale->text('Continue') . qq|">
2337 $lxdebug->leave_sub();
2340 sub save_exchangerate {
2341 $lxdebug->enter_sub();
2343 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2344 $form->{exchangerate} =
2345 $form->parse_amount(\%myconfig, $form->{exchangerate});
2346 $form->save_exchangerate(\%myconfig, $form->{currency},
2347 $form->{exchangeratedate},
2348 $form->{exchangerate}, $form->{buysell});
2352 $lxdebug->leave_sub();
2355 sub create_backorder {
2356 $lxdebug->enter_sub();
2358 $form->{shipped} = 1;
2360 # figure out if we need to create a backorder
2361 # items aren't saved if qty != 0
2363 for $i (1 .. $form->{rowcount}) {
2364 $totalqty += $qty = $form->{"qty_$i"};
2365 $totalship += $ship = $form->{"ship_$i"};
2367 $form->{"qty_$i"} = $qty - $ship;
2370 if ($totalship == 0) {
2371 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2372 $form->{ordtotal} = 0;
2373 $form->{shipped} = 0;
2377 if ($totalqty == $totalship) {
2378 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2379 $form->{ordtotal} = 0;
2384 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2387 for $i (1 .. $form->{rowcount}) {
2389 $form->{"${_}_$i"} =
2390 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2391 } qw(sellprice discount);
2396 OE->save(\%myconfig, \%$form);
2398 # rebuild rows for invoice
2402 for $i (1 .. $form->{rowcount}) {
2403 $form->{"qty_$i"} = $form->{"ship_$i"};
2405 if ($form->{"qty_$i"}) {
2408 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2413 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2414 $form->{rowcount} = $count;
2416 $lxdebug->leave_sub();
2420 $lxdebug->enter_sub();
2422 $form->{saveasnew} = 1;
2423 $form->{closed} = 0;
2424 map { delete $form->{$_} } qw(printed emailed queued ordnumber quonumber);
2428 $lxdebug->leave_sub();
2431 sub purchase_order {
2432 $lxdebug->enter_sub();
2434 if ( $form->{type} eq 'sales_quotation'
2435 || $form->{type} eq 'request_quotation') {
2436 $form->{closed} = 1;
2438 OE->save(\%myconfig, \%$form);
2441 $form->{cp_id} *= 1;
2443 $form->{title} = $locale->text('Add Purchase Order');
2444 $form->{vc} = "vendor";
2445 $form->{type} = "purchase_order";
2449 $lxdebug->leave_sub();
2453 $lxdebug->enter_sub();
2455 if ( $form->{type} eq 'sales_quotation'
2456 || $form->{type} eq 'request_quotation') {
2457 $form->{closed} = 1;
2459 OE->save(\%myconfig, \%$form);
2462 $form->{cp_id} *= 1;
2464 $form->{title} = $locale->text('Add Sales Order');
2465 $form->{vc} = "customer";
2466 $form->{type} = "sales_order";
2470 $lxdebug->leave_sub();
2474 $lxdebug->enter_sub();
2476 $form->{transdate} = $form->current_date(\%myconfig);
2477 delete $form->{duedate};
2479 $form->{closed} = 0;
2482 map { delete $form->{$_} }
2483 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2490 for $i (1 .. $form->{rowcount} - 1) {
2491 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2492 qw(partnumber description unit);
2495 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2496 qw(creditlimit creditremaining);
2500 $lxdebug->leave_sub();
2504 $lxdebug->enter_sub();
2510 OE->get_warehouses(\%myconfig, \%$form);
2513 if (@{ $form->{all_warehouses} }) {
2514 $form->{selectwarehouse} = "<option>\n";
2516 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2517 (@{ $form->{all_warehouses} });
2519 if ($form->{warehouse}) {
2520 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2524 $form->{shippingdate} = $form->current_date(\%myconfig);
2525 $form->{"$form->{vc}"} =~ s/--.*//;
2530 foreach $key (keys %$form) {
2531 if ($key =~ /_1$/) {
2537 for $i (1 .. $form->{rowcount}) {
2539 # undo formatting from prepare_order
2541 $form->{"${_}_$i"} =
2542 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2544 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2546 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2547 $form->{"ship_$i"} = "";
2548 $form->{"serialnumber_$i"} = "";
2553 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2558 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2559 $form->{rowcount} = $count;
2561 &display_ship_receive;
2563 $lxdebug->leave_sub();
2566 sub display_ship_receive {
2567 $lxdebug->enter_sub();
2569 $vclabel = ucfirst $form->{vc};
2570 $vclabel = $locale->text($vclabel);
2572 $form->{rowcount}++;
2574 if ($form->{vc} eq 'customer') {
2575 $form->{title} = $locale->text('Ship Merchandise');
2576 $shipped = $locale->text('Shipping Date');
2578 $form->{title} = $locale->text('Receive Merchandise');
2579 $shipped = $locale->text('Date Received');
2582 # set option selected
2583 foreach $item (warehouse, employee) {
2584 $form->{"select$item"} =~ s/ selected//;
2585 $form->{"select$item"} =~
2586 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2591 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2592 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2593 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2595 | if $form->{selectwarehouse};
2599 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2600 <td><select name=employee>$form->{selectemployee}</select></td>
2601 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2610 <form method=post action=$form->{script}>
2612 <input type=hidden name=id value=$form->{id}>
2614 <input type=hidden name=display_form value=display_ship_receive>
2616 <input type=hidden name=type value=$form->{type}>
2617 <input type=hidden name=media value=$form->{media}>
2618 <input type=hidden name=format value=$form->{format}>
2620 <input type=hidden name=queued value="$form->{queued}">
2621 <input type=hidden name=printed value="$form->{printed}">
2622 <input type=hidden name=emailed value="$form->{emailed}">
2624 <input type=hidden name=vc value=$form->{vc}>
2628 <th class=listtop>$form->{title}</th>
2630 <tr height="5"></tr>
2633 <table width="100%">
2638 <th align=right>$vclabel</th>
2639 <td colspan=3>$form->{$form->{vc}}</td>
2640 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2641 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2645 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2647 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2650 <th align=right>| . $locale->text('Ship via') . qq|</th>
2652 <input name=shipvia size=35 value="$form->{shipvia}">
2661 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2662 <td>$form->{ordnumber}</td>
2663 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2666 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2667 <td>$form->{transdate}</td>
2668 <input type=hidden name=transdate value=$form->{transdate}>
2671 <th align=right nowrap>$shipped</th>
2672 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2681 <!-- shipto are in hidden variables -->
2683 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2684 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2685 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2686 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2687 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2688 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2689 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2690 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2691 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2692 <input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
2693 <input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
2695 <!-- email variables -->
2696 <input type=hidden name=message value="$form->{message}">
2697 <input type=hidden name=email value="$form->{email}">
2698 <input type=hidden name=subject value="$form->{subject}">
2699 <input type=hidden name=cc value="$form->{cc}">
2700 <input type=hidden name=bcc value="$form->{bcc}">
2705 (partnumber, description, qty, ship, unit, bin, serialnumber);
2707 if ($form->{type} eq "ship_order") {
2708 $column_data{ship} =
2709 qq|<th class=listheading align=center width="auto">|
2710 . $locale->text('Ship')
2713 if ($form->{type} eq "receive_order") {
2714 $column_data{ship} =
2715 qq|<th class=listheading align=center width="auto">|
2716 . $locale->text('Recd')
2720 my $colspan = $#column_index + 1;
2722 $column_data{partnumber} =
2723 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2724 $column_data{description} =
2725 qq|<th class=listheading nowrap>|
2726 . $locale->text('Description')
2729 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2730 $column_data{unit} =
2731 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2733 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2734 $column_data{serialnumber} =
2735 qq|<th class=listheading nowrap>|
2736 . $locale->text('Serial No.')
2743 <tr class=listheading>|;
2745 map { print "\n$column_data{$_}" } @column_index;
2751 for $i (1 .. $form->{rowcount} - 1) {
2754 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2756 # convert " to "
2757 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2758 qw(partnumber description unit bin serialnumber);
2760 $description = $form->{"description_$i"};
2761 $description =~ s/\n/<br>/g;
2763 $column_data{partnumber} =
2764 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2765 $column_data{description} =
2766 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2768 qq|<td align=right>|
2769 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2770 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2771 $column_data{ship} =
2772 qq|<td align=right><input name="ship_$i" size=5 value=|
2773 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2775 $column_data{unit} =
2776 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2778 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2780 $column_data{serialnumber} =
2781 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2786 map { print "\n$column_data{$_}" } @column_index;
2791 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2792 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2793 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2794 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2805 <td><hr size=3 noshade></td>
2811 $form->{copies} = 1;
2820 <input class=submit type=submit name=action value="|
2821 . $locale->text('Update') . qq|">
2822 <input class=submit type=submit name=action value="|
2823 . $locale->text('Print') . qq|">
2826 if ($form->{type} eq 'ship_order') {
2828 <input class=submit type=submit name=action value="|
2829 . $locale->text('Ship to') . qq|">
2830 <input class=submit type=submit name=action value="|
2831 . $locale->text('E-mail') . qq|">
2837 <input class=submit type=submit name=action value="|
2838 . $locale->text('Done') . qq|">
2841 if ($form->{menubar}) {
2842 require "$form->{path}/menu.pl";
2848 <input type=hidden name=rowcount value=$form->{rowcount}>
2850 <input name=callback type=hidden value="$callback">
2852 <input type=hidden name=path value=$form->{path}>
2853 <input type=hidden name=login value=$form->{login}>
2854 <input type=hidden name=password value=$form->{password}>
2862 $lxdebug->leave_sub();
2866 $lxdebug->enter_sub();
2868 if ($form->{type} eq 'ship_order') {
2869 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2871 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2876 $total += $form->{"ship_$_"} =
2877 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2878 } (1 .. $form->{rowcount} - 1);
2880 $form->error($locale->text('Nothing entered!')) unless $total;
2882 $form->redirect($locale->text('Inventory saved!'))
2883 if OE->save_inventory(\%myconfig, \%$form);
2884 $form->error($locale->text('Could not save!'));
2886 $lxdebug->leave_sub();
2889 sub search_transfer {
2890 $lxdebug->enter_sub();
2892 OE->get_warehouses(\%myconfig, \%$form);
2895 if (@{ $form->{all_warehouses} }) {
2896 $form->{selectwarehouse} = "<option>\n";
2897 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2899 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2900 (@{ $form->{all_warehouses} });
2902 $form->error($locale->text('Nothing to transfer!'));
2905 $form->{title} = $locale->text('Transfer Inventory');
2912 <form method=post action=$form->{script}>
2916 <th class=listtop>$form->{title}</th>
2918 <tr height="5"></tr>
2923 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2924 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2927 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2928 <td><input name=partnumber size=20></td>
2931 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2932 <td><input name=description size=40></td>
2935 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2936 <td><input name=partsgroup size=20></td>
2942 <td><hr size=3 noshade></td>
2947 <input type=hidden name=sort value=partnumber>
2948 <input type=hidden name=nextsub value=list_transfer>
2950 <input type=hidden name=path value=$form->{path}>
2951 <input type=hidden name=login value=$form->{login}>
2952 <input type=hidden name=password value=$form->{password}>
2954 <input class=submit type=submit name=action value="|
2955 . $locale->text('Continue') . qq|">
2962 $lxdebug->leave_sub();
2966 $lxdebug->enter_sub();
2968 OE->get_inventory(\%myconfig, \%$form);
2970 $partnumber = $form->escape($form->{partnumber});
2971 $warehouse = $form->escape($form->{warehouse});
2972 $description = $form->escape($form->{description});
2973 $partsgroup = $form->escape($form->{partsgroup});
2977 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2979 # construct callback
2980 $partnumber = $form->escape($form->{partnumber}, 1);
2981 $warehouse = $form->escape($form->{warehouse}, 1);
2982 $description = $form->escape($form->{description}, 1);
2983 $partsgroup = $form->escape($form->{partsgroup}, 1);
2986 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2989 $form->sort_columns(
2990 qw(partnumber description partsgroup make model warehouse qty transfer));
2992 $column_header{partnumber} =
2993 qq|<th><a class=listheading href=$href&sort=partnumber>|
2994 . $locale->text('Part Number')
2996 $column_header{description} =
2997 qq|<th><a class=listheading href=$href&sort=description>|
2998 . $locale->text('Description')
3000 $column_header{partsgroup} =
3001 qq|<th><a class=listheading href=$href&sort=partsgroup>|
3002 . $locale->text('Group')
3004 $column_header{warehouse} =
3005 qq|<th><a class=listheading href=$href&sort=warehouse>|
3006 . $locale->text('From')
3008 $column_header{qty} =
3009 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
3010 $column_header{transfer} =
3011 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
3013 $option = $locale->text('Transfer to');
3015 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
3017 if ($form->{warehouse}) {
3018 $option .= " : $warehouse";
3020 if ($form->{partnumber}) {
3021 $option .= "\n<br>" if ($option);
3022 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
3024 if ($form->{description}) {
3025 $option .= "\n<br>" if ($option);
3026 $option .= $locale->text('Description') . " : $form->{description}";
3028 if ($form->{partsgroup}) {
3029 $option .= "\n<br>" if ($option);
3030 $option .= $locale->text('Group') . " : $form->{partsgroup}";
3033 $form->{title} = $locale->text('Transfer Inventory');
3040 <form method=post action=$form->{script}>
3042 <input type=hidden name=warehouse_id value=$warehouse_id>
3046 <th class=listtop>$form->{title}</th>
3048 <tr height="5"></tr>
3055 <tr class=listheading>|;
3057 map { print "\n$column_header{$_}" } @column_index;
3063 if (@{ $form->{all_inventory} }) {
3064 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
3068 foreach $ref (@{ $form->{all_inventory} }) {
3072 $column_data{partnumber} =
3073 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
3074 $column_data{description} = "<td>$ref->{description} </td>";
3075 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
3076 $column_data{warehouse} =
3077 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
3079 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
3080 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
3082 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
3087 <tr class=listrow$j>";
3089 map { print "\n$column_data{$_}" } @column_index;
3103 <td><hr size=3 noshade></td>
3109 <input name=callback type=hidden value="$callback">
3111 <input type=hidden name=rowcount value=$i>
3113 <input type=hidden name=path value=$form->{path}>
3114 <input type=hidden name=login value=$form->{login}>
3115 <input type=hidden name=password value=$form->{password}>
3117 <input class=submit type=submit name=action value="|
3118 . $locale->text('Transfer') . qq|">|;
3120 if ($form->{menubar}) {
3121 require "$form->{path}/menu.pl";
3132 $lxdebug->leave_sub();
3136 $lxdebug->enter_sub();
3138 $form->redirect($locale->text('Inventory transferred!'))
3139 if OE->transfer(\%myconfig, \%$form);
3140 $form->error($locale->text('Could not transfer Inventory!'));
3142 $lxdebug->leave_sub();