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});
85 undef $form->{rowcount};
96 if ($form->{type} eq 'purchase_order') {
97 $form->{title} = $locale->text('Edit Purchase Order');
98 $form->{heading} = $locale->text('Purchase Order');
99 $form->{vc} = 'vendor';
101 if ($form->{type} eq 'sales_order') {
102 $form->{title} = $locale->text('Edit Sales Order');
103 $form->{heading} = $locale->text('Sales Order');
104 $form->{vc} = 'customer';
106 if ($form->{type} eq 'request_quotation') {
107 $form->{title} = $locale->text('Edit Request for Quotation');
108 $form->{heading} = $locale->text('Request for Quotation');
109 $form->{vc} = 'vendor';
111 if ($form->{type} eq 'sales_quotation') {
112 $form->{title} = $locale->text('Edit Quotation');
113 $form->{heading} = $locale->text('Quotation');
114 $form->{vc} = 'customer';
121 $lxdebug->leave_sub();
125 $lxdebug->enter_sub();
127 # get customer/vendor
128 $form->all_vc(\%myconfig, $form->{vc},
129 ($form->{vc} eq 'customer') ? "AR" : "AP");
131 # retrieve order/quotation
132 $form->{webdav} = $webdav;
136 $form->{jscalendar} = $jscalendar;
138 OE->retrieve(\%myconfig, \%$form);
140 # if multiple rowcounts (== collective order) then check if the
141 # there were more than one customer (in that case OE::retrieve removes
142 # the content from the field)
143 if ($form->{rowcount} && $form->{type} eq 'sales_order' && defined $form->{customer} && $form->{customer} eq '') {
144 # $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
145 $form->error($locale->text('Collective Orders only work for orders from one customer!'));
148 $taxincluded = $form->{taxincluded};
149 $form->{shipto} = 1 if $form->{id};
151 if ($form->{"all_$form->{vc}"}) {
152 unless ($form->{"$form->{vc}_id"}) {
153 $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
157 $cp_id = $form->{cp_id};
158 $intnotes = $form->{intnotes};
160 # get customer / vendor
161 if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/) {
162 IR->get_vendor(\%myconfig, \%$form);
164 if ($form->{type} =~ /(sales|ship)_(order|quotation)/) {
165 IS->get_customer(\%myconfig, \%$form);
167 $form->{cp_id} = $cp_id;
169 $form->{intnotes} = $intnotes;
170 ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
171 $form->{"old$form->{vc}"} =
172 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
174 # build the popup menus
175 if (@{ $form->{"all_$form->{vc}"} }) {
176 $form->{ $form->{vc} } =
177 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
178 map { $form->{"select$form->{vc}"} .= "<option>$_->{name}--$_->{id}\n" }
179 (@{ $form->{"all_$form->{vc}"} });
183 @curr = split /:/, $form->{currencies};
185 $form->{defaultcurrency} = $curr[0];
186 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
188 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
190 $form->{taxincluded} = $taxincluded if ($form->{id});
193 if (@{ $form->{all_departments} }) {
194 $form->{selectdepartment} = "<option>\n";
195 $form->{department} = "$form->{department}--$form->{department_id}";
198 $form->{selectdepartment} .=
199 "<option>$_->{description}--$_->{id}\n"
200 } (@{ $form->{all_departments} });
203 $form->{employee} = "$form->{employee}--$form->{employee_id}";
206 if (@{ $form->{all_employees} }) {
207 $form->{selectemployee} = "";
208 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
209 (@{ $form->{all_employees} });
213 $form->{forex} = $form->{exchangerate};
215 $lxdebug->leave_sub();
219 $lxdebug->enter_sub();
220 $form->{format} = "pdf";
221 $form->{media} = "screen";
222 $form->{formname} = $form->{type};
224 map { $form->{$_} =~ s/\"/"/g }
225 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
227 foreach $ref (@{ $form->{form_details} }) {
228 $form->{rowcount} = ++$i;
230 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
232 for my $i (1 .. $form->{rowcount}) {
234 $form->{"discount_$i"} =
235 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
237 $form->{"discount_$i"} =
238 $form->format_amount(\%myconfig, $form->{"discount_$i"});
240 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
242 $decimalplaces = ($dec > 2) ? $dec : 2;
244 # copy reqdate from deliverydate for invoice -> order conversion
245 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"} unless $form->{"reqdate_$i"};
247 $form->{"sellprice_$i"} =
248 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
251 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
252 $dec_qty = length $dec_qty;
253 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
255 map { $form->{"${_}_$i"} =~ s/\"/"/g }
256 qw(partnumber description unit);
259 $lxdebug->leave_sub();
263 $lxdebug->enter_sub();
265 $checkedopen = ($form->{closed}) ? "" : "checked";
266 $checkedclosed = ($form->{closed}) ? "checked" : "";
268 # use JavaScript Calendar or not
269 $form->{jsscript} = $form->{jscalendar};
272 if ($form->{jsscript}) {
274 # with JavaScript Calendar
276 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
277 <td><input type=button name=transdate id="trigger1" value=|
278 . $locale->text('button') . qq|></td>
281 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
282 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
283 . $locale->text('button') . qq|></td>
288 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
289 "reqdate", "BL", "trigger2");
293 # without JavaScript Calendar
295 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
297 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
303 <td colspan=2 align=center>
306 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
307 . $locale->text('Open') . qq|</th>
308 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
309 . $locale->text('Closed') . qq|</th>
317 # set option selected
318 foreach $item ($form->{vc}, currency, department, employee, contact) {
319 $form->{"select$item"} =~ s/ selected//;
320 $form->{"select$item"} =~
321 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
325 if ($form->{all_contacts}) {
327 $form->{selectcontact} = "";
328 foreach $item (@{ $form->{all_contacts} }) {
329 if ($form->{cp_id} == $item->{cp_id}) {
330 $form->{selectcontact} .=
331 "<option selected>$item->{cp_name}--$item->{cp_id}";
333 $form->{selectcontact} .= "<option>$item->{cp_name}--$item->{cp_id}";
338 $form->{exchangerate} =
339 $form->format_amount(\%myconfig, $form->{exchangerate});
341 $form->{creditlimit} =
342 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
343 $form->{creditremaining} =
344 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
347 ($form->{selectcontact})
348 ? qq|<select name=contact>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
349 : qq|<input name=contact value="$form->{contact}" size=35>|;
352 <input type=hidden name=forex value=$form->{forex}>
355 if ($form->{currency} ne $form->{defaultcurrency}) {
356 if ($form->{forex}) {
359 . $locale->text('Exchangerate')
360 . qq|</th><td>$form->{exchangerate}</td>
361 <input type=hidden name=exchangerate value=$form->{exchangerate}>
366 . $locale->text('Exchangerate')
367 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
371 $vclabel = ucfirst $form->{vc};
372 $vclabel = $locale->text($vclabel);
376 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
377 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
378 . $locale->text('days') . qq|</td>
382 if ($form->{business}) {
385 <th align=right>| . $locale->text('Business') . qq|</th>
386 <td>$form->{business}</td>
387 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
389 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
395 if ($form->{type} !~ /_quotation$/) {
398 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
399 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
402 <th width=70% align=right nowrap>|
403 . $locale->text('Quotation Number') . qq|</th>
404 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
407 <th width=70% align=right nowrap>|
408 . $locale->text('Customer Order Number') . qq|</th>
409 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
412 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
417 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
422 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
424 $creditremaining = qq|
430 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
431 <td>$form->{creditlimit}</td>
433 <th nowrap>| . $locale->text('Remaining') . qq|</th>
434 <td class="plus$n">$form->{creditremaining}</td>
442 ($form->{type} eq 'sales_quotation')
443 ? $locale->text('Valid until')
444 : $locale->text('Required by');
445 if ($form->{type} eq 'sales_quotation') {
448 <th width=70% align=right nowrap>|
449 . $locale->text('Quotation Number') . qq|</th>
450 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
451 <input type=hidden name=ordnumber value="$form->{ordnumber}">
457 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
458 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
459 <input type=hidden name=ordnumber value="$form->{ordnumber}">
468 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
472 <th align=right nowrap=true>$reqlabel</th>
480 ($form->{"select$form->{vc}"})
481 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
482 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
486 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
487 <td colspan=3><select name=department>$form->{selectdepartment}</select>
488 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
491 | if $form->{selectdepartment};
494 <input type=hidden name=employee value="$form->{employee}">
497 if ($form->{type} eq 'sales_order') {
498 if ($form->{selectemployee}) {
500 <input type=hidden name=customer_klass value=$form->{customer_klass}>
502 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
503 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
504 <input type=hidden name=selectemployee value="$form->{selectemployee}">
511 <input type=hidden name=customer_klass value=$form->{customer_klass}>
513 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
514 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
515 <input type=hidden name=selectemployee value="$form->{selectemployee}">
526 <form method=post action=$form->{script}>
528 <input type=hidden name=id value=$form->{id}>
530 <input type=hidden name=type value=$form->{type}>
531 <input type=hidden name=formname value=$form->{formname}>
532 <input type=hidden name=media value=$form->{media}>
533 <input type=hidden name=format value=$form->{format}>
535 <input type=hidden name=queued value="$form->{queued}">
536 <input type=hidden name=printed value="$form->{printed}">
537 <input type=hidden name=emailed value="$form->{emailed}">
539 <input type=hidden name=vc value=$form->{vc}>
541 <input type=hidden name=title value="$form->{title}">
543 <input type=hidden name=discount value=$form->{discount}>
544 <input type=hidden name=creditlimit value=$form->{creditlimit}>
545 <input type=hidden name=creditremaining value=$form->{creditremaining}>
547 <input type=hidden name=tradediscount value=$form->{tradediscount}>
548 <input type=hidden name=business value=$form->{business}>
549 <input type=hidden name=webdav value=$webdav>
553 <th class=listtop>$form->{title}</th>
563 <th align=right>$vclabel</th>
564 <td colspan=3>$vc</td>
565 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
566 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
567 <th align=richt nowrap>|
568 . $locale->text('Contact Person') . qq|</th>
569 <td colspan=3>$contact</td>
575 <th align=right>| . $locale->text('Currency') . qq|</th>
576 <td><select name=currency>$form->{selectcurrency}</select></td>
577 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
578 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
582 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
583 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
586 <th align=right>| . $locale->text('Ship via') . qq|</th>
587 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
606 <!-- shipto are in hidden variables -->
608 <input type=hidden name=shiptoname value="$form->{shiptoname}">
609 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
610 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
611 <input type=hidden name=shiptocity value="$form->{shiptocity}">
612 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
613 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
614 <input type=hidden name=shiptophone value="$form->{shiptophone}">
615 <input type=hidden name=shiptofax value="$form->{shiptofax}">
616 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
618 <!-- email variables -->
619 <input type=hidden name=message value="$form->{message}">
620 <input type=hidden name=email value="$form->{email}">
621 <input type=hidden name=subject value="$form->{subject}">
622 <input type=hidden name=cc value="$form->{cc}">
623 <input type=hidden name=bcc value="$form->{bcc}">
625 <input type=hidden name=taxpart value="$form->{taxpart}">
626 <input type=hidden name=taxservice value="$form->{taxservice}">
628 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
631 foreach $item (split / /, $form->{taxaccounts}) {
633 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
634 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
637 $lxdebug->leave_sub();
641 $lxdebug->enter_sub();
643 $form->{invtotal} = $form->{invsubtotal};
645 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
648 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
651 $rows = ($rows > $introws) ? $rows : $introws;
653 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
655 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
657 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
660 if ($form->{taxaccounts}) {
662 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
663 . $locale->text('Tax Included') . qq|</b><br><br>
667 if (!$form->{taxincluded}) {
669 foreach $item (split / /, $form->{taxaccounts}) {
670 if ($form->{"${item}_base"}) {
671 $form->{invtotal} += $form->{"${item}_total"} =
673 $form->{"${item}_base"} * $form->{"${item}_rate"},
675 $form->{"${item}_total"} =
676 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
680 <th align=right>$form->{"${item}_description"}</th>
681 <td align=right>$form->{"${item}_total"}</td>
687 $form->{invsubtotal} =
688 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
692 <th align=right>| . $locale->text('Subtotal') . qq|</th>
693 <td align=right>$form->{invsubtotal}</td>
699 if ($form->{taxincluded}) {
700 foreach $item (split / /, $form->{taxaccounts}) {
701 if ($form->{"${item}_base"}) {
702 $form->{"${item}_total"} =
704 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
705 (1 + $form->{"${item}_rate"})
708 $form->{"${item}_netto"} =
710 ($form->{"${item}_base"} - $form->{"${item}_total"}),
712 $form->{"${item}_total"} =
713 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
714 $form->{"${item}_netto"} =
715 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
719 <th align=right>Enthaltene $form->{"${item}_description"}</th>
720 <td align=right>$form->{"${item}_total"}</td>
723 <th align=right>Nettobetrag</th>
724 <td align=right>$form->{"${item}_netto"}</td>
732 $form->{oldinvtotal} = $form->{invtotal};
734 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
744 <th align=left>| . $locale->text('Notes') . qq|</th>
745 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
753 <td align=right width=100%>
759 <th align=right>| . $locale->text('Total') . qq|</th>
760 <td align=right>$form->{invtotal}</td>
768 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
769 <input type=hidden name=oldtotalpaid value=$totalpaid>
771 <td><hr size=3 noshade></td>
779 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
782 <td align=left width=30%><b>Dateiname</b></td>
783 <td align=left width=70%><b>Webdavlink</b></td>
785 foreach $file (keys %{ $form->{WEBDAV} }) {
788 <td align=left>$file</td>
789 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
797 <td><hr size=3 noshade></td>
804 <input type=hidden name=jscalendar value=$form->{jscalendar}>
817 Bearbeiten des $form->{heading}<br>
818 <input class=submit type=submit name=action value="|
819 . $locale->text('Update') . qq|">
820 <input class=submit type=submit name=action value="|
821 . $locale->text('Ship to') . qq|">
822 <input class=submit type=submit name=action value="|
823 . $locale->text('Print') . qq|">
824 <input class=submit type=submit name=action value="|
825 . $locale->text('E-mail') . qq|">
826 <input class=submit type=submit name=action value="|
827 . $locale->text('Save') . qq|">
832 <br>Workflow $form->{heading}<br>
833 <input class=submit type=submit name=action value="|
834 . $locale->text('Save as new') . qq|">
835 <input class=submit type=submit name=action value="|
836 . $locale->text('Delete') . qq|">|;
837 if ($form->{type} =~ /sales_quotation$/) {
839 <input class=submit type=submit name=action value="|
840 . $locale->text('Sales Order') . qq|">|;
842 if ($form->{type} =~ /request_quotation$/) {
844 <input class=submit type=submit name=action value="|
845 . $locale->text('Purchase Order') . qq|">|;
848 <input class=submit type=submit name=action value="|
849 . $locale->text('Invoice') . qq|">
852 if ($form->{type} =~ /sales_order$/) {
854 <br>$form->{heading} als neue Vorlage verwenden für<br>
855 <input class=submit type=submit name=action value="|
856 . $locale->text('Purchase Order') . qq|">
857 <input class=submit type=submit name=action value="|
858 . $locale->text('Quotation') . qq|">
861 } elsif ($form->{type} =~ /purchase_order$/) {
863 <br>$form->{heading} als neue Vorlage verwenden für<br>
864 <input class=submit type=submit name=action value="|
865 . $locale->text('Sales Order') . qq|">
866 <input class=submit type=submit name=action value="|
867 . $locale->text('Quotation') . qq|">
872 <br>$form->{heading} als neue Vorlage verwenden für<br>
873 <input class=submit type=submit name=action value="|
874 . $locale->text('Order') . qq|">
877 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount}) {
879 <br>Workflow $form->{heading}<br>
880 <input class=submit type=submit name=action value="|
881 . $locale->text('Save as new') . qq|">
882 <input class=submit type=submit name=action value="|
883 . $locale->text('Invoice') . qq|">
888 if ($form->{menubar}) {
889 require "$form->{path}/menu.pl";
895 <input type=hidden name=rowcount value=$form->{rowcount}>
897 <input name=callback type=hidden value="$form->{callback}">
899 <input type=hidden name=path value=$form->{path}>
900 <input type=hidden name=login value=$form->{login}>
901 <input type=hidden name=password value=$form->{password}>
908 $lxdebug->leave_sub();
912 $lxdebug->enter_sub();
914 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
915 qw(exchangerate creditlimit creditremaining);
917 &check_name($form->{vc});
922 $buysell = 'sell' if ($form->{vc} eq 'vendor');
923 $form->{exchangerate} = $exchangerate
927 $form->check_exchangerate(
928 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
932 $i = $form->{rowcount};
934 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
936 if ( ($form->{"partnumber_$i"} eq "")
937 && ($form->{"description_$i"} eq "")
938 && ($form->{"partsgroup_$i"} eq "")) {
940 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
945 if ( $form->{type} eq 'purchase_order'
946 || $form->{type} eq 'request_quotation') {
947 IR->retrieve_item(\%myconfig, \%$form);
949 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
950 IS->retrieve_item(\%myconfig, \%$form);
953 my $rows = scalar @{ $form->{item_list} };
955 $form->{"discount_$i"} =
956 $form->format_amount(\%myconfig, $form->{discount} * 100);
959 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
968 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
970 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
971 qw(partnumber description unit);
972 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
973 keys %{ $form->{item_list}[0] };
975 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
977 ($dec) = ($s =~ /\.(\d+)/);
979 $decimalplaces = ($dec > 2) ? $dec : 2;
982 $form->{"sellprice_$i"} = $sellprice;
985 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
986 # if there is an exchange rate adjust sellprice
987 $form->{"sellprice_$i"} /= $exchangerate;
991 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
992 (1 - $form->{"discount_$i"} / 100);
993 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
994 map { $form->{"${_}_base"} += $amount }
995 (split / /, $form->{"taxaccounts_$i"});
996 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
997 split / /, $form->{taxaccounts}
998 if !$form->{taxincluded};
1000 $form->{creditremaining} -= $amount;
1002 $form->{"sellprice_$i"} =
1003 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1006 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1008 # get pricegroups for parts
1009 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1011 # build up html code for prices_$i
1012 &set_pricegroup($i);
1019 # ok, so this is a new part
1020 # ask if it is a part or service item
1022 if ( $form->{"partsgroup_$i"}
1023 && ($form->{"partsnumber_$i"} eq "")
1024 && ($form->{"description_$i"} eq "")) {
1025 $form->{rowcount}--;
1026 $form->{"discount_$i"} = "";
1030 $form->{"id_$i"} = 0;
1031 $form->{"unit_$i"} = $locale->text('ea');
1040 $lxdebug->leave_sub();
1044 $lxdebug->enter_sub();
1046 if ($form->{type} eq 'purchase_order') {
1047 $form->{title} = $locale->text('Purchase Orders');
1048 $form->{vc} = 'vendor';
1049 $ordlabel = $locale->text('Order Number');
1050 $ordnumber = 'ordnumber';
1051 $employee = $locale->text('Employee');
1053 if ($form->{type} eq 'request_quotation') {
1054 $form->{title} = $locale->text('Request for Quotations');
1055 $form->{vc} = 'vendor';
1056 $ordlabel = $locale->text('RFQ Number');
1057 $ordnumber = 'quonumber';
1058 $employee = $locale->text('Employee');
1060 if ($form->{type} eq 'receive_order') {
1061 $form->{title} = $locale->text('Receive Merchandise');
1062 $form->{vc} = 'vendor';
1063 $ordlabel = $locale->text('Order Number');
1064 $ordnumber = 'ordnumber';
1065 $employee = $locale->text('Employee');
1067 if ($form->{type} eq 'sales_order') {
1068 $form->{title} = $locale->text('Sales Orders');
1069 $form->{vc} = 'customer';
1070 $ordlabel = $locale->text('Order Number');
1071 $ordnumber = 'ordnumber';
1072 $employee = $locale->text('Salesperson');
1074 if ($form->{type} eq 'ship_order') {
1075 $form->{title} = $locale->text('Ship Merchandise');
1076 $form->{vc} = 'customer';
1077 $ordlabel = $locale->text('Order Number');
1078 $ordnumber = 'ordnumber';
1079 $employee = $locale->text('Salesperson');
1083 if ($form->{type} eq 'sales_quotation') {
1084 $form->{title} = $locale->text('Quotations');
1085 $form->{vc} = 'customer';
1086 $ordlabel = $locale->text('Quotation Number');
1087 $ordnumber = 'quonumber';
1088 $employee = $locale->text('Employee');
1091 if ($form->{type} =~ /(ship|receive)_order/) {
1092 OE->get_warehouses(\%myconfig, \%$form);
1095 if (@{ $form->{all_warehouses} }) {
1096 $form->{selectwarehouse} = "<option>\n";
1097 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1100 $form->{selectwarehouse} .=
1101 "<option>$_->{description}--$_->{id}\n"
1102 } (@{ $form->{all_warehouses} });
1106 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1107 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1108 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1115 # setup vendor / customer selection
1116 $form->all_vc(\%myconfig, $form->{vc},
1117 ($form->{vc} eq 'customer') ? "AR" : "AP");
1119 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1120 @{ $form->{"all_$form->{vc}"} };
1122 $vclabel = ucfirst $form->{vc};
1123 $vclabel = $locale->text($vclabel);
1125 # $locale->text('Vendor')
1126 # $locale->text('Customer')
1130 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1131 : qq|<input name=$form->{vc} size=35>|;
1134 if (@{ $form->{all_departments} }) {
1135 $form->{selectdepartment} = "<option>\n";
1138 $form->{selectdepartment} .=
1139 "<option>$_->{description}--$_->{id}\n"
1140 } (@{ $form->{all_departments} });
1145 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1146 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1148 | if $form->{selectdepartment};
1150 if ($form->{type} !~ /(ship_order|receive_order)/) {
1153 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1154 . $locale->text('Open') . qq|</td>
1155 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1156 . $locale->text('Closed') . qq|</td>
1162 <input type=hidden name="open" value=1>
1166 # use JavaScript Calendar or not
1167 $form->{jsscript} = $jscalendar;
1169 if ($form->{jsscript}) {
1171 # with JavaScript Calendar
1173 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1174 <input type=button name=transdatefrom id="trigger3" value=|
1175 . $locale->text('button') . qq|></td>
1178 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1179 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1180 . $locale->text('button') . qq|></td>
1185 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1186 "transdateto", "BL", "trigger4");
1189 # without JavaScript Calendar
1191 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1193 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1201 <form method=post action=$form->{script}>
1205 <th class=listtop>$form->{title}</th>
1207 <tr height="5"></tr>
1212 <th align=right>$vclabel</th>
1213 <td colspan=3>$vc</td>
1218 <th align=right>$ordlabel</th>
1219 <td colspan=3><input name="$ordnumber" size=20></td>
1222 <th align=right>| . $locale->text('From') . qq|</th>
1224 <th align=right>| . $locale->text('Bis') . qq|</th>
1227 <input type=hidden name=sort value=transdate>
1229 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1234 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1235 | . $locale->text('ID') . qq|</td>
1236 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1237 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1238 . $locale->text('Date') . qq|</td>
1239 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1240 . $locale->text('Required by') . qq|</td>
1243 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1244 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1245 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1246 . $locale->text('Ship via') . qq|</td>
1249 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1250 . $locale->text('Amount') . qq|</td>
1251 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1252 . $locale->text('Tax') . qq|</td>
1253 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1254 . $locale->text('Total') . qq|</td>
1257 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1258 . $locale->text('Subtotal') . qq|</td>
1266 <tr><td colspan=4><hr size=3 noshade></td></tr>
1272 <input type=hidden name=nextsub value=orders>
1273 <input type=hidden name=path value=$form->{path}>
1274 <input type=hidden name=login value=$form->{login}>
1275 <input type=hidden name=password value=$form->{password}>
1276 <input type=hidden name=vc value=$form->{vc}>
1277 <input type=hidden name=type value=$form->{type}>
1279 <input class=submit type=submit name=action value="|
1280 . $locale->text('Continue') . qq|">
1287 $lxdebug->leave_sub();
1291 $lxdebug->enter_sub();
1293 # split vendor / customer
1294 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1295 split(/--/, $form->{ $form->{vc} });
1297 OE->transactions(\%myconfig, \%$form);
1299 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1301 $number = $form->escape($form->{$ordnumber});
1302 $name = $form->escape($form->{ $form->{vc} });
1303 $department = $form->escape($form->{department});
1304 $warehouse = $form->escape($form->{warehouse});
1308 "$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";
1310 # construct callback
1311 $number = $form->escape($form->{$ordnumber}, 1);
1312 $name = $form->escape($form->{ $form->{vc} }, 1);
1313 $department = $form->escape($form->{department}, 1);
1314 $warehouse = $form->escape($form->{warehouse}, 1);
1317 "$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";
1320 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1321 "name", "netamount", "tax", "amount",
1322 "curr", "employee", "shipvia", "open",
1325 $form->{l_open} = $form->{l_closed} = "Y"
1326 if ($form->{open} && $form->{closed});
1328 foreach $item (@columns) {
1329 if ($form->{"l_$item"} eq "Y") {
1330 push @column_index, $item;
1332 # add column to href and callback
1333 $callback .= "&l_$item=Y";
1334 $href .= "&l_$item=Y";
1338 # only show checkboxes if gotten here via sales_order form.
1339 if ($form->{type} =~ /sales_order/) {
1340 unshift @column_index, "ids";
1343 if ($form->{l_subtotal} eq 'Y') {
1344 $callback .= "&l_subtotal=Y";
1345 $href .= "&l_subtotal=Y";
1348 if ($form->{vc} eq 'vendor') {
1349 if ($form->{type} eq 'receive_order') {
1350 $form->{title} = $locale->text('Receive Merchandise');
1351 } elsif ($form->{type} eq 'purchase_order') {
1352 $form->{title} = $locale->text('Purchase Orders');
1354 $form->{title} = $locale->text('Request for Quotations');
1356 $name = $locale->text('Vendor');
1357 $employee = $locale->text('Employee');
1359 if ($form->{vc} eq 'customer') {
1360 if ($form->{type} eq 'sales_order') {
1361 $form->{title} = $locale->text('Sales Orders');
1362 $employee = $locale->text('Salesperson');
1363 } elsif ($form->{type} eq 'ship_order') {
1364 $form->{title} = $locale->text('Ship Merchandise');
1365 $employee = $locale->text('Salesperson');
1367 $form->{title} = $locale->text('Quotations');
1368 $employee = $locale->text('Employee');
1370 $name = $locale->text('Customer');
1373 $column_header{id} =
1374 qq|<th><a class=listheading href=$href&sort=id>|
1375 . $locale->text('ID')
1377 $column_header{transdate} =
1378 qq|<th><a class=listheading href=$href&sort=transdate>|
1379 . $locale->text('Date')
1381 $column_header{reqdate} =
1382 qq|<th><a class=listheading href=$href&sort=reqdate>|
1383 . $locale->text('Required by')
1385 $column_header{ordnumber} =
1386 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1387 . $locale->text('Order')
1389 $column_header{quonumber} =
1390 qq|<th><a class=listheading href=$href&sort=quonumber>|
1391 . $locale->text('Quotation')
1393 $column_header{name} =
1394 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1395 $column_header{netamount} =
1396 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1397 $column_header{tax} =
1398 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1399 $column_header{amount} =
1400 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1401 $column_header{curr} =
1402 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1403 $column_header{shipvia} =
1404 qq|<th><a class=listheading href=$href&sort=shipvia>|
1405 . $locale->text('Ship via')
1407 $column_header{open} =
1408 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1409 $column_header{closed} =
1410 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1412 $column_header{employee} =
1413 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1415 $column_header{ids} = qq|<th></th>|;
1417 if ($form->{ $form->{vc} }) {
1418 $option = $locale->text(ucfirst $form->{vc});
1419 $option .= " : $form->{$form->{vc}}";
1421 if ($form->{warehouse}) {
1422 ($warehouse) = split /--/, $form->{warehouse};
1423 $option .= "\n<br>" if ($option);
1424 $option .= $locale->text('Warehouse');
1425 $option .= " : $warehouse";
1427 if ($form->{department}) {
1428 $option .= "\n<br>" if ($option);
1429 ($department) = split /--/, $form->{department};
1430 $option .= $locale->text('Department') . " : $department";
1432 if ($form->{transdatefrom}) {
1434 . $locale->text('From') . " "
1435 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1437 if ($form->{transdateto}) {
1439 . $locale->text('Bis') . " "
1440 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1442 if ($form->{open}) {
1443 $option .= "\n<br>" if ($option);
1444 $option .= $locale->text('Open');
1446 if ($form->{closed}) {
1447 $option .= "\n<br>" if ($option);
1448 $option .= $locale->text('Closed');
1456 <form method="post" action="oe.pl">
1459 <th class=listtop>$form->{title}</th>
1461 <tr height="5"></tr>
1468 <tr class=listheading>|;
1470 map { print "\n$column_header{$_}" } @column_index;
1476 # add sort and escape callback
1477 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1479 if (@{ $form->{OE} }) {
1480 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1484 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1486 $warehouse = $form->escape($form->{warehouse});
1488 foreach $oe (@{ $form->{OE} }) {
1489 $form->{rowcount} = ++$j;
1491 if ($form->{l_subtotal} eq 'Y') {
1492 if ($sameitem ne $oe->{ $form->{sort} }) {
1494 $sameitem = $oe->{ $form->{sort} };
1498 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1500 $column_data{netamount} =
1502 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1504 $column_data{tax} = "<td align=right>"
1505 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1508 $column_data{amount} =
1510 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1512 $totalnetamount += $oe->{netamount};
1513 $totalamount += $oe->{amount};
1515 $subtotalnetamount += $oe->{netamount};
1516 $subtotalamount += $oe->{amount};
1518 $column_data{ids} = qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1519 $column_data{id} = "<td>$oe->{id}</td>";
1520 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1521 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1523 $column_data{$ordnumber} =
1524 "<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>";
1525 $column_data{name} = "<td>$oe->{name}</td>";
1527 $column_data{employee} = "<td>$oe->{employee} </td>";
1528 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1530 if ($oe->{closed}) {
1531 $column_data{closed} = "<td align=center>X</td>";
1532 $column_data{open} = "<td> </td>";
1534 $column_data{closed} = "<td> </td>";
1535 $column_data{open} = "<td align=center>X</td>";
1541 <tr class=listrow$i>";
1543 map { print "\n$column_data{$_}" } @column_index;
1551 if ($form->{l_subtotal} eq 'Y') {
1557 <tr class=listtotal>|;
1559 map { $column_data{$_} = "<td> </td>" } @column_index;
1561 $column_data{netamount} =
1562 "<th class=listtotal align=right>"
1563 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1564 $column_data{tax} = "<th class=listtotal align=right>"
1565 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1568 $column_data{amount} =
1569 "<th class=listtotal align=right>"
1570 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1572 map { print "\n$column_data{$_}" } @column_index;
1580 <td><hr size=3 noshade></td>
1584 # multiple invoice edit button only if gotten there via sales_order form.
1586 if ($form->{type} =~ /sales_order/) {
1588 <input type="hidden" name="path" value="$form->{path}">
1589 <input class"submit" type="submit" name="action" value="|
1590 . $locale->text('Continue') .qq|">
1591 <input type="hidden" name="nextsub" value="edit">
1592 <input type="hidden" name="type" value="$form->{type}">
1593 <input type="hidden" name="warehouse" value="$warehouse">
1594 <input type="hidden" name="vc" value="$form->{vc}">
1595 <input type="hidden" name="login" value="$form->{login}">
1596 <input type="hidden" name="password" value="$form->{password}">
1597 <input type="hidden" name="callback" value="$callback">
1598 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1605 <form method=post action=$form->{script}>
1607 <input name=callback type=hidden value="$form->{callback}">
1609 <input type=hidden name=type value=$form->{type}>
1610 <input type=hidden name=vc value=$form->{vc}>
1612 <input type=hidden name=path value=$form->{path}>
1613 <input type=hidden name=login value=$form->{login}>
1614 <input type=hidden name=password value=$form->{password}>
1617 if ($form->{type} !~ /(ship|receive)_order/) {
1619 <input class=submit type=submit name=action value="|
1620 . $locale->text('Add') . qq|">|;
1623 if ($form->{menubar}) {
1624 require "$form->{path}/menu.pl";
1635 $lxdebug->leave_sub();
1639 $lxdebug->enter_sub();
1641 map { $column_data{$_} = "<td> </td>" } @column_index;
1643 $column_data{netamount} =
1644 "<th class=listsubtotal align=right>"
1645 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1647 $column_data{tax} = "<td class=listsubtotal align=right>"
1648 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1651 $column_data{amount} =
1652 "<th class=listsubtotal align=right>"
1653 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1655 $subtotalnetamount = 0;
1656 $subtotalamount = 0;
1659 <tr class=listsubtotal>
1662 map { print "\n$column_data{$_}" } @column_index;
1668 $lxdebug->leave_sub();
1672 $lxdebug->enter_sub();
1674 if ($form->{type} =~ /_order$/) {
1675 $form->isblank("transdate", $locale->text('Order Date missing!'));
1677 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1680 $msg = ucfirst $form->{vc};
1681 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1683 # $locale->text('Customer missing!');
1684 # $locale->text('Vendor missing!');
1686 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1687 if ($form->{currency} ne $form->{defaultcurrency});
1691 # if the name changed get new values
1692 if (&check_name($form->{vc})) {
1697 $form->{id} = 0 if $form->{saveasnew};
1699 # this is for the internal notes section for the [email] Subject
1700 if ($form->{type} =~ /_order$/) {
1701 if ($form->{type} eq 'sales_order') {
1702 $form->{label} = $locale->text('Sales Order');
1704 $numberfld = "sonumber";
1705 $ordnumber = "ordnumber";
1707 $form->{label} = $locale->text('Purchase Order');
1709 $numberfld = "ponumber";
1710 $ordnumber = "ordnumber";
1713 $err = $locale->text('Cannot save order!');
1716 if ($form->{type} eq 'sales_quotation') {
1717 $form->{label} = $locale->text('Quotation');
1719 $numberfld = "sqnumber";
1720 $ordnumber = "quonumber";
1722 $form->{label} = $locale->text('Request for Quotation');
1724 $numberfld = "rfqnumber";
1725 $ordnumber = "quonumber";
1728 $err = $locale->text('Cannot save quotation!');
1732 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
1733 unless $form->{$ordnumber};
1736 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1737 if (OE->save(\%myconfig, \%$form));
1740 $lxdebug->leave_sub();
1744 $lxdebug->enter_sub();
1748 if ($form->{type} =~ /_order$/) {
1749 $msg = $locale->text('Are you sure you want to delete Order Number');
1750 $ordnumber = 'ordnumber';
1752 $msg = $locale->text('Are you sure you want to delete Quotation Number');
1753 $ordnumber = 'quonumber';
1759 <form method=post action=$form->{script}>
1762 # delete action variable
1763 map { delete $form->{$_} } qw(action header);
1765 foreach $key (keys %$form) {
1766 $form->{$key} =~ s/\"/"/g;
1767 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1771 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1773 <h4>$msg $form->{$ordnumber}</h4>
1775 <input name=action class=submit type=submit value="|
1776 . $locale->text('Yes') . qq|">
1783 $lxdebug->leave_sub();
1787 $lxdebug->enter_sub();
1789 if ($form->{type} =~ /_order$/) {
1790 $msg = $locale->text('Order deleted!');
1791 $err = $locale->text('Cannot delete order!');
1793 $msg = $locale->text('Quotation deleted!');
1794 $err = $locale->text('Cannot delete quotation!');
1797 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
1800 $lxdebug->leave_sub();
1804 $lxdebug->enter_sub();
1806 if ($form->{type} =~ /_order$/) {
1807 # these checks only apply if the items don't bring their own ordnumbers/transdates.
1808 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
1809 $form->isblank("ordnumber", $locale->text('Order Number missing!')) if ( +{ map { $form->{"ordnumber_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} );
1810 $form->isblank("transdate", $locale->text('Order Date missing!')) if ( +{ map { $form->{"transdate_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} );
1812 # also copy deliverydate from the order
1813 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
1815 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
1816 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1817 $form->{ordnumber} = "";
1820 # if the name changed get new values
1821 if (&check_name($form->{vc})) {
1826 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1827 $form->{cp_id} *= 1;
1829 if ( $form->{type} =~ /_order/
1830 && $form->{currency} ne $form->{defaultcurrency}) {
1832 # check if we need a new exchangerate
1833 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
1835 $orddate = $form->current_date(\%myconfig);
1837 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
1840 if (!$exchangerate) {
1841 &backorder_exchangerate($orddate, $buysell);
1846 # close orders/quotations
1847 $form->{closed} = 1;
1849 # save order if one ordnumber has been given
1850 # if not it's most likely a collective order, which can't be saved back
1851 # so they just have to be closed
1852 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
1853 OE->save(\%myconfig, \%$form);
1855 OE->close_orders(\%myconfig, \%$form);
1858 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1860 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1863 $form->{closed} = 0;
1864 $form->{rowcount}--;
1865 $form->{shipto} = 1;
1867 if ($form->{type} =~ /_order$/) {
1868 $form->{exchangerate} = $exchangerate;
1872 if ( $form->{type} eq 'purchase_order'
1873 || $form->{type} eq 'request_quotation') {
1874 $form->{title} = $locale->text('Add Vendor Invoice');
1875 $form->{script} = 'ir.pl';
1879 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1880 $form->{title} = $locale->text('Add Sales Invoice');
1881 $form->{script} = 'is.pl';
1886 # bo creates the id, reset it
1887 map { delete $form->{$_} }
1888 qw(id subject message cc bcc printed emailed queued);
1889 $form->{ $form->{vc} } =~ s/--.*//g;
1890 $form->{type} = "invoice";
1893 $locale = new Locale "$myconfig{countrycode}", "$script";
1895 require "$form->{path}/$form->{script}";
1897 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1899 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1900 qw(creditlimit creditremaining);
1902 $currency = $form->{currency};
1905 $form->{currency} = $currency;
1906 $form->{exchangerate} = "";
1907 $form->{forex} = "";
1908 $form->{exchangerate} = $exchangerate
1912 $form->check_exchangerate(
1913 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
1916 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1921 for $i (1 .. $form->{rowcount}) {
1922 $form->{"discount_$i"} =
1923 $form->format_amount(\%myconfig, $form->{"discount_$i"});
1925 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
1927 $decimalplaces = ($dec > 2) ? $dec : 2;
1929 # copy delivery date from reqdate for order -> invoice conversion
1930 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"} unless $form->{"deliverydate_$i"};
1932 $form->{"sellprice_$i"} =
1933 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1936 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
1937 $dec_qty = length $dec_qty;
1938 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1940 map { $form->{"${_}_$i"} =~ s/\"/"/g }
1941 qw(partnumber description unit);
1947 $lxdebug->leave_sub();
1950 sub backorder_exchangerate {
1951 $lxdebug->enter_sub();
1952 my ($orddate, $buysell) = @_;
1959 <form method=post action=$form->{script}>
1962 # delete action variable
1963 map { delete $form->{$_} } qw(action header exchangerate);
1965 foreach $key (keys %$form) {
1966 $form->{$key} =~ s/\"/"/g;
1967 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1970 $form->{title} = $locale->text('Add Exchangerate');
1974 <input type=hidden name=path value=$form->{path}>
1975 <input type=hidden name=login value=$form->{login}>
1976 <input type=hidden name=password value=$form->{password}>
1978 <input type=hidden name=exchangeratedate value=$orddate>
1979 <input type=hidden name=buysell value=$buysell>
1982 <tr><th class=listtop>$form->{title}</th></tr>
1983 <tr height="5"></tr>
1988 <th align=right>| . $locale->text('Currency') . qq|</th>
1989 <td>$form->{currency}</td>
1992 <th align=right>| . $locale->text('Date') . qq|</th>
1996 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
1997 <td><input name=exchangerate size=11></td>
2007 <input type=hidden name=nextsub value=save_exchangerate>
2009 <input name=action class=submit type=submit value="|
2010 . $locale->text('Continue') . qq|">
2018 $lxdebug->leave_sub();
2021 sub save_exchangerate {
2022 $lxdebug->enter_sub();
2024 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2025 $form->{exchangerate} =
2026 $form->parse_amount(\%myconfig, $form->{exchangerate});
2027 $form->save_exchangerate(\%myconfig, $form->{currency},
2028 $form->{exchangeratedate},
2029 $form->{exchangerate}, $form->{buysell});
2033 $lxdebug->leave_sub();
2036 sub create_backorder {
2037 $lxdebug->enter_sub();
2039 $form->{shipped} = 1;
2041 # figure out if we need to create a backorder
2042 # items aren't saved if qty != 0
2044 for $i (1 .. $form->{rowcount}) {
2045 $totalqty += $qty = $form->{"qty_$i"};
2046 $totalship += $ship = $form->{"ship_$i"};
2048 $form->{"qty_$i"} = $qty - $ship;
2051 if ($totalship == 0) {
2052 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2053 $form->{ordtotal} = 0;
2054 $form->{shipped} = 0;
2058 if ($totalqty == $totalship) {
2059 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2060 $form->{ordtotal} = 0;
2065 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2068 for $i (1 .. $form->{rowcount}) {
2070 $form->{"${_}_$i"} =
2071 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2072 } qw(sellprice discount);
2075 OE->save(\%myconfig, \%$form);
2077 # rebuild rows for invoice
2081 for $i (1 .. $form->{rowcount}) {
2082 $form->{"qty_$i"} = $form->{"ship_$i"};
2084 if ($form->{"qty_$i"}) {
2087 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2092 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2093 $form->{rowcount} = $count;
2095 $lxdebug->leave_sub();
2099 $lxdebug->enter_sub();
2101 $form->{saveasnew} = 1;
2102 $form->{closed} = 0;
2103 map { delete $form->{$_} } qw(printed emailed queued);
2107 $lxdebug->leave_sub();
2110 sub purchase_order {
2111 $lxdebug->enter_sub();
2113 if ( $form->{type} eq 'sales_quotation'
2114 || $form->{type} eq 'request_quotation') {
2115 $form->{closed} = 1;
2116 OE->save(\%myconfig, \%$form);
2119 ($null, $form->{cp_id}) = split /--/, $form->{contact};
2120 $form->{cp_id} *= 1;
2122 $form->{title} = $locale->text('Add Purchase Order');
2123 $form->{vc} = "vendor";
2124 $form->{type} = "purchase_order";
2128 $lxdebug->leave_sub();
2132 $lxdebug->enter_sub();
2134 if ( $form->{type} eq 'sales_quotation'
2135 || $form->{type} eq 'request_quotation') {
2136 $form->{closed} = 1;
2137 OE->save(\%myconfig, \%$form);
2140 ($null, $form->{cp_id}) = split /--/, $form->{contact};
2141 $form->{cp_id} *= 1;
2143 $form->{title} = $locale->text('Add Sales Order');
2144 $form->{vc} = "customer";
2145 $form->{type} = "sales_order";
2149 $lxdebug->leave_sub();
2153 $lxdebug->enter_sub();
2155 $form->{transdate} = $form->current_date(\%myconfig);
2156 delete $form->{duedate};
2158 $form->{closed} = 0;
2161 map { delete $form->{$_} }
2162 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2169 for $i (1 .. $form->{rowcount} - 1) {
2170 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2171 qw(partnumber description unit);
2174 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2175 qw(creditlimit creditremaining);
2179 $lxdebug->leave_sub();
2183 $lxdebug->enter_sub();
2189 OE->get_warehouses(\%myconfig, \%$form);
2192 if (@{ $form->{all_warehouses} }) {
2193 $form->{selectwarehouse} = "<option>\n";
2195 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2196 (@{ $form->{all_warehouses} });
2198 if ($form->{warehouse}) {
2199 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2203 $form->{shippingdate} = $form->current_date(\%myconfig);
2204 $form->{"$form->{vc}"} =~ s/--.*//;
2209 foreach $key (keys %$form) {
2210 if ($key =~ /_1$/) {
2216 for $i (1 .. $form->{rowcount}) {
2218 # undo formatting from prepare_order
2220 $form->{"${_}_$i"} =
2221 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2223 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2225 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2226 $form->{"ship_$i"} = "";
2227 $form->{"serialnumber_$i"} = "";
2232 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2237 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2238 $form->{rowcount} = $count;
2240 &display_ship_receive;
2242 $lxdebug->leave_sub();
2245 sub display_ship_receive {
2246 $lxdebug->enter_sub();
2248 $vclabel = ucfirst $form->{vc};
2249 $vclabel = $locale->text($vclabel);
2251 $form->{rowcount}++;
2253 if ($form->{vc} eq 'customer') {
2254 $form->{title} = $locale->text('Ship Merchandise');
2255 $shipped = $locale->text('Shipping Date');
2257 $form->{title} = $locale->text('Receive Merchandise');
2258 $shipped = $locale->text('Date Received');
2261 # set option selected
2262 foreach $item (warehouse, employee) {
2263 $form->{"select$item"} =~ s/ selected//;
2264 $form->{"select$item"} =~
2265 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2270 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2271 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2272 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2274 | if $form->{selectwarehouse};
2278 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2279 <td><select name=employee>$form->{selectemployee}</select></td>
2280 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2289 <form method=post action=$form->{script}>
2291 <input type=hidden name=id value=$form->{id}>
2293 <input type=hidden name=display_form value=display_ship_receive>
2295 <input type=hidden name=type value=$form->{type}>
2296 <input type=hidden name=media value=$form->{media}>
2297 <input type=hidden name=format value=$form->{format}>
2299 <input type=hidden name=queued value="$form->{queued}">
2300 <input type=hidden name=printed value="$form->{printed}">
2301 <input type=hidden name=emailed value="$form->{emailed}">
2303 <input type=hidden name=vc value=$form->{vc}>
2307 <th class=listtop>$form->{title}</th>
2309 <tr height="5"></tr>
2312 <table width="100%">
2317 <th align=right>$vclabel</th>
2318 <td colspan=3>$form->{$form->{vc}}</td>
2319 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2320 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2324 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2326 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2329 <th align=right>| . $locale->text('Ship via') . qq|</th>
2331 <input name=shipvia size=35 value="$form->{shipvia}">
2340 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2341 <td>$form->{ordnumber}</td>
2342 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2345 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2346 <td>$form->{transdate}</td>
2347 <input type=hidden name=transdate value=$form->{transdate}>
2350 <th align=right nowrap>$shipped</th>
2351 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2360 <!-- shipto are in hidden variables -->
2362 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2363 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2364 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2365 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2366 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2367 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2368 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2369 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2370 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2372 <!-- email variables -->
2373 <input type=hidden name=message value="$form->{message}">
2374 <input type=hidden name=email value="$form->{email}">
2375 <input type=hidden name=subject value="$form->{subject}">
2376 <input type=hidden name=cc value="$form->{cc}">
2377 <input type=hidden name=bcc value="$form->{bcc}">
2382 (partnumber, description, qty, ship, unit, bin, serialnumber);
2384 if ($form->{type} eq "ship_order") {
2385 $column_data{ship} =
2386 qq|<th class=listheading align=center width="auto">|
2387 . $locale->text('Ship')
2390 if ($form->{type} eq "receive_order") {
2391 $column_data{ship} =
2392 qq|<th class=listheading align=center width="auto">|
2393 . $locale->text('Recd')
2397 my $colspan = $#column_index + 1;
2399 $column_data{partnumber} =
2400 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2401 $column_data{description} =
2402 qq|<th class=listheading nowrap>|
2403 . $locale->text('Description')
2406 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2407 $column_data{unit} =
2408 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2410 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2411 $column_data{serialnumber} =
2412 qq|<th class=listheading nowrap>|
2413 . $locale->text('Serial No.')
2420 <tr class=listheading>|;
2422 map { print "\n$column_data{$_}" } @column_index;
2428 for $i (1 .. $form->{rowcount} - 1) {
2431 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2433 # convert " to "
2434 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2435 qw(partnumber description unit bin serialnumber);
2437 $description = $form->{"description_$i"};
2438 $description =~ s/\n/<br>/g;
2440 $column_data{partnumber} =
2441 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2442 $column_data{description} =
2443 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2445 qq|<td align=right>|
2446 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2447 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2448 $column_data{ship} =
2449 qq|<td align=right><input name="ship_$i" size=5 value=|
2450 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2452 $column_data{unit} =
2453 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2455 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2457 $column_data{serialnumber} =
2458 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2463 map { print "\n$column_data{$_}" } @column_index;
2468 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2469 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2470 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2471 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2482 <td><hr size=3 noshade></td>
2488 $form->{copies} = 1;
2497 <input class=submit type=submit name=action value="|
2498 . $locale->text('Update') . qq|">
2499 <input class=submit type=submit name=action value="|
2500 . $locale->text('Print') . qq|">
2503 if ($form->{type} eq 'ship_order') {
2505 <input class=submit type=submit name=action value="|
2506 . $locale->text('Ship to') . qq|">
2507 <input class=submit type=submit name=action value="|
2508 . $locale->text('E-mail') . qq|">
2514 <input class=submit type=submit name=action value="|
2515 . $locale->text('Done') . qq|">
2518 if ($form->{menubar}) {
2519 require "$form->{path}/menu.pl";
2525 <input type=hidden name=rowcount value=$form->{rowcount}>
2527 <input name=callback type=hidden value="$callback">
2529 <input type=hidden name=path value=$form->{path}>
2530 <input type=hidden name=login value=$form->{login}>
2531 <input type=hidden name=password value=$form->{password}>
2539 $lxdebug->leave_sub();
2543 $lxdebug->enter_sub();
2545 if ($form->{type} eq 'ship_order') {
2546 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2548 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2553 $total += $form->{"ship_$_"} =
2554 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2555 } (1 .. $form->{rowcount} - 1);
2557 $form->error($locale->text('Nothing entered!')) unless $total;
2559 $form->redirect($locale->text('Inventory saved!'))
2560 if OE->save_inventory(\%myconfig, \%$form);
2561 $form->error($locale->text('Could not save!'));
2563 $lxdebug->leave_sub();
2566 sub search_transfer {
2567 $lxdebug->enter_sub();
2569 OE->get_warehouses(\%myconfig, \%$form);
2572 if (@{ $form->{all_warehouses} }) {
2573 $form->{selectwarehouse} = "<option>\n";
2574 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2576 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2577 (@{ $form->{all_warehouses} });
2579 $form->error($locale->text('Nothing to transfer!'));
2582 $form->{title} = $locale->text('Transfer Inventory');
2589 <form method=post action=$form->{script}>
2593 <th class=listtop>$form->{title}</th>
2595 <tr height="5"></tr>
2600 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2601 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2604 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2605 <td><input name=partnumber size=20></td>
2608 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2609 <td><input name=description size=40></td>
2612 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2613 <td><input name=partsgroup size=20></td>
2619 <td><hr size=3 noshade></td>
2624 <input type=hidden name=sort value=partnumber>
2625 <input type=hidden name=nextsub value=list_transfer>
2627 <input type=hidden name=path value=$form->{path}>
2628 <input type=hidden name=login value=$form->{login}>
2629 <input type=hidden name=password value=$form->{password}>
2631 <input class=submit type=submit name=action value="|
2632 . $locale->text('Continue') . qq|">
2639 $lxdebug->leave_sub();
2643 $lxdebug->enter_sub();
2645 OE->get_inventory(\%myconfig, \%$form);
2647 $partnumber = $form->escape($form->{partnumber});
2648 $warehouse = $form->escape($form->{warehouse});
2649 $description = $form->escape($form->{description});
2650 $partsgroup = $form->escape($form->{partsgroup});
2654 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2656 # construct callback
2657 $partnumber = $form->escape($form->{partnumber}, 1);
2658 $warehouse = $form->escape($form->{warehouse}, 1);
2659 $description = $form->escape($form->{description}, 1);
2660 $partsgroup = $form->escape($form->{partsgroup}, 1);
2663 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2666 $form->sort_columns(
2667 qw(partnumber description partsgroup make model warehouse qty transfer));
2669 $column_header{partnumber} =
2670 qq|<th><a class=listheading href=$href&sort=partnumber>|
2671 . $locale->text('Part Number')
2673 $column_header{description} =
2674 qq|<th><a class=listheading href=$href&sort=description>|
2675 . $locale->text('Description')
2677 $column_header{partsgroup} =
2678 qq|<th><a class=listheading href=$href&sort=partsgroup>|
2679 . $locale->text('Group')
2681 $column_header{warehouse} =
2682 qq|<th><a class=listheading href=$href&sort=warehouse>|
2683 . $locale->text('From')
2685 $column_header{qty} =
2686 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
2687 $column_header{transfer} =
2688 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
2690 $option = $locale->text('Transfer to');
2692 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
2694 if ($form->{warehouse}) {
2695 $option .= " : $warehouse";
2697 if ($form->{partnumber}) {
2698 $option .= "\n<br>" if ($option);
2699 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
2701 if ($form->{description}) {
2702 $option .= "\n<br>" if ($option);
2703 $option .= $locale->text('Description') . " : $form->{description}";
2705 if ($form->{partsgroup}) {
2706 $option .= "\n<br>" if ($option);
2707 $option .= $locale->text('Group') . " : $form->{partsgroup}";
2710 $form->{title} = $locale->text('Transfer Inventory');
2717 <form method=post action=$form->{script}>
2719 <input type=hidden name=warehouse_id value=$warehouse_id>
2723 <th class=listtop>$form->{title}</th>
2725 <tr height="5"></tr>
2732 <tr class=listheading>|;
2734 map { print "\n$column_header{$_}" } @column_index;
2740 if (@{ $form->{all_inventory} }) {
2741 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
2745 foreach $ref (@{ $form->{all_inventory} }) {
2749 $column_data{partnumber} =
2750 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
2751 $column_data{description} = "<td>$ref->{description} </td>";
2752 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
2753 $column_data{warehouse} =
2754 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
2756 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
2757 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
2759 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
2764 <tr class=listrow$j>";
2766 map { print "\n$column_data{$_}" } @column_index;
2780 <td><hr size=3 noshade></td>
2786 <input name=callback type=hidden value="$callback">
2788 <input type=hidden name=rowcount value=$i>
2790 <input type=hidden name=path value=$form->{path}>
2791 <input type=hidden name=login value=$form->{login}>
2792 <input type=hidden name=password value=$form->{password}>
2794 <input class=submit type=submit name=action value="|
2795 . $locale->text('Transfer') . qq|">|;
2797 if ($form->{menubar}) {
2798 require "$form->{path}/menu.pl";
2809 $lxdebug->leave_sub();
2813 $lxdebug->enter_sub();
2815 $form->redirect($locale->text('Inventory transferred!'))
2816 if OE->transfer(\%myconfig, \%$form);
2817 $form->error($locale->text('Could not transfer Inventory!'));
2819 $lxdebug->leave_sub();