Changeset 2146


Ignore:
Timestamp:
08/29/18 20:15:47 (6 years ago)
Author:
nanardon
Message:

Add activeEmployment attribute: allow to select current and futur employment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r2144 r2146  
    13551355                } 
    13561356            }, 
     1357            activeEmployment => { 
     1358                managed => 1, 
     1359                ro => 1, 
     1360                reference => 'employment', 
     1361                multiple => 1, 
     1362                get => sub { 
     1363                    my ($attr) = @_; 
     1364                    my $self = $attr->object; 
     1365 
     1366                    my $now = DateTime->now()->iso8601 . 'Z'; 
     1367 
     1368                    my $sth = $self->base->db->prepare_cached( 
     1369                        q{ 
     1370                        select name from employment where (lastday > ?::timestamp or lastday IS NULL) and "user" = ? 
     1371                        order by firstday asc 
     1372                        limit 1 
     1373                        } 
     1374                    ); 
     1375                    $sth->execute($now, $self->id); 
     1376                    my @Res; 
     1377                    while (my  $res = $sth->fetchrow_hashref) { 
     1378                        push(@Res, $res->{name}); 
     1379                    } 
     1380 
     1381                    return \@Res; 
     1382                } 
     1383            }, 
    13571384            prevEmployment => { 
    13581385                managed => 1, 
Note: See TracChangeset for help on using the changeset viewer.