- Timestamp:
- 01/04/17 19:57:18 (7 years ago)
- Location:
- trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Employment.pm
r1860 r1912 372 372 my $cval = $self->get_attributes($attr) || ''; 373 373 374 for ($attr) { 375 if ($attr eq 'managerContact') { 376 if (!$cval) { 377 my $dpmt = $self->get_attributes('department') or last; 378 my $odmpt = $self->base->get_object('group', $dpmt) or last; 379 $cval = $odmpt->get_attributes('managedBy'); 380 } 381 } 382 } 383 374 384 if ($uval ne $cval) { 375 385 my $oattr = $self->base->attribute('user', $attr); -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm
r1904 r1912 40 40 uniq => 1, 41 41 iname => 'gidnumber', 42 mandatory => 1, 42 mandatory => 1, 43 43 label => l('GID'), 44 44 }, … … 52 52 delayed => 1, 53 53 ro => sub { 54 $_[0] && 54 $_[0] && 55 55 (($_[0]->_get_c_field('sutype') ||'') =~ /^(jobtype|contrattype)$/ 56 56 || $_[0]->_get_c_field('autoMemberFilter') 57 57 || $_[0]->_get_c_field('autoFromSutype')) 58 ? 1 : 0 58 ? 1 : 0 59 59 }, 60 60 get => sub { 61 my ($self) = @_; 61 my ($self) = @_; 62 62 my $sth = $self->base->db->prepare_cached( 63 63 q{ … … 85 85 monitored => 1, 86 86 reference => 'user', 87 multiple => 1, 87 multiple => 1, 88 88 delayed => 1, 89 89 iname => 'memberUID', 90 90 can_values => sub { $base->list_objects('user') }, 91 91 ro => sub { 92 $_[0] && 92 $_[0] && 93 93 (($_[0]->_get_c_field('sutype') ||'') =~ /^(jobtype|contrattype)$/ 94 94 || $_[0]->_get_c_field('autoMemberFilter') 95 95 || $_[0]->_get_c_field('autoFromSutype')) 96 ? 1 : 0 96 ? 1 : 0 97 97 }, 98 98 get => sub { … … 113 113 can_values => sub { 114 114 my %uniq = map { $_ => 1 } grep { $_ } 115 ( $_[1] ? $_[1]->get_attributes('manager') : ()),116 $base->search_objects('user', 'active=*') ;115 (($_[1] ? $_[1]->get_attributes('managedBy') : ()), 116 $base->search_objects('user', 'active=*')); 117 117 sort keys %uniq; 118 118 }, 119 119 label => l('Manager'), 120 post => sub { 121 my ($self, $value) = @_; 122 $self->object->_update_employment_manager; 123 }, 120 124 }, 121 125 managedAlsoBy => { … … 126 130 can_values => sub { 127 131 my %uniq = map { $_ => 1 } grep { $_ } 128 ($_[1] ? $_[1]->get_attributes('manage r') : ()),132 ($_[1] ? $_[1]->get_attributes('managedBy') : ()), 129 133 $base->search_objects('user', 'active=*'); 130 134 sort keys %uniq; … … 250 254 } 251 255 252 253 256 if (my $filter = $self->get_field('autoMemberFilter')) { 254 257 foreach ($self->base->search_objects( … … 265 268 } 266 269 270 sub _update_employment_manager { 271 my ($self) = @_; 272 273 my $listEmp = $self->base->db->prepare(q{ 274 select name from employment join employment_attributes 275 on employment.ikey = employment_attributes.okey 276 where firstday < now() and (lastday > now() or lastday is NULL) 277 and employment_attributes.attr = 'department' and employment_attributes.value = ? 278 }); 279 $listEmp->execute($self->id); 280 while (my $res = $listEmp->fetchrow_hashref()) { 281 my $employment = $self->base->get_object('employment', $res->{name}) or next; 282 $employment->get_attributes('managerContact') and next; 283 my $dpmt = $employment->_get_attributes('department') or next; 284 my $odmpt = $employment->base->get_object('group', $dpmt) or next; 285 my $manager = $odmpt->get_attributes('managedBy') or next; 286 my $user = $employment->get_attributes('user'); 287 my $ouser = $employment->base->get_object('user', $user) or next; 288 $self->base->log(LA_DEBUG, "Updating manager for $user due to dpmt update"); 289 $ouser->ReportChange( 290 'Update', 'Attr manager updated to match Dpmt manager %s (%s)', 291 $manager, 292 $dpmt, 293 ); 294 $ouser->set_fields('managerContact', $manager); 295 } 296 297 return 1; 298 } 299 267 300 1; 268 301 -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm
r1910 r1912 1085 1085 can_values => sub { 1086 1086 my %uniq = map { $_ => 1 } grep { $_ } 1087 ( $_[1] ? $_[1]->get_attributes('managerContact') : ()),1088 $base->search_objects('user', 'active=1') ;1087 (($_[1] ? $_[1]->get_attributes('managerContact') : ()), 1088 $base->search_objects('user', 'active=1')); 1089 1089 sort keys %uniq; 1090 1090 },
Note: See TracChangeset
for help on using the changeset viewer.