Ignore:
Timestamp:
11/20/16 23:41:54 (8 years ago)
Author:
nanardon
Message:

Add contratTypeHistory attribute

File:
1 edited

Legend:

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

    r1847 r1854  
    13181318                reference => 'employment', 
    13191319            }, 
     1320            contratTypeHistory => { 
     1321                reference => 'group', 
     1322                can_values => sub { 
     1323                    $base->search_objects('group', 'sutype=contrattype') 
     1324                }, 
     1325                multiple => 1, 
     1326            }, 
    13201327            hosted => { 
    13211328                formtype => 'CHECKBOX', 
     
    13581365    }; 
    13591366 
    1360     foreach (qw(contratType managerContact company endcircuit department hosted)) { 
     1367    foreach (qw(contratType managerContact company endcircuit department hosted 
     1368                contratTypeHistory)) { 
    13611369        $attrs->{$_}{ro} = $employmentro; 
    13621370    } 
     
    15211529        $self->set_fields(%changes); 
    15221530    } 
     1531 
     1532    $self->_computeEmploymentHistory(); 
    15231533 
    15241534    return 1; 
     
    16471657} 
    16481658 
     1659sub _computeEmploymentHistory { 
     1660    my ($self) = @_; 
     1661 
     1662    my %changes; 
     1663 
     1664    foreach my $attribute (qw(contratType)) { 
     1665        my $sth = $self->db->prepare_cached(q{ 
     1666            select employment_attributes.value from employment 
     1667            join employment_attributes 
     1668            on employment.ikey = employment_attributes.okey 
     1669            where "user" = ? and employment_attributes.attr = ? 
     1670            and employment.firstday < now() 
     1671            group by employment_attributes.value 
     1672            }); 
     1673        $sth->execute($self->id, $attribute); 
     1674        my @values; 
     1675        while (my $res = $sth->fetchrow_hashref) { 
     1676            push(@values, $res->{value}); 
     1677        } 
     1678        $changes{$attribute . "History"} = \@values; 
     1679    } 
     1680 
     1681    $self->set_fields(%changes); 
     1682} 
     1683 
    16491684=head2 storeBannedPassword($epassword) 
    16501685 
Note: See TracChangeset for help on using the changeset viewer.