Changeset 1787 for trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases
- Timestamp:
- 06/23/16 18:53:38 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Employment.pm
r1773 r1787 418 418 my $id = ref $obj ? $obj->id : $obj; 419 419 420 if ($changes{lastday}) { 420 my $firstday = exists($changes{firstday}) ? $changes{firstday} : $obj->get_attributes('firstday'); 421 my $lastday = exists($changes{lastday}) ? $changes{lastday} : $obj->get_attributes('lastday'); 422 423 if ($lastday) { 421 424 my $sth = $base->db->prepare_cached(q{ 422 select name from employment where "user" = ? and name != ? and 423 firstday <= ? and (lastday is null or lastday >= ?) 425 select name, firstday, lastday from employment where "user" = ? and name != ? 426 and 427 ( 428 (firstday <= ? and (lastday is NULL or lastday >= ?)) 429 or 430 ((lastday is NOT NULL and lastday <= ?) and firstday >= ?) 431 ) 424 432 }); 425 $sth->execute($user, $id, $ changes{lastday}, $changes{lastday});433 $sth->execute($user, $id, $lastday, $firstday, $lastday, $firstday); 426 434 my $res = $sth->fetchrow_hashref; 427 435 $sth->finish; 436 428 437 if ($res) { 429 $base->log(LA_ERR, " New ending overlap contrat %s (%s)", $res->{name}, $changes{lastday});438 $base->log(LA_ERR, "The change will overlap contrat %s (%s - %s)", $res->{name}, $res->{firstday}, $res->{lastday} || ''); 430 439 return; 431 440 } 432 } els if(exists($changes{lastday})){441 } else { 433 442 my $sth = $base->db->prepare_cached(q{ 434 select * from employment where "user" = ? and lastday is null 443 select * from employment where "user" = ? and name != ? 444 and lastday is NULL OR lastday >= ? 435 445 limit 1 436 446 }); 437 $sth->execute($user );447 $sth->execute($user, $id, $firstday); 438 448 my $res = $sth->fetchrow_hashref; 439 449 if ($res && $res->{name}) { … … 444 454 } 445 455 } 446 if ($changes{firstday}) {447 my $sth = $base->db->prepare_cached(q{448 select name from employment where "user" = ? and name != ? and449 firstday <= ? and (lastday is null or lastday >= ?)450 });451 $sth->execute($user, $id, $changes{firstday}, $changes{firstday});452 my $res = $sth->fetchrow_hashref;453 $sth->finish;454 if ($res) {455 $base->log(LA_ERR, "New starting overlap contrat %s (%s)", $res->{name}, $changes{firstday});456 return;457 }458 }459 456 460 457 return 1;
Note: See TracChangeset
for help on using the changeset viewer.