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' && $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} = "html";
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 $form->{"sellprice_$i"} =
242 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
245 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
246 $dec_qty = length $dec_qty;
247 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
249 map { $form->{"${_}_$i"} =~ s/\"/"/g }
250 qw(partnumber description unit);
253 $lxdebug->leave_sub();
257 $lxdebug->enter_sub();
259 $checkedopen = ($form->{closed}) ? "" : "checked";
260 $checkedclosed = ($form->{closed}) ? "checked" : "";
262 # use JavaScript Calendar or not
263 $form->{jsscript} = $form->{jscalendar};
266 if ($form->{jsscript}) {
268 # with JavaScript Calendar
270 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
271 <td><input type=button name=transdate id="trigger1" value=|
272 . $locale->text('button') . qq|></td>
275 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
276 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
277 . $locale->text('button') . qq|></td>
282 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
283 "reqdate", "BL", "trigger2");
287 # without JavaScript Calendar
289 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
291 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
297 <td colspan=2 align=center>
300 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
301 . $locale->text('Open') . qq|</th>
302 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
303 . $locale->text('Closed') . qq|</th>
311 # set option selected
312 foreach $item ($form->{vc}, currency, department, employee, contact) {
313 $form->{"select$item"} =~ s/ selected//;
314 $form->{"select$item"} =~
315 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
319 if ($form->{all_contacts}) {
321 $form->{selectcontact} = "";
322 foreach $item (@{ $form->{all_contacts} }) {
323 if ($form->{cp_id} == $item->{cp_id}) {
324 $form->{selectcontact} .=
325 "<option selected>$item->{cp_name}--$item->{cp_id}";
327 $form->{selectcontact} .= "<option>$item->{cp_name}--$item->{cp_id}";
332 $form->{exchangerate} =
333 $form->format_amount(\%myconfig, $form->{exchangerate});
335 $form->{creditlimit} =
336 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
337 $form->{creditremaining} =
338 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
341 ($form->{selectcontact})
342 ? qq|<select name=contact>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
343 : qq|<input name=contact value="$form->{contact}" size=35>|;
346 <input type=hidden name=forex value=$form->{forex}>
349 if ($form->{currency} ne $form->{defaultcurrency}) {
350 if ($form->{forex}) {
353 . $locale->text('Exchangerate')
354 . qq|</th><td>$form->{exchangerate}</td>
355 <input type=hidden name=exchangerate value=$form->{exchangerate}>
360 . $locale->text('Exchangerate')
361 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
365 $vclabel = ucfirst $form->{vc};
366 $vclabel = $locale->text($vclabel);
370 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
371 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
372 . $locale->text('days') . qq|</td>
376 if ($form->{business}) {
379 <th align=right>| . $locale->text('Business') . qq|</th>
380 <td>$form->{business}</td>
381 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
383 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
389 if ($form->{type} !~ /_quotation$/) {
392 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
393 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
396 <th width=70% align=right nowrap>|
397 . $locale->text('Quotation Number') . qq|</th>
398 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
401 <th width=70% align=right nowrap>|
402 . $locale->text('Customer Order Number') . qq|</th>
403 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
406 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
411 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
416 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
418 $creditremaining = qq|
424 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
425 <td>$form->{creditlimit}</td>
427 <th nowrap>| . $locale->text('Remaining') . qq|</th>
428 <td class="plus$n">$form->{creditremaining}</td>
436 ($form->{type} eq 'sales_quotation')
437 ? $locale->text('Valid until')
438 : $locale->text('Required by');
439 if ($form->{type} eq 'sales_quotation') {
442 <th width=70% align=right nowrap>|
443 . $locale->text('Quotation Number') . qq|</th>
444 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
445 <input type=hidden name=ordnumber value="$form->{ordnumber}">
451 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
452 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
453 <input type=hidden name=ordnumber value="$form->{ordnumber}">
462 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
466 <th align=right nowrap=true>$reqlabel</th>
474 ($form->{"select$form->{vc}"})
475 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
476 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
480 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
481 <td colspan=3><select name=department>$form->{selectdepartment}</select>
482 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
485 | if $form->{selectdepartment};
488 <input type=hidden name=employee value="$form->{employee}">
491 if ($form->{type} eq 'sales_order') {
492 if ($form->{selectemployee}) {
494 <input type=hidden name=customer_klass value=$form->{customer_klass}>
496 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
497 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
498 <input type=hidden name=selectemployee value="$form->{selectemployee}">
505 <input type=hidden name=customer_klass value=$form->{customer_klass}>
507 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
508 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
509 <input type=hidden name=selectemployee value="$form->{selectemployee}">
520 <form method=post action=$form->{script}>
522 <input type=hidden name=id value=$form->{id}>
524 <input type=hidden name=type value=$form->{type}>
525 <input type=hidden name=formname value=$form->{formname}>
526 <input type=hidden name=media value=$form->{media}>
527 <input type=hidden name=format value=$form->{format}>
529 <input type=hidden name=queued value="$form->{queued}">
530 <input type=hidden name=printed value="$form->{printed}">
531 <input type=hidden name=emailed value="$form->{emailed}">
533 <input type=hidden name=vc value=$form->{vc}>
535 <input type=hidden name=title value="$form->{title}">
537 <input type=hidden name=discount value=$form->{discount}>
538 <input type=hidden name=creditlimit value=$form->{creditlimit}>
539 <input type=hidden name=creditremaining value=$form->{creditremaining}>
541 <input type=hidden name=tradediscount value=$form->{tradediscount}>
542 <input type=hidden name=business value=$form->{business}>
543 <input type=hidden name=webdav value=$webdav>
547 <th class=listtop>$form->{title}</th>
557 <th align=right>$vclabel</th>
558 <td colspan=3>$vc</td>
559 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
560 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
561 <th align=richt nowrap>|
562 . $locale->text('Contact Person') . qq|</th>
563 <td colspan=3>$contact</td>
569 <th align=right>| . $locale->text('Currency') . qq|</th>
570 <td><select name=currency>$form->{selectcurrency}</select></td>
571 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
572 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
576 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
577 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
580 <th align=right>| . $locale->text('Ship via') . qq|</th>
581 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
600 <!-- shipto are in hidden variables -->
602 <input type=hidden name=shiptoname value="$form->{shiptoname}">
603 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
604 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
605 <input type=hidden name=shiptocity value="$form->{shiptocity}">
606 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
607 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
608 <input type=hidden name=shiptophone value="$form->{shiptophone}">
609 <input type=hidden name=shiptofax value="$form->{shiptofax}">
610 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
612 <!-- email variables -->
613 <input type=hidden name=message value="$form->{message}">
614 <input type=hidden name=email value="$form->{email}">
615 <input type=hidden name=subject value="$form->{subject}">
616 <input type=hidden name=cc value="$form->{cc}">
617 <input type=hidden name=bcc value="$form->{bcc}">
619 <input type=hidden name=taxpart value="$form->{taxpart}">
620 <input type=hidden name=taxservice value="$form->{taxservice}">
622 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
625 foreach $item (split / /, $form->{taxaccounts}) {
627 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
628 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
631 $lxdebug->leave_sub();
635 $lxdebug->enter_sub();
637 $form->{invtotal} = $form->{invsubtotal};
639 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
642 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
645 $rows = ($rows > $introws) ? $rows : $introws;
647 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
649 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
651 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
654 if ($form->{taxaccounts}) {
656 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
657 . $locale->text('Tax Included') . qq|</b><br><br>
661 if (!$form->{taxincluded}) {
663 foreach $item (split / /, $form->{taxaccounts}) {
664 if ($form->{"${item}_base"}) {
665 $form->{invtotal} += $form->{"${item}_total"} =
667 $form->{"${item}_base"} * $form->{"${item}_rate"},
669 $form->{"${item}_total"} =
670 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
674 <th align=right>$form->{"${item}_description"}</th>
675 <td align=right>$form->{"${item}_total"}</td>
681 $form->{invsubtotal} =
682 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
686 <th align=right>| . $locale->text('Subtotal') . qq|</th>
687 <td align=right>$form->{invsubtotal}</td>
693 if ($form->{taxincluded}) {
694 foreach $item (split / /, $form->{taxaccounts}) {
695 if ($form->{"${item}_base"}) {
696 $form->{"${item}_total"} =
698 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
699 (1 + $form->{"${item}_rate"})
702 $form->{"${item}_netto"} =
704 ($form->{"${item}_base"} - $form->{"${item}_total"}),
706 $form->{"${item}_total"} =
707 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
708 $form->{"${item}_netto"} =
709 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
713 <th align=right>Enthaltene $form->{"${item}_description"}</th>
714 <td align=right>$form->{"${item}_total"}</td>
717 <th align=right>Nettobetrag</th>
718 <td align=right>$form->{"${item}_netto"}</td>
726 $form->{oldinvtotal} = $form->{invtotal};
728 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
738 <th align=left>| . $locale->text('Notes') . qq|</th>
739 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
747 <td align=right width=100%>
753 <th align=right>| . $locale->text('Total') . qq|</th>
754 <td align=right>$form->{invtotal}</td>
762 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
763 <input type=hidden name=oldtotalpaid value=$totalpaid>
765 <td><hr size=3 noshade></td>
773 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
776 <td align=left width=30%><b>Dateiname</b></td>
777 <td align=left width=70%><b>Webdavlink</b></td>
779 foreach $file (keys %{ $form->{WEBDAV} }) {
782 <td align=left>$file</td>
783 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
791 <td><hr size=3 noshade></td>
798 <input type=hidden name=jscalendar value=$form->{jscalendar}>
811 Bearbeiten des $form->{heading}<br>
812 <input class=submit type=submit name=action value="|
813 . $locale->text('Update') . qq|">
814 <input class=submit type=submit name=action value="|
815 . $locale->text('Ship to') . qq|">
816 <input class=submit type=submit name=action value="|
817 . $locale->text('Print') . qq|">
818 <input class=submit type=submit name=action value="|
819 . $locale->text('E-mail') . qq|">
820 <input class=submit type=submit name=action value="|
821 . $locale->text('Save') . qq|">
826 <br>Workflow $form->{heading}<br>
827 <input class=submit type=submit name=action value="|
828 . $locale->text('Save as new') . qq|">
829 <input class=submit type=submit name=action value="|
830 . $locale->text('Delete') . qq|">|;
831 if ($form->{type} =~ /quotation$/) {
833 <input class=submit type=submit name=action value="|
834 . $locale->text('Order') . qq|">|;
837 <input class=submit type=submit name=action value="|
838 . $locale->text('Invoice') . qq|">
841 if ($form->{type} =~ /sales_order$/) {
843 <br>$form->{heading} als neue Vorlage verwenden für<br>
844 <input class=submit type=submit name=action value="|
845 . $locale->text('Purchase Order') . qq|">
846 <input class=submit type=submit name=action value="|
847 . $locale->text('Quotation') . qq|">
850 } elsif ($form->{type} =~ /purchase_order$/) {
852 <br>$form->{heading} als neue Vorlage verwenden für<br>
853 <input class=submit type=submit name=action value="|
854 . $locale->text('Sales Order') . qq|">
855 <input class=submit type=submit name=action value="|
856 . $locale->text('Quotation') . qq|">
861 <br>$form->{heading} als neue Vorlage verwenden für<br>
862 <input class=submit type=submit name=action value="|
863 . $locale->text('Order') . qq|">
866 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount}) {
868 <br>Workflow $form->{heading}<br>
869 <input class=submit type=submit name=action value="|
870 . $locale->text('Save as new') . qq|">
871 <input class=submit type=submit name=action value="|
872 . $locale->text('Invoice') . qq|">
877 if ($form->{menubar}) {
878 require "$form->{path}/menu.pl";
884 <input type=hidden name=rowcount value=$form->{rowcount}>
886 <input name=callback type=hidden value="$form->{callback}">
888 <input type=hidden name=path value=$form->{path}>
889 <input type=hidden name=login value=$form->{login}>
890 <input type=hidden name=password value=$form->{password}>
897 $lxdebug->leave_sub();
901 $lxdebug->enter_sub();
903 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
904 qw(exchangerate creditlimit creditremaining);
906 &check_name($form->{vc});
911 $buysell = 'sell' if ($form->{vc} eq 'vendor');
912 $form->{exchangerate} = $exchangerate
916 $form->check_exchangerate(
917 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
921 $i = $form->{rowcount};
923 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
925 if ( ($form->{"partnumber_$i"} eq "")
926 && ($form->{"description_$i"} eq "")
927 && ($form->{"partsgroup_$i"} eq "")) {
929 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
934 if ( $form->{type} eq 'purchase_order'
935 || $form->{type} eq 'request_quotation') {
936 IR->retrieve_item(\%myconfig, \%$form);
938 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
939 IS->retrieve_item(\%myconfig, \%$form);
942 my $rows = scalar @{ $form->{item_list} };
944 $form->{"discount_$i"} =
945 $form->format_amount(\%myconfig, $form->{discount} * 100);
948 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
957 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
959 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
960 qw(partnumber description unit);
961 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
962 keys %{ $form->{item_list}[0] };
964 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
966 ($dec) = ($s =~ /\.(\d+)/);
968 $decimalplaces = ($dec > 2) ? $dec : 2;
971 $form->{"sellprice_$i"} = $sellprice;
974 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
975 # if there is an exchange rate adjust sellprice
976 $form->{"sellprice_$i"} /= $exchangerate;
980 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
981 (1 - $form->{"discount_$i"} / 100);
982 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
983 map { $form->{"${_}_base"} += $amount }
984 (split / /, $form->{"taxaccounts_$i"});
985 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
986 split / /, $form->{taxaccounts}
987 if !$form->{taxincluded};
989 $form->{creditremaining} -= $amount;
991 $form->{"sellprice_$i"} =
992 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
995 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
997 # get pricegroups for parts
998 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1000 # build up html code for prices_$i
1001 &set_pricegroup($i);
1008 # ok, so this is a new part
1009 # ask if it is a part or service item
1011 if ( $form->{"partsgroup_$i"}
1012 && ($form->{"partsnumber_$i"} eq "")
1013 && ($form->{"description_$i"} eq "")) {
1014 $form->{rowcount}--;
1015 $form->{"discount_$i"} = "";
1019 $form->{"id_$i"} = 0;
1020 $form->{"unit_$i"} = $locale->text('ea');
1029 $lxdebug->leave_sub();
1033 $lxdebug->enter_sub();
1035 if ($form->{type} eq 'purchase_order') {
1036 $form->{title} = $locale->text('Purchase Orders');
1037 $form->{vc} = 'vendor';
1038 $ordlabel = $locale->text('Order Number');
1039 $ordnumber = 'ordnumber';
1040 $employee = $locale->text('Employee');
1042 if ($form->{type} eq 'request_quotation') {
1043 $form->{title} = $locale->text('Request for Quotations');
1044 $form->{vc} = 'vendor';
1045 $ordlabel = $locale->text('RFQ Number');
1046 $ordnumber = 'quonumber';
1047 $employee = $locale->text('Employee');
1049 if ($form->{type} eq 'receive_order') {
1050 $form->{title} = $locale->text('Receive Merchandise');
1051 $form->{vc} = 'vendor';
1052 $ordlabel = $locale->text('Order Number');
1053 $ordnumber = 'ordnumber';
1054 $employee = $locale->text('Employee');
1056 if ($form->{type} eq 'sales_order') {
1057 $form->{title} = $locale->text('Sales Orders');
1058 $form->{vc} = 'customer';
1059 $ordlabel = $locale->text('Order Number');
1060 $ordnumber = 'ordnumber';
1061 $employee = $locale->text('Salesperson');
1063 if ($form->{type} eq 'ship_order') {
1064 $form->{title} = $locale->text('Ship Merchandise');
1065 $form->{vc} = 'customer';
1066 $ordlabel = $locale->text('Order Number');
1067 $ordnumber = 'ordnumber';
1068 $employee = $locale->text('Salesperson');
1072 if ($form->{type} eq 'sales_quotation') {
1073 $form->{title} = $locale->text('Quotations');
1074 $form->{vc} = 'customer';
1075 $ordlabel = $locale->text('Quotation Number');
1076 $ordnumber = 'quonumber';
1077 $employee = $locale->text('Employee');
1080 if ($form->{type} =~ /(ship|receive)_order/) {
1081 OE->get_warehouses(\%myconfig, \%$form);
1084 if (@{ $form->{all_warehouses} }) {
1085 $form->{selectwarehouse} = "<option>\n";
1086 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1089 $form->{selectwarehouse} .=
1090 "<option>$_->{description}--$_->{id}\n"
1091 } (@{ $form->{all_warehouses} });
1095 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1096 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1097 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1104 # setup vendor / customer selection
1105 $form->all_vc(\%myconfig, $form->{vc},
1106 ($form->{vc} eq 'customer') ? "AR" : "AP");
1108 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1109 @{ $form->{"all_$form->{vc}"} };
1111 $vclabel = ucfirst $form->{vc};
1112 $vclabel = $locale->text($vclabel);
1114 # $locale->text('Vendor')
1115 # $locale->text('Customer')
1119 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1120 : qq|<input name=$form->{vc} size=35>|;
1123 if (@{ $form->{all_departments} }) {
1124 $form->{selectdepartment} = "<option>\n";
1127 $form->{selectdepartment} .=
1128 "<option>$_->{description}--$_->{id}\n"
1129 } (@{ $form->{all_departments} });
1134 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1135 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1137 | if $form->{selectdepartment};
1139 if ($form->{type} !~ /(ship_order|receive_order)/) {
1142 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1143 . $locale->text('Open') . qq|</td>
1144 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1145 . $locale->text('Closed') . qq|</td>
1151 <input type=hidden name="open" value=1>
1155 # use JavaScript Calendar or not
1156 $form->{jsscript} = $jscalendar;
1158 if ($form->{jsscript}) {
1160 # with JavaScript Calendar
1162 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1163 <input type=button name=transdatefrom id="trigger3" value=|
1164 . $locale->text('button') . qq|></td>
1167 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1168 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1169 . $locale->text('button') . qq|></td>
1174 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1175 "transdateto", "BL", "trigger4");
1178 # without JavaScript Calendar
1180 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1182 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1190 <form method=post action=$form->{script}>
1194 <th class=listtop>$form->{title}</th>
1196 <tr height="5"></tr>
1201 <th align=right>$vclabel</th>
1202 <td colspan=3>$vc</td>
1207 <th align=right>$ordlabel</th>
1208 <td colspan=3><input name="$ordnumber" size=20></td>
1211 <th align=right>| . $locale->text('From') . qq|</th>
1213 <th align=right>| . $locale->text('Bis') . qq|</th>
1216 <input type=hidden name=sort value=transdate>
1218 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1223 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1224 | . $locale->text('ID') . qq|</td>
1225 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1226 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1227 . $locale->text('Date') . qq|</td>
1228 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1229 . $locale->text('Required by') . qq|</td>
1232 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1233 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1234 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1235 . $locale->text('Ship via') . qq|</td>
1238 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1239 . $locale->text('Amount') . qq|</td>
1240 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1241 . $locale->text('Tax') . qq|</td>
1242 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1243 . $locale->text('Total') . qq|</td>
1246 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1247 . $locale->text('Subtotal') . qq|</td>
1255 <tr><td colspan=4><hr size=3 noshade></td></tr>
1261 <input type=hidden name=nextsub value=orders>
1262 <input type=hidden name=path value=$form->{path}>
1263 <input type=hidden name=login value=$form->{login}>
1264 <input type=hidden name=password value=$form->{password}>
1265 <input type=hidden name=vc value=$form->{vc}>
1266 <input type=hidden name=type value=$form->{type}>
1268 <input class=submit type=submit name=action value="|
1269 . $locale->text('Continue') . qq|">
1276 $lxdebug->leave_sub();
1280 $lxdebug->enter_sub();
1282 # split vendor / customer
1283 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1284 split(/--/, $form->{ $form->{vc} });
1286 OE->transactions(\%myconfig, \%$form);
1288 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1290 $number = $form->escape($form->{$ordnumber});
1291 $name = $form->escape($form->{ $form->{vc} });
1292 $department = $form->escape($form->{department});
1293 $warehouse = $form->escape($form->{warehouse});
1297 "$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";
1299 # construct callback
1300 $number = $form->escape($form->{$ordnumber}, 1);
1301 $name = $form->escape($form->{ $form->{vc} }, 1);
1302 $department = $form->escape($form->{department}, 1);
1303 $warehouse = $form->escape($form->{warehouse}, 1);
1306 "$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";
1309 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1310 "name", "netamount", "tax", "amount",
1311 "curr", "employee", "shipvia", "open",
1314 $form->{l_open} = $form->{l_closed} = "Y"
1315 if ($form->{open} && $form->{closed});
1317 foreach $item (@columns) {
1318 if ($form->{"l_$item"} eq "Y") {
1319 push @column_index, $item;
1321 # add column to href and callback
1322 $callback .= "&l_$item=Y";
1323 $href .= "&l_$item=Y";
1327 # only show checkboxes if gotten here via sales_order form.
1328 if ($form->{type} =~ /sales_order/) {
1329 unshift @column_index, "ids";
1332 if ($form->{l_subtotal} eq 'Y') {
1333 $callback .= "&l_subtotal=Y";
1334 $href .= "&l_subtotal=Y";
1337 if ($form->{vc} eq 'vendor') {
1338 if ($form->{type} eq 'receive_order') {
1339 $form->{title} = $locale->text('Receive Merchandise');
1340 } elsif ($form->{type} eq 'purchase_order') {
1341 $form->{title} = $locale->text('Purchase Orders');
1343 $form->{title} = $locale->text('Request for Quotations');
1345 $name = $locale->text('Vendor');
1346 $employee = $locale->text('Employee');
1348 if ($form->{vc} eq 'customer') {
1349 if ($form->{type} eq 'sales_order') {
1350 $form->{title} = $locale->text('Sales Orders');
1351 $employee = $locale->text('Salesperson');
1352 } elsif ($form->{type} eq 'ship_order') {
1353 $form->{title} = $locale->text('Ship Merchandise');
1354 $employee = $locale->text('Salesperson');
1356 $form->{title} = $locale->text('Quotations');
1357 $employee = $locale->text('Employee');
1359 $name = $locale->text('Customer');
1362 $column_header{id} =
1363 qq|<th><a class=listheading href=$href&sort=id>|
1364 . $locale->text('ID')
1366 $column_header{transdate} =
1367 qq|<th><a class=listheading href=$href&sort=transdate>|
1368 . $locale->text('Date')
1370 $column_header{reqdate} =
1371 qq|<th><a class=listheading href=$href&sort=reqdate>|
1372 . $locale->text('Required by')
1374 $column_header{ordnumber} =
1375 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1376 . $locale->text('Order')
1378 $column_header{quonumber} =
1379 qq|<th><a class=listheading href=$href&sort=quonumber>|
1380 . $locale->text('Quotation')
1382 $column_header{name} =
1383 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1384 $column_header{netamount} =
1385 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1386 $column_header{tax} =
1387 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1388 $column_header{amount} =
1389 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1390 $column_header{curr} =
1391 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1392 $column_header{shipvia} =
1393 qq|<th><a class=listheading href=$href&sort=shipvia>|
1394 . $locale->text('Ship via')
1396 $column_header{open} =
1397 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1398 $column_header{closed} =
1399 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1401 $column_header{employee} =
1402 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1404 $column_header{ids} = qq|<th></th>|;
1406 if ($form->{ $form->{vc} }) {
1407 $option = $locale->text(ucfirst $form->{vc});
1408 $option .= " : $form->{$form->{vc}}";
1410 if ($form->{warehouse}) {
1411 ($warehouse) = split /--/, $form->{warehouse};
1412 $option .= "\n<br>" if ($option);
1413 $option .= $locale->text('Warehouse');
1414 $option .= " : $warehouse";
1416 if ($form->{department}) {
1417 $option .= "\n<br>" if ($option);
1418 ($department) = split /--/, $form->{department};
1419 $option .= $locale->text('Department') . " : $department";
1421 if ($form->{transdatefrom}) {
1423 . $locale->text('From') . " "
1424 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1426 if ($form->{transdateto}) {
1428 . $locale->text('Bis') . " "
1429 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1431 if ($form->{open}) {
1432 $option .= "\n<br>" if ($option);
1433 $option .= $locale->text('Open');
1435 if ($form->{closed}) {
1436 $option .= "\n<br>" if ($option);
1437 $option .= $locale->text('Closed');
1445 <form method="post" action="oe.pl">
1448 <th class=listtop>$form->{title}</th>
1450 <tr height="5"></tr>
1457 <tr class=listheading>|;
1459 map { print "\n$column_header{$_}" } @column_index;
1465 # add sort and escape callback
1466 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1468 if (@{ $form->{OE} }) {
1469 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1473 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1475 $warehouse = $form->escape($form->{warehouse});
1477 foreach $oe (@{ $form->{OE} }) {
1478 $form->{rowcount} = ++$j;
1480 if ($form->{l_subtotal} eq 'Y') {
1481 if ($sameitem ne $oe->{ $form->{sort} }) {
1483 $sameitem = $oe->{ $form->{sort} };
1487 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1489 $column_data{netamount} =
1491 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1493 $column_data{tax} = "<td align=right>"
1494 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1497 $column_data{amount} =
1499 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1501 $totalnetamount += $oe->{netamount};
1502 $totalamount += $oe->{amount};
1504 $subtotalnetamount += $oe->{netamount};
1505 $subtotalamount += $oe->{amount};
1507 $column_data{ids} = qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1508 $column_data{id} = "<td>$oe->{id}</td>";
1509 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1510 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1512 $column_data{$ordnumber} =
1513 "<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>";
1514 $column_data{name} = "<td>$oe->{name}</td>";
1516 $column_data{employee} = "<td>$oe->{employee} </td>";
1517 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1519 if ($oe->{closed}) {
1520 $column_data{closed} = "<td align=center>X</td>";
1521 $column_data{open} = "<td> </td>";
1523 $column_data{closed} = "<td> </td>";
1524 $column_data{open} = "<td align=center>X</td>";
1530 <tr class=listrow$i>";
1532 map { print "\n$column_data{$_}" } @column_index;
1540 if ($form->{l_subtotal} eq 'Y') {
1546 <tr class=listtotal>|;
1548 map { $column_data{$_} = "<td> </td>" } @column_index;
1550 $column_data{netamount} =
1551 "<th class=listtotal align=right>"
1552 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1553 $column_data{tax} = "<th class=listtotal align=right>"
1554 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1557 $column_data{amount} =
1558 "<th class=listtotal align=right>"
1559 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1561 map { print "\n$column_data{$_}" } @column_index;
1569 <td><hr size=3 noshade></td>
1573 # multiple invoice edit button only if gotten there via sales_order form.
1575 if ($form->{type} =~ /sales_order/) {
1577 <input type="hidden" name="path" value="$form->{path}">
1578 <input class"submit" type="submit" name="action" value="|
1579 . $locale->text('Continue') .qq|">
1580 <input type="hidden" name="nextsub" value="edit">
1581 <input type="hidden" name="type" value="$form->{type}">
1582 <input type="hidden" name="warehouse" value="$warehouse">
1583 <input type="hidden" name="vc" value="$form->{vc}">
1584 <input type="hidden" name="login" value="$form->{login}">
1585 <input type="hidden" name="password" value="$form->{password}">
1586 <input type="hidden" name="callback" value="$callback">
1587 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1594 <form method=post action=$form->{script}>
1596 <input name=callback type=hidden value="$form->{callback}">
1598 <input type=hidden name=type value=$form->{type}>
1599 <input type=hidden name=vc value=$form->{vc}>
1601 <input type=hidden name=path value=$form->{path}>
1602 <input type=hidden name=login value=$form->{login}>
1603 <input type=hidden name=password value=$form->{password}>
1606 if ($form->{type} !~ /(ship|receive)_order/) {
1608 <input class=submit type=submit name=action value="|
1609 . $locale->text('Add') . qq|">|;
1612 if ($form->{menubar}) {
1613 require "$form->{path}/menu.pl";
1624 $lxdebug->leave_sub();
1628 $lxdebug->enter_sub();
1630 map { $column_data{$_} = "<td> </td>" } @column_index;
1632 $column_data{netamount} =
1633 "<th class=listsubtotal align=right>"
1634 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1636 $column_data{tax} = "<td class=listsubtotal align=right>"
1637 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1640 $column_data{amount} =
1641 "<th class=listsubtotal align=right>"
1642 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1644 $subtotalnetamount = 0;
1645 $subtotalamount = 0;
1648 <tr class=listsubtotal>
1651 map { print "\n$column_data{$_}" } @column_index;
1657 $lxdebug->leave_sub();
1661 $lxdebug->enter_sub();
1663 if ($form->{type} =~ /_order$/) {
1664 $form->isblank("transdate", $locale->text('Order Date missing!'));
1666 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1669 $msg = ucfirst $form->{vc};
1670 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1672 # $locale->text('Customer missing!');
1673 # $locale->text('Vendor missing!');
1675 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1676 if ($form->{currency} ne $form->{defaultcurrency});
1680 # if the name changed get new values
1681 if (&check_name($form->{vc})) {
1686 $form->{id} = 0 if $form->{saveasnew};
1688 # this is for the internal notes section for the [email] Subject
1689 if ($form->{type} =~ /_order$/) {
1690 if ($form->{type} eq 'sales_order') {
1691 $form->{label} = $locale->text('Sales Order');
1693 $numberfld = "sonumber";
1694 $ordnumber = "ordnumber";
1696 $form->{label} = $locale->text('Purchase Order');
1698 $numberfld = "ponumber";
1699 $ordnumber = "ordnumber";
1702 $err = $locale->text('Cannot save order!');
1705 if ($form->{type} eq 'sales_quotation') {
1706 $form->{label} = $locale->text('Quotation');
1708 $numberfld = "sqnumber";
1709 $ordnumber = "quonumber";
1711 $form->{label} = $locale->text('Request for Quotation');
1713 $numberfld = "rfqnumber";
1714 $ordnumber = "quonumber";
1717 $err = $locale->text('Cannot save quotation!');
1721 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
1722 unless $form->{$ordnumber};
1725 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1726 if (OE->save(\%myconfig, \%$form));
1729 $lxdebug->leave_sub();
1733 $lxdebug->enter_sub();
1737 if ($form->{type} =~ /_order$/) {
1738 $msg = $locale->text('Are you sure you want to delete Order Number');
1739 $ordnumber = 'ordnumber';
1741 $msg = $locale->text('Are you sure you want to delete Quotation Number');
1742 $ordnumber = 'quonumber';
1748 <form method=post action=$form->{script}>
1751 # delete action variable
1752 map { delete $form->{$_} } qw(action header);
1754 foreach $key (keys %$form) {
1755 $form->{$key} =~ s/\"/"/g;
1756 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1760 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1762 <h4>$msg $form->{$ordnumber}</h4>
1764 <input name=action class=submit type=submit value="|
1765 . $locale->text('Yes') . qq|">
1772 $lxdebug->leave_sub();
1776 $lxdebug->enter_sub();
1778 if ($form->{type} =~ /_order$/) {
1779 $msg = $locale->text('Order deleted!');
1780 $err = $locale->text('Cannot delete order!');
1782 $msg = $locale->text('Quotation deleted!');
1783 $err = $locale->text('Cannot delete quotation!');
1786 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
1789 $lxdebug->leave_sub();
1793 $lxdebug->enter_sub();
1795 if ($form->{type} =~ /_order$/) {
1796 # these checks only apply if the items don't bring their own ordnumbers/transdates.
1797 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
1798 $form->isblank("ordnumber", $locale->text('Order Number missing!')) if ( +{ map { $form->{"ordnumber_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} );
1799 $form->isblank("transdate", $locale->text('Order Date missing!')) if ( +{ map { $form->{"transdate_$_"}, 1 } ( 1 .. $form->{rowcount}-1 ) }->{''} );
1802 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
1803 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1804 $form->{ordnumber} = "";
1807 # if the name changed get new values
1808 if (&check_name($form->{vc})) {
1813 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1814 $form->{cp_id} *= 1;
1816 if ( $form->{type} =~ /_order/
1817 && $form->{currency} ne $form->{defaultcurrency}) {
1819 # check if we need a new exchangerate
1820 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
1822 $orddate = $form->current_date(\%myconfig);
1824 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
1827 if (!$exchangerate) {
1828 &backorder_exchangerate($orddate, $buysell);
1833 # close orders/quotations
1834 $form->{closed} = 1;
1836 # save order if one ordnumber has been given
1837 # if not it's most likely a collective order, which can't be saved back
1838 # so they just have to be closed
1839 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
1840 OE->save(\%myconfig, \%$form);
1842 OE->close_orders(\%myconfig, \%$form);
1845 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1847 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1850 $form->{closed} = 0;
1851 $form->{rowcount}--;
1852 $form->{shipto} = 1;
1854 if ($form->{type} =~ /_order$/) {
1855 $form->{exchangerate} = $exchangerate;
1859 if ( $form->{type} eq 'purchase_order'
1860 || $form->{type} eq 'request_quotation') {
1861 $form->{title} = $locale->text('Add Vendor Invoice');
1862 $form->{script} = 'ir.pl';
1866 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1867 $form->{title} = $locale->text('Add Sales Invoice');
1868 $form->{script} = 'is.pl';
1873 # bo creates the id, reset it
1874 map { delete $form->{$_} }
1875 qw(id subject message cc bcc printed emailed queued);
1876 $form->{ $form->{vc} } =~ s/--.*//g;
1877 $form->{type} = "invoice";
1880 $locale = new Locale "$myconfig{countrycode}", "$script";
1882 require "$form->{path}/$form->{script}";
1884 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1886 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1887 qw(creditlimit creditremaining);
1889 $currency = $form->{currency};
1892 $form->{currency} = $currency;
1893 $form->{exchangerate} = "";
1894 $form->{forex} = "";
1895 $form->{exchangerate} = $exchangerate
1899 $form->check_exchangerate(
1900 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
1903 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1908 for $i (1 .. $form->{rowcount}) {
1909 $form->{"discount_$i"} =
1910 $form->format_amount(\%myconfig, $form->{"discount_$i"});
1912 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
1914 $decimalplaces = ($dec > 2) ? $dec : 2;
1916 $form->{"sellprice_$i"} =
1917 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1920 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
1921 $dec_qty = length $dec_qty;
1922 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1924 map { $form->{"${_}_$i"} =~ s/\"/"/g }
1925 qw(partnumber description unit);
1931 $lxdebug->leave_sub();
1934 sub backorder_exchangerate {
1935 $lxdebug->enter_sub();
1936 my ($orddate, $buysell) = @_;
1943 <form method=post action=$form->{script}>
1946 # delete action variable
1947 map { delete $form->{$_} } qw(action header exchangerate);
1949 foreach $key (keys %$form) {
1950 $form->{$key} =~ s/\"/"/g;
1951 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1954 $form->{title} = $locale->text('Add Exchangerate');
1958 <input type=hidden name=path value=$form->{path}>
1959 <input type=hidden name=login value=$form->{login}>
1960 <input type=hidden name=password value=$form->{password}>
1962 <input type=hidden name=exchangeratedate value=$orddate>
1963 <input type=hidden name=buysell value=$buysell>
1966 <tr><th class=listtop>$form->{title}</th></tr>
1967 <tr height="5"></tr>
1972 <th align=right>| . $locale->text('Currency') . qq|</th>
1973 <td>$form->{currency}</td>
1976 <th align=right>| . $locale->text('Date') . qq|</th>
1980 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
1981 <td><input name=exchangerate size=11></td>
1991 <input type=hidden name=nextsub value=save_exchangerate>
1993 <input name=action class=submit type=submit value="|
1994 . $locale->text('Continue') . qq|">
2002 $lxdebug->leave_sub();
2005 sub save_exchangerate {
2006 $lxdebug->enter_sub();
2008 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2009 $form->{exchangerate} =
2010 $form->parse_amount(\%myconfig, $form->{exchangerate});
2011 $form->save_exchangerate(\%myconfig, $form->{currency},
2012 $form->{exchangeratedate},
2013 $form->{exchangerate}, $form->{buysell});
2017 $lxdebug->leave_sub();
2020 sub create_backorder {
2021 $lxdebug->enter_sub();
2023 $form->{shipped} = 1;
2025 # figure out if we need to create a backorder
2026 # items aren't saved if qty != 0
2028 for $i (1 .. $form->{rowcount}) {
2029 $totalqty += $qty = $form->{"qty_$i"};
2030 $totalship += $ship = $form->{"ship_$i"};
2032 $form->{"qty_$i"} = $qty - $ship;
2035 if ($totalship == 0) {
2036 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2037 $form->{ordtotal} = 0;
2038 $form->{shipped} = 0;
2042 if ($totalqty == $totalship) {
2043 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2044 $form->{ordtotal} = 0;
2049 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2052 for $i (1 .. $form->{rowcount}) {
2054 $form->{"${_}_$i"} =
2055 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2056 } qw(sellprice discount);
2059 OE->save(\%myconfig, \%$form);
2061 # rebuild rows for invoice
2065 for $i (1 .. $form->{rowcount}) {
2066 $form->{"qty_$i"} = $form->{"ship_$i"};
2068 if ($form->{"qty_$i"}) {
2071 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2076 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2077 $form->{rowcount} = $count;
2079 $lxdebug->leave_sub();
2083 $lxdebug->enter_sub();
2085 $form->{saveasnew} = 1;
2086 $form->{closed} = 0;
2087 map { delete $form->{$_} } qw(printed emailed queued);
2091 $lxdebug->leave_sub();
2094 sub purchase_order {
2095 $lxdebug->enter_sub();
2097 $form->{title} = $locale->text('Add Purchase Order');
2098 $form->{vc} = "vendor";
2099 $form->{type} = "purchase_order";
2103 $lxdebug->leave_sub();
2107 $lxdebug->enter_sub();
2109 if ( $form->{type} eq 'sales_quotation'
2110 || $form->{type} eq 'request_quotation') {
2111 $form->{closed} = 1;
2112 OE->save(\%myconfig, \%$form);
2115 ($null, $form->{cp_id}) = split /--/, $form->{contact};
2116 $form->{cp_id} *= 1;
2118 $form->{title} = $locale->text('Add Sales Order');
2119 $form->{vc} = "customer";
2120 $form->{type} = "sales_order";
2124 $lxdebug->leave_sub();
2128 $lxdebug->enter_sub();
2130 $form->{transdate} = $form->current_date(\%myconfig);
2131 delete $form->{duedate};
2133 $form->{closed} = 0;
2136 map { delete $form->{$_} }
2137 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2144 for $i (1 .. $form->{rowcount} - 1) {
2145 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2146 qw(partnumber description unit);
2149 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2150 qw(creditlimit creditremaining);
2154 $lxdebug->leave_sub();
2158 $lxdebug->enter_sub();
2164 OE->get_warehouses(\%myconfig, \%$form);
2167 if (@{ $form->{all_warehouses} }) {
2168 $form->{selectwarehouse} = "<option>\n";
2170 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2171 (@{ $form->{all_warehouses} });
2173 if ($form->{warehouse}) {
2174 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2178 $form->{shippingdate} = $form->current_date(\%myconfig);
2179 $form->{"$form->{vc}"} =~ s/--.*//;
2184 foreach $key (keys %$form) {
2185 if ($key =~ /_1$/) {
2191 for $i (1 .. $form->{rowcount}) {
2193 # undo formatting from prepare_order
2195 $form->{"${_}_$i"} =
2196 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2198 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2200 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2201 $form->{"ship_$i"} = "";
2202 $form->{"serialnumber_$i"} = "";
2207 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2212 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2213 $form->{rowcount} = $count;
2215 &display_ship_receive;
2217 $lxdebug->leave_sub();
2220 sub display_ship_receive {
2221 $lxdebug->enter_sub();
2223 $vclabel = ucfirst $form->{vc};
2224 $vclabel = $locale->text($vclabel);
2226 $form->{rowcount}++;
2228 if ($form->{vc} eq 'customer') {
2229 $form->{title} = $locale->text('Ship Merchandise');
2230 $shipped = $locale->text('Shipping Date');
2232 $form->{title} = $locale->text('Receive Merchandise');
2233 $shipped = $locale->text('Date Received');
2236 # set option selected
2237 foreach $item (warehouse, employee) {
2238 $form->{"select$item"} =~ s/ selected//;
2239 $form->{"select$item"} =~
2240 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2245 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2246 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2247 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2249 | if $form->{selectwarehouse};
2253 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2254 <td><select name=employee>$form->{selectemployee}</select></td>
2255 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2264 <form method=post action=$form->{script}>
2266 <input type=hidden name=id value=$form->{id}>
2268 <input type=hidden name=display_form value=display_ship_receive>
2270 <input type=hidden name=type value=$form->{type}>
2271 <input type=hidden name=media value=$form->{media}>
2272 <input type=hidden name=format value=$form->{format}>
2274 <input type=hidden name=queued value="$form->{queued}">
2275 <input type=hidden name=printed value="$form->{printed}">
2276 <input type=hidden name=emailed value="$form->{emailed}">
2278 <input type=hidden name=vc value=$form->{vc}>
2282 <th class=listtop>$form->{title}</th>
2284 <tr height="5"></tr>
2287 <table width="100%">
2292 <th align=right>$vclabel</th>
2293 <td colspan=3>$form->{$form->{vc}}</td>
2294 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2295 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2299 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2301 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2304 <th align=right>| . $locale->text('Ship via') . qq|</th>
2306 <input name=shipvia size=35 value="$form->{shipvia}">
2315 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2316 <td>$form->{ordnumber}</td>
2317 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2320 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2321 <td>$form->{transdate}</td>
2322 <input type=hidden name=transdate value=$form->{transdate}>
2325 <th align=right nowrap>$shipped</th>
2326 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2335 <!-- shipto are in hidden variables -->
2337 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2338 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2339 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2340 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2341 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2342 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2343 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2344 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2345 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2347 <!-- email variables -->
2348 <input type=hidden name=message value="$form->{message}">
2349 <input type=hidden name=email value="$form->{email}">
2350 <input type=hidden name=subject value="$form->{subject}">
2351 <input type=hidden name=cc value="$form->{cc}">
2352 <input type=hidden name=bcc value="$form->{bcc}">
2357 (partnumber, description, qty, ship, unit, bin, serialnumber);
2359 if ($form->{type} eq "ship_order") {
2360 $column_data{ship} =
2361 qq|<th class=listheading align=center width="auto">|
2362 . $locale->text('Ship')
2365 if ($form->{type} eq "receive_order") {
2366 $column_data{ship} =
2367 qq|<th class=listheading align=center width="auto">|
2368 . $locale->text('Recd')
2372 my $colspan = $#column_index + 1;
2374 $column_data{partnumber} =
2375 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2376 $column_data{description} =
2377 qq|<th class=listheading nowrap>|
2378 . $locale->text('Description')
2381 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2382 $column_data{unit} =
2383 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2385 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2386 $column_data{serialnumber} =
2387 qq|<th class=listheading nowrap>|
2388 . $locale->text('Serial No.')
2395 <tr class=listheading>|;
2397 map { print "\n$column_data{$_}" } @column_index;
2403 for $i (1 .. $form->{rowcount} - 1) {
2406 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2408 # convert " to "
2409 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2410 qw(partnumber description unit bin serialnumber);
2412 $description = $form->{"description_$i"};
2413 $description =~ s/\n/<br>/g;
2415 $column_data{partnumber} =
2416 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2417 $column_data{description} =
2418 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2420 qq|<td align=right>|
2421 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2422 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2423 $column_data{ship} =
2424 qq|<td align=right><input name="ship_$i" size=5 value=|
2425 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2427 $column_data{unit} =
2428 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2430 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2432 $column_data{serialnumber} =
2433 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2438 map { print "\n$column_data{$_}" } @column_index;
2443 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2444 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2445 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2446 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2457 <td><hr size=3 noshade></td>
2463 $form->{copies} = 1;
2472 <input class=submit type=submit name=action value="|
2473 . $locale->text('Update') . qq|">
2474 <input class=submit type=submit name=action value="|
2475 . $locale->text('Print') . qq|">
2478 if ($form->{type} eq 'ship_order') {
2480 <input class=submit type=submit name=action value="|
2481 . $locale->text('Ship to') . qq|">
2482 <input class=submit type=submit name=action value="|
2483 . $locale->text('E-mail') . qq|">
2489 <input class=submit type=submit name=action value="|
2490 . $locale->text('Done') . qq|">
2493 if ($form->{menubar}) {
2494 require "$form->{path}/menu.pl";
2500 <input type=hidden name=rowcount value=$form->{rowcount}>
2502 <input name=callback type=hidden value="$callback">
2504 <input type=hidden name=path value=$form->{path}>
2505 <input type=hidden name=login value=$form->{login}>
2506 <input type=hidden name=password value=$form->{password}>
2514 $lxdebug->leave_sub();
2518 $lxdebug->enter_sub();
2520 if ($form->{type} eq 'ship_order') {
2521 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2523 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2528 $total += $form->{"ship_$_"} =
2529 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2530 } (1 .. $form->{rowcount} - 1);
2532 $form->error($locale->text('Nothing entered!')) unless $total;
2534 $form->redirect($locale->text('Inventory saved!'))
2535 if OE->save_inventory(\%myconfig, \%$form);
2536 $form->error($locale->text('Could not save!'));
2538 $lxdebug->leave_sub();
2541 sub search_transfer {
2542 $lxdebug->enter_sub();
2544 OE->get_warehouses(\%myconfig, \%$form);
2547 if (@{ $form->{all_warehouses} }) {
2548 $form->{selectwarehouse} = "<option>\n";
2549 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2551 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2552 (@{ $form->{all_warehouses} });
2554 $form->error($locale->text('Nothing to transfer!'));
2557 $form->{title} = $locale->text('Transfer Inventory');
2564 <form method=post action=$form->{script}>
2568 <th class=listtop>$form->{title}</th>
2570 <tr height="5"></tr>
2575 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2576 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2579 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2580 <td><input name=partnumber size=20></td>
2583 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2584 <td><input name=description size=40></td>
2587 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2588 <td><input name=partsgroup size=20></td>
2594 <td><hr size=3 noshade></td>
2599 <input type=hidden name=sort value=partnumber>
2600 <input type=hidden name=nextsub value=list_transfer>
2602 <input type=hidden name=path value=$form->{path}>
2603 <input type=hidden name=login value=$form->{login}>
2604 <input type=hidden name=password value=$form->{password}>
2606 <input class=submit type=submit name=action value="|
2607 . $locale->text('Continue') . qq|">
2614 $lxdebug->leave_sub();
2618 $lxdebug->enter_sub();
2620 OE->get_inventory(\%myconfig, \%$form);
2622 $partnumber = $form->escape($form->{partnumber});
2623 $warehouse = $form->escape($form->{warehouse});
2624 $description = $form->escape($form->{description});
2625 $partsgroup = $form->escape($form->{partsgroup});
2629 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2631 # construct callback
2632 $partnumber = $form->escape($form->{partnumber}, 1);
2633 $warehouse = $form->escape($form->{warehouse}, 1);
2634 $description = $form->escape($form->{description}, 1);
2635 $partsgroup = $form->escape($form->{partsgroup}, 1);
2638 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2641 $form->sort_columns(
2642 qw(partnumber description partsgroup make model warehouse qty transfer));
2644 $column_header{partnumber} =
2645 qq|<th><a class=listheading href=$href&sort=partnumber>|
2646 . $locale->text('Part Number')
2648 $column_header{description} =
2649 qq|<th><a class=listheading href=$href&sort=description>|
2650 . $locale->text('Description')
2652 $column_header{partsgroup} =
2653 qq|<th><a class=listheading href=$href&sort=partsgroup>|
2654 . $locale->text('Group')
2656 $column_header{warehouse} =
2657 qq|<th><a class=listheading href=$href&sort=warehouse>|
2658 . $locale->text('From')
2660 $column_header{qty} =
2661 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
2662 $column_header{transfer} =
2663 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
2665 $option = $locale->text('Transfer to');
2667 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
2669 if ($form->{warehouse}) {
2670 $option .= " : $warehouse";
2672 if ($form->{partnumber}) {
2673 $option .= "\n<br>" if ($option);
2674 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
2676 if ($form->{description}) {
2677 $option .= "\n<br>" if ($option);
2678 $option .= $locale->text('Description') . " : $form->{description}";
2680 if ($form->{partsgroup}) {
2681 $option .= "\n<br>" if ($option);
2682 $option .= $locale->text('Group') . " : $form->{partsgroup}";
2685 $form->{title} = $locale->text('Transfer Inventory');
2692 <form method=post action=$form->{script}>
2694 <input type=hidden name=warehouse_id value=$warehouse_id>
2698 <th class=listtop>$form->{title}</th>
2700 <tr height="5"></tr>
2707 <tr class=listheading>|;
2709 map { print "\n$column_header{$_}" } @column_index;
2715 if (@{ $form->{all_inventory} }) {
2716 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
2720 foreach $ref (@{ $form->{all_inventory} }) {
2724 $column_data{partnumber} =
2725 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
2726 $column_data{description} = "<td>$ref->{description} </td>";
2727 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
2728 $column_data{warehouse} =
2729 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
2731 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
2732 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
2734 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
2739 <tr class=listrow$j>";
2741 map { print "\n$column_data{$_}" } @column_index;
2755 <td><hr size=3 noshade></td>
2761 <input name=callback type=hidden value="$callback">
2763 <input type=hidden name=rowcount value=$i>
2765 <input type=hidden name=path value=$form->{path}>
2766 <input type=hidden name=login value=$form->{login}>
2767 <input type=hidden name=password value=$form->{password}>
2769 <input class=submit type=submit name=action value="|
2770 . $locale->text('Transfer') . qq|">|;
2772 if ($form->{menubar}) {
2773 require "$form->{path}/menu.pl";
2784 $lxdebug->leave_sub();
2788 $lxdebug->enter_sub();
2790 $form->redirect($locale->text('Inventory transferred!'))
2791 if OE->transfer(\%myconfig, \%$form);
2792 $form->error($locale->text('Could not transfer Inventory!'));
2794 $lxdebug->leave_sub();