Commit d9911f45 authored by Stéphane Bouvry's avatar Stéphane Bouvry
Browse files

Ajout du champ schedule pour stoquer les horaires du déclarant

parent bab5ab33
Loading
Loading
Loading
Loading
+514 −520

File changed.

Preview size limit exceeded, changes collapsed.

+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
@@ -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);
@@ -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);
@@ -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 */
@@ -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;
@@ -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');
@@ -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);
@@ -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));

@@ -1084,8 +1086,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        }




        return true;
    }

@@ -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];
@@ -1252,7 +1253,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
    }



    public function getPersonPeriods(Person $person, $period)
    {

@@ -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
@@ -1546,7 +1547,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        }



        foreach ($daysInfos as $day => &$daydata) {
            $datetime = new \DateTime($daydata['datefull']);
            $daydata['date'] = $daydata['datefull'];
@@ -1591,7 +1591,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
                ];



                $period = $this->getValidationPeriosOutOfWorkpackageAt($t->getPerson(), $year, $month, $t->getLabel());
                $key = $t->getLabel();

@@ -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();
@@ -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'];
@@ -1880,7 +1878,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa

    }

    public function getValidationHorsLotByReferent( Person $referent ){
    public function getValidationHorsLotByReferent(Person $referent)
    {

        $validations = [];

@@ -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)')
@@ -1899,8 +1897,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        }




        return $validations;
    }

@@ -1950,7 +1946,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
            if (!array_key_exists($period, $datas[$activityId])) {



                $datas[$activityId][$period] = [
                    'toto' => 'tata',
                    'unvalidate' => $validationState['state'],
@@ -2246,7 +2241,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
    /**
     * @return PersonService
     */
    protected function getPersonService(){
    protected function getPersonService()
    {
        return $this->getServiceLocator()->get('PersonService');
    }

@@ -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);
    }

@@ -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')
@@ -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:
@@ -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:
@@ -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()) {
@@ -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',
@@ -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',
@@ -2472,7 +2475,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
                new \DateTime(),
                new \DateTime());
        }

    }

    /**
@@ -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);
@@ -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)
@@ -2654,8 +2649,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        $validableAdm = false;

        if ($periodValidation) {


            switch ($periodValidation->getStatus()) {
                case ValidationPeriod::STATUS_STEP1 :
                case ValidationPeriod::STATUS_STEP2 :