Loading module/Oscar/src/Oscar/Entity/ValidationPeriod.php +514 −520 File changed.Preview size limit exceeded, changes collapsed. Show changes module/Oscar/src/Oscar/Service/TimesheetService.php +42 −49 Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 42 added lines, 49 removed lines. Original line number Diff line number Diff line Loading @@ -54,7 +54,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa * @param ValidationPeriod $validation * @throws OscarException */ public function removeValidatorToValidation( $type, Person $person, ValidationPeriod $validation ){ public function removeValidatorToValidation($type, Person $person, ValidationPeriod $validation) { switch ($type) { case 'prj' : $validation->getValidatorsPrj()->removeElement($person); Loading @@ -79,7 +80,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa * @param ValidationPeriod $validation * @throws OscarException */ public function addValidatorToValidation( $type, Person $person, ValidationPeriod $validation ){ public function addValidatorToValidation($type, Person $person, ValidationPeriod $validation) { switch ($type) { case 'prj' : $validation->addValidatorPrj($person); Loading @@ -98,7 +100,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } public function getDatasDeclarations(){ public function getDatasDeclarations() { $output = []; $declarations = $this->getEntityManager()->getRepository(ValidationPeriod::class)->findAll(); /** @var ValidationPeriod $declaration */ Loading Loading @@ -603,8 +606,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $timesheets = $this->getTimesheetsValidationPeriod($period); $code = array_key_exists($period->getObject(), $hwp) ? $period->getObject() : 'other'; $wpDetails = false; $details = null; Loading Loading @@ -899,7 +900,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } public function getDayLengthPerson( Person $person ){ public function getDayLengthPerson(Person $person) { $configApp = $this->getOscarConfig()->getConfiguration('declarationsDurations.dayLength'); if ($person->getCustomSettingsKey('days')) { $customDays = $person->getCustomSettingsKey('days'); Loading Loading @@ -940,7 +942,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $daysDetails = $this->getDayLengthPerson($person); for ($i = $decaleDay; $i < $nbr + $decaleDay; $i++) { $day = $i - $decaleDay + 1; $dayIndex = ($i % 7); Loading Loading @@ -1004,7 +1005,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa return $days; } public function verificationPeriod( Person $person, $year, $month) { public function verificationPeriod(Person $person, $year, $month) { $this->getLogger()->debug("VERIFICATION PERIODE $year $month"); $datas = $this->getTimesheetDatasPersonPeriod($person, sprintf('%s-%s', $year, $month)); Loading Loading @@ -1084,8 +1086,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } return true; } Loading Loading @@ -1200,7 +1200,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa return $query->getQuery()->getResult(); } public function deleteValidationPeriodPerson( Person $person, $period ){ public function deleteValidationPeriodPerson(Person $person, $period) { $spli = explode('-', $period); $year = (int)$spli[0]; $month = (int)$spli[1]; Loading Loading @@ -1252,7 +1253,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } public function getPersonPeriods(Person $person, $period) { Loading Loading @@ -1329,7 +1329,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa * @param WorkPackage $wp * @throws OscarException */ public function checkAllowedAddedTimesheetInWorkPackage(Person $person, \DateTime $start, \DateTime $to, WorkPackage $wp ){ public function checkAllowedAddedTimesheetInWorkPackage(Person $person, \DateTime $start, \DateTime $to, WorkPackage $wp) { $jourCreneau = $start->format('d/m/Y'); // On test si la personne est bien identifiée comme déclarante sur le lot Loading Loading @@ -1546,7 +1547,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } foreach ($daysInfos as $day => &$daydata) { $datetime = new \DateTime($daydata['datefull']); $daydata['date'] = $daydata['datefull']; Loading Loading @@ -1591,7 +1591,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa ]; $period = $this->getValidationPeriosOutOfWorkpackageAt($t->getPerson(), $year, $month, $t->getLabel()); $key = $t->getLabel(); Loading @@ -1600,13 +1599,11 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $datas['status_id'] = TimeSheet::STATUS_ACTIVE; $datas['status_id'] = TimeSheet::STATUS_ACTIVE; $datas['validations'] = $period->json(); } elseif ($period->getStatus() != ValidationPeriod::STATUS_CONFLICT) { } elseif ($period->getStatus() != ValidationPeriod::STATUS_CONFLICT) { $datas['status_id'] = TimeSheet::STATUS_TOVALIDATE_ADMIN; $datas['status_id'] = TimeSheet::STATUS_TOVALIDATE_ADMIN; $datas['validations'] = $period->json(); } else { } else { $datas['status_id'] = TimeSheet::STATUS_CONFLICT; $datas['status_id'] = TimeSheet::STATUS_CONFLICT; $datas['validations'] = $period->json(); Loading Loading @@ -1849,7 +1846,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa * @return mixed * @throws OscarException */ public function getValidationStatePersonPeriod(Person $person, $periodKey){ public function getValidationStatePersonPeriod(Person $person, $periodKey) { $periodData = DateTimeUtils::extractPeriodDatasFromString($periodKey); $year = $periodData['year']; $month = $periodData['month']; Loading Loading @@ -1880,7 +1878,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } public function getValidationHorsLotByReferent( Person $referent ){ public function getValidationHorsLotByReferent(Person $referent) { $validations = []; Loading @@ -1889,7 +1888,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $subordinates = $this->getServiceLocator()->get('PersonService')->getSubordinates($referent); if (count($subordinates)) $validations = $this->getEntityManager()->getRepository(ValidationPeriod::class)->createQueryBuilder('vp') ->where('vp.declarer IN(:persons)') Loading @@ -1899,8 +1897,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } return $validations; } Loading Loading @@ -1950,7 +1946,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa if (!array_key_exists($period, $datas[$activityId])) { $datas[$activityId][$period] = [ 'toto' => 'tata', 'unvalidate' => $validationState['state'], Loading Loading @@ -2246,7 +2241,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa /** * @return PersonService */ protected function getPersonService(){ protected function getPersonService() { return $this->getServiceLocator()->get('PersonService'); } Loading Loading @@ -2347,15 +2343,18 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $this->getLogger()->debug(print_r($declarations, true)); } public function getValidatorsPrj( Activity $activity ){ public function getValidatorsPrj(Activity $activity) { return $this->getPersonService()->getAllPersonsWithPrivilegeInActivity(Privileges::ACTIVITY_TIMESHEET_VALIDATE_ACTIVITY, $activity); } public function getValidatorsSci( Activity $activity ){ public function getValidatorsSci(Activity $activity) { return $this->getPersonService()->getAllPersonsWithPrivilegeInActivity(Privileges::ACTIVITY_TIMESHEET_VALIDATE_SCI, $activity); } public function getValidatorsAdm( Activity $activity ){ public function getValidatorsAdm(Activity $activity) { return $this->getPersonService()->getAllPersonsWithPrivilegeInActivity(Privileges::ACTIVITY_TIMESHEET_VALIDATE_ADM, $activity); } Loading @@ -2366,7 +2365,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa * @param Person $person * @return array */ public function getValidationToDoPerson( Person $person ){ public function getValidationToDoPerson(Person $person) { $query = $this->getEntityManager()->getRepository(ValidationPeriod::class) ->createQueryBuilder('vp') Loading @@ -2388,7 +2388,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa return $validations; } public function validation( ValidationPeriod $period, Person $validateur, $message="" ){ public function validation(ValidationPeriod $period, Person $validateur, $message = "") { if ($period->isValidator($validateur)) { switch ($period->getStatus()) { case ValidationPeriod::STATUS_STEP1: Loading @@ -2414,7 +2415,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } } public function reject( ValidationPeriod $period, Person $validateur, $message="" ){ public function reject(ValidationPeriod $period, Person $validateur, $message = "") { if ($period->isValidator($validateur)) { switch ($period->getStatus()) { case ValidationPeriod::STATUS_STEP1: Loading @@ -2440,8 +2442,12 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } } public function notificationsValidationPeriod( ValidationPeriod $validationPeriod ){ /** * @param ValidationPeriod $validationPeriod * @throws OscarException */ public function notificationsValidationPeriod(ValidationPeriod $validationPeriod) { $notificationService = $this->getServiceNotification(); if ($validationPeriod->hasConflict()) { Loading @@ -2452,8 +2458,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa 'Application', new \DateTime(), new \DateTime()); } elseif ( $validationPeriod->getStatus() == ValidationPeriod::STATUS_VALID ){ } elseif ($validationPeriod->getStatus() == ValidationPeriod::STATUS_VALID) { $notificationService->notification(_("Déclaration validée"), [$validationPeriod->getDeclarer()], 'ValidationPeriod-valid', Loading @@ -2461,9 +2466,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa 'Application', new \DateTime(), new \DateTime()); } else { } else { $notificationService->notification(_("Validation en attente"), $validationPeriod->getCurrentValidators()->toArray(), 'ValidationPeriod-wait', Loading @@ -2472,7 +2475,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa new \DateTime(), new \DateTime()); } } /** Loading @@ -2490,7 +2492,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $declaration = new ValidationPeriod(); // CAS N°1 : Validation Hors-Lot if ($objectGroup == ValidationPeriod::GROUP_OTHER) { $validateurs = $this->getPersonService()->getManagers($sender); Loading Loading @@ -2536,14 +2537,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } $declaration->setStatus(ValidationPeriod::STATUS_STEP1); } //throw new OscarException('Refonte de la création de déclaration en cours'); $now = new \DateTime(); $declaration ->setDateSend($now) Loading Loading @@ -2654,8 +2649,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $validableAdm = false; if ($periodValidation) { switch ($periodValidation->getStatus()) { case ValidationPeriod::STATUS_STEP1 : case ValidationPeriod::STATUS_STEP2 : Loading Loading
module/Oscar/src/Oscar/Entity/ValidationPeriod.php +514 −520 File changed.Preview size limit exceeded, changes collapsed. Show changes
module/Oscar/src/Oscar/Service/TimesheetService.php +42 −49 Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 42 added lines, 49 removed lines. Original line number Diff line number Diff line Loading @@ -54,7 +54,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa * @param ValidationPeriod $validation * @throws OscarException */ public function removeValidatorToValidation( $type, Person $person, ValidationPeriod $validation ){ public function removeValidatorToValidation($type, Person $person, ValidationPeriod $validation) { switch ($type) { case 'prj' : $validation->getValidatorsPrj()->removeElement($person); Loading @@ -79,7 +80,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa * @param ValidationPeriod $validation * @throws OscarException */ public function addValidatorToValidation( $type, Person $person, ValidationPeriod $validation ){ public function addValidatorToValidation($type, Person $person, ValidationPeriod $validation) { switch ($type) { case 'prj' : $validation->addValidatorPrj($person); Loading @@ -98,7 +100,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } public function getDatasDeclarations(){ public function getDatasDeclarations() { $output = []; $declarations = $this->getEntityManager()->getRepository(ValidationPeriod::class)->findAll(); /** @var ValidationPeriod $declaration */ Loading Loading @@ -603,8 +606,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $timesheets = $this->getTimesheetsValidationPeriod($period); $code = array_key_exists($period->getObject(), $hwp) ? $period->getObject() : 'other'; $wpDetails = false; $details = null; Loading Loading @@ -899,7 +900,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } public function getDayLengthPerson( Person $person ){ public function getDayLengthPerson(Person $person) { $configApp = $this->getOscarConfig()->getConfiguration('declarationsDurations.dayLength'); if ($person->getCustomSettingsKey('days')) { $customDays = $person->getCustomSettingsKey('days'); Loading Loading @@ -940,7 +942,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $daysDetails = $this->getDayLengthPerson($person); for ($i = $decaleDay; $i < $nbr + $decaleDay; $i++) { $day = $i - $decaleDay + 1; $dayIndex = ($i % 7); Loading Loading @@ -1004,7 +1005,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa return $days; } public function verificationPeriod( Person $person, $year, $month) { public function verificationPeriod(Person $person, $year, $month) { $this->getLogger()->debug("VERIFICATION PERIODE $year $month"); $datas = $this->getTimesheetDatasPersonPeriod($person, sprintf('%s-%s', $year, $month)); Loading Loading @@ -1084,8 +1086,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } return true; } Loading Loading @@ -1200,7 +1200,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa return $query->getQuery()->getResult(); } public function deleteValidationPeriodPerson( Person $person, $period ){ public function deleteValidationPeriodPerson(Person $person, $period) { $spli = explode('-', $period); $year = (int)$spli[0]; $month = (int)$spli[1]; Loading Loading @@ -1252,7 +1253,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } public function getPersonPeriods(Person $person, $period) { Loading Loading @@ -1329,7 +1329,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa * @param WorkPackage $wp * @throws OscarException */ public function checkAllowedAddedTimesheetInWorkPackage(Person $person, \DateTime $start, \DateTime $to, WorkPackage $wp ){ public function checkAllowedAddedTimesheetInWorkPackage(Person $person, \DateTime $start, \DateTime $to, WorkPackage $wp) { $jourCreneau = $start->format('d/m/Y'); // On test si la personne est bien identifiée comme déclarante sur le lot Loading Loading @@ -1546,7 +1547,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } foreach ($daysInfos as $day => &$daydata) { $datetime = new \DateTime($daydata['datefull']); $daydata['date'] = $daydata['datefull']; Loading Loading @@ -1591,7 +1591,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa ]; $period = $this->getValidationPeriosOutOfWorkpackageAt($t->getPerson(), $year, $month, $t->getLabel()); $key = $t->getLabel(); Loading @@ -1600,13 +1599,11 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $datas['status_id'] = TimeSheet::STATUS_ACTIVE; $datas['status_id'] = TimeSheet::STATUS_ACTIVE; $datas['validations'] = $period->json(); } elseif ($period->getStatus() != ValidationPeriod::STATUS_CONFLICT) { } elseif ($period->getStatus() != ValidationPeriod::STATUS_CONFLICT) { $datas['status_id'] = TimeSheet::STATUS_TOVALIDATE_ADMIN; $datas['status_id'] = TimeSheet::STATUS_TOVALIDATE_ADMIN; $datas['validations'] = $period->json(); } else { } else { $datas['status_id'] = TimeSheet::STATUS_CONFLICT; $datas['status_id'] = TimeSheet::STATUS_CONFLICT; $datas['validations'] = $period->json(); Loading Loading @@ -1849,7 +1846,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa * @return mixed * @throws OscarException */ public function getValidationStatePersonPeriod(Person $person, $periodKey){ public function getValidationStatePersonPeriod(Person $person, $periodKey) { $periodData = DateTimeUtils::extractPeriodDatasFromString($periodKey); $year = $periodData['year']; $month = $periodData['month']; Loading Loading @@ -1880,7 +1878,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } public function getValidationHorsLotByReferent( Person $referent ){ public function getValidationHorsLotByReferent(Person $referent) { $validations = []; Loading @@ -1889,7 +1888,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $subordinates = $this->getServiceLocator()->get('PersonService')->getSubordinates($referent); if (count($subordinates)) $validations = $this->getEntityManager()->getRepository(ValidationPeriod::class)->createQueryBuilder('vp') ->where('vp.declarer IN(:persons)') Loading @@ -1899,8 +1897,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } return $validations; } Loading Loading @@ -1950,7 +1946,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa if (!array_key_exists($period, $datas[$activityId])) { $datas[$activityId][$period] = [ 'toto' => 'tata', 'unvalidate' => $validationState['state'], Loading Loading @@ -2246,7 +2241,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa /** * @return PersonService */ protected function getPersonService(){ protected function getPersonService() { return $this->getServiceLocator()->get('PersonService'); } Loading Loading @@ -2347,15 +2343,18 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $this->getLogger()->debug(print_r($declarations, true)); } public function getValidatorsPrj( Activity $activity ){ public function getValidatorsPrj(Activity $activity) { return $this->getPersonService()->getAllPersonsWithPrivilegeInActivity(Privileges::ACTIVITY_TIMESHEET_VALIDATE_ACTIVITY, $activity); } public function getValidatorsSci( Activity $activity ){ public function getValidatorsSci(Activity $activity) { return $this->getPersonService()->getAllPersonsWithPrivilegeInActivity(Privileges::ACTIVITY_TIMESHEET_VALIDATE_SCI, $activity); } public function getValidatorsAdm( Activity $activity ){ public function getValidatorsAdm(Activity $activity) { return $this->getPersonService()->getAllPersonsWithPrivilegeInActivity(Privileges::ACTIVITY_TIMESHEET_VALIDATE_ADM, $activity); } Loading @@ -2366,7 +2365,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa * @param Person $person * @return array */ public function getValidationToDoPerson( Person $person ){ public function getValidationToDoPerson(Person $person) { $query = $this->getEntityManager()->getRepository(ValidationPeriod::class) ->createQueryBuilder('vp') Loading @@ -2388,7 +2388,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa return $validations; } public function validation( ValidationPeriod $period, Person $validateur, $message="" ){ public function validation(ValidationPeriod $period, Person $validateur, $message = "") { if ($period->isValidator($validateur)) { switch ($period->getStatus()) { case ValidationPeriod::STATUS_STEP1: Loading @@ -2414,7 +2415,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } } public function reject( ValidationPeriod $period, Person $validateur, $message="" ){ public function reject(ValidationPeriod $period, Person $validateur, $message = "") { if ($period->isValidator($validateur)) { switch ($period->getStatus()) { case ValidationPeriod::STATUS_STEP1: Loading @@ -2440,8 +2442,12 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } } public function notificationsValidationPeriod( ValidationPeriod $validationPeriod ){ /** * @param ValidationPeriod $validationPeriod * @throws OscarException */ public function notificationsValidationPeriod(ValidationPeriod $validationPeriod) { $notificationService = $this->getServiceNotification(); if ($validationPeriod->hasConflict()) { Loading @@ -2452,8 +2458,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa 'Application', new \DateTime(), new \DateTime()); } elseif ( $validationPeriod->getStatus() == ValidationPeriod::STATUS_VALID ){ } elseif ($validationPeriod->getStatus() == ValidationPeriod::STATUS_VALID) { $notificationService->notification(_("Déclaration validée"), [$validationPeriod->getDeclarer()], 'ValidationPeriod-valid', Loading @@ -2461,9 +2466,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa 'Application', new \DateTime(), new \DateTime()); } else { } else { $notificationService->notification(_("Validation en attente"), $validationPeriod->getCurrentValidators()->toArray(), 'ValidationPeriod-wait', Loading @@ -2472,7 +2475,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa new \DateTime(), new \DateTime()); } } /** Loading @@ -2490,7 +2492,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $declaration = new ValidationPeriod(); // CAS N°1 : Validation Hors-Lot if ($objectGroup == ValidationPeriod::GROUP_OTHER) { $validateurs = $this->getPersonService()->getManagers($sender); Loading Loading @@ -2536,14 +2537,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa } $declaration->setStatus(ValidationPeriod::STATUS_STEP1); } //throw new OscarException('Refonte de la création de déclaration en cours'); $now = new \DateTime(); $declaration ->setDateSend($now) Loading Loading @@ -2654,8 +2649,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $validableAdm = false; if ($periodValidation) { switch ($periodValidation->getStatus()) { case ValidationPeriod::STATUS_STEP1 : case ValidationPeriod::STATUS_STEP2 : Loading