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};
291 map { $form->{$_} =~ s/\"/"/g }
292 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
294 foreach $ref (@{ $form->{form_details} }) {
295 $form->{rowcount} = ++$i;
297 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
299 for my $i (1 .. $form->{rowcount}) {
301 $form->{"discount_$i"} =
302 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
304 $form->{"discount_$i"} =
305 $form->format_amount(\%myconfig, $form->{"discount_$i"});
307 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
309 $decimalplaces = ($dec > 2) ? $dec : 2;
311 # copy reqdate from deliverydate for invoice -> order conversion
312 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
313 unless $form->{"reqdate_$i"};
315 $form->{"sellprice_$i"} =
316 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
319 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
320 $dec_qty = length $dec_qty;
322 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
324 map { $form->{"${_}_$i"} =~ s/\"/"/g }
325 qw(partnumber description unit);
328 $lxdebug->leave_sub();
332 $lxdebug->enter_sub();
334 $checkedopen = ($form->{closed}) ? "" : "checked";
335 $checkedclosed = ($form->{closed}) ? "checked" : "";
337 # use JavaScript Calendar or not
338 $form->{jsscript} = $form->{jscalendar};
341 $payment = qq|<option value=""></option>|;
342 foreach $item (@{ $form->{payment_terms} }) {
343 if ($form->{payment_id} eq $item->{id}) {
344 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
346 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
349 if ($form->{jsscript}) {
351 # with JavaScript Calendar
353 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
354 <td><input type=button name=transdate id="trigger1" value=|
355 . $locale->text('button') . qq|></td>
358 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
359 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
360 . $locale->text('button') . qq|></td>
365 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
366 "reqdate", "BL", "trigger2");
370 # without JavaScript Calendar
372 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
374 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
380 <td colspan=2 align=center>
383 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
384 . $locale->text('Open') . qq|</th>
385 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
386 . $locale->text('Closed') . qq|</th>
394 # set option selected
395 foreach $item ($form->{vc}, currency, department, employee) {
396 $form->{"select$item"} =~ s/ selected//;
397 $form->{"select$item"} =~
398 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
401 #quote select[customer|vendor] Bug 133
402 $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
405 if ($form->{all_contacts}) {
407 $form->{selectcontact} = "<option></option>";
408 foreach $item (@{ $form->{all_contacts} }) {
409 my $department = ($item->{cp_abteilung}) ? "--$item->{cp_abteilung}" : "";
410 if ($form->{cp_id} == $item->{cp_id}) {
411 $form->{selectcontact} .=
412 "<option value=$item->{cp_id} selected>$item->{cp_name}$department</option>";
414 $form->{selectcontact} .= "<option value=$item->{cp_id}>$item->{cp_name}$department</option>";
418 $form->{selectcontact} =~ s/ selected//g;
419 if ($form->{cp_id} ne "") {
420 $form->{selectcontact} =~ s/value=$form->{cp_id}/value=$form->{cp_id} selected/;
425 if (@{ $form->{SHIPTO} }) {
426 $form->{selectshipto} = "<option value=0></option>";
427 foreach $item (@{ $form->{SHIPTO} }) {
428 if ($item->{shipto_id} == $form->{shipto_id}) {
429 $form->{selectshipto} .=
430 "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}</option>";
432 $form->{selectshipto} .=
433 "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment_1}</option>";
438 $form->{selectshipto} =~ s/ selected//g;
439 if ($form->{shipto_id} ne "") {
440 $form->{selectshipto} =~ s/value=$form->{shipto_id}/value=$form->{shipto_id} selected/;
445 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
446 <td><select name=shipto_id>$form->{selectshipto}</select></td>
447 <input type=hidden name=selectshipto value="$form->{selectshipto}">|;
452 $form->{exchangerate} =
453 $form->format_amount(\%myconfig, $form->{exchangerate});
455 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
461 $form->{creditlimit} =
462 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
463 $form->{creditremaining} =
464 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
467 ($form->{selectcontact})
468 ? qq|<select name=cp_id>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
469 : qq|<input name=contact value="$form->{contact}" size=35>|;
472 <input type=hidden name=forex value=$form->{forex}>
475 if ($form->{currency} ne $form->{defaultcurrency}) {
476 if ($form->{forex}) {
479 . $locale->text('Exchangerate')
480 . qq|</th><td>$form->{exchangerate}</td>
481 <input type=hidden name=exchangerate value=$form->{exchangerate}>
486 . $locale->text('Exchangerate')
487 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
491 $vclabel = ucfirst $form->{vc};
492 $vclabel = $locale->text($vclabel);
496 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
497 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
498 . $locale->text('days') . qq|</td>
502 if ($form->{business}) {
505 <th align=right>| . $locale->text('Business') . qq|</th>
506 <td>$form->{business}</td>
507 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
509 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
515 if ($form->{max_dunning_level}) {
521 <th align=right>| . $locale->text('Max. Dunning Level') . qq|:</th>
522 <td><b>$form->{max_dunning_level}</b></td>
523 <th align=right>| . $locale->text('Dunning Amount') . qq|:</th>
525 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
534 if (@{ $form->{TAXZONE} }) {
535 $form->{selecttaxzone} = "";
536 foreach $item (@{ $form->{TAXZONE} }) {
537 if ($item->{id} == $form->{taxzone_id}) {
538 $form->{selecttaxzone} .=
539 "<option value=$item->{id} selected>$item->{description}</option>";
541 $form->{selecttaxzone} .=
542 "<option value=$item->{id}>$item->{description}</option>";
547 $form->{selecttaxzone} =~ s/ selected//g;
548 if ($form->{taxzone_id} ne "") {
549 $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/;
553 if ($form->{rowcount} >0) {
554 $form->{selecttaxzone} =~ /<option value=\d+ selected>.*?<\/option>/;
555 $form->{selecttaxzone} = $&;
561 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
562 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
563 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
567 if ($form->{type} !~ /_quotation$/) {
570 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
571 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
574 <th width=70% align=right nowrap>|
575 . $locale->text('Quotation Number') . qq|</th>
576 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
579 <th width=70% align=right nowrap>|
580 . $locale->text('Customer Order Number') . qq|</th>
581 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
584 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
589 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
594 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
596 $creditremaining = qq|
602 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
603 <td>$form->{creditlimit}</td>
605 <th nowrap>| . $locale->text('Remaining') . qq|</th>
606 <td class="plus$n">$form->{creditremaining}</td>
615 ($form->{type} eq 'sales_quotation')
616 ? $locale->text('Valid until')
617 : $locale->text('Required by');
618 if ($form->{type} eq 'sales_quotation') {
621 <th width=70% align=right nowrap>|
622 . $locale->text('Quotation Number') . qq|</th>
623 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
624 <input type=hidden name=ordnumber value="$form->{ordnumber}">
630 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
631 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
632 <input type=hidden name=ordnumber value="$form->{ordnumber}">
641 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
645 <th align=right nowrap=true>$reqlabel</th>
649 $creditremaining = qq| <tr>
656 ($form->{"select$form->{vc}"})
657 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
658 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
662 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
663 <td colspan=3><select name=department>$form->{selectdepartment}</select>
664 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
667 | if $form->{selectdepartment};
670 <input type=hidden name=employee value="$form->{employee}">
673 if ($form->{type} eq 'sales_order') {
674 if ($form->{selectemployee}) {
676 <input type=hidden name=customer_klass value=$form->{customer_klass}>
678 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
679 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
680 <input type=hidden name=selectemployee value="$form->{selectemployee}">
687 <input type=hidden name=customer_klass value=$form->{customer_klass}>
689 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
690 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
691 <input type=hidden name=selectemployee value="$form->{selectemployee}">
696 if ($form->{resubmit} && ($form->{format} eq "html")) {
698 qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
699 } elsif ($form->{resubmit}) {
700 $onload = qq|document.oe.submit()|;
705 $credittext = $locale->text('Credit Limit exceeded!!!');
706 if ($creditwarning) {
707 $onload = qq|alert('$credittext')|;
713 <body onLoad="$onload">
715 <form method=post name=oe action=$form->{script}>
716 <script type="text/javascript" src="js/common.js"></script>
717 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
718 <script type="text/javascript" src="js/vendor_selection.js"></script>
719 <script type="text/javascript" src="js/calculate_qty.js"></script>
721 <input type=hidden name=id value=$form->{id}>
722 <input type=hidden name=action value=$form->{action}>
724 <input type=hidden name=type value=$form->{type}>
725 <input type=hidden name=formname value=$form->{formname}>
726 <input type=hidden name=media value=$form->{media}>
727 <input type=hidden name=format value=$form->{format}>
728 <input type=hidden name=proforma value=$form->{proforma}>
730 <input type=hidden name=queued value="$form->{queued}">
731 <input type=hidden name=printed value="$form->{printed}">
732 <input type=hidden name=emailed value="$form->{emailed}">
734 <input type=hidden name=vc value=$form->{vc}>
736 <input type=hidden name=title value="$form->{title}">
738 <input type=hidden name=discount value=$form->{discount}>
739 <input type=hidden name=creditlimit value=$form->{creditlimit}>
740 <input type=hidden name=creditremaining value=$form->{creditremaining}>
742 <input type=hidden name=tradediscount value=$form->{tradediscount}>
743 <input type=hidden name=business value=$form->{business}>
744 <input type=hidden name=webdav value=$webdav>
748 <th class=listtop>$form->{title}</th>
758 <th align=right>$vclabel</th>
759 <td colspan=3>$vc</td>
760 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
761 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
762 <th align=richt nowrap>|
763 . $locale->text('Contact Person') . qq|</th>
764 <td colspan=3>$contact</td>
772 <th align=right>| . $locale->text('Currency') . qq|</th>
773 <td><select name=currency>$form->{selectcurrency}</select></td>
774 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
775 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
779 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
780 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
783 <th align=right>| . $locale->text('Ship via') . qq|</th>
784 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
791 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
793 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
794 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
798 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
800 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
801 # <input size=45 id=vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
823 <!-- shipto are in hidden variables -->
825 <input type=hidden name=shiptoname value="$form->{shiptoname}">
826 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
827 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
828 <input type=hidden name=shiptocity value="$form->{shiptocity}">
829 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
830 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
831 <input type=hidden name=shiptophone value="$form->{shiptophone}">
832 <input type=hidden name=shiptofax value="$form->{shiptofax}">
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('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 $form->{"selected_unit_$i"} = $form->{"unit_$i"};
1173 if ( $form->{type} eq 'purchase_order'
1174 || $form->{type} eq 'request_quotation') {
1175 IR->retrieve_item(\%myconfig, \%$form);
1177 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1178 IS->retrieve_item(\%myconfig, \%$form);
1181 my $rows = scalar @{ $form->{item_list} };
1183 $form->{"discount_$i"} =
1184 $form->format_amount(\%myconfig, $form->{discount} * 100);
1187 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1196 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1197 if ($form->{"not_discountable_$i"}) {
1198 $form->{"discount_$i"} = 0;
1200 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1201 qw(partnumber description unit);
1202 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1203 keys %{ $form->{item_list}[0] };
1204 if ($form->{"part_payment_id_$i"} ne "") {
1205 $form->{payment_id} = $form->{"part_payment_id_$i"};
1208 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1210 ($dec) = ($s =~ /\.(\d+)/);
1212 $decimalplaces = ($dec > 2) ? $dec : 2;
1215 $form->{"sellprice_$i"} = $sellprice;
1218 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1220 # if there is an exchange rate adjust sellprice
1221 $form->{"sellprice_$i"} /= $exchangerate;
1225 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1226 (1 - $form->{"discount_$i"} / 100);
1227 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1228 map { $form->{"${_}_base"} += $amount }
1229 (split / /, $form->{"taxaccounts_$i"});
1230 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1231 split / /, $form->{taxaccounts}
1232 if !$form->{taxincluded};
1234 $form->{creditremaining} -= $amount;
1236 $form->{"sellprice_$i"} =
1237 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1240 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1242 # get pricegroups for parts
1243 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1245 # build up html code for prices_$i
1246 &set_pricegroup($i);
1253 # ok, so this is a new part
1254 # ask if it is a part or service item
1256 if ( $form->{"partsgroup_$i"}
1257 && ($form->{"partsnumber_$i"} eq "")
1258 && ($form->{"description_$i"} eq "")) {
1259 $form->{rowcount}--;
1260 $form->{"discount_$i"} = "";
1264 $form->{"id_$i"} = 0;
1265 $form->{"unit_$i"} = $locale->text('ea');
1273 $lxdebug->leave_sub();
1277 $lxdebug->enter_sub();
1279 if ($form->{type} eq 'purchase_order') {
1280 $form->{title} = $locale->text('Purchase Orders');
1281 $form->{vc} = 'vendor';
1282 $ordlabel = $locale->text('Order Number');
1283 $ordnumber = 'ordnumber';
1284 $employee = $locale->text('Employee');
1286 if ($form->{type} eq 'request_quotation') {
1287 $form->{title} = $locale->text('Request for Quotations');
1288 $form->{vc} = 'vendor';
1289 $ordlabel = $locale->text('RFQ Number');
1290 $ordnumber = 'quonumber';
1291 $employee = $locale->text('Employee');
1293 if ($form->{type} eq 'receive_order') {
1294 $form->{title} = $locale->text('Receive Merchandise');
1295 $form->{vc} = 'vendor';
1296 $ordlabel = $locale->text('Order Number');
1297 $ordnumber = 'ordnumber';
1298 $employee = $locale->text('Employee');
1300 if ($form->{type} eq 'sales_order') {
1301 $form->{title} = $locale->text('Sales Orders');
1302 $form->{vc} = 'customer';
1303 $ordlabel = $locale->text('Order Number');
1304 $ordnumber = 'ordnumber';
1305 $employee = $locale->text('Salesperson');
1307 if ($form->{type} eq 'ship_order') {
1308 $form->{title} = $locale->text('Ship Merchandise');
1309 $form->{vc} = 'customer';
1310 $ordlabel = $locale->text('Order Number');
1311 $ordnumber = 'ordnumber';
1312 $employee = $locale->text('Salesperson');
1316 if ($form->{type} eq 'sales_quotation') {
1317 $form->{title} = $locale->text('Quotations');
1318 $form->{vc} = 'customer';
1319 $ordlabel = $locale->text('Quotation Number');
1320 $ordnumber = 'quonumber';
1321 $employee = $locale->text('Employee');
1324 if ($form->{type} =~ /(ship|receive)_order/) {
1325 OE->get_warehouses(\%myconfig, \%$form);
1328 if (@{ $form->{all_warehouses} }) {
1329 $form->{selectwarehouse} = "<option>\n";
1330 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1333 $form->{selectwarehouse} .=
1334 "<option>$_->{description}--$_->{id}\n"
1335 } (@{ $form->{all_warehouses} });
1339 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1340 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1341 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1348 # setup vendor / customer selection
1349 $form->all_vc(\%myconfig, $form->{vc},
1350 ($form->{vc} eq 'customer') ? "AR" : "AP");
1352 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1353 @{ $form->{"all_$form->{vc}"} };
1355 $vclabel = ucfirst $form->{vc};
1356 $vclabel = $locale->text($vclabel);
1358 # $locale->text('Vendor')
1359 # $locale->text('Customer')
1363 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1364 : qq|<input name=$form->{vc} size=35>|;
1367 if (@{ $form->{all_departments} }) {
1368 $form->{selectdepartment} = "<option>\n";
1371 $form->{selectdepartment} .=
1372 "<option>$_->{description}--$_->{id}\n"
1373 } (@{ $form->{all_departments} });
1378 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1379 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1381 | if $form->{selectdepartment};
1383 if ($form->{type} !~ /(ship_order|receive_order)/) {
1386 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1387 . $locale->text('Open') . qq|</td>
1388 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1389 . $locale->text('Closed') . qq|</td>
1395 <input type=hidden name="open" value=1>
1399 # use JavaScript Calendar or not
1400 $form->{jsscript} = $jscalendar;
1402 if ($form->{jsscript}) {
1404 # with JavaScript Calendar
1406 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1407 <input type=button name=transdatefrom id="trigger3" value=|
1408 . $locale->text('button') . qq|></td>
1411 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1412 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1413 . $locale->text('button') . qq|></td>
1418 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1419 "transdateto", "BL", "trigger4");
1422 # without JavaScript Calendar
1424 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1426 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1434 <form method=post action=$form->{script}>
1438 <th class=listtop>$form->{title}</th>
1440 <tr height="5"></tr>
1445 <th align=right>$vclabel</th>
1446 <td colspan=3>$vc</td>
1451 <th align=right>$ordlabel</th>
1452 <td colspan=3><input name="$ordnumber" size=20></td>
1455 <th align=right>| . $locale->text('From') . qq|</th>
1457 <th align=right>| . $locale->text('Bis') . qq|</th>
1460 <input type=hidden name=sort value=transdate>
1462 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1467 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1468 | . $locale->text('ID') . qq|</td>
1469 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1470 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1471 . $locale->text('Date') . qq|</td>
1472 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1473 . $locale->text('Required by') . qq|</td>
1476 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1477 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1478 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1479 . $locale->text('Ship via') . qq|</td>
1482 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1483 . $locale->text('Amount') . qq|</td>
1484 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1485 . $locale->text('Tax') . qq|</td>
1486 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1487 . $locale->text('Total') . qq|</td>
1490 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1491 . $locale->text('Subtotal') . qq|</td>
1499 <tr><td colspan=4><hr size=3 noshade></td></tr>
1505 <input type=hidden name=nextsub value=orders>
1506 <input type=hidden name=path value=$form->{path}>
1507 <input type=hidden name=login value=$form->{login}>
1508 <input type=hidden name=password value=$form->{password}>
1509 <input type=hidden name=vc value=$form->{vc}>
1510 <input type=hidden name=type value=$form->{type}>
1512 <input class=submit type=submit name=action value="|
1513 . $locale->text('Continue') . qq|">
1520 $lxdebug->leave_sub();
1524 $lxdebug->enter_sub();
1526 # split vendor / customer
1527 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1528 split(/--/, $form->{ $form->{vc} });
1530 OE->transactions(\%myconfig, \%$form);
1532 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1534 $number = $form->escape($form->{$ordnumber});
1535 $name = $form->escape($form->{ $form->{vc} });
1536 $department = $form->escape($form->{department});
1537 $warehouse = $form->escape($form->{warehouse});
1541 "$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";
1543 # construct callback
1544 $number = $form->escape($form->{$ordnumber}, 1);
1545 $name = $form->escape($form->{ $form->{vc} }, 1);
1546 $department = $form->escape($form->{department}, 1);
1547 $warehouse = $form->escape($form->{warehouse}, 1);
1550 "$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";
1553 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1554 "name", "netamount", "tax", "amount",
1555 "curr", "employee", "shipvia", "open",
1558 $form->{l_open} = $form->{l_closed} = "Y"
1559 if ($form->{open} && $form->{closed});
1561 foreach $item (@columns) {
1562 if ($form->{"l_$item"} eq "Y") {
1563 push @column_index, $item;
1565 # add column to href and callback
1566 $callback .= "&l_$item=Y";
1567 $href .= "&l_$item=Y";
1571 # only show checkboxes if gotten here via sales_order form.
1572 if ($form->{type} =~ /sales_order/) {
1573 unshift @column_index, "ids";
1576 if ($form->{l_subtotal} eq 'Y') {
1577 $callback .= "&l_subtotal=Y";
1578 $href .= "&l_subtotal=Y";
1581 if ($form->{vc} eq 'vendor') {
1582 if ($form->{type} eq 'receive_order') {
1583 $form->{title} = $locale->text('Receive Merchandise');
1584 } elsif ($form->{type} eq 'purchase_order') {
1585 $form->{title} = $locale->text('Purchase Orders');
1587 $form->{title} = $locale->text('Request for Quotations');
1589 $name = $locale->text('Vendor');
1590 $employee = $locale->text('Employee');
1592 if ($form->{vc} eq 'customer') {
1593 if ($form->{type} eq 'sales_order') {
1594 $form->{title} = $locale->text('Sales Orders');
1595 $employee = $locale->text('Salesperson');
1596 } elsif ($form->{type} eq 'ship_order') {
1597 $form->{title} = $locale->text('Ship Merchandise');
1598 $employee = $locale->text('Salesperson');
1600 $form->{title} = $locale->text('Quotations');
1601 $employee = $locale->text('Employee');
1603 $name = $locale->text('Customer');
1606 $column_header{id} =
1607 qq|<th><a class=listheading href=$href&sort=id>|
1608 . $locale->text('ID')
1610 $column_header{transdate} =
1611 qq|<th><a class=listheading href=$href&sort=transdate>|
1612 . $locale->text('Date')
1614 $column_header{reqdate} =
1615 qq|<th><a class=listheading href=$href&sort=reqdate>|
1616 . $locale->text('Required by')
1618 $column_header{ordnumber} =
1619 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1620 . $locale->text('Order')
1622 $column_header{quonumber} =
1623 qq|<th><a class=listheading href=$href&sort=quonumber>|
1624 . $locale->text('Quotation')
1626 $column_header{name} =
1627 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1628 $column_header{netamount} =
1629 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1630 $column_header{tax} =
1631 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1632 $column_header{amount} =
1633 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1634 $column_header{curr} =
1635 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1636 $column_header{shipvia} =
1637 qq|<th><a class=listheading href=$href&sort=shipvia>|
1638 . $locale->text('Ship via')
1640 $column_header{open} =
1641 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1642 $column_header{closed} =
1643 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1645 $column_header{employee} =
1646 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1648 $column_header{ids} = qq|<th></th>|;
1650 if ($form->{ $form->{vc} }) {
1651 $option = $locale->text(ucfirst $form->{vc});
1652 $option .= " : $form->{$form->{vc}}";
1654 if ($form->{warehouse}) {
1655 ($warehouse) = split /--/, $form->{warehouse};
1656 $option .= "\n<br>" if ($option);
1657 $option .= $locale->text('Warehouse');
1658 $option .= " : $warehouse";
1660 if ($form->{department}) {
1661 $option .= "\n<br>" if ($option);
1662 ($department) = split /--/, $form->{department};
1663 $option .= $locale->text('Department') . " : $department";
1665 if ($form->{transdatefrom}) {
1667 . $locale->text('From') . " "
1668 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1670 if ($form->{transdateto}) {
1672 . $locale->text('Bis') . " "
1673 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1675 if ($form->{open}) {
1676 $option .= "\n<br>" if ($option);
1677 $option .= $locale->text('Open');
1679 if ($form->{closed}) {
1680 $option .= "\n<br>" if ($option);
1681 $option .= $locale->text('Closed');
1689 <form method="post" action="oe.pl">
1692 <th class=listtop>$form->{title}</th>
1694 <tr height="5"></tr>
1701 <tr class=listheading>|;
1703 map { print "\n$column_header{$_}" } @column_index;
1709 # add sort and escape callback
1710 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1712 if (@{ $form->{OE} }) {
1713 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1717 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1719 $warehouse = $form->escape($form->{warehouse});
1721 foreach $oe (@{ $form->{OE} }) {
1722 $form->{rowcount} = ++$j;
1724 if ($form->{l_subtotal} eq 'Y') {
1725 if ($sameitem ne $oe->{ $form->{sort} }) {
1727 $sameitem = $oe->{ $form->{sort} };
1731 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1733 $column_data{netamount} =
1735 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1737 $column_data{tax} = "<td align=right>"
1738 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1741 $column_data{amount} =
1743 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1745 $totalnetamount += $oe->{netamount};
1746 $totalamount += $oe->{amount};
1748 $subtotalnetamount += $oe->{netamount};
1749 $subtotalamount += $oe->{amount};
1752 qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1753 $column_data{id} = "<td>$oe->{id}</td>";
1754 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1755 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1757 $column_data{$ordnumber} =
1758 "<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>";
1759 $column_data{name} = "<td>$oe->{name}</td>";
1761 $column_data{employee} = "<td>$oe->{employee} </td>";
1762 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1764 if ($oe->{closed}) {
1765 $column_data{closed} = "<td align=center>X</td>";
1766 $column_data{open} = "<td> </td>";
1768 $column_data{closed} = "<td> </td>";
1769 $column_data{open} = "<td align=center>X</td>";
1775 <tr class=listrow$i>";
1777 map { print "\n$column_data{$_}" } @column_index;
1785 if ($form->{l_subtotal} eq 'Y') {
1791 <tr class=listtotal>|;
1793 map { $column_data{$_} = "<td> </td>" } @column_index;
1795 $column_data{netamount} =
1796 "<th class=listtotal align=right>"
1797 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1798 $column_data{tax} = "<th class=listtotal align=right>"
1799 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1802 $column_data{amount} =
1803 "<th class=listtotal align=right>"
1804 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1806 map { print "\n$column_data{$_}" } @column_index;
1814 <td><hr size=3 noshade></td>
1818 # multiple invoice edit button only if gotten there via sales_order form.
1820 if ($form->{type} =~ /sales_order/) {
1822 <input type="hidden" name="path" value="$form->{path}">
1823 <input class"submit" type="submit" name="action" value="|
1824 . $locale->text('Continue') . qq|">
1825 <input type="hidden" name="nextsub" value="edit">
1826 <input type="hidden" name="type" value="$form->{type}">
1827 <input type="hidden" name="warehouse" value="$warehouse">
1828 <input type="hidden" name="vc" value="$form->{vc}">
1829 <input type="hidden" name="login" value="$form->{login}">
1830 <input type="hidden" name="password" value="$form->{password}">
1831 <input type="hidden" name="callback" value="$callback">
1832 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1839 <form method=post action=$form->{script}>
1841 <input name=callback type=hidden value="$form->{callback}">
1843 <input type=hidden name=type value=$form->{type}>
1844 <input type=hidden name=vc value=$form->{vc}>
1846 <input type=hidden name=path value=$form->{path}>
1847 <input type=hidden name=login value=$form->{login}>
1848 <input type=hidden name=password value=$form->{password}>
1851 if ($form->{type} !~ /(ship|receive)_order/) {
1853 <input class=submit type=submit name=action value="|
1854 . $locale->text('Add') . qq|">|;
1857 if ($form->{menubar}) {
1858 require "$form->{path}/menu.pl";
1869 $lxdebug->leave_sub();
1873 $lxdebug->enter_sub();
1875 map { $column_data{$_} = "<td> </td>" } @column_index;
1877 $column_data{netamount} =
1878 "<th class=listsubtotal align=right>"
1879 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1881 $column_data{tax} = "<td class=listsubtotal align=right>"
1882 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1885 $column_data{amount} =
1886 "<th class=listsubtotal align=right>"
1887 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1889 $subtotalnetamount = 0;
1890 $subtotalamount = 0;
1893 <tr class=listsubtotal>
1896 map { print "\n$column_data{$_}" } @column_index;
1902 $lxdebug->leave_sub();
1905 sub save_and_close {
1906 $lxdebug->enter_sub();
1908 if ($form->{type} =~ /_order$/) {
1909 $form->isblank("transdate", $locale->text('Order Date missing!'));
1911 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1914 $msg = ucfirst $form->{vc};
1915 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1917 # $locale->text('Customer missing!');
1918 # $locale->text('Vendor missing!');
1920 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1921 if ($form->{currency} ne $form->{defaultcurrency});
1925 # if the name changed get new values
1926 if (&check_name($form->{vc})) {
1931 $form->{id} = 0 if $form->{saveasnew};
1933 # this is for the internal notes section for the [email] Subject
1934 if ($form->{type} =~ /_order$/) {
1935 if ($form->{type} eq 'sales_order') {
1936 $form->{label} = $locale->text('Sales Order');
1938 $numberfld = "sonumber";
1939 $ordnumber = "ordnumber";
1941 $form->{label} = $locale->text('Purchase Order');
1943 $numberfld = "ponumber";
1944 $ordnumber = "ordnumber";
1947 $err = $locale->text('Cannot save order!');
1950 if ($form->{type} eq 'sales_quotation') {
1951 $form->{label} = $locale->text('Quotation');
1953 $numberfld = "sqnumber";
1954 $ordnumber = "quonumber";
1956 $form->{label} = $locale->text('Request for Quotation');
1958 $numberfld = "rfqnumber";
1959 $ordnumber = "quonumber";
1962 $err = $locale->text('Cannot save quotation!');
1966 # get new number in sequence if no number is given or if saveasnew was requested
1967 if (!$form->{$ordumber} || $form->{saveasnew}) {
1968 $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};
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->save(\%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});
2236 for $i (1 .. $form->{rowcount}) {
2237 $form->{"discount_$i"} =
2238 $form->format_amount(\%myconfig, $form->{"discount_$i"});
2240 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
2242 $decimalplaces = ($dec > 2) ? $dec : 2;
2244 # copy delivery date from reqdate for order -> invoice conversion
2245 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
2246 unless $form->{"deliverydate_$i"};
2248 $form->{"sellprice_$i"} =
2249 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
2252 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
2253 $dec_qty = length $dec_qty;
2255 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
2257 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2258 qw(partnumber description unit);
2264 $lxdebug->leave_sub();
2267 sub backorder_exchangerate {
2268 $lxdebug->enter_sub();
2269 my ($orddate, $buysell) = @_;
2276 <form method=post action=$form->{script}>
2279 # delete action variable
2280 map { delete $form->{$_} } qw(action header exchangerate);
2282 foreach $key (keys %$form) {
2283 $form->{$key} =~ s/\"/"/g;
2284 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2287 $form->{title} = $locale->text('Add Exchangerate');
2291 <input type=hidden name=path value=$form->{path}>
2292 <input type=hidden name=login value=$form->{login}>
2293 <input type=hidden name=password value=$form->{password}>
2295 <input type=hidden name=exchangeratedate value=$orddate>
2296 <input type=hidden name=buysell value=$buysell>
2299 <tr><th class=listtop>$form->{title}</th></tr>
2300 <tr height="5"></tr>
2305 <th align=right>| . $locale->text('Currency') . qq|</th>
2306 <td>$form->{currency}</td>
2309 <th align=right>| . $locale->text('Date') . qq|</th>
2313 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2314 <td><input name=exchangerate size=11></td>
2324 <input type=hidden name=nextsub value=save_exchangerate>
2326 <input name=action class=submit type=submit value="|
2327 . $locale->text('Continue') . qq|">
2335 $lxdebug->leave_sub();
2338 sub save_exchangerate {
2339 $lxdebug->enter_sub();
2341 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2342 $form->{exchangerate} =
2343 $form->parse_amount(\%myconfig, $form->{exchangerate});
2344 $form->save_exchangerate(\%myconfig, $form->{currency},
2345 $form->{exchangeratedate},
2346 $form->{exchangerate}, $form->{buysell});
2350 $lxdebug->leave_sub();
2353 sub create_backorder {
2354 $lxdebug->enter_sub();
2356 $form->{shipped} = 1;
2358 # figure out if we need to create a backorder
2359 # items aren't saved if qty != 0
2361 for $i (1 .. $form->{rowcount}) {
2362 $totalqty += $qty = $form->{"qty_$i"};
2363 $totalship += $ship = $form->{"ship_$i"};
2365 $form->{"qty_$i"} = $qty - $ship;
2368 if ($totalship == 0) {
2369 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2370 $form->{ordtotal} = 0;
2371 $form->{shipped} = 0;
2375 if ($totalqty == $totalship) {
2376 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2377 $form->{ordtotal} = 0;
2382 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2385 for $i (1 .. $form->{rowcount}) {
2387 $form->{"${_}_$i"} =
2388 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2389 } qw(sellprice discount);
2392 OE->save(\%myconfig, \%$form);
2394 # rebuild rows for invoice
2398 for $i (1 .. $form->{rowcount}) {
2399 $form->{"qty_$i"} = $form->{"ship_$i"};
2401 if ($form->{"qty_$i"}) {
2404 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2409 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2410 $form->{rowcount} = $count;
2412 $lxdebug->leave_sub();
2416 $lxdebug->enter_sub();
2418 $form->{saveasnew} = 1;
2419 $form->{closed} = 0;
2420 map { delete $form->{$_} } qw(printed emailed queued ordnumber quonumber);
2424 $lxdebug->leave_sub();
2427 sub purchase_order {
2428 $lxdebug->enter_sub();
2430 if ( $form->{type} eq 'sales_quotation'
2431 || $form->{type} eq 'request_quotation') {
2432 $form->{closed} = 1;
2433 OE->save(\%myconfig, \%$form);
2436 $form->{cp_id} *= 1;
2438 $form->{title} = $locale->text('Add Purchase Order');
2439 $form->{vc} = "vendor";
2440 $form->{type} = "purchase_order";
2444 $lxdebug->leave_sub();
2448 $lxdebug->enter_sub();
2450 if ( $form->{type} eq 'sales_quotation'
2451 || $form->{type} eq 'request_quotation') {
2452 $form->{closed} = 1;
2453 OE->save(\%myconfig, \%$form);
2456 $form->{cp_id} *= 1;
2458 $form->{title} = $locale->text('Add Sales Order');
2459 $form->{vc} = "customer";
2460 $form->{type} = "sales_order";
2464 $lxdebug->leave_sub();
2468 $lxdebug->enter_sub();
2470 $form->{transdate} = $form->current_date(\%myconfig);
2471 delete $form->{duedate};
2473 $form->{closed} = 0;
2476 map { delete $form->{$_} }
2477 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2484 for $i (1 .. $form->{rowcount} - 1) {
2485 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2486 qw(partnumber description unit);
2489 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2490 qw(creditlimit creditremaining);
2494 $lxdebug->leave_sub();
2498 $lxdebug->enter_sub();
2504 OE->get_warehouses(\%myconfig, \%$form);
2507 if (@{ $form->{all_warehouses} }) {
2508 $form->{selectwarehouse} = "<option>\n";
2510 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2511 (@{ $form->{all_warehouses} });
2513 if ($form->{warehouse}) {
2514 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2518 $form->{shippingdate} = $form->current_date(\%myconfig);
2519 $form->{"$form->{vc}"} =~ s/--.*//;
2524 foreach $key (keys %$form) {
2525 if ($key =~ /_1$/) {
2531 for $i (1 .. $form->{rowcount}) {
2533 # undo formatting from prepare_order
2535 $form->{"${_}_$i"} =
2536 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2538 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2540 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2541 $form->{"ship_$i"} = "";
2542 $form->{"serialnumber_$i"} = "";
2547 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2552 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2553 $form->{rowcount} = $count;
2555 &display_ship_receive;
2557 $lxdebug->leave_sub();
2560 sub display_ship_receive {
2561 $lxdebug->enter_sub();
2563 $vclabel = ucfirst $form->{vc};
2564 $vclabel = $locale->text($vclabel);
2566 $form->{rowcount}++;
2568 if ($form->{vc} eq 'customer') {
2569 $form->{title} = $locale->text('Ship Merchandise');
2570 $shipped = $locale->text('Shipping Date');
2572 $form->{title} = $locale->text('Receive Merchandise');
2573 $shipped = $locale->text('Date Received');
2576 # set option selected
2577 foreach $item (warehouse, employee) {
2578 $form->{"select$item"} =~ s/ selected//;
2579 $form->{"select$item"} =~
2580 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2585 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2586 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2587 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2589 | if $form->{selectwarehouse};
2593 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2594 <td><select name=employee>$form->{selectemployee}</select></td>
2595 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2604 <form method=post action=$form->{script}>
2606 <input type=hidden name=id value=$form->{id}>
2608 <input type=hidden name=display_form value=display_ship_receive>
2610 <input type=hidden name=type value=$form->{type}>
2611 <input type=hidden name=media value=$form->{media}>
2612 <input type=hidden name=format value=$form->{format}>
2614 <input type=hidden name=queued value="$form->{queued}">
2615 <input type=hidden name=printed value="$form->{printed}">
2616 <input type=hidden name=emailed value="$form->{emailed}">
2618 <input type=hidden name=vc value=$form->{vc}>
2622 <th class=listtop>$form->{title}</th>
2624 <tr height="5"></tr>
2627 <table width="100%">
2632 <th align=right>$vclabel</th>
2633 <td colspan=3>$form->{$form->{vc}}</td>
2634 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2635 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2639 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2641 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2644 <th align=right>| . $locale->text('Ship via') . qq|</th>
2646 <input name=shipvia size=35 value="$form->{shipvia}">
2655 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2656 <td>$form->{ordnumber}</td>
2657 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2660 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2661 <td>$form->{transdate}</td>
2662 <input type=hidden name=transdate value=$form->{transdate}>
2665 <th align=right nowrap>$shipped</th>
2666 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2675 <!-- shipto are in hidden variables -->
2677 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2678 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2679 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2680 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2681 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2682 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2683 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2684 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2685 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2687 <!-- email variables -->
2688 <input type=hidden name=message value="$form->{message}">
2689 <input type=hidden name=email value="$form->{email}">
2690 <input type=hidden name=subject value="$form->{subject}">
2691 <input type=hidden name=cc value="$form->{cc}">
2692 <input type=hidden name=bcc value="$form->{bcc}">
2697 (partnumber, description, qty, ship, unit, bin, serialnumber);
2699 if ($form->{type} eq "ship_order") {
2700 $column_data{ship} =
2701 qq|<th class=listheading align=center width="auto">|
2702 . $locale->text('Ship')
2705 if ($form->{type} eq "receive_order") {
2706 $column_data{ship} =
2707 qq|<th class=listheading align=center width="auto">|
2708 . $locale->text('Recd')
2712 my $colspan = $#column_index + 1;
2714 $column_data{partnumber} =
2715 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2716 $column_data{description} =
2717 qq|<th class=listheading nowrap>|
2718 . $locale->text('Description')
2721 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2722 $column_data{unit} =
2723 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2725 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2726 $column_data{serialnumber} =
2727 qq|<th class=listheading nowrap>|
2728 . $locale->text('Serial No.')
2735 <tr class=listheading>|;
2737 map { print "\n$column_data{$_}" } @column_index;
2743 for $i (1 .. $form->{rowcount} - 1) {
2746 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2748 # convert " to "
2749 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2750 qw(partnumber description unit bin serialnumber);
2752 $description = $form->{"description_$i"};
2753 $description =~ s/\n/<br>/g;
2755 $column_data{partnumber} =
2756 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2757 $column_data{description} =
2758 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2760 qq|<td align=right>|
2761 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2762 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2763 $column_data{ship} =
2764 qq|<td align=right><input name="ship_$i" size=5 value=|
2765 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2767 $column_data{unit} =
2768 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2770 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2772 $column_data{serialnumber} =
2773 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2778 map { print "\n$column_data{$_}" } @column_index;
2783 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2784 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2785 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2786 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2797 <td><hr size=3 noshade></td>
2803 $form->{copies} = 1;
2812 <input class=submit type=submit name=action value="|
2813 . $locale->text('Update') . qq|">
2814 <input class=submit type=submit name=action value="|
2815 . $locale->text('Print') . qq|">
2818 if ($form->{type} eq 'ship_order') {
2820 <input class=submit type=submit name=action value="|
2821 . $locale->text('Ship to') . qq|">
2822 <input class=submit type=submit name=action value="|
2823 . $locale->text('E-mail') . qq|">
2829 <input class=submit type=submit name=action value="|
2830 . $locale->text('Done') . qq|">
2833 if ($form->{menubar}) {
2834 require "$form->{path}/menu.pl";
2840 <input type=hidden name=rowcount value=$form->{rowcount}>
2842 <input name=callback type=hidden value="$callback">
2844 <input type=hidden name=path value=$form->{path}>
2845 <input type=hidden name=login value=$form->{login}>
2846 <input type=hidden name=password value=$form->{password}>
2854 $lxdebug->leave_sub();
2858 $lxdebug->enter_sub();
2860 if ($form->{type} eq 'ship_order') {
2861 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2863 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2868 $total += $form->{"ship_$_"} =
2869 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2870 } (1 .. $form->{rowcount} - 1);
2872 $form->error($locale->text('Nothing entered!')) unless $total;
2874 $form->redirect($locale->text('Inventory saved!'))
2875 if OE->save_inventory(\%myconfig, \%$form);
2876 $form->error($locale->text('Could not save!'));
2878 $lxdebug->leave_sub();
2881 sub search_transfer {
2882 $lxdebug->enter_sub();
2884 OE->get_warehouses(\%myconfig, \%$form);
2887 if (@{ $form->{all_warehouses} }) {
2888 $form->{selectwarehouse} = "<option>\n";
2889 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2891 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2892 (@{ $form->{all_warehouses} });
2894 $form->error($locale->text('Nothing to transfer!'));
2897 $form->{title} = $locale->text('Transfer Inventory');
2904 <form method=post action=$form->{script}>
2908 <th class=listtop>$form->{title}</th>
2910 <tr height="5"></tr>
2915 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2916 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2919 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2920 <td><input name=partnumber size=20></td>
2923 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2924 <td><input name=description size=40></td>
2927 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2928 <td><input name=partsgroup size=20></td>
2934 <td><hr size=3 noshade></td>
2939 <input type=hidden name=sort value=partnumber>
2940 <input type=hidden name=nextsub value=list_transfer>
2942 <input type=hidden name=path value=$form->{path}>
2943 <input type=hidden name=login value=$form->{login}>
2944 <input type=hidden name=password value=$form->{password}>
2946 <input class=submit type=submit name=action value="|
2947 . $locale->text('Continue') . qq|">
2954 $lxdebug->leave_sub();
2958 $lxdebug->enter_sub();
2960 OE->get_inventory(\%myconfig, \%$form);
2962 $partnumber = $form->escape($form->{partnumber});
2963 $warehouse = $form->escape($form->{warehouse});
2964 $description = $form->escape($form->{description});
2965 $partsgroup = $form->escape($form->{partsgroup});
2969 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2971 # construct callback
2972 $partnumber = $form->escape($form->{partnumber}, 1);
2973 $warehouse = $form->escape($form->{warehouse}, 1);
2974 $description = $form->escape($form->{description}, 1);
2975 $partsgroup = $form->escape($form->{partsgroup}, 1);
2978 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2981 $form->sort_columns(
2982 qw(partnumber description partsgroup make model warehouse qty transfer));
2984 $column_header{partnumber} =
2985 qq|<th><a class=listheading href=$href&sort=partnumber>|
2986 . $locale->text('Part Number')
2988 $column_header{description} =
2989 qq|<th><a class=listheading href=$href&sort=description>|
2990 . $locale->text('Description')
2992 $column_header{partsgroup} =
2993 qq|<th><a class=listheading href=$href&sort=partsgroup>|
2994 . $locale->text('Group')
2996 $column_header{warehouse} =
2997 qq|<th><a class=listheading href=$href&sort=warehouse>|
2998 . $locale->text('From')
3000 $column_header{qty} =
3001 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
3002 $column_header{transfer} =
3003 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
3005 $option = $locale->text('Transfer to');
3007 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
3009 if ($form->{warehouse}) {
3010 $option .= " : $warehouse";
3012 if ($form->{partnumber}) {
3013 $option .= "\n<br>" if ($option);
3014 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
3016 if ($form->{description}) {
3017 $option .= "\n<br>" if ($option);
3018 $option .= $locale->text('Description') . " : $form->{description}";
3020 if ($form->{partsgroup}) {
3021 $option .= "\n<br>" if ($option);
3022 $option .= $locale->text('Group') . " : $form->{partsgroup}";
3025 $form->{title} = $locale->text('Transfer Inventory');
3032 <form method=post action=$form->{script}>
3034 <input type=hidden name=warehouse_id value=$warehouse_id>
3038 <th class=listtop>$form->{title}</th>
3040 <tr height="5"></tr>
3047 <tr class=listheading>|;
3049 map { print "\n$column_header{$_}" } @column_index;
3055 if (@{ $form->{all_inventory} }) {
3056 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
3060 foreach $ref (@{ $form->{all_inventory} }) {
3064 $column_data{partnumber} =
3065 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
3066 $column_data{description} = "<td>$ref->{description} </td>";
3067 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
3068 $column_data{warehouse} =
3069 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
3071 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
3072 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
3074 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
3079 <tr class=listrow$j>";
3081 map { print "\n$column_data{$_}" } @column_index;
3095 <td><hr size=3 noshade></td>
3101 <input name=callback type=hidden value="$callback">
3103 <input type=hidden name=rowcount value=$i>
3105 <input type=hidden name=path value=$form->{path}>
3106 <input type=hidden name=login value=$form->{login}>
3107 <input type=hidden name=password value=$form->{password}>
3109 <input class=submit type=submit name=action value="|
3110 . $locale->text('Transfer') . qq|">|;
3112 if ($form->{menubar}) {
3113 require "$form->{path}/menu.pl";
3124 $lxdebug->leave_sub();
3128 $lxdebug->enter_sub();
3130 $form->redirect($locale->text('Inventory transferred!'))
3131 if OE->transfer(\%myconfig, \%$form);
3132 $form->error($locale->text('Could not transfer Inventory!'));
3134 $lxdebug->leave_sub();