Loading module/Application/src/Controller/IntervenantController.php +3 −2 Changes for module/Application/src/Controller/IntervenantController.php: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -132,8 +132,9 @@ class IntervenantController extends AbstractController return $vh; } $notificationNote = $this->getServiceNote()->countNote($intervenant); $date = new \DateTime(); $date->sub(new \DateInterval('P7D')); $notificationNote = $this->getServiceNote()->countNote($intervenant, $date); $this->addIntervenantRecent($intervenant); return compact('intervenant', 'tab', 'notificationNote'); Loading module/Intervenant/config/module.config.php +9 −15 Changes for module/Intervenant/config/module.config.php: 9 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ return [ ], 'resources' => [ 'Statut', 'Statut', 'Note', ], 'rules' => [ Loading @@ -113,6 +113,14 @@ return [ 'resources' => 'Statut', 'assertion' => Assertion\StatutAssertion::class, ], [ 'privileges' => [ NoteAssertion::PRIV_EDITER_NOTE, NoteAssertion::PRIV_SUPPRIMER_NOTE, ], 'resources' => 'Note', 'assertion' => Assertion\NoteAssertion::class, ], ], 'guards' => [ Loading Loading @@ -156,20 +164,6 @@ return [ ], ], 'resources' => [ 'Note', ], 'rules' => [ [ 'privileges' => [ NoteAssertion::PRIV_EDITER_NOTE, NoteAssertion::PRIV_SUPPRIMER_NOTE, ], 'resources' => 'Note', 'assertion' => Assertion\NoteAssertion::class, ], ], 'controllers' => [ 'Intervenant\Controller\Statut' => Controller\StatutControllerFactory::class, Loading module/Intervenant/src/Controller/NoteController.php +9 −4 Changes for module/Intervenant/src/Controller/NoteController.php: 9 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -36,12 +36,13 @@ class NoteController extends AbstractController throw new \Exception('Intervenant introuvable'); } $notes = $this->getServiceNote()->getByIntervenant($intervenant); $notes = $this->getServiceNote()->getByIntervenant($intervenant, 'note'); $emails = $this->getServiceNote()->getByIntervenant($intervenant, 'email'); $historique = $this->getServiceNote()->getHistoriqueIntervenant($intervenant); return compact('notes', 'intervenant', 'historique'); return compact('notes', 'emails', 'intervenant', 'historique'); } Loading Loading @@ -103,7 +104,7 @@ class NoteController extends AbstractController if (!$canDelete) { $this->flashMessenger()->addErrorMessage('Statut non modifiable : droit non accordé, car vous n\'avez pas le privilège pour cela'); $this->flashMessenger()->addErrorMessage('Note non supprimable : droit non accordé, car vous n\'avez pas le privilège pour cela'); } else { try { $this->getServiceNote()->delete($note); Loading @@ -124,7 +125,7 @@ class NoteController extends AbstractController $form = $this->getFormMailerIntervenant()->setIntervenant($intervenant)->initForm(); if ($this->getRequest()->isPost()) { try { $data = $this->getRequest()->getPost(); $from = $data['from']; $to = $data['to']; Loading @@ -149,6 +150,10 @@ class NoteController extends AbstractController $this->mail()->send($message); //Création d'une trace de l'envoi dans les notes de l'intervenant $this->getServiceNote()->createNoteFromEmail($intervenant, $subject, $content); $this->flashMessenger()->addSuccessMessage('Email envoyé à l\'intervenant'); } catch (\Exception $e) { $this->flashMessenger()->addErrorMessage($this->translate($e)); } } Loading module/Intervenant/src/Form/NoteSaisieForm.php +2 −2 Changes for module/Intervenant/src/Form/NoteSaisieForm.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ class NoteSaisieForm extends AbstractForm $this->setAttribute('class', 'note'); $this->addSubmit(); $this->setValueOptions('type', $this->getServiceTypeNote()->getList()); $qb = $this->getServiceTypeNote()->findDefaultCode(); $this->setValueOptions('type', $this->getServiceTypeNote()->getList($qb)); return $this; } Loading module/Intervenant/src/Service/NoteService.php +35 −9 Changes for module/Intervenant/src/Service/NoteService.php: 35 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ use Application\Service\AbstractEntityService; use Application\Service\Traits\ContextServiceAwareTrait; use Doctrine\DBAL\Query\QueryBuilder; use Intervenant\Entity\Db\Note; use Laminas\Mail\Message; use Laminas\Validator\Date; /** * Description of NoteService Loading Loading @@ -42,20 +42,25 @@ class NoteService extends AbstractEntityService return 'note'; } /** * @param Intervenant $intervenant * * @return Array * @param Intervenant $intervenant Intervenant concerné * @param string|null $typeNoteCode Code du type de note souhaité, si null renvoi toutes les notes * @return array */ public function getByIntervenant(Intervenant $intervenant): array public function getByIntervenant(Intervenant $intervenant, ?string $typeNoteCode = null): array { /** * @var $qb QueryBuilder */ $qb = $this->finderByIntervenant($intervenant); $this->finderByHistorique($qb); if (!empty($typeNoteCode)) { $type = $this->getServiceTypeNote()->getByCode($typeNoteCode); $qb->andWhere($this->getAlias() . '.type = :type'); $qb->setParameter('type', $type); } $qb->orderBy($this->getAlias() . '.histoCreation', 'DESC'); $notes = $this->getList($qb); Loading Loading @@ -87,6 +92,13 @@ class NoteService extends AbstractEntityService } /** * @param Intervenant $intervenant * @param $sujet string Sujet du mail * @param $message string Contenu du mail * @return Note */ public function createNoteFromEmail(Intervenant $intervenant, $sujet, $message): Note { $note = $this->newEntity(); Loading @@ -100,16 +112,30 @@ class NoteService extends AbstractEntityService } public function countNote(Intervenant $intervenant) /** * @param Intervenant $intervenant * @param \DateTime|null $since Date à partir de laquelle on calcule le nombre de note, si NULL on compte toutes les notes * @return int */ public function countNote(Intervenant $intervenant, ?\DateTime $since = null): int { $sql = 'SELECT count(*) AS nb FROM note WHERE intervenant_id = ' . $intervenant->getId() . ' AND histo_destruction IS NULL'; $sql = "SELECT count(*) AS nb FROM note n JOIN type_note tn ON tn.id = n.type_note_id AND tn.code = 'note' WHERE intervenant_id = " . $intervenant->getId() . " AND n.histo_destruction IS NULL"; if (!empty($since)) { $sql .= " AND n.histo_creation > to_date('" . $since->format('d/m/Y') . "', 'dd/mm/yyyy')"; } $count = $this->getEntityManager()->getConnection()->fetchOne($sql); return $count; } /** * Retourne une nouvelle entité, initialisée avec les bons paramètres * Loading Loading
module/Application/src/Controller/IntervenantController.php +3 −2 Changes for module/Application/src/Controller/IntervenantController.php: 3 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -132,8 +132,9 @@ class IntervenantController extends AbstractController return $vh; } $notificationNote = $this->getServiceNote()->countNote($intervenant); $date = new \DateTime(); $date->sub(new \DateInterval('P7D')); $notificationNote = $this->getServiceNote()->countNote($intervenant, $date); $this->addIntervenantRecent($intervenant); return compact('intervenant', 'tab', 'notificationNote'); Loading
module/Intervenant/config/module.config.php +9 −15 Changes for module/Intervenant/config/module.config.php: 9 added lines, 15 removed lines. Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ return [ ], 'resources' => [ 'Statut', 'Statut', 'Note', ], 'rules' => [ Loading @@ -113,6 +113,14 @@ return [ 'resources' => 'Statut', 'assertion' => Assertion\StatutAssertion::class, ], [ 'privileges' => [ NoteAssertion::PRIV_EDITER_NOTE, NoteAssertion::PRIV_SUPPRIMER_NOTE, ], 'resources' => 'Note', 'assertion' => Assertion\NoteAssertion::class, ], ], 'guards' => [ Loading Loading @@ -156,20 +164,6 @@ return [ ], ], 'resources' => [ 'Note', ], 'rules' => [ [ 'privileges' => [ NoteAssertion::PRIV_EDITER_NOTE, NoteAssertion::PRIV_SUPPRIMER_NOTE, ], 'resources' => 'Note', 'assertion' => Assertion\NoteAssertion::class, ], ], 'controllers' => [ 'Intervenant\Controller\Statut' => Controller\StatutControllerFactory::class, Loading
module/Intervenant/src/Controller/NoteController.php +9 −4 Changes for module/Intervenant/src/Controller/NoteController.php: 9 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -36,12 +36,13 @@ class NoteController extends AbstractController throw new \Exception('Intervenant introuvable'); } $notes = $this->getServiceNote()->getByIntervenant($intervenant); $notes = $this->getServiceNote()->getByIntervenant($intervenant, 'note'); $emails = $this->getServiceNote()->getByIntervenant($intervenant, 'email'); $historique = $this->getServiceNote()->getHistoriqueIntervenant($intervenant); return compact('notes', 'intervenant', 'historique'); return compact('notes', 'emails', 'intervenant', 'historique'); } Loading Loading @@ -103,7 +104,7 @@ class NoteController extends AbstractController if (!$canDelete) { $this->flashMessenger()->addErrorMessage('Statut non modifiable : droit non accordé, car vous n\'avez pas le privilège pour cela'); $this->flashMessenger()->addErrorMessage('Note non supprimable : droit non accordé, car vous n\'avez pas le privilège pour cela'); } else { try { $this->getServiceNote()->delete($note); Loading @@ -124,7 +125,7 @@ class NoteController extends AbstractController $form = $this->getFormMailerIntervenant()->setIntervenant($intervenant)->initForm(); if ($this->getRequest()->isPost()) { try { $data = $this->getRequest()->getPost(); $from = $data['from']; $to = $data['to']; Loading @@ -149,6 +150,10 @@ class NoteController extends AbstractController $this->mail()->send($message); //Création d'une trace de l'envoi dans les notes de l'intervenant $this->getServiceNote()->createNoteFromEmail($intervenant, $subject, $content); $this->flashMessenger()->addSuccessMessage('Email envoyé à l\'intervenant'); } catch (\Exception $e) { $this->flashMessenger()->addErrorMessage($this->translate($e)); } } Loading
module/Intervenant/src/Form/NoteSaisieForm.php +2 −2 Changes for module/Intervenant/src/Form/NoteSaisieForm.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ class NoteSaisieForm extends AbstractForm $this->setAttribute('class', 'note'); $this->addSubmit(); $this->setValueOptions('type', $this->getServiceTypeNote()->getList()); $qb = $this->getServiceTypeNote()->findDefaultCode(); $this->setValueOptions('type', $this->getServiceTypeNote()->getList($qb)); return $this; } Loading
module/Intervenant/src/Service/NoteService.php +35 −9 Changes for module/Intervenant/src/Service/NoteService.php: 35 added lines, 9 removed lines. Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ use Application\Service\AbstractEntityService; use Application\Service\Traits\ContextServiceAwareTrait; use Doctrine\DBAL\Query\QueryBuilder; use Intervenant\Entity\Db\Note; use Laminas\Mail\Message; use Laminas\Validator\Date; /** * Description of NoteService Loading Loading @@ -42,20 +42,25 @@ class NoteService extends AbstractEntityService return 'note'; } /** * @param Intervenant $intervenant * * @return Array * @param Intervenant $intervenant Intervenant concerné * @param string|null $typeNoteCode Code du type de note souhaité, si null renvoi toutes les notes * @return array */ public function getByIntervenant(Intervenant $intervenant): array public function getByIntervenant(Intervenant $intervenant, ?string $typeNoteCode = null): array { /** * @var $qb QueryBuilder */ $qb = $this->finderByIntervenant($intervenant); $this->finderByHistorique($qb); if (!empty($typeNoteCode)) { $type = $this->getServiceTypeNote()->getByCode($typeNoteCode); $qb->andWhere($this->getAlias() . '.type = :type'); $qb->setParameter('type', $type); } $qb->orderBy($this->getAlias() . '.histoCreation', 'DESC'); $notes = $this->getList($qb); Loading Loading @@ -87,6 +92,13 @@ class NoteService extends AbstractEntityService } /** * @param Intervenant $intervenant * @param $sujet string Sujet du mail * @param $message string Contenu du mail * @return Note */ public function createNoteFromEmail(Intervenant $intervenant, $sujet, $message): Note { $note = $this->newEntity(); Loading @@ -100,16 +112,30 @@ class NoteService extends AbstractEntityService } public function countNote(Intervenant $intervenant) /** * @param Intervenant $intervenant * @param \DateTime|null $since Date à partir de laquelle on calcule le nombre de note, si NULL on compte toutes les notes * @return int */ public function countNote(Intervenant $intervenant, ?\DateTime $since = null): int { $sql = 'SELECT count(*) AS nb FROM note WHERE intervenant_id = ' . $intervenant->getId() . ' AND histo_destruction IS NULL'; $sql = "SELECT count(*) AS nb FROM note n JOIN type_note tn ON tn.id = n.type_note_id AND tn.code = 'note' WHERE intervenant_id = " . $intervenant->getId() . " AND n.histo_destruction IS NULL"; if (!empty($since)) { $sql .= " AND n.histo_creation > to_date('" . $since->format('d/m/Y') . "', 'dd/mm/yyyy')"; } $count = $this->getEntityManager()->getConnection()->fetchOne($sql); return $count; } /** * Retourne une nouvelle entité, initialisée avec les bons paramètres * Loading