X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FProjects.pm;h=d3df51fdd9e1b009519d7c3c46d1cc25fe033e95;hb=23551aa675eb5966b8135e8797243364e709965f;hp=5327e91ad529a8434e6b6a372421b31057bb611f;hpb=0884406403ce36af3484924086527ba689807329;p=kivitendo-erp.git diff --git a/SL/Projects.pm b/SL/Projects.pm index 5327e91ad..d3df51fdd 100644 --- a/SL/Projects.pm +++ b/SL/Projects.pm @@ -37,6 +37,9 @@ package Projects; use Data::Dumper; use SL::DBUtils; +use SL::CVar; + +use strict; my %project_id_column_prefixes = ("ar" => "global", "ap" => "global", @@ -68,7 +71,7 @@ sub search_projects { foreach my $column (qw(projectnumber description)) { if ($params{$column}) { - push @filters, "$column ILIKE ?"; + push @filters, "p.$column ILIKE ?"; push @values, '%' . $params{$column} . '%'; } } @@ -81,22 +84,32 @@ sub search_projects { WHERE NOT $project_id_column_prefixes{$table}project_id ISNULL|; } - push @filters, "id NOT IN (" . join(" UNION ", @sub_filters) . ")"; + push @filters, "p.id NOT IN (" . join(" UNION ", @sub_filters) . ")"; } if ($params{active} eq "active") { - push @filters, 'active'; + push @filters, 'p.active'; } elsif ($params{active} eq "inactive") { - push @filters, 'NOT COALESCE(active, FALSE)'; + push @filters, 'NOT COALESCE(p.active, FALSE)'; + } + + my ($cvar_where, @cvar_values) = CVar->build_filter_query('module' => 'Projects', + 'trans_id_field' => 'p.id', + 'filter' => $form); + + if ($cvar_where) { + push @filters, $cvar_where; + push @values, @cvar_values; } - my $where = 'WHERE ' . join(' AND ', map { "($_)" } @filters) if (scalar @filters); + + my $where = @filters ? 'WHERE ' . join(' AND ', map { "($_)" } @filters) : ''; my $sortorder = $params{sort} ? $params{sort} : "projectnumber"; $sortorder =~ s/[^a-z_]//g; - my $query = qq|SELECT id, projectnumber, description, active - FROM project + my $query = qq|SELECT p.id, p.projectnumber, p.description, p.active + FROM project p $where ORDER BY $sortorder|; @@ -167,12 +180,18 @@ sub save_project { $params{active} = 1; } - $query = qq|UPDATE project SET projectnumber = ?, description = ?, active = ? + my $query = qq|UPDATE project SET projectnumber = ?, description = ?, active = ? WHERE id = ?|; @values = ($params{projectnumber}, $params{description}, $params{active} ? 't' : 'f', conv_i($params{id})); do_query($form, $dbh, $query, @values); + CVar->save_custom_variables('dbh' => $dbh, + 'module' => 'Projects', + 'trans_id' => $params{id}, + 'variables' => $form, + 'always_valid' => 1); + $dbh->commit(); $main::lxdebug->leave_sub();