1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
7 #=====================================================================
8 # SQL-Ledger, Accounting
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 #======================================================================
30 # Inventory Control module
32 #======================================================================
37 require "$form->{path}/io.pl";
43 $lxdebug->enter_sub();
45 $form->{title} = $locale->text('Add ' . ucfirst $form->{item});
47 $form->{callback} = "$form->{script}?action=add&item=$form->{item}&path=$form->{path}&login=$form->{login}&password=$form->{password}" unless $form->{callback};
49 $form->{unit} = ($form->{item} eq 'service') ? $locale->text('hr') : $locale->text('ea');
54 $lxdebug->leave_sub();
58 $lxdebug->enter_sub();
60 $form->{title} = (ucfirst $form->{searchitems})."s";
61 $form->{title} = $locale->text($form->{title});
63 # switch for backward sorting
65 # memory for which table was sort at last time
66 $form->{lastsort} = "";
67 # counter for added entries to top100
68 $form->{ndxs_counter} = 0;
70 # $locale->text('Parts')
71 # $locale->text('Services')
73 # use JavaScript Calendar or not
74 $form->{jsscript} = $jscalendar;
76 if ($form->{jsscript})
78 # with JavaScript Calendar
80 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>
81 <td><input type=button name=transdatefrom id="trigger1" value=|.$locale->text('button').qq|></td>
84 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>
85 <td><input type=button name=transdateto name=transdateto id="trigger2" value=|.$locale->text('button').qq|></td>
88 $jsscript = Form->write_trigger(\%myconfig,"2","transdatefrom","BL","trigger1","transdateto","BL","trigger2");
92 # without JavaScript Calendar
94 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
96 <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
99 unless ($form->{searchitems} eq 'service') {
102 <input name=itemstatus class=radio type=radio value=onhand> |.$locale->text('On Hand').qq|
103 <input name=itemstatus class=radio type=radio value=short> |.$locale->text('Short').qq|
108 <th align=right nowrap>|.$locale->text('Make').qq|</th>
109 <td><input name=make size=20></td>
110 <th align=right nowrap>|.$locale->text('Model').qq|</th>
111 <td><input name=model size=20></td>
116 <th align=right nowrap>|.$locale->text('Serial Number').qq|</th>
117 <td><input name=serialnumber size=20></td>
120 $l_serialnumber = qq|
121 <td><input name=l_serialnumber class=checkbox type=checkbox value=Y> |.$locale->text('Serial Number').qq|</td>
126 if ($form->{searchitems} eq 'assembly') {
128 $form->{title} = $locale->text('Assemblies');
134 <input name=null class=radio type=radio value=1 checked> |.$locale->text('Top Level').qq|
135 <input name=bom class=checkbox type=checkbox value=1> |.$locale->text('Individual Items').qq|
149 <td><input name=sold class=checkbox type=checkbox value=1></td>
150 <td nowrap>|.$locale->text('Sold').qq|</td>
153 <td colspan=2><hr size=1 noshade></td>
156 <td><input name=ordered class=checkbox type=checkbox value=1></td>
157 <td nowrap>|.$locale->text('Ordered').qq|</td>
160 <td colspan=4><hr size=1 noshade></td>
163 <td><input name=quoted class=checkbox type=checkbox value=1></td>
164 <td nowrap>|.$locale->text('Quoted').qq|</td>
168 <td width=5%> </td>
169 <th>|.$locale->text('From').qq|</th>
171 <th>|.$locale->text('To').qq|</th>
190 <td><input name=bought class=checkbox type=checkbox value=1></td>
191 <td nowrap>|.$locale->text('Bought').qq|</td>
192 <td><input name=sold class=checkbox type=checkbox value=1></td>
193 <td nowrap>|.$locale->text('Sold').qq|</td>
196 <td colspan=4><hr size=1 noshade></td>
199 <td><input name=onorder class=checkbox type=checkbox value=1></td>
200 <td nowrap>|.$locale->text('On Order').qq|</td>
201 <td><input name=ordered class=checkbox type=checkbox value=1></td>
202 <td nowrap>|.$locale->text('Ordered').qq|</td>
205 <td colspan=4><hr size=1 noshade></td>
208 <td><input name=rfq class=checkbox type=checkbox value=1></td>
209 <td nowrap>|.$locale->text('RFQ').qq|</td>
210 <td><input name=quoted class=checkbox type=checkbox value=1></td>
211 <td nowrap>|.$locale->text('Quoted').qq|</td>
215 <td width=5%> </td>
219 <th>|.$locale->text('From').qq|</th>
221 <th>|.$locale->text('To').qq|</th>
238 <form method=post action=$form->{script}>
240 <input type=hidden name=searchitems value=$form->{searchitems}>
241 <input type=hidden name=title value="$form->{title}">
243 <input type=hidden name=revers value="$form->{revers}">
244 <input type=hidden name=lastsort value="$form->{lastsort}">
247 <tr><th class=listtop>$form->{title}</th></tr>
253 <th align=right nowrap>|.$locale->text('Part Number').qq|</th>
254 <td><input name=partnumber size=20></td>
257 <th align=right nowrap>|.$locale->text('Part Description').qq|</th>
258 <td colspan=3><input name=description size=40></td>
261 <th align=right nowrap>|.$locale->text('Group').qq|</th>
262 <td><input name=partsgroup size=20></td>
267 <th align=right nowrap>|.$locale->text('Drawing').qq|</th>
268 <td><input name=drawing size=20></td>
269 <th align=right nowrap>|.$locale->text('Microfiche').qq|</th>
270 <td><input name=microfiche size=20></td>
276 <input name=itemstatus class=radio type=radio value=active checked> |.$locale->text('Active').qq|
278 <input name=itemstatus class=radio type=radio value=obsolete> |.$locale->text('Obsolete').qq|
279 <input name=itemstatus class=radio type=radio value=orphaned> |.$locale->text('Orphaned').qq|
290 <th align=right nowrap>|.$locale->text('Include in Report').qq|</th>
294 <td><input name=l_partnumber class=checkbox type=checkbox value=Y checked> |.$locale->text('Part Number').qq|</td>
295 <td><input name=l_description class=checkbox type=checkbox value=Y checked> |.$locale->text('Part Description').qq|</td>
297 <td><input name=l_unit class=checkbox type=checkbox value=Y checked> |.$locale->text('Unit of measure').qq|</td>
300 <td><input name=l_listprice class=checkbox type=checkbox value=Y> |.$locale->text('List Price').qq|</td>
301 <td><input name=l_sellprice class=checkbox type=checkbox value=Y checked> |.$locale->text('Sell Price').qq|</td>
302 <td><input name=l_lastcost class=checkbox type=checkbox value=Y> |.$locale->text('Last Cost').qq|</td>
303 <td><input name=l_linetotal class=checkbox type=checkbox value=Y checked> |.$locale->text('Line Total').qq|</td>
306 <td><input name=l_priceupdate class=checkbox type=checkbox value=Y> |.$locale->text('Updated').qq|</td>
307 <td><input name=l_bin class=checkbox type=checkbox value=Y> |.$locale->text('Bin').qq|</td>
308 <td><input name=l_rop class=checkbox type=checkbox value=Y> |.$locale->text('ROP').qq|</td>
309 <td><input name=l_weight class=checkbox type=checkbox value=Y> |.$locale->text('Weight').qq|</td>
312 <td><input name=l_image class=checkbox type=checkbox value=Y> |.$locale->text('Image').qq|</td>
313 <td><input name=l_drawing class=checkbox type=checkbox value=Y> |.$locale->text('Drawing').qq|</td>
314 <td><input name=l_microfiche class=checkbox type=checkbox value=Y> |.$locale->text('Microfiche').qq|</td>
315 <td><input name=l_partsgroup class=checkbox type=checkbox value=Y> |.$locale->text('Group').qq|</td>
318 <td><input name=l_subtotal class=checkbox type=checkbox value=Y> |.$locale->text('Subtotal').qq|</td>
319 <td><input name=l_soldtotal class=checkbox type=checkbox value=Y> |.$locale->text('soldtotal').qq|</td>
327 <tr><td colspan=4><hr size=3 noshade></td></tr>
332 <input type=hidden name=nextsub value=generate_report>
334 <input type=hidden name=path value=$form->{path}>
335 <input type=hidden name=login value=$form->{login}>
336 <input type=hidden name=password value=$form->{password}>
338 <input type=hidden name=revers value="$form->{revers}">
339 <input type=hidden name=lastsort value="$form->{lastsort}">
341 <input type=hidden name=ndxs_counter value="$form->{ndxs_counter}">
344 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
345 <input class=submit type=submit name=action value="|.$locale->text('TOP100').qq|">
351 $lxdebug->leave_sub();
356 $lxdebug->enter_sub();
358 $form->{title} = $locale->text('Top 100 hinzufuegen');
365 <form method=post action=$form->{script}>
367 <input type=hidden name=searchitems value=$form->{searchitems}>
368 <input type=hidden name=title value="$form->{title}">
370 <input type=hidden name=revers value="$form->{revers}">
371 <input type=hidden name=lastsort value="$form->{lastsort}">|;
376 <tr class=listheading>
377 <th class=listheading nowrap>|.$locale->text('Part Number').qq|</th>
378 <th class=listheading nowrap>|.$locale->text('Part Description').qq|</th>
381 <td><input type=text name=partnumber size=20 value=></td>
382 <td><input type=text name=description size=30 value=></td>
389 <input type=hidden name=path value=$form->{path}>
390 <input type=hidden name=login value=$form->{login}>
391 <input type=hidden name=password value=$form->{password}>
393 <input type=hidden name=itemstatus value="$form->{itemstatus}">
394 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
395 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
396 <input type=hidden name=l_description value="$form->{l_description}">
397 <input type=hidden name=l_onhand value="$form->{l_onhand}">
398 <input type=hidden name=l_unit value="$form->{l_unit}">
399 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
400 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
401 <input type=hidden name=sort value="$form->{sort}">
402 <input type=hidden name=revers value="$form->{revers}">
403 <input type=hidden name=lastsort value="$form->{lastsort}">
405 <input type=hidden name=bom value="$form->{bom}">
406 <input type=hidden name=titel value="$form->{titel}">
407 <input type=hidden name=searchitems value="$form->{searchitems}">
409 <input type=hidden name=row value=$j>
411 <input type=hidden name=nextsub value=item_selected>
413 <input type=hidden name=test value=item_selected>
415 <input name=lastndx type=hidden value=$lastndx>
417 <input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>
419 <input name=extras type=hidden value=$form->{extras}>|;
424 for($i=0;$i<$form->{ndxs_counter};$i++)
427 $partnumber=$form->{"totop100_partnumber_$j"};
428 $description=$form->{"totop100_description_$j"};
429 $unit=$form->{"totop100_unit_$j"};
430 $sellprice=$form->{"totop100_sellprice_$j"};
431 $soldtotal=$form->{"totop100_soldtotal_$j"};
433 # insert data into top100
434 push @{$form->{parts}},{number => "",partnumber => "$partnumber",description => "$description",unit => "$unit",sellprice => "$sellprice", soldtotal => "$soldtotal"};
440 # set data for next page
441 if (($form->{ndxs_counter})>0)
443 for($i=1;($i<$form->{ndxs_counter}+1);$i++)
445 $partnumber=$form->{"totop100_partnumber_$i"};
446 $description=$form->{"totop100_description_$i"};
447 $unit=$form->{"totop100_unit_$i"};
448 $sellprice=$form->{"totop100_sellprice_$i"};
449 $soldtotal=$form->{"totop100_soldtotal_$i"};
452 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
453 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
454 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
455 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
456 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
464 <input class=submit type=submit name=action value="|.$locale->text('list').qq|">
469 $lxdebug->leave_sub();
475 $lxdebug->enter_sub();
478 if (($form->{partnumber} eq "") and ($form->{description} eq ""))
480 IC->get_parts(\%myconfig, \%$form, "");
484 if ((!($form->{partnumber} eq "")) and ($form->{description} eq ""))
486 IC->get_parts(\%myconfig, \%$form, "partnumber");
490 if (($form->{partnumber} eq "") and (!($form->{description} eq "")))
492 IC->get_parts(\%myconfig, \%$form, "description");
496 IC->get_parts(\%myconfig, \%$form, "all");
501 $form->{title} = $locale->text('Top 100 hinzufuegen');
507 <form method=post action=ic.pl>
510 <th class=listtop colspan=6>|.$locale->text('choice part').qq|</th>
513 <tr class=listheading>
515 <th class=listheading>|.$locale->text('Part Number').qq|</th>
516 <th class=listheading>|.$locale->text('Part Description').qq|</th>
517 <th class=listheading>|.$locale->text('Unit of measure').qq|</th>
518 <th class=listheading>|.$locale->text('Sell Price').qq|</th>
519 <th class=listheading>|.$locale->text('soldtotal').qq|</th>
525 for ($j=1; $j<=$i; $j++){
528 <tr class=listrow1>|;
531 <td><input name=ndx class=radio type=radio value=$j checked></td>|;
535 <td><input name=ndx class=radio type=radio value=$j></td>|;
538 <td><input name="new_partnumber_$j" type=hidden value="$form->{"partnumber_$j"}">$form->{"partnumber_$j"}</td>
539 <td><input name="new_description_$j" type=hidden value="$form->{"description_$j"}">$form->{"description_$j"}</td>
540 <td><input name="new_unit_$j" type=hidden value="$form->{"unit_$j"}">$form->{"unit_$j"}</td>
541 <td><input name="new_sellprice_$j" type=hidden value="$form->{"sellprice_$j"}">$form->{"sellprice_$j"}</td>
542 <td><input name="new_soldtotal_$j" type=hidden value="$form->{"soldtotal_$j"}">$form->{"soldtotal_$j"}</td>
545 <input name="new_id_$j" type=hidden value="$form->{"id_$j"}">|;
555 <input type=hidden name=path value=$form->{path}>
556 <input type=hidden name=login value=$form->{login}>
557 <input type=hidden name=password value=$form->{password}>
559 <input type=hidden name=itemstatus value="$form->{itemstatus}">
560 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
561 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
562 <input type=hidden name=l_description value="$form->{l_description}">
563 <input type=hidden name=l_onhand value="$form->{l_onhand}">
564 <input type=hidden name=l_unit value="$form->{l_unit}">
565 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
566 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
567 <input type=hidden name=sort value="$form->{sort}">
568 <input type=hidden name=revers value="$form->{revers}">
569 <input type=hidden name=lastsort value="$form->{lastsort}">
571 <input type=hidden name=bom value="$form->{bom}">
572 <input type=hidden name=titel value="$form->{titel}">
573 <input type=hidden name=searchitems value="$form->{searchitems}">
575 <input type=hidden name=row value=$j>
577 <input type=hidden name=nextsub value=item_selected>
579 <input name=lastndx type=hidden value=$lastndx>
581 <input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>|;
586 if (($form->{ndxs_counter})>0)
588 for($i=1;($i<$form->{ndxs_counter}+1);$i++)
590 $j1=$form->{"totop100_partnumber_$i"};
591 $j2=$form->{"totop100_description_$i"};
592 $j3=$form->{"totop100_unit_$i"};
593 $j4=$form->{"totop100_sellprice_$i"};
594 $j5=$form->{"totop100_soldtotal_$i"};
603 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
604 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
605 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
606 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
607 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
615 <input class=submit type=submit name=action value="|.$locale->text('TOP100').qq|">
621 $lxdebug->leave_sub();
626 $lxdebug->enter_sub();
629 $form->{ndxs_counter}++;
631 if ($form->{ndxs_counter}>0){
633 $index = $form->{ndx};
635 $j1 = $form->{"new_partnumber_$index"};
636 $form->{"totop100_partnumber_$form->{ndxs_counter}"} =$j1;
637 $j2 = $form->{"new_description_$index"};
638 $form->{"totop100_description_$form->{ndxs_counter}"} = $j2;
639 $j3 = $form->{"new_unit_$index"};
640 $form->{"totop100_unit_$form->{ndxs_counter}"} = $j3;
641 $j4 = $form->{"new_sellprice_$index"};
642 $form->{"totop100_sellprice_$form->{ndxs_counter}"} = $j4;
643 $j5 = $form->{"new_soldtotal_$index"};
644 $form->{"totop100_soldtotal_$form->{ndxs_counter}"} = $j5;
648 $lxdebug->leave_sub();
653 $lxdebug->enter_sub();
655 $form->{top100} = "top100";
656 $form->{l_soldtotal} = "Y";
657 $form->{soldtotal} = "soldtotal";
658 $form->{sort} = "soldtotal";
659 $form->{l_qty} = "N";
660 $callback .= "&form->{top100}=$form->{top100}";
661 $form->{l_linetotal} = "";
663 $form->{number} = "position";
664 $form->{l_number} = "Y";
668 $form->{title} = $locale->text('Top 100');
670 $revers = $form->{revers};
671 $lastsort = $form->{lastsort};
673 if (($form->{lastsort} eq "")&&($form->{sort} eq undef))
676 $form->{lastsort} = "partnumber";
677 $form->{sort} = "partnumber";
680 $callback = "$form->{script}?action=top100&path=$form->{path}&login=$form->{login}&password=$form->{password}&searchitems=$form->{searchitems}&itemstatus=$form->{itemstatus}&bom=$form->{bom}&l_linetotal=$form->{l_linetotal}&title=".$form->escape($form->{title},1);
682 # if we have a serialnumber limit search
683 if ($form->{serialnumber} || $form->{l_serialnumber}) {
684 $form->{l_serialnumber} = "Y";
685 unless ($form->{bought} || $form->{sold} || $form->{rfq} || $form->{quoted}) {
686 $form->{bought} = $form->{sold} = 1;
689 IC->all_parts(\%myconfig, \%$form);
691 if ($form->{itemstatus} eq 'active') {
692 $option .= $locale->text('Active')." : ";
694 if ($form->{itemstatus} eq 'obsolete') {
695 $option .= $locale->text('Obsolete')." : ";
697 if ($form->{itemstatus} eq 'orphaned') {
698 $option .= $locale->text('Orphaned')." : ";
700 if ($form->{itemstatus} eq 'onhand') {
701 $option .= $locale->text('On Hand')." : ";
702 $form->{l_onhand} = "Y";
704 if ($form->{itemstatus} eq 'short') {
705 $option .= $locale->text('Short')." : ";
706 $form->{l_onhand} = "Y";
708 if ($form->{onorder}) {
709 $form->{l_ordnumber} = "Y";
710 $callback .= "&onorder=$form->{onorder}";
711 $option .= $locale->text('On Order')." : ";
713 if ($form->{ordered}) {
714 $form->{l_ordnumber} = "Y";
715 $callback .= "&ordered=$form->{ordered}";
716 $option .= $locale->text('Ordered')." : ";
719 $form->{l_quonumber} = "Y";
720 $callback .= "&rfq=$form->{rfq}";
721 $option .= $locale->text('RFQ')." : ";
723 if ($form->{quoted}) {
724 $form->{l_quonumber} = "Y";
725 $callback .= ""ed=$form->{quoted}";
726 $option .= $locale->text('Quoted')." : ";
728 if ($form->{bought}) {
729 $form->{l_invnumber} = "Y";
730 $callback .= "&bought=$form->{bought}";
731 $option .= $locale->text('Bought')." : ";
734 $form->{l_invnumber} = "Y";
735 $callback .= "&sold=$form->{sold}";
736 $option .= $locale->text('Sold')." : ";
738 if ($form->{bought} || $form->{sold} || $form->{onorder} || $form->{ordered} || $form->{rfq} || $form->{quoted}) {
740 $form->{l_lastcost} = "";
741 $form->{l_name} = "Y";
742 if ($form->{transdatefrom}) {
743 $callback .= "&transdatefrom=$form->{transdatefrom}";
744 $option .= "\n<br>".$locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
746 if ($form->{transdateto}) {
747 $callback .= "&transdateto=$form->{transdateto}";
748 $option .= "\n<br>".$locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1);
754 if ($form->{partnumber}) {
755 $callback .= "&partnumber=$form->{partnumber}";
756 $option .= $locale->text('Part Number').qq| : $form->{partnumber}<br>|;
758 if ($form->{partsgroup}) {
759 $callback .= "&partsgroup=$form->{partsgroup}";
760 $option .= $locale->text('Group').qq| : $form->{partsgroup}<br>|;
762 if ($form->{serialnumber}) {
763 $callback .= "&serialnumber=$form->{serialnumber}";
764 $option .= $locale->text('Serial Number').qq| : $form->{serialnumber}<br>|;
766 if ($form->{description}) {
767 $callback .= "&description=$form->{description}";
768 $description = $form->{description};
771 $option .= $locale->text('Part Description').qq| : $form->{description}<br>|;
774 $callback .= "&make=$form->{make}";
775 $option .= $locale->text('Make').qq| : $form->{make}<br>|;
777 if ($form->{model}) {
778 $callback .= "&model=$form->{model}";
779 $option .= $locale->text('Model').qq| : $form->{model}<br>|;
781 if ($form->{drawing}) {
782 $callback .= "&drawing=$form->{drawing}";
783 $option .= $locale->text('Drawing').qq| : $form->{drawing}<br>|;
785 if ($form->{microfiche}) {
786 $callback .= "µfiche=$form->{microfiche}";
787 $option .= $locale->text('Microfiche').qq| : $form->{microfiche}<br>|;
789 if ($form->{l_soldtotal})
791 $callback .= "&soldtotal=$form->{soldtotal}";
792 $option .= $locale->text('soldtotal').qq| : $form->{soldtotal}<br>|;
795 @columns = $form->sort_columns(qw(number partnumber description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal));
797 if ($form->{l_linetotal}) {
798 $form->{l_onhand} = "Y";
799 $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
800 if ($form->{l_lastcost}) {
801 $form->{l_linetotallastcost} = "Y";
802 if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
803 $form->{l_linetotallastcost} = "";
806 $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
809 if ($form->{searchitems} eq 'service') {
810 # remove bin, weight and rop from list
811 map { $form->{"l_$_"} = "" } qw(bin weight rop);
813 $form->{l_onhand} = "";
814 # qty is irrelevant unless bought or sold
815 if ($form->{bought} || $form->{sold} || $form->{onorder} ||
816 $form->{ordered} || $form->{rfq} || $form->{quoted}) {
817 $form->{l_onhand} = "Y";
819 $form->{l_linetotalsellprice} = "";
820 $form->{l_linetotallastcost} = "";
824 $form->{l_lastcost} = "" if ($form->{searchitems} eq 'assembly' && !$form->{bom});
826 foreach $item (@columns) {
827 if ($form->{"l_$item"} eq "Y") {
828 push @column_index, $item;
830 # add column to callback
831 $callback .= "&l_$item=Y";
835 if ($form->{l_subtotal} eq 'Y') {
836 $callback .= "&l_subtotal=Y";
839 $column_header{number} = qq|<th class=listheading nowrap>|.$locale->text('number').qq|</th>|;
840 $column_header{partnumber} = qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|.$locale->text('Part Number').qq|</a></th>|;
841 $column_header{description} = qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|.$locale->text('Part Description').qq|</a></th>|;
842 $column_header{partsgroup} = qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|.$locale->text('Group').qq|</a></th>|;
843 $column_header{bin} = qq|<th><a class=listheading href=$callback&sort=bin>|.$locale->text('Bin').qq|</a></th>|;
844 $column_header{priceupdate} = qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|.$locale->text('Updated').qq|</a></th>|;
845 $column_header{onhand} = qq|<th nowrap><a class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|.$locale->text('Qty').qq|</th>|;
846 $column_header{unit} = qq|<th class=listheading nowrap>|.$locale->text('Unit').qq|</th>|;
847 $column_header{listprice} = qq|<th class=listheading nowrap>|.$locale->text('List Price').qq|</th>|;
848 $column_header{lastcost} = qq|<th class=listheading nowrap>|.$locale->text('Last Cost').qq|</th>|;
849 $column_header{rop} = qq|<th class=listheading nowrap>|.$locale->text('ROP').qq|</th>|;
850 $column_header{weight} = qq|<th class=listheading nowrap>|.$locale->text('Weight').qq|</th>|;
852 $column_header{invnumber} = qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|.$locale->text('Invoice Number').qq|</a></th>|;
853 $column_header{ordnumber} = qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|.$locale->text('Order Number').qq|</a></th>|;
854 $column_header{quonumber} = qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|.$locale->text('Quotation').qq|</a></th>|;
856 $column_header{name} = qq|<th nowrap><a class=listheading href=$callback&sort=name>|.$locale->text('Name').qq|</a></th>|;
858 $column_header{sellprice} = qq|<th class=listheading nowrap>|.$locale->text('Sell Price').qq|</th>|;
859 $column_header{linetotalsellprice} = qq|<th class=listheading nowrap>|.$locale->text('Extended').qq|</th>|;
860 $column_header{linetotallastcost} = qq|<th class=listheading nowrap>|.$locale->text('Extended').qq|</th>|;
861 $column_header{linetotallistprice} = qq|<th class=listheading nowrap>|.$locale->text('Extended').qq|</th>|;
863 $column_header{image} = qq|<th class=listheading nowrap>|.$locale->text('Image').qq|</a></th>|;
864 $column_header{drawing} = qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|.$locale->text('Drawing').qq|</a></th>|;
865 $column_header{microfiche} = qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|.$locale->text('Microfiche').qq|</a></th>|;
867 $column_header{serialnumber} = qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|.$locale->text('Serial Number').qq|</a></th>|;
868 $column_header{soldtotal} = qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|.$locale->text('soldtotal').qq|</a></th>|;
871 $colspan = $#column_index + 1;
878 <th class=listtop colspan=$colspan>$form->{title}</th>
882 <tr><td colspan=$colspan>$option</td></tr>
884 <tr class=listheading>
887 map { print "\n$column_header{$_}" } @column_index;
893 # add order to callback
894 $form->{callback} = $callback .= "&sort=$form->{sort}";
896 # escape callback for href
897 $callback = $form->escape($callback);
899 if (@{ $form->{parts} }) {
900 $sameitem = $form->{parts}->[0]->{$form->{sort}};
902 # insert numbers for top100
904 foreach $ref (@{ $form->{parts} }) {
908 # if avaible -> insert choice here
909 if (($form->{ndxs_counter})>0)
911 for($i=1;($i<$form->{ndxs_counter}+1);$i++)
913 $partnumber=$form->{"totop100_partnumber_$i"};
914 $description=$form->{"totop100_description_$i"};
915 $unit=$form->{"totop100_unit_$i"};
916 $sellprice=$form->{"totop100_sellprice_$i"};
917 $soldtotal=$form->{"totop100_soldtotal_$i"};
920 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
921 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
922 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
923 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
924 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
927 push @{$form->{parts}},{number => "",partnumber => "$partnumber",description => "$description",unit => "$unit",sellprice => "$sellprice", soldtotal => "$soldtotal"};
930 # build data for columns
931 foreach $ref (@{ $form->{parts} }) {
933 if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
934 if ($sameitem ne $ref->{$form->{sort}}) {
936 $sameitem = $ref->{$form->{sort}};
940 $ref->{exchangerate} = 1 unless $ref->{exchangerate};
941 $ref->{sellprice} *= $ref->{exchangerate};
942 $ref->{listprice} *= $ref->{exchangerate};
943 $ref->{lastcost} *= $ref->{exchangerate};
945 # use this for assemblies
946 $onhand = $ref->{onhand};
949 if ($ref->{assemblyitem}) {
951 $onhand = 0 if ($form->{sold});
954 $ref->{description} =~ s/
957 $column_data{number} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{number}, '', " ")."</td>";
958 $column_data{partnumber} = "<td align=$align>$ref->{partnumber} </a></td>";
959 $column_data{description} = "<td>$ref->{description} </td>";
960 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
962 $column_data{onhand} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{onhand}, '', " ")."</td>";
963 $column_data{sellprice} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ") . "</td>";
964 $column_data{listprice} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{listprice}, 2, " ") . "</td>";
965 $column_data{lastcost} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{lastcost}, 2, " ") . "</td>";
967 $column_data{linetotalsellprice} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice}, 2, " ")."</td>";
968 $column_data{linetotallastcost} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost}, 2, " ")."</td>";
969 $column_data{linetotallistprice} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice}, 2, " ")."</td>";
971 if (!$ref->{assemblyitem}) {
972 $totalsellprice += $onhand * $ref->{sellprice};
973 $totallastcost += $onhand * $ref->{lastcost};
974 $totallistprice += $onhand * $ref->{listprice};
976 $subtotalonhand += $onhand;
977 $subtotalsellprice += $onhand * $ref->{sellprice};
978 $subtotallastcost += $onhand * $ref->{lastcost};
979 $subtotallistprice += $onhand * $ref->{listprice};
982 $column_data{rop} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{rop}, '', " ")."</td>";
983 $column_data{weight} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{weight}, '', " ")."</td>";
984 $column_data{unit} = "<td>$ref->{unit} </td>";
985 $column_data{bin} = "<td>$ref->{bin} </td>";
986 $column_data{priceupdate} = "<td>$ref->{priceupdate} </td>";
988 $column_data{invnumber} = ($ref->{module} ne 'oe') ? "<td><a href=$ref->{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}</a></td>" : "<td>$ref->{invnumber}</td>";
989 $column_data{ordnumber} = ($ref->{module} eq 'oe') ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber}</a></td>" : "<td>$ref->{ordnumber}</td>";
990 $column_data{quonumber} = ($ref->{module} eq 'oe' && !$ref->{ordnumber}) ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber}</a></td>" : "<td>$ref->{quonumber}</td>";
992 $column_data{name} = "<td>$ref->{name}</td>";
994 $column_data{image} = ($ref->{image}) ? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>" : "<td> </td>";
995 $column_data{drawing} = ($ref->{drawing}) ? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>" : "<td> </td>";
996 $column_data{microfiche} = ($ref->{microfiche}) ? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>" : "<td> </td>";
998 $column_data{serialnumber} = "<td>$ref->{serialnumber}</td>";
1000 $column_data{soldtotal} = "<td align=right>$ref->{soldtotal}</td>";
1003 print "<tr class=listrow$i>";
1005 map { print "\n$column_data{$_}" } @column_index;
1012 if ($form->{l_subtotal} eq 'Y') {
1016 if ($form->{"l_linetotal"}) {
1017 map { $column_data{$_} = "<td> </td>" } @column_index;
1018 $column_data{linetotalsellprice} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalsellprice, 2, " ")."</th>";
1019 $column_data{linetotallastcost} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totallastcost, 2, " ")."</th>";
1020 $column_data{linetotallistprice} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totallistprice, 2, " ")."</th>";
1022 print "<tr class=listtotal>";
1024 map { print "\n$column_data{$_}" } @column_index;
1031 <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
1040 <form method=post action=$form->{script}>
1042 <input type=hidden name=path value=$form->{path}>
1043 <input type=hidden name=login value=$form->{login}>
1044 <input type=hidden name=password value=$form->{password}>
1046 <input type=hidden name=itemstatus value="$form->{itemstatus}">
1047 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
1048 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
1049 <input type=hidden name=l_description value="$form->{l_description}">
1050 <input type=hidden name=l_onhand value="$form->{l_onhand}">
1051 <input type=hidden name=l_unit value="$form->{l_unit}">
1052 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
1053 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
1054 <input type=hidden name=sort value="$form->{sort}">
1055 <input type=hidden name=revers value="$form->{revers}">
1056 <input type=hidden name=lastsort value="$form->{lastsort}">
1057 <input type=hidden name=parts value="$form->{parts}">
1059 <input type=hidden name=bom value="$form->{bom}">
1060 <input type=hidden name=titel value="$form->{titel}">
1061 <input type=hidden name=searchitems value="$form->{searchitems}">|;
1066 <input type=hidden name=ndxs_counter value="$form->{ndxs_counter}">
1068 <input class=submit type=submit name=action value="|.$locale->text('choice').qq|">|;
1071 if ($form->{menubar}) {
1072 require "$form->{path}/menu.pl";
1083 $lxdebug->leave_sub();
1087 sub generate_report {
1088 $lxdebug->enter_sub();
1090 $revers = $form->{revers};
1091 $lastsort = $form->{lastsort};
1093 if (($form->{lastsort} eq "")&&($form->{sort} eq undef))
1095 $form->{revers} = 0;
1096 $form->{lastsort} = "partnumber";
1097 $form->{sort} = "partnumber";
1101 # switch between backward sorting of tables
1102 if ($form->{lastsort} eq $form->{sort})
1104 if ($form->{revers}==0)
1106 $form->{revers} = 1;
1110 $form->{revers} = 0;
1115 $form->{revers}== 0;
1116 $form->{lastsort} = $form->{sort};
1120 $callback = "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}&searchitems=$form->{searchitems}&itemstatus=$form->{itemstatus}&bom=$form->{bom}&l_linetotal=$form->{l_linetotal}&title=".$form->escape($form->{title},1);
1123 # if we have a serialnumber limit search
1124 if ($form->{serialnumber} || $form->{l_serialnumber}) {
1125 $form->{l_serialnumber} = "Y";
1126 unless ($form->{bought} || $form->{sold} || $form->{rfq} || $form->{quoted}) {
1127 $form->{bought} = $form->{sold} = 1;
1131 IC->all_parts(\%myconfig, \%$form);
1134 if ($form->{itemstatus} eq 'active') {
1135 $option .= $locale->text('Active')." : ";
1137 if ($form->{itemstatus} eq 'obsolete') {
1138 $option .= $locale->text('Obsolete')." : ";
1140 if ($form->{itemstatus} eq 'orphaned') {
1141 $option .= $locale->text('Orphaned')." : ";
1143 if ($form->{itemstatus} eq 'onhand') {
1144 $option .= $locale->text('On Hand')." : ";
1145 $form->{l_onhand} = "Y";
1147 if ($form->{itemstatus} eq 'short') {
1148 $option .= $locale->text('Short')." : ";
1149 $form->{l_onhand} = "Y";
1151 if ($form->{onorder}) {
1152 $form->{l_ordnumber} = "Y";
1153 $callback .= "&onorder=$form->{onorder}";
1154 $option .= $locale->text('On Order')." : ";
1156 if ($form->{ordered}) {
1157 $form->{l_ordnumber} = "Y";
1158 $callback .= "&ordered=$form->{ordered}";
1159 $option .= $locale->text('Ordered')." : ";
1162 $form->{l_quonumber} = "Y";
1163 $callback .= "&rfq=$form->{rfq}";
1164 $option .= $locale->text('RFQ')." : ";
1166 if ($form->{quoted}) {
1167 $form->{l_quonumber} = "Y";
1168 $callback .= ""ed=$form->{quoted}";
1169 $option .= $locale->text('Quoted')." : ";
1171 if ($form->{bought}) {
1172 $form->{l_invnumber} = "Y";
1173 $callback .= "&bought=$form->{bought}";
1174 $option .= $locale->text('Bought')." : ";
1176 if ($form->{sold}) {
1177 $form->{l_invnumber} = "Y";
1178 $callback .= "&sold=$form->{sold}";
1179 $option .= $locale->text('Sold')." : ";
1181 if ($form->{bought} || $form->{sold} || $form->{onorder} || $form->{ordered} || $form->{rfq} || $form->{quoted}) {
1183 $form->{l_lastcost} = "";
1184 $form->{l_name} = "Y";
1185 if ($form->{transdatefrom}) {
1186 $callback .= "&transdatefrom=$form->{transdatefrom}";
1187 $option .= "\n<br>".$locale->text('From')." ".$locale->date(\%myconfig, $form->{transdatefrom}, 1);
1189 if ($form->{transdateto}) {
1190 $callback .= "&transdateto=$form->{transdateto}";
1191 $option .= "\n<br>".$locale->text('To')." ".$locale->date(\%myconfig, $form->{transdateto}, 1);
1197 if ($form->{partnumber}) {
1198 $callback .= "&partnumber=$form->{partnumber}";
1199 $option .= $locale->text('Part Number').qq| : $form->{partnumber}<br>|;
1201 if ($form->{partsgroup}) {
1202 $callback .= "&partsgroup=$form->{partsgroup}";
1203 $option .= $locale->text('Group').qq| : $form->{partsgroup}<br>|;
1205 if ($form->{serialnumber}) {
1206 $callback .= "&serialnumber=$form->{serialnumber}";
1207 $option .= $locale->text('Serial Number').qq| : $form->{serialnumber}<br>|;
1209 if ($form->{description}) {
1210 $callback .= "&description=$form->{description}";
1211 $description = $form->{description};
1214 $option .= $locale->text('Part Description').qq| : $form->{description}<br>|;
1216 if ($form->{make}) {
1217 $callback .= "&make=$form->{make}";
1218 $option .= $locale->text('Make').qq| : $form->{make}<br>|;
1220 if ($form->{model}) {
1221 $callback .= "&model=$form->{model}";
1222 $option .= $locale->text('Model').qq| : $form->{model}<br>|;
1224 if ($form->{drawing}) {
1225 $callback .= "&drawing=$form->{drawing}";
1226 $option .= $locale->text('Drawing').qq| : $form->{drawing}<br>|;
1228 if ($form->{microfiche}) {
1229 $callback .= "µfiche=$form->{microfiche}";
1230 $option .= $locale->text('Microfiche').qq| : $form->{microfiche}<br>|;
1232 # table soldtotal aktive
1233 if ($form->{l_soldtotal})
1235 $callback .= "&soldtotal=$form->{soldtotal}";
1236 $option .= $locale->text('soldtotal').qq| : $form->{soldtotal}<br>|;
1239 @columns = $form->sort_columns(qw(partnumber description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal));
1241 if ($form->{l_linetotal}) {
1242 $form->{l_onhand} = "Y";
1243 $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
1244 if ($form->{l_lastcost}) {
1245 $form->{l_linetotallastcost} = "Y";
1246 if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
1247 $form->{l_linetotallastcost} = "";
1250 $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
1253 if ($form->{searchitems} eq 'service') {
1254 # remove bin, weight and rop from list
1255 map { $form->{"l_$_"} = "" } qw(bin weight rop);
1257 $form->{l_onhand} = "";
1258 # qty is irrelevant unless bought or sold
1259 if ($form->{bought} || $form->{sold} || $form->{onorder} ||
1260 $form->{ordered} || $form->{rfq} || $form->{quoted}) {
1261 $form->{l_onhand} = "Y";
1263 $form->{l_linetotalsellprice} = "";
1264 $form->{l_linetotallastcost} = "";
1268 $form->{l_lastcost} = "" if ($form->{searchitems} eq 'assembly' && !$form->{bom});
1270 foreach $item (@columns) {
1271 if ($form->{"l_$item"} eq "Y") {
1272 push @column_index, $item;
1274 # add column to callback
1275 $callback .= "&l_$item=Y";
1279 if ($form->{l_subtotal} eq 'Y') {
1280 $callback .= "&l_subtotal=Y";
1282 $column_header{partnumber} = qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|.$locale->text('Part Number').qq|</a></th>|;
1283 $column_header{description} = qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|.$locale->text('Part Description').qq|</a></th>|;
1284 $column_header{partsgroup} = qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|.$locale->text('Group').qq|</a></th>|;
1285 $column_header{bin} = qq|<th><a class=listheading href=$callback&sort=bin>|.$locale->text('Bin').qq|</a></th>|;
1286 $column_header{priceupdate} = qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|.$locale->text('Updated').qq|</a></th>|;
1287 $column_header{onhand} = qq|<th nowrap><a class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|.$locale->text('Qty').qq|</th>|;
1288 $column_header{unit} = qq|<th class=listheading nowrap>|.$locale->text('Unit').qq|</th>|;
1289 $column_header{listprice} = qq|<th class=listheading nowrap>|.$locale->text('List Price').qq|</th>|;
1290 $column_header{lastcost} = qq|<th class=listheading nowrap>|.$locale->text('Last Cost').qq|</th>|;
1291 $column_header{rop} = qq|<th class=listheading nowrap>|.$locale->text('ROP').qq|</th>|;
1292 $column_header{weight} = qq|<th class=listheading nowrap>|.$locale->text('Weight').qq|</th>|;
1294 $column_header{invnumber} = qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|.$locale->text('Invoice Number').qq|</a></th>|;
1295 $column_header{ordnumber} = qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|.$locale->text('Order Number').qq|</a></th>|;
1296 $column_header{quonumber} = qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|.$locale->text('Quotation').qq|</a></th>|;
1298 $column_header{name} = qq|<th nowrap><a class=listheading href=$callback&sort=name>|.$locale->text('Name').qq|</a></th>|;
1300 $column_header{sellprice} = qq|<th class=listheading nowrap>|.$locale->text('Sell Price').qq|</th>|;
1301 $column_header{linetotalsellprice} = qq|<th class=listheading nowrap>|.$locale->text('Extended').qq|</th>|;
1302 $column_header{linetotallastcost} = qq|<th class=listheading nowrap>|.$locale->text('Extended').qq|</th>|;
1303 $column_header{linetotallistprice} = qq|<th class=listheading nowrap>|.$locale->text('Extended').qq|</th>|;
1305 $column_header{image} = qq|<th class=listheading nowrap>|.$locale->text('Image').qq|</a></th>|;
1306 $column_header{drawing} = qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|.$locale->text('Drawing').qq|</a></th>|;
1307 $column_header{microfiche} = qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|.$locale->text('Microfiche').qq|</a></th>|;
1309 $column_header{serialnumber} = qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|.$locale->text('Serial Number').qq|</a></th>|;
1310 $column_header{soldtotal} = qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|.$locale->text('soldtotal').qq|</a></th>|;
1313 $colspan = $#column_index + 1;
1320 <th class=listtop colspan=$colspan>$form->{title}</th>
1322 <tr height="5"></tr>
1324 <tr><td colspan=$colspan>$option</td></tr>
1326 <tr class=listheading>
1329 map { print "\n$column_header{$_}" } @column_index;
1336 # add order to callback
1337 $form->{callback} = $callback .= "&sort=$form->{sort}";
1339 # escape callback for href
1340 $callback = $form->escape($callback);
1342 if (@{ $form->{parts} }) {
1343 $sameitem = $form->{parts}->[0]->{$form->{sort}};
1346 foreach $ref (@{ $form->{parts} }) {
1348 if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
1349 if ($sameitem ne $ref->{$form->{sort}}) {
1351 $sameitem = $ref->{$form->{sort}};
1355 $ref->{exchangerate} = 1 unless $ref->{exchangerate};
1356 $ref->{sellprice} *= $ref->{exchangerate};
1357 $ref->{listprice} *= $ref->{exchangerate};
1358 $ref->{lastcost} *= $ref->{exchangerate};
1360 # use this for assemblies
1361 $onhand = $ref->{onhand};
1364 if ($ref->{assemblyitem}) {
1366 $onhand = 0 if ($form->{sold});
1369 $ref->{description} =~ s/
1372 $column_data{partnumber} = "<td align=$align><a href=$form->{script}?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{partnumber} </a></td>";
1373 $column_data{description} = "<td>$ref->{description} </td>";
1374 $column_data{partsgroup} = "<td>$ref->{partsgroup} </td>";
1376 $column_data{onhand} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{onhand}, '', " ")."</td>";
1377 $column_data{sellprice} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ") . "</td>";
1378 $column_data{listprice} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{listprice}, 2, " ") . "</td>";
1379 $column_data{lastcost} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{lastcost}, 2, " ") . "</td>";
1381 $column_data{linetotalsellprice} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice}, 2, " ")."</td>";
1382 $column_data{linetotallastcost} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost}, 2, " ")."</td>";
1383 $column_data{linetotallistprice} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice}, 2, " ")."</td>";
1385 if (!$ref->{assemblyitem}) {
1386 $totalsellprice += $onhand * $ref->{sellprice};
1387 $totallastcost += $onhand * $ref->{lastcost};
1388 $totallistprice += $onhand * $ref->{listprice};
1390 $subtotalonhand += $onhand;
1391 $subtotalsellprice += $onhand * $ref->{sellprice};
1392 $subtotallastcost += $onhand * $ref->{lastcost};
1393 $subtotallistprice += $onhand * $ref->{listprice};
1396 $column_data{rop} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{rop}, '', " ")."</td>";
1397 $column_data{weight} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{weight}, '', " ")."</td>";
1398 $column_data{unit} = "<td>$ref->{unit} </td>";
1399 $column_data{bin} = "<td>$ref->{bin} </td>";
1400 $column_data{priceupdate} = "<td>$ref->{priceupdate} </td>";
1402 $column_data{invnumber} = ($ref->{module} ne 'oe') ? "<td><a href=$ref->{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}</a></td>" : "<td>$ref->{invnumber}</td>";
1403 $column_data{ordnumber} = ($ref->{module} eq 'oe') ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber}</a></td>" : "<td>$ref->{ordnumber}</td>";
1404 $column_data{quonumber} = ($ref->{module} eq 'oe' && !$ref->{ordnumber}) ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber}</a></td>" : "<td>$ref->{quonumber}</td>";
1406 $column_data{name} = "<td>$ref->{name}</td>";
1408 $column_data{image} = ($ref->{image}) ? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>" : "<td> </td>";
1409 $column_data{drawing} = ($ref->{drawing}) ? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>" : "<td> </td>";
1410 $column_data{microfiche} = ($ref->{microfiche}) ? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>" : "<td> </td>";
1412 $column_data{serialnumber} = "<td>$ref->{serialnumber}</td>";
1414 $column_data{soldtotal} = "<td align=right>".$form->format_amount(\%myconfig, $ref->{soldtotal}, '', " ")."</td>";
1417 print "<tr class=listrow$i>";
1419 map { print "\n$column_data{$_}" } @column_index;
1428 if ($form->{l_subtotal} eq 'Y') {
1432 if ($form->{"l_linetotal"}) {
1433 map { $column_data{$_} = "<td> </td>" } @column_index;
1434 $column_data{linetotalsellprice} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totalsellprice, 2, " ")."</th>";
1435 $column_data{linetotallastcost} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totallastcost, 2, " ")."</th>";
1436 $column_data{linetotallistprice} = "<th class=listtotal align=right>".$form->format_amount(\%myconfig, $totallistprice, 2, " ")."</th>";
1438 print "<tr class=listtotal>";
1440 map { print "\n$column_data{$_}" } @column_index;
1447 <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
1457 <form method=post action=$form->{script}>
1459 <input name=callback type=hidden value="$form->{callback}">
1461 <input type=hidden name=item value=$form->{searchitems}>
1463 <input type=hidden name=path value=$form->{path}>
1464 <input type=hidden name=login value=$form->{login}>
1465 <input type=hidden name=password value=$form->{password}>|;
1468 <input class=submit type=submit name=action value="|.$locale->text('Add').qq|">|;
1471 if ($form->{menubar}) {
1472 require "$form->{path}/menu.pl";
1483 $lxdebug->leave_sub();
1484 }#end generate_report
1488 sub parts_subtotal {
1489 $lxdebug->enter_sub();
1491 map { $column_data{$_} = "<td> </td>" } @column_index;
1492 $subtotalonhand = 0 if ($form->{searchitems} eq 'assembly' && $form->{bom});
1494 $column_data{onhand} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalonhand, '', " ")."</th>";
1496 $column_data{linetotalsellprice} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotalsellprice, 2, " ")."</th>";
1497 $column_data{linetotallistprice} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotallistprice, 2, " ")."</th>";
1498 $column_data{linetotallastcost} = "<th class=listsubtotal align=right>".$form->format_amount(\%myconfig, $subtotallastcost, 2, " ")."</th>";
1500 $subtotalonhand = 0;
1501 $subtotalsellprice = 0;
1502 $subtotallistprice = 0;
1503 $subtotallastcost = 0;
1505 print "<tr class=listsubtotal>";
1507 map { print "\n$column_data{$_}" } @column_index;
1513 $lxdebug->leave_sub();
1519 $lxdebug->enter_sub();
1521 IC->get_part(\%myconfig, \%$form);
1523 $form->{title} = $locale->text('Edit '.ucfirst $form->{item});
1528 $lxdebug->leave_sub();
1534 $lxdebug->enter_sub();
1536 IC->create_links("IC", \%myconfig, \%$form);
1538 map { $form->{selectcurrency} .= "<option>$_\n" } split /:/, $form->{currencies};
1540 # parts and assemblies have the same links
1541 $item = $form->{item};
1542 if ($form->{item} eq 'assembly') {
1546 # build the popup menus
1547 $form->{taxaccounts} = "";
1548 foreach $key (keys %{ $form->{IC_links} }) {
1549 foreach $ref (@{ $form->{IC_links}{$key} }) {
1550 # if this is a tax field
1551 if ($key =~ /IC_tax/) {
1552 if ($key =~ /$item/) {
1553 $form->{taxaccounts} .= "$ref->{accno} ";
1554 $form->{"IC_tax_$ref->{accno}_description"} = "$ref->{accno}--$ref->{description}";
1557 if ($form->{amount}{$ref->{accno}}) {
1558 $form->{"IC_tax_$ref->{accno}"} = "checked";
1561 $form->{"IC_tax_$ref->{accno}"} = "checked";
1566 $form->{"select$key"} .= "<option $ref->{selected}>$ref->{accno}--$ref->{description}\n";
1567 if ($form->{amount}{$key} eq $ref->{accno}) {
1568 $form->{$key} = "$ref->{accno}--$ref->{description}";
1574 chop $form->{taxaccounts};
1576 if (($form->{item} eq "part") || ($form->{item} eq "assembly")) {
1577 $form->{selectIC_income} = $form->{selectIC_sale};
1578 $form->{selectIC_expense} = $form->{selectIC_cogs};
1579 $form->{IC_income} = $form->{IC_sale};
1580 $form->{IC_expense} = $form->{IC_cogs};
1583 delete $form->{IC_links};
1584 delete $form->{amount};
1587 $form->get_partsgroup(\%myconfig, {all => 1});
1588 $form->{partsgroup} = "$form->{partsgroup}--$form->{partsgroup_id}";
1589 if (@{ $form->{all_partsgroup} }) {
1590 $form->{selectpartsgroup} = qq|<option>\n|;
1591 map { $form->{selectpartsgroup} .= qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n| } @{ $form->{all_partsgroup} };
1594 if ($form->{item} eq 'assembly') {
1596 foreach $i (1 .. $form->{assembly_rows}) {
1597 if ($form->{"partsgroup_id_$i"}) {
1598 $form->{"partsgroup_$i"} = qq|$form->{"partsgroup_$i"}--$form->{"partsgroup_id_$i"}|;
1601 $form->get_partsgroup(\%myconfig);
1603 if (@{ $form->{all_partsgroup} }) {
1604 $form->{selectassemblypartsgroup} = qq|<option>\n|;
1606 map { $form->{selectassemblypartsgroup} .= qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n| } @{ $form->{all_partsgroup} };
1609 $lxdebug->leave_sub();
1615 $lxdebug->enter_sub();
1617 ($dec) = ($form->{sellprice} =~ /\.(\d+)/);
1619 my $decimalplaces = ($dec > 2) ? $dec : 2;
1621 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, $decimalplaces)} qw(listprice sellprice gv);
1623 ($dec) = ($form->{lastcost} =~ /\.(\d+)/);
1625 my $decimalplaces = ($dec > 2) ? $dec : 2;
1627 $form->{lastcost} = $form->format_amount(\%myconfig, $form->{lastcost}, $decimalplaces);
1629 map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}) } qw(weight rop stock);
1631 foreach $item (qw(partnumber description unit notes)) {
1632 $form->{$item} =~ s/\"/"/g;
1635 if (($rows = $form->numtextrows($form->{notes}, 40)) < 2) {
1639 $notes = qq|<textarea name=notes rows=$rows cols=40 wrap=soft>$form->{notes}</textarea>|;
1640 if (($rows = $form->numtextrows($form->{description}, 40)) > 1) {
1641 $description = qq|<textarea name="description" rows=$rows cols=40 wrap=soft>$form->{description}</textarea>|;
1643 $description = qq|<input name=description size=40 value="$form->{description}">|;
1646 foreach $item (split / /, $form->{taxaccounts}) {
1647 $form->{"IC_tax_$item"} = ($form->{"IC_tax_$item"}) ? "checked" : "";
1651 foreach $item (qw(IC IC_income IC_expense)) {
1652 if ($form->{$item}) {
1653 if ($form->{id} && $form->{orphaned}) {
1654 $form->{"select$item"} =~ s/ selected//;
1655 $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
1657 $form->{"select$item"} = qq|<option selected>$form->{$item}|;
1661 if ($form->{selectpartsgroup}) {
1662 $form->{selectpartsgroup} = $form->unescape($form->{selectpartsgroup});
1663 $partsgroup = qq|<input type=hidden name=selectpartsgroup value="|.$form->escape($form->{selectpartsgroup},1).qq|">|;
1664 $form->{selectpartsgroup} =~ s/(<option value="\Q$form->{partsgroup}\E")/$1 selected/;
1666 $partsgroup .= qq|<select name=partsgroup>$form->{selectpartsgroup}</select>|;
1667 $group = $locale->text('Group');
1670 foreach $item (split / /, $form->{taxaccounts}) {
1672 <input class=checkbox type=checkbox name="IC_tax_$item" value=1 $form->{"IC_tax_$item"}> <b>$form->{"IC_tax_${item}_description"}</b>
1673 <br><input type=hidden name=IC_tax_${item}_description value="$form->{"IC_tax_${item}_description"}">
1677 $form->{obsolete} = "checked" if $form->{obsolete};
1681 <th align="right" nowrap="true">|.$locale->text('Last Cost').qq|</th>
1682 <td><input name=lastcost size=11 value=$form->{lastcost}></td>
1688 <th align=right>|.$locale->text('Inventory').qq|</th>
1689 <td><select name=IC>$form->{selectIC}</select></td>
1690 <input name=selectIC type=hidden value="$form->{selectIC}">
1694 if ($form->{item} eq "part") {
1696 $linkaccounts .= qq|
1698 <th align=right>|.$locale->text('Revenue').qq|</th>
1699 <td><select name=IC_income>$form->{selectIC_income}</select></td>
1700 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
1703 <th align=right>|.$locale->text('COGS').qq|</th>
1704 <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
1705 <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
1713 <th align="right" nowrap="true">|.$locale->text('Weight').qq|</th>
1718 <input name=weight size=10 value=$form->{weight}>
1723 <input type=hidden name=weightunit value=$form->{weightunit}>
1734 if ($form->{item} eq "assembly") {
1740 <th align=right>|.$locale->text('Revenue').qq|</th>
1741 <td><select name=IC_income>$form->{selectIC_income}</select></td>
1742 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
1750 <th align="right" nowrap="true">|.$locale->text('Weight').qq|</th>
1755 $form->{weight}
1756 <input type=hidden name=weight value=$form->{weight}>
1761 <input type=hidden name=weightunit value=$form->{weightunit}>
1772 if ($form->{item} eq "service") {
1776 <th align=right>|.$locale->text('Revenue').qq|</th>
1777 <td><select name=IC_income>$form->{selectIC_income}</select></td>
1778 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
1781 <th align=right>|.$locale->text('Expense').qq|</th>
1782 <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
1783 <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
1791 if ($form->{item} ne 'service') {
1792 $n = ($form->{onhand} > 0) ? "1" : "0";
1795 <th align="right" nowrap>|.$locale->text('On Hand').qq|</th>
1796 <th align=left nowrap class="plus$n"> |.$form->format_amount(\%myconfig, $form->{onhand}).qq|</th>
1800 if ($form->{item} eq 'assembly') {
1803 <th align="right" nowrap>|.$locale->text('Stock').qq|</th>
1804 <td><input name=stock size=10 value=$form->{stock}></td>
1811 <th align="right" nowrap="true">|.$locale->text('ROP').qq|</th>
1812 <td><input name=rop size=10 value=$form->{rop}></td>
1818 <th align="right" nowrap="true">|.$locale->text('Bin').qq|</th>
1819 <td><input name=bin size=10 value=$form->{bin}></td>
1824 <th align="right" nowrap="true">|.$locale->text('Verrechnungseinheit').qq|</th>
1825 <td><input name=ve size=10 value=$form->{ve}></td>
1828 <th align="right" nowrap="true">|.$locale->text('Geschäftsvolumen').qq|</th>
1829 <td><input name=gv size=10 value=$form->{gv}></td>
1837 <th align=right nowrap>|.$locale->text('Image').qq|</th>
1838 <td><input name=image size=40 value="$form->{image}"></td>
1839 <th align=right nowrap>|.$locale->text('Microfiche').qq|</th>
1840 <td><input name=microfiche size=20 value="$form->{microfiche}"></td>
1843 <th align=right nowrap>|.$locale->text('Drawing').qq|</th>
1844 <td><input name=drawing size=40 value="$form->{drawing}"></td>
1856 <th align="right" nowrap="true">|.$locale->text('Obsolete').qq|</th>
1857 <td><input name=obsolete type=checkbox class=checkbox value=1 $form->{obsolete}></td>
1861 $shopok=$form->{shop} == 1 ? "checked" : "";
1864 <th align=right nowrap>|.$locale->text('Shopartikel').qq|</th>
1865 <td><input class=checkbox type=checkbox name=shop value=1 $shopok></td>
1870 # type=submit $locale->text('Add Part')
1871 # type=submit $locale->text('Add Service')
1872 # type=submit $locale->text('Add Assembly')
1874 # type=submit $locale->text('Edit Part')
1875 # type=submit $locale->text('Edit Service')
1876 # type=submit $locale->text('Edit Assembly')
1877 # use JavaScript Calendar or not
1878 $form->{jsscript} = $jscalendar;
1880 if ($form->{jsscript})
1882 # with JavaScript Calendar
1884 <td width="13"><input name=priceupdate id=priceupdate size=11 title="$myconfig{dateformat}" value="$form->{priceupdate}"></td>
1885 <td width="4" align="left"><input type=button name=priceupdate id="trigger1" value=|.$locale->text('button').qq|></td>
1888 $jsscript = Form->write_trigger(\%myconfig,"1","priceupdate","BL","trigger1","","","");
1892 # without JavaScript Calendar
1894 <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
1897 $form->{fokus} = "ic.partnumber";
1901 <body onLoad="fokus()">
1904 <form method=post name="ic" action=$form->{script}>
1906 <input name=id type=hidden value=$form->{id}>
1907 <input name=item type=hidden value=$form->{item}>
1908 <input name=title type=hidden value="$form->{title}">
1909 <input name=makemodel type=hidden value="$form->{makemodel}">
1910 <input name=alternate type=hidden value="$form->{alternate}">
1911 <input name=onhand type=hidden value=$form->{onhand}>
1912 <input name=orphaned type=hidden value=$form->{orphaned}>
1913 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
1914 <input name=rowcount type=hidden value=$form->{rowcount}>
1915 <input name=eur type=hidden value=$eur>
1917 <table width="100%">
1919 <th class=listtop>$form->{title}</th>
1921 <tr height="5"></tr>
1924 <table width="100%">
1926 <th align=left>|.$locale->text('Part Number').qq|</th>
1927 <th align=left>|.$locale->text('Part Description').qq|</th>
1928 <th align=left>$group</th>
1931 <td><input name=partnumber value="$form->{partnumber}" size=20></td>
1932 <td>$description</td>
1933 <td>$partsgroup</td>
1934 <input type=hidden name=oldpartsgroup value="$form->{oldpartsgroup}">
1941 <table width="100%" height="100%">
1944 <table width="100%" height="100%">
1945 <tr class="listheading">
1946 <th class="listheading" align="center" colspan=2>|.$locale->text('Link Accounts').qq|</th>
1950 <th align="left">|.$locale->text('Notes').qq|</th>
1960 <table width="100%">
1962 <th align="right" nowrap="true">|.$locale->text('Updated').qq|</th>
1966 <th align="right" nowrap="true">|.$locale->text('List Price').qq|</th>
1967 <td><input name=listprice size=11 value=$form->{listprice}></td>
1970 <th align="right" nowrap="true">|.$locale->text('Sell Price').qq|</th>
1971 <td><input name=sellprice size=11 value=$form->{sellprice}></td>
1975 <th align="right" nowrap="true">|.$locale->text('Unit').qq|</th>
1976 <td><input name=unit size=5 maxlength="10" value="$form->{unit}"></td>
1993 $lxdebug->leave_sub();
1998 $lxdebug->enter_sub();
2000 if ($form->{item} eq "assembly") {
2005 <table width="100%">
2007 <th colspan=2 align=right>|.$locale->text('Total').qq| </th>
2008 <th align=right>|.$form->format_amount(\%myconfig, $form->{assemblytotal}, 2).qq|</th>
2013 <input type=hidden name=assembly_rows value=$form->{assembly_rows}>
2018 <input type=hidden name=path value=$form->{path}>
2019 <input type=hidden name=login value=$form->{login}>
2020 <input type=hidden name=password value=$form->{password}>
2021 <input type=hidden name=callback value="$form->{callback}">
2022 <input type=hidden name=previousform value="$form->{previousform}">
2023 <input type=hidden name=taxaccount2 value="$form->{taxaccount2}">
2024 <input type=hidden name=vc value=$form->{vc}>
2026 <td><hr size=3 noshade></td>
2031 <input class=submit type=submit name=action value="|.$locale->text('Update').qq|">
2034 unless ($form->{item} eq "service") {
2036 <input type=hidden name=makemodel_rows value=$form->{makemodel_rows}>
2041 <input class=submit type=submit name=action value="|.$locale->text('Save').qq|">|;
2045 if (! $form->{previousform}) {
2047 <input class=submit type=submit name=action value="|.$locale->text('Save as new').qq|">|;
2050 if ($form->{orphaned}) {
2051 if (! $form->{previousform}) {
2052 if ($form->{item} eq 'assembly') {
2053 if (! $form->{onhand}) {
2055 <input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">|;
2059 <input class=submit type=submit name=action value="|.$locale->text('Delete').qq|">|;
2065 if (! $form->{previousform}) {
2066 if ($form->{menubar}) {
2067 require "$form->{path}/menu.pl";
2080 $lxdebug->leave_sub();
2085 $lxdebug->enter_sub();
2088 $form->{"make_$i"} =~ s/\"/"/g;
2089 $form->{"model_$i"} =~ s/\"/"/g;
2096 <th class="listheading">|.$locale->text('Make').qq|</th>
2097 <th class="listheading">|.$locale->text('Model').qq|</th>
2101 for $i (1 .. $numrows) {
2104 <td width=50%><input name="make_$i" size=30 value="$form->{"make_$i"}"></td>
2105 <td width=50%><input name="model_$i" size=30 value="$form->{"model_$i"}"></td>
2116 $lxdebug->leave_sub();
2121 $lxdebug->enter_sub();
2124 @column_index = qw(runningnumber qty unit bom partnumber description partsgroup total);
2126 if ($form->{previousform}) {
2128 @column_index = qw(qty unit bom partnumber description partsgroup total);
2131 $form->{old_callback} = $form->{callback};
2132 $callback = $form->{callback};
2133 $form->{callback} = "$form->{script}?action=display_form";
2136 map { delete $form->{$_} } qw(action header);
2139 # save form variables in a previousform variable
2140 foreach $key (sort keys %$form) {
2142 $form->{$key} =~ s/&/%26/g;
2143 $previousform .= qq|$key=$form->{$key}&|;
2146 $previousform = $form->escape($form->escape($previousform, 1));
2147 $form->{callback} = $callback;
2149 $form->{assemblytotal} = 0;
2150 $form->{weight} = 0;
2153 $column_header{runningnumber} = qq|<th nowrap width=5%>|.$locale->text('No.').qq|</th>|;
2154 $column_header{qty} = qq|<th align=left nowrap width=10%>|.$locale->text('Qty').qq|</th>|;
2155 $column_header{unit} = qq|<th align=left nowrap width=5%>|.$locale->text('Unit').qq|</th>|;
2156 $column_header{partnumber} = qq|<th align=left nowrap width=20%>|.$locale->text('Part Number').qq|</th>|;
2157 $column_header{description} = qq|<th nowrap width=50%>|.$locale->text('Part Description').qq|</th>|;
2158 $column_header{total} = qq|<th align=right nowrap>|.$locale->text('Extended').qq|</th>|;
2159 $column_header{bom} = qq|<th>|.$locale->text('BOM').qq|</th>|;
2160 $column_header{partsgroup} = qq|<th>|.$locale->text('Group').qq|</th>|;
2163 <tr class=listheading>
2164 <th class=listheading>|.$locale->text('Individual Items').qq|</th>
2172 map { print "\n$column_header{$_}" } @column_index;
2178 for $i (1 .. $numrows) {
2179 $form->{"partnumber_$i"} =~ s/\"/"/g;
2181 $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
2182 $form->{assemblytotal} += $linetotal;
2184 $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
2186 $linetotal = $form->format_amount(\%myconfig, $linetotal, 2);
2188 if (($i >= 1) && ($i == $numrows)) {
2191 map { $column_data{$_} = qq|<td></td>| } qw(qty unit partnumber description bom partsgroup);
2194 map { $column_data{$_} = qq|<td></td>| } qw(runningnumber unit bom);
2196 $column_data{qty} = qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
2197 $column_data{partnumber} = qq|<td><input name="partnumber_$i" size=15 value="$form->{"partnumber_$i"}"></td>|;
2198 $column_data{description} = qq|<td><input name="description_$i" size=40 value="$form->{"description_$i"}"></td>|;
2199 $column_data{partsgroup} = qq|<td><input name="partsgroup_$i" size=10 value="$form->{"partsgroup_$i"}"></td>|;
2206 if ($form->{previousform}) {
2207 $column_data{partnumber} = qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}">$form->{"partnumber_$i"}</td>|;
2208 $column_data{qty} = qq|<td align=right><input type=hidden name="qty_$i" value="$form->{"qty_$i"}">$form->{"qty_$i"}</td>|;
2210 $column_data{bom} = qq|<td align=center><input type=hidden name="bom_$i" value=$form->{"bom_$i"}>|;
2211 $column_data{bom} .= ($form->{"bom_$i"}) ? "x" : " ";
2212 $column_data{bom} .= qq|</td>|;
2214 $column_data{partsgroup} = qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
2217 $href = qq|$form->{script}?action=edit&id=$form->{"id_$i"}&path=$form->{path}&login=$form->{login}&password=$form->{password}&rowcount=$i&previousform=$previousform|;
2218 $column_data{partnumber} = qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"><a href=$href>$form->{"partnumber_$i"}</a></td>|;
2219 $column_data{runningnumber} = qq|<td><input name="runningnumber_$i" size=3 value="$i"></td>|;
2220 $column_data{qty} = qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
2222 $form->{"bom_$i"} = ($form->{"bom_$i"}) ? "checked" : "";
2223 $column_data{bom} = qq|<td align=center><input name="bom_$i" type=checkbox class=checkbox value=1 $form->{"bom_$i"}></td>|;
2225 $column_data{partsgroup} = qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
2228 $column_data{unit} = qq|<td><input type=hidden name="unit_$i" value="$form->{"unit_$i"}">$form->{"unit_$i"}</td>|;
2229 $column_data{description} = qq|<td><input type=hidden name="description_$i" value="$form->{"description_$i"}">$form->{"description_$i"}</td>|;
2232 $column_data{total} = qq|<td align=right>$linetotal</td>|;
2237 map { print "\n$column_data{$_}" } @column_index;
2241 <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2242 <input type=hidden name="sellprice_$i" value=$form->{"sellprice_$i"}>
2243 <input type=hidden name="weight_$i" value=$form->{"weight_$i"}>
2253 $lxdebug->leave_sub();
2258 $lxdebug->enter_sub();
2260 if ($form->{item} eq "assembly") {
2261 $i = $form->{assembly_rows};
2263 # if last row is empty check the form otherwise retrieve item
2264 if (($form->{"partnumber_$i"} eq "") && ($form->{"description_$i"} eq "") && ($form->{"partsgroup_$i"} eq "")) {
2270 IC->assembly_item(\%myconfig, \%$form);
2272 $rows = scalar @{ $form->{item_list} };
2275 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
2278 $form->{makemodel_rows}--;
2282 map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit partsgroup);
2283 map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
2284 $form->{"runningnumber_$i"} = $form->{assembly_rows};
2285 $form->{assembly_rows}++;
2293 $form->{rowcount} = $i;
2294 $form->{assembly_rows}++;
2302 if ($form->{item} eq "part") {
2306 if ($form->{item} eq 'service') {
2307 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(sellprice listprice);
2313 $lxdebug->leave_sub();
2318 $lxdebug->enter_sub();
2320 # check if there is a part number
2321 # $form->isblank("partnumber", $locale->text(ucfirst $form->{item}." Part Number missing!"));
2323 if ($form->{obsolete}) {
2324 $form->error($locale->text("Inventory quantity must be zero before you can set this $form->{item} obsolete!")) if ($form->{onhand});
2327 # expand dynamic strings
2328 # $locale->text('Inventory quantity must be zero before you can set this part obsolete!')
2329 # $locale->text('Inventory quantity must be zero before you can set this assembly obsolete!')
2330 # $locale->text('Part Number missing!')
2331 # $locale->text('Service Number missing!')
2332 # $locale->text('Assembly Number missing!')
2336 $rc = IC->save(\%myconfig, \%$form);
2338 $form->error($locale->text('Partnumber not unique!'));
2340 $parts_id = $form->{id};
2342 # load previous variables
2343 if ($form->{previousform}) {
2344 # save the new form variables before splitting previousform
2345 map { $newform{$_} = $form->{$_} } keys %$form;
2347 $previousform = $form->unescape($form->{previousform});
2349 # don't trample on previous variables
2350 map { delete $form->{$_} } keys %newform;
2352 # now take it apart and restore original values
2353 foreach $item (split /&/, $previousform) {
2354 ($key, $value) = split /=/, $item, 2;
2355 $value =~ s/%26/&/g;
2356 $form->{$key} = $value;
2358 $form->{taxaccounts} = $newform{taxaccount2};
2360 if ($form->{item} eq 'assembly') {
2362 # undo number formatting
2363 map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(weight listprice sellprice rop);
2365 $form->{assembly_rows}--;
2366 $i = $newform{rowcount};
2367 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
2369 $form->{sellprice} -= $form->{"sellprice_$i"} * $form->{"qty_$i"};
2370 $form->{weight} -= $form->{"weight_$i"} * $form->{"qty_$i"};
2372 # change/add values for assembly item
2373 map { $form->{"${_}_$i"} = $newform{$_} } qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno);
2375 $form->{sellprice} += $form->{"sellprice_$i"} * $form->{"qty_$i"};
2376 $form->{weight} += $form->{"weight_$i"} * $form->{"qty_$i"};
2379 # set values for last invoice/order item
2380 $i = $form->{rowcount};
2381 $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
2383 map { $form->{"${_}_$i"} = $newform{$_} } qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice);
2384 $form->{"sellprice_$i"} = $newform{lastcost} if ($form->{vendor_id});
2386 if ($form->{exchangerate} != 0) {
2387 $form->{"sellprice_$i"} /= $form->{exchangerate};
2390 map { $form->{"taxaccounts_$i"} .= "$_ " } split / /, $newform{taxaccount};
2391 chop $form->{"taxaccounts_$i"};
2392 foreach $item (qw(description rate taxnumber)) {
2393 $index = $form->{"taxaccounts_$i"} . "_$item";
2394 $form->{$index} = $newform{$index};
2397 # credit remaining calculation
2398 $amount = $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) * $form->{"qty_$i"};
2399 map { $form->{"${_}_base"} += $amount } (split / /, $form->{"taxaccounts_$i"});
2400 map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{"taxaccounts_$i"} if !$form->{taxincluded};
2402 $form->{creditremaining} -= $amount;
2406 $form->{"id_$i"} = $parts_id;
2407 delete $form->{action};
2409 # restore original callback
2410 $callback = $form->unescape($form->{callback});
2411 $form->{callback} = $form->unescape($form->{old_callback});
2412 delete $form->{old_callback};
2414 $form->{makemodel_rows}--;
2416 # put callback together
2417 foreach $key (keys %$form) {
2418 # do single escape for Apache 2.0
2419 $value = $form->escape($form->{$key}, 1);
2420 $callback .= qq|&$key=$value|;
2422 $form->{callback} = $callback;
2428 $lxdebug->leave_sub();
2433 $lxdebug->enter_sub();
2438 $lxdebug->leave_sub();
2443 $lxdebug->enter_sub();
2445 $rc = IC->delete(\%myconfig, \%$form);
2448 $form->redirect($locale->text('Item deleted!')) if ($rc > 0);
2449 $form->error($locale->text('Cannot delete item!'));
2451 $lxdebug->leave_sub();
2455 sub stock_assembly {
2456 $lxdebug->enter_sub();
2458 $form->{title} = $locale->text('Stock Assembly');
2465 <form method=post action=$form->{script}>
2467 <table width="100%">
2469 <th class=listtop>$form->{title}</th>
2471 <tr height="5"></tr>
2476 <th align="right" nowrap="true">|.$locale->text('Part Number').qq|</th>
2477 <td><input name=partnumber size=20></td>
2481 <th align="right" nowrap="true">|.$locale->text('Part Description').qq|</th>
2482 <td><input name=description size=40></td>
2487 <tr><td><hr size=3 noshade></td></tr>
2490 <input type=hidden name=path value=$form->{path}>
2491 <input type=hidden name=login value=$form->{login}>
2492 <input type=hidden name=password value=$form->{password}>
2494 <input type=hidden name=nextsub value=list_assemblies>
2497 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
2504 $lxdebug->leave_sub();
2508 sub list_assemblies {
2509 $lxdebug->enter_sub();
2511 IC->retrieve_assemblies(\%myconfig, \%$form);
2513 $column_header{partnumber} = qq|<th class=listheading>|.$locale->text('Part Number').qq|</th>|;
2514 $column_header{description} = qq|<th class=listheading>|.$locale->text('Part Description').qq|</th>|;
2515 $column_header{bin} = qq|<th class=listheading>|.$locale->text('Bin').qq|</th>|;
2516 $column_header{onhand} = qq|<th class=listheading>|.$locale->text('Qty').qq|</th>|;
2517 $column_header{rop} = qq|<th class=listheading>|.$locale->text('ROP').qq|</th>|;
2518 $column_header{stock} = qq|<th class=listheading>|.$locale->text('Add').qq|</th>|;
2520 @column_index = (qw(partnumber description bin onhand rop stock));
2522 $form->{title} = $locale->text('Stock Assembly');
2524 $form->{callback} = "$form->{script}?action=stock_assembly&path=$form->{path}&login=$form->{login}&password=$form->{password}";
2528 $colspan = $#column_index + 1;
2533 <form method=post action=$form->{script}>
2537 <th class=listtop colspan=$colspan>$form->{title}</th>
2540 <tr class=listheading>|;
2542 map { print "\n$column_header{$_}" } @column_index;
2549 foreach $ref (@{ $form->{assembly_items} }) {
2551 map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description);
2553 $column_data{partnumber} = qq|<td width=20%>$ref->{partnumber}</td>|;
2554 $column_data{description} = qq|<td width=50%>$ref->{description} </td>|;
2555 $column_data{bin} = qq|<td>$ref->{bin} </td>|;
2556 $column_data{onhand} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{onhand}, '', " ").qq|</td>|;
2557 $column_data{rop} = qq|<td align=right>|.$form->format_amount(\%myconfig, $ref->{rop}, '', " ").qq|</td>|;
2558 $column_data{stock} = qq|<td width=10%><input name="qty_$i" size=10></td>|;
2561 print qq|<tr class=listrow$j><input name="id_$i" type=hidden value=$ref->{id}>\n|;
2563 map { print "\n$column_data{$_}" } @column_index;
2576 <td colspan=6><hr size=3 noshade>
2579 <input name=rowcount type=hidden value="$i">
2581 <input type=hidden name=path value=$form->{path}>
2582 <input type=hidden name=login value=$form->{login}>
2583 <input type=hidden name=password value=$form->{password}>
2585 <input name=callback type=hidden value="$form->{callback}">
2587 <input type=hidden name=nextsub value=restock_assemblies>
2590 <input class=submit type=submit name=action value="|.$locale->text('Continue').qq|">
2598 $lxdebug->leave_sub();
2602 sub restock_assemblies {
2603 $lxdebug->enter_sub();
2605 $form->redirect($locale->text('Assemblies restocked!')) if (IC->restock_assemblies(\%myconfig, \%$form));
2606 $form->error($locale->text('Cannot stock assemblies!'));
2608 $lxdebug->leave_sub();
2612 sub continue { &{ $form->{nextsub} } };