Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision cd92cf1c

Von Moritz Bunkus vor etwa 16 Jahren hinzugefügt

  • ID cd92cf1c19785cdcd5812735185676c9ad982175
  • Vorgänger 79778ae9
  • Nachfolger a13d2254

Benutzerdefinierte Variablen für Projekte implementiert.

Unterschiede anzeigen:

SL/Projects.pm
37 37
use Data::Dumper;
38 38

  
39 39
use SL::DBUtils;
40
use SL::CVar;
40 41

  
41 42
my %project_id_column_prefixes  = ("ar"              => "global",
42 43
                                   "ap"              => "global",
......
68 69

  
69 70
  foreach my $column (qw(projectnumber description)) {
70 71
    if ($params{$column}) {
71
      push @filters, "$column ILIKE ?";
72
      push @filters, "p.$column ILIKE ?";
72 73
      push @values, '%' . $params{$column} . '%';
73 74
    }
74 75
  }
......
81 82
                            WHERE NOT $project_id_column_prefixes{$table}project_id ISNULL|;
82 83
    }
83 84

  
84
    push @filters, "id NOT IN (" . join(" UNION ", @sub_filters) . ")";
85
    push @filters, "p.id NOT IN (" . join(" UNION ", @sub_filters) . ")";
85 86
  }
86 87

  
87 88
  if ($params{active} eq "active") {
88
    push @filters, 'active';
89
    push @filters, 'p.active';
89 90

  
90 91
  } elsif ($params{active} eq "inactive") {
91
    push @filters, 'NOT COALESCE(active, FALSE)';
92
    push @filters, 'NOT COALESCE(p.active, FALSE)';
92 93
  }
93 94

  
95
  my ($cvar_where, @cvar_values) = CVar->build_filter_query('module'         => 'Projects',
96
                                                            'trans_id_field' => 'p.id',
97
                                                            'filter'         => $form);
98

  
99
  if ($cvar_where) {
100
    push @filters, $cvar_where;
101
    push @values,  @cvar_values;
102
  }
103

  
104

  
94 105
  my $where = 'WHERE ' . join(' AND ', map { "($_)" } @filters) if (scalar @filters);
95 106

  
96 107
  my $sortorder =  $params{sort} ? $params{sort} : "projectnumber";
97 108
  $sortorder    =~ s/[^a-z_]//g;
98
  my $query     = qq|SELECT id, projectnumber, description, active
99
                     FROM project
109
  my $query     = qq|SELECT p.id, p.projectnumber, p.description, p.active
110
                     FROM project p
100 111
                     $where
101 112
                     ORDER BY $sortorder|;
102 113

  
......
173 184
  @values = ($params{projectnumber}, $params{description}, $params{active} ? 't' : 'f', conv_i($params{id}));
174 185
  do_query($form, $dbh, $query, @values);
175 186

  
187
  CVar->save_custom_variables('dbh'       => $dbh,
188
                              'module'    => 'Projects',
189
                              'trans_id'  => $params{id},
190
                              'variables' => $form);
191

  
176 192
  $dbh->commit();
177 193

  
178 194
  $main::lxdebug->leave_sub();

Auch abrufbar als: Unified diff