Changeset 1566 for trunk


Ignore:
Timestamp:
12/30/15 13:56:55 (9 years ago)
Author:
nanardon
Message:

Make employment date store litterally to allow fast search

Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql
Files:
2 edited

Legend:

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

    r1551 r1566  
    282282    my $expire = str2time($user->get_attributes('expire') || '1970-01-01T00:00:00'); 
    283283 
     284    my %changes; 
     285    foreach (qw( endEmployment endStrictEmployment endCurrentEmployment endLastEmployment )) { 
     286        my $old = $user->_get_attributes($_) || ''; 
     287        my $new = $user->_get_attributes("_$_") || ''; 
     288        if ($old ne $new) { 
     289            $changes{$_} = $new; 
     290        } 
     291    } 
     292 
    284293    # If there is no current employment we try to find any to not let expire 
    285294    # unset 
    286295    my $endemploy = $currentemployment 
    287         ? $user->get_attributes('endEmployment') 
    288         : $user->get_attributes('endLastEmployment'); 
     296        ? $user->_get_attributes('_endEmployment') 
     297        : $user->_get_attributes('_endLastEmployment'); 
    289298    my $nextexpire = str2time($endemploy || '1970-01-01T00:00:00'); 
    290299 
    291300    if ($expire != $nextexpire) { 
    292         $user->set_fields(expire => $endemploy); 
    293         $user->ReportChange('Update', 'Expire update to %s to match employment', ($endemploy || '(none)')); 
     301        $changes{expire} = $endemploy; 
     302    } 
     303 
     304    if (keys %changes) { 
     305        $user->ReportChange('Update', 'Update %s to match employment', join(', ', sort keys %changes)); 
     306        $user->ReportChange('Update', 'Expire update to %s to match employment', ($endemploy || '(none)')) 
     307            if (exists($changes{expire})); 
     308        $user->set_fields(%changes); 
    294309    } 
    295310 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r1559 r1566  
    214214                label => l('End of entrance'), 
    215215            }, 
    216             endEmployment => { 
     216            _endEmployment => { 
    217217                formtype => 'DATETIME', 
    218218                managed => 1, 
    219219                ro => 1, 
     220                hide => 1, 
    220221                get => sub { 
    221222                    my ($attr) = @_; 
     
    225226                label => l('End of employment'), 
    226227            }, 
    227             endStrictEmployment => { 
     228            endEmployment => { 
     229                formtype => 'DATETIME', 
     230                ro => 1, 
     231                label => l('End of employment'), 
     232            }, 
     233            _endStrictEmployment => { 
    228234                formtype => 'DATETIME', 
    229235                managed => 1, 
    230236                ro => 1, 
     237                hide => 1, 
    231238                get => sub { 
    232239                    my ($attr) = @_; 
     
    235242                }, 
    236243            }, 
    237             endCurrentEmployment => { 
     244            endStrictEmployment => { 
     245                formtype => 'DATETIME', 
     246                ro => 1, 
     247            }, 
     248            _endCurrentEmployment => { 
    238249                formtype => 'DATETIME', 
    239250                managed => 1, 
    240251                ro => 1, 
     252                hide => 1, 
    241253                get => sub { 
    242254                    my ($attr) = @_; 
     
    268280                }, 
    269281            }, 
    270             endLastEmployment => { 
     282            endCurrentEmployment => { 
     283                formtype => 'DATETIME', 
     284                ro => 1, 
     285            }, 
     286            _endLastEmployment => { 
    271287                formtype => 'DATETIME', 
    272288                managed => 1, 
    273289                ro => 1, 
     290                hide => 1, 
    274291                get => sub { 
    275292                    my ($attr) = @_; 
     
    291308                    return $end ? $end->iso8601 : undef 
    292309                }, 
     310                label => l('End of any employment'), 
     311            }, 
     312            endLastEmployment => { 
     313                formtype => 'DATETIME', 
     314                ro => 1, 
    293315                label => l('End of any employment'), 
    294316            }, 
     
    10761098            }, 
    10771099            appliedEmployement => { 
    1078                 hidden => 1, 
     1100                hide => 1, 
    10791101                reference => 'employment', 
    10801102            }, 
Note: See TracChangeset for help on using the changeset viewer.