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->{formname} = $form->{type} unless $form->{formname};
290 foreach $ref (@{ $form->{form_details} }) {
291 $form->{rowcount} = ++$i;
293 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
295 for my $i (1 .. $form->{rowcount}) {
297 $form->{"discount_$i"} =
298 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
300 $form->{"discount_$i"} =
301 $form->format_amount(\%myconfig, $form->{"discount_$i"});
303 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
305 $decimalplaces = ($dec > 2) ? $dec : 2;
307 # copy reqdate from deliverydate for invoice -> order conversion
308 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
309 unless $form->{"reqdate_$i"};
311 $form->{"sellprice_$i"} =
312 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
315 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
316 $dec_qty = length $dec_qty;
318 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
320 map { $form->{"${_}_$i"} =~ s/\"/"/g }
321 qw(partnumber description unit);
324 $lxdebug->leave_sub();
328 $lxdebug->enter_sub();
330 my $checkedclosed = $form->{"closed"} ? "checked" : "";
331 my $checkeddelivered = $form->{"delivered"} ? "checked" : "";
333 map { $form->{$_} =~ s/\"/"/g }
334 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname
335 shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact
336 shiptophone shiptofax shiptodepartment_1 shiptodepartment_2);
338 # use JavaScript Calendar or not
339 $form->{jsscript} = $form->{jscalendar};
342 $payment = qq|<option value=""></option>|;
343 foreach $item (@{ $form->{payment_terms} }) {
344 if ($form->{payment_id} eq $item->{id}) {
345 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
347 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
350 if ($form->{jsscript}) {
352 # with JavaScript Calendar
354 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
355 <td><input type=button name=transdate id="trigger1" value=|
356 . $locale->text('button') . qq|></td>
359 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
360 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
361 . $locale->text('button') . qq|></td>
366 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
367 "reqdate", "BL", "trigger2");
371 # without JavaScript Calendar
373 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
375 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
381 <td colspan=2 align=center>
382 <input name="closed" id="closed" type="checkbox" class="checkbox" value="1" $checkedclosed>
383 <label for="closed">| . $locale->text('Closed') . qq|</label>
386 if (($form->{"type"} eq "sales_order") ||
387 ($form->{"type"} eq "purchase_order")) {
389 <input name="delivered" id="delivered" type="checkbox" class="checkbox" value="1" $checkeddelivered>
390 <label for="delivered">| . $locale->text('Delivered') . qq|</label>
400 # set option selected
401 foreach $item ($form->{vc}, currency, department, employee) {
402 $form->{"select$item"} =~ s/ selected//;
403 $form->{"select$item"} =~
404 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
407 #quote select[customer|vendor] Bug 133
408 $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
411 if ($form->{all_contacts}) {
413 $form->{selectcontact} = "<option></option>";
414 foreach $item (@{ $form->{all_contacts} }) {
415 my $department = ($item->{cp_abteilung}) ? "--$item->{cp_abteilung}" : "";
416 if ($form->{cp_id} == $item->{cp_id}) {
417 $form->{selectcontact} .=
418 "<option value=$item->{cp_id} selected>$item->{cp_name}$department</option>";
420 $form->{selectcontact} .= "<option value=$item->{cp_id}>$item->{cp_name}$department</option>";
424 $form->{selectcontact} =~ s/ selected//g;
425 if ($form->{cp_id} ne "") {
426 $form->{selectcontact} =~ s/value=$form->{cp_id}/value=$form->{cp_id} selected/;
431 if (@{ $form->{SHIPTO} }) {
432 $form->{selectshipto} = "<option value=0></option>";
433 foreach $item (@{ $form->{SHIPTO} }) {
434 if ($item->{shipto_id} == $form->{shipto_id}) {
435 $form->{selectshipto} .=
436 "<option value=$item->{shipto_id} selected>$item->{shiptoname} $item->{shiptodepartment_1}</option>";
438 $form->{selectshipto} .=
439 "<option value=$item->{shipto_id}>$item->{shiptoname} $item->{shiptodepartment}</option>";
444 $form->{selectshipto} = $form->unquote($form->{selectshipto});
445 $form->{selectshipto} =~ s/ selected//g;
446 if ($form->{shipto_id} ne "") {
447 $form->{selectshipto} =~ s/value=$form->{shipto_id}/value=$form->{shipto_id} selected/;
452 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
453 <td><select name=shipto_id style="width:200px;">$form->{selectshipto}</select></td>|;
454 $form->{selectshipto} = $form->quote($form->{selectshipto});
455 $shipto .= qq| <input type=hidden name=selectshipto value="$form->{selectshipto}">|;
459 $form->{exchangerate} =
460 $form->format_amount(\%myconfig, $form->{exchangerate});
462 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
468 $form->{creditlimit} =
469 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
470 $form->{creditremaining} =
471 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
474 ($form->{selectcontact})
475 ? qq|<select name=cp_id>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
476 : qq|<input name=contact value="$form->{contact}" size=35>|;
479 <input type=hidden name=forex value=$form->{forex}>
482 if ($form->{currency} ne $form->{defaultcurrency}) {
483 if ($form->{forex}) {
486 . $locale->text('Exchangerate')
487 . qq|</th><td>$form->{exchangerate}</td>
488 <input type=hidden name=exchangerate value=$form->{exchangerate}>
493 . $locale->text('Exchangerate')
494 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
498 $vclabel = ucfirst $form->{vc};
499 $vclabel = $locale->text($vclabel);
503 if ($form->{business}) {
506 <th align=right>| . $locale->text('Business') . qq|</th>
507 <td>$form->{business}</td>
508 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
510 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
516 if ($form->{max_dunning_level}) {
522 <th align=right>| . $locale->text('Max. Dunning Level') . qq|:</th>
523 <td><b>$form->{max_dunning_level}</b></td>
524 <th align=right>| . $locale->text('Dunning Amount') . qq|:</th>
526 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
535 if (@{ $form->{TAXZONE} }) {
536 $form->{selecttaxzone} = "";
537 foreach $item (@{ $form->{TAXZONE} }) {
538 if ($item->{id} == $form->{taxzone_id}) {
539 $form->{selecttaxzone} .=
540 "<option value=$item->{id} selected>" . H($item->{description}) .
543 $form->{selecttaxzone} .=
544 "<option value=$item->{id}>" . H($item->{description}) . "</option>";
549 $form->{selecttaxzone} =~ s/ selected//g;
550 if ($form->{taxzone_id} ne "") {
551 $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}>/value=$form->{taxzone_id} selected>/;
557 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
558 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
559 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
563 if ($form->{type} !~ /_quotation$/) {
566 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
567 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
570 <th width=70% align=right nowrap>|
571 . $locale->text('Quotation Number') . qq|</th>
572 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
575 <th width=70% align=right nowrap>|
576 . $locale->text('Customer Order Number') . qq|</th>
577 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
580 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
585 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
590 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
592 $creditremaining = qq|
598 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
599 <td>$form->{creditlimit}</td>
601 <th nowrap>| . $locale->text('Remaining') . qq|</th>
602 <td class="plus$n" nowrap>$form->{creditremaining}</td>
611 ($form->{type} eq 'sales_quotation')
612 ? $locale->text('Valid until')
613 : $locale->text('Required by');
614 if ($form->{type} eq 'sales_quotation') {
617 <th width=70% align=right nowrap>|
618 . $locale->text('Quotation Number') . qq|</th>
619 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
620 <input type=hidden name=ordnumber value="$form->{ordnumber}">
626 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
627 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
628 <input type=hidden name=ordnumber value="$form->{ordnumber}">
636 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
640 <th align=right nowrap=true>$reqlabel</th>
644 $creditremaining = qq| <tr>
651 ($form->{"select$form->{vc}"})
652 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
653 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
657 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
658 <td colspan=3><select name=department>$form->{selectdepartment}</select>
659 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
662 | if $form->{selectdepartment};
665 <input type=hidden name=employee value="$form->{employee}">
668 if ($form->{type} eq 'sales_order') {
669 if ($form->{selectemployee}) {
671 <input type=hidden name=customer_klass value=$form->{customer_klass}>
673 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
674 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
675 <input type=hidden name=selectemployee value="$form->{selectemployee}">
682 <input type=hidden name=customer_klass value=$form->{customer_klass}>
684 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
685 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
686 <input type=hidden name=selectemployee value="$form->{selectemployee}">
691 if ($form->{resubmit} && ($form->{format} eq "html")) {
693 qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
694 } elsif ($form->{resubmit}) {
695 $onload = qq|document.oe.submit()|;
700 $credittext = $locale->text('Credit Limit exceeded!!!');
701 if ($creditwarning) {
702 $onload = qq|alert('$credittext')|;
705 $form->{"javascript"} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
710 <body onLoad="$onload">
712 <form method=post name=oe action=$form->{script}>
713 <script type="text/javascript" src="js/common.js"></script>
714 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
715 <script type="text/javascript" src="js/vendor_selection.js"></script>
716 <script type="text/javascript" src="js/calculate_qty.js"></script>
718 <input type=hidden name=id value=$form->{id}>
719 <input type=hidden name=action value=$form->{action}>
721 <input type=hidden name=type value=$form->{type}>
722 <input type=hidden name=formname value=$form->{formname}>
723 <input type=hidden name=media value=$form->{media}>
724 <input type=hidden name=format value=$form->{format}>
725 <input type=hidden name=proforma value=$form->{proforma}>
727 <input type=hidden name=queued value="$form->{queued}">
728 <input type=hidden name=printed value="$form->{printed}">
729 <input type=hidden name=emailed value="$form->{emailed}">
731 <input type=hidden name=vc value=$form->{vc}>
733 <input type=hidden name=title value="$form->{title}">
735 <input type=hidden name=discount value=$form->{discount}>
736 <input type=hidden name=creditlimit value=$form->{creditlimit}>
737 <input type=hidden name=creditremaining value=$form->{creditremaining}>
739 <input type=hidden name=tradediscount value=$form->{tradediscount}>
740 <input type=hidden name=business value=$form->{business}>
741 <input type=hidden name=webdav value=$webdav>
745 <th class=listtop>$form->{title}</th>
755 <th align=right>$vclabel</th>
756 <td colspan=3>$vc</td>
757 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
758 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
759 <th align=richt nowrap>|
760 . $locale->text('Contact Person') . qq|</th>
761 <td colspan=3>$contact</td>
769 <th align=right>| . $locale->text('Currency') . qq|</th>
770 <td><select name=currency>$form->{selectcurrency}</select></td>
771 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
772 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
776 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
777 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
780 <th align=right>| . $locale->text('Ship via') . qq|</th>
781 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
788 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
790 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
791 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
795 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
797 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
798 # <input size=45 id=vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
819 <!-- shipto are in hidden variables -->
821 <input type=hidden name=shiptoname value="$form->{shiptoname}">
822 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
823 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
824 <input type=hidden name=shiptocity value="$form->{shiptocity}">
825 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
826 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
827 <input type=hidden name=shiptophone value="$form->{shiptophone}">
828 <input type=hidden name=shiptofax value="$form->{shiptofax}">
829 <input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
830 <input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
831 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
833 <!-- email variables -->
834 <input type=hidden name=message value="$form->{message}">
835 <input type=hidden name=email value="$form->{email}">
836 <input type=hidden name=subject value="$form->{subject}">
837 <input type=hidden name=cc value="$form->{cc}">
838 <input type=hidden name=bcc value="$form->{bcc}">
840 <input type=hidden name=taxpart value="$form->{taxpart}">
841 <input type=hidden name=taxservice value="$form->{taxservice}">
843 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
846 foreach $item (split / /, $form->{taxaccounts}) {
848 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
849 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
852 $lxdebug->leave_sub();
856 $lxdebug->enter_sub();
858 $form->{invtotal} = $form->{invsubtotal};
860 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
863 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
866 $rows = ($rows > $introws) ? $rows : $introws;
868 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
870 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
872 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
875 if ($form->{taxaccounts}) {
877 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
878 . $locale->text('Tax Included') . qq|</b><br><br>
882 if (!$form->{taxincluded}) {
884 foreach $item (split / /, $form->{taxaccounts}) {
885 if ($form->{"${item}_base"}) {
886 $form->{invtotal} += $form->{"${item}_total"} =
888 $form->{"${item}_base"} * $form->{"${item}_rate"},
890 $form->{"${item}_total"} =
891 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
895 <th align=right>$form->{"${item}_description"}</th>
896 <td align=right>$form->{"${item}_total"}</td>
902 $form->{invsubtotal} =
903 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
907 <th align=right>| . $locale->text('Subtotal') . qq|</th>
908 <td align=right>$form->{invsubtotal}</td>
914 if ($form->{taxincluded}) {
915 foreach $item (split / /, $form->{taxaccounts}) {
916 if ($form->{"${item}_base"}) {
917 $form->{"${item}_total"} =
919 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
920 (1 + $form->{"${item}_rate"})
923 $form->{"${item}_netto"} =
925 ($form->{"${item}_base"} - $form->{"${item}_total"}),
927 $form->{"${item}_total"} =
928 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
929 $form->{"${item}_netto"} =
930 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
934 <th align=right>Enthaltene $form->{"${item}_description"}</th>
935 <td align=right>$form->{"${item}_total"}</td>
938 <th align=right>Nettobetrag</th>
939 <td align=right>$form->{"${item}_netto"}</td>
947 $form->{oldinvtotal} = $form->{invtotal};
949 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
959 <th align=left>| . $locale->text('Notes') . qq|</th>
960 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
966 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
967 <td><select name=payment_id tabindex=24>$payment
971 <td align=right width=100%>
977 <th align=right>| . $locale->text('Total') . qq|</th>
978 <td align=right>$form->{invtotal}</td>
986 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
987 <input type=hidden name=oldtotalpaid value=$totalpaid>
989 <td><hr size=3 noshade></td>
997 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
1000 <td align=left width=30%><b>Dateiname</b></td>
1001 <td align=left width=70%><b>Webdavlink</b></td>
1003 foreach $file (keys %{ $form->{WEBDAV} }) {
1006 <td align=left>$file</td>
1007 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
1015 <td><hr size=3 noshade></td>
1022 <input type=hidden name=jscalendar value=$form->{jscalendar}>
1035 | . $locale->text("Edit the $form->{type}") . qq|<br>
1036 <input class=submit type=submit name=action id=update_button value="|
1037 . $locale->text('Update') . qq|">
1038 <input class=submit type=submit name=action value="|
1039 . $locale->text('Ship to') . qq|">
1040 <input class=submit type=submit name=action value="|
1041 . $locale->text('Print') . qq|">
1042 <input class=submit type=submit name=action value="|
1043 . $locale->text('E-mail') . qq|">
1044 <input class=submit type=submit name=action value="|
1045 . $locale->text('Save') . qq|">
1046 <input class=submit type=submit name=action value="|
1047 . $locale->text('Save and Close') . qq|">
1050 if (($form->{id})) {
1052 <br>| . $locale->text("Workflow $form->{type}") . qq|<br>
1053 <input class=submit type=submit name=action value="|
1054 . $locale->text('Save as new') . qq|">
1055 <input class=submit type=submit name=action value="|
1056 . $locale->text('Delete') . qq|">|;
1057 if (($form->{type} =~ /sales_quotation$/)) {
1059 <input class=submit type=submit name=action value="|
1060 . $locale->text('Sales Order') . qq|">|;
1062 if ($form->{type} =~ /request_quotation$/) {
1064 <input class=submit type=submit name=action value="|
1065 . $locale->text('Purchase Order') . qq|">|;
1069 <input class=submit type=submit name=action value="|
1070 . $locale->text('Invoice') . qq|">
1074 if ($form->{type} =~ /sales_order$/) {
1076 <br>$form->{heading} als neue Vorlage verwenden für<br>
1077 <input class=submit type=submit name=action value="|
1078 . $locale->text('Purchase Order') . qq|">
1079 <input class=submit type=submit name=action value="|
1080 . $locale->text('Quotation') . qq|">
1083 } elsif ($form->{type} =~ /purchase_order$/) {
1085 <br>$form->{heading} als neue Vorlage verwenden für<br>
1086 <input class=submit type=submit name=action value="|
1087 . $locale->text('Sales Order') . qq|">
1088 <input class=submit type=submit name=action value="|
1089 . $locale->text('Request for Quotation') . qq|">
1094 <br>$form->{heading} als neue Vorlage verwenden für<br>
1095 <input class=submit type=submit name=action value="|
1096 . $locale->text('Order') . qq|">
1099 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount} && !$form->{proforma}) {
1101 <br>Workflow $form->{heading}<br>
1102 <input class=submit type=submit name=action value="|
1103 . $locale->text('Save as new') . qq|">
1104 <input class=submit type=submit name=action value="|
1105 . $locale->text('Invoice') . qq|">
1111 <input type=hidden name=rowcount value=$form->{rowcount}>
1113 <input name=callback type=hidden value="$form->{callback}">
1115 <input type=hidden name=path value=$form->{path}>
1116 <input type=hidden name=login value=$form->{login}>
1117 <input type=hidden name=password value=$form->{password}>
1124 $lxdebug->leave_sub();
1128 $lxdebug->enter_sub();
1130 set_headings($form->{"id"} ? "edit" : "add");
1132 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1133 qw(exchangerate creditlimit creditremaining);
1134 $form->{update} = 1;
1136 &check_name($form->{vc});
1141 $buysell = 'sell' if ($form->{vc} eq 'vendor');
1142 $form->{exchangerate} = $exchangerate
1146 $form->check_exchangerate(
1147 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1151 $i = $form->{rowcount};
1153 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1155 if ( ($form->{"partnumber_$i"} eq "")
1156 && ($form->{"description_$i"} eq "")
1157 && ($form->{"partsgroup_$i"} eq "")) {
1159 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1164 if ( $form->{type} eq 'purchase_order'
1165 || $form->{type} eq 'request_quotation') {
1166 IR->retrieve_item(\%myconfig, \%$form);
1168 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1169 IS->retrieve_item(\%myconfig, \%$form);
1172 my $rows = scalar @{ $form->{item_list} };
1174 $form->{"discount_$i"} =
1175 $form->format_amount(\%myconfig, $form->{discount} * 100);
1178 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1187 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1188 if ($form->{"not_discountable_$i"}) {
1189 $form->{"discount_$i"} = 0;
1191 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1192 qw(partnumber description unit);
1193 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1194 keys %{ $form->{item_list}[0] };
1195 if ($form->{"part_payment_id_$i"} ne "") {
1196 $form->{payment_id} = $form->{"part_payment_id_$i"};
1199 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1201 ($dec) = ($s =~ /\.(\d+)/);
1203 $decimalplaces = ($dec > 2) ? $dec : 2;
1206 $form->{"sellprice_$i"} = $sellprice;
1209 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1211 # if there is an exchange rate adjust sellprice
1212 $form->{"sellprice_$i"} /= $exchangerate;
1216 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1217 (1 - $form->{"discount_$i"} / 100);
1218 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1219 map { $form->{"${_}_base"} += $amount }
1220 (split / /, $form->{"taxaccounts_$i"});
1221 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1222 split / /, $form->{taxaccounts}
1223 if !$form->{taxincluded};
1225 $form->{creditremaining} -= $amount;
1227 $form->{"sellprice_$i"} =
1228 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1231 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1233 # get pricegroups for parts
1234 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1236 # build up html code for prices_$i
1237 &set_pricegroup($i);
1244 # ok, so this is a new part
1245 # ask if it is a part or service item
1247 if ( $form->{"partsgroup_$i"}
1248 && ($form->{"partsnumber_$i"} eq "")
1249 && ($form->{"description_$i"} eq "")) {
1250 $form->{rowcount}--;
1251 $form->{"discount_$i"} = "";
1255 $form->{"id_$i"} = 0;
1256 $form->{"unit_$i"} = $locale->text('ea');
1264 $lxdebug->leave_sub();
1268 $lxdebug->enter_sub();
1270 if ($form->{type} eq 'purchase_order') {
1271 $form->{title} = $locale->text('Purchase Orders');
1272 $form->{vc} = 'vendor';
1273 $ordlabel = $locale->text('Order Number');
1274 $ordnumber = 'ordnumber';
1275 $employee = $locale->text('Employee');
1277 if ($form->{type} eq 'request_quotation') {
1278 $form->{title} = $locale->text('Request for Quotations');
1279 $form->{vc} = 'vendor';
1280 $ordlabel = $locale->text('RFQ Number');
1281 $ordnumber = 'quonumber';
1282 $employee = $locale->text('Employee');
1284 if ($form->{type} eq 'receive_order') {
1285 $form->{title} = $locale->text('Receive Merchandise');
1286 $form->{vc} = 'vendor';
1287 $ordlabel = $locale->text('Order Number');
1288 $ordnumber = 'ordnumber';
1289 $employee = $locale->text('Employee');
1291 if ($form->{type} eq 'sales_order') {
1292 $form->{title} = $locale->text('Sales Orders');
1293 $form->{vc} = 'customer';
1294 $ordlabel = $locale->text('Order Number');
1295 $ordnumber = 'ordnumber';
1296 $employee = $locale->text('Salesperson');
1298 if ($form->{type} eq 'ship_order') {
1299 $form->{title} = $locale->text('Ship Merchandise');
1300 $form->{vc} = 'customer';
1301 $ordlabel = $locale->text('Order Number');
1302 $ordnumber = 'ordnumber';
1303 $employee = $locale->text('Salesperson');
1307 if ($form->{type} eq 'sales_quotation') {
1308 $form->{title} = $locale->text('Quotations');
1309 $form->{vc} = 'customer';
1310 $ordlabel = $locale->text('Quotation Number');
1311 $ordnumber = 'quonumber';
1312 $employee = $locale->text('Employee');
1315 if ($form->{type} =~ /(ship|receive)_order/) {
1316 OE->get_warehouses(\%myconfig, \%$form);
1319 if (@{ $form->{all_warehouses} }) {
1320 $form->{selectwarehouse} = "<option>\n";
1321 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1324 $form->{selectwarehouse} .=
1325 "<option>$_->{description}--$_->{id}\n"
1326 } (@{ $form->{all_warehouses} });
1330 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1331 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1332 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1339 # setup vendor / customer selection
1340 $form->all_vc(\%myconfig, $form->{vc},
1341 ($form->{vc} eq 'customer') ? "AR" : "AP");
1343 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1344 @{ $form->{"all_$form->{vc}"} };
1346 $vclabel = ucfirst $form->{vc};
1347 $vclabel = $locale->text($vclabel);
1349 # $locale->text('Vendor')
1350 # $locale->text('Customer')
1354 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1355 : qq|<input name=$form->{vc} size=35>|;
1358 if (@{ $form->{all_departments} }) {
1359 $form->{selectdepartment} = "<option>\n";
1362 $form->{selectdepartment} .=
1363 "<option>$_->{description}--$_->{id}\n"
1364 } (@{ $form->{all_departments} });
1369 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1370 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1372 | if $form->{selectdepartment};
1374 if ($form->{type} !~ /(ship_order|receive_order)/) {
1377 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1378 . $locale->text('Open') . qq|</td>
1379 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1380 . $locale->text('Closed') . qq|</td>
1386 <input type=hidden name="open" value=1>
1391 if (($form->{"type"} eq "sales_order") ||
1392 ($form->{"type"} eq "purchase_order")) {
1395 <td><input name="notdelivered" id="notdelivered" class="checkbox" type="checkbox" value="1" checked>
1396 <label for="notdelivered">|. $locale->text('Not delivered') . qq|</label></td>
1397 <td><input name="delivered" id="delivered" class="checkbox" type="checkbox" value="1" checked>
1398 <label for="delivered">| . $locale->text('Delivered') . qq|</label></td>
1403 # use JavaScript Calendar or not
1404 $form->{jsscript} = $jscalendar;
1406 if ($form->{jsscript}) {
1408 # with JavaScript Calendar
1410 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1411 <input type=button name=transdatefrom id="trigger3" value=|
1412 . $locale->text('button') . qq|></td>
1415 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1416 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1417 . $locale->text('button') . qq|></td>
1422 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1423 "transdateto", "BL", "trigger4");
1426 # without JavaScript Calendar
1428 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1430 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1438 <form method=post action=$form->{script}>
1442 <th class=listtop>$form->{title}</th>
1444 <tr height="5"></tr>
1449 <th align=right>$vclabel</th>
1450 <td colspan=3>$vc</td>
1455 <th align=right>$ordlabel</th>
1456 <td colspan=3><input name="$ordnumber" size=20></td>
1459 <th align=right>| . $locale->text('From') . qq|</th>
1461 <th align=right>| . $locale->text('Bis') . qq|</th>
1464 <input type=hidden name=sort value=transdate>
1466 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1472 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1473 | . $locale->text('ID') . qq|</td>
1474 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1475 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1476 . $locale->text('Date') . qq|</td>
1477 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1478 . $locale->text('Required by') . qq|</td>
1481 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1482 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1483 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1484 . $locale->text('Ship via') . qq|</td>
1487 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1488 . $locale->text('Amount') . qq|</td>
1489 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1490 . $locale->text('Tax') . qq|</td>
1491 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1492 . $locale->text('Total') . qq|</td>
1495 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1496 . $locale->text('Subtotal') . qq|</td>
1504 <tr><td colspan=4><hr size=3 noshade></td></tr>
1510 <input type=hidden name=nextsub value=orders>
1511 <input type=hidden name=path value=$form->{path}>
1512 <input type=hidden name=login value=$form->{login}>
1513 <input type=hidden name=password value=$form->{password}>
1514 <input type=hidden name=vc value=$form->{vc}>
1515 <input type=hidden name=type value=$form->{type}>
1517 <input class=submit type=submit name=action value="|
1518 . $locale->text('Continue') . qq|">
1525 $lxdebug->leave_sub();
1529 $lxdebug->enter_sub();
1531 # split vendor / customer
1532 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1533 split(/--/, $form->{ $form->{vc} });
1535 OE->transactions(\%myconfig, \%$form);
1537 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1539 $number = $form->escape($form->{$ordnumber});
1540 $name = $form->escape($form->{ $form->{vc} });
1541 $department = $form->escape($form->{department});
1542 $warehouse = $form->escape($form->{warehouse});
1546 "$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}¬delivered=$form->{notdelivered}&delivered=$form->{delivered}&$ordnumber=$number&$form->{vc}=$name&department=$department&warehouse=$warehouse";
1548 # construct callback
1549 $number = $form->escape($form->{$ordnumber}, 1);
1550 $name = $form->escape($form->{ $form->{vc} }, 1);
1551 $department = $form->escape($form->{department}, 1);
1552 $warehouse = $form->escape($form->{warehouse}, 1);
1555 "$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}¬delivered=$form->{notdelivered}&delivered=$form->{delivered}&$ordnumber=$number&$form->{vc}=$name&department=$department&warehouse=$warehouse";
1558 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1559 "name", "netamount", "tax", "amount",
1560 "curr", "employee", "shipvia", "open",
1561 "closed", "delivered");
1563 $form->{l_open} = $form->{l_closed} = "Y"
1564 if ($form->{open} && $form->{closed});
1566 $form->{"l_delivered"} = "Y"
1567 if ($form->{"delivered"} && $form->{"notdelivered"});
1569 foreach $item (@columns) {
1570 if ($form->{"l_$item"} eq "Y") {
1571 push @column_index, $item;
1573 # add column to href and callback
1574 $callback .= "&l_$item=Y";
1575 $href .= "&l_$item=Y";
1579 # only show checkboxes if gotten here via sales_order form.
1580 if ($form->{type} =~ /sales_order/) {
1581 unshift @column_index, "ids";
1584 if ($form->{l_subtotal} eq 'Y') {
1585 $callback .= "&l_subtotal=Y";
1586 $href .= "&l_subtotal=Y";
1589 if ($form->{vc} eq 'vendor') {
1590 if ($form->{type} eq 'receive_order') {
1591 $form->{title} = $locale->text('Receive Merchandise');
1592 } elsif ($form->{type} eq 'purchase_order') {
1593 $form->{title} = $locale->text('Purchase Orders');
1595 $form->{title} = $locale->text('Request for Quotations');
1597 $name = $locale->text('Vendor');
1598 $employee = $locale->text('Employee');
1600 if ($form->{vc} eq 'customer') {
1601 if ($form->{type} eq 'sales_order') {
1602 $form->{title} = $locale->text('Sales Orders');
1603 $employee = $locale->text('Salesperson');
1604 } elsif ($form->{type} eq 'ship_order') {
1605 $form->{title} = $locale->text('Ship Merchandise');
1606 $employee = $locale->text('Salesperson');
1608 $form->{title} = $locale->text('Quotations');
1609 $employee = $locale->text('Employee');
1611 $name = $locale->text('Customer');
1614 $column_header{id} =
1615 qq|<th><a class=listheading href=$href&sort=id>|
1616 . $locale->text('ID')
1618 $column_header{transdate} =
1619 qq|<th><a class=listheading href=$href&sort=transdate>|
1620 . $locale->text('Date')
1622 $column_header{reqdate} =
1623 qq|<th><a class=listheading href=$href&sort=reqdate>|
1624 . $locale->text('Required by')
1626 $column_header{ordnumber} =
1627 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1628 . $locale->text('Order')
1630 $column_header{quonumber} =
1631 qq|<th><a class=listheading href=$href&sort=quonumber>|
1632 . ($form->{"type"} eq "request_quotation" ?
1633 $locale->text('RFQ') :
1634 $locale->text('Quotation'))
1636 $column_header{name} =
1637 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1638 $column_header{netamount} =
1639 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1640 $column_header{tax} =
1641 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1642 $column_header{amount} =
1643 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1644 $column_header{curr} =
1645 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1646 $column_header{shipvia} =
1647 qq|<th><a class=listheading href=$href&sort=shipvia>|
1648 . $locale->text('Ship via')
1650 $column_header{open} =
1651 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1652 $column_header{closed} =
1653 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1654 $column_header{"delivered"} =
1655 qq|<th class="listheading">| . $locale->text("Delivered") . qq|</th>|;
1657 $column_header{employee} =
1658 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1660 $column_header{ids} = qq|<th></th>|;
1662 if ($form->{ $form->{vc} }) {
1663 $option = $locale->text(ucfirst $form->{vc});
1664 $option .= " : $form->{$form->{vc}}";
1666 if ($form->{warehouse}) {
1667 ($warehouse) = split /--/, $form->{warehouse};
1668 $option .= "\n<br>" if ($option);
1669 $option .= $locale->text('Warehouse');
1670 $option .= " : $warehouse";
1672 if ($form->{department}) {
1673 $option .= "\n<br>" if ($option);
1674 ($department) = split /--/, $form->{department};
1675 $option .= $locale->text('Department') . " : $department";
1677 if ($form->{transdatefrom}) {
1679 . $locale->text('From') . " "
1680 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1682 if ($form->{transdateto}) {
1684 . $locale->text('Bis') . " "
1685 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1687 if ($form->{open}) {
1688 $option .= "\n<br>" if ($option);
1689 $option .= $locale->text('Open');
1691 if ($form->{closed}) {
1692 $option .= "\n<br>" if ($option);
1693 $option .= $locale->text('Closed');
1701 <form method="post" action="oe.pl">
1704 <th class=listtop>$form->{title}</th>
1706 <tr height="5"></tr>
1713 <tr class=listheading>|;
1715 map { print "\n$column_header{$_}" } @column_index;
1721 # add sort and escape callback
1722 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1724 if (@{ $form->{OE} }) {
1725 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1729 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1731 $warehouse = $form->escape($form->{warehouse});
1733 foreach $oe (@{ $form->{OE} }) {
1734 $form->{rowcount} = ++$j;
1736 if ($form->{l_subtotal} eq 'Y') {
1737 if ($sameitem ne $oe->{ $form->{sort} }) {
1739 $sameitem = $oe->{ $form->{sort} };
1743 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1745 $column_data{netamount} =
1747 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1749 $column_data{tax} = "<td align=right>"
1750 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1753 $column_data{amount} =
1755 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1757 $totalnetamount += $oe->{netamount};
1758 $totalamount += $oe->{amount};
1760 $subtotalnetamount += $oe->{netamount};
1761 $subtotalamount += $oe->{amount};
1764 qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1765 $column_data{id} = "<td>$oe->{id}</td>";
1766 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1767 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1769 $column_data{$ordnumber} =
1770 "<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>";
1771 $column_data{name} = "<td>$oe->{name}</td>";
1773 $column_data{employee} = "<td>$oe->{employee} </td>";
1774 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1776 if ($oe->{closed}) {
1777 $column_data{closed} = "<td align=center>X</td>";
1778 $column_data{open} = "<td> </td>";
1780 $column_data{closed} = "<td> </td>";
1781 $column_data{open} = "<td align=center>X</td>";
1783 $column_data{"delivered"} = "<td>" .
1784 ($oe->{"delivered"} ? $locale->text("Yes") : $locale->text("No")) .
1790 <tr class=listrow$i>";
1792 map { print "\n$column_data{$_}" } @column_index;
1800 if ($form->{l_subtotal} eq 'Y') {
1806 <tr class=listtotal>|;
1808 map { $column_data{$_} = "<td> </td>" } @column_index;
1810 $column_data{netamount} =
1811 "<th class=listtotal align=right>"
1812 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1813 $column_data{tax} = "<th class=listtotal align=right>"
1814 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1817 $column_data{amount} =
1818 "<th class=listtotal align=right>"
1819 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1821 map { print "\n$column_data{$_}" } @column_index;
1829 <td><hr size=3 noshade></td>
1833 # multiple invoice edit button only if gotten there via sales_order form.
1835 if ($form->{type} =~ /sales_order/) {
1837 <input type="hidden" name="path" value="$form->{path}">
1838 <input class"submit" type="submit" name="action" value="|
1839 . $locale->text('Continue') . qq|">
1840 <input type="hidden" name="nextsub" value="edit">
1841 <input type="hidden" name="type" value="$form->{type}">
1842 <input type="hidden" name="warehouse" value="$warehouse">
1843 <input type="hidden" name="vc" value="$form->{vc}">
1844 <input type="hidden" name="login" value="$form->{login}">
1845 <input type="hidden" name="password" value="$form->{password}">
1846 <input type="hidden" name="callback" value="$callback">
1847 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1854 <form method=post action=$form->{script}>
1856 <input name=callback type=hidden value="$form->{callback}">
1858 <input type=hidden name=type value=$form->{type}>
1859 <input type=hidden name=vc value=$form->{vc}>
1861 <input type=hidden name=path value=$form->{path}>
1862 <input type=hidden name=login value=$form->{login}>
1863 <input type=hidden name=password value=$form->{password}>
1866 if ($form->{type} !~ /(ship|receive)_order/) {
1868 <input class=submit type=submit name=action value="|
1869 . $locale->text('Add') . qq|">|;
1879 $lxdebug->leave_sub();
1883 $lxdebug->enter_sub();
1885 map { $column_data{$_} = "<td> </td>" } @column_index;
1887 $column_data{netamount} =
1888 "<th class=listsubtotal align=right>"
1889 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1891 $column_data{tax} = "<td class=listsubtotal align=right>"
1892 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1895 $column_data{amount} =
1896 "<th class=listsubtotal align=right>"
1897 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1899 $subtotalnetamount = 0;
1900 $subtotalamount = 0;
1903 <tr class=listsubtotal>
1906 map { print "\n$column_data{$_}" } @column_index;
1912 $lxdebug->leave_sub();
1915 sub save_and_close {
1916 $lxdebug->enter_sub();
1918 if ($form->{type} =~ /_order$/) {
1919 $form->isblank("transdate", $locale->text('Order Date missing!'));
1921 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1924 $msg = ucfirst $form->{vc};
1925 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1927 # $locale->text('Customer missing!');
1928 # $locale->text('Vendor missing!');
1930 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1931 if ($form->{currency} ne $form->{defaultcurrency});
1935 # if the name changed get new values
1936 if (&check_name($form->{vc})) {
1941 $form->{id} = 0 if $form->{saveasnew};
1943 # this is for the internal notes section for the [email] Subject
1944 if ($form->{type} =~ /_order$/) {
1945 if ($form->{type} eq 'sales_order') {
1946 $form->{label} = $locale->text('Sales Order');
1948 $numberfld = "sonumber";
1949 $ordnumber = "ordnumber";
1951 $form->{label} = $locale->text('Purchase Order');
1953 $numberfld = "ponumber";
1954 $ordnumber = "ordnumber";
1957 $err = $locale->text('Cannot save order!');
1960 if ($form->{type} eq 'sales_quotation') {
1961 $form->{label} = $locale->text('Quotation');
1963 $numberfld = "sqnumber";
1964 $ordnumber = "quonumber";
1966 $form->{label} = $locale->text('Request for Quotation');
1968 $numberfld = "rfqnumber";
1969 $ordnumber = "quonumber";
1972 $err = $locale->text('Cannot save quotation!');
1976 # get new number in sequence if no number is given or if saveasnew was requested
1977 if (!$form->{$ordnumber} || $form->{saveasnew}) {
1978 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
1984 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1985 if (OE->save(\%myconfig, \%$form));
1988 $lxdebug->leave_sub();
1992 $lxdebug->enter_sub();
1994 if ($form->{type} =~ /_order$/) {
1995 $form->isblank("transdate", $locale->text('Order Date missing!'));
1997 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2000 $msg = ucfirst $form->{vc};
2001 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
2003 # $locale->text('Customer missing!');
2004 # $locale->text('Vendor missing!');
2006 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
2007 if ($form->{currency} ne $form->{defaultcurrency});
2011 # if the name changed get new values
2012 if (&check_name($form->{vc})) {
2017 $form->{id} = 0 if $form->{saveasnew};
2019 # this is for the internal notes section for the [email] Subject
2020 if ($form->{type} =~ /_order$/) {
2021 if ($form->{type} eq 'sales_order') {
2022 $form->{label} = $locale->text('Sales Order');
2024 $numberfld = "sonumber";
2025 $ordnumber = "ordnumber";
2027 $form->{label} = $locale->text('Purchase Order');
2029 $numberfld = "ponumber";
2030 $ordnumber = "ordnumber";
2033 $err = $locale->text('Cannot save order!');
2036 if ($form->{type} eq 'sales_quotation') {
2037 $form->{label} = $locale->text('Quotation');
2039 $numberfld = "sqnumber";
2040 $ordnumber = "quonumber";
2042 $form->{label} = $locale->text('Request for Quotation');
2044 $numberfld = "rfqnumber";
2045 $ordnumber = "quonumber";
2048 $err = $locale->text('Cannot save quotation!');
2052 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
2053 unless $form->{$ordnumber};
2057 OE->save(\%myconfig, \%$form);
2058 $form->{simple_save} = 1;
2059 if(!$form->{print_and_save}) {
2060 set_headings("edit");
2064 $lxdebug->leave_sub();
2068 $lxdebug->enter_sub();
2072 if ($form->{type} =~ /_order$/) {
2073 $msg = $locale->text('Are you sure you want to delete Order Number');
2074 $ordnumber = 'ordnumber';
2076 $msg = $locale->text('Are you sure you want to delete Quotation Number');
2077 $ordnumber = 'quonumber';
2083 <form method=post action=$form->{script}>
2086 # delete action variable
2087 map { delete $form->{$_} } qw(action header);
2089 foreach $key (keys %$form) {
2090 $form->{$key} =~ s/\"/"/g;
2091 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2095 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
2097 <h4>$msg $form->{$ordnumber}</h4>
2099 <input name=action class=submit type=submit value="|
2100 . $locale->text('Yes') . qq|">
2107 $lxdebug->leave_sub();
2111 $lxdebug->enter_sub();
2113 if ($form->{type} =~ /_order$/) {
2114 $msg = $locale->text('Order deleted!');
2115 $err = $locale->text('Cannot delete order!');
2117 $msg = $locale->text('Quotation deleted!');
2118 $err = $locale->text('Cannot delete quotation!');
2121 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
2124 $lxdebug->leave_sub();
2128 $lxdebug->enter_sub();
2130 if ($form->{type} =~ /_order$/) {
2132 # these checks only apply if the items don't bring their own ordnumbers/transdates.
2133 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
2134 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
2135 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2137 $form->isblank("transdate", $locale->text('Order Date missing!'))
2138 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2141 # also copy deliverydate from the order
2142 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
2144 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
2145 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2146 $form->{ordnumber} = "";
2149 # if the name changed get new values
2150 if (&check_name($form->{vc})) {
2155 $form->{cp_id} *= 1;
2157 for $i (1 .. $form->{rowcount}) {
2158 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
2159 $form->{"${_}_${i}"})
2160 if ($form->{"${_}_${i}"}) }
2161 qw(ship qty sellprice listprice basefactor));
2164 if ( $form->{type} =~ /_order/
2165 && $form->{currency} ne $form->{defaultcurrency}) {
2167 # check if we need a new exchangerate
2168 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
2170 $orddate = $form->current_date(\%myconfig);
2172 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
2175 if (!$exchangerate) {
2176 &backorder_exchangerate($orddate, $buysell);
2181 # close orders/quotations
2182 $form->{closed} = 1;
2184 # save order if one ordnumber has been given
2185 # if not it's most likely a collective order, which can't be saved back
2186 # so they just have to be closed
2187 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
2188 OE->close_order(\%myconfig, \%$form);
2190 OE->close_orders(\%myconfig, \%$form);
2193 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
2195 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2198 $form->{closed} = 0;
2199 $form->{rowcount}--;
2200 $form->{shipto} = 1;
2202 if ($form->{type} =~ /_order$/) {
2203 $form->{exchangerate} = $exchangerate;
2207 if ( $form->{type} eq 'purchase_order'
2208 || $form->{type} eq 'request_quotation') {
2209 $form->{title} = $locale->text('Add Vendor Invoice');
2210 $form->{script} = 'ir.pl';
2214 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
2215 $form->{title} = $locale->text('Add Sales Invoice');
2216 $form->{script} = 'is.pl';
2221 # bo creates the id, reset it
2222 map { delete $form->{$_} }
2223 qw(id subject message cc bcc printed emailed queued);
2224 $form->{ $form->{vc} } =~ s/--.*//g;
2225 $form->{type} = "invoice";
2228 $locale = new Locale "$myconfig{countrycode}", "$script";
2230 require "$form->{path}/$form->{script}";
2232 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
2234 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2235 qw(creditlimit creditremaining);
2237 $currency = $form->{currency};
2240 $form->{currency} = $currency;
2241 $form->{exchangerate} = "";
2242 $form->{forex} = "";
2243 $form->{exchangerate} = $exchangerate
2247 $form->check_exchangerate(
2248 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
2251 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
2256 for $i (1 .. $form->{rowcount}) {
2257 $form->{"discount_$i"} =
2258 $form->format_amount(\%myconfig, $form->{"discount_$i"});
2260 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
2262 $decimalplaces = ($dec > 2) ? $dec : 2;
2264 # copy delivery date from reqdate for order -> invoice conversion
2265 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
2266 unless $form->{"deliverydate_$i"};
2268 $form->{"sellprice_$i"} =
2269 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
2272 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
2273 $dec_qty = length $dec_qty;
2275 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
2277 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2278 qw(partnumber description unit);
2284 $lxdebug->leave_sub();
2287 sub backorder_exchangerate {
2288 $lxdebug->enter_sub();
2289 my ($orddate, $buysell) = @_;
2296 <form method=post action=$form->{script}>
2299 # delete action variable
2300 map { delete $form->{$_} } qw(action header exchangerate);
2302 foreach $key (keys %$form) {
2303 $form->{$key} =~ s/\"/"/g;
2304 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2307 $form->{title} = $locale->text('Add Exchangerate');
2311 <input type=hidden name=path value=$form->{path}>
2312 <input type=hidden name=login value=$form->{login}>
2313 <input type=hidden name=password value=$form->{password}>
2315 <input type=hidden name=exchangeratedate value=$orddate>
2316 <input type=hidden name=buysell value=$buysell>
2319 <tr><th class=listtop>$form->{title}</th></tr>
2320 <tr height="5"></tr>
2325 <th align=right>| . $locale->text('Currency') . qq|</th>
2326 <td>$form->{currency}</td>
2329 <th align=right>| . $locale->text('Date') . qq|</th>
2333 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2334 <td><input name=exchangerate size=11></td>
2344 <input type=hidden name=nextsub value=save_exchangerate>
2346 <input name=action class=submit type=submit value="|
2347 . $locale->text('Continue') . qq|">
2355 $lxdebug->leave_sub();
2358 sub save_exchangerate {
2359 $lxdebug->enter_sub();
2361 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2362 $form->{exchangerate} =
2363 $form->parse_amount(\%myconfig, $form->{exchangerate});
2364 $form->save_exchangerate(\%myconfig, $form->{currency},
2365 $form->{exchangeratedate},
2366 $form->{exchangerate}, $form->{buysell});
2370 $lxdebug->leave_sub();
2373 sub create_backorder {
2374 $lxdebug->enter_sub();
2376 $form->{shipped} = 1;
2378 # figure out if we need to create a backorder
2379 # items aren't saved if qty != 0
2381 for $i (1 .. $form->{rowcount}) {
2382 $totalqty += $qty = $form->{"qty_$i"};
2383 $totalship += $ship = $form->{"ship_$i"};
2385 $form->{"qty_$i"} = $qty - $ship;
2388 if ($totalship == 0) {
2389 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2390 $form->{ordtotal} = 0;
2391 $form->{shipped} = 0;
2395 if ($totalqty == $totalship) {
2396 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2397 $form->{ordtotal} = 0;
2402 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2405 for $i (1 .. $form->{rowcount}) {
2407 $form->{"${_}_$i"} =
2408 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2409 } qw(sellprice discount);
2414 OE->save(\%myconfig, \%$form);
2416 # rebuild rows for invoice
2420 for $i (1 .. $form->{rowcount}) {
2421 $form->{"qty_$i"} = $form->{"ship_$i"};
2423 if ($form->{"qty_$i"}) {
2426 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2431 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2432 $form->{rowcount} = $count;
2434 $lxdebug->leave_sub();
2438 $lxdebug->enter_sub();
2440 $form->{saveasnew} = 1;
2441 $form->{closed} = 0;
2442 map { delete $form->{$_} } qw(printed emailed queued ordnumber quonumber);
2446 $lxdebug->leave_sub();
2449 sub purchase_order {
2450 $lxdebug->enter_sub();
2452 if ( $form->{type} eq 'sales_quotation'
2453 || $form->{type} eq 'request_quotation') {
2454 OE->close_order(\%myconfig, \%$form);
2457 $form->{cp_id} *= 1;
2459 $form->{title} = $locale->text('Add Purchase Order');
2460 $form->{vc} = "vendor";
2461 $form->{type} = "purchase_order";
2465 $lxdebug->leave_sub();
2469 $lxdebug->enter_sub();
2471 if ( $form->{type} eq 'sales_quotation'
2472 || $form->{type} eq 'request_quotation') {
2473 OE->close_order(\%myconfig, $form);
2476 $form->{cp_id} *= 1;
2478 $form->{title} = $locale->text('Add Sales Order');
2479 $form->{vc} = "customer";
2480 $form->{type} = "sales_order";
2484 $lxdebug->leave_sub();
2488 $lxdebug->enter_sub();
2490 $form->{transdate} = $form->current_date(\%myconfig);
2491 delete $form->{duedate};
2493 $form->{closed} = 0;
2496 map { delete $form->{$_} }
2497 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2499 for $i (1 .. $form->{rowcount}) {
2500 map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
2501 $form->{"${_}_${i}"})
2502 if ($form->{"${_}_${i}"}) }
2503 qw(ship qty sellprice listprice basefactor));
2511 for $i (1 .. $form->{rowcount} - 1) {
2512 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2513 qw(partnumber description unit);
2516 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2517 qw(creditlimit creditremaining);
2521 $lxdebug->leave_sub();
2525 $lxdebug->enter_sub();
2531 OE->get_warehouses(\%myconfig, \%$form);
2534 if (@{ $form->{all_warehouses} }) {
2535 $form->{selectwarehouse} = "<option>\n";
2537 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2538 (@{ $form->{all_warehouses} });
2540 if ($form->{warehouse}) {
2541 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2545 $form->{shippingdate} = $form->current_date(\%myconfig);
2546 $form->{"$form->{vc}"} =~ s/--.*//;
2551 foreach $key (keys %$form) {
2552 if ($key =~ /_1$/) {
2558 for $i (1 .. $form->{rowcount}) {
2560 # undo formatting from prepare_order
2562 $form->{"${_}_$i"} =
2563 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2565 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2567 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2568 $form->{"ship_$i"} = "";
2569 $form->{"serialnumber_$i"} = "";
2574 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2579 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2580 $form->{rowcount} = $count;
2582 &display_ship_receive;
2584 $lxdebug->leave_sub();
2587 sub display_ship_receive {
2588 $lxdebug->enter_sub();
2590 $vclabel = ucfirst $form->{vc};
2591 $vclabel = $locale->text($vclabel);
2593 $form->{rowcount}++;
2595 if ($form->{vc} eq 'customer') {
2596 $form->{title} = $locale->text('Ship Merchandise');
2597 $shipped = $locale->text('Shipping Date');
2599 $form->{title} = $locale->text('Receive Merchandise');
2600 $shipped = $locale->text('Date Received');
2603 # set option selected
2604 foreach $item (warehouse, employee) {
2605 $form->{"select$item"} =~ s/ selected//;
2606 $form->{"select$item"} =~
2607 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2612 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2613 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2614 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2616 | if $form->{selectwarehouse};
2620 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2621 <td><select name=employee>$form->{selectemployee}</select></td>
2622 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2631 <form method=post action=$form->{script}>
2633 <input type=hidden name=id value=$form->{id}>
2635 <input type=hidden name=display_form value=display_ship_receive>
2637 <input type=hidden name=type value=$form->{type}>
2638 <input type=hidden name=media value=$form->{media}>
2639 <input type=hidden name=format value=$form->{format}>
2641 <input type=hidden name=queued value="$form->{queued}">
2642 <input type=hidden name=printed value="$form->{printed}">
2643 <input type=hidden name=emailed value="$form->{emailed}">
2645 <input type=hidden name=vc value=$form->{vc}>
2649 <th class=listtop>$form->{title}</th>
2651 <tr height="5"></tr>
2654 <table width="100%">
2659 <th align=right>$vclabel</th>
2660 <td colspan=3>$form->{$form->{vc}}</td>
2661 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2662 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2666 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2668 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2671 <th align=right>| . $locale->text('Ship via') . qq|</th>
2673 <input name=shipvia size=35 value="$form->{shipvia}">
2682 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2683 <td>$form->{ordnumber}</td>
2684 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2687 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2688 <td>$form->{transdate}</td>
2689 <input type=hidden name=transdate value=$form->{transdate}>
2692 <th align=right nowrap>$shipped</th>
2693 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2702 <!-- shipto are in hidden variables -->
2704 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2705 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2706 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2707 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2708 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2709 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2710 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2711 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2712 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2713 <input type=hidden name=shiptodepartment_1 value="$form->{shiptodepartment_1}">
2714 <input type=hidden name=shiptodepartment_2 value="$form->{shiptodepartment_2}">
2716 <!-- email variables -->
2717 <input type=hidden name=message value="$form->{message}">
2718 <input type=hidden name=email value="$form->{email}">
2719 <input type=hidden name=subject value="$form->{subject}">
2720 <input type=hidden name=cc value="$form->{cc}">
2721 <input type=hidden name=bcc value="$form->{bcc}">
2726 (partnumber, description, qty, ship, unit, bin, serialnumber);
2728 if ($form->{type} eq "ship_order") {
2729 $column_data{ship} =
2730 qq|<th class=listheading align=center width="auto">|
2731 . $locale->text('Ship')
2734 if ($form->{type} eq "receive_order") {
2735 $column_data{ship} =
2736 qq|<th class=listheading align=center width="auto">|
2737 . $locale->text('Recd')
2741 my $colspan = $#column_index + 1;
2743 $column_data{partnumber} =
2744 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2745 $column_data{description} =
2746 qq|<th class=listheading nowrap>|
2747 . $locale->text('Description')
2750 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2751 $column_data{unit} =
2752 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2754 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2755 $column_data{serialnumber} =
2756 qq|<th class=listheading nowrap>|
2757 . $locale->text('Serial No.')
2764 <tr class=listheading>|;
2766 map { print "\n$column_data{$_}" } @column_index;
2772 for $i (1 .. $form->{rowcount} - 1) {
2775 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2777 # convert " to "
2778 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2779 qw(partnumber description unit bin serialnumber);
2781 $description = $form->{"description_$i"};
2782 $description =~ s/\n/<br>/g;
2784 $column_data{partnumber} =
2785 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2786 $column_data{description} =
2787 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2789 qq|<td align=right>|
2790 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2791 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2792 $column_data{ship} =
2793 qq|<td align=right><input name="ship_$i" size=5 value=|
2794 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2796 $column_data{unit} =
2797 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2799 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2801 $column_data{serialnumber} =
2802 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2807 map { print "\n$column_data{$_}" } @column_index;
2812 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2813 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2814 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2815 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2826 <td><hr size=3 noshade></td>
2832 $form->{copies} = 1;
2841 <input class=submit type=submit name=action value="|
2842 . $locale->text('Update') . qq|">
2843 <input class=submit type=submit name=action value="|
2844 . $locale->text('Print') . qq|">
2847 if ($form->{type} eq 'ship_order') {
2849 <input class=submit type=submit name=action value="|
2850 . $locale->text('Ship to') . qq|">
2851 <input class=submit type=submit name=action value="|
2852 . $locale->text('E-mail') . qq|">
2858 <input class=submit type=submit name=action value="|
2859 . $locale->text('Done') . qq|">
2861 <input type=hidden name=rowcount value=$form->{rowcount}>
2863 <input name=callback type=hidden value="$callback">
2865 <input type=hidden name=path value=$form->{path}>
2866 <input type=hidden name=login value=$form->{login}>
2867 <input type=hidden name=password value=$form->{password}>
2875 $lxdebug->leave_sub();
2879 $lxdebug->enter_sub();
2881 if ($form->{type} eq 'ship_order') {
2882 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2884 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2889 $total += $form->{"ship_$_"} =
2890 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2891 } (1 .. $form->{rowcount} - 1);
2893 $form->error($locale->text('Nothing entered!')) unless $total;
2895 $form->redirect($locale->text('Inventory saved!'))
2896 if OE->save_inventory(\%myconfig, \%$form);
2897 $form->error($locale->text('Could not save!'));
2899 $lxdebug->leave_sub();
2902 sub search_transfer {
2903 $lxdebug->enter_sub();
2905 OE->get_warehouses(\%myconfig, \%$form);
2908 if (@{ $form->{all_warehouses} }) {
2909 $form->{selectwarehouse} = "<option>\n";
2910 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2912 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2913 (@{ $form->{all_warehouses} });
2915 $form->error($locale->text('Nothing to transfer!'));
2918 $form->{title} = $locale->text('Transfer Inventory');
2925 <form method=post action=$form->{script}>
2929 <th class=listtop>$form->{title}</th>
2931 <tr height="5"></tr>
2936 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2937 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2940 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2941 <td><input name=partnumber size=20></td>
2944 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2945 <td><input name=description size=40></td>
2948 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2949 <td><input name=partsgroup size=20></td>
2955 <td><hr size=3 noshade></td>
2960 <input type=hidden name=sort value=partnumber>
2961 <input type=hidden name=nextsub value=list_transfer>
2963 <input type=hidden name=path value=$form->{path}>
2964 <input type=hidden name=login value=$form->{login}>
2965 <input type=hidden name=password value=$form->{password}>
2967 <input class=submit type=submit name=action value="|
2968 . $locale->text('Continue') . qq|">
2975 $lxdebug->leave_sub();
2979 $lxdebug->enter_sub();
2981 OE->get_inventory(\%myconfig, \%$form);
2983 $partnumber = $form->escape($form->{partnumber});
2984 $warehouse = $form->escape($form->{warehouse});
2985 $description = $form->escape($form->{description});
2986 $partsgroup = $form->escape($form->{partsgroup});
2990 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2992 # construct callback
2993 $partnumber = $form->escape($form->{partnumber}, 1);
2994 $warehouse = $form->escape($form->{warehouse}, 1);
2995 $description = $form->escape($form->{description}, 1);
2996 $partsgroup = $form->escape($form->{partsgroup}, 1);
2999 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
3002 $form->sort_columns(
3003 qw(partnumber description partsgroup make model warehouse qty transfer));
3005 $column_header{partnumber} =
3006 qq|<th><a class=listheading href=$href&sort=partnumber>|
3007 . $locale->text('Part Number')
3009 $column_header{description} =
3010 qq|<th><a class=listheading href=$href&sort=description>|
3011 . $locale->text('Description')
3013 $column_header{partsgroup} =
3014 qq|<th><a class=listheading href=$href&sort=partsgroup>|
3015 . $locale->text('Group')
3017 $column_header{warehouse} =
3018 qq|<th><a class=listheading href=$href&sort=warehouse>|
3019 . $locale->text('From')
3021 $column_header{qty} =
3022 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
3023 $column_header{transfer} =
3024 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
3026 $option = $locale->text('Transfer to');
3028 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
3030 if ($form->{warehouse}) {
3031 $option .= " : $warehouse";
3033 if ($form->{partnumber}) {
3034 $option .= "\n<br>" if ($option);
3035 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
3037 if ($form->{description}) {
3038 $option .= "\n<br>" if ($option);
3039 $option .= $locale->text('Description') . " : $form->{description}";
3041 if ($form->{partsgroup}) {
3042 $option .= "\n<br>" if ($option);
3043 $option .= $locale->text('Group') . " : $form->{partsgroup}";
3046 $form->{title} = $locale->text('Transfer Inventory');
3053 <form method=post action=$form->{script}>
3055 <input type=hidden name=warehouse_id value=$warehouse_id>
3059 <th class=listtop>$form->{title}</th>
3061 <tr height="5"></tr>
3068 <tr class=listheading>|;
3070 map { print "\n$column_header{$_}" } @column_index;
3076 if (@{ $form->{all_inventory} }) {
3077 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
3081 foreach $ref (@{ $form->{all_inventory} }) {
3085 $column_data{partnumber} =
3086 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
3087 $column_data{description} = "<td>$ref->{description} </td>";
3088 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
3089 $column_data{warehouse} =
3090 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
3092 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
3093 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
3095 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
3100 <tr class=listrow$j>";
3102 map { print "\n$column_data{$_}" } @column_index;
3116 <td><hr size=3 noshade></td>
3122 <input name=callback type=hidden value="$callback">
3124 <input type=hidden name=rowcount value=$i>
3126 <input type=hidden name=path value=$form->{path}>
3127 <input type=hidden name=login value=$form->{login}>
3128 <input type=hidden name=password value=$form->{password}>
3130 <input class=submit type=submit name=action value="|
3131 . $locale->text('Transfer') . qq|">
3139 $lxdebug->leave_sub();
3143 $lxdebug->enter_sub();
3145 $form->redirect($locale->text('Inventory transferred!'))
3146 if OE->transfer(\%myconfig, \%$form);
3147 $form->error($locale->text('Could not transfer Inventory!'));
3149 $lxdebug->leave_sub();