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 (time)') . 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 (time)') . 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>
 
 272           <th align=right nowrap>| . $locale->text('EAN') . qq|</th>
 
 273           <td><input name=ean size=20></td>
 
 276           <th align=right nowrap>|
 
 277     . $locale->text('Part Description') . qq|</th>
 
 278           <td colspan=3><input name=description size=40></td>
 
 281           <th align=right nowrap>| . $locale->text('Group') . qq|</th>
 
 282           <td><input name=partsgroup size=20></td>
 
 287           <th align=right nowrap>| . $locale->text('Drawing') . qq|</th>
 
 288           <td><input name=drawing size=20></td>
 
 289           <th align=right nowrap>| . $locale->text('Microfiche') . qq|</th>
 
 290           <td><input name=microfiche size=20></td>
 
 296             <input name=itemstatus class=radio type=radio value=active checked> |
 
 297     . $locale->text('Active') . qq|
 
 299             <input name=itemstatus class=radio type=radio value=obsolete> |
 
 300     . $locale->text('Obsolete') . qq|
 
 301             <input name=itemstatus class=radio type=radio value=orphaned> |
 
 302     . $locale->text('Orphaned') . qq|
 
 313           <th align=right nowrap>|
 
 314     . $locale->text('Include in Report') . qq|</th>
 
 318                 <td><input name=l_partnumber class=checkbox type=checkbox value=Y checked> |
 
 319     . $locale->text('Part Number') . qq|</td>
 
 320                 <td><input name=l_description class=checkbox type=checkbox value=Y checked> |
 
 321     . $locale->text('Part Description') . qq|</td>
 
 323                 <td><input name=l_unit class=checkbox type=checkbox value=Y checked> |
 
 324     . $locale->text('Unit of measure') . qq|</td>
 
 327                 <td><input name=l_listprice class=checkbox type=checkbox value=Y> |
 
 328     . $locale->text('List Price') . qq|</td>
 
 329                 <td><input name=l_sellprice class=checkbox type=checkbox value=Y checked> |
 
 330     . $locale->text('Sell Price') . qq|</td>
 
 331                 <td><input name=l_lastcost class=checkbox type=checkbox value=Y checked> |
 
 332     . $locale->text('Last Cost') . qq|</td>
 
 333                 <td><input name=l_linetotal class=checkbox type=checkbox value=Y checked> |
 
 334     . $locale->text('Line Total') . qq|</td>
 
 337                 <td><input name=l_priceupdate class=checkbox type=checkbox value=Y> |
 
 338     . $locale->text('Updated') . qq|</td>
 
 339                 <td><input name=l_bin class=checkbox type=checkbox value=Y> |
 
 340     . $locale->text('Bin') . qq|</td>
 
 341                 <td><input name=l_rop class=checkbox type=checkbox value=Y> |
 
 342     . $locale->text('ROP') . qq|</td>
 
 343                 <td><input name=l_weight class=checkbox type=checkbox value=Y> |
 
 344     . $locale->text('Weight') . qq|</td>
 
 347                 <td><input name=l_image class=checkbox type=checkbox value=Y> |
 
 348     . $locale->text('Image') . qq|</td>
 
 349                 <td><input name=l_drawing class=checkbox type=checkbox value=Y> |
 
 350     . $locale->text('Drawing') . qq|</td>
 
 351                 <td><input name=l_microfiche class=checkbox type=checkbox value=Y> |
 
 352     . $locale->text('Microfiche') . qq|</td>
 
 353                 <td><input name=l_partsgroup class=checkbox type=checkbox value=Y> |
 
 354     . $locale->text('Group') . qq|</td>
 
 357                 <td><input name=l_subtotal class=checkbox type=checkbox value=Y> |
 
 358     . $locale->text('Subtotal') . qq|</td>
 
 359                 <td><input name=l_soldtotal class=checkbox type=checkbox value=Y> |
 
 360     . $locale->text('soldtotal') . qq|</td>
 
 361                 <td><input name=l_deliverydate class=checkbox type=checkbox value=Y> |
 
 362     . $locale->text('deliverydate') . qq|</td>    
 
 370   <tr><td colspan=4><hr size=3 noshade></td></tr>
 
 375 <input type=hidden name=nextsub value=generate_report>
 
 377 <input type=hidden name=path value=$form->{path}>
 
 378 <input type=hidden name=login value=$form->{login}>
 
 379 <input type=hidden name=password value=$form->{password}>
 
 381 <input type=hidden name=revers value="$form->{revers}">
 
 382 <input type=hidden name=lastsort value="$form->{lastsort}">
 
 383 <input type=hidden name=sort value="description">
 
 385 <input type=hidden name=ndxs_counter value="$form->{ndxs_counter}">
 
 388 <input class=submit type=submit name=action value="|
 
 389     . $locale->text('Continue') . qq|">
 
 390 <input class=submit type=submit name=action value="|
 
 391     . $locale->text('TOP100') . qq|">
 
 397   $lxdebug->leave_sub();
 
 400 sub search_update_prices {
 
 401   $lxdebug->enter_sub();
 
 403   $form->{title} = $locale->text('Update prices');
 
 404   IC->get_pricegroups(\%myconfig, \%$form);
 
 406   # use JavaScript Calendar or not
 
 407 #   $form->{jsscript} = $jscalendar;
 
 409 #   if ($form->{jsscript}) {
 
 411 #     # with JavaScript Calendar
 
 413 #        <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>
 
 414 #        <td><input type=button name=transdatefrom id="trigger1" value=|
 
 415 #       . $locale->text('button') . qq|></td>
 
 418 #        <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>
 
 419 #        <td><input type=button name=transdateto name=transdateto id="trigger2" value=|
 
 420 #       . $locale->text('button') . qq|></td>
 
 425 #       Form->write_trigger(\%myconfig, "2", "transdatefrom", "BL", "trigger1",
 
 426 #                           "transdateto", "BL", "trigger2");
 
 429 #     # without JavaScript Calendar
 
 431 #                               <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
 
 433 #                               <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
 
 437             <input name=itemstatus class=radio type=radio value=onhand> |
 
 438       . $locale->text('On Hand') . qq|
 
 439             <input name=itemstatus class=radio type=radio value=short> |
 
 440       . $locale->text('Short') . qq|
 
 445           <th align=right nowrap>| . $locale->text('Make') . qq|</th>
 
 446           <td><input name=make size=20></td>
 
 447           <th align=right nowrap>| . $locale->text('Model') . qq|</th>
 
 448           <td><input name=model size=20></td>
 
 453           <th align=right nowrap>| . $locale->text('Serial Number') . qq|</th>
 
 454           <td><input name=serialnumber size=20></td>
 
 457     $l_serialnumber = qq|
 
 458         <td><input name=l_serialnumber class=checkbox type=checkbox value=Y> |
 
 459       . $locale->text('Serial Number') . qq|</td>
 
 469 <form method=post action=$form->{script}>
 
 471 <input type=hidden name=title value="$form->{title}">
 
 474   <tr><th class=listtop>$form->{title}</th></tr>
 
 480           <th align=right nowrap>| . $locale->text('Part Number') . qq|</th>
 
 481           <td><input name=partnumber size=20></td>
 
 484           <th align=right nowrap>|
 
 485     . $locale->text('Part Description') . qq|</th>
 
 486           <td colspan=3><input name=description size=40></td>
 
 489           <th align=right nowrap>| . $locale->text('Group') . qq|</th>
 
 490           <td><input name=partsgroup size=20></td>
 
 495           <th align=right nowrap>| . $locale->text('Drawing') . qq|</th>
 
 496           <td><input name=drawing size=20></td>
 
 497           <th align=right nowrap>| . $locale->text('Microfiche') . qq|</th>
 
 498           <td><input name=microfiche size=20></td>
 
 504             <input name=itemstatus class=radio type=radio value=active checked> |
 
 505     . $locale->text('Active') . qq|
 
 507             <input name=itemstatus class=radio type=radio value=obsolete> |
 
 508     . $locale->text('Obsolete') . qq|
 
 509             <input name=itemstatus class=radio type=radio value=orphaned> |
 
 510     . $locale->text('Orphaned') . qq|
 
 525           <th class="listheading">| . $locale->text('Preisklasse') . qq|</th>
 
 526           <th class="listheading">| . $locale->text('Preis') . qq|</th>
 
 527           <th class="listheading">| . $locale->text('Prozentual/Absolut') . qq|</th>
 
 530           <td>| . $locale->text('Sell Price') . qq|</td>
 
 531           <td><input name="sellprice" size=11 value="$form->{"sellprice"}"></td>
 
 532           <td><input name="sellprice_type" class=radio type=radio value=percent checked>/<input name="sellprice_type" class=radio type=radio value=absolut></td>
 
 535           <td>| . $locale->text('List Price') . qq|</td>
 
 536           <td><input name="listprice" size=11 value="$form->{"listprice"}"></td>
 
 537           <td><input name="listprice_type" class=radio type=radio value=percent checked>/<input name="listprice_type" class=radio type=radio value=absolut></td>
 
 540   for $i (1 .. $form->{price_rows}) {
 
 543           <td width=50%><input type=hidden name="pricegroup_$i" size=30  value="$form->{"pricegroup_$i"}">$form->{"pricegroup_$i"}</td>
 
 544           <td width=50%><input name="price_$i" size=11></td>
 
 545           <input type=hidden name="pricegroup_id_$i" value="$form->{"pricegroup_id_$i"}">
 
 546           <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>
 
 556   <tr><td colspan=4><hr size=3 noshade></td></tr>
 
 558 <input type=hidden name=nextsub value=confirm_price_update>
 
 559 <input type=hidden name=price_rows value=$form->{price_rows}>
 
 561 <input type=hidden name=path value=$form->{path}>
 
 562 <input type=hidden name=login value=$form->{login}>
 
 563 <input type=hidden name=password value=$form->{password}>
 
 566 <input class=submit type=submit name=action value="|
 
 567     . $locale->text('Continue') . qq|">
 
 573   $lxdebug->leave_sub();
 
 576 sub confirm_price_update {
 
 577   $lxdebug->enter_sub();
 
 580   $form->{nextsub} = "update_prices";
 
 586 <form method=post action=$form->{script}>
 
 589   # delete action variable
 
 590   map { delete $form->{$_} } qw(action header);
 
 592   foreach $key (keys %$form) {
 
 593     $form->{$key} =~ s/\"/"/g;
 
 594     print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
 
 598 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
 
 601     . $locale->text('Are you sure you want to update the prices')
 
 605 <input name=action class=submit type=submit value="|
 
 606     . $locale->text('Continue') . qq|">
 
 610   $lxdebug->leave_sub();
 
 614   $lxdebug->enter_sub();
 
 616   if (IC->update_prices(\%myconfig, \%$form)) {
 
 617     $form->redirect($form->{update_count} . $locale->text('prices updated!'));
 
 619     $form->error($locale->text('Could not update prices!'));
 
 622   $lxdebug->leave_sub();
 
 626   $lxdebug->enter_sub();
 
 628   $form->{title} = $locale->text('Top 100 hinzufuegen');
 
 635   <form method=post action=$form->{script}>
 
 637   <input type=hidden name=searchitems value=$form->{searchitems}>
 
 638   <input type=hidden name=title value="$form->{title}">
 
 640   <input type=hidden name=revers value="$form->{revers}">
 
 641   <input type=hidden name=lastsort value="$form->{lastsort}">|;
 
 645         <tr class=listheading>
 
 646          <th class=listheading nowrap>|
 
 647     . $locale->text('Part Number') . qq|</th>
 
 648          <th class=listheading nowrap>|
 
 649     . $locale->text('Part Description') . qq|</th>
 
 652          <td><input type=text name=partnumber size=20 value=></td>
 
 653          <td><input type=text name=description size=30 value=></td>
 
 660 <input type=hidden name=path value=$form->{path}>
 
 661 <input type=hidden name=login value=$form->{login}>
 
 662 <input type=hidden name=password value=$form->{password}>
 
 664 <input type=hidden name=itemstatus value="$form->{itemstatus}">
 
 665 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
 
 666 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
 
 667 <input type=hidden name=l_description value="$form->{l_description}">
 
 668 <input type=hidden name=l_onhand value="$form->{l_onhand}">
 
 669 <input type=hidden name=l_unit value="$form->{l_unit}">
 
 670 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
 
 671 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
 
 672 <input type=hidden name=sort value="$form->{sort}">
 
 673 <input type=hidden name=revers value="$form->{revers}">
 
 674 <input type=hidden name=lastsort value="$form->{lastsort}">
 
 676 <input type=hidden name=bom value="$form->{bom}">
 
 677 <input type=hidden name=titel value="$form->{titel}">
 
 678 <input type=hidden name=searchitems value="$form->{searchitems}">
 
 680 <input type=hidden name=row value=$j>
 
 682 <input type=hidden name=nextsub value=item_selected>
 
 684 <input type=hidden name=test value=item_selected>
 
 686 <input name=lastndx type=hidden value=$lastndx>
 
 688 <input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>
 
 690 <input name=extras type=hidden value=$form->{extras}>|;
 
 694     for ($i = 0; $i < $form->{ndxs_counter}; $i++) {
 
 697       $partnumber  = $form->{"totop100_partnumber_$j"};
 
 698       $description = $form->{"totop100_description_$j"};
 
 699       $unit        = $form->{"totop100_unit_$j"};
 
 700       $sellprice   = $form->{"totop100_sellprice_$j"};
 
 701       $soldtotal   = $form->{"totop100_soldtotal_$j"};
 
 703       # insert data into top100
 
 704       push @{ $form->{parts} },
 
 706           partnumber  => "$partnumber",
 
 707           description => "$description",
 
 709           sellprice   => "$sellprice",
 
 710           soldtotal   => "$soldtotal" };
 
 716   # set data for next page
 
 717   if (($form->{ndxs_counter}) > 0) {
 
 718     for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
 
 719       $partnumber  = $form->{"totop100_partnumber_$i"};
 
 720       $description = $form->{"totop100_description_$i"};
 
 721       $unit        = $form->{"totop100_unit_$i"};
 
 722       $sellprice   = $form->{"totop100_sellprice_$i"};
 
 723       $soldtotal   = $form->{"totop100_soldtotal_$i"};
 
 726 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
 
 727 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
 
 728 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
 
 729 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
 
 730 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
 
 738      <input class=submit type=submit name=action value="|
 
 739     . $locale->text('list') . qq|">
 
 744   $lxdebug->leave_sub();
 
 748   $lxdebug->enter_sub();
 
 751   if (($form->{partnumber} eq "") and ($form->{description} eq "")) {
 
 752     IC->get_parts(\%myconfig, \%$form, "");
 
 754     if ((!($form->{partnumber} eq "")) and ($form->{description} eq "")) {
 
 755       IC->get_parts(\%myconfig, \%$form, "partnumber");
 
 757       if (($form->{partnumber} eq "") and (!($form->{description} eq ""))) {
 
 758         IC->get_parts(\%myconfig, \%$form, "description");
 
 760         IC->get_parts(\%myconfig, \%$form, "all");
 
 765   $form->{title} = $locale->text('Top 100 hinzufuegen');
 
 771   <form method=post action=ic.pl>
 
 774       <th class=listtop colspan=6>| . $locale->text('choice part') . qq|</th>
 
 777         <tr class=listheading>
 
 779           <th class=listheading>| . $locale->text('Part Number') . qq|</th>
 
 780           <th class=listheading>| . $locale->text('Part Description') . qq|</th>
 
 781           <th class=listheading>| . $locale->text('Unit of measure') . qq|</th>
 
 782           <th class=listheading>| . $locale->text('Sell Price') . qq|</th>
 
 783           <th class=listheading>| . $locale->text('soldtotal') . qq|</th>
 
 787   my $i = $form->{rows};
 
 789   for ($j = 1; $j <= $i; $j++) {
 
 792         <tr class=listrow1>|;
 
 795             <td><input name=ndx class=radio type=radio value=$j checked></td>|;
 
 798           <td><input name=ndx class=radio type=radio value=$j></td>|;
 
 801           <td><input name="new_partnumber_$j" type=hidden value="$form->{"partnumber_$j"}">$form->{"partnumber_$j"}</td>
 
 802           <td><input name="new_description_$j" type=hidden value="$form->{"description_$j"}">$form->{"description_$j"}</td>
 
 803           <td><input name="new_unit_$j" type=hidden value="$form->{"unit_$j"}">$form->{"unit_$j"}</td>
 
 804           <td><input name="new_sellprice_$j" type=hidden value="$form->{"sellprice_$j"}">$form->{"sellprice_$j"}</td>
 
 805           <td><input name="new_soldtotal_$j" type=hidden value="$form->{"soldtotal_$j"}">$form->{"soldtotal_$j"}</td>
 
 808         <input name="new_id_$j" type=hidden value="$form->{"id_$j"}">|;
 
 818 <input type=hidden name=path value=$form->{path}>
 
 819 <input type=hidden name=login value=$form->{login}>
 
 820 <input type=hidden name=password value=$form->{password}>
 
 822 <input type=hidden name=itemstatus value="$form->{itemstatus}">
 
 823 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
 
 824 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
 
 825 <input type=hidden name=l_description value="$form->{l_description}">
 
 826 <input type=hidden name=l_onhand value="$form->{l_onhand}">
 
 827 <input type=hidden name=l_unit value="$form->{l_unit}">
 
 828 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
 
 829 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
 
 830 <input type=hidden name=sort value="$form->{sort}">
 
 831 <input type=hidden name=revers value="$form->{revers}">
 
 832 <input type=hidden name=lastsort value="$form->{lastsort}">
 
 834 <input type=hidden name=bom value="$form->{bom}">
 
 835 <input type=hidden name=titel value="$form->{titel}">
 
 836 <input type=hidden name=searchitems value="$form->{searchitems}">
 
 838 <input type=hidden name=row value=$j>
 
 840 <input type=hidden name=nextsub value=item_selected>
 
 842 <input name=lastndx type=hidden value=$lastndx>
 
 844 <input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>|;
 
 848   if (($form->{ndxs_counter}) > 0) {
 
 849     for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
 
 850       $j1 = $form->{"totop100_partnumber_$i"};
 
 851       $j2 = $form->{"totop100_description_$i"};
 
 852       $j3 = $form->{"totop100_unit_$i"};
 
 853       $j4 = $form->{"totop100_sellprice_$i"};
 
 854       $j5 = $form->{"totop100_soldtotal_$i"};
 
 863 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
 
 864 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
 
 865 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
 
 866 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
 
 867 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
 
 875 <input class=submit type=submit name=action value="|
 
 876     . $locale->text('TOP100') . qq|">
 
 882   $lxdebug->leave_sub();
 
 886   $lxdebug->enter_sub();
 
 889     $form->{ndxs_counter}++;
 
 891     if ($form->{ndxs_counter} > 0) {
 
 893       $index = $form->{ndx};
 
 895       $j1 = $form->{"new_partnumber_$index"};
 
 896       $form->{"totop100_partnumber_$form->{ndxs_counter}"} = $j1;
 
 897       $j2 = $form->{"new_description_$index"};
 
 898       $form->{"totop100_description_$form->{ndxs_counter}"} = $j2;
 
 899       $j3 = $form->{"new_unit_$index"};
 
 900       $form->{"totop100_unit_$form->{ndxs_counter}"} = $j3;
 
 901       $j4 = $form->{"new_sellprice_$index"};
 
 902       $form->{"totop100_sellprice_$form->{ndxs_counter}"} = $j4;
 
 903       $j5 = $form->{"new_soldtotal_$index"};
 
 904       $form->{"totop100_soldtotal_$form->{ndxs_counter}"} = $j5;
 
 908   $lxdebug->leave_sub();
 
 912   $lxdebug->enter_sub();
 
 914   $form->{top100}      = "top100";
 
 915   $form->{l_soldtotal} = "Y";
 
 916   $form->{soldtotal}   = "soldtotal";
 
 917   $form->{sort}        = "soldtotal";
 
 918   $form->{l_qty}       = "N";
 
 919   $callback .= "&form->{top100}=$form->{top100}";
 
 920   $form->{l_linetotal} = "";
 
 922   $form->{number}      = "position";
 
 923   $form->{l_number}    = "Y";
 
 927   $form->{title} = $locale->text('Top 100');
 
 929   $revers   = $form->{revers};
 
 930   $lastsort = $form->{lastsort};
 
 932   if (($form->{lastsort} eq "") && ($form->{sort} eq undef)) {
 
 934     $form->{lastsort} = "partnumber";
 
 935     $form->{sort}     = "partnumber";
 
 939     "$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="
 
 940     . $form->escape($form->{title}, 1);
 
 942   # if we have a serialnumber limit search
 
 943   if ($form->{serialnumber} || $form->{l_serialnumber}) {
 
 944     $form->{l_serialnumber} = "Y";
 
 945     unless (   $form->{bought}
 
 948             || $form->{quoted}) {
 
 949       $form->{bought} = $form->{sold} = 1;
 
 952   IC->all_parts(\%myconfig, \%$form);
 
 954   if ($form->{itemstatus} eq 'active') {
 
 955     $option .= $locale->text('Active') . " : ";
 
 957   if ($form->{itemstatus} eq 'obsolete') {
 
 958     $option .= $locale->text('Obsolete') . " : ";
 
 960   if ($form->{itemstatus} eq 'orphaned') {
 
 961     $option .= $locale->text('Orphaned') . " : ";
 
 963   if ($form->{itemstatus} eq 'onhand') {
 
 964     $option .= $locale->text('On Hand') . " : ";
 
 965     $form->{l_onhand} = "Y";
 
 967   if ($form->{itemstatus} eq 'short') {
 
 968     $option .= $locale->text('Short') . " : ";
 
 969     $form->{l_onhand} = "Y";
 
 971   if ($form->{onorder}) {
 
 972     $form->{l_ordnumber} = "Y";
 
 973     $callback .= "&onorder=$form->{onorder}";
 
 974     $option   .= $locale->text('On Order') . " : ";
 
 976   if ($form->{ordered}) {
 
 977     $form->{l_ordnumber} = "Y";
 
 978     $callback .= "&ordered=$form->{ordered}";
 
 979     $option   .= $locale->text('Ordered') . " : ";
 
 982     $form->{l_quonumber} = "Y";
 
 983     $callback .= "&rfq=$form->{rfq}";
 
 984     $option   .= $locale->text('RFQ') . " : ";
 
 986   if ($form->{quoted}) {
 
 987     $form->{l_quonumber} = "Y";
 
 988     $callback .= ""ed=$form->{quoted}";
 
 989     $option   .= $locale->text('Quoted') . " : ";
 
 991   if ($form->{bought}) {
 
 992     $form->{l_invnumber} = "Y";
 
 993     $callback .= "&bought=$form->{bought}";
 
 994     $option   .= $locale->text('Bought') . " : ";
 
 997     $form->{l_invnumber} = "Y";
 
 998     $callback .= "&sold=$form->{sold}";
 
 999     $option   .= $locale->text('Sold') . " : ";
 
1001   if (   $form->{bought}
 
1006       || $form->{quoted}) {
 
1008     $form->{l_lastcost} = "";
 
1009     $form->{l_name}     = "Y";
 
1010     if ($form->{transdatefrom}) {
 
1011       $callback .= "&transdatefrom=$form->{transdatefrom}";
 
1013         . $locale->text('From')
 
1015         . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
 
1017     if ($form->{transdateto}) {
 
1018       $callback .= "&transdateto=$form->{transdateto}";
 
1020         . $locale->text('To')
 
1022         . $locale->date(\%myconfig, $form->{transdateto}, 1);
 
1028   if ($form->{partnumber}) {
 
1029     $callback .= "&partnumber=$form->{partnumber}";
 
1030     $option   .= $locale->text('Part Number') . qq| : $form->{partnumber}<br>|;
 
1033     $callback .= "&partnumber=$form->{ean}";
 
1034     $option   .= $locale->text('EAN') . qq| : $form->{ean}<br>|;
 
1036   if ($form->{partsgroup}) {
 
1037     $callback .= "&partsgroup=$form->{partsgroup}";
 
1038     $option   .= $locale->text('Group') . qq| : $form->{partsgroup}<br>|;
 
1040   if ($form->{serialnumber}) {
 
1041     $callback .= "&serialnumber=$form->{serialnumber}";
 
1043       $locale->text('Serial Number') . qq| : $form->{serialnumber}<br>|;
 
1045   if ($form->{description}) {
 
1046     $callback .= "&description=$form->{description}";
 
1047     $description = $form->{description};
 
1051       $locale->text('Part Description') . qq| : $form->{description}<br>|;
 
1053   if ($form->{make}) {
 
1054     $callback .= "&make=$form->{make}";
 
1055     $option   .= $locale->text('Make') . qq| : $form->{make}<br>|;
 
1057   if ($form->{model}) {
 
1058     $callback .= "&model=$form->{model}";
 
1059     $option   .= $locale->text('Model') . qq| : $form->{model}<br>|;
 
1061   if ($form->{drawing}) {
 
1062     $callback .= "&drawing=$form->{drawing}";
 
1063     $option   .= $locale->text('Drawing') . qq| : $form->{drawing}<br>|;
 
1065   if ($form->{microfiche}) {
 
1066     $callback .= "µfiche=$form->{microfiche}";
 
1067     $option   .= $locale->text('Microfiche') . qq| : $form->{microfiche}<br>|;
 
1069   if ($form->{l_soldtotal}) {
 
1070     $callback .= "&soldtotal=$form->{soldtotal}";
 
1071     $option   .= $locale->text('soldtotal') . qq| : $form->{soldtotal}<br>|;
 
1074   @columns = $form->sort_columns(
 
1075     qw(number partnumber ean description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal)
 
1078   if ($form->{l_linetotal}) {
 
1079     $form->{l_onhand} = "Y";
 
1080     $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
 
1081     if ($form->{l_lastcost}) {
 
1082       $form->{l_linetotallastcost} = "Y";
 
1083       if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
 
1084         $form->{l_linetotallastcost} = "";
 
1087     $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
 
1090   if ($form->{searchitems} eq 'service') {
 
1092     # remove bin, weight and rop from list
 
1093     map { $form->{"l_$_"} = "" } qw(bin weight rop);
 
1095     $form->{l_onhand} = "";
 
1097     # qty is irrelevant unless bought or sold
 
1098     if (   $form->{bought}
 
1103         || $form->{quoted}) {
 
1104       $form->{l_onhand} = "Y";
 
1106       $form->{l_linetotalsellprice} = "";
 
1107       $form->{l_linetotallastcost}  = "";
 
1111   $form->{l_lastcost} = ""
 
1112     if ($form->{searchitems} eq 'assembly' && !$form->{bom});
 
1114   foreach $item (@columns) {
 
1115     if ($form->{"l_$item"} eq "Y") {
 
1116       push @column_index, $item;
 
1118       # add column to callback
 
1119       $callback .= "&l_$item=Y";
 
1123   if ($form->{l_subtotal} eq 'Y') {
 
1124     $callback .= "&l_subtotal=Y";
 
1127   $column_header{number} =
 
1128     qq|<th class=listheading nowrap>| . $locale->text('number') . qq|</th>|;
 
1129   $column_header{partnumber} =
 
1130     qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1131     . $locale->text('Part Number')
 
1133   $column_header{description} =
 
1134     qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1135     . $locale->text('Part Description')
 
1137   $column_header{partsgroup} =
 
1138       qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|
 
1139     . $locale->text('Group')
 
1141   $column_header{bin} =
 
1142       qq|<th><a class=listheading href=$callback&sort=bin>|
 
1143     . $locale->text('Bin')
 
1145   $column_header{priceupdate} =
 
1146       qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|
 
1147     . $locale->text('Updated')
 
1149   $column_header{onhand} =
 
1150     qq|<th nowrap><a  class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1151     . $locale->text('Qty')
 
1153   $column_header{unit} =
 
1154     qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
 
1155   $column_header{listprice} =
 
1156       qq|<th class=listheading nowrap>|
 
1157     . $locale->text('List Price')
 
1159   $column_header{lastcost} =
 
1160     qq|<th class=listheading nowrap>| . $locale->text('Last Cost') . qq|</th>|;
 
1161   $column_header{rop} =
 
1162     qq|<th class=listheading nowrap>| . $locale->text('ROP') . qq|</th>|;
 
1163   $column_header{weight} =
 
1164     qq|<th class=listheading nowrap>| . $locale->text('Weight') . qq|</th>|;
 
1166   $column_header{invnumber} =
 
1167       qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|
 
1168     . $locale->text('Invoice Number')
 
1170   $column_header{ordnumber} =
 
1171       qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|
 
1172     . $locale->text('Order Number')
 
1174   $column_header{quonumber} =
 
1175       qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|
 
1176     . $locale->text('Quotation')
 
1179   $column_header{name} =
 
1180       qq|<th nowrap><a class=listheading href=$callback&sort=name>|
 
1181     . $locale->text('Name')
 
1184   $column_header{sellprice} =
 
1185       qq|<th class=listheading nowrap>|
 
1186     . $locale->text('Sell Price')
 
1188   $column_header{linetotalsellprice} =
 
1189     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1190   $column_header{linetotallastcost} =
 
1191     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1192   $column_header{linetotallistprice} =
 
1193     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1195   $column_header{image} =
 
1196     qq|<th class=listheading nowrap>| . $locale->text('Image') . qq|</a></th>|;
 
1197   $column_header{drawing} =
 
1198       qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|
 
1199     . $locale->text('Drawing')
 
1201   $column_header{microfiche} =
 
1202       qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|
 
1203     . $locale->text('Microfiche')
 
1206   $column_header{serialnumber} =
 
1207       qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|
 
1208     . $locale->text('Serial Number')
 
1210   $column_header{soldtotal} =
 
1211     qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1212     . $locale->text('soldtotal')
 
1216   $colspan = $#column_index + 1;
 
1223     <th class=listtop colspan=$colspan>$form->{title}</th>
 
1225   <tr height="5"></tr>
 
1227   <tr><td colspan=$colspan>$option</td></tr>
 
1229   <tr class=listheading>
 
1232   map { print "\n$column_header{$_}" } @column_index;
 
1238   # add order to callback
 
1239   $form->{callback} = $callback .= "&sort=$form->{sort}";
 
1241   # escape callback for href
 
1242   $callback = $form->escape($callback);
 
1244   if (@{ $form->{parts} }) {
 
1245     $sameitem = $form->{parts}->[0]->{ $form->{sort} };
 
1248   # insert numbers for top100
 
1250   foreach $ref (@{ $form->{parts} }) {
 
1252     $ref->{number} = $j;
 
1255   # if avaible -> insert choice here
 
1256   if (($form->{ndxs_counter}) > 0) {
 
1257     for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
 
1258       $partnumber  = $form->{"totop100_partnumber_$i"};
 
1259       $description = $form->{"totop100_description_$i"};
 
1260       $unit        = $form->{"totop100_unit_$i"};
 
1261       $sellprice   = $form->{"totop100_sellprice_$i"};
 
1262       $soldtotal   = $form->{"totop100_soldtotal_$i"};
 
1265 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
 
1266 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
 
1267 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
 
1268 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
 
1269 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
 
1273       push @{ $form->{parts} },
 
1275           partnumber  => "$partnumber",
 
1276           description => "$description",
 
1278           sellprice   => "$sellprice",
 
1279           soldtotal   => "$soldtotal" };
 
1282        # build data for columns
 
1283   foreach $ref (@{ $form->{parts} }) {
 
1285     if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
 
1286       if ($sameitem ne $ref->{ $form->{sort} }) {
 
1288         $sameitem = $ref->{ $form->{sort} };
 
1292     $ref->{exchangerate} = 1 unless $ref->{exchangerate};
 
1293     $ref->{sellprice} *= $ref->{exchangerate};
 
1294     $ref->{listprice} *= $ref->{exchangerate};
 
1295     $ref->{lastcost}  *= $ref->{exchangerate};
 
1297     # use this for assemblies
 
1298     $onhand = $ref->{onhand};
 
1301     if ($ref->{assemblyitem}) {
 
1303       $onhand = 0 if ($form->{sold});
 
1306     $ref->{description} =~ s/
 
1309     $column_data{number} =
 
1311       . $form->format_amount(\%myconfig, $ref->{number})
 
1313     $column_data{partnumber} =
 
1314       "<td align=$align>$ref->{partnumber} </a></td>";
 
1315     $column_data{description} = "<td>$ref->{description} </td>";
 
1316     $column_data{partsgroup}  = "<td>$ref->{partsgroup} </td>";
 
1318     $column_data{onhand} =
 
1320       . $form->format_amount(\%myconfig, $ref->{onhand})
 
1322     $column_data{sellprice} =
 
1324       . $form->format_amount(\%myconfig, $ref->{sellprice})
 
1326     $column_data{listprice} =
 
1328       . $form->format_amount(\%myconfig, $ref->{listprice})
 
1330     $column_data{lastcost} =
 
1332       . $form->format_amount(\%myconfig, $ref->{lastcost})
 
1335     $column_data{linetotalsellprice} = "<td align=right>"
 
1336       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice}, 2)
 
1338     $column_data{linetotallastcost} = "<td align=right>"
 
1339       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost}, 2)
 
1341     $column_data{linetotallistprice} = "<td align=right>"
 
1342       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice}, 2)
 
1345     if (!$ref->{assemblyitem}) {
 
1346       $totalsellprice += $onhand * $ref->{sellprice};
 
1347       $totallastcost  += $onhand * $ref->{lastcost};
 
1348       $totallistprice += $onhand * $ref->{listprice};
 
1350       $subtotalonhand    += $onhand;
 
1351       $subtotalsellprice += $onhand * $ref->{sellprice};
 
1352       $subtotallastcost  += $onhand * $ref->{lastcost};
 
1353       $subtotallistprice += $onhand * $ref->{listprice};
 
1358       . $form->format_amount(\%myconfig, $ref->{rop}) . "</td>";
 
1359     $column_data{weight} =
 
1361       . $form->format_amount(\%myconfig, $ref->{weight})
 
1363     $column_data{unit}        = "<td>$ref->{unit} </td>";
 
1364     $column_data{bin}         = "<td>$ref->{bin} </td>";
 
1365     $column_data{priceupdate} = "<td>$ref->{priceupdate} </td>";
 
1367     $column_data{invnumber} =
 
1368       ($ref->{module} ne 'oe')
 
1369       ? "<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>"
 
1370       : "<td>$ref->{invnumber}</td>";
 
1371     $column_data{ordnumber} =
 
1372       ($ref->{module} eq 'oe')
 
1373       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber}</a></td>"
 
1374       : "<td>$ref->{ordnumber}</td>";
 
1375     $column_data{quonumber} =
 
1376       ($ref->{module} eq 'oe' && !$ref->{ordnumber})
 
1377       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber}</a></td>"
 
1378       : "<td>$ref->{quonumber}</td>";
 
1380     $column_data{name} = "<td>$ref->{name}</td>";
 
1382     $column_data{image} =
 
1384       ? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>"
 
1385       : "<td> </td>";
 
1386     $column_data{drawing} =
 
1388       ? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>"
 
1389       : "<td> </td>";
 
1390     $column_data{microfiche} =
 
1391       ($ref->{microfiche})
 
1392       ? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>"
 
1393       : "<td> </td>";
 
1395     $column_data{serialnumber} = "<td>$ref->{serialnumber}</td>";
 
1397     $column_data{soldtotal} = "<td  align=right>$ref->{soldtotal}</td>";
 
1401     print "<tr class=listrow$i>";
 
1403     map { print "\n$column_data{$_}" } @column_index;
 
1410   if ($form->{l_subtotal} eq 'Y') {
 
1414   if ($form->{"l_linetotal"}) {
 
1415     map { $column_data{$_} = "<td> </td>" } @column_index;
 
1416     $column_data{linetotalsellprice} =
 
1417         "<th class=listtotal align=right>"
 
1418       . $form->format_amount(\%myconfig, $totalsellprice, 2)
 
1420     $column_data{linetotallastcost} =
 
1421         "<th class=listtotal align=right>"
 
1422       . $form->format_amount(\%myconfig, $totallastcost, 2)
 
1424     $column_data{linetotallistprice} =
 
1425         "<th class=listtotal align=right>"
 
1426       . $form->format_amount(\%myconfig, $totallistprice, 2)
 
1429     print "<tr class=listtotal>";
 
1431     map { print "\n$column_data{$_}" } @column_index;
 
1438   <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
 
1447 <form method=post action=$form->{script}>
 
1449 <input type=hidden name=path value=$form->{path}>
 
1450 <input type=hidden name=login value=$form->{login}>
 
1451 <input type=hidden name=password value=$form->{password}>
 
1453 <input type=hidden name=itemstatus value="$form->{itemstatus}">
 
1454 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
 
1455 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
 
1456 <input type=hidden name=l_description value="$form->{l_description}">
 
1457 <input type=hidden name=l_onhand value="$form->{l_onhand}">
 
1458 <input type=hidden name=l_unit value="$form->{l_unit}">
 
1459 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
 
1460 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
 
1461 <input type=hidden name=sort value="$form->{sort}">
 
1462 <input type=hidden name=revers value="$form->{revers}">
 
1463 <input type=hidden name=lastsort value="$form->{lastsort}">
 
1464 <input type=hidden name=parts value="$form->{parts}">
 
1466 <input type=hidden name=bom value="$form->{bom}">
 
1467 <input type=hidden name=titel value="$form->{titel}">
 
1468 <input type=hidden name=searchitems value="$form->{searchitems}">|;
 
1473     <input type=hidden name=ndxs_counter value="$form->{ndxs_counter}">
 
1475     <input class=submit type=submit name=action value="|
 
1476     . $locale->text('choice') . qq|">
 
1484   $lxdebug->leave_sub();
 
1487 sub generate_report {
 
1488   $lxdebug->enter_sub();
 
1490   $revers   = $form->{revers};
 
1491   $lastsort = $form->{lastsort};
 
1493   if (($form->{lastsort} eq "") && ($form->{sort} eq undef)) {
 
1494     $form->{revers}   = 0;
 
1495     $form->{lastsort} = "partnumber";
 
1496     $form->{sort}     = "partnumber";
 
1499     # switch between backward sorting of tables
 
1500     if ($form->{lastsort} eq $form->{sort}) {
 
1501       if ($form->{revers} == 0) {
 
1502         $form->{revers} = 1;
 
1504         $form->{revers} = 0;
 
1507       $form->{revers} == 0;
 
1508       $form->{lastsort} = $form->{sort};
 
1513     "$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="
 
1514     . $form->escape($form->{title}, 1);
 
1516   # if we have a serialnumber limit search
 
1517   if ($form->{serialnumber} || $form->{l_serialnumber}) {
 
1518     $form->{l_serialnumber} = "Y";
 
1519     unless (   $form->{bought}
 
1522             || $form->{quoted}) {
 
1523       $form->{bought} = $form->{sold} = 1;
 
1527   IC->all_parts(\%myconfig, \%$form);
 
1529   if ($form->{itemstatus} eq 'active') {
 
1530     $option .= $locale->text('Active') . " : ";
 
1532   if ($form->{itemstatus} eq 'obsolete') {
 
1533     $option .= $locale->text('Obsolete') . " : ";
 
1535   if ($form->{itemstatus} eq 'orphaned') {
 
1536     $option .= $locale->text('Orphaned') . " : ";
 
1538   if ($form->{itemstatus} eq 'onhand') {
 
1539     $option .= $locale->text('On Hand') . " : ";
 
1540     $form->{l_onhand} = "Y";
 
1542   if ($form->{itemstatus} eq 'short') {
 
1543     $option .= $locale->text('Short') . " : ";
 
1544     $form->{l_onhand} = "Y";
 
1546   if ($form->{onorder}) {
 
1547     $form->{l_ordnumber} = "Y";
 
1548     $callback .= "&onorder=$form->{onorder}";
 
1549     $option   .= $locale->text('On Order') . " : ";
 
1551   if ($form->{ordered}) {
 
1552     $form->{l_ordnumber} = "Y";
 
1553     $callback .= "&ordered=$form->{ordered}";
 
1554     $option   .= $locale->text('Ordered') . " : ";
 
1557     $form->{l_quonumber} = "Y";
 
1558     $callback .= "&rfq=$form->{rfq}";
 
1559     $option   .= $locale->text('RFQ') . " : ";
 
1561   if ($form->{quoted}) {
 
1562     $form->{l_quonumber} = "Y";
 
1563     $callback .= ""ed=$form->{quoted}";
 
1564     $option   .= $locale->text('Quoted') . " : ";
 
1566   if ($form->{bought}) {
 
1567     $form->{l_invnumber} = "Y";
 
1568     $callback .= "&bought=$form->{bought}";
 
1569     $option   .= $locale->text('Bought') . " : ";
 
1571   if ($form->{sold}) {
 
1572     $form->{l_invnumber} = "Y";
 
1573     $callback .= "&sold=$form->{sold}";
 
1574     $option   .= $locale->text('Sold') . " : ";
 
1576   if (   $form->{bought}
 
1581       || $form->{quoted}) {
 
1583     $form->{l_lastcost} = "";
 
1584     $form->{l_name}     = "Y";
 
1585     if ($form->{transdatefrom}) {
 
1586       $callback .= "&transdatefrom=$form->{transdatefrom}";
 
1588         . $locale->text('From')
 
1590         . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
 
1592     if ($form->{transdateto}) {
 
1593       $callback .= "&transdateto=$form->{transdateto}";
 
1595         . $locale->text('To (time)')
 
1597         . $locale->date(\%myconfig, $form->{transdateto}, 1);
 
1603   if ($form->{partnumber}) {
 
1604     $callback .= "&partnumber=$form->{partnumber}";
 
1605     $option   .= $locale->text('Part Number') . qq| : $form->{partnumber}<br>|;
 
1607   if ($form->{partsgroup}) {
 
1608     $callback .= "&partsgroup=$form->{partsgroup}";
 
1609     $option   .= $locale->text('Group') . qq| : $form->{partsgroup}<br>|;
 
1611   if ($form->{serialnumber}) {
 
1612     $callback .= "&serialnumber=$form->{serialnumber}";
 
1614       $locale->text('Serial Number') . qq| : $form->{serialnumber}<br>|;
 
1616   if ($form->{description}) {
 
1617     $callback .= "&description=$form->{description}";
 
1618     $description = $form->{description};
 
1622       $locale->text('Part Description') . qq| : $form->{description}<br>|;
 
1624   if ($form->{make}) {
 
1625     $callback .= "&make=$form->{make}";
 
1626     $option   .= $locale->text('Make') . qq| : $form->{make}<br>|;
 
1628   if ($form->{model}) {
 
1629     $callback .= "&model=$form->{model}";
 
1630     $option   .= $locale->text('Model') . qq| : $form->{model}<br>|;
 
1632   if ($form->{drawing}) {
 
1633     $callback .= "&drawing=$form->{drawing}";
 
1634     $option   .= $locale->text('Drawing') . qq| : $form->{drawing}<br>|;
 
1636   if ($form->{microfiche}) {
 
1637     $callback .= "µfiche=$form->{microfiche}";
 
1638     $option   .= $locale->text('Microfiche') . qq| : $form->{microfiche}<br>|;
 
1641   # table soldtotal aktive
 
1642   if ($form->{l_soldtotal}) {
 
1643     $callback .= "&soldtotal=$form->{soldtotal}";
 
1644     $option   .= $locale->text('soldtotal') . qq| : $form->{soldtotal}<br>|;
 
1647   if ($form->{l_deliverydate}) {
 
1648     $callback .= "&deliverydate=$form->{deliverydate}";
 
1651   @columns = $form->sort_columns(
 
1652     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)
 
1655   if ($form->{l_linetotal}) {
 
1656     $form->{l_onhand} = "Y";
 
1657     $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
 
1658     if ($form->{l_lastcost}) {
 
1659       $form->{l_linetotallastcost} = "Y";
 
1660       if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
 
1661         $form->{l_linetotallastcost} = "";
 
1664     $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
 
1667   if ($form->{searchitems} eq 'service') {
 
1669     # remove bin, weight and rop from list
 
1670     map { $form->{"l_$_"} = "" } qw(bin weight rop);
 
1672     $form->{l_onhand} = "";
 
1674     # qty is irrelevant unless bought or sold
 
1675     if (   $form->{bought}
 
1680         || $form->{quoted}) {
 
1681       $form->{l_onhand} = "Y";
 
1683       $form->{l_linetotalsellprice} = "";
 
1684       $form->{l_linetotallastcost}  = "";
 
1688   $form->{l_lastcost} = ""
 
1689     if ($form->{searchitems} eq 'assembly' && !$form->{bom});
 
1691   foreach $item (@columns) {
 
1692     if ($form->{"l_$item"} eq "Y") {
 
1693       push @column_index, $item;
 
1695       # add column to callback
 
1696       $callback .= "&l_$item=Y";
 
1700   if ($form->{l_subtotal} eq 'Y') {
 
1701     $callback .= "&l_subtotal=Y";
 
1703   $column_header{partnumber} =
 
1704     qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1705     . $locale->text('Part Number')
 
1707   $column_header{description} =
 
1708     qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1709     . $locale->text('Part Description')
 
1711   $column_header{partsgroup} =
 
1712       qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|
 
1713     . $locale->text('Group')
 
1715   $column_header{bin} =
 
1716       qq|<th><a class=listheading href=$callback&sort=bin>|
 
1717     . $locale->text('Bin')
 
1719   $column_header{priceupdate} =
 
1720       qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|
 
1721     . $locale->text('Updated')
 
1723   $column_header{onhand} =
 
1724     qq|<th nowrap><a  class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1725     . $locale->text('Qty')
 
1727   $column_header{unit} =
 
1728     qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
 
1729   $column_header{listprice} =
 
1730       qq|<th class=listheading nowrap>|
 
1731     . $locale->text('List Price')
 
1733   $column_header{lastcost} =
 
1734     qq|<th class=listheading nowrap>| . $locale->text('Last Cost') . qq|</th>|;
 
1735   $column_header{rop} =
 
1736     qq|<th class=listheading nowrap>| . $locale->text('ROP') . qq|</th>|;
 
1737   $column_header{weight} =
 
1738     qq|<th class=listheading nowrap>| . $locale->text('Weight') . qq|</th>|;
 
1740   $column_header{invnumber} =
 
1741       qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|
 
1742     . $locale->text('Invoice Number')
 
1744   $column_header{ordnumber} =
 
1745       qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|
 
1746     . $locale->text('Order Number')
 
1748   $column_header{quonumber} =
 
1749       qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|
 
1750     . $locale->text('Quotation')
 
1753   $column_header{name} =
 
1754       qq|<th nowrap><a class=listheading href=$callback&sort=name>|
 
1755     . $locale->text('Name')
 
1758   $column_header{sellprice} =
 
1759       qq|<th class=listheading nowrap>|
 
1760     . $locale->text('Sell Price')
 
1762   $column_header{linetotalsellprice} =
 
1763     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1764   $column_header{linetotallastcost} =
 
1765     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1766   $column_header{linetotallistprice} =
 
1767     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1769   $column_header{image} =
 
1770     qq|<th class=listheading nowrap>| . $locale->text('Image') . qq|</a></th>|;
 
1771   $column_header{drawing} =
 
1772       qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|
 
1773     . $locale->text('Drawing')
 
1775   $column_header{microfiche} =
 
1776       qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|
 
1777     . $locale->text('Microfiche')
 
1780   $column_header{serialnumber} =
 
1781       qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|
 
1782     . $locale->text('Serial Number')
 
1784   $column_header{soldtotal} =
 
1785     qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1786     . $locale->text('soldtotal')
 
1789   $column_header{deliverydate} =
 
1790     qq|<th nowrap><a class=listheading href=$callback&sort=deliverydate&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1791     . $locale->text('deliverydate')
 
1795   $colspan = $#column_index + 1;
 
1802     <th class=listtop colspan=$colspan>$form->{title}</th>
 
1804   <tr height="5"></tr>
 
1806   <tr><td colspan=$colspan>$option</td></tr>
 
1808   <tr class=listheading>
 
1811   map { print "\n$column_header{$_}" } @column_index;
 
1817   # add order to callback
 
1818   $form->{callback} = $callback .= "&sort=$form->{sort}";
 
1820   # escape callback for href
 
1821   $callback = $form->escape($callback);
 
1823   if (@{ $form->{parts} }) {
 
1824     $sameitem = $form->{parts}->[0]->{ $form->{sort} };
 
1827   foreach $ref (@{ $form->{parts} }) {
 
1829     if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
 
1830       if ($sameitem ne $ref->{ $form->{sort} }) {
 
1832         $sameitem = $ref->{ $form->{sort} };
 
1836     $ref->{exchangerate} = 1 unless $ref->{exchangerate};
 
1837     $ref->{sellprice} *= $ref->{exchangerate};
 
1838     $ref->{listprice} *= $ref->{exchangerate};
 
1839     $ref->{lastcost}  *= $ref->{exchangerate};
 
1841     # use this for assemblies
 
1842     $onhand = $ref->{onhand};
 
1845     if ($ref->{assemblyitem}) {
 
1847       $onhand = 0 if ($form->{sold});
 
1850     $ref->{description} =~ s/
 
1853     $column_data{partnumber} =
 
1854       "<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>";
 
1855     $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>";
 
1856     $column_data{partsgroup}  = "<td>$ref->{partsgroup} </td>";
 
1858     $column_data{onhand} =
 
1860       . $form->format_amount(\%myconfig, $ref->{onhand})
 
1862     $column_data{sellprice} =
 
1864       . $form->format_amount(\%myconfig, $ref->{sellprice}, -2)
 
1866     $column_data{listprice} =
 
1868       . $form->format_amount(\%myconfig, $ref->{listprice}, -2)
 
1870     $column_data{lastcost} =
 
1872       . $form->format_amount(\%myconfig, $ref->{lastcost}, -2)
 
1875     $column_data{linetotalsellprice} = "<td align=right>"
 
1876       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice}, 2)
 
1878     $column_data{linetotallastcost} = "<td align=right>"
 
1879       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost}, 2)
 
1881     $column_data{linetotallistprice} = "<td align=right>"
 
1882       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice}, 2)
 
1885     if (!$ref->{assemblyitem}) {
 
1886       $totalsellprice += $onhand * $ref->{sellprice};
 
1887       $totallastcost  += $onhand * $ref->{lastcost};
 
1888       $totallistprice += $onhand * $ref->{listprice};
 
1890       $subtotalonhand    += $onhand;
 
1891       $subtotalsellprice += $onhand * $ref->{sellprice};
 
1892       $subtotallastcost  += $onhand * $ref->{lastcost};
 
1893       $subtotallistprice += $onhand * $ref->{listprice};
 
1898       . $form->format_amount(\%myconfig, $ref->{rop}) . "</td>";
 
1899     $column_data{weight} =
 
1901       . $form->format_amount(\%myconfig, $ref->{weight})
 
1903     $column_data{unit}        = "<td>$ref->{unit} </td>";
 
1904     $column_data{bin}         = "<td>$ref->{bin} </td>";
 
1905     $column_data{priceupdate} = "<td>$ref->{priceupdate} </td>";
 
1907     $column_data{invnumber} =
 
1908       ($ref->{module} ne 'oe')
 
1909       ? "<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>"
 
1910       : "<td>$ref->{invnumber}</td>";
 
1911     $column_data{ordnumber} =
 
1912       ($ref->{module} eq 'oe')
 
1913       ? "<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>"
 
1914       : "<td>$ref->{ordnumber}</td>";
 
1915     $column_data{quonumber} =
 
1916       ($ref->{module} eq 'oe' && !$ref->{ordnumber})
 
1917       ? "<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>"
 
1918       : "<td>$ref->{quonumber}</td>";
 
1920     $column_data{name} = "<td>$ref->{name}</td>";
 
1922     $column_data{image} =
 
1924       ? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>"
 
1925       : "<td> </td>";
 
1926     $column_data{drawing} =
 
1928       ? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>"
 
1929       : "<td> </td>";
 
1930     $column_data{microfiche} =
 
1931       ($ref->{microfiche})
 
1932       ? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>"
 
1933       : "<td> </td>";
 
1935     $column_data{serialnumber} = "<td>$ref->{serialnumber}</td>";
 
1937     $column_data{soldtotal} =
 
1939       . $form->format_amount(\%myconfig, $ref->{soldtotal})
 
1942     $column_data{deliverydate} = "<td>$ref->{deliverydate}</td>";
 
1946     print "<tr class=listrow$i>";
 
1948     map { print "\n$column_data{$_}" } @column_index;
 
1956   if ($form->{l_subtotal} eq 'Y') {
 
1960   if ($form->{"l_linetotal"}) {
 
1961     map { $column_data{$_} = "<td> </td>" } @column_index;
 
1962     $column_data{linetotalsellprice} =
 
1963         "<th class=listtotal align=right>"
 
1964       . $form->format_amount(\%myconfig, $totalsellprice, 2)
 
1966     $column_data{linetotallastcost} =
 
1967         "<th class=listtotal align=right>"
 
1968       . $form->format_amount(\%myconfig, $totallastcost, 2)
 
1970     $column_data{linetotallistprice} =
 
1971         "<th class=listtotal align=right>"
 
1972       . $form->format_amount(\%myconfig, $totallistprice, 2)
 
1975     print "<tr class=listtotal>";
 
1977     map { print "\n$column_data{$_}" } @column_index;
 
1984   <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
 
1993 <form method=post action=$form->{script}>
 
1995 <input name=callback type=hidden value="$form->{callback}">
 
1997 <input type=hidden name=item value=$form->{searchitems}>
 
1999 <input type=hidden name=path value=$form->{path}>
 
2000 <input type=hidden name=login value=$form->{login}>
 
2001 <input type=hidden name=password value=$form->{password}>|;
 
2004   <input class=submit type=submit name=action value="|
 
2005     . $locale->text('Add') . qq|">
 
2013   $lxdebug->leave_sub();
 
2014 }    #end generate_report
 
2016 sub parts_subtotal {
 
2017   $lxdebug->enter_sub();
 
2019   map { $column_data{$_} = "<td> </td>" } @column_index;
 
2020   $subtotalonhand = 0 if ($form->{searchitems} eq 'assembly' && $form->{bom});
 
2022   $column_data{onhand} =
 
2023       "<th class=listsubtotal align=right>"
 
2024     . $form->format_amount(\%myconfig, $subtotalonhand)
 
2027   $column_data{linetotalsellprice} =
 
2028       "<th class=listsubtotal align=right>"
 
2029     . $form->format_amount(\%myconfig, $subtotalsellprice, 2)
 
2031   $column_data{linetotallistprice} =
 
2032       "<th class=listsubtotal align=right>"
 
2033     . $form->format_amount(\%myconfig, $subtotallistprice, 2)
 
2035   $column_data{linetotallastcost} =
 
2036       "<th class=listsubtotal align=right>"
 
2037     . $form->format_amount(\%myconfig, $subtotallastcost, 2)
 
2040   $subtotalonhand    = 0;
 
2041   $subtotalsellprice = 0;
 
2042   $subtotallistprice = 0;
 
2043   $subtotallastcost  = 0;
 
2045   print "<tr class=listsubtotal>";
 
2047   map { print "\n$column_data{$_}" } @column_index;
 
2053   $lxdebug->leave_sub();
 
2057   $lxdebug->enter_sub();
 
2058   # show history button
 
2059   $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
 
2060   #/show hhistory button
 
2061   IC->get_part(\%myconfig, \%$form);
 
2063   $form->{"original_partnumber"} = $form->{"partnumber"};
 
2065   $form->{title} = $locale->text('Edit ' . ucfirst $form->{item});
 
2070   $lxdebug->leave_sub();
 
2074   $lxdebug->enter_sub();
 
2076   IC->create_links("IC", \%myconfig, \%$form);
 
2079   map({ $form->{selectcurrency} .= "<option>$_\n" }
 
2080       split(/:/, $form->{currencies}));
 
2082   # parts and assemblies have the same links
 
2083   $item = $form->{item};
 
2084   if ($form->{item} eq 'assembly') {
 
2088   # build the popup menus
 
2089   $form->{taxaccounts} = "";
 
2090   foreach $key (keys %{ $form->{IC_links} }) {
 
2091     foreach $ref (@{ $form->{IC_links}{$key} }) {
 
2093       # if this is a tax field
 
2094       if ($key =~ /IC_tax/) {
 
2095         if ($key =~ /$item/) {
 
2096           $form->{taxaccounts} .= "$ref->{accno} ";
 
2097           $form->{"IC_tax_$ref->{accno}_description"} =
 
2098             "$ref->{accno}--$ref->{description}";
 
2101             if ($form->{amount}{ $ref->{accno} }) {
 
2102               $form->{"IC_tax_$ref->{accno}"} = "checked";
 
2105             $form->{"IC_tax_$ref->{accno}"} = "checked";
 
2110         $form->{"select$key"} .=
 
2111           "<option $ref->{selected}>$ref->{accno}--$ref->{description}\n";
 
2112         if ($form->{amount}{$key} eq $ref->{accno}) {
 
2113           $form->{$key} = "$ref->{accno}--$ref->{description}";
 
2119   chop $form->{taxaccounts};
 
2121   if (($form->{item} eq "part") || ($form->{item} eq "assembly")) {
 
2122     $form->{selectIC_income}  = $form->{selectIC_sale};
 
2123     $form->{selectIC_expense} = $form->{selectIC_cogs};
 
2124     $form->{IC_income}        = $form->{IC_sale};
 
2125     $form->{IC_expense}       = $form->{IC_cogs};
 
2128   delete $form->{IC_links};
 
2129   delete $form->{amount};
 
2131   $form->get_partsgroup(\%myconfig, { all => 1 });
 
2133   $form->{partsgroup} = "$form->{partsgroup}--$form->{partsgroup_id}";
 
2135   if (@{ $form->{all_partsgroup} }) {
 
2136     $form->{selectpartsgroup} = qq|<option>\n|;
 
2138       $form->{selectpartsgroup} .=
 
2139         qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n|
 
2140     } @{ $form->{all_partsgroup} };
 
2143   if ($form->{item} eq 'assembly') {
 
2145     foreach $i (1 .. $form->{assembly_rows}) {
 
2146       if ($form->{"partsgroup_id_$i"}) {
 
2147         $form->{"partsgroup_$i"} =
 
2148           qq|$form->{"partsgroup_$i"}--$form->{"partsgroup_id_$i"}|;
 
2151     $form->get_partsgroup(\%myconfig);
 
2153     if (@{ $form->{all_partsgroup} }) {
 
2154       $form->{selectassemblypartsgroup} = qq|<option>\n|;
 
2157         $form->{selectassemblypartsgroup} .=
 
2158           qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n|
 
2159       } @{ $form->{all_partsgroup} };
 
2162   $lxdebug->leave_sub();
 
2166   $lxdebug->enter_sub();
 
2168   map({ $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, -2) }
 
2169       qw(sellprice listprice lastcost gv));
 
2171   map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}) }
 
2172     qw(weight rop stock);
 
2174   foreach $item (qw(partnumber description unit notes)) {
 
2175     $form->{$item} =~ s/\"/"/g;
 
2178   $payment = qq|<option value=""></option>|;
 
2179   foreach $item (@{ $form->{payment_terms} }) {
 
2180     if ($form->{payment_id} eq $item->{id}) {
 
2181       $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
 
2183       $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
 
2188   if (($rows = $form->numtextrows($form->{notes}, 40)) < 2) {
 
2193     qq|<textarea name=notes rows=$rows cols=45 wrap=soft>$form->{notes}</textarea>|;
 
2194   if (($rows = $form->numtextrows($form->{description}, 40)) > 1) {
 
2196       qq|<textarea name="description" rows=$rows cols=40 wrap=soft>$form->{description}</textarea>|;
 
2199       qq|<input name=description size=40 value="$form->{description}">|;
 
2202   $ean =  qq|<input name=ean size=40 value="$form->{ean}">|;
 
2204   foreach $item (split / /, $form->{taxaccounts}) {
 
2205     $form->{"IC_tax_$item"} = ($form->{"IC_tax_$item"}) ? "checked" : "";
 
2208   IC->retrieve_buchungsgruppen(\%myconfig, $form);
 
2209   if (@{ $form->{BUCHUNGSGRUPPEN} }) {
 
2210     foreach $item (@{ $form->{BUCHUNGSGRUPPEN} }) {
 
2211       if ($item->{id} == $form->{buchungsgruppen_id}) {
 
2212         $form->{selectbuchungsgruppe} .=
 
2213           "<option value=$item->{id} selected>$item->{description}\n";
 
2214       } elsif (($form->{id} && $form->{orphaned}) || (!$form->{id})) {
 
2215         $form->{selectbuchungsgruppe} .=
 
2216           "<option value=$item->{id}>$item->{description}\n";
 
2222   $buchungsgruppe = qq|
 
2224                 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
 
2225                 <td><select name=buchungsgruppen_id>$form->{selectbuchungsgruppe}</select></td>
 
2230   foreach $item (qw(IC IC_income IC_expense)) {
 
2231     if ($form->{$item}) {
 
2232       if ($form->{id} && $form->{orphaned}) {
 
2233         $form->{"select$item"} =~ s/ selected//;
 
2234         $form->{"select$item"} =~
 
2235           s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
 
2237         $form->{"select$item"} = qq|<option selected>$form->{$item}|;
 
2242   if ($form->{selectpartsgroup}) {
 
2243     $form->{selectpartsgroup} = $form->unescape($form->{selectpartsgroup});
 
2245       qq|<input type=hidden name=selectpartsgroup value="|
 
2246       . $form->escape($form->{selectpartsgroup}, 1) . qq|">|;
 
2247     $form->{selectpartsgroup} =~
 
2248       s/(<option value="\Q$form->{partsgroup}\E")/$1 selected/;
 
2251       qq|<select name=partsgroup>$form->{selectpartsgroup}</select>|;
 
2252     $group = $locale->text('Group');
 
2256   foreach $item (split / /, $form->{taxaccounts}) {
 
2258       <input class=checkbox type=checkbox name="IC_tax_$item" value=1 $form->{"IC_tax_$item"}> <b>$form->{"IC_tax_${item}_description"}</b>
 
2259       <br><input type=hidden name=IC_tax_${item}_description value="$form->{"IC_tax_${item}_description"}">
 
2263   $form->{obsolete} = "checked" if $form->{obsolete};
 
2267                 <th align="right" nowrap="true">|
 
2268     . $locale->text('Last Cost') . qq|</th>
 
2269                 <td><input name=lastcost size=11 value=$form->{lastcost}></td>
 
2275                 <th align=right>| . $locale->text('Inventory') . qq|</th>
 
2276                 <td><select name=IC>$form->{selectIC}</select></td>
 
2277                 <input name=selectIC type=hidden value="$form->{selectIC}">
 
2281   if ($form->{item} eq "part") {
 
2283     $linkaccounts .= qq|
 
2285                 <th align=right>| . $locale->text('Revenue') . qq|</th>
 
2286                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
 
2287                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
 
2290                 <th align=right>| . $locale->text('Expense') . qq|</th>
 
2291                 <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
 
2292                 <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
 
2298                 <th align="right" nowrap="true">| . $locale->text('Weight') . qq|</th>
 
2303                         <input name=weight size=10 value=$form->{weight}>
 
2313   if ($form->{item} eq "assembly") {
 
2319                 <th align=right>| . $locale->text('Revenue') . qq|</th>
 
2320                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
 
2321                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
 
2327                 <th align="right" nowrap="true">| . $locale->text('Weight') . qq|</th>
 
2332                          $form->{weight}
 
2333                         <input type=hidden name=weight value=$form->{weight}>
 
2343   if ($form->{item} eq "service") {
 
2347                 <th align=right>| . $locale->text('Revenue') . qq|</th>
 
2348                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
 
2349                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
 
2352                 <th align=right>| . $locale->text('Expense') . qq|</th>
 
2353                 <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
 
2354                 <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
 
2359   $linkaccounts = qq|<input type=hidden name=IC_income value="$form->{IC_income_default}">|;
 
2361   if ($form->{IC_cogs_default}) {
 
2362     $form->{IC_expense_default} = $form->{IC_cogs_default};
 
2365   if (($form->{item} eq "service") || ($form->{item} eq "part")) {
 
2366     $linkaccounts .= qq|<input type=hidden name=IC_expense value="$form->{IC_expense_default}">|;
 
2368   if ($form->{item} eq "part") {
 
2369     $linkaccounts .= qq|<input type=hidden name=IC value="$form->{IC_default}">|;
 
2372   if ($form->{item} ne 'service') {
 
2373     $n   = ($form->{onhand} > 0) ? "1" : "0";
 
2376                 <th align="right" nowrap>| . $locale->text('On Hand') . qq|</th>
 
2377                 <th align=left nowrap class="plus$n"> |
 
2378       . $form->format_amount(\%myconfig, $form->{onhand}) . qq|</th>
 
2382     if ($form->{item} eq 'assembly') {
 
2385                 <th align="right" nowrap>| . $locale->text('Stock') . qq|</th>
 
2386                 <td><input name=stock size=10 value=$form->{stock}></td>
 
2393                 <th align="right" nowrap="true">| . $locale->text('ROP') . qq|</th>
 
2394                 <td><input name=rop size=10 value=$form->{rop}></td>
 
2400                 <th align="right" nowrap="true">| . $locale->text('Bin') . qq|</th>
 
2401                 <td><input name=bin size=10 value=$form->{bin}></td>
 
2406                 <th align="right" nowrap="true">|
 
2407       . $locale->text('Verrechnungseinheit') . qq|</th>
 
2408                 <td><input name=ve size=10 value=$form->{ve}></td>
 
2411                 <th align="right" nowrap="true">|
 
2412       . $locale->text('Geschäftsvolumen') . qq|</th>
 
2413                 <td><input name=gv size=10 value=$form->{gv}></td>
 
2416     $notdiscountableok = ($form->{not_discountable}) == 1 ? "checked" : "";
 
2417     $notdiscountable .= qq|
 
2419                 <th align=right nowrap>|
 
2420     . $locale->text('Not Discountable') . qq|</th>
 
2421                 <td><input class=checkbox type=checkbox name=not_discountable value=1 $notdiscountableok></td>
 
2426     qq|<ilayer><layer  onmouseover="this.T_STICKY=true;this.T_STATIC=true;return escape('| . $locale->text('The formula needs the following syntax:<br>For regular article:<br>Variablename= Variable Unit;<br>Variablename2= Variable2 Unit2;<br>...<br>###<br>Variable + ( Variable2 / Variable )<br><b>Please be beware of the spaces in the formula</b><br>') . qq|')"><textarea name=formel rows=4 cols=30 wrap=soft>$form->{formel}</textarea></layer><ilayer>|;
 
2432           <th align=right nowrap>| . $locale->text('Image') . qq|</th>
 
2433           <td><input name=image size=40 value="$form->{image}"></td>
 
2434           <th align=right nowrap>| . $locale->text('Microfiche') . qq|</th>
 
2435           <td><input name=microfiche size=20 value="$form->{microfiche}"></td>
 
2438           <th align=right nowrap>| . $locale->text('Drawing') . qq|</th>
 
2439           <td><input name=drawing size=40 value="$form->{drawing}"></td>
 
2451                 <th align="right" nowrap="true">| . $locale->text('Obsolete') . qq|</th>
 
2452                 <td><input name=obsolete type=checkbox class=checkbox value=1 $form->{obsolete}></td>
 
2456   $shopok = $form->{shop} == 1 ? "checked" : "";
 
2459                 <th align=right nowrap>|
 
2460     . $locale->text('Shopartikel') . qq|</th>
 
2461                 <td><input class=checkbox type=checkbox name=shop value=1 $shopok></td>
 
2466   # type=submit $locale->text('Add Part')
 
2467   # type=submit $locale->text('Add Service')
 
2468   # type=submit $locale->text('Add Assembly')
 
2470   # type=submit $locale->text('Edit Part')
 
2471   # type=submit $locale->text('Edit Service')
 
2472   # type=submit $locale->text('Edit Assembly')
 
2473   # use JavaScript Calendar or not
 
2474   $form->{jsscript} = $jscalendar;
 
2476   if ($form->{jsscript}) {
 
2478     # with JavaScript Calendar
 
2480        <td width="13"><input name=priceupdate id=priceupdate size=11  title="$myconfig{dateformat}" value="$form->{priceupdate}"></td>
 
2481        <td width="4" align="left"><input type=button name=priceupdate id="trigger1" value=|
 
2482       . $locale->text('button') . qq|></td>
 
2487       Form->write_trigger(\%myconfig, "1", "priceupdate", "BL", "trigger1");
 
2490     # without JavaScript Calendar
 
2492                               <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
 
2495   my $unit_select = '<input type="hidden" name="unit_changeable" value="' . $form->{"unit_changeable"} . '">';
 
2496   if (!$form->{"unit_changeable"}) {
 
2497     $unit_select .= '<input type="hidden" name="unit" value="' . $form->{"unit"} . '">' . $form->{"unit"};
 
2499     my $units = AM->retrieve_units(\%myconfig, $form, $form->{"item"} eq "service" ? "service" : "dimension");
 
2500     $unit_select .= AM->unit_select_html($units, "unit", $form->{"unit"});
 
2503   $form->{fokus} = "ic.partnumber";
 
2507   <body onLoad="fokus()">
 
2508  <script type="text/javascript" src="js/common.js"></script>
 
2509  <script type="text/javascript" src="js/parts_language_selection.js"></script>
 
2511 <form method=post name="ic" action=$form->{script}>
 
2513 <input name=id type=hidden value=$form->{id}>
 
2514 <input name=item type=hidden value=$form->{item}>
 
2515 <input name=title type=hidden value="$form->{title}">
 
2516 <input name=makemodel type=hidden value="$form->{makemodel}">
 
2517 <input name=alternate type=hidden value="$form->{alternate}">
 
2518 <input name=onhand type=hidden value=$form->{onhand}>
 
2519 <input name=orphaned type=hidden value=$form->{orphaned}>
 
2520 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
 
2521 <input name=rowcount type=hidden value=$form->{rowcount}>
 
2522 <input name=eur type=hidden value=$eur>
 
2523 <input name=language_values type=hidden value="$form->{language_values}">
 
2524 <input name="original_partnumber" type="hidden" value="| . $form->quote($form->{"original_partnumber"}) . qq|">
 
2526 <table width="100%">
 
2528     <th class=listtop>$form->{title}</th>
 
2530   <tr height="5"></tr>
 
2533       <table width="100%">
 
2535           <th align=left>| . $locale->text('Part Number') . qq|</th>
 
2536           <th align=left>| . $locale->text('Part Description') . qq|</th>
 
2537           <th align=left>$group</th>
 
2540           <td><input name=partnumber value="$form->{partnumber}" size=20></td>
 
2541           <td>$description</td>
 
2542           <td>$partsgroup</td>
 
2543           <input type=hidden name=oldpartsgroup value="$form->{oldpartsgroup}">
 
2550       <table width="100%" height="100%">
 
2553             <table width="100%" height="100%">
 
2554               <tr class="listheading">
 
2555                 <th class="listheading" align="center" colspan=2>|
 
2556     . $locale->text('') . qq|</th>
 
2565                 <th align="left">| . $locale->text('Notes') . qq|</th>
 
2566                 <th align="left">| . $locale->text('Formula') . qq|</th>
 
2577                 <th align="left"></th>
 
2578                 <th align="left">| . $locale->text('EAN-Code') . qq|</th>
 
2582                   <button type="button" onclick="parts_language_selection_window('language_values')">| . $locale->text('Set Language Values') . qq|</button>
 
2592                <th align=right>| . $locale->text('Payment Terms') . qq|</th>
 
2593                  <td><select name=payment_id>$payment</select></td>
 
2601             <table width="100%">
 
2603                 <th align="right" nowrap="true">|
 
2604     . $locale->text('Updated') . qq|</th>
 
2608                 <th align="right" nowrap="true">| . $locale->text('List Price') . qq|</th>
 
2609                 <td><input name=listprice size=11 value=$form->{listprice}></td>
 
2612                 <th align="right" nowrap="true">| . $locale->text('Sell Price') . qq|</th>
 
2613                 <td><input name=sellprice size=11 value=$form->{sellprice}></td>
 
2617                 <th align="right" nowrap="true">| . $locale->text('Unit') . qq|</th>
 
2618                 <td>$unit_select</td>
 
2637   $lxdebug->leave_sub();
 
2641   $lxdebug->enter_sub();
 
2643   if ($form->{item} eq "assembly") {
 
2648             <table width="100%">
 
2650                 <th colspan=2 align=right>|
 
2651       . $locale->text('Total') . qq| </th>
 
2653       . $form->format_amount(\%myconfig, $form->{assemblytotal}, 2) . qq|</th>
 
2658         <input type=hidden name=assembly_rows value=$form->{assembly_rows}>
 
2663       <input type=hidden name=path value=$form->{path}>
 
2664       <input type=hidden name=login value=$form->{login}>
 
2665       <input type=hidden name=password value=$form->{password}>
 
2666       <input type=hidden name=callback value="$form->{callback}">
 
2667       <input type=hidden name=previousform value="$form->{previousform}">
 
2668       <input type=hidden name=taxaccount2 value="$form->{taxaccount2}">
 
2669       <input type=hidden name=vc value=$form->{vc}>
 
2671     <td><hr size=3 noshade></td>
 
2676 <input class=submit type=submit name=action value="|
 
2677     . $locale->text('Update') . qq|">
 
2680   unless ($form->{item} eq "service") {
 
2682       <input type=hidden name=makemodel_rows value=$form->{makemodel_rows}>
 
2687      <input type=hidden name=price_rows value=$form->{price_rows}>|;
 
2690       <input class=submit type=submit name=action value="|
 
2691     . $locale->text('Save') . qq|">|;
 
2695     if (!$form->{previousform}) {
 
2697       <input class=submit type=submit name=action value="|
 
2698         . $locale->text('Save as new') . qq|">|;
 
2701     if ($form->{orphaned}) {
 
2702       if (!$form->{previousform}) {
 
2703         if ($form->{item} eq 'assembly') {
 
2704           if (!$form->{onhand}) {
 
2706       <input class=submit type=submit name=action value="|
 
2707               . $locale->text('Delete') . qq|">|;
 
2711       <input class=submit type=submit name=action value="|
 
2712             . $locale->text('Delete') . qq|">|;
 
2718   if (!$form->{previousform}) {
 
2719     if ($form->{menubar}) {
 
2720       require "$form->{path}/menu.pl";
 
2724 # button for saving history
 
2725   if($form->{id} ne "") {
 
2727                 <input type=button class=submit onclick=set_history_window(|
 
2729                 . qq|); name=history id=history value=|
 
2730                 . $locale->text('history') 
 
2733 # /button for saving history
 
2738 <script type="text/javascript" src="js/wz_tooltip.js"></script>
 
2744   $lxdebug->leave_sub();
 
2748   $lxdebug->enter_sub();
 
2751   $form->{"make_$i"}  =~ s/\"/"/g;
 
2752   $form->{"model_$i"} =~ s/\"/"/g;
 
2759           <th class="listheading">| . $locale->text('Make') . qq|</th>
 
2760           <th class="listheading">| . $locale->text('Model') . qq|</th>
 
2764   for $i (1 .. $numrows) {
 
2767           <td width=50%><input name="make_$i" size=30 value="$form->{"make_$i"}"></td>
 
2768           <td width=50%><input name="model_$i" size=30 value="$form->{"model_$i"}"></td>
 
2779   $lxdebug->leave_sub();
 
2783   $lxdebug->enter_sub();
 
2787     qw(runningnumber qty unit bom partnumber description partsgroup total);
 
2789   if ($form->{previousform}) {
 
2791     @column_index = qw(qty unit bom partnumber description partsgroup total);
 
2795     $form->{old_callback} = $form->{callback};
 
2796     $callback             = $form->{callback};
 
2797     $form->{callback}     = "$form->{script}?action=display_form";
 
2800     map { delete $form->{$_} } qw(action header);
 
2804     # save form variables in a previousform variable
 
2805     foreach $key (sort keys %$form) {
 
2808       $form->{$key} =~ s/&/%26/g;
 
2809       $previousform .= qq|$key=$form->{$key}&|;
 
2812     $previousform = $form->escape($form->escape($previousform, 1));
 
2813     $form->{callback} = $callback;
 
2815     $form->{assemblytotal} = 0;
 
2816     $form->{weight}        = 0;
 
2819   $column_header{runningnumber} =
 
2820     qq|<th nowrap width=5%>| . $locale->text('No.') . qq|</th>|;
 
2821   $column_header{qty} =
 
2822     qq|<th align=left nowrap width=10%>| . $locale->text('Qty') . qq|</th>|;
 
2823   $column_header{unit} =
 
2824     qq|<th align=left nowrap width=5%>| . $locale->text('Unit') . qq|</th>|;
 
2825   $column_header{partnumber} =
 
2826       qq|<th align=left nowrap width=20%>|
 
2827     . $locale->text('Part Number')
 
2829   $column_header{description} =
 
2830     qq|<th nowrap width=50%>| . $locale->text('Part Description') . qq|</th>|;
 
2831   $column_header{total} =
 
2832     qq|<th align=right nowrap>| . $locale->text('Extended') . qq|</th>|;
 
2833   $column_header{bom}        = qq|<th>| . $locale->text('BOM') . qq|</th>|;
 
2834   $column_header{partsgroup} = qq|<th>| . $locale->text('Group') . qq|</th>|;
 
2837   <tr class=listheading>
 
2838     <th class=listheading>| . $locale->text('Individual Items') . qq|</th>
 
2846   map { print "\n$column_header{$_}" } @column_index;
 
2852   for $i (1 .. $numrows) {
 
2853     $form->{"partnumber_$i"} =~ s/\"/"/g;
 
2856       $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
 
2857     $form->{assemblytotal} += $linetotal;
 
2859     $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
 
2861     $linetotal = $form->format_amount(\%myconfig, $linetotal, 2);
 
2863     if (($i >= 1) && ($i == $numrows)) {
 
2866         map { $column_data{$_} = qq|<td></td>| }
 
2867           qw(qty unit partnumber description bom partsgroup);
 
2870         map { $column_data{$_} = qq|<td></td>| } qw(runningnumber unit bom);
 
2873           qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
 
2874         $column_data{partnumber} =
 
2875           qq|<td><input name="partnumber_$i" size=15 value="$form->{"partnumber_$i"}"></td>|;
 
2876         $column_data{description} =
 
2877           qq|<td><input name="description_$i" size=40 value="$form->{"description_$i"}"></td>|;
 
2878         $column_data{partsgroup} =
 
2879           qq|<td><input name="partsgroup_$i" size=10 value="$form->{"partsgroup_$i"}"></td>|;
 
2885       if ($form->{previousform}) {
 
2886         $column_data{partnumber} =
 
2887           qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}">$form->{"partnumber_$i"}</td>|;
 
2889           qq|<td align=right><input type=hidden name="qty_$i" value="$form->{"qty_$i"}">$form->{"qty_$i"}</td>|;
 
2892           qq|<td align=center><input type=hidden name="bom_$i" value=$form->{"bom_$i"}>|;
 
2893         $column_data{bom} .= ($form->{"bom_$i"}) ? "x" : " ";
 
2894         $column_data{bom} .= qq|</td>|;
 
2896         $column_data{partsgroup} =
 
2897           qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
 
2901           qq|$form->{script}?action=edit&id=$form->{"id_$i"}&path=$form->{path}&login=$form->{login}&password=$form->{password}&rowcount=$i&previousform=$previousform|;
 
2902         $column_data{partnumber} =
 
2903           qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"><a href=$href>$form->{"partnumber_$i"}</a></td>|;
 
2904         $column_data{runningnumber} =
 
2905           qq|<td><input name="runningnumber_$i" size=3 value="$i"></td>|;
 
2907           qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
 
2909         $form->{"bom_$i"} = ($form->{"bom_$i"}) ? "checked" : "";
 
2911           qq|<td align=center><input name="bom_$i" type=checkbox class=checkbox value=1 $form->{"bom_$i"}></td>|;
 
2913         $column_data{partsgroup} =
 
2914           qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
 
2917       $column_data{unit} =
 
2918         qq|<td><input type=hidden name="unit_$i" value="$form->{"unit_$i"}">$form->{"unit_$i"}</td>|;
 
2919       $column_data{description} =
 
2920         qq|<td><input type=hidden name="description_$i" value="$form->{"description_$i"}">$form->{"description_$i"}</td>|;
 
2923     $column_data{total} = qq|<td align=right>$linetotal</td>|;
 
2925     $column_data{deliverydate} = qq|<td align=right>$deliverydate</td>|;
 
2930     map { print "\n$column_data{$_}" } @column_index;
 
2934   <input type=hidden name="id_$i" value=$form->{"id_$i"}>
 
2935   <input type=hidden name="sellprice_$i" value=$form->{"sellprice_$i"}>
 
2936   <input type=hidden name="weight_$i" value=$form->{"weight_$i"}>
 
2946   $lxdebug->leave_sub();
 
2950   $lxdebug->enter_sub();
 
2952   if ($form->{item} eq "assembly") {
 
2953     $i = $form->{assembly_rows};
 
2955     # if last row is empty check the form otherwise retrieve item
 
2956     if (   ($form->{"partnumber_$i"} eq "")
 
2957         && ($form->{"description_$i"} eq "")
 
2958         && ($form->{"partsgroup_$i"}  eq "")) {
 
2964       IC->assembly_item(\%myconfig, \%$form);
 
2966       $rows = scalar @{ $form->{item_list} };
 
2969         $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
 
2972           $form->{makemodel_rows}--;
 
2976           map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
 
2977             qw(partnumber description unit partsgroup);
 
2978           map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
 
2979             keys %{ $form->{item_list}[0] };
 
2980           $form->{"runningnumber_$i"} = $form->{assembly_rows};
 
2981           $form->{assembly_rows}++;
 
2989         $form->{rowcount} = $i;
 
2990         $form->{assembly_rows}++;
 
2998   if ($form->{item} eq "part") {
 
3002   if ($form->{item} eq 'service') {
 
3003     map({ $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
3004         qw(sellprice listprice lastcost));
 
3010   $lxdebug->leave_sub();
 
3014   $lxdebug->enter_sub();
 
3016   # check if there is a part number - commented out, cause there is an automatic allocation of numbers
 
3017   # $form->isblank("partnumber", $locale->text(ucfirst $form->{item}." Part Number missing!"));
 
3019   # check if there is a description
 
3020   $form->isblank("description", $locale->text("Part Description missing!"));
 
3022   if ($form->{obsolete}) {
 
3025         "Inventory quantity must be zero before you can set this $form->{item} obsolete!"
 
3027       if ($form->{onhand} * 1);
 
3030   if (!$form->{buchungsgruppen_id}) {
 
3031     $form->error($locale->text("Parts must have an entry type.") . " " . 
 
3032      $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.") 
 
3036   $form->error($locale->text('Description must not be empty!')) unless $form->{description};
 
3037   $form->error($locale->text('Partnumber must not be set to empty!')) if $form->{id} && !$form->{partnumber};
 
3039   # expand dynamic strings
 
3040   # $locale->text('Inventory quantity must be zero before you can set this part obsolete!')
 
3041   # $locale->text('Inventory quantity must be zero before you can set this assembly obsolete!')
 
3042   # $locale->text('Part Number missing!')
 
3043   # $locale->text('Service Number missing!')
 
3044   # $locale->text('Assembly Number missing!')
 
3047   $lxdebug->message(LXDebug::DEBUG1,
 
3048                     "ic.pl: sellprice in save = $form->{sellprice}\n");
 
3049   $rc = IC->save(\%myconfig, \%$form);
 
3051     $form->error($locale->text('Partnumber not unique!'));
 
3053   # saving the history
 
3054   if(!exists $form->{addition}) {
 
3055         $form->{addition} = "SAVED";
 
3056         $form->save_history($form->dbconnect(\%myconfig));
 
3058   # /saving the history
 
3059   $parts_id = $form->{id};
 
3061   # load previous variables
 
3062   if ($form->{previousform}) {
 
3064     # save the new form variables before splitting previousform
 
3065     map { $newform{$_} = $form->{$_} } keys %$form;
 
3067     $previousform = $form->unescape($form->{previousform});
 
3069     # don't trample on previous variables
 
3070     map { delete $form->{$_} } keys %newform;
 
3072     # now take it apart and restore original values
 
3073     foreach $item (split /&/, $previousform) {
 
3074       ($key, $value) = split /=/, $item, 2;
 
3075       $value =~ s/%26/&/g;
 
3076       $form->{$key} = $value;
 
3078     $form->{taxaccounts} = $newform{taxaccount2};
 
3080     if ($form->{item} eq 'assembly') {
 
3082       # undo number formatting
 
3083       map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
3084         qw(weight listprice sellprice rop);
 
3086       $form->{assembly_rows}--;
 
3087       $i = $newform{rowcount};
 
3088       $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
 
3090       $form->{sellprice} -= $form->{"sellprice_$i"} * $form->{"qty_$i"};
 
3091       $form->{weight}    -= $form->{"weight_$i"} * $form->{"qty_$i"};
 
3093       # change/add values for assembly item
 
3094       map { $form->{"${_}_$i"} = $newform{$_} }
 
3095         qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno);
 
3097       $form->{sellprice} += $form->{"sellprice_$i"} * $form->{"qty_$i"};
 
3098       $form->{weight}    += $form->{"weight_$i"} * $form->{"qty_$i"};
 
3102       # set values for last invoice/order item
 
3103       $i = $form->{rowcount};
 
3104       $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
 
3106       map { $form->{"${_}_$i"} = $newform{$_} }
 
3107         qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice);
 
3108       $form->{"sellprice_$i"} = $newform{lastcost} if ($form->{vendor_id});
 
3109       if ($form->{exchangerate} != 0) {
 
3110         $form->{"sellprice_$i"} /= $form->{exchangerate};
 
3112       $lxdebug->message(LXDebug::DEBUG1,
 
3113                         qq|sellprice_$i in previousform 2 = |
 
3114                           . $form->{"sellprice_$i"} . qq|\n|);
 
3115       map { $form->{"taxaccounts_$i"} .= "$_ " } split / /,
 
3116         $newform{taxaccount};
 
3117       chop $form->{"taxaccounts_$i"};
 
3118       foreach $item (qw(description rate taxnumber)) {
 
3119         $index = $form->{"taxaccounts_$i"} . "_$item";
 
3120         $form->{$index} = $newform{$index};
 
3123       # credit remaining calculation
 
3125         $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
 
3127       map { $form->{"${_}_base"} += $amount }
 
3128         (split / /, $form->{"taxaccounts_$i"});
 
3129       map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
 
3130         split / /, $form->{"taxaccounts_$i"}
 
3131         if !$form->{taxincluded};
 
3133       $form->{creditremaining} -= $amount;
 
3135       # redo number formatting, because invoice parse them!
 
3136       $i = $form->{rowcount};
 
3138         $form->{"${_}_$i"} =
 
3139           $form->format_amount(\%myconfig, $form->{"${_}_$i"})
 
3140       } qw(weight listprice sellprice rop);
 
3143     $form->{"id_$i"} = $parts_id;
 
3144     delete $form->{action};
 
3146     # restore original callback
 
3147     $callback = $form->unescape($form->{callback});
 
3148     $form->{callback} = $form->unescape($form->{old_callback});
 
3149     delete $form->{old_callback};
 
3151     $form->{makemodel_rows}--;
 
3153     # put callback together
 
3154     foreach $key (keys %$form) {
 
3156       # do single escape for Apache 2.0
 
3157       $value = $form->escape($form->{$key}, 1);
 
3158       $callback .= qq|&$key=$value|;
 
3160     $form->{callback} = $callback;
 
3162   $lxdebug->message(LXDebug::DEBUG1,
 
3163                     qq|ic.pl: sellprice_$i nach sub save = |
 
3164                       . $form->{"sellprice_$i"} . qq|\n|);
 
3169   $lxdebug->leave_sub();
 
3173   $lxdebug->enter_sub();
 
3175   # saving the history
 
3176   if(!exists $form->{addition}) {
 
3177         $form->{addition} = "SAVED AS NEW";
 
3178         $form->save_history($form->dbconnect(\%myconfig));
 
3180   # /saving the history
 
3182   if ($form->{"original_partnumber"} &&
 
3183       ($form->{"partnumber"} eq $form->{"original_partnumber"})) {
 
3184     $form->{partnumber} = "";
 
3187   $lxdebug->leave_sub();
 
3191   $lxdebug->enter_sub();
 
3192   # saving the history
 
3193   if(!exists $form->{addition}) {
 
3194         $form->{addition} = "DELETED";
 
3195         $form->save_history($form->dbconnect(\%myconfig));
 
3197   # /saving the history
 
3198   $rc = IC->delete(\%myconfig, \%$form);
 
3201   $form->redirect($locale->text('Item deleted!')) if ($rc > 0);
 
3202   $form->error($locale->text('Cannot delete item!'));
 
3204   $lxdebug->leave_sub();
 
3208   $lxdebug->enter_sub();
 
3217           <th class="listheading">| . $locale->text('Preisklasse') . qq|</th>
 
3218           <th class="listheading">| . $locale->text('Preis') . qq|</th>
 
3221   for $i (1 .. $numrows) {
 
3224           <td width=50%><input type=hidden name="pricegroup_$i" size=30  value="$form->{"pricegroup_$i"}">$form->{"pricegroup_$i"}</td>
 
3225           <td width=50%><input name="price_$i" size=11 value="$form->{"price_$i"}"></td>
 
3226           <input type=hidden name="pricegroup_id_$i" value="$form->{"pricegroup_id_$i"}">
 
3237   $lxdebug->leave_sub();
 
3240 sub parts_language_selection {
 
3241   $lxdebug->enter_sub();
 
3244   my $languages = IC->retrieve_languages(\%myconfig, $form);
 
3247   my $callback = "$form->{script}?action=parts_language_selection&";
 
3248   map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
 
3249       (qw(login path password name input_name), grep({ /^[fl]_/ } keys %$form)));
 
3251   my @header_sort = qw(name longdescription);
 
3252   my %header_title = ( "name" => $locale->text("Name"),
 
3253                        "longdescription" => $locale->text("Long Description"),
 
3257     map(+{ "column_title" => $header_title{$_},
 
3259            "callback" => $callback,
 
3263   $form->{"title"} = $locale->text("Language Values");
 
3265   print($form->parse_html_template("ic/parts_language_selection", { "HEADER" => \@header,
 
3266                                                                    "LANGUAGES" => $languages,
 
3267                                                                    "onload" => $onload }));
 
3269   $lxdebug->leave_sub();
 
3272 sub continue { &{ $form->{nextsub} } }