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 "bin/mozilla/io.pl";
 
  40 require "bin/mozilla/common.pl";
 
  47   $lxdebug->enter_sub();
 
  49   $form->{title} = $locale->text('Add ' . ucfirst $form->{item});
 
  52     "$form->{script}?action=add&item=$form->{item}&login=$form->{login}&password=$form->{password}"
 
  53     unless $form->{callback};
 
  55   $form->{"unit_changeable"} = 1;
 
  57   IC->get_pricegroups(\%myconfig, \%$form);
 
  61   $lxdebug->leave_sub();
 
  65   $lxdebug->enter_sub();
 
  67   $form->{title} = (ucfirst $form->{searchitems}) . "s";
 
  68   $form->{title} = $locale->text($form->{title});
 
  70   # switch for backward sorting
 
  73   # memory for which table was sort at last time
 
  74   $form->{lastsort} = "";
 
  76   # counter for added entries to top100
 
  77   $form->{ndxs_counter} = 0;
 
  79   # $locale->text('Parts')
 
  80   # $locale->text('Services')
 
  82   # use JavaScript Calendar or not
 
  83   $form->{jsscript} = $jscalendar;
 
  85   if ($form->{jsscript}) {
 
  87     # with JavaScript Calendar
 
  89        <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>
 
  90        <td><input type=button name=transdatefrom id="trigger1" value=|
 
  91       . $locale->text('button') . qq|></td>
 
  94        <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>
 
  95        <td><input type=button name=transdateto name=transdateto id="trigger2" value=|
 
  96       . $locale->text('button') . qq|></td>
 
 101       Form->write_trigger(\%myconfig, "2", "transdatefrom", "BL", "trigger1",
 
 102                           "transdateto", "BL", "trigger2");
 
 105     # without JavaScript Calendar
 
 107                               <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
 
 109                               <td><input name=transdateto id=transdateto size=11 title="$myconfig{dateformat}"></td>|;
 
 112   unless ($form->{searchitems} eq 'service') {
 
 115             <input name=itemstatus class=radio type=radio value=onhand> |
 
 116       . $locale->text('On Hand') . qq|
 
 117             <input name=itemstatus class=radio type=radio value=short> |
 
 118       . $locale->text('Short') . qq|
 
 123           <th align=right nowrap>| . $locale->text('Make') . qq|</th>
 
 124           <td><input name=make size=20></td>
 
 125           <th align=right nowrap>| . $locale->text('Model') . qq|</th>
 
 126           <td><input name=model size=20></td>
 
 131           <th align=right nowrap>| . $locale->text('Serial Number') . qq|</th>
 
 132           <td><input name=serialnumber size=20></td>
 
 135     $l_serialnumber = qq|
 
 136         <td><input name=l_serialnumber class=checkbox type=checkbox value=Y> |
 
 137       . $locale->text('Serial Number') . qq|</td>
 
 142   if ($form->{searchitems} eq 'assembly') {
 
 144     $form->{title} = $locale->text('Assemblies');
 
 150           <input name=null class=radio type=radio value=1 checked> |
 
 151       . $locale->text('Top Level') . qq|
 
 152           <input name=bom class=checkbox type=checkbox value=1> |
 
 153       . $locale->text('Individual Items') . qq|
 
 167                       <td><input name=sold class=checkbox type=checkbox value=1></td>
 
 168                       <td nowrap>| . $locale->text('Sold') . qq|</td>
 
 171                       <td colspan=2><hr size=1 noshade></td>
 
 174                       <td><input name=ordered class=checkbox type=checkbox value=1></td>
 
 175                       <td nowrap>| . $locale->text('Ordered') . qq|</td>
 
 178                       <td colspan=4><hr size=1 noshade></td>
 
 181                       <td><input name=quoted class=checkbox type=checkbox value=1></td>
 
 182                       <td nowrap>| . $locale->text('Quoted') . qq|</td>
 
 186                 <td width=5%> </td>
 
 187                 <th>| . $locale->text('From') . qq|</th>
 
 189                 <th>| . $locale->text('To (time)') . qq|</th>
 
 208                       <td><input name=bought class=checkbox type=checkbox value=1></td>
 
 209                       <td nowrap>| . $locale->text('Bought') . qq|</td>
 
 210                       <td><input name=sold class=checkbox type=checkbox value=1></td>
 
 211                       <td nowrap>| . $locale->text('Sold') . qq|</td>
 
 214                       <td colspan=4><hr size=1 noshade></td>
 
 217                       <td><input name=onorder class=checkbox type=checkbox value=1></td>
 
 218                       <td nowrap>| . $locale->text('On Order') . qq|</td>
 
 219                       <td><input name=ordered class=checkbox type=checkbox value=1></td>
 
 220                       <td nowrap>| . $locale->text('Ordered') . qq|</td>
 
 223                       <td colspan=4><hr size=1 noshade></td>
 
 226                       <td><input name=rfq class=checkbox type=checkbox value=1></td>
 
 227                       <td nowrap>| . $locale->text('RFQ') . qq|</td>
 
 228                       <td><input name=quoted class=checkbox type=checkbox value=1></td>
 
 229                       <td nowrap>| . $locale->text('Quoted') . qq|</td>
 
 233                 <td width=5%> </td>
 
 237                       <th>| . $locale->text('From') . qq|</th>
 
 239                       <th>| . $locale->text('To (time)') . qq|</th>
 
 256 <form method=post action=$form->{script}>
 
 258 <input type=hidden name=searchitems value=$form->{searchitems}>
 
 259 <input type=hidden name=title value="$form->{title}">
 
 261 <input type=hidden name=revers value="$form->{revers}">
 
 262 <input type=hidden name=lastsort value="$form->{lastsort}">
 
 265   <tr><th class=listtop>$form->{title}</th></tr>
 
 271           <th align=right nowrap>| . $locale->text('Part Number') . qq|</th>
 
 272           <td><input name=partnumber size=20></td>
 
 273           <th align=right nowrap>| . $locale->text('EAN') . qq|</th>
 
 274           <td><input name=ean size=20></td>
 
 277           <th align=right nowrap>|
 
 278     . $locale->text('Part Description') . qq|</th>
 
 279           <td colspan=3><input name=description size=40></td>
 
 282           <th align=right nowrap>| . $locale->text('Group') . qq|</th>
 
 283           <td><input name=partsgroup size=20></td>
 
 288           <th align=right nowrap>| . $locale->text('Drawing') . qq|</th>
 
 289           <td><input name=drawing size=20></td>
 
 290           <th align=right nowrap>| . $locale->text('Microfiche') . qq|</th>
 
 291           <td><input name=microfiche size=20></td>
 
 297             <input name=itemstatus class=radio type=radio value=active checked> |
 
 298     . $locale->text('Active') . qq|
 
 300             <input name=itemstatus class=radio type=radio value=obsolete> |
 
 301     . $locale->text('Obsolete') . qq|
 
 302             <input name=itemstatus class=radio type=radio value=orphaned> |
 
 303     . $locale->text('Orphaned') . qq|
 
 314           <th align=right nowrap>|
 
 315     . $locale->text('Include in Report') . qq|</th>
 
 319                 <td><input name=l_partnumber class=checkbox type=checkbox value=Y checked> |
 
 320     . $locale->text('Part Number') . qq|</td>
 
 321                 <td><input name=l_description class=checkbox type=checkbox value=Y checked> |
 
 322     . $locale->text('Part Description') . qq|</td>
 
 324                 <td><input name=l_unit class=checkbox type=checkbox value=Y checked> |
 
 325     . $locale->text('Unit of measure') . qq|</td>
 
 328                 <td><input name=l_listprice class=checkbox type=checkbox value=Y> |
 
 329     . $locale->text('List Price') . qq|</td>
 
 330                 <td><input name=l_sellprice class=checkbox type=checkbox value=Y checked> |
 
 331     . $locale->text('Sell Price') . qq|</td>
 
 332                 <td><input name=l_lastcost class=checkbox type=checkbox value=Y checked> |
 
 333     . $locale->text('Last Cost') . qq|</td>
 
 334                 <td><input name=l_linetotal class=checkbox type=checkbox value=Y checked> |
 
 335     . $locale->text('Line Total') . qq|</td>
 
 338                 <td><input name=l_priceupdate class=checkbox type=checkbox value=Y> |
 
 339     . $locale->text('Updated') . qq|</td>
 
 340                 <td><input name=l_bin class=checkbox type=checkbox value=Y> |
 
 341     . $locale->text('Bin') . qq|</td>
 
 342                 <td><input name=l_rop class=checkbox type=checkbox value=Y> |
 
 343     . $locale->text('ROP') . qq|</td>
 
 344                 <td><input name=l_weight class=checkbox type=checkbox value=Y> |
 
 345     . $locale->text('Weight') . qq|</td>
 
 348                 <td><input name=l_image class=checkbox type=checkbox value=Y> |
 
 349     . $locale->text('Image') . qq|</td>
 
 350                 <td><input name=l_drawing class=checkbox type=checkbox value=Y> |
 
 351     . $locale->text('Drawing') . qq|</td>
 
 352                 <td><input name=l_microfiche class=checkbox type=checkbox value=Y> |
 
 353     . $locale->text('Microfiche') . qq|</td>
 
 354                 <td><input name=l_partsgroup class=checkbox type=checkbox value=Y> |
 
 355     . $locale->text('Group') . qq|</td>
 
 358                 <td><input name=l_subtotal class=checkbox type=checkbox value=Y> |
 
 359     . $locale->text('Subtotal') . qq|</td>
 
 360                 <td><input name=l_soldtotal class=checkbox type=checkbox value=Y> |
 
 361     . $locale->text('soldtotal') . qq|</td>
 
 362                 <td><input name=l_deliverydate class=checkbox type=checkbox value=Y> |
 
 363     . $locale->text('deliverydate') . qq|</td>    
 
 371   <tr><td colspan=4><hr size=3 noshade></td></tr>
 
 376 <input type=hidden name=nextsub value=generate_report>
 
 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=login value=$form->{login}>
 
 562 <input type=hidden name=password value=$form->{password}>
 
 565 <input class=submit type=submit name=action value="|
 
 566     . $locale->text('Continue') . qq|">
 
 572   $lxdebug->leave_sub();
 
 575 sub confirm_price_update {
 
 576   $lxdebug->enter_sub();
 
 579   $form->{nextsub} = "update_prices";
 
 585 <form method=post action=$form->{script}>
 
 588   # delete action variable
 
 589   map { delete $form->{$_} } qw(action header);
 
 591   foreach $key (keys %$form) {
 
 592     $form->{$key} =~ s/\"/"/g;
 
 593     print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
 
 597 <h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2>
 
 600     . $locale->text('Are you sure you want to update the prices')
 
 604 <input name=action class=submit type=submit value="|
 
 605     . $locale->text('Continue') . qq|">
 
 609   $lxdebug->leave_sub();
 
 613   $lxdebug->enter_sub();
 
 615   if (IC->update_prices(\%myconfig, \%$form)) {
 
 616     $form->redirect($form->{update_count} . $locale->text('prices updated!'));
 
 618     $form->error($locale->text('Could not update prices!'));
 
 621   $lxdebug->leave_sub();
 
 625   $lxdebug->enter_sub();
 
 627   $form->{title} = $locale->text('Top 100 hinzufuegen');
 
 634   <form method=post action=$form->{script}>
 
 636   <input type=hidden name=searchitems value=$form->{searchitems}>
 
 637   <input type=hidden name=title value="$form->{title}">
 
 639   <input type=hidden name=revers value="$form->{revers}">
 
 640   <input type=hidden name=lastsort value="$form->{lastsort}">|;
 
 644         <tr class=listheading>
 
 645          <th class=listheading nowrap>|
 
 646     . $locale->text('Part Number') . qq|</th>
 
 647          <th class=listheading nowrap>|
 
 648     . $locale->text('Part Description') . qq|</th>
 
 651          <td><input type=text name=partnumber size=20 value=></td>
 
 652          <td><input type=text name=description size=30 value=></td>
 
 659 <input type=hidden name=login value=$form->{login}>
 
 660 <input type=hidden name=password value=$form->{password}>
 
 662 <input type=hidden name=itemstatus value="$form->{itemstatus}">
 
 663 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
 
 664 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
 
 665 <input type=hidden name=l_description value="$form->{l_description}">
 
 666 <input type=hidden name=l_onhand value="$form->{l_onhand}">
 
 667 <input type=hidden name=l_unit value="$form->{l_unit}">
 
 668 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
 
 669 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
 
 670 <input type=hidden name=sort value="$form->{sort}">
 
 671 <input type=hidden name=revers value="$form->{revers}">
 
 672 <input type=hidden name=lastsort value="$form->{lastsort}">
 
 674 <input type=hidden name=bom value="$form->{bom}">
 
 675 <input type=hidden name=titel value="$form->{titel}">
 
 676 <input type=hidden name=searchitems value="$form->{searchitems}">
 
 678 <input type=hidden name=row value=$j>
 
 680 <input type=hidden name=nextsub value=item_selected>
 
 682 <input type=hidden name=test value=item_selected>
 
 684 <input name=lastndx type=hidden value=$lastndx>
 
 686 <input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>
 
 688 <input name=extras type=hidden value=$form->{extras}>|;
 
 692     for ($i = 0; $i < $form->{ndxs_counter}; $i++) {
 
 695       $partnumber  = $form->{"totop100_partnumber_$j"};
 
 696       $description = $form->{"totop100_description_$j"};
 
 697       $unit        = $form->{"totop100_unit_$j"};
 
 698       $sellprice   = $form->{"totop100_sellprice_$j"};
 
 699       $soldtotal   = $form->{"totop100_soldtotal_$j"};
 
 701       # insert data into top100
 
 702       push @{ $form->{parts} },
 
 704           partnumber  => "$partnumber",
 
 705           description => "$description",
 
 707           sellprice   => "$sellprice",
 
 708           soldtotal   => "$soldtotal" };
 
 714   # set data for next page
 
 715   if (($form->{ndxs_counter}) > 0) {
 
 716     for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
 
 717       $partnumber  = $form->{"totop100_partnumber_$i"};
 
 718       $description = $form->{"totop100_description_$i"};
 
 719       $unit        = $form->{"totop100_unit_$i"};
 
 720       $sellprice   = $form->{"totop100_sellprice_$i"};
 
 721       $soldtotal   = $form->{"totop100_soldtotal_$i"};
 
 724 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
 
 725 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
 
 726 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
 
 727 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
 
 728 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
 
 736      <input class=submit type=submit name=action value="|
 
 737     . $locale->text('list') . qq|">
 
 742   $lxdebug->leave_sub();
 
 746   $lxdebug->enter_sub();
 
 748   my @sortorders = ("", "partnumber", "description", "all");
 
 749   my $sortorder = $sortorders[($form->{description} ? 2 : 0) + ($form->{partnumber} ? 1 : 0)];
 
 750   IC->get_parts(\%myconfig, \%$form, $sortorder);
 
 752   $form->{title} = $locale->text('Top 100 hinzufuegen');
 
 758   <form method=post action=ic.pl>
 
 761       <th class=listtop colspan=6>| . $locale->text('choice part') . qq|</th>
 
 764         <tr class=listheading>
 
 766           <th class=listheading>| . $locale->text('Part Number') . qq|</th>
 
 767           <th class=listheading>| . $locale->text('Part Description') . qq|</th>
 
 768           <th class=listheading>| . $locale->text('Unit of measure') . qq|</th>
 
 769           <th class=listheading>| . $locale->text('Sell Price') . qq|</th>
 
 770           <th class=listheading>| . $locale->text('soldtotal') . qq|</th>
 
 774   my $i = $form->{rows};
 
 776   for ($j = 1; $j <= $i; $j++) {
 
 779         <tr class=listrow1>|;
 
 782             <td><input name=ndx class=radio type=radio value=$j checked></td>|;
 
 785           <td><input name=ndx class=radio type=radio value=$j></td>|;
 
 788           <td><input name="new_partnumber_$j" type=hidden value="$form->{"partnumber_$j"}">$form->{"partnumber_$j"}</td>
 
 789           <td><input name="new_description_$j" type=hidden value="$form->{"description_$j"}">$form->{"description_$j"}</td>
 
 790           <td><input name="new_unit_$j" type=hidden value="$form->{"unit_$j"}">$form->{"unit_$j"}</td>
 
 791           <td><input name="new_sellprice_$j" type=hidden value="$form->{"sellprice_$j"}">$form->{"sellprice_$j"}</td>
 
 792           <td><input name="new_soldtotal_$j" type=hidden value="$form->{"soldtotal_$j"}">$form->{"soldtotal_$j"}</td>
 
 795         <input name="new_id_$j" type=hidden value="$form->{"id_$j"}">|;
 
 805 <input type=hidden name=login value=$form->{login}>
 
 806 <input type=hidden name=password value=$form->{password}>
 
 808 <input type=hidden name=itemstatus value="$form->{itemstatus}">
 
 809 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
 
 810 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
 
 811 <input type=hidden name=l_description value="$form->{l_description}">
 
 812 <input type=hidden name=l_onhand value="$form->{l_onhand}">
 
 813 <input type=hidden name=l_unit value="$form->{l_unit}">
 
 814 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
 
 815 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
 
 816 <input type=hidden name=sort value="$form->{sort}">
 
 817 <input type=hidden name=revers value="$form->{revers}">
 
 818 <input type=hidden name=lastsort value="$form->{lastsort}">
 
 820 <input type=hidden name=bom value="$form->{bom}">
 
 821 <input type=hidden name=titel value="$form->{titel}">
 
 822 <input type=hidden name=searchitems value="$form->{searchitems}">
 
 824 <input type=hidden name=row value=$j>
 
 826 <input type=hidden name=nextsub value=item_selected>
 
 828 <input name=lastndx type=hidden value=$lastndx>
 
 830 <input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>|;
 
 834   if (($form->{ndxs_counter}) > 0) {
 
 835     for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
 
 836       $j1 = $form->{"totop100_partnumber_$i"};
 
 837       $j2 = $form->{"totop100_description_$i"};
 
 838       $j3 = $form->{"totop100_unit_$i"};
 
 839       $j4 = $form->{"totop100_sellprice_$i"};
 
 840       $j5 = $form->{"totop100_soldtotal_$i"};
 
 849 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
 
 850 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
 
 851 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
 
 852 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
 
 853 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
 
 861 <input class=submit type=submit name=action value="|
 
 862     . $locale->text('TOP100') . qq|">
 
 868   $lxdebug->leave_sub();
 
 872   $lxdebug->enter_sub();
 
 875     $form->{ndxs_counter}++;
 
 877     if ($form->{ndxs_counter} > 0) {
 
 879       $index = $form->{ndx};
 
 881       $j1 = $form->{"new_partnumber_$index"};
 
 882       $form->{"totop100_partnumber_$form->{ndxs_counter}"} = $j1;
 
 883       $j2 = $form->{"new_description_$index"};
 
 884       $form->{"totop100_description_$form->{ndxs_counter}"} = $j2;
 
 885       $j3 = $form->{"new_unit_$index"};
 
 886       $form->{"totop100_unit_$form->{ndxs_counter}"} = $j3;
 
 887       $j4 = $form->{"new_sellprice_$index"};
 
 888       $form->{"totop100_sellprice_$form->{ndxs_counter}"} = $j4;
 
 889       $j5 = $form->{"new_soldtotal_$index"};
 
 890       $form->{"totop100_soldtotal_$form->{ndxs_counter}"} = $j5;
 
 894   $lxdebug->leave_sub();
 
 898   $lxdebug->enter_sub();
 
 900   $form->{top100}      = "top100";
 
 901   $form->{l_soldtotal} = "Y";
 
 902   $form->{soldtotal}   = "soldtotal";
 
 903   $form->{sort}        = "soldtotal";
 
 904   $form->{l_qty}       = "N";
 
 905   $callback .= "&form->{top100}=$form->{top100}";
 
 906   $form->{l_linetotal} = "";
 
 908   $form->{number}      = "position";
 
 909   $form->{l_number}    = "Y";
 
 913   $form->{title} = $locale->text('Top 100');
 
 915   $revers   = $form->{revers};
 
 916   $lastsort = $form->{lastsort};
 
 918   if (($form->{lastsort} eq "") && ($form->{sort} eq undef)) {
 
 920     $form->{lastsort} = "partnumber";
 
 921     $form->{sort}     = "partnumber";
 
 925     "$form->{script}?action=top100&login=$form->{login}&password=$form->{password}&searchitems=$form->{searchitems}&itemstatus=$form->{itemstatus}&bom=$form->{bom}&l_linetotal=$form->{l_linetotal}&title="
 
 926     . $form->escape($form->{title}, 1);
 
 928   # if we have a serialnumber limit search
 
 929   if ($form->{serialnumber} || $form->{l_serialnumber}) {
 
 930     $form->{l_serialnumber} = "Y";
 
 931     unless (   $form->{bought}
 
 934             || $form->{quoted}) {
 
 935       $form->{bought} = $form->{sold} = 1;
 
 938   IC->all_parts(\%myconfig, \%$form);
 
 940   if ($form->{itemstatus} eq 'active') {
 
 941     $option .= $locale->text('Active') . " : ";
 
 943   if ($form->{itemstatus} eq 'obsolete') {
 
 944     $option .= $locale->text('Obsolete') . " : ";
 
 946   if ($form->{itemstatus} eq 'orphaned') {
 
 947     $option .= $locale->text('Orphaned') . " : ";
 
 949   if ($form->{itemstatus} eq 'onhand') {
 
 950     $option .= $locale->text('On Hand') . " : ";
 
 951     $form->{l_onhand} = "Y";
 
 953   if ($form->{itemstatus} eq 'short') {
 
 954     $option .= $locale->text('Short') . " : ";
 
 955     $form->{l_onhand} = "Y";
 
 957   if ($form->{onorder}) {
 
 958     $form->{l_ordnumber} = "Y";
 
 959     $callback .= "&onorder=$form->{onorder}";
 
 960     $option   .= $locale->text('On Order') . " : ";
 
 962   if ($form->{ordered}) {
 
 963     $form->{l_ordnumber} = "Y";
 
 964     $callback .= "&ordered=$form->{ordered}";
 
 965     $option   .= $locale->text('Ordered') . " : ";
 
 968     $form->{l_quonumber} = "Y";
 
 969     $callback .= "&rfq=$form->{rfq}";
 
 970     $option   .= $locale->text('RFQ') . " : ";
 
 972   if ($form->{quoted}) {
 
 973     $form->{l_quonumber} = "Y";
 
 974     $callback .= ""ed=$form->{quoted}";
 
 975     $option   .= $locale->text('Quoted') . " : ";
 
 977   if ($form->{bought}) {
 
 978     $form->{l_invnumber} = "Y";
 
 979     $callback .= "&bought=$form->{bought}";
 
 980     $option   .= $locale->text('Bought') . " : ";
 
 983     $form->{l_invnumber} = "Y";
 
 984     $callback .= "&sold=$form->{sold}";
 
 985     $option   .= $locale->text('Sold') . " : ";
 
 992       || $form->{quoted}) {
 
 994     $form->{l_lastcost} = "";
 
 995     $form->{l_name}     = "Y";
 
 996     if ($form->{transdatefrom}) {
 
 997       $callback .= "&transdatefrom=$form->{transdatefrom}";
 
 999         . $locale->text('From')
 
1001         . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
 
1003     if ($form->{transdateto}) {
 
1004       $callback .= "&transdateto=$form->{transdateto}";
 
1006         . $locale->text('To')
 
1008         . $locale->date(\%myconfig, $form->{transdateto}, 1);
 
1014   if ($form->{partnumber}) {
 
1015     $callback .= "&partnumber=$form->{partnumber}";
 
1016     $option   .= $locale->text('Part Number') . qq| : $form->{partnumber}<br>|;
 
1019     $callback .= "&partnumber=$form->{ean}";
 
1020     $option   .= $locale->text('EAN') . qq| : $form->{ean}<br>|;
 
1022   if ($form->{partsgroup}) {
 
1023     $callback .= "&partsgroup=$form->{partsgroup}";
 
1024     $option   .= $locale->text('Group') . qq| : $form->{partsgroup}<br>|;
 
1026   if ($form->{serialnumber}) {
 
1027     $callback .= "&serialnumber=$form->{serialnumber}";
 
1029       $locale->text('Serial Number') . qq| : $form->{serialnumber}<br>|;
 
1031   if ($form->{description}) {
 
1032     $callback .= "&description=$form->{description}";
 
1033     $description = $form->{description};
 
1037       $locale->text('Part Description') . qq| : $form->{description}<br>|;
 
1039   if ($form->{make}) {
 
1040     $callback .= "&make=$form->{make}";
 
1041     $option   .= $locale->text('Make') . qq| : $form->{make}<br>|;
 
1043   if ($form->{model}) {
 
1044     $callback .= "&model=$form->{model}";
 
1045     $option   .= $locale->text('Model') . qq| : $form->{model}<br>|;
 
1047   if ($form->{drawing}) {
 
1048     $callback .= "&drawing=$form->{drawing}";
 
1049     $option   .= $locale->text('Drawing') . qq| : $form->{drawing}<br>|;
 
1051   if ($form->{microfiche}) {
 
1052     $callback .= "µfiche=$form->{microfiche}";
 
1053     $option   .= $locale->text('Microfiche') . qq| : $form->{microfiche}<br>|;
 
1055   if ($form->{l_soldtotal}) {
 
1056     $callback .= "&soldtotal=$form->{soldtotal}";
 
1057     $option   .= $locale->text('soldtotal') . qq| : $form->{soldtotal}<br>|;
 
1060   @columns = $form->sort_columns(
 
1061     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)
 
1064   if ($form->{l_linetotal}) {
 
1065     $form->{l_onhand} = "Y";
 
1066     $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
 
1067     if ($form->{l_lastcost}) {
 
1068       $form->{l_linetotallastcost} = "Y";
 
1069       if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
 
1070         $form->{l_linetotallastcost} = "";
 
1073     $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
 
1076   if ($form->{searchitems} eq 'service') {
 
1078     # remove bin, weight and rop from list
 
1079     map { $form->{"l_$_"} = "" } qw(bin weight rop);
 
1081     $form->{l_onhand} = "";
 
1083     # qty is irrelevant unless bought or sold
 
1084     if (   $form->{bought}
 
1089         || $form->{quoted}) {
 
1090       $form->{l_onhand} = "Y";
 
1092       $form->{l_linetotalsellprice} = "";
 
1093       $form->{l_linetotallastcost}  = "";
 
1097   $form->{l_lastcost} = ""
 
1098     if ($form->{searchitems} eq 'assembly' && !$form->{bom});
 
1100   foreach $item (@columns) {
 
1101     if ($form->{"l_$item"} eq "Y") {
 
1102       push @column_index, $item;
 
1104       # add column to callback
 
1105       $callback .= "&l_$item=Y";
 
1109   if ($form->{l_subtotal} eq 'Y') {
 
1110     $callback .= "&l_subtotal=Y";
 
1113   $column_header{number} =
 
1114     qq|<th class=listheading nowrap>| . $locale->text('number') . qq|</th>|;
 
1115   $column_header{partnumber} =
 
1116     qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1117     . $locale->text('Part Number')
 
1119   $column_header{description} =
 
1120     qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1121     . $locale->text('Part Description')
 
1123   $column_header{partsgroup} =
 
1124       qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|
 
1125     . $locale->text('Group')
 
1127   $column_header{bin} =
 
1128       qq|<th><a class=listheading href=$callback&sort=bin>|
 
1129     . $locale->text('Bin')
 
1131   $column_header{priceupdate} =
 
1132       qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|
 
1133     . $locale->text('Updated')
 
1135   $column_header{onhand} =
 
1136     qq|<th nowrap><a  class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1137     . $locale->text('Qty')
 
1139   $column_header{unit} =
 
1140     qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
 
1141   $column_header{listprice} =
 
1142       qq|<th class=listheading nowrap>|
 
1143     . $locale->text('List Price')
 
1145   $column_header{lastcost} =
 
1146     qq|<th class=listheading nowrap>| . $locale->text('Last Cost') . qq|</th>|;
 
1147   $column_header{rop} =
 
1148     qq|<th class=listheading nowrap>| . $locale->text('ROP') . qq|</th>|;
 
1149   $column_header{weight} =
 
1150     qq|<th class=listheading nowrap>| . $locale->text('Weight') . qq|</th>|;
 
1152   $column_header{invnumber} =
 
1153       qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|
 
1154     . $locale->text('Invoice Number')
 
1156   $column_header{ordnumber} =
 
1157       qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|
 
1158     . $locale->text('Order Number')
 
1160   $column_header{quonumber} =
 
1161       qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|
 
1162     . $locale->text('Quotation')
 
1165   $column_header{name} =
 
1166       qq|<th nowrap><a class=listheading href=$callback&sort=name>|
 
1167     . $locale->text('Name')
 
1170   $column_header{sellprice} =
 
1171       qq|<th class=listheading nowrap>|
 
1172     . $locale->text('Sell Price')
 
1174   $column_header{linetotalsellprice} =
 
1175     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1176   $column_header{linetotallastcost} =
 
1177     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1178   $column_header{linetotallistprice} =
 
1179     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1181   $column_header{image} =
 
1182     qq|<th class=listheading nowrap>| . $locale->text('Image') . qq|</a></th>|;
 
1183   $column_header{drawing} =
 
1184       qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|
 
1185     . $locale->text('Drawing')
 
1187   $column_header{microfiche} =
 
1188       qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|
 
1189     . $locale->text('Microfiche')
 
1192   $column_header{serialnumber} =
 
1193       qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|
 
1194     . $locale->text('Serial Number')
 
1196   $column_header{soldtotal} =
 
1197     qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1198     . $locale->text('soldtotal')
 
1202   $colspan = $#column_index + 1;
 
1209     <th class=listtop colspan=$colspan>$form->{title}</th>
 
1211   <tr height="5"></tr>
 
1213   <tr><td colspan=$colspan>$option</td></tr>
 
1215   <tr class=listheading>
 
1218   map { print "\n$column_header{$_}" } @column_index;
 
1224   # add order to callback
 
1225   $form->{callback} = $callback .= "&sort=$form->{sort}";
 
1227   # escape callback for href
 
1228   $callback = $form->escape($callback);
 
1230   if (@{ $form->{parts} }) {
 
1231     $sameitem = $form->{parts}->[0]->{ $form->{sort} };
 
1234   # insert numbers for top100
 
1236   foreach $ref (@{ $form->{parts} }) {
 
1238     $ref->{number} = $j;
 
1241   # if avaible -> insert choice here
 
1242   if (($form->{ndxs_counter}) > 0) {
 
1243     for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
 
1244       $partnumber  = $form->{"totop100_partnumber_$i"};
 
1245       $description = $form->{"totop100_description_$i"};
 
1246       $unit        = $form->{"totop100_unit_$i"};
 
1247       $sellprice   = $form->{"totop100_sellprice_$i"};
 
1248       $soldtotal   = $form->{"totop100_soldtotal_$i"};
 
1251 <input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
 
1252 <input type=hidden name=totop100_description_$i value=$form->{"totop100_description_$i"}>
 
1253 <input type=hidden name=totop100_unit_$i value=$form->{"totop100_unit_$i"}>
 
1254 <input type=hidden name=totop100_sellprice_$i value=$form->{"totop100_sellprice_$i"}>
 
1255 <input type=hidden name=totop100_soldtotal_$i value=$form->{"totop100_soldtotal_$i"}>
 
1259       push @{ $form->{parts} },
 
1261           partnumber  => "$partnumber",
 
1262           description => "$description",
 
1264           sellprice   => "$sellprice",
 
1265           soldtotal   => "$soldtotal" };
 
1268        # build data for columns
 
1269   foreach $ref (@{ $form->{parts} }) {
 
1271     if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
 
1272       if ($sameitem ne $ref->{ $form->{sort} }) {
 
1274         $sameitem = $ref->{ $form->{sort} };
 
1278     $ref->{exchangerate} = 1 unless $ref->{exchangerate};
 
1279     $ref->{sellprice} *= $ref->{exchangerate};
 
1280     $ref->{listprice} *= $ref->{exchangerate};
 
1281     $ref->{lastcost}  *= $ref->{exchangerate};
 
1283     # use this for assemblies
 
1284     $onhand = $ref->{onhand};
 
1287     if ($ref->{assemblyitem}) {
 
1289       $onhand = 0 if ($form->{sold});
 
1292     $ref->{description} =~ s/
 
1295     $column_data{number} =
 
1297       . $form->format_amount(\%myconfig, $ref->{number})
 
1299     $column_data{partnumber} =
 
1300       "<td align=$align>$ref->{partnumber} </a></td>";
 
1301     $column_data{description} = "<td>$ref->{description} </td>";
 
1302     $column_data{partsgroup}  = "<td>$ref->{partsgroup} </td>";
 
1304     $column_data{onhand} =
 
1306       . $form->format_amount(\%myconfig, $ref->{onhand})
 
1308     $column_data{sellprice} =
 
1310       . $form->format_amount(\%myconfig, $ref->{sellprice})
 
1312     $column_data{listprice} =
 
1314       . $form->format_amount(\%myconfig, $ref->{listprice})
 
1316     $column_data{lastcost} =
 
1318       . $form->format_amount(\%myconfig, $ref->{lastcost})
 
1321     $column_data{linetotalsellprice} = "<td align=right>"
 
1322       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice}, 2)
 
1324     $column_data{linetotallastcost} = "<td align=right>"
 
1325       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost}, 2)
 
1327     $column_data{linetotallistprice} = "<td align=right>"
 
1328       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice}, 2)
 
1331     if (!$ref->{assemblyitem}) {
 
1332       $totalsellprice += $onhand * $ref->{sellprice};
 
1333       $totallastcost  += $onhand * $ref->{lastcost};
 
1334       $totallistprice += $onhand * $ref->{listprice};
 
1336       $subtotalonhand    += $onhand;
 
1337       $subtotalsellprice += $onhand * $ref->{sellprice};
 
1338       $subtotallastcost  += $onhand * $ref->{lastcost};
 
1339       $subtotallistprice += $onhand * $ref->{listprice};
 
1344       . $form->format_amount(\%myconfig, $ref->{rop}) . "</td>";
 
1345     $column_data{weight} =
 
1347       . $form->format_amount(\%myconfig, $ref->{weight})
 
1349     $column_data{unit}        = "<td>$ref->{unit} </td>";
 
1350     $column_data{bin}         = "<td>$ref->{bin} </td>";
 
1351     $column_data{priceupdate} = "<td>$ref->{priceupdate} </td>";
 
1353     $column_data{invnumber} =
 
1354       ($ref->{module} ne 'oe')
 
1355       ? "<td><a href=$ref->{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}</a></td>"
 
1356       : "<td>$ref->{invnumber}</td>";
 
1357     $column_data{ordnumber} =
 
1358       ($ref->{module} eq 'oe')
 
1359       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber}</a></td>"
 
1360       : "<td>$ref->{ordnumber}</td>";
 
1361     $column_data{quonumber} =
 
1362       ($ref->{module} eq 'oe' && !$ref->{ordnumber})
 
1363       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber}</a></td>"
 
1364       : "<td>$ref->{quonumber}</td>";
 
1366     $column_data{name} = "<td>$ref->{name}</td>";
 
1368     $column_data{image} =
 
1370       ? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>"
 
1371       : "<td> </td>";
 
1372     $column_data{drawing} =
 
1374       ? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>"
 
1375       : "<td> </td>";
 
1376     $column_data{microfiche} =
 
1377       ($ref->{microfiche})
 
1378       ? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>"
 
1379       : "<td> </td>";
 
1381     $column_data{serialnumber} = "<td>$ref->{serialnumber}</td>";
 
1383     $column_data{soldtotal} = "<td  align=right>$ref->{soldtotal}</td>";
 
1387     print "<tr class=listrow$i>";
 
1389     map { print "\n$column_data{$_}" } @column_index;
 
1396   if ($form->{l_subtotal} eq 'Y') {
 
1400   if ($form->{"l_linetotal"}) {
 
1401     map { $column_data{$_} = "<td> </td>" } @column_index;
 
1402     $column_data{linetotalsellprice} =
 
1403         "<th class=listtotal align=right>"
 
1404       . $form->format_amount(\%myconfig, $totalsellprice, 2)
 
1406     $column_data{linetotallastcost} =
 
1407         "<th class=listtotal align=right>"
 
1408       . $form->format_amount(\%myconfig, $totallastcost, 2)
 
1410     $column_data{linetotallistprice} =
 
1411         "<th class=listtotal align=right>"
 
1412       . $form->format_amount(\%myconfig, $totallistprice, 2)
 
1415     print "<tr class=listtotal>";
 
1417     map { print "\n$column_data{$_}" } @column_index;
 
1424   <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
 
1433 <form method=post action=$form->{script}>
 
1435 <input type=hidden name=login value=$form->{login}>
 
1436 <input type=hidden name=password value=$form->{password}>
 
1438 <input type=hidden name=itemstatus value="$form->{itemstatus}">
 
1439 <input type=hidden name=l_linetotal value="$form->{l_linetotal}">
 
1440 <input type=hidden name=l_partnumber value="$form->{l_partnumber}">
 
1441 <input type=hidden name=l_description value="$form->{l_description}">
 
1442 <input type=hidden name=l_onhand value="$form->{l_onhand}">
 
1443 <input type=hidden name=l_unit value="$form->{l_unit}">
 
1444 <input type=hidden name=l_sellprice value="$form->{l_sellprice}">
 
1445 <input type=hidden name=l_linetotalsellprice value="$form->{l_linetotalsellprice}">
 
1446 <input type=hidden name=sort value="$form->{sort}">
 
1447 <input type=hidden name=revers value="$form->{revers}">
 
1448 <input type=hidden name=lastsort value="$form->{lastsort}">
 
1449 <input type=hidden name=parts value="$form->{parts}">
 
1451 <input type=hidden name=bom value="$form->{bom}">
 
1452 <input type=hidden name=titel value="$form->{titel}">
 
1453 <input type=hidden name=searchitems value="$form->{searchitems}">|;
 
1458     <input type=hidden name=ndxs_counter value="$form->{ndxs_counter}">
 
1460     <input class=submit type=submit name=action value="|
 
1461     . $locale->text('choice') . qq|">
 
1469   $lxdebug->leave_sub();
 
1472 sub generate_report {
 
1473   $lxdebug->enter_sub();
 
1475   $revers   = $form->{revers};
 
1476   $lastsort = $form->{lastsort};
 
1478   if (($form->{lastsort} eq "") && ($form->{sort} eq undef)) {
 
1479     $form->{revers}   = 0;
 
1480     $form->{lastsort} = "partnumber";
 
1481     $form->{sort}     = "partnumber";
 
1484     # switch between backward sorting of tables
 
1485     if ($form->{lastsort} eq $form->{sort}) {
 
1486       if ($form->{revers} == 0) {
 
1487         $form->{revers} = 1;
 
1489         $form->{revers} = 0;
 
1492       $form->{revers} == 0;
 
1493       $form->{lastsort} = $form->{sort};
 
1498     "$form->{script}?action=generate_report&login=$form->{login}&password=$form->{password}&searchitems=$form->{searchitems}&itemstatus=$form->{itemstatus}&bom=$form->{bom}&l_linetotal=$form->{l_linetotal}&title="
 
1499     . $form->escape($form->{title}, 1);
 
1501   # if we have a serialnumber limit search
 
1502   if ($form->{serialnumber} || $form->{l_serialnumber}) {
 
1503     $form->{l_serialnumber} = "Y";
 
1504     unless (   $form->{bought}
 
1507             || $form->{quoted}) {
 
1508       $form->{bought} = $form->{sold} = 1;
 
1512   IC->all_parts(\%myconfig, \%$form);
 
1514   if ($form->{itemstatus} eq 'active') {
 
1515     $option .= $locale->text('Active') . " : ";
 
1517   if ($form->{itemstatus} eq 'obsolete') {
 
1518     $option .= $locale->text('Obsolete') . " : ";
 
1520   if ($form->{itemstatus} eq 'orphaned') {
 
1521     $option .= $locale->text('Orphaned') . " : ";
 
1523   if ($form->{itemstatus} eq 'onhand') {
 
1524     $option .= $locale->text('On Hand') . " : ";
 
1525     $form->{l_onhand} = "Y";
 
1527   if ($form->{itemstatus} eq 'short') {
 
1528     $option .= $locale->text('Short') . " : ";
 
1529     $form->{l_onhand} = "Y";
 
1531   if ($form->{onorder}) {
 
1532     $form->{l_ordnumber} = "Y";
 
1533     $callback .= "&onorder=$form->{onorder}";
 
1534     $option   .= $locale->text('On Order') . " : ";
 
1536   if ($form->{ordered}) {
 
1537     $form->{l_ordnumber} = "Y";
 
1538     $callback .= "&ordered=$form->{ordered}";
 
1539     $option   .= $locale->text('Ordered') . " : ";
 
1542     $form->{l_quonumber} = "Y";
 
1543     $callback .= "&rfq=$form->{rfq}";
 
1544     $option   .= $locale->text('RFQ') . " : ";
 
1546   if ($form->{quoted}) {
 
1547     $form->{l_quonumber} = "Y";
 
1548     $callback .= ""ed=$form->{quoted}";
 
1549     $option   .= $locale->text('Quoted') . " : ";
 
1551   if ($form->{bought}) {
 
1552     $form->{l_invnumber} = "Y";
 
1553     $callback .= "&bought=$form->{bought}";
 
1554     $option   .= $locale->text('Bought') . " : ";
 
1556   if ($form->{sold}) {
 
1557     $form->{l_invnumber} = "Y";
 
1558     $callback .= "&sold=$form->{sold}";
 
1559     $option   .= $locale->text('Sold') . " : ";
 
1561   if (   $form->{bought}
 
1566       || $form->{quoted}) {
 
1568     $form->{l_lastcost} = "";
 
1569     $form->{l_name}     = "Y";
 
1570     if ($form->{transdatefrom}) {
 
1571       $callback .= "&transdatefrom=$form->{transdatefrom}";
 
1573         . $locale->text('From')
 
1575         . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
 
1577     if ($form->{transdateto}) {
 
1578       $callback .= "&transdateto=$form->{transdateto}";
 
1580         . $locale->text('To (time)')
 
1582         . $locale->date(\%myconfig, $form->{transdateto}, 1);
 
1588   if ($form->{partnumber}) {
 
1589     $callback .= "&partnumber=$form->{partnumber}";
 
1590     $option   .= $locale->text('Part Number') . qq| : $form->{partnumber}<br>|;
 
1592   if ($form->{partsgroup}) {
 
1593     $callback .= "&partsgroup=$form->{partsgroup}";
 
1594     $option   .= $locale->text('Group') . qq| : $form->{partsgroup}<br>|;
 
1596   if ($form->{serialnumber}) {
 
1597     $callback .= "&serialnumber=$form->{serialnumber}";
 
1599       $locale->text('Serial Number') . qq| : $form->{serialnumber}<br>|;
 
1601   if ($form->{description}) {
 
1602     $callback .= "&description=$form->{description}";
 
1603     $description = $form->{description};
 
1607       $locale->text('Part Description') . qq| : $form->{description}<br>|;
 
1609   if ($form->{make}) {
 
1610     $callback .= "&make=$form->{make}";
 
1611     $option   .= $locale->text('Make') . qq| : $form->{make}<br>|;
 
1613   if ($form->{model}) {
 
1614     $callback .= "&model=$form->{model}";
 
1615     $option   .= $locale->text('Model') . qq| : $form->{model}<br>|;
 
1617   if ($form->{drawing}) {
 
1618     $callback .= "&drawing=$form->{drawing}";
 
1619     $option   .= $locale->text('Drawing') . qq| : $form->{drawing}<br>|;
 
1621   if ($form->{microfiche}) {
 
1622     $callback .= "µfiche=$form->{microfiche}";
 
1623     $option   .= $locale->text('Microfiche') . qq| : $form->{microfiche}<br>|;
 
1626   # table soldtotal aktive
 
1627   if ($form->{l_soldtotal}) {
 
1628     $callback .= "&soldtotal=$form->{soldtotal}";
 
1629     $option   .= $locale->text('soldtotal') . qq| : $form->{soldtotal}<br>|;
 
1632   if ($form->{l_deliverydate}) {
 
1633     $callback .= "&deliverydate=$form->{deliverydate}";
 
1636   @columns = $form->sort_columns(
 
1637     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)
 
1640   if ($form->{l_linetotal}) {
 
1641     $form->{l_onhand} = "Y";
 
1642     $form->{l_linetotalsellprice} = "Y" if $form->{l_sellprice};
 
1643     if ($form->{l_lastcost}) {
 
1644       $form->{l_linetotallastcost} = "Y";
 
1645       if (($form->{searchitems} eq 'assembly') && !$form->{bom}) {
 
1646         $form->{l_linetotallastcost} = "";
 
1649     $form->{l_linetotallistprice} = "Y" if $form->{l_listprice};
 
1652   if ($form->{searchitems} eq 'service') {
 
1654     # remove bin, weight and rop from list
 
1655     map { $form->{"l_$_"} = "" } qw(bin weight rop);
 
1657     $form->{l_onhand} = "";
 
1659     # qty is irrelevant unless bought or sold
 
1660     if (   $form->{bought}
 
1665         || $form->{quoted}) {
 
1666       $form->{l_onhand} = "Y";
 
1668       $form->{l_linetotalsellprice} = "";
 
1669       $form->{l_linetotallastcost}  = "";
 
1673   $form->{l_lastcost} = ""
 
1674     if ($form->{searchitems} eq 'assembly' && !$form->{bom});
 
1676   foreach $item (@columns) {
 
1677     if ($form->{"l_$item"} eq "Y") {
 
1678       push @column_index, $item;
 
1680       # add column to callback
 
1681       $callback .= "&l_$item=Y";
 
1685   if ($form->{l_subtotal} eq 'Y') {
 
1686     $callback .= "&l_subtotal=Y";
 
1688   $column_header{partnumber} =
 
1689     qq|<th nowrap><a class=listheading href=$callback&sort=partnumber&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1690     . $locale->text('Part Number')
 
1692   $column_header{description} =
 
1693     qq|<th nowrap><a class=listheading href=$callback&sort=description&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1694     . $locale->text('Part Description')
 
1696   $column_header{partsgroup} =
 
1697       qq|<th nowrap><a class=listheading href=$callback&sort=partsgroup>|
 
1698     . $locale->text('Group')
 
1700   $column_header{bin} =
 
1701       qq|<th><a class=listheading href=$callback&sort=bin>|
 
1702     . $locale->text('Bin')
 
1704   $column_header{priceupdate} =
 
1705       qq|<th nowrap><a class=listheading href=$callback&sort=priceupdate>|
 
1706     . $locale->text('Updated')
 
1708   $column_header{onhand} =
 
1709     qq|<th nowrap><a  class=listheading href=$callback&sort=onhand&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1710     . $locale->text('Qty')
 
1712   $column_header{unit} =
 
1713     qq|<th class=listheading nowrap>| . $locale->text('Unit') . qq|</th>|;
 
1714   $column_header{listprice} =
 
1715       qq|<th class=listheading nowrap>|
 
1716     . $locale->text('List Price')
 
1718   $column_header{lastcost} =
 
1719     qq|<th class=listheading nowrap>| . $locale->text('Last Cost') . qq|</th>|;
 
1720   $column_header{rop} =
 
1721     qq|<th class=listheading nowrap>| . $locale->text('ROP') . qq|</th>|;
 
1722   $column_header{weight} =
 
1723     qq|<th class=listheading nowrap>| . $locale->text('Weight') . qq|</th>|;
 
1725   $column_header{invnumber} =
 
1726       qq|<th nowrap><a class=listheading href=$callback&sort=invnumber>|
 
1727     . $locale->text('Invoice Number')
 
1729   $column_header{ordnumber} =
 
1730       qq|<th nowrap><a class=listheading href=$callback&sort=ordnumber>|
 
1731     . $locale->text('Order Number')
 
1733   $column_header{quonumber} =
 
1734       qq|<th nowrap><a class=listheading href=$callback&sort=quonumber>|
 
1735     . $locale->text('Quotation')
 
1738   $column_header{name} =
 
1739       qq|<th nowrap><a class=listheading href=$callback&sort=name>|
 
1740     . $locale->text('Name')
 
1743   $column_header{sellprice} =
 
1744       qq|<th class=listheading nowrap>|
 
1745     . $locale->text('Sell Price')
 
1747   $column_header{linetotalsellprice} =
 
1748     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1749   $column_header{linetotallastcost} =
 
1750     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1751   $column_header{linetotallistprice} =
 
1752     qq|<th class=listheading nowrap>| . $locale->text('Extended') . qq|</th>|;
 
1754   $column_header{image} =
 
1755     qq|<th class=listheading nowrap>| . $locale->text('Image') . qq|</a></th>|;
 
1756   $column_header{drawing} =
 
1757       qq|<th nowrap><a class=listheading href=$callback&sort=drawing>|
 
1758     . $locale->text('Drawing')
 
1760   $column_header{microfiche} =
 
1761       qq|<th nowrap><a class=listheading href=$callback&sort=microfiche>|
 
1762     . $locale->text('Microfiche')
 
1765   $column_header{serialnumber} =
 
1766       qq|<th nowrap><a class=listheading href=$callback&sort=serialnumber>|
 
1767     . $locale->text('Serial Number')
 
1769   $column_header{soldtotal} =
 
1770     qq|<th nowrap><a class=listheading href=$callback&sort=soldtotal&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1771     . $locale->text('soldtotal')
 
1774   $column_header{deliverydate} =
 
1775     qq|<th nowrap><a class=listheading href=$callback&sort=deliverydate&revers=$form->{revers}&lastsort=$form->{lastsort}>|
 
1776     . $locale->text('deliverydate')
 
1780   $colspan = $#column_index + 1;
 
1787     <th class=listtop colspan=$colspan>$form->{title}</th>
 
1789   <tr height="5"></tr>
 
1791   <tr><td colspan=$colspan>$option</td></tr>
 
1793   <tr class=listheading>
 
1796   map { print "\n$column_header{$_}" } @column_index;
 
1802   # add order to callback
 
1803   $form->{callback} = $callback .= "&sort=$form->{sort}";
 
1805   # escape callback for href
 
1806   $callback = $form->escape($callback);
 
1808   if (@{ $form->{parts} }) {
 
1809     $sameitem = $form->{parts}->[0]->{ $form->{sort} };
 
1812   foreach $ref (@{ $form->{parts} }) {
 
1814     if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
 
1815       if ($sameitem ne $ref->{ $form->{sort} }) {
 
1817         $sameitem = $ref->{ $form->{sort} };
 
1821     $ref->{exchangerate} = 1 unless $ref->{exchangerate};
 
1822     $ref->{sellprice} *= $ref->{exchangerate};
 
1823     $ref->{listprice} *= $ref->{exchangerate};
 
1824     $ref->{lastcost}  *= $ref->{exchangerate};
 
1826     # use this for assemblies
 
1827     $onhand = $ref->{onhand};
 
1830     if ($ref->{assemblyitem}) {
 
1832       $onhand = 0 if ($form->{sold});
 
1835     $ref->{description} =~ s/
 
1838     $column_data{partnumber} =
 
1839       "<td align=$align><a href=$form->{script}?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{partnumber} </a></td>";
 
1840     $column_data{description} = "<td><a href=$form->{script}?action=edit&id=$ref->{id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{description} </a></td>";
 
1841     $column_data{partsgroup}  = "<td>$ref->{partsgroup} </td>";
 
1843     $column_data{onhand} =
 
1845       . $form->format_amount(\%myconfig, $ref->{onhand})
 
1847     $column_data{sellprice} =
 
1849       . $form->format_amount(\%myconfig, $ref->{sellprice}, -2)
 
1851     $column_data{listprice} =
 
1853       . $form->format_amount(\%myconfig, $ref->{listprice}, -2)
 
1855     $column_data{lastcost} =
 
1857       . $form->format_amount(\%myconfig, $ref->{lastcost}, -2)
 
1860     $column_data{linetotalsellprice} = "<td align=right>"
 
1861       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{sellprice}, 2)
 
1863     $column_data{linetotallastcost} = "<td align=right>"
 
1864       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{lastcost}, 2)
 
1866     $column_data{linetotallistprice} = "<td align=right>"
 
1867       . $form->format_amount(\%myconfig, $ref->{onhand} * $ref->{listprice}, 2)
 
1870     if (!$ref->{assemblyitem}) {
 
1871       $totalsellprice += $onhand * $ref->{sellprice};
 
1872       $totallastcost  += $onhand * $ref->{lastcost};
 
1873       $totallistprice += $onhand * $ref->{listprice};
 
1875       $subtotalonhand    += $onhand;
 
1876       $subtotalsellprice += $onhand * $ref->{sellprice};
 
1877       $subtotallastcost  += $onhand * $ref->{lastcost};
 
1878       $subtotallistprice += $onhand * $ref->{listprice};
 
1883       . $form->format_amount(\%myconfig, $ref->{rop}) . "</td>";
 
1884     $column_data{weight} =
 
1886       . $form->format_amount(\%myconfig, $ref->{weight})
 
1888     $column_data{unit}        = "<td>$ref->{unit} </td>";
 
1889     $column_data{bin}         = "<td>$ref->{bin} </td>";
 
1890     $column_data{priceupdate} = "<td>$ref->{priceupdate} </td>";
 
1892     $column_data{invnumber} =
 
1893       ($ref->{module} ne 'oe')
 
1894       ? "<td><a href=$ref->{module}.pl?action=edit&type=invoice&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{invnumber}</a></td>"
 
1895       : "<td>$ref->{invnumber}</td>";
 
1896     $column_data{ordnumber} =
 
1897       ($ref->{module} eq 'oe')
 
1898       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{ordnumber}</a></td>"
 
1899       : "<td>$ref->{ordnumber}</td>";
 
1900     $column_data{quonumber} =
 
1901       ($ref->{module} eq 'oe' && !$ref->{ordnumber})
 
1902       ? "<td><a href=$ref->{module}.pl?action=edit&type=$ref->{type}&id=$ref->{trans_id}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{quonumber}</a></td>"
 
1903       : "<td>$ref->{quonumber}</td>";
 
1905     $column_data{name} = "<td>$ref->{name}</td>";
 
1907     $column_data{image} =
 
1909       ? "<td><a href=$ref->{image}><img src=$ref->{image} height=32 border=0></a></td>"
 
1910       : "<td> </td>";
 
1911     $column_data{drawing} =
 
1913       ? "<td><a href=$ref->{drawing}>$ref->{drawing}</a></td>"
 
1914       : "<td> </td>";
 
1915     $column_data{microfiche} =
 
1916       ($ref->{microfiche})
 
1917       ? "<td><a href=$ref->{microfiche}>$ref->{microfiche}</a></td>"
 
1918       : "<td> </td>";
 
1920     $column_data{serialnumber} = "<td>$ref->{serialnumber}</td>";
 
1922     $column_data{soldtotal} =
 
1924       . $form->format_amount(\%myconfig, $ref->{soldtotal})
 
1927     $column_data{deliverydate} = "<td>$ref->{deliverydate}</td>";
 
1931     print "<tr class=listrow$i>";
 
1933     map { print "\n$column_data{$_}" } @column_index;
 
1941   if ($form->{l_subtotal} eq 'Y') {
 
1945   if ($form->{"l_linetotal"}) {
 
1946     map { $column_data{$_} = "<td> </td>" } @column_index;
 
1947     $column_data{linetotalsellprice} =
 
1948         "<th class=listtotal align=right>"
 
1949       . $form->format_amount(\%myconfig, $totalsellprice, 2)
 
1951     $column_data{linetotallastcost} =
 
1952         "<th class=listtotal align=right>"
 
1953       . $form->format_amount(\%myconfig, $totallastcost, 2)
 
1955     $column_data{linetotallistprice} =
 
1956         "<th class=listtotal align=right>"
 
1957       . $form->format_amount(\%myconfig, $totallistprice, 2)
 
1960     print "<tr class=listtotal>";
 
1962     map { print "\n$column_data{$_}" } @column_index;
 
1969   <tr><td colspan=$colspan><hr size=3 noshade></td></tr>
 
1978 <form method=post action=$form->{script}>
 
1980 <input name=callback type=hidden value="$form->{callback}">
 
1982 <input type=hidden name=item value=$form->{searchitems}>
 
1984 <input type=hidden name=login value=$form->{login}>
 
1985 <input type=hidden name=password value=$form->{password}>|;
 
1988   <input class=submit type=submit name=action value="|
 
1989     . $locale->text('Add') . qq|">
 
1997   $lxdebug->leave_sub();
 
1998 }    #end generate_report
 
2000 sub parts_subtotal {
 
2001   $lxdebug->enter_sub();
 
2003   map { $column_data{$_} = "<td> </td>" } @column_index;
 
2004   $subtotalonhand = 0 if ($form->{searchitems} eq 'assembly' && $form->{bom});
 
2006   $column_data{onhand} =
 
2007       "<th class=listsubtotal align=right>"
 
2008     . $form->format_amount(\%myconfig, $subtotalonhand)
 
2011   $column_data{linetotalsellprice} =
 
2012       "<th class=listsubtotal align=right>"
 
2013     . $form->format_amount(\%myconfig, $subtotalsellprice, 2)
 
2015   $column_data{linetotallistprice} =
 
2016       "<th class=listsubtotal align=right>"
 
2017     . $form->format_amount(\%myconfig, $subtotallistprice, 2)
 
2019   $column_data{linetotallastcost} =
 
2020       "<th class=listsubtotal align=right>"
 
2021     . $form->format_amount(\%myconfig, $subtotallastcost, 2)
 
2024   $subtotalonhand    = 0;
 
2025   $subtotalsellprice = 0;
 
2026   $subtotallistprice = 0;
 
2027   $subtotallastcost  = 0;
 
2029   print "<tr class=listsubtotal>";
 
2031   map { print "\n$column_data{$_}" } @column_index;
 
2037   $lxdebug->leave_sub();
 
2041   $lxdebug->enter_sub();
 
2042   # show history button
 
2043   $form->{javascript} = qq|<script type="text/javascript" src="js/show_history.js"></script>|;
 
2044   #/show hhistory button
 
2045   IC->get_part(\%myconfig, \%$form);
 
2047   $form->{"original_partnumber"} = $form->{"partnumber"};
 
2049   $form->{title} = $locale->text('Edit ' . ucfirst $form->{item});
 
2054   $lxdebug->leave_sub();
 
2058   $lxdebug->enter_sub();
 
2060   IC->create_links("IC", \%myconfig, \%$form);
 
2063   map({ $form->{selectcurrency} .= "<option>$_\n" }
 
2064       split(/:/, $form->{currencies}));
 
2066   # parts and assemblies have the same links
 
2067   $item = $form->{item};
 
2068   if ($form->{item} eq 'assembly') {
 
2072   # build the popup menus
 
2073   $form->{taxaccounts} = "";
 
2074   foreach $key (keys %{ $form->{IC_links} }) {
 
2075     foreach $ref (@{ $form->{IC_links}{$key} }) {
 
2077       # if this is a tax field
 
2078       if ($key =~ /IC_tax/) {
 
2079         if ($key =~ /$item/) {
 
2080           $form->{taxaccounts} .= "$ref->{accno} ";
 
2081           $form->{"IC_tax_$ref->{accno}_description"} =
 
2082             "$ref->{accno}--$ref->{description}";
 
2085             if ($form->{amount}{ $ref->{accno} }) {
 
2086               $form->{"IC_tax_$ref->{accno}"} = "checked";
 
2089             $form->{"IC_tax_$ref->{accno}"} = "checked";
 
2094         $form->{"select$key"} .=
 
2095           "<option $ref->{selected}>$ref->{accno}--$ref->{description}\n";
 
2096         if ($form->{amount}{$key} eq $ref->{accno}) {
 
2097           $form->{$key} = "$ref->{accno}--$ref->{description}";
 
2103   chop $form->{taxaccounts};
 
2105   if (($form->{item} eq "part") || ($form->{item} eq "assembly")) {
 
2106     $form->{selectIC_income}  = $form->{selectIC_sale};
 
2107     $form->{selectIC_expense} = $form->{selectIC_cogs};
 
2108     $form->{IC_income}        = $form->{IC_sale};
 
2109     $form->{IC_expense}       = $form->{IC_cogs};
 
2112   delete $form->{IC_links};
 
2113   delete $form->{amount};
 
2115   $form->get_partsgroup(\%myconfig, { all => 1 });
 
2117   $form->{partsgroup} = "$form->{partsgroup}--$form->{partsgroup_id}";
 
2119   if (@{ $form->{all_partsgroup} }) {
 
2120     $form->{selectpartsgroup} = qq|<option>\n|;
 
2122       $form->{selectpartsgroup} .=
 
2123         qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n|
 
2124     } @{ $form->{all_partsgroup} };
 
2127   if ($form->{item} eq 'assembly') {
 
2129     foreach $i (1 .. $form->{assembly_rows}) {
 
2130       if ($form->{"partsgroup_id_$i"}) {
 
2131         $form->{"partsgroup_$i"} =
 
2132           qq|$form->{"partsgroup_$i"}--$form->{"partsgroup_id_$i"}|;
 
2135     $form->get_partsgroup(\%myconfig);
 
2137     if (@{ $form->{all_partsgroup} }) {
 
2138       $form->{selectassemblypartsgroup} = qq|<option>\n|;
 
2141         $form->{selectassemblypartsgroup} .=
 
2142           qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n|
 
2143       } @{ $form->{all_partsgroup} };
 
2146   $lxdebug->leave_sub();
 
2150   $lxdebug->enter_sub();
 
2152   map({ $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, -2) }
 
2153       qw(sellprice listprice lastcost gv));
 
2155   map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}) }
 
2156     qw(weight rop stock);
 
2158   foreach $item (qw(partnumber description unit notes)) {
 
2159     $form->{$item} =~ s/\"/"/g;
 
2162   $payment = qq|<option value=""></option>|;
 
2163   foreach $item (@{ $form->{payment_terms} }) {
 
2164     if ($form->{payment_id} eq $item->{id}) {
 
2165       $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
 
2167       $payment .= qq|<option value="$item->{id}">$item->{description}</option>|;
 
2172   if (($rows = $form->numtextrows($form->{notes}, 40)) < 2) {
 
2177     qq|<textarea name=notes rows=$rows cols=45 wrap=soft>$form->{notes}</textarea>|;
 
2178   if (($rows = $form->numtextrows($form->{description}, 40)) > 1) {
 
2180       qq|<textarea name="description" rows=$rows cols=40 wrap=soft>$form->{description}</textarea>|;
 
2183       qq|<input name=description size=40 value="$form->{description}">|;
 
2186   $ean =  qq|<input name=ean size=40 value="$form->{ean}">|;
 
2188   foreach $item (split / /, $form->{taxaccounts}) {
 
2189     $form->{"IC_tax_$item"} = ($form->{"IC_tax_$item"}) ? "checked" : "";
 
2192   IC->retrieve_buchungsgruppen(\%myconfig, $form);
 
2193   if (@{ $form->{BUCHUNGSGRUPPEN} }) {
 
2194     foreach $item (@{ $form->{BUCHUNGSGRUPPEN} }) {
 
2195       if ($item->{id} == $form->{buchungsgruppen_id}) {
 
2196         $form->{selectbuchungsgruppe} .=
 
2197           "<option value=$item->{id} selected>$item->{description}\n";
 
2198       } elsif (($form->{id} && $form->{orphaned}) || (!$form->{id})) {
 
2199         $form->{selectbuchungsgruppe} .=
 
2200           "<option value=$item->{id}>$item->{description}\n";
 
2206   $buchungsgruppe = qq|
 
2208                 <th align=right>| . $locale->text('Buchungsgruppe') . qq|</th>
 
2209                 <td><select name=buchungsgruppen_id>$form->{selectbuchungsgruppe}</select></td>
 
2214   foreach $item (qw(IC IC_income IC_expense)) {
 
2215     if ($form->{$item}) {
 
2216       if ($form->{id} && $form->{orphaned}) {
 
2217         $form->{"select$item"} =~ s/ selected//;
 
2218         $form->{"select$item"} =~
 
2219           s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
 
2221         $form->{"select$item"} = qq|<option selected>$form->{$item}|;
 
2226   if ($form->{selectpartsgroup}) {
 
2227     $form->{selectpartsgroup} = $form->unescape($form->{selectpartsgroup});
 
2229       qq|<input type=hidden name=selectpartsgroup value="|
 
2230       . $form->escape($form->{selectpartsgroup}, 1) . qq|">|;
 
2231     $form->{selectpartsgroup} =~
 
2232       s/(<option value="\Q$form->{partsgroup}\E")/$1 selected/;
 
2235       qq|<select name=partsgroup>$form->{selectpartsgroup}</select>|;
 
2236     $group = $locale->text('Group');
 
2240   foreach $item (split / /, $form->{taxaccounts}) {
 
2242       <input class=checkbox type=checkbox name="IC_tax_$item" value=1 $form->{"IC_tax_$item"}> <b>$form->{"IC_tax_${item}_description"}</b>
 
2243       <br><input type=hidden name=IC_tax_${item}_description value="$form->{"IC_tax_${item}_description"}">
 
2247   $form->{obsolete} = "checked" if $form->{obsolete};
 
2251                 <th align="right" nowrap="true">|
 
2252     . $locale->text('Last Cost') . qq|</th>
 
2253                 <td><input name=lastcost size=11 value=$form->{lastcost}></td>
 
2259                 <th align=right>| . $locale->text('Inventory') . qq|</th>
 
2260                 <td><select name=IC>$form->{selectIC}</select></td>
 
2261                 <input name=selectIC type=hidden value="$form->{selectIC}">
 
2265   if ($form->{item} eq "part") {
 
2267     $linkaccounts .= qq|
 
2269                 <th align=right>| . $locale->text('Revenue') . qq|</th>
 
2270                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
 
2271                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
 
2274                 <th align=right>| . $locale->text('Expense') . qq|</th>
 
2275                 <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
 
2276                 <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
 
2282                 <th align="right" nowrap="true">| . $locale->text('Weight') . qq|</th>
 
2287                         <input name=weight size=10 value=$form->{weight}>
 
2297   if ($form->{item} eq "assembly") {
 
2303                 <th align=right>| . $locale->text('Revenue') . qq|</th>
 
2304                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
 
2305                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
 
2311                 <th align="right" nowrap="true">| . $locale->text('Weight') . qq|</th>
 
2316                          $form->{weight}
 
2317                         <input type=hidden name=weight value=$form->{weight}>
 
2327   if ($form->{item} eq "service") {
 
2331                 <th align=right>| . $locale->text('Revenue') . qq|</th>
 
2332                 <td><select name=IC_income>$form->{selectIC_income}</select></td>
 
2333                 <input name=selectIC_income type=hidden value="$form->{selectIC_income}">
 
2336                 <th align=right>| . $locale->text('Expense') . qq|</th>
 
2337                 <td><select name=IC_expense>$form->{selectIC_expense}</select></td>
 
2338                 <input name=selectIC_expense type=hidden value="$form->{selectIC_expense}">
 
2343   $linkaccounts = qq|<input type=hidden name=IC_income value="$form->{IC_income_default}">|;
 
2345   if ($form->{IC_cogs_default}) {
 
2346     $form->{IC_expense_default} = $form->{IC_cogs_default};
 
2349   if (($form->{item} eq "service") || ($form->{item} eq "part")) {
 
2350     $linkaccounts .= qq|<input type=hidden name=IC_expense value="$form->{IC_expense_default}">|;
 
2352   if ($form->{item} eq "part") {
 
2353     $linkaccounts .= qq|<input type=hidden name=IC value="$form->{IC_default}">|;
 
2356   if ($form->{item} ne 'service') {
 
2357     $n   = ($form->{onhand} > 0) ? "1" : "0";
 
2360                 <th align="right" nowrap>| . $locale->text('On Hand') . qq|</th>
 
2361                 <th align=left nowrap class="plus$n"> |
 
2362       . $form->format_amount(\%myconfig, $form->{onhand}) . qq|</th>
 
2366     if ($form->{item} eq 'assembly') {
 
2369                 <th align="right" nowrap>| . $locale->text('Stock') . qq|</th>
 
2370                 <td><input name=stock size=10 value=$form->{stock}></td>
 
2377                 <th align="right" nowrap="true">| . $locale->text('ROP') . qq|</th>
 
2378                 <td><input name=rop size=10 value=$form->{rop}></td>
 
2384                 <th align="right" nowrap="true">| . $locale->text('Bin') . qq|</th>
 
2385                 <td><input name=bin size=10 value=$form->{bin}></td>
 
2390                 <th align="right" nowrap="true">|
 
2391       . $locale->text('Verrechnungseinheit') . qq|</th>
 
2392                 <td><input name=ve size=10 value=$form->{ve}></td>
 
2395                 <th align="right" nowrap="true">|
 
2396       . $locale->text('Geschäftsvolumen') . qq|</th>
 
2397                 <td><input name=gv size=10 value=$form->{gv}></td>
 
2400     $notdiscountableok = ($form->{not_discountable}) == 1 ? "checked" : "";
 
2401     $notdiscountable .= qq|
 
2403                 <th align=right nowrap>|
 
2404     . $locale->text('Not Discountable') . qq|</th>
 
2405                 <td><input class=checkbox type=checkbox name=not_discountable value=1 $notdiscountableok></td>
 
2410     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>|;
 
2416           <th align=right nowrap>| . $locale->text('Image') . qq|</th>
 
2417           <td><input name=image size=40 value="$form->{image}"></td>
 
2418           <th align=right nowrap>| . $locale->text('Microfiche') . qq|</th>
 
2419           <td><input name=microfiche size=20 value="$form->{microfiche}"></td>
 
2422           <th align=right nowrap>| . $locale->text('Drawing') . qq|</th>
 
2423           <td><input name=drawing size=40 value="$form->{drawing}"></td>
 
2435                 <th align="right" nowrap="true">| . $locale->text('Obsolete') . qq|</th>
 
2436                 <td><input name=obsolete type=checkbox class=checkbox value=1 $form->{obsolete}></td>
 
2440   $shopok = $form->{shop} == 1 ? "checked" : "";
 
2443                 <th align=right nowrap>|
 
2444     . $locale->text('Shopartikel') . qq|</th>
 
2445                 <td><input class=checkbox type=checkbox name=shop value=1 $shopok></td>
 
2450   # type=submit $locale->text('Add Part')
 
2451   # type=submit $locale->text('Add Service')
 
2452   # type=submit $locale->text('Add Assembly')
 
2454   # type=submit $locale->text('Edit Part')
 
2455   # type=submit $locale->text('Edit Service')
 
2456   # type=submit $locale->text('Edit Assembly')
 
2457   # use JavaScript Calendar or not
 
2458   $form->{jsscript} = $jscalendar;
 
2460   if ($form->{jsscript}) {
 
2462     # with JavaScript Calendar
 
2464        <td width="13"><input name=priceupdate id=priceupdate size=11  title="$myconfig{dateformat}" value="$form->{priceupdate}"></td>
 
2465        <td width="4" align="left"><input type=button name=priceupdate id="trigger1" value=|
 
2466       . $locale->text('button') . qq|></td>
 
2471       Form->write_trigger(\%myconfig, "1", "priceupdate", "BL", "trigger1");
 
2474     # without JavaScript Calendar
 
2476                               <td><input name=transdatefrom id=transdatefrom size=11 title="$myconfig{dateformat}"></td>|;
 
2479   my $unit_select = '<input type="hidden" name="unit_changeable" value="' . $form->{"unit_changeable"} . '">';
 
2480   if (!$form->{"unit_changeable"}) {
 
2481     $unit_select .= '<input type="hidden" name="unit" value="' . $form->{"unit"} . '">' . $form->{"unit"};
 
2483     my $units = AM->retrieve_units(\%myconfig, $form, $form->{"item"} eq "service" ? "service" : "dimension");
 
2484     $unit_select .= AM->unit_select_html($units, "unit", $form->{"unit"});
 
2487   $form->{fokus} = "ic.partnumber";
 
2491   <body onLoad="fokus()">
 
2492  <script type="text/javascript" src="js/common.js"></script>
 
2493  <script type="text/javascript" src="js/parts_language_selection.js"></script>
 
2495 <form method=post name="ic" action=$form->{script}>
 
2497 <input name=id type=hidden value=$form->{id}>
 
2498 <input name=item type=hidden value=$form->{item}>
 
2499 <input name=title type=hidden value="$form->{title}">
 
2500 <input name=makemodel type=hidden value="$form->{makemodel}">
 
2501 <input name=alternate type=hidden value="$form->{alternate}">
 
2502 <input name=onhand type=hidden value=$form->{onhand}>
 
2503 <input name=orphaned type=hidden value=$form->{orphaned}>
 
2504 <input name=taxaccounts type=hidden value="$form->{taxaccounts}">
 
2505 <input name=rowcount type=hidden value=$form->{rowcount}>
 
2506 <input name=eur type=hidden value=$eur>
 
2507 <input name=language_values type=hidden value="$form->{language_values}">
 
2508 <input name="original_partnumber" type="hidden" value="| . $form->quote($form->{"original_partnumber"}) . qq|">
 
2510 <table width="100%">
 
2512     <th class=listtop>$form->{title}</th>
 
2514   <tr height="5"></tr>
 
2517       <table width="100%">
 
2519           <th align=left>| . $locale->text('Part Number') . qq|</th>
 
2520           <th align=left>| . $locale->text('Part Description') . qq|</th>
 
2521           <th align=left>$group</th>
 
2524           <td><input name=partnumber value="$form->{partnumber}" size=20></td>
 
2525           <td>$description</td>
 
2526           <td>$partsgroup</td>
 
2527           <input type=hidden name=oldpartsgroup value="$form->{oldpartsgroup}">
 
2534       <table width="100%" height="100%">
 
2537             <table width="100%" height="100%">
 
2538               <tr class="listheading">
 
2539                 <th class="listheading" align="center" colspan=2>|
 
2540     . $locale->text('') . qq|</th>
 
2549                 <th align="left">| . $locale->text('Notes') . qq|</th>
 
2550                 <th align="left">| . $locale->text('Formula') . qq|</th>
 
2561                 <th align="left"></th>
 
2562                 <th align="left">| . $locale->text('EAN-Code') . qq|</th>
 
2566                   <button type="button" onclick="parts_language_selection_window('language_values')">| . $locale->text('Set Language Values') . qq|</button>
 
2576                <th align=right>| . $locale->text('Payment Terms') . qq|</th>
 
2577                  <td><select name=payment_id>$payment</select></td>
 
2585             <table width="100%">
 
2587                 <th align="right" nowrap="true">|
 
2588     . $locale->text('Updated') . qq|</th>
 
2592                 <th align="right" nowrap="true">| . $locale->text('List Price') . qq|</th>
 
2593                 <td><input name=listprice size=11 value=$form->{listprice}></td>
 
2596                 <th align="right" nowrap="true">| . $locale->text('Sell Price') . qq|</th>
 
2597                 <td><input name=sellprice size=11 value=$form->{sellprice}></td>
 
2601                 <th align="right" nowrap="true">| . $locale->text('Unit') . qq|</th>
 
2602                 <td>$unit_select</td>
 
2621   $lxdebug->leave_sub();
 
2625   $lxdebug->enter_sub();
 
2627   if ($form->{item} eq "assembly") {
 
2632             <table width="100%">
 
2634                 <th colspan=2 align=right>|
 
2635       . $locale->text('Total') . qq| </th>
 
2637       . $form->format_amount(\%myconfig, $form->{assemblytotal}, 2) . qq|</th>
 
2642         <input type=hidden name=assembly_rows value=$form->{assembly_rows}>
 
2647       <input type=hidden name=login value=$form->{login}>
 
2648       <input type=hidden name=password value=$form->{password}>
 
2649       <input type=hidden name=callback value="$form->{callback}">
 
2650       <input type=hidden name=previousform value="$form->{previousform}">
 
2651       <input type=hidden name=taxaccount2 value="$form->{taxaccount2}">
 
2652       <input type=hidden name=vc value=$form->{vc}>
 
2654     <td><hr size=3 noshade></td>
 
2659 <input class=submit type=submit name=action value="|
 
2660     . $locale->text('Update') . qq|">
 
2663   unless ($form->{item} eq "service") {
 
2665       <input type=hidden name=makemodel_rows value=$form->{makemodel_rows}>
 
2670      <input type=hidden name=price_rows value=$form->{price_rows}>|;
 
2673       <input class=submit type=submit name=action value="|
 
2674     . $locale->text('Save') . qq|">|;
 
2678     if (!$form->{previousform}) {
 
2680       <input class=submit type=submit name=action value="|
 
2681         . $locale->text('Save as new') . qq|">|;
 
2684     if ($form->{orphaned}) {
 
2685       if (!$form->{previousform}) {
 
2686         if ($form->{item} eq 'assembly') {
 
2687           if (!$form->{onhand}) {
 
2689       <input class=submit type=submit name=action value="|
 
2690               . $locale->text('Delete') . qq|">|;
 
2694       <input class=submit type=submit name=action value="|
 
2695             . $locale->text('Delete') . qq|">|;
 
2701   if (!$form->{previousform}) {
 
2702     if ($form->{menubar}) {
 
2703       require "bin/mozilla/menu.pl";
 
2707 # button for saving history
 
2708   if($form->{id} ne "") {
 
2710                 <input type=button class=submit onclick=set_history_window(|
 
2712                 . qq|); name=history id=history value=|
 
2713                 . $locale->text('history') 
 
2716 # /button for saving history
 
2721 <script type="text/javascript" src="js/wz_tooltip.js"></script>
 
2727   $lxdebug->leave_sub();
 
2731   $lxdebug->enter_sub();
 
2734   $form->{"make_$i"}  =~ s/\"/"/g;
 
2735   $form->{"model_$i"} =~ s/\"/"/g;
 
2742           <th class="listheading">| . $locale->text('Make') . qq|</th>
 
2743           <th class="listheading">| . $locale->text('Model') . qq|</th>
 
2747   for $i (1 .. $numrows) {
 
2750           <td width=50%><input name="make_$i" size=30 value="$form->{"make_$i"}"></td>
 
2751           <td width=50%><input name="model_$i" size=30 value="$form->{"model_$i"}"></td>
 
2762   $lxdebug->leave_sub();
 
2766   $lxdebug->enter_sub();
 
2770     qw(runningnumber qty unit bom partnumber description partsgroup total);
 
2772   if ($form->{previousform}) {
 
2774     @column_index = qw(qty unit bom partnumber description partsgroup total);
 
2778     $form->{old_callback} = $form->{callback};
 
2779     $callback             = $form->{callback};
 
2780     $form->{callback}     = "$form->{script}?action=display_form";
 
2783     map { delete $form->{$_} } qw(action header);
 
2787     # save form variables in a previousform variable
 
2788     foreach $key (sort keys %$form) {
 
2791       $form->{$key} =~ s/&/%26/g;
 
2792       $previousform .= qq|$key=$form->{$key}&|;
 
2795     $previousform = $form->escape($form->escape($previousform, 1));
 
2796     $form->{callback} = $callback;
 
2798     $form->{assemblytotal} = 0;
 
2799     $form->{weight}        = 0;
 
2802   $column_header{runningnumber} =
 
2803     qq|<th nowrap width=5%>| . $locale->text('No.') . qq|</th>|;
 
2804   $column_header{qty} =
 
2805     qq|<th align=left nowrap width=10%>| . $locale->text('Qty') . qq|</th>|;
 
2806   $column_header{unit} =
 
2807     qq|<th align=left nowrap width=5%>| . $locale->text('Unit') . qq|</th>|;
 
2808   $column_header{partnumber} =
 
2809       qq|<th align=left nowrap width=20%>|
 
2810     . $locale->text('Part Number')
 
2812   $column_header{description} =
 
2813     qq|<th nowrap width=50%>| . $locale->text('Part Description') . qq|</th>|;
 
2814   $column_header{total} =
 
2815     qq|<th align=right nowrap>| . $locale->text('Extended') . qq|</th>|;
 
2816   $column_header{bom}        = qq|<th>| . $locale->text('BOM') . qq|</th>|;
 
2817   $column_header{partsgroup} = qq|<th>| . $locale->text('Group') . qq|</th>|;
 
2820   <tr class=listheading>
 
2821     <th class=listheading>| . $locale->text('Individual Items') . qq|</th>
 
2829   map { print "\n$column_header{$_}" } @column_index;
 
2835   for $i (1 .. $numrows) {
 
2836     $form->{"partnumber_$i"} =~ s/\"/"/g;
 
2839       $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
 
2840     $form->{assemblytotal} += $linetotal;
 
2842     $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
 
2844     $linetotal = $form->format_amount(\%myconfig, $linetotal, 2);
 
2846     if (($i >= 1) && ($i == $numrows)) {
 
2849         map { $column_data{$_} = qq|<td></td>| }
 
2850           qw(qty unit partnumber description bom partsgroup);
 
2853         map { $column_data{$_} = qq|<td></td>| } qw(runningnumber unit bom);
 
2856           qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
 
2857         $column_data{partnumber} =
 
2858           qq|<td><input name="partnumber_$i" size=15 value="$form->{"partnumber_$i"}"></td>|;
 
2859         $column_data{description} =
 
2860           qq|<td><input name="description_$i" size=40 value="$form->{"description_$i"}"></td>|;
 
2861         $column_data{partsgroup} =
 
2862           qq|<td><input name="partsgroup_$i" size=10 value="$form->{"partsgroup_$i"}"></td>|;
 
2868       if ($form->{previousform}) {
 
2869         $column_data{partnumber} =
 
2870           qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}">$form->{"partnumber_$i"}</td>|;
 
2872           qq|<td align=right><input type=hidden name="qty_$i" value="$form->{"qty_$i"}">$form->{"qty_$i"}</td>|;
 
2875           qq|<td align=center><input type=hidden name="bom_$i" value=$form->{"bom_$i"}>|;
 
2876         $column_data{bom} .= ($form->{"bom_$i"}) ? "x" : " ";
 
2877         $column_data{bom} .= qq|</td>|;
 
2879         $column_data{partsgroup} =
 
2880           qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
 
2884           qq|$form->{script}?action=edit&id=$form->{"id_$i"}&login=$form->{login}&password=$form->{password}&rowcount=$i&previousform=$previousform|;
 
2885         $column_data{partnumber} =
 
2886           qq|<td><input type=hidden name="partnumber_$i" value="$form->{"partnumber_$i"}"><a href=$href>$form->{"partnumber_$i"}</a></td>|;
 
2887         $column_data{runningnumber} =
 
2888           qq|<td><input name="runningnumber_$i" size=3 value="$i"></td>|;
 
2890           qq|<td><input name="qty_$i" size=5 value="$form->{"qty_$i"}"></td>|;
 
2892         $form->{"bom_$i"} = ($form->{"bom_$i"}) ? "checked" : "";
 
2894           qq|<td align=center><input name="bom_$i" type=checkbox class=checkbox value=1 $form->{"bom_$i"}></td>|;
 
2896         $column_data{partsgroup} =
 
2897           qq|<td><input type=hidden name="partsgroup_$i" value="$form->{"partsgroup_$i"}">$form->{"partsgroup_$i"}</td>|;
 
2900       $column_data{unit} =
 
2901         qq|<td><input type=hidden name="unit_$i" value="$form->{"unit_$i"}">$form->{"unit_$i"}</td>|;
 
2902       $column_data{description} =
 
2903         qq|<td><input type=hidden name="description_$i" value="$form->{"description_$i"}">$form->{"description_$i"}</td>|;
 
2906     $column_data{total} = qq|<td align=right>$linetotal</td>|;
 
2908     $column_data{deliverydate} = qq|<td align=right>$deliverydate</td>|;
 
2913     map { print "\n$column_data{$_}" } @column_index;
 
2917   <input type=hidden name="id_$i" value=$form->{"id_$i"}>
 
2918   <input type=hidden name="sellprice_$i" value=$form->{"sellprice_$i"}>
 
2919   <input type=hidden name="weight_$i" value=$form->{"weight_$i"}>
 
2929   $lxdebug->leave_sub();
 
2933   $lxdebug->enter_sub();
 
2935   if ($form->{item} eq "assembly") {
 
2936     $i = $form->{assembly_rows};
 
2938     # if last row is empty check the form otherwise retrieve item
 
2939     if (   ($form->{"partnumber_$i"} eq "")
 
2940         && ($form->{"description_$i"} eq "")
 
2941         && ($form->{"partsgroup_$i"}  eq "")) {
 
2947       IC->assembly_item(\%myconfig, \%$form);
 
2949       $rows = scalar @{ $form->{item_list} };
 
2952         $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
 
2955           $form->{makemodel_rows}--;
 
2959           map { $form->{item_list}[$i]{$_} =~ s/\"/"/g }
 
2960             qw(partnumber description unit partsgroup);
 
2961           map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} }
 
2962             keys %{ $form->{item_list}[0] };
 
2963           $form->{"runningnumber_$i"} = $form->{assembly_rows};
 
2964           $form->{assembly_rows}++;
 
2972         $form->{rowcount} = $i;
 
2973         $form->{assembly_rows}++;
 
2981   if ($form->{item} eq "part") {
 
2985   if ($form->{item} eq 'service') {
 
2986     map({ $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
2987         qw(sellprice listprice lastcost));
 
2993   $lxdebug->leave_sub();
 
2997   $lxdebug->enter_sub();
 
2999   # check if there is a part number - commented out, cause there is an automatic allocation of numbers
 
3000   # $form->isblank("partnumber", $locale->text(ucfirst $form->{item}." Part Number missing!"));
 
3002   # check if there is a description
 
3003   $form->isblank("description", $locale->text("Part Description missing!"));
 
3005   if ($form->{obsolete}) {
 
3008         "Inventory quantity must be zero before you can set this $form->{item} obsolete!"
 
3010       if ($form->{onhand} * 1);
 
3013   if (!$form->{buchungsgruppen_id}) {
 
3014     $form->error($locale->text("Parts must have an entry type.") . " " . 
 
3015      $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.") 
 
3019   $form->error($locale->text('Description must not be empty!')) unless $form->{description};
 
3020   $form->error($locale->text('Partnumber must not be set to empty!')) if $form->{id} && !$form->{partnumber};
 
3022   # expand dynamic strings
 
3023   # $locale->text('Inventory quantity must be zero before you can set this part obsolete!')
 
3024   # $locale->text('Inventory quantity must be zero before you can set this assembly obsolete!')
 
3025   # $locale->text('Part Number missing!')
 
3026   # $locale->text('Service Number missing!')
 
3027   # $locale->text('Assembly Number missing!')
 
3030   $lxdebug->message(LXDebug::DEBUG1,
 
3031                     "ic.pl: sellprice in save = $form->{sellprice}\n");
 
3032   $rc = IC->save(\%myconfig, \%$form);
 
3034     $form->error($locale->text('Partnumber not unique!'));
 
3036   # saving the history
 
3037   if(!exists $form->{addition}) {
 
3038     $form->{snumbers} = qq|partnumber_| . $form->{partnumber};
 
3039         $form->{addition} = "SAVED";
 
3040         $form->save_history($form->dbconnect(\%myconfig));
 
3042   # /saving the history
 
3043   $parts_id = $form->{id};
 
3045   # load previous variables
 
3046   if ($form->{previousform}) {
 
3048     # save the new form variables before splitting previousform
 
3049     map { $newform{$_} = $form->{$_} } keys %$form;
 
3051     $previousform = $form->unescape($form->{previousform});
 
3053     # don't trample on previous variables
 
3054     map { delete $form->{$_} } keys %newform;
 
3056     # now take it apart and restore original values
 
3057     foreach $item (split /&/, $previousform) {
 
3058       ($key, $value) = split /=/, $item, 2;
 
3059       $value =~ s/%26/&/g;
 
3060       $form->{$key} = $value;
 
3062     $form->{taxaccounts} = $newform{taxaccount2};
 
3064     if ($form->{item} eq 'assembly') {
 
3066       # undo number formatting
 
3067       map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
 
3068         qw(weight listprice sellprice rop);
 
3070       $form->{assembly_rows}--;
 
3071       $i = $newform{rowcount};
 
3072       $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
 
3074       $form->{sellprice} -= $form->{"sellprice_$i"} * $form->{"qty_$i"};
 
3075       $form->{weight}    -= $form->{"weight_$i"} * $form->{"qty_$i"};
 
3077       # change/add values for assembly item
 
3078       map { $form->{"${_}_$i"} = $newform{$_} }
 
3079         qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno);
 
3081       $form->{sellprice} += $form->{"sellprice_$i"} * $form->{"qty_$i"};
 
3082       $form->{weight}    += $form->{"weight_$i"} * $form->{"qty_$i"};
 
3086       # set values for last invoice/order item
 
3087       $i = $form->{rowcount};
 
3088       $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
 
3090       map { $form->{"${_}_$i"} = $newform{$_} }
 
3091         qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice);
 
3092       $form->{"sellprice_$i"} = $newform{lastcost} if ($form->{vendor_id});
 
3093       if ($form->{exchangerate} != 0) {
 
3094         $form->{"sellprice_$i"} /= $form->{exchangerate};
 
3096       $lxdebug->message(LXDebug::DEBUG1,
 
3097                         qq|sellprice_$i in previousform 2 = |
 
3098                           . $form->{"sellprice_$i"} . qq|\n|);
 
3099       map { $form->{"taxaccounts_$i"} .= "$_ " } split / /,
 
3100         $newform{taxaccount};
 
3101       chop $form->{"taxaccounts_$i"};
 
3102       foreach $item (qw(description rate taxnumber)) {
 
3103         $index = $form->{"taxaccounts_$i"} . "_$item";
 
3104         $form->{$index} = $newform{$index};
 
3107       # credit remaining calculation
 
3109         $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) *
 
3111       map { $form->{"${_}_base"} += $amount }
 
3112         (split / /, $form->{"taxaccounts_$i"});
 
3113       map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) }
 
3114         split / /, $form->{"taxaccounts_$i"}
 
3115         if !$form->{taxincluded};
 
3117       $form->{creditremaining} -= $amount;
 
3119       # redo number formatting, because invoice parse them!
 
3120       $i = $form->{rowcount};
 
3122         $form->{"${_}_$i"} =
 
3123           $form->format_amount(\%myconfig, $form->{"${_}_$i"})
 
3124       } qw(weight listprice sellprice rop);
 
3127     $form->{"id_$i"} = $parts_id;
 
3128     delete $form->{action};
 
3130     # restore original callback
 
3131     $callback = $form->unescape($form->{callback});
 
3132     $form->{callback} = $form->unescape($form->{old_callback});
 
3133     delete $form->{old_callback};
 
3135     $form->{makemodel_rows}--;
 
3137     # put callback together
 
3138     foreach $key (keys %$form) {
 
3140       # do single escape for Apache 2.0
 
3141       $value = $form->escape($form->{$key}, 1);
 
3142       $callback .= qq|&$key=$value|;
 
3144     $form->{callback} = $callback;
 
3146   $lxdebug->message(LXDebug::DEBUG1,
 
3147                     qq|ic.pl: sellprice_$i nach sub save = |
 
3148                       . $form->{"sellprice_$i"} . qq|\n|);
 
3153   $lxdebug->leave_sub();
 
3157   $lxdebug->enter_sub();
 
3159   # saving the history
 
3160   if(!exists $form->{addition}) {
 
3161     $form->{snumbers} = qq|partnumber_| . $form->{partnumber};
 
3162         $form->{addition} = "SAVED AS NEW";
 
3163         $form->save_history($form->dbconnect(\%myconfig));
 
3165   # /saving the history
 
3167   if ($form->{"original_partnumber"} &&
 
3168       ($form->{"partnumber"} eq $form->{"original_partnumber"})) {
 
3169     $form->{partnumber} = "";
 
3172   $lxdebug->leave_sub();
 
3176   $lxdebug->enter_sub();
 
3177   # saving the history
 
3178   if(!exists $form->{addition}) {
 
3179     $form->{snumbers} = qq|partnumber_| . $form->{partnumber};
 
3180         $form->{addition} = "DELETED";
 
3181         $form->save_history($form->dbconnect(\%myconfig));
 
3183   # /saving the history
 
3184   $rc = IC->delete(\%myconfig, \%$form);
 
3187   $form->redirect($locale->text('Item deleted!')) if ($rc > 0);
 
3188   $form->error($locale->text('Cannot delete item!'));
 
3190   $lxdebug->leave_sub();
 
3194   $lxdebug->enter_sub();
 
3203           <th class="listheading">| . $locale->text('Preisklasse') . qq|</th>
 
3204           <th class="listheading">| . $locale->text('Preis') . qq|</th>
 
3207   for $i (1 .. $numrows) {
 
3210           <td width=50%><input type=hidden name="pricegroup_$i" size=30  value="$form->{"pricegroup_$i"}">$form->{"pricegroup_$i"}</td>
 
3211           <td width=50%><input name="price_$i" size=11 value="$form->{"price_$i"}"></td>
 
3212           <input type=hidden name="pricegroup_id_$i" value="$form->{"pricegroup_id_$i"}">
 
3223   $lxdebug->leave_sub();
 
3226 sub parts_language_selection {
 
3227   $lxdebug->enter_sub();
 
3230   my $languages = IC->retrieve_languages(\%myconfig, $form);
 
3233   my $callback = "$form->{script}?action=parts_language_selection&";
 
3234   map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" }
 
3235       (qw(login password name input_name), grep({ /^[fl]_/ } keys %$form)));
 
3237   my @header_sort = qw(name longdescription);
 
3238   my %header_title = ( "name" => $locale->text("Name"),
 
3239                        "longdescription" => $locale->text("Long Description"),
 
3243     map(+{ "column_title" => $header_title{$_},
 
3245            "callback" => $callback,
 
3249   $form->{"title"} = $locale->text("Language Values");
 
3251   print($form->parse_html_template("ic/parts_language_selection", { "HEADER" => \@header,
 
3252                                                                    "LANGUAGES" => $languages,
 
3253                                                                    "onload" => $onload }));
 
3255   $lxdebug->leave_sub();
 
3258 sub continue { call_sub($form->{"nextsub"}); }