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 #======================================================================
39 require "$form->{path}/io.pl";
40 require "$form->{path}/arap.pl";
47 $lxdebug->enter_sub();
49 if ($form->{type} eq 'purchase_order') {
50 $form->{title} = $locale->text('Add Purchase Order');
51 $form->{vc} = 'vendor';
53 if ($form->{type} eq 'sales_order') {
54 $form->{title} = $locale->text('Add Sales Order');
55 $form->{vc} = 'customer';
57 if ($form->{type} eq 'request_quotation') {
58 $form->{title} = $locale->text('Add Request for Quotation');
59 $form->{vc} = 'vendor';
61 if ($form->{type} eq 'sales_quotation') {
62 $form->{title} = $locale->text('Add Quotation');
63 $form->{vc} = 'customer';
67 "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&password=$form->{password}"
68 unless $form->{callback};
74 $lxdebug->leave_sub();
78 $lxdebug->enter_sub();
80 # editing without stuff to edit? try adding it first
81 if ($form->{rowcount}) {
82 map { $id++ if $form->{"id_$_"} } (1 .. $form->{rowcount});
86 undef $form->{rowcount};
97 if ($form->{print_and_save}) {
98 $form->{action} = "print";
99 $form->{resubmit} = 1;
100 $language_id = $form->{language_id};
101 $printer_id = $form->{printer_id};
104 if ($form->{type} eq 'purchase_order') {
105 $form->{title} = $locale->text('Edit Purchase Order');
106 $form->{heading} = $locale->text('Purchase Order');
107 $form->{vc} = 'vendor';
109 if ($form->{type} eq 'sales_order') {
110 $form->{title} = $locale->text('Edit Sales Order');
111 $form->{heading} = $locale->text('Sales Order');
112 $form->{vc} = 'customer';
114 if ($form->{type} eq 'request_quotation') {
115 $form->{title} = $locale->text('Edit Request for Quotation');
116 $form->{heading} = $locale->text('Request for Quotation');
117 $form->{vc} = 'vendor';
119 if ($form->{type} eq 'sales_quotation') {
120 $form->{title} = $locale->text('Edit Quotation');
121 $form->{heading} = $locale->text('Quotation');
122 $form->{vc} = 'customer';
127 if ($form->{print_and_save}) {
128 $form->{language_id} = $language_id;
129 $form->{printer_id} = $printer_id;
133 $lxdebug->leave_sub();
137 $lxdebug->enter_sub();
139 # get customer/vendor
140 $form->all_vc(\%myconfig, $form->{vc},
141 ($form->{vc} eq 'customer') ? "AR" : "AP");
143 # retrieve order/quotation
144 $form->{webdav} = $webdav;
146 $form->{jscalendar} = $jscalendar;
148 OE->retrieve(\%myconfig, \%$form);
150 if ($form->{payment_id}) {
151 $payment_id = $form->{payment_id};
153 if ($form->{language_id}) {
154 $language_id = $form->{language_id};
156 if ($form->{taxzone_id}) {
157 $taxzone_id = $form->{taxzone_id};
161 # if multiple rowcounts (== collective order) then check if the
162 # there were more than one customer (in that case OE::retrieve removes
163 # the content from the field)
164 if ( $form->{rowcount}
165 && $form->{type} eq 'sales_order'
166 && defined $form->{customer}
167 && $form->{customer} eq '') {
169 # $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
172 'Collective Orders only work for orders from one customer!')
176 $taxincluded = $form->{taxincluded};
177 $form->{shipto} = 1 if $form->{id};
179 if ($form->{"all_$form->{vc}"}) {
180 unless ($form->{"$form->{vc}_id"}) {
181 $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
185 $cp_id = $form->{cp_id};
186 $intnotes = $form->{intnotes};
188 # get customer / vendor
189 if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/) {
190 IR->get_vendor(\%myconfig, \%$form);
192 if ($form->{type} =~ /(sales|ship)_(order|quotation)/) {
193 IS->get_customer(\%myconfig, \%$form);
195 $form->{cp_id} = $cp_id;
197 $form->{payment_id} = $payment_id;
200 $form->{language_id} = $language_id;
203 $form->{taxzone_id} = $taxzone_id;
205 $form->{intnotes} = $intnotes;
206 ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
207 $form->{"old$form->{vc}"} =
208 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
210 # build the popup menus
211 if (@{ $form->{"all_$form->{vc}"} }) {
212 $form->{ $form->{vc} } =
213 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
214 map { $form->{"select$form->{vc}"} .= "<option>$_->{name}--$_->{id}\n" }
215 (@{ $form->{"all_$form->{vc}"} });
219 @curr = split /:/, $form->{currencies};
221 $form->{defaultcurrency} = $curr[0];
222 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
224 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
226 $form->{taxincluded} = $taxincluded if ($form->{id});
229 if (@{ $form->{all_departments} }) {
230 $form->{selectdepartment} = "<option>\n";
231 $form->{department} = "$form->{department}--$form->{department_id}";
234 $form->{selectdepartment} .=
235 "<option>$_->{description}--$_->{id}\n"
236 } (@{ $form->{all_departments} });
239 $form->{employee} = "$form->{employee}--$form->{employee_id}";
242 if (@{ $form->{all_employees} }) {
243 $form->{selectemployee} = "";
244 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
245 (@{ $form->{all_employees} });
249 $form->{forex} = $form->{exchangerate};
251 $lxdebug->leave_sub();
255 $lxdebug->enter_sub();
256 $form->{format} = "pdf";
257 $form->{media} = "screen";
258 $form->{formname} = $form->{type} unless $form->{formname};
260 map { $form->{$_} =~ s/\"/"/g }
261 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
263 foreach $ref (@{ $form->{form_details} }) {
264 $form->{rowcount} = ++$i;
266 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
268 for my $i (1 .. $form->{rowcount}) {
270 $form->{"discount_$i"} =
271 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
273 $form->{"discount_$i"} =
274 $form->format_amount(\%myconfig, $form->{"discount_$i"});
276 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
278 $decimalplaces = ($dec > 2) ? $dec : 2;
280 # copy reqdate from deliverydate for invoice -> order conversion
281 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
282 unless $form->{"reqdate_$i"};
284 $form->{"sellprice_$i"} =
285 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
288 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
289 $dec_qty = length $dec_qty;
291 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
293 map { $form->{"${_}_$i"} =~ s/\"/"/g }
294 qw(partnumber description unit);
297 $lxdebug->leave_sub();
301 $lxdebug->enter_sub();
303 $checkedopen = ($form->{closed}) ? "" : "checked";
304 $checkedclosed = ($form->{closed}) ? "checked" : "";
306 # use JavaScript Calendar or not
307 $form->{jsscript} = $form->{jscalendar};
310 $payment = qq|<option value=""></option>|;
311 foreach $item (@{ $form->{payment_terms} }) {
312 if ($form->{payment_id} eq $item->{id}) {
313 $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
315 $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
318 if ($form->{jsscript}) {
320 # with JavaScript Calendar
322 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
323 <td><input type=button name=transdate id="trigger1" value=|
324 . $locale->text('button') . qq|></td>
327 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
328 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
329 . $locale->text('button') . qq|></td>
334 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
335 "reqdate", "BL", "trigger2");
339 # without JavaScript Calendar
341 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
343 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
349 <td colspan=2 align=center>
352 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
353 . $locale->text('Open') . qq|</th>
354 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
355 . $locale->text('Closed') . qq|</th>
363 # set option selected
364 foreach $item ($form->{vc}, currency, department, employee) {
365 $form->{"select$item"} =~ s/ selected//;
366 $form->{"select$item"} =~
367 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
371 if ($form->{all_contacts}) {
373 $form->{selectcontact} = "<option></option>";
374 foreach $item (@{ $form->{all_contacts} }) {
375 my $department = ($item->{cp_abteilung}) ? "--$item->{cp_abteilung}" : "";
376 if ($form->{cp_id} == $item->{cp_id}) {
377 $form->{selectcontact} .=
378 "<option value=$item->{cp_id} selected>$item->{cp_name}$department</option>";
380 $form->{selectcontact} .= "<option value=$item->{cp_id}>$item->{cp_name}$department</option>";
384 $form->{selectcontact} =~ s/ selected//g;
385 if ($form->{cp_id} ne "") {
386 $form->{selectcontact} =~ s/value=$form->{cp_id}/value=$form->{cp_id} selected/;
391 if (@{ $form->{SHIPTO} }) {
392 $form->{selectshipto} = "<option value=0></option>";
393 foreach $item (@{ $form->{SHIPTO} }) {
394 if ($item->{id} == $form->{shipto_id}) {
395 $form->{selectshipto} .=
396 "<option value=$item->{id} selected>$item->{shiptoname}</option>";
398 $form->{selectshipto} .=
399 "<option value=$item->{id}>$item->{shiptoname}</option>";
404 $form->{selectshipto} =~ s/ selected//g;
405 if ($form->{shipto_id} ne "") {
406 $form->{selectshipto} =~ s/value=$form->{shipto_id}/value=$form->{shipto_id} selected/;
411 <th align=right>| . $locale->text('Shipping Address') . qq|</th>
412 <td><select name=shipto_id>$form->{selectshipto}</select></td>
413 <input type=hidden name=selectshipto value="$form->{selectshipto}">|;
418 $form->{exchangerate} =
419 $form->format_amount(\%myconfig, $form->{exchangerate});
421 if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
427 $form->{creditlimit} =
428 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
429 $form->{creditremaining} =
430 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
433 ($form->{selectcontact})
434 ? qq|<select name=cp_id>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
435 : qq|<input name=contact value="$form->{contact}" size=35>|;
438 <input type=hidden name=forex value=$form->{forex}>
441 if ($form->{currency} ne $form->{defaultcurrency}) {
442 if ($form->{forex}) {
445 . $locale->text('Exchangerate')
446 . qq|</th><td>$form->{exchangerate}</td>
447 <input type=hidden name=exchangerate value=$form->{exchangerate}>
452 . $locale->text('Exchangerate')
453 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
457 $vclabel = ucfirst $form->{vc};
458 $vclabel = $locale->text($vclabel);
462 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
463 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
464 . $locale->text('days') . qq|</td>
468 if ($form->{business}) {
471 <th align=right>| . $locale->text('Business') . qq|</th>
472 <td>$form->{business}</td>
473 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
475 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
481 if ($form->{max_dunning_level}) {
487 <th align=right>| . $locale->text('Max. Dunning Level') . qq|:</th>
488 <td><b>$form->{max_dunning_level}</b></td>
489 <th align=right>| . $locale->text('Dunning Amount') . qq|:</th>
491 . $form->format_amount(\%myconfig, $form->{dunning_amount},2)
500 if (@{ $form->{TAXZONE} }) {
501 $form->{selecttaxzone} = "";
502 foreach $item (@{ $form->{TAXZONE} }) {
503 if ($item->{id} == $form->{taxzone_id}) {
504 $form->{selecttaxzone} .=
505 "<option value=$item->{id} selected>$item->{description}</option>";
507 $form->{selecttaxzone} .=
508 "<option value=$item->{id}>$item->{description}</option>";
513 $form->{selecttaxzone} =~ s/ selected//g;
514 if ($form->{taxzone_id} ne "") {
515 $form->{selecttaxzone} =~ s/value=$form->{taxzone_id}/value=$form->{taxzone_id} selected/;
519 if ($form->{rowcount} >0) {
520 $form->{selecttaxzone} =~ /<option value=\d+ selected>.*?<\/option>/;
521 $form->{selecttaxzone} = $&;
527 <th align=right>| . $locale->text('Steuersatz') . qq|</th>
528 <td><select name=taxzone_id>$form->{selecttaxzone}</select></td>
529 <input type=hidden name=selecttaxzone value="$form->{selecttaxzone}">
533 if ($form->{type} !~ /_quotation$/) {
536 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
537 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
540 <th width=70% align=right nowrap>|
541 . $locale->text('Quotation Number') . qq|</th>
542 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
545 <th width=70% align=right nowrap>|
546 . $locale->text('Customer Order Number') . qq|</th>
547 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
550 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
555 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
560 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
562 $creditremaining = qq|
568 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
569 <td>$form->{creditlimit}</td>
571 <th nowrap>| . $locale->text('Remaining') . qq|</th>
572 <td class="plus$n">$form->{creditremaining}</td>
581 ($form->{type} eq 'sales_quotation')
582 ? $locale->text('Valid until')
583 : $locale->text('Required by');
584 if ($form->{type} eq 'sales_quotation') {
587 <th width=70% align=right nowrap>|
588 . $locale->text('Quotation Number') . qq|</th>
589 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
590 <input type=hidden name=ordnumber value="$form->{ordnumber}">
596 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
597 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
598 <input type=hidden name=ordnumber value="$form->{ordnumber}">
607 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
611 <th align=right nowrap=true>$reqlabel</th>
615 $creditremaining = qq| <tr>
622 ($form->{"select$form->{vc}"})
623 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
624 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
628 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
629 <td colspan=3><select name=department>$form->{selectdepartment}</select>
630 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
633 | if $form->{selectdepartment};
636 <input type=hidden name=employee value="$form->{employee}">
639 if ($form->{type} eq 'sales_order') {
640 if ($form->{selectemployee}) {
642 <input type=hidden name=customer_klass value=$form->{customer_klass}>
644 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
645 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
646 <input type=hidden name=selectemployee value="$form->{selectemployee}">
653 <input type=hidden name=customer_klass value=$form->{customer_klass}>
655 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
656 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
657 <input type=hidden name=selectemployee value="$form->{selectemployee}">
662 if ($form->{resubmit} && ($form->{format} eq "html")) {
664 qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|;
665 } elsif ($form->{resubmit}) {
666 $onload = qq|document.oe.submit()|;
671 $credittext = $locale->text('Credit Limit exceeded!!!');
672 if ($creditwarning) {
673 $onload = qq|alert('$credittext')|;
679 <body onLoad="$onload">
681 <form method=post name=oe action=$form->{script}>
682 <script type="text/javascript" src="js/common.js"></script>
683 <script type="text/javascript" src="js/delivery_customer_selection.js"></script>
684 <script type="text/javascript" src="js/vendor_selection.js"></script>
685 <script type="text/javascript" src="js/calculate_qty.js"></script>
687 <input type=hidden name=id value=$form->{id}>
688 <input type=hidden name=action value=$form->{action}>
690 <input type=hidden name=type value=$form->{type}>
691 <input type=hidden name=formname value=$form->{formname}>
692 <input type=hidden name=media value=$form->{media}>
693 <input type=hidden name=format value=$form->{format}>
694 <input type=hidden name=proforma value=$form->{proforma}>
696 <input type=hidden name=queued value="$form->{queued}">
697 <input type=hidden name=printed value="$form->{printed}">
698 <input type=hidden name=emailed value="$form->{emailed}">
700 <input type=hidden name=vc value=$form->{vc}>
702 <input type=hidden name=title value="$form->{title}">
704 <input type=hidden name=discount value=$form->{discount}>
705 <input type=hidden name=creditlimit value=$form->{creditlimit}>
706 <input type=hidden name=creditremaining value=$form->{creditremaining}>
708 <input type=hidden name=tradediscount value=$form->{tradediscount}>
709 <input type=hidden name=business value=$form->{business}>
710 <input type=hidden name=webdav value=$webdav>
714 <th class=listtop>$form->{title}</th>
724 <th align=right>$vclabel</th>
725 <td colspan=3>$vc</td>
726 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
727 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
728 <th align=richt nowrap>|
729 . $locale->text('Contact Person') . qq|</th>
730 <td colspan=3>$contact</td>
738 <th align=right>| . $locale->text('Currency') . qq|</th>
739 <td><select name=currency>$form->{selectcurrency}</select></td>
740 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
741 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
745 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
746 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
749 <th align=right>| . $locale->text('Ship via') . qq|</th>
750 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
757 # <button type="button" onclick="delivery_customer_selection_window('delivery_customer_string','delivery_customer_id')">| . $locale->text('Choose Customer') . qq|</button>
759 # <td colspan=2><input type=hidden name=delivery_customer_id value="$form->{delivery_customer_id}">
760 # <input size=45 id=delivery_customer_string name=delivery_customer_string value="$form->{delivery_customer_string}"></td>
764 # <button type="button" onclick="vendor_selection_window('delivery_vendor_string','delivery_vendor_id')">| . $locale->text('Choose Vendor') . qq|</button>
766 # <td colspan=2><input type=hidden name=delivery_vendor_id value="$form->{delivery_vendor_id}">
767 # <input size=45 id=vendor_string name=delivery_vendor_string value="$form->{delivery_vendor_string}"></td>
789 <!-- shipto are in hidden variables -->
791 <input type=hidden name=shiptoname value="$form->{shiptoname}">
792 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
793 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
794 <input type=hidden name=shiptocity value="$form->{shiptocity}">
795 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
796 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
797 <input type=hidden name=shiptophone value="$form->{shiptophone}">
798 <input type=hidden name=shiptofax value="$form->{shiptofax}">
799 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
801 <!-- email variables -->
802 <input type=hidden name=message value="$form->{message}">
803 <input type=hidden name=email value="$form->{email}">
804 <input type=hidden name=subject value="$form->{subject}">
805 <input type=hidden name=cc value="$form->{cc}">
806 <input type=hidden name=bcc value="$form->{bcc}">
808 <input type=hidden name=taxpart value="$form->{taxpart}">
809 <input type=hidden name=taxservice value="$form->{taxservice}">
811 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
814 foreach $item (split / /, $form->{taxaccounts}) {
816 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
817 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
820 $lxdebug->leave_sub();
824 $lxdebug->enter_sub();
826 $form->{invtotal} = $form->{invsubtotal};
828 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
831 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
834 $rows = ($rows > $introws) ? $rows : $introws;
836 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
838 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
840 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
843 if ($form->{taxaccounts}) {
845 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
846 . $locale->text('Tax Included') . qq|</b><br><br>
850 if (!$form->{taxincluded}) {
852 foreach $item (split / /, $form->{taxaccounts}) {
853 if ($form->{"${item}_base"}) {
854 $form->{invtotal} += $form->{"${item}_total"} =
856 $form->{"${item}_base"} * $form->{"${item}_rate"},
858 $form->{"${item}_total"} =
859 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
863 <th align=right>$form->{"${item}_description"}</th>
864 <td align=right>$form->{"${item}_total"}</td>
870 $form->{invsubtotal} =
871 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
875 <th align=right>| . $locale->text('Subtotal') . qq|</th>
876 <td align=right>$form->{invsubtotal}</td>
882 if ($form->{taxincluded}) {
883 foreach $item (split / /, $form->{taxaccounts}) {
884 if ($form->{"${item}_base"}) {
885 $form->{"${item}_total"} =
887 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
888 (1 + $form->{"${item}_rate"})
891 $form->{"${item}_netto"} =
893 ($form->{"${item}_base"} - $form->{"${item}_total"}),
895 $form->{"${item}_total"} =
896 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
897 $form->{"${item}_netto"} =
898 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
902 <th align=right>Enthaltene $form->{"${item}_description"}</th>
903 <td align=right>$form->{"${item}_total"}</td>
906 <th align=right>Nettobetrag</th>
907 <td align=right>$form->{"${item}_netto"}</td>
915 $form->{oldinvtotal} = $form->{invtotal};
917 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
927 <th align=left>| . $locale->text('Notes') . qq|</th>
928 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
934 <th align=right>| . $locale->text('Payment Terms') . qq|</th>
935 <td><select name=payment_id tabindex=24>$payment
939 <td align=right width=100%>
945 <th align=right>| . $locale->text('Total') . qq|</th>
946 <td align=right>$form->{invtotal}</td>
954 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
955 <input type=hidden name=oldtotalpaid value=$totalpaid>
957 <td><hr size=3 noshade></td>
965 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
968 <td align=left width=30%><b>Dateiname</b></td>
969 <td align=left width=70%><b>Webdavlink</b></td>
971 foreach $file (keys %{ $form->{WEBDAV} }) {
974 <td align=left>$file</td>
975 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
983 <td><hr size=3 noshade></td>
990 <input type=hidden name=jscalendar value=$form->{jscalendar}>
1003 Bearbeiten des $form->{heading}<br>
1004 <input class=submit type=submit name=action value="|
1005 . $locale->text('Update') . qq|">
1006 <input class=submit type=submit name=action value="|
1007 . $locale->text('Ship to') . qq|">
1008 <input class=submit type=submit name=action value="|
1009 . $locale->text('Print') . qq|">
1010 <input class=submit type=submit name=action value="|
1011 . $locale->text('E-mail') . qq|">
1012 <input class=submit type=submit name=action value="|
1013 . $locale->text('Save') . qq|">
1014 <input class=submit type=submit name=action value="|
1015 . $locale->text('Save and Close') . qq|">
1018 if (($form->{id})) {
1020 <br>Workflow $form->{heading}<br>
1021 <input class=submit type=submit name=action value="|
1022 . $locale->text('Save as new') . qq|">
1023 <input class=submit type=submit name=action value="|
1024 . $locale->text('Delete') . qq|">|;
1025 if (($form->{type} =~ /sales_quotation$/)) {
1027 <input class=submit type=submit name=action value="|
1028 . $locale->text('Sales Order') . qq|">|;
1030 if ($form->{type} =~ /request_quotation$/) {
1032 <input class=submit type=submit name=action value="|
1033 . $locale->text('Purchase Order') . qq|">|;
1037 <input class=submit type=submit name=action value="|
1038 . $locale->text('Invoice') . qq|">
1042 if ($form->{type} =~ /sales_order$/) {
1044 <br>$form->{heading} als neue Vorlage verwenden für<br>
1045 <input class=submit type=submit name=action value="|
1046 . $locale->text('Purchase Order') . qq|">
1047 <input class=submit type=submit name=action value="|
1048 . $locale->text('Quotation') . qq|">
1051 } elsif ($form->{type} =~ /purchase_order$/) {
1053 <br>$form->{heading} als neue Vorlage verwenden für<br>
1054 <input class=submit type=submit name=action value="|
1055 . $locale->text('Sales Order') . qq|">
1056 <input class=submit type=submit name=action value="|
1057 . $locale->text('Quotation') . qq|">
1062 <br>$form->{heading} als neue Vorlage verwenden für<br>
1063 <input class=submit type=submit name=action value="|
1064 . $locale->text('Order') . qq|">
1067 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount} && !$form->{proforma}) {
1069 <br>Workflow $form->{heading}<br>
1070 <input class=submit type=submit name=action value="|
1071 . $locale->text('Save as new') . qq|">
1072 <input class=submit type=submit name=action value="|
1073 . $locale->text('Invoice') . qq|">
1077 if ($form->{menubar}) {
1078 require "$form->{path}/menu.pl";
1084 <input type=hidden name=rowcount value=$form->{rowcount}>
1086 <input name=callback type=hidden value="$form->{callback}">
1088 <input type=hidden name=path value=$form->{path}>
1089 <input type=hidden name=login value=$form->{login}>
1090 <input type=hidden name=password value=$form->{password}>
1097 $lxdebug->leave_sub();
1101 $lxdebug->enter_sub();
1103 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1104 qw(exchangerate creditlimit creditremaining);
1105 $form->{update} = 1;
1107 &check_name($form->{vc});
1112 $buysell = 'sell' if ($form->{vc} eq 'vendor');
1113 $form->{exchangerate} = $exchangerate
1117 $form->check_exchangerate(
1118 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
1122 $i = $form->{rowcount};
1124 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
1126 if ( ($form->{"partnumber_$i"} eq "")
1127 && ($form->{"description_$i"} eq "")
1128 && ($form->{"partsgroup_$i"} eq "")) {
1130 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
1135 $form->{"selected_unit_$i"} = $form->{"unit_$i"};
1137 if ( $form->{type} eq 'purchase_order'
1138 || $form->{type} eq 'request_quotation') {
1139 IR->retrieve_item(\%myconfig, \%$form);
1141 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1142 IS->retrieve_item(\%myconfig, \%$form);
1145 my $rows = scalar @{ $form->{item_list} };
1147 $form->{"discount_$i"} =
1148 $form->format_amount(\%myconfig, $form->{discount} * 100);
1151 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
1160 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
1161 if ($form->{"not_discountable_$i"}) {
1162 $form->{"discount_$i"} = 0;
1164 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
1165 qw(partnumber description unit);
1166 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
1167 keys %{ $form->{item_list}[0] };
1168 if ($form->{"part_payment_id_$i"} ne "") {
1169 $form->{payment_id} = $form->{"part_payment_id_$i"};
1172 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1174 ($dec) = ($s =~ /\.(\d+)/);
1176 $decimalplaces = ($dec > 2) ? $dec : 2;
1179 $form->{"sellprice_$i"} = $sellprice;
1182 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1184 # if there is an exchange rate adjust sellprice
1185 $form->{"sellprice_$i"} /= $exchangerate;
1189 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1190 (1 - $form->{"discount_$i"} / 100);
1191 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1192 map { $form->{"${_}_base"} += $amount }
1193 (split / /, $form->{"taxaccounts_$i"});
1194 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1195 split / /, $form->{taxaccounts}
1196 if !$form->{taxincluded};
1198 $form->{creditremaining} -= $amount;
1200 $form->{"sellprice_$i"} =
1201 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1204 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1206 # get pricegroups for parts
1207 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1209 # build up html code for prices_$i
1210 &set_pricegroup($i);
1217 # ok, so this is a new part
1218 # ask if it is a part or service item
1220 if ( $form->{"partsgroup_$i"}
1221 && ($form->{"partsnumber_$i"} eq "")
1222 && ($form->{"description_$i"} eq "")) {
1223 $form->{rowcount}--;
1224 $form->{"discount_$i"} = "";
1228 $form->{"id_$i"} = 0;
1229 $form->{"unit_$i"} = $locale->text('ea');
1237 $lxdebug->leave_sub();
1241 $lxdebug->enter_sub();
1243 if ($form->{type} eq 'purchase_order') {
1244 $form->{title} = $locale->text('Purchase Orders');
1245 $form->{vc} = 'vendor';
1246 $ordlabel = $locale->text('Order Number');
1247 $ordnumber = 'ordnumber';
1248 $employee = $locale->text('Employee');
1250 if ($form->{type} eq 'request_quotation') {
1251 $form->{title} = $locale->text('Request for Quotations');
1252 $form->{vc} = 'vendor';
1253 $ordlabel = $locale->text('RFQ Number');
1254 $ordnumber = 'quonumber';
1255 $employee = $locale->text('Employee');
1257 if ($form->{type} eq 'receive_order') {
1258 $form->{title} = $locale->text('Receive Merchandise');
1259 $form->{vc} = 'vendor';
1260 $ordlabel = $locale->text('Order Number');
1261 $ordnumber = 'ordnumber';
1262 $employee = $locale->text('Employee');
1264 if ($form->{type} eq 'sales_order') {
1265 $form->{title} = $locale->text('Sales Orders');
1266 $form->{vc} = 'customer';
1267 $ordlabel = $locale->text('Order Number');
1268 $ordnumber = 'ordnumber';
1269 $employee = $locale->text('Salesperson');
1271 if ($form->{type} eq 'ship_order') {
1272 $form->{title} = $locale->text('Ship Merchandise');
1273 $form->{vc} = 'customer';
1274 $ordlabel = $locale->text('Order Number');
1275 $ordnumber = 'ordnumber';
1276 $employee = $locale->text('Salesperson');
1280 if ($form->{type} eq 'sales_quotation') {
1281 $form->{title} = $locale->text('Quotations');
1282 $form->{vc} = 'customer';
1283 $ordlabel = $locale->text('Quotation Number');
1284 $ordnumber = 'quonumber';
1285 $employee = $locale->text('Employee');
1288 if ($form->{type} =~ /(ship|receive)_order/) {
1289 OE->get_warehouses(\%myconfig, \%$form);
1292 if (@{ $form->{all_warehouses} }) {
1293 $form->{selectwarehouse} = "<option>\n";
1294 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1297 $form->{selectwarehouse} .=
1298 "<option>$_->{description}--$_->{id}\n"
1299 } (@{ $form->{all_warehouses} });
1303 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1304 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1305 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1312 # setup vendor / customer selection
1313 $form->all_vc(\%myconfig, $form->{vc},
1314 ($form->{vc} eq 'customer') ? "AR" : "AP");
1316 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1317 @{ $form->{"all_$form->{vc}"} };
1319 $vclabel = ucfirst $form->{vc};
1320 $vclabel = $locale->text($vclabel);
1322 # $locale->text('Vendor')
1323 # $locale->text('Customer')
1327 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1328 : qq|<input name=$form->{vc} size=35>|;
1331 if (@{ $form->{all_departments} }) {
1332 $form->{selectdepartment} = "<option>\n";
1335 $form->{selectdepartment} .=
1336 "<option>$_->{description}--$_->{id}\n"
1337 } (@{ $form->{all_departments} });
1342 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1343 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1345 | if $form->{selectdepartment};
1347 if ($form->{type} !~ /(ship_order|receive_order)/) {
1350 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1351 . $locale->text('Open') . qq|</td>
1352 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1353 . $locale->text('Closed') . qq|</td>
1359 <input type=hidden name="open" value=1>
1363 # use JavaScript Calendar or not
1364 $form->{jsscript} = $jscalendar;
1366 if ($form->{jsscript}) {
1368 # with JavaScript Calendar
1370 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1371 <input type=button name=transdatefrom id="trigger3" value=|
1372 . $locale->text('button') . qq|></td>
1375 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1376 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1377 . $locale->text('button') . qq|></td>
1382 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1383 "transdateto", "BL", "trigger4");
1386 # without JavaScript Calendar
1388 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1390 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1398 <form method=post action=$form->{script}>
1402 <th class=listtop>$form->{title}</th>
1404 <tr height="5"></tr>
1409 <th align=right>$vclabel</th>
1410 <td colspan=3>$vc</td>
1415 <th align=right>$ordlabel</th>
1416 <td colspan=3><input name="$ordnumber" size=20></td>
1419 <th align=right>| . $locale->text('From') . qq|</th>
1421 <th align=right>| . $locale->text('Bis') . qq|</th>
1424 <input type=hidden name=sort value=transdate>
1426 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1431 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1432 | . $locale->text('ID') . qq|</td>
1433 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1434 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1435 . $locale->text('Date') . qq|</td>
1436 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1437 . $locale->text('Required by') . qq|</td>
1440 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1441 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1442 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1443 . $locale->text('Ship via') . qq|</td>
1446 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1447 . $locale->text('Amount') . qq|</td>
1448 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1449 . $locale->text('Tax') . qq|</td>
1450 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1451 . $locale->text('Total') . qq|</td>
1454 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1455 . $locale->text('Subtotal') . qq|</td>
1463 <tr><td colspan=4><hr size=3 noshade></td></tr>
1469 <input type=hidden name=nextsub value=orders>
1470 <input type=hidden name=path value=$form->{path}>
1471 <input type=hidden name=login value=$form->{login}>
1472 <input type=hidden name=password value=$form->{password}>
1473 <input type=hidden name=vc value=$form->{vc}>
1474 <input type=hidden name=type value=$form->{type}>
1476 <input class=submit type=submit name=action value="|
1477 . $locale->text('Continue') . qq|">
1484 $lxdebug->leave_sub();
1488 $lxdebug->enter_sub();
1490 # split vendor / customer
1491 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1492 split(/--/, $form->{ $form->{vc} });
1494 OE->transactions(\%myconfig, \%$form);
1496 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1498 $number = $form->escape($form->{$ordnumber});
1499 $name = $form->escape($form->{ $form->{vc} });
1500 $department = $form->escape($form->{department});
1501 $warehouse = $form->escape($form->{warehouse});
1505 "$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";
1507 # construct callback
1508 $number = $form->escape($form->{$ordnumber}, 1);
1509 $name = $form->escape($form->{ $form->{vc} }, 1);
1510 $department = $form->escape($form->{department}, 1);
1511 $warehouse = $form->escape($form->{warehouse}, 1);
1514 "$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";
1517 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1518 "name", "netamount", "tax", "amount",
1519 "curr", "employee", "shipvia", "open",
1522 $form->{l_open} = $form->{l_closed} = "Y"
1523 if ($form->{open} && $form->{closed});
1525 foreach $item (@columns) {
1526 if ($form->{"l_$item"} eq "Y") {
1527 push @column_index, $item;
1529 # add column to href and callback
1530 $callback .= "&l_$item=Y";
1531 $href .= "&l_$item=Y";
1535 # only show checkboxes if gotten here via sales_order form.
1536 if ($form->{type} =~ /sales_order/) {
1537 unshift @column_index, "ids";
1540 if ($form->{l_subtotal} eq 'Y') {
1541 $callback .= "&l_subtotal=Y";
1542 $href .= "&l_subtotal=Y";
1545 if ($form->{vc} eq 'vendor') {
1546 if ($form->{type} eq 'receive_order') {
1547 $form->{title} = $locale->text('Receive Merchandise');
1548 } elsif ($form->{type} eq 'purchase_order') {
1549 $form->{title} = $locale->text('Purchase Orders');
1551 $form->{title} = $locale->text('Request for Quotations');
1553 $name = $locale->text('Vendor');
1554 $employee = $locale->text('Employee');
1556 if ($form->{vc} eq 'customer') {
1557 if ($form->{type} eq 'sales_order') {
1558 $form->{title} = $locale->text('Sales Orders');
1559 $employee = $locale->text('Salesperson');
1560 } elsif ($form->{type} eq 'ship_order') {
1561 $form->{title} = $locale->text('Ship Merchandise');
1562 $employee = $locale->text('Salesperson');
1564 $form->{title} = $locale->text('Quotations');
1565 $employee = $locale->text('Employee');
1567 $name = $locale->text('Customer');
1570 $column_header{id} =
1571 qq|<th><a class=listheading href=$href&sort=id>|
1572 . $locale->text('ID')
1574 $column_header{transdate} =
1575 qq|<th><a class=listheading href=$href&sort=transdate>|
1576 . $locale->text('Date')
1578 $column_header{reqdate} =
1579 qq|<th><a class=listheading href=$href&sort=reqdate>|
1580 . $locale->text('Required by')
1582 $column_header{ordnumber} =
1583 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1584 . $locale->text('Order')
1586 $column_header{quonumber} =
1587 qq|<th><a class=listheading href=$href&sort=quonumber>|
1588 . $locale->text('Quotation')
1590 $column_header{name} =
1591 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1592 $column_header{netamount} =
1593 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1594 $column_header{tax} =
1595 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1596 $column_header{amount} =
1597 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1598 $column_header{curr} =
1599 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1600 $column_header{shipvia} =
1601 qq|<th><a class=listheading href=$href&sort=shipvia>|
1602 . $locale->text('Ship via')
1604 $column_header{open} =
1605 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1606 $column_header{closed} =
1607 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1609 $column_header{employee} =
1610 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1612 $column_header{ids} = qq|<th></th>|;
1614 if ($form->{ $form->{vc} }) {
1615 $option = $locale->text(ucfirst $form->{vc});
1616 $option .= " : $form->{$form->{vc}}";
1618 if ($form->{warehouse}) {
1619 ($warehouse) = split /--/, $form->{warehouse};
1620 $option .= "\n<br>" if ($option);
1621 $option .= $locale->text('Warehouse');
1622 $option .= " : $warehouse";
1624 if ($form->{department}) {
1625 $option .= "\n<br>" if ($option);
1626 ($department) = split /--/, $form->{department};
1627 $option .= $locale->text('Department') . " : $department";
1629 if ($form->{transdatefrom}) {
1631 . $locale->text('From') . " "
1632 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1634 if ($form->{transdateto}) {
1636 . $locale->text('Bis') . " "
1637 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1639 if ($form->{open}) {
1640 $option .= "\n<br>" if ($option);
1641 $option .= $locale->text('Open');
1643 if ($form->{closed}) {
1644 $option .= "\n<br>" if ($option);
1645 $option .= $locale->text('Closed');
1653 <form method="post" action="oe.pl">
1656 <th class=listtop>$form->{title}</th>
1658 <tr height="5"></tr>
1665 <tr class=listheading>|;
1667 map { print "\n$column_header{$_}" } @column_index;
1673 # add sort and escape callback
1674 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1676 if (@{ $form->{OE} }) {
1677 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1681 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1683 $warehouse = $form->escape($form->{warehouse});
1685 foreach $oe (@{ $form->{OE} }) {
1686 $form->{rowcount} = ++$j;
1688 if ($form->{l_subtotal} eq 'Y') {
1689 if ($sameitem ne $oe->{ $form->{sort} }) {
1691 $sameitem = $oe->{ $form->{sort} };
1695 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1697 $column_data{netamount} =
1699 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1701 $column_data{tax} = "<td align=right>"
1702 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1705 $column_data{amount} =
1707 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1709 $totalnetamount += $oe->{netamount};
1710 $totalamount += $oe->{amount};
1712 $subtotalnetamount += $oe->{netamount};
1713 $subtotalamount += $oe->{amount};
1716 qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1717 $column_data{id} = "<td>$oe->{id}</td>";
1718 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1719 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1721 $column_data{$ordnumber} =
1722 "<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>";
1723 $column_data{name} = "<td>$oe->{name}</td>";
1725 $column_data{employee} = "<td>$oe->{employee} </td>";
1726 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1728 if ($oe->{closed}) {
1729 $column_data{closed} = "<td align=center>X</td>";
1730 $column_data{open} = "<td> </td>";
1732 $column_data{closed} = "<td> </td>";
1733 $column_data{open} = "<td align=center>X</td>";
1739 <tr class=listrow$i>";
1741 map { print "\n$column_data{$_}" } @column_index;
1749 if ($form->{l_subtotal} eq 'Y') {
1755 <tr class=listtotal>|;
1757 map { $column_data{$_} = "<td> </td>" } @column_index;
1759 $column_data{netamount} =
1760 "<th class=listtotal align=right>"
1761 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1762 $column_data{tax} = "<th class=listtotal align=right>"
1763 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1766 $column_data{amount} =
1767 "<th class=listtotal align=right>"
1768 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1770 map { print "\n$column_data{$_}" } @column_index;
1778 <td><hr size=3 noshade></td>
1782 # multiple invoice edit button only if gotten there via sales_order form.
1784 if ($form->{type} =~ /sales_order/) {
1786 <input type="hidden" name="path" value="$form->{path}">
1787 <input class"submit" type="submit" name="action" value="|
1788 . $locale->text('Continue') . qq|">
1789 <input type="hidden" name="nextsub" value="edit">
1790 <input type="hidden" name="type" value="$form->{type}">
1791 <input type="hidden" name="warehouse" value="$warehouse">
1792 <input type="hidden" name="vc" value="$form->{vc}">
1793 <input type="hidden" name="login" value="$form->{login}">
1794 <input type="hidden" name="password" value="$form->{password}">
1795 <input type="hidden" name="callback" value="$callback">
1796 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1803 <form method=post action=$form->{script}>
1805 <input name=callback type=hidden value="$form->{callback}">
1807 <input type=hidden name=type value=$form->{type}>
1808 <input type=hidden name=vc value=$form->{vc}>
1810 <input type=hidden name=path value=$form->{path}>
1811 <input type=hidden name=login value=$form->{login}>
1812 <input type=hidden name=password value=$form->{password}>
1815 if ($form->{type} !~ /(ship|receive)_order/) {
1817 <input class=submit type=submit name=action value="|
1818 . $locale->text('Add') . qq|">|;
1821 if ($form->{menubar}) {
1822 require "$form->{path}/menu.pl";
1833 $lxdebug->leave_sub();
1837 $lxdebug->enter_sub();
1839 map { $column_data{$_} = "<td> </td>" } @column_index;
1841 $column_data{netamount} =
1842 "<th class=listsubtotal align=right>"
1843 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1845 $column_data{tax} = "<td class=listsubtotal align=right>"
1846 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1849 $column_data{amount} =
1850 "<th class=listsubtotal align=right>"
1851 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1853 $subtotalnetamount = 0;
1854 $subtotalamount = 0;
1857 <tr class=listsubtotal>
1860 map { print "\n$column_data{$_}" } @column_index;
1866 $lxdebug->leave_sub();
1869 sub save_and_close {
1870 $lxdebug->enter_sub();
1872 if ($form->{type} =~ /_order$/) {
1873 $form->isblank("transdate", $locale->text('Order Date missing!'));
1875 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1878 $msg = ucfirst $form->{vc};
1879 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1881 # $locale->text('Customer missing!');
1882 # $locale->text('Vendor missing!');
1884 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1885 if ($form->{currency} ne $form->{defaultcurrency});
1889 # if the name changed get new values
1890 if (&check_name($form->{vc})) {
1895 $form->{id} = 0 if $form->{saveasnew};
1897 # this is for the internal notes section for the [email] Subject
1898 if ($form->{type} =~ /_order$/) {
1899 if ($form->{type} eq 'sales_order') {
1900 $form->{label} = $locale->text('Sales Order');
1902 $numberfld = "sonumber";
1903 $ordnumber = "ordnumber";
1905 $form->{label} = $locale->text('Purchase Order');
1907 $numberfld = "ponumber";
1908 $ordnumber = "ordnumber";
1911 $err = $locale->text('Cannot save order!');
1914 if ($form->{type} eq 'sales_quotation') {
1915 $form->{label} = $locale->text('Quotation');
1917 $numberfld = "sqnumber";
1918 $ordnumber = "quonumber";
1920 $form->{label} = $locale->text('Request for Quotation');
1922 $numberfld = "rfqnumber";
1923 $ordnumber = "quonumber";
1926 $err = $locale->text('Cannot save quotation!');
1930 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
1931 unless $form->{$ordnumber};
1934 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1935 if (OE->save(\%myconfig, \%$form));
1938 $lxdebug->leave_sub();
1942 $lxdebug->enter_sub();
1944 if ($form->{type} =~ /_order$/) {
1945 $form->isblank("transdate", $locale->text('Order Date missing!'));
1947 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1950 $msg = ucfirst $form->{vc};
1951 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1953 # $locale->text('Customer missing!');
1954 # $locale->text('Vendor missing!');
1956 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1957 if ($form->{currency} ne $form->{defaultcurrency});
1961 # if the name changed get new values
1962 if (&check_name($form->{vc})) {
1967 $form->{id} = 0 if $form->{saveasnew};
1969 # this is for the internal notes section for the [email] Subject
1970 if ($form->{type} =~ /_order$/) {
1971 if ($form->{type} eq 'sales_order') {
1972 $form->{label} = $locale->text('Sales Order');
1974 $numberfld = "sonumber";
1975 $ordnumber = "ordnumber";
1977 $form->{label} = $locale->text('Purchase Order');
1979 $numberfld = "ponumber";
1980 $ordnumber = "ordnumber";
1983 $err = $locale->text('Cannot save order!');
1986 if ($form->{type} eq 'sales_quotation') {
1987 $form->{label} = $locale->text('Quotation');
1989 $numberfld = "sqnumber";
1990 $ordnumber = "quonumber";
1992 $form->{label} = $locale->text('Request for Quotation');
1994 $numberfld = "rfqnumber";
1995 $ordnumber = "quonumber";
1998 $err = $locale->text('Cannot save quotation!');
2002 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
2003 unless $form->{$ordnumber};
2006 OE->save(\%myconfig, \%$form);
2007 $form->{simple_save} = 1;
2008 if(!$form->{print_and_save}) {
2012 $lxdebug->leave_sub();
2016 $lxdebug->enter_sub();
2020 if ($form->{type} =~ /_order$/) {
2021 $msg = $locale->text('Are you sure you want to delete Order Number');
2022 $ordnumber = 'ordnumber';
2024 $msg = $locale->text('Are you sure you want to delete Quotation Number');
2025 $ordnumber = 'quonumber';
2031 <form method=post action=$form->{script}>
2034 # delete action variable
2035 map { delete $form->{$_} } qw(action header);
2037 foreach $key (keys %$form) {
2038 $form->{$key} =~ s/\"/"/g;
2039 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2043 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
2045 <h4>$msg $form->{$ordnumber}</h4>
2047 <input name=action class=submit type=submit value="|
2048 . $locale->text('Yes') . qq|">
2055 $lxdebug->leave_sub();
2059 $lxdebug->enter_sub();
2061 if ($form->{type} =~ /_order$/) {
2062 $msg = $locale->text('Order deleted!');
2063 $err = $locale->text('Cannot delete order!');
2065 $msg = $locale->text('Quotation deleted!');
2066 $err = $locale->text('Cannot delete quotation!');
2069 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
2072 $lxdebug->leave_sub();
2076 $lxdebug->enter_sub();
2078 if ($form->{type} =~ /_order$/) {
2080 # these checks only apply if the items don't bring their own ordnumbers/transdates.
2081 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
2082 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
2083 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2085 $form->isblank("transdate", $locale->text('Order Date missing!'))
2086 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
2089 # also copy deliverydate from the order
2090 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
2092 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
2093 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2094 $form->{ordnumber} = "";
2097 # if the name changed get new values
2098 if (&check_name($form->{vc})) {
2103 $form->{cp_id} *= 1;
2105 if ( $form->{type} =~ /_order/
2106 && $form->{currency} ne $form->{defaultcurrency}) {
2108 # check if we need a new exchangerate
2109 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
2111 $orddate = $form->current_date(\%myconfig);
2113 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
2116 if (!$exchangerate) {
2117 &backorder_exchangerate($orddate, $buysell);
2122 # close orders/quotations
2123 $form->{closed} = 1;
2125 # save order if one ordnumber has been given
2126 # if not it's most likely a collective order, which can't be saved back
2127 # so they just have to be closed
2128 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
2129 OE->save(\%myconfig, \%$form);
2131 OE->close_orders(\%myconfig, \%$form);
2134 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
2136 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2139 $form->{closed} = 0;
2140 $form->{rowcount}--;
2141 $form->{shipto} = 1;
2143 if ($form->{type} =~ /_order$/) {
2144 $form->{exchangerate} = $exchangerate;
2148 if ( $form->{type} eq 'purchase_order'
2149 || $form->{type} eq 'request_quotation') {
2150 $form->{title} = $locale->text('Add Vendor Invoice');
2151 $form->{script} = 'ir.pl';
2155 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
2156 $form->{title} = $locale->text('Add Sales Invoice');
2157 $form->{script} = 'is.pl';
2162 # bo creates the id, reset it
2163 map { delete $form->{$_} }
2164 qw(id subject message cc bcc printed emailed queued);
2165 $form->{ $form->{vc} } =~ s/--.*//g;
2166 $form->{type} = "invoice";
2169 $locale = new Locale "$myconfig{countrycode}", "$script";
2171 require "$form->{path}/$form->{script}";
2173 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
2175 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2176 qw(creditlimit creditremaining);
2178 $currency = $form->{currency};
2181 $form->{currency} = $currency;
2182 $form->{exchangerate} = "";
2183 $form->{forex} = "";
2184 $form->{exchangerate} = $exchangerate
2188 $form->check_exchangerate(
2189 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
2192 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
2197 for $i (1 .. $form->{rowcount}) {
2198 $form->{"discount_$i"} =
2199 $form->format_amount(\%myconfig, $form->{"discount_$i"});
2201 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
2203 $decimalplaces = ($dec > 2) ? $dec : 2;
2205 # copy delivery date from reqdate for order -> invoice conversion
2206 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
2207 unless $form->{"deliverydate_$i"};
2209 $form->{"sellprice_$i"} =
2210 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
2213 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
2214 $dec_qty = length $dec_qty;
2216 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
2218 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2219 qw(partnumber description unit);
2225 $lxdebug->leave_sub();
2228 sub backorder_exchangerate {
2229 $lxdebug->enter_sub();
2230 my ($orddate, $buysell) = @_;
2237 <form method=post action=$form->{script}>
2240 # delete action variable
2241 map { delete $form->{$_} } qw(action header exchangerate);
2243 foreach $key (keys %$form) {
2244 $form->{$key} =~ s/\"/"/g;
2245 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2248 $form->{title} = $locale->text('Add Exchangerate');
2252 <input type=hidden name=path value=$form->{path}>
2253 <input type=hidden name=login value=$form->{login}>
2254 <input type=hidden name=password value=$form->{password}>
2256 <input type=hidden name=exchangeratedate value=$orddate>
2257 <input type=hidden name=buysell value=$buysell>
2260 <tr><th class=listtop>$form->{title}</th></tr>
2261 <tr height="5"></tr>
2266 <th align=right>| . $locale->text('Currency') . qq|</th>
2267 <td>$form->{currency}</td>
2270 <th align=right>| . $locale->text('Date') . qq|</th>
2274 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2275 <td><input name=exchangerate size=11></td>
2285 <input type=hidden name=nextsub value=save_exchangerate>
2287 <input name=action class=submit type=submit value="|
2288 . $locale->text('Continue') . qq|">
2296 $lxdebug->leave_sub();
2299 sub save_exchangerate {
2300 $lxdebug->enter_sub();
2302 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2303 $form->{exchangerate} =
2304 $form->parse_amount(\%myconfig, $form->{exchangerate});
2305 $form->save_exchangerate(\%myconfig, $form->{currency},
2306 $form->{exchangeratedate},
2307 $form->{exchangerate}, $form->{buysell});
2311 $lxdebug->leave_sub();
2314 sub create_backorder {
2315 $lxdebug->enter_sub();
2317 $form->{shipped} = 1;
2319 # figure out if we need to create a backorder
2320 # items aren't saved if qty != 0
2322 for $i (1 .. $form->{rowcount}) {
2323 $totalqty += $qty = $form->{"qty_$i"};
2324 $totalship += $ship = $form->{"ship_$i"};
2326 $form->{"qty_$i"} = $qty - $ship;
2329 if ($totalship == 0) {
2330 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2331 $form->{ordtotal} = 0;
2332 $form->{shipped} = 0;
2336 if ($totalqty == $totalship) {
2337 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2338 $form->{ordtotal} = 0;
2343 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2346 for $i (1 .. $form->{rowcount}) {
2348 $form->{"${_}_$i"} =
2349 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2350 } qw(sellprice discount);
2353 OE->save(\%myconfig, \%$form);
2355 # rebuild rows for invoice
2359 for $i (1 .. $form->{rowcount}) {
2360 $form->{"qty_$i"} = $form->{"ship_$i"};
2362 if ($form->{"qty_$i"}) {
2365 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2370 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2371 $form->{rowcount} = $count;
2373 $lxdebug->leave_sub();
2377 $lxdebug->enter_sub();
2379 $form->{saveasnew} = 1;
2380 $form->{closed} = 0;
2381 map { delete $form->{$_} } qw(printed emailed queued ordnumber quonumber);
2385 $lxdebug->leave_sub();
2388 sub purchase_order {
2389 $lxdebug->enter_sub();
2391 if ( $form->{type} eq 'sales_quotation'
2392 || $form->{type} eq 'request_quotation') {
2393 $form->{closed} = 1;
2394 OE->save(\%myconfig, \%$form);
2397 $form->{cp_id} *= 1;
2399 $form->{title} = $locale->text('Add Purchase Order');
2400 $form->{vc} = "vendor";
2401 $form->{type} = "purchase_order";
2405 $lxdebug->leave_sub();
2409 $lxdebug->enter_sub();
2411 if ( $form->{type} eq 'sales_quotation'
2412 || $form->{type} eq 'request_quotation') {
2413 $form->{closed} = 1;
2414 OE->save(\%myconfig, \%$form);
2417 $form->{cp_id} *= 1;
2419 $form->{title} = $locale->text('Add Sales Order');
2420 $form->{vc} = "customer";
2421 $form->{type} = "sales_order";
2425 $lxdebug->leave_sub();
2429 $lxdebug->enter_sub();
2431 $form->{transdate} = $form->current_date(\%myconfig);
2432 delete $form->{duedate};
2434 $form->{closed} = 0;
2437 map { delete $form->{$_} }
2438 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2445 for $i (1 .. $form->{rowcount} - 1) {
2446 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2447 qw(partnumber description unit);
2450 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2451 qw(creditlimit creditremaining);
2455 $lxdebug->leave_sub();
2459 $lxdebug->enter_sub();
2465 OE->get_warehouses(\%myconfig, \%$form);
2468 if (@{ $form->{all_warehouses} }) {
2469 $form->{selectwarehouse} = "<option>\n";
2471 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2472 (@{ $form->{all_warehouses} });
2474 if ($form->{warehouse}) {
2475 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2479 $form->{shippingdate} = $form->current_date(\%myconfig);
2480 $form->{"$form->{vc}"} =~ s/--.*//;
2485 foreach $key (keys %$form) {
2486 if ($key =~ /_1$/) {
2492 for $i (1 .. $form->{rowcount}) {
2494 # undo formatting from prepare_order
2496 $form->{"${_}_$i"} =
2497 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2499 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2501 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2502 $form->{"ship_$i"} = "";
2503 $form->{"serialnumber_$i"} = "";
2508 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2513 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2514 $form->{rowcount} = $count;
2516 &display_ship_receive;
2518 $lxdebug->leave_sub();
2521 sub display_ship_receive {
2522 $lxdebug->enter_sub();
2524 $vclabel = ucfirst $form->{vc};
2525 $vclabel = $locale->text($vclabel);
2527 $form->{rowcount}++;
2529 if ($form->{vc} eq 'customer') {
2530 $form->{title} = $locale->text('Ship Merchandise');
2531 $shipped = $locale->text('Shipping Date');
2533 $form->{title} = $locale->text('Receive Merchandise');
2534 $shipped = $locale->text('Date Received');
2537 # set option selected
2538 foreach $item (warehouse, employee) {
2539 $form->{"select$item"} =~ s/ selected//;
2540 $form->{"select$item"} =~
2541 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2546 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2547 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2548 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2550 | if $form->{selectwarehouse};
2554 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2555 <td><select name=employee>$form->{selectemployee}</select></td>
2556 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2565 <form method=post action=$form->{script}>
2567 <input type=hidden name=id value=$form->{id}>
2569 <input type=hidden name=display_form value=display_ship_receive>
2571 <input type=hidden name=type value=$form->{type}>
2572 <input type=hidden name=media value=$form->{media}>
2573 <input type=hidden name=format value=$form->{format}>
2575 <input type=hidden name=queued value="$form->{queued}">
2576 <input type=hidden name=printed value="$form->{printed}">
2577 <input type=hidden name=emailed value="$form->{emailed}">
2579 <input type=hidden name=vc value=$form->{vc}>
2583 <th class=listtop>$form->{title}</th>
2585 <tr height="5"></tr>
2588 <table width="100%">
2593 <th align=right>$vclabel</th>
2594 <td colspan=3>$form->{$form->{vc}}</td>
2595 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2596 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2600 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2602 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2605 <th align=right>| . $locale->text('Ship via') . qq|</th>
2607 <input name=shipvia size=35 value="$form->{shipvia}">
2616 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2617 <td>$form->{ordnumber}</td>
2618 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2621 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2622 <td>$form->{transdate}</td>
2623 <input type=hidden name=transdate value=$form->{transdate}>
2626 <th align=right nowrap>$shipped</th>
2627 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2636 <!-- shipto are in hidden variables -->
2638 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2639 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2640 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2641 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2642 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2643 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2644 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2645 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2646 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2648 <!-- email variables -->
2649 <input type=hidden name=message value="$form->{message}">
2650 <input type=hidden name=email value="$form->{email}">
2651 <input type=hidden name=subject value="$form->{subject}">
2652 <input type=hidden name=cc value="$form->{cc}">
2653 <input type=hidden name=bcc value="$form->{bcc}">
2658 (partnumber, description, qty, ship, unit, bin, serialnumber);
2660 if ($form->{type} eq "ship_order") {
2661 $column_data{ship} =
2662 qq|<th class=listheading align=center width="auto">|
2663 . $locale->text('Ship')
2666 if ($form->{type} eq "receive_order") {
2667 $column_data{ship} =
2668 qq|<th class=listheading align=center width="auto">|
2669 . $locale->text('Recd')
2673 my $colspan = $#column_index + 1;
2675 $column_data{partnumber} =
2676 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2677 $column_data{description} =
2678 qq|<th class=listheading nowrap>|
2679 . $locale->text('Description')
2682 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2683 $column_data{unit} =
2684 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2686 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2687 $column_data{serialnumber} =
2688 qq|<th class=listheading nowrap>|
2689 . $locale->text('Serial No.')
2696 <tr class=listheading>|;
2698 map { print "\n$column_data{$_}" } @column_index;
2704 for $i (1 .. $form->{rowcount} - 1) {
2707 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2709 # convert " to "
2710 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2711 qw(partnumber description unit bin serialnumber);
2713 $description = $form->{"description_$i"};
2714 $description =~ s/\n/<br>/g;
2716 $column_data{partnumber} =
2717 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2718 $column_data{description} =
2719 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2721 qq|<td align=right>|
2722 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2723 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2724 $column_data{ship} =
2725 qq|<td align=right><input name="ship_$i" size=5 value=|
2726 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2728 $column_data{unit} =
2729 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2731 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2733 $column_data{serialnumber} =
2734 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2739 map { print "\n$column_data{$_}" } @column_index;
2744 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2745 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2746 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2747 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2758 <td><hr size=3 noshade></td>
2764 $form->{copies} = 1;
2773 <input class=submit type=submit name=action value="|
2774 . $locale->text('Update') . qq|">
2775 <input class=submit type=submit name=action value="|
2776 . $locale->text('Print') . qq|">
2779 if ($form->{type} eq 'ship_order') {
2781 <input class=submit type=submit name=action value="|
2782 . $locale->text('Ship to') . qq|">
2783 <input class=submit type=submit name=action value="|
2784 . $locale->text('E-mail') . qq|">
2790 <input class=submit type=submit name=action value="|
2791 . $locale->text('Done') . qq|">
2794 if ($form->{menubar}) {
2795 require "$form->{path}/menu.pl";
2801 <input type=hidden name=rowcount value=$form->{rowcount}>
2803 <input name=callback type=hidden value="$callback">
2805 <input type=hidden name=path value=$form->{path}>
2806 <input type=hidden name=login value=$form->{login}>
2807 <input type=hidden name=password value=$form->{password}>
2815 $lxdebug->leave_sub();
2819 $lxdebug->enter_sub();
2821 if ($form->{type} eq 'ship_order') {
2822 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2824 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2829 $total += $form->{"ship_$_"} =
2830 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2831 } (1 .. $form->{rowcount} - 1);
2833 $form->error($locale->text('Nothing entered!')) unless $total;
2835 $form->redirect($locale->text('Inventory saved!'))
2836 if OE->save_inventory(\%myconfig, \%$form);
2837 $form->error($locale->text('Could not save!'));
2839 $lxdebug->leave_sub();
2842 sub search_transfer {
2843 $lxdebug->enter_sub();
2845 OE->get_warehouses(\%myconfig, \%$form);
2848 if (@{ $form->{all_warehouses} }) {
2849 $form->{selectwarehouse} = "<option>\n";
2850 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2852 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2853 (@{ $form->{all_warehouses} });
2855 $form->error($locale->text('Nothing to transfer!'));
2858 $form->{title} = $locale->text('Transfer Inventory');
2865 <form method=post action=$form->{script}>
2869 <th class=listtop>$form->{title}</th>
2871 <tr height="5"></tr>
2876 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2877 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2880 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2881 <td><input name=partnumber size=20></td>
2884 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2885 <td><input name=description size=40></td>
2888 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2889 <td><input name=partsgroup size=20></td>
2895 <td><hr size=3 noshade></td>
2900 <input type=hidden name=sort value=partnumber>
2901 <input type=hidden name=nextsub value=list_transfer>
2903 <input type=hidden name=path value=$form->{path}>
2904 <input type=hidden name=login value=$form->{login}>
2905 <input type=hidden name=password value=$form->{password}>
2907 <input class=submit type=submit name=action value="|
2908 . $locale->text('Continue') . qq|">
2915 $lxdebug->leave_sub();
2919 $lxdebug->enter_sub();
2921 OE->get_inventory(\%myconfig, \%$form);
2923 $partnumber = $form->escape($form->{partnumber});
2924 $warehouse = $form->escape($form->{warehouse});
2925 $description = $form->escape($form->{description});
2926 $partsgroup = $form->escape($form->{partsgroup});
2930 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2932 # construct callback
2933 $partnumber = $form->escape($form->{partnumber}, 1);
2934 $warehouse = $form->escape($form->{warehouse}, 1);
2935 $description = $form->escape($form->{description}, 1);
2936 $partsgroup = $form->escape($form->{partsgroup}, 1);
2939 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2942 $form->sort_columns(
2943 qw(partnumber description partsgroup make model warehouse qty transfer));
2945 $column_header{partnumber} =
2946 qq|<th><a class=listheading href=$href&sort=partnumber>|
2947 . $locale->text('Part Number')
2949 $column_header{description} =
2950 qq|<th><a class=listheading href=$href&sort=description>|
2951 . $locale->text('Description')
2953 $column_header{partsgroup} =
2954 qq|<th><a class=listheading href=$href&sort=partsgroup>|
2955 . $locale->text('Group')
2957 $column_header{warehouse} =
2958 qq|<th><a class=listheading href=$href&sort=warehouse>|
2959 . $locale->text('From')
2961 $column_header{qty} =
2962 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
2963 $column_header{transfer} =
2964 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
2966 $option = $locale->text('Transfer to');
2968 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
2970 if ($form->{warehouse}) {
2971 $option .= " : $warehouse";
2973 if ($form->{partnumber}) {
2974 $option .= "\n<br>" if ($option);
2975 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
2977 if ($form->{description}) {
2978 $option .= "\n<br>" if ($option);
2979 $option .= $locale->text('Description') . " : $form->{description}";
2981 if ($form->{partsgroup}) {
2982 $option .= "\n<br>" if ($option);
2983 $option .= $locale->text('Group') . " : $form->{partsgroup}";
2986 $form->{title} = $locale->text('Transfer Inventory');
2993 <form method=post action=$form->{script}>
2995 <input type=hidden name=warehouse_id value=$warehouse_id>
2999 <th class=listtop>$form->{title}</th>
3001 <tr height="5"></tr>
3008 <tr class=listheading>|;
3010 map { print "\n$column_header{$_}" } @column_index;
3016 if (@{ $form->{all_inventory} }) {
3017 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
3021 foreach $ref (@{ $form->{all_inventory} }) {
3025 $column_data{partnumber} =
3026 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
3027 $column_data{description} = "<td>$ref->{description} </td>";
3028 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
3029 $column_data{warehouse} =
3030 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
3032 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
3033 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
3035 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
3040 <tr class=listrow$j>";
3042 map { print "\n$column_data{$_}" } @column_index;
3056 <td><hr size=3 noshade></td>
3062 <input name=callback type=hidden value="$callback">
3064 <input type=hidden name=rowcount value=$i>
3066 <input type=hidden name=path value=$form->{path}>
3067 <input type=hidden name=login value=$form->{login}>
3068 <input type=hidden name=password value=$form->{password}>
3070 <input class=submit type=submit name=action value="|
3071 . $locale->text('Transfer') . qq|">|;
3073 if ($form->{menubar}) {
3074 require "$form->{path}/menu.pl";
3085 $lxdebug->leave_sub();
3089 $lxdebug->enter_sub();
3091 $form->redirect($locale->text('Inventory transferred!'))
3092 if OE->transfer(\%myconfig, \%$form);
3093 $form->error($locale->text('Could not transfer Inventory!'));
3095 $lxdebug->leave_sub();