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->{media} = "screen";
288 $form->{formname} = $form->{type} unless $form->{formname};
291 foreach $ref (@{ $form->{form_details} }) {
292 $form->{rowcount} = ++$i;
294 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
296 for my $i (1 .. $form->{rowcount}) {
298 $form->{"discount_$i"} =
299 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
301 $form->{"discount_$i"} =
302 $form->format_amount(\%myconfig, $form->{"discount_$i"});
304 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
306 $decimalplaces = ($dec > 2) ? $dec : 2;
308 # copy reqdate from deliverydate for invoice -> order conversion
309 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
310 unless $form->{"reqdate_$i"};
312 $form->{"sellprice_$i"} =
313 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
316 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
317 $dec_qty = length $dec_qty;
319 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
321 map { $form->{"${_}_$i"} =~ s/\"/"/g }
322 qw(partnumber description unit);
325 $lxdebug->leave_sub();
329 $lxdebug->enter_sub();
331 $checkedopen = ($form->{closed}) ? "" : "checked";
332 $checkedclosed = ($form->{closed}) ? "checked" : "";
334 map { $form->{$_} =~ s/\"/"/g }
335 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
336 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
337 shiptophone shiptofax shiptodepartment_1 shiptodepartment_2);
339 # use JavaScript Calendar or not
340 $form->{jsscript} = $form->{jscalendar};
343 $payment = qq|<option value=""></option>|;
344 foreach $item (@{ $form->{payment_terms} }) {
345 if ($form->{payment_id} eq $item->{id}) {
346 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
348 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
351 if ($form->{jsscript}) {
353 # with JavaScript Calendar
355 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
356 <td><input type=button name=transdate id="trigger1" value=|
357 . $locale->text('button') . qq|></td>
360 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
361 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
362 . $locale->text('button') . qq|></td>
367 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
368 "reqdate", "BL", "trigger2");
372 # without JavaScript Calendar
374 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
376 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
382 <td colspan=2 align=center>
385 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
386 . $locale->text('Open') . qq|</th>
387 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
388 . $locale->text('Closed') . qq|</th>
396 # set option selected
397 foreach $item ($form->{vc}, currency, department, employee) {
398 $form->{"select$item"} =~ s/ selected//;
399 $form->{"select$item"} =~
400 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
403 #quote select[customer|vendor] Bug 133
404 $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
407 if ($form->{all_contacts}) {
409 $form->{selectcontact} = "<option></option>";
410 foreach $item (@{ $form->{all_contacts} }) {
411 my $department = ($item->{cp_abteilung}) ? "--$item->{cp_abteilung}" : "";
412 if ($form->{cp_id} == $item->{cp_id}) {
413 $form->{selectcontact} .=
414 "<option value=$item->{cp_id} selected>$item->{cp_name}$department</option>";
416 $form->{selectcontact} .= "<option value=$item->{cp_id}>$item->{cp_name}$department</option>";
420 $form->{selectcontact} =~ s/ selected//g;
421 if ($form->{cp_id} ne "") {
422 $form->{selectcontact} =~ s/value=$form->{cp_id}/value=$form->{cp_id} selected/;
427 if (@{ $form->{SHIPTO} }) {
428 $form->{selectshipto} = "<option value=0></option>";
429 foreach $item (@{ $form->{SHIPTO} }) {
430 if ($item->{shipto_id} == $form->{shipto_id}) {
431 $form->{selectshipto} .=
432 "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}</option>";
434 $form->{selectshipto} .=
435 "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment_1}</option>";
440 $form->{selectshipto} =~ s/ selected//g;
441 if ($form->{shipto_id} ne "") {
442 $form->{selectshipto} =~ s/value=$form->{shipto_id}/value=$form->{shipto_id} selected/;
447 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
448 <td><select name=shipto_id>$form->{selectshipto}</select></td>
449 <input type=hidden name=selectshipto value="$form->{selectshipto}">|;
454 $form->{exchangerate} =
455 $form->format_amount(\%myconfig, $form->{exchangerate});
457 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
463 $form->{creditlimit} =
464 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
465 $form->{creditremaining} =
466 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
469 ($form->{selectcontact})
470 ? qq|<select name=cp_id>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
471 : qq|<input name=contact value="$form->{contact}" size=35>|;
474 <input type=hidden name=forex value=$form->{forex}>
477 if ($form->{currency} ne $form->{defaultcurrency}) {
478 if ($form->{forex}) {
481 . $locale->text('Exchangerate')
482 . qq|</th><td>$form->{exchangerate}</td>
483 <input type=hidden name=exchangerate value=$form->{exchangerate}>
488 . $locale->text('Exchangerate')
489 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
493 $vclabel = ucfirst $form->{vc};
494 $vclabel = $locale->text($vclabel);
498 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
499 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
500 . $locale->text('days') . qq|</td>
504 if ($form->{business}) {
507 <th align=right>| . $locale->text('Business') . qq|</th>
508 <td>$form->{business}</td>
509 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
511 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
517 if ($form->{max_dunning_level}) {
523 <th align=right>| . $locale->text('Max. Dunning Level') . qq|:</th>
524 <td><b>$form->{max_dunning_level}</b></td>
525 <th align=right>| . $locale->text('Dunning Amount') . qq|:</th>
527 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
536 if (@{ $form->{TAXZONE} }) {
537 $form->{selecttaxzone} = "";
538 foreach $item (@{ $form->{TAXZONE} }) {
539 if ($item->{id} == $form->{taxzone_id}) {
540 $form->{selecttaxzone} .=
541 "<option value=$item->{id} selected>" . H($item->{description}) .
544 $form->{selecttaxzone} .=
545 "<option value=$item->{id}>" . H($item->{description}) . "</option>";
550 $form->{selecttaxzone} =~ s/ selected//g;
551 if ($form->{taxzone_id} ne "") {
552 $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}>/value=$form->{taxzone_id} selected>/;
558 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
559 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
560 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
564 if ($form->{type} !~ /_quotation$/) {
567 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
568 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
571 <th width=70% align=right nowrap>|
572 . $locale->text('Quotation Number') . qq|</th>
573 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
576 <th width=70% align=right nowrap>|
577 . $locale->text('Customer Order Number') . qq|</th>
578 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
581 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
586 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
591 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
593 $creditremaining = qq|
599 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
600 <td>$form->{creditlimit}</td>
602 <th nowrap>| . $locale->text('Remaining') . qq|</th>
603 <td class="plus$n">$form->{creditremaining}</td>
612 ($form->{type} eq 'sales_quotation')
613 ? $locale->text('Valid until')
614 : $locale->text('Required by');
615 if ($form->{type} eq 'sales_quotation') {
618 <th width=70% align=right nowrap>|
619 . $locale->text('Quotation Number') . qq|</th>
620 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
621 <input type=hidden name=ordnumber value="$form->{ordnumber}">
627 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
628 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
629 <input type=hidden name=ordnumber value="$form->{ordnumber}">
638 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
642 <th align=right nowrap=true>$reqlabel</th>
646 $creditremaining = qq| <tr>
653 ($form->{"select$form->{vc}"})
654 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
655 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
659 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
660 <td colspan=3><select name=department>$form->{selectdepartment}</select>
661 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
664 | if $form->{selectdepartment};
667 <input type=hidden name=employee value="$form->{employee}">
670 if ($form->{type} eq 'sales_order') {
671 if ($form->{selectemployee}) {
673 <input type=hidden name=customer_klass value=$form->{customer_klass}>
675 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
676 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
677 <input type=hidden name=selectemployee value="$form->{selectemployee}">
684 <input type=hidden name=customer_klass value=$form->{customer_klass}>
686 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
687 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
688 <input type=hidden name=selectemployee value="$form->{selectemployee}">
693 if ($form->{resubmit} && ($form->{format} eq "html")) {
695 qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
696 } elsif ($form->{resubmit}) {
697 $onload = qq|document.oe.submit()|;
702 $credittext = $locale->text('Credit Limit exceeded!!!');
703 if ($creditwarning) {
704 $onload = qq|alert('$credittext')|;
710 <body onLoad="$onload">
712 <form method=post name=oe action=$form->{script}>
713 <script type="text/javascript" src="js/common.js"></script>
714 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
715 <script type="text/javascript" src="js/vendor_selection.js"></script>
716 <script type="text/javascript" src="js/calculate_qty.js"></script>
718 <input type=hidden name=id value=$form->{id}>
719 <input type=hidden name=action value=$form->{action}>
721 <input type=hidden name=type value=$form->{type}>
722 <input type=hidden name=formname value=$form->{formname}>
723 <input type=hidden name=media value=$form->{media}>
724 <input type=hidden name=format value=$form->{format}>
725 <input type=hidden name=proforma value=$form->{proforma}>
727 <input type=hidden name=queued value="$form->{queued}">
728 <input type=hidden name=printed value="$form->{printed}">
729 <input type=hidden name=emailed value="$form->{emailed}">
731 <input type=hidden name=vc value=$form->{vc}>
733 <input type=hidden name=title value="$form->{title}">
735 <input type=hidden name=discount value=$form->{discount}>
736 <input type=hidden name=creditlimit value=$form->{creditlimit}>
737 <input type=hidden name=creditremaining value=$form->{creditremaining}>
739 <input type=hidden name=tradediscount value=$form->{tradediscount}>
740 <input type=hidden name=business value=$form->{business}>
741 <input type=hidden name=webdav value=$webdav>
745 <th class=listtop>$form->{title}</th>
755 <th align=right>$vclabel</th>
756 <td colspan=3>$vc</td>
757 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
758 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
759 <th align=richt nowrap>|
760 . $locale->text('Contact Person') . qq|</th>
761 <td colspan=3>$contact</td>
769 <th align=right>| . $locale->text('Currency') . qq|</th>
770 <td><select name=currency>$form->{selectcurrency}</select></td>
771 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
772 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
776 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
777 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
780 <th align=right>| . $locale->text('Ship via') . qq|</th>
781 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
788 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
790 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
791 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
795 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
797 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
798 # <input size=45 id=vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
820 <!-- shipto are in hidden variables -->
822 <input type=hidden name=shiptoname value="$form->{shiptoname}">
823 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
824 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
825 <input type=hidden name=shiptocity value="$form->{shiptocity}">
826 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
827 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
828 <input type=hidden name=shiptophone value="$form->{shiptophone}">
829 <input type=hidden name=shiptofax value="$form->{shiptofax}">
830 <input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
831 <input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
832 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
834 <!-- email variables -->
835 <input type=hidden name=message value="$form->{message}">
836 <input type=hidden name=email value="$form->{email}">
837 <input type=hidden name=subject value="$form->{subject}">
838 <input type=hidden name=cc value="$form->{cc}">
839 <input type=hidden name=bcc value="$form->{bcc}">
841 <input type=hidden name=taxpart value="$form->{taxpart}">
842 <input type=hidden name=taxservice value="$form->{taxservice}">
844 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
847 foreach $item (split / /, $form->{taxaccounts}) {
849 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
850 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
853 $lxdebug->leave_sub();
857 $lxdebug->enter_sub();
859 $form->{invtotal} = $form->{invsubtotal};
861 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
864 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
867 $rows = ($rows > $introws) ? $rows : $introws;
869 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
871 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
873 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
876 if ($form->{taxaccounts}) {
878 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
879 . $locale->text('Tax Included') . qq|</b><br><br>
883 if (!$form->{taxincluded}) {
885 foreach $item (split / /, $form->{taxaccounts}) {
886 if ($form->{"${item}_base"}) {
887 $form->{invtotal} += $form->{"${item}_total"} =
889 $form->{"${item}_base"} * $form->{"${item}_rate"},
891 $form->{"${item}_total"} =
892 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
896 <th align=right>$form->{"${item}_description"}</th>
897 <td align=right>$form->{"${item}_total"}</td>
903 $form->{invsubtotal} =
904 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
908 <th align=right>| . $locale->text('Subtotal') . qq|</th>
909 <td align=right>$form->{invsubtotal}</td>
915 if ($form->{taxincluded}) {
916 foreach $item (split / /, $form->{taxaccounts}) {
917 if ($form->{"${item}_base"}) {
918 $form->{"${item}_total"} =
920 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
921 (1 + $form->{"${item}_rate"})
924 $form->{"${item}_netto"} =
926 ($form->{"${item}_base"} - $form->{"${item}_total"}),
928 $form->{"${item}_total"} =
929 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
930 $form->{"${item}_netto"} =
931 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
935 <th align=right>Enthaltene $form->{"${item}_description"}</th>
936 <td align=right>$form->{"${item}_total"}</td>
939 <th align=right>Nettobetrag</th>
940 <td align=right>$form->{"${item}_netto"}</td>
948 $form->{oldinvtotal} = $form->{invtotal};
950 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
960 <th align=left>| . $locale->text('Notes') . qq|</th>
961 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
967 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
968 <td><select name=payment_id tabindex=24>$payment
972 <td align=right width=100%>
978 <th align=right>| . $locale->text('Total') . qq|</th>
979 <td align=right>$form->{invtotal}</td>
987 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
988 <input type=hidden name=oldtotalpaid value=$totalpaid>
990 <td><hr size=3 noshade></td>
998 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
1001 <td align=left width=30%><b>Dateiname</b></td>
1002 <td align=left width=70%><b>Webdavlink</b></td>
1004 foreach $file (keys %{ $form->{WEBDAV} }) {
1007 <td align=left>$file</td>
1008 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
1016 <td><hr size=3 noshade></td>
1023 <input type=hidden name=jscalendar value=$form->{jscalendar}>
1036 | . $locale->text("Edit the $form->{type}") . qq|<br>
1037 <input class=submit type=submit name=action value="|
1038 . $locale->text('Update') . qq|">
1039 <input class=submit type=submit name=action value="|
1040 . $locale->text('Ship to') . qq|">
1041 <input class=submit type=submit name=action value="|
1042 . $locale->text('Print') . qq|">
1043 <input class=submit type=submit name=action value="|
1044 . $locale->text('E-mail') . qq|">
1045 <input class=submit type=submit name=action value="|
1046 . $locale->text('Save') . qq|">
1047 <input class=submit type=submit name=action value="|
1048 . $locale->text('Save and Close') . qq|">
1051 if (($form->{id})) {
1053 <br>| . $locale->text("Workflow $form->{type}") . qq|<br>
1054 <input class=submit type=submit name=action value="|
1055 . $locale->text('Save as new') . qq|">
1056 <input class=submit type=submit name=action value="|
1057 . $locale->text('Delete') . qq|">|;
1058 if (($form->{type} =~ /sales_quotation$/)) {
1060 <input class=submit type=submit name=action value="|
1061 . $locale->text('Sales Order') . qq|">|;
1063 if ($form->{type} =~ /request_quotation$/) {
1065 <input class=submit type=submit name=action value="|
1066 . $locale->text('Purchase Order') . qq|">|;
1070 <input class=submit type=submit name=action value="|
1071 . $locale->text('Invoice') . qq|">
1075 if ($form->{type} =~ /sales_order$/) {
1077 <br>$form->{heading} als neue Vorlage verwenden für<br>
1078 <input class=submit type=submit name=action value="|
1079 . $locale->text('Purchase Order') . qq|">
1080 <input class=submit type=submit name=action value="|
1081 . $locale->text('Quotation') . qq|">
1084 } elsif ($form->{type} =~ /purchase_order$/) {
1086 <br>$form->{heading} als neue Vorlage verwenden für<br>
1087 <input class=submit type=submit name=action value="|
1088 . $locale->text('Sales Order') . qq|">
1089 <input class=submit type=submit name=action value="|
1090 . $locale->text('Request for Quotation') . qq|">
1095 <br>$form->{heading} als neue Vorlage verwenden für<br>
1096 <input class=submit type=submit name=action value="|
1097 . $locale->text('Order') . qq|">
1100 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount} && !$form->{proforma}) {
1102 <br>Workflow $form->{heading}<br>
1103 <input class=submit type=submit name=action value="|
1104 . $locale->text('Save as new') . qq|">
1105 <input class=submit type=submit name=action value="|
1106 . $locale->text('Invoice') . qq|">
1110 if ($form->{menubar}) {
1111 require "$form->{path}/menu.pl";
1117 <input type=hidden name=rowcount value=$form->{rowcount}>
1119 <input name=callback type=hidden value="$form->{callback}">
1121 <input type=hidden name=path value=$form->{path}>
1122 <input type=hidden name=login value=$form->{login}>
1123 <input type=hidden name=password value=$form->{password}>
1130 $lxdebug->leave_sub();
1134 $lxdebug->enter_sub();
1136 set_headings($form->{"id"} ? "edit" : "add");
1138 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1139 qw(exchangerate creditlimit creditremaining);
1140 $form->{update} = 1;
1142 &check_name($form->{vc});
1147 $buysell = 'sell' if ($form->{vc} eq 'vendor');
1148 $form->{exchangerate} = $exchangerate
1152 $form->check_exchangerate(
1153 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1157 $i = $form->{rowcount};
1159 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1161 if ( ($form->{"partnumber_$i"} eq "")
1162 && ($form->{"description_$i"} eq "")
1163 && ($form->{"partsgroup_$i"} eq "")) {
1165 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1170 if ( $form->{type} eq 'purchase_order'
1171 || $form->{type} eq 'request_quotation') {
1172 IR->retrieve_item(\%myconfig, \%$form);
1174 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1175 IS->retrieve_item(\%myconfig, \%$form);
1178 my $rows = scalar @{ $form->{item_list} };
1180 $form->{"discount_$i"} =
1181 $form->format_amount(\%myconfig, $form->{discount} * 100);
1184 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1193 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1194 if ($form->{"not_discountable_$i"}) {
1195 $form->{"discount_$i"} = 0;
1197 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1198 qw(partnumber description unit);
1199 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1200 keys %{ $form->{item_list}[0] };
1201 if ($form->{"part_payment_id_$i"} ne "") {
1202 $form->{payment_id} = $form->{"part_payment_id_$i"};
1205 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1207 ($dec) = ($s =~ /\.(\d+)/);
1209 $decimalplaces = ($dec > 2) ? $dec : 2;
1212 $form->{"sellprice_$i"} = $sellprice;
1215 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1217 # if there is an exchange rate adjust sellprice
1218 $form->{"sellprice_$i"} /= $exchangerate;
1222 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1223 (1 - $form->{"discount_$i"} / 100);
1224 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1225 map { $form->{"${_}_base"} += $amount }
1226 (split / /, $form->{"taxaccounts_$i"});
1227 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1228 split / /, $form->{taxaccounts}
1229 if !$form->{taxincluded};
1231 $form->{creditremaining} -= $amount;
1233 $form->{"sellprice_$i"} =
1234 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1237 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1239 # get pricegroups for parts
1240 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1242 # build up html code for prices_$i
1243 &set_pricegroup($i);
1250 # ok, so this is a new part
1251 # ask if it is a part or service item
1253 if ( $form->{"partsgroup_$i"}
1254 && ($form->{"partsnumber_$i"} eq "")
1255 && ($form->{"description_$i"} eq "")) {
1256 $form->{rowcount}--;
1257 $form->{"discount_$i"} = "";
1261 $form->{"id_$i"} = 0;
1262 $form->{"unit_$i"} = $locale->text('ea');
1270 $lxdebug->leave_sub();
1274 $lxdebug->enter_sub();
1276 if ($form->{type} eq 'purchase_order') {
1277 $form->{title} = $locale->text('Purchase Orders');
1278 $form->{vc} = 'vendor';
1279 $ordlabel = $locale->text('Order Number');
1280 $ordnumber = 'ordnumber';
1281 $employee = $locale->text('Employee');
1283 if ($form->{type} eq 'request_quotation') {
1284 $form->{title} = $locale->text('Request for Quotations');
1285 $form->{vc} = 'vendor';
1286 $ordlabel = $locale->text('RFQ Number');
1287 $ordnumber = 'quonumber';
1288 $employee = $locale->text('Employee');
1290 if ($form->{type} eq 'receive_order') {
1291 $form->{title} = $locale->text('Receive Merchandise');
1292 $form->{vc} = 'vendor';
1293 $ordlabel = $locale->text('Order Number');
1294 $ordnumber = 'ordnumber';
1295 $employee = $locale->text('Employee');
1297 if ($form->{type} eq 'sales_order') {
1298 $form->{title} = $locale->text('Sales Orders');
1299 $form->{vc} = 'customer';
1300 $ordlabel = $locale->text('Order Number');
1301 $ordnumber = 'ordnumber';
1302 $employee = $locale->text('Salesperson');
1304 if ($form->{type} eq 'ship_order') {
1305 $form->{title} = $locale->text('Ship Merchandise');
1306 $form->{vc} = 'customer';
1307 $ordlabel = $locale->text('Order Number');
1308 $ordnumber = 'ordnumber';
1309 $employee = $locale->text('Salesperson');
1313 if ($form->{type} eq 'sales_quotation') {
1314 $form->{title} = $locale->text('Quotations');
1315 $form->{vc} = 'customer';
1316 $ordlabel = $locale->text('Quotation Number');
1317 $ordnumber = 'quonumber';
1318 $employee = $locale->text('Employee');
1321 if ($form->{type} =~ /(ship|receive)_order/) {
1322 OE->get_warehouses(\%myconfig, \%$form);
1325 if (@{ $form->{all_warehouses} }) {
1326 $form->{selectwarehouse} = "<option>\n";
1327 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1330 $form->{selectwarehouse} .=
1331 "<option>$_->{description}--$_->{id}\n"
1332 } (@{ $form->{all_warehouses} });
1336 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1337 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1338 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1345 # setup vendor / customer selection
1346 $form->all_vc(\%myconfig, $form->{vc},
1347 ($form->{vc} eq 'customer') ? "AR" : "AP");
1349 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1350 @{ $form->{"all_$form->{vc}"} };
1352 $vclabel = ucfirst $form->{vc};
1353 $vclabel = $locale->text($vclabel);
1355 # $locale->text('Vendor')
1356 # $locale->text('Customer')
1360 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1361 : qq|<input name=$form->{vc} size=35>|;
1364 if (@{ $form->{all_departments} }) {
1365 $form->{selectdepartment} = "<option>\n";
1368 $form->{selectdepartment} .=
1369 "<option>$_->{description}--$_->{id}\n"
1370 } (@{ $form->{all_departments} });
1375 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1376 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1378 | if $form->{selectdepartment};
1380 if ($form->{type} !~ /(ship_order|receive_order)/) {
1383 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1384 . $locale->text('Open') . qq|</td>
1385 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1386 . $locale->text('Closed') . qq|</td>
1392 <input type=hidden name="open" value=1>
1396 # use JavaScript Calendar or not
1397 $form->{jsscript} = $jscalendar;
1399 if ($form->{jsscript}) {
1401 # with JavaScript Calendar
1403 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1404 <input type=button name=transdatefrom id="trigger3" value=|
1405 . $locale->text('button') . qq|></td>
1408 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1409 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1410 . $locale->text('button') . qq|></td>
1415 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1416 "transdateto", "BL", "trigger4");
1419 # without JavaScript Calendar
1421 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1423 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1431 <form method=post action=$form->{script}>
1435 <th class=listtop>$form->{title}</th>
1437 <tr height="5"></tr>
1442 <th align=right>$vclabel</th>
1443 <td colspan=3>$vc</td>
1448 <th align=right>$ordlabel</th>
1449 <td colspan=3><input name="$ordnumber" size=20></td>
1452 <th align=right>| . $locale->text('From') . qq|</th>
1454 <th align=right>| . $locale->text('Bis') . qq|</th>
1457 <input type=hidden name=sort value=transdate>
1459 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1464 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1465 | . $locale->text('ID') . qq|</td>
1466 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1467 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1468 . $locale->text('Date') . qq|</td>
1469 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1470 . $locale->text('Required by') . qq|</td>
1473 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1474 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1475 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1476 . $locale->text('Ship via') . qq|</td>
1479 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1480 . $locale->text('Amount') . qq|</td>
1481 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1482 . $locale->text('Tax') . qq|</td>
1483 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1484 . $locale->text('Total') . qq|</td>
1487 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1488 . $locale->text('Subtotal') . qq|</td>
1496 <tr><td colspan=4><hr size=3 noshade></td></tr>
1502 <input type=hidden name=nextsub value=orders>
1503 <input type=hidden name=path value=$form->{path}>
1504 <input type=hidden name=login value=$form->{login}>
1505 <input type=hidden name=password value=$form->{password}>
1506 <input type=hidden name=vc value=$form->{vc}>
1507 <input type=hidden name=type value=$form->{type}>
1509 <input class=submit type=submit name=action value="|
1510 . $locale->text('Continue') . qq|">
1517 $lxdebug->leave_sub();
1521 $lxdebug->enter_sub();
1523 # split vendor / customer
1524 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1525 split(/--/, $form->{ $form->{vc} });
1527 OE->transactions(\%myconfig, \%$form);
1529 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1531 $number = $form->escape($form->{$ordnumber});
1532 $name = $form->escape($form->{ $form->{vc} });
1533 $department = $form->escape($form->{department});
1534 $warehouse = $form->escape($form->{warehouse});
1538 "$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";
1540 # construct callback
1541 $number = $form->escape($form->{$ordnumber}, 1);
1542 $name = $form->escape($form->{ $form->{vc} }, 1);
1543 $department = $form->escape($form->{department}, 1);
1544 $warehouse = $form->escape($form->{warehouse}, 1);
1547 "$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";
1550 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1551 "name", "netamount", "tax", "amount",
1552 "curr", "employee", "shipvia", "open",
1555 $form->{l_open} = $form->{l_closed} = "Y"
1556 if ($form->{open} && $form->{closed});
1558 foreach $item (@columns) {
1559 if ($form->{"l_$item"} eq "Y") {
1560 push @column_index, $item;
1562 # add column to href and callback
1563 $callback .= "&l_$item=Y";
1564 $href .= "&l_$item=Y";
1568 # only show checkboxes if gotten here via sales_order form.
1569 if ($form->{type} =~ /sales_order/) {
1570 unshift @column_index, "ids";
1573 if ($form->{l_subtotal} eq 'Y') {
1574 $callback .= "&l_subtotal=Y";
1575 $href .= "&l_subtotal=Y";
1578 if ($form->{vc} eq 'vendor') {
1579 if ($form->{type} eq 'receive_order') {
1580 $form->{title} = $locale->text('Receive Merchandise');
1581 } elsif ($form->{type} eq 'purchase_order') {
1582 $form->{title} = $locale->text('Purchase Orders');
1584 $form->{title} = $locale->text('Request for Quotations');
1586 $name = $locale->text('Vendor');
1587 $employee = $locale->text('Employee');
1589 if ($form->{vc} eq 'customer') {
1590 if ($form->{type} eq 'sales_order') {
1591 $form->{title} = $locale->text('Sales Orders');
1592 $employee = $locale->text('Salesperson');
1593 } elsif ($form->{type} eq 'ship_order') {
1594 $form->{title} = $locale->text('Ship Merchandise');
1595 $employee = $locale->text('Salesperson');
1597 $form->{title} = $locale->text('Quotations');
1598 $employee = $locale->text('Employee');
1600 $name = $locale->text('Customer');
1603 $column_header{id} =
1604 qq|<th><a class=listheading href=$href&sort=id>|
1605 . $locale->text('ID')
1607 $column_header{transdate} =
1608 qq|<th><a class=listheading href=$href&sort=transdate>|
1609 . $locale->text('Date')
1611 $column_header{reqdate} =
1612 qq|<th><a class=listheading href=$href&sort=reqdate>|
1613 . $locale->text('Required by')
1615 $column_header{ordnumber} =
1616 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1617 . $locale->text('Order')
1619 $column_header{quonumber} =
1620 qq|<th><a class=listheading href=$href&sort=quonumber>|
1621 . $locale->text('Quotation')
1623 $column_header{name} =
1624 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1625 $column_header{netamount} =
1626 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1627 $column_header{tax} =
1628 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1629 $column_header{amount} =
1630 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1631 $column_header{curr} =
1632 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1633 $column_header{shipvia} =
1634 qq|<th><a class=listheading href=$href&sort=shipvia>|
1635 . $locale->text('Ship via')
1637 $column_header{open} =
1638 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1639 $column_header{closed} =
1640 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1642 $column_header{employee} =
1643 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1645 $column_header{ids} = qq|<th></th>|;
1647 if ($form->{ $form->{vc} }) {
1648 $option = $locale->text(ucfirst $form->{vc});
1649 $option .= " : $form->{$form->{vc}}";
1651 if ($form->{warehouse}) {
1652 ($warehouse) = split /--/, $form->{warehouse};
1653 $option .= "\n<br>" if ($option);
1654 $option .= $locale->text('Warehouse');
1655 $option .= " : $warehouse";
1657 if ($form->{department}) {
1658 $option .= "\n<br>" if ($option);
1659 ($department) = split /--/, $form->{department};
1660 $option .= $locale->text('Department') . " : $department";
1662 if ($form->{transdatefrom}) {
1664 . $locale->text('From') . " "
1665 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1667 if ($form->{transdateto}) {
1669 . $locale->text('Bis') . " "
1670 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1672 if ($form->{open}) {
1673 $option .= "\n<br>" if ($option);
1674 $option .= $locale->text('Open');
1676 if ($form->{closed}) {
1677 $option .= "\n<br>" if ($option);
1678 $option .= $locale->text('Closed');
1686 <form method="post" action="oe.pl">
1689 <th class=listtop>$form->{title}</th>
1691 <tr height="5"></tr>
1698 <tr class=listheading>|;
1700 map { print "\n$column_header{$_}" } @column_index;
1706 # add sort and escape callback
1707 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1709 if (@{ $form->{OE} }) {
1710 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1714 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1716 $warehouse = $form->escape($form->{warehouse});
1718 foreach $oe (@{ $form->{OE} }) {
1719 $form->{rowcount} = ++$j;
1721 if ($form->{l_subtotal} eq 'Y') {
1722 if ($sameitem ne $oe->{ $form->{sort} }) {
1724 $sameitem = $oe->{ $form->{sort} };
1728 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1730 $column_data{netamount} =
1732 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1734 $column_data{tax} = "<td align=right>"
1735 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1738 $column_data{amount} =
1740 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1742 $totalnetamount += $oe->{netamount};
1743 $totalamount += $oe->{amount};
1745 $subtotalnetamount += $oe->{netamount};
1746 $subtotalamount += $oe->{amount};
1749 qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1750 $column_data{id} = "<td>$oe->{id}</td>";
1751 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1752 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1754 $column_data{$ordnumber} =
1755 "<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>";
1756 $column_data{name} = "<td>$oe->{name}</td>";
1758 $column_data{employee} = "<td>$oe->{employee} </td>";
1759 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1761 if ($oe->{closed}) {
1762 $column_data{closed} = "<td align=center>X</td>";
1763 $column_data{open} = "<td> </td>";
1765 $column_data{closed} = "<td> </td>";
1766 $column_data{open} = "<td align=center>X</td>";
1772 <tr class=listrow$i>";
1774 map { print "\n$column_data{$_}" } @column_index;
1782 if ($form->{l_subtotal} eq 'Y') {
1788 <tr class=listtotal>|;
1790 map { $column_data{$_} = "<td> </td>" } @column_index;
1792 $column_data{netamount} =
1793 "<th class=listtotal align=right>"
1794 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1795 $column_data{tax} = "<th class=listtotal align=right>"
1796 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1799 $column_data{amount} =
1800 "<th class=listtotal align=right>"
1801 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1803 map { print "\n$column_data{$_}" } @column_index;
1811 <td><hr size=3 noshade></td>
1815 # multiple invoice edit button only if gotten there via sales_order form.
1817 if ($form->{type} =~ /sales_order/) {
1819 <input type="hidden" name="path" value="$form->{path}">
1820 <input class"submit" type="submit" name="action" value="|
1821 . $locale->text('Continue') . qq|">
1822 <input type="hidden" name="nextsub" value="edit">
1823 <input type="hidden" name="type" value="$form->{type}">
1824 <input type="hidden" name="warehouse" value="$warehouse">
1825 <input type="hidden" name="vc" value="$form->{vc}">
1826 <input type="hidden" name="login" value="$form->{login}">
1827 <input type="hidden" name="password" value="$form->{password}">
1828 <input type="hidden" name="callback" value="$callback">
1829 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1836 <form method=post action=$form->{script}>
1838 <input name=callback type=hidden value="$form->{callback}">
1840 <input type=hidden name=type value=$form->{type}>
1841 <input type=hidden name=vc value=$form->{vc}>
1843 <input type=hidden name=path value=$form->{path}>
1844 <input type=hidden name=login value=$form->{login}>
1845 <input type=hidden name=password value=$form->{password}>
1848 if ($form->{type} !~ /(ship|receive)_order/) {
1850 <input class=submit type=submit name=action value="|
1851 . $locale->text('Add') . qq|">|;
1854 if ($form->{menubar}) {
1855 require "$form->{path}/menu.pl";
1866 $lxdebug->leave_sub();
1870 $lxdebug->enter_sub();
1872 map { $column_data{$_} = "<td> </td>" } @column_index;
1874 $column_data{netamount} =
1875 "<th class=listsubtotal align=right>"
1876 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1878 $column_data{tax} = "<td class=listsubtotal align=right>"
1879 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1882 $column_data{amount} =
1883 "<th class=listsubtotal align=right>"
1884 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1886 $subtotalnetamount = 0;
1887 $subtotalamount = 0;
1890 <tr class=listsubtotal>
1893 map { print "\n$column_data{$_}" } @column_index;
1899 $lxdebug->leave_sub();
1902 sub save_and_close {
1903 $lxdebug->enter_sub();
1905 if ($form->{type} =~ /_order$/) {
1906 $form->isblank("transdate", $locale->text('Order Date missing!'));
1908 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1911 $msg = ucfirst $form->{vc};
1912 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1914 # $locale->text('Customer missing!');
1915 # $locale->text('Vendor missing!');
1917 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1918 if ($form->{currency} ne $form->{defaultcurrency});
1922 # if the name changed get new values
1923 if (&check_name($form->{vc})) {
1928 $form->{id} = 0 if $form->{saveasnew};
1930 # this is for the internal notes section for the [email] Subject
1931 if ($form->{type} =~ /_order$/) {
1932 if ($form->{type} eq 'sales_order') {
1933 $form->{label} = $locale->text('Sales Order');
1935 $numberfld = "sonumber";
1936 $ordnumber = "ordnumber";
1938 $form->{label} = $locale->text('Purchase Order');
1940 $numberfld = "ponumber";
1941 $ordnumber = "ordnumber";
1944 $err = $locale->text('Cannot save order!');
1947 if ($form->{type} eq 'sales_quotation') {
1948 $form->{label} = $locale->text('Quotation');
1950 $numberfld = "sqnumber";
1951 $ordnumber = "quonumber";
1953 $form->{label} = $locale->text('Request for Quotation');
1955 $numberfld = "rfqnumber";
1956 $ordnumber = "quonumber";
1959 $err = $locale->text('Cannot save quotation!');
1963 # get new number in sequence if no number is given or if saveasnew was requested
1964 if (!$form->{$ordnumber} || $form->{saveasnew}) {
1965 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
1971 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1972 if (OE->save(\%myconfig, \%$form));
1975 $lxdebug->leave_sub();
1979 $lxdebug->enter_sub();
1981 if ($form->{type} =~ /_order$/) {
1982 $form->isblank("transdate", $locale->text('Order Date missing!'));
1984 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1987 $msg = ucfirst $form->{vc};
1988 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1990 # $locale->text('Customer missing!');
1991 # $locale->text('Vendor missing!');
1993 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1994 if ($form->{currency} ne $form->{defaultcurrency});
1998 # if the name changed get new values
1999 if (&check_name($form->{vc})) {
2004 $form->{id} = 0 if $form->{saveasnew};
2006 # this is for the internal notes section for the [email] Subject
2007 if ($form->{type} =~ /_order$/) {
2008 if ($form->{type} eq 'sales_order') {
2009 $form->{label} = $locale->text('Sales Order');
2011 $numberfld = "sonumber";
2012 $ordnumber = "ordnumber";
2014 $form->{label} = $locale->text('Purchase Order');
2016 $numberfld = "ponumber";
2017 $ordnumber = "ordnumber";
2020 $err = $locale->text('Cannot save order!');
2023 if ($form->{type} eq 'sales_quotation') {
2024 $form->{label} = $locale->text('Quotation');
2026 $numberfld = "sqnumber";
2027 $ordnumber = "quonumber";
2029 $form->{label} = $locale->text('Request for Quotation');
2031 $numberfld = "rfqnumber";
2032 $ordnumber = "quonumber";
2035 $err = $locale->text('Cannot save quotation!');
2039 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
2040 unless $form->{$ordnumber};
2044 OE->save(\%myconfig, \%$form);
2045 $form->{simple_save} = 1;
2046 if(!$form->{print_and_save}) {
2047 set_headings("edit");
2051 $lxdebug->leave_sub();
2055 $lxdebug->enter_sub();
2059 if ($form->{type} =~ /_order$/) {
2060 $msg = $locale->text('Are you sure you want to delete Order Number');
2061 $ordnumber = 'ordnumber';
2063 $msg = $locale->text('Are you sure you want to delete Quotation Number');
2064 $ordnumber = 'quonumber';
2070 <form method=post action=$form->{script}>
2073 # delete action variable
2074 map { delete $form->{$_} } qw(action header);
2076 foreach $key (keys %$form) {
2077 $form->{$key} =~ s/\"/"/g;
2078 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2082 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
2084 <h4>$msg $form->{$ordnumber}</h4>
2086 <input name=action class=submit type=submit value="|
2087 . $locale->text('Yes') . qq|">
2094 $lxdebug->leave_sub();
2098 $lxdebug->enter_sub();
2100 if ($form->{type} =~ /_order$/) {
2101 $msg = $locale->text('Order deleted!');
2102 $err = $locale->text('Cannot delete order!');
2104 $msg = $locale->text('Quotation deleted!');
2105 $err = $locale->text('Cannot delete quotation!');
2108 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
2111 $lxdebug->leave_sub();
2115 $lxdebug->enter_sub();
2117 if ($form->{type} =~ /_order$/) {
2119 # these checks only apply if the items don't bring their own ordnumbers/transdates.
2120 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
2121 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
2122 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2124 $form->isblank("transdate", $locale->text('Order Date missing!'))
2125 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2128 # also copy deliverydate from the order
2129 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
2131 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
2132 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2133 $form->{ordnumber} = "";
2136 # if the name changed get new values
2137 if (&check_name($form->{vc})) {
2142 $form->{cp_id} *= 1;
2144 if ( $form->{type} =~ /_order/
2145 && $form->{currency} ne $form->{defaultcurrency}) {
2147 # check if we need a new exchangerate
2148 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
2150 $orddate = $form->current_date(\%myconfig);
2152 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
2155 if (!$exchangerate) {
2156 &backorder_exchangerate($orddate, $buysell);
2161 # close orders/quotations
2162 $form->{closed} = 1;
2164 # save order if one ordnumber has been given
2165 # if not it's most likely a collective order, which can't be saved back
2166 # so they just have to be closed
2167 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
2168 OE->close_order(\%myconfig, \%$form);
2170 OE->close_orders(\%myconfig, \%$form);
2173 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
2175 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2178 $form->{closed} = 0;
2179 $form->{rowcount}--;
2180 $form->{shipto} = 1;
2182 if ($form->{type} =~ /_order$/) {
2183 $form->{exchangerate} = $exchangerate;
2187 if ( $form->{type} eq 'purchase_order'
2188 || $form->{type} eq 'request_quotation') {
2189 $form->{title} = $locale->text('Add Vendor Invoice');
2190 $form->{script} = 'ir.pl';
2194 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
2195 $form->{title} = $locale->text('Add Sales Invoice');
2196 $form->{script} = 'is.pl';
2201 # bo creates the id, reset it
2202 map { delete $form->{$_} }
2203 qw(id subject message cc bcc printed emailed queued);
2204 $form->{ $form->{vc} } =~ s/--.*//g;
2205 $form->{type} = "invoice";
2208 $locale = new Locale "$myconfig{countrycode}", "$script";
2210 require "$form->{path}/$form->{script}";
2212 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
2214 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2215 qw(creditlimit creditremaining);
2217 $currency = $form->{currency};
2220 $form->{currency} = $currency;
2221 $form->{exchangerate} = "";
2222 $form->{forex} = "";
2223 $form->{exchangerate} = $exchangerate
2227 $form->check_exchangerate(
2228 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
2231 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
2233 for $i (1 .. $form->{rowcount}) {
2234 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
2235 $form->{"${_}_${i}"})
2236 if ($form->{"${_}_${i}"}) }
2237 qw(ship qty sellprice listprice basefactor));
2243 for $i (1 .. $form->{rowcount}) {
2244 $form->{"discount_$i"} =
2245 $form->format_amount(\%myconfig, $form->{"discount_$i"});
2247 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
2249 $decimalplaces = ($dec > 2) ? $dec : 2;
2251 # copy delivery date from reqdate for order -> invoice conversion
2252 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
2253 unless $form->{"deliverydate_$i"};
2255 $form->{"sellprice_$i"} =
2256 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
2259 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
2260 $dec_qty = length $dec_qty;
2262 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
2264 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2265 qw(partnumber description unit);
2271 $lxdebug->leave_sub();
2274 sub backorder_exchangerate {
2275 $lxdebug->enter_sub();
2276 my ($orddate, $buysell) = @_;
2283 <form method=post action=$form->{script}>
2286 # delete action variable
2287 map { delete $form->{$_} } qw(action header exchangerate);
2289 foreach $key (keys %$form) {
2290 $form->{$key} =~ s/\"/"/g;
2291 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2294 $form->{title} = $locale->text('Add Exchangerate');
2298 <input type=hidden name=path value=$form->{path}>
2299 <input type=hidden name=login value=$form->{login}>
2300 <input type=hidden name=password value=$form->{password}>
2302 <input type=hidden name=exchangeratedate value=$orddate>
2303 <input type=hidden name=buysell value=$buysell>
2306 <tr><th class=listtop>$form->{title}</th></tr>
2307 <tr height="5"></tr>
2312 <th align=right>| . $locale->text('Currency') . qq|</th>
2313 <td>$form->{currency}</td>
2316 <th align=right>| . $locale->text('Date') . qq|</th>
2320 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2321 <td><input name=exchangerate size=11></td>
2331 <input type=hidden name=nextsub value=save_exchangerate>
2333 <input name=action class=submit type=submit value="|
2334 . $locale->text('Continue') . qq|">
2342 $lxdebug->leave_sub();
2345 sub save_exchangerate {
2346 $lxdebug->enter_sub();
2348 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2349 $form->{exchangerate} =
2350 $form->parse_amount(\%myconfig, $form->{exchangerate});
2351 $form->save_exchangerate(\%myconfig, $form->{currency},
2352 $form->{exchangeratedate},
2353 $form->{exchangerate}, $form->{buysell});
2357 $lxdebug->leave_sub();
2360 sub create_backorder {
2361 $lxdebug->enter_sub();
2363 $form->{shipped} = 1;
2365 # figure out if we need to create a backorder
2366 # items aren't saved if qty != 0
2368 for $i (1 .. $form->{rowcount}) {
2369 $totalqty += $qty = $form->{"qty_$i"};
2370 $totalship += $ship = $form->{"ship_$i"};
2372 $form->{"qty_$i"} = $qty - $ship;
2375 if ($totalship == 0) {
2376 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2377 $form->{ordtotal} = 0;
2378 $form->{shipped} = 0;
2382 if ($totalqty == $totalship) {
2383 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2384 $form->{ordtotal} = 0;
2389 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2392 for $i (1 .. $form->{rowcount}) {
2394 $form->{"${_}_$i"} =
2395 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2396 } qw(sellprice discount);
2401 OE->save(\%myconfig, \%$form);
2403 # rebuild rows for invoice
2407 for $i (1 .. $form->{rowcount}) {
2408 $form->{"qty_$i"} = $form->{"ship_$i"};
2410 if ($form->{"qty_$i"}) {
2413 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2418 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2419 $form->{rowcount} = $count;
2421 $lxdebug->leave_sub();
2425 $lxdebug->enter_sub();
2427 $form->{saveasnew} = 1;
2428 $form->{closed} = 0;
2429 map { delete $form->{$_} } qw(printed emailed queued ordnumber quonumber);
2433 $lxdebug->leave_sub();
2436 sub purchase_order {
2437 $lxdebug->enter_sub();
2439 if ( $form->{type} eq 'sales_quotation'
2440 || $form->{type} eq 'request_quotation') {
2441 $form->{closed} = 1;
2443 OE->save(\%myconfig, \%$form);
2446 $form->{cp_id} *= 1;
2448 $form->{title} = $locale->text('Add Purchase Order');
2449 $form->{vc} = "vendor";
2450 $form->{type} = "purchase_order";
2454 $lxdebug->leave_sub();
2458 $lxdebug->enter_sub();
2460 if ( $form->{type} eq 'sales_quotation'
2461 || $form->{type} eq 'request_quotation') {
2462 OE->close_order(\%myconfig, $form);
2465 $form->{cp_id} *= 1;
2467 $form->{title} = $locale->text('Add Sales Order');
2468 $form->{vc} = "customer";
2469 $form->{type} = "sales_order";
2473 $lxdebug->leave_sub();
2477 $lxdebug->enter_sub();
2479 $form->{transdate} = $form->current_date(\%myconfig);
2480 delete $form->{duedate};
2482 $form->{closed} = 0;
2485 map { delete $form->{$_} }
2486 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2488 for $i (1 .. $form->{rowcount}) {
2489 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
2490 $form->{"${_}_${i}"})
2491 if ($form->{"${_}_${i}"}) }
2492 qw(ship qty sellprice listprice basefactor));
2500 for $i (1 .. $form->{rowcount} - 1) {
2501 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2502 qw(partnumber description unit);
2505 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2506 qw(creditlimit creditremaining);
2510 $lxdebug->leave_sub();
2514 $lxdebug->enter_sub();
2520 OE->get_warehouses(\%myconfig, \%$form);
2523 if (@{ $form->{all_warehouses} }) {
2524 $form->{selectwarehouse} = "<option>\n";
2526 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2527 (@{ $form->{all_warehouses} });
2529 if ($form->{warehouse}) {
2530 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2534 $form->{shippingdate} = $form->current_date(\%myconfig);
2535 $form->{"$form->{vc}"} =~ s/--.*//;
2540 foreach $key (keys %$form) {
2541 if ($key =~ /_1$/) {
2547 for $i (1 .. $form->{rowcount}) {
2549 # undo formatting from prepare_order
2551 $form->{"${_}_$i"} =
2552 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2554 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2556 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2557 $form->{"ship_$i"} = "";
2558 $form->{"serialnumber_$i"} = "";
2563 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2568 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2569 $form->{rowcount} = $count;
2571 &display_ship_receive;
2573 $lxdebug->leave_sub();
2576 sub display_ship_receive {
2577 $lxdebug->enter_sub();
2579 $vclabel = ucfirst $form->{vc};
2580 $vclabel = $locale->text($vclabel);
2582 $form->{rowcount}++;
2584 if ($form->{vc} eq 'customer') {
2585 $form->{title} = $locale->text('Ship Merchandise');
2586 $shipped = $locale->text('Shipping Date');
2588 $form->{title} = $locale->text('Receive Merchandise');
2589 $shipped = $locale->text('Date Received');
2592 # set option selected
2593 foreach $item (warehouse, employee) {
2594 $form->{"select$item"} =~ s/ selected//;
2595 $form->{"select$item"} =~
2596 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2601 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2602 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2603 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2605 | if $form->{selectwarehouse};
2609 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2610 <td><select name=employee>$form->{selectemployee}</select></td>
2611 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2620 <form method=post action=$form->{script}>
2622 <input type=hidden name=id value=$form->{id}>
2624 <input type=hidden name=display_form value=display_ship_receive>
2626 <input type=hidden name=type value=$form->{type}>
2627 <input type=hidden name=media value=$form->{media}>
2628 <input type=hidden name=format value=$form->{format}>
2630 <input type=hidden name=queued value="$form->{queued}">
2631 <input type=hidden name=printed value="$form->{printed}">
2632 <input type=hidden name=emailed value="$form->{emailed}">
2634 <input type=hidden name=vc value=$form->{vc}>
2638 <th class=listtop>$form->{title}</th>
2640 <tr height="5"></tr>
2643 <table width="100%">
2648 <th align=right>$vclabel</th>
2649 <td colspan=3>$form->{$form->{vc}}</td>
2650 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2651 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2655 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2657 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2660 <th align=right>| . $locale->text('Ship via') . qq|</th>
2662 <input name=shipvia size=35 value="$form->{shipvia}">
2671 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2672 <td>$form->{ordnumber}</td>
2673 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2676 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2677 <td>$form->{transdate}</td>
2678 <input type=hidden name=transdate value=$form->{transdate}>
2681 <th align=right nowrap>$shipped</th>
2682 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2691 <!-- shipto are in hidden variables -->
2693 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2694 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2695 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2696 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2697 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2698 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2699 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2700 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2701 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2702 <input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
2703 <input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
2705 <!-- email variables -->
2706 <input type=hidden name=message value="$form->{message}">
2707 <input type=hidden name=email value="$form->{email}">
2708 <input type=hidden name=subject value="$form->{subject}">
2709 <input type=hidden name=cc value="$form->{cc}">
2710 <input type=hidden name=bcc value="$form->{bcc}">
2715 (partnumber, description, qty, ship, unit, bin, serialnumber);
2717 if ($form->{type} eq "ship_order") {
2718 $column_data{ship} =
2719 qq|<th class=listheading align=center width="auto">|
2720 . $locale->text('Ship')
2723 if ($form->{type} eq "receive_order") {
2724 $column_data{ship} =
2725 qq|<th class=listheading align=center width="auto">|
2726 . $locale->text('Recd')
2730 my $colspan = $#column_index + 1;
2732 $column_data{partnumber} =
2733 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2734 $column_data{description} =
2735 qq|<th class=listheading nowrap>|
2736 . $locale->text('Description')
2739 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2740 $column_data{unit} =
2741 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2743 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2744 $column_data{serialnumber} =
2745 qq|<th class=listheading nowrap>|
2746 . $locale->text('Serial No.')
2753 <tr class=listheading>|;
2755 map { print "\n$column_data{$_}" } @column_index;
2761 for $i (1 .. $form->{rowcount} - 1) {
2764 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2766 # convert " to "
2767 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2768 qw(partnumber description unit bin serialnumber);
2770 $description = $form->{"description_$i"};
2771 $description =~ s/\n/<br>/g;
2773 $column_data{partnumber} =
2774 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2775 $column_data{description} =
2776 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2778 qq|<td align=right>|
2779 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2780 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2781 $column_data{ship} =
2782 qq|<td align=right><input name="ship_$i" size=5 value=|
2783 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2785 $column_data{unit} =
2786 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2788 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2790 $column_data{serialnumber} =
2791 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2796 map { print "\n$column_data{$_}" } @column_index;
2801 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2802 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2803 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2804 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2815 <td><hr size=3 noshade></td>
2821 $form->{copies} = 1;
2830 <input class=submit type=submit name=action value="|
2831 . $locale->text('Update') . qq|">
2832 <input class=submit type=submit name=action value="|
2833 . $locale->text('Print') . qq|">
2836 if ($form->{type} eq 'ship_order') {
2838 <input class=submit type=submit name=action value="|
2839 . $locale->text('Ship to') . qq|">
2840 <input class=submit type=submit name=action value="|
2841 . $locale->text('E-mail') . qq|">
2847 <input class=submit type=submit name=action value="|
2848 . $locale->text('Done') . qq|">
2851 if ($form->{menubar}) {
2852 require "$form->{path}/menu.pl";
2858 <input type=hidden name=rowcount value=$form->{rowcount}>
2860 <input name=callback type=hidden value="$callback">
2862 <input type=hidden name=path value=$form->{path}>
2863 <input type=hidden name=login value=$form->{login}>
2864 <input type=hidden name=password value=$form->{password}>
2872 $lxdebug->leave_sub();
2876 $lxdebug->enter_sub();
2878 if ($form->{type} eq 'ship_order') {
2879 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2881 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2886 $total += $form->{"ship_$_"} =
2887 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2888 } (1 .. $form->{rowcount} - 1);
2890 $form->error($locale->text('Nothing entered!')) unless $total;
2892 $form->redirect($locale->text('Inventory saved!'))
2893 if OE->save_inventory(\%myconfig, \%$form);
2894 $form->error($locale->text('Could not save!'));
2896 $lxdebug->leave_sub();
2899 sub search_transfer {
2900 $lxdebug->enter_sub();
2902 OE->get_warehouses(\%myconfig, \%$form);
2905 if (@{ $form->{all_warehouses} }) {
2906 $form->{selectwarehouse} = "<option>\n";
2907 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2909 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2910 (@{ $form->{all_warehouses} });
2912 $form->error($locale->text('Nothing to transfer!'));
2915 $form->{title} = $locale->text('Transfer Inventory');
2922 <form method=post action=$form->{script}>
2926 <th class=listtop>$form->{title}</th>
2928 <tr height="5"></tr>
2933 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2934 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2937 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2938 <td><input name=partnumber size=20></td>
2941 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2942 <td><input name=description size=40></td>
2945 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2946 <td><input name=partsgroup size=20></td>
2952 <td><hr size=3 noshade></td>
2957 <input type=hidden name=sort value=partnumber>
2958 <input type=hidden name=nextsub value=list_transfer>
2960 <input type=hidden name=path value=$form->{path}>
2961 <input type=hidden name=login value=$form->{login}>
2962 <input type=hidden name=password value=$form->{password}>
2964 <input class=submit type=submit name=action value="|
2965 . $locale->text('Continue') . qq|">
2972 $lxdebug->leave_sub();
2976 $lxdebug->enter_sub();
2978 OE->get_inventory(\%myconfig, \%$form);
2980 $partnumber = $form->escape($form->{partnumber});
2981 $warehouse = $form->escape($form->{warehouse});
2982 $description = $form->escape($form->{description});
2983 $partsgroup = $form->escape($form->{partsgroup});
2987 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2989 # construct callback
2990 $partnumber = $form->escape($form->{partnumber}, 1);
2991 $warehouse = $form->escape($form->{warehouse}, 1);
2992 $description = $form->escape($form->{description}, 1);
2993 $partsgroup = $form->escape($form->{partsgroup}, 1);
2996 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2999 $form->sort_columns(
3000 qw(partnumber description partsgroup make model warehouse qty transfer));
3002 $column_header{partnumber} =
3003 qq|<th><a class=listheading href=$href&sort=partnumber>|
3004 . $locale->text('Part Number')
3006 $column_header{description} =
3007 qq|<th><a class=listheading href=$href&sort=description>|
3008 . $locale->text('Description')
3010 $column_header{partsgroup} =
3011 qq|<th><a class=listheading href=$href&sort=partsgroup>|
3012 . $locale->text('Group')
3014 $column_header{warehouse} =
3015 qq|<th><a class=listheading href=$href&sort=warehouse>|
3016 . $locale->text('From')
3018 $column_header{qty} =
3019 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
3020 $column_header{transfer} =
3021 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
3023 $option = $locale->text('Transfer to');
3025 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
3027 if ($form->{warehouse}) {
3028 $option .= " : $warehouse";
3030 if ($form->{partnumber}) {
3031 $option .= "\n<br>" if ($option);
3032 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
3034 if ($form->{description}) {
3035 $option .= "\n<br>" if ($option);
3036 $option .= $locale->text('Description') . " : $form->{description}";
3038 if ($form->{partsgroup}) {
3039 $option .= "\n<br>" if ($option);
3040 $option .= $locale->text('Group') . " : $form->{partsgroup}";
3043 $form->{title} = $locale->text('Transfer Inventory');
3050 <form method=post action=$form->{script}>
3052 <input type=hidden name=warehouse_id value=$warehouse_id>
3056 <th class=listtop>$form->{title}</th>
3058 <tr height="5"></tr>
3065 <tr class=listheading>|;
3067 map { print "\n$column_header{$_}" } @column_index;
3073 if (@{ $form->{all_inventory} }) {
3074 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
3078 foreach $ref (@{ $form->{all_inventory} }) {
3082 $column_data{partnumber} =
3083 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
3084 $column_data{description} = "<td>$ref->{description} </td>";
3085 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
3086 $column_data{warehouse} =
3087 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
3089 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
3090 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
3092 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
3097 <tr class=listrow$j>";
3099 map { print "\n$column_data{$_}" } @column_index;
3113 <td><hr size=3 noshade></td>
3119 <input name=callback type=hidden value="$callback">
3121 <input type=hidden name=rowcount value=$i>
3123 <input type=hidden name=path value=$form->{path}>
3124 <input type=hidden name=login value=$form->{login}>
3125 <input type=hidden name=password value=$form->{password}>
3127 <input class=submit type=submit name=action value="|
3128 . $locale->text('Transfer') . qq|">|;
3130 if ($form->{menubar}) {
3131 require "$form->{path}/menu.pl";
3142 $lxdebug->leave_sub();
3146 $lxdebug->enter_sub();
3148 $form->redirect($locale->text('Inventory transferred!'))
3149 if OE->transfer(\%myconfig, \%$form);
3150 $form->error($locale->text('Could not transfer Inventory!'));
3152 $lxdebug->leave_sub();