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});
86 undef $form->{rowcount};
97 if ($form->{type} eq 'purchase_order') {
98 $form->{title} = $locale->text('Edit Purchase Order');
99 $form->{heading} = $locale->text('Purchase Order');
100 $form->{vc} = 'vendor';
102 if ($form->{type} eq 'sales_order') {
103 $form->{title} = $locale->text('Edit Sales Order');
104 $form->{heading} = $locale->text('Sales Order');
105 $form->{vc} = 'customer';
107 if ($form->{type} eq 'request_quotation') {
108 $form->{title} = $locale->text('Edit Request for Quotation');
109 $form->{heading} = $locale->text('Request for Quotation');
110 $form->{vc} = 'vendor';
112 if ($form->{type} eq 'sales_quotation') {
113 $form->{title} = $locale->text('Edit Quotation');
114 $form->{heading} = $locale->text('Quotation');
115 $form->{vc} = 'customer';
122 $lxdebug->leave_sub();
126 $lxdebug->enter_sub();
128 # get customer/vendor
129 $form->all_vc(\%myconfig, $form->{vc},
130 ($form->{vc} eq 'customer') ? "AR" : "AP");
132 # retrieve order/quotation
133 $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}
144 && $form->{type} eq 'sales_order'
145 && defined $form->{customer}
146 && $form->{customer} eq '') {
148 # $main::lxdebug->message(0, "Detected Edit order with concurrent customers");
151 'Collective Orders only work for orders from one customer!')
155 $taxincluded = $form->{taxincluded};
156 $form->{shipto} = 1 if $form->{id};
158 if ($form->{"all_$form->{vc}"}) {
159 unless ($form->{"$form->{vc}_id"}) {
160 $form->{"$form->{vc}_id"} = $form->{"all_$form->{vc}"}->[0]->{id};
164 $cp_id = $form->{cp_id};
165 $intnotes = $form->{intnotes};
167 # get customer / vendor
168 if ($form->{type} =~ /(purchase_order|request_quotation|receive_order)/) {
169 IR->get_vendor(\%myconfig, \%$form);
171 if ($form->{type} =~ /(sales|ship)_(order|quotation)/) {
172 IS->get_customer(\%myconfig, \%$form);
174 $form->{cp_id} = $cp_id;
176 $form->{intnotes} = $intnotes;
177 ($form->{ $form->{vc} }) = split /--/, $form->{ $form->{vc} };
178 $form->{"old$form->{vc}"} =
179 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
181 # build the popup menus
182 if (@{ $form->{"all_$form->{vc}"} }) {
183 $form->{ $form->{vc} } =
184 qq|$form->{$form->{vc}}--$form->{"$form->{vc}_id"}|;
185 map { $form->{"select$form->{vc}"} .= "<option>$_->{name}--$_->{id}\n" }
186 (@{ $form->{"all_$form->{vc}"} });
190 @curr = split /:/, $form->{currencies};
192 $form->{defaultcurrency} = $curr[0];
193 $form->{currency} = $form->{defaultcurrency} unless $form->{currency};
195 map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
197 $form->{taxincluded} = $taxincluded if ($form->{id});
200 if (@{ $form->{all_departments} }) {
201 $form->{selectdepartment} = "<option>\n";
202 $form->{department} = "$form->{department}--$form->{department_id}";
205 $form->{selectdepartment} .=
206 "<option>$_->{description}--$_->{id}\n"
207 } (@{ $form->{all_departments} });
210 $form->{employee} = "$form->{employee}--$form->{employee_id}";
213 if (@{ $form->{all_employees} }) {
214 $form->{selectemployee} = "";
215 map { $form->{selectemployee} .= "<option>$_->{name}--$_->{id}\n" }
216 (@{ $form->{all_employees} });
220 $form->{forex} = $form->{exchangerate};
222 $lxdebug->leave_sub();
226 $lxdebug->enter_sub();
227 $form->{format} = "pdf";
228 $form->{media} = "screen";
229 $form->{formname} = $form->{type};
231 map { $form->{$_} =~ s/\"/"/g }
232 qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact);
234 foreach $ref (@{ $form->{form_details} }) {
235 $form->{rowcount} = ++$i;
237 map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
239 for my $i (1 .. $form->{rowcount}) {
241 $form->{"discount_$i"} =
242 $form->format_amount(\%myconfig, $form->{"discount_$i"} * 100);
244 $form->{"discount_$i"} =
245 $form->format_amount(\%myconfig, $form->{"discount_$i"});
247 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
249 $decimalplaces = ($dec > 2) ? $dec : 2;
251 # copy reqdate from deliverydate for invoice -> order conversion
252 $form->{"reqdate_$i"} = $form->{"deliverydate_$i"}
253 unless $form->{"reqdate_$i"};
255 $form->{"sellprice_$i"} =
256 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
259 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
260 $dec_qty = length $dec_qty;
262 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
264 map { $form->{"${_}_$i"} =~ s/\"/"/g }
265 qw(partnumber description unit);
268 $lxdebug->leave_sub();
272 $lxdebug->enter_sub();
274 $checkedopen = ($form->{closed}) ? "" : "checked";
275 $checkedclosed = ($form->{closed}) ? "checked" : "";
277 # use JavaScript Calendar or not
278 $form->{jsscript} = $form->{jscalendar};
281 if ($form->{jsscript}) {
283 # with JavaScript Calendar
285 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>
286 <td><input type=button name=transdate id="trigger1" value=|
287 . $locale->text('button') . qq|></td>
290 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>
291 <td width="4"><input type=button name=reqdate name=reqdate id="trigger2" value=|
292 . $locale->text('button') . qq|></td>
297 Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1",
298 "reqdate", "BL", "trigger2");
302 # without JavaScript Calendar
304 <td><input name=transdate id=transdate size=11 title="$myconfig{dateformat}" value=$form->{transdate}></td>|;
306 <td width="13"><input name=reqdate id=reqdate size=11 title="$myconfig{dateformat}" value=$form->{reqdate}></td>|;
312 <td colspan=2 align=center>
315 <th nowrap><input name=closed type=radio class=radio value=0 $checkedopen> |
316 . $locale->text('Open') . qq|</th>
317 <th nowrap><input name=closed type=radio class=radio value=1 $checkedclosed> |
318 . $locale->text('Closed') . qq|</th>
326 # set option selected
327 foreach $item ($form->{vc}, currency, department, employee, contact) {
328 $form->{"select$item"} =~ s/ selected//;
329 $form->{"select$item"} =~
330 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
334 if ($form->{all_contacts}) {
336 $form->{selectcontact} = "";
337 foreach $item (@{ $form->{all_contacts} }) {
338 if ($form->{cp_id} == $item->{cp_id}) {
339 $form->{selectcontact} .=
340 "<option selected>$item->{cp_name}--$item->{cp_id}";
342 $form->{selectcontact} .= "<option>$item->{cp_name}--$item->{cp_id}";
347 $form->{exchangerate} =
348 $form->format_amount(\%myconfig, $form->{exchangerate});
350 $form->{creditlimit} =
351 $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
352 $form->{creditremaining} =
353 $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
356 ($form->{selectcontact})
357 ? qq|<select name=contact>$form->{selectcontact}</select>\n<input type=hidden name="selectcontact" value="$form->{selectcontact}">|
358 : qq|<input name=contact value="$form->{contact}" size=35>|;
361 <input type=hidden name=forex value=$form->{forex}>
364 if ($form->{currency} ne $form->{defaultcurrency}) {
365 if ($form->{forex}) {
368 . $locale->text('Exchangerate')
369 . qq|</th><td>$form->{exchangerate}</td>
370 <input type=hidden name=exchangerate value=$form->{exchangerate}>
375 . $locale->text('Exchangerate')
376 . qq|</th><td><input name=exchangerate size=10 value=$form->{exchangerate}></td>|;
380 $vclabel = ucfirst $form->{vc};
381 $vclabel = $locale->text($vclabel);
385 <th align=right nowrap>| . $locale->text('Terms: Net') . qq|</th>
386 <td nowrap><input name=terms size="3" maxlength="3" value=$form->{terms}> |
387 . $locale->text('days') . qq|</td>
391 if ($form->{business}) {
394 <th align=right>| . $locale->text('Business') . qq|</th>
395 <td>$form->{business}</td>
396 <th align=right>| . $locale->text('Trade Discount') . qq|</th>
398 . $form->format_amount(\%myconfig, $form->{tradediscount} * 100)
404 if ($form->{type} !~ /_quotation$/) {
407 <th width=70% align=right nowrap>| . $locale->text('Order Number') . qq|</th>
408 <td><input name=ordnumber size=11 value="$form->{ordnumber}"></td>
411 <th width=70% align=right nowrap>|
412 . $locale->text('Quotation Number') . qq|</th>
413 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
416 <th width=70% align=right nowrap>|
417 . $locale->text('Customer Order Number') . qq|</th>
418 <td><input name=cusordnumber size=11 value="$form->{cusordnumber}"></td>
421 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
426 <th align=right nowrap=true>| . $locale->text('Required by') . qq|</th>
431 $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
433 $creditremaining = qq|
439 <th nowrap>| . $locale->text('Credit Limit') . qq|</th>
440 <td>$form->{creditlimit}</td>
442 <th nowrap>| . $locale->text('Remaining') . qq|</th>
443 <td class="plus$n">$form->{creditremaining}</td>
451 ($form->{type} eq 'sales_quotation')
452 ? $locale->text('Valid until')
453 : $locale->text('Required by');
454 if ($form->{type} eq 'sales_quotation') {
457 <th width=70% align=right nowrap>|
458 . $locale->text('Quotation Number') . qq|</th>
459 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
460 <input type=hidden name=ordnumber value="$form->{ordnumber}">
466 <th width=70% align=right nowrap>| . $locale->text('RFQ Number') . qq|</th>
467 <td><input name=quonumber size=11 value="$form->{quonumber}"></td>
468 <input type=hidden name=ordnumber value="$form->{ordnumber}">
477 <th align=right nowrap>| . $locale->text('Quotation Date') . qq|</th>
481 <th align=right nowrap=true>$reqlabel</th>
489 ($form->{"select$form->{vc}"})
490 ? qq|<select name=$form->{vc}>$form->{"select$form->{vc}"}</select>\n<input type=hidden name="select$form->{vc}" value="$form->{"select$form->{vc}"}">|
491 : qq|<input name=$form->{vc} value="$form->{$form->{vc}}" size=35>|;
495 <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
496 <td colspan=3><select name=department>$form->{selectdepartment}</select>
497 <input type=hidden name=selectdepartment value="$form->{selectdepartment}">
500 | if $form->{selectdepartment};
503 <input type=hidden name=employee value="$form->{employee}">
506 if ($form->{type} eq 'sales_order') {
507 if ($form->{selectemployee}) {
509 <input type=hidden name=customer_klass value=$form->{customer_klass}>
511 <th align=right nowrap>| . $locale->text('Salesperson') . qq|</th>
512 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
513 <input type=hidden name=selectemployee value="$form->{selectemployee}">
520 <input type=hidden name=customer_klass value=$form->{customer_klass}>
522 <th align=right nowrap>| . $locale->text('Employee') . qq|</th>
523 <td colspan=2><select name=employee>$form->{selectemployee}</select></td>
524 <input type=hidden name=selectemployee value="$form->{selectemployee}">
535 <form method=post action=$form->{script}>
537 <input type=hidden name=id value=$form->{id}>
539 <input type=hidden name=type value=$form->{type}>
540 <input type=hidden name=formname value=$form->{formname}>
541 <input type=hidden name=media value=$form->{media}>
542 <input type=hidden name=format value=$form->{format}>
544 <input type=hidden name=queued value="$form->{queued}">
545 <input type=hidden name=printed value="$form->{printed}">
546 <input type=hidden name=emailed value="$form->{emailed}">
548 <input type=hidden name=vc value=$form->{vc}>
550 <input type=hidden name=title value="$form->{title}">
552 <input type=hidden name=discount value=$form->{discount}>
553 <input type=hidden name=creditlimit value=$form->{creditlimit}>
554 <input type=hidden name=creditremaining value=$form->{creditremaining}>
556 <input type=hidden name=tradediscount value=$form->{tradediscount}>
557 <input type=hidden name=business value=$form->{business}>
558 <input type=hidden name=webdav value=$webdav>
562 <th class=listtop>$form->{title}</th>
572 <th align=right>$vclabel</th>
573 <td colspan=3>$vc</td>
574 <input type=hidden name=$form->{vc}_id value=$form->{"$form->{vc}_id"}>
575 <input type=hidden name="old$form->{vc}" value="$form->{"old$form->{vc}"}">
576 <th align=richt nowrap>|
577 . $locale->text('Contact Person') . qq|</th>
578 <td colspan=3>$contact</td>
584 <th align=right>| . $locale->text('Currency') . qq|</th>
585 <td><select name=currency>$form->{selectcurrency}</select></td>
586 <input type=hidden name=selectcurrency value="$form->{selectcurrency}">
587 <input type=hidden name=defaultcurrency value=$form->{defaultcurrency}>
591 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
592 <td colspan=3><input name=shippingpoint size=35 value="$form->{shippingpoint}"></td>
595 <th align=right>| . $locale->text('Ship via') . qq|</th>
596 <td colspan=3><input name=shipvia size=35 value="$form->{shipvia}"></td>
615 <!-- shipto are in hidden variables -->
617 <input type=hidden name=shiptoname value="$form->{shiptoname}">
618 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
619 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
620 <input type=hidden name=shiptocity value="$form->{shiptocity}">
621 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
622 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
623 <input type=hidden name=shiptophone value="$form->{shiptophone}">
624 <input type=hidden name=shiptofax value="$form->{shiptofax}">
625 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
627 <!-- email variables -->
628 <input type=hidden name=message value="$form->{message}">
629 <input type=hidden name=email value="$form->{email}">
630 <input type=hidden name=subject value="$form->{subject}">
631 <input type=hidden name=cc value="$form->{cc}">
632 <input type=hidden name=bcc value="$form->{bcc}">
634 <input type=hidden name=taxpart value="$form->{taxpart}">
635 <input type=hidden name=taxservice value="$form->{taxservice}">
637 <input type=hidden name=taxaccounts value="$form->{taxaccounts}">
640 foreach $item (split / /, $form->{taxaccounts}) {
642 <input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
643 <input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
646 $lxdebug->leave_sub();
650 $lxdebug->enter_sub();
652 $form->{invtotal} = $form->{invsubtotal};
654 if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
657 if (($introws = $form->numtextrows($form->{intnotes}, 35, 8)) < 2) {
660 $rows = ($rows > $introws) ? $rows : $introws;
662 qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
664 qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
666 $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
669 if ($form->{taxaccounts}) {
671 <input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
672 . $locale->text('Tax Included') . qq|</b><br><br>
676 if (!$form->{taxincluded}) {
678 foreach $item (split / /, $form->{taxaccounts}) {
679 if ($form->{"${item}_base"}) {
680 $form->{invtotal} += $form->{"${item}_total"} =
682 $form->{"${item}_base"} * $form->{"${item}_rate"},
684 $form->{"${item}_total"} =
685 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
689 <th align=right>$form->{"${item}_description"}</th>
690 <td align=right>$form->{"${item}_total"}</td>
696 $form->{invsubtotal} =
697 $form->format_amount(\%myconfig, $form->{invsubtotal}, 2, 0);
701 <th align=right>| . $locale->text('Subtotal') . qq|</th>
702 <td align=right>$form->{invsubtotal}</td>
708 if ($form->{taxincluded}) {
709 foreach $item (split / /, $form->{taxaccounts}) {
710 if ($form->{"${item}_base"}) {
711 $form->{"${item}_total"} =
713 ($form->{"${item}_base"} * $form->{"${item}_rate"} /
714 (1 + $form->{"${item}_rate"})
717 $form->{"${item}_netto"} =
719 ($form->{"${item}_base"} - $form->{"${item}_total"}),
721 $form->{"${item}_total"} =
722 $form->format_amount(\%myconfig, $form->{"${item}_total"}, 2);
723 $form->{"${item}_netto"} =
724 $form->format_amount(\%myconfig, $form->{"${item}_netto"}, 2);
728 <th align=right>Enthaltene $form->{"${item}_description"}</th>
729 <td align=right>$form->{"${item}_total"}</td>
732 <th align=right>Nettobetrag</th>
733 <td align=right>$form->{"${item}_netto"}</td>
741 $form->{oldinvtotal} = $form->{invtotal};
743 $form->format_amount(\%myconfig, $form->{invtotal}, 2, 0);
753 <th align=left>| . $locale->text('Notes') . qq|</th>
754 <th align=left>| . $locale->text('Internal Notes') . qq|</th>
762 <td align=right width=100%>
768 <th align=right>| . $locale->text('Total') . qq|</th>
769 <td align=right>$form->{invtotal}</td>
777 <input type=hidden name=oldinvtotal value=$form->{oldinvtotal}>
778 <input type=hidden name=oldtotalpaid value=$totalpaid>
780 <td><hr size=3 noshade></td>
788 <th class=listtop align=left>Dokumente im Webdav-Repository</th>
791 <td align=left width=30%><b>Dateiname</b></td>
792 <td align=left width=70%><b>Webdavlink</b></td>
794 foreach $file (keys %{ $form->{WEBDAV} }) {
797 <td align=left>$file</td>
798 <td align=left><a href="$form->{WEBDAV}{$file}">$form->{WEBDAV}{$file}</a></td>
806 <td><hr size=3 noshade></td>
813 <input type=hidden name=jscalendar value=$form->{jscalendar}>
826 Bearbeiten des $form->{heading}<br>
827 <input class=submit type=submit name=action value="|
828 . $locale->text('Update') . qq|">
829 <input class=submit type=submit name=action value="|
830 . $locale->text('Ship to') . qq|">
831 <input class=submit type=submit name=action value="|
832 . $locale->text('Print') . qq|">
833 <input class=submit type=submit name=action value="|
834 . $locale->text('E-mail') . qq|">
835 <input class=submit type=submit name=action value="|
836 . $locale->text('Save') . qq|">
841 <br>Workflow $form->{heading}<br>
842 <input class=submit type=submit name=action value="|
843 . $locale->text('Save as new') . qq|">
844 <input class=submit type=submit name=action value="|
845 . $locale->text('Delete') . qq|">|;
846 if ($form->{type} =~ /sales_quotation$/) {
848 <input class=submit type=submit name=action value="|
849 . $locale->text('Sales Order') . qq|">|;
851 if ($form->{type} =~ /request_quotation$/) {
853 <input class=submit type=submit name=action value="|
854 . $locale->text('Purchase Order') . qq|">|;
857 <input class=submit type=submit name=action value="|
858 . $locale->text('Invoice') . qq|">
861 if ($form->{type} =~ /sales_order$/) {
863 <br>$form->{heading} als neue Vorlage verwenden für<br>
864 <input class=submit type=submit name=action value="|
865 . $locale->text('Purchase Order') . qq|">
866 <input class=submit type=submit name=action value="|
867 . $locale->text('Quotation') . qq|">
870 } elsif ($form->{type} =~ /purchase_order$/) {
872 <br>$form->{heading} als neue Vorlage verwenden für<br>
873 <input class=submit type=submit name=action value="|
874 . $locale->text('Sales Order') . qq|">
875 <input class=submit type=submit name=action value="|
876 . $locale->text('Quotation') . qq|">
881 <br>$form->{heading} als neue Vorlage verwenden für<br>
882 <input class=submit type=submit name=action value="|
883 . $locale->text('Order') . qq|">
886 } elsif ($form->{type} =~ /sales_order$/ && $form->{rowcount}) {
888 <br>Workflow $form->{heading}<br>
889 <input class=submit type=submit name=action value="|
890 . $locale->text('Save as new') . qq|">
891 <input class=submit type=submit name=action value="|
892 . $locale->text('Invoice') . qq|">
896 if ($form->{menubar}) {
897 require "$form->{path}/menu.pl";
903 <input type=hidden name=rowcount value=$form->{rowcount}>
905 <input name=callback type=hidden value="$form->{callback}">
907 <input type=hidden name=path value=$form->{path}>
908 <input type=hidden name=login value=$form->{login}>
909 <input type=hidden name=password value=$form->{password}>
916 $lxdebug->leave_sub();
920 $lxdebug->enter_sub();
922 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
923 qw(exchangerate creditlimit creditremaining);
925 &check_name($form->{vc});
930 $buysell = 'sell' if ($form->{vc} eq 'vendor');
931 $form->{exchangerate} = $exchangerate
935 $form->check_exchangerate(
936 \%myconfig, $form->{currency}, $form->{transdate}, $buysell
940 $i = $form->{rowcount};
942 $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
944 if ( ($form->{"partnumber_$i"} eq "")
945 && ($form->{"description_$i"} eq "")
946 && ($form->{"partsgroup_$i"} eq "")) {
948 $form->{creditremaining} += ($form->{oldinvtotal} - $form->{oldtotalpaid});
953 if ( $form->{type} eq 'purchase_order'
954 || $form->{type} eq 'request_quotation') {
955 IR->retrieve_item(\%myconfig, \%$form);
957 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
958 IS->retrieve_item(\%myconfig, \%$form);
961 my $rows = scalar @{ $form->{item_list} };
963 $form->{"discount_$i"} =
964 $form->format_amount(\%myconfig, $form->{discount} * 100);
967 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
976 $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
978 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
979 qw(partnumber description unit);
980 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
981 keys %{ $form->{item_list}[0] };
983 $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"};
985 ($dec) = ($s =~ /\.(\d+)/);
987 $decimalplaces = ($dec > 2) ? $dec : 2;
990 $form->{"sellprice_$i"} = $sellprice;
993 $form->{"sellprice_$i"} *= (1 - $form->{tradediscount});
995 # if there is an exchange rate adjust sellprice
996 $form->{"sellprice_$i"} /= $exchangerate;
1000 $form->{"sellprice_$i"} * $form->{"qty_$i"} *
1001 (1 - $form->{"discount_$i"} / 100);
1002 map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts});
1003 map { $form->{"${_}_base"} += $amount }
1004 (split / /, $form->{"taxaccounts_$i"});
1005 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
1006 split / /, $form->{taxaccounts}
1007 if !$form->{taxincluded};
1009 $form->{creditremaining} -= $amount;
1011 $form->{"sellprice_$i"} =
1012 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1015 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1017 # get pricegroups for parts
1018 IS->get_pricegroups_for_parts(\%myconfig, \%$form);
1020 # build up html code for prices_$i
1021 &set_pricegroup($i);
1028 # ok, so this is a new part
1029 # ask if it is a part or service item
1031 if ( $form->{"partsgroup_$i"}
1032 && ($form->{"partsnumber_$i"} eq "")
1033 && ($form->{"description_$i"} eq "")) {
1034 $form->{rowcount}--;
1035 $form->{"discount_$i"} = "";
1039 $form->{"id_$i"} = 0;
1040 $form->{"unit_$i"} = $locale->text('ea');
1048 $lxdebug->leave_sub();
1052 $lxdebug->enter_sub();
1054 if ($form->{type} eq 'purchase_order') {
1055 $form->{title} = $locale->text('Purchase Orders');
1056 $form->{vc} = 'vendor';
1057 $ordlabel = $locale->text('Order Number');
1058 $ordnumber = 'ordnumber';
1059 $employee = $locale->text('Employee');
1061 if ($form->{type} eq 'request_quotation') {
1062 $form->{title} = $locale->text('Request for Quotations');
1063 $form->{vc} = 'vendor';
1064 $ordlabel = $locale->text('RFQ Number');
1065 $ordnumber = 'quonumber';
1066 $employee = $locale->text('Employee');
1068 if ($form->{type} eq 'receive_order') {
1069 $form->{title} = $locale->text('Receive Merchandise');
1070 $form->{vc} = 'vendor';
1071 $ordlabel = $locale->text('Order Number');
1072 $ordnumber = 'ordnumber';
1073 $employee = $locale->text('Employee');
1075 if ($form->{type} eq 'sales_order') {
1076 $form->{title} = $locale->text('Sales Orders');
1077 $form->{vc} = 'customer';
1078 $ordlabel = $locale->text('Order Number');
1079 $ordnumber = 'ordnumber';
1080 $employee = $locale->text('Salesperson');
1082 if ($form->{type} eq 'ship_order') {
1083 $form->{title} = $locale->text('Ship Merchandise');
1084 $form->{vc} = 'customer';
1085 $ordlabel = $locale->text('Order Number');
1086 $ordnumber = 'ordnumber';
1087 $employee = $locale->text('Salesperson');
1091 if ($form->{type} eq 'sales_quotation') {
1092 $form->{title} = $locale->text('Quotations');
1093 $form->{vc} = 'customer';
1094 $ordlabel = $locale->text('Quotation Number');
1095 $ordnumber = 'quonumber';
1096 $employee = $locale->text('Employee');
1099 if ($form->{type} =~ /(ship|receive)_order/) {
1100 OE->get_warehouses(\%myconfig, \%$form);
1103 if (@{ $form->{all_warehouses} }) {
1104 $form->{selectwarehouse} = "<option>\n";
1105 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
1108 $form->{selectwarehouse} .=
1109 "<option>$_->{description}--$_->{id}\n"
1110 } (@{ $form->{all_warehouses} });
1114 <th align=right>| . $locale->text('Warehouse') . qq|</th>
1115 <td colspan=3><select name=warehouse>$form->{selectwarehouse}</select></td>
1116 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
1123 # setup vendor / customer selection
1124 $form->all_vc(\%myconfig, $form->{vc},
1125 ($form->{vc} eq 'customer') ? "AR" : "AP");
1127 map { $vc .= "<option>$_->{name}--$_->{id}\n" }
1128 @{ $form->{"all_$form->{vc}"} };
1130 $vclabel = ucfirst $form->{vc};
1131 $vclabel = $locale->text($vclabel);
1133 # $locale->text('Vendor')
1134 # $locale->text('Customer')
1138 ? qq|<select name=$form->{vc}><option>\n$vc</select>|
1139 : qq|<input name=$form->{vc} size=35>|;
1142 if (@{ $form->{all_departments} }) {
1143 $form->{selectdepartment} = "<option>\n";
1146 $form->{selectdepartment} .=
1147 "<option>$_->{description}--$_->{id}\n"
1148 } (@{ $form->{all_departments} });
1153 <th align=right nowrap>| . $locale->text('Department') . qq|</th>
1154 <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
1156 | if $form->{selectdepartment};
1158 if ($form->{type} !~ /(ship_order|receive_order)/) {
1161 <td><input name="open" class=checkbox type=checkbox value=1 checked> |
1162 . $locale->text('Open') . qq|</td>
1163 <td><input name="closed" class=checkbox type=checkbox value=1 $form->{closed}> |
1164 . $locale->text('Closed') . qq|</td>
1170 <input type=hidden name="open" value=1>
1174 # use JavaScript Calendar or not
1175 $form->{jsscript} = $jscalendar;
1177 if ($form->{jsscript}) {
1179 # with JavaScript Calendar
1181 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}">
1182 <input type=button name=transdatefrom id="trigger3" value=|
1183 . $locale->text('button') . qq|></td>
1186 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}">
1187 <input type=button name=transdateto name=transdateto id="trigger4" value=|
1188 . $locale->text('button') . qq|></td>
1193 Form->write_trigger(\%myconfig, "2", "transdatefrom", "BR", "trigger3",
1194 "transdateto", "BL", "trigger4");
1197 # without JavaScript Calendar
1199 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1201 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
1209 <form method=post action=$form->{script}>
1213 <th class=listtop>$form->{title}</th>
1215 <tr height="5"></tr>
1220 <th align=right>$vclabel</th>
1221 <td colspan=3>$vc</td>
1226 <th align=right>$ordlabel</th>
1227 <td colspan=3><input name="$ordnumber" size=20></td>
1230 <th align=right>| . $locale->text('From') . qq|</th>
1232 <th align=right>| . $locale->text('Bis') . qq|</th>
1235 <input type=hidden name=sort value=transdate>
1237 <th align=right>| . $locale->text('Include in Report') . qq|</th>
1242 <td><input name="l_id" class=checkbox type=checkbox value=Y>
1243 | . $locale->text('ID') . qq|</td>
1244 <td><input name="l_$ordnumber" class=checkbox type=checkbox value=Y checked> $ordlabel</td>
1245 <td><input name="l_transdate" class=checkbox type=checkbox value=Y checked> |
1246 . $locale->text('Date') . qq|</td>
1247 <td><input name="l_reqdate" class=checkbox type=checkbox value=Y checked> |
1248 . $locale->text('Required by') . qq|</td>
1251 <td><input name="l_name" class=checkbox type=checkbox value=Y checked> $vclabel</td>
1252 <td><input name="l_employee" class=checkbox type=checkbox value=Y checked> $employee</td>
1253 <td><input name="l_shipvia" class=checkbox type=checkbox value=Y> |
1254 . $locale->text('Ship via') . qq|</td>
1257 <td><input name="l_netamount" class=checkbox type=checkbox value=Y> |
1258 . $locale->text('Amount') . qq|</td>
1259 <td><input name="l_tax" class=checkbox type=checkbox value=Y> |
1260 . $locale->text('Tax') . qq|</td>
1261 <td><input name="l_amount" class=checkbox type=checkbox value=Y checked> |
1262 . $locale->text('Total') . qq|</td>
1265 <td><input name="l_subtotal" class=checkbox type=checkbox value=Y> |
1266 . $locale->text('Subtotal') . qq|</td>
1274 <tr><td colspan=4><hr size=3 noshade></td></tr>
1280 <input type=hidden name=nextsub value=orders>
1281 <input type=hidden name=path value=$form->{path}>
1282 <input type=hidden name=login value=$form->{login}>
1283 <input type=hidden name=password value=$form->{password}>
1284 <input type=hidden name=vc value=$form->{vc}>
1285 <input type=hidden name=type value=$form->{type}>
1287 <input class=submit type=submit name=action value="|
1288 . $locale->text('Continue') . qq|">
1295 $lxdebug->leave_sub();
1299 $lxdebug->enter_sub();
1301 # split vendor / customer
1302 ($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) =
1303 split(/--/, $form->{ $form->{vc} });
1305 OE->transactions(\%myconfig, \%$form);
1307 $ordnumber = ($form->{type} =~ /_order$/) ? "ordnumber" : "quonumber";
1309 $number = $form->escape($form->{$ordnumber});
1310 $name = $form->escape($form->{ $form->{vc} });
1311 $department = $form->escape($form->{department});
1312 $warehouse = $form->escape($form->{warehouse});
1316 "$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";
1318 # construct callback
1319 $number = $form->escape($form->{$ordnumber}, 1);
1320 $name = $form->escape($form->{ $form->{vc} }, 1);
1321 $department = $form->escape($form->{department}, 1);
1322 $warehouse = $form->escape($form->{warehouse}, 1);
1325 "$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";
1328 $form->sort_columns("transdate", "reqdate", "id", "$ordnumber",
1329 "name", "netamount", "tax", "amount",
1330 "curr", "employee", "shipvia", "open",
1333 $form->{l_open} = $form->{l_closed} = "Y"
1334 if ($form->{open} && $form->{closed});
1336 foreach $item (@columns) {
1337 if ($form->{"l_$item"} eq "Y") {
1338 push @column_index, $item;
1340 # add column to href and callback
1341 $callback .= "&l_$item=Y";
1342 $href .= "&l_$item=Y";
1346 # only show checkboxes if gotten here via sales_order form.
1347 if ($form->{type} =~ /sales_order/) {
1348 unshift @column_index, "ids";
1351 if ($form->{l_subtotal} eq 'Y') {
1352 $callback .= "&l_subtotal=Y";
1353 $href .= "&l_subtotal=Y";
1356 if ($form->{vc} eq 'vendor') {
1357 if ($form->{type} eq 'receive_order') {
1358 $form->{title} = $locale->text('Receive Merchandise');
1359 } elsif ($form->{type} eq 'purchase_order') {
1360 $form->{title} = $locale->text('Purchase Orders');
1362 $form->{title} = $locale->text('Request for Quotations');
1364 $name = $locale->text('Vendor');
1365 $employee = $locale->text('Employee');
1367 if ($form->{vc} eq 'customer') {
1368 if ($form->{type} eq 'sales_order') {
1369 $form->{title} = $locale->text('Sales Orders');
1370 $employee = $locale->text('Salesperson');
1371 } elsif ($form->{type} eq 'ship_order') {
1372 $form->{title} = $locale->text('Ship Merchandise');
1373 $employee = $locale->text('Salesperson');
1375 $form->{title} = $locale->text('Quotations');
1376 $employee = $locale->text('Employee');
1378 $name = $locale->text('Customer');
1381 $column_header{id} =
1382 qq|<th><a class=listheading href=$href&sort=id>|
1383 . $locale->text('ID')
1385 $column_header{transdate} =
1386 qq|<th><a class=listheading href=$href&sort=transdate>|
1387 . $locale->text('Date')
1389 $column_header{reqdate} =
1390 qq|<th><a class=listheading href=$href&sort=reqdate>|
1391 . $locale->text('Required by')
1393 $column_header{ordnumber} =
1394 qq|<th><a class=listheading href=$href&sort=ordnumber>|
1395 . $locale->text('Order')
1397 $column_header{quonumber} =
1398 qq|<th><a class=listheading href=$href&sort=quonumber>|
1399 . $locale->text('Quotation')
1401 $column_header{name} =
1402 qq|<th><a class=listheading href=$href&sort=name>$name</a></th>|;
1403 $column_header{netamount} =
1404 qq|<th class=listheading>| . $locale->text('Amount') . qq|</th>|;
1405 $column_header{tax} =
1406 qq|<th class=listheading>| . $locale->text('Tax') . qq|</th>|;
1407 $column_header{amount} =
1408 qq|<th class=listheading>| . $locale->text('Total') . qq|</th>|;
1409 $column_header{curr} =
1410 qq|<th class=listheading>| . $locale->text('Curr') . qq|</th>|;
1411 $column_header{shipvia} =
1412 qq|<th><a class=listheading href=$href&sort=shipvia>|
1413 . $locale->text('Ship via')
1415 $column_header{open} =
1416 qq|<th class=listheading>| . $locale->text('O') . qq|</th>|;
1417 $column_header{closed} =
1418 qq|<th class=listheading>| . $locale->text('C') . qq|</th>|;
1420 $column_header{employee} =
1421 qq|<th><a class=listheading href=$href&sort=employee>$employee</a></th>|;
1423 $column_header{ids} = qq|<th></th>|;
1425 if ($form->{ $form->{vc} }) {
1426 $option = $locale->text(ucfirst $form->{vc});
1427 $option .= " : $form->{$form->{vc}}";
1429 if ($form->{warehouse}) {
1430 ($warehouse) = split /--/, $form->{warehouse};
1431 $option .= "\n<br>" if ($option);
1432 $option .= $locale->text('Warehouse');
1433 $option .= " : $warehouse";
1435 if ($form->{department}) {
1436 $option .= "\n<br>" if ($option);
1437 ($department) = split /--/, $form->{department};
1438 $option .= $locale->text('Department') . " : $department";
1440 if ($form->{transdatefrom}) {
1442 . $locale->text('From') . " "
1443 . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1445 if ($form->{transdateto}) {
1447 . $locale->text('Bis') . " "
1448 . $locale->date(\%myconfig, $form->{transdateto}, 1);
1450 if ($form->{open}) {
1451 $option .= "\n<br>" if ($option);
1452 $option .= $locale->text('Open');
1454 if ($form->{closed}) {
1455 $option .= "\n<br>" if ($option);
1456 $option .= $locale->text('Closed');
1464 <form method="post" action="oe.pl">
1467 <th class=listtop>$form->{title}</th>
1469 <tr height="5"></tr>
1476 <tr class=listheading>|;
1478 map { print "\n$column_header{$_}" } @column_index;
1484 # add sort and escape callback
1485 $callback_escaped = $form->escape($callback . "&sort=$form->{sort}");
1487 if (@{ $form->{OE} }) {
1488 $sameitem = $form->{OE}->[0]->{ $form->{sort} };
1492 $action = "ship_receive" if ($form->{type} =~ /(ship|receive)_order/);
1494 $warehouse = $form->escape($form->{warehouse});
1496 foreach $oe (@{ $form->{OE} }) {
1497 $form->{rowcount} = ++$j;
1499 if ($form->{l_subtotal} eq 'Y') {
1500 if ($sameitem ne $oe->{ $form->{sort} }) {
1502 $sameitem = $oe->{ $form->{sort} };
1506 map { $oe->{$_} *= $oe->{exchangerate} } (qw(netamount amount));
1508 $column_data{netamount} =
1510 . $form->format_amount(\%myconfig, $oe->{netamount}, 2, " ")
1512 $column_data{tax} = "<td align=right>"
1513 . $form->format_amount(\%myconfig, $oe->{amount} - $oe->{netamount},
1516 $column_data{amount} =
1518 . $form->format_amount(\%myconfig, $oe->{amount}, 2, " ") . "</td>";
1520 $totalnetamount += $oe->{netamount};
1521 $totalamount += $oe->{amount};
1523 $subtotalnetamount += $oe->{netamount};
1524 $subtotalamount += $oe->{amount};
1527 qq|<td><input name="id_$j" class=checkbox type=checkbox><input type="hidden" name="trans_id_$j" value="$oe->{id}"></td>|;
1528 $column_data{id} = "<td>$oe->{id}</td>";
1529 $column_data{transdate} = "<td>$oe->{transdate} </td>";
1530 $column_data{reqdate} = "<td>$oe->{reqdate} </td>";
1532 $column_data{$ordnumber} =
1533 "<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>";
1534 $column_data{name} = "<td>$oe->{name}</td>";
1536 $column_data{employee} = "<td>$oe->{employee} </td>";
1537 $column_data{shipvia} = "<td>$oe->{shipvia} </td>";
1539 if ($oe->{closed}) {
1540 $column_data{closed} = "<td align=center>X</td>";
1541 $column_data{open} = "<td> </td>";
1543 $column_data{closed} = "<td> </td>";
1544 $column_data{open} = "<td align=center>X</td>";
1550 <tr class=listrow$i>";
1552 map { print "\n$column_data{$_}" } @column_index;
1560 if ($form->{l_subtotal} eq 'Y') {
1566 <tr class=listtotal>|;
1568 map { $column_data{$_} = "<td> </td>" } @column_index;
1570 $column_data{netamount} =
1571 "<th class=listtotal align=right>"
1572 . $form->format_amount(\%myconfig, $totalnetamount, 2, " ") . "</th>";
1573 $column_data{tax} = "<th class=listtotal align=right>"
1574 . $form->format_amount(\%myconfig, $totalamount - $totalnetamount,
1577 $column_data{amount} =
1578 "<th class=listtotal align=right>"
1579 . $form->format_amount(\%myconfig, $totalamount, 2, " ") . "</th>";
1581 map { print "\n$column_data{$_}" } @column_index;
1589 <td><hr size=3 noshade></td>
1593 # multiple invoice edit button only if gotten there via sales_order form.
1595 if ($form->{type} =~ /sales_order/) {
1597 <input type="hidden" name="path" value="$form->{path}">
1598 <input class"submit" type="submit" name="action" value="|
1599 . $locale->text('Continue') . qq|">
1600 <input type="hidden" name="nextsub" value="edit">
1601 <input type="hidden" name="type" value="$form->{type}">
1602 <input type="hidden" name="warehouse" value="$warehouse">
1603 <input type="hidden" name="vc" value="$form->{vc}">
1604 <input type="hidden" name="login" value="$form->{login}">
1605 <input type="hidden" name="password" value="$form->{password}">
1606 <input type="hidden" name="callback" value="$callback">
1607 <input type="hidden" name="rowcount" value="$form->{rowcount}">|;
1614 <form method=post action=$form->{script}>
1616 <input name=callback type=hidden value="$form->{callback}">
1618 <input type=hidden name=type value=$form->{type}>
1619 <input type=hidden name=vc value=$form->{vc}>
1621 <input type=hidden name=path value=$form->{path}>
1622 <input type=hidden name=login value=$form->{login}>
1623 <input type=hidden name=password value=$form->{password}>
1626 if ($form->{type} !~ /(ship|receive)_order/) {
1628 <input class=submit type=submit name=action value="|
1629 . $locale->text('Add') . qq|">|;
1632 if ($form->{menubar}) {
1633 require "$form->{path}/menu.pl";
1644 $lxdebug->leave_sub();
1648 $lxdebug->enter_sub();
1650 map { $column_data{$_} = "<td> </td>" } @column_index;
1652 $column_data{netamount} =
1653 "<th class=listsubtotal align=right>"
1654 . $form->format_amount(\%myconfig, $subtotalnetamount, 2, " ")
1656 $column_data{tax} = "<td class=listsubtotal align=right>"
1657 . $form->format_amount(\%myconfig, $subtotalamount - $subtotalnetamount,
1660 $column_data{amount} =
1661 "<th class=listsubtotal align=right>"
1662 . $form->format_amount(\%myconfig, $subtotalamount, 2, " ") . "</th>";
1664 $subtotalnetamount = 0;
1665 $subtotalamount = 0;
1668 <tr class=listsubtotal>
1671 map { print "\n$column_data{$_}" } @column_index;
1677 $lxdebug->leave_sub();
1681 $lxdebug->enter_sub();
1683 if ($form->{type} =~ /_order$/) {
1684 $form->isblank("transdate", $locale->text('Order Date missing!'));
1686 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1689 $msg = ucfirst $form->{vc};
1690 $form->isblank($form->{vc}, $locale->text($msg . " missing!"));
1692 # $locale->text('Customer missing!');
1693 # $locale->text('Vendor missing!');
1695 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
1696 if ($form->{currency} ne $form->{defaultcurrency});
1700 # if the name changed get new values
1701 if (&check_name($form->{vc})) {
1706 $form->{id} = 0 if $form->{saveasnew};
1708 # this is for the internal notes section for the [email] Subject
1709 if ($form->{type} =~ /_order$/) {
1710 if ($form->{type} eq 'sales_order') {
1711 $form->{label} = $locale->text('Sales Order');
1713 $numberfld = "sonumber";
1714 $ordnumber = "ordnumber";
1716 $form->{label} = $locale->text('Purchase Order');
1718 $numberfld = "ponumber";
1719 $ordnumber = "ordnumber";
1722 $err = $locale->text('Cannot save order!');
1725 if ($form->{type} eq 'sales_quotation') {
1726 $form->{label} = $locale->text('Quotation');
1728 $numberfld = "sqnumber";
1729 $ordnumber = "quonumber";
1731 $form->{label} = $locale->text('Request for Quotation');
1733 $numberfld = "rfqnumber";
1734 $ordnumber = "quonumber";
1737 $err = $locale->text('Cannot save quotation!');
1741 $form->{$ordnumber} = $form->update_defaults(\%myconfig, $numberfld)
1742 unless $form->{$ordnumber};
1745 $form->{label} . " $form->{$ordnumber} " . $locale->text('saved!'))
1746 if (OE->save(\%myconfig, \%$form));
1749 $lxdebug->leave_sub();
1753 $lxdebug->enter_sub();
1757 if ($form->{type} =~ /_order$/) {
1758 $msg = $locale->text('Are you sure you want to delete Order Number');
1759 $ordnumber = 'ordnumber';
1761 $msg = $locale->text('Are you sure you want to delete Quotation Number');
1762 $ordnumber = 'quonumber';
1768 <form method=post action=$form->{script}>
1771 # delete action variable
1772 map { delete $form->{$_} } qw(action header);
1774 foreach $key (keys %$form) {
1775 $form->{$key} =~ s/\"/"/g;
1776 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1780 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
1782 <h4>$msg $form->{$ordnumber}</h4>
1784 <input name=action class=submit type=submit value="|
1785 . $locale->text('Yes') . qq|">
1792 $lxdebug->leave_sub();
1796 $lxdebug->enter_sub();
1798 if ($form->{type} =~ /_order$/) {
1799 $msg = $locale->text('Order deleted!');
1800 $err = $locale->text('Cannot delete order!');
1802 $msg = $locale->text('Quotation deleted!');
1803 $err = $locale->text('Cannot delete quotation!');
1806 $form->redirect($msg) if (OE->delete(\%myconfig, \%$form, $spool));
1809 $lxdebug->leave_sub();
1813 $lxdebug->enter_sub();
1815 if ($form->{type} =~ /_order$/) {
1817 # these checks only apply if the items don't bring their own ordnumbers/transdates.
1818 # The if clause ensures that by searching for empty ordnumber_#/transdate_# fields.
1819 $form->isblank("ordnumber", $locale->text('Order Number missing!'))
1820 if (+{ map { $form->{"ordnumber_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
1822 $form->isblank("transdate", $locale->text('Order Date missing!'))
1823 if (+{ map { $form->{"transdate_$_"}, 1 } (1 .. $form->{rowcount} - 1) }
1826 # also copy deliverydate from the order
1827 $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
1829 $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
1830 $form->isblank("transdate", $locale->text('Quotation Date missing!'));
1831 $form->{ordnumber} = "";
1834 # if the name changed get new values
1835 if (&check_name($form->{vc})) {
1840 ($null, $form->{cp_id}) = split /--/, $form->{contact};
1841 $form->{cp_id} *= 1;
1843 if ( $form->{type} =~ /_order/
1844 && $form->{currency} ne $form->{defaultcurrency}) {
1846 # check if we need a new exchangerate
1847 $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
1849 $orddate = $form->current_date(\%myconfig);
1851 $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
1854 if (!$exchangerate) {
1855 &backorder_exchangerate($orddate, $buysell);
1860 # close orders/quotations
1861 $form->{closed} = 1;
1863 # save order if one ordnumber has been given
1864 # if not it's most likely a collective order, which can't be saved back
1865 # so they just have to be closed
1866 if (($form->{ordnumber} ne '') || ($form->{quonumber} ne '')) {
1867 OE->save(\%myconfig, \%$form);
1869 OE->close_orders(\%myconfig, \%$form);
1872 $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
1874 $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
1877 $form->{closed} = 0;
1878 $form->{rowcount}--;
1879 $form->{shipto} = 1;
1881 if ($form->{type} =~ /_order$/) {
1882 $form->{exchangerate} = $exchangerate;
1886 if ( $form->{type} eq 'purchase_order'
1887 || $form->{type} eq 'request_quotation') {
1888 $form->{title} = $locale->text('Add Vendor Invoice');
1889 $form->{script} = 'ir.pl';
1893 if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
1894 $form->{title} = $locale->text('Add Sales Invoice');
1895 $form->{script} = 'is.pl';
1900 # bo creates the id, reset it
1901 map { delete $form->{$_} }
1902 qw(id subject message cc bcc printed emailed queued);
1903 $form->{ $form->{vc} } =~ s/--.*//g;
1904 $form->{type} = "invoice";
1907 $locale = new Locale "$myconfig{countrycode}", "$script";
1909 require "$form->{path}/$form->{script}";
1911 map { $form->{"select$_"} = "" } ($form->{vc}, currency);
1913 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
1914 qw(creditlimit creditremaining);
1916 $currency = $form->{currency};
1919 $form->{currency} = $currency;
1920 $form->{exchangerate} = "";
1921 $form->{forex} = "";
1922 $form->{exchangerate} = $exchangerate
1926 $form->check_exchangerate(
1927 \%myconfig, $form->{currency}, $form->{invdate}, $buysell
1930 $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal});
1935 for $i (1 .. $form->{rowcount}) {
1936 $form->{"discount_$i"} =
1937 $form->format_amount(\%myconfig, $form->{"discount_$i"});
1939 ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
1941 $decimalplaces = ($dec > 2) ? $dec : 2;
1943 # copy delivery date from reqdate for order -> invoice conversion
1944 $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
1945 unless $form->{"deliverydate_$i"};
1947 $form->{"sellprice_$i"} =
1948 $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
1951 (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
1952 $dec_qty = length $dec_qty;
1954 $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
1956 map { $form->{"${_}_$i"} =~ s/\"/"/g }
1957 qw(partnumber description unit);
1963 $lxdebug->leave_sub();
1966 sub backorder_exchangerate {
1967 $lxdebug->enter_sub();
1968 my ($orddate, $buysell) = @_;
1975 <form method=post action=$form->{script}>
1978 # delete action variable
1979 map { delete $form->{$_} } qw(action header exchangerate);
1981 foreach $key (keys %$form) {
1982 $form->{$key} =~ s/\"/"/g;
1983 print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
1986 $form->{title} = $locale->text('Add Exchangerate');
1990 <input type=hidden name=path value=$form->{path}>
1991 <input type=hidden name=login value=$form->{login}>
1992 <input type=hidden name=password value=$form->{password}>
1994 <input type=hidden name=exchangeratedate value=$orddate>
1995 <input type=hidden name=buysell value=$buysell>
1998 <tr><th class=listtop>$form->{title}</th></tr>
1999 <tr height="5"></tr>
2004 <th align=right>| . $locale->text('Currency') . qq|</th>
2005 <td>$form->{currency}</td>
2008 <th align=right>| . $locale->text('Date') . qq|</th>
2012 <th align=right>| . $locale->text('Exchangerate') . qq|</th>
2013 <td><input name=exchangerate size=11></td>
2023 <input type=hidden name=nextsub value=save_exchangerate>
2025 <input name=action class=submit type=submit value="|
2026 . $locale->text('Continue') . qq|">
2034 $lxdebug->leave_sub();
2037 sub save_exchangerate {
2038 $lxdebug->enter_sub();
2040 $form->isblank("exchangerate", $locale->text('Exchangerate missing!'));
2041 $form->{exchangerate} =
2042 $form->parse_amount(\%myconfig, $form->{exchangerate});
2043 $form->save_exchangerate(\%myconfig, $form->{currency},
2044 $form->{exchangeratedate},
2045 $form->{exchangerate}, $form->{buysell});
2049 $lxdebug->leave_sub();
2052 sub create_backorder {
2053 $lxdebug->enter_sub();
2055 $form->{shipped} = 1;
2057 # figure out if we need to create a backorder
2058 # items aren't saved if qty != 0
2060 for $i (1 .. $form->{rowcount}) {
2061 $totalqty += $qty = $form->{"qty_$i"};
2062 $totalship += $ship = $form->{"ship_$i"};
2064 $form->{"qty_$i"} = $qty - $ship;
2067 if ($totalship == 0) {
2068 map { $form->{"ship_$_"} = $form->{"qty_$_"} } (1 .. $form->{rowcount});
2069 $form->{ordtotal} = 0;
2070 $form->{shipped} = 0;
2074 if ($totalqty == $totalship) {
2075 map { $form->{"qty_$_"} = $form->{"ship_$_"} } (1 .. $form->{rowcount});
2076 $form->{ordtotal} = 0;
2081 qw(partnumber description qty ship unit sellprice discount id inventory_accno bin income_accno expense_accno listprice assembly taxaccounts partsgroup)
2084 for $i (1 .. $form->{rowcount}) {
2086 $form->{"${_}_$i"} =
2087 $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2088 } qw(sellprice discount);
2091 OE->save(\%myconfig, \%$form);
2093 # rebuild rows for invoice
2097 for $i (1 .. $form->{rowcount}) {
2098 $form->{"qty_$i"} = $form->{"ship_$i"};
2100 if ($form->{"qty_$i"}) {
2103 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2108 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2109 $form->{rowcount} = $count;
2111 $lxdebug->leave_sub();
2115 $lxdebug->enter_sub();
2117 $form->{saveasnew} = 1;
2118 $form->{closed} = 0;
2119 map { delete $form->{$_} } qw(printed emailed queued);
2123 $lxdebug->leave_sub();
2126 sub purchase_order {
2127 $lxdebug->enter_sub();
2129 if ( $form->{type} eq 'sales_quotation'
2130 || $form->{type} eq 'request_quotation') {
2131 $form->{closed} = 1;
2132 OE->save(\%myconfig, \%$form);
2135 ($null, $form->{cp_id}) = split /--/, $form->{contact};
2136 $form->{cp_id} *= 1;
2138 $form->{title} = $locale->text('Add Purchase Order');
2139 $form->{vc} = "vendor";
2140 $form->{type} = "purchase_order";
2144 $lxdebug->leave_sub();
2148 $lxdebug->enter_sub();
2150 if ( $form->{type} eq 'sales_quotation'
2151 || $form->{type} eq 'request_quotation') {
2152 $form->{closed} = 1;
2153 OE->save(\%myconfig, \%$form);
2156 ($null, $form->{cp_id}) = split /--/, $form->{contact};
2157 $form->{cp_id} *= 1;
2159 $form->{title} = $locale->text('Add Sales Order');
2160 $form->{vc} = "customer";
2161 $form->{type} = "sales_order";
2165 $lxdebug->leave_sub();
2169 $lxdebug->enter_sub();
2171 $form->{transdate} = $form->current_date(\%myconfig);
2172 delete $form->{duedate};
2174 $form->{closed} = 0;
2177 map { delete $form->{$_} }
2178 qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal);
2185 for $i (1 .. $form->{rowcount} - 1) {
2186 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2187 qw(partnumber description unit);
2190 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 0, "0") }
2191 qw(creditlimit creditremaining);
2195 $lxdebug->leave_sub();
2199 $lxdebug->enter_sub();
2205 OE->get_warehouses(\%myconfig, \%$form);
2208 if (@{ $form->{all_warehouses} }) {
2209 $form->{selectwarehouse} = "<option>\n";
2211 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2212 (@{ $form->{all_warehouses} });
2214 if ($form->{warehouse}) {
2215 $form->{selectwarehouse} = "<option>$form->{warehouse}";
2219 $form->{shippingdate} = $form->current_date(\%myconfig);
2220 $form->{"$form->{vc}"} =~ s/--.*//;
2225 foreach $key (keys %$form) {
2226 if ($key =~ /_1$/) {
2232 for $i (1 .. $form->{rowcount}) {
2234 # undo formatting from prepare_order
2236 $form->{"${_}_$i"} =
2237 $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
2239 $n = ($form->{"qty_$i"} -= $form->{"ship_$i"});
2241 && ($form->{"inventory_accno_$i"} || $form->{"assembly_$i"})) {
2242 $form->{"ship_$i"} = "";
2243 $form->{"serialnumber_$i"} = "";
2248 map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds;
2253 $form->redo_rows(\@flds, \@a, $count, $form->{rowcount});
2254 $form->{rowcount} = $count;
2256 &display_ship_receive;
2258 $lxdebug->leave_sub();
2261 sub display_ship_receive {
2262 $lxdebug->enter_sub();
2264 $vclabel = ucfirst $form->{vc};
2265 $vclabel = $locale->text($vclabel);
2267 $form->{rowcount}++;
2269 if ($form->{vc} eq 'customer') {
2270 $form->{title} = $locale->text('Ship Merchandise');
2271 $shipped = $locale->text('Shipping Date');
2273 $form->{title} = $locale->text('Receive Merchandise');
2274 $shipped = $locale->text('Date Received');
2277 # set option selected
2278 foreach $item (warehouse, employee) {
2279 $form->{"select$item"} =~ s/ selected//;
2280 $form->{"select$item"} =~
2281 s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2286 <th align=right>| . $locale->text('Warehouse') . qq|</th>
2287 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2288 <input type=hidden name=selectwarehouse value="$form->{selectwarehouse}">
2290 | if $form->{selectwarehouse};
2294 <th align=right nowrap>| . $locale->text('Contact') . qq|</th>
2295 <td><select name=employee>$form->{selectemployee}</select></td>
2296 <input type=hidden name=selectemployee value="$form->{selectemployee}">
2305 <form method=post action=$form->{script}>
2307 <input type=hidden name=id value=$form->{id}>
2309 <input type=hidden name=display_form value=display_ship_receive>
2311 <input type=hidden name=type value=$form->{type}>
2312 <input type=hidden name=media value=$form->{media}>
2313 <input type=hidden name=format value=$form->{format}>
2315 <input type=hidden name=queued value="$form->{queued}">
2316 <input type=hidden name=printed value="$form->{printed}">
2317 <input type=hidden name=emailed value="$form->{emailed}">
2319 <input type=hidden name=vc value=$form->{vc}>
2323 <th class=listtop>$form->{title}</th>
2325 <tr height="5"></tr>
2328 <table width="100%">
2333 <th align=right>$vclabel</th>
2334 <td colspan=3>$form->{$form->{vc}}</td>
2335 <input type=hidden name=$form->{vc} value="$form->{$form->{vc}}">
2336 <input type=hidden name="$form->{vc}_id" value=$form->{"$form->{vc}_id"}>
2340 <th align=right>| . $locale->text('Shipping Point') . qq|</th>
2342 <input name=shippingpoint size=35 value="$form->{shippingpoint}">
2345 <th align=right>| . $locale->text('Ship via') . qq|</th>
2347 <input name=shipvia size=35 value="$form->{shipvia}">
2356 <th align=right nowrap>| . $locale->text('Order Number') . qq|</th>
2357 <td>$form->{ordnumber}</td>
2358 <input type=hidden name=ordnumber value="$form->{ordnumber}">
2361 <th align=right nowrap>| . $locale->text('Order Date') . qq|</th>
2362 <td>$form->{transdate}</td>
2363 <input type=hidden name=transdate value=$form->{transdate}>
2366 <th align=right nowrap>$shipped</th>
2367 <td><input name=shippingdate size=11 value=$form->{shippingdate}></td>
2376 <!-- shipto are in hidden variables -->
2378 <input type=hidden name=shiptoname value="$form->{shiptoname}">
2379 <input type=hidden name=shiptostreet value="$form->{shiptostreet}">
2380 <input type=hidden name=shiptozipcode value="$form->{shiptozipcode}">
2381 <input type=hidden name=shiptocity value="$form->{shiptocity}">
2382 <input type=hidden name=shiptocountry value="$form->{shiptocountry}">
2383 <input type=hidden name=shiptocontact value="$form->{shiptocontact}">
2384 <input type=hidden name=shiptophone value="$form->{shiptophone}">
2385 <input type=hidden name=shiptofax value="$form->{shiptofax}">
2386 <input type=hidden name=shiptoemail value="$form->{shiptoemail}">
2388 <!-- email variables -->
2389 <input type=hidden name=message value="$form->{message}">
2390 <input type=hidden name=email value="$form->{email}">
2391 <input type=hidden name=subject value="$form->{subject}">
2392 <input type=hidden name=cc value="$form->{cc}">
2393 <input type=hidden name=bcc value="$form->{bcc}">
2398 (partnumber, description, qty, ship, unit, bin, serialnumber);
2400 if ($form->{type} eq "ship_order") {
2401 $column_data{ship} =
2402 qq|<th class=listheading align=center width="auto">|
2403 . $locale->text('Ship')
2406 if ($form->{type} eq "receive_order") {
2407 $column_data{ship} =
2408 qq|<th class=listheading align=center width="auto">|
2409 . $locale->text('Recd')
2413 my $colspan = $#column_index + 1;
2415 $column_data{partnumber} =
2416 qq|<th class=listheading nowrap>| . $locale->text('Number') . qq|</th>|;
2417 $column_data{description} =
2418 qq|<th class=listheading nowrap>|
2419 . $locale->text('Description')
2422 qq|<th class=listheading nowrap>| . $locale->text('Qty') . qq|</th>|;
2423 $column_data{unit} =
2424 qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
2426 qq|<th class=listheading nowrap>| . $locale->text('Bin') . qq|</th>|;
2427 $column_data{serialnumber} =
2428 qq|<th class=listheading nowrap>|
2429 . $locale->text('Serial No.')
2436 <tr class=listheading>|;
2438 map { print "\n$column_data{$_}" } @column_index;
2444 for $i (1 .. $form->{rowcount} - 1) {
2447 $form->{"ship_$i"} = $form->parse_amount(\%myconfig, $form->{"ship_$i"});
2449 # convert " to "
2450 map { $form->{"${_}_$i"} =~ s/\"/"/g }
2451 qw(partnumber description unit bin serialnumber);
2453 $description = $form->{"description_$i"};
2454 $description =~ s/\n/<br>/g;
2456 $column_data{partnumber} =
2457 qq|<td>$form->{"partnumber_$i"}<input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"></td>|;
2458 $column_data{description} =
2459 qq|<td>$description<input type=hidden name="description_$i" value="$form->{"description_$i"}"></td>|;
2461 qq|<td align=right>|
2462 . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty)
2463 . qq|<input type=hidden name="qty_$i" value="$form->{"qty_$i"}"></td>|;
2464 $column_data{ship} =
2465 qq|<td align=right><input name="ship_$i" size=5 value=|
2466 . $form->format_amount(\%myconfig, $form->{"ship_$i"})
2468 $column_data{unit} =
2469 qq|<td>$form->{"unit_$i"}<input type=hidden name="unit_$i" value="$form->{"unit_$i"}"></td>|;
2471 qq|<td>$form->{"bin_$i"}<input type=hidden name="bin_$i" value="$form->{"bin_$i"}"></td>|;
2473 $column_data{serialnumber} =
2474 qq|<td><input name="serialnumber_$i" size=15 value="$form->{"serialnumber_$i"}"></td>|;
2479 map { print "\n$column_data{$_}" } @column_index;
2484 <input type=hidden name="orderitems_id_$i" value=$form->{"orderitems_id_$i"}>
2485 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2486 <input type=hidden name="assembly_$i" value="$form->{"assembly_$i"}">
2487 <input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">
2498 <td><hr size=3 noshade></td>
2504 $form->{copies} = 1;
2513 <input class=submit type=submit name=action value="|
2514 . $locale->text('Update') . qq|">
2515 <input class=submit type=submit name=action value="|
2516 . $locale->text('Print') . qq|">
2519 if ($form->{type} eq 'ship_order') {
2521 <input class=submit type=submit name=action value="|
2522 . $locale->text('Ship to') . qq|">
2523 <input class=submit type=submit name=action value="|
2524 . $locale->text('E-mail') . qq|">
2530 <input class=submit type=submit name=action value="|
2531 . $locale->text('Done') . qq|">
2534 if ($form->{menubar}) {
2535 require "$form->{path}/menu.pl";
2541 <input type=hidden name=rowcount value=$form->{rowcount}>
2543 <input name=callback type=hidden value="$callback">
2545 <input type=hidden name=path value=$form->{path}>
2546 <input type=hidden name=login value=$form->{login}>
2547 <input type=hidden name=password value=$form->{password}>
2555 $lxdebug->leave_sub();
2559 $lxdebug->enter_sub();
2561 if ($form->{type} eq 'ship_order') {
2562 $form->isblank("shippingdate", $locale->text('Shipping Date missing!'));
2564 $form->isblank("shippingdate", $locale->text('Date received missing!'));
2569 $total += $form->{"ship_$_"} =
2570 $form->parse_amount(\%myconfig, $form->{"ship_$_"})
2571 } (1 .. $form->{rowcount} - 1);
2573 $form->error($locale->text('Nothing entered!')) unless $total;
2575 $form->redirect($locale->text('Inventory saved!'))
2576 if OE->save_inventory(\%myconfig, \%$form);
2577 $form->error($locale->text('Could not save!'));
2579 $lxdebug->leave_sub();
2582 sub search_transfer {
2583 $lxdebug->enter_sub();
2585 OE->get_warehouses(\%myconfig, \%$form);
2588 if (@{ $form->{all_warehouses} }) {
2589 $form->{selectwarehouse} = "<option>\n";
2590 $form->{warehouse} = qq|$form->{warehouse}--$form->{warehouse_id}|;
2592 map { $form->{selectwarehouse} .= "<option>$_->{description}--$_->{id}\n" }
2593 (@{ $form->{all_warehouses} });
2595 $form->error($locale->text('Nothing to transfer!'));
2598 $form->{title} = $locale->text('Transfer Inventory');
2605 <form method=post action=$form->{script}>
2609 <th class=listtop>$form->{title}</th>
2611 <tr height="5"></tr>
2616 <th align=right nowrap>| . $locale->text('Transfer to') . qq|</th>
2617 <td><select name=warehouse>$form->{selectwarehouse}</select></td>
2620 <th align="right" nowrap="true">| . $locale->text('Part Number') . qq|</th>
2621 <td><input name=partnumber size=20></td>
2624 <th align="right" nowrap="true">| . $locale->text('Description') . qq|</th>
2625 <td><input name=description size=40></td>
2628 <th align=right nowrap>| . $locale->text('Group') . qq|</th>
2629 <td><input name=partsgroup size=20></td>
2635 <td><hr size=3 noshade></td>
2640 <input type=hidden name=sort value=partnumber>
2641 <input type=hidden name=nextsub value=list_transfer>
2643 <input type=hidden name=path value=$form->{path}>
2644 <input type=hidden name=login value=$form->{login}>
2645 <input type=hidden name=password value=$form->{password}>
2647 <input class=submit type=submit name=action value="|
2648 . $locale->text('Continue') . qq|">
2655 $lxdebug->leave_sub();
2659 $lxdebug->enter_sub();
2661 OE->get_inventory(\%myconfig, \%$form);
2663 $partnumber = $form->escape($form->{partnumber});
2664 $warehouse = $form->escape($form->{warehouse});
2665 $description = $form->escape($form->{description});
2666 $partsgroup = $form->escape($form->{partsgroup});
2670 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2672 # construct callback
2673 $partnumber = $form->escape($form->{partnumber}, 1);
2674 $warehouse = $form->escape($form->{warehouse}, 1);
2675 $description = $form->escape($form->{description}, 1);
2676 $partsgroup = $form->escape($form->{partsgroup}, 1);
2679 "$form->{script}?path=$form->{path}&action=list_transfer&partnumber=$partnumber&warehouse=$warehouse&description=$description&partsgroup=$partsgroup&login=$form->{login}&password=$form->{password}";
2682 $form->sort_columns(
2683 qw(partnumber description partsgroup make model warehouse qty transfer));
2685 $column_header{partnumber} =
2686 qq|<th><a class=listheading href=$href&sort=partnumber>|
2687 . $locale->text('Part Number')
2689 $column_header{description} =
2690 qq|<th><a class=listheading href=$href&sort=description>|
2691 . $locale->text('Description')
2693 $column_header{partsgroup} =
2694 qq|<th><a class=listheading href=$href&sort=partsgroup>|
2695 . $locale->text('Group')
2697 $column_header{warehouse} =
2698 qq|<th><a class=listheading href=$href&sort=warehouse>|
2699 . $locale->text('From')
2701 $column_header{qty} =
2702 qq|<th><a class=listheading>| . $locale->text('Qty') . qq|</a></th>|;
2703 $column_header{transfer} =
2704 qq|<th><a class=listheading>| . $locale->text('Transfer') . qq|</a></th>|;
2706 $option = $locale->text('Transfer to');
2708 ($warehouse, $warehouse_id) = split /--/, $form->{warehouse};
2710 if ($form->{warehouse}) {
2711 $option .= " : $warehouse";
2713 if ($form->{partnumber}) {
2714 $option .= "\n<br>" if ($option);
2715 $option .= $locale->text('Part Number') . " : $form->{partnumber}";
2717 if ($form->{description}) {
2718 $option .= "\n<br>" if ($option);
2719 $option .= $locale->text('Description') . " : $form->{description}";
2721 if ($form->{partsgroup}) {
2722 $option .= "\n<br>" if ($option);
2723 $option .= $locale->text('Group') . " : $form->{partsgroup}";
2726 $form->{title} = $locale->text('Transfer Inventory');
2733 <form method=post action=$form->{script}>
2735 <input type=hidden name=warehouse_id value=$warehouse_id>
2739 <th class=listtop>$form->{title}</th>
2741 <tr height="5"></tr>
2748 <tr class=listheading>|;
2750 map { print "\n$column_header{$_}" } @column_index;
2756 if (@{ $form->{all_inventory} }) {
2757 $sameitem = $form->{all_inventory}->[0]->{ $form->{sort} };
2761 foreach $ref (@{ $form->{all_inventory} }) {
2765 $column_data{partnumber} =
2766 qq|<td><input type=hidden name="id_$i" value=$ref->{id}>$ref->{partnumber}</td>|;
2767 $column_data{description} = "<td>$ref->{description} </td>";
2768 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
2769 $column_data{warehouse} =
2770 qq|<td><input type=hidden name="warehouse_id_$i" value=$ref->{warehouse_id}>$ref->{warehouse} </td>|;
2772 qq|<td><input type=hidden name="qty_$i" value=$ref->{qty}>|
2773 . $form->format_amount(\%myconfig, $ref->{qty}, $dec_qty)
2775 $column_data{transfer} = qq|<td><input name="transfer_$i" size=4></td>|;
2780 <tr class=listrow$j>";
2782 map { print "\n$column_data{$_}" } @column_index;
2796 <td><hr size=3 noshade></td>
2802 <input name=callback type=hidden value="$callback">
2804 <input type=hidden name=rowcount value=$i>
2806 <input type=hidden name=path value=$form->{path}>
2807 <input type=hidden name=login value=$form->{login}>
2808 <input type=hidden name=password value=$form->{password}>
2810 <input class=submit type=submit name=action value="|
2811 . $locale->text('Transfer') . qq|">|;
2813 if ($form->{menubar}) {
2814 require "$form->{path}/menu.pl";
2825 $lxdebug->leave_sub();
2829 $lxdebug->enter_sub();
2831 $form->redirect($locale->text('Inventory transferred!'))
2832 if OE->transfer(\%myconfig, \%$form);
2833 $form->error($locale->text('Could not transfer Inventory!'));
2835 $lxdebug->leave_sub();