Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1163cee7

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

  • ID 1163cee7d5cfe9355a9d231ac544ce0943623d77
  • Vorgänger f633eda2
  • Nachfolger 684e84d8

Warensuche: überlagerte custom variables werden nun korrekt auch in der Warensuche überlagert.

Unterschiede anzeigen:

SL/CVar.pm
438 438

  
439 439
      my $f_op = $params{filter}->{"${name}_qtyop"};
440 440

  
441
      my $op;
441 442
      if ($f_op eq '==') {
442 443
        $op  = '=';
443 444

  
......
515 516
    return;
516 517
  }
517 518

  
519
  # allow sub_module to be a coderef or a fixed value
520
  if (ref $params{sub_module} ne 'CODE') {
521
    $params{sub_module} = sub { "$params{sub_module}" };
522
  }
523

  
518 524
  my %cfg_map   = map { $_->{id} => $_ } @{ $configs };
519 525
  my @cfg_ids   = keys %cfg_map;
520 526

  
......
527 533
  my $sth       = prepare_query($form, $dbh, $query);
528 534

  
529 535
  foreach my $row (@{ $params{data} }) {
530
    do_statement($form, $sth, $query, @cfg_ids, conv_i($row->{$params{trans_id_field}}), "$params{sub_module}");
536
    do_statement($form, $sth, $query, @cfg_ids, conv_i($row->{$params{trans_id_field}}), $params{sub_module}->($row));
531 537

  
532 538
    while (my $ref = $sth->fetchrow_hashref()) {
533 539
      my $cfg = $cfg_map{$ref->{config_id}};
......
535 541
      $row->{"cvar_$cfg->{name}"} =
536 542
          $cfg->{type} eq 'date'      ? $ref->{date_value}
537 543
        : $cfg->{type} eq 'timestamp' ? $ref->{timestamp_value}
538
        : $cfg->{type} eq 'number'    ? $form->format_amount($myconfig, $ref->{number_value} * 1, $config->{precision})
544
        : $cfg->{type} eq 'number'    ? $form->format_amount($myconfig, $ref->{number_value} * 1, $cfg->{precision})
539 545
        : $cfg->{type} eq 'bool'      ? ($ref->{bool_value} ? $locale->text('Yes') : $locale->text('No'))
540 546
        :                               $ref->{text_value};
541 547
    }
SL/IC.pm
792 792
    pfac       => 'LEFT JOIN price_factors pfac ON (pfac.id     = p.price_factor_id)',
793 793
    invoice_oi =>
794 794
      q|LEFT JOIN (
795
         SELECT parts_id, description, serialnumber, trans_id, unit, sellprice, qty,          assemblyitem,         deliverydate, 'invoice'    AS ioi FROM invoice UNION
796
         SELECT parts_id, description, serialnumber, trans_id, unit, sellprice, qty, FALSE AS assemblyitem, NULL AS deliverydate, 'orderitems' AS ioi FROM orderitems
795
         SELECT parts_id, description, serialnumber, trans_id, unit, sellprice, qty,          assemblyitem,         deliverydate, 'invoice'    AS ioi, id FROM invoice UNION
796
         SELECT parts_id, description, serialnumber, trans_id, unit, sellprice, qty, FALSE AS assemblyitem, NULL AS deliverydate, 'orderitems' AS ioi, id FROM orderitems
797 797
       ) AS ioi ON ioi.parts_id = p.id|,
798 798
    apoe       =>
799 799
      q|LEFT JOIN (
......
824 824
     serialnumber => 'ioi.',
825 825
     quotation    => 'apoe.',
826 826
     cv           => 'cv.',
827
     "ioi.id"     => ' ',
828
     "ioi.ioi"    => ' ',
827 829
  );
828 830

  
829 831
  # if the join condition in these blocks are met, the column
......
841 843
  my %renamed_columns = (
842 844
    'factor'       => 'price_factor',
843 845
    'SUM(ioi.qty)' => 'soldtotal',
846
    'ioi.id'       => 'ioi_id',
847
    'ioi.ioi'      => 'ioi',
844 848
  );
845 849

  
846 850
  if (($form->{searchitems} eq 'assembly') && $form->{l_lastcost}) {
......
937 941
  my $bsooqr        = any { $form->{$_} } @oe_flags;
938 942
  my @bsooqr_tokens = ();
939 943

  
940
  push @select_tokens, @qsooqr_flags, 'quotation', 'cv'                       if $bsooqr;
944
  push @select_tokens, @qsooqr_flags, 'quotation', 'cv', 'ioi.id', 'ioi.ioi'  if $bsooqr;
941 945
  push @select_tokens, @deliverydate_flags                                    if $bsooqr && $form->{l_deliverydate};
942 946
  push @select_tokens, $q_assembly_lastcost                                   if ($form->{searchitems} eq 'assembly') && $form->{l_lastcost};
943 947
  push @bsooqr_tokens, q|module = 'ir' AND NOT ioi.assemblyitem|              if $form->{bought};
......
1005 1009
    push @bind_vars, @cvar_values;
1006 1010
  }
1007 1011

  
1008
  my $query = qq|SELECT DISTINCT $select_clause FROM parts p $join_clause WHERE $where_clause $group_clause $order_clause $limit_clause|;
1012
  my $query = <<"  SQL";
1013
    SELECT DISTINCT $select_clause
1014
    FROM parts p
1015
    $join_clause
1016
    WHERE $where_clause
1017
    $group_clause
1018
    $order_clause
1019
    $limit_clause
1020
  SQL
1009 1021

  
1010 1022
  $form->{parts} = selectall_hashref_query($form, $dbh, $query, @bind_vars);
1011 1023

  
bin/mozilla/ic.pl
1241 1241
                                       'column_defs'    => \%column_defs,
1242 1242
                                       'data'           => $form->{parts});
1243 1243

  
1244
  CVar->add_custom_variables_to_report('module'         => 'IC',
1245
                                       'sub_module'     => sub { $_[0]->{ioi} },
1246
                                       'trans_id_field' => 'ioi_id',
1247
                                       'configs'        => $cvar_configs,
1248
                                       'column_defs'    => \%column_defs,
1249
                                       'data'           => $form->{parts});
1250

  
1244 1251
  my @subtotal_columns = qw(sellprice listprice lastcost);
1245 1252
  my %subtotals = map { $_ => 0 } ('onhand', @subtotal_columns);
1246 1253
  my %totals    = map { $_ => 0 } @subtotal_columns;

Auch abrufbar als: Unified diff