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->{$ordnumber} || $form->{saveasnew}) {
1968 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
1974 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1975 if (OE->save(\%myconfig, \%$form));
1978 $lxdebug->leave_sub();
1982 $lxdebug->enter_sub();
1984 if ($form->{type} =~ /_order$/) {
1985 $form->isblank("transdate", $locale->text('Order Date missing!'));
1987 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1990 $msg = ucfirst $form->{vc};
1991 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1993 # $locale->text('Customer missing!');
1994 # $locale->text('Vendor missing!');
1996 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1997 if ($form->{currency} ne $form->{defaultcurrency});
2001 # if the name changed get new values
2002 if (&check_name($form->{vc})) {
2007 $form->{id} = 0 if $form->{saveasnew};
2009 # this is for the internal notes section for the [email] Subject
2010 if ($form->{type} =~ /_order$/) {
2011 if ($form->{type} eq 'sales_order') {
2012 $form->{label} = $locale->text('Sales Order');
2014 $numberfld = "sonumber";
2015 $ordnumber = "ordnumber";
2017 $form->{label} = $locale->text('Purchase Order');
2019 $numberfld = "ponumber";
2020 $ordnumber = "ordnumber";
2023 $err = $locale->text('Cannot save order!');
2026 if ($form->{type} eq 'sales_quotation') {
2027 $form->{label} = $locale->text('Quotation');
2029 $numberfld = "sqnumber";
2030 $ordnumber = "quonumber";
2032 $form->{label} = $locale->text('Request for Quotation');
2034 $numberfld = "rfqnumber";
2035 $ordnumber = "quonumber";
2038 $err = $locale->text('Cannot save quotation!');
2042 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
2043 unless $form->{$ordnumber};
2047 OE->save(\%myconfig, \%$form);
2048 $form->{simple_save} = 1;
2049 if(!$form->{print_and_save}) {
2050 set_headings("edit");
2054 $lxdebug->leave_sub();
2058 $lxdebug->enter_sub();
2062 if ($form->{type} =~ /_order$/) {
2063 $msg = $locale->text('Are you sure you want to delete Order Number');
2064 $ordnumber = 'ordnumber';
2066 $msg = $locale->text('Are you sure you want to delete Quotation Number');
2067 $ordnumber = 'quonumber';
2073 <form method=post action=$form->{script}>
2076 # delete action variable
2077 map { delete $form->{$_} } qw(action header);
2079 foreach $key (keys %$form) {
2080 $form->{$key} =~ s/\"/"/g;
2081 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2085 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
2087 <h4>$msg $form->{$ordnumber}</h4>
2089 <input name=action class=submit type=submit value="|
2090 . $locale->text('Yes') . qq|">
2097 $lxdebug->leave_sub();
2101 $lxdebug->enter_sub();
2103 if ($form->{type} =~ /_order$/) {
2104 $msg = $locale->text('Order deleted!');
2105 $err = $locale->text('Cannot delete order!');
2107 $msg = $locale->text('Quotation deleted!');
2108 $err = $locale->text('Cannot delete quotation!');
2111 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
2114 $lxdebug->leave_sub();
2118 $lxdebug->enter_sub();
2120 if ($form->{type} =~ /_order$/) {
2122 # these checks only apply if the items don't bring their own ordnumbers/transdates.
2123 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
2124 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
2125 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2127 $form->isblank("transdate", $locale->text('Order Date missing!'))
2128 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2131 # also copy deliverydate from the order
2132 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
2134 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
2135 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2136 $form->{ordnumber} = "";
2139 # if the name changed get new values
2140 if (&check_name($form->{vc})) {
2145 $form->{cp_id} *= 1;
2147 if ( $form->{type} =~ /_order/
2148 && $form->{currency} ne $form->{defaultcurrency}) {
2150 # check if we need a new exchangerate
2151 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
2153 $orddate = $form->current_date(\%myconfig);
2155 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
2158 if (!$exchangerate) {
2159 &backorder_exchangerate($orddate, $buysell);
2164 # close orders/quotations
2165 $form->{closed} = 1;
2167 # save order if one ordnumber has been given
2168 # if not it's most likely a collective order, which can't be saved back
2169 # so they just have to be closed
2170 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
2172 OE->save(\%myconfig, \%$form);
2174 OE->close_orders(\%myconfig, \%$form);
2177 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
2179 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2182 $form->{closed} = 0;
2183 $form->{rowcount}--;
2184 $form->{shipto} = 1;
2186 if ($form->{type} =~ /_order$/) {
2187 $form->{exchangerate} = $exchangerate;
2191 if ( $form->{type} eq 'purchase_order'
2192 || $form->{type} eq 'request_quotation') {
2193 $form->{title} = $locale->text('Add Vendor Invoice');
2194 $form->{script} = 'ir.pl';
2198 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
2199 $form->{title} = $locale->text('Add Sales Invoice');
2200 $form->{script} = 'is.pl';
2205 # bo creates the id, reset it
2206 map { delete $form->{$_} }
2207 qw(id subject message cc bcc printed emailed queued);
2208 $form->{ $form->{vc} } =~ s/--.*//g;
2209 $form->{type} = "invoice";
2212 $locale = new Locale "$myconfig{countrycode}", "$script";
2214 require "$form->{path}/$form->{script}";
2216 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
2218 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2219 qw(creditlimit creditremaining);
2221 $currency = $form->{currency};
2224 $form->{currency} = $currency;
2225 $form->{exchangerate} = "";
2226 $form->{forex} = "";
2227 $form->{exchangerate} = $exchangerate
2231 $form->check_exchangerate(
2232 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
2235 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
2240 for $i (1 .. $form->{rowcount}) {
2241 $form->{"discount_$i"} =
2242 $form->format_amount(\%myconfig, $form->{"discount_$i"});
2244 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
2246 $decimalplaces = ($dec > 2) ? $dec : 2;
2248 # copy delivery date from reqdate for order -> invoice conversion
2249 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
2250 unless $form->{"deliverydate_$i"};
2252 $form->{"sellprice_$i"} =
2253 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
2256 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
2257 $dec_qty = length $dec_qty;
2259 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
2261 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2262 qw(partnumber description unit);
2268 $lxdebug->leave_sub();
2271 sub backorder_exchangerate {
2272 $lxdebug->enter_sub();
2273 my ($orddate, $buysell) = @_;
2280 <form method=post action=$form->{script}>
2283 # delete action variable
2284 map { delete $form->{$_} } qw(action header exchangerate);
2286 foreach $key (keys %$form) {
2287 $form->{$key} =~ s/\"/"/g;
2288 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2291 $form->{title} = $locale->text('Add Exchangerate');
2295 <input type=hidden name=path value=$form->{path}>
2296 <input type=hidden name=login value=$form->{login}>
2297 <input type=hidden name=password value=$form->{password}>
2299 <input type=hidden name=exchangeratedate value=$orddate>
2300 <input type=hidden name=buysell value=$buysell>
2303 <tr><th class=listtop>$form->{title}</th></tr>
2304 <tr height="5"></tr>
2309 <th align=right>| . $locale->text('Currency') . qq|</th>
2310 <td>$form->{currency}</td>
2313 <th align=right>| . $locale->text('Date') . qq|</th>
2317 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2318 <td><input name=exchangerate size=11></td>
2328 <input type=hidden name=nextsub value=save_exchangerate>
2330 <input name=action class=submit type=submit value="|
2331 . $locale->text('Continue') . qq|">
2339 $lxdebug->leave_sub();
2342 sub save_exchangerate {
2343 $lxdebug->enter_sub();
2345 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2346 $form->{exchangerate} =
2347 $form->parse_amount(\%myconfig, $form->{exchangerate});
2348 $form->save_exchangerate(\%myconfig, $form->{currency},
2349 $form->{exchangeratedate},
2350 $form->{exchangerate}, $form->{buysell});
2354 $lxdebug->leave_sub();
2357 sub create_backorder {
2358 $lxdebug->enter_sub();
2360 $form->{shipped} = 1;
2362 # figure out if we need to create a backorder
2363 # items aren't saved if qty != 0
2365 for $i (1 .. $form->{rowcount}) {
2366 $totalqty += $qty = $form->{"qty_$i"};
2367 $totalship += $ship = $form->{"ship_$i"};
2369 $form->{"qty_$i"} = $qty - $ship;
2372 if ($totalship == 0) {
2373 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2374 $form->{ordtotal} = 0;
2375 $form->{shipped} = 0;
2379 if ($totalqty == $totalship) {
2380 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2381 $form->{ordtotal} = 0;
2386 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2389 for $i (1 .. $form->{rowcount}) {
2391 $form->{"${_}_$i"} =
2392 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2393 } qw(sellprice discount);
2398 OE->save(\%myconfig, \%$form);
2400 # rebuild rows for invoice
2404 for $i (1 .. $form->{rowcount}) {
2405 $form->{"qty_$i"} = $form->{"ship_$i"};
2407 if ($form->{"qty_$i"}) {
2410 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2415 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2416 $form->{rowcount} = $count;
2418 $lxdebug->leave_sub();
2422 $lxdebug->enter_sub();
2424 $form->{saveasnew} = 1;
2425 $form->{closed} = 0;
2426 map { delete $form->{$_} } qw(printed emailed queued ordnumber quonumber);
2430 $lxdebug->leave_sub();
2433 sub purchase_order {
2434 $lxdebug->enter_sub();
2436 if ( $form->{type} eq 'sales_quotation'
2437 || $form->{type} eq 'request_quotation') {
2438 $form->{closed} = 1;
2440 OE->save(\%myconfig, \%$form);
2443 $form->{cp_id} *= 1;
2445 $form->{title} = $locale->text('Add Purchase Order');
2446 $form->{vc} = "vendor";
2447 $form->{type} = "purchase_order";
2451 $lxdebug->leave_sub();
2455 $lxdebug->enter_sub();
2457 if ( $form->{type} eq 'sales_quotation'
2458 || $form->{type} eq 'request_quotation') {
2459 $form->{closed} = 1;
2461 OE->save(\%myconfig, \%$form);
2464 $form->{cp_id} *= 1;
2466 $form->{title} = $locale->text('Add Sales Order');
2467 $form->{vc} = "customer";
2468 $form->{type} = "sales_order";
2472 $lxdebug->leave_sub();
2476 $lxdebug->enter_sub();
2478 $form->{transdate} = $form->current_date(\%myconfig);
2479 delete $form->{duedate};
2481 $form->{closed} = 0;
2484 map { delete $form->{$_} }
2485 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2492 for $i (1 .. $form->{rowcount} - 1) {
2493 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2494 qw(partnumber description unit);
2497 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2498 qw(creditlimit creditremaining);
2502 $lxdebug->leave_sub();
2506 $lxdebug->enter_sub();
2512 OE->get_warehouses(\%myconfig, \%$form);
2515 if (@{ $form->{all_warehouses} }) {
2516 $form->{selectwarehouse} = "<option>\n";
2518 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2519 (@{ $form->{all_warehouses} });
2521 if ($form->{warehouse}) {
2522 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2526 $form->{shippingdate} = $form->current_date(\%myconfig);
2527 $form->{"$form->{vc}"} =~ s/--.*//;
2532 foreach $key (keys %$form) {
2533 if ($key =~ /_1$/) {
2539 for $i (1 .. $form->{rowcount}) {
2541 # undo formatting from prepare_order
2543 $form->{"${_}_$i"} =
2544 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2546 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2548 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2549 $form->{"ship_$i"} = "";
2550 $form->{"serialnumber_$i"} = "";
2555 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2560 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2561 $form->{rowcount} = $count;
2563 &display_ship_receive;
2565 $lxdebug->leave_sub();
2568 sub display_ship_receive {
2569 $lxdebug->enter_sub();
2571 $vclabel = ucfirst $form->{vc};
2572 $vclabel = $locale->text($vclabel);
2574 $form->{rowcount}++;
2576 if ($form->{vc} eq 'customer') {
2577 $form->{title} = $locale->text('Ship Merchandise');
2578 $shipped = $locale->text('Shipping Date');
2580 $form->{title} = $locale->text('Receive Merchandise');
2581 $shipped = $locale->text('Date Received');
2584 # set option selected
2585 foreach $item (warehouse, employee) {
2586 $form->{"select$item"} =~ s/ selected//;
2587 $form->{"select$item"} =~
2588 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2593 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2594 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2595 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2597 | if $form->{selectwarehouse};
2601 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2602 <td><select name=employee>$form->{selectemployee}</select></td>
2603 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2612 <form method=post action=$form->{script}>
2614 <input type=hidden name=id value=$form->{id}>
2616 <input type=hidden name=display_form value=display_ship_receive>
2618 <input type=hidden name=type value=$form->{type}>
2619 <input type=hidden name=media value=$form->{media}>
2620 <input type=hidden name=format value=$form->{format}>
2622 <input type=hidden name=queued value="$form->{queued}">
2623 <input type=hidden name=printed value="$form->{printed}">
2624 <input type=hidden name=emailed value="$form->{emailed}">
2626 <input type=hidden name=vc value=$form->{vc}>
2630 <th class=listtop>$form->{title}</th>
2632 <tr height="5"></tr>
2635 <table width="100%">
2640 <th align=right>$vclabel</th>
2641 <td colspan=3>$form->{$form->{vc}}</td>
2642 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2643 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2647 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2649 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2652 <th align=right>| . $locale->text('Ship via') . qq|</th>
2654 <input name=shipvia size=35 value="$form->{shipvia}">
2663 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2664 <td>$form->{ordnumber}</td>
2665 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2668 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2669 <td>$form->{transdate}</td>
2670 <input type=hidden name=transdate value=$form->{transdate}>
2673 <th align=right nowrap>$shipped</th>
2674 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2683 <!-- shipto are in hidden variables -->
2685 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2686 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2687 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2688 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2689 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2690 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2691 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2692 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2693 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2695 <!-- email variables -->
2696 <input type=hidden name=message value="$form->{message}">
2697 <input type=hidden name=email value="$form->{email}">
2698 <input type=hidden name=subject value="$form->{subject}">
2699 <input type=hidden name=cc value="$form->{cc}">
2700 <input type=hidden name=bcc value="$form->{bcc}">
2705 (partnumber, description, qty, ship, unit, bin, serialnumber);
2707 if ($form->{type} eq "ship_order") {
2708 $column_data{ship} =
2709 qq|<th class=listheading align=center width="auto">|
2710 . $locale->text('Ship')
2713 if ($form->{type} eq "receive_order") {
2714 $column_data{ship} =
2715 qq|<th class=listheading align=center width="auto">|
2716 . $locale->text('Recd')
2720 my $colspan = $#column_index + 1;
2722 $column_data{partnumber} =
2723 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2724 $column_data{description} =
2725 qq|<th class=listheading nowrap>|
2726 . $locale->text('Description')
2729 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2730 $column_data{unit} =
2731 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2733 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2734 $column_data{serialnumber} =
2735 qq|<th class=listheading nowrap>|
2736 . $locale->text('Serial No.')
2743 <tr class=listheading>|;
2745 map { print "\n$column_data{$_}" } @column_index;
2751 for $i (1 .. $form->{rowcount} - 1) {
2754 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2756 # convert " to "
2757 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2758 qw(partnumber description unit bin serialnumber);
2760 $description = $form->{"description_$i"};
2761 $description =~ s/\n/<br>/g;
2763 $column_data{partnumber} =
2764 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2765 $column_data{description} =
2766 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2768 qq|<td align=right>|
2769 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2770 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2771 $column_data{ship} =
2772 qq|<td align=right><input name="ship_$i" size=5 value=|
2773 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2775 $column_data{unit} =
2776 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2778 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2780 $column_data{serialnumber} =
2781 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2786 map { print "\n$column_data{$_}" } @column_index;
2791 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2792 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2793 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2794 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2805 <td><hr size=3 noshade></td>
2811 $form->{copies} = 1;
2820 <input class=submit type=submit name=action value="|
2821 . $locale->text('Update') . qq|">
2822 <input class=submit type=submit name=action value="|
2823 . $locale->text('Print') . qq|">
2826 if ($form->{type} eq 'ship_order') {
2828 <input class=submit type=submit name=action value="|
2829 . $locale->text('Ship to') . qq|">
2830 <input class=submit type=submit name=action value="|
2831 . $locale->text('E-mail') . qq|">
2837 <input class=submit type=submit name=action value="|
2838 . $locale->text('Done') . qq|">
2841 if ($form->{menubar}) {
2842 require "$form->{path}/menu.pl";
2848 <input type=hidden name=rowcount value=$form->{rowcount}>
2850 <input name=callback type=hidden value="$callback">
2852 <input type=hidden name=path value=$form->{path}>
2853 <input type=hidden name=login value=$form->{login}>
2854 <input type=hidden name=password value=$form->{password}>
2862 $lxdebug->leave_sub();
2866 $lxdebug->enter_sub();
2868 if ($form->{type} eq 'ship_order') {
2869 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2871 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2876 $total += $form->{"ship_$_"} =
2877 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2878 } (1 .. $form->{rowcount} - 1);
2880 $form->error($locale->text('Nothing entered!')) unless $total;
2882 $form->redirect($locale->text('Inventory saved!'))
2883 if OE->save_inventory(\%myconfig, \%$form);
2884 $form->error($locale->text('Could not save!'));
2886 $lxdebug->leave_sub();
2889 sub search_transfer {
2890 $lxdebug->enter_sub();
2892 OE->get_warehouses(\%myconfig, \%$form);
2895 if (@{ $form->{all_warehouses} }) {
2896 $form->{selectwarehouse} = "<option>\n";
2897 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2899 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2900 (@{ $form->{all_warehouses} });
2902 $form->error($locale->text('Nothing to transfer!'));
2905 $form->{title} = $locale->text('Transfer Inventory');
2912 <form method=post action=$form->{script}>
2916 <th class=listtop>$form->{title}</th>
2918 <tr height="5"></tr>
2923 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2924 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2927 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2928 <td><input name=partnumber size=20></td>
2931 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2932 <td><input name=description size=40></td>
2935 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2936 <td><input name=partsgroup size=20></td>
2942 <td><hr size=3 noshade></td>
2947 <input type=hidden name=sort value=partnumber>
2948 <input type=hidden name=nextsub value=list_transfer>
2950 <input type=hidden name=path value=$form->{path}>
2951 <input type=hidden name=login value=$form->{login}>
2952 <input type=hidden name=password value=$form->{password}>
2954 <input class=submit type=submit name=action value="|
2955 . $locale->text('Continue') . qq|">
2962 $lxdebug->leave_sub();
2966 $lxdebug->enter_sub();
2968 OE->get_inventory(\%myconfig, \%$form);
2970 $partnumber = $form->escape($form->{partnumber});
2971 $warehouse = $form->escape($form->{warehouse});
2972 $description = $form->escape($form->{description});
2973 $partsgroup = $form->escape($form->{partsgroup});
2977 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2979 # construct callback
2980 $partnumber = $form->escape($form->{partnumber}, 1);
2981 $warehouse = $form->escape($form->{warehouse}, 1);
2982 $description = $form->escape($form->{description}, 1);
2983 $partsgroup = $form->escape($form->{partsgroup}, 1);
2986 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2989 $form->sort_columns(
2990 qw(partnumber description partsgroup make model warehouse qty transfer));
2992 $column_header{partnumber} =
2993 qq|<th><a class=listheading href=$href&sort=partnumber>|
2994 . $locale->text('Part Number')
2996 $column_header{description} =
2997 qq|<th><a class=listheading href=$href&sort=description>|
2998 . $locale->text('Description')
3000 $column_header{partsgroup} =
3001 qq|<th><a class=listheading href=$href&sort=partsgroup>|
3002 . $locale->text('Group')
3004 $column_header{warehouse} =
3005 qq|<th><a class=listheading href=$href&sort=warehouse>|
3006 . $locale->text('From')
3008 $column_header{qty} =
3009 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
3010 $column_header{transfer} =
3011 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
3013 $option = $locale->text('Transfer to');
3015 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
3017 if ($form->{warehouse}) {
3018 $option .= " : $warehouse";
3020 if ($form->{partnumber}) {
3021 $option .= "\n<br>" if ($option);
3022 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
3024 if ($form->{description}) {
3025 $option .= "\n<br>" if ($option);
3026 $option .= $locale->text('Description') . " : $form->{description}";
3028 if ($form->{partsgroup}) {
3029 $option .= "\n<br>" if ($option);
3030 $option .= $locale->text('Group') . " : $form->{partsgroup}";
3033 $form->{title} = $locale->text('Transfer Inventory');
3040 <form method=post action=$form->{script}>
3042 <input type=hidden name=warehouse_id value=$warehouse_id>
3046 <th class=listtop>$form->{title}</th>
3048 <tr height="5"></tr>
3055 <tr class=listheading>|;
3057 map { print "\n$column_header{$_}" } @column_index;
3063 if (@{ $form->{all_inventory} }) {
3064 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
3068 foreach $ref (@{ $form->{all_inventory} }) {
3072 $column_data{partnumber} =
3073 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
3074 $column_data{description} = "<td>$ref->{description} </td>";
3075 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
3076 $column_data{warehouse} =
3077 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
3079 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
3080 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
3082 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
3087 <tr class=listrow$j>";
3089 map { print "\n$column_data{$_}" } @column_index;
3103 <td><hr size=3 noshade></td>
3109 <input name=callback type=hidden value="$callback">
3111 <input type=hidden name=rowcount value=$i>
3113 <input type=hidden name=path value=$form->{path}>
3114 <input type=hidden name=login value=$form->{login}>
3115 <input type=hidden name=password value=$form->{password}>
3117 <input class=submit type=submit name=action value="|
3118 . $locale->text('Transfer') . qq|">|;
3120 if ($form->{menubar}) {
3121 require "$form->{path}/menu.pl";
3132 $lxdebug->leave_sub();
3136 $lxdebug->enter_sub();
3138 $form->redirect($locale->text('Inventory transferred!'))
3139 if OE->transfer(\%myconfig, \%$form);
3140 $form->error($locale->text('Could not transfer Inventory!'));
3142 $lxdebug->leave_sub();