Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2efc8cbc

Von Sven Schöling vor mehr als 17 Jahren hinzugefügt

  • ID 2efc8cbcc63c56094e0692067b7cb678c1583987
  • Vorgänger 79b00e85
  • Nachfolger 7783c24d

ic.pl auf use strict umgeschrieben (experimentell)
ic.pl generate_reports konsistenzchecks umgeschirben, und kommentiert, wird im weiteren mit verbesserter datenbanklogik
verwendet.
SL/IC.pm: kosmetik

Unterschiede anzeigen:

bin/mozilla/ic.pl
36 36

  
37 37
#use SL::PE;
38 38

  
39
use strict;
40
#use warnings;
41

  
39 42
require "bin/mozilla/io.pl";
40 43
require "bin/mozilla/common.pl";
41 44

  
42 45
1;
43 46

  
47
# global imports
48
my $form     = $main::form;
49
my $locale   = $main::locale;
50
my %myconfig = %main::myconfig;
51
my $lxdebug  = $main::lxdebug;
52

  
44 53
# end of main
45 54

  
46 55
sub add {
......
64 73
sub search {
65 74
  $lxdebug->enter_sub();
66 75

  
76
  my ($button1, $button2, $onhand, $makemodel, $serialnumber, $l_serialnumber, $toplevel, $bought);
77

  
67 78
  $form->{title} = (ucfirst $form->{searchitems}) . "s";
68 79
  $form->{title} = $locale->text($form->{title});
69 80

  
......
81 92

  
82 93
  # use JavaScript Calendar or not
83 94
  $form->{jsscript} = 1;
84
  $jsscript = "";
95
  my $jsscript = "";
85 96
  if ($form->{jsscript}) {
86 97

  
87 98
    # with JavaScript Calendar
......
400 411
sub search_update_prices {
401 412
  $lxdebug->enter_sub();
402 413

  
414
  my ($onhand, $makemodel, $serialnumber, $l_serialnumber, $toplevel, $bought);
415

  
403 416
  $form->{title} = $locale->text('Update prices');
404 417
  IC->get_pricegroups(\%myconfig, \%$form);
405 418

  
......
537 550
          <td><input name="listprice_type" class=radio type=radio value=percent checked>/<input name="listprice_type" class=radio type=radio value=absolut></td>
538 551
        </tr>
539 552
|;
540
  for $i (1 .. $form->{price_rows}) {
553
  for my $i (1 .. $form->{price_rows}) {
541 554
    print qq|
542 555
        <tr>
543 556
          <td width=50%><input type=hidden name="pricegroup_$i" size=30  value="$form->{"pricegroup_$i"}">$form->{"pricegroup_$i"}</td>
......
588 601
  # delete action variable
589 602
  map { delete $form->{$_} } qw(action header);
590 603

  
591
  foreach $key (keys %$form) {
604
  foreach my $key (keys %$form) {
592 605
    $form->{$key} =~ s/\"/&quot;/g;
593 606
    print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
594 607
  }
......
624 637
sub choice {
625 638
  $lxdebug->enter_sub();
626 639

  
640
  my $j       = $main::j;
641
  my $lastndx = $main::lastndx;
642

  
643
  my ($totop100);
644

  
627 645
  $form->{title} = $locale->text('Top 100 hinzufuegen');
628 646

  
629 647
  $form->header;
......
642 660
  print qq|
643 661
      <table>
644 662
	<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>
663
         <th class=listheading nowrap>| . $locale->text('Part Number') . qq|</th>
664
         <th class=listheading nowrap>| . $locale->text('Part Description') . qq|</th>
649 665
        </tr>
650 666
        <tr valign=top>
651 667
         <td><input type=text name=partnumber size=20 value=></td>
......
687 703

  
688 704
<input name=extras type=hidden value=$form->{extras}>|;
689 705

  
706
  my ($partnumber, $description, $unit, $sellprice, $soldtotal);
690 707
  # if choice set data
691 708
  if ($form->{ndx}) {
692
    for ($i = 0; $i < $form->{ndxs_counter}; $i++) {
709
    for (my $i = 0; $i < $form->{ndxs_counter}; $i++) {
693 710

  
694 711
      # prepeare data
695 712
      $partnumber  = $form->{"totop100_partnumber_$j"};
......
713 730

  
714 731
  # set data for next page
715 732
  if (($form->{ndxs_counter}) > 0) {
716
    for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
733
    for (my $i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
717 734
      $partnumber  = $form->{"totop100_partnumber_$i"};
718 735
      $description = $form->{"totop100_description_$i"};
719 736
      $unit        = $form->{"totop100_unit_$i"};
......
745 762
sub list {
746 763
  $lxdebug->enter_sub();
747 764

  
765
  my $lastndx = $main::lastndx;
766

  
748 767
  my @sortorders = ("", "partnumber", "description", "all");
749 768
  my $sortorder = $sortorders[($form->{description} ? 2 : 0) + ($form->{partnumber} ? 1 : 0)];
750 769
  IC->get_parts(\%myconfig, \%$form, $sortorder);
......
829 848

  
830 849
<input name=ndxs_counter type=hidden value=$form->{ndxs_counter}>|;
831 850

  
832
  $totop100 = "";
851
  my $totop100 = "";
833 852

  
834 853
  if (($form->{ndxs_counter}) > 0) {
835 854
    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"};
841

  
842
      $partnumber  = $j1;
843
      $description = $j2;
844
      $unit        = $j3;
845
      $sellprice   = $j4;
846
      $soldtotal   = $j5;
855

  
856
      # ToDO: does this really make sense?
857
      $main::partnumber  = $form->{"totop100_partnumber_$i"};
858
      $main::description = $form->{"totop100_description_$i"};
859
      $main::unit        = $form->{"totop100_unit_$i"};
860
      $main::sellprice   = $form->{"totop100_sellprice_$i"};
861
      $main::soldtotal   = $form->{"totop100_soldtotal_$i"};
847 862

  
848 863
      $totop100 .= qq|
849 864
<input type=hidden name=totop100_partnumber_$i value=$form->{"totop100_partnumber_$i"}>
......
876 891

  
877 892
    if ($form->{ndxs_counter} > 0) {
878 893

  
879
      $index = $form->{ndx};
880

  
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
      my $index = $form->{ndx};
895

  
896
      $form->{"totop100_partnumber_$form->{ndxs_counter}"} = $form->{"new_partnumber_$index"};
897
      $form->{"totop100_description_$form->{ndxs_counter}"} = $form->{"new_description_$index"};
898
      $form->{"totop100_unit_$form->{ndxs_counter}"} = $form->{"new_unit_$index"};
899
      $form->{"totop100_sellprice_$form->{ndxs_counter}"} = $form->{"new_sellprice_$index"};
900
      $form->{"totop100_soldtotal_$form->{ndxs_counter}"} = $form->{"new_soldtotal_$index"};
891 901
    }    #fi
892 902
  }    #fi
893 903
  &addtop100();
......
897 907
sub addtop100 {
898 908
  $lxdebug->enter_sub();
899 909

  
910
  my ($revers, $lastsort, $callback, $option, $description, $sameitem,
911
      $partnumber, $unit, $sellprice, $soldtotal, $totop100, $onhand, $align);
912
  my (@column_index, %column_header, %column_data);
913
  my ($totalsellprice, $totallastcost, $totallistprice, $subtotalonhand, $subtotalsellprice, $subtotallastcost, $subtotallistprice);
914

  
900 915
  $form->{top100}      = "top100";
901 916
  $form->{l_soldtotal} = "Y";
902 917
  $form->{soldtotal}   = "soldtotal";
903 918
  $form->{sort}        = "soldtotal";
904 919
  $form->{l_qty}       = "N";
905
  $callback .= "&form->{top100}=$form->{top100}";
906 920
  $form->{l_linetotal} = "";
907 921
  $form->{revers}      = 1;
908 922
  $form->{number}      = "position";
909 923
  $form->{l_number}    = "Y";
910 924

  
911
  my $totop100 = "";
925
  $totop100 = "";
912 926

  
913 927
  $form->{title} = $locale->text('Top 100');
914 928

  
......
1057 1071
    $option   .= $locale->text('soldtotal') . qq| : $form->{soldtotal}<br>|;
1058 1072
  }
1059 1073

  
1060
  @columns = $form->sort_columns(
1074
  my @columns = $form->sort_columns(
1061 1075
    qw(number partnumber ean description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice lastcost linetotallastcost priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal)
1062 1076
  );
1063 1077

  
......
1097 1111
  $form->{l_lastcost} = ""
1098 1112
    if ($form->{searchitems} eq 'assembly' && !$form->{bom});
1099 1113

  
1100
  foreach $item (@columns) {
1114
  foreach my $item (@columns) {
1101 1115
    if ($form->{"l_$item"} eq "Y") {
1102 1116
      push @column_index, $item;
1103 1117

  
......
1199 1213
    . qq|</a></th>|;
1200 1214

  
1201 1215
  $form->header;
1202
  $colspan = $#column_index + 1;
1216
  my $colspan = $#column_index + 1;
1203 1217

  
1204 1218
  print qq|
1205 1219
<body>
......
1233 1247

  
1234 1248
  # insert numbers for top100
1235 1249
  my $j = 0;
1236
  foreach $ref (@{ $form->{parts} }) {
1250
  foreach my $ref (@{ $form->{parts} }) {
1237 1251
    $j++;
1238 1252
    $ref->{number} = $j;
1239 1253
  }
1240 1254

  
1241 1255
  # if avaible -> insert choice here
1242 1256
  if (($form->{ndxs_counter}) > 0) {
1243
    for ($i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
1257
    for (my $i = 1; ($i < $form->{ndxs_counter} + 1); $i++) {
1244 1258
      $partnumber  = $form->{"totop100_partnumber_$i"};
1245 1259
      $description = $form->{"totop100_description_$i"};
1246 1260
      $unit        = $form->{"totop100_unit_$i"};
......
1266 1280
    }    #rof
1267 1281
  }    #fi
1268 1282
       # build data for columns
1269
  foreach $ref (@{ $form->{parts} }) {
1283
  foreach my $ref (@{ $form->{parts} }) {
1284
    my $i = 0;
1270 1285

  
1271 1286
    if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
1272 1287
      if ($sameitem ne $ref->{ $form->{sort} }) {
......
1469 1484
  $lxdebug->leave_sub();
1470 1485
}    # end addtop100
1471 1486

  
1487
#
1488
# Report for Wares.
1489
# Warning, deep magic ahead.
1490
# This function parses the requested details, sanity checks them, and converts them into a format thats usable for IC->all_parts
1491
#
1492
# flags coming from the form:
1493
# hardcoded:
1494
#  searchitems=part revers=0 lastsort=''
1495
#
1496
# filter:
1497
# partnumber ean description partsgroup serialnumber make model drawing microfiche
1498
# transdatefrom transdateto
1499
#
1500
# radio:
1501
#  itemstatus = active | onhand | short | obsolete | orphaned
1502
#  action     = continue | top100
1503
#
1504
# checkboxes:
1505
#  bought sold onorder ordered rfq quoted
1506
#  l_partnumber l_description l_serialnumber l_unit l_listprice l_sellprice l_lastcost
1507
#  l_linetotal l_priceupdate l_bin l_rop l_weight l_image l_drawing l_microfiche
1508
#  l_partsgroup l_subtotal l_soldtotal l_deliverydate
1509
#
1510
# hiddens: 
1511
#  nextsub login password revers lastsort sort ndxs_counter
1512
#
1472 1513
sub generate_report {
1473 1514
  $lxdebug->enter_sub();
1474 1515

  
1516
  my ($revers, $lastsort, $description);
1517
  my (@column_index, %column_header, %column_data, @columns, @options, @callbacks);
1518
  my ($totalsellprice, $totallastcost, $totallistprice, $subtotalonhand, $subtotalsellprice, $subtotallastcost, $subtotallistprice);
1519
  my ($colspan, $sameitem, $onhand, $align);
1520

  
1475 1521
  $revers   = $form->{revers};
1476 1522
  $lastsort = $form->{lastsort};
1477 1523

  
1524
  # sorting and direction of sorting
1525
  # ToDO: change this to the simpler field+direction method
1478 1526
  if (($form->{lastsort} eq "") && ($form->{sort} eq undef)) {
1479 1527
    $form->{revers}   = 0;
1480 1528
    $form->{lastsort} = "partnumber";
1481 1529
    $form->{sort}     = "partnumber";
1482 1530
  } else {
1483

  
1484
    # switch between backward sorting of tables
1485 1531
    if ($form->{lastsort} eq $form->{sort}) {
1486
      if ($form->{revers} == 0) {
1487
        $form->{revers} = 1;
1488
      } else {
1489
        $form->{revers} = 0;
1490
      }    #fi
1532
      $form->{revers} = 1 - $form->{revers};
1491 1533
    } else {
1492
      $form->{revers} == 0;
1534
      $form->{revers} = 0;
1493 1535
      $form->{lastsort} = $form->{sort};
1494 1536
    }    #fi
1495 1537
  }    #fi
1496 1538

  
1497
  $callback =
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);
1500

  
1501
  # if we have a serialnumber limit search
1502
  if ($form->{serialnumber} || $form->{l_serialnumber}) {
1503
    $form->{l_serialnumber} = "Y";
1504
    unless (   $form->{bought}
1505
            || $form->{sold}
1506
            || $form->{rfq}
1507
            || $form->{quoted}) {
1508
      $form->{bought} = $form->{sold} = 1;
1509
    }
1510
  }
1539
  # special case if we have a serialnumber limit search
1540
  # serialnumbers are only given in invoices and orders, 
1541
  # so they can only pop up in bought, sold, rfq, and quoted stuff
1542
  $form->{no_sn_joins} = 'Y' if (   !$form->{bought} && !$form->{sold} 
1543
                                 && !$form->{rfq}    && !$form->{quoted} 
1544
                                 && ($form->{l_serialnumber} || $form->{serialnumber}));
1545

  
1546
  # special case for any checkbox of bought | sold | onorder | ordered | rfq | quoted.
1547
  # if any of these are ticked the behavior changes slightly for lastcost
1548
  # since all those are aggregation checks for the legder tables this is an internal switch
1549
  # refered to as ledgerchecks
1550
  $form->{ledgerchecks} = 'Y' if (   $form->{bought} || $form->{sold} || $form->{onorder}
1551
                                  || $form->{ordered} || $form->{rfq} || $form->{quoted});
1552

  
1553
  # if something should be aktivated if something else is active, enter it here
1554
  my %dependencies = (
1555
    onhand       => [ qw(l_onhand) ],
1556
    short        => [ qw(l_onhand) ],
1557
    onorder      => [ qw(l_ordnumber) ],
1558
    ordered      => [ qw(l_ordnumber) ],
1559
    rfq          => [ qw(l_quonumber) ],
1560
    quoted       => [ qw(l_quonumber) ],
1561
    bought       => [ qw(l_invnumber) ],
1562
    sold         => [ qw(l_invnumber) ],
1563
    ledgerchecks => [ qw(l_name) ],
1564
    serialnumber => [ qw(l_serialnumber) ],
1565
    no_sn_joins  => [ qw(bought sold) ],
1566
  );
1511 1567

  
1512
  IC->all_parts(\%myconfig, \%$form);
1568
  # these strings get displayed at the top of the results to indicate the user which switches were used
1569
  my %optiontexts = (
1570
    active        => $locale->text('Active'),
1571
    obsolete      => $locale->text('Obsolete'),
1572
    orphaned      => $locale->text('Orphaned'),
1573
    onhand        => $locale->text('On Hand'),
1574
    short         => $locale->text('Short'),
1575
    onorder       => $locale->text('On Order'),
1576
    ordered       => $locale->text('Ordered'),
1577
    rfq           => $locale->text('RFQ'),
1578
    quoted        => $locale->text('Quoted'),
1579
    bought        => $locale->text('Bought'),
1580
    sold          => $locale->text('Sold'),
1581
    transdatefrom => $locale->text('From')       . " " . $locale->date(\%myconfig, $form->{transdatefrom}, 1),
1582
    transdateto   => $locale->text('To (time)')  . " " . $locale->date(\%myconfig, $form->{transdateto}, 1),
1583
    partnumber    => $locale->text('Part Number')      . ": '$form->{partnumber}'",
1584
    partsgroup    => $locale->text('Group')            . ": '$form->{partsgroup}'",
1585
    serialnumber  => $locale->text('Serial Number')    . ": '$form->{serialnumber}'",
1586
    description   => $locale->text('Part Description') . ": '$form->{description}'",
1587
    make          => $locale->text('Make')             . ": '$form->{make}'",
1588
    model         => $locale->text('Model')            . ": '$form->{model}'",
1589
    drawing       => $locale->text('Drawing')          . ": '$form->{drawing}'",
1590
    microfiche    => $locale->text('Microfiche')       . ": '$form->{microfiche}'",
1591
    l_soldtotal   => $locale->text('soldtotal'),
1592
  );
1513 1593

  
1514
  if ($form->{itemstatus} eq 'active') {
1515
    $option .= $locale->text('Active') . " : ";
1516
  }
1517
  if ($form->{itemstatus} eq 'obsolete') {
1518
    $option .= $locale->text('Obsolete') . " : ";
1519
  }
1520
  if ($form->{itemstatus} eq 'orphaned') {
1521
    $option .= $locale->text('Orphaned') . " : ";
1522
  }
1523
  if ($form->{itemstatus} eq 'onhand') {
1524
    $option .= $locale->text('On Hand') . " : ";
1525
    $form->{l_onhand} = "Y";
1526
  }
1527
  if ($form->{itemstatus} eq 'short') {
1528
    $option .= $locale->text('Short') . " : ";
1529
    $form->{l_onhand} = "Y";
1530
  }
1531
  if ($form->{onorder}) {
1532
    $form->{l_ordnumber} = "Y";
1533
    $callback .= "&onorder=$form->{onorder}";
1534
    $option   .= $locale->text('On Order') . " : ";
1535
  }
1536
  if ($form->{ordered}) {
1537
    $form->{l_ordnumber} = "Y";
1538
    $callback .= "&ordered=$form->{ordered}";
1539
    $option   .= $locale->text('Ordered') . " : ";
1540
  }
1541
  if ($form->{rfq}) {
1542
    $form->{l_quonumber} = "Y";
1543
    $callback .= "&rfq=$form->{rfq}";
1544
    $option   .= $locale->text('RFQ') . " : ";
1545
  }
1546
  if ($form->{quoted}) {
1547
    $form->{l_quonumber} = "Y";
1548
    $callback .= "&quoted=$form->{quoted}";
1549
    $option   .= $locale->text('Quoted') . " : ";
1594
  # this local subfunction generates a callback token from the input key.
1595
  # easy to join into a callback later
1596
  sub callback_token { 
1597
    map { /\w+$/; return "&$&=$form->{$&}" } @_;
1550 1598
  }
1551
  if ($form->{bought}) {
1552
    $form->{l_invnumber} = "Y";
1553
    $callback .= "&bought=$form->{bought}";
1554
    $option   .= $locale->text('Bought') . " : ";
1555
  }
1556
  if ($form->{sold}) {
1557
    $form->{l_invnumber} = "Y";
1558
    $callback .= "&sold=$form->{sold}";
1559
    $option   .= $locale->text('Sold') . " : ";
1599

  
1600
  my @itemstatus_keys = qw(active obsolete orphaned onhand short);
1601
  my @callback_keys   = qw(onorder ordered rfq quoted bought sold partnumber partsgroup serialnumber description make model 
1602
                           drawing microfiche l_soldtotal l_deliverydate transdatefrom transdateto);
1603
  my $callback           = "$form->{script}?action=generate_report";
1604
  map { $callback .= "&$_=" . $form->escape($form->{$_}) } qw(login password searchitems itemstatus bom l_linetotal title);
1605
    
1606
  # calculate dependencies
1607
  for (@itemstatus_keys, @callback_keys) { 
1608
    next if ($form->{itemstatus} ne $_ && !$form->{$_});
1609
    map { $form->{$_} = 'Y' } @{ $dependencies{$_} } if $dependencies{$_};
1560 1610
  }
1561
  if (   $form->{bought}
1562
      || $form->{sold}
1563
      || $form->{onorder}
1564
      || $form->{ordered}
1565
      || $form->{rfq}
1566
      || $form->{quoted}) {
1567 1611

  
1568
    $form->{l_lastcost} = "";
1569
    $form->{l_name}     = "Y";
1570
    if ($form->{transdatefrom}) {
1571
      $callback .= "&transdatefrom=$form->{transdatefrom}";
1572
      $option   .= "\n<br>"
1573
        . $locale->text('From')
1574
        . "&nbsp;"
1575
        . $locale->date(\%myconfig, $form->{transdatefrom}, 1);
1576
    }
1577
    if ($form->{transdateto}) {
1578
      $callback .= "&transdateto=$form->{transdateto}";
1579
      $option   .= "\n<br>"
1580
        . $locale->text('To (time)')
1581
        . "&nbsp;"
1582
        . $locale->date(\%myconfig, $form->{transdateto}, 1);
1583
    }
1612
  # generate callback and optionstrings
1613
  for my  $key (@itemstatus_keys, @callback_keys) { 
1614
    next if ($form->{itemstatus} ne $key && !$form->{$key});
1615
    push @options, $optiontexts{$key};
1616
    push @callbacks, callback_token($key) if grep { $_ eq $key } @callback_keys;;
1584 1617
  }
1618
  my $option    = $locale->text('Options') . ': ' . join(', ', grep $_, @options) . '<br>';
1619
  $callback .= join '', grep $_, @callbacks;
1585 1620

  
1586
  $option .= "<br>";
1621
  $lxdebug->message(0, $callback);
1587 1622

  
1588
  if ($form->{partnumber}) {
1589
    $callback .= "&partnumber=$form->{partnumber}";
1590
    $option   .= $locale->text('Part Number') . qq| : $form->{partnumber}<br>|;
1591
  }
1592
  if ($form->{partsgroup}) {
1593
    $callback .= "&partsgroup=$form->{partsgroup}";
1594
    $option   .= $locale->text('Group') . qq| : $form->{partsgroup}<br>|;
1595
  }
1596
  if ($form->{serialnumber}) {
1597
    $callback .= "&serialnumber=$form->{serialnumber}";
1598
    $option   .=
1599
      $locale->text('Serial Number') . qq| : $form->{serialnumber}<br>|;
1600
  }
1601
  if ($form->{description}) {
1602
    $callback .= "&description=$form->{description}";
1603
    $description = $form->{description};
1604
    $description =~ s/
1605
/<br>/g;
1606
    $option .=
1607
      $locale->text('Part Description') . qq| : $form->{description}<br>|;
1608
  }
1609
  if ($form->{make}) {
1610
    $callback .= "&make=$form->{make}";
1611
    $option   .= $locale->text('Make') . qq| : $form->{make}<br>|;
1612
  }
1613
  if ($form->{model}) {
1614
    $callback .= "&model=$form->{model}";
1615
    $option   .= $locale->text('Model') . qq| : $form->{model}<br>|;
1616
  }
1617
  if ($form->{drawing}) {
1618
    $callback .= "&drawing=$form->{drawing}";
1619
    $option   .= $locale->text('Drawing') . qq| : $form->{drawing}<br>|;
1620
  }
1621
  if ($form->{microfiche}) {
1622
    $callback .= "&microfiche=$form->{microfiche}";
1623
    $option   .= $locale->text('Microfiche') . qq| : $form->{microfiche}<br>|;
1624
  }
1623
  IC->all_parts(\%myconfig, \%$form);
1625 1624

  
1626
  # table soldtotal aktive
1627
  if ($form->{l_soldtotal}) {
1628
    $callback .= "&soldtotal=$form->{soldtotal}";
1629
    $option   .= $locale->text('soldtotal') . qq| : $form->{soldtotal}<br>|;
1630
  }
1625
  # special case for lastcost
1626
  $form->{l_lastcost} = "" if $form->{ledgerchecks};
1631 1627

  
1632
  if ($form->{l_deliverydate}) {
1633
    $callback .= "&deliverydate=$form->{deliverydate}";
1628
  if ($form->{description}) {
1629
    $description = $form->{description};
1630
    $description =~ s/\n/<br>/g;
1634 1631
  }
1635 1632

  
1636 1633
  @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)
1634
    qw(partnumber description partsgroup bin onhand rop unit listprice linetotallistprice sellprice linetotalsellprice 
1635
       lastcost linetotallastcost priceupdate weight image drawing microfiche invnumber ordnumber quonumber name serialnumber soldtotal deliverydate)
1638 1636
  );
1639 1637

  
1640 1638
  if ($form->{l_linetotal}) {
......
1673 1671
  $form->{l_lastcost} = ""
1674 1672
    if ($form->{searchitems} eq 'assembly' && !$form->{bom});
1675 1673

  
1676
  foreach $item (@columns) {
1674
  foreach my $item (@columns) {
1677 1675
    if ($form->{"l_$item"} eq "Y") {
1678 1676
      push @column_index, $item;
1679 1677

  
......
1809 1807
    $sameitem = $form->{parts}->[0]->{ $form->{sort} };
1810 1808
  }
1811 1809

  
1812
  foreach $ref (@{ $form->{parts} }) {
1810
  foreach my $ref (@{ $form->{parts} }) {
1811
    my $i = 0;
1813 1812

  
1814 1813
    if ($form->{l_subtotal} eq 'Y' && !$ref->{assemblyitem}) {
1815 1814
      if ($sameitem ne $ref->{ $form->{sort} }) {
......
1999 1998

  
2000 1999
sub parts_subtotal {
2001 2000
  $lxdebug->enter_sub();
2001
  
2002
  # imports
2003
  my %column_data       = $main::column_data;
2004
  my @column_index      = $main::column_index;
2005
  my $subtotalonhand    = $main::subtotalonhand;
2006
  my $totalsellprice    = $main::totalsellprice;
2007
  my $totallastcost     = $main::totallastcost;
2008
  my $totallistprice    = $main::totallistprice;
2009
  my $subtotalsellprice = $main::subtotalsellprice;
2010
  my $subtotallastcost  = $main::subtotallastcost;
2011
  my $subtotallistprice = $main::subtotallistprice;
2002 2012

  
2003 2013
  map { $column_data{$_} = "<td>&nbsp;</td>" } @column_index;
2004 2014
  $subtotalonhand = 0 if ($form->{searchitems} eq 'assembly' && $form->{bom});
......
2064 2074
      split(/:/, $form->{currencies}));
2065 2075

  
2066 2076
  # parts and assemblies have the same links
2067
  $item = $form->{item};
2077
  my $item = $form->{item};
2068 2078
  if ($form->{item} eq 'assembly') {
2069 2079
    $item = 'part';
2070 2080
  }
2071 2081

  
2072 2082
  # build the popup menus
2073 2083
  $form->{taxaccounts} = "";
2074
  foreach $key (keys %{ $form->{IC_links} }) {
2075
    foreach $ref (@{ $form->{IC_links}{$key} }) {
2084
  foreach my $key (keys %{ $form->{IC_links} }) {
2085
    foreach my $ref (@{ $form->{IC_links}{$key} }) {
2076 2086

  
2077 2087
      # if this is a tax field
2078 2088
      if ($key =~ /IC_tax/) {
......
2126 2136

  
2127 2137
  if ($form->{item} eq 'assembly') {
2128 2138

  
2129
    foreach $i (1 .. $form->{assembly_rows}) {
2139
    foreach my $i (1 .. $form->{assembly_rows}) {
2130 2140
      if ($form->{"partsgroup_id_$i"}) {
2131 2141
        $form->{"partsgroup_$i"} =
2132 2142
          qq|$form->{"partsgroup_$i"}--$form->{"partsgroup_id_$i"}|;
......
2149 2159
sub form_header {
2150 2160
  $lxdebug->enter_sub();
2151 2161

  
2162
  my ($payment, $rows, $notes, $description, $ean, $buchungsgruppe, $partsgroup, $group, $tax, $lastcost, $eur, $linkaccounts, $weight, $n, $rop, $bin, $vegv);
2163
  my ($notdiscountableok, $notdiscountable);
2164
  my ($formel, $imagelinks, $obsolete, $shopok, $shop);
2165

  
2166

  
2152 2167
  map({ $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, -2) }
2153 2168
      qw(sellprice listprice lastcost gv));
2154 2169

  
2155 2170
  map { $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}) }
2156 2171
    qw(weight rop stock);
2157 2172

  
2158
  foreach $item (qw(partnumber description unit notes)) {
2173
  foreach my $item (qw(partnumber description unit notes)) {
2159 2174
    $form->{$item} =~ s/\"/&quot;/g;
2160 2175
  }
2161 2176

  
2162 2177
  $payment = qq|<option value=""></option>|;
2163
  foreach $item (@{ $form->{payment_terms} }) {
2178
  foreach my $item (@{ $form->{payment_terms} }) {
2164 2179
    if ($form->{payment_id} eq $item->{id}) {
2165 2180
      $payment .= qq|<option value="$item->{id}" selected>$item->{description}</option>|;
2166 2181
    } else {
......
2185 2200

  
2186 2201
  $ean =  qq|<input name=ean size=40 value="$form->{ean}">|;
2187 2202

  
2188
  foreach $item (split / /, $form->{taxaccounts}) {
2203
  foreach my $item (split / /, $form->{taxaccounts}) {
2189 2204
    $form->{"IC_tax_$item"} = ($form->{"IC_tax_$item"}) ? "checked" : "";
2190 2205
  }
2191 2206

  
2192 2207
  IC->retrieve_buchungsgruppen(\%myconfig, $form);
2193 2208
  if (@{ $form->{BUCHUNGSGRUPPEN} }) {
2194
    foreach $item (@{ $form->{BUCHUNGSGRUPPEN} }) {
2209
    foreach my $item (@{ $form->{BUCHUNGSGRUPPEN} }) {
2195 2210
      if ($item->{id} == $form->{buchungsgruppen_id}) {
2196 2211
        $form->{selectbuchungsgruppe} .=
2197 2212
          "<option value=$item->{id} selected>$item->{description}\n";
......
2211 2226

  
2212 2227

  
2213 2228
  # set option
2214
  foreach $item (qw(IC IC_income IC_expense)) {
2229
  foreach my $item (qw(IC IC_income IC_expense)) {
2215 2230
    if ($form->{$item}) {
2216 2231
      if ($form->{id} && $form->{orphaned}) {
2217 2232
        $form->{"select$item"} =~ s/ selected//;
......
2237 2252
  }
2238 2253

  
2239 2254
  # tax fields
2240
  foreach $item (split / /, $form->{taxaccounts}) {
2255
  foreach my $item (split / /, $form->{taxaccounts}) {
2241 2256
    $tax .= qq|
2242 2257
      <input class=checkbox type=checkbox name="IC_tax_$item" value=1 $form->{"IC_tax_$item"}>&nbsp;<b>$form->{"IC_tax_${item}_description"}</b>
2243 2258
      <br><input type=hidden name=IC_tax_${item}_description value="$form->{"IC_tax_${item}_description"}">
......
2455 2470
  # type=submit $locale->text('Edit Service')
2456 2471
  # type=submit $locale->text('Edit Assembly')
2457 2472
  # use JavaScript Calendar or not
2473
  my ($jsscript, $button1);
2458 2474
  $form->{jsscript} = 1;
2459 2475
  $jsscript = "";
2460 2476
  if ($form->{jsscript}) {
......
2730 2746
sub makemodel_row {
2731 2747
  $lxdebug->enter_sub();
2732 2748
  my ($numrows) = @_;
2733

  
2734
  $form->{"make_$i"}  =~ s/\"/&quot;/g;
2735
  $form->{"model_$i"} =~ s/\"/&quot;/g;
2736

  
2749
  
2737 2750
  print qq|
2738 2751
  <tr>
2739 2752
    <td>
......
2744 2757
	</tr>
2745 2758
|;
2746 2759

  
2747
  for $i (1 .. $numrows) {
2760
  for my $i (1 .. $numrows) {
2761
    $form->{"make_$i"}  =~ s/\"/&quot;/g;
2762
    $form->{"model_$i"} =~ s/\"/&quot;/g;
2748 2763
    print qq|
2749 2764
	<tr>
2750 2765
	  <td width=50%><input name="make_$i" size=30 value="$form->{"make_$i"}"></td>
......
2765 2780
sub assembly_row {
2766 2781
  $lxdebug->enter_sub();
2767 2782
  my ($numrows) = @_;
2783
  my (@column_index, %column_data, %column_header);
2784
  my ($nochange, $callback, $previousform, $linetotal, $href);
2785

  
2786
  my $deliverydate = $main::deliverydate; # ToDO: cjeck if this indeed comes from global context
2768 2787

  
2769 2788
  @column_index =
2770 2789
    qw(runningnumber qty unit bom partnumber description partsgroup total);
......
2785 2804
    $previousform = "";
2786 2805

  
2787 2806
    # save form variables in a previousform variable
2788
    foreach $key (sort keys %$form) {
2807
    foreach my $key (sort keys %$form) {
2789 2808

  
2790 2809
      # escape ampersands
2791 2810
      $form->{$key} =~ s/&/%26/g;
......
2832 2851
        </tr>
2833 2852
|;
2834 2853

  
2835
  for $i (1 .. $numrows) {
2854
  for my $i (1 .. $numrows) {
2836 2855
    $form->{"partnumber_$i"} =~ s/\"/&quot;/g;
2837 2856

  
2838 2857
    $linetotal =
......
2933 2952
  $lxdebug->enter_sub();
2934 2953

  
2935 2954
  if ($form->{item} eq "assembly") {
2936
    $i = $form->{assembly_rows};
2955
    my $i = $form->{assembly_rows};
2937 2956

  
2938 2957
    # if last row is empty check the form otherwise retrieve item
2939 2958
    if (   ($form->{"partnumber_$i"} eq "")
......
2946 2965

  
2947 2966
      IC->assembly_item(\%myconfig, \%$form);
2948 2967

  
2949
      $rows = scalar @{ $form->{item_list} };
2968
      my $rows = scalar @{ $form->{item_list} };
2950 2969

  
2951 2970
      if ($rows) {
2952 2971
        $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
......
2996 3015
sub save {
2997 3016
  $lxdebug->enter_sub();
2998 3017

  
3018
  my ($parts_id, %newform, $previousform, $amount, $callback);
3019

  
2999 3020
  # check if there is a part number - commented out, cause there is an automatic allocation of numbers
3000 3021
  # $form->isblank("partnumber", $locale->text(ucfirst $form->{item}." Part Number missing!"));
3001 3022

  
......
3027 3048
  # $locale->text('Assembly Number missing!')
3028 3049

  
3029 3050
  # save part
3030
  $lxdebug->message(LXDebug::DEBUG1,
3031
                    "ic.pl: sellprice in save = $form->{sellprice}\n");
3032
  $rc = IC->save(\%myconfig, \%$form);
3033
  if ($rc == 3) {
3051
  $lxdebug->message($LXDebug::DEBUG1, "ic.pl: sellprice in save = $form->{sellprice}\n");
3052
  if (IC->save(\%myconfig, \%$form) == 3) {
3034 3053
    $form->error($locale->text('Partnumber not unique!'));
3035 3054
  }
3036 3055
  # saving the history
......
3042 3061
  # /saving the history
3043 3062
  $parts_id = $form->{id};
3044 3063

  
3064
  my $i;
3045 3065
  # load previous variables
3046 3066
  if ($form->{previousform}) {
3047 3067

  
......
3054 3074
    map { delete $form->{$_} } keys %newform;
3055 3075

  
3056 3076
    # now take it apart and restore original values
3057
    foreach $item (split /&/, $previousform) {
3058
      ($key, $value) = split /=/, $item, 2;
3077
    foreach my $item (split /&/, $previousform) {
3078
      my ($key, $value) = split /=/, $item, 2;
3059 3079
      $value =~ s/%26/&/g;
3060 3080
      $form->{$key} = $value;
3061 3081
    }
......
3093 3113
      if ($form->{exchangerate} != 0) {
3094 3114
        $form->{"sellprice_$i"} /= $form->{exchangerate};
3095 3115
      }
3096
      $lxdebug->message(LXDebug::DEBUG1,
3097
                        qq|sellprice_$i in previousform 2 = |
3098
                          . $form->{"sellprice_$i"} . qq|\n|);
3116
      $lxdebug->message($LXDebug::DEBUG1, qq|sellprice_$i in previousform 2 = | . $form->{"sellprice_$i"} . qq|\n|);
3099 3117
      map { $form->{"taxaccounts_$i"} .= "$_ " } split / /,
3100 3118
        $newform{taxaccount};
3101 3119
      chop $form->{"taxaccounts_$i"};
3102
      foreach $item (qw(description rate taxnumber)) {
3103
        $index = $form->{"taxaccounts_$i"} . "_$item";
3120
      foreach my $item (qw(description rate taxnumber)) {
3121
        my $index = $form->{"taxaccounts_$i"} . "_$item";
3104 3122
        $form->{$index} = $newform{$index};
3105 3123
      }
3106 3124

  
......
3135 3153
    $form->{makemodel_rows}--;
3136 3154

  
3137 3155
    # put callback together
3138
    foreach $key (keys %$form) {
3156
    foreach my $key (keys %$form) {
3139 3157

  
3140 3158
      # do single escape for Apache 2.0
3141
      $value = $form->escape($form->{$key}, 1);
3159
      my $value = $form->escape($form->{$key}, 1);
3142 3160
      $callback .= qq|&$key=$value|;
3143 3161
    }
3144 3162
    $form->{callback} = $callback;
3145 3163
  }
3146
  $lxdebug->message(LXDebug::DEBUG1,
3147
                    qq|ic.pl: sellprice_$i nach sub save = |
3148
                      . $form->{"sellprice_$i"} . qq|\n|);
3164
  $lxdebug->message($LXDebug::DEBUG1, qq|ic.pl: sellprice_$i nach sub save = | . $form->{"sellprice_$i"} . qq|\n|);
3149 3165

  
3150 3166
  # redirect
3151 3167
  $form->redirect;
......
3181 3197
  	$form->save_history($form->dbconnect(\%myconfig));
3182 3198
  }
3183 3199
  # /saving the history
3184
  $rc = IC->delete(\%myconfig, \%$form);
3200
  my $rc = IC->delete(\%myconfig, \%$form);
3185 3201

  
3186 3202
  # redirect
3187 3203
  $form->redirect($locale->text('Item deleted!')) if ($rc > 0);
......
3204 3220
          <th class="listheading">| . $locale->text('Preis') . qq|</th>
3205 3221
        </tr>
3206 3222
|;
3207
  for $i (1 .. $numrows) {
3223
  for my $i (1 .. $numrows) {
3208 3224
    print qq|
3209 3225
        <tr>
3210 3226
          <td width=50%><input type=hidden name="pricegroup_$i" size=30  value="$form->{"pricegroup_$i"}">$form->{"pricegroup_$i"}</td>
......
3226 3242
sub parts_language_selection {
3227 3243
  $lxdebug->enter_sub();
3228 3244

  
3245
  my $onload = $main::onload;
3229 3246

  
3230 3247
  my $languages = IC->retrieve_languages(\%myconfig, $form);
3231 3248

  

Auch abrufbar als: Unified diff