Commit 0a15c86a authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Possibilité de dupliquer, amélioration de la précision de la recherche

parent 49d43eb2
......@@ -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
......@@ -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',
],
],
],
......
......@@ -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);
......
......@@ -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>",
];
}
......
......@@ -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;
}
}
......@@ -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();
......
......@@ -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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment