1 #=====================================================================
 
   4 # Based on SQL-Ledger Version 2.1.9
 
   5 # Web http://www.lx-office.org
 
   7 #=====================================================================
 
   8 # SQL-Ledger, Accounting
 
  11 #  Author: Dieter Simader
 
  12 #   Email: dsimader@sql-ledger.org
 
  13 #     Web: http://www.sql-ledger.org
 
  16 # This program is free software; you can redistribute it and/or modify
 
  17 # it under the terms of the GNU General Public License as published by
 
  18 # the Free Software Foundation; either version 2 of the License, or
 
  19 # (at your option) any later version.
 
  21 # This program is distributed in the hope that it will be useful,
 
  22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
  23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
  24 # GNU General Public License for more details.
 
  25 # You should have received a copy of the GNU General Public License
 
  26 # along with this program; if not, write to the Free Software
 
  27 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
  28 #======================================================================
 
  30 # Inventory Control module
 
  32 #======================================================================
 
  39 require "$form->{path}/io.pl";
 
  46   $lxdebug->enter_sub();
 
  48   $form->{title} = $locale->text('Add ' . ucfirst $form->{item});
 
  51     "$form->{script}?action=add&item=$form->{item}&path=$form->{path}&login=$form->{login}&password=$form->{password}"
 
  52     unless $form->{callback};
 
  54   $form->{"unit_changeable"} = 1;
 
  56   IC->get_pricegroups(\%myconfig, \%$form);
 
  60   $lxdebug->leave_sub();
 
  64   $lxdebug->enter_sub();
 
  66   $form->{title} = (ucfirst $form->{searchitems}) . "s";
 
  67   $form->{title} = $locale->text($form->{title});
 
  69   # switch for backward sorting
 
  72   # memory for which table was sort at last time
 
  73   $form->{lastsort} = "";
 
  75   # counter for added entries to top100
 
  76   $form->{ndxs_counter} = 0;
 
  78   # $locale->text('Parts')
 
  79   # $locale->text('Services')
 
  81   # use JavaScript Calendar or not
 
  82   $form->{jsscript} = $jscalendar;
 
  84   if ($form->{jsscript}) {
 
  86     # with JavaScript Calendar
 
  88        <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>
 
  89        <td><input type=button name=transdatefrom id="trigger1" value=|
 
  90       . $locale->text('button') . qq|></td>
 
  93        <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>
 
  94        <td><input type=button name=transdateto name=transdateto id="trigger2" value=|
 
  95       . $locale->text('button') . qq|></td>
 
 100       Form->write_trigger(\%myconfig, "2", "transdatefrom", "BL", "trigger1",
 
 101                           "transdateto", "BL", "trigger2");
 
 104     # without JavaScript Calendar
 
 106                               <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
 
 108                               <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
 
 111   unless ($form->{searchitems} eq 'service') {
 
 114             <input name=itemstatus class=radio type=radio value=onhand> |
 
 115       . $locale->text('On Hand') . qq|
 
 116             <input name=itemstatus class=radio type=radio value=short> |
 
 117       . $locale->text('Short') . qq|
 
 122           <th align=right nowrap>| . $locale->text('Make') . qq|</th>
 
 123           <td><input name=make size=20></td>
 
 124           <th align=right nowrap>| . $locale->text('Model') . qq|</th>
 
 125           <td><input name=model size=20></td>
 
 130           <th align=right nowrap>| . $locale->text('Serial Number') . qq|</th>
 
 131           <td><input name=serialnumber size=20></td>
 
 134     $l_serialnumber = qq|
 
 135         <td><input name=l_serialnumber class=checkbox type=checkbox value=Y> |
 
 136       . $locale->text('Serial Number') . qq|</td>
 
 141   if ($form->{searchitems} eq 'assembly') {
 
 143     $form->{title} = $locale->text('Assemblies');
 
 149           <input name=null class=radio type=radio value=1 checked> |
 
 150       . $locale->text('Top Level') . qq|
 
 151           <input name=bom class=checkbox type=checkbox value=1> |
 
 152       . $locale->text('Individual Items') . qq|
 
 166                       <td><input name=sold class=checkbox type=checkbox value=1></td>
 
 167                       <td nowrap>| . $locale->text('Sold') . qq|</td>
 
 170                       <td colspan=2><hr size=1 noshade></td>
 
 173                       <td><input name=ordered class=checkbox type=checkbox value=1></td>
 
 174                       <td nowrap>| . $locale->text('Ordered') . qq|</td>
 
 177                       <td colspan=4><hr size=1 noshade></td>
 
 180                       <td><input name=quoted class=checkbox type=checkbox value=1></td>
 
 181                       <td nowrap>| . $locale->text('Quoted') . qq|</td>
 
 185                 <td width=5%> </td>
 
 186                 <th>| . $locale->text('From') . qq|</th>
 
 188                 <th>| . $locale->text('To') . qq|</th>
 
 207                       <td><input name=bought class=checkbox type=checkbox value=1></td>
 
 208                       <td nowrap>| . $locale->text('Bought') . qq|</td>
 
 209                       <td><input name=sold class=checkbox type=checkbox value=1></td>
 
 210                       <td nowrap>| . $locale->text('Sold') . qq|</td>
 
 213                       <td colspan=4><hr size=1 noshade></td>
 
 216                       <td><input name=onorder class=checkbox type=checkbox value=1></td>
 
 217                       <td nowrap>| . $locale->text('On Order') . qq|</td>
 
 218                       <td><input name=ordered class=checkbox type=checkbox value=1></td>
 
 219                       <td nowrap>| . $locale->text('Ordered') . qq|</td>
 
 222                       <td colspan=4><hr size=1 noshade></td>
 
 225                       <td><input name=rfq class=checkbox type=checkbox value=1></td>
 
 226                       <td nowrap>| . $locale->text('RFQ') . qq|</td>
 
 227                       <td><input name=quoted class=checkbox type=checkbox value=1></td>
 
 228                       <td nowrap>| . $locale->text('Quoted') . qq|</td>
 
 232                 <td width=5%> </td>
 
 236                       <th>| . $locale->text('From') . qq|</th>
 
 238                       <th>| . $locale->text('To') . qq|</th>
 
 255 <form method=post action=$form->{script}>
 
 257 <input type=hidden name=searchitems value=$form->{searchitems}>
 
 258 <input type=hidden name=title value="$form->{title}">
 
 260 <input type=hidden name=revers value="$form->{revers}">
 
 261 <input type=hidden name=lastsort value="$form->{lastsort}">
 
 264   <tr><th class=listtop>$form->{title}</th></tr>
 
 270           <th align=right nowrap>| . $locale->text('Part Number') . qq|</th>
 
 271           <td><input name=partnumber size=20></td>
 
 274           <th align=right nowrap>|
 
 275     . $locale->text('Part Description') . qq|</th>
 
 276           <td colspan=3><input name=description size=40></td>
 
 279           <th align=right nowrap>| . $locale->text('Group') . qq|</th>
 
 280           <td><input name=partsgroup size=20></td>
 
 285           <th align=right nowrap>| . $locale->text('Drawing') . qq|</th>
 
 286           <td><input name=drawing size=20></td>
 
 287           <th align=right nowrap>| . $locale->text('Microfiche') . qq|</th>
 
 288           <td><input name=microfiche size=20></td>
 
 294             <input name=itemstatus class=radio type=radio value=active checked> |
 
 295     . $locale->text('Active') . qq|
 
 297             <input name=itemstatus class=radio type=radio value=obsolete> |
 
 298     . $locale->text('Obsolete') . qq|
 
 299             <input name=itemstatus class=radio type=radio value=orphaned> |
 
 300     . $locale->text('Orphaned') . qq|
 
 311           <th align=right nowrap>|
 
 312     . $locale->text('Include in Report') . qq|</th>
 
 316                 <td><input name=l_partnumber class=checkbox type=checkbox value=Y checked> |
 
 317     . $locale->text('Part Number') . qq|</td>
 
 318                 <td><input name=l_description class=checkbox type=checkbox value=Y checked> |
 
 319     . $locale->text('Part Description') . qq|</td>
 
 321                 <td><input name=l_unit class=checkbox type=checkbox value=Y checked> |
 
 322     . $locale->text('Unit of measure') . qq|</td>
 
 325                 <td><input name=l_listprice class=checkbox type=checkbox value=Y> |
 
 326     . $locale->text('List Price') . qq|</td>
 
 327                 <td><input name=l_sellprice class=checkbox type=checkbox value=Y checked> |
 
 328     . $locale->text('Sell Price') . qq|</td>
 
 329                 <td><input name=l_lastcost class=checkbox type=checkbox value=Y checked> |
 
 330     . $locale->text('Last Cost') . qq|</td>
 
 331                 <td><input name=l_linetotal class=checkbox type=checkbox value=Y checked> |
 
 332     . $locale->text('Line Total') . qq|</td>
 
 335                 <td><input name=l_priceupdate class=checkbox type=checkbox value=Y> |
 
 336     . $locale->text('Updated') . qq|</td>
 
 337                 <td><input name=l_bin class=checkbox type=checkbox value=Y> |
 
 338     . $locale->text('Bin') . qq|</td>
 
 339                 <td><input name=l_rop class=checkbox type=checkbox value=Y> |
 
 340     . $locale->text('ROP') . qq|</td>
 
 341                 <td><input name=l_weight class=checkbox type=checkbox value=Y> |
 
 342     . $locale->text('Weight') . qq|</td>
 
 345                 <td><input name=l_image class=checkbox type=checkbox value=Y> |
 
 346     . $locale->text('Image') . qq|</td>
 
 347                 <td><input name=l_drawing class=checkbox type=checkbox value=Y> |
 
 348     . $locale->text('Drawing') . qq|</td>
 
 349                 <td><input name=l_microfiche class=checkbox type=checkbox value=Y> |
 
 350     . $locale->text('Microfiche') . qq|</td>
 
 351                 <td><input name=l_partsgroup class=checkbox type=checkbox value=Y> |
 
 352     . $locale->text('Group') . qq|</td>
 
 355                 <td><input name=l_subtotal class=checkbox type=checkbox value=Y> |
 
 356     . $locale->text('Subtotal') . qq|</td>
 
 357                 <td><input name=l_soldtotal class=checkbox type=checkbox value=Y> |
 
 358     . $locale->text('soldtotal') . qq|</td>
 
 359                 <td><input name=l_deliverydate class=checkbox type=checkbox value=Y> |
 
 360     . $locale->text('deliverydate') . qq|</td>    
 
 368   <tr><td colspan=4><hr size=3 noshade></td></tr>
 
 373 <input type=hidden name=nextsub value=generate_report>
 
 375 <input type=hidden name=path value=$form->{path}>
 
 376 <input type=hidden name=login value=$form->{login}>
 
 377 <input type=hidden name=password value=$form->{password}>
 
 379 <input type=hidden name=revers value="$form->{revers}">
 
 380 <input type=hidden name=lastsort value="$form->{lastsort}">
 
 381 <input type=hidden name=sort value="description">
 
 383 <input type=hidden name=ndxs_counter value="$form->{ndxs_counter}">
 
 386 <input class=submit type=submit name=action value="|
 
 387     . $locale->text('Continue') . qq|">
 
 388 <input class=submit type=submit name=action value="|
 
 389     . $locale->text('TOP100') . qq|">
 
 395   $lxdebug->leave_sub();
 
 399 sub search_update_prices {
 
 400   $lxdebug->enter_sub();
 
 402   $form->{title} = $locale->text('Update prices');
 
 403   IC->get_pricegroups(\%myconfig, \%$form);
 
 405   # use JavaScript Calendar or not
 
 406 #   $form->{jsscript} = $jscalendar;
 
 408 #   if ($form->{jsscript}) {
 
 410 #     # with JavaScript Calendar
 
 412 #        <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>
 
 413 #        <td><input type=button name=transdatefrom id="trigger1" value=|
 
 414 #       . $locale->text('button') . qq|></td>
 
 417 #        <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>
 
 418 #        <td><input type=button name=transdateto name=transdateto id="trigger2" value=|
 
 419 #       . $locale->text('button') . qq|></td>
 
 424 #       Form->write_trigger(\%myconfig, "2", "transdatefrom", "BL", "trigger1",
 
 425 #                           "transdateto", "BL", "trigger2");
 
 428 #     # without JavaScript Calendar
 
 430 #                               <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
 
 432 #                               <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
 
 436             <input name=itemstatus class=radio type=radio value=onhand> |
 
 437       . $locale->text('On Hand') . qq|
 
 438             <input name=itemstatus class=radio type=radio value=short> |
 
 439       . $locale->text('Short') . qq|
 
 444           <th align=right nowrap>| . $locale->text('Make') . qq|</th>
 
 445           <td><input name=make size=20></td>
 
 446           <th align=right nowrap>| . $locale->text('Model') . qq|</th>
 
 447           <td><input name=model size=20></td>
 
 452           <th align=right nowrap>| . $locale->text('Serial Number') . qq|</th>
 
 453           <td><input name=serialnumber size=20></td>
 
 456     $l_serialnumber = qq|
 
 457         <td><input name=l_serialnumber class=checkbox type=checkbox value=Y> |
 
 458       . $locale->text('Serial Number') . qq|</td>
 
 468 <form method=post action=$form->{script}>
 
 470 <input type=hidden name=title value="$form->{title}">
 
 473   <tr><th class=listtop>$form->{title}</th></tr>
 
 479           <th align=right nowrap>| . $locale->text('Part Number') . qq|</th>
 
 480           <td><input name=partnumber size=20></td>
 
 483           <th align=right nowrap>|
 
 484     . $locale->text('Part Description') . qq|</th>
 
 485           <td colspan=3><input name=description size=40></td>
 
 488           <th align=right nowrap>| . $locale->text('Group') . qq|</th>
 
 489           <td><input name=partsgroup size=20></td>
 
 494           <th align=right nowrap>| . $locale->text('Drawing') . qq|</th>
 
 495           <td><input name=drawing size=20></td>
 
 496           <th align=right nowrap>| . $locale->text('Microfiche') . qq|</th>
 
 497           <td><input name=microfiche size=20></td>
 
 503             <input name=itemstatus class=radio type=radio value=active checked> |
 
 504     . $locale->text('Active') . qq|
 
 506             <input name=itemstatus class=radio type=radio value=obsolete> |
 
 507     . $locale->text('Obsolete') . qq|
 
 508             <input name=itemstatus class=radio type=radio value=orphaned> |
 
 509     . $locale->text('Orphaned') . qq|
 
 524           <th class="listheading">| . $locale->text('Preisklasse') . qq|</th>
 
 525           <th class="listheading">| . $locale->text('Preis') . qq|</th>
 
 526           <th class="listheading">| . $locale->text('Prozentual/Absolut') . qq|</th>
 
 529           <td>| . $locale->text('Sell Price') . qq|</td>
 
 530           <td><input name="sellprice" size=11 value="$form->{"sellprice"}"></td>
 
 531           <td><input name="sellprice_type" class=radio type=radio value=percent checked>/<input name="sellprice_type" class=radio type=radio value=absolut></td>
 
 534           <td>| . $locale->text('List Price') . qq|</td>
 
 535           <td><input name="listprice" size=11 value="$form->{"listprice"}"></td>
 
 536           <td><input name="listprice_type" class=radio type=radio value=percent checked>/<input name="listprice_type" class=radio type=radio value=absolut></td>
 
 539   for $i (1 .. $form->{price_rows}) {
 
 542           <td width=50%><input type=hidden name="pricegroup_$i" size=30  value="$form->{"pricegroup_$i"}">$form->{"pricegroup_$i"}</td>
 
 543           <td width=50%><input name="price_$i" size=11></td>
 
 544           <input type=hidden name="pricegroup_id_$i" value="$form->{"pricegroup_id_$i"}">
 
 545           <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>
 
 555   <tr><td colspan=4><hr size=3 noshade></td></tr>
 
 557 <input type=hidden name=nextsub value=confirm_price_update>
 
 558 <input type=hidden name=price_rows value=$form->{price_rows}>
 
 560 <input type=hidden name=path value=$form->{path}>
 
 561 <input type=hidden name=login value=$form->{login}>
 
 562 <input type=hidden name=password value=$form->{password}>
 
 565 <input class=submit type=submit name=action value="|
 
 566     . $locale->text('Continue') . qq|">
 
 572   $lxdebug->leave_sub();
 
 575 sub confirm_price_update {
 
 576   $lxdebug->enter_sub();
 
 579   $form->{nextsub} = "update_prices";
 
 585 <form method=post action=$form->{script}>
 
 588   # delete action variable
 
 589   map { delete $form->{$_} } qw(action header);
 
 591   foreach $key (keys %$form) {
 
 592     $form->{$key} =~ s/\"/"/g;
 
 593     print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
 
 597 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
 
 600     . $locale->text('Are you sure you want to update the prices')
 
 604 <input name=action class=submit type=submit value="|
 
 605     . $locale->text('Continue') . qq|">
 
 609   $lxdebug->leave_sub();
 
 613   $lxdebug->enter_sub();
 
 615   if (IC->update_prices(\%myconfig, \%$form)) {
 
 616     $form->redirect($form->{update_count} . $locale->text('prices updated!'));
 
 618     $form->error($locale->text('Could not update prices!'));
 
 621   $lxdebug->leave_sub();
 
 625   $lxdebug->enter_sub();
 
 627   $form->{title} = $locale->text('Top 100 hinzufuegen');
 
 634   <form method=post action=$form->{script}>
 
 636   <input type=hidden name=searchitems value=$form->{searchitems}>
 
 637   <input type=hidden name=title value="$form->{title}">
 
 639   <input type=hidden name=revers value="$form->{revers}">
 
 640   <input type=hidden name=lastsort value="$form->{lastsort}">|;
 
 644         <tr class=listheading>
 
 645          <th class=listheading nowrap>|
 
 646     . $locale->text('Part Number') . qq|</th>
 
 647          <th class=listheading nowrap>|
 
 648     . $locale->text('Part Description') . qq|</th>
 
 651          <td><input type=text name=partnumber size=20 value=></td>
 
 652          <td><input type=text name=description size=30 value=></td>
 
 659 <input type=hidden name=path value=$form->{path}>
 
 660 <input type=hidden name=login value=$form->{login}>
 
 661 <input type=hidden name=password value=$form->{password}>
 
 663 <input type=hidden name=itemstatus value="$form->{itemstatus}">
 
 664 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
 
 665 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
 
 666 <input type=hidden name=l_description value="$form->{l_description}">
 
 667 <input type=hidden name=l_onhand value="$form->{l_onhand}">
 
 668 <input type=hidden name=l_unit value="$form->{l_unit}">
 
 669 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
 
 670 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
 
 671 <input type=hidden name=sort value="$form->{sort}">
 
 672 <input type=hidden name=revers value="$form->{revers}">
 
 673 <input type=hidden name=lastsort value="$form->{lastsort}">
 
 675 <input type=hidden name=bom value="$form->{bom}">
 
 676 <input type=hidden name=titel value="$form->{titel}">
 
 677 <input type=hidden name=searchitems value="$form->{searchitems}">
 
 679 <input type=hidden name=row value=$j>
 
 681 <input type=hidden name=nextsub value=item_selected>
 
 683 <input type=hidden name=test value=item_selected>
 
 685 <input name=lastndx type=hidden value=$lastndx>
 
 687 <input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>
 
 689 <input name=extras type=hidden value=$form->{extras}>|;
 
 693     for ($i = 0; $i < $form->{ndxs_counter}; $i++) {
 
 696       $partnumber  = $form->{"totop100_partnumber_$j"};
 
 697       $description = $form->{"totop100_description_$j"};
 
 698       $unit        = $form->{"totop100_unit_$j"};
 
 699       $sellprice   = $form->{"totop100_sellprice_$j"};
 
 700       $soldtotal   = $form->{"totop100_soldtotal_$j"};
 
 702       # insert data into top100
 
 703       push @{ $form->{parts} },
 
 705           partnumber  => "$partnumber",
 
 706           description => "$description",
 
 708           sellprice   => "$sellprice",
 
 709           soldtotal   => "$soldtotal" };
 
 715   # set data for next page
 
 716   if (($form->{ndxs_counter}) > 0) {
 
 717     for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
 
 718       $partnumber  = $form->{"totop100_partnumber_$i"};
 
 719       $description = $form->{"totop100_description_$i"};
 
 720       $unit        = $form->{"totop100_unit_$i"};
 
 721       $sellprice   = $form->{"totop100_sellprice_$i"};
 
 722       $soldtotal   = $form->{"totop100_soldtotal_$i"};
 
 725 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
 
 726 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
 
 727 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
 
 728 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
 
 729 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
 
 737      <input class=submit type=submit name=action value="|
 
 738     . $locale->text('list') . qq|">
 
 743   $lxdebug->leave_sub();
 
 747   $lxdebug->enter_sub();
 
 750   if (($form->{partnumber} eq "") and ($form->{description} eq "")) {
 
 751     IC->get_parts(\%myconfig, \%$form, "");
 
 753     if ((!($form->{partnumber} eq "")) and ($form->{description} eq "")) {
 
 754       IC->get_parts(\%myconfig, \%$form, "partnumber");
 
 756       if (($form->{partnumber} eq "") and (!($form->{description} eq ""))) {
 
 757         IC->get_parts(\%myconfig, \%$form, "description");
 
 759         IC->get_parts(\%myconfig, \%$form, "all");
 
 764   $form->{title} = $locale->text('Top 100 hinzufuegen');
 
 770   <form method=post action=ic.pl>
 
 773       <th class=listtop colspan=6>| . $locale->text('choice part') . qq|</th>
 
 776         <tr class=listheading>
 
 778           <th class=listheading>| . $locale->text('Part Number') . qq|</th>
 
 779           <th class=listheading>| . $locale->text('Part Description') . qq|</th>
 
 780           <th class=listheading>| . $locale->text('Unit of measure') . qq|</th>
 
 781           <th class=listheading>| . $locale->text('Sell Price') . qq|</th>
 
 782           <th class=listheading>| . $locale->text('soldtotal') . qq|</th>
 
 786   my $i = $form->{rows};
 
 788   for ($j = 1; $j <= $i; $j++) {
 
 791         <tr class=listrow1>|;
 
 794             <td><input name=ndx class=radio type=radio value=$j checked></td>|;
 
 797           <td><input name=ndx class=radio type=radio value=$j></td>|;
 
 800           <td><input name="new_partnumber_$j" type=hidden value="$form->{"partnumber_$j"}">$form->{"partnumber_$j"}</td>
 
 801           <td><input name="new_description_$j" type=hidden value="$form->{"description_$j"}">$form->{"description_$j"}</td>
 
 802           <td><input name="new_unit_$j" type=hidden value="$form->{"unit_$j"}">$form->{"unit_$j"}</td>
 
 803           <td><input name="new_sellprice_$j" type=hidden value="$form->{"sellprice_$j"}">$form->{"sellprice_$j"}</td>
 
 804           <td><input name="new_soldtotal_$j" type=hidden value="$form->{"soldtotal_$j"}">$form->{"soldtotal_$j"}</td>
 
 807         <input name="new_id_$j" type=hidden value="$form->{"id_$j"}">|;
 
 817 <input type=hidden name=path value=$form->{path}>
 
 818 <input type=hidden name=login value=$form->{login}>
 
 819 <input type=hidden name=password value=$form->{password}>
 
 821 <input type=hidden name=itemstatus value="$form->{itemstatus}">
 
 822 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
 
 823 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
 
 824 <input type=hidden name=l_description value="$form->{l_description}">
 
 825 <input type=hidden name=l_onhand value="$form->{l_onhand}">
 
 826 <input type=hidden name=l_unit value="$form->{l_unit}">
 
 827 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
 
 828 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
 
 829 <input type=hidden name=sort value="$form->{sort}">
 
 830 <input type=hidden name=revers value="$form->{revers}">
 
 831 <input type=hidden name=lastsort value="$form->{lastsort}">
 
 833 <input type=hidden name=bom value="$form->{bom}">
 
 834 <input type=hidden name=titel value="$form->{titel}">
 
 835 <input type=hidden name=searchitems value="$form->{searchitems}">
 
 837 <input type=hidden name=row value=$j>
 
 839 <input type=hidden name=nextsub value=item_selected>
 
 841 <input name=lastndx type=hidden value=$lastndx>
 
 843 <input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>|;
 
 847   if (($form->{ndxs_counter}) > 0) {
 
 848     for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
 
 849       $j1 = $form->{"totop100_partnumber_$i"};
 
 850       $j2 = $form->{"totop100_description_$i"};
 
 851       $j3 = $form->{"totop100_unit_$i"};
 
 852       $j4 = $form->{"totop100_sellprice_$i"};
 
 853       $j5 = $form->{"totop100_soldtotal_$i"};
 
 862 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
 
 863 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
 
 864 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
 
 865 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
 
 866 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
 
 874 <input class=submit type=submit name=action value="|
 
 875     . $locale->text('TOP100') . qq|">
 
 881   $lxdebug->leave_sub();
 
 885   $lxdebug->enter_sub();
 
 888     $form->{ndxs_counter}++;
 
 890     if ($form->{ndxs_counter} > 0) {
 
 892       $index = $form->{ndx};
 
 894       $j1 = $form->{"new_partnumber_$index"};
 
 895       $form->{"totop100_partnumber_$form->{ndxs_counter}"} = $j1;
 
 896       $j2 = $form->{"new_description_$index"};
 
 897       $form->{"totop100_description_$form->{ndxs_counter}"} = $j2;
 
 898       $j3 = $form->{"new_unit_$index"};
 
 899       $form->{"totop100_unit_$form->{ndxs_counter}"} = $j3;
 
 900       $j4 = $form->{"new_sellprice_$index"};
 
 901       $form->{"totop100_sellprice_$form->{ndxs_counter}"} = $j4;
 
 902       $j5 = $form->{"new_soldtotal_$index"};
 
 903       $form->{"totop100_soldtotal_$form->{ndxs_counter}"} = $j5;
 
 907   $lxdebug->leave_sub();
 
 911   $lxdebug->enter_sub();
 
 913   $form->{top100}      = "top100";
 
 914   $form->{l_soldtotal} = "Y";
 
 915   $form->{soldtotal}   = "soldtotal";
 
 916   $form->{sort}        = "soldtotal";
 
 917   $form->{l_qty}       = "N";
 
 918   $callback .= "&form->{top100}=$form->{top100}";
 
 919   $form->{l_linetotal} = "";
 
 921   $form->{number}      = "position";
 
 922   $form->{l_number}    = "Y";
 
 926   $form->{title} = $locale->text('Top 100');
 
 928   $revers   = $form->{revers};
 
 929   $lastsort = $form->{lastsort};
 
 931   if (($form->{lastsort} eq "") && ($form->{sort} eq undef)) {
 
 933     $form->{lastsort} = "partnumber";
 
 934     $form->{sort}     = "partnumber";
 
 938     "$form->{script}?action=top100&path=$form->{path}&login=$form->{login}&password=$form->{password}&searchitems=$form->{searchitems}&itemstatus=$form->{itemstatus}&bom=$form->{bom}&l_linetotal=$form->{l_linetotal}&title="
 
 939     . $form->escape($form->{title}, 1);
 
 941   # if we have a serialnumber limit search
 
 942   if ($form->{serialnumber} || $form->{l_serialnumber}) {
 
 943     $form->{l_serialnumber} = "Y";
 
 944     unless (   $form->{bought}
 
 947             || $form->{quoted}) {
 
 948       $form->{bought} = $form->{sold} = 1;
 
 951   IC->all_parts(\%myconfig, \%$form);
 
 953   if ($form->{itemstatus} eq 'active') {
 
 954     $option .= $locale->text('Active') . " : ";
 
 956   if ($form->{itemstatus} eq 'obsolete') {
 
 957     $option .= $locale->text('Obsolete') . " : ";
 
 959   if ($form->{itemstatus} eq 'orphaned') {
 
 960     $option .= $locale->text('Orphaned') . " : ";
 
 962   if ($form->{itemstatus} eq 'onhand') {
 
 963     $option .= $locale->text('On Hand') . " : ";
 
 964     $form->{l_onhand} = "Y";
 
 966   if ($form->{itemstatus} eq 'short') {
 
 967     $option .= $locale->text('Short') . " : ";
 
 968     $form->{l_onhand} = "Y";
 
 970   if ($form->{onorder}) {
 
 971     $form->{l_ordnumber} = "Y";
 
 972     $callback .= "&onorder=$form->{onorder}";
 
 973     $option   .= $locale->text('On Order') . " : ";
 
 975   if ($form->{ordered}) {
 
 976     $form->{l_ordnumber} = "Y";
 
 977     $callback .= "&ordered=$form->{ordered}";
 
 978     $option   .= $locale->text('Ordered') . " : ";
 
 981     $form->{l_quonumber} = "Y";
 
 982     $callback .= "&rfq=$form->{rfq}";
 
 983     $option   .= $locale->text('RFQ') . " : ";
 
 985   if ($form->{quoted}) {
 
 986     $form->{l_quonumber} = "Y";
 
 987     $callback .= ""ed=$form->{quoted}";
 
 988     $option   .= $locale->text('Quoted') . " : ";
 
 990   if ($form->{bought}) {
 
 991     $form->{l_invnumber} = "Y";
 
 992     $callback .= "&bought=$form->{bought}";
 
 993     $option   .= $locale->text('Bought') . " : ";
 
 996     $form->{l_invnumber} = "Y";
 
 997     $callback .= "&sold=$form->{sold}";
 
 998     $option   .= $locale->text('Sold') . " : ";
 
1000   if (   $form->{bought}
 
1005       || $form->{quoted}) {
 
1007     $form->{l_lastcost} = "";
 
1008     $form->{l_name}     = "Y";
 
1009     if ($form->{transdatefrom}) {
 
1010       $callback .= "&transdatefrom=$form->{transdatefrom}";
 
1012         . $locale->text('From')
 
1014         . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
 
1016     if ($form->{transdateto}) {
 
1017       $callback .= "&transdateto=$form->{transdateto}";
 
1019         . $locale->text('To')
 
1021         . $locale->date(\%myconfig, $form->{transdateto}, 1);
 
1027   if ($form->{partnumber}) {
 
1028     $callback .= "&partnumber=$form->{partnumber}";
 
1029     $option   .= $locale->text('Part Number') . qq| : $form->{partnumber}<br>|;
 
1031   if ($form->{partsgroup}) {
 
1032     $callback .= "&partsgroup=$form->{partsgroup}";
 
1033     $option   .= $locale->text('Group') . qq| : $form->{partsgroup}<br>|;
 
1035   if ($form->{serialnumber}) {
 
1036     $callback .= "&serialnumber=$form->{serialnumber}";
 
1038       $locale->text('Serial Number') . qq| : $form->{serialnumber}<br>|;
 
1040   if ($form->{description}) {
 
1041     $callback .= "&description=$form->{description}";
 
1042     $description = $form->{description};
 
1046       $locale->text('Part Description') . qq| : $form->{description}<br>|;
 
1048   if ($form->{make}) {
 
1049     $callback .= "&make=$form->{make}";
 
1050     $option   .= $locale->text('Make') . qq| : $form->{make}<br>|;
 
1052   if ($form->{model}) {
 
1053     $callback .= "&model=$form->{model}";
 
1054     $option   .= $locale->text('Model') . qq| : $form->{model}<br>|;
 
1056   if ($form->{drawing}) {
 
1057     $callback .= "&drawing=$form->{drawing}";
 
1058     $option   .= $locale->text('Drawing') . qq| : $form->{drawing}<br>|;
 
1060   if ($form->{microfiche}) {
 
1061     $callback .= "µfiche=$form->{microfiche}";
 
1062     $option   .= $locale->text('Microfiche') . qq| : $form->{microfiche}<br>|;
 
1064   if ($form->{l_soldtotal}) {
 
1065     $callback .= "&soldtotal=$form->{soldtotal}";
 
1066     $option   .= $locale->text('soldtotal') . qq| : $form->{soldtotal}<br>|;
 
1069   @columns = $form->sort_columns(
 
1070     qw(number partnumber description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal)
 
1073   if ($form->{l_linetotal}) {
 
1074     $form->{l_onhand} = "Y";
 
1075     $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
 
1076     if ($form->{l_lastcost}) {
 
1077       $form->{l_linetotallastcost} = "Y";
 
1078       if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
 
1079         $form->{l_linetotallastcost} = "";
 
1082     $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
 
1085   if ($form->{searchitems} eq 'service') {
 
1087     # remove bin, weight and rop from list
 
1088     map { $form->{"l_$_"} = "" } qw(bin weight rop);
 
1090     $form->{l_onhand} = "";
 
1092     # qty is irrelevant unless bought or sold
 
1093     if (   $form->{bought}
 
1098         || $form->{quoted}) {
 
1099       $form->{l_onhand} = "Y";
 
1101       $form->{l_linetotalsellprice} = "";
 
1102       $form->{l_linetotallastcost}  = "";
 
1106   $form->{l_lastcost} = ""
 
1107     if ($form->{searchitems} eq 'assembly' && !$form->{bom});
 
1109   foreach $item (@columns) {
 
1110     if ($form->{"l_$item"} eq "Y") {
 
1111       push @column_index, $item;
 
1113       # add column to callback
 
1114       $callback .= "&l_$item=Y";
 
1118   if ($form->{l_subtotal} eq 'Y') {
 
1119     $callback .= "&l_subtotal=Y";
 
1122   $column_header{number} =
 
1123     qq|<th class=listheading nowrap>| . $locale->text('number') . qq|</th>|;
 
1124   $column_header{partnumber} =
 
1125     qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1126     . $locale->text('Part Number')
 
1128   $column_header{description} =
 
1129     qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1130     . $locale->text('Part Description')
 
1132   $column_header{partsgroup} =
 
1133       qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|
 
1134     . $locale->text('Group')
 
1136   $column_header{bin} =
 
1137       qq|<th><a class=listheading href=$callback&sort=bin>|
 
1138     . $locale->text('Bin')
 
1140   $column_header{priceupdate} =
 
1141       qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|
 
1142     . $locale->text('Updated')
 
1144   $column_header{onhand} =
 
1145     qq|<th nowrap><a  class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1146     . $locale->text('Qty')
 
1148   $column_header{unit} =
 
1149     qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
 
1150   $column_header{listprice} =
 
1151       qq|<th class=listheading nowrap>|
 
1152     . $locale->text('List Price')
 
1154   $column_header{lastcost} =
 
1155     qq|<th class=listheading nowrap>| . $locale->text('Last Cost') . qq|</th>|;
 
1156   $column_header{rop} =
 
1157     qq|<th class=listheading nowrap>| . $locale->text('ROP') . qq|</th>|;
 
1158   $column_header{weight} =
 
1159     qq|<th class=listheading nowrap>| . $locale->text('Weight') . qq|</th>|;
 
1161   $column_header{invnumber} =
 
1162       qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|
 
1163     . $locale->text('Invoice Number')
 
1165   $column_header{ordnumber} =
 
1166       qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|
 
1167     . $locale->text('Order Number')
 
1169   $column_header{quonumber} =
 
1170       qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|
 
1171     . $locale->text('Quotation')
 
1174   $column_header{name} =
 
1175       qq|<th nowrap><a class=listheading href=$callback&sort=name>|
 
1176     . $locale->text('Name')
 
1179   $column_header{sellprice} =
 
1180       qq|<th class=listheading nowrap>|
 
1181     . $locale->text('Sell Price')
 
1183   $column_header{linetotalsellprice} =
 
1184     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1185   $column_header{linetotallastcost} =
 
1186     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1187   $column_header{linetotallistprice} =
 
1188     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1190   $column_header{image} =
 
1191     qq|<th class=listheading nowrap>| . $locale->text('Image') . qq|</a></th>|;
 
1192   $column_header{drawing} =
 
1193       qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|
 
1194     . $locale->text('Drawing')
 
1196   $column_header{microfiche} =
 
1197       qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|
 
1198     . $locale->text('Microfiche')
 
1201   $column_header{serialnumber} =
 
1202       qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|
 
1203     . $locale->text('Serial Number')
 
1205   $column_header{soldtotal} =
 
1206     qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1207     . $locale->text('soldtotal')
 
1211   $colspan = $#column_index + 1;
 
1218     <th class=listtop colspan=$colspan>$form->{title}</th>
 
1220   <tr height="5"></tr>
 
1222   <tr><td colspan=$colspan>$option</td></tr>
 
1224   <tr class=listheading>
 
1227   map { print "\n$column_header{$_}" } @column_index;
 
1233   # add order to callback
 
1234   $form->{callback} = $callback .= "&sort=$form->{sort}";
 
1236   # escape callback for href
 
1237   $callback = $form->escape($callback);
 
1239   if (@{ $form->{parts} }) {
 
1240     $sameitem = $form->{parts}->[0]->{ $form->{sort} };
 
1243   # insert numbers for top100
 
1245   foreach $ref (@{ $form->{parts} }) {
 
1247     $ref->{number} = $j;
 
1250   # if avaible -> insert choice here
 
1251   if (($form->{ndxs_counter}) > 0) {
 
1252     for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
 
1253       $partnumber  = $form->{"totop100_partnumber_$i"};
 
1254       $description = $form->{"totop100_description_$i"};
 
1255       $unit        = $form->{"totop100_unit_$i"};
 
1256       $sellprice   = $form->{"totop100_sellprice_$i"};
 
1257       $soldtotal   = $form->{"totop100_soldtotal_$i"};
 
1260 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
 
1261 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
 
1262 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
 
1263 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
 
1264 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
 
1268       push @{ $form->{parts} },
 
1270           partnumber  => "$partnumber",
 
1271           description => "$description",
 
1273           sellprice   => "$sellprice",
 
1274           soldtotal   => "$soldtotal" };
 
1277        # build data for columns
 
1278   foreach $ref (@{ $form->{parts} }) {
 
1280     if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
 
1281       if ($sameitem ne $ref->{ $form->{sort} }) {
 
1283         $sameitem = $ref->{ $form->{sort} };
 
1287     $ref->{exchangerate} = 1 unless $ref->{exchangerate};
 
1288     $ref->{sellprice} *= $ref->{exchangerate};
 
1289     $ref->{listprice} *= $ref->{exchangerate};
 
1290     $ref->{lastcost}  *= $ref->{exchangerate};
 
1292     # use this for assemblies
 
1293     $onhand = $ref->{onhand};
 
1296     if ($ref->{assemblyitem}) {
 
1298       $onhand = 0 if ($form->{sold});
 
1301     $ref->{description} =~ s/
 
1304     $column_data{number} =
 
1306       . $form->format_amount(\%myconfig, $ref->{number}, '', " ")
 
1308     $column_data{partnumber} =
 
1309       "<td align=$align>$ref->{partnumber} </a></td>";
 
1310     $column_data{description} = "<td>$ref->{description} </td>";
 
1311     $column_data{partsgroup}  = "<td>$ref->{partsgroup} </td>";
 
1313     $column_data{onhand} =
 
1315       . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
 
1317     $column_data{sellprice} =
 
1319       . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
 
1321     $column_data{listprice} =
 
1323       . $form->format_amount(\%myconfig, $ref->{listprice}, 2, " ")
 
1325     $column_data{lastcost} =
 
1327       . $form->format_amount(\%myconfig, $ref->{lastcost}, 2, " ")
 
1330     $column_data{linetotalsellprice} = "<td align=right>"
 
1331       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice},
 
1334     $column_data{linetotallastcost} = "<td align=right>"
 
1335       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost},
 
1338     $column_data{linetotallistprice} = "<td align=right>"
 
1339       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice},
 
1343     if (!$ref->{assemblyitem}) {
 
1344       $totalsellprice += $onhand * $ref->{sellprice};
 
1345       $totallastcost  += $onhand * $ref->{lastcost};
 
1346       $totallistprice += $onhand * $ref->{listprice};
 
1348       $subtotalonhand    += $onhand;
 
1349       $subtotalsellprice += $onhand * $ref->{sellprice};
 
1350       $subtotallastcost  += $onhand * $ref->{lastcost};
 
1351       $subtotallistprice += $onhand * $ref->{listprice};
 
1356       . $form->format_amount(\%myconfig, $ref->{rop}, '', " ") . "</td>";
 
1357     $column_data{weight} =
 
1359       . $form->format_amount(\%myconfig, $ref->{weight}, '', " ")
 
1361     $column_data{unit}        = "<td>$ref->{unit} </td>";
 
1362     $column_data{bin}         = "<td>$ref->{bin} </td>";
 
1363     $column_data{priceupdate} = "<td>$ref->{priceupdate} </td>";
 
1365     $column_data{invnumber} =
 
1366       ($ref->{module} ne 'oe')
 
1367       ? "<td><a href=$ref->{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}</a></td>"
 
1368       : "<td>$ref->{invnumber}</td>";
 
1369     $column_data{ordnumber} =
 
1370       ($ref->{module} eq 'oe')
 
1371       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber}</a></td>"
 
1372       : "<td>$ref->{ordnumber}</td>";
 
1373     $column_data{quonumber} =
 
1374       ($ref->{module} eq 'oe' && !$ref->{ordnumber})
 
1375       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber}</a></td>"
 
1376       : "<td>$ref->{quonumber}</td>";
 
1378     $column_data{name} = "<td>$ref->{name}</td>";
 
1380     $column_data{image} =
 
1382       ? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>"
 
1383       : "<td> </td>";
 
1384     $column_data{drawing} =
 
1386       ? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>"
 
1387       : "<td> </td>";
 
1388     $column_data{microfiche} =
 
1389       ($ref->{microfiche})
 
1390       ? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>"
 
1391       : "<td> </td>";
 
1393     $column_data{serialnumber} = "<td>$ref->{serialnumber}</td>";
 
1395     $column_data{soldtotal} = "<td  align=right>$ref->{soldtotal}</td>";
 
1399     print "<tr class=listrow$i>";
 
1401     map { print "\n$column_data{$_}" } @column_index;
 
1408   if ($form->{l_subtotal} eq 'Y') {
 
1412   if ($form->{"l_linetotal"}) {
 
1413     map { $column_data{$_} = "<td> </td>" } @column_index;
 
1414     $column_data{linetotalsellprice} =
 
1415         "<th class=listtotal align=right>"
 
1416       . $form->format_amount(\%myconfig, $totalsellprice, 2, " ")
 
1418     $column_data{linetotallastcost} =
 
1419         "<th class=listtotal align=right>"
 
1420       . $form->format_amount(\%myconfig, $totallastcost, 2, " ")
 
1422     $column_data{linetotallistprice} =
 
1423         "<th class=listtotal align=right>"
 
1424       . $form->format_amount(\%myconfig, $totallistprice, 2, " ")
 
1427     print "<tr class=listtotal>";
 
1429     map { print "\n$column_data{$_}" } @column_index;
 
1436   <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
 
1445 <form method=post action=$form->{script}>
 
1447 <input type=hidden name=path value=$form->{path}>
 
1448 <input type=hidden name=login value=$form->{login}>
 
1449 <input type=hidden name=password value=$form->{password}>
 
1451 <input type=hidden name=itemstatus value="$form->{itemstatus}">
 
1452 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
 
1453 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
 
1454 <input type=hidden name=l_description value="$form->{l_description}">
 
1455 <input type=hidden name=l_onhand value="$form->{l_onhand}">
 
1456 <input type=hidden name=l_unit value="$form->{l_unit}">
 
1457 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
 
1458 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
 
1459 <input type=hidden name=sort value="$form->{sort}">
 
1460 <input type=hidden name=revers value="$form->{revers}">
 
1461 <input type=hidden name=lastsort value="$form->{lastsort}">
 
1462 <input type=hidden name=parts value="$form->{parts}">
 
1464 <input type=hidden name=bom value="$form->{bom}">
 
1465 <input type=hidden name=titel value="$form->{titel}">
 
1466 <input type=hidden name=searchitems value="$form->{searchitems}">|;
 
1471     <input type=hidden name=ndxs_counter value="$form->{ndxs_counter}">
 
1473     <input class=submit type=submit name=action value="|
 
1474     . $locale->text('choice') . qq|">|;
 
1476   if ($form->{menubar}) {
 
1477     require "$form->{path}/menu.pl";
 
1488   $lxdebug->leave_sub();
 
1491 sub generate_report {
 
1492   $lxdebug->enter_sub();
 
1494   $revers   = $form->{revers};
 
1495   $lastsort = $form->{lastsort};
 
1497   if (($form->{lastsort} eq "") && ($form->{sort} eq undef)) {
 
1498     $form->{revers}   = 0;
 
1499     $form->{lastsort} = "partnumber";
 
1500     $form->{sort}     = "partnumber";
 
1503     # switch between backward sorting of tables
 
1504     if ($form->{lastsort} eq $form->{sort}) {
 
1505       if ($form->{revers} == 0) {
 
1506         $form->{revers} = 1;
 
1508         $form->{revers} = 0;
 
1511       $form->{revers} == 0;
 
1512       $form->{lastsort} = $form->{sort};
 
1517     "$form->{script}?action=generate_report&path=$form->{path}&login=$form->{login}&password=$form->{password}&searchitems=$form->{searchitems}&itemstatus=$form->{itemstatus}&bom=$form->{bom}&l_linetotal=$form->{l_linetotal}&title="
 
1518     . $form->escape($form->{title}, 1);
 
1520   # if we have a serialnumber limit search
 
1521   if ($form->{serialnumber} || $form->{l_serialnumber}) {
 
1522     $form->{l_serialnumber} = "Y";
 
1523     unless (   $form->{bought}
 
1526             || $form->{quoted}) {
 
1527       $form->{bought} = $form->{sold} = 1;
 
1531   IC->all_parts(\%myconfig, \%$form);
 
1533   if ($form->{itemstatus} eq 'active') {
 
1534     $option .= $locale->text('Active') . " : ";
 
1536   if ($form->{itemstatus} eq 'obsolete') {
 
1537     $option .= $locale->text('Obsolete') . " : ";
 
1539   if ($form->{itemstatus} eq 'orphaned') {
 
1540     $option .= $locale->text('Orphaned') . " : ";
 
1542   if ($form->{itemstatus} eq 'onhand') {
 
1543     $option .= $locale->text('On Hand') . " : ";
 
1544     $form->{l_onhand} = "Y";
 
1546   if ($form->{itemstatus} eq 'short') {
 
1547     $option .= $locale->text('Short') . " : ";
 
1548     $form->{l_onhand} = "Y";
 
1550   if ($form->{onorder}) {
 
1551     $form->{l_ordnumber} = "Y";
 
1552     $callback .= "&onorder=$form->{onorder}";
 
1553     $option   .= $locale->text('On Order') . " : ";
 
1555   if ($form->{ordered}) {
 
1556     $form->{l_ordnumber} = "Y";
 
1557     $callback .= "&ordered=$form->{ordered}";
 
1558     $option   .= $locale->text('Ordered') . " : ";
 
1561     $form->{l_quonumber} = "Y";
 
1562     $callback .= "&rfq=$form->{rfq}";
 
1563     $option   .= $locale->text('RFQ') . " : ";
 
1565   if ($form->{quoted}) {
 
1566     $form->{l_quonumber} = "Y";
 
1567     $callback .= ""ed=$form->{quoted}";
 
1568     $option   .= $locale->text('Quoted') . " : ";
 
1570   if ($form->{bought}) {
 
1571     $form->{l_invnumber} = "Y";
 
1572     $callback .= "&bought=$form->{bought}";
 
1573     $option   .= $locale->text('Bought') . " : ";
 
1575   if ($form->{sold}) {
 
1576     $form->{l_invnumber} = "Y";
 
1577     $callback .= "&sold=$form->{sold}";
 
1578     $option   .= $locale->text('Sold') . " : ";
 
1580   if (   $form->{bought}
 
1585       || $form->{quoted}) {
 
1587     $form->{l_lastcost} = "";
 
1588     $form->{l_name}     = "Y";
 
1589     if ($form->{transdatefrom}) {
 
1590       $callback .= "&transdatefrom=$form->{transdatefrom}";
 
1592         . $locale->text('From')
 
1594         . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
 
1596     if ($form->{transdateto}) {
 
1597       $callback .= "&transdateto=$form->{transdateto}";
 
1599         . $locale->text('To')
 
1601         . $locale->date(\%myconfig, $form->{transdateto}, 1);
 
1607   if ($form->{partnumber}) {
 
1608     $callback .= "&partnumber=$form->{partnumber}";
 
1609     $option   .= $locale->text('Part Number') . qq| : $form->{partnumber}<br>|;
 
1611   if ($form->{partsgroup}) {
 
1612     $callback .= "&partsgroup=$form->{partsgroup}";
 
1613     $option   .= $locale->text('Group') . qq| : $form->{partsgroup}<br>|;
 
1615   if ($form->{serialnumber}) {
 
1616     $callback .= "&serialnumber=$form->{serialnumber}";
 
1618       $locale->text('Serial Number') . qq| : $form->{serialnumber}<br>|;
 
1620   if ($form->{description}) {
 
1621     $callback .= "&description=$form->{description}";
 
1622     $description = $form->{description};
 
1626       $locale->text('Part Description') . qq| : $form->{description}<br>|;
 
1628   if ($form->{make}) {
 
1629     $callback .= "&make=$form->{make}";
 
1630     $option   .= $locale->text('Make') . qq| : $form->{make}<br>|;
 
1632   if ($form->{model}) {
 
1633     $callback .= "&model=$form->{model}";
 
1634     $option   .= $locale->text('Model') . qq| : $form->{model}<br>|;
 
1636   if ($form->{drawing}) {
 
1637     $callback .= "&drawing=$form->{drawing}";
 
1638     $option   .= $locale->text('Drawing') . qq| : $form->{drawing}<br>|;
 
1640   if ($form->{microfiche}) {
 
1641     $callback .= "µfiche=$form->{microfiche}";
 
1642     $option   .= $locale->text('Microfiche') . qq| : $form->{microfiche}<br>|;
 
1645   # table soldtotal aktive
 
1646   if ($form->{l_soldtotal}) {
 
1647     $callback .= "&soldtotal=$form->{soldtotal}";
 
1648     $option   .= $locale->text('soldtotal') . qq| : $form->{soldtotal}<br>|;
 
1651   if ($form->{l_deliverydate}) {
 
1652     $callback .= "&deliverydate=$form->{deliverydate}";
 
1655   @columns = $form->sort_columns(
 
1656     qw(partnumber description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal deliverydate)
 
1659   if ($form->{l_linetotal}) {
 
1660     $form->{l_onhand} = "Y";
 
1661     $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
 
1662     if ($form->{l_lastcost}) {
 
1663       $form->{l_linetotallastcost} = "Y";
 
1664       if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
 
1665         $form->{l_linetotallastcost} = "";
 
1668     $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
 
1671   if ($form->{searchitems} eq 'service') {
 
1673     # remove bin, weight and rop from list
 
1674     map { $form->{"l_$_"} = "" } qw(bin weight rop);
 
1676     $form->{l_onhand} = "";
 
1678     # qty is irrelevant unless bought or sold
 
1679     if (   $form->{bought}
 
1684         || $form->{quoted}) {
 
1685       $form->{l_onhand} = "Y";
 
1687       $form->{l_linetotalsellprice} = "";
 
1688       $form->{l_linetotallastcost}  = "";
 
1692   $form->{l_lastcost} = ""
 
1693     if ($form->{searchitems} eq 'assembly' && !$form->{bom});
 
1695   foreach $item (@columns) {
 
1696     if ($form->{"l_$item"} eq "Y") {
 
1697       push @column_index, $item;
 
1699       # add column to callback
 
1700       $callback .= "&l_$item=Y";
 
1704   if ($form->{l_subtotal} eq 'Y') {
 
1705     $callback .= "&l_subtotal=Y";
 
1707   $column_header{partnumber} =
 
1708     qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1709     . $locale->text('Part Number')
 
1711   $column_header{description} =
 
1712     qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1713     . $locale->text('Part Description')
 
1715   $column_header{partsgroup} =
 
1716       qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|
 
1717     . $locale->text('Group')
 
1719   $column_header{bin} =
 
1720       qq|<th><a class=listheading href=$callback&sort=bin>|
 
1721     . $locale->text('Bin')
 
1723   $column_header{priceupdate} =
 
1724       qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|
 
1725     . $locale->text('Updated')
 
1727   $column_header{onhand} =
 
1728     qq|<th nowrap><a  class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1729     . $locale->text('Qty')
 
1731   $column_header{unit} =
 
1732     qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
 
1733   $column_header{listprice} =
 
1734       qq|<th class=listheading nowrap>|
 
1735     . $locale->text('List Price')
 
1737   $column_header{lastcost} =
 
1738     qq|<th class=listheading nowrap>| . $locale->text('Last Cost') . qq|</th>|;
 
1739   $column_header{rop} =
 
1740     qq|<th class=listheading nowrap>| . $locale->text('ROP') . qq|</th>|;
 
1741   $column_header{weight} =
 
1742     qq|<th class=listheading nowrap>| . $locale->text('Weight') . qq|</th>|;
 
1744   $column_header{invnumber} =
 
1745       qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|
 
1746     . $locale->text('Invoice Number')
 
1748   $column_header{ordnumber} =
 
1749       qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|
 
1750     . $locale->text('Order Number')
 
1752   $column_header{quonumber} =
 
1753       qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|
 
1754     . $locale->text('Quotation')
 
1757   $column_header{name} =
 
1758       qq|<th nowrap><a class=listheading href=$callback&sort=name>|
 
1759     . $locale->text('Name')
 
1762   $column_header{sellprice} =
 
1763       qq|<th class=listheading nowrap>|
 
1764     . $locale->text('Sell Price')
 
1766   $column_header{linetotalsellprice} =
 
1767     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1768   $column_header{linetotallastcost} =
 
1769     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1770   $column_header{linetotallistprice} =
 
1771     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1773   $column_header{image} =
 
1774     qq|<th class=listheading nowrap>| . $locale->text('Image') . qq|</a></th>|;
 
1775   $column_header{drawing} =
 
1776       qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|
 
1777     . $locale->text('Drawing')
 
1779   $column_header{microfiche} =
 
1780       qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|
 
1781     . $locale->text('Microfiche')
 
1784   $column_header{serialnumber} =
 
1785       qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|
 
1786     . $locale->text('Serial Number')
 
1788   $column_header{soldtotal} =
 
1789     qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1790     . $locale->text('soldtotal')
 
1793   $column_header{deliverydate} =
 
1794     qq|<th nowrap><a class=listheading href=$callback&sort=deliverydate&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1795     . $locale->text('deliverydate')
 
1799   $colspan = $#column_index + 1;
 
1806     <th class=listtop colspan=$colspan>$form->{title}</th>
 
1808   <tr height="5"></tr>
 
1810   <tr><td colspan=$colspan>$option</td></tr>
 
1812   <tr class=listheading>
 
1815   map { print "\n$column_header{$_}" } @column_index;
 
1821   # add order to callback
 
1822   $form->{callback} = $callback .= "&sort=$form->{sort}";
 
1824   # escape callback for href
 
1825   $callback = $form->escape($callback);
 
1827   if (@{ $form->{parts} }) {
 
1828     $sameitem = $form->{parts}->[0]->{ $form->{sort} };
 
1831   foreach $ref (@{ $form->{parts} }) {
 
1833     if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
 
1834       if ($sameitem ne $ref->{ $form->{sort} }) {
 
1836         $sameitem = $ref->{ $form->{sort} };
 
1840     $ref->{exchangerate} = 1 unless $ref->{exchangerate};
 
1841     $ref->{sellprice} *= $ref->{exchangerate};
 
1842     $ref->{listprice} *= $ref->{exchangerate};
 
1843     $ref->{lastcost}  *= $ref->{exchangerate};
 
1845     # use this for assemblies
 
1846     $onhand = $ref->{onhand};
 
1849     if ($ref->{assemblyitem}) {
 
1851       $onhand = 0 if ($form->{sold});
 
1854     $ref->{description} =~ s/
 
1857     $column_data{partnumber} =
 
1858       "<td align=$align><a href=$form->{script}?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{partnumber} </a></td>";
 
1859     $column_data{description} = "<td><a href=$form->{script}?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description} </a></td>";
 
1860     $column_data{partsgroup}  = "<td>$ref->{partsgroup} </td>";
 
1862     $column_data{onhand} =
 
1864       . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
 
1866     $column_data{sellprice} =
 
1868       . $form->format_amount(\%myconfig, $ref->{sellprice}, 2, " ")
 
1870     $column_data{listprice} =
 
1872       . $form->format_amount(\%myconfig, $ref->{listprice}, 2, " ")
 
1874     $column_data{lastcost} =
 
1876       . $form->format_amount(\%myconfig, $ref->{lastcost}, 2, " ")
 
1879     $column_data{linetotalsellprice} = "<td align=right>"
 
1880       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice},
 
1883     $column_data{linetotallastcost} = "<td align=right>"
 
1884       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost},
 
1887     $column_data{linetotallistprice} = "<td align=right>"
 
1888       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice},
 
1892     if (!$ref->{assemblyitem}) {
 
1893       $totalsellprice += $onhand * $ref->{sellprice};
 
1894       $totallastcost  += $onhand * $ref->{lastcost};
 
1895       $totallistprice += $onhand * $ref->{listprice};
 
1897       $subtotalonhand    += $onhand;
 
1898       $subtotalsellprice += $onhand * $ref->{sellprice};
 
1899       $subtotallastcost  += $onhand * $ref->{lastcost};
 
1900       $subtotallistprice += $onhand * $ref->{listprice};
 
1905       . $form->format_amount(\%myconfig, $ref->{rop}, '', " ") . "</td>";
 
1906     $column_data{weight} =
 
1908       . $form->format_amount(\%myconfig, $ref->{weight}, '', " ")
 
1910     $column_data{unit}        = "<td>$ref->{unit} </td>";
 
1911     $column_data{bin}         = "<td>$ref->{bin} </td>";
 
1912     $column_data{priceupdate} = "<td>$ref->{priceupdate} </td>";
 
1914     $column_data{invnumber} =
 
1915       ($ref->{module} ne 'oe')
 
1916       ? "<td><a href=$ref->{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}</a></td>"
 
1917       : "<td>$ref->{invnumber}</td>";
 
1918     $column_data{ordnumber} =
 
1919       ($ref->{module} eq 'oe')
 
1920       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber}</a></td>"
 
1921       : "<td>$ref->{ordnumber}</td>";
 
1922     $column_data{quonumber} =
 
1923       ($ref->{module} eq 'oe' && !$ref->{ordnumber})
 
1924       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber}</a></td>"
 
1925       : "<td>$ref->{quonumber}</td>";
 
1927     $column_data{name} = "<td>$ref->{name}</td>";
 
1929     $column_data{image} =
 
1931       ? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>"
 
1932       : "<td> </td>";
 
1933     $column_data{drawing} =
 
1935       ? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>"
 
1936       : "<td> </td>";
 
1937     $column_data{microfiche} =
 
1938       ($ref->{microfiche})
 
1939       ? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>"
 
1940       : "<td> </td>";
 
1942     $column_data{serialnumber} = "<td>$ref->{serialnumber}</td>";
 
1944     $column_data{soldtotal} =
 
1946       . $form->format_amount(\%myconfig, $ref->{soldtotal}, '', " ")
 
1949     $column_data{deliverydate} = "<td>$ref->{deliverydate}</td>";
 
1953     print "<tr class=listrow$i>";
 
1955     map { print "\n$column_data{$_}" } @column_index;
 
1963   if ($form->{l_subtotal} eq 'Y') {
 
1967   if ($form->{"l_linetotal"}) {
 
1968     map { $column_data{$_} = "<td> </td>" } @column_index;
 
1969     $column_data{linetotalsellprice} =
 
1970         "<th class=listtotal align=right>"
 
1971       . $form->format_amount(\%myconfig, $totalsellprice, 2, " ")
 
1973     $column_data{linetotallastcost} =
 
1974         "<th class=listtotal align=right>"
 
1975       . $form->format_amount(\%myconfig, $totallastcost, 2, " ")
 
1977     $column_data{linetotallistprice} =
 
1978         "<th class=listtotal align=right>"
 
1979       . $form->format_amount(\%myconfig, $totallistprice, 2, " ")
 
1982     print "<tr class=listtotal>";
 
1984     map { print "\n$column_data{$_}" } @column_index;
 
1991   <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
 
2000 <form method=post action=$form->{script}>
 
2002 <input name=callback type=hidden value="$form->{callback}">
 
2004 <input type=hidden name=item value=$form->{searchitems}>
 
2006 <input type=hidden name=path value=$form->{path}>
 
2007 <input type=hidden name=login value=$form->{login}>
 
2008 <input type=hidden name=password value=$form->{password}>|;
 
2011   <input class=submit type=submit name=action value="|
 
2012     . $locale->text('Add') . qq|">|;
 
2014   if ($form->{menubar}) {
 
2015     require "$form->{path}/menu.pl";
 
2026   $lxdebug->leave_sub();
 
2027 }    #end generate_report
 
2029 sub parts_subtotal {
 
2030   $lxdebug->enter_sub();
 
2032   map { $column_data{$_} = "<td> </td>" } @column_index;
 
2033   $subtotalonhand = 0 if ($form->{searchitems} eq 'assembly' && $form->{bom});
 
2035   $column_data{onhand} =
 
2036       "<th class=listsubtotal align=right>"
 
2037     . $form->format_amount(\%myconfig, $subtotalonhand, '', " ")
 
2040   $column_data{linetotalsellprice} =
 
2041       "<th class=listsubtotal align=right>"
 
2042     . $form->format_amount(\%myconfig, $subtotalsellprice, 2, " ")
 
2044   $column_data{linetotallistprice} =
 
2045       "<th class=listsubtotal align=right>"
 
2046     . $form->format_amount(\%myconfig, $subtotallistprice, 2, " ")
 
2048   $column_data{linetotallastcost} =
 
2049       "<th class=listsubtotal align=right>"
 
2050     . $form->format_amount(\%myconfig, $subtotallastcost, 2, " ")
 
2053   $subtotalonhand    = 0;
 
2054   $subtotalsellprice = 0;
 
2055   $subtotallistprice = 0;
 
2056   $subtotallastcost  = 0;
 
2058   print "<tr class=listsubtotal>";
 
2060   map { print "\n$column_data{$_}" } @column_index;
 
2066   $lxdebug->leave_sub();
 
2070   $lxdebug->enter_sub();
 
2072   IC->get_part(\%myconfig, \%$form);
 
2074   $form->{title} = $locale->text('Edit ' . ucfirst $form->{item});
 
2079   $lxdebug->leave_sub();
 
2083   $lxdebug->enter_sub();
 
2085   IC->create_links("IC", \%myconfig, \%$form);
 
2088   map { $form->{selectcurrency} .= "<option>$_\n" } split /:/,
 
2089     $form->{currencies};
 
2091   # parts and assemblies have the same links
 
2092   $item = $form->{item};
 
2093   if ($form->{item} eq 'assembly') {
 
2097   # build the popup menus
 
2098   $form->{taxaccounts} = "";
 
2099   foreach $key (keys %{ $form->{IC_links} }) {
 
2100     foreach $ref (@{ $form->{IC_links}{$key} }) {
 
2102       # if this is a tax field
 
2103       if ($key =~ /IC_tax/) {
 
2104         if ($key =~ /$item/) {
 
2105           $form->{taxaccounts} .= "$ref->{accno} ";
 
2106           $form->{"IC_tax_$ref->{accno}_description"} =
 
2107             "$ref->{accno}--$ref->{description}";
 
2110             if ($form->{amount}{ $ref->{accno} }) {
 
2111               $form->{"IC_tax_$ref->{accno}"} = "checked";
 
2114             $form->{"IC_tax_$ref->{accno}"} = "checked";
 
2119         $form->{"select$key"} .=
 
2120           "<option $ref->{selected}>$ref->{accno}--$ref->{description}\n";
 
2121         if ($form->{amount}{$key} eq $ref->{accno}) {
 
2122           $form->{$key} = "$ref->{accno}--$ref->{description}";
 
2128   chop $form->{taxaccounts};
 
2130   if (($form->{item} eq "part") || ($form->{item} eq "assembly")) {
 
2131     $form->{selectIC_income}  = $form->{selectIC_sale};
 
2132     $form->{selectIC_expense} = $form->{selectIC_cogs};
 
2133     $form->{IC_income}        = $form->{IC_sale};
 
2134     $form->{IC_expense}       = $form->{IC_cogs};
 
2137   delete $form->{IC_links};
 
2138   delete $form->{amount};
 
2140   $form->get_partsgroup(\%myconfig, { all => 1 });
 
2142   $form->{partsgroup} = "$form->{partsgroup}--$form->{partsgroup_id}";
 
2144   if (@{ $form->{all_partsgroup} }) {
 
2145     $form->{selectpartsgroup} = qq|<option>\n|;
 
2147       $form->{selectpartsgroup} .=
 
2148         qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n|
 
2149     } @{ $form->{all_partsgroup} };
 
2152   if ($form->{item} eq 'assembly') {
 
2154     foreach $i (1 .. $form->{assembly_rows}) {
 
2155       if ($form->{"partsgroup_id_$i"}) {
 
2156         $form->{"partsgroup_$i"} =
 
2157           qq|$form->{"partsgroup_$i"}--$form->{"partsgroup_id_$i"}|;
 
2160     $form->get_partsgroup(\%myconfig);
 
2162     if (@{ $form->{all_partsgroup} }) {
 
2163       $form->{selectassemblypartsgroup} = qq|<option>\n|;
 
2166         $form->{selectassemblypartsgroup} .=
 
2167           qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n|
 
2168       } @{ $form->{all_partsgroup} };
 
2171   $lxdebug->leave_sub();
 
2175   $lxdebug->enter_sub();
 
2179   #decimalplaces for listprice
 
2180   ($dec) = ($form->{listprice} =~ /\.(\d+)/);
 
2182   my $decimalplaces = ($dec == 2) ? $dec : 2;
 
2183   $form->{listprice} =
 
2184     $form->format_amount(\%myconfig, $form->{listprice}, $decimalplaces);
 
2186   #decimalplaces for sellprice and gv
 
2187   ($dec) = ($form->{sellprice} =~ /\.(\d+)/);
 
2189   my $decimalplaces = ($dec == 2) ? $dec : 2;
 
2193       $form->format_amount(\%myconfig, $form->{$_}, $decimalplaces)
 
2196   ($dec) = ($form->{lastcost} =~ /\.(\d+)/);
 
2198   my $decimalplaces = ($dec == 2) ? $dec : 2;
 
2201     $form->format_amount(\%myconfig, $form->{lastcost}, $decimalplaces);
 
2203   map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}) }
 
2204     qw(weight rop stock);
 
2206   foreach $item (qw(partnumber description unit notes)) {
 
2207     $form->{$item} =~ s/\"/"/g;
 
2210   $payment = qq|<option value=""></option>|;
 
2211   foreach $item (@{ $form->{payment_terms} }) {
 
2212     if ($form->{payment_id} eq $item->{id}) {
 
2213       $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
 
2215       $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
 
2220   if (($rows = $form->numtextrows($form->{notes}, 40)) < 2) {
 
2225     qq|<textarea name=notes rows=$rows cols=50 wrap=soft>$form->{notes}</textarea>|;
 
2226   if (($rows = $form->numtextrows($form->{description}, 40)) > 1) {
 
2228       qq|<textarea name="description" rows=$rows cols=40 wrap=soft>$form->{description}</textarea>|;
 
2231       qq|<input name=description size=40 value="$form->{description}">|;
 
2234   foreach $item (split / /, $form->{taxaccounts}) {
 
2235     $form->{"IC_tax_$item"} = ($form->{"IC_tax_$item"}) ? "checked" : "";
 
2238   IC->retrieve_buchungsgruppen(\%myconfig, $form);
 
2239   if (@{ $form->{BUCHUNGSGRUPPEN} }) {
 
2240     foreach $item (@{ $form->{BUCHUNGSGRUPPEN} }) {
 
2241       if ($item->{id} == $form->{buchungsgruppen_id}) {
 
2242         $form->{selectbuchungsgruppe} .=
 
2243           "<option value=$item->{id} selected>$item->{description}\n";
 
2244       } elsif (($form->{id} && $form->{orphaned}) || (!$form->{id})) {
 
2245         $form->{selectbuchungsgruppe} .=
 
2246           "<option value=$item->{id}>$item->{description}\n";
 
2252   $buchungsgruppe = qq|
 
2254                 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
 
2255                 <td><select name=buchungsgruppen_id>$form->{selectbuchungsgruppe}</select></td>
 
2260   foreach $item (qw(IC IC_income IC_expense)) {
 
2261     if ($form->{$item}) {
 
2262       if ($form->{id} && $form->{orphaned}) {
 
2263         $form->{"select$item"} =~ s/ selected//;
 
2264         $form->{"select$item"} =~
 
2265           s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
 
2267         $form->{"select$item"} = qq|<option selected>$form->{$item}|;
 
2272   if ($form->{selectpartsgroup}) {
 
2273     $form->{selectpartsgroup} = $form->unescape($form->{selectpartsgroup});
 
2275       qq|<input type=hidden name=selectpartsgroup value="|
 
2276       . $form->escape($form->{selectpartsgroup}, 1) . qq|">|;
 
2277     $form->{selectpartsgroup} =~
 
2278       s/(<option value="\Q$form->{partsgroup}\E")/$1 selected/;
 
2281       qq|<select name=partsgroup>$form->{selectpartsgroup}</select>|;
 
2282     $group = $locale->text('Group');
 
2286   foreach $item (split / /, $form->{taxaccounts}) {
 
2288       <input class=checkbox type=checkbox name="IC_tax_$item" value=1 $form->{"IC_tax_$item"}> <b>$form->{"IC_tax_${item}_description"}</b>
 
2289       <br><input type=hidden name=IC_tax_${item}_description value="$form->{"IC_tax_${item}_description"}">
 
2293   $form->{obsolete} = "checked" if $form->{obsolete};
 
2297                 <th align="right" nowrap="true">|
 
2298     . $locale->text('Last Cost') . qq|</th>
 
2299                 <td><input name=lastcost size=11 value=$form->{lastcost}></td>
 
2305                 <th align=right>| . $locale->text('Inventory') . qq|</th>
 
2306                 <td><select name=IC>$form->{selectIC}</select></td>
 
2307                 <input name=selectIC type=hidden value="$form->{selectIC}">
 
2311   if ($form->{item} eq "part") {
 
2313     $linkaccounts .= qq|
 
2315                 <th align=right>| . $locale->text('Revenue') . qq|</th>
 
2316                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
 
2317                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
 
2320                 <th align=right>| . $locale->text('Expense') . qq|</th>
 
2321                 <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
 
2322                 <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
 
2328                 <th align="right" nowrap="true">| . $locale->text('Weight') . qq|</th>
 
2333                         <input name=weight size=10 value=$form->{weight}>
 
2338                         <input type=hidden name=weightunit value=$form->{weightunit}>
 
2348   if ($form->{item} eq "assembly") {
 
2354                 <th align=right>| . $locale->text('Revenue') . qq|</th>
 
2355                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
 
2356                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
 
2362                 <th align="right" nowrap="true">| . $locale->text('Weight') . qq|</th>
 
2367                          $form->{weight}
 
2368                         <input type=hidden name=weight value=$form->{weight}>
 
2373                         <input type=hidden name=weightunit value=$form->{weightunit}>
 
2383   if ($form->{item} eq "service") {
 
2387                 <th align=right>| . $locale->text('Revenue') . qq|</th>
 
2388                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
 
2389                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
 
2392                 <th align=right>| . $locale->text('Expense') . qq|</th>
 
2393                 <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
 
2394                 <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
 
2399   $linkaccounts = qq|<input type=hidden name=IC_income value="$form->{IC_income_default}">|;
 
2401   if ($form->{IC_cogs_default}) {
 
2402     $form->{IC_expense_default} = $form->{IC_cogs_default};
 
2405   if (($form->{item} eq "service") || ($form->{item} eq "part")) {
 
2406     $linkaccounts .= qq|<input type=hidden name=IC_expense value="$form->{IC_expense_default}">|;
 
2408   if ($form->{item} eq "part") {
 
2409     $linkaccounts .= qq|<input type=hidden name=IC value="$form->{IC_default}">|;
 
2412   if ($form->{item} ne 'service') {
 
2413     $n   = ($form->{onhand} > 0) ? "1" : "0";
 
2416                 <th align="right" nowrap>| . $locale->text('On Hand') . qq|</th>
 
2417                 <th align=left nowrap class="plus$n"> |
 
2418       . $form->format_amount(\%myconfig, $form->{onhand}) . qq|</th>
 
2422     if ($form->{item} eq 'assembly') {
 
2425                 <th align="right" nowrap>| . $locale->text('Stock') . qq|</th>
 
2426                 <td><input name=stock size=10 value=$form->{stock}></td>
 
2433                 <th align="right" nowrap="true">| . $locale->text('ROP') . qq|</th>
 
2434                 <td><input name=rop size=10 value=$form->{rop}></td>
 
2440                 <th align="right" nowrap="true">| . $locale->text('Bin') . qq|</th>
 
2441                 <td><input name=bin size=10 value=$form->{bin}></td>
 
2446                 <th align="right" nowrap="true">|
 
2447       . $locale->text('Verrechnungseinheit') . qq|</th>
 
2448                 <td><input name=ve size=10 value=$form->{ve}></td>
 
2451                 <th align="right" nowrap="true">|
 
2452       . $locale->text('Geschäftsvolumen') . qq|</th>
 
2453                 <td><input name=gv size=10 value=$form->{gv}></td>
 
2456     $notdiscountableok = ($form->{not_discountable}) == 1 ? "checked" : "";
 
2457     $notdiscountable .= qq|
 
2459                 <th align=right nowrap>|
 
2460     . $locale->text('Not Discountable') . qq|</th>
 
2461                 <td><input class=checkbox type=checkbox name=not_discountable value=1 $notdiscountableok></td>
 
2466     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=40 wrap=soft>$form->{formel}</textarea></layer><ilayer>|;
 
2472           <th align=right nowrap>| . $locale->text('Image') . qq|</th>
 
2473           <td><input name=image size=40 value="$form->{image}"></td>
 
2474           <th align=right nowrap>| . $locale->text('Microfiche') . qq|</th>
 
2475           <td><input name=microfiche size=20 value="$form->{microfiche}"></td>
 
2478           <th align=right nowrap>| . $locale->text('Drawing') . qq|</th>
 
2479           <td><input name=drawing size=40 value="$form->{drawing}"></td>
 
2491                 <th align="right" nowrap="true">| . $locale->text('Obsolete') . qq|</th>
 
2492                 <td><input name=obsolete type=checkbox class=checkbox value=1 $form->{obsolete}></td>
 
2496   $shopok = $form->{shop} == 1 ? "checked" : "";
 
2499                 <th align=right nowrap>|
 
2500     . $locale->text('Shopartikel') . qq|</th>
 
2501                 <td><input class=checkbox type=checkbox name=shop value=1 $shopok></td>
 
2506   # type=submit $locale->text('Add Part')
 
2507   # type=submit $locale->text('Add Service')
 
2508   # type=submit $locale->text('Add Assembly')
 
2510   # type=submit $locale->text('Edit Part')
 
2511   # type=submit $locale->text('Edit Service')
 
2512   # type=submit $locale->text('Edit Assembly')
 
2513   # use JavaScript Calendar or not
 
2514   $form->{jsscript} = $jscalendar;
 
2516   if ($form->{jsscript}) {
 
2518     # with JavaScript Calendar
 
2520        <td width="13"><input name=priceupdate id=priceupdate size=11  title="$myconfig{dateformat}" value="$form->{priceupdate}"></td>
 
2521        <td width="4" align="left"><input type=button name=priceupdate id="trigger1" value=|
 
2522       . $locale->text('button') . qq|></td>
 
2527       Form->write_trigger(\%myconfig, "1", "priceupdate", "BL", "trigger1");
 
2530     # without JavaScript Calendar
 
2532                               <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
 
2535   my $unit_select = '<input type="hidden" name="unit_changeable" value="' . $form->{"unit_changeable"} . '">';
 
2536   if (!$form->{"unit_changeable"}) {
 
2537     $unit_select .= '<input type="hidden" name="unit" value="' . $form->{"unit"} . '">' . $form->{"unit"};
 
2539     my $units = AM->retrieve_units(\%myconfig, $form, $form->{"item"} eq "service" ? "service" : "dimension");
 
2540     $unit_select .= AM->unit_select_html($units, "unit", $form->{"unit"});
 
2543   $form->{fokus} = "ic.partnumber";
 
2547   <body onLoad="fokus()">
 
2548  <script type="text/javascript" src="js/common.js"></script>
 
2549  <script type="text/javascript" src="js/parts_language_selection.js"></script>
 
2551 <form method=post name="ic" action=$form->{script}>
 
2553 <input name=id type=hidden value=$form->{id}>
 
2554 <input name=item type=hidden value=$form->{item}>
 
2555 <input name=title type=hidden value="$form->{title}">
 
2556 <input name=makemodel type=hidden value="$form->{makemodel}">
 
2557 <input name=alternate type=hidden value="$form->{alternate}">
 
2558 <input name=onhand type=hidden value=$form->{onhand}>
 
2559 <input name=orphaned type=hidden value=$form->{orphaned}>
 
2560 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
 
2561 <input name=rowcount type=hidden value=$form->{rowcount}>
 
2562 <input name=eur type=hidden value=$eur>
 
2563 <input name=language_values type=hidden value="$form->{language_values}">
 
2565 <table width="100%">
 
2567     <th class=listtop>$form->{title}</th>
 
2569   <tr height="5"></tr>
 
2572       <table width="100%">
 
2574           <th align=left>| . $locale->text('Part Number') . qq|</th>
 
2575           <th align=left>| . $locale->text('Part Description') . qq|</th>
 
2576           <th align=left>$group</th>
 
2579           <td><input name=partnumber value="$form->{partnumber}" size=20></td>
 
2580           <td>$description</td>
 
2581           <td>$partsgroup</td>
 
2582           <input type=hidden name=oldpartsgroup value="$form->{oldpartsgroup}">
 
2589       <table width="100%" height="100%">
 
2592             <table width="100%" height="100%">
 
2593               <tr class="listheading">
 
2594                 <th class="listheading" align="center" colspan=2>|
 
2595     . $locale->text('') . qq|</th>
 
2604                 <th align="left">| . $locale->text('Notes') . qq|</th>
 
2605                 <th align="left">| . $locale->text('Formula') . qq|</th>
 
2617                   <button type="button" onclick="parts_language_selection_window('language_values')">| . $locale->text('Set Language Values') . qq|</button>
 
2624                <th align=right>| . $locale->text('Payment Terms') . qq|</th>
 
2625                  <td><select name=payment_id>$payment</select></td>
 
2633             <table width="100%">
 
2635                 <th align="right" nowrap="true">|
 
2636     . $locale->text('Updated') . qq|</th>
 
2640                 <th align="right" nowrap="true">| . $locale->text('List Price') . qq|</th>
 
2641                 <td><input name=listprice size=11 value=$form->{listprice}></td>
 
2644                 <th align="right" nowrap="true">| . $locale->text('Sell Price') . qq|</th>
 
2645                 <td><input name=sellprice size=11 value=$form->{sellprice}></td>
 
2649                 <th align="right" nowrap="true">| . $locale->text('Unit') . qq|</th>
 
2650                 <td>$unit_select</td>
 
2669   $lxdebug->leave_sub();
 
2673   $lxdebug->enter_sub();
 
2675   if ($form->{item} eq "assembly") {
 
2680             <table width="100%">
 
2682                 <th colspan=2 align=right>|
 
2683       . $locale->text('Total') . qq| </th>
 
2685       . $form->format_amount(\%myconfig, $form->{assemblytotal}, 2) . qq|</th>
 
2690         <input type=hidden name=assembly_rows value=$form->{assembly_rows}>
 
2695       <input type=hidden name=path value=$form->{path}>
 
2696       <input type=hidden name=login value=$form->{login}>
 
2697       <input type=hidden name=password value=$form->{password}>
 
2698       <input type=hidden name=callback value="$form->{callback}">
 
2699       <input type=hidden name=previousform value="$form->{previousform}">
 
2700       <input type=hidden name=taxaccount2 value="$form->{taxaccount2}">
 
2701       <input type=hidden name=vc value=$form->{vc}>
 
2703     <td><hr size=3 noshade></td>
 
2708 <input class=submit type=submit name=action value="|
 
2709     . $locale->text('Update') . qq|">
 
2712   unless ($form->{item} eq "service") {
 
2714       <input type=hidden name=makemodel_rows value=$form->{makemodel_rows}>
 
2719      <input type=hidden name=price_rows value=$form->{price_rows}>|;
 
2722       <input class=submit type=submit name=action value="|
 
2723     . $locale->text('Save') . qq|">|;
 
2727     if (!$form->{previousform}) {
 
2729       <input class=submit type=submit name=action value="|
 
2730         . $locale->text('Save as new') . qq|">|;
 
2733     if ($form->{orphaned}) {
 
2734       if (!$form->{previousform}) {
 
2735         if ($form->{item} eq 'assembly') {
 
2736           if (!$form->{onhand}) {
 
2738       <input class=submit type=submit name=action value="|
 
2739               . $locale->text('Delete') . qq|">|;
 
2743       <input class=submit type=submit name=action value="|
 
2744             . $locale->text('Delete') . qq|">|;
 
2750   if (!$form->{previousform}) {
 
2751     if ($form->{menubar}) {
 
2752       require "$form->{path}/menu.pl";
 
2760 <script type="text/javascript" src="js/wz_tooltip.js"></script>
 
2766   $lxdebug->leave_sub();
 
2770   $lxdebug->enter_sub();
 
2773   $form->{"make_$i"}  =~ s/\"/"/g;
 
2774   $form->{"model_$i"} =~ s/\"/"/g;
 
2781           <th class="listheading">| . $locale->text('Make') . qq|</th>
 
2782           <th class="listheading">| . $locale->text('Model') . qq|</th>
 
2786   for $i (1 .. $numrows) {
 
2789           <td width=50%><input name="make_$i" size=30 value="$form->{"make_$i"}"></td>
 
2790           <td width=50%><input name="model_$i" size=30 value="$form->{"model_$i"}"></td>
 
2801   $lxdebug->leave_sub();
 
2805   $lxdebug->enter_sub();
 
2809     qw(runningnumber qty unit bom partnumber description partsgroup total);
 
2811   if ($form->{previousform}) {
 
2813     @column_index = qw(qty unit bom partnumber description partsgroup total);
 
2817     $form->{old_callback} = $form->{callback};
 
2818     $callback             = $form->{callback};
 
2819     $form->{callback}     = "$form->{script}?action=display_form";
 
2822     map { delete $form->{$_} } qw(action header);
 
2826     # save form variables in a previousform variable
 
2827     foreach $key (sort keys %$form) {
 
2830       $form->{$key} =~ s/&/%26/g;
 
2831       $previousform .= qq|$key=$form->{$key}&|;
 
2834     $previousform = $form->escape($form->escape($previousform, 1));
 
2835     $form->{callback} = $callback;
 
2837     $form->{assemblytotal} = 0;
 
2838     $form->{weight}        = 0;
 
2841   $column_header{runningnumber} =
 
2842     qq|<th nowrap width=5%>| . $locale->text('No.') . qq|</th>|;
 
2843   $column_header{qty} =
 
2844     qq|<th align=left nowrap width=10%>| . $locale->text('Qty') . qq|</th>|;
 
2845   $column_header{unit} =
 
2846     qq|<th align=left nowrap width=5%>| . $locale->text('Unit') . qq|</th>|;
 
2847   $column_header{partnumber} =
 
2848       qq|<th align=left nowrap width=20%>|
 
2849     . $locale->text('Part Number')
 
2851   $column_header{description} =
 
2852     qq|<th nowrap width=50%>| . $locale->text('Part Description') . qq|</th>|;
 
2853   $column_header{total} =
 
2854     qq|<th align=right nowrap>| . $locale->text('Extended') . qq|</th>|;
 
2855   $column_header{bom}        = qq|<th>| . $locale->text('BOM') . qq|</th>|;
 
2856   $column_header{partsgroup} = qq|<th>| . $locale->text('Group') . qq|</th>|;
 
2859   <tr class=listheading>
 
2860     <th class=listheading>| . $locale->text('Individual Items') . qq|</th>
 
2868   map { print "\n$column_header{$_}" } @column_index;
 
2874   for $i (1 .. $numrows) {
 
2875     $form->{"partnumber_$i"} =~ s/\"/"/g;
 
2878       $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
 
2879     $form->{assemblytotal} += $linetotal;
 
2881     $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
 
2883     $linetotal = $form->format_amount(\%myconfig, $linetotal, 2);
 
2885     if (($i >= 1) && ($i == $numrows)) {
 
2888         map { $column_data{$_} = qq|<td></td>| }
 
2889           qw(qty unit partnumber description bom partsgroup);
 
2892         map { $column_data{$_} = qq|<td></td>| } qw(runningnumber unit bom);
 
2895           qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
 
2896         $column_data{partnumber} =
 
2897           qq|<td><input name="partnumber_$i" size=15 value="$form->{"partnumber_$i"}"></td>|;
 
2898         $column_data{description} =
 
2899           qq|<td><input name="description_$i" size=40 value="$form->{"description_$i"}"></td>|;
 
2900         $column_data{partsgroup} =
 
2901           qq|<td><input name="partsgroup_$i" size=10 value="$form->{"partsgroup_$i"}"></td>|;
 
2907       if ($form->{previousform}) {
 
2908         $column_data{partnumber} =
 
2909           qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}">$form->{"partnumber_$i"}</td>|;
 
2911           qq|<td align=right><input type=hidden name="qty_$i" value="$form->{"qty_$i"}">$form->{"qty_$i"}</td>|;
 
2914           qq|<td align=center><input type=hidden name="bom_$i" value=$form->{"bom_$i"}>|;
 
2915         $column_data{bom} .= ($form->{"bom_$i"}) ? "x" : " ";
 
2916         $column_data{bom} .= qq|</td>|;
 
2918         $column_data{partsgroup} =
 
2919           qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
 
2923           qq|$form->{script}?action=edit&id=$form->{"id_$i"}&path=$form->{path}&login=$form->{login}&password=$form->{password}&rowcount=$i&previousform=$previousform|;
 
2924         $column_data{partnumber} =
 
2925           qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"><a href=$href>$form->{"partnumber_$i"}</a></td>|;
 
2926         $column_data{runningnumber} =
 
2927           qq|<td><input name="runningnumber_$i" size=3 value="$i"></td>|;
 
2929           qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
 
2931         $form->{"bom_$i"} = ($form->{"bom_$i"}) ? "checked" : "";
 
2933           qq|<td align=center><input name="bom_$i" type=checkbox class=checkbox value=1 $form->{"bom_$i"}></td>|;
 
2935         $column_data{partsgroup} =
 
2936           qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
 
2939       $column_data{unit} =
 
2940         qq|<td><input type=hidden name="unit_$i" value="$form->{"unit_$i"}">$form->{"unit_$i"}</td>|;
 
2941       $column_data{description} =
 
2942         qq|<td><input type=hidden name="description_$i" value="$form->{"description_$i"}">$form->{"description_$i"}</td>|;
 
2945     $column_data{total} = qq|<td align=right>$linetotal</td>|;
 
2947     $column_data{deliverydate} = qq|<td align=right>$deliverydate</td>|;
 
2952     map { print "\n$column_data{$_}" } @column_index;
 
2956   <input type=hidden name="id_$i" value=$form->{"id_$i"}>
 
2957   <input type=hidden name="sellprice_$i" value=$form->{"sellprice_$i"}>
 
2958   <input type=hidden name="weight_$i" value=$form->{"weight_$i"}>
 
2968   $lxdebug->leave_sub();
 
2972   $lxdebug->enter_sub();
 
2974   if ($form->{item} eq "assembly") {
 
2975     $i = $form->{assembly_rows};
 
2977     # if last row is empty check the form otherwise retrieve item
 
2978     if (   ($form->{"partnumber_$i"} eq "")
 
2979         && ($form->{"description_$i"} eq "")
 
2980         && ($form->{"partsgroup_$i"}  eq "")) {
 
2986       IC->assembly_item(\%myconfig, \%$form);
 
2988       $rows = scalar @{ $form->{item_list} };
 
2991         $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
 
2994           $form->{makemodel_rows}--;
 
2998           map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
 
2999             qw(partnumber description unit partsgroup);
 
3000           map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
 
3001             keys %{ $form->{item_list}[0] };
 
3002           $form->{"runningnumber_$i"} = $form->{assembly_rows};
 
3003           $form->{assembly_rows}++;
 
3011         $form->{rowcount} = $i;
 
3012         $form->{assembly_rows}++;
 
3020   if ($form->{item} eq "part") {
 
3024   if ($form->{item} eq 'service') {
 
3025     map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
3026       qw(sellprice listprice);
 
3032   $lxdebug->leave_sub();
 
3036   $lxdebug->enter_sub();
 
3038   # check if there is a part number - commented out, cause there is an automatic allocation of numbers
 
3039   # $form->isblank("partnumber", $locale->text(ucfirst $form->{item}." Part Number missing!"));
 
3041   # check if there is a description
 
3042   $form->isblank("description", $locale->text("Part Description missing!"));
 
3044   if ($form->{obsolete}) {
 
3047         "Inventory quantity must be zero before you can set this $form->{item} obsolete!"
 
3049       if ($form->{onhand});
 
3052   if (!$form->{buchungsgruppen_id}) {
 
3053     $form->error($locale->text("Parts must have an entry type.") . " " . 
 
3054      $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.") 
 
3058   $form->error($locale->text('Description must not be empty!')) unless $form->{description};
 
3059   $form->error($locale->text('Partnumber must not be set to empty!')) if $form->{id} && !$form->{partnumber};
 
3061   # expand dynamic strings
 
3062   # $locale->text('Inventory quantity must be zero before you can set this part obsolete!')
 
3063   # $locale->text('Inventory quantity must be zero before you can set this assembly obsolete!')
 
3064   # $locale->text('Part Number missing!')
 
3065   # $locale->text('Service Number missing!')
 
3066   # $locale->text('Assembly Number missing!')
 
3069   $lxdebug->message(LXDebug::DEBUG1,
 
3070                     "ic.pl: sellprice in save = $form->{sellprice}\n");
 
3071   $rc = IC->save(\%myconfig, \%$form);
 
3073     $form->error($locale->text('Partnumber not unique!'));
 
3075   $parts_id = $form->{id};
 
3077   # load previous variables
 
3078   if ($form->{previousform}) {
 
3080     # save the new form variables before splitting previousform
 
3081     map { $newform{$_} = $form->{$_} } keys %$form;
 
3083     $previousform = $form->unescape($form->{previousform});
 
3085     # don't trample on previous variables
 
3086     map { delete $form->{$_} } keys %newform;
 
3088     # now take it apart and restore original values
 
3089     foreach $item (split /&/, $previousform) {
 
3090       ($key, $value) = split /=/, $item, 2;
 
3091       $value =~ s/%26/&/g;
 
3092       $form->{$key} = $value;
 
3094     $form->{taxaccounts} = $newform{taxaccount2};
 
3096     if ($form->{item} eq 'assembly') {
 
3098       # undo number formatting
 
3099       map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
3100         qw(weight listprice sellprice rop);
 
3102       $form->{assembly_rows}--;
 
3103       $i = $newform{rowcount};
 
3104       $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
 
3106       $form->{sellprice} -= $form->{"sellprice_$i"} * $form->{"qty_$i"};
 
3107       $form->{weight}    -= $form->{"weight_$i"} * $form->{"qty_$i"};
 
3109       # change/add values for assembly item
 
3110       map { $form->{"${_}_$i"} = $newform{$_} }
 
3111         qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno);
 
3113       $form->{sellprice} += $form->{"sellprice_$i"} * $form->{"qty_$i"};
 
3114       $form->{weight}    += $form->{"weight_$i"} * $form->{"qty_$i"};
 
3118       # set values for last invoice/order item
 
3119       $i = $form->{rowcount};
 
3120       $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
 
3122       map { $form->{"${_}_$i"} = $newform{$_} }
 
3123         qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice);
 
3124       $form->{"sellprice_$i"} = $newform{lastcost} if ($form->{vendor_id});
 
3125       if ($form->{exchangerate} != 0) {
 
3126         $form->{"sellprice_$i"} /= $form->{exchangerate};
 
3128       $lxdebug->message(LXDebug::DEBUG1,
 
3129                         qq|sellprice_$i in previousform 2 = |
 
3130                           . $form->{"sellprice_$i"} . qq|\n|);
 
3131       map { $form->{"taxaccounts_$i"} .= "$_ " } split / /,
 
3132         $newform{taxaccount};
 
3133       chop $form->{"taxaccounts_$i"};
 
3134       foreach $item (qw(description rate taxnumber)) {
 
3135         $index = $form->{"taxaccounts_$i"} . "_$item";
 
3136         $form->{$index} = $newform{$index};
 
3139       # credit remaining calculation
 
3141         $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
 
3143       map { $form->{"${_}_base"} += $amount }
 
3144         (split / /, $form->{"taxaccounts_$i"});
 
3145       map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
 
3146         split / /, $form->{"taxaccounts_$i"}
 
3147         if !$form->{taxincluded};
 
3149       $form->{creditremaining} -= $amount;
 
3151       # redo number formatting, because invoice parse them!
 
3152       $i = $form->{rowcount};
 
3154         $form->{"${_}_$i"} =
 
3155           $form->format_amount(\%myconfig, $form->{"${_}_$i"})
 
3156       } qw(weight listprice sellprice rop);
 
3159     $form->{"id_$i"} = $parts_id;
 
3160     delete $form->{action};
 
3162     # restore original callback
 
3163     $callback = $form->unescape($form->{callback});
 
3164     $form->{callback} = $form->unescape($form->{old_callback});
 
3165     delete $form->{old_callback};
 
3167     $form->{makemodel_rows}--;
 
3169     # put callback together
 
3170     foreach $key (keys %$form) {
 
3172       # do single escape for Apache 2.0
 
3173       $value = $form->escape($form->{$key}, 1);
 
3174       $callback .= qq|&$key=$value|;
 
3176     $form->{callback} = $callback;
 
3178   $lxdebug->message(LXDebug::DEBUG1,
 
3179                     qq|ic.pl: sellprice_$i nach sub save = |
 
3180                       . $form->{"sellprice_$i"} . qq|\n|);
 
3185   $lxdebug->leave_sub();
 
3189   $lxdebug->enter_sub();
 
3192   $form->{partnumber} = "";
 
3195   $lxdebug->leave_sub();
 
3199   $lxdebug->enter_sub();
 
3201   $rc = IC->delete(\%myconfig, \%$form);
 
3204   $form->redirect($locale->text('Item deleted!')) if ($rc > 0);
 
3205   $form->error($locale->text('Cannot delete item!'));
 
3207   $lxdebug->leave_sub();
 
3210 sub stock_assembly {
 
3211   $lxdebug->enter_sub();
 
3213   $form->{title} = $locale->text('Stock Assembly');
 
3220 <form method=post action=$form->{script}>
 
3222 <table width="100%">
 
3224     <th class=listtop>$form->{title}</th>
 
3226   <tr height="5"></tr>
 
3231           <th align="right" nowrap="true">|
 
3232     . $locale->text('Part Number') . qq|</th>
 
3233           <td><input name=partnumber size=20></td>
 
3237           <th align="right" nowrap="true">|
 
3238     . $locale->text('Part Description') . qq|</th>
 
3239           <td><input name=description size=40></td>
 
3244   <tr><td><hr size=3 noshade></td></tr>
 
3247 <input type=hidden name=path value=$form->{path}>
 
3248 <input type=hidden name=login value=$form->{login}>
 
3249 <input type=hidden name=password value=$form->{password}>
 
3251 <input type=hidden name=nextsub value=list_assemblies>
 
3254 <input class=submit type=submit name=action value="|
 
3255     . $locale->text('Continue') . qq|">
 
3262   $lxdebug->leave_sub();
 
3265 sub list_assemblies {
 
3266   $lxdebug->enter_sub();
 
3268   IC->retrieve_assemblies(\%myconfig, \%$form);
 
3270   $column_header{partnumber} =
 
3271     qq|<th class=listheading>| . $locale->text('Part Number') . qq|</th>|;
 
3272   $column_header{description} =
 
3273     qq|<th class=listheading>| . $locale->text('Part Description') . qq|</th>|;
 
3274   $column_header{bin} =
 
3275     qq|<th class=listheading>| . $locale->text('Bin') . qq|</th>|;
 
3276   $column_header{onhand} =
 
3277     qq|<th class=listheading>| . $locale->text('Qty') . qq|</th>|;
 
3278   $column_header{rop} =
 
3279     qq|<th class=listheading>| . $locale->text('ROP') . qq|</th>|;
 
3280   $column_header{stock} =
 
3281     qq|<th class=listheading>| . $locale->text('Add') . qq|</th>|;
 
3283   @column_index = (qw(partnumber description bin onhand rop stock));
 
3285   $form->{title} = $locale->text('Stock Assembly');
 
3288     "$form->{script}?action=stock_assembly&path=$form->{path}&login=$form->{login}&password=$form->{password}";
 
3292   $colspan = $#column_index + 1;
 
3297 <form method=post action=$form->{script}>
 
3301     <th class=listtop colspan=$colspan>$form->{title}</th>
 
3304   <tr class=listheading>|;
 
3306   map { print "\n$column_header{$_}" } @column_index;
 
3313   foreach $ref (@{ $form->{assembly_items} }) {
 
3315     map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description);
 
3317     $column_data{partnumber}  = qq|<td width=20%>$ref->{partnumber}</td>|;
 
3318     $column_data{description} =
 
3319       qq|<td width=50%>$ref->{description} </td>|;
 
3320     $column_data{bin}    = qq|<td>$ref->{bin} </td>|;
 
3321     $column_data{onhand} =
 
3322         qq|<td align=right>|
 
3323       . $form->format_amount(\%myconfig, $ref->{onhand}, '', " ")
 
3326         qq|<td align=right>|
 
3327       . $form->format_amount(\%myconfig, $ref->{rop}, '', " ")
 
3329     $column_data{stock} = qq|<td width=10%><input name="qty_$i" size=10></td>|;
 
3334       qq|<tr class=listrow$j><input name="id_$i" type=hidden value=$ref->{id}>\n|;
 
3336     map { print "\n$column_data{$_}" } @column_index;
 
3349     <td colspan=6><hr size=3 noshade>
 
3352 <input name=rowcount type=hidden value="$i">
 
3354 <input type=hidden name=path value=$form->{path}>
 
3355 <input type=hidden name=login value=$form->{login}>
 
3356 <input type=hidden name=password value=$form->{password}>
 
3358 <input name=callback type=hidden value="$form->{callback}">
 
3360 <input type=hidden name=nextsub value=restock_assemblies>
 
3363 <input class=submit type=submit name=action value="|
 
3364     . $locale->text('Continue') . qq|">
 
3372   $lxdebug->leave_sub();
 
3375 sub restock_assemblies {
 
3376   $lxdebug->enter_sub();
 
3378   $form->redirect($locale->text('Assemblies restocked!'))
 
3379     if (IC->restock_assemblies(\%myconfig, \%$form));
 
3380   $form->error($locale->text('Cannot stock assemblies!'));
 
3382   $lxdebug->leave_sub();
 
3386   $lxdebug->enter_sub();
 
3395           <th class="listheading">| . $locale->text('Preisklasse') . qq|</th>
 
3396           <th class="listheading">| . $locale->text('Preis') . qq|</th>
 
3399   for $i (1 .. $numrows) {
 
3402           <td width=50%><input type=hidden name="pricegroup_$i" size=30  value="$form->{"pricegroup_$i"}">$form->{"pricegroup_$i"}</td>
 
3403           <td width=50%><input name="price_$i" size=11 value="$form->{"price_$i"}"></td>
 
3404           <input type=hidden name="pricegroup_id_$i" value="$form->{"pricegroup_id_$i"}">
 
3415   $lxdebug->leave_sub();
 
3419 sub parts_language_selection {
 
3420   $lxdebug->enter_sub();
 
3423   my $languages = IC->retrieve_languages(\%myconfig, $form);
 
3426   my $callback = "$form->{script}?action=parts_language_selection&";
 
3427   map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
 
3428       (qw(login path password name input_name), grep({ /^[fl]_/ } keys %$form)));
 
3430   my @header_sort = qw(name longdescription);
 
3431   my %header_title = ( "name" => $locale->text("Name"),
 
3432                        "longdescription" => $locale->text("Long Description"),
 
3436     map(+{ "column_title" => $header_title{$_},
 
3438            "callback" => $callback,
 
3442   $form->{"title"} = $locale->text("Language Values");
 
3444   print($form->parse_html_template("ic/parts_language_selection", { "HEADER" => \@header,
 
3445                                                                    "LANGUAGES" => $languages,
 
3446                                                                    "onload" => $onload }));
 
3448   $lxdebug->leave_sub();
 
3451 sub continue { &{ $form->{nextsub} } }