Skip to content
Snippets Groups Projects
Commit 0a15c86a authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

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

parent 49d43eb2
Branches
Tags
1 merge request!55Ll bug report services
......@@ -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
......@@ -63,6 +63,7 @@ return [
'route' => '/creer',
'defaults' => [
'action' => 'saisir',
'action-detail' => 'creer',
],
],
],
......@@ -72,6 +73,17 @@ return [
'route' => '/:intervenant/saisir',
'defaults' => [
'action' => 'saisir',
'action-detail' => 'saisir',
],
],
],
'dupliquer' => [
'type' => 'Segment',
'options' => [
'route' => '/:intervenant/dupliquer',
'defaults' => [
'action' => 'saisir',
'action-detail' => 'dupliquer',
],
],
],
......
......@@ -266,6 +266,7 @@ class IntervenantController extends AbstractController
$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';
$feminin = $r['civilite'] == 'Madame';
$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'];
$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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment