Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision dc18ebba

Von Bernd Bleßmann vor mehr als 2 Jahren hinzugefügt

  • ID dc18ebba1c0c8bc69cca025ef0f60d8f04018e88
  • Vorgänger 1b3afb17
  • Nachfolger 8ce18fa4

Wiedervorlage für mehrere Benutzer: Filter und Anzeige im Bericht

Unterschiede anzeigen:

SL/FU.pm
7 7
use SL::Common;
8 8
use SL::DBUtils;
9 9
use SL::DB;
10
use SL::DB::FollowUpCreatedForEmployee;
10 11
use SL::Notes;
11 12

  
12 13
use strict;
......
249 250
    push @values, conv_date($params{itime_to});
250 251
  }
251 252
  if ($params{created_for}) {
252
    $where .= qq| AND fu.created_for_user = ?|;
253
    $where .= qq| AND follow_up_created_for_employees.employee_id = ?|;
253 254
    push @values, conv_i($params{created_for});
254 255
  }
255 256

  
......
264 265
    my %sort_columns = (
265 266
      'follow_up_date' => [ qw(fu.follow_up_date fu.id) ],
266 267
      'created_on'     => [ qw(created_on fu.id) ],
267
      'subject'        => [ qw(lower(n.subject)) ],
268
      'subject'        => [ qw(n.subject) ],
268 269
      );
269 270

  
270 271
    my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
......
272 273
    $order_by   = 'ORDER BY ' . join(', ', map { "$_ $sortdir" } @{ $sort_columns{$sortkey} });
273 274
  }
274 275

  
275
  $query  = qq|SELECT fu.*, n.subject, n.body, n.created_by,
276
  $query  = qq|SELECT DISTINCT fu.*, n.subject, n.body, n.created_by,
276 277
                 fu.follow_up_date <= current_date AS due,
277 278
                 fu.itime::DATE                    AS created_on,
278
                 COALESCE(eby.name,  eby.login)    AS created_by_name,
279
                 COALESCE(efor.name, efor.login)   AS created_for_user_name
279
                 COALESCE(eby.name,  eby.login)    AS created_by_name
280 280
               FROM follow_ups fu
281 281
               LEFT JOIN notes    n    ON (fu.note_id          = n.id)
282 282
               LEFT JOIN employee eby  ON (n.created_by        = eby.id)
283
               LEFT JOIN employee efor ON (fu.created_for_user = efor.id)
284
               WHERE ((fu.created_by = ?) OR (fu.created_for_user = ?)
283
               LEFT JOIN follow_up_created_for_employees ON (follow_up_created_for_employees.follow_up_id = fu.id)
284
               WHERE ((fu.created_by = ?) OR (follow_up_created_for_employees.employee_id = ?)
285 285
                      $where_user)
286 286
                 $where
287 287
               $order_by|;
......
295 295

  
296 296
  foreach my $fu (@{ $follow_ups }) {
297 297
    $fu->{LINKS} = $self->retrieve_links(%{ $fu });
298

  
299
    my $fu_created_for_employees = SL::DB::Manager::FollowUpCreatedForEmployee->get_all(
300
      where       => [follow_up_id => $fu->{id}],
301
      with_obects => ['employee']);
302
    $fu->{created_for_user_name} = join "\n", map { $_->employee->safe_name } @{$fu_created_for_employees};
298 303
  }
299 304

  
300 305
  if ($form->{sort} eq 'title') {

Auch abrufbar als: Unified diff