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}) {
234 $form->{"discount_$i"} =
235 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
237 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
239 $decimalplaces = ($dec > 2) ? $dec : 2;
241 # copy reqdate from deliverydate for invoice -> order conversion
242 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"} unless $form->{"reqdate_$i"};
244 $form->{"sellprice_$i"} =
245 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
248 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
249 $dec_qty = length $dec_qty;
250 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
252 map { $form->{"${_}_$i"} =~ s/\"/"/g }
253 qw(partnumber description unit);
256 $lxdebug->leave_sub();
260 $lxdebug->enter_sub();
262 $checkedopen = ($form->{closed}) ? "" : "checked";
263 $checkedclosed = ($form->{closed}) ? "checked" : "";
265 # use JavaScript Calendar or not
266 $form->{jsscript} = $form->{jscalendar};
269 if ($form->{jsscript}) {
271 # with JavaScript Calendar
273 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
274 <td><input type=button name=transdate id="trigger1" value=|
275 . $locale->text('button') . qq|></td>
278 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
279 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
280 . $locale->text('button') . qq|></td>
285 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
286 "reqdate", "BL", "trigger2");
290 # without JavaScript Calendar
292 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
294 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
300 <td colspan=2 align=center>
303 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
304 . $locale->text('Open') . qq|</th>
305 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
306 . $locale->text('Closed') . qq|</th>
314 # set option selected
315 foreach $item ($form->{vc}, currency, department, employee, contact) {
316 $form->{"select$item"} =~ s/ selected//;
317 $form->{"select$item"} =~
318 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
322 if ($form->{all_contacts}) {
324 $form->{selectcontact} = "";
325 foreach $item (@{ $form->{all_contacts} }) {
326 if ($form->{cp_id} == $item->{cp_id}) {
327 $form->{selectcontact} .=
328 "<option selected>$item->{cp_name}--$item->{cp_id}";
330 $form->{selectcontact} .= "<option>$item->{cp_name}--$item->{cp_id}";
335 $form->{exchangerate} =
336 $form->format_amount(\%myconfig, $form->{exchangerate});
338 $form->{creditlimit} =
339 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
340 $form->{creditremaining} =
341 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
344 ($form->{selectcontact})
345 ? qq|<select name=contact>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
346 : qq|<input name=contact value="$form->{contact}" size=35>|;
349 <input type=hidden name=forex value=$form->{forex}>
352 if ($form->{currency} ne $form->{defaultcurrency}) {
353 if ($form->{forex}) {
356 . $locale->text('Exchangerate')
357 . qq|</th><td>$form->{exchangerate}</td>
358 <input type=hidden name=exchangerate value=$form->{exchangerate}>
363 . $locale->text('Exchangerate')
364 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
368 $vclabel = ucfirst $form->{vc};
369 $vclabel = $locale->text($vclabel);
373 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
374 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
375 . $locale->text('days') . qq|</td>
379 if ($form->{business}) {
382 <th align=right>| . $locale->text('Business') . qq|</th>
383 <td>$form->{business}</td>
384 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
386 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
392 if ($form->{type} !~ /_quotation$/) {
395 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
396 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
399 <th width=70% align=right nowrap>|
400 . $locale->text('Quotation Number') . qq|</th>
401 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
404 <th width=70% align=right nowrap>|
405 . $locale->text('Customer Order Number') . qq|</th>
406 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
409 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
414 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
419 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
421 $creditremaining = qq|
427 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
428 <td>$form->{creditlimit}</td>
430 <th nowrap>| . $locale->text('Remaining') . qq|</th>
431 <td class="plus$n">$form->{creditremaining}</td>
439 ($form->{type} eq 'sales_quotation')
440 ? $locale->text('Valid until')
441 : $locale->text('Required by');
442 if ($form->{type} eq 'sales_quotation') {
445 <th width=70% align=right nowrap>|
446 . $locale->text('Quotation Number') . qq|</th>
447 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
448 <input type=hidden name=ordnumber value="$form->{ordnumber}">
454 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
455 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
456 <input type=hidden name=ordnumber value="$form->{ordnumber}">
465 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
469 <th align=right nowrap=true>$reqlabel</th>
477 ($form->{"select$form->{vc}"})
478 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
479 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
483 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
484 <td colspan=3><select name=department>$form->{selectdepartment}</select>
485 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
488 | if $form->{selectdepartment};
491 <input type=hidden name=employee value="$form->{employee}">
494 if ($form->{type} eq 'sales_order') {
495 if ($form->{selectemployee}) {
497 <input type=hidden name=customer_klass value=$form->{customer_klass}>
499 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
500 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
501 <input type=hidden name=selectemployee value="$form->{selectemployee}">
508 <input type=hidden name=customer_klass value=$form->{customer_klass}>
510 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
511 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
512 <input type=hidden name=selectemployee value="$form->{selectemployee}">
523 <form method=post action=$form->{script}>
525 <input type=hidden name=id value=$form->{id}>
527 <input type=hidden name=type value=$form->{type}>
528 <input type=hidden name=formname value=$form->{formname}>
529 <input type=hidden name=media value=$form->{media}>
530 <input type=hidden name=format value=$form->{format}>
532 <input type=hidden name=queued value="$form->{queued}">
533 <input type=hidden name=printed value="$form->{printed}">
534 <input type=hidden name=emailed value="$form->{emailed}">
536 <input type=hidden name=vc value=$form->{vc}>
538 <input type=hidden name=title value="$form->{title}">
540 <input type=hidden name=discount value=$form->{discount}>
541 <input type=hidden name=creditlimit value=$form->{creditlimit}>
542 <input type=hidden name=creditremaining value=$form->{creditremaining}>
544 <input type=hidden name=tradediscount value=$form->{tradediscount}>
545 <input type=hidden name=business value=$form->{business}>
546 <input type=hidden name=webdav value=$webdav>
550 <th class=listtop>$form->{title}</th>
560 <th align=right>$vclabel</th>
561 <td colspan=3>$vc</td>
562 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
563 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
564 <th align=richt nowrap>|
565 . $locale->text('Contact Person') . qq|</th>
566 <td colspan=3>$contact</td>
572 <th align=right>| . $locale->text('Currency') . qq|</th>
573 <td><select name=currency>$form->{selectcurrency}</select></td>
574 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
575 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
579 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
580 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
583 <th align=right>| . $locale->text('Ship via') . qq|</th>
584 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
603 <!-- shipto are in hidden variables -->
605 <input type=hidden name=shiptoname value="$form->{shiptoname}">
606 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
607 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
608 <input type=hidden name=shiptocity value="$form->{shiptocity}">
609 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
610 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
611 <input type=hidden name=shiptophone value="$form->{shiptophone}">
612 <input type=hidden name=shiptofax value="$form->{shiptofax}">
613 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
615 <!-- email variables -->
616 <input type=hidden name=message value="$form->{message}">
617 <input type=hidden name=email value="$form->{email}">
618 <input type=hidden name=subject value="$form->{subject}">
619 <input type=hidden name=cc value="$form->{cc}">
620 <input type=hidden name=bcc value="$form->{bcc}">
622 <input type=hidden name=taxpart value="$form->{taxpart}">
623 <input type=hidden name=taxservice value="$form->{taxservice}">
625 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
628 foreach $item (split / /, $form->{taxaccounts}) {
630 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
631 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
634 $lxdebug->leave_sub();
638 $lxdebug->enter_sub();
640 $form->{invtotal} = $form->{invsubtotal};
642 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
645 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
648 $rows = ($rows > $introws) ? $rows : $introws;
650 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
652 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
654 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
657 if ($form->{taxaccounts}) {
659 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
660 . $locale->text('Tax Included') . qq|</b><br><br>
664 if (!$form->{taxincluded}) {
666 foreach $item (split / /, $form->{taxaccounts}) {
667 if ($form->{"${item}_base"}) {
668 $form->{invtotal} += $form->{"${item}_total"} =
670 $form->{"${item}_base"} * $form->{"${item}_rate"},
672 $form->{"${item}_total"} =
673 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
677 <th align=right>$form->{"${item}_description"}</th>
678 <td align=right>$form->{"${item}_total"}</td>
684 $form->{invsubtotal} =
685 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
689 <th align=right>| . $locale->text('Subtotal') . qq|</th>
690 <td align=right>$form->{invsubtotal}</td>
696 if ($form->{taxincluded}) {
697 foreach $item (split / /, $form->{taxaccounts}) {
698 if ($form->{"${item}_base"}) {
699 $form->{"${item}_total"} =
701 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
702 (1 + $form->{"${item}_rate"})
705 $form->{"${item}_netto"} =
707 ($form->{"${item}_base"} - $form->{"${item}_total"}),
709 $form->{"${item}_total"} =
710 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
711 $form->{"${item}_netto"} =
712 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
716 <th align=right>Enthaltene $form->{"${item}_description"}</th>
717 <td align=right>$form->{"${item}_total"}</td>
720 <th align=right>Nettobetrag</th>
721 <td align=right>$form->{"${item}_netto"}</td>
729 $form->{oldinvtotal} = $form->{invtotal};
731 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
741 <th align=left>| . $locale->text('Notes') . qq|</th>
742 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
750 <td align=right width=100%>
756 <th align=right>| . $locale->text('Total') . qq|</th>
757 <td align=right>$form->{invtotal}</td>
765 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
766 <input type=hidden name=oldtotalpaid value=$totalpaid>
768 <td><hr size=3 noshade></td>
776 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
779 <td align=left width=30%><b>Dateiname</b></td>
780 <td align=left width=70%><b>Webdavlink</b></td>
782 foreach $file (keys %{ $form->{WEBDAV} }) {
785 <td align=left>$file</td>
786 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
794 <td><hr size=3 noshade></td>
801 <input type=hidden name=jscalendar value=$form->{jscalendar}>
814 Bearbeiten des $form->{heading}<br>
815 <input class=submit type=submit name=action value="|
816 . $locale->text('Update') . qq|">
817 <input class=submit type=submit name=action value="|
818 . $locale->text('Ship to') . qq|">
819 <input class=submit type=submit name=action value="|
820 . $locale->text('Print') . qq|">
821 <input class=submit type=submit name=action value="|
822 . $locale->text('E-mail') . qq|">
823 <input class=submit type=submit name=action value="|
824 . $locale->text('Save') . qq|">
829 <br>Workflow $form->{heading}<br>
830 <input class=submit type=submit name=action value="|
831 . $locale->text('Save as new') . qq|">
832 <input class=submit type=submit name=action value="|
833 . $locale->text('Delete') . qq|">|;
834 if ($form->{type} =~ /quotation$/) {
836 <input class=submit type=submit name=action value="|
837 . $locale->text('Order') . qq|">|;
840 <input class=submit type=submit name=action value="|
841 . $locale->text('Invoice') . qq|">
844 if ($form->{type} =~ /sales_order$/) {
846 <br>$form->{heading} als neue Vorlage verwenden für<br>
847 <input class=submit type=submit name=action value="|
848 . $locale->text('Purchase Order') . qq|">
849 <input class=submit type=submit name=action value="|
850 . $locale->text('Quotation') . qq|">
853 } elsif ($form->{type} =~ /purchase_order$/) {
855 <br>$form->{heading} als neue Vorlage verwenden für<br>
856 <input class=submit type=submit name=action value="|
857 . $locale->text('Sales Order') . qq|">
858 <input class=submit type=submit name=action value="|
859 . $locale->text('Quotation') . qq|">
864 <br>$form->{heading} als neue Vorlage verwenden für<br>
865 <input class=submit type=submit name=action value="|
866 . $locale->text('Order') . qq|">
869 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount}) {
871 <br>Workflow $form->{heading}<br>
872 <input class=submit type=submit name=action value="|
873 . $locale->text('Save as new') . qq|">
874 <input class=submit type=submit name=action value="|
875 . $locale->text('Invoice') . qq|">
880 if ($form->{menubar}) {
881 require "$form->{path}/menu.pl";
887 <input type=hidden name=rowcount value=$form->{rowcount}>
889 <input name=callback type=hidden value="$form->{callback}">
891 <input type=hidden name=path value=$form->{path}>
892 <input type=hidden name=login value=$form->{login}>
893 <input type=hidden name=password value=$form->{password}>
900 $lxdebug->leave_sub();
904 $lxdebug->enter_sub();
906 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
907 qw(exchangerate creditlimit creditremaining);
909 &check_name($form->{vc});
914 $buysell = 'sell' if ($form->{vc} eq 'vendor');
915 $form->{exchangerate} = $exchangerate
919 $form->check_exchangerate(
920 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
924 $i = $form->{rowcount};
926 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
928 if ( ($form->{"partnumber_$i"} eq "")
929 && ($form->{"description_$i"} eq "")
930 && ($form->{"partsgroup_$i"} eq "")) {
932 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
937 if ( $form->{type} eq 'purchase_order'
938 || $form->{type} eq 'request_quotation') {
939 IR->retrieve_item(\%myconfig, \%$form);
941 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
942 IS->retrieve_item(\%myconfig, \%$form);
945 my $rows = scalar @{ $form->{item_list} };
947 $form->{"discount_$i"} =
948 $form->format_amount(\%myconfig, $form->{discount} * 100);
951 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
960 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
962 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
963 qw(partnumber description unit);
964 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
965 keys %{ $form->{item_list}[0] };
967 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
969 ($dec) = ($s =~ /\.(\d+)/);
971 $decimalplaces = ($dec > 2) ? $dec : 2;
974 $form->{"sellprice_$i"} = $sellprice;
977 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
978 # if there is an exchange rate adjust sellprice
979 $form->{"sellprice_$i"} /= $exchangerate;
983 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
984 (1 - $form->{"discount_$i"} / 100);
985 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
986 map { $form->{"${_}_base"} += $amount }
987 (split / /, $form->{"taxaccounts_$i"});
988 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
989 split / /, $form->{taxaccounts}
990 if !$form->{taxincluded};
992 $form->{creditremaining} -= $amount;
994 $form->{"sellprice_$i"} =
995 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
998 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1000 # get pricegroups for parts
1001 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1003 # build up html code for prices_$i
1004 &set_pricegroup($i);
1011 # ok, so this is a new part
1012 # ask if it is a part or service item
1014 if ( $form->{"partsgroup_$i"}
1015 && ($form->{"partsnumber_$i"} eq "")
1016 && ($form->{"description_$i"} eq "")) {
1017 $form->{rowcount}--;
1018 $form->{"discount_$i"} = "";
1022 $form->{"id_$i"} = 0;
1023 $form->{"unit_$i"} = $locale->text('ea');
1032 $lxdebug->leave_sub();
1036 $lxdebug->enter_sub();
1038 if ($form->{type} eq 'purchase_order') {
1039 $form->{title} = $locale->text('Purchase Orders');
1040 $form->{vc} = 'vendor';
1041 $ordlabel = $locale->text('Order Number');
1042 $ordnumber = 'ordnumber';
1043 $employee = $locale->text('Employee');
1045 if ($form->{type} eq 'request_quotation') {
1046 $form->{title} = $locale->text('Request for Quotations');
1047 $form->{vc} = 'vendor';
1048 $ordlabel = $locale->text('RFQ Number');
1049 $ordnumber = 'quonumber';
1050 $employee = $locale->text('Employee');
1052 if ($form->{type} eq 'receive_order') {
1053 $form->{title} = $locale->text('Receive Merchandise');
1054 $form->{vc} = 'vendor';
1055 $ordlabel = $locale->text('Order Number');
1056 $ordnumber = 'ordnumber';
1057 $employee = $locale->text('Employee');
1059 if ($form->{type} eq 'sales_order') {
1060 $form->{title} = $locale->text('Sales Orders');
1061 $form->{vc} = 'customer';
1062 $ordlabel = $locale->text('Order Number');
1063 $ordnumber = 'ordnumber';
1064 $employee = $locale->text('Salesperson');
1066 if ($form->{type} eq 'ship_order') {
1067 $form->{title} = $locale->text('Ship Merchandise');
1068 $form->{vc} = 'customer';
1069 $ordlabel = $locale->text('Order Number');
1070 $ordnumber = 'ordnumber';
1071 $employee = $locale->text('Salesperson');
1075 if ($form->{type} eq 'sales_quotation') {
1076 $form->{title} = $locale->text('Quotations');
1077 $form->{vc} = 'customer';
1078 $ordlabel = $locale->text('Quotation Number');
1079 $ordnumber = 'quonumber';
1080 $employee = $locale->text('Employee');
1083 if ($form->{type} =~ /(ship|receive)_order/) {
1084 OE->get_warehouses(\%myconfig, \%$form);
1087 if (@{ $form->{all_warehouses} }) {
1088 $form->{selectwarehouse} = "<option>\n";
1089 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1092 $form->{selectwarehouse} .=
1093 "<option>$_->{description}--$_->{id}\n"
1094 } (@{ $form->{all_warehouses} });
1098 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1099 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1100 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1107 # setup vendor / customer selection
1108 $form->all_vc(\%myconfig, $form->{vc},
1109 ($form->{vc} eq 'customer') ? "AR" : "AP");
1111 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1112 @{ $form->{"all_$form->{vc}"} };
1114 $vclabel = ucfirst $form->{vc};
1115 $vclabel = $locale->text($vclabel);
1117 # $locale->text('Vendor')
1118 # $locale->text('Customer')
1122 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1123 : qq|<input name=$form->{vc} size=35>|;
1126 if (@{ $form->{all_departments} }) {
1127 $form->{selectdepartment} = "<option>\n";
1130 $form->{selectdepartment} .=
1131 "<option>$_->{description}--$_->{id}\n"
1132 } (@{ $form->{all_departments} });
1137 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1138 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1140 | if $form->{selectdepartment};
1142 if ($form->{type} !~ /(ship_order|receive_order)/) {
1145 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1146 . $locale->text('Open') . qq|</td>
1147 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1148 . $locale->text('Closed') . qq|</td>
1154 <input type=hidden name="open" value=1>
1158 # use JavaScript Calendar or not
1159 $form->{jsscript} = $jscalendar;
1161 if ($form->{jsscript}) {
1163 # with JavaScript Calendar
1165 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1166 <input type=button name=transdatefrom id="trigger3" value=|
1167 . $locale->text('button') . qq|></td>
1170 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1171 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1172 . $locale->text('button') . qq|></td>
1177 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1178 "transdateto", "BL", "trigger4");
1181 # without JavaScript Calendar
1183 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1185 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1193 <form method=post action=$form->{script}>
1197 <th class=listtop>$form->{title}</th>
1199 <tr height="5"></tr>
1204 <th align=right>$vclabel</th>
1205 <td colspan=3>$vc</td>
1210 <th align=right>$ordlabel</th>
1211 <td colspan=3><input name="$ordnumber" size=20></td>
1214 <th align=right>| . $locale->text('From') . qq|</th>
1216 <th align=right>| . $locale->text('Bis') . qq|</th>
1219 <input type=hidden name=sort value=transdate>
1221 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1226 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1227 | . $locale->text('ID') . qq|</td>
1228 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1229 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1230 . $locale->text('Date') . qq|</td>
1231 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1232 . $locale->text('Required by') . qq|</td>
1235 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1236 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1237 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1238 . $locale->text('Ship via') . qq|</td>
1241 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1242 . $locale->text('Amount') . qq|</td>
1243 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1244 . $locale->text('Tax') . qq|</td>
1245 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1246 . $locale->text('Total') . qq|</td>
1249 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1250 . $locale->text('Subtotal') . qq|</td>
1258 <tr><td colspan=4><hr size=3 noshade></td></tr>
1264 <input type=hidden name=nextsub value=orders>
1265 <input type=hidden name=path value=$form->{path}>
1266 <input type=hidden name=login value=$form->{login}>
1267 <input type=hidden name=password value=$form->{password}>
1268 <input type=hidden name=vc value=$form->{vc}>
1269 <input type=hidden name=type value=$form->{type}>
1271 <input class=submit type=submit name=action value="|
1272 . $locale->text('Continue') . qq|">
1279 $lxdebug->leave_sub();
1283 $lxdebug->enter_sub();
1285 # split vendor / customer
1286 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1287 split(/--/, $form->{ $form->{vc} });
1289 OE->transactions(\%myconfig, \%$form);
1291 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1293 $number = $form->escape($form->{$ordnumber});
1294 $name = $form->escape($form->{ $form->{vc} });
1295 $department = $form->escape($form->{department});
1296 $warehouse = $form->escape($form->{warehouse});
1300 "$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";
1302 # construct callback
1303 $number = $form->escape($form->{$ordnumber}, 1);
1304 $name = $form->escape($form->{ $form->{vc} }, 1);
1305 $department = $form->escape($form->{department}, 1);
1306 $warehouse = $form->escape($form->{warehouse}, 1);
1309 "$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";
1312 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1313 "name", "netamount", "tax", "amount",
1314 "curr", "employee", "shipvia", "open",
1317 $form->{l_open} = $form->{l_closed} = "Y"
1318 if ($form->{open} && $form->{closed});
1320 foreach $item (@columns) {
1321 if ($form->{"l_$item"} eq "Y") {
1322 push @column_index, $item;
1324 # add column to href and callback
1325 $callback .= "&l_$item=Y";
1326 $href .= "&l_$item=Y";
1330 # only show checkboxes if gotten here via sales_order form.
1331 if ($form->{type} =~ /sales_order/) {
1332 unshift @column_index, "ids";
1335 if ($form->{l_subtotal} eq 'Y') {
1336 $callback .= "&l_subtotal=Y";
1337 $href .= "&l_subtotal=Y";
1340 if ($form->{vc} eq 'vendor') {
1341 if ($form->{type} eq 'receive_order') {
1342 $form->{title} = $locale->text('Receive Merchandise');
1343 } elsif ($form->{type} eq 'purchase_order') {
1344 $form->{title} = $locale->text('Purchase Orders');
1346 $form->{title} = $locale->text('Request for Quotations');
1348 $name = $locale->text('Vendor');
1349 $employee = $locale->text('Employee');
1351 if ($form->{vc} eq 'customer') {
1352 if ($form->{type} eq 'sales_order') {
1353 $form->{title} = $locale->text('Sales Orders');
1354 $employee = $locale->text('Salesperson');
1355 } elsif ($form->{type} eq 'ship_order') {
1356 $form->{title} = $locale->text('Ship Merchandise');
1357 $employee = $locale->text('Salesperson');
1359 $form->{title} = $locale->text('Quotations');
1360 $employee = $locale->text('Employee');
1362 $name = $locale->text('Customer');
1365 $column_header{id} =
1366 qq|<th><a class=listheading href=$href&sort=id>|
1367 . $locale->text('ID')
1369 $column_header{transdate} =
1370 qq|<th><a class=listheading href=$href&sort=transdate>|
1371 . $locale->text('Date')
1373 $column_header{reqdate} =
1374 qq|<th><a class=listheading href=$href&sort=reqdate>|
1375 . $locale->text('Required by')
1377 $column_header{ordnumber} =
1378 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1379 . $locale->text('Order')
1381 $column_header{quonumber} =
1382 qq|<th><a class=listheading href=$href&sort=quonumber>|
1383 . $locale->text('Quotation')
1385 $column_header{name} =
1386 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1387 $column_header{netamount} =
1388 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1389 $column_header{tax} =
1390 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1391 $column_header{amount} =
1392 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1393 $column_header{curr} =
1394 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1395 $column_header{shipvia} =
1396 qq|<th><a class=listheading href=$href&sort=shipvia>|
1397 . $locale->text('Ship via')
1399 $column_header{open} =
1400 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1401 $column_header{closed} =
1402 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1404 $column_header{employee} =
1405 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1407 $column_header{ids} = qq|<th></th>|;
1409 if ($form->{ $form->{vc} }) {
1410 $option = $locale->text(ucfirst $form->{vc});
1411 $option .= " : $form->{$form->{vc}}";
1413 if ($form->{warehouse}) {
1414 ($warehouse) = split /--/, $form->{warehouse};
1415 $option .= "\n<br>" if ($option);
1416 $option .= $locale->text('Warehouse');
1417 $option .= " : $warehouse";
1419 if ($form->{department}) {
1420 $option .= "\n<br>" if ($option);
1421 ($department) = split /--/, $form->{department};
1422 $option .= $locale->text('Department') . " : $department";
1424 if ($form->{transdatefrom}) {
1426 . $locale->text('From') . " "
1427 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1429 if ($form->{transdateto}) {
1431 . $locale->text('Bis') . " "
1432 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1434 if ($form->{open}) {
1435 $option .= "\n<br>" if ($option);
1436 $option .= $locale->text('Open');
1438 if ($form->{closed}) {
1439 $option .= "\n<br>" if ($option);
1440 $option .= $locale->text('Closed');
1448 <form method="post" action="oe.pl">
1451 <th class=listtop>$form->{title}</th>
1453 <tr height="5"></tr>
1460 <tr class=listheading>|;
1462 map { print "\n$column_header{$_}" } @column_index;
1468 # add sort and escape callback
1469 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1471 if (@{ $form->{OE} }) {
1472 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1476 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1478 $warehouse = $form->escape($form->{warehouse});
1480 foreach $oe (@{ $form->{OE} }) {
1481 $form->{rowcount} = ++$j;
1483 if ($form->{l_subtotal} eq 'Y') {
1484 if ($sameitem ne $oe->{ $form->{sort} }) {
1486 $sameitem = $oe->{ $form->{sort} };
1490 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1492 $column_data{netamount} =
1494 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1496 $column_data{tax} = "<td align=right>"
1497 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1500 $column_data{amount} =
1502 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1504 $totalnetamount += $oe->{netamount};
1505 $totalamount += $oe->{amount};
1507 $subtotalnetamount += $oe->{netamount};
1508 $subtotalamount += $oe->{amount};
1510 $column_data{ids} = qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1511 $column_data{id} = "<td>$oe->{id}</td>";
1512 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1513 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1515 $column_data{$ordnumber} =
1516 "<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>";
1517 $column_data{name} = "<td>$oe->{name}</td>";
1519 $column_data{employee} = "<td>$oe->{employee} </td>";
1520 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1522 if ($oe->{closed}) {
1523 $column_data{closed} = "<td align=center>X</td>";
1524 $column_data{open} = "<td> </td>";
1526 $column_data{closed} = "<td> </td>";
1527 $column_data{open} = "<td align=center>X</td>";
1533 <tr class=listrow$i>";
1535 map { print "\n$column_data{$_}" } @column_index;
1543 if ($form->{l_subtotal} eq 'Y') {
1549 <tr class=listtotal>|;
1551 map { $column_data{$_} = "<td> </td>" } @column_index;
1553 $column_data{netamount} =
1554 "<th class=listtotal align=right>"
1555 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1556 $column_data{tax} = "<th class=listtotal align=right>"
1557 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1560 $column_data{amount} =
1561 "<th class=listtotal align=right>"
1562 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1564 map { print "\n$column_data{$_}" } @column_index;
1572 <td><hr size=3 noshade></td>
1576 # multiple invoice edit button only if gotten there via sales_order form.
1578 if ($form->{type} =~ /sales_order/) {
1580 <input type="hidden" name="path" value="$form->{path}">
1581 <input class"submit" type="submit" name="action" value="|
1582 . $locale->text('Continue') .qq|">
1583 <input type="hidden" name="nextsub" value="edit">
1584 <input type="hidden" name="type" value="$form->{type}">
1585 <input type="hidden" name="warehouse" value="$warehouse">
1586 <input type="hidden" name="vc" value="$form->{vc}">
1587 <input type="hidden" name="login" value="$form->{login}">
1588 <input type="hidden" name="password" value="$form->{password}">
1589 <input type="hidden" name="callback" value="$callback">
1590 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1597 <form method=post action=$form->{script}>
1599 <input name=callback type=hidden value="$form->{callback}">
1601 <input type=hidden name=type value=$form->{type}>
1602 <input type=hidden name=vc value=$form->{vc}>
1604 <input type=hidden name=path value=$form->{path}>
1605 <input type=hidden name=login value=$form->{login}>
1606 <input type=hidden name=password value=$form->{password}>
1609 if ($form->{type} !~ /(ship|receive)_order/) {
1611 <input class=submit type=submit name=action value="|
1612 . $locale->text('Add') . qq|">|;
1615 if ($form->{menubar}) {
1616 require "$form->{path}/menu.pl";
1627 $lxdebug->leave_sub();
1631 $lxdebug->enter_sub();
1633 map { $column_data{$_} = "<td> </td>" } @column_index;
1635 $column_data{netamount} =
1636 "<th class=listsubtotal align=right>"
1637 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1639 $column_data{tax} = "<td class=listsubtotal align=right>"
1640 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1643 $column_data{amount} =
1644 "<th class=listsubtotal align=right>"
1645 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1647 $subtotalnetamount = 0;
1648 $subtotalamount = 0;
1651 <tr class=listsubtotal>
1654 map { print "\n$column_data{$_}" } @column_index;
1660 $lxdebug->leave_sub();
1664 $lxdebug->enter_sub();
1666 if ($form->{type} =~ /_order$/) {
1667 $form->isblank("transdate", $locale->text('Order Date missing!'));
1669 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1672 $msg = ucfirst $form->{vc};
1673 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1675 # $locale->text('Customer missing!');
1676 # $locale->text('Vendor missing!');
1678 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1679 if ($form->{currency} ne $form->{defaultcurrency});
1683 # if the name changed get new values
1684 if (&check_name($form->{vc})) {
1689 $form->{id} = 0 if $form->{saveasnew};
1691 # this is for the internal notes section for the [email] Subject
1692 if ($form->{type} =~ /_order$/) {
1693 if ($form->{type} eq 'sales_order') {
1694 $form->{label} = $locale->text('Sales Order');
1696 $numberfld = "sonumber";
1697 $ordnumber = "ordnumber";
1699 $form->{label} = $locale->text('Purchase Order');
1701 $numberfld = "ponumber";
1702 $ordnumber = "ordnumber";
1705 $err = $locale->text('Cannot save order!');
1708 if ($form->{type} eq 'sales_quotation') {
1709 $form->{label} = $locale->text('Quotation');
1711 $numberfld = "sqnumber";
1712 $ordnumber = "quonumber";
1714 $form->{label} = $locale->text('Request for Quotation');
1716 $numberfld = "rfqnumber";
1717 $ordnumber = "quonumber";
1720 $err = $locale->text('Cannot save quotation!');
1724 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
1725 unless $form->{$ordnumber};
1728 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1729 if (OE->save(\%myconfig, \%$form));
1732 $lxdebug->leave_sub();
1736 $lxdebug->enter_sub();
1740 if ($form->{type} =~ /_order$/) {
1741 $msg = $locale->text('Are you sure you want to delete Order Number');
1742 $ordnumber = 'ordnumber';
1744 $msg = $locale->text('Are you sure you want to delete Quotation Number');
1745 $ordnumber = 'quonumber';
1751 <form method=post action=$form->{script}>
1754 # delete action variable
1755 map { delete $form->{$_} } qw(action header);
1757 foreach $key (keys %$form) {
1758 $form->{$key} =~ s/\"/"/g;
1759 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1763 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1765 <h4>$msg $form->{$ordnumber}</h4>
1767 <input name=action class=submit type=submit value="|
1768 . $locale->text('Yes') . qq|">
1775 $lxdebug->leave_sub();
1779 $lxdebug->enter_sub();
1781 if ($form->{type} =~ /_order$/) {
1782 $msg = $locale->text('Order deleted!');
1783 $err = $locale->text('Cannot delete order!');
1785 $msg = $locale->text('Quotation deleted!');
1786 $err = $locale->text('Cannot delete quotation!');
1789 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
1792 $lxdebug->leave_sub();
1796 $lxdebug->enter_sub();
1798 if ($form->{type} =~ /_order$/) {
1799 # these checks only apply if the items don't bring their own ordnumbers/transdates.
1800 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
1801 $form->isblank("ordnumber", $locale->text('Order Number missing!')) if ( +{ map { $form->{"ordnumber_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} );
1802 $form->isblank("transdate", $locale->text('Order Date missing!')) if ( +{ map { $form->{"transdate_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} );
1805 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
1806 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1807 $form->{ordnumber} = "";
1810 # if the name changed get new values
1811 if (&check_name($form->{vc})) {
1816 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1817 $form->{cp_id} *= 1;
1819 if ( $form->{type} =~ /_order/
1820 && $form->{currency} ne $form->{defaultcurrency}) {
1822 # check if we need a new exchangerate
1823 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
1825 $orddate = $form->current_date(\%myconfig);
1827 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
1830 if (!$exchangerate) {
1831 &backorder_exchangerate($orddate, $buysell);
1836 # close orders/quotations
1837 $form->{closed} = 1;
1839 # save order if one ordnumber has been given
1840 # if not it's most likely a collective order, which can't be saved back
1841 # so they just have to be closed
1842 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
1843 OE->save(\%myconfig, \%$form);
1845 OE->close_orders(\%myconfig, \%$form);
1848 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1850 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1853 $form->{closed} = 0;
1854 $form->{rowcount}--;
1855 $form->{shipto} = 1;
1857 if ($form->{type} =~ /_order$/) {
1858 $form->{exchangerate} = $exchangerate;
1862 if ( $form->{type} eq 'purchase_order'
1863 || $form->{type} eq 'request_quotation') {
1864 $form->{title} = $locale->text('Add Vendor Invoice');
1865 $form->{script} = 'ir.pl';
1869 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1870 $form->{title} = $locale->text('Add Sales Invoice');
1871 $form->{script} = 'is.pl';
1876 # bo creates the id, reset it
1877 map { delete $form->{$_} }
1878 qw(id subject message cc bcc printed emailed queued);
1879 $form->{ $form->{vc} } =~ s/--.*//g;
1880 $form->{type} = "invoice";
1883 $locale = new Locale "$myconfig{countrycode}", "$script";
1885 require "$form->{path}/$form->{script}";
1887 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1889 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1890 qw(creditlimit creditremaining);
1892 $currency = $form->{currency};
1895 $form->{currency} = $currency;
1896 $form->{exchangerate} = "";
1897 $form->{forex} = "";
1898 $form->{exchangerate} = $exchangerate
1902 $form->check_exchangerate(
1903 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
1906 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1911 for $i (1 .. $form->{rowcount}) {
1912 $form->{"discount_$i"} =
1913 $form->format_amount(\%myconfig, $form->{"discount_$i"});
1915 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
1917 $decimalplaces = ($dec > 2) ? $dec : 2;
1919 # copy delivery date from reqdate for order -> invoice conversion
1920 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"} unless $form->{"deliverydate_$i"};
1922 $form->{"sellprice_$i"} =
1923 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1926 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
1927 $dec_qty = length $dec_qty;
1928 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1930 map { $form->{"${_}_$i"} =~ s/\"/"/g }
1931 qw(partnumber description unit);
1937 $lxdebug->leave_sub();
1940 sub backorder_exchangerate {
1941 $lxdebug->enter_sub();
1942 my ($orddate, $buysell) = @_;
1949 <form method=post action=$form->{script}>
1952 # delete action variable
1953 map { delete $form->{$_} } qw(action header exchangerate);
1955 foreach $key (keys %$form) {
1956 $form->{$key} =~ s/\"/"/g;
1957 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1960 $form->{title} = $locale->text('Add Exchangerate');
1964 <input type=hidden name=path value=$form->{path}>
1965 <input type=hidden name=login value=$form->{login}>
1966 <input type=hidden name=password value=$form->{password}>
1968 <input type=hidden name=exchangeratedate value=$orddate>
1969 <input type=hidden name=buysell value=$buysell>
1972 <tr><th class=listtop>$form->{title}</th></tr>
1973 <tr height="5"></tr>
1978 <th align=right>| . $locale->text('Currency') . qq|</th>
1979 <td>$form->{currency}</td>
1982 <th align=right>| . $locale->text('Date') . qq|</th>
1986 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
1987 <td><input name=exchangerate size=11></td>
1997 <input type=hidden name=nextsub value=save_exchangerate>
1999 <input name=action class=submit type=submit value="|
2000 . $locale->text('Continue') . qq|">
2008 $lxdebug->leave_sub();
2011 sub save_exchangerate {
2012 $lxdebug->enter_sub();
2014 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2015 $form->{exchangerate} =
2016 $form->parse_amount(\%myconfig, $form->{exchangerate});
2017 $form->save_exchangerate(\%myconfig, $form->{currency},
2018 $form->{exchangeratedate},
2019 $form->{exchangerate}, $form->{buysell});
2023 $lxdebug->leave_sub();
2026 sub create_backorder {
2027 $lxdebug->enter_sub();
2029 $form->{shipped} = 1;
2031 # figure out if we need to create a backorder
2032 # items aren't saved if qty != 0
2034 for $i (1 .. $form->{rowcount}) {
2035 $totalqty += $qty = $form->{"qty_$i"};
2036 $totalship += $ship = $form->{"ship_$i"};
2038 $form->{"qty_$i"} = $qty - $ship;
2041 if ($totalship == 0) {
2042 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2043 $form->{ordtotal} = 0;
2044 $form->{shipped} = 0;
2048 if ($totalqty == $totalship) {
2049 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2050 $form->{ordtotal} = 0;
2055 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2058 for $i (1 .. $form->{rowcount}) {
2060 $form->{"${_}_$i"} =
2061 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2062 } qw(sellprice discount);
2065 OE->save(\%myconfig, \%$form);
2067 # rebuild rows for invoice
2071 for $i (1 .. $form->{rowcount}) {
2072 $form->{"qty_$i"} = $form->{"ship_$i"};
2074 if ($form->{"qty_$i"}) {
2077 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2082 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2083 $form->{rowcount} = $count;
2085 $lxdebug->leave_sub();
2089 $lxdebug->enter_sub();
2091 $form->{saveasnew} = 1;
2092 $form->{closed} = 0;
2093 map { delete $form->{$_} } qw(printed emailed queued);
2097 $lxdebug->leave_sub();
2100 sub purchase_order {
2101 $lxdebug->enter_sub();
2103 $form->{title} = $locale->text('Add Purchase Order');
2104 $form->{vc} = "vendor";
2105 $form->{type} = "purchase_order";
2109 $lxdebug->leave_sub();
2113 $lxdebug->enter_sub();
2115 if ( $form->{type} eq 'sales_quotation'
2116 || $form->{type} eq 'request_quotation') {
2117 $form->{closed} = 1;
2118 OE->save(\%myconfig, \%$form);
2121 ($null, $form->{cp_id}) = split /--/, $form->{contact};
2122 $form->{cp_id} *= 1;
2124 $form->{title} = $locale->text('Add Sales Order');
2125 $form->{vc} = "customer";
2126 $form->{type} = "sales_order";
2130 $lxdebug->leave_sub();
2134 $lxdebug->enter_sub();
2136 $form->{transdate} = $form->current_date(\%myconfig);
2137 delete $form->{duedate};
2139 $form->{closed} = 0;
2142 map { delete $form->{$_} }
2143 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2150 for $i (1 .. $form->{rowcount} - 1) {
2151 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2152 qw(partnumber description unit);
2155 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2156 qw(creditlimit creditremaining);
2160 $lxdebug->leave_sub();
2164 $lxdebug->enter_sub();
2170 OE->get_warehouses(\%myconfig, \%$form);
2173 if (@{ $form->{all_warehouses} }) {
2174 $form->{selectwarehouse} = "<option>\n";
2176 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2177 (@{ $form->{all_warehouses} });
2179 if ($form->{warehouse}) {
2180 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2184 $form->{shippingdate} = $form->current_date(\%myconfig);
2185 $form->{"$form->{vc}"} =~ s/--.*//;
2190 foreach $key (keys %$form) {
2191 if ($key =~ /_1$/) {
2197 for $i (1 .. $form->{rowcount}) {
2199 # undo formatting from prepare_order
2201 $form->{"${_}_$i"} =
2202 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2204 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2206 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2207 $form->{"ship_$i"} = "";
2208 $form->{"serialnumber_$i"} = "";
2213 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2218 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2219 $form->{rowcount} = $count;
2221 &display_ship_receive;
2223 $lxdebug->leave_sub();
2226 sub display_ship_receive {
2227 $lxdebug->enter_sub();
2229 $vclabel = ucfirst $form->{vc};
2230 $vclabel = $locale->text($vclabel);
2232 $form->{rowcount}++;
2234 if ($form->{vc} eq 'customer') {
2235 $form->{title} = $locale->text('Ship Merchandise');
2236 $shipped = $locale->text('Shipping Date');
2238 $form->{title} = $locale->text('Receive Merchandise');
2239 $shipped = $locale->text('Date Received');
2242 # set option selected
2243 foreach $item (warehouse, employee) {
2244 $form->{"select$item"} =~ s/ selected//;
2245 $form->{"select$item"} =~
2246 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2251 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2252 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2253 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2255 | if $form->{selectwarehouse};
2259 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2260 <td><select name=employee>$form->{selectemployee}</select></td>
2261 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2270 <form method=post action=$form->{script}>
2272 <input type=hidden name=id value=$form->{id}>
2274 <input type=hidden name=display_form value=display_ship_receive>
2276 <input type=hidden name=type value=$form->{type}>
2277 <input type=hidden name=media value=$form->{media}>
2278 <input type=hidden name=format value=$form->{format}>
2280 <input type=hidden name=queued value="$form->{queued}">
2281 <input type=hidden name=printed value="$form->{printed}">
2282 <input type=hidden name=emailed value="$form->{emailed}">
2284 <input type=hidden name=vc value=$form->{vc}>
2288 <th class=listtop>$form->{title}</th>
2290 <tr height="5"></tr>
2293 <table width="100%">
2298 <th align=right>$vclabel</th>
2299 <td colspan=3>$form->{$form->{vc}}</td>
2300 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2301 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2305 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2307 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2310 <th align=right>| . $locale->text('Ship via') . qq|</th>
2312 <input name=shipvia size=35 value="$form->{shipvia}">
2321 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2322 <td>$form->{ordnumber}</td>
2323 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2326 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2327 <td>$form->{transdate}</td>
2328 <input type=hidden name=transdate value=$form->{transdate}>
2331 <th align=right nowrap>$shipped</th>
2332 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2341 <!-- shipto are in hidden variables -->
2343 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2344 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2345 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2346 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2347 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2348 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2349 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2350 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2351 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2353 <!-- email variables -->
2354 <input type=hidden name=message value="$form->{message}">
2355 <input type=hidden name=email value="$form->{email}">
2356 <input type=hidden name=subject value="$form->{subject}">
2357 <input type=hidden name=cc value="$form->{cc}">
2358 <input type=hidden name=bcc value="$form->{bcc}">
2363 (partnumber, description, qty, ship, unit, bin, serialnumber);
2365 if ($form->{type} eq "ship_order") {
2366 $column_data{ship} =
2367 qq|<th class=listheading align=center width="auto">|
2368 . $locale->text('Ship')
2371 if ($form->{type} eq "receive_order") {
2372 $column_data{ship} =
2373 qq|<th class=listheading align=center width="auto">|
2374 . $locale->text('Recd')
2378 my $colspan = $#column_index + 1;
2380 $column_data{partnumber} =
2381 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2382 $column_data{description} =
2383 qq|<th class=listheading nowrap>|
2384 . $locale->text('Description')
2387 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2388 $column_data{unit} =
2389 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2391 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2392 $column_data{serialnumber} =
2393 qq|<th class=listheading nowrap>|
2394 . $locale->text('Serial No.')
2401 <tr class=listheading>|;
2403 map { print "\n$column_data{$_}" } @column_index;
2409 for $i (1 .. $form->{rowcount} - 1) {
2412 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2414 # convert " to "
2415 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2416 qw(partnumber description unit bin serialnumber);
2418 $description = $form->{"description_$i"};
2419 $description =~ s/\n/<br>/g;
2421 $column_data{partnumber} =
2422 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2423 $column_data{description} =
2424 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2426 qq|<td align=right>|
2427 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2428 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2429 $column_data{ship} =
2430 qq|<td align=right><input name="ship_$i" size=5 value=|
2431 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2433 $column_data{unit} =
2434 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2436 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2438 $column_data{serialnumber} =
2439 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2444 map { print "\n$column_data{$_}" } @column_index;
2449 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2450 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2451 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2452 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2463 <td><hr size=3 noshade></td>
2469 $form->{copies} = 1;
2478 <input class=submit type=submit name=action value="|
2479 . $locale->text('Update') . qq|">
2480 <input class=submit type=submit name=action value="|
2481 . $locale->text('Print') . qq|">
2484 if ($form->{type} eq 'ship_order') {
2486 <input class=submit type=submit name=action value="|
2487 . $locale->text('Ship to') . qq|">
2488 <input class=submit type=submit name=action value="|
2489 . $locale->text('E-mail') . qq|">
2495 <input class=submit type=submit name=action value="|
2496 . $locale->text('Done') . qq|">
2499 if ($form->{menubar}) {
2500 require "$form->{path}/menu.pl";
2506 <input type=hidden name=rowcount value=$form->{rowcount}>
2508 <input name=callback type=hidden value="$callback">
2510 <input type=hidden name=path value=$form->{path}>
2511 <input type=hidden name=login value=$form->{login}>
2512 <input type=hidden name=password value=$form->{password}>
2520 $lxdebug->leave_sub();
2524 $lxdebug->enter_sub();
2526 if ($form->{type} eq 'ship_order') {
2527 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2529 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2534 $total += $form->{"ship_$_"} =
2535 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2536 } (1 .. $form->{rowcount} - 1);
2538 $form->error($locale->text('Nothing entered!')) unless $total;
2540 $form->redirect($locale->text('Inventory saved!'))
2541 if OE->save_inventory(\%myconfig, \%$form);
2542 $form->error($locale->text('Could not save!'));
2544 $lxdebug->leave_sub();
2547 sub search_transfer {
2548 $lxdebug->enter_sub();
2550 OE->get_warehouses(\%myconfig, \%$form);
2553 if (@{ $form->{all_warehouses} }) {
2554 $form->{selectwarehouse} = "<option>\n";
2555 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2557 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2558 (@{ $form->{all_warehouses} });
2560 $form->error($locale->text('Nothing to transfer!'));
2563 $form->{title} = $locale->text('Transfer Inventory');
2570 <form method=post action=$form->{script}>
2574 <th class=listtop>$form->{title}</th>
2576 <tr height="5"></tr>
2581 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2582 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2585 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2586 <td><input name=partnumber size=20></td>
2589 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2590 <td><input name=description size=40></td>
2593 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2594 <td><input name=partsgroup size=20></td>
2600 <td><hr size=3 noshade></td>
2605 <input type=hidden name=sort value=partnumber>
2606 <input type=hidden name=nextsub value=list_transfer>
2608 <input type=hidden name=path value=$form->{path}>
2609 <input type=hidden name=login value=$form->{login}>
2610 <input type=hidden name=password value=$form->{password}>
2612 <input class=submit type=submit name=action value="|
2613 . $locale->text('Continue') . qq|">
2620 $lxdebug->leave_sub();
2624 $lxdebug->enter_sub();
2626 OE->get_inventory(\%myconfig, \%$form);
2628 $partnumber = $form->escape($form->{partnumber});
2629 $warehouse = $form->escape($form->{warehouse});
2630 $description = $form->escape($form->{description});
2631 $partsgroup = $form->escape($form->{partsgroup});
2635 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2637 # construct callback
2638 $partnumber = $form->escape($form->{partnumber}, 1);
2639 $warehouse = $form->escape($form->{warehouse}, 1);
2640 $description = $form->escape($form->{description}, 1);
2641 $partsgroup = $form->escape($form->{partsgroup}, 1);
2644 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2647 $form->sort_columns(
2648 qw(partnumber description partsgroup make model warehouse qty transfer));
2650 $column_header{partnumber} =
2651 qq|<th><a class=listheading href=$href&sort=partnumber>|
2652 . $locale->text('Part Number')
2654 $column_header{description} =
2655 qq|<th><a class=listheading href=$href&sort=description>|
2656 . $locale->text('Description')
2658 $column_header{partsgroup} =
2659 qq|<th><a class=listheading href=$href&sort=partsgroup>|
2660 . $locale->text('Group')
2662 $column_header{warehouse} =
2663 qq|<th><a class=listheading href=$href&sort=warehouse>|
2664 . $locale->text('From')
2666 $column_header{qty} =
2667 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
2668 $column_header{transfer} =
2669 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
2671 $option = $locale->text('Transfer to');
2673 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
2675 if ($form->{warehouse}) {
2676 $option .= " : $warehouse";
2678 if ($form->{partnumber}) {
2679 $option .= "\n<br>" if ($option);
2680 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
2682 if ($form->{description}) {
2683 $option .= "\n<br>" if ($option);
2684 $option .= $locale->text('Description') . " : $form->{description}";
2686 if ($form->{partsgroup}) {
2687 $option .= "\n<br>" if ($option);
2688 $option .= $locale->text('Group') . " : $form->{partsgroup}";
2691 $form->{title} = $locale->text('Transfer Inventory');
2698 <form method=post action=$form->{script}>
2700 <input type=hidden name=warehouse_id value=$warehouse_id>
2704 <th class=listtop>$form->{title}</th>
2706 <tr height="5"></tr>
2713 <tr class=listheading>|;
2715 map { print "\n$column_header{$_}" } @column_index;
2721 if (@{ $form->{all_inventory} }) {
2722 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
2726 foreach $ref (@{ $form->{all_inventory} }) {
2730 $column_data{partnumber} =
2731 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
2732 $column_data{description} = "<td>$ref->{description} </td>";
2733 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
2734 $column_data{warehouse} =
2735 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
2737 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
2738 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
2740 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
2745 <tr class=listrow$j>";
2747 map { print "\n$column_data{$_}" } @column_index;
2761 <td><hr size=3 noshade></td>
2767 <input name=callback type=hidden value="$callback">
2769 <input type=hidden name=rowcount value=$i>
2771 <input type=hidden name=path value=$form->{path}>
2772 <input type=hidden name=login value=$form->{login}>
2773 <input type=hidden name=password value=$form->{password}>
2775 <input class=submit type=submit name=action value="|
2776 . $locale->text('Transfer') . qq|">|;
2778 if ($form->{menubar}) {
2779 require "$form->{path}/menu.pl";
2790 $lxdebug->leave_sub();
2794 $lxdebug->enter_sub();
2796 $form->redirect($locale->text('Inventory transferred!'))
2797 if OE->transfer(\%myconfig, \%$form);
2798 $form->error($locale->text('Could not transfer Inventory!'));
2800 $lxdebug->leave_sub();