diff --git a/code/test4.php b/code/test4.php index 400c3bc0c5dec5b37aed87b9d9a525d93127f000..dfce9d745f826f8247a25289f207aa10ff7ee5da 100755 --- a/code/test4.php +++ b/code/test4.php @@ -9,4 +9,7 @@ */ -return $controller->redirect()->toRoute('intervenant/voir', ['intervenant' => 51987], ['query' => ['tab' => 'edition']]); \ No newline at end of file +/* @var $intervenant \Application\Entity\Db\Intervenant */ +$intervenant = $container->get(\Application\Service\IntervenantService::class)->get(578); + +$ni = $intervenant->dupliquer(); \ No newline at end of file diff --git a/module/Application/config/intervenant.config.php b/module/Application/config/intervenant.config.php index ebb1de2d09011214810e94508f4bbfd10045a4ef..960139d6a33ce568a33b8434ec6e512c96c0708c 100755 --- a/module/Application/config/intervenant.config.php +++ b/module/Application/config/intervenant.config.php @@ -62,7 +62,8 @@ return [ 'options' => [ 'route' => '/creer', 'defaults' => [ - 'action' => 'saisir', + 'action' => 'saisir', + 'action-detail' => 'creer', ], ], ], @@ -71,7 +72,18 @@ return [ 'options' => [ 'route' => '/:intervenant/saisir', 'defaults' => [ - 'action' => 'saisir', + 'action' => 'saisir', + 'action-detail' => 'saisir', + ], + ], + ], + 'dupliquer' => [ + 'type' => 'Segment', + 'options' => [ + 'route' => '/:intervenant/dupliquer', + 'defaults' => [ + 'action' => 'saisir', + 'action-detail' => 'dupliquer', ], ], ], diff --git a/module/Application/src/Application/Controller/IntervenantController.php b/module/Application/src/Application/Controller/IntervenantController.php index 95aa21d3629d2feb5b912ccb5ea9f7f2023b65a8..e9d6d3974c2ca9dc1237d49506cce9beb3c140cb 100755 --- a/module/Application/src/Application/Controller/IntervenantController.php +++ b/module/Application/src/Application/Controller/IntervenantController.php @@ -261,11 +261,12 @@ class IntervenantController extends AbstractController public function saisirAction() { - $role = $this->getServiceContext()->getSelectedIdentityRole(); - $intervenant = $role->getIntervenant() ?: $this->getEvent()->getParam('intervenant'); - $title = "Saisie d'un intervenant"; - $form = $this->getFormIntervenantEdition(); - $errors = []; + $role = $this->getServiceContext()->getSelectedIdentityRole(); + $intervenant = $role->getIntervenant() ?: $this->getEvent()->getParam('intervenant'); + $title = "Saisie d'un intervenant"; + $form = $this->getFormIntervenantEdition(); + $errors = []; + $actionDetail = $this->params()->fromRoute('action-detail'); $isNew = !$intervenant; if (!$intervenant) { @@ -277,6 +278,13 @@ class IntervenantController extends AbstractController $intervenant->setCode(uniqid('OSE')); } + if ($actionDetail == 'dupliquer') { + $intervenant = $intervenant->dupliquer(); + $intervenant->setSource($this->getServiceSource()->getOse()); + $intervenant->setSourceCode(null); + $intervenant->setStatut($this->getServiceStatutIntervenant()->getAutres()); + } + $canEdit = $this->isAllowed($intervenant, Privileges::INTERVENANT_EDITION); $form->setReadOnly(!$canEdit); $form->bind($intervenant); diff --git a/module/Application/src/Application/Controller/RechercheController.php b/module/Application/src/Application/Controller/RechercheController.php index 50b7189a4ac42998a2492dba9df45495c86d2894..55e80d55196d44b512809be511d448a1d6e0ef91 100755 --- a/module/Application/src/Application/Controller/RechercheController.php +++ b/module/Application/src/Application/Controller/RechercheController.php @@ -28,19 +28,27 @@ class RechercheController extends AbstractController $result = []; foreach ($res as $key => $r) { - $feminin = $r['civilite'] != 'Monsieur'; - - $civilite = $feminin ? 'M<sup>me</sup>' : 'M.'; - $nom = strtoupper($r['nom']); - $prenom = ucfirst($r['prenom']); - $naissance = 'né' . ($feminin ? 'e' : '') . ' le ' . $r['date-naissance']->format(Constants::DATE_FORMAT); - $numeroPersonnel = 'N°' . $r['numero-personnel']; - $structure = $r['structure']; + $feminin = $r['civilite'] == 'Madame'; + + $details = []; + if ($r['civilite']) { + $details['civilite'] = $feminin ? 'M<sup>me</sup>' : 'M.'; + } + $details['nom'] = strtoupper($r['nom']); + $details['prenom'] = ucfirst($r['prenom']); + $details['naissance'] = 'né' . ($feminin ? 'e' : '') . ' le ' . $r['date-naissance']->format(Constants::DATE_FORMAT); + $details['code'] = 'N°' . $r['numero-personnel']; + if ($r['structure']) { + $details['structure'] = $r['structure']; + } + if ($r['statut']) { + $details['statut'] = $r['statut']; + } $result[$key] = [ 'id' => $key, - 'label' => "$nom $prenom", - 'extra' => "<small>($civilite, $naissance, $numeroPersonnel, $structure)</small>", + 'label' => $details['nom'] . ' ' . $details['prenom'], + 'extra' => "<small>(" . implode(', ', $details) . ")</small>", ]; } diff --git a/module/Application/src/Application/Entity/Db/Intervenant.php b/module/Application/src/Application/Entity/Db/Intervenant.php index e988d0e2624dd39659dad260f60dd440eed46651..52f91a5139bd9f0c194fc7b5442aa5ff166d0608 100755 --- a/module/Application/src/Application/Entity/Db/Intervenant.php +++ b/module/Application/src/Application/Entity/Db/Intervenant.php @@ -18,6 +18,7 @@ use UnicaenApp\Entity\HistoriqueAwareTrait; use UnicaenApp\Service\EntityManagerAwareTrait; use UnicaenImport\Entity\Db\Interfaces\ImportAwareInterface; use UnicaenImport\Entity\Db\Traits\ImportAwareTrait; +use Zend\Hydrator\ClassMethods; use Zend\Permissions\Acl\Resource\ResourceInterface; /** @@ -1386,4 +1387,16 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import return $validations; } + + + public function dupliquer() + { + $intervenant = new Intervenant(); + + $hydrator = new ClassMethods(); + $data = $hydrator->extract($this); + $hydrator->hydrate($data, $intervenant); + + return $intervenant; + } } diff --git a/module/Application/src/Application/Service/ServiceReferentielService.php b/module/Application/src/Application/Service/ServiceReferentielService.php index 245b0878bb636e4a1d4cc74c8b3be146b744e091..4de63723f3da274793c31044395341a7561c2039 100755 --- a/module/Application/src/Application/Service/ServiceReferentielService.php +++ b/module/Application/src/Application/Service/ServiceReferentielService.php @@ -379,7 +379,7 @@ class ServiceReferentielService extends AbstractEntityService $tvhPrevu = $this->getServiceTypeVolumeHoraire()->getPrevu(); $evhValide = $this->getServiceEtatVolumeHoraire()->getSaisi(); - $intervenantPrec = $this->getServiceIntervenant()->getPrecedent(); + $intervenantPrec = $this->getServiceIntervenant()->getPrecedent($intervenant); $sVolumeHoraireReferentiel = $this->getServiceVolumeHoraireReferentiel(); diff --git a/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php b/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php index 3676b0887cce47aac189cd785bb9bc96f901f606..010f23cfd50e666945f620b3b89fed61a4326ff1 100755 --- a/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php +++ b/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php @@ -172,7 +172,7 @@ class IntervenantViewHelper extends AbstractHtmlElement <?php endforeach; ?> <?php if ($canAddIntervenant): ?> <li class="ajout-intervenant"> - <a href="<?= $this->getView()->url('intervenant/voir', ['intervenant' => $intervenantId]); ?>" + <a href="<?= $this->getView()->url('intervenant/dupliquer', ['intervenant' => $intervenantId]); ?>" title="Ajout d'un nouveau statut à l'intervenant"><span class="glyphicon glyphicon-plus"></span></a> </li>