Loading module/Oscar/src/Oscar/Controller/TimesheetController.php +4 −1 Changes for module/Oscar/src/Oscar/Controller/TimesheetController.php: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -1052,13 +1052,16 @@ class TimesheetController extends AbstractOscarController } public function validationsAction() { if( $this->isAjax() ){ $method = $this->getHttpXMethod(); $serviceTimesheet = $this->getTimesheetService(); switch ($method) { case 'GET' : return $this->ajaxResponse($serviceTimesheet->getValidationsForValidator($this->getCurrentPerson())); $datas = $serviceTimesheet->getValidationsForValidator2($this->getCurrentPerson()); return $this->ajaxResponse($datas); break; case 'POST' : Loading module/Oscar/src/Oscar/Entity/ValidationPeriod.php +16 −1 Changes for module/Oscar/src/Oscar/Entity/ValidationPeriod.php: 16 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ namespace Oscar\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Oscar\Exception\OscarException; use Oscar\Utils\DateTimeUtils; /** Loading Loading @@ -541,6 +542,14 @@ class ValidationPeriod } } public function isValidable(){ return $this->getStatus() == self::STATUS_STEP1 || $this->getStatus() == self::STATUS_STEP2 || $this->getStatus() == self::STATUS_STEP3; } /** * @return string */ Loading Loading @@ -730,7 +739,7 @@ class ValidationPeriod return $this->getValidatorsAdm(); } throw new OscarException("Non éligible à validation"); return []; } public function isOpenForDeclaration() Loading Loading @@ -1212,6 +1221,12 @@ class ValidationPeriod } } public function getPeriod() { return DateTimeUtils::getCodePeriod($this->getYear(), $this->getMonth()); } /** * @return string */ Loading module/Oscar/src/Oscar/Service/TimesheetService.php +175 −2 Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 175 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -588,6 +588,179 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa return $this->getValidationPeriodRepository()->find($idPeriod); } public function getStatusMessage( $status ){ static $statusMessages; if( $statusMessages === null ){ $statusMessages = [ ValidationPeriod::STATUS_VALID => "Validée", ValidationPeriod::STATUS_CONFLICT => "Conflict", ValidationPeriod::STATUS_STEP1 => "En attente de validation projet", ValidationPeriod::STATUS_STEP2 => "En attente de validation scientifique", ValidationPeriod::STATUS_STEP3 => "En attente de validation administrative", ]; } if( array_key_exists($status, $statusMessages) ){ return $statusMessages[$status]; } else { return "Unknow Status"; } } //public function public function getValidationsForValidator2(Person $validator, $declarer = null, $period = null) { $timesheetFormatter = new TimesheetsMonthFormatter(); // Configuration des Hors-Lots $hwp = $this->getOthersWP(); // Récupération des données à traiter $queryValidationPeriod = $this->getEntityManager()->getRepository(ValidationPeriod::class) ->createQueryBuilder('vp') ->leftJoin('vp.validatorsPrj', 'vprj') ->leftJoin('vp.validatorsSci', 'vsci') ->leftJoin('vp.validatorsAdm', 'vadm') ->where("vprj = :person OR vsci = :person OR vadm = :person") ->setParameter('person', $validator) ->getQuery(); $periods = $queryValidationPeriod->getResult(); $group = []; $periodIds = []; $output = []; /** @var ValidationPeriod $period */ foreach ($periods as $period) { $periodIds[] = $period->getId(); $key = $period->getPeriod().'-'.$period->getDeclarer()->getId(); $validateCurrentState = false; $validators = []; foreach ( $period->getCurrentValidators() as $v ){ if( $v->getId() == $validator->getId() ){ $validateCurrentState = true; } $validators[] = (string)$v; } $periodBounds = DateTimeUtils::periodBounds($period->getPeriod()); if( !array_key_exists($key, $group) ){ $group[$key] = [ 'period' => $period->getPeriod(), 'totalDays' => $periodBounds['totalDays'], 'periodFirstDay' => $periodBounds['firstDay'], 'periodLastDay' => $periodBounds['lastDay'], 'person' => (string)$period->getDeclarer(), 'person_id' => $period->getDeclarer()->getId(), 'declarations_activities' => [], 'declarations_others' => [], 'declarations_off' => [ 'timesheets' => [], 'total' => 0.0, ], 'details' => $this->getDaysPeriodInfosPerson($period->getDeclarer(), $period->getYear(), $period->getMonth()), ]; } // Modèle commun $periodDatas = [ 'validationperiod_id' => $period->getId(), 'validationperiod_object' => $period->getObject(), 'validationperiod_objectid' => $period->getObjectId(), 'validableStep' => $validateCurrentState, 'validabe' => $period->isValidable(), 'validators' => $validators, 'total' => 0.0, 'label' => "Inconnu", 'status' => $period->getStatus(), 'statusMessage' => $this->getStatusMessage($period->getStatus()), ]; // Déclarations sur des activités if( $period->getObject() == 'activity' ){ /** @var Activity $activity */ $activity = $this->getEntityManager()->getRepository(Activity::class)->find($period->getObjectId()); $activityDatas = [ 'label' => $activity->getFullLabel(), 'workpackages' => [] ]; /** @var WorkPackage $workpackage */ foreach ($activity->getWorkPackages() as $workpackage) { $inWorkpackage = $workpackage->hasPerson($period->getDeclarer()); $activityDatas['workpackages'][$workpackage->getCode()] = [ 'code' => $workpackage->getCode(), 'enabled' => $inWorkpackage, 'label' => $workpackage->getLabel(), 'total' => 0.0, 'timesheets' => [] ]; } $periodDatas = array_merge($periodDatas, $activityDatas); $group[$key]['declarations_activities'][$activity->getId()] = $periodDatas; } // Déclarations Hors-Lot else { $otherInfos = $this->getOthersWPByCode($period->getObject()); $periodDatas['label'] = $otherInfos['label']; $periodDatas['timesheets'] = []; $group[$key]['declarations_others'][$otherInfos['code']] = $periodDatas; } } foreach ($group as $periodPerson=>$periodPersonDatas ){ $period = $periodPersonDatas['period']; $personId = $periodPersonDatas['person_id']; $declarer = $this->getEntityManager()->getRepository(Person::class)->find($personId); $timesheets = $this->getTimesheetsPersonPeriod($declarer, $periodPersonDatas['periodFirstDay'], $periodPersonDatas['periodLastDay']); /** @var TimeSheet $timesheet */ foreach ($timesheets as $timesheet) { $dayStr = $timesheet->getDateFrom()->format('j'); $activity = $timesheet->getActivity(); if( $activity ){ $main = $activity->getId(); $sub = $timesheet->getWorkpackage()->getCode(); if( array_key_exists($main, $periodPersonDatas['declarations_activities']) ){ $periodPersonDatas['declarations_activities'][$main]['workpackages'][$sub]['timesheets'][$dayStr] += $timesheet->getDuration(); $periodPersonDatas['declarations_activities'][$main]['workpackages'][$sub]['total'] += $timesheet->getDuration(); $periodPersonDatas['declarations_activities'][$main]['total'] += $timesheet->getDuration(); } else { $periodPersonDatas['declarations_off']['total'] += $timesheet->getDuration(); $periodPersonDatas['declarations_off']['timesheets'][$dayStr] += $timesheet->getDuration(); } } else { $main = 'others'; $sub = $timesheet->getLabel(); if( array_key_exists($sub, $periodPersonDatas['declarations_others']) ){ $periodPersonDatas['declarations_others'][$sub]['timesheets'][$dayStr] += $timesheet->getDuration(); $periodPersonDatas['declarations_others'][$sub]['total'] += $timesheet->getDuration(); } else { $periodPersonDatas['declarations_off']['total'] += $timesheet->getDuration(); $periodPersonDatas['declarations_off']['timesheets'][$dayStr] += $timesheet->getDuration(); } } $periodPersonDatas['total'] += $timesheet->getDuration(); $periodPersonDatas['details'][$dayStr]['duration'] += $timesheet->getDuration(); } $output[] = $periodPersonDatas; } return $output; } public function getValidationsForValidator(Person $person) { Loading Loading @@ -1180,7 +1353,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $close = false; $infos = ""; $dayKey = $day < 10 ? '0' . $day : "" . $day; $dayKey = $day; // < 10 ? '0' . $day : "" . $day; $lockedKey = "$year-".intval($month)."-$day"; // Jour fermé (provisoire) Loading Loading @@ -1229,7 +1402,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa 'datefull' => $lockedKey, ]; } ksort($days, SORT_NATURAL); return $days; } Loading module/Oscar/src/Oscar/Utils/DateTimeUtils.php +2 −0 Changes for module/Oscar/src/Oscar/Utils/DateTimeUtils.php: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -31,7 +31,9 @@ class DateTimeUtils { 'year' => $dateRef->format('Y'), 'month' => $dateRef->format('m'), 'start' => $dateRef->format('Y-m-01 00:00:00'), 'firstDay' => $dateRef->format('Y-m-01'), 'end' => $dateRef->format('Y-m-' . $nbr .' 23:59:59'), 'lastDay' => $dateRef->format('Y-m-'. $nbr), ]; } Loading module/Oscar/view/oscar/timesheet/declarant.phtml +1 −1 Changes for module/Oscar/view/oscar/timesheet/declarant.phtml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ <?php else: ?> Vue.filter('duration2', function(duree, total){ if( duree == 0 ) return 0.0; return duree + '(' + Math.round( 100 / total * duree) + "%)"; return Math.round( 100 / total * duree) + "%"; }); <?php endif; ?> <?php /* Loading Loading
module/Oscar/src/Oscar/Controller/TimesheetController.php +4 −1 Changes for module/Oscar/src/Oscar/Controller/TimesheetController.php: 4 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -1052,13 +1052,16 @@ class TimesheetController extends AbstractOscarController } public function validationsAction() { if( $this->isAjax() ){ $method = $this->getHttpXMethod(); $serviceTimesheet = $this->getTimesheetService(); switch ($method) { case 'GET' : return $this->ajaxResponse($serviceTimesheet->getValidationsForValidator($this->getCurrentPerson())); $datas = $serviceTimesheet->getValidationsForValidator2($this->getCurrentPerson()); return $this->ajaxResponse($datas); break; case 'POST' : Loading
module/Oscar/src/Oscar/Entity/ValidationPeriod.php +16 −1 Changes for module/Oscar/src/Oscar/Entity/ValidationPeriod.php: 16 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ namespace Oscar\Entity; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Oscar\Exception\OscarException; use Oscar\Utils\DateTimeUtils; /** Loading Loading @@ -541,6 +542,14 @@ class ValidationPeriod } } public function isValidable(){ return $this->getStatus() == self::STATUS_STEP1 || $this->getStatus() == self::STATUS_STEP2 || $this->getStatus() == self::STATUS_STEP3; } /** * @return string */ Loading Loading @@ -730,7 +739,7 @@ class ValidationPeriod return $this->getValidatorsAdm(); } throw new OscarException("Non éligible à validation"); return []; } public function isOpenForDeclaration() Loading Loading @@ -1212,6 +1221,12 @@ class ValidationPeriod } } public function getPeriod() { return DateTimeUtils::getCodePeriod($this->getYear(), $this->getMonth()); } /** * @return string */ Loading
module/Oscar/src/Oscar/Service/TimesheetService.php +175 −2 Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 175 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -588,6 +588,179 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa return $this->getValidationPeriodRepository()->find($idPeriod); } public function getStatusMessage( $status ){ static $statusMessages; if( $statusMessages === null ){ $statusMessages = [ ValidationPeriod::STATUS_VALID => "Validée", ValidationPeriod::STATUS_CONFLICT => "Conflict", ValidationPeriod::STATUS_STEP1 => "En attente de validation projet", ValidationPeriod::STATUS_STEP2 => "En attente de validation scientifique", ValidationPeriod::STATUS_STEP3 => "En attente de validation administrative", ]; } if( array_key_exists($status, $statusMessages) ){ return $statusMessages[$status]; } else { return "Unknow Status"; } } //public function public function getValidationsForValidator2(Person $validator, $declarer = null, $period = null) { $timesheetFormatter = new TimesheetsMonthFormatter(); // Configuration des Hors-Lots $hwp = $this->getOthersWP(); // Récupération des données à traiter $queryValidationPeriod = $this->getEntityManager()->getRepository(ValidationPeriod::class) ->createQueryBuilder('vp') ->leftJoin('vp.validatorsPrj', 'vprj') ->leftJoin('vp.validatorsSci', 'vsci') ->leftJoin('vp.validatorsAdm', 'vadm') ->where("vprj = :person OR vsci = :person OR vadm = :person") ->setParameter('person', $validator) ->getQuery(); $periods = $queryValidationPeriod->getResult(); $group = []; $periodIds = []; $output = []; /** @var ValidationPeriod $period */ foreach ($periods as $period) { $periodIds[] = $period->getId(); $key = $period->getPeriod().'-'.$period->getDeclarer()->getId(); $validateCurrentState = false; $validators = []; foreach ( $period->getCurrentValidators() as $v ){ if( $v->getId() == $validator->getId() ){ $validateCurrentState = true; } $validators[] = (string)$v; } $periodBounds = DateTimeUtils::periodBounds($period->getPeriod()); if( !array_key_exists($key, $group) ){ $group[$key] = [ 'period' => $period->getPeriod(), 'totalDays' => $periodBounds['totalDays'], 'periodFirstDay' => $periodBounds['firstDay'], 'periodLastDay' => $periodBounds['lastDay'], 'person' => (string)$period->getDeclarer(), 'person_id' => $period->getDeclarer()->getId(), 'declarations_activities' => [], 'declarations_others' => [], 'declarations_off' => [ 'timesheets' => [], 'total' => 0.0, ], 'details' => $this->getDaysPeriodInfosPerson($period->getDeclarer(), $period->getYear(), $period->getMonth()), ]; } // Modèle commun $periodDatas = [ 'validationperiod_id' => $period->getId(), 'validationperiod_object' => $period->getObject(), 'validationperiod_objectid' => $period->getObjectId(), 'validableStep' => $validateCurrentState, 'validabe' => $period->isValidable(), 'validators' => $validators, 'total' => 0.0, 'label' => "Inconnu", 'status' => $period->getStatus(), 'statusMessage' => $this->getStatusMessage($period->getStatus()), ]; // Déclarations sur des activités if( $period->getObject() == 'activity' ){ /** @var Activity $activity */ $activity = $this->getEntityManager()->getRepository(Activity::class)->find($period->getObjectId()); $activityDatas = [ 'label' => $activity->getFullLabel(), 'workpackages' => [] ]; /** @var WorkPackage $workpackage */ foreach ($activity->getWorkPackages() as $workpackage) { $inWorkpackage = $workpackage->hasPerson($period->getDeclarer()); $activityDatas['workpackages'][$workpackage->getCode()] = [ 'code' => $workpackage->getCode(), 'enabled' => $inWorkpackage, 'label' => $workpackage->getLabel(), 'total' => 0.0, 'timesheets' => [] ]; } $periodDatas = array_merge($periodDatas, $activityDatas); $group[$key]['declarations_activities'][$activity->getId()] = $periodDatas; } // Déclarations Hors-Lot else { $otherInfos = $this->getOthersWPByCode($period->getObject()); $periodDatas['label'] = $otherInfos['label']; $periodDatas['timesheets'] = []; $group[$key]['declarations_others'][$otherInfos['code']] = $periodDatas; } } foreach ($group as $periodPerson=>$periodPersonDatas ){ $period = $periodPersonDatas['period']; $personId = $periodPersonDatas['person_id']; $declarer = $this->getEntityManager()->getRepository(Person::class)->find($personId); $timesheets = $this->getTimesheetsPersonPeriod($declarer, $periodPersonDatas['periodFirstDay'], $periodPersonDatas['periodLastDay']); /** @var TimeSheet $timesheet */ foreach ($timesheets as $timesheet) { $dayStr = $timesheet->getDateFrom()->format('j'); $activity = $timesheet->getActivity(); if( $activity ){ $main = $activity->getId(); $sub = $timesheet->getWorkpackage()->getCode(); if( array_key_exists($main, $periodPersonDatas['declarations_activities']) ){ $periodPersonDatas['declarations_activities'][$main]['workpackages'][$sub]['timesheets'][$dayStr] += $timesheet->getDuration(); $periodPersonDatas['declarations_activities'][$main]['workpackages'][$sub]['total'] += $timesheet->getDuration(); $periodPersonDatas['declarations_activities'][$main]['total'] += $timesheet->getDuration(); } else { $periodPersonDatas['declarations_off']['total'] += $timesheet->getDuration(); $periodPersonDatas['declarations_off']['timesheets'][$dayStr] += $timesheet->getDuration(); } } else { $main = 'others'; $sub = $timesheet->getLabel(); if( array_key_exists($sub, $periodPersonDatas['declarations_others']) ){ $periodPersonDatas['declarations_others'][$sub]['timesheets'][$dayStr] += $timesheet->getDuration(); $periodPersonDatas['declarations_others'][$sub]['total'] += $timesheet->getDuration(); } else { $periodPersonDatas['declarations_off']['total'] += $timesheet->getDuration(); $periodPersonDatas['declarations_off']['timesheets'][$dayStr] += $timesheet->getDuration(); } } $periodPersonDatas['total'] += $timesheet->getDuration(); $periodPersonDatas['details'][$dayStr]['duration'] += $timesheet->getDuration(); } $output[] = $periodPersonDatas; } return $output; } public function getValidationsForValidator(Person $person) { Loading Loading @@ -1180,7 +1353,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa $close = false; $infos = ""; $dayKey = $day < 10 ? '0' . $day : "" . $day; $dayKey = $day; // < 10 ? '0' . $day : "" . $day; $lockedKey = "$year-".intval($month)."-$day"; // Jour fermé (provisoire) Loading Loading @@ -1229,7 +1402,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa 'datefull' => $lockedKey, ]; } ksort($days, SORT_NATURAL); return $days; } Loading
module/Oscar/src/Oscar/Utils/DateTimeUtils.php +2 −0 Changes for module/Oscar/src/Oscar/Utils/DateTimeUtils.php: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -31,7 +31,9 @@ class DateTimeUtils { 'year' => $dateRef->format('Y'), 'month' => $dateRef->format('m'), 'start' => $dateRef->format('Y-m-01 00:00:00'), 'firstDay' => $dateRef->format('Y-m-01'), 'end' => $dateRef->format('Y-m-' . $nbr .' 23:59:59'), 'lastDay' => $dateRef->format('Y-m-'. $nbr), ]; } Loading
module/Oscar/view/oscar/timesheet/declarant.phtml +1 −1 Changes for module/Oscar/view/oscar/timesheet/declarant.phtml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ <?php else: ?> Vue.filter('duration2', function(duree, total){ if( duree == 0 ) return 0.0; return duree + '(' + Math.round( 100 / total * duree) + "%)"; return Math.round( 100 / total * duree) + "%"; }); <?php endif; ?> <?php /* Loading