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 #======================================================================
40 require "$form->{path}/io.pl";
41 require "$form->{path}/arap.pl";
48 $lxdebug->enter_sub();
50 if ($form->{type} eq 'purchase_order') {
51 $form->{title} = $locale->text('Add Purchase Order');
52 $form->{vc} = 'vendor';
54 if ($form->{type} eq 'sales_order') {
55 $form->{title} = $locale->text('Add Sales Order');
56 $form->{vc} = 'customer';
58 if ($form->{type} eq 'request_quotation') {
59 $form->{title} = $locale->text('Add Request for Quotation');
60 $form->{vc} = 'vendor';
62 if ($form->{type} eq 'sales_quotation') {
63 $form->{title} = $locale->text('Add Quotation');
64 $form->{vc} = 'customer';
68 "$form->{script}?action=add&type=$form->{type}&vc=$form->{vc}&login=$form->{login}&path=$form->{path}&password=$form->{password}"
69 unless $form->{callback};
75 $lxdebug->leave_sub();
79 $lxdebug->enter_sub();
81 # editing without stuff to edit? try adding it first
82 if ($form->{rowcount}) {
83 map { $id++ if $form->{"id_$_"} } (1 .. $form->{rowcount});
87 undef $form->{rowcount};
98 if ($form->{type} eq 'purchase_order') {
99 $form->{title} = $locale->text('Edit Purchase Order');
100 $form->{heading} = $locale->text('Purchase Order');
101 $form->{vc} = 'vendor';
103 if ($form->{type} eq 'sales_order') {
104 $form->{title} = $locale->text('Edit Sales Order');
105 $form->{heading} = $locale->text('Sales Order');
106 $form->{vc} = 'customer';
108 if ($form->{type} eq 'request_quotation') {
109 $form->{title} = $locale->text('Edit Request for Quotation');
110 $form->{heading} = $locale->text('Request for Quotation');
111 $form->{vc} = 'vendor';
113 if ($form->{type} eq 'sales_quotation') {
114 $form->{title} = $locale->text('Edit Quotation');
115 $form->{heading} = $locale->text('Quotation');
116 $form->{vc} = 'customer';
123 $lxdebug->leave_sub();
127 $lxdebug->enter_sub();
129 # get customer/vendor
130 $form->all_vc(\%myconfig, $form->{vc},
131 ($form->{vc} eq 'customer') ? "AR" : "AP");
133 # retrieve order/quotation
134 $form->{webdav} = $webdav;
137 $form->{jscalendar} = $jscalendar;
139 OE->retrieve(\%myconfig, \%$form);
141 # if multiple rowcounts (== collective order) then check if the
142 # there were more than one customer (in that case OE::retrieve removes
143 # the content from the field)
144 if ( $form->{rowcount}
145 && $form->{type} eq 'sales_order'
146 && defined $form->{customer}
147 && $form->{customer} eq '') {
149 # $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
152 'Collective Orders only work for orders from one customer!')
156 $taxincluded = $form->{taxincluded};
157 $form->{shipto} = 1 if $form->{id};
159 if ($form->{"all_$form->{vc}"}) {
160 unless ($form->{"$form->{vc}_id"}) {
161 $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
165 $cp_id = $form->{cp_id};
166 $intnotes = $form->{intnotes};
168 # get customer / vendor
169 if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/) {
170 IR->get_vendor(\%myconfig, \%$form);
172 #quote all_vendor Bug 133
173 foreach $ref (@{ $form->{all_vendor} }) {
174 $ref->{name} = $form->quote($ref->{name});
178 if ($form->{type} =~ /(sales|ship)_(order|quotation)/) {
179 IS->get_customer(\%myconfig, \%$form);
181 #quote all_vendor Bug 133
182 foreach $ref (@{ $form->{all_customer} }) {
183 $ref->{name} = $form->quote($ref->{name});
187 $form->{cp_id} = $cp_id;
189 $form->{intnotes} = $intnotes;
190 ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
191 $form->{"old$form->{vc}"} =
192 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
194 # build the popup menus
195 if (@{ $form->{"all_$form->{vc}"} }) {
196 $form->{ $form->{vc} } =
197 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
198 map { $form->{"select$form->{vc}"} .= "<option>$_->{name}--$_->{id}\n" }
199 (@{ $form->{"all_$form->{vc}"} });
203 @curr = split /:/, $form->{currencies};
205 $form->{defaultcurrency} = $curr[0];
206 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
208 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
210 $form->{taxincluded} = $taxincluded if ($form->{id});
213 if (@{ $form->{all_departments} }) {
214 $form->{selectdepartment} = "<option>\n";
215 $form->{department} = "$form->{department}--$form->{department_id}";
218 $form->{selectdepartment} .=
219 "<option>$_->{description}--$_->{id}\n"
220 } (@{ $form->{all_departments} });
223 $form->{employee} = "$form->{employee}--$form->{employee_id}";
226 if (@{ $form->{all_employees} }) {
227 $form->{selectemployee} = "";
228 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
229 (@{ $form->{all_employees} });
233 $form->{forex} = $form->{exchangerate};
235 $lxdebug->leave_sub();
239 $lxdebug->enter_sub();
240 $form->{format} = "pdf";
241 $form->{media} = "screen";
242 $form->{formname} = $form->{type};
244 map { $form->{$_} =~ s/\"/"/g }
245 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
247 foreach $ref (@{ $form->{form_details} }) {
248 $form->{rowcount} = ++$i;
250 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
252 for my $i (1 .. $form->{rowcount}) {
254 $form->{"discount_$i"} =
255 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
257 $form->{"discount_$i"} =
258 $form->format_amount(\%myconfig, $form->{"discount_$i"});
260 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
262 $decimalplaces = ($dec > 2) ? $dec : 2;
264 # copy reqdate from deliverydate for invoice -> order conversion
265 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
266 unless $form->{"reqdate_$i"};
268 $form->{"sellprice_$i"} =
269 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
272 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
273 $dec_qty = length $dec_qty;
275 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
277 map { $form->{"${_}_$i"} =~ s/\"/"/g }
278 qw(partnumber description unit);
281 $lxdebug->leave_sub();
285 $lxdebug->enter_sub();
287 $checkedopen = ($form->{closed}) ? "" : "checked";
288 $checkedclosed = ($form->{closed}) ? "checked" : "";
290 # use JavaScript Calendar or not
291 $form->{jsscript} = $form->{jscalendar};
294 if ($form->{jsscript}) {
296 # with JavaScript Calendar
298 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
299 <td><input type=button name=transdate id="trigger1" value=|
300 . $locale->text('button') . qq|></td>
303 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
304 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
305 . $locale->text('button') . qq|></td>
310 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
311 "reqdate", "BL", "trigger2");
315 # without JavaScript Calendar
317 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
319 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
325 <td colspan=2 align=center>
328 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
329 . $locale->text('Open') . qq|</th>
330 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
331 . $locale->text('Closed') . qq|</th>
339 # set option selected
340 foreach $item ($form->{vc}, currency, department, employee, contact) {
341 $form->{"select$item"} =~ s/ selected//;
342 $form->{"select$item"} =~
343 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
346 #quote select[customer|vendor] Bug 133
347 $form->{"select$form->{vc}"} = $form->quote($form->{"select$form->{vc}"});
350 if ($form->{all_contacts}) {
352 $form->{selectcontact} = "";
353 foreach $item (@{ $form->{all_contacts} }) {
354 if ($form->{cp_id} == $item->{cp_id}) {
355 $form->{selectcontact} .=
356 "<option selected>$item->{cp_name}--$item->{cp_id}";
358 $form->{selectcontact} .= "<option>$item->{cp_name}--$item->{cp_id}";
363 $form->{exchangerate} =
364 $form->format_amount(\%myconfig, $form->{exchangerate});
366 $form->{creditlimit} =
367 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
368 $form->{creditremaining} =
369 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
372 ($form->{selectcontact})
373 ? qq|<select name=contact>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
374 : qq|<input name=contact value="$form->{contact}" size=35>|;
377 <input type=hidden name=forex value=$form->{forex}>
380 if ($form->{currency} ne $form->{defaultcurrency}) {
381 if ($form->{forex}) {
384 . $locale->text('Exchangerate')
385 . qq|</th><td>$form->{exchangerate}</td>
386 <input type=hidden name=exchangerate value=$form->{exchangerate}>
391 . $locale->text('Exchangerate')
392 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
396 $vclabel = ucfirst $form->{vc};
397 $vclabel = $locale->text($vclabel);
401 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
402 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
403 . $locale->text('days') . qq|</td>
407 if ($form->{business}) {
410 <th align=right>| . $locale->text('Business') . qq|</th>
411 <td>$form->{business}</td>
412 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
414 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
420 if ($form->{type} !~ /_quotation$/) {
423 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
424 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
427 <th width=70% align=right nowrap>|
428 . $locale->text('Quotation Number') . qq|</th>
429 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
432 <th width=70% align=right nowrap>|
433 . $locale->text('Customer Order Number') . qq|</th>
434 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
437 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
442 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
447 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
449 $creditremaining = qq|
455 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
456 <td>$form->{creditlimit}</td>
458 <th nowrap>| . $locale->text('Remaining') . qq|</th>
459 <td class="plus$n">$form->{creditremaining}</td>
467 ($form->{type} eq 'sales_quotation')
468 ? $locale->text('Valid until')
469 : $locale->text('Required by');
470 if ($form->{type} eq 'sales_quotation') {
473 <th width=70% align=right nowrap>|
474 . $locale->text('Quotation Number') . qq|</th>
475 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
476 <input type=hidden name=ordnumber value="$form->{ordnumber}">
482 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
483 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
484 <input type=hidden name=ordnumber value="$form->{ordnumber}">
493 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
497 <th align=right nowrap=true>$reqlabel</th>
505 ($form->{"select$form->{vc}"})
506 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
507 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
511 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
512 <td colspan=3><select name=department>$form->{selectdepartment}</select>
513 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
516 | if $form->{selectdepartment};
519 <input type=hidden name=employee value="$form->{employee}">
522 if ($form->{type} eq 'sales_order') {
523 if ($form->{selectemployee}) {
525 <input type=hidden name=customer_klass value=$form->{customer_klass}>
527 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
528 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
529 <input type=hidden name=selectemployee value="$form->{selectemployee}">
536 <input type=hidden name=customer_klass value=$form->{customer_klass}>
538 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
539 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
540 <input type=hidden name=selectemployee value="$form->{selectemployee}">
551 <form method=post action=$form->{script}>
553 <input type=hidden name=id value=$form->{id}>
555 <input type=hidden name=type value=$form->{type}>
556 <input type=hidden name=formname value=$form->{formname}>
557 <input type=hidden name=media value=$form->{media}>
558 <input type=hidden name=format value=$form->{format}>
560 <input type=hidden name=queued value="$form->{queued}">
561 <input type=hidden name=printed value="$form->{printed}">
562 <input type=hidden name=emailed value="$form->{emailed}">
564 <input type=hidden name=vc value=$form->{vc}>
566 <input type=hidden name=title value="$form->{title}">
568 <input type=hidden name=discount value=$form->{discount}>
569 <input type=hidden name=creditlimit value=$form->{creditlimit}>
570 <input type=hidden name=creditremaining value=$form->{creditremaining}>
572 <input type=hidden name=tradediscount value=$form->{tradediscount}>
573 <input type=hidden name=business value=$form->{business}>
574 <input type=hidden name=webdav value=$webdav>
578 <th class=listtop>$form->{title}</th>
588 <th align=right>$vclabel</th>
589 <td colspan=3>$vc</td>
590 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
591 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
592 <th align=richt nowrap>|
593 . $locale->text('Contact Person') . qq|</th>
594 <td colspan=3>$contact</td>
600 <th align=right>| . $locale->text('Currency') . qq|</th>
601 <td><select name=currency>$form->{selectcurrency}</select></td>
602 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
603 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
607 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
608 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
611 <th align=right>| . $locale->text('Ship via') . qq|</th>
612 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
631 <!-- shipto are in hidden variables -->
633 <input type=hidden name=shiptoname value="$form->{shiptoname}">
634 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
635 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
636 <input type=hidden name=shiptocity value="$form->{shiptocity}">
637 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
638 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
639 <input type=hidden name=shiptophone value="$form->{shiptophone}">
640 <input type=hidden name=shiptofax value="$form->{shiptofax}">
641 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
643 <!-- email variables -->
644 <input type=hidden name=message value="$form->{message}">
645 <input type=hidden name=email value="$form->{email}">
646 <input type=hidden name=subject value="$form->{subject}">
647 <input type=hidden name=cc value="$form->{cc}">
648 <input type=hidden name=bcc value="$form->{bcc}">
650 <input type=hidden name=taxpart value="$form->{taxpart}">
651 <input type=hidden name=taxservice value="$form->{taxservice}">
653 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
656 foreach $item (split / /, $form->{taxaccounts}) {
658 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
659 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
662 $lxdebug->leave_sub();
666 $lxdebug->enter_sub();
668 $form->{invtotal} = $form->{invsubtotal};
670 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
673 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
676 $rows = ($rows > $introws) ? $rows : $introws;
678 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
680 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
682 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
685 if ($form->{taxaccounts}) {
687 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
688 . $locale->text('Tax Included') . qq|</b><br><br>
692 if (!$form->{taxincluded}) {
694 foreach $item (split / /, $form->{taxaccounts}) {
695 if ($form->{"${item}_base"}) {
696 $form->{invtotal} += $form->{"${item}_total"} =
698 $form->{"${item}_base"} * $form->{"${item}_rate"},
700 $form->{"${item}_total"} =
701 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
705 <th align=right>$form->{"${item}_description"}</th>
706 <td align=right>$form->{"${item}_total"}</td>
712 $form->{invsubtotal} =
713 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
717 <th align=right>| . $locale->text('Subtotal') . qq|</th>
718 <td align=right>$form->{invsubtotal}</td>
724 if ($form->{taxincluded}) {
725 foreach $item (split / /, $form->{taxaccounts}) {
726 if ($form->{"${item}_base"}) {
727 $form->{"${item}_total"} =
729 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
730 (1 + $form->{"${item}_rate"})
733 $form->{"${item}_netto"} =
735 ($form->{"${item}_base"} - $form->{"${item}_total"}),
737 $form->{"${item}_total"} =
738 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
739 $form->{"${item}_netto"} =
740 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
744 <th align=right>Enthaltene $form->{"${item}_description"}</th>
745 <td align=right>$form->{"${item}_total"}</td>
748 <th align=right>Nettobetrag</th>
749 <td align=right>$form->{"${item}_netto"}</td>
757 $form->{oldinvtotal} = $form->{invtotal};
759 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
769 <th align=left>| . $locale->text('Notes') . qq|</th>
770 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
778 <td align=right width=100%>
784 <th align=right>| . $locale->text('Total') . qq|</th>
785 <td align=right>$form->{invtotal}</td>
793 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
794 <input type=hidden name=oldtotalpaid value=$totalpaid>
796 <td><hr size=3 noshade></td>
804 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
807 <td align=left width=30%><b>Dateiname</b></td>
808 <td align=left width=70%><b>Webdavlink</b></td>
810 foreach $file (keys %{ $form->{WEBDAV} }) {
813 <td align=left>$file</td>
814 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
822 <td><hr size=3 noshade></td>
829 <input type=hidden name=jscalendar value=$form->{jscalendar}>
842 Bearbeiten des $form->{heading}<br>
843 <input class=submit type=submit name=action value="|
844 . $locale->text('Update') . qq|">
845 <input class=submit type=submit name=action value="|
846 . $locale->text('Ship to') . qq|">
847 <input class=submit type=submit name=action value="|
848 . $locale->text('Print') . qq|">
849 <input class=submit type=submit name=action value="|
850 . $locale->text('E-mail') . qq|">
851 <input class=submit type=submit name=action value="|
852 . $locale->text('Save') . qq|">
857 <br>Workflow $form->{heading}<br>
858 <input class=submit type=submit name=action value="|
859 . $locale->text('Save as new') . qq|">
860 <input class=submit type=submit name=action value="|
861 . $locale->text('Delete') . qq|">|;
862 if ($form->{type} =~ /sales_quotation$/) {
864 <input class=submit type=submit name=action value="|
865 . $locale->text('Sales Order') . qq|">|;
867 if ($form->{type} =~ /request_quotation$/) {
869 <input class=submit type=submit name=action value="|
870 . $locale->text('Purchase Order') . qq|">|;
873 <input class=submit type=submit name=action value="|
874 . $locale->text('Invoice') . qq|">
877 if ($form->{type} =~ /sales_order$/) {
879 <br>$form->{heading} als neue Vorlage verwenden für<br>
880 <input class=submit type=submit name=action value="|
881 . $locale->text('Purchase Order') . qq|">
882 <input class=submit type=submit name=action value="|
883 . $locale->text('Quotation') . qq|">
886 } elsif ($form->{type} =~ /purchase_order$/) {
888 <br>$form->{heading} als neue Vorlage verwenden für<br>
889 <input class=submit type=submit name=action value="|
890 . $locale->text('Sales Order') . qq|">
891 <input class=submit type=submit name=action value="|
892 . $locale->text('Quotation') . qq|">
897 <br>$form->{heading} als neue Vorlage verwenden für<br>
898 <input class=submit type=submit name=action value="|
899 . $locale->text('Order') . qq|">
902 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount}) {
904 <br>Workflow $form->{heading}<br>
905 <input class=submit type=submit name=action value="|
906 . $locale->text('Save as new') . qq|">
907 <input class=submit type=submit name=action value="|
908 . $locale->text('Invoice') . qq|">
912 if ($form->{menubar}) {
913 require "$form->{path}/menu.pl";
919 <input type=hidden name=rowcount value=$form->{rowcount}>
921 <input name=callback type=hidden value="$form->{callback}">
923 <input type=hidden name=path value=$form->{path}>
924 <input type=hidden name=login value=$form->{login}>
925 <input type=hidden name=password value=$form->{password}>
932 $lxdebug->leave_sub();
936 $lxdebug->enter_sub();
938 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
939 qw(exchangerate creditlimit creditremaining);
941 &check_name($form->{vc});
946 $buysell = 'sell' if ($form->{vc} eq 'vendor');
947 $form->{exchangerate} = $exchangerate
951 $form->check_exchangerate(
952 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
956 $i = $form->{rowcount};
958 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
960 if ( ($form->{"partnumber_$i"} eq "")
961 && ($form->{"description_$i"} eq "")
962 && ($form->{"partsgroup_$i"} eq "")) {
964 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
969 if ( $form->{type} eq 'purchase_order'
970 || $form->{type} eq 'request_quotation') {
971 IR->retrieve_item(\%myconfig, \%$form);
973 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
974 IS->retrieve_item(\%myconfig, \%$form);
977 my $rows = scalar @{ $form->{item_list} };
979 $form->{"discount_$i"} =
980 $form->format_amount(\%myconfig, $form->{discount} * 100);
983 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
992 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
994 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
995 qw(partnumber description unit);
996 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
997 keys %{ $form->{item_list}[0] };
999 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
1001 ($dec) = ($s =~ /\.(\d+)/);
1003 $decimalplaces = ($dec > 2) ? $dec : 2;
1006 $form->{"sellprice_$i"} = $sellprice;
1009 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
1011 # if there is an exchange rate adjust sellprice
1012 $form->{"sellprice_$i"} /= $exchangerate;
1016 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1017 (1 - $form->{"discount_$i"} / 100);
1018 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1019 map { $form->{"${_}_base"} += $amount }
1020 (split / /, $form->{"taxaccounts_$i"});
1021 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1022 split / /, $form->{taxaccounts}
1023 if !$form->{taxincluded};
1025 $form->{creditremaining} -= $amount;
1027 $form->{"sellprice_$i"} =
1028 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1031 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1033 # get pricegroups for parts
1034 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1036 # build up html code for prices_$i
1037 &set_pricegroup($i);
1044 # ok, so this is a new part
1045 # ask if it is a part or service item
1047 if ( $form->{"partsgroup_$i"}
1048 && ($form->{"partsnumber_$i"} eq "")
1049 && ($form->{"description_$i"} eq "")) {
1050 $form->{rowcount}--;
1051 $form->{"discount_$i"} = "";
1055 $form->{"id_$i"} = 0;
1056 $form->{"unit_$i"} = $locale->text('ea');
1064 $lxdebug->leave_sub();
1068 $lxdebug->enter_sub();
1070 if ($form->{type} eq 'purchase_order') {
1071 $form->{title} = $locale->text('Purchase Orders');
1072 $form->{vc} = 'vendor';
1073 $ordlabel = $locale->text('Order Number');
1074 $ordnumber = 'ordnumber';
1075 $employee = $locale->text('Employee');
1077 if ($form->{type} eq 'request_quotation') {
1078 $form->{title} = $locale->text('Request for Quotations');
1079 $form->{vc} = 'vendor';
1080 $ordlabel = $locale->text('RFQ Number');
1081 $ordnumber = 'quonumber';
1082 $employee = $locale->text('Employee');
1084 if ($form->{type} eq 'receive_order') {
1085 $form->{title} = $locale->text('Receive Merchandise');
1086 $form->{vc} = 'vendor';
1087 $ordlabel = $locale->text('Order Number');
1088 $ordnumber = 'ordnumber';
1089 $employee = $locale->text('Employee');
1091 if ($form->{type} eq 'sales_order') {
1092 $form->{title} = $locale->text('Sales Orders');
1093 $form->{vc} = 'customer';
1094 $ordlabel = $locale->text('Order Number');
1095 $ordnumber = 'ordnumber';
1096 $employee = $locale->text('Salesperson');
1098 if ($form->{type} eq 'ship_order') {
1099 $form->{title} = $locale->text('Ship Merchandise');
1100 $form->{vc} = 'customer';
1101 $ordlabel = $locale->text('Order Number');
1102 $ordnumber = 'ordnumber';
1103 $employee = $locale->text('Salesperson');
1107 if ($form->{type} eq 'sales_quotation') {
1108 $form->{title} = $locale->text('Quotations');
1109 $form->{vc} = 'customer';
1110 $ordlabel = $locale->text('Quotation Number');
1111 $ordnumber = 'quonumber';
1112 $employee = $locale->text('Employee');
1115 if ($form->{type} =~ /(ship|receive)_order/) {
1116 OE->get_warehouses(\%myconfig, \%$form);
1119 if (@{ $form->{all_warehouses} }) {
1120 $form->{selectwarehouse} = "<option>\n";
1121 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1124 $form->{selectwarehouse} .=
1125 "<option>$_->{description}--$_->{id}\n"
1126 } (@{ $form->{all_warehouses} });
1130 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1131 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1132 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1139 # setup vendor / customer selection
1140 $form->all_vc(\%myconfig, $form->{vc},
1141 ($form->{vc} eq 'customer') ? "AR" : "AP");
1143 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1144 @{ $form->{"all_$form->{vc}"} };
1146 $vclabel = ucfirst $form->{vc};
1147 $vclabel = $locale->text($vclabel);
1149 # $locale->text('Vendor')
1150 # $locale->text('Customer')
1154 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1155 : qq|<input name=$form->{vc} size=35>|;
1158 if (@{ $form->{all_departments} }) {
1159 $form->{selectdepartment} = "<option>\n";
1162 $form->{selectdepartment} .=
1163 "<option>$_->{description}--$_->{id}\n"
1164 } (@{ $form->{all_departments} });
1169 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1170 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1172 | if $form->{selectdepartment};
1174 if ($form->{type} !~ /(ship_order|receive_order)/) {
1177 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1178 . $locale->text('Open') . qq|</td>
1179 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1180 . $locale->text('Closed') . qq|</td>
1186 <input type=hidden name="open" value=1>
1190 # use JavaScript Calendar or not
1191 $form->{jsscript} = $jscalendar;
1193 if ($form->{jsscript}) {
1195 # with JavaScript Calendar
1197 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1198 <input type=button name=transdatefrom id="trigger3" value=|
1199 . $locale->text('button') . qq|></td>
1202 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1203 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1204 . $locale->text('button') . qq|></td>
1209 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1210 "transdateto", "BL", "trigger4");
1213 # without JavaScript Calendar
1215 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1217 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1225 <form method=post action=$form->{script}>
1229 <th class=listtop>$form->{title}</th>
1231 <tr height="5"></tr>
1236 <th align=right>$vclabel</th>
1237 <td colspan=3>$vc</td>
1242 <th align=right>$ordlabel</th>
1243 <td colspan=3><input name="$ordnumber" size=20></td>
1246 <th align=right>| . $locale->text('From') . qq|</th>
1248 <th align=right>| . $locale->text('Bis') . qq|</th>
1251 <input type=hidden name=sort value=transdate>
1253 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1258 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1259 | . $locale->text('ID') . qq|</td>
1260 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1261 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1262 . $locale->text('Date') . qq|</td>
1263 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1264 . $locale->text('Required by') . qq|</td>
1267 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1268 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1269 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1270 . $locale->text('Ship via') . qq|</td>
1273 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1274 . $locale->text('Amount') . qq|</td>
1275 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1276 . $locale->text('Tax') . qq|</td>
1277 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1278 . $locale->text('Total') . qq|</td>
1281 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1282 . $locale->text('Subtotal') . qq|</td>
1290 <tr><td colspan=4><hr size=3 noshade></td></tr>
1296 <input type=hidden name=nextsub value=orders>
1297 <input type=hidden name=path value=$form->{path}>
1298 <input type=hidden name=login value=$form->{login}>
1299 <input type=hidden name=password value=$form->{password}>
1300 <input type=hidden name=vc value=$form->{vc}>
1301 <input type=hidden name=type value=$form->{type}>
1303 <input class=submit type=submit name=action value="|
1304 . $locale->text('Continue') . qq|">
1311 $lxdebug->leave_sub();
1315 $lxdebug->enter_sub();
1317 # split vendor / customer
1318 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1319 split(/--/, $form->{ $form->{vc} });
1321 OE->transactions(\%myconfig, \%$form);
1323 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1325 $number = $form->escape($form->{$ordnumber});
1326 $name = $form->escape($form->{ $form->{vc} });
1327 $department = $form->escape($form->{department});
1328 $warehouse = $form->escape($form->{warehouse});
1332 "$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";
1334 # construct callback
1335 $number = $form->escape($form->{$ordnumber}, 1);
1336 $name = $form->escape($form->{ $form->{vc} }, 1);
1337 $department = $form->escape($form->{department}, 1);
1338 $warehouse = $form->escape($form->{warehouse}, 1);
1341 "$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";
1344 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1345 "name", "netamount", "tax", "amount",
1346 "curr", "employee", "shipvia", "open",
1349 $form->{l_open} = $form->{l_closed} = "Y"
1350 if ($form->{open} && $form->{closed});
1352 foreach $item (@columns) {
1353 if ($form->{"l_$item"} eq "Y") {
1354 push @column_index, $item;
1356 # add column to href and callback
1357 $callback .= "&l_$item=Y";
1358 $href .= "&l_$item=Y";
1362 # only show checkboxes if gotten here via sales_order form.
1363 if ($form->{type} =~ /sales_order/) {
1364 unshift @column_index, "ids";
1367 if ($form->{l_subtotal} eq 'Y') {
1368 $callback .= "&l_subtotal=Y";
1369 $href .= "&l_subtotal=Y";
1372 if ($form->{vc} eq 'vendor') {
1373 if ($form->{type} eq 'receive_order') {
1374 $form->{title} = $locale->text('Receive Merchandise');
1375 } elsif ($form->{type} eq 'purchase_order') {
1376 $form->{title} = $locale->text('Purchase Orders');
1378 $form->{title} = $locale->text('Request for Quotations');
1380 $name = $locale->text('Vendor');
1381 $employee = $locale->text('Employee');
1383 if ($form->{vc} eq 'customer') {
1384 if ($form->{type} eq 'sales_order') {
1385 $form->{title} = $locale->text('Sales Orders');
1386 $employee = $locale->text('Salesperson');
1387 } elsif ($form->{type} eq 'ship_order') {
1388 $form->{title} = $locale->text('Ship Merchandise');
1389 $employee = $locale->text('Salesperson');
1391 $form->{title} = $locale->text('Quotations');
1392 $employee = $locale->text('Employee');
1394 $name = $locale->text('Customer');
1397 $column_header{id} =
1398 qq|<th><a class=listheading href=$href&sort=id>|
1399 . $locale->text('ID')
1401 $column_header{transdate} =
1402 qq|<th><a class=listheading href=$href&sort=transdate>|
1403 . $locale->text('Date')
1405 $column_header{reqdate} =
1406 qq|<th><a class=listheading href=$href&sort=reqdate>|
1407 . $locale->text('Required by')
1409 $column_header{ordnumber} =
1410 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1411 . $locale->text('Order')
1413 $column_header{quonumber} =
1414 qq|<th><a class=listheading href=$href&sort=quonumber>|
1415 . $locale->text('Quotation')
1417 $column_header{name} =
1418 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1419 $column_header{netamount} =
1420 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1421 $column_header{tax} =
1422 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1423 $column_header{amount} =
1424 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1425 $column_header{curr} =
1426 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1427 $column_header{shipvia} =
1428 qq|<th><a class=listheading href=$href&sort=shipvia>|
1429 . $locale->text('Ship via')
1431 $column_header{open} =
1432 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1433 $column_header{closed} =
1434 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1436 $column_header{employee} =
1437 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1439 $column_header{ids} = qq|<th></th>|;
1441 if ($form->{ $form->{vc} }) {
1442 $option = $locale->text(ucfirst $form->{vc});
1443 $option .= " : $form->{$form->{vc}}";
1445 if ($form->{warehouse}) {
1446 ($warehouse) = split /--/, $form->{warehouse};
1447 $option .= "\n<br>" if ($option);
1448 $option .= $locale->text('Warehouse');
1449 $option .= " : $warehouse";
1451 if ($form->{department}) {
1452 $option .= "\n<br>" if ($option);
1453 ($department) = split /--/, $form->{department};
1454 $option .= $locale->text('Department') . " : $department";
1456 if ($form->{transdatefrom}) {
1458 . $locale->text('From') . " "
1459 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1461 if ($form->{transdateto}) {
1463 . $locale->text('Bis') . " "
1464 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1466 if ($form->{open}) {
1467 $option .= "\n<br>" if ($option);
1468 $option .= $locale->text('Open');
1470 if ($form->{closed}) {
1471 $option .= "\n<br>" if ($option);
1472 $option .= $locale->text('Closed');
1480 <form method="post" action="oe.pl">
1483 <th class=listtop>$form->{title}</th>
1485 <tr height="5"></tr>
1492 <tr class=listheading>|;
1494 map { print "\n$column_header{$_}" } @column_index;
1500 # add sort and escape callback
1501 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1503 if (@{ $form->{OE} }) {
1504 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1508 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1510 $warehouse = $form->escape($form->{warehouse});
1512 foreach $oe (@{ $form->{OE} }) {
1513 $form->{rowcount} = ++$j;
1515 if ($form->{l_subtotal} eq 'Y') {
1516 if ($sameitem ne $oe->{ $form->{sort} }) {
1518 $sameitem = $oe->{ $form->{sort} };
1522 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1524 $column_data{netamount} =
1526 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1528 $column_data{tax} = "<td align=right>"
1529 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1532 $column_data{amount} =
1534 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1536 $totalnetamount += $oe->{netamount};
1537 $totalamount += $oe->{amount};
1539 $subtotalnetamount += $oe->{netamount};
1540 $subtotalamount += $oe->{amount};
1543 qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1544 $column_data{id} = "<td>$oe->{id}</td>";
1545 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1546 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1548 $column_data{$ordnumber} =
1549 "<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>";
1550 $column_data{name} = "<td>$oe->{name}</td>";
1552 $column_data{employee} = "<td>$oe->{employee} </td>";
1553 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1555 if ($oe->{closed}) {
1556 $column_data{closed} = "<td align=center>X</td>";
1557 $column_data{open} = "<td> </td>";
1559 $column_data{closed} = "<td> </td>";
1560 $column_data{open} = "<td align=center>X</td>";
1566 <tr class=listrow$i>";
1568 map { print "\n$column_data{$_}" } @column_index;
1576 if ($form->{l_subtotal} eq 'Y') {
1582 <tr class=listtotal>|;
1584 map { $column_data{$_} = "<td> </td>" } @column_index;
1586 $column_data{netamount} =
1587 "<th class=listtotal align=right>"
1588 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1589 $column_data{tax} = "<th class=listtotal align=right>"
1590 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1593 $column_data{amount} =
1594 "<th class=listtotal align=right>"
1595 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1597 map { print "\n$column_data{$_}" } @column_index;
1605 <td><hr size=3 noshade></td>
1609 # multiple invoice edit button only if gotten there via sales_order form.
1611 if ($form->{type} =~ /sales_order/) {
1613 <input type="hidden" name="path" value="$form->{path}">
1614 <input class"submit" type="submit" name="action" value="|
1615 . $locale->text('Continue') . qq|">
1616 <input type="hidden" name="nextsub" value="edit">
1617 <input type="hidden" name="type" value="$form->{type}">
1618 <input type="hidden" name="warehouse" value="$warehouse">
1619 <input type="hidden" name="vc" value="$form->{vc}">
1620 <input type="hidden" name="login" value="$form->{login}">
1621 <input type="hidden" name="password" value="$form->{password}">
1622 <input type="hidden" name="callback" value="$callback">
1623 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1630 <form method=post action=$form->{script}>
1632 <input name=callback type=hidden value="$form->{callback}">
1634 <input type=hidden name=type value=$form->{type}>
1635 <input type=hidden name=vc value=$form->{vc}>
1637 <input type=hidden name=path value=$form->{path}>
1638 <input type=hidden name=login value=$form->{login}>
1639 <input type=hidden name=password value=$form->{password}>
1642 if ($form->{type} !~ /(ship|receive)_order/) {
1644 <input class=submit type=submit name=action value="|
1645 . $locale->text('Add') . qq|">|;
1648 if ($form->{menubar}) {
1649 require "$form->{path}/menu.pl";
1660 $lxdebug->leave_sub();
1664 $lxdebug->enter_sub();
1666 map { $column_data{$_} = "<td> </td>" } @column_index;
1668 $column_data{netamount} =
1669 "<th class=listsubtotal align=right>"
1670 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1672 $column_data{tax} = "<td class=listsubtotal align=right>"
1673 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1676 $column_data{amount} =
1677 "<th class=listsubtotal align=right>"
1678 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1680 $subtotalnetamount = 0;
1681 $subtotalamount = 0;
1684 <tr class=listsubtotal>
1687 map { print "\n$column_data{$_}" } @column_index;
1693 $lxdebug->leave_sub();
1697 $lxdebug->enter_sub();
1699 if ($form->{type} =~ /_order$/) {
1700 $form->isblank("transdate", $locale->text('Order Date missing!'));
1702 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1705 $msg = ucfirst $form->{vc};
1706 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1708 # $locale->text('Customer missing!');
1709 # $locale->text('Vendor missing!');
1711 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1712 if ($form->{currency} ne $form->{defaultcurrency});
1716 # if the name changed get new values
1717 if (&check_name($form->{vc})) {
1722 $form->{id} = 0 if $form->{saveasnew};
1724 # this is for the internal notes section for the [email] Subject
1725 if ($form->{type} =~ /_order$/) {
1726 if ($form->{type} eq 'sales_order') {
1727 $form->{label} = $locale->text('Sales Order');
1729 $numberfld = "sonumber";
1730 $ordnumber = "ordnumber";
1732 $form->{label} = $locale->text('Purchase Order');
1734 $numberfld = "ponumber";
1735 $ordnumber = "ordnumber";
1738 $err = $locale->text('Cannot save order!');
1741 if ($form->{type} eq 'sales_quotation') {
1742 $form->{label} = $locale->text('Quotation');
1744 $numberfld = "sqnumber";
1745 $ordnumber = "quonumber";
1747 $form->{label} = $locale->text('Request for Quotation');
1749 $numberfld = "rfqnumber";
1750 $ordnumber = "quonumber";
1753 $err = $locale->text('Cannot save quotation!');
1757 # get new number in sequence if no number is given or if saveasnew was requested
1758 if (!$form->{$ordumber} || $form->{saveasnew}) {
1759 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld);
1763 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1764 if (OE->save(\%myconfig, \%$form));
1767 $lxdebug->leave_sub();
1771 $lxdebug->enter_sub();
1775 if ($form->{type} =~ /_order$/) {
1776 $msg = $locale->text('Are you sure you want to delete Order Number');
1777 $ordnumber = 'ordnumber';
1779 $msg = $locale->text('Are you sure you want to delete Quotation Number');
1780 $ordnumber = 'quonumber';
1786 <form method=post action=$form->{script}>
1789 # delete action variable
1790 map { delete $form->{$_} } qw(action header);
1792 foreach $key (keys %$form) {
1793 $form->{$key} =~ s/\"/"/g;
1794 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1798 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1800 <h4>$msg $form->{$ordnumber}</h4>
1802 <input name=action class=submit type=submit value="|
1803 . $locale->text('Yes') . qq|">
1810 $lxdebug->leave_sub();
1814 $lxdebug->enter_sub();
1816 if ($form->{type} =~ /_order$/) {
1817 $msg = $locale->text('Order deleted!');
1818 $err = $locale->text('Cannot delete order!');
1820 $msg = $locale->text('Quotation deleted!');
1821 $err = $locale->text('Cannot delete quotation!');
1824 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
1827 $lxdebug->leave_sub();
1831 $lxdebug->enter_sub();
1833 if ($form->{type} =~ /_order$/) {
1835 # these checks only apply if the items don't bring their own ordnumbers/transdates.
1836 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
1837 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
1838 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
1840 $form->isblank("transdate", $locale->text('Order Date missing!'))
1841 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
1844 # also copy deliverydate from the order
1845 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
1847 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
1848 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1849 $form->{ordnumber} = "";
1852 # if the name changed get new values
1853 if (&check_name($form->{vc})) {
1858 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1859 $form->{cp_id} *= 1;
1861 if ( $form->{type} =~ /_order/
1862 && $form->{currency} ne $form->{defaultcurrency}) {
1864 # check if we need a new exchangerate
1865 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
1867 $orddate = $form->current_date(\%myconfig);
1869 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
1872 if (!$exchangerate) {
1873 &backorder_exchangerate($orddate, $buysell);
1878 # close orders/quotations
1879 $form->{closed} = 1;
1881 # save order if one ordnumber has been given
1882 # if not it's most likely a collective order, which can't be saved back
1883 # so they just have to be closed
1884 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
1885 OE->save(\%myconfig, \%$form);
1887 OE->close_orders(\%myconfig, \%$form);
1890 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1892 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1895 $form->{closed} = 0;
1896 $form->{rowcount}--;
1897 $form->{shipto} = 1;
1899 if ($form->{type} =~ /_order$/) {
1900 $form->{exchangerate} = $exchangerate;
1904 if ( $form->{type} eq 'purchase_order'
1905 || $form->{type} eq 'request_quotation') {
1906 $form->{title} = $locale->text('Add Vendor Invoice');
1907 $form->{script} = 'ir.pl';
1911 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1912 $form->{title} = $locale->text('Add Sales Invoice');
1913 $form->{script} = 'is.pl';
1918 # bo creates the id, reset it
1919 map { delete $form->{$_} }
1920 qw(id subject message cc bcc printed emailed queued);
1921 $form->{ $form->{vc} } =~ s/--.*//g;
1922 $form->{type} = "invoice";
1925 $locale = new Locale "$myconfig{countrycode}", "$script";
1927 require "$form->{path}/$form->{script}";
1929 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1931 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1932 qw(creditlimit creditremaining);
1934 $currency = $form->{currency};
1937 $form->{currency} = $currency;
1938 $form->{exchangerate} = "";
1939 $form->{forex} = "";
1940 $form->{exchangerate} = $exchangerate
1944 $form->check_exchangerate(
1945 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
1948 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1953 for $i (1 .. $form->{rowcount}) {
1954 $form->{"discount_$i"} =
1955 $form->format_amount(\%myconfig, $form->{"discount_$i"});
1957 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
1959 $decimalplaces = ($dec > 2) ? $dec : 2;
1961 # copy delivery date from reqdate for order -> invoice conversion
1962 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
1963 unless $form->{"deliverydate_$i"};
1965 $form->{"sellprice_$i"} =
1966 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1969 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
1970 $dec_qty = length $dec_qty;
1972 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1974 map { $form->{"${_}_$i"} =~ s/\"/"/g }
1975 qw(partnumber description unit);
1981 $lxdebug->leave_sub();
1984 sub backorder_exchangerate {
1985 $lxdebug->enter_sub();
1986 my ($orddate, $buysell) = @_;
1993 <form method=post action=$form->{script}>
1996 # delete action variable
1997 map { delete $form->{$_} } qw(action header exchangerate);
1999 foreach $key (keys %$form) {
2000 $form->{$key} =~ s/\"/"/g;
2001 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
2004 $form->{title} = $locale->text('Add Exchangerate');
2008 <input type=hidden name=path value=$form->{path}>
2009 <input type=hidden name=login value=$form->{login}>
2010 <input type=hidden name=password value=$form->{password}>
2012 <input type=hidden name=exchangeratedate value=$orddate>
2013 <input type=hidden name=buysell value=$buysell>
2016 <tr><th class=listtop>$form->{title}</th></tr>
2017 <tr height="5"></tr>
2022 <th align=right>| . $locale->text('Currency') . qq|</th>
2023 <td>$form->{currency}</td>
2026 <th align=right>| . $locale->text('Date') . qq|</th>
2030 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2031 <td><input name=exchangerate size=11></td>
2041 <input type=hidden name=nextsub value=save_exchangerate>
2043 <input name=action class=submit type=submit value="|
2044 . $locale->text('Continue') . qq|">
2052 $lxdebug->leave_sub();
2055 sub save_exchangerate {
2056 $lxdebug->enter_sub();
2058 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2059 $form->{exchangerate} =
2060 $form->parse_amount(\%myconfig, $form->{exchangerate});
2061 $form->save_exchangerate(\%myconfig, $form->{currency},
2062 $form->{exchangeratedate},
2063 $form->{exchangerate}, $form->{buysell});
2067 $lxdebug->leave_sub();
2070 sub create_backorder {
2071 $lxdebug->enter_sub();
2073 $form->{shipped} = 1;
2075 # figure out if we need to create a backorder
2076 # items aren't saved if qty != 0
2078 for $i (1 .. $form->{rowcount}) {
2079 $totalqty += $qty = $form->{"qty_$i"};
2080 $totalship += $ship = $form->{"ship_$i"};
2082 $form->{"qty_$i"} = $qty - $ship;
2085 if ($totalship == 0) {
2086 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2087 $form->{ordtotal} = 0;
2088 $form->{shipped} = 0;
2092 if ($totalqty == $totalship) {
2093 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2094 $form->{ordtotal} = 0;
2099 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2102 for $i (1 .. $form->{rowcount}) {
2104 $form->{"${_}_$i"} =
2105 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2106 } qw(sellprice discount);
2109 OE->save(\%myconfig, \%$form);
2111 # rebuild rows for invoice
2115 for $i (1 .. $form->{rowcount}) {
2116 $form->{"qty_$i"} = $form->{"ship_$i"};
2118 if ($form->{"qty_$i"}) {
2121 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2126 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2127 $form->{rowcount} = $count;
2129 $lxdebug->leave_sub();
2133 $lxdebug->enter_sub();
2135 $form->{saveasnew} = 1;
2136 $form->{closed} = 0;
2137 map { delete $form->{$_} } qw(printed emailed queued);
2141 $lxdebug->leave_sub();
2144 sub purchase_order {
2145 $lxdebug->enter_sub();
2147 if ( $form->{type} eq 'sales_quotation'
2148 || $form->{type} eq 'request_quotation') {
2149 $form->{closed} = 1;
2150 OE->save(\%myconfig, \%$form);
2153 ($null, $form->{cp_id}) = split /--/, $form->{contact};
2154 $form->{cp_id} *= 1;
2156 $form->{title} = $locale->text('Add Purchase Order');
2157 $form->{vc} = "vendor";
2158 $form->{type} = "purchase_order";
2162 $lxdebug->leave_sub();
2166 $lxdebug->enter_sub();
2168 if ( $form->{type} eq 'sales_quotation'
2169 || $form->{type} eq 'request_quotation') {
2170 $form->{closed} = 1;
2171 OE->save(\%myconfig, \%$form);
2174 ($null, $form->{cp_id}) = split /--/, $form->{contact};
2175 $form->{cp_id} *= 1;
2177 $form->{title} = $locale->text('Add Sales Order');
2178 $form->{vc} = "customer";
2179 $form->{type} = "sales_order";
2183 $lxdebug->leave_sub();
2187 $lxdebug->enter_sub();
2189 $form->{transdate} = $form->current_date(\%myconfig);
2190 delete $form->{duedate};
2192 $form->{closed} = 0;
2195 map { delete $form->{$_} }
2196 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2203 for $i (1 .. $form->{rowcount} - 1) {
2204 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2205 qw(partnumber description unit);
2208 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2209 qw(creditlimit creditremaining);
2213 $lxdebug->leave_sub();
2217 $lxdebug->enter_sub();
2223 OE->get_warehouses(\%myconfig, \%$form);
2226 if (@{ $form->{all_warehouses} }) {
2227 $form->{selectwarehouse} = "<option>\n";
2229 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2230 (@{ $form->{all_warehouses} });
2232 if ($form->{warehouse}) {
2233 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2237 $form->{shippingdate} = $form->current_date(\%myconfig);
2238 $form->{"$form->{vc}"} =~ s/--.*//;
2243 foreach $key (keys %$form) {
2244 if ($key =~ /_1$/) {
2250 for $i (1 .. $form->{rowcount}) {
2252 # undo formatting from prepare_order
2254 $form->{"${_}_$i"} =
2255 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2257 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2259 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2260 $form->{"ship_$i"} = "";
2261 $form->{"serialnumber_$i"} = "";
2266 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2271 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2272 $form->{rowcount} = $count;
2274 &display_ship_receive;
2276 $lxdebug->leave_sub();
2279 sub display_ship_receive {
2280 $lxdebug->enter_sub();
2282 $vclabel = ucfirst $form->{vc};
2283 $vclabel = $locale->text($vclabel);
2285 $form->{rowcount}++;
2287 if ($form->{vc} eq 'customer') {
2288 $form->{title} = $locale->text('Ship Merchandise');
2289 $shipped = $locale->text('Shipping Date');
2291 $form->{title} = $locale->text('Receive Merchandise');
2292 $shipped = $locale->text('Date Received');
2295 # set option selected
2296 foreach $item (warehouse, employee) {
2297 $form->{"select$item"} =~ s/ selected//;
2298 $form->{"select$item"} =~
2299 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2304 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2305 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2306 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2308 | if $form->{selectwarehouse};
2312 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2313 <td><select name=employee>$form->{selectemployee}</select></td>
2314 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2323 <form method=post action=$form->{script}>
2325 <input type=hidden name=id value=$form->{id}>
2327 <input type=hidden name=display_form value=display_ship_receive>
2329 <input type=hidden name=type value=$form->{type}>
2330 <input type=hidden name=media value=$form->{media}>
2331 <input type=hidden name=format value=$form->{format}>
2333 <input type=hidden name=queued value="$form->{queued}">
2334 <input type=hidden name=printed value="$form->{printed}">
2335 <input type=hidden name=emailed value="$form->{emailed}">
2337 <input type=hidden name=vc value=$form->{vc}>
2341 <th class=listtop>$form->{title}</th>
2343 <tr height="5"></tr>
2346 <table width="100%">
2351 <th align=right>$vclabel</th>
2352 <td colspan=3>$form->{$form->{vc}}</td>
2353 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2354 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2358 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2360 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2363 <th align=right>| . $locale->text('Ship via') . qq|</th>
2365 <input name=shipvia size=35 value="$form->{shipvia}">
2374 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2375 <td>$form->{ordnumber}</td>
2376 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2379 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2380 <td>$form->{transdate}</td>
2381 <input type=hidden name=transdate value=$form->{transdate}>
2384 <th align=right nowrap>$shipped</th>
2385 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2394 <!-- shipto are in hidden variables -->
2396 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2397 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2398 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2399 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2400 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2401 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2402 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2403 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2404 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2406 <!-- email variables -->
2407 <input type=hidden name=message value="$form->{message}">
2408 <input type=hidden name=email value="$form->{email}">
2409 <input type=hidden name=subject value="$form->{subject}">
2410 <input type=hidden name=cc value="$form->{cc}">
2411 <input type=hidden name=bcc value="$form->{bcc}">
2416 (partnumber, description, qty, ship, unit, bin, serialnumber);
2418 if ($form->{type} eq "ship_order") {
2419 $column_data{ship} =
2420 qq|<th class=listheading align=center width="auto">|
2421 . $locale->text('Ship')
2424 if ($form->{type} eq "receive_order") {
2425 $column_data{ship} =
2426 qq|<th class=listheading align=center width="auto">|
2427 . $locale->text('Recd')
2431 my $colspan = $#column_index + 1;
2433 $column_data{partnumber} =
2434 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2435 $column_data{description} =
2436 qq|<th class=listheading nowrap>|
2437 . $locale->text('Description')
2440 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2441 $column_data{unit} =
2442 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2444 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2445 $column_data{serialnumber} =
2446 qq|<th class=listheading nowrap>|
2447 . $locale->text('Serial No.')
2454 <tr class=listheading>|;
2456 map { print "\n$column_data{$_}" } @column_index;
2462 for $i (1 .. $form->{rowcount} - 1) {
2465 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2467 # convert " to "
2468 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2469 qw(partnumber description unit bin serialnumber);
2471 $description = $form->{"description_$i"};
2472 $description =~ s/\n/<br>/g;
2474 $column_data{partnumber} =
2475 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2476 $column_data{description} =
2477 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2479 qq|<td align=right>|
2480 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2481 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2482 $column_data{ship} =
2483 qq|<td align=right><input name="ship_$i" size=5 value=|
2484 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2486 $column_data{unit} =
2487 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2489 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2491 $column_data{serialnumber} =
2492 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2497 map { print "\n$column_data{$_}" } @column_index;
2502 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2503 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2504 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2505 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2516 <td><hr size=3 noshade></td>
2522 $form->{copies} = 1;
2531 <input class=submit type=submit name=action value="|
2532 . $locale->text('Update') . qq|">
2533 <input class=submit type=submit name=action value="|
2534 . $locale->text('Print') . qq|">
2537 if ($form->{type} eq 'ship_order') {
2539 <input class=submit type=submit name=action value="|
2540 . $locale->text('Ship to') . qq|">
2541 <input class=submit type=submit name=action value="|
2542 . $locale->text('E-mail') . qq|">
2548 <input class=submit type=submit name=action value="|
2549 . $locale->text('Done') . qq|">
2552 if ($form->{menubar}) {
2553 require "$form->{path}/menu.pl";
2559 <input type=hidden name=rowcount value=$form->{rowcount}>
2561 <input name=callback type=hidden value="$callback">
2563 <input type=hidden name=path value=$form->{path}>
2564 <input type=hidden name=login value=$form->{login}>
2565 <input type=hidden name=password value=$form->{password}>
2573 $lxdebug->leave_sub();
2577 $lxdebug->enter_sub();
2579 if ($form->{type} eq 'ship_order') {
2580 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2582 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2587 $total += $form->{"ship_$_"} =
2588 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2589 } (1 .. $form->{rowcount} - 1);
2591 $form->error($locale->text('Nothing entered!')) unless $total;
2593 $form->redirect($locale->text('Inventory saved!'))
2594 if OE->save_inventory(\%myconfig, \%$form);
2595 $form->error($locale->text('Could not save!'));
2597 $lxdebug->leave_sub();
2600 sub search_transfer {
2601 $lxdebug->enter_sub();
2603 OE->get_warehouses(\%myconfig, \%$form);
2606 if (@{ $form->{all_warehouses} }) {
2607 $form->{selectwarehouse} = "<option>\n";
2608 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2610 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2611 (@{ $form->{all_warehouses} });
2613 $form->error($locale->text('Nothing to transfer!'));
2616 $form->{title} = $locale->text('Transfer Inventory');
2623 <form method=post action=$form->{script}>
2627 <th class=listtop>$form->{title}</th>
2629 <tr height="5"></tr>
2634 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2635 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2638 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2639 <td><input name=partnumber size=20></td>
2642 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2643 <td><input name=description size=40></td>
2646 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2647 <td><input name=partsgroup size=20></td>
2653 <td><hr size=3 noshade></td>
2658 <input type=hidden name=sort value=partnumber>
2659 <input type=hidden name=nextsub value=list_transfer>
2661 <input type=hidden name=path value=$form->{path}>
2662 <input type=hidden name=login value=$form->{login}>
2663 <input type=hidden name=password value=$form->{password}>
2665 <input class=submit type=submit name=action value="|
2666 . $locale->text('Continue') . qq|">
2673 $lxdebug->leave_sub();
2677 $lxdebug->enter_sub();
2679 OE->get_inventory(\%myconfig, \%$form);
2681 $partnumber = $form->escape($form->{partnumber});
2682 $warehouse = $form->escape($form->{warehouse});
2683 $description = $form->escape($form->{description});
2684 $partsgroup = $form->escape($form->{partsgroup});
2688 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2690 # construct callback
2691 $partnumber = $form->escape($form->{partnumber}, 1);
2692 $warehouse = $form->escape($form->{warehouse}, 1);
2693 $description = $form->escape($form->{description}, 1);
2694 $partsgroup = $form->escape($form->{partsgroup}, 1);
2697 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2700 $form->sort_columns(
2701 qw(partnumber description partsgroup make model warehouse qty transfer));
2703 $column_header{partnumber} =
2704 qq|<th><a class=listheading href=$href&sort=partnumber>|
2705 . $locale->text('Part Number')
2707 $column_header{description} =
2708 qq|<th><a class=listheading href=$href&sort=description>|
2709 . $locale->text('Description')
2711 $column_header{partsgroup} =
2712 qq|<th><a class=listheading href=$href&sort=partsgroup>|
2713 . $locale->text('Group')
2715 $column_header{warehouse} =
2716 qq|<th><a class=listheading href=$href&sort=warehouse>|
2717 . $locale->text('From')
2719 $column_header{qty} =
2720 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
2721 $column_header{transfer} =
2722 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
2724 $option = $locale->text('Transfer to');
2726 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
2728 if ($form->{warehouse}) {
2729 $option .= " : $warehouse";
2731 if ($form->{partnumber}) {
2732 $option .= "\n<br>" if ($option);
2733 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
2735 if ($form->{description}) {
2736 $option .= "\n<br>" if ($option);
2737 $option .= $locale->text('Description') . " : $form->{description}";
2739 if ($form->{partsgroup}) {
2740 $option .= "\n<br>" if ($option);
2741 $option .= $locale->text('Group') . " : $form->{partsgroup}";
2744 $form->{title} = $locale->text('Transfer Inventory');
2751 <form method=post action=$form->{script}>
2753 <input type=hidden name=warehouse_id value=$warehouse_id>
2757 <th class=listtop>$form->{title}</th>
2759 <tr height="5"></tr>
2766 <tr class=listheading>|;
2768 map { print "\n$column_header{$_}" } @column_index;
2774 if (@{ $form->{all_inventory} }) {
2775 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
2779 foreach $ref (@{ $form->{all_inventory} }) {
2783 $column_data{partnumber} =
2784 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
2785 $column_data{description} = "<td>$ref->{description} </td>";
2786 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
2787 $column_data{warehouse} =
2788 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
2790 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
2791 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
2793 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
2798 <tr class=listrow$j>";
2800 map { print "\n$column_data{$_}" } @column_index;
2814 <td><hr size=3 noshade></td>
2820 <input name=callback type=hidden value="$callback">
2822 <input type=hidden name=rowcount value=$i>
2824 <input type=hidden name=path value=$form->{path}>
2825 <input type=hidden name=login value=$form->{login}>
2826 <input type=hidden name=password value=$form->{password}>
2828 <input class=submit type=submit name=action value="|
2829 . $locale->text('Transfer') . qq|">|;
2831 if ($form->{menubar}) {
2832 require "$form->{path}/menu.pl";
2843 $lxdebug->leave_sub();
2847 $lxdebug->enter_sub();
2849 $form->redirect($locale->text('Inventory transferred!'))
2850 if OE->transfer(\%myconfig, \%$form);
2851 $form->error($locale->text('Could not transfer Inventory!'));
2853 $lxdebug->leave_sub();