Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1cf7af35

Von Sven Schöling vor etwa 15 Jahren hinzugefügt

  • ID 1cf7af35bbd40e41d819739f8837fbd05b71be44
  • Vorgänger f7c2c55c
  • Nachfolger c19f41e1

Bisschen sanity durch strictness.

Unterschiede anzeigen:

SL/IC.pm
139 139
  $form->{PRICEGROUPS} = selectall_hashref_query($form, $dbh, $query);
140 140

  
141 141
  #find not used pricegroups
142
  while ($tmp = pop(@{ $form->{PRICEGROUPS} })) {
142
  while (my $tmp = pop(@{ $form->{PRICEGROUPS} })) {
143 143
    my $in_use = 0;
144 144
    foreach my $item (@pricegroups) {
145 145
      if ($item eq $tmp->{id}) {
......
153 153
  # if not used pricegroups are avaible
154 154
  if (@pricegroups_not_used) {
155 155

  
156
    foreach $name (@pricegroups_not_used) {
156
    foreach my $name (@pricegroups_not_used) {
157 157
      $form->{"klass_$i"} = "$name->{id}";
158 158
      $form->{"pricegroup_id_$i"} = "$name->{id}";
159 159
      $form->{"pricegroup_$i"}    = "$name->{pricegroup}";
......
170 170
    if ($form->{makemodel}) {
171 171
      $query = qq|SELECT m.make, m.model FROM makemodel m | .
172 172
               qq|WHERE m.parts_id = ?|;
173
      @values = ($form->{id});
173
      my @values = ($form->{id});
174 174
      $sth = $dbh->prepare($query);
175 175
      $sth->execute(@values) || $form->dberror("$query (" . join(', ', @values) . ")");
176 176

  
......
202 202
       FROM chart c, partstax pt
203 203
       WHERE (pt.chart_id = c.id) AND (pt.parts_id = ?)|;
204 204
  $sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id}));
205
  while (($key) = $sth->fetchrow_array) {
205
  while (my ($key) = $sth->fetchrow_array) {
206 206
    $form->{amount}{$key} = $key;
207 207
  }
208 208

  
......
245 245
  my $pricegroups = selectall_hashref_query($form, $dbh, $query);
246 246

  
247 247
  my $i = 1;
248
  foreach $pg (@{ $pricegroups }) {
248
  foreach my $pg (@{ $pricegroups }) {
249 249
    $form->{"klass_$i"} = "$pg->{id}";
250 250
    $form->{"price_$i"} = $form->format_amount($myconfig, $form->{"price_$i"}, -2);
251 251
    $form->{"pricegroup_id_$i"} = "$pg->{id}";
......
365 365
  my $partsgroup_id = 0;
366 366

  
367 367
  if ($form->{partsgroup}) {
368
    ($partsgroup, $partsgroup_id) = split(/--/, $form->{partsgroup});
368
    (my $partsgroup, $partsgroup_id) = split(/--/, $form->{partsgroup});
369 369
  }
370 370

  
371 371
  my ($subq_inventory, $subq_expense, $subq_income);
......
456 456
  do_query($form, $dbh, qq|DELETE FROM translation WHERE parts_id = ?|, conv_i($form->{id}));
457 457

  
458 458
  if ($form->{language_values} ne "") {
459
    foreach $item (split(/---\+\+\+---/, $form->{language_values})) {
459
    foreach my $item (split(/---\+\+\+---/, $form->{language_values})) {
460 460
      my ($language_id, $translation, $longdescription) = split(/--\+\+--/, $item);
461 461
      if ($translation ne "") {
462 462
        $query = qq|INSERT into translation (parts_id, language_id, translation, longdescription)
......
505 505
  }
506 506

  
507 507
  # insert taxes
508
  foreach $item (split(/ /, $form->{taxaccounts})) {
508
  foreach my $item (split(/ /, $form->{taxaccounts})) {
509 509
    if ($form->{"IC_tax_$item"}) {
510 510
      $query =
511 511
        qq|INSERT INTO partstax (parts_id, chart_id)
......
530 530
      }
531 531
    }
532 532

  
533
    @a = localtime;
533
    my @a = localtime;
534 534
    $a[5] += 1900;
535 535
    $a[4]++;
536 536
    my $shippingdate = "$a[5]-$a[4]-$a[3]";
......
553 553
       FROM chart c, tax t
554 554
       WHERE (c.id = t.chart_id) AND (t.taxkey IN (SELECT taxkey_id FROM chart where accno = ?))
555 555
       ORDER BY c.accno|;
556
  $stw = prepare_execute_query($form, $dbh, $query, $accno_id);
556
  my $stw = prepare_execute_query($form, $dbh, $query, $accno_id);
557 557

  
558 558
  $form->{taxaccount} = "";
559
  while ($ptr = $stw->fetchrow_hashref(NAME_lc)) {
559
  while (my $ptr = $stw->fetchrow_hashref(NAME_lc)) {
560 560
    $form->{taxaccount} .= "$ptr->{accno} ";
561 561
    if (!($form->{taxaccount2} =~ /\Q$ptr->{accno}\E/)) {
562 562
      $form->{"$ptr->{accno}_rate"}        = $ptr->{rate};
......
813 813
  my @select_tokens = qw(id factor);
814 814
  my @where_tokens  = qw(1=1);
815 815
  my @group_tokens  = ();
816
  my @bind_vars     = ();
816 817

  
817 818
  # special case transdate
818 819
  if (grep { $form->{$_} } qw(transdatefrom transdateto)) {
......
879 880
  # and yes, that expression is designed to hold that array of regexes only once, so the map is kinda messy, sorry about that.
880 881
  # ToDO: implement proper functional sorting
881 882
  # Nette Idee von Sven, gibt aber Probleme wenn die Artikelnummern groesser als 32bit sind. Korrekt waere es, dass Sort-Natural-Modul zu nehmen
882
  # Ich lass das mal hier drin, damit die Idee erhalten bleibt jb 28.5.2009 bug 1018 
883
  # Ich lass das mal hier drin, damit die Idee erhalten bleibt jb 28.5.2009 bug 1018
883 884
  #$form->{sort} = join ', ', map { push @select_tokens, $_; ($table_prefix{$_} = "substring(partnumber,'[") . $_ } qw|^[:digit:]]+') [:digit:]]+')::INTEGER|
884 885
  #  if $form->{sort} eq 'partnumber';
885 886

  
......
894 895
            || $form->{quoted}  || $form->{rfq};
895 896

  
896 897
  my @bsooqr;
898
  my @bsooqr_tokens = ();
897 899
  push @select_tokens, @qsooqr_flags                                          if $bsooqr;
898 900
  push @select_tokens, @deliverydate_flags                                    if $bsooqr && $form->{l_deliverydate};
899 901
  push @select_tokens, $q_assembly_lastcost                                   if ($form->{searchitems} eq 'assembly') && $form->{l_lastcost};
......
935 937

  
936 938
  #============= build query ================#
937 939

  
940
  my %table_prefix;
938 941
  %table_prefix = (
939 942
     %table_prefix,
940 943
     deliverydate => 'apoe.', serialnumber => 'ioi.',
......
993 996
         INNER JOIN assembly a ON (p.id = a.parts_id)
994 997
         $joins{pfac}
995 998
         WHERE a.id = ?|;
996
    $sth = prepare_query($form, $dbh, $query);
999
    my $sth = prepare_query($form, $dbh, $query);
997 1000

  
998
    foreach $item (@{ $form->{parts} }) {
1001
    foreach my $item (@{ $form->{parts} }) {
999 1002
      push(@assemblies, $item);
1000 1003
      do_statement($form, $sth, $query, conv_i($item->{id}));
1001 1004

  
1002
      while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
1005
      while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
1003 1006
        $ref->{assemblyitem} = 1;
1004 1007
        map { $ref->{$_} /= $ref->{factor} || 1 } qw(sellprice listprice lastcost);
1005 1008
        push(@assemblies, $ref);
......
1069 1072
  }
1070 1073

  
1071 1074
  foreach my $column (qw(make model)) {
1072
    next unless ($form->{$colum});
1075
    next unless ($form->{$column});
1073 1076
    $where .= qq| AND p.id IN (SELECT DISTINCT parts_id FROM makemodel WHERE $column ILIKE ?|;
1074 1077
    push(@where_values, '%' . $form->{$column} . '%');
1075 1078
  }
......
1087 1090
  my $myconfig = \%main::myconfig;
1088 1091
  my $form     = $main::form;
1089 1092

  
1090
  my $dbh      = $params{dbh} || $form->get_standard_dbh($myconfig);
1093
  my $dbh      = $form->get_standard_dbh($myconfig);
1091 1094

  
1092 1095
  my ($where, @where_values) = $self->_create_filter_for_priceupdate();
1093 1096

  
......
1105 1108
            FROM parts p
1106 1109
            LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id)
1107 1110
            WHERE $where)|;
1108
    my ($result)  = selectfirst_array_query($from, $dbh, $query, @where_values);
1111
    my ($result)  = selectfirst_array_query($form, $dbh, $query, @where_values);
1109 1112
    $num_updated += $result if (0 <= $result);
1110 1113
  }
1111 1114

  
......
1154 1157
      $operator = '*';
1155 1158
    }
1156 1159

  
1157
    $query =
1160
    my $query =
1158 1161
      qq|UPDATE parts SET $column = $column $operator ?
1159 1162
         WHERE id IN
1160 1163
           (SELECT p.id
1161 1164
            FROM parts p
1162 1165
            LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id)
1163 1166
            WHERE $where)|;
1164
    my $result    = do_query($from, $dbh, $query, $value, @where_values);
1167
    my $result    = do_query($form, $dbh, $query, $value, @where_values);
1165 1168
    $num_updated += $result if (0 <= $result);
1166 1169
  }
1167 1170

  
......
1218 1221
  my $dbh = $form->dbconnect($myconfig);
1219 1222

  
1220 1223
  my @values = ('%' . $module . '%');
1224
  my $query;
1221 1225

  
1222 1226
  if ($form->{id}) {
1223 1227
    $query =
......
1354 1358

  
1355 1359
  my @values;
1356 1360
  my $where;
1361
  my $query;
1357 1362

  
1358 1363
  if ($form->{language_values} ne "") {
1359 1364
    $query =
......
1397 1402

  
1398 1403
  while (1) {
1399 1404
    do_statement($form, $sth, $query, $accno_id);
1400
    $ref = $sth->fetchrow_hashref();
1405
    my $ref = $sth->fetchrow_hashref();
1401 1406
    last unless ($ref && $ref->{"is_valid"} &&
1402 1407
                 !grep({ $_ == $ref->{"new_chart_id"} } @visited_accno_ids));
1403 1408
    $accno_id = $ref->{"new_chart_id"};

Auch abrufbar als: Unified diff