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

Ajout du contrôle lors du réenvoi

parent 63773cb5
Loading
Loading
Loading
Loading
+7 −6
Changes for module/Oscar/src/Oscar/Controller/TimesheetController.php: 7 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -1451,25 +1451,28 @@ class TimesheetController extends AbstractOscarController
        /** @var Person $currentPerson */
        $currentPerson = $this->getCurrentPerson();

        $output = $this->getTimesheetService()->getTimesheetDatasPersonPeriod($currentPerson, $period);

        /** @var TimesheetService $timesheetService */
        $timesheetService = $this->getServiceLocator()->get('TimesheetService');

        if( $this->isAjax() ) {
            switch ($method) {

                // Envois des créneaux
                case 'GET' :
                    return $this->ajaxResponse($output);
                    return $this->ajaxResponse($this->getTimesheetService()->getTimesheetDatasPersonPeriod($currentPerson, $period));
                    break;

                case 'POST' :
                    $action = $this->params()->fromPost('action', 'send');

                    // Réenvoi de la déclaration
                    if( $action == 'resend' ){
                        $periodId = $this->params()->fromPost('period_id');
                        /** @var ValidationPeriod $period */
                        $period = $this->getEntityManager()->getRepository(ValidationPeriod::class)->find($periodId);
                        if( $period->getDeclarer() == $currentPerson ){
                            try {
                                $timesheetService->verificationPeriod($currentPerson, $period->getYear(), $period->getMonth());
                                $timesheetService->reSendValidation($period);
                                return $this->getResponseOk();
                            } catch (\Exception $e ){
@@ -1490,8 +1493,6 @@ class TimesheetController extends AbstractOscarController
                        return $this->getResponseInternalError("La période soumise est incomplète");
                    }

                    $this->getLogger()->debug("##### ENVOI DES DECLARATIONS");

                    try {
                        $firstDay = new \DateTime($datas->from);
                        $this->getTimesheetService()->verificationPeriod($currentPerson, $firstDay->format('Y'), $firstDay->format('m'));
@@ -1524,7 +1525,7 @@ class TimesheetController extends AbstractOscarController
            }
        }

        return $output;
        return $this->getTimesheetService()->getTimesheetDatasPersonPeriod($currentPerson, $period);;
    }