Changeset 1511
- Timestamp:
- 12/21/15 18:01:43 (9 years ago)
- 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
r1506 r1511 109 109 company => { }, 110 110 endcircuit => { formtype => 'DATE', monitored => 1, }, 111 previous => { 112 ro => 1, 113 managed => 1, 114 get => sub { 115 my ($self) = @_; 116 my $find = $self->object->base->db->prepare_cached(q{ 117 SELECT name from employment where "user" = ? 118 and (lastday is not null and lastday < ?) 119 order by lastday desc 120 }); 121 $find->execute( 122 $self->object->get_field('user'), 123 $self->object->get_field('firstday') 124 ); 125 my $res = $find->fetchrow_hashref; 126 $find->finish; 127 return $res->{name}; 128 }, 129 }, 130 next => { 131 ro => 1, 132 managed => 1, 133 get => sub { 134 my ($self) = @_; 135 my $find = $self->object->base->db->prepare_cached(q{ 136 SELECT name from employment where "user" = ? 137 and firstday > ? 138 order by firstday asc 139 }); 140 $find->execute( 141 $self->object->get_field('user'), 142 $self->object->get_field('lastday') 143 ); 144 my $res = $find->fetchrow_hashref; 145 $find->finish; 146 return $res->{name}; 147 }, 148 }, 111 149 } 112 150 ); -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm
r1508 r1511 258 258 } 259 259 $listold->finish; 260 } 261 return $end ? $end->iso8601 : undef 262 }, 263 }, 264 endLastEmployment => { 265 formtype => 'DATETIME', 266 managed => 1, 267 ro => 1, 268 get => sub { 269 my ($attr) = @_; 270 my $self = $attr->object; 271 272 my $list_empl = $self->base->db->prepare_cached(q{ 273 SELECT * FROM employment WHERE "user" = ? 274 order by lastday desc nulls first 275 }); 276 $list_empl->execute($self->id); 277 my $res = $list_empl->fetchrow_hashref; 278 $list_empl->finish; 279 my $end; 280 if ($res && $res->{lastday}) { 281 $end = DateTime->from_epoch(epoch => str2time($res->{lastday})); 282 $end->set_time_zone( DateTime::TimeZone->new( name => 'local' ) ); 283 $end->add(hours => 23, minutes => 59, seconds => 59); 260 284 } 261 285 return $end ? $end->iso8601 : undef
Note: See TracChangeset
for help on using the changeset viewer.