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

Utilisatio des ID pour identifier les fiches intervenant

parent a95f6144
......@@ -102,7 +102,7 @@ class AgrementController extends AbstractController
$tas = $this->getServiceTblAgrement()->getList($qb);
$test = false;
$test = false;
$needStructure = false;
$hasActions = false;
$data = [];
......@@ -113,14 +113,14 @@ class AgrementController extends AbstractController
$params = [
'agrement' => $a->getId(),
'intervenant' => $ta->getIntervenant()->getRouteParam(),
'intervenant' => $ta->getIntervenant()->getId(),
];
$actionUrl = $this->url()->fromRoute('intervenant/agrement/supprimer', $params);
$actionLabel = '<span class="glyphicon glyphicon-trash"></span> Retirer l\'agrément';
} elseif (!$ta->getAgrement() && $this->isAllowed($ta, $ta->getTypeAgrement()->getPrivilegeEdition())) {
$params = [
'typeAgrement' => $ta->getTypeAgrement()->getId(),
'intervenant' => $ta->getIntervenant()->getRouteParam(),
'intervenant' => $ta->getIntervenant()->getId(),
];
if ($ta->getStructure()) $params['structure'] = $ta->getStructure()->getId();
......
......@@ -111,8 +111,8 @@ class ContratController extends AbstractController
//Récupération email intervenant (Perso puis unicaen)
$dossierIntervenant = $this->getServiceDossier()->getByIntervenant($intervenant);
$emailPerso = ($dossierIntervenant) ? $dossierIntervenant->getEmailPerso() : '';
$emailIntervenant = (!empty($emailPerso)) ? $emailPerso : $intervenant->getEmail();
$emailPerso = ($dossierIntervenant) ? $dossierIntervenant->getEmailPerso() : '';
$emailIntervenant = (!empty($emailPerso)) ? $emailPerso : $intervenant->getEmail();
/* Récupération des services par contrat et par structure (pour les non contractualisés) */
$services = [
......@@ -169,7 +169,7 @@ class ContratController extends AbstractController
}
}
return $this->redirect()->toRoute('intervenant/contrat', ['intervenant' => $intervenant->getRouteParam()]);
return $this->redirect()->toRoute('intervenant/contrat', ['intervenant' => $intervenant->getId()]);
}
......@@ -349,18 +349,17 @@ class ContratController extends AbstractController
if (!empty($contrat->getIntervenant()->getEmail())) {
//Utilisation ici du parametre email
$html = $this->getServiceParametres()->get('contrat_modele_mail');
$html = $this->getServiceParametres()->get('contrat_modele_mail');
//Ajout pour transformer les sauts de lignes en html <br/>
$html = nl2br($html);
//Personnalisation des variables
$vIntervenant = $contrat->getIntervenant()->getCivilite()->getLibelleCourt() . " ". $contrat->getIntervenant()->getNomUsuel();
$vIntervenant = $contrat->getIntervenant()->getCivilite()->getLibelleCourt() . " " . $contrat->getIntervenant()->getNomUsuel();
$vUtilisateur = $this->getServiceContext()->getUtilisateur()->getDisplayName();
$html = str_replace([':intervenant', ':utilisateur'], [$vIntervenant, $vUtilisateur], $html);
$subject = $this->getServiceParametres()->get('contrat_modele_mail_objet');
$subject = str_replace(':intervenant', $vIntervenant, $subject);
$message = $this->getServiceModeleContrat()->prepareMail($contrat, $html, $subject);
$mail = $this->mail()->send($message);
$html = str_replace([':intervenant', ':utilisateur'], [$vIntervenant, $vUtilisateur], $html);
$subject = $this->getServiceParametres()->get('contrat_modele_mail_objet');
$subject = str_replace(':intervenant', $vIntervenant, $subject);
$message = $this->getServiceModeleContrat()->prepareMail($contrat, $html, $subject);
$mail = $this->mail()->send($message);
}
return $this->getResponse();
......
......@@ -68,7 +68,7 @@ class IntervenantController extends AbstractController
return $this->redirect()->toUrl($url);
}
} else {
return $this->redirect()->toRoute('intervenant/voir', ['intervenant' => $intervenant->getRouteParam()]);
return $this->redirect()->toRoute('intervenant/voir', ['intervenant' => $intervenant->getId()]);
}
}
......@@ -376,21 +376,25 @@ class IntervenantController extends AbstractController
return compact('intervenant', 'data');
}
public function validationVolumeHoraireTypeIntervenantAction()
{
$serviceRVS = $this->getServiceRegleStructureValidation();
$listeRsv = $serviceRVS->getList();
return compact('listeRsv');
$listeRsv = $serviceRVS->getList();
return compact('listeRsv');
}
public function validationVolumeHoraireTypeIntervenantSaisieAction()
{
$regleStructureValidation = $this->getEvent()->getParam('regleStructureValidation');
$form = $this->getFormRegleStructureValidationSaisie();
$form = $this->getFormRegleStructureValidationSaisie();
if (empty($regleStructureValidation)) {
$title = 'Création d\'une nouvelle régle';
$title = 'Création d\'une nouvelle régle';
$regleStructureValidation = $this->getServiceRegleStructureValidation()->newEntity();
} else {
$title = 'Édition d\'une règle';
......@@ -405,8 +409,7 @@ class IntervenantController extends AbstractController
if (false !== strpos($message, 'ORA-00001')) {
$this->flashMessenger()->addErrorMessage("Règle non enregistrée car elle existe déjà dans OSE");
}
else{
} else {
$this->flashMessenger()->addErrorMessage($this->translate($e));
}
}
......@@ -415,6 +418,8 @@ class IntervenantController extends AbstractController
return compact('form', 'title');
}
public function validationVolumeHoraireTypeIntervenantDeleteAction()
{
$regleStructureValidation = $this->getEvent()->getParam('regleStructureValidation');
......@@ -430,6 +435,7 @@ class IntervenantController extends AbstractController
}
/**
*
* @return array
......
......@@ -83,7 +83,7 @@ abstract class AbstractIndicateur
public function getUrlParams()
{
return [
'intervenant' => $this->getIntervenant()->getRouteParam(),
'intervenant' => $this->getIntervenant()->getId(),
];
}
......
......@@ -313,18 +313,6 @@ class Intervenant implements HistoriqueAwareInterface, ResourceInterface, Import
/**
* retourne le paramètre de route
*
* @return string
*/
public function getRouteParam()
{
return $this->getCode();
}
public function getAdresseIdentite(): ?string
{
$identite = [];
......
......@@ -262,8 +262,8 @@ class RechercheFormHydrator implements HydratorInterface
/**
* Hydrate $object with the provided $data.
*
* @param array $data
* @param object $object
* @param array $data
* @param object $object
*
* @return object
*/
......@@ -306,7 +306,7 @@ class RechercheFormHydrator implements HydratorInterface
/**
* Extract values from an object
*
* @param \Application\Entity\Service\Recherche $object
* @param \Application\Entity\Service\Recherche $object
*
* @return array
*/
......@@ -316,7 +316,7 @@ class RechercheFormHydrator implements HydratorInterface
'type-intervenant' => $object->getTypeIntervenant() ? $object->getTypeIntervenant()->getId() : null,
'structure-aff' => $object->getStructureAff() ? $object->getStructureAff()->getId() : null,
'intervenant' => [
'id' => $object->getIntervenant() ? $object->getIntervenant()->getRouteParam() : null,
'id' => $object->getIntervenant() ? $object->getIntervenant()->getId() : null,
'label' => $object->getIntervenant() ? (string)$object->getIntervenant() : null,
],
'element-pedagogique' => [
......
......@@ -123,7 +123,7 @@ class SaisieFieldset extends AbstractFieldset
/* Peuple le formulaire avec les valeurs issues du contexte local */
if ($this->has('intervenant') && $this->getServiceLocalContext()->getIntervenant()) {
$this->get('intervenant')->setValue([
'id' => $this->getServiceLocalContext()->getIntervenant()->getRouteParam(),
'id' => $this->getServiceLocalContext()->getIntervenant()->getId(),
'label' => (string)$this->getServiceLocalContext()->getIntervenant(),
]);
}
......@@ -212,8 +212,8 @@ class SaisieFieldset extends AbstractFieldset
$canSaisieExterieur = $this->getServiceAuthorize()->isAllowed($this->getIntervenant(), Privileges::ENSEIGNEMENT_EXTERIEUR);
$this->remove('intervenant');
$this->add([
'name' => 'intervenant-id',
'type' => 'Hidden',
'name' => 'intervenant-id',
'type' => 'Hidden',
'attributes' => [
'value' => $this->getIntervenant()->getId(),
],
......@@ -251,16 +251,16 @@ class SaisieFieldsetHydrator implements HydratorInterface
/**
* Hydrate $object with the provided $data.
*
* @param array $data
* @param Service $object
* @param array $data
* @param Service $object
*
* @return object
*/
public function hydrate(array $data, $object)
{
$intervenant = isset($data['intervenant']['id']) ? $data['intervenant']['id'] : null;
if ($intervenant){
$object->setIntervenant( $this->getServiceIntervenant()->getBySourceCode($intervenant));
if ($intervenant) {
$object->setIntervenant($this->getServiceIntervenant()->getBySourceCode($intervenant));
}
if (isset($data['element-pedagogique']) && $data['element-pedagogique'] instanceof ElementPedagogique) {
......@@ -283,7 +283,7 @@ class SaisieFieldsetHydrator implements HydratorInterface
/**
* Extract values from an object
*
* @param Service $object
* @param Service $object
*
* @return array
*/
......@@ -297,7 +297,7 @@ class SaisieFieldsetHydrator implements HydratorInterface
if ($object->getIntervenant()) {
$data['intervenant'] = [
'id' => $object->getIntervenant()->getRouteParam(),
'id' => $object->getIntervenant()->getId(),
'label' => (string)$object->getIntervenant(),
];
} else {
......
......@@ -164,7 +164,7 @@ class SaisieFieldset extends AbstractFieldset implements EntityManagerAwareInter
public function getFonctions()
{
$fncs = $this->getServiceFonctionReferentiel()->getList();
$fncs = $this->getServiceFonctionReferentiel()->getList();
$fonctions = [];
foreach ($fncs as $id => $fonction) {
if ($fonction->getFille()->count() > 0) {
......@@ -190,7 +190,7 @@ class SaisieFieldset extends AbstractFieldset implements EntityManagerAwareInter
$cl = $this->getServiceLocalContext();
if ($this->has('intervenant') && $cl->getIntervenant()) {
$this->get('intervenant')->setValue([
'id' => $cl->getIntervenant()->getRouteParam(),
'id' => $cl->getIntervenant()->getId(),
'label' => (string)$cl->getIntervenant(),
]);
}
......@@ -344,8 +344,8 @@ class SaisieFieldsetHydrator implements HydratorInterface
/**
* Hydrate $object with the provided $data.
*
* @param array $data
* @param ServiceReferentiel $object
* @param array $data
* @param ServiceReferentiel $object
*
* @return object
*/
......@@ -379,7 +379,7 @@ class SaisieFieldsetHydrator implements HydratorInterface
/**
* Extract values from an object
*
* @param ServiceReferentiel $object
* @param ServiceReferentiel $object
*
* @return array
*/
......@@ -393,7 +393,7 @@ class SaisieFieldsetHydrator implements HydratorInterface
if ($object->getIntervenant()) {
$data['intervenant'] = [
'id' => $object->getIntervenant()->getRouteParam(),
'id' => $object->getIntervenant()->getId(),
'label' => (string)$object->getIntervenant(),
];
} else {
......
......@@ -33,7 +33,7 @@ class RechercheProcessus
WITH vrec AS (
SELECT
i.id,
i.source_code,
i.code,
i.nom_usuel,
i.nom_patronymique,
i.prenom,
......@@ -53,7 +53,7 @@ class RechercheProcessus
SELECT
null id,
i.source_code,
i.code,
i.nom_usuel,
i.nom_patronymique,
i.prenom,
......@@ -96,13 +96,13 @@ class RechercheProcessus
try {
$stmt = $this->getEntityManager()->getConnection()->executeQuery($sql);
while ($r = $stmt->fetch()) {
$intervenants[$r['SOURCE_CODE']] = [
$intervenants[$r['CODE']] = [
'civilite' => $r['CIVILITE'],
'nom' => $r['NOM_USUEL'],
'prenom' => $r['PRENOM'],
'date-naissance' => new \DateTime($r['DATE_NAISSANCE']),
'structure' => $r['STRUCTURE'],
'numero-personnel' => $r['SOURCE_CODE'],
'numero-personnel' => $r['CODE'],
];
}
} catch (\Exception $e) {
......
......@@ -83,7 +83,7 @@ class WorkflowService extends AbstractService
*/
public function getEtape($etape, Intervenant $intervenant = null, Structure $structure = null)
{
list($etapeCode, $intervenant, $structure) = $this->prepareEtapeParams($etape, $intervenant, $structure);
[$etapeCode, $intervenant, $structure] = $this->prepareEtapeParams($etape, $intervenant, $structure);
$fdr = $this->getFeuilleDeRoute($intervenant, $structure);
if ($fdr) {
......@@ -108,7 +108,7 @@ class WorkflowService extends AbstractService
*/
public function getNextEtape($etape, Intervenant $intervenant = null, Structure $structure = null)
{
list($etapeCode, $intervenant, $structure) = $this->prepareEtapeParams($etape, $intervenant, $structure);
[$etapeCode, $intervenant, $structure] = $this->prepareEtapeParams($etape, $intervenant, $structure);
$fdr = $this->getFeuilleDeRoute($intervenant, $structure);
$isCurrent = false;
......@@ -135,7 +135,7 @@ class WorkflowService extends AbstractService
*/
public function getPreviousAccessibleEtape($etape, Intervenant $intervenant = null, Structure $structure = null)
{
list($etapeCode, $intervenant, $structure) = $this->prepareEtapeParams($etape, $intervenant, $structure);
[$etapeCode, $intervenant, $structure] = $this->prepareEtapeParams($etape, $intervenant, $structure);
$fdr = $this->getFeuilleDeRoute($intervenant, $structure);
$isCurrent = false;
......@@ -162,7 +162,7 @@ class WorkflowService extends AbstractService
*/
public function getNextAccessibleEtape($etape, Intervenant $intervenant = null, Structure $structure = null)
{
list($etapeCode, $intervenant, $structure) = $this->prepareEtapeParams($etape, $intervenant, $structure);
[$etapeCode, $intervenant, $structure] = $this->prepareEtapeParams($etape, $intervenant, $structure);
$fdr = $this->getFeuilleDeRoute($intervenant, $structure);
$isCurrent = false;
......@@ -198,7 +198,7 @@ class WorkflowService extends AbstractService
/**
* @param Intervenant|null $intervenant
* @param Structure|null $structure
* @param Structure|null $structure
*
* @return WorkflowEtape|null
*/
......@@ -218,7 +218,7 @@ class WorkflowService extends AbstractService
/**
*
* @param Intervenant|null $intervenant
* @param Structure|null $structure
* @param Structure|null $structure
*
* @return WorkflowEtape[]
*/
......@@ -255,7 +255,7 @@ class WorkflowService extends AbstractService
$we->setStructure($structure);
$we->setEtape($e->getEtape());
$url = $this->getUrl($e->getEtape()->getRoute(), ['intervenant' => $intervenant->getRouteParam()]);
$url = $this->getUrl($e->getEtape()->getRoute(), ['intervenant' => $intervenant->getId()]);
$we->setUrl($url);
$this->feuillesDeRoute[$iid][$sid][$eid] = $we;
......@@ -287,48 +287,49 @@ class WorkflowService extends AbstractService
* @return int
* @throws \Doctrine\DBAL\DBALException
*/
public function calculerTousTableauxBord($beforeTrigger=null, $afterTrigger=null)
public function calculerTousTableauxBord($beforeTrigger = null, $afterTrigger = null)
{
$sql = "SELECT tbl_name FROM tbl WHERE tbl_name <> 'formule' ORDER BY ordre";
$tbls = $this->getEntityManager()->getConnection()->fetchAll($sql);
$sql = "SELECT tbl_name FROM tbl WHERE tbl_name <> 'formule' ORDER BY ordre";
$tbls = $this->getEntityManager()->getConnection()->fetchAll($sql);
$result = true;
foreach( $tbls as $tbl ){
foreach ($tbls as $tbl) {
$begin = microtime(true);
$tbl = $tbl['TBL_NAME'];
$sql = 'BEGIN UNICAEN_TBL.CALCULER(\''.$tbl.'\'); END;';
if (is_callable($beforeTrigger)){
$tbl = $tbl['TBL_NAME'];
$sql = 'BEGIN UNICAEN_TBL.CALCULER(\'' . $tbl . '\'); END;';
if (is_callable($beforeTrigger)) {
$beforeTrigger([
'tableau-bord' => $tbl,
]);
}
try{
try {
$this->getEntityManager()->getConnection()->exec($sql);
if (is_callable($afterTrigger)){
if (is_callable($afterTrigger)) {
$afterTrigger([
'tableau-bord' => $tbl,
'result' => true,
'duree' => microtime(true) - $begin,
'result' => true,
'duree' => microtime(true) - $begin,
]);
}
}catch(\Exception $e){
if (is_callable($afterTrigger)){
} catch (\Exception $e) {
if (is_callable($afterTrigger)) {
$afterTrigger([
'tableau-bord' => $tbl,
'result' => false,
'exception' => $e,
'duree' => microtime(true) - $begin,
'result' => false,
'exception' => $e,
'duree' => microtime(true) - $begin,
]);
}
$result = false;
}
}
return $result;
}
/**
* @param array $tableauxBords
* @param array $tableauxBords
* @param Intervenant|Intervenant[]|string $intervenant
*/
public function calculerTableauxBord($tableauxBords = [], $intervenant): array
......@@ -385,7 +386,7 @@ class WorkflowService extends AbstractService
$dep,
$params
);
}catch(\Exception $e ){
} catch (\Exception $e) {
$errors[$dep] = $e;
}
}
......@@ -491,14 +492,14 @@ class WorkflowService extends AbstractService
/**
* Generates a url given the name of a route.
*
* @see \Zend\Mvc\Router\RouteInterface::assemble()
*
* @param string $name Name of the route
* @param array $params Parameters for the link
* @param array|Traversable $options Options for the route
* @param bool $reuseMatchedParams Whether to reuse matched parameters
* @param string $name Name of the route
* @param array $params Parameters for the link
* @param array|Traversable $options Options for the route
* @param bool $reuseMatchedParams Whether to reuse matched parameters
*
* @return string Url For the link href attribute
* @see \Zend\Mvc\Router\RouteInterface::assemble()
*
*/
protected function getUrl($name = null, $params = [], $options = [], $reuseMatchedParams = false)
{
......
......@@ -117,7 +117,7 @@ class IntervenantViewHelper extends AbstractHtmlElement
return '<span class="bg-danger"><abbr title="Cet intervenant a été supprimé de OSE">' . $intervenant . '</abbr></span>';
}
$pourl = $this->getView()->url('intervenant/voir', ['intervenant' => $intervenant->getRouteParam()]);
$pourl = $this->getView()->url('intervenant/voir', ['intervenant' => $intervenant->getId()]);
$out = '<a href="' . $pourl . '" data-po-href="' . $pourl . '" class="ajax-modal">' . $intervenant . '</a>';
return $out;
......
......@@ -16,18 +16,24 @@ class TotauxHetdViewHelper extends AbstractHtmlElement implements FormuleResulta
{
use FormuleResultatAwareTrait;
/**
* Helper entry point.
*
* @param FormuleResultat $formuleResultat
*
* @return self
*/
final public function __invoke( FormuleResultat $formuleResultat )
final public function __invoke(FormuleResultat $formuleResultat)
{
$this->setFormuleResultat( $formuleResultat );
$this->setFormuleResultat($formuleResultat);
return $this;
}
/**
* Retourne le code HTML généré par cette aide de vue.
*
......@@ -38,91 +44,120 @@ class TotauxHetdViewHelper extends AbstractHtmlElement implements FormuleResulta
return $this->render();
}
public function getRefreshUrl()
{
$fr = $this->getFormuleResultat();
return $this->getView()->url(
'intervenant/formule-totaux-hetd', [
'intervenant' => $fr->getIntervenant()->getRouteParam(),
'typeVolumeHoraire' => $fr->getTypeVolumeHoraire()->getId(),
'etatVolumeHoraire' => $fr->getEtatVolumeHoraire()->getId()
] );
'intervenant' => $fr->getIntervenant()->getId(),
'typeVolumeHoraire' => $fr->getTypeVolumeHoraire()->getId(),
'etatVolumeHoraire' => $fr->getEtatVolumeHoraire()->getId(),
]);
}
public function render()
{
$fr = $this->getFormuleResultat();
$attrs = [
'id' => 'formule-totaux-hetd',
'data-url' => $this->getRefreshUrl()
'id' => 'formule-totaux-hetd',
'data-url' => $this->getRefreshUrl(),
];
ob_start();
?>
<div <?= $this->htmlAttribs($attrs) ?>>
<h1>Totaux <abbr title="Heures Équivalent TD">HETD</abbr></h1>
<table class="table table-bordered" style="width:auto;">
<?php if ($fr->getServiceDu() > 0): ?>
<tr><th>Service Dû</th>
<td style="text-align: right"><?= \UnicaenApp\Util::formattedNumber($fr->getServiceDu()) ?></td></tr>
<?php endif; ?>
<?php if ($fr->getHeuresService() > 0): ?>
<tr><th>Service assuré</th>
<td style="text-align: right"><?= \UnicaenApp\Util::formattedNumber($fr->getHeuresService()) ?></td></tr>
<?php if ($fr->getHeuresServiceFa() + $fr->getHeuresServiceFc() + $fr->getHeuresServiceFi() > 0): ?>
<tr><th