diff --git a/module/ShiftBundle/Entity/RegistrationShift.php b/module/ShiftBundle/Entity/RegistrationShift.php index 57106679b5..4679ad7257 100644 --- a/module/ShiftBundle/Entity/RegistrationShift.php +++ b/module/ShiftBundle/Entity/RegistrationShift.php @@ -405,6 +405,10 @@ public function canHaveAsRegistered(EntityManager $entityManager, Person $regist if ($this->getStartDate() < $shift->getEndDate() && $shift->getStartDate() < $this->getEndDate()) { return false; } + + if ($this->getStartDate()->format('Y-m-d') === $shift->getStartDate()->format('Y-m-d')) { + return false; + } } if ($this->getFinalSigninDate() !== null && $this->getFinalSigninDate() < new DateTime()) { @@ -414,6 +418,26 @@ public function canHaveAsRegistered(EntityManager $entityManager, Person $regist return !($this->countRegistered() >= $this->getNbRegistered()); } + /** + * Checks whether or not the given person already has a registered shift on the same day as this shift + * shift. + * + * @param EntityManager $entityManager The EntityManager instance + * @param Person $registered The person that should be checked + * @return boolean + */ + public function hasShiftOnThisDay(EntityManager $entityManager, Person $registered) + { + $shifts = $entityManager->getRepository('ShiftBundle\Entity\RegistrationShift') + ->findAllActiveByPerson($registered);//TODO: Create + foreach ($shifts as $shift) { + if ($this->getStartDate()->format('Y-m-d') === $shift->getStartDate()->format('Y-m-d')) { + return true; + } + } + return false; + } + /** * @return Unit */ diff --git a/module/ShiftBundle/Resources/translations/shift.en.php b/module/ShiftBundle/Resources/translations/shift.en.php index bd94005b4a..2f439b30cc 100644 --- a/module/ShiftBundle/Resources/translations/shift.en.php +++ b/module/ShiftBundle/Resources/translations/shift.en.php @@ -56,6 +56,7 @@ 'Final Signup' => 'Final Signup', 'Final Signout' => 'Final Signout', + 'You already have a timeslot on this day' => 'You already have a timeslot on this day', 'on the event' => 'on the event', 'You have currently %unPayedShifts% unpayed shift(s). You can get your reward from the vice-preases at \'blok 6\'. This reward will expire at the end of this academic year.' => 'You have currently %unPayedShifts% unpayed shift(s). You can get your reward from the vice-preases at \'blok 6\'. This reward will expire at the end of this academic year.', 'You haven\'t done any shifts this year yet. Sign up for a shift, have fun with the others while working and get some coins in return!' => 'You haven\'t done any shifts this year yet. Sign up for a shift, have fun with the others while working and get some coins in return!', diff --git a/module/ShiftBundle/Resources/translations/shift.nl.php b/module/ShiftBundle/Resources/translations/shift.nl.php index c299ccd9fe..f9b64379ea 100644 --- a/module/ShiftBundle/Resources/translations/shift.nl.php +++ b/module/ShiftBundle/Resources/translations/shift.nl.php @@ -57,6 +57,7 @@ 'Final Signup' => 'Einde Inschrijvingen', 'Final Signout' => 'Einde Uitschrijvingen', + 'You already have a timeslot on this day' => 'Je hebt al een tijdslot op deze dag', 'You have currently %unPayedShifts% unpayed shift(s). You can get your reward from the vice-preases at \'blok 6\'. This reward will expire at the end of this academic year.' => 'Je hebt momenteel %unPayedShifts% onbetaalde shift(en). Je kan je beloning komen halen bij de vice-praeses op \'blok 6\'. Deze beloning zal vervallen op het einde van dit academiejaar.', 'You haven\'t done any shifts this year yet. Sign up for a shift, have fun with the others while working and get some coins in return!' => 'Je hebt momenteel nog geen shiften gedaan dit jaar. Schrijf je in voor een shift, have fun tijdens de shift, leer nieuwe mensen kennen en krijg bonnetjes als beloning!', 'You have done your last shift on %lastShift%.' => 'Je hebt je laatste shift gedaan op %lastShift%.', diff --git a/module/ShiftBundle/Resources/views/shift/registration-shift/index.twig b/module/ShiftBundle/Resources/views/shift/registration-shift/index.twig index 14dc7f4883..ec5ac8e5b5 100644 --- a/module/ShiftBundle/Resources/views/shift/registration-shift/index.twig +++ b/module/ShiftBundle/Resources/views/shift/registration-shift/index.twig @@ -300,6 +300,7 @@ panel.fadeIn(); $('#shifts-search ' + button.data('panel')).fadeOut(function () {$(this).remove()}); } else { + console.log("error"); errorSave(); } }, @@ -324,7 +325,7 @@
{{dateLocalized(shift.getStartDate(), 'd/M/y')}} | {{ dateLocalized(shift.getStartDate(), 'HH:mm') }}-{{ dateLocalized(shift.getEndDate(), 'HH:mm') }}