Loading module/Oscar/src/Oscar/Controller/TimesheetController.php +6 −2 Changes for module/Oscar/src/Oscar/Controller/TimesheetController.php: 6 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -1912,13 +1912,17 @@ class TimesheetController extends AbstractOscarController return $this->sendTimesheet($currentPerson); } $datas = json_decode($this->params()->fromPost('datas')); // Réenvoi de la déclaration if( $action == 'resend' ){ $timesheetService->reSendPeriod($year, $month, $currentPerson); $from = new \DateTime($datas->from); $to = new \DateTime($datas->to); // $timesheetService->sendPeriod($from, $to, $currentPerson, $comments); $timesheetService->reSendPeriod($from, $to, $currentPerson, $comments); return $this->getResponseOk(); } $datas = json_decode($this->params()->fromPost('datas')); if( !$datas ){ return $this->getResponseBadRequest('Problème de transmission des données'); Loading module/Oscar/src/Oscar/Service/TimesheetService.php +13 −6 Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 13 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -367,13 +367,19 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa return true; } public function reSendPeriod( $year, $month, Person $declarer ){ $validationsPeriods = $this->getValidationPeriods((int)$year, (int)$month, $declarer); public function reSendPeriod( $from, $to, Person $declarer, $comments ){ /** @var ValidationPeriod $validationPeriod */ foreach ($validationsPeriods as $validationPeriod) { $this->reSendValidation($validationPeriod); $year = (int)$from->format('Y'); $month = (int)$from->format('m'); // Suppression des anciennes déclarations $validations = $this->getValidationPeriods($year, $month, $declarer); foreach ($validations as $v){ $this->getEntityManager()->remove($v); } $this->getEntityManager()->flush(); $this->sendPeriod($from, $to, $$declarer, $comments); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -2318,6 +2324,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa foreach ($periodValidations as $periodValidation) { if( $periodValidation->hasConflict() ){ $hasConflict = true; $editable = true; } $data = $periodValidation->json(); if ($periodValidation->getObjectId() > 0) { Loading @@ -2340,7 +2347,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa if (count($periodValidations)) { $submitable = false; $submitableInfos = "Vous avez déja envoyé cette période pour validation"; $editable = false; $editable = $hasConflict; $editableInfos = "Vous avez déja envoyé cette période pour validation"; } else { $submitable = true; Loading Loading
module/Oscar/src/Oscar/Controller/TimesheetController.php +6 −2 Changes for module/Oscar/src/Oscar/Controller/TimesheetController.php: 6 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -1912,13 +1912,17 @@ class TimesheetController extends AbstractOscarController return $this->sendTimesheet($currentPerson); } $datas = json_decode($this->params()->fromPost('datas')); // Réenvoi de la déclaration if( $action == 'resend' ){ $timesheetService->reSendPeriod($year, $month, $currentPerson); $from = new \DateTime($datas->from); $to = new \DateTime($datas->to); // $timesheetService->sendPeriod($from, $to, $currentPerson, $comments); $timesheetService->reSendPeriod($from, $to, $currentPerson, $comments); return $this->getResponseOk(); } $datas = json_decode($this->params()->fromPost('datas')); if( !$datas ){ return $this->getResponseBadRequest('Problème de transmission des données'); Loading
module/Oscar/src/Oscar/Service/TimesheetService.php +13 −6 Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 13 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -367,13 +367,19 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa return true; } public function reSendPeriod( $year, $month, Person $declarer ){ $validationsPeriods = $this->getValidationPeriods((int)$year, (int)$month, $declarer); public function reSendPeriod( $from, $to, Person $declarer, $comments ){ /** @var ValidationPeriod $validationPeriod */ foreach ($validationsPeriods as $validationPeriod) { $this->reSendValidation($validationPeriod); $year = (int)$from->format('Y'); $month = (int)$from->format('m'); // Suppression des anciennes déclarations $validations = $this->getValidationPeriods($year, $month, $declarer); foreach ($validations as $v){ $this->getEntityManager()->remove($v); } $this->getEntityManager()->flush(); $this->sendPeriod($from, $to, $$declarer, $comments); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Loading Loading @@ -2318,6 +2324,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa foreach ($periodValidations as $periodValidation) { if( $periodValidation->hasConflict() ){ $hasConflict = true; $editable = true; } $data = $periodValidation->json(); if ($periodValidation->getObjectId() > 0) { Loading @@ -2340,7 +2347,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa if (count($periodValidations)) { $submitable = false; $submitableInfos = "Vous avez déja envoyé cette période pour validation"; $editable = false; $editable = $hasConflict; $editableInfos = "Vous avez déja envoyé cette période pour validation"; } else { $submitable = true; Loading