Selected der USTVA Kennziffern mit eq statt == testen.
[kivitendo-erp.git] / bin / mozilla / ic.pl
1 #=====================================================================
2 # LX-Office ERP
3 # Copyright (C) 2004
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #
7 #=====================================================================
8 # SQL-Ledger, Accounting
9 # Copyright (c) 2001
10 #
11 #  Author: Dieter Simader
12 #   Email: dsimader@sql-ledger.org
13 #     Web: http://www.sql-ledger.org
14 #
15 #
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.
20 #
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 #======================================================================
29 #
30 # Inventory Control module
31 #
32 #======================================================================
33 #$locale->text('ea');
34
35 use POSIX qw(strftime);
36
37 use SL::IC;
38 use SL::ReportGenerator;
39
40 #use SL::PE;
41
42 # use strict;
43 #use warnings;
44
45 # global imports
46 our ($form, $locale, %myconfig, $lxdebug);
47
48 require "bin/mozilla/io.pl";
49 require "bin/mozilla/common.pl";
50 require "bin/mozilla/reportgenerator.pl";
51
52 1;
53
54 # end of main
55
56 sub add {
57   $lxdebug->enter_sub();
58
59   $form->{title} = $locale->text('Add ' . ucfirst $form->{item});
60
61   $form->{callback} =
62     "$form->{script}?action=add&item=$form->{item}&login=$form->{login}&password=$form->{password}"
63     unless $form->{callback};
64
65   $form->{"unit_changeable"} = 1;
66
67   IC->get_pricegroups(\%myconfig, \%$form);
68   &link_part;
69   &display_form;
70
71   $lxdebug->leave_sub();
72 }
73
74 sub search {
75   $lxdebug->enter_sub();
76
77   my ($button1, $button2, $onhand, $makemodel, $serialnumber, $l_serialnumber, $toplevel, $bought);
78
79   $form->{title} = (ucfirst $form->{searchitems}) . "s";
80   $form->{title} = $locale->text($form->{title});
81
82   # switch for backward sorting
83   $form->{revers} = 0;
84
85   # memory for which table was sort at last time
86   $form->{lastsort} = "";
87
88   # counter for added entries to top100
89   $form->{ndxs_counter} = 0;
90
91   # $locale->text('Parts')
92   # $locale->text('Services')
93
94   # use JavaScript Calendar or not
95   $form->{jsscript} = 1;
96   my $jsscript = "";
97   if ($form->{jsscript}) {
98
99     # with JavaScript Calendar
100     $button1 = qq|
101        <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>
102        <td><input type=button name=transdatefrom id="trigger1" value=|
103       . $locale->text('button') . qq|></td>
104       |;
105     $button2 = qq|
106        <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>
107        <td><input type=button name=transdateto name=transdateto id="trigger2" value=|
108       . $locale->text('button') . qq|></td>
109      |;
110
111     #write Trigger
112     $jsscript =
113       Form->write_trigger(\%myconfig, "2", "transdatefrom", "BL", "trigger1",
114                           "transdateto", "BL", "trigger2");
115   } else {
116
117     # without JavaScript Calendar
118     $button1 = qq|
119                               <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
120     $button2 = qq|
121                               <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
122   }
123
124   unless ($form->{searchitems} eq 'service') {
125
126     $onhand = qq|
127             <input name=itemstatus class=radio type=radio value=onhand>&nbsp;|
128       . $locale->text('On Hand') . qq|
129             <input name=itemstatus class=radio type=radio value=short>&nbsp;|
130       . $locale->text('Short') . qq|
131 |;
132
133     $makemodel = qq|
134         <tr>
135           <th align=right nowrap>| . $locale->text('Make') . qq|</th>
136           <td><input name=make size=20></td>
137           <th align=right nowrap>| . $locale->text('Model') . qq|</th>
138           <td><input name=model size=20></td>
139         </tr>
140 |;
141
142     $serialnumber = qq|
143           <th align=right nowrap>| . $locale->text('Serial Number') . qq|</th>
144           <td><input name=serialnumber size=20></td>
145 |;
146
147     $l_serialnumber = qq|
148         <td><input name=l_serialnumber class=checkbox type=checkbox value=Y>&nbsp;|
149       . $locale->text('Serial Number') . qq|</td>
150 |;
151
152   }
153
154   if ($form->{searchitems} eq 'assembly') {
155
156     $form->{title} = $locale->text('Assemblies');
157
158     $toplevel = qq|
159         <tr>
160           <td></td>
161           <td colspan=3>
162           <input name=null class=radio type=radio value=1 checked>&nbsp;|
163       . $locale->text('Top Level') . qq|
164           <input name=bom class=checkbox type=checkbox value=1>&nbsp;|
165       . $locale->text('Individual Items') . qq|
166           </td>
167         </tr>
168 |;
169
170     $bought = qq|
171         <tr>
172           <td></td>
173           <td colspan=3>
174             <table>
175               <tr>
176                 <td>
177                   <table>
178                     <tr>
179                       <td><input name=sold class=checkbox type=checkbox value=1></td>
180                       <td nowrap>| . $locale->text('Sold') . qq|</td>
181                     </tr>
182                     <tr>
183                       <td colspan=2><hr size=1 noshade></td>
184                     </tr>
185                     <tr>
186                       <td><input name=ordered class=checkbox type=checkbox value=1></td>
187                       <td nowrap>| . $locale->text('Ordered') . qq|</td>
188                     </tr>
189                     <tr>
190                       <td colspan=4><hr size=1 noshade></td>
191                     </tr>
192                     <tr>
193                       <td><input name=quoted class=checkbox type=checkbox value=1></td>
194                       <td nowrap>| . $locale->text('Quoted') . qq|</td>
195                     </tr>
196                   </table>
197                 </td>
198                 <td width=5%>&nbsp;</td>
199                 <th>| . $locale->text('From') . qq|</th>
200                 $button1
201                 <th>| . $locale->text('To (time)') . qq|</th>
202                 $button2
203               </tr>
204             </table>
205           </td>
206         </tr>
207 |;
208
209   } else {
210
211     $bought = qq|
212         <tr>
213           <td></td>
214           <td colspan=3>
215             <table>
216               <tr>
217                 <td>
218                   <table>
219                     <tr>
220                       <td><input name=bought class=checkbox type=checkbox value=1></td>
221                       <td nowrap>| . $locale->text('Bought') . qq|</td>
222                       <td><input name=sold class=checkbox type=checkbox value=1></td>
223                       <td nowrap>| . $locale->text('Sold') . qq|</td>
224                     </tr>
225                     <tr>
226                       <td colspan=4><hr size=1 noshade></td>
227                     </tr>
228                     <tr>
229                       <td><input name=onorder class=checkbox type=checkbox value=1></td>
230                       <td nowrap>| . $locale->text('On Order') . qq|</td>
231                       <td><input name=ordered class=checkbox type=checkbox value=1></td>
232                       <td nowrap>| . $locale->text('Ordered') . qq|</td>
233                     </tr>
234                     <tr>
235                       <td colspan=4><hr size=1 noshade></td>
236                     </tr>
237                     <tr>
238                       <td><input name=rfq class=checkbox type=checkbox value=1></td>
239                       <td nowrap>| . $locale->text('RFQ') . qq|</td>
240                       <td><input name=quoted class=checkbox type=checkbox value=1></td>
241                       <td nowrap>| . $locale->text('Quoted') . qq|</td>
242                     </tr>
243                   </table>
244                 </td>
245                 <td width=5%>&nbsp;</td>
246                 <td>
247                   <table>
248                     <tr>
249                       <th>| . $locale->text('From') . qq|</th>
250                       $button1
251                       <th>| . $locale->text('To (time)') . qq|</th>
252                       $button2
253                     </tr>
254                   </table>
255                 </td>
256               </tr>
257             </table>
258           </td>
259         </tr>
260 |;
261   }
262
263   $form->header;
264
265   print qq|
266 <body>
267
268 <form method=post action=$form->{script}>
269
270 <input type=hidden name=searchitems value=$form->{searchitems}>
271 <input type=hidden name=title value="$form->{title}">
272
273 <input type=hidden name=revers value="$form->{revers}">
274 <input type=hidden name=lastsort value="$form->{lastsort}">
275
276 <table width="100%">
277   <tr><th class=listtop>$form->{title}</th></tr>
278   <tr height="5"></tr>
279   <tr valign=top>
280     <td>
281       <table>
282         <tr>
283           <th align=right nowrap>| . $locale->text('Part Number') . qq|</th>
284           <td><input name=partnumber size=20></td>
285           <th align=right nowrap>| . $locale->text('EAN') . qq|</th>
286           <td><input name=ean size=20></td>
287         </tr>
288         <tr>
289           <th align=right nowrap>|
290     . $locale->text('Part Description') . qq|</th>
291           <td colspan=3><input name=description size=40></td>
292         </tr>
293         <tr>
294           <th align=right nowrap>| . $locale->text('Group') . qq|</th>
295           <td><input name=partsgroup size=20></td>
296           $serialnumber
297         </tr>
298         $makemodel
299         <tr>
300           <th align=right nowrap>| . $locale->text('Drawing') . qq|</th>
301           <td><input name=drawing size=20></td>
302           <th align=right nowrap>| . $locale->text('Microfiche') . qq|</th>
303           <td><input name=microfiche size=20></td>
304         </tr>
305         $toplevel
306         <tr>
307           <td></td>
308           <td colspan=3>
309             <input name=itemstatus class=radio type=radio value=active checked>&nbsp;|
310     . $locale->text('Active') . qq|
311             $onhand
312             <input name=itemstatus class=radio type=radio value=obsolete>&nbsp;|
313     . $locale->text('Obsolete') . qq|
314             <input name=itemstatus class=radio type=radio value=orphaned>&nbsp;|
315     . $locale->text('Orphaned') . qq|
316           </td>
317         </tr>
318         $bought
319         <tr>
320           <td></td>
321           <td colspan=3>
322             <hr size=1 noshade>
323           </td>
324         </tr>
325         <tr>
326           <th align=right nowrap>|
327     . $locale->text('Include in Report') . qq|</th>
328           <td colspan=3>
329             <table>
330               <tr>
331                 <td><input name=l_partnumber class=checkbox type=checkbox value=Y checked>&nbsp;|
332     . $locale->text('Part Number') . qq|</td>
333                 <td><input name=l_description class=checkbox type=checkbox value=Y checked>&nbsp;|
334     . $locale->text('Part Description') . qq|</td>
335                 $l_serialnumber
336                 <td><input name=l_unit class=checkbox type=checkbox value=Y checked>&nbsp;|
337     . $locale->text('Unit of measure') . qq|</td>
338               </tr>
339               <tr>
340                 <td><input name=l_listprice class=checkbox type=checkbox value=Y>&nbsp;|
341     . $locale->text('List Price') . qq|</td>
342                 <td><input name=l_sellprice class=checkbox type=checkbox value=Y checked>&nbsp;|
343     . $locale->text('Sell Price') . qq|</td>
344                 <td><input name=l_lastcost class=checkbox type=checkbox value=Y checked>&nbsp;|
345     . $locale->text('Last Cost') . qq|</td>
346                 <td><input name=l_linetotal class=checkbox type=checkbox value=Y checked>&nbsp;|
347     . $locale->text('Line Total') . qq|</td>
348               </tr>
349               <tr>
350                 <td><input name=l_priceupdate class=checkbox type=checkbox value=Y>&nbsp;|
351     . $locale->text('Updated') . qq|</td>
352                 <td><input name=l_bin class=checkbox type=checkbox value=Y>&nbsp;|
353     . $locale->text('Bin') . qq|</td>
354                 <td><input name=l_rop class=checkbox type=checkbox value=Y>&nbsp;|
355     . $locale->text('ROP') . qq|</td>
356                 <td><input name=l_weight class=checkbox type=checkbox value=Y>&nbsp;|
357     . $locale->text('Weight') . qq|</td>
358               </tr>
359               <tr>
360                 <td><input name=l_image class=checkbox type=checkbox value=Y>&nbsp;|
361     . $locale->text('Image') . qq|</td>
362                 <td><input name=l_drawing class=checkbox type=checkbox value=Y>&nbsp;|
363     . $locale->text('Drawing') . qq|</td>
364                 <td><input name=l_microfiche class=checkbox type=checkbox value=Y>&nbsp;|
365     . $locale->text('Microfiche') . qq|</td>
366                 <td><input name=l_partsgroup class=checkbox type=checkbox value=Y>&nbsp;|
367     . $locale->text('Group') . qq|</td>
368               </tr>
369               <tr>
370                 <td><input name=l_subtotal class=checkbox type=checkbox value=Y>&nbsp;|
371     . $locale->text('Subtotal') . qq|</td>
372                 <td><input name=l_soldtotal class=checkbox type=checkbox value=Y>&nbsp;|
373     . $locale->text('soldtotal') . qq|</td>
374                 <td><input name=l_deliverydate class=checkbox type=checkbox value=Y>&nbsp;|
375     . $locale->text('deliverydate') . qq|</td>    
376               </tr>
377             </table>
378           </td>
379         </tr>
380       </table>
381     </td>
382   </tr>
383   <tr><td colspan=4><hr size=3 noshade></td></tr>
384 </table>
385
386 $jsscript
387
388 <input type=hidden name=nextsub value=generate_report>
389
390 <input type=hidden name=login value=$form->{login}>
391 <input type=hidden name=password value=$form->{password}>
392
393 <input type=hidden name=revers value="$form->{revers}">
394 <input type=hidden name=lastsort value="$form->{lastsort}">
395 <input type=hidden name=sort value="description">
396
397 <input type=hidden name=ndxs_counter value="$form->{ndxs_counter}">
398
399 <br>
400 <input class=submit type=submit name=action value="|
401     . $locale->text('Continue') . qq|">
402 <input class=submit type=submit name=action value="|
403     . $locale->text('TOP100') . qq|">
404 </form>
405
406 </body>
407 </html>
408 |;
409   $lxdebug->leave_sub();
410 }    #end search()
411
412 sub search_update_prices {
413   $lxdebug->enter_sub();
414
415   my ($onhand, $makemodel, $serialnumber, $l_serialnumber, $toplevel, $bought);
416
417   $form->{title} = $locale->text('Update prices');
418   IC->get_pricegroups(\%myconfig, \%$form);
419
420   # use JavaScript Calendar or not
421 #   $form->{jsscript} = 1;
422 #   $jsscript = "";
423 #   if ($form->{jsscript}) {
424
425 #     # with JavaScript Calendar
426 #     $button1 = qq|
427 #        <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>
428 #        <td><input type=button name=transdatefrom id="trigger1" value=|
429 #       . $locale->text('button') . qq|></td>
430 #       |;
431 #     $button2 = qq|
432 #        <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>
433 #        <td><input type=button name=transdateto name=transdateto id="trigger2" value=|
434 #       . $locale->text('button') . qq|></td>
435 #      |;
436
437 #     #write Trigger
438 #     $jsscript =
439 #       Form->write_trigger(\%myconfig, "2", "transdatefrom", "BL", "trigger1",
440 #                           "transdateto", "BL", "trigger2");
441 #   } else {
442
443 #     # without JavaScript Calendar
444 #     $button1 = qq|
445 #                               <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
446 #     $button2 = qq|
447 #                               <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
448 #   }
449
450     $onhand = qq|
451             <input name=itemstatus class=radio type=radio value=onhand>&nbsp;|
452       . $locale->text('On Hand') . qq|
453             <input name=itemstatus class=radio type=radio value=short>&nbsp;|
454       . $locale->text('Short') . qq|
455 |;
456
457     $makemodel = qq|
458         <tr>
459           <th align=right nowrap>| . $locale->text('Make') . qq|</th>
460           <td><input name=make size=20></td>
461           <th align=right nowrap>| . $locale->text('Model') . qq|</th>
462           <td><input name=model size=20></td>
463         </tr>
464 |;
465
466     $serialnumber = qq|
467           <th align=right nowrap>| . $locale->text('Serial Number') . qq|</th>
468           <td><input name=serialnumber size=20></td>
469 |;
470
471     $l_serialnumber = qq|
472         <td><input name=l_serialnumber class=checkbox type=checkbox value=Y>&nbsp;|
473       . $locale->text('Serial Number') . qq|</td>
474 |;
475
476
477
478   $form->header;
479
480   print qq|
481 <body>
482
483 <form method=post action=$form->{script}>
484
485 <input type=hidden name=title value="$form->{title}">
486
487 <table width="100%">
488   <tr><th class=listtop>$form->{title}</th></tr>
489   <tr height="5"></tr>
490   <tr valign=top>
491     <td>
492       <table>
493         <tr>
494           <th align=right nowrap>| . $locale->text('Part Number') . qq|</th>
495           <td><input name=partnumber size=20></td>
496         </tr>
497         <tr>
498           <th align=right nowrap>|
499     . $locale->text('Part Description') . qq|</th>
500           <td colspan=3><input name=description size=40></td>
501         </tr>
502         <tr>
503           <th align=right nowrap>| . $locale->text('Group') . qq|</th>
504           <td><input name=partsgroup size=20></td>
505           $serialnumber
506         </tr>
507         $makemodel
508         <tr>
509           <th align=right nowrap>| . $locale->text('Drawing') . qq|</th>
510           <td><input name=drawing size=20></td>
511           <th align=right nowrap>| . $locale->text('Microfiche') . qq|</th>
512           <td><input name=microfiche size=20></td>
513         </tr>
514         $toplevel
515         <tr>
516           <td></td>
517           <td colspan=3>
518             <input name=itemstatus class=radio type=radio value=active checked>&nbsp;|
519     . $locale->text('Active') . qq|
520             $onhand
521             <input name=itemstatus class=radio type=radio value=obsolete>&nbsp;|
522     . $locale->text('Obsolete') . qq|
523             <input name=itemstatus class=radio type=radio value=orphaned>&nbsp;|
524     . $locale->text('Orphaned') . qq|
525           </td>
526         </tr>
527         $bought
528         <tr>
529           <td></td>
530           <td colspan=3>
531             <hr size=1 noshade>
532           </td>
533         </tr>|;
534   print qq|
535   <tr>
536     <td colspan=4>
537       <table width=100%>
538         <tr>
539           <th class="listheading">| . $locale->text('Preisklasse') . qq|</th>
540           <th class="listheading">| . $locale->text('Preis') . qq|</th>
541           <th class="listheading">| . $locale->text('Prozentual/Absolut') . qq|</th>
542         </tr>
543         <tr>
544           <td>| . $locale->text('Sell Price') . qq|</td>
545           <td><input name="sellprice" size=11 value="$form->{"sellprice"}"></td>
546           <td><input name="sellprice_type" class=radio type=radio value=percent checked>/<input name="sellprice_type" class=radio type=radio value=absolut></td>
547         </tr>
548         <tr>
549           <td>| . $locale->text('List Price') . qq|</td>
550           <td><input name="listprice" size=11 value="$form->{"listprice"}"></td>
551           <td><input name="listprice_type" class=radio type=radio value=percent checked>/<input name="listprice_type" class=radio type=radio value=absolut></td>
552         </tr>
553 |;
554   for my $i (1 .. $form->{price_rows}) {
555     print qq|
556         <tr>
557           <td width=50%><input type=hidden name="pricegroup_$i" size=30  value="$form->{"pricegroup_$i"}">$form->{"pricegroup_$i"}</td>
558           <td width=50%><input name="price_$i" size=11></td>
559           <input type=hidden name="pricegroup_id_$i" value="$form->{"pricegroup_id_$i"}">
560           <td><input name="pricegroup_type_$i" class=radio type=radio value=percent checked>/<input name="pricegroup_type_$i" class=radio type=radio value=absolut></td>
561         </tr>
562 |;
563   }
564
565   print qq|
566       </table>
567     </td>
568   </tr>
569
570   <tr><td colspan=4><hr size=3 noshade></td></tr>
571 </table>
572 <input type=hidden name=nextsub value=confirm_price_update>
573 <input type=hidden name=price_rows value=$form->{price_rows}>
574
575 <input type=hidden name=login value=$form->{login}>
576 <input type=hidden name=password value=$form->{password}>
577
578 <br>
579 <input class=submit type=submit name=action value="|
580     . $locale->text('Continue') . qq|">
581 </form>
582
583 </body>
584 </html>
585 |;
586   $lxdebug->leave_sub();
587 }    #end search()
588
589 sub confirm_price_update {
590   $lxdebug->enter_sub();
591
592
593   $form->{nextsub} = "update_prices";
594   $form->header;
595
596   print qq|
597 <body>
598
599 <form method=post action=$form->{script}>
600 |;
601
602   # delete action variable
603   map { delete $form->{$_} } qw(action header);
604
605   foreach my $key (keys %$form) {
606     $form->{$key} =~ s/\"/&quot;/g;
607     print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
608   }
609
610   print qq|
611 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
612
613 <h4>|
614     . $locale->text('Are you sure you want to update the prices')
615 . qq| </h4>
616
617 <p>
618 <input name=action class=submit type=submit value="|
619     . $locale->text('Continue') . qq|">
620 </form>
621 |;
622
623   $lxdebug->leave_sub();
624 }
625
626 sub update_prices {
627   $lxdebug->enter_sub();
628
629   if (IC->update_prices(\%myconfig, \%$form)) {
630     $form->redirect($form->{update_count} . $locale->text('prices updated!'));
631   } else {
632     $form->error($locale->text('Could not update prices!'));
633   }
634
635   $lxdebug->leave_sub();
636 }
637
638 sub choice {
639   $lxdebug->enter_sub();
640
641   our ($j, $lastndx);
642   my ($totop100);
643
644   $form->{title} = $locale->text('Top 100 hinzufuegen');
645
646   $form->header;
647
648   print qq|
649   <body>
650
651   <form method=post action=$form->{script}>
652
653   <input type=hidden name=searchitems value=$form->{searchitems}>
654   <input type=hidden name=title value="$form->{title}">
655
656   <input type=hidden name=revers value="$form->{revers}">
657   <input type=hidden name=lastsort value="$form->{lastsort}">|;
658
659   print qq|
660       <table>
661         <tr class=listheading>
662          <th class=listheading nowrap>| . $locale->text('Part Number') . qq|</th>
663          <th class=listheading nowrap>| . $locale->text('Part Description') . qq|</th>
664         </tr>
665         <tr valign=top>
666          <td><input type=text name=partnumber size=20 value=></td>
667          <td><input type=text name=description size=30 value=></td>
668        </tr>
669       </table>
670      <br>|;
671
672   print qq|
673
674 <input type=hidden name=login value=$form->{login}>
675 <input type=hidden name=password value=$form->{password}>
676
677 <input type=hidden name=itemstatus value="$form->{itemstatus}">
678 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
679 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
680 <input type=hidden name=l_description value="$form->{l_description}">
681 <input type=hidden name=l_onhand value="$form->{l_onhand}">
682 <input type=hidden name=l_unit value="$form->{l_unit}">
683 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
684 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
685 <input type=hidden name=sort value="$form->{sort}">
686 <input type=hidden name=revers value="$form->{revers}">
687 <input type=hidden name=lastsort value="$form->{lastsort}">
688
689 <input type=hidden name=bom value="$form->{bom}">
690 <input type=hidden name=titel value="$form->{titel}">
691 <input type=hidden name=searchitems value="$form->{searchitems}">
692
693 <input type=hidden name=row value=$j>
694
695 <input type=hidden name=nextsub value=item_selected>
696
697 <input type=hidden name=test value=item_selected>
698
699 <input name=lastndx type=hidden value=$lastndx>
700
701 <input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>
702
703 <input name=extras type=hidden value=$form->{extras}>|;
704
705   my ($partnumber, $description, $unit, $sellprice, $soldtotal);
706   # if choice set data
707   if ($form->{ndx}) {
708     for (my $i = 0; $i < $form->{ndxs_counter}; $i++) {
709
710       # prepeare data
711       $partnumber  = $form->{"totop100_partnumber_$j"};
712       $description = $form->{"totop100_description_$j"};
713       $unit        = $form->{"totop100_unit_$j"};
714       $sellprice   = $form->{"totop100_sellprice_$j"};
715       $soldtotal   = $form->{"totop100_soldtotal_$j"};
716
717       # insert data into top100
718       push @{ $form->{parts} },
719         { number      => "",
720           partnumber  => "$partnumber",
721           description => "$description",
722           unit        => "$unit",
723           sellprice   => "$sellprice",
724           soldtotal   => "$soldtotal" };
725     }    #rof
726   }    #fi
727
728   $totop100 = "";
729
730   # set data for next page
731   if (($form->{ndxs_counter}) > 0) {
732     for (my $i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
733       $partnumber  = $form->{"totop100_partnumber_$i"};
734       $description = $form->{"totop100_description_$i"};
735       $unit        = $form->{"totop100_unit_$i"};
736       $sellprice   = $form->{"totop100_sellprice_$i"};
737       $soldtotal   = $form->{"totop100_soldtotal_$i"};
738
739       $totop100 .= qq|
740 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
741 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
742 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
743 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
744 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
745       |;
746     }    #rof
747   }    #fi
748
749   print $totop100;
750
751   print qq|
752      <input class=submit type=submit name=action value="|
753     . $locale->text('list') . qq|">
754     </form>
755
756    </body>
757   </html>|;
758   $lxdebug->leave_sub();
759 }    #end choice
760
761 sub list {
762   $lxdebug->enter_sub();
763
764   our ($lastndx);
765   our ($partnumber, $description, $unit, $sellprice, $soldtotal);
766
767   my @sortorders = ("", "partnumber", "description", "all");
768   my $sortorder = $sortorders[($form->{description} ? 2 : 0) + ($form->{partnumber} ? 1 : 0)];
769   IC->get_parts(\%myconfig, \%$form, $sortorder);
770
771   $form->{title} = $locale->text('Top 100 hinzufuegen');
772
773   $form->header;
774
775   print qq|
776 <body>
777   <form method=post action=ic.pl>
778     <table width=100%>
779      <tr>
780       <th class=listtop colspan=6>| . $locale->text('choice part') . qq|</th>
781      </tr>
782         <tr height="5"></tr>
783         <tr class=listheading>
784           <th>&nbsp;</th>
785           <th class=listheading>| . $locale->text('Part Number') . qq|</th>
786           <th class=listheading>| . $locale->text('Part Description') . qq|</th>
787           <th class=listheading>| . $locale->text('Unit of measure') . qq|</th>
788           <th class=listheading>| . $locale->text('Sell Price') . qq|</th>
789           <th class=listheading>| . $locale->text('soldtotal') . qq|</th>
790         </tr>|;
791
792   my $j = 0;
793   my $i = $form->{rows};
794
795   for ($j = 1; $j <= $i; $j++) {
796
797     print qq|
798         <tr class=listrow1>|;
799     if ($j == 1) {
800       print qq|
801             <td><input name=ndx class=radio type=radio value=$j checked></td>|;
802     } else {
803       print qq|
804           <td><input name=ndx class=radio type=radio value=$j></td>|;
805     }
806     print qq|
807           <td><input name="new_partnumber_$j" type=hidden value="$form->{"partnumber_$j"}">$form->{"partnumber_$j"}</td>
808           <td><input name="new_description_$j" type=hidden value="$form->{"description_$j"}">$form->{"description_$j"}</td>
809           <td><input name="new_unit_$j" type=hidden value="$form->{"unit_$j"}">$form->{"unit_$j"}</td>
810           <td><input name="new_sellprice_$j" type=hidden value="$form->{"sellprice_$j"}">$form->{"sellprice_$j"}</td>
811           <td><input name="new_soldtotal_$j" type=hidden value="$form->{"soldtotal_$j"}">$form->{"soldtotal_$j"}</td>
812         </tr>
813
814         <input name="new_id_$j" type=hidden value="$form->{"id_$j"}">|;
815   }
816
817   print qq|
818
819 </table>
820
821 <br>
822
823
824 <input type=hidden name=login value=$form->{login}>
825 <input type=hidden name=password value=$form->{password}>
826
827 <input type=hidden name=itemstatus value="$form->{itemstatus}">
828 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
829 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
830 <input type=hidden name=l_description value="$form->{l_description}">
831 <input type=hidden name=l_onhand value="$form->{l_onhand}">
832 <input type=hidden name=l_unit value="$form->{l_unit}">
833 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
834 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
835 <input type=hidden name=sort value="$form->{sort}">
836 <input type=hidden name=revers value="$form->{revers}">
837 <input type=hidden name=lastsort value="$form->{lastsort}">
838
839 <input type=hidden name=bom value="$form->{bom}">
840 <input type=hidden name=titel value="$form->{titel}">
841 <input type=hidden name=searchitems value="$form->{searchitems}">
842
843 <input type=hidden name=row value=$j>
844
845 <input type=hidden name=nextsub value=item_selected>
846
847 <input name=lastndx type=hidden value=$lastndx>
848
849 <input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>|;
850
851   my $totop100 = "";
852
853   if (($form->{ndxs_counter}) > 0) {
854     for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
855
856       $partnumber  = $form->{"totop100_partnumber_$i"};
857       $description = $form->{"totop100_description_$i"};
858       $unit        = $form->{"totop100_unit_$i"};
859       $sellprice   = $form->{"totop100_sellprice_$i"};
860       $soldtotal   = $form->{"totop100_soldtotal_$i"};
861
862       $totop100 .= qq|
863 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
864 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
865 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
866 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
867 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
868       |;
869     }    #rof
870   }    #fi
871
872   print $totop100;
873
874   print qq|
875 <input class=submit type=submit name=action value="|
876     . $locale->text('TOP100') . qq|">
877
878 </form>
879 </body>
880 </html>
881 |;
882   $lxdebug->leave_sub();
883 }    #end list()
884
885 sub top100 {
886   $lxdebug->enter_sub();
887
888   if ($form->{ndx}) {
889     $form->{ndxs_counter}++;
890
891     if ($form->{ndxs_counter} > 0) {
892
893       my $index = $form->{ndx};
894
895       $form->{"totop100_partnumber_$form->{ndxs_counter}"} = $form->{"new_partnumber_$index"};
896       $form->{"totop100_description_$form->{ndxs_counter}"} = $form->{"new_description_$index"};
897       $form->{"totop100_unit_$form->{ndxs_counter}"} = $form->{"new_unit_$index"};
898       $form->{"totop100_sellprice_$form->{ndxs_counter}"} = $form->{"new_sellprice_$index"};
899       $form->{"totop100_soldtotal_$form->{ndxs_counter}"} = $form->{"new_soldtotal_$index"};
900     }    #fi
901   }    #fi
902   &addtop100();
903   $lxdebug->leave_sub();
904 }    #end top100
905
906 sub addtop100 {
907   $lxdebug->enter_sub();
908
909   my ($revers, $lastsort, $callback, $option, $description, $sameitem,
910       $partnumber, $unit, $sellprice, $soldtotal, $totop100, $onhand, $align);
911   my (@column_index, %column_header, %column_data);
912   my ($totalsellprice, $totallastcost, $totallistprice, $subtotalonhand, $subtotalsellprice, $subtotallastcost, $subtotallistprice);
913
914   $form->{top100}      = "top100";
915   $form->{l_soldtotal} = "Y";
916   $form->{soldtotal}   = "soldtotal";
917   $form->{sort}        = "soldtotal";
918   $form->{l_qty}       = "N";
919   $form->{l_linetotal} = "";
920   $form->{revers}      = 1;
921   $form->{number}      = "position";
922   $form->{l_number}    = "Y";
923
924   $totop100 = "";
925
926   $form->{title} = $locale->text('Top 100');
927
928   $revers   = $form->{revers};
929   $lastsort = $form->{lastsort};
930
931   if (($form->{lastsort} eq "") && ($form->{sort} eq undef)) {
932     $form->{revers}   = 0;
933     $form->{lastsort} = "partnumber";
934     $form->{sort}     = "partnumber";
935   }    #fi
936
937   $callback =
938     "$form->{script}?action=top100&login=$form->{login}&password=$form->{password}&searchitems=$form->{searchitems}&itemstatus=$form->{itemstatus}&bom=$form->{bom}&l_linetotal=$form->{l_linetotal}&title="
939     . $form->escape($form->{title}, 1);
940
941   # if we have a serialnumber limit search
942   if ($form->{serialnumber} || $form->{l_serialnumber}) {
943     $form->{l_serialnumber} = "Y";
944     unless (   $form->{bought}
945             || $form->{sold}
946             || $form->{rfq}
947             || $form->{quoted}) {
948       $form->{bought} = $form->{sold} = 1;
949     }
950   }
951   IC->all_parts(\%myconfig, \%$form);
952
953   if ($form->{itemstatus} eq 'active') {
954     $option .= $locale->text('Active') . " : ";
955   }
956   if ($form->{itemstatus} eq 'obsolete') {
957     $option .= $locale->text('Obsolete') . " : ";
958   }
959   if ($form->{itemstatus} eq 'orphaned') {
960     $option .= $locale->text('Orphaned') . " : ";
961   }
962   if ($form->{itemstatus} eq 'onhand') {
963     $option .= $locale->text('On Hand') . " : ";
964     $form->{l_onhand} = "Y";
965   }
966   if ($form->{itemstatus} eq 'short') {
967     $option .= $locale->text('Short') . " : ";
968     $form->{l_onhand} = "Y";
969   }
970   if ($form->{onorder}) {
971     $form->{l_ordnumber} = "Y";
972     $callback .= "&onorder=$form->{onorder}";
973     $option   .= $locale->text('On Order') . " : ";
974   }
975   if ($form->{ordered}) {
976     $form->{l_ordnumber} = "Y";
977     $callback .= "&ordered=$form->{ordered}";
978     $option   .= $locale->text('Ordered') . " : ";
979   }
980   if ($form->{rfq}) {
981     $form->{l_quonumber} = "Y";
982     $callback .= "&rfq=$form->{rfq}";
983     $option   .= $locale->text('RFQ') . " : ";
984   }
985   if ($form->{quoted}) {
986     $form->{l_quonumber} = "Y";
987     $callback .= "&quoted=$form->{quoted}";
988     $option   .= $locale->text('Quoted') . " : ";
989   }
990   if ($form->{bought}) {
991     $form->{l_invnumber} = "Y";
992     $callback .= "&bought=$form->{bought}";
993     $option   .= $locale->text('Bought') . " : ";
994   }
995   if ($form->{sold}) {
996     $form->{l_invnumber} = "Y";
997     $callback .= "&sold=$form->{sold}";
998     $option   .= $locale->text('Sold') . " : ";
999   }
1000   if (   $form->{bought}
1001       || $form->{sold}
1002       || $form->{onorder}
1003       || $form->{ordered}
1004       || $form->{rfq}
1005       || $form->{quoted}) {
1006
1007     $form->{l_lastcost} = "";
1008     $form->{l_name}     = "Y";
1009     if ($form->{transdatefrom}) {
1010       $callback .= "&transdatefrom=$form->{transdatefrom}";
1011       $option   .= "\n<br>"
1012         . $locale->text('From')
1013         . "&nbsp;"
1014         . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1015     }
1016     if ($form->{transdateto}) {
1017       $callback .= "&transdateto=$form->{transdateto}";
1018       $option   .= "\n<br>"
1019         . $locale->text('To')
1020         . "&nbsp;"
1021         . $locale->date(\%myconfig, $form->{transdateto}, 1);
1022     }
1023   }
1024
1025   $option .= "<br>";
1026
1027   if ($form->{partnumber}) {
1028     $callback .= "&partnumber=$form->{partnumber}";
1029     $option   .= $locale->text('Part Number') . qq| : $form->{partnumber}<br>|;
1030   }
1031   if ($form->{ean}) {
1032     $callback .= "&partnumber=$form->{ean}";
1033     $option   .= $locale->text('EAN') . qq| : $form->{ean}<br>|;
1034   }
1035   if ($form->{partsgroup}) {
1036     $callback .= "&partsgroup=$form->{partsgroup}";
1037     $option   .= $locale->text('Group') . qq| : $form->{partsgroup}<br>|;
1038   }
1039   if ($form->{serialnumber}) {
1040     $callback .= "&serialnumber=$form->{serialnumber}";
1041     $option   .=
1042       $locale->text('Serial Number') . qq| : $form->{serialnumber}<br>|;
1043   }
1044   if ($form->{description}) {
1045     $callback .= "&description=$form->{description}";
1046     $description = $form->{description};
1047     $description =~ s/
1048 /<br>/g;
1049     $option .=
1050       $locale->text('Part Description') . qq| : $form->{description}<br>|;
1051   }
1052   if ($form->{make}) {
1053     $callback .= "&make=$form->{make}";
1054     $option   .= $locale->text('Make') . qq| : $form->{make}<br>|;
1055   }
1056   if ($form->{model}) {
1057     $callback .= "&model=$form->{model}";
1058     $option   .= $locale->text('Model') . qq| : $form->{model}<br>|;
1059   }
1060   if ($form->{drawing}) {
1061     $callback .= "&drawing=$form->{drawing}";
1062     $option   .= $locale->text('Drawing') . qq| : $form->{drawing}<br>|;
1063   }
1064   if ($form->{microfiche}) {
1065     $callback .= "&microfiche=$form->{microfiche}";
1066     $option   .= $locale->text('Microfiche') . qq| : $form->{microfiche}<br>|;
1067   }
1068   if ($form->{l_soldtotal}) {
1069     $callback .= "&soldtotal=$form->{soldtotal}";
1070     $option   .= $locale->text('soldtotal') . qq| : $form->{soldtotal}<br>|;
1071   }
1072
1073   my @columns = $form->sort_columns(
1074     qw(number partnumber ean description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal)
1075   );
1076
1077   if ($form->{l_linetotal}) {
1078     $form->{l_onhand} = "Y";
1079     $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
1080     if ($form->{l_lastcost}) {
1081       $form->{l_linetotallastcost} = "Y";
1082       if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
1083         $form->{l_linetotallastcost} = "";
1084       }
1085     }
1086     $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
1087   }
1088
1089   if ($form->{searchitems} eq 'service') {
1090
1091     # remove bin, weight and rop from list
1092     map { $form->{"l_$_"} = "" } qw(bin weight rop);
1093
1094     $form->{l_onhand} = "";
1095
1096     # qty is irrelevant unless bought or sold
1097     if (   $form->{bought}
1098         || $form->{sold}
1099         || $form->{onorder}
1100         || $form->{ordered}
1101         || $form->{rfq}
1102         || $form->{quoted}) {
1103       $form->{l_onhand} = "Y";
1104     } else {
1105       $form->{l_linetotalsellprice} = "";
1106       $form->{l_linetotallastcost}  = "";
1107     }
1108   }
1109
1110   $form->{l_lastcost} = ""
1111     if ($form->{searchitems} eq 'assembly' && !$form->{bom});
1112
1113   foreach my $item (@columns) {
1114     if ($form->{"l_$item"} eq "Y") {
1115       push @column_index, $item;
1116
1117       # add column to callback
1118       $callback .= "&l_$item=Y";
1119     }
1120   }
1121
1122   if ($form->{l_subtotal} eq 'Y') {
1123     $callback .= "&l_subtotal=Y";
1124   }
1125
1126   $column_header{number} =
1127     qq|<th class=listheading nowrap>| . $locale->text('number') . qq|</th>|;
1128   $column_header{partnumber} =
1129     qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|
1130     . $locale->text('Part Number')
1131     . qq|</a></th>|;
1132   $column_header{description} =
1133     qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|
1134     . $locale->text('Part Description')
1135     . qq|</a></th>|;
1136   $column_header{partsgroup} =
1137       qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|
1138     . $locale->text('Group')
1139     . qq|</a></th>|;
1140   $column_header{bin} =
1141       qq|<th><a class=listheading href=$callback&sort=bin>|
1142     . $locale->text('Bin')
1143     . qq|</a></th>|;
1144   $column_header{priceupdate} =
1145       qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|
1146     . $locale->text('Updated')
1147     . qq|</a></th>|;
1148   $column_header{onhand} =
1149     qq|<th nowrap><a  class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|
1150     . $locale->text('Qty')
1151     . qq|</th>|;
1152   $column_header{unit} =
1153     qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
1154   $column_header{listprice} =
1155       qq|<th class=listheading nowrap>|
1156     . $locale->text('List Price')
1157     . qq|</th>|;
1158   $column_header{lastcost} =
1159     qq|<th class=listheading nowrap>| . $locale->text('Last Cost') . qq|</th>|;
1160   $column_header{rop} =
1161     qq|<th class=listheading nowrap>| . $locale->text('ROP') . qq|</th>|;
1162   $column_header{weight} =
1163     qq|<th class=listheading nowrap>| . $locale->text('Weight') . qq|</th>|;
1164
1165   $column_header{invnumber} =
1166       qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|
1167     . $locale->text('Invoice Number')
1168     . qq|</a></th>|;
1169   $column_header{ordnumber} =
1170       qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|
1171     . $locale->text('Order Number')
1172     . qq|</a></th>|;
1173   $column_header{quonumber} =
1174       qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|
1175     . $locale->text('Quotation')
1176     . qq|</a></th>|;
1177
1178   $column_header{name} =
1179       qq|<th nowrap><a class=listheading href=$callback&sort=name>|
1180     . $locale->text('Name')
1181     . qq|</a></th>|;
1182
1183   $column_header{sellprice} =
1184       qq|<th class=listheading nowrap>|
1185     . $locale->text('Sell Price')
1186     . qq|</th>|;
1187   $column_header{linetotalsellprice} =
1188     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
1189   $column_header{linetotallastcost} =
1190     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
1191   $column_header{linetotallistprice} =
1192     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
1193
1194   $column_header{image} =
1195     qq|<th class=listheading nowrap>| . $locale->text('Image') . qq|</a></th>|;
1196   $column_header{drawing} =
1197       qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|
1198     . $locale->text('Drawing')
1199     . qq|</a></th>|;
1200   $column_header{microfiche} =
1201       qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|
1202     . $locale->text('Microfiche')
1203     . qq|</a></th>|;
1204
1205   $column_header{serialnumber} =
1206       qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|
1207     . $locale->text('Serial Number')
1208     . qq|</a></th>|;
1209   $column_header{soldtotal} =
1210     qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|
1211     . $locale->text('soldtotal')
1212     . qq|</a></th>|;
1213
1214   $form->header;
1215   my $colspan = $#column_index + 1;
1216
1217   print qq|
1218 <body>
1219
1220 <table width=100%>
1221   <tr>
1222     <th class=listtop colspan=$colspan>$form->{title}</th>
1223   </tr>
1224   <tr height="5"></tr>
1225
1226   <tr><td colspan=$colspan>$option</td></tr>
1227
1228   <tr class=listheading>
1229 |;
1230
1231   map { print "\n$column_header{$_}" } @column_index;
1232
1233   print qq|
1234   </tr>
1235   |;
1236
1237   # add order to callback
1238   $form->{callback} = $callback .= "&sort=$form->{sort}";
1239
1240   # escape callback for href
1241   $callback = $form->escape($callback);
1242
1243   if (@{ $form->{parts} }) {
1244     $sameitem = $form->{parts}->[0]->{ $form->{sort} };
1245   }
1246
1247   # insert numbers for top100
1248   my $j = 0;
1249   foreach my $ref (@{ $form->{parts} }) {
1250     $j++;
1251     $ref->{number} = $j;
1252   }
1253
1254   # if avaible -> insert choice here
1255   if (($form->{ndxs_counter}) > 0) {
1256     for (my $i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
1257       $partnumber  = $form->{"totop100_partnumber_$i"};
1258       $description = $form->{"totop100_description_$i"};
1259       $unit        = $form->{"totop100_unit_$i"};
1260       $sellprice   = $form->{"totop100_sellprice_$i"};
1261       $soldtotal   = $form->{"totop100_soldtotal_$i"};
1262
1263       $totop100 .= qq|
1264 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
1265 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
1266 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
1267 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
1268 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
1269       |;
1270
1271       # insert into list
1272       push @{ $form->{parts} },
1273         { number      => "",
1274           partnumber  => "$partnumber",
1275           description => "$description",
1276           unit        => "$unit",
1277           sellprice   => "$sellprice",
1278           soldtotal   => "$soldtotal" };
1279     }    #rof
1280   }    #fi
1281        # build data for columns
1282   foreach my $ref (@{ $form->{parts} }) {
1283     my $i = 0;
1284
1285     if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
1286       if ($sameitem ne $ref->{ $form->{sort} }) {
1287         &parts_subtotal;
1288         $sameitem = $ref->{ $form->{sort} };
1289       }
1290     }
1291
1292     $ref->{exchangerate} = 1 unless $ref->{exchangerate};
1293     $ref->{sellprice} *= $ref->{exchangerate};
1294     $ref->{listprice} *= $ref->{exchangerate};
1295     $ref->{lastcost}  *= $ref->{exchangerate};
1296
1297     # use this for assemblies
1298     $onhand = $ref->{onhand};
1299
1300     $align = "left";
1301     if ($ref->{assemblyitem}) {
1302       $align = "right";
1303       $onhand = 0 if ($form->{sold});
1304     }
1305
1306     $ref->{description} =~ s/
1307 /<br>/g;
1308
1309     $column_data{number} =
1310         "<td align=right>"
1311       . $form->format_amount(\%myconfig, $ref->{number})
1312       . "</td>";
1313     $column_data{partnumber} =
1314       "<td align=$align>$ref->{partnumber}&nbsp;</a></td>";
1315     $column_data{description} = "<td>$ref->{description}&nbsp;</td>";
1316     $column_data{partsgroup}  = "<td>$ref->{partsgroup}&nbsp;</td>";
1317
1318     $column_data{onhand} =
1319         "<td align=right>"
1320       . $form->format_amount(\%myconfig, $ref->{onhand})
1321       . "</td>";
1322     $column_data{sellprice} =
1323         "<td align=right>"
1324       . $form->format_amount(\%myconfig, $ref->{sellprice})
1325       . "</td>";
1326     $column_data{listprice} =
1327         "<td align=right>"
1328       . $form->format_amount(\%myconfig, $ref->{listprice})
1329       . "</td>";
1330     $column_data{lastcost} =
1331         "<td align=right>"
1332       . $form->format_amount(\%myconfig, $ref->{lastcost})
1333       . "</td>";
1334
1335     $column_data{linetotalsellprice} = "<td align=right>"
1336       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice}, 2)
1337       . "</td>";
1338     $column_data{linetotallastcost} = "<td align=right>"
1339       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost}, 2)
1340       . "</td>";
1341     $column_data{linetotallistprice} = "<td align=right>"
1342       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice}, 2)
1343       . "</td>";
1344
1345     if (!$ref->{assemblyitem}) {
1346       $totalsellprice += $onhand * $ref->{sellprice};
1347       $totallastcost  += $onhand * $ref->{lastcost};
1348       $totallistprice += $onhand * $ref->{listprice};
1349
1350       $subtotalonhand    += $onhand;
1351       $subtotalsellprice += $onhand * $ref->{sellprice};
1352       $subtotallastcost  += $onhand * $ref->{lastcost};
1353       $subtotallistprice += $onhand * $ref->{listprice};
1354     }
1355
1356     $column_data{rop} =
1357       "<td align=right>"
1358       . $form->format_amount(\%myconfig, $ref->{rop}) . "</td>";
1359     $column_data{weight} =
1360         "<td align=right>"
1361       . $form->format_amount(\%myconfig, $ref->{weight})
1362       . "</td>";
1363     $column_data{unit}        = "<td>$ref->{unit}&nbsp;</td>";
1364     $column_data{bin}         = "<td>$ref->{bin}&nbsp;</td>";
1365     $column_data{priceupdate} = "<td>$ref->{priceupdate}&nbsp;</td>";
1366
1367     $column_data{invnumber} =
1368       ($ref->{module} ne 'oe')
1369       ? "<td><a href=$ref->{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}</a></td>"
1370       : "<td>$ref->{invnumber}</td>";
1371     $column_data{ordnumber} =
1372       ($ref->{module} eq 'oe')
1373       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber}</a></td>"
1374       : "<td>$ref->{ordnumber}</td>";
1375     $column_data{quonumber} =
1376       ($ref->{module} eq 'oe' && !$ref->{ordnumber})
1377       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber}</a></td>"
1378       : "<td>$ref->{quonumber}</td>";
1379
1380     $column_data{name} = "<td>$ref->{name}</td>";
1381
1382     $column_data{image} =
1383       ($ref->{image})
1384       ? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>"
1385       : "<td>&nbsp;</td>";
1386     $column_data{drawing} =
1387       ($ref->{drawing})
1388       ? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>"
1389       : "<td>&nbsp;</td>";
1390     $column_data{microfiche} =
1391       ($ref->{microfiche})
1392       ? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>"
1393       : "<td>&nbsp;</td>";
1394
1395     $column_data{serialnumber} = "<td>$ref->{serialnumber}</td>";
1396
1397     $column_data{soldtotal} = "<td  align=right>$ref->{soldtotal}</td>";
1398
1399     $i++;
1400     $i %= 2;
1401     print "<tr class=listrow$i>";
1402
1403     map { print "\n$column_data{$_}" } @column_index;
1404
1405     print qq|
1406     </tr>
1407 |;
1408   }
1409
1410   if ($form->{l_subtotal} eq 'Y') {
1411     &parts_subtotal;
1412   }    #fi
1413
1414   if ($form->{"l_linetotal"}) {
1415     map { $column_data{$_} = "<td>&nbsp;</td>" } @column_index;
1416     $column_data{linetotalsellprice} =
1417         "<th class=listtotal align=right>"
1418       . $form->format_amount(\%myconfig, $totalsellprice, 2)
1419       . "</th>";
1420     $column_data{linetotallastcost} =
1421         "<th class=listtotal align=right>"
1422       . $form->format_amount(\%myconfig, $totallastcost, 2)
1423       . "</th>";
1424     $column_data{linetotallistprice} =
1425         "<th class=listtotal align=right>"
1426       . $form->format_amount(\%myconfig, $totallistprice, 2)
1427       . "</th>";
1428
1429     print "<tr class=listtotal>";
1430
1431     map { print "\n$column_data{$_}" } @column_index;
1432
1433     print qq|</tr>
1434     |;
1435   }
1436
1437   print qq|
1438   <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
1439 </table>
1440
1441 |;
1442
1443   print qq|
1444
1445 <br>
1446
1447 <form method=post action=$form->{script}>
1448
1449 <input type=hidden name=login value=$form->{login}>
1450 <input type=hidden name=password value=$form->{password}>
1451
1452 <input type=hidden name=itemstatus value="$form->{itemstatus}">
1453 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
1454 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
1455 <input type=hidden name=l_description value="$form->{l_description}">
1456 <input type=hidden name=l_onhand value="$form->{l_onhand}">
1457 <input type=hidden name=l_unit value="$form->{l_unit}">
1458 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
1459 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
1460 <input type=hidden name=sort value="$form->{sort}">
1461 <input type=hidden name=revers value="$form->{revers}">
1462 <input type=hidden name=lastsort value="$form->{lastsort}">
1463 <input type=hidden name=parts value="$form->{parts}">
1464
1465 <input type=hidden name=bom value="$form->{bom}">
1466 <input type=hidden name=titel value="$form->{titel}">
1467 <input type=hidden name=searchitems value="$form->{searchitems}">|;
1468
1469   print $totop100;
1470
1471   print qq|
1472     <input type=hidden name=ndxs_counter value="$form->{ndxs_counter}">
1473
1474     <input class=submit type=submit name=action value="|
1475     . $locale->text('choice') . qq|">
1476
1477   </form>
1478
1479 </body>
1480 </html>
1481 |;
1482
1483   $lxdebug->leave_sub();
1484 }    # end addtop100
1485
1486 #
1487 # Report for Wares.
1488 # Warning, deep magic ahead.
1489 # This function parses the requested details, sanity checks them, and converts them into a format thats usable for IC->all_parts
1490 #
1491 # flags coming from the form:
1492 # hardcoded:
1493 #  searchitems=part revers=0 lastsort=''
1494 #
1495 # filter:
1496 # partnumber ean description partsgroup serialnumber make model drawing microfiche
1497 # transdatefrom transdateto
1498 #
1499 # radio:
1500 #  itemstatus = active | onhand | short | obsolete | orphaned
1501 #  action     = continue | top100
1502 #
1503 # checkboxes:
1504 #  bought sold onorder ordered rfq quoted
1505 #  l_partnumber l_description l_serialnumber l_unit l_listprice l_sellprice l_lastcost
1506 #  l_linetotal l_priceupdate l_bin l_rop l_weight l_image l_drawing l_microfiche
1507 #  l_partsgroup l_subtotal l_soldtotal l_deliverydate
1508 #
1509 # hiddens: 
1510 #  nextsub login password revers lastsort sort ndxs_counter
1511 #
1512 sub generate_report {
1513   $lxdebug->enter_sub();
1514
1515   my ($revers, $lastsort, $description);
1516
1517   $form->{title} = (ucfirst $form->{searchitems}) . "s";
1518   $form->{title} = $locale->text($form->{title});
1519
1520   my $revers     = $form->{revers};
1521   my $lastsort   = $form->{lastsort};
1522
1523   # sorting and direction of sorting
1524   # ToDO: change this to the simpler field+direction method
1525   if (($form->{lastsort} eq "") && ($form->{sort} eq undef)) {
1526     $form->{revers}   = 0;
1527     $form->{lastsort} = "partnumber";
1528     $form->{sort}     = "partnumber";
1529   } else {
1530     if ($form->{lastsort} eq $form->{sort}) {
1531       $form->{revers} = 1 - $form->{revers};
1532     } else {
1533       $form->{revers} = 0;
1534       $form->{lastsort} = $form->{sort};
1535     }    #fi
1536   }    #fi
1537
1538   # special case if we have a serialnumber limit search
1539   # serialnumbers are only given in invoices and orders, 
1540   # so they can only pop up in bought, sold, rfq, and quoted stuff
1541   $form->{no_sn_joins} = 'Y' if (   !$form->{bought} && !$form->{sold} 
1542                                  && !$form->{rfq}    && !$form->{quoted} 
1543                                  && ($form->{l_serialnumber} || $form->{serialnumber}));
1544
1545   # special case for any checkbox of bought | sold | onorder | ordered | rfq | quoted.
1546   # if any of these are ticked the behavior changes slightly for lastcost
1547   # since all those are aggregation checks for the legder tables this is an internal switch
1548   # refered to as ledgerchecks
1549   $form->{ledgerchecks} = 'Y' if (   $form->{bought} || $form->{sold} || $form->{onorder}
1550                                   || $form->{ordered} || $form->{rfq} || $form->{quoted});
1551
1552   # if something should be aktivated if something else is active, enter it here
1553   my %dependencies = (
1554     onhand       => [ qw(l_onhand) ],
1555     short        => [ qw(l_onhand) ],
1556     onorder      => [ qw(l_ordnumber) ],
1557     ordered      => [ qw(l_ordnumber) ],
1558     rfq          => [ qw(l_quonumber) ],
1559     quoted       => [ qw(l_quonumber) ],
1560     bought       => [ qw(l_invnumber) ],
1561     sold         => [ qw(l_invnumber) ],
1562     ledgerchecks => [ qw(l_name) ],
1563     serialnumber => [ qw(l_serialnumber) ],
1564     no_sn_joins  => [ qw(bought sold) ],
1565   );
1566
1567   # these strings get displayed at the top of the results to indicate the user which switches were used
1568   my %optiontexts = (
1569     active        => $locale->text('Active'),
1570     obsolete      => $locale->text('Obsolete'),
1571     orphaned      => $locale->text('Orphaned'),
1572     onhand        => $locale->text('On Hand'),
1573     short         => $locale->text('Short'),
1574     onorder       => $locale->text('On Order'),
1575     ordered       => $locale->text('Ordered'),
1576     rfq           => $locale->text('RFQ'),
1577     quoted        => $locale->text('Quoted'),
1578     bought        => $locale->text('Bought'),
1579     sold          => $locale->text('Sold'),
1580     transdatefrom => $locale->text('From')       . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1),
1581     transdateto   => $locale->text('To (time)')  . " " . $locale->date(\%myconfig, $form->{transdateto}, 1),
1582     partnumber    => $locale->text('Part Number')      . ": '$form->{partnumber}'",
1583     partsgroup    => $locale->text('Group')            . ": '$form->{partsgroup}'",
1584     serialnumber  => $locale->text('Serial Number')    . ": '$form->{serialnumber}'",
1585     description   => $locale->text('Part Description') . ": '$form->{description}'",
1586     make          => $locale->text('Make')             . ": '$form->{make}'",
1587     model         => $locale->text('Model')            . ": '$form->{model}'",
1588     drawing       => $locale->text('Drawing')          . ": '$form->{drawing}'",
1589     microfiche    => $locale->text('Microfiche')       . ": '$form->{microfiche}'",
1590     l_soldtotal   => $locale->text('soldtotal'),
1591   );
1592
1593   my @itemstatus_keys = qw(active obsolete orphaned onhand short);
1594   my @callback_keys   = qw(onorder ordered rfq quoted bought sold partnumber partsgroup serialnumber description make model
1595                            drawing microfiche l_soldtotal l_deliverydate transdatefrom transdateto ean);
1596
1597   # calculate dependencies
1598   for (@itemstatus_keys, @callback_keys) {
1599     next if ($form->{itemstatus} ne $_ && !$form->{$_});
1600     map { $form->{$_} = 'Y' } @{ $dependencies{$_} } if $dependencies{$_};
1601   }
1602
1603   # generate callback and optionstrings
1604   my @options;
1605   for my  $key (@itemstatus_keys, @callback_keys) { 
1606     next if ($form->{itemstatus} ne $key && !$form->{$key});
1607     push @options, $optiontexts{$key};
1608   }
1609
1610   IC->all_parts(\%myconfig, \%$form);
1611
1612   # special case for lastcost
1613   $form->{l_lastcost} = "" if $form->{ledgerchecks};
1614
1615   if ($form->{description}) {
1616     $description = $form->{description};
1617     $description =~ s/\n/<br>/g;
1618   }
1619
1620   if ($form->{l_linetotal}) {
1621     $form->{l_onhand} = "Y";
1622     $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
1623     if ($form->{l_lastcost}) {
1624       $form->{l_linetotallastcost} = "Y";
1625       if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
1626         $form->{l_linetotallastcost} = "";
1627       }
1628     }
1629     $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
1630   }
1631
1632   if ($form->{searchitems} eq 'service') {
1633
1634     # remove bin, weight and rop from list
1635     map { $form->{"l_$_"} = "" } qw(bin weight rop);
1636
1637     $form->{l_onhand} = "";
1638
1639     # qty is irrelevant unless bought or sold
1640     if (   $form->{bought}
1641         || $form->{sold}
1642         || $form->{onorder}
1643         || $form->{ordered}
1644         || $form->{rfq}
1645         || $form->{quoted}) {
1646       $form->{l_onhand} = "Y";
1647     } else {
1648       $form->{l_linetotalsellprice} = "";
1649       $form->{l_linetotallastcost}  = "";
1650     }
1651   }
1652
1653   $form->{l_lastcost} = "" if ($form->{searchitems} eq 'assembly' && !$form->{bom});
1654
1655   my @columns =
1656     qw(partnumber description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost
1657        priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal deliverydate);
1658
1659   my %column_defs = (
1660     'bin'                => { 'text' => $locale->text('Bin'), },
1661     'deliverydate'       => { 'text' => $locale->text('deliverydate'), },
1662     'description'        => { 'text' => $locale->text('Part Description'), },
1663     'drawing'            => { 'text' => $locale->text('Drawing'), },
1664     'image'              => { 'text' => $locale->text('Image'), },
1665     'invnumber'          => { 'text' => $locale->text('Invoice Number'), },
1666     'lastcost'           => { 'text' => $locale->text('Last Cost'), },
1667     'linetotallastcost'  => { 'text' => $locale->text('Extended'), },
1668     'linetotallistprice' => { 'text' => $locale->text('Extended'), },
1669     'linetotalsellprice' => { 'text' => $locale->text('Extended'), },
1670     'listprice'          => { 'text' => $locale->text('List Price'), },
1671     'microfiche'         => { 'text' => $locale->text('Microfiche'), },
1672     'name'               => { 'text' => $locale->text('Name'), },
1673     'onhand'             => { 'text' => $locale->text('Qty'), },
1674     'ordnumber'          => { 'text' => $locale->text('Order Number'), },
1675     'partnumber'         => { 'text' => $locale->text('Part Number'), },
1676     'partsgroup'         => { 'text' => $locale->text('Group'), },
1677     'priceupdate'        => { 'text' => $locale->text('Updated'), },
1678     'quonumber'          => { 'text' => $locale->text('Quotation'), },
1679     'rop'                => { 'text' => $locale->text('ROP'), },
1680     'sellprice'          => { 'text' => $locale->text('Sell Price'), },
1681     'serialnumber'       => { 'text' => $locale->text('Serial Number'), },
1682     'soldtotal'          => { 'text' => $locale->text('soldtotal'), },
1683     'unit'               => { 'text' => $locale->text('Unit'), },
1684     'weight'             => { 'text' => $locale->text('Weight'), },
1685   );
1686
1687   map { $column_defs{$_}->{visible} = $form->{"l_$_"} ? 1 : 0 } @columns;
1688   map { $column_defs{$_}->{align}   = 'right' } qw(onhand sellprice listprice lastcost linetotalsellprice linetotallastcost linetotallistprice rop weight soldtotal);
1689
1690   my @hidden_variables = (qw(l_subtotal l_linetotal searchitems itemstatus bom), @itemstatus_keys, @callback_keys, map { "l_$_" } @columns);
1691   my $callback         = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
1692
1693   my @sort_full        = qw(partnumber description onhand soldtotal deliverydate);
1694   my @sort_no_revers   = qw(partsgroup bin priceupdate invnumber ordnumber quonumber name image drawing serialnumber);
1695
1696   foreach my $col (@sort_full) {
1697     $column_defs{$col}->{link} = join '&', $callback, "sort=$col", map { "$_=" . E($form->{$_}) } qw(revers lastsort);
1698   }
1699   map { $column_defs{$_}->{link} = "${callback}&sort=$_" } @sort_no_revers;
1700
1701   # add order to callback
1702   $form->{callback} = join '&', ($callback, map { "${_}=" . E($form->{$_}) } qw(sort revers));
1703
1704   my $report = SL::ReportGenerator->new(\%myconfig, $form);
1705
1706   my %attachment_basenames = (
1707     'part'     => $locale->text('part_list'),
1708     'service'  => $locale->text('service_list'),
1709     'assembly' => $locale->text('assembly_list'),
1710   );
1711
1712   $report->set_options('top_info_text'         => $locale->text('Options') . ': ' . join(', ', grep $_, @options),
1713                        'raw_bottom_info_text'  => $form->parse_html_template2('ic/generate_report_bottom'),
1714                        'output_format'         => 'HTML',
1715                        'title'                 => $form->{title},
1716                        'attachment_basename'   => $attachment_basenames{$form->{searchitems}} . strftime('_%Y%m%d', localtime time),
1717     );
1718   $report->set_options_from_form();
1719
1720   $report->set_columns(%column_defs);
1721   $report->set_column_order(@columns);
1722
1723   $report->set_export_options('generate_report', @hidden_variables, qw(sort revers));
1724
1725   $report->set_sort_indicator($form->{sort}, $form->{revers} ? 0 : 1);
1726
1727   my @subtotal_columns = qw(sellprice listprice lastcost);
1728   my %subtotals = map { $_ => 0 } ('onhand', @subtotal_columns);
1729   my %totals    = map { $_ => 0 } @subtotal_columns;
1730   my $idx       = 0;
1731   my $same_item = $form->{parts}->[0]->{ $form->{sort} } if (scalar @{ $form->{parts} });
1732
1733   foreach my $ref (@{ $form->{parts} }) {
1734     my $row = { map { $_ => { 'data' => $ref->{$_} } } @columns };
1735
1736     $ref->{exchangerate}  = 1 unless $ref->{exchangerate};
1737     $ref->{sellprice}    *= $ref->{exchangerate};
1738     $ref->{listprice}    *= $ref->{exchangerate};
1739     $ref->{lastcost}     *= $ref->{exchangerate};
1740
1741     # use this for assemblies
1742     my $onhand = $ref->{onhand};
1743
1744     if ($ref->{assemblyitem}) {
1745       $row->{partnumber}->{align} = 'right';
1746       $row->{onhand}->{data}      = 0;
1747       $onhand                     = 0 if ($form->{sold});
1748     }
1749
1750     my $edit_link               = build_std_url('action=edit', 'id=' . E($ref->{id}), 'callback');
1751     $row->{partnumber}->{link}  = $edit_link;
1752     $row->{description}->{link} = $edit_link;
1753
1754     foreach (qw(sellprice listprice lastcost)) {
1755       $row->{$_}->{data}            = $form->format_amount(\%myconfig, $ref->{$_}, -2);
1756       $row->{"linetotal$_"}->{data} = $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{$_}, 2);
1757     }
1758
1759     map { $row->{$_}->{data} = $form->format_amount(\%myconfig, $ref->{$_}); } qw(onhand rop weight soldtotal);
1760
1761     if (!$ref->{assemblyitem}) {
1762       foreach my $col (@subtotal_columns) {
1763         $totals{$col}    += $onhand * $ref->{$col};
1764         $subtotals{$col} += $onhand * $ref->{$col};
1765       }
1766
1767       $subtotals{onhand} += $onhand;
1768     }
1769
1770     if ($ref->{module} eq 'oe') {
1771       my $edit_oe_link = build_std_url("script=oe.pl", 'action=edit', 'type=' . E($ref->{type}), 'id=' . E($ref->{trans_id}), 'callback');
1772       $row->{ordnumber}->{link} = $edit_oe_link;
1773       $row->{quonumber}->{link} = $edit_oe_link if (!$ref->{ordnumber});
1774
1775     } else {
1776       $row->{invnumber}->{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'type=invoice', 'id=' . E($ref->{trans_id}), 'callback');
1777     }
1778
1779     if ($ref->{image} && (lc $report->{options}->{output_format} eq 'html')) {
1780       $row->{image}->{data}     = '';
1781       $row->{image}->{raw_data} = '<a href="' . H($ref->{image}) . '"><img src="' . H($ref->{image}) . '" height="32" border="0"></a>';
1782     }
1783     map { $row->{$_}->{link} = $ref->{$_} } qw(drawing microfiche);
1784
1785     $report->add_data($row);
1786
1787     my $next_ref = $form->{parts}->[$idx + 1];
1788
1789     if (($form->{l_subtotal} eq 'Y') &&
1790         (!$next_ref ||
1791          (!$next_ref->{assemblyitem} && ($same_item ne $next_ref->{ $form->{sort} })))) {
1792       my $row = { map { $_ => { 'class' => 'listsubtotal', } } @columns };
1793
1794       if (($form->{searchitems} ne 'assembly') || !$form->{bom}) {
1795         $row->{onhand}->{data} = $form->format_amount(\%myconfig, $subtotals{onhand});
1796       }
1797
1798       map { $row->{"linetotal$_"}->{data} = $form->format_amount(\%myconfig, $subtotals{$_}, 2) } @subtotal_columns;
1799       map { $subtotals{$_} = 0 } ('onhand', @subtotal_columns);
1800
1801       $report->add_data($row);
1802
1803       $same_item = $next_ref->{ $form->{sort} };
1804     }
1805
1806     $idx++;
1807   }
1808
1809   if ($form->{"l_linetotal"}) {
1810     my $row = { map { $_ => { 'class' => 'listtotal', } } @columns };
1811
1812     map { $row->{"linetotal$_"}->{data} = $form->format_amount(\%myconfig, $totals{$_}, 2) } @subtotal_columns;
1813
1814     $report->add_separator();
1815     $report->add_data($row);
1816   }
1817
1818   $report->generate_with_headers();
1819
1820   $lxdebug->leave_sub();
1821 }    #end generate_report
1822
1823 sub parts_subtotal {
1824   $lxdebug->enter_sub();
1825   
1826   # imports
1827   our (%column_data, @column_index);
1828   our ($subtotalonhand, $totalsellprice, $totallastcost, $totallistprice, $subtotalsellprice, $subtotallastcost, $subtotallistprice);
1829
1830   map { $column_data{$_} = "<td>&nbsp;</td>" } @column_index;
1831   $subtotalonhand = 0 if ($form->{searchitems} eq 'assembly' && $form->{bom});
1832
1833   $column_data{onhand} =
1834       "<th class=listsubtotal align=right>"
1835     . $form->format_amount(\%myconfig, $subtotalonhand)
1836     . "</th>";
1837
1838   $column_data{linetotalsellprice} =
1839       "<th class=listsubtotal align=right>"
1840     . $form->format_amount(\%myconfig, $subtotalsellprice, 2)
1841     . "</th>";
1842   $column_data{linetotallistprice} =
1843       "<th class=listsubtotal align=right>"
1844     . $form->format_amount(\%myconfig, $subtotallistprice, 2)
1845     . "</th>";
1846   $column_data{linetotallastcost} =
1847       "<th class=listsubtotal align=right>"
1848     . $form->format_amount(\%myconfig, $subtotallastcost, 2)
1849     . "</th>";
1850
1851   $subtotalonhand    = 0;
1852   $subtotalsellprice = 0;
1853   $subtotallistprice = 0;
1854   $subtotallastcost  = 0;
1855
1856   print "<tr class=listsubtotal>";
1857
1858   map { print "\n$column_data{$_}" } @column_index;
1859
1860   print qq|
1861   </tr>
1862 |;
1863
1864   $lxdebug->leave_sub();
1865 }
1866
1867 sub edit {
1868   $lxdebug->enter_sub();
1869   # show history button
1870   $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
1871   #/show hhistory button
1872   IC->get_part(\%myconfig, \%$form);
1873
1874   $form->{"original_partnumber"} = $form->{"partnumber"};
1875
1876   $form->{title} = $locale->text('Edit ' . ucfirst $form->{item});
1877
1878   &link_part;
1879   &display_form;
1880
1881   $lxdebug->leave_sub();
1882 }
1883
1884 sub link_part {
1885   $lxdebug->enter_sub();
1886
1887   IC->create_links("IC", \%myconfig, \%$form);
1888
1889   # currencies
1890   map({ $form->{selectcurrency} .= "<option>$_\n" }
1891       split(/:/, $form->{currencies}));
1892
1893   # parts and assemblies have the same links
1894   my $item = $form->{item};
1895   if ($form->{item} eq 'assembly') {
1896     $item = 'part';
1897   }
1898
1899   # build the popup menus
1900   $form->{taxaccounts} = "";
1901   foreach my $key (keys %{ $form->{IC_links} }) {
1902     foreach my $ref (@{ $form->{IC_links}{$key} }) {
1903
1904       # if this is a tax field
1905       if ($key =~ /IC_tax/) {
1906         if ($key =~ /$item/) {
1907           $form->{taxaccounts} .= "$ref->{accno} ";
1908           $form->{"IC_tax_$ref->{accno}_description"} =
1909             "$ref->{accno}--$ref->{description}";
1910
1911           if ($form->{id}) {
1912             if ($form->{amount}{ $ref->{accno} }) {
1913               $form->{"IC_tax_$ref->{accno}"} = "checked";
1914             }
1915           } else {
1916             $form->{"IC_tax_$ref->{accno}"} = "checked";
1917           }
1918         }
1919       } else {
1920
1921         $form->{"select$key"} .=
1922           "<option $ref->{selected}>$ref->{accno}--$ref->{description}\n";
1923         if ($form->{amount}{$key} eq $ref->{accno}) {
1924           $form->{$key} = "$ref->{accno}--$ref->{description}";
1925         }
1926
1927       }
1928     }
1929   }
1930   chop $form->{taxaccounts};
1931
1932   if (($form->{item} eq "part") || ($form->{item} eq "assembly")) {
1933     $form->{selectIC_income}  = $form->{selectIC_sale};
1934     $form->{selectIC_expense} = $form->{selectIC_cogs};
1935     $form->{IC_income}        = $form->{IC_sale};
1936     $form->{IC_expense}       = $form->{IC_cogs};
1937   }
1938
1939   delete $form->{IC_links};
1940   delete $form->{amount};
1941
1942   $form->get_partsgroup(\%myconfig, { all => 1 });
1943
1944   $form->{partsgroup} = "$form->{partsgroup}--$form->{partsgroup_id}";
1945
1946   if (@{ $form->{all_partsgroup} }) {
1947     $form->{selectpartsgroup} = qq|<option>\n|;
1948     map {
1949       $form->{selectpartsgroup} .=
1950         qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n|
1951     } @{ $form->{all_partsgroup} };
1952   }
1953
1954   if ($form->{item} eq 'assembly') {
1955
1956     foreach my $i (1 .. $form->{assembly_rows}) {
1957       if ($form->{"partsgroup_id_$i"}) {
1958         $form->{"partsgroup_$i"} =
1959           qq|$form->{"partsgroup_$i"}--$form->{"partsgroup_id_$i"}|;
1960       }
1961     }
1962     $form->get_partsgroup(\%myconfig);
1963
1964     if (@{ $form->{all_partsgroup} }) {
1965       $form->{selectassemblypartsgroup} = qq|<option>\n|;
1966
1967       map {
1968         $form->{selectassemblypartsgroup} .=
1969           qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n|
1970       } @{ $form->{all_partsgroup} };
1971     }
1972   }
1973   $lxdebug->leave_sub();
1974 }
1975
1976 sub form_header {
1977   $lxdebug->enter_sub();
1978
1979   my ($payment, $rows, $notes, $description, $ean, $buchungsgruppe, $partsgroup, $group, $tax, $lastcost, $eur, $linkaccounts, $weight, $n, $rop, $bin, $vegv);
1980   my ($notdiscountableok, $notdiscountable);
1981   my ($formula, $formula_label, $imagelinks, $obsolete, $shopok, $shop);
1982
1983
1984   map({ $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, -2) }
1985       qw(sellprice listprice lastcost gv));
1986
1987   map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}) }
1988     qw(weight rop stock);
1989
1990   foreach my $item (qw(partnumber description unit notes)) {
1991     $form->{$item} =~ s/\"/&quot;/g;
1992   }
1993
1994   $payment = qq|<option value=""></option>|;
1995   foreach my $item (@{ $form->{payment_terms} }) {
1996     if ($form->{payment_id} eq $item->{id}) {
1997       $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
1998     } else {
1999       $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
2000     }
2001   }
2002
2003
2004   if (($rows = $form->numtextrows($form->{notes}, 40)) < 2) {
2005     $rows = 4;
2006   }
2007
2008   $notes =
2009     qq|<textarea name=notes rows=$rows cols=45 wrap=soft>$form->{notes}</textarea>|;
2010   if (($rows = $form->numtextrows($form->{description}, 40)) > 1) {
2011     $description =
2012       qq|<textarea name="description" rows=$rows cols=40 wrap=soft>$form->{description}</textarea>|;
2013   } else {
2014     $description =
2015       qq|<input name=description size=40 value="$form->{description}">|;
2016   }
2017
2018   $ean =  qq|<input name=ean size=40 value="$form->{ean}">|;
2019
2020   foreach my $item (split / /, $form->{taxaccounts}) {
2021     $form->{"IC_tax_$item"} = ($form->{"IC_tax_$item"}) ? "checked" : "";
2022   }
2023
2024   IC->retrieve_buchungsgruppen(\%myconfig, $form);
2025   if (@{ $form->{BUCHUNGSGRUPPEN} }) {
2026     foreach my $item (@{ $form->{BUCHUNGSGRUPPEN} }) {
2027       if ($item->{id} == $form->{buchungsgruppen_id}) {
2028         $form->{selectbuchungsgruppe} .=
2029           "<option value=$item->{id} selected>$item->{description}\n";
2030       } elsif (($form->{id} && $form->{orphaned}) || (!$form->{id})) {
2031         $form->{selectbuchungsgruppe} .=
2032           "<option value=$item->{id}>$item->{description}\n";
2033       }
2034
2035     }
2036   }
2037
2038   $buchungsgruppe = qq|
2039               <tr>
2040                 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
2041                 <td><select name=buchungsgruppen_id>$form->{selectbuchungsgruppe}</select></td>
2042               </tr>|;
2043
2044
2045   # set option
2046   foreach my $item (qw(IC IC_income IC_expense)) {
2047     if ($form->{$item}) {
2048       if ($form->{id} && $form->{orphaned}) {
2049         $form->{"select$item"} =~ s/ selected//;
2050         $form->{"select$item"} =~
2051           s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
2052       } else {
2053         $form->{"select$item"} = qq|<option selected>$form->{$item}|;
2054       }
2055     }
2056   }
2057
2058   if ($form->{selectpartsgroup}) {
2059     $form->{selectpartsgroup} = $form->unescape($form->{selectpartsgroup});
2060     $partsgroup =
2061       qq|<input type=hidden name=selectpartsgroup value="|
2062       . $form->escape($form->{selectpartsgroup}, 1) . qq|">|;
2063     $form->{selectpartsgroup} =~
2064       s/(<option value="\Q$form->{partsgroup}\E")/$1 selected/;
2065
2066     $partsgroup .=
2067       qq|<select name=partsgroup>$form->{selectpartsgroup}</select>|;
2068     $group = $locale->text('Group');
2069   }
2070
2071   # tax fields
2072   foreach my $item (split / /, $form->{taxaccounts}) {
2073     $tax .= qq|
2074       <input class=checkbox type=checkbox name="IC_tax_$item" value=1 $form->{"IC_tax_$item"}>&nbsp;<b>$form->{"IC_tax_${item}_description"}</b>
2075       <br><input type=hidden name=IC_tax_${item}_description value="$form->{"IC_tax_${item}_description"}">
2076 |;
2077   }
2078
2079   $form->{obsolete} = "checked" if $form->{obsolete};
2080
2081   $lastcost = qq|
2082               <tr>
2083                 <th align="right" nowrap="true">|
2084     . $locale->text('Last Cost') . qq|</th>
2085                 <td><input name=lastcost size=11 value=$form->{lastcost}></td>
2086               </tr>
2087 |;
2088   if (!$eur) {
2089     $linkaccounts = qq|
2090                <tr>
2091                 <th align=right>| . $locale->text('Inventory') . qq|</th>
2092                 <td><select name=IC>$form->{selectIC}</select></td>
2093                 <input name=selectIC type=hidden value="$form->{selectIC}">
2094               </tr>|;
2095   }
2096
2097   if ($form->{item} eq "part") {
2098
2099     $linkaccounts .= qq|
2100               <tr>
2101                 <th align=right>| . $locale->text('Revenue') . qq|</th>
2102                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
2103                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
2104               </tr>
2105               <tr>
2106                 <th align=right>| . $locale->text('Expense') . qq|</th>
2107                 <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
2108                 <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
2109               </tr>
2110 |;
2111
2112     $weight = qq|
2113               <tr>
2114                 <th align="right" nowrap="true">| . $locale->text('Weight') . qq|</th>
2115                 <td>
2116                   <table>
2117                     <tr>
2118                       <td>
2119                         <input name=weight size=10 value=$form->{weight}>
2120                       </td>
2121                     </tr>
2122                   </table>
2123                 </td>
2124               </tr>
2125 |;
2126
2127   }
2128
2129   if ($form->{item} eq "assembly") {
2130
2131     $lastcost = "";
2132
2133     $linkaccounts = qq|
2134               <tr>
2135                 <th align=right>| . $locale->text('Revenue') . qq|</th>
2136                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
2137                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
2138               </tr>
2139 |;
2140
2141     $weight = qq|
2142               <tr>
2143                 <th align="right" nowrap="true">| . $locale->text('Weight') . qq|</th>
2144                 <td>
2145                   <table>
2146                     <tr>
2147                       <td>
2148                         &nbsp;$form->{weight}
2149                         <input type=hidden name=weight value=$form->{weight}>
2150                       </td>
2151                     </tr>
2152                   </table>
2153                 </td>
2154               </tr>
2155 |;
2156
2157   }
2158
2159   if ($form->{item} eq "service") {
2160
2161     $linkaccounts = qq|
2162               <tr>
2163                 <th align=right>| . $locale->text('Revenue') . qq|</th>
2164                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
2165                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
2166               </tr>
2167               <tr>
2168                 <th align=right>| . $locale->text('Expense') . qq|</th>
2169                 <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
2170                 <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
2171               </tr>
2172 |;
2173
2174   }
2175   $linkaccounts = qq|<input type=hidden name=IC_income value="$form->{IC_income_default}">|;
2176
2177   if ($form->{IC_cogs_default}) {
2178     $form->{IC_expense_default} = $form->{IC_cogs_default};
2179   }
2180
2181   if (($form->{item} eq "service") || ($form->{item} eq "part")) {
2182     $linkaccounts .= qq|<input type=hidden name=IC_expense value="$form->{IC_expense_default}">|;
2183   }
2184   if ($form->{item} eq "part") {
2185     $linkaccounts .= qq|<input type=hidden name=IC value="$form->{IC_default}">|;
2186   }
2187
2188   if ($form->{item} ne 'service') {
2189     $n   = ($form->{onhand} > 0) ? "1" : "0";
2190     $rop = qq|
2191               <tr>
2192                 <th align="right" nowrap>| . $locale->text('On Hand') . qq|</th>
2193                 <th align=left nowrap class="plus$n">&nbsp;|
2194       . $form->format_amount(\%myconfig, $form->{onhand}) . qq|</th>
2195               </tr>
2196 |;
2197
2198     if ($form->{item} eq 'assembly') {
2199       $rop .= qq|
2200               <tr>
2201                 <th align="right" nowrap>| . $locale->text('Stock') . qq|</th>
2202                 <td><input name=stock size=10 value=$form->{stock}></td>
2203               </tr>
2204 |;
2205     }
2206
2207     $rop .= qq|
2208               <tr>
2209                 <th align="right" nowrap="true">| . $locale->text('ROP') . qq|</th>
2210                 <td><input name=rop size=10 value=$form->{rop}></td>
2211               </tr>
2212 |;
2213
2214     $bin = qq|
2215               <tr>
2216                 <th align="right" nowrap="true">| . $locale->text('Bin') . qq|</th>
2217                 <td><input name=bin size=10 value=$form->{bin}></td>
2218               </tr>
2219 |;
2220     $vegv = qq|
2221               <tr>
2222                 <th align="right" nowrap="true">|
2223       . $locale->text('Verrechnungseinheit') . qq|</th>
2224                 <td><input name=ve size=10 value=$form->{ve}></td>
2225               </tr>
2226               <tr>
2227                 <th align="right" nowrap="true">|
2228       . $locale->text('Business Volume') . qq|</th>
2229                 <td><input name=gv size=10 value=$form->{gv}></td>
2230               </tr>
2231 |;
2232     $notdiscountableok = ($form->{not_discountable}) == 1 ? "checked" : "";
2233     $notdiscountable .= qq|
2234               <tr>
2235                 <th align=right nowrap>|
2236     . $locale->text('Not Discountable') . qq|</th>
2237                 <td><input class=checkbox type=checkbox name=not_discountable value=1 $notdiscountableok></td>
2238              </tr>
2239 |;
2240
2241     $formula =
2242       qq|<ilayer><layer  onmouseover="this.T_STICKY=true;this.T_STATIC=true;return escape('| . $locale->text('The formula needs the following syntax:<br>For regular article:<br>Variablename= Variable Unit;<br>Variablename2= Variable2 Unit2;<br>...<br>###<br>Variable + ( Variable2 / Variable )<br><b>Please be beware of the spaces in the formula</b><br>') . qq|')"><textarea name=formel rows=4 cols=30 wrap=soft>$form->{formel}</textarea></layer><ilayer>|;
2243
2244     $formula_label = $locale->text('Formula');
2245
2246     $imagelinks = qq|
2247   <tr>
2248     <td>
2249       <table width=100%>
2250         <tr>
2251           <th align=right nowrap>| . $locale->text('Image') . qq|</th>
2252           <td><input name=image size=40 value="$form->{image}"></td>
2253           <th align=right nowrap>| . $locale->text('Microfiche') . qq|</th>
2254           <td><input name=microfiche size=20 value="$form->{microfiche}"></td>
2255         </tr>
2256         <tr>
2257           <th align=right nowrap>| . $locale->text('Drawing') . qq|</th>
2258           <td><input name=drawing size=40 value="$form->{drawing}"></td>
2259         </tr>
2260       </table>
2261     </td>
2262   </tr>
2263 |;
2264
2265   }
2266
2267   if ($form->{id}) {
2268     $obsolete = qq|
2269               <tr>
2270                 <th align="right" nowrap="true">| . $locale->text('Obsolete') . qq|</th>
2271                 <td><input name=obsolete type=checkbox class=checkbox value=1 $form->{obsolete}></td>
2272               </tr>
2273 |;
2274   }
2275   $shopok = $form->{shop} == 1 ? "checked" : "";
2276   $shop .= qq|
2277               <tr>
2278                 <th align=right nowrap>|
2279     . $locale->text('Shopartikel') . qq|</th>
2280                 <td><input class=checkbox type=checkbox name=shop value=1 $shopok></td>
2281              </tr>
2282 |;
2283
2284
2285   # type=submit $locale->text('Add Part')
2286   # type=submit $locale->text('Add Service')
2287   # type=submit $locale->text('Add Assembly')
2288
2289   # type=submit $locale->text('Edit Part')
2290   # type=submit $locale->text('Edit Service')
2291   # type=submit $locale->text('Edit Assembly')
2292   # use JavaScript Calendar or not
2293   my ($jsscript, $button1);
2294   $form->{jsscript} = 1;
2295   $jsscript = "";
2296   if ($form->{jsscript}) {
2297
2298     # with JavaScript Calendar
2299     $button1 = qq|
2300        <td width="13"><input name=priceupdate id=priceupdate size=11  title="$myconfig{dateformat}" value="$form->{priceupdate}"></td>
2301        <td width="4" align="left"><input type=button name=priceupdate id="trigger1" value=|
2302       . $locale->text('button') . qq|></td>
2303       |;
2304
2305     #write Trigger
2306     $jsscript =
2307       Form->write_trigger(\%myconfig, "1", "priceupdate", "BL", "trigger1");
2308   } else {
2309
2310     # without JavaScript Calendar
2311     $button1 = qq|
2312                               <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
2313   }
2314
2315   my $unit_select = '<input type="hidden" name="unit_changeable" value="' . $form->{"unit_changeable"} . '">';
2316   if (!$form->{"unit_changeable"}) {
2317     $unit_select .= '<input type="hidden" name="unit" value="' . $form->{"unit"} . '">' . $form->{"unit"};
2318   } else {
2319     my $units = AM->retrieve_units(\%myconfig, $form, $form->{"item"} eq "service" ? "service" : "dimension");
2320     $unit_select .= AM->unit_select_html($units, "unit", $form->{"unit"});
2321   }
2322
2323   $form->{fokus} = "ic.partnumber";
2324   $form->header;
2325
2326   print qq|
2327   <body onLoad="fokus()">
2328  <script type="text/javascript" src="js/common.js"></script>
2329  <script type="text/javascript" src="js/parts_language_selection.js"></script>
2330
2331 <form method=post name="ic" action=$form->{script}>
2332
2333 <input name=id type=hidden value=$form->{id}>
2334 <input name=item type=hidden value=$form->{item}>
2335 <input name=title type=hidden value="$form->{title}">
2336 <input name=makemodel type=hidden value="$form->{makemodel}">
2337 <input name=alternate type=hidden value="$form->{alternate}">
2338 <input name=onhand type=hidden value=$form->{onhand}>
2339 <input name=orphaned type=hidden value=$form->{orphaned}>
2340 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
2341 <input name=rowcount type=hidden value=$form->{rowcount}>
2342 <input name=eur type=hidden value=$eur>
2343 <input name=language_values type=hidden value="$form->{language_values}">
2344 <input name="original_partnumber" type="hidden" value="| . $form->quote($form->{"original_partnumber"}) . qq|">
2345
2346 <table width="100%">
2347   <tr>
2348     <th class=listtop>$form->{title}</th>
2349   </tr>
2350   <tr height="5"></tr>
2351   <tr>
2352     <td>
2353       <table width="100%">
2354         <tr valign=top>
2355           <th align=left>| . $locale->text('Part Number') . qq|</th>
2356           <th align=left>| . $locale->text('Part Description') . qq|</th>
2357           <th align=left>$group</th>
2358         </tr>
2359         <tr valign=top>
2360           <td><input name=partnumber value="$form->{partnumber}" size=20></td>
2361           <td>$description</td>
2362           <td>$partsgroup</td>
2363           <input type=hidden name=oldpartsgroup value="$form->{oldpartsgroup}">
2364         </tr>
2365       </table>
2366     </td>
2367   </tr>
2368   <tr>
2369     <td>
2370       <table width="100%" height="100%">
2371         <tr valign=top>
2372           <td width=70%>
2373             <table width="100%" height="100%">
2374               <tr class="listheading">
2375                 <th class="listheading" align="center" colspan=2>|
2376     . $locale->text('') . qq|</th>
2377               </tr>
2378               <td colspan=2>
2379                 <table>
2380                   $buchungsgruppe
2381                   $linkaccounts
2382                 </table>
2383               </td>
2384               <tr>
2385                 <th align="left">| . $locale->text('Notes') . qq|</th>
2386                 <th align="left">$formula_label</th>
2387               </tr>
2388               <tr>
2389                 <td>
2390                   $notes
2391                 </td>
2392                 <td>
2393                   $formula
2394                 </td>
2395               </tr>
2396               <tr>
2397                 <th align="left"></th>
2398                 <th align="left">| . $locale->text('EAN-Code') . qq|</th>
2399               </tr>
2400               <tr>
2401                 <td>
2402                   <button type="button" onclick="parts_language_selection_window('language_values')">| . $locale->text('Set Language Values') . qq|</button>
2403                 </td>
2404                 <td>
2405                   $ean  
2406                 </td>
2407               </tr>
2408               <tr>
2409               <td colspan=2>
2410                 <table>
2411                 <tr>
2412                <th align=right>| . $locale->text('Payment Terms') . qq|</th>
2413                  <td><select name=payment_id>$payment</select></td>
2414                 </tr>
2415                </table>
2416               </td>
2417               </tr>
2418             </table>
2419           </td>
2420           <td width="30%">
2421             <table width="100%">
2422               <tr>
2423                 <th align="right" nowrap="true">|
2424     . $locale->text('Updated') . qq|</th>
2425                 $button1
2426               </tr>
2427               <tr>
2428                 <th align="right" nowrap="true">| . $locale->text('List Price') . qq|</th>
2429                 <td><input name=listprice size=11 value=$form->{listprice}></td>
2430               </tr>
2431               <tr>
2432                 <th align="right" nowrap="true">| . $locale->text('Sell Price') . qq|</th>
2433                 <td><input name=sellprice size=11 value=$form->{sellprice}></td>
2434               </tr>
2435               $lastcost
2436               <tr>
2437                 <th align="right" nowrap="true">| . $locale->text('Unit') . qq|</th>
2438                 <td>$unit_select</td>
2439               </tr>
2440               $weight
2441               $rop
2442               $bin
2443               $notdiscountable
2444               $vegv
2445               $shop
2446               $obsolete
2447             </table>
2448           </td>
2449         </tr>
2450       </table>
2451     </td>
2452   </tr>
2453   $imagelinks
2454
2455 $jsscript
2456 |;
2457   $lxdebug->leave_sub();
2458 }
2459
2460 sub form_footer {
2461   $lxdebug->enter_sub();
2462
2463   if ($form->{item} eq "assembly") {
2464
2465     print qq|
2466         <tr>
2467           <td>
2468             <table width="100%">
2469               <tr>
2470                 <th colspan=2 align=right>|
2471       . $locale->text('Total') . qq|&nbsp;</th>
2472                 <th align=right>|
2473       . $form->format_amount(\%myconfig, $form->{assemblytotal}, 2) . qq|</th>
2474               </tr>
2475             </table>
2476           </td>
2477         </tr>
2478         <input type=hidden name=assembly_rows value=$form->{assembly_rows}>
2479 |;
2480   }
2481
2482   print qq|
2483       <input type=hidden name=login value=$form->{login}>
2484       <input type=hidden name=password value=$form->{password}>
2485       <input type=hidden name=callback value="$form->{callback}">
2486       <input type=hidden name=previousform value="$form->{previousform}">
2487       <input type=hidden name=taxaccount2 value="$form->{taxaccount2}">
2488       <input type=hidden name=vc value=$form->{vc}>
2489   <tr>
2490     <td><hr size=3 noshade></td>
2491   </tr>
2492 </table>
2493
2494 <br>
2495 <input class=submit type=submit name=action value="|
2496     . $locale->text('Update') . qq|">
2497   |;
2498
2499   unless ($form->{item} eq "service") {
2500     print qq|
2501       <input type=hidden name=makemodel_rows value=$form->{makemodel_rows}>
2502     |;
2503   }
2504
2505   print qq|
2506      <input type=hidden name=price_rows value=$form->{price_rows}>|;
2507
2508   print qq|
2509       <input class=submit type=submit name=action value="|
2510     . $locale->text('Save') . qq|">|;
2511
2512   if ($form->{id}) {
2513
2514     if (!$form->{previousform}) {
2515       print qq|
2516       <input class=submit type=submit name=action value="|
2517         . $locale->text('Save as new') . qq|">|;
2518     }
2519
2520     if ($form->{orphaned}) {
2521       if (!$form->{previousform}) {
2522         if ($form->{item} eq 'assembly') {
2523           if (!$form->{onhand}) {
2524             print qq|
2525       <input class=submit type=submit name=action value="|
2526               . $locale->text('Delete') . qq|">|;
2527           }
2528         } else {
2529           print qq|
2530       <input class=submit type=submit name=action value="|
2531             . $locale->text('Delete') . qq|">|;
2532         }
2533       }
2534     }
2535   }
2536
2537   if (!$form->{previousform}) {
2538     if ($form->{menubar}) {
2539       require "bin/mozilla/menu.pl";
2540       &menubar;
2541     }
2542   }
2543 # button for saving history
2544   if($form->{id} ne "") {
2545         print qq|
2546                 <input type=button class=submit onclick=set_history_window(|
2547                 . $form->{id} 
2548                 . qq|); name=history id=history value=|
2549                 . $locale->text('history') 
2550                 . qq|>|;
2551   }
2552 # /button for saving history
2553   print qq|
2554
2555 </form>
2556
2557 <script type="text/javascript" src="js/wz_tooltip.js"></script>
2558
2559 </body>
2560 </html>
2561 |;
2562
2563   $lxdebug->leave_sub();
2564 }
2565
2566 sub makemodel_row {
2567   $lxdebug->enter_sub();
2568   my ($numrows) = @_;
2569   
2570   print qq|
2571   <tr>
2572     <td>
2573       <table width=100%>
2574         <tr>
2575           <th class="listheading">| . $locale->text('Make') . qq|</th>
2576           <th class="listheading">| . $locale->text('Model') . qq|</th>
2577         </tr>
2578 |;
2579
2580   for my $i (1 .. $numrows) {
2581     $form->{"make_$i"}  =~ s/\"/&quot;/g;
2582     $form->{"model_$i"} =~ s/\"/&quot;/g;
2583     print qq|
2584         <tr>
2585           <td width=50%><input name="make_$i" size=30 value="$form->{"make_$i"}"></td>
2586           <td width=50%><input name="model_$i" size=30 value="$form->{"model_$i"}"></td>
2587         </tr>
2588 |;
2589   }
2590
2591   print qq|
2592       </table>
2593     </td>
2594   </tr>
2595 |;
2596
2597   $lxdebug->leave_sub();
2598 }
2599
2600 sub assembly_row {
2601   $lxdebug->enter_sub();
2602   my ($numrows) = @_;
2603   my (@column_index, %column_data, %column_header);
2604   my ($nochange, $callback, $previousform, $linetotal, $href);
2605
2606   our ($deliverydate); # ToDO: cjeck if this indeed comes from global context
2607
2608   @column_index =
2609     qw(runningnumber qty unit bom partnumber description partsgroup total);
2610
2611   if ($form->{previousform}) {
2612     $nochange     = 1;
2613     @column_index = qw(qty unit bom partnumber description partsgroup total);
2614   } else {
2615
2616     # change callback
2617     $form->{old_callback} = $form->{callback};
2618     $callback             = $form->{callback};
2619     $form->{callback}     = "$form->{script}?action=display_form";
2620
2621     # delete action
2622     map { delete $form->{$_} } qw(action header);
2623
2624     $previousform = "";
2625
2626     # save form variables in a previousform variable
2627     foreach my $key (sort keys %$form) {
2628
2629       # escape ampersands
2630       $form->{$key} =~ s/&/%26/g;
2631       $previousform .= qq|$key=$form->{$key}&|;
2632     }
2633     chop $previousform;
2634     $previousform = $form->escape($form->escape($previousform, 1));
2635     $form->{callback} = $callback;
2636
2637     $form->{assemblytotal} = 0;
2638     $form->{weight}        = 0;
2639
2640   }
2641   $column_header{runningnumber} =
2642     qq|<th nowrap width=5%>| . $locale->text('No.') . qq|</th>|;
2643   $column_header{qty} =
2644     qq|<th align=left nowrap width=10%>| . $locale->text('Qty') . qq|</th>|;
2645   $column_header{unit} =
2646     qq|<th align=left nowrap width=5%>| . $locale->text('Unit') . qq|</th>|;
2647   $column_header{partnumber} =
2648       qq|<th align=left nowrap width=20%>|
2649     . $locale->text('Part Number')
2650     . qq|</th>|;
2651   $column_header{description} =
2652     qq|<th nowrap width=50%>| . $locale->text('Part Description') . qq|</th>|;
2653   $column_header{total} =
2654     qq|<th align=right nowrap>| . $locale->text('Extended') . qq|</th>|;
2655   $column_header{bom}        = qq|<th>| . $locale->text('BOM') . qq|</th>|;
2656   $column_header{partsgroup} = qq|<th>| . $locale->text('Group') . qq|</th>|;
2657
2658   print qq|
2659   <tr class=listheading>
2660     <th class=listheading>| . $locale->text('Individual Items') . qq|</th>
2661   </tr>
2662   <tr>
2663     <td>
2664       <table width=100%>
2665         <tr>
2666 |;
2667
2668   map { print "\n$column_header{$_}" } @column_index;
2669
2670   print qq|
2671         </tr>
2672 |;
2673
2674   for my $i (1 .. $numrows) {
2675     $form->{"partnumber_$i"} =~ s/\"/&quot;/g;
2676
2677     $linetotal =
2678       $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
2679     $form->{assemblytotal} += $linetotal;
2680
2681     $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
2682
2683     $linetotal = $form->format_amount(\%myconfig, $linetotal, 2);
2684
2685     if (($i >= 1) && ($i == $numrows)) {
2686
2687       if ($nochange) {
2688         map { $column_data{$_} = qq|<td></td>| }
2689           qw(qty unit partnumber description bom partsgroup);
2690       } else {
2691
2692         map { $column_data{$_} = qq|<td></td>| } qw(runningnumber unit bom);
2693
2694         $column_data{qty} =
2695           qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
2696         $column_data{partnumber} =
2697           qq|<td><input name="partnumber_$i" size=15 value="$form->{"partnumber_$i"}"></td>|;
2698         $column_data{description} =
2699           qq|<td><input name="description_$i" size=40 value="$form->{"description_$i"}"></td>|;
2700         $column_data{partsgroup} =
2701           qq|<td><input name="partsgroup_$i" size=10 value="$form->{"partsgroup_$i"}"></td>|;
2702
2703       }
2704
2705     } else {
2706
2707       if ($form->{previousform}) {
2708         $column_data{partnumber} =
2709           qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}">$form->{"partnumber_$i"}</td>|;
2710         $column_data{qty} =
2711           qq|<td align=right><input type=hidden name="qty_$i" value="$form->{"qty_$i"}">$form->{"qty_$i"}</td>|;
2712
2713         $column_data{bom} =
2714           qq|<td align=center><input type=hidden name="bom_$i" value=$form->{"bom_$i"}>|;
2715         $column_data{bom} .= ($form->{"bom_$i"}) ? "x" : "&nbsp;";
2716         $column_data{bom} .= qq|</td>|;
2717
2718         $column_data{partsgroup} =
2719           qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
2720
2721       } else {
2722         $href =
2723           qq|$form->{script}?action=edit&id=$form->{"id_$i"}&login=$form->{login}&password=$form->{password}&rowcount=$i&previousform=$previousform|;
2724         $column_data{partnumber} =
2725           qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"><a href=$href>$form->{"partnumber_$i"}</a></td>|;
2726         $column_data{runningnumber} =
2727           qq|<td><input name="runningnumber_$i" size=3 value="$i"></td>|;
2728         $column_data{qty} =
2729           qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
2730
2731         $form->{"bom_$i"} = ($form->{"bom_$i"}) ? "checked" : "";
2732         $column_data{bom} =
2733           qq|<td align=center><input name="bom_$i" type=checkbox class=checkbox value=1 $form->{"bom_$i"}></td>|;
2734
2735         $column_data{partsgroup} =
2736           qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
2737       }
2738
2739       $column_data{unit} =
2740         qq|<td><input type=hidden name="unit_$i" value="$form->{"unit_$i"}">$form->{"unit_$i"}</td>|;
2741       $column_data{description} =
2742         qq|<td><input type=hidden name="description_$i" value="$form->{"description_$i"}">$form->{"description_$i"}</td>|;
2743     }
2744
2745     $column_data{total} = qq|<td align=right>$linetotal</td>|;
2746
2747     $column_data{deliverydate} = qq|<td align=right>$deliverydate</td>|;
2748
2749     print qq|
2750         <tr>|;
2751
2752     map { print "\n$column_data{$_}" } @column_index;
2753
2754     print qq|
2755         </tr>
2756   <input type=hidden name="id_$i" value=$form->{"id_$i"}>
2757   <input type=hidden name="sellprice_$i" value=$form->{"sellprice_$i"}>
2758   <input type=hidden name="weight_$i" value=$form->{"weight_$i"}>
2759 |;
2760   }
2761
2762   print qq|
2763       </table>
2764     </td>
2765   </tr>
2766 |;
2767
2768   $lxdebug->leave_sub();
2769 }
2770
2771 sub update {
2772   $lxdebug->enter_sub();
2773
2774   if ($form->{item} eq "assembly") {
2775     my $i = $form->{assembly_rows};
2776
2777     # if last row is empty check the form otherwise retrieve item
2778     if (   ($form->{"partnumber_$i"} eq "")
2779         && ($form->{"description_$i"} eq "")
2780         && ($form->{"partsgroup_$i"}  eq "")) {
2781
2782       &check_form;
2783
2784     } else {
2785
2786       IC->assembly_item(\%myconfig, \%$form);
2787
2788       my $rows = scalar @{ $form->{item_list} };
2789
2790       if ($rows) {
2791         $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
2792
2793         if ($rows > 1) {
2794           $form->{makemodel_rows}--;
2795           &select_item;
2796           exit;
2797         } else {
2798           map { $form->{item_list}[$i]{$_} =~ s/\"/&quot;/g }
2799             qw(partnumber description unit partsgroup);
2800           map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
2801             keys %{ $form->{item_list}[0] };
2802           $form->{"runningnumber_$i"} = $form->{assembly_rows};
2803           $form->{assembly_rows}++;
2804
2805           &check_form;
2806
2807         }
2808
2809       } else {
2810
2811         $form->{rowcount} = $i;
2812         $form->{assembly_rows}++;
2813
2814         &new_item;
2815
2816       }
2817     }
2818
2819   } elsif (($form->{item} eq 'part') || ($form->{item} eq 'service')) {
2820     &check_form;
2821   }
2822
2823   $lxdebug->leave_sub();
2824 }
2825
2826 sub save {
2827   $lxdebug->enter_sub();
2828
2829   my ($parts_id, %newform, $previousform, $amount, $callback);
2830
2831   # check if there is a part number - commented out, cause there is an automatic allocation of numbers
2832   # $form->isblank("partnumber", $locale->text(ucfirst $form->{item}." Part Number missing!"));
2833
2834   # check if there is a description
2835   $form->isblank("description", $locale->text("Part Description missing!"));
2836
2837   if ($form->{obsolete}) {
2838     $form->error(
2839       $locale->text(
2840         "Inventory quantity must be zero before you can set this $form->{item} obsolete!"
2841       ))
2842       if ($form->{onhand} * 1);
2843   }
2844
2845   if (!$form->{buchungsgruppen_id}) {
2846     $form->error($locale->text("Parts must have an entry type.") . " " . 
2847      $locale->text("If you see this message, you most likely just setup your LX-Office and haven't added any entry types. If this is the case, the option is accessible for administrators in the System menu.") 
2848     );
2849   }
2850
2851   $form->error($locale->text('Description must not be empty!')) unless $form->{description};
2852   $form->error($locale->text('Partnumber must not be set to empty!')) if $form->{id} && !$form->{partnumber};
2853
2854   # expand dynamic strings
2855   # $locale->text('Inventory quantity must be zero before you can set this part obsolete!')
2856   # $locale->text('Inventory quantity must be zero before you can set this assembly obsolete!')
2857   # $locale->text('Part Number missing!')
2858   # $locale->text('Service Number missing!')
2859   # $locale->text('Assembly Number missing!')
2860
2861   # save part
2862   $lxdebug->message($LXDebug::DEBUG1, "ic.pl: sellprice in save = $form->{sellprice}\n");
2863   if (IC->save(\%myconfig, \%$form) == 3) {
2864     $form->error($locale->text('Partnumber not unique!'));
2865   }
2866   # saving the history
2867   if(!exists $form->{addition}) {
2868     $form->{snumbers} = qq|partnumber_| . $form->{partnumber};
2869         $form->{addition} = "SAVED";
2870         $form->save_history($form->dbconnect(\%myconfig));
2871   }
2872   # /saving the history
2873   $parts_id = $form->{id};
2874
2875   my $i;
2876   # load previous variables
2877   if ($form->{previousform}) {
2878
2879     # save the new form variables before splitting previousform
2880     map { $newform{$_} = $form->{$_} } keys %$form;
2881
2882     $previousform = $form->unescape($form->{previousform});
2883
2884     # don't trample on previous variables
2885     map { delete $form->{$_} } keys %newform;
2886
2887     # now take it apart and restore original values
2888     foreach my $item (split /&/, $previousform) {
2889       my ($key, $value) = split /=/, $item, 2;
2890       $value =~ s/%26/&/g;
2891       $form->{$key} = $value;
2892     }
2893     $form->{taxaccounts} = $newform{taxaccount2};
2894
2895     if ($form->{item} eq 'assembly') {
2896
2897       # undo number formatting
2898       map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
2899         qw(weight listprice sellprice rop);
2900
2901       $form->{assembly_rows}--;
2902       $i = $newform{rowcount};
2903       $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
2904
2905       $form->{sellprice} -= $form->{"sellprice_$i"} * $form->{"qty_$i"};
2906       $form->{weight}    -= $form->{"weight_$i"} * $form->{"qty_$i"};
2907
2908       # change/add values for assembly item
2909       map { $form->{"${_}_$i"} = $newform{$_} }
2910         qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno);
2911
2912       $form->{sellprice} += $form->{"sellprice_$i"} * $form->{"qty_$i"};
2913       $form->{weight}    += $form->{"weight_$i"} * $form->{"qty_$i"};
2914
2915     } else {
2916
2917       # set values for last invoice/order item
2918       $i = $form->{rowcount};
2919       $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
2920
2921       map { $form->{"${_}_$i"} = $newform{$_} }
2922         qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice);
2923       $form->{"sellprice_$i"} = $newform{lastcost} if ($form->{vendor_id});
2924       if ($form->{exchangerate} != 0) {
2925         $form->{"sellprice_$i"} /= $form->{exchangerate};
2926       }
2927       $lxdebug->message($LXDebug::DEBUG1, qq|sellprice_$i in previousform 2 = | . $form->{"sellprice_$i"} . qq|\n|);
2928       map { $form->{"taxaccounts_$i"} .= "$_ " } split / /,
2929         $newform{taxaccount};
2930       chop $form->{"taxaccounts_$i"};
2931       foreach my $item (qw(description rate taxnumber)) {
2932         my $index = $form->{"taxaccounts_$i"} . "_$item";
2933         $form->{$index} = $newform{$index};
2934       }
2935
2936       # credit remaining calculation
2937       $amount =
2938         $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
2939         $form->{"qty_$i"};
2940       map { $form->{"${_}_base"} += $amount }
2941         (split / /, $form->{"taxaccounts_$i"});
2942       map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
2943         split / /, $form->{"taxaccounts_$i"}
2944         if !$form->{taxincluded};
2945
2946       $form->{creditremaining} -= $amount;
2947
2948       # redo number formatting, because invoice parse them!
2949       $i = $form->{rowcount};
2950       map {
2951         $form->{"${_}_$i"} =
2952           $form->format_amount(\%myconfig, $form->{"${_}_$i"})
2953       } qw(weight listprice sellprice rop);
2954     }
2955
2956     $form->{"id_$i"} = $parts_id;
2957     delete $form->{action};
2958
2959     # restore original callback
2960     $callback = $form->unescape($form->{callback});
2961     $form->{callback} = $form->unescape($form->{old_callback});
2962     delete $form->{old_callback};
2963
2964     $form->{makemodel_rows}--;
2965
2966     # put callback together
2967     foreach my $key (keys %$form) {
2968
2969       # do single escape for Apache 2.0
2970       my $value = $form->escape($form->{$key}, 1);
2971       $callback .= qq|&$key=$value|;
2972     }
2973     $form->{callback} = $callback;
2974   }
2975   $lxdebug->message($LXDebug::DEBUG1, qq|ic.pl: sellprice_$i nach sub save = | . $form->{"sellprice_$i"} . qq|\n|);
2976
2977   # redirect
2978   $form->redirect;
2979
2980   $lxdebug->leave_sub();
2981 }
2982
2983 sub save_as_new {
2984   $lxdebug->enter_sub();
2985
2986   # saving the history
2987   if(!exists $form->{addition}) {
2988     $form->{snumbers} = qq|partnumber_| . $form->{partnumber};
2989         $form->{addition} = "SAVED AS NEW";
2990         $form->save_history($form->dbconnect(\%myconfig));
2991   }
2992   # /saving the history
2993   $form->{id} = 0;
2994   if ($form->{"original_partnumber"} &&
2995       ($form->{"partnumber"} eq $form->{"original_partnumber"})) {
2996     $form->{partnumber} = "";
2997   }
2998   &save;
2999   $lxdebug->leave_sub();
3000 }
3001
3002 sub delete {
3003   $lxdebug->enter_sub();
3004   # saving the history
3005   if(!exists $form->{addition}) {
3006     $form->{snumbers} = qq|partnumber_| . $form->{partnumber};
3007         $form->{addition} = "DELETED";
3008         $form->save_history($form->dbconnect(\%myconfig));
3009   }
3010   # /saving the history
3011   my $rc = IC->delete(\%myconfig, \%$form);
3012
3013   # redirect
3014   $form->redirect($locale->text('Item deleted!')) if ($rc > 0);
3015   $form->error($locale->text('Cannot delete item!'));
3016
3017   $lxdebug->leave_sub();
3018 }
3019
3020 sub price_row {
3021   $lxdebug->enter_sub();
3022
3023   my ($numrows) = @_;
3024
3025   print qq|
3026   <tr>
3027     <td>
3028       <table width=100%>
3029         <tr>
3030           <th class="listheading">| . $locale->text('Preisklasse') . qq|</th>
3031           <th class="listheading">| . $locale->text('Preis') . qq|</th>
3032         </tr>
3033 |;
3034   for my $i (1 .. $numrows) {
3035     print qq|
3036         <tr>
3037           <td width=50%><input type=hidden name="pricegroup_$i" size=30  value="$form->{"pricegroup_$i"}">$form->{"pricegroup_$i"}</td>
3038           <td width=50%><input name="price_$i" size=11 value="$form->{"price_$i"}"></td>
3039           <input type=hidden name="pricegroup_id_$i" value="$form->{"pricegroup_id_$i"}">
3040         </tr>
3041 |;
3042   }
3043
3044   print qq|
3045       </table>
3046     </td>
3047   </tr>
3048 |;
3049
3050   $lxdebug->leave_sub();
3051 }
3052
3053 sub parts_language_selection {
3054   $lxdebug->enter_sub();
3055
3056   our ($onload);
3057
3058   my $languages = IC->retrieve_languages(\%myconfig, $form);
3059
3060
3061   my $callback = "$form->{script}?action=parts_language_selection&";
3062   map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
3063       (qw(login password name input_name), grep({ /^[fl]_/ } keys %$form)));
3064
3065   my @header_sort = qw(name longdescription);
3066   my %header_title = ( "name" => $locale->text("Name"),
3067                        "longdescription" => $locale->text("Long Description"),
3068                        );
3069
3070   my @header =
3071     map(+{ "column_title" => $header_title{$_},
3072            "column" => $_,
3073            "callback" => $callback,
3074          },
3075         @header_sort);
3076
3077   $form->{"title"} = $locale->text("Language Values");
3078   $form->header();
3079   print($form->parse_html_template("ic/parts_language_selection", { "HEADER" => \@header,
3080                                                                    "LANGUAGES" => $languages,
3081                                                                    "onload" => $onload }));
3082
3083   $lxdebug->leave_sub();
3084 }
3085
3086 sub continue { call_sub($form->{"nextsub"}); }