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};
233 for my $i (1 .. $form->{rowcount}) {
235 $form->{"discount_$i"} =
236 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
238 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
240 $decimalplaces = ($dec > 2) ? $dec : 2;
242 # copy reqdate from deliverydate for invoice -> order conversion
243 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"} unless $form->{"reqdate_$i"};
245 $form->{"sellprice_$i"} =
246 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
249 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
250 $dec_qty = length $dec_qty;
251 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
253 map { $form->{"${_}_$i"} =~ s/\"/"/g }
254 qw(partnumber description unit);
257 $lxdebug->leave_sub();
261 $lxdebug->enter_sub();
263 $checkedopen = ($form->{closed}) ? "" : "checked";
264 $checkedclosed = ($form->{closed}) ? "checked" : "";
266 # use JavaScript Calendar or not
267 $form->{jsscript} = $form->{jscalendar};
270 if ($form->{jsscript}) {
272 # with JavaScript Calendar
274 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
275 <td><input type=button name=transdate id="trigger1" value=|
276 . $locale->text('button') . qq|></td>
279 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
280 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
281 . $locale->text('button') . qq|></td>
286 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
287 "reqdate", "BL", "trigger2");
291 # without JavaScript Calendar
293 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
295 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
301 <td colspan=2 align=center>
304 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
305 . $locale->text('Open') . qq|</th>
306 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
307 . $locale->text('Closed') . qq|</th>
315 # set option selected
316 foreach $item ($form->{vc}, currency, department, employee, contact) {
317 $form->{"select$item"} =~ s/ selected//;
318 $form->{"select$item"} =~
319 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
323 if ($form->{all_contacts}) {
325 $form->{selectcontact} = "";
326 foreach $item (@{ $form->{all_contacts} }) {
327 if ($form->{cp_id} == $item->{cp_id}) {
328 $form->{selectcontact} .=
329 "<option selected>$item->{cp_name}--$item->{cp_id}";
331 $form->{selectcontact} .= "<option>$item->{cp_name}--$item->{cp_id}";
336 $form->{exchangerate} =
337 $form->format_amount(\%myconfig, $form->{exchangerate});
339 $form->{creditlimit} =
340 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
341 $form->{creditremaining} =
342 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
345 ($form->{selectcontact})
346 ? qq|<select name=contact>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
347 : qq|<input name=contact value="$form->{contact}" size=35>|;
350 <input type=hidden name=forex value=$form->{forex}>
353 if ($form->{currency} ne $form->{defaultcurrency}) {
354 if ($form->{forex}) {
357 . $locale->text('Exchangerate')
358 . qq|</th><td>$form->{exchangerate}</td>
359 <input type=hidden name=exchangerate value=$form->{exchangerate}>
364 . $locale->text('Exchangerate')
365 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
369 $vclabel = ucfirst $form->{vc};
370 $vclabel = $locale->text($vclabel);
374 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
375 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
376 . $locale->text('days') . qq|</td>
380 if ($form->{business}) {
383 <th align=right>| . $locale->text('Business') . qq|</th>
384 <td>$form->{business}</td>
385 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
387 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
393 if ($form->{type} !~ /_quotation$/) {
396 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
397 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
400 <th width=70% align=right nowrap>|
401 . $locale->text('Quotation Number') . qq|</th>
402 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
405 <th width=70% align=right nowrap>|
406 . $locale->text('Customer Order Number') . qq|</th>
407 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
410 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
415 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
420 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
422 $creditremaining = qq|
428 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
429 <td>$form->{creditlimit}</td>
431 <th nowrap>| . $locale->text('Remaining') . qq|</th>
432 <td class="plus$n">$form->{creditremaining}</td>
440 ($form->{type} eq 'sales_quotation')
441 ? $locale->text('Valid until')
442 : $locale->text('Required by');
443 if ($form->{type} eq 'sales_quotation') {
446 <th width=70% align=right nowrap>|
447 . $locale->text('Quotation Number') . qq|</th>
448 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
449 <input type=hidden name=ordnumber value="$form->{ordnumber}">
455 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
456 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
457 <input type=hidden name=ordnumber value="$form->{ordnumber}">
466 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
470 <th align=right nowrap=true>$reqlabel</th>
478 ($form->{"select$form->{vc}"})
479 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
480 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
484 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
485 <td colspan=3><select name=department>$form->{selectdepartment}</select>
486 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
489 | if $form->{selectdepartment};
492 <input type=hidden name=employee value="$form->{employee}">
495 if ($form->{type} eq 'sales_order') {
496 if ($form->{selectemployee}) {
498 <input type=hidden name=customer_klass value=$form->{customer_klass}>
500 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
501 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
502 <input type=hidden name=selectemployee value="$form->{selectemployee}">
509 <input type=hidden name=customer_klass value=$form->{customer_klass}>
511 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
512 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
513 <input type=hidden name=selectemployee value="$form->{selectemployee}">
524 <form method=post action=$form->{script}>
526 <input type=hidden name=id value=$form->{id}>
528 <input type=hidden name=type value=$form->{type}>
529 <input type=hidden name=formname value=$form->{formname}>
530 <input type=hidden name=media value=$form->{media}>
531 <input type=hidden name=format value=$form->{format}>
533 <input type=hidden name=queued value="$form->{queued}">
534 <input type=hidden name=printed value="$form->{printed}">
535 <input type=hidden name=emailed value="$form->{emailed}">
537 <input type=hidden name=vc value=$form->{vc}>
539 <input type=hidden name=title value="$form->{title}">
541 <input type=hidden name=discount value=$form->{discount}>
542 <input type=hidden name=creditlimit value=$form->{creditlimit}>
543 <input type=hidden name=creditremaining value=$form->{creditremaining}>
545 <input type=hidden name=tradediscount value=$form->{tradediscount}>
546 <input type=hidden name=business value=$form->{business}>
547 <input type=hidden name=webdav value=$webdav>
551 <th class=listtop>$form->{title}</th>
561 <th align=right>$vclabel</th>
562 <td colspan=3>$vc</td>
563 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
564 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
565 <th align=richt nowrap>|
566 . $locale->text('Contact Person') . qq|</th>
567 <td colspan=3>$contact</td>
573 <th align=right>| . $locale->text('Currency') . qq|</th>
574 <td><select name=currency>$form->{selectcurrency}</select></td>
575 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
576 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
580 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
581 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
584 <th align=right>| . $locale->text('Ship via') . qq|</th>
585 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
604 <!-- shipto are in hidden variables -->
606 <input type=hidden name=shiptoname value="$form->{shiptoname}">
607 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
608 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
609 <input type=hidden name=shiptocity value="$form->{shiptocity}">
610 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
611 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
612 <input type=hidden name=shiptophone value="$form->{shiptophone}">
613 <input type=hidden name=shiptofax value="$form->{shiptofax}">
614 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
616 <!-- email variables -->
617 <input type=hidden name=message value="$form->{message}">
618 <input type=hidden name=email value="$form->{email}">
619 <input type=hidden name=subject value="$form->{subject}">
620 <input type=hidden name=cc value="$form->{cc}">
621 <input type=hidden name=bcc value="$form->{bcc}">
623 <input type=hidden name=taxpart value="$form->{taxpart}">
624 <input type=hidden name=taxservice value="$form->{taxservice}">
626 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
629 foreach $item (split / /, $form->{taxaccounts}) {
631 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
632 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
635 $lxdebug->leave_sub();
639 $lxdebug->enter_sub();
641 $form->{invtotal} = $form->{invsubtotal};
643 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
646 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
649 $rows = ($rows > $introws) ? $rows : $introws;
651 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
653 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
655 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
658 if ($form->{taxaccounts}) {
660 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
661 . $locale->text('Tax Included') . qq|</b><br><br>
665 if (!$form->{taxincluded}) {
667 foreach $item (split / /, $form->{taxaccounts}) {
668 if ($form->{"${item}_base"}) {
669 $form->{invtotal} += $form->{"${item}_total"} =
671 $form->{"${item}_base"} * $form->{"${item}_rate"},
673 $form->{"${item}_total"} =
674 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
678 <th align=right>$form->{"${item}_description"}</th>
679 <td align=right>$form->{"${item}_total"}</td>
685 $form->{invsubtotal} =
686 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
690 <th align=right>| . $locale->text('Subtotal') . qq|</th>
691 <td align=right>$form->{invsubtotal}</td>
697 if ($form->{taxincluded}) {
698 foreach $item (split / /, $form->{taxaccounts}) {
699 if ($form->{"${item}_base"}) {
700 $form->{"${item}_total"} =
702 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
703 (1 + $form->{"${item}_rate"})
706 $form->{"${item}_netto"} =
708 ($form->{"${item}_base"} - $form->{"${item}_total"}),
710 $form->{"${item}_total"} =
711 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
712 $form->{"${item}_netto"} =
713 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
717 <th align=right>Enthaltene $form->{"${item}_description"}</th>
718 <td align=right>$form->{"${item}_total"}</td>
721 <th align=right>Nettobetrag</th>
722 <td align=right>$form->{"${item}_netto"}</td>
730 $form->{oldinvtotal} = $form->{invtotal};
732 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
742 <th align=left>| . $locale->text('Notes') . qq|</th>
743 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
751 <td align=right width=100%>
757 <th align=right>| . $locale->text('Total') . qq|</th>
758 <td align=right>$form->{invtotal}</td>
766 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
767 <input type=hidden name=oldtotalpaid value=$totalpaid>
769 <td><hr size=3 noshade></td>
777 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
780 <td align=left width=30%><b>Dateiname</b></td>
781 <td align=left width=70%><b>Webdavlink</b></td>
783 foreach $file (keys %{ $form->{WEBDAV} }) {
786 <td align=left>$file</td>
787 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
795 <td><hr size=3 noshade></td>
802 <input type=hidden name=jscalendar value=$form->{jscalendar}>
815 Bearbeiten des $form->{heading}<br>
816 <input class=submit type=submit name=action value="|
817 . $locale->text('Update') . qq|">
818 <input class=submit type=submit name=action value="|
819 . $locale->text('Ship to') . qq|">
820 <input class=submit type=submit name=action value="|
821 . $locale->text('Print') . qq|">
822 <input class=submit type=submit name=action value="|
823 . $locale->text('E-mail') . qq|">
824 <input class=submit type=submit name=action value="|
825 . $locale->text('Save') . qq|">
830 <br>Workflow $form->{heading}<br>
831 <input class=submit type=submit name=action value="|
832 . $locale->text('Save as new') . qq|">
833 <input class=submit type=submit name=action value="|
834 . $locale->text('Delete') . qq|">|;
835 if ($form->{type} =~ /quotation$/) {
837 <input class=submit type=submit name=action value="|
838 . $locale->text('Order') . qq|">|;
841 <input class=submit type=submit name=action value="|
842 . $locale->text('Invoice') . qq|">
845 if ($form->{type} =~ /sales_order$/) {
847 <br>$form->{heading} als neue Vorlage verwenden für<br>
848 <input class=submit type=submit name=action value="|
849 . $locale->text('Purchase Order') . qq|">
850 <input class=submit type=submit name=action value="|
851 . $locale->text('Quotation') . qq|">
854 } elsif ($form->{type} =~ /purchase_order$/) {
856 <br>$form->{heading} als neue Vorlage verwenden für<br>
857 <input class=submit type=submit name=action value="|
858 . $locale->text('Sales Order') . qq|">
859 <input class=submit type=submit name=action value="|
860 . $locale->text('Quotation') . qq|">
865 <br>$form->{heading} als neue Vorlage verwenden für<br>
866 <input class=submit type=submit name=action value="|
867 . $locale->text('Order') . qq|">
870 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount}) {
872 <br>Workflow $form->{heading}<br>
873 <input class=submit type=submit name=action value="|
874 . $locale->text('Save as new') . qq|">
875 <input class=submit type=submit name=action value="|
876 . $locale->text('Invoice') . qq|">
881 if ($form->{menubar}) {
882 require "$form->{path}/menu.pl";
888 <input type=hidden name=rowcount value=$form->{rowcount}>
890 <input name=callback type=hidden value="$form->{callback}">
892 <input type=hidden name=path value=$form->{path}>
893 <input type=hidden name=login value=$form->{login}>
894 <input type=hidden name=password value=$form->{password}>
901 $lxdebug->leave_sub();
905 $lxdebug->enter_sub();
907 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
908 qw(exchangerate creditlimit creditremaining);
910 &check_name($form->{vc});
915 $buysell = 'sell' if ($form->{vc} eq 'vendor');
916 $form->{exchangerate} = $exchangerate
920 $form->check_exchangerate(
921 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
925 $i = $form->{rowcount};
927 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
929 if ( ($form->{"partnumber_$i"} eq "")
930 && ($form->{"description_$i"} eq "")
931 && ($form->{"partsgroup_$i"} eq "")) {
933 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
938 if ( $form->{type} eq 'purchase_order'
939 || $form->{type} eq 'request_quotation') {
940 IR->retrieve_item(\%myconfig, \%$form);
942 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
943 IS->retrieve_item(\%myconfig, \%$form);
946 my $rows = scalar @{ $form->{item_list} };
948 $form->{"discount_$i"} =
949 $form->format_amount(\%myconfig, $form->{discount} * 100);
952 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
961 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
963 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
964 qw(partnumber description unit);
965 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
966 keys %{ $form->{item_list}[0] };
968 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
970 ($dec) = ($s =~ /\.(\d+)/);
972 $decimalplaces = ($dec > 2) ? $dec : 2;
975 $form->{"sellprice_$i"} = $sellprice;
978 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
979 # if there is an exchange rate adjust sellprice
980 $form->{"sellprice_$i"} /= $exchangerate;
984 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
985 (1 - $form->{"discount_$i"} / 100);
986 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
987 map { $form->{"${_}_base"} += $amount }
988 (split / /, $form->{"taxaccounts_$i"});
989 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
990 split / /, $form->{taxaccounts}
991 if !$form->{taxincluded};
993 $form->{creditremaining} -= $amount;
995 $form->{"sellprice_$i"} =
996 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
999 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1001 # get pricegroups for parts
1002 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1004 # build up html code for prices_$i
1005 &set_pricegroup($i);
1012 # ok, so this is a new part
1013 # ask if it is a part or service item
1015 if ( $form->{"partsgroup_$i"}
1016 && ($form->{"partsnumber_$i"} eq "")
1017 && ($form->{"description_$i"} eq "")) {
1018 $form->{rowcount}--;
1019 $form->{"discount_$i"} = "";
1023 $form->{"id_$i"} = 0;
1024 $form->{"unit_$i"} = $locale->text('ea');
1033 $lxdebug->leave_sub();
1037 $lxdebug->enter_sub();
1039 if ($form->{type} eq 'purchase_order') {
1040 $form->{title} = $locale->text('Purchase Orders');
1041 $form->{vc} = 'vendor';
1042 $ordlabel = $locale->text('Order Number');
1043 $ordnumber = 'ordnumber';
1044 $employee = $locale->text('Employee');
1046 if ($form->{type} eq 'request_quotation') {
1047 $form->{title} = $locale->text('Request for Quotations');
1048 $form->{vc} = 'vendor';
1049 $ordlabel = $locale->text('RFQ Number');
1050 $ordnumber = 'quonumber';
1051 $employee = $locale->text('Employee');
1053 if ($form->{type} eq 'receive_order') {
1054 $form->{title} = $locale->text('Receive Merchandise');
1055 $form->{vc} = 'vendor';
1056 $ordlabel = $locale->text('Order Number');
1057 $ordnumber = 'ordnumber';
1058 $employee = $locale->text('Employee');
1060 if ($form->{type} eq 'sales_order') {
1061 $form->{title} = $locale->text('Sales Orders');
1062 $form->{vc} = 'customer';
1063 $ordlabel = $locale->text('Order Number');
1064 $ordnumber = 'ordnumber';
1065 $employee = $locale->text('Salesperson');
1067 if ($form->{type} eq 'ship_order') {
1068 $form->{title} = $locale->text('Ship Merchandise');
1069 $form->{vc} = 'customer';
1070 $ordlabel = $locale->text('Order Number');
1071 $ordnumber = 'ordnumber';
1072 $employee = $locale->text('Salesperson');
1076 if ($form->{type} eq 'sales_quotation') {
1077 $form->{title} = $locale->text('Quotations');
1078 $form->{vc} = 'customer';
1079 $ordlabel = $locale->text('Quotation Number');
1080 $ordnumber = 'quonumber';
1081 $employee = $locale->text('Employee');
1084 if ($form->{type} =~ /(ship|receive)_order/) {
1085 OE->get_warehouses(\%myconfig, \%$form);
1088 if (@{ $form->{all_warehouses} }) {
1089 $form->{selectwarehouse} = "<option>\n";
1090 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1093 $form->{selectwarehouse} .=
1094 "<option>$_->{description}--$_->{id}\n"
1095 } (@{ $form->{all_warehouses} });
1099 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1100 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1101 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1108 # setup vendor / customer selection
1109 $form->all_vc(\%myconfig, $form->{vc},
1110 ($form->{vc} eq 'customer') ? "AR" : "AP");
1112 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1113 @{ $form->{"all_$form->{vc}"} };
1115 $vclabel = ucfirst $form->{vc};
1116 $vclabel = $locale->text($vclabel);
1118 # $locale->text('Vendor')
1119 # $locale->text('Customer')
1123 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1124 : qq|<input name=$form->{vc} size=35>|;
1127 if (@{ $form->{all_departments} }) {
1128 $form->{selectdepartment} = "<option>\n";
1131 $form->{selectdepartment} .=
1132 "<option>$_->{description}--$_->{id}\n"
1133 } (@{ $form->{all_departments} });
1138 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1139 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1141 | if $form->{selectdepartment};
1143 if ($form->{type} !~ /(ship_order|receive_order)/) {
1146 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1147 . $locale->text('Open') . qq|</td>
1148 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1149 . $locale->text('Closed') . qq|</td>
1155 <input type=hidden name="open" value=1>
1159 # use JavaScript Calendar or not
1160 $form->{jsscript} = $jscalendar;
1162 if ($form->{jsscript}) {
1164 # with JavaScript Calendar
1166 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1167 <input type=button name=transdatefrom id="trigger3" value=|
1168 . $locale->text('button') . qq|></td>
1171 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1172 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1173 . $locale->text('button') . qq|></td>
1178 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1179 "transdateto", "BL", "trigger4");
1182 # without JavaScript Calendar
1184 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1186 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1194 <form method=post action=$form->{script}>
1198 <th class=listtop>$form->{title}</th>
1200 <tr height="5"></tr>
1205 <th align=right>$vclabel</th>
1206 <td colspan=3>$vc</td>
1211 <th align=right>$ordlabel</th>
1212 <td colspan=3><input name="$ordnumber" size=20></td>
1215 <th align=right>| . $locale->text('From') . qq|</th>
1217 <th align=right>| . $locale->text('Bis') . qq|</th>
1220 <input type=hidden name=sort value=transdate>
1222 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1227 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1228 | . $locale->text('ID') . qq|</td>
1229 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1230 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1231 . $locale->text('Date') . qq|</td>
1232 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1233 . $locale->text('Required by') . qq|</td>
1236 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1237 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1238 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1239 . $locale->text('Ship via') . qq|</td>
1242 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1243 . $locale->text('Amount') . qq|</td>
1244 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1245 . $locale->text('Tax') . qq|</td>
1246 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1247 . $locale->text('Total') . qq|</td>
1250 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1251 . $locale->text('Subtotal') . qq|</td>
1259 <tr><td colspan=4><hr size=3 noshade></td></tr>
1265 <input type=hidden name=nextsub value=orders>
1266 <input type=hidden name=path value=$form->{path}>
1267 <input type=hidden name=login value=$form->{login}>
1268 <input type=hidden name=password value=$form->{password}>
1269 <input type=hidden name=vc value=$form->{vc}>
1270 <input type=hidden name=type value=$form->{type}>
1272 <input class=submit type=submit name=action value="|
1273 . $locale->text('Continue') . qq|">
1280 $lxdebug->leave_sub();
1284 $lxdebug->enter_sub();
1286 # split vendor / customer
1287 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1288 split(/--/, $form->{ $form->{vc} });
1290 OE->transactions(\%myconfig, \%$form);
1292 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1294 $number = $form->escape($form->{$ordnumber});
1295 $name = $form->escape($form->{ $form->{vc} });
1296 $department = $form->escape($form->{department});
1297 $warehouse = $form->escape($form->{warehouse});
1301 "$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";
1303 # construct callback
1304 $number = $form->escape($form->{$ordnumber}, 1);
1305 $name = $form->escape($form->{ $form->{vc} }, 1);
1306 $department = $form->escape($form->{department}, 1);
1307 $warehouse = $form->escape($form->{warehouse}, 1);
1310 "$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";
1313 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1314 "name", "netamount", "tax", "amount",
1315 "curr", "employee", "shipvia", "open",
1318 $form->{l_open} = $form->{l_closed} = "Y"
1319 if ($form->{open} && $form->{closed});
1321 foreach $item (@columns) {
1322 if ($form->{"l_$item"} eq "Y") {
1323 push @column_index, $item;
1325 # add column to href and callback
1326 $callback .= "&l_$item=Y";
1327 $href .= "&l_$item=Y";
1331 # only show checkboxes if gotten here via sales_order form.
1332 if ($form->{type} =~ /sales_order/) {
1333 unshift @column_index, "ids";
1336 if ($form->{l_subtotal} eq 'Y') {
1337 $callback .= "&l_subtotal=Y";
1338 $href .= "&l_subtotal=Y";
1341 if ($form->{vc} eq 'vendor') {
1342 if ($form->{type} eq 'receive_order') {
1343 $form->{title} = $locale->text('Receive Merchandise');
1344 } elsif ($form->{type} eq 'purchase_order') {
1345 $form->{title} = $locale->text('Purchase Orders');
1347 $form->{title} = $locale->text('Request for Quotations');
1349 $name = $locale->text('Vendor');
1350 $employee = $locale->text('Employee');
1352 if ($form->{vc} eq 'customer') {
1353 if ($form->{type} eq 'sales_order') {
1354 $form->{title} = $locale->text('Sales Orders');
1355 $employee = $locale->text('Salesperson');
1356 } elsif ($form->{type} eq 'ship_order') {
1357 $form->{title} = $locale->text('Ship Merchandise');
1358 $employee = $locale->text('Salesperson');
1360 $form->{title} = $locale->text('Quotations');
1361 $employee = $locale->text('Employee');
1363 $name = $locale->text('Customer');
1366 $column_header{id} =
1367 qq|<th><a class=listheading href=$href&sort=id>|
1368 . $locale->text('ID')
1370 $column_header{transdate} =
1371 qq|<th><a class=listheading href=$href&sort=transdate>|
1372 . $locale->text('Date')
1374 $column_header{reqdate} =
1375 qq|<th><a class=listheading href=$href&sort=reqdate>|
1376 . $locale->text('Required by')
1378 $column_header{ordnumber} =
1379 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1380 . $locale->text('Order')
1382 $column_header{quonumber} =
1383 qq|<th><a class=listheading href=$href&sort=quonumber>|
1384 . $locale->text('Quotation')
1386 $column_header{name} =
1387 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1388 $column_header{netamount} =
1389 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1390 $column_header{tax} =
1391 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1392 $column_header{amount} =
1393 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1394 $column_header{curr} =
1395 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1396 $column_header{shipvia} =
1397 qq|<th><a class=listheading href=$href&sort=shipvia>|
1398 . $locale->text('Ship via')
1400 $column_header{open} =
1401 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1402 $column_header{closed} =
1403 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1405 $column_header{employee} =
1406 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1408 $column_header{ids} = qq|<th></th>|;
1410 if ($form->{ $form->{vc} }) {
1411 $option = $locale->text(ucfirst $form->{vc});
1412 $option .= " : $form->{$form->{vc}}";
1414 if ($form->{warehouse}) {
1415 ($warehouse) = split /--/, $form->{warehouse};
1416 $option .= "\n<br>" if ($option);
1417 $option .= $locale->text('Warehouse');
1418 $option .= " : $warehouse";
1420 if ($form->{department}) {
1421 $option .= "\n<br>" if ($option);
1422 ($department) = split /--/, $form->{department};
1423 $option .= $locale->text('Department') . " : $department";
1425 if ($form->{transdatefrom}) {
1427 . $locale->text('From') . " "
1428 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1430 if ($form->{transdateto}) {
1432 . $locale->text('Bis') . " "
1433 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1435 if ($form->{open}) {
1436 $option .= "\n<br>" if ($option);
1437 $option .= $locale->text('Open');
1439 if ($form->{closed}) {
1440 $option .= "\n<br>" if ($option);
1441 $option .= $locale->text('Closed');
1449 <form method="post" action="oe.pl">
1452 <th class=listtop>$form->{title}</th>
1454 <tr height="5"></tr>
1461 <tr class=listheading>|;
1463 map { print "\n$column_header{$_}" } @column_index;
1469 # add sort and escape callback
1470 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1472 if (@{ $form->{OE} }) {
1473 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1477 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1479 $warehouse = $form->escape($form->{warehouse});
1481 foreach $oe (@{ $form->{OE} }) {
1482 $form->{rowcount} = ++$j;
1484 if ($form->{l_subtotal} eq 'Y') {
1485 if ($sameitem ne $oe->{ $form->{sort} }) {
1487 $sameitem = $oe->{ $form->{sort} };
1491 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1493 $column_data{netamount} =
1495 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1497 $column_data{tax} = "<td align=right>"
1498 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1501 $column_data{amount} =
1503 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1505 $totalnetamount += $oe->{netamount};
1506 $totalamount += $oe->{amount};
1508 $subtotalnetamount += $oe->{netamount};
1509 $subtotalamount += $oe->{amount};
1511 $column_data{ids} = qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1512 $column_data{id} = "<td>$oe->{id}</td>";
1513 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1514 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1516 $column_data{$ordnumber} =
1517 "<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>";
1518 $column_data{name} = "<td>$oe->{name}</td>";
1520 $column_data{employee} = "<td>$oe->{employee} </td>";
1521 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1523 if ($oe->{closed}) {
1524 $column_data{closed} = "<td align=center>X</td>";
1525 $column_data{open} = "<td> </td>";
1527 $column_data{closed} = "<td> </td>";
1528 $column_data{open} = "<td align=center>X</td>";
1534 <tr class=listrow$i>";
1536 map { print "\n$column_data{$_}" } @column_index;
1544 if ($form->{l_subtotal} eq 'Y') {
1550 <tr class=listtotal>|;
1552 map { $column_data{$_} = "<td> </td>" } @column_index;
1554 $column_data{netamount} =
1555 "<th class=listtotal align=right>"
1556 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1557 $column_data{tax} = "<th class=listtotal align=right>"
1558 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1561 $column_data{amount} =
1562 "<th class=listtotal align=right>"
1563 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1565 map { print "\n$column_data{$_}" } @column_index;
1573 <td><hr size=3 noshade></td>
1577 # multiple invoice edit button only if gotten there via sales_order form.
1579 if ($form->{type} =~ /sales_order/) {
1581 <input type="hidden" name="path" value="$form->{path}">
1582 <input class"submit" type="submit" name="action" value="|
1583 . $locale->text('Continue') .qq|">
1584 <input type="hidden" name="nextsub" value="edit">
1585 <input type="hidden" name="type" value="$form->{type}">
1586 <input type="hidden" name="warehouse" value="$warehouse">
1587 <input type="hidden" name="vc" value="$form->{vc}">
1588 <input type="hidden" name="login" value="$form->{login}">
1589 <input type="hidden" name="password" value="$form->{password}">
1590 <input type="hidden" name="callback" value="$callback">
1591 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1598 <form method=post action=$form->{script}>
1600 <input name=callback type=hidden value="$form->{callback}">
1602 <input type=hidden name=type value=$form->{type}>
1603 <input type=hidden name=vc value=$form->{vc}>
1605 <input type=hidden name=path value=$form->{path}>
1606 <input type=hidden name=login value=$form->{login}>
1607 <input type=hidden name=password value=$form->{password}>
1610 if ($form->{type} !~ /(ship|receive)_order/) {
1612 <input class=submit type=submit name=action value="|
1613 . $locale->text('Add') . qq|">|;
1616 if ($form->{menubar}) {
1617 require "$form->{path}/menu.pl";
1628 $lxdebug->leave_sub();
1632 $lxdebug->enter_sub();
1634 map { $column_data{$_} = "<td> </td>" } @column_index;
1636 $column_data{netamount} =
1637 "<th class=listsubtotal align=right>"
1638 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1640 $column_data{tax} = "<td class=listsubtotal align=right>"
1641 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1644 $column_data{amount} =
1645 "<th class=listsubtotal align=right>"
1646 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1648 $subtotalnetamount = 0;
1649 $subtotalamount = 0;
1652 <tr class=listsubtotal>
1655 map { print "\n$column_data{$_}" } @column_index;
1661 $lxdebug->leave_sub();
1665 $lxdebug->enter_sub();
1667 if ($form->{type} =~ /_order$/) {
1668 $form->isblank("transdate", $locale->text('Order Date missing!'));
1670 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1673 $msg = ucfirst $form->{vc};
1674 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1676 # $locale->text('Customer missing!');
1677 # $locale->text('Vendor missing!');
1679 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1680 if ($form->{currency} ne $form->{defaultcurrency});
1684 # if the name changed get new values
1685 if (&check_name($form->{vc})) {
1690 $form->{id} = 0 if $form->{saveasnew};
1692 # this is for the internal notes section for the [email] Subject
1693 if ($form->{type} =~ /_order$/) {
1694 if ($form->{type} eq 'sales_order') {
1695 $form->{label} = $locale->text('Sales Order');
1697 $numberfld = "sonumber";
1698 $ordnumber = "ordnumber";
1700 $form->{label} = $locale->text('Purchase Order');
1702 $numberfld = "ponumber";
1703 $ordnumber = "ordnumber";
1706 $err = $locale->text('Cannot save order!');
1709 if ($form->{type} eq 'sales_quotation') {
1710 $form->{label} = $locale->text('Quotation');
1712 $numberfld = "sqnumber";
1713 $ordnumber = "quonumber";
1715 $form->{label} = $locale->text('Request for Quotation');
1717 $numberfld = "rfqnumber";
1718 $ordnumber = "quonumber";
1721 $err = $locale->text('Cannot save quotation!');
1725 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
1726 unless $form->{$ordnumber};
1729 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1730 if (OE->save(\%myconfig, \%$form));
1733 $lxdebug->leave_sub();
1737 $lxdebug->enter_sub();
1741 if ($form->{type} =~ /_order$/) {
1742 $msg = $locale->text('Are you sure you want to delete Order Number');
1743 $ordnumber = 'ordnumber';
1745 $msg = $locale->text('Are you sure you want to delete Quotation Number');
1746 $ordnumber = 'quonumber';
1752 <form method=post action=$form->{script}>
1755 # delete action variable
1756 map { delete $form->{$_} } qw(action header);
1758 foreach $key (keys %$form) {
1759 $form->{$key} =~ s/\"/"/g;
1760 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1764 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1766 <h4>$msg $form->{$ordnumber}</h4>
1768 <input name=action class=submit type=submit value="|
1769 . $locale->text('Yes') . qq|">
1776 $lxdebug->leave_sub();
1780 $lxdebug->enter_sub();
1782 if ($form->{type} =~ /_order$/) {
1783 $msg = $locale->text('Order deleted!');
1784 $err = $locale->text('Cannot delete order!');
1786 $msg = $locale->text('Quotation deleted!');
1787 $err = $locale->text('Cannot delete quotation!');
1790 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
1793 $lxdebug->leave_sub();
1797 $lxdebug->enter_sub();
1799 if ($form->{type} =~ /_order$/) {
1800 # these checks only apply if the items don't bring their own ordnumbers/transdates.
1801 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
1802 $form->isblank("ordnumber", $locale->text('Order Number missing!')) if ( +{ map { $form->{"ordnumber_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} );
1803 $form->isblank("transdate", $locale->text('Order Date missing!')) if ( +{ map { $form->{"transdate_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} );
1806 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
1807 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1808 $form->{ordnumber} = "";
1811 # if the name changed get new values
1812 if (&check_name($form->{vc})) {
1817 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1818 $form->{cp_id} *= 1;
1820 if ( $form->{type} =~ /_order/
1821 && $form->{currency} ne $form->{defaultcurrency}) {
1823 # check if we need a new exchangerate
1824 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
1826 $orddate = $form->current_date(\%myconfig);
1828 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
1831 if (!$exchangerate) {
1832 &backorder_exchangerate($orddate, $buysell);
1837 # close orders/quotations
1838 $form->{closed} = 1;
1840 # save order if one ordnumber has been given
1841 # if not it's most likely a collective order, which can't be saved back
1842 # so they just have to be closed
1843 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
1844 OE->save(\%myconfig, \%$form);
1846 OE->close_orders(\%myconfig, \%$form);
1849 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1851 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1854 $form->{closed} = 0;
1855 $form->{rowcount}--;
1856 $form->{shipto} = 1;
1858 if ($form->{type} =~ /_order$/) {
1859 $form->{exchangerate} = $exchangerate;
1863 if ( $form->{type} eq 'purchase_order'
1864 || $form->{type} eq 'request_quotation') {
1865 $form->{title} = $locale->text('Add Vendor Invoice');
1866 $form->{script} = 'ir.pl';
1870 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1871 $form->{title} = $locale->text('Add Sales Invoice');
1872 $form->{script} = 'is.pl';
1877 # bo creates the id, reset it
1878 map { delete $form->{$_} }
1879 qw(id subject message cc bcc printed emailed queued);
1880 $form->{ $form->{vc} } =~ s/--.*//g;
1881 $form->{type} = "invoice";
1884 $locale = new Locale "$myconfig{countrycode}", "$script";
1886 require "$form->{path}/$form->{script}";
1888 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1890 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1891 qw(creditlimit creditremaining);
1893 $currency = $form->{currency};
1896 $form->{currency} = $currency;
1897 $form->{exchangerate} = "";
1898 $form->{forex} = "";
1899 $form->{exchangerate} = $exchangerate
1903 $form->check_exchangerate(
1904 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
1907 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1912 for $i (1 .. $form->{rowcount}) {
1913 $form->{"discount_$i"} =
1914 $form->format_amount(\%myconfig, $form->{"discount_$i"});
1916 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
1918 $decimalplaces = ($dec > 2) ? $dec : 2;
1920 # copy delivery date from reqdate for order -> invoice conversion
1921 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"} unless $form->{"deliverydate_$i"};
1923 $form->{"sellprice_$i"} =
1924 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1927 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
1928 $dec_qty = length $dec_qty;
1929 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1931 map { $form->{"${_}_$i"} =~ s/\"/"/g }
1932 qw(partnumber description unit);
1938 $lxdebug->leave_sub();
1941 sub backorder_exchangerate {
1942 $lxdebug->enter_sub();
1943 my ($orddate, $buysell) = @_;
1950 <form method=post action=$form->{script}>
1953 # delete action variable
1954 map { delete $form->{$_} } qw(action header exchangerate);
1956 foreach $key (keys %$form) {
1957 $form->{$key} =~ s/\"/"/g;
1958 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1961 $form->{title} = $locale->text('Add Exchangerate');
1965 <input type=hidden name=path value=$form->{path}>
1966 <input type=hidden name=login value=$form->{login}>
1967 <input type=hidden name=password value=$form->{password}>
1969 <input type=hidden name=exchangeratedate value=$orddate>
1970 <input type=hidden name=buysell value=$buysell>
1973 <tr><th class=listtop>$form->{title}</th></tr>
1974 <tr height="5"></tr>
1979 <th align=right>| . $locale->text('Currency') . qq|</th>
1980 <td>$form->{currency}</td>
1983 <th align=right>| . $locale->text('Date') . qq|</th>
1987 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
1988 <td><input name=exchangerate size=11></td>
1998 <input type=hidden name=nextsub value=save_exchangerate>
2000 <input name=action class=submit type=submit value="|
2001 . $locale->text('Continue') . qq|">
2009 $lxdebug->leave_sub();
2012 sub save_exchangerate {
2013 $lxdebug->enter_sub();
2015 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2016 $form->{exchangerate} =
2017 $form->parse_amount(\%myconfig, $form->{exchangerate});
2018 $form->save_exchangerate(\%myconfig, $form->{currency},
2019 $form->{exchangeratedate},
2020 $form->{exchangerate}, $form->{buysell});
2024 $lxdebug->leave_sub();
2027 sub create_backorder {
2028 $lxdebug->enter_sub();
2030 $form->{shipped} = 1;
2032 # figure out if we need to create a backorder
2033 # items aren't saved if qty != 0
2035 for $i (1 .. $form->{rowcount}) {
2036 $totalqty += $qty = $form->{"qty_$i"};
2037 $totalship += $ship = $form->{"ship_$i"};
2039 $form->{"qty_$i"} = $qty - $ship;
2042 if ($totalship == 0) {
2043 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2044 $form->{ordtotal} = 0;
2045 $form->{shipped} = 0;
2049 if ($totalqty == $totalship) {
2050 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2051 $form->{ordtotal} = 0;
2056 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2059 for $i (1 .. $form->{rowcount}) {
2061 $form->{"${_}_$i"} =
2062 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2063 } qw(sellprice discount);
2066 OE->save(\%myconfig, \%$form);
2068 # rebuild rows for invoice
2072 for $i (1 .. $form->{rowcount}) {
2073 $form->{"qty_$i"} = $form->{"ship_$i"};
2075 if ($form->{"qty_$i"}) {
2078 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2083 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2084 $form->{rowcount} = $count;
2086 $lxdebug->leave_sub();
2090 $lxdebug->enter_sub();
2092 $form->{saveasnew} = 1;
2093 $form->{closed} = 0;
2094 map { delete $form->{$_} } qw(printed emailed queued);
2098 $lxdebug->leave_sub();
2101 sub purchase_order {
2102 $lxdebug->enter_sub();
2104 $form->{title} = $locale->text('Add Purchase Order');
2105 $form->{vc} = "vendor";
2106 $form->{type} = "purchase_order";
2110 $lxdebug->leave_sub();
2114 $lxdebug->enter_sub();
2116 if ( $form->{type} eq 'sales_quotation'
2117 || $form->{type} eq 'request_quotation') {
2118 $form->{closed} = 1;
2119 OE->save(\%myconfig, \%$form);
2122 ($null, $form->{cp_id}) = split /--/, $form->{contact};
2123 $form->{cp_id} *= 1;
2125 $form->{title} = $locale->text('Add Sales Order');
2126 $form->{vc} = "customer";
2127 $form->{type} = "sales_order";
2131 $lxdebug->leave_sub();
2135 $lxdebug->enter_sub();
2137 $form->{transdate} = $form->current_date(\%myconfig);
2138 delete $form->{duedate};
2140 $form->{closed} = 0;
2143 map { delete $form->{$_} }
2144 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2151 for $i (1 .. $form->{rowcount} - 1) {
2152 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2153 qw(partnumber description unit);
2156 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2157 qw(creditlimit creditremaining);
2161 $lxdebug->leave_sub();
2165 $lxdebug->enter_sub();
2171 OE->get_warehouses(\%myconfig, \%$form);
2174 if (@{ $form->{all_warehouses} }) {
2175 $form->{selectwarehouse} = "<option>\n";
2177 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2178 (@{ $form->{all_warehouses} });
2180 if ($form->{warehouse}) {
2181 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2185 $form->{shippingdate} = $form->current_date(\%myconfig);
2186 $form->{"$form->{vc}"} =~ s/--.*//;
2191 foreach $key (keys %$form) {
2192 if ($key =~ /_1$/) {
2198 for $i (1 .. $form->{rowcount}) {
2200 # undo formatting from prepare_order
2202 $form->{"${_}_$i"} =
2203 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2205 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2207 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2208 $form->{"ship_$i"} = "";
2209 $form->{"serialnumber_$i"} = "";
2214 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2219 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2220 $form->{rowcount} = $count;
2222 &display_ship_receive;
2224 $lxdebug->leave_sub();
2227 sub display_ship_receive {
2228 $lxdebug->enter_sub();
2230 $vclabel = ucfirst $form->{vc};
2231 $vclabel = $locale->text($vclabel);
2233 $form->{rowcount}++;
2235 if ($form->{vc} eq 'customer') {
2236 $form->{title} = $locale->text('Ship Merchandise');
2237 $shipped = $locale->text('Shipping Date');
2239 $form->{title} = $locale->text('Receive Merchandise');
2240 $shipped = $locale->text('Date Received');
2243 # set option selected
2244 foreach $item (warehouse, employee) {
2245 $form->{"select$item"} =~ s/ selected//;
2246 $form->{"select$item"} =~
2247 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2252 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2253 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2254 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2256 | if $form->{selectwarehouse};
2260 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2261 <td><select name=employee>$form->{selectemployee}</select></td>
2262 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2271 <form method=post action=$form->{script}>
2273 <input type=hidden name=id value=$form->{id}>
2275 <input type=hidden name=display_form value=display_ship_receive>
2277 <input type=hidden name=type value=$form->{type}>
2278 <input type=hidden name=media value=$form->{media}>
2279 <input type=hidden name=format value=$form->{format}>
2281 <input type=hidden name=queued value="$form->{queued}">
2282 <input type=hidden name=printed value="$form->{printed}">
2283 <input type=hidden name=emailed value="$form->{emailed}">
2285 <input type=hidden name=vc value=$form->{vc}>
2289 <th class=listtop>$form->{title}</th>
2291 <tr height="5"></tr>
2294 <table width="100%">
2299 <th align=right>$vclabel</th>
2300 <td colspan=3>$form->{$form->{vc}}</td>
2301 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2302 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2306 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2308 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2311 <th align=right>| . $locale->text('Ship via') . qq|</th>
2313 <input name=shipvia size=35 value="$form->{shipvia}">
2322 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2323 <td>$form->{ordnumber}</td>
2324 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2327 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2328 <td>$form->{transdate}</td>
2329 <input type=hidden name=transdate value=$form->{transdate}>
2332 <th align=right nowrap>$shipped</th>
2333 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2342 <!-- shipto are in hidden variables -->
2344 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2345 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2346 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2347 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2348 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2349 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2350 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2351 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2352 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2354 <!-- email variables -->
2355 <input type=hidden name=message value="$form->{message}">
2356 <input type=hidden name=email value="$form->{email}">
2357 <input type=hidden name=subject value="$form->{subject}">
2358 <input type=hidden name=cc value="$form->{cc}">
2359 <input type=hidden name=bcc value="$form->{bcc}">
2364 (partnumber, description, qty, ship, unit, bin, serialnumber);
2366 if ($form->{type} eq "ship_order") {
2367 $column_data{ship} =
2368 qq|<th class=listheading align=center width="auto">|
2369 . $locale->text('Ship')
2372 if ($form->{type} eq "receive_order") {
2373 $column_data{ship} =
2374 qq|<th class=listheading align=center width="auto">|
2375 . $locale->text('Recd')
2379 my $colspan = $#column_index + 1;
2381 $column_data{partnumber} =
2382 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2383 $column_data{description} =
2384 qq|<th class=listheading nowrap>|
2385 . $locale->text('Description')
2388 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2389 $column_data{unit} =
2390 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2392 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2393 $column_data{serialnumber} =
2394 qq|<th class=listheading nowrap>|
2395 . $locale->text('Serial No.')
2402 <tr class=listheading>|;
2404 map { print "\n$column_data{$_}" } @column_index;
2410 for $i (1 .. $form->{rowcount} - 1) {
2413 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2415 # convert " to "
2416 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2417 qw(partnumber description unit bin serialnumber);
2419 $description = $form->{"description_$i"};
2420 $description =~ s/\n/<br>/g;
2422 $column_data{partnumber} =
2423 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2424 $column_data{description} =
2425 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2427 qq|<td align=right>|
2428 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2429 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2430 $column_data{ship} =
2431 qq|<td align=right><input name="ship_$i" size=5 value=|
2432 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2434 $column_data{unit} =
2435 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2437 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2439 $column_data{serialnumber} =
2440 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2445 map { print "\n$column_data{$_}" } @column_index;
2450 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2451 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2452 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2453 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2464 <td><hr size=3 noshade></td>
2470 $form->{copies} = 1;
2479 <input class=submit type=submit name=action value="|
2480 . $locale->text('Update') . qq|">
2481 <input class=submit type=submit name=action value="|
2482 . $locale->text('Print') . qq|">
2485 if ($form->{type} eq 'ship_order') {
2487 <input class=submit type=submit name=action value="|
2488 . $locale->text('Ship to') . qq|">
2489 <input class=submit type=submit name=action value="|
2490 . $locale->text('E-mail') . qq|">
2496 <input class=submit type=submit name=action value="|
2497 . $locale->text('Done') . qq|">
2500 if ($form->{menubar}) {
2501 require "$form->{path}/menu.pl";
2507 <input type=hidden name=rowcount value=$form->{rowcount}>
2509 <input name=callback type=hidden value="$callback">
2511 <input type=hidden name=path value=$form->{path}>
2512 <input type=hidden name=login value=$form->{login}>
2513 <input type=hidden name=password value=$form->{password}>
2521 $lxdebug->leave_sub();
2525 $lxdebug->enter_sub();
2527 if ($form->{type} eq 'ship_order') {
2528 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2530 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2535 $total += $form->{"ship_$_"} =
2536 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2537 } (1 .. $form->{rowcount} - 1);
2539 $form->error($locale->text('Nothing entered!')) unless $total;
2541 $form->redirect($locale->text('Inventory saved!'))
2542 if OE->save_inventory(\%myconfig, \%$form);
2543 $form->error($locale->text('Could not save!'));
2545 $lxdebug->leave_sub();
2548 sub search_transfer {
2549 $lxdebug->enter_sub();
2551 OE->get_warehouses(\%myconfig, \%$form);
2554 if (@{ $form->{all_warehouses} }) {
2555 $form->{selectwarehouse} = "<option>\n";
2556 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2558 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2559 (@{ $form->{all_warehouses} });
2561 $form->error($locale->text('Nothing to transfer!'));
2564 $form->{title} = $locale->text('Transfer Inventory');
2571 <form method=post action=$form->{script}>
2575 <th class=listtop>$form->{title}</th>
2577 <tr height="5"></tr>
2582 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2583 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2586 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2587 <td><input name=partnumber size=20></td>
2590 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2591 <td><input name=description size=40></td>
2594 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2595 <td><input name=partsgroup size=20></td>
2601 <td><hr size=3 noshade></td>
2606 <input type=hidden name=sort value=partnumber>
2607 <input type=hidden name=nextsub value=list_transfer>
2609 <input type=hidden name=path value=$form->{path}>
2610 <input type=hidden name=login value=$form->{login}>
2611 <input type=hidden name=password value=$form->{password}>
2613 <input class=submit type=submit name=action value="|
2614 . $locale->text('Continue') . qq|">
2621 $lxdebug->leave_sub();
2625 $lxdebug->enter_sub();
2627 OE->get_inventory(\%myconfig, \%$form);
2629 $partnumber = $form->escape($form->{partnumber});
2630 $warehouse = $form->escape($form->{warehouse});
2631 $description = $form->escape($form->{description});
2632 $partsgroup = $form->escape($form->{partsgroup});
2636 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2638 # construct callback
2639 $partnumber = $form->escape($form->{partnumber}, 1);
2640 $warehouse = $form->escape($form->{warehouse}, 1);
2641 $description = $form->escape($form->{description}, 1);
2642 $partsgroup = $form->escape($form->{partsgroup}, 1);
2645 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2648 $form->sort_columns(
2649 qw(partnumber description partsgroup make model warehouse qty transfer));
2651 $column_header{partnumber} =
2652 qq|<th><a class=listheading href=$href&sort=partnumber>|
2653 . $locale->text('Part Number')
2655 $column_header{description} =
2656 qq|<th><a class=listheading href=$href&sort=description>|
2657 . $locale->text('Description')
2659 $column_header{partsgroup} =
2660 qq|<th><a class=listheading href=$href&sort=partsgroup>|
2661 . $locale->text('Group')
2663 $column_header{warehouse} =
2664 qq|<th><a class=listheading href=$href&sort=warehouse>|
2665 . $locale->text('From')
2667 $column_header{qty} =
2668 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
2669 $column_header{transfer} =
2670 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
2672 $option = $locale->text('Transfer to');
2674 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
2676 if ($form->{warehouse}) {
2677 $option .= " : $warehouse";
2679 if ($form->{partnumber}) {
2680 $option .= "\n<br>" if ($option);
2681 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
2683 if ($form->{description}) {
2684 $option .= "\n<br>" if ($option);
2685 $option .= $locale->text('Description') . " : $form->{description}";
2687 if ($form->{partsgroup}) {
2688 $option .= "\n<br>" if ($option);
2689 $option .= $locale->text('Group') . " : $form->{partsgroup}";
2692 $form->{title} = $locale->text('Transfer Inventory');
2699 <form method=post action=$form->{script}>
2701 <input type=hidden name=warehouse_id value=$warehouse_id>
2705 <th class=listtop>$form->{title}</th>
2707 <tr height="5"></tr>
2714 <tr class=listheading>|;
2716 map { print "\n$column_header{$_}" } @column_index;
2722 if (@{ $form->{all_inventory} }) {
2723 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
2727 foreach $ref (@{ $form->{all_inventory} }) {
2731 $column_data{partnumber} =
2732 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
2733 $column_data{description} = "<td>$ref->{description} </td>";
2734 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
2735 $column_data{warehouse} =
2736 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
2738 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
2739 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
2741 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
2746 <tr class=listrow$j>";
2748 map { print "\n$column_data{$_}" } @column_index;
2762 <td><hr size=3 noshade></td>
2768 <input name=callback type=hidden value="$callback">
2770 <input type=hidden name=rowcount value=$i>
2772 <input type=hidden name=path value=$form->{path}>
2773 <input type=hidden name=login value=$form->{login}>
2774 <input type=hidden name=password value=$form->{password}>
2776 <input class=submit type=submit name=action value="|
2777 . $locale->text('Transfer') . qq|">|;
2779 if ($form->{menubar}) {
2780 require "$form->{path}/menu.pl";
2791 $lxdebug->leave_sub();
2795 $lxdebug->enter_sub();
2797 $form->redirect($locale->text('Inventory transferred!'))
2798 if OE->transfer(\%myconfig, \%$form);
2799 $form->error($locale->text('Could not transfer Inventory!'));
2801 $lxdebug->leave_sub();