From aa7ec43842ec0cb37fa28cb092476f85ff8e9432 Mon Sep 17 00:00:00 2001 From: lecluse <lecluse@d57fa8bc-6af1-4de9-8b7d-78e900e231e7> Date: Mon, 23 Nov 2015 16:29:46 +0000 Subject: [PATCH] #2574 --- .../Application/config/intervenant.config.php | 305 +++++++++--------- .../Assertion/IntervenantAssertion.php | 30 -- .../Controller/IntervenantController.php | 52 +++ .../src/Application/Entity/Db/Privilege.php | 2 + .../Form/Intervenant/AjouterModifier.php | 13 - .../Form/Intervenant/EditionForm.php | 106 ++++++ .../Interfaces/EditionFormAwareInterface.php | 28 ++ .../Traits/EditionFormAwareTrait.php | 59 ++++ .../Intervenant/IntervenantViewHelper.php | 26 +- .../view/application/intervenant/fiche.phtml | 9 + .../view/application/intervenant/saisir.phtml | 18 ++ .../view/application/intervenant/voir.phtml | 35 +- public/css/app.css | 5 + public/js/app.js | 5 +- 14 files changed, 488 insertions(+), 205 deletions(-) delete mode 100644 module/Application/src/Application/Form/Intervenant/AjouterModifier.php create mode 100644 module/Application/src/Application/Form/Intervenant/EditionForm.php create mode 100755 module/Application/src/Application/Form/Intervenant/Interfaces/EditionFormAwareInterface.php create mode 100755 module/Application/src/Application/Form/Intervenant/Traits/EditionFormAwareTrait.php create mode 100644 module/Application/view/application/intervenant/fiche.phtml create mode 100644 module/Application/view/application/intervenant/saisir.phtml diff --git a/module/Application/config/intervenant.config.php b/module/Application/config/intervenant.config.php index 2842fc0990..47a6870971 100644 --- a/module/Application/config/intervenant.config.php +++ b/module/Application/config/intervenant.config.php @@ -5,7 +5,7 @@ namespace Application; use Application\Entity\Db\Privilege; return [ - 'router' => [ + 'router' => [ 'routes' => [ 'intervenant' => [ 'type' => 'Literal', @@ -35,22 +35,22 @@ return [ 'rechercher' => [ 'type' => 'Literal', 'options' => [ - 'route' => '/rechercher', - 'defaults' => [ + 'route' => '/rechercher', + 'defaults' => [ 'action' => 'rechercher', ], ], ], - 'recherche' => [ + 'recherche' => [ 'type' => 'Literal', 'options' => [ - 'route' => '/recherche', - 'defaults' => [ + 'route' => '/recherche', + 'defaults' => [ 'action' => 'recherche', ], ], ], - 'fiche' => [ + 'voir' => [ 'type' => 'Segment', 'options' => [ 'route' => '/:intervenant', @@ -62,12 +62,35 @@ return [ ], ], ], + 'fiche' => [ + 'type' => 'Segment', + 'options' => [ + 'route' => '/:intervenant/fiche', + 'constraints' => [ + 'intervenant' => '[0-9]*', + ], + 'defaults' => [ + 'action' => 'fiche', + ], + ], + ], + 'saisir' => [ + 'type' => 'Segment', + 'options' => [ + 'route' => '/:intervenant/saisir', + 'constraints' => [ + 'intervenant' => '[0-9]*', + ], + 'defaults' => [ + 'action' => 'saisir', + ], + ], + ], 'voir-heures-comp' => [ 'type' => 'Segment', 'options' => [ 'route' => '/voir-heures-comp/:intervenant', 'constraints' => [ - 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', 'intervenant' => '[0-9]*', ], 'defaults' => [ @@ -80,7 +103,6 @@ return [ 'options' => [ 'route' => '/formule-totaux-hetd/:intervenant/:typeVolumeHoraire/:etatVolumeHoraire', 'constraints' => [ - 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', 'intervenant' => '[0-9]*', 'typeVolumeHoraire' => '[0-9]*', 'etatVolumeHoraire' => '[0-9]*', @@ -297,7 +319,7 @@ return [ ], ], ], - 'navigation' => [ + 'navigation' => [ 'default' => [ 'home' => [ 'pages' => [ @@ -305,7 +327,7 @@ return [ 'label' => 'Intervenant', 'title' => "Intervenant", 'route' => 'intervenant', - 'resource' => 'controller/Application\Controller\Intervenant:index', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Intervenant','index'), 'pages' => [ 'rechercher' => [ 'label' => " Rechercher", @@ -316,17 +338,17 @@ return [ ], 'icon' => "glyphicon glyphicon-search", 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Intervenant:rechercher', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Intervenant','rechercher'), ], - 'fiche' => [ + 'voir' => [ 'label' => "Fiche individuelle", 'title' => "Consultation de la fiche de l'intervenant {id}", - 'route' => 'intervenant/fiche', + 'route' => 'intervenant/voir', 'paramsInject' => [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Intervenant:voir', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Intervenant','voir'), ], 'voir-heures-comp' => [ 'label' => "Calcul HETD", @@ -337,7 +359,7 @@ return [ ], 'action' => 'voir-heures-comp', 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Intervenant:voir-heures-comp', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Intervenant','voir-heures-comp'), ], 'modification-service-du' => [ 'label' => "Modification de service dû", @@ -347,7 +369,7 @@ return [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\ModificationServiceDu:saisir', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\ModificationServiceDu','saisir'), ], 'dossier' => [ 'label' => "Données personnelles", @@ -357,7 +379,7 @@ return [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Dossier:modifier', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Dossier','modifier'), 'visible' => 'IntervenantNavigationPageVisibility', ], 'service' => [ @@ -368,7 +390,7 @@ return [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Service:index', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Service','index'), 'visible' => 'IntervenantNavigationPageVisibility', ], 'pieces-jointes-saisie' => [ @@ -385,7 +407,7 @@ return [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Validation:dossier', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Validation','dossier'), 'visible' => 'IntervenantNavigationPageVisibility', ], 'validation-service-prevu' => [ @@ -396,7 +418,7 @@ return [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Validation:service', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Validation','service'), 'visible' => 'IntervenantNavigationPageVisibility', ], 'validation-referentiel-prevu' => [ @@ -407,7 +429,7 @@ return [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Validation:referentiel', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Validation','referentiel'), 'visible' => 'IntervenantNavigationPageVisibility', ], 'agrement' => [ @@ -421,7 +443,7 @@ return [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Contrat:index', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Contrat','index'), 'visible' => 'IntervenantNavigationPageVisibility', ], 'services-realises' => [ @@ -432,7 +454,7 @@ return [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Service:index', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Service','index'), 'visible' => 'IntervenantNavigationPageVisibility', ], 'validation-service-realise' => [ @@ -443,7 +465,7 @@ return [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Validation:service', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Validation','service'), 'visible' => 'IntervenantNavigationPageVisibility', ], 'validation-referentiel-realise' => [ @@ -454,7 +476,7 @@ return [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Validation:referentiel', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Validation','referentiel'), 'visible' => 'IntervenantNavigationPageVisibility', ], 'demande-mise-en-paiement' => [ @@ -465,7 +487,7 @@ return [ 'intervenant', ], 'withtarget' => true, - 'resource' => 'controller/Application\Controller\Paiement:demandemiseenpaiement', + 'resource' => Guard\PrivilegeController::getResourceId('Application\Controller\Paiement','demandeMiseEnPaiement'), 'visible' => 'IntervenantNavigationPageVisibility', ], ], @@ -475,143 +497,138 @@ return [ ], ], 'bjyauthorize' => [ - 'guards' => [ - Guard\PrivilegeController::class => [ - [ - 'controller' => 'Application\Controller\Intervenant', - 'action' => ['rechercher'], - 'privileges' => [ - Privilege::INTERVENANT_RECHERCHE, - ], - ], - [ - 'controller' => 'Application\Controller\Intervenant', - 'action' => ['index', 'voir'], - 'privileges' => [ - Privilege::INTERVENANT_FICHE, - ], - ], - [ - 'controller' => 'Application\Controller\ModificationServiceDu', - 'action' => ['saisir'], - 'privileges' => [ - Privilege::MODIF_SERVICE_DU_VISUALISATION, - ], - 'assertion' => 'ModificationServiceDuAssertion', - ], - [ - 'controller' => 'Application\Controller\Intervenant', - 'action' => ['voir-heures-comp'], - 'privileges' => [ - Privilege::INTERVENANT_CALCUL_HETD, - ], + 'guards' => [ + Guard\PrivilegeController::class => [ + [ + 'controller' => 'Application\Controller\Intervenant', + 'action' => ['rechercher'], + 'privileges' => [ + Privilege::INTERVENANT_RECHERCHE, ], ], - 'BjyAuthorize\Guard\Controller' => [ - [ - 'controller' => 'Application\Controller\Intervenant', - 'action' => ['formule-totaux-hetd'], - 'roles' => $R_ALL, - 'assertion' => 'IntervenantAssertion', - ], - [ - 'controller' => 'Application\Controller\Intervenant', - 'action' => ['apercevoir',], - 'roles' => ['user'], + [ + 'controller' => 'Application\Controller\Intervenant', + 'action' => ['index', 'voir', 'fiche'], + 'privileges' => [ + Privilege::INTERVENANT_FICHE, ], - [ - 'controller' => 'Application\Controller\Intervenant', - 'action' => ['feuille-de-route'], - 'roles' => [R_INTERVENANT, R_COMPOSANTE, R_ADMINISTRATEUR], + ], + [ + 'controller' => 'Application\Controller\Intervenant', + 'action' => ['saisir'], + 'privileges' => [ + Privilege::INTERVENANT_EDITION, ], - [ - 'controller' => 'Application\Controller\Intervenant', - 'action' => ['choisir', 'rechercher', 'recherche'], - 'roles' => [R_COMPOSANTE, R_ADMINISTRATEUR], + ], + [ + 'controller' => 'Application\Controller\ModificationServiceDu', + 'action' => ['saisir'], + 'privileges' => [ + Privilege::MODIF_SERVICE_DU_VISUALISATION, ], - [ - 'controller' => 'Application\Controller\Dossier', - 'action' => ['voir', 'modifier'], - 'roles' => [R_INTERVENANT_EXTERIEUR, R_COMPOSANTE, R_ADMINISTRATEUR], + 'assertion' => 'ModificationServiceDuAssertion', + ], + [ + 'controller' => 'Application\Controller\Intervenant', + 'action' => ['voir-heures-comp'], + 'privileges' => [ + Privilege::INTERVENANT_CALCUL_HETD, ], ], ], - 'resource_providers' => [ - 'BjyAuthorize\Provider\Resource\Config' => [ - 'Intervenant' => [], + 'BjyAuthorize\Guard\Controller' => [ + [ + 'controller' => 'Application\Controller\Intervenant', + 'action' => ['formule-totaux-hetd'], + 'roles' => $R_ALL, ], - ], - 'rule_providers' => [ - Provider\Rule\PrivilegeRuleProvider::class => [ - 'allow' => [ - [ - 'privileges' => Privilege::MODIF_SERVICE_DU_EDITION, - 'resources' => 'Intervenant', - 'assertion' => 'ModificationServiceDuAssertion', - ], - ], + [ + 'controller' => 'Application\Controller\Intervenant', + 'action' => ['apercevoir',], + 'roles' => ['user'], ], - 'BjyAuthorize\Provider\Rule\Config' => [ - 'allow' => [ - [ - $R_ALL, - 'Intervenant', - ['total-heures-comp'], - 'IntervenantAssertion', - ], - - ], + [ + 'controller' => 'Application\Controller\Intervenant', + 'action' => ['feuille-de-route'], + 'roles' => [R_INTERVENANT, R_COMPOSANTE, R_ADMINISTRATEUR], + ], + [ + 'controller' => 'Application\Controller\Intervenant', + 'action' => ['choisir', 'rechercher', 'recherche'], + 'roles' => [R_COMPOSANTE, R_ADMINISTRATEUR], + ], + [ + 'controller' => 'Application\Controller\Dossier', + 'action' => ['voir', 'modifier'], + 'roles' => [R_INTERVENANT_EXTERIEUR, R_COMPOSANTE, R_ADMINISTRATEUR], ], ], ], - 'controllers' => [ - 'invokables' => [ - 'Application\Controller\Intervenant' => Controller\IntervenantController::class, - 'Application\Controller\Dossier' => Controller\DossierController::class, - 'Application\Controller\ModificationServiceDu' => Controller\ModificationServiceDuController::class, + 'resource_providers' => [ + 'BjyAuthorize\Provider\Resource\Config' => [ + 'Intervenant' => [], ], - 'aliases' => [ - 'IntervenantController' => 'Application\Controller\Intervenant', + ], + 'rule_providers' => [ + Provider\Rule\PrivilegeRuleProvider::class => [ + 'allow' => [ + [ + 'privileges' => Privilege::MODIF_SERVICE_DU_EDITION, + 'resources' => 'Intervenant', + 'assertion' => 'ModificationServiceDuAssertion', + ], + ], ], ], +], + 'controllers' => [ + 'invokables' => [ + 'Application\Controller\Intervenant' => Controller\IntervenantController::class, + 'Application\Controller\Dossier' => Controller\DossierController::class, + 'Application\Controller\ModificationServiceDu' => Controller\ModificationServiceDuController::class, + ], + 'aliases' => [ + 'IntervenantController' => 'Application\Controller\Intervenant', + ], +], 'service_manager' => [ - 'invokables' => [ - 'ApplicationIntervenant' => Service\Intervenant::class, - 'ApplicationMotifModificationServiceDu' => Service\MotifModificationServiceDu::class, - 'ApplicationCivilite' => Service\Civilite::class, - 'ApplicationStatutIntervenant' => Service\StatutIntervenant::class, - 'ApplicationTypeIntervenant' => Service\TypeIntervenant::class, - 'ApplicationDossier' => Service\Dossier::class, - 'IntervenantAssertion' => Assertion\IntervenantAssertion::class, - 'ModificationServiceDuAssertion' => Assertion\ModificationServiceDuAssertion::class, - 'PeutSaisirDossierRule' => Rule\Intervenant\PeutSaisirDossierRule::class, - 'PeutSaisirServiceRule' => Rule\Intervenant\PeutSaisirServiceRule::class, - 'PeutSaisirReferentielRule' => Rule\Intervenant\PeutSaisirReferentielRule::class, - 'PossedeDossierRule' => Rule\Intervenant\PossedeDossierRule::class, - 'ServiceValideRule' => Rule\Intervenant\ServiceValideRule::class, - 'PeutValiderServiceRule' => Rule\Intervenant\PeutValiderServiceRule::class, - 'ReferentielValideRule' => Rule\Intervenant\ReferentielValideRule::class, - 'NecessiteAgrementRule' => Rule\Intervenant\NecessiteAgrementRule::class, - 'AgrementFourniRule' => Rule\Intervenant\AgrementFourniRule::class, - 'EstAffecteRule' => Rule\Intervenant\EstAffecteRule::class, - ], + 'invokables' => [ + 'ApplicationIntervenant' => Service\Intervenant::class, + 'ApplicationMotifModificationServiceDu' => Service\MotifModificationServiceDu::class, + 'ApplicationCivilite' => Service\Civilite::class, + 'ApplicationStatutIntervenant' => Service\StatutIntervenant::class, + 'ApplicationTypeIntervenant' => Service\TypeIntervenant::class, + 'ApplicationDossier' => Service\Dossier::class, + 'IntervenantAssertion' => Assertion\IntervenantAssertion::class, + 'ModificationServiceDuAssertion' => Assertion\ModificationServiceDuAssertion::class, + 'PeutSaisirDossierRule' => Rule\Intervenant\PeutSaisirDossierRule::class, + 'PeutSaisirServiceRule' => Rule\Intervenant\PeutSaisirServiceRule::class, + 'PeutSaisirReferentielRule' => Rule\Intervenant\PeutSaisirReferentielRule::class, + 'PossedeDossierRule' => Rule\Intervenant\PossedeDossierRule::class, + 'ServiceValideRule' => Rule\Intervenant\ServiceValideRule::class, + 'PeutValiderServiceRule' => Rule\Intervenant\PeutValiderServiceRule::class, + 'ReferentielValideRule' => Rule\Intervenant\ReferentielValideRule::class, + 'NecessiteAgrementRule' => Rule\Intervenant\NecessiteAgrementRule::class, + 'AgrementFourniRule' => Rule\Intervenant\AgrementFourniRule::class, + 'EstAffecteRule' => Rule\Intervenant\EstAffecteRule::class, ], +], 'view_helpers' => [ - 'invokables' => [ - 'formuleTotauxHetd' => View\Helper\Intervenant\TotauxHetdViewHelper::class, - 'Intervenant' => View\Helper\Intervenant\IntervenantViewHelper::class, - ], - 'initializers' => [ - ], + 'invokables' => [ + 'formuleTotauxHetd' => View\Helper\Intervenant\TotauxHetdViewHelper::class, + 'Intervenant' => View\Helper\Intervenant\IntervenantViewHelper::class, ], + 'initializers' => [ + ], +], 'form_elements' => [ - 'invokables' => [ - 'intervenantForm' => Form\Intervenant\IntervenantForm::class, - 'IntervenantDossier' => Form\Intervenant\Dossier::class, - 'IntervenantHeuresCompForm' => Form\Intervenant\HeuresCompForm::class, - 'IntervenantModificationServiceDuForm' => Form\Intervenant\ModificationServiceDuForm::class, - 'IntervenantModificationServiceDuFieldset' => Form\Intervenant\ModificationServiceDuFieldset::class, - 'IntervenantMotifModificationServiceDuFieldset' => Form\Intervenant\MotifModificationServiceDuFieldset::class, - ], + 'invokables' => [ + 'IntervenantEditionForm' => Form\Intervenant\EditionForm::class, + 'IntervenantDossier' => Form\Intervenant\Dossier::class, + 'IntervenantHeuresCompForm' => Form\Intervenant\HeuresCompForm::class, + 'IntervenantModificationServiceDuForm' => Form\Intervenant\ModificationServiceDuForm::class, + 'IntervenantModificationServiceDuFieldset' => Form\Intervenant\ModificationServiceDuFieldset::class, + 'IntervenantMotifModificationServiceDuFieldset' => Form\Intervenant\MotifModificationServiceDuFieldset::class, ], +], ]; diff --git a/module/Application/src/Application/Assertion/IntervenantAssertion.php b/module/Application/src/Application/Assertion/IntervenantAssertion.php index 2050f57f51..7cdc45dbee 100644 --- a/module/Application/src/Application/Assertion/IntervenantAssertion.php +++ b/module/Application/src/Application/Assertion/IntervenantAssertion.php @@ -2,7 +2,6 @@ namespace Application\Assertion; -use Application\Entity\Db\Intervenant; use Zend\Permissions\Acl\Acl; use Zend\Permissions\Acl\Resource\ResourceInterface; use Zend\Permissions\Acl\Role\RoleInterface; @@ -31,36 +30,7 @@ class IntervenantAssertion extends AbstractAssertion { parent::assert($acl, $role, $resource, $privilege); - $privilege = $this->normalizedPrivilege($privilege, $resource); - - if ('total-heures-comp' == $privilege){ - $resource = $this->getMvcEvent()->getParam('intervenant'); - return $this->assertIntervenantTotalHeuresComp($this->getSelectedIdentityRole(), $resource); - } - return true; } - /** - * - * @param RoleInterface $role - * @param Intervenant $resource - * @return boolean - */ - protected function assertIntervenantTotalHeuresComp(RoleInterface $role = null, Intervenant $resource = null) - { - /********************************************************* - * Rôle intervenant - *********************************************************/ - if ($role instanceof \Application\Acl\IntervenantRole){ - if ($role->getIntervenant() <> $resource){ - return false; - } - } - - /********************************************************* - * Tous les autres - *********************************************************/ - return true; - } } \ No newline at end of file diff --git a/module/Application/src/Application/Controller/IntervenantController.php b/module/Application/src/Application/Controller/IntervenantController.php index e9f7b44087..516e0013e1 100644 --- a/module/Application/src/Application/Controller/IntervenantController.php +++ b/module/Application/src/Application/Controller/IntervenantController.php @@ -2,6 +2,8 @@ namespace Application\Controller; +use Application\Exception\DbException; +use Application\Form\Intervenant\Traits\EditionFormAwareTrait; use Application\Form\Intervenant\Traits\HeuresCompFormAwareTrait; use Application\Traits\SessionContainerTrait; use Zend\Mvc\Controller\AbstractActionController; @@ -28,6 +30,7 @@ class IntervenantController extends AbstractActionController implements Workflow use TypeHeuresAwareTrait; use HeuresCompFormAwareTrait; use SessionContainerTrait; + use EditionFormAwareTrait; @@ -91,6 +94,16 @@ class IntervenantController extends AbstractActionController implements Workflow + public function ficheAction() + { + $role = $this->getServiceContext()->getSelectedIdentityRole(); + $intervenant = $role->getIntervenant() ?: $this->getEvent()->getParam('intervenant'); + + return compact('intervenant', 'role'); + } + + + public function apercevoirAction() { $role = $this->getServiceContext()->getSelectedIdentityRole(); @@ -102,6 +115,45 @@ class IntervenantController extends AbstractActionController implements Workflow + public function saisirAction() + { + $this->em()->getFilters()->enable('historique')->init([ + ]); + + $role = $this->getServiceContext()->getSelectedIdentityRole(); + $intervenant = $role->getIntervenant() ?: $this->getEvent()->getParam('intervenant'); + $title = "Saisie d'un intervenant"; + $form = $this->getFormIntervenantEdition(); + $errors = []; + + if ($intervenant) { + $form->bind($intervenant); + } else { + $intervenant = $this->getServiceIntervenant()->newEntity(); + $form->setObject($intervenant); + } + + $form->setAttribute('action', $this->url()->fromRoute(null, [], [], true)); + + $request = $this->getRequest(); + if ($request->isPost()) { + $form->setData($request->getPost()); + if ($form->isValid()) { + try { + $this->getServiceIntervenant()->save($intervenant); + $form->get('id')->setValue($intervenant->getId()); // transmet le nouvel ID + } catch (\Exception $e) { + $e = DbException::translate($e); + $errors[] = $e->getMessage(); + } + } + } + + return compact('intervenant', 'form', 'errors', 'title'); + } + + + public function voirHeuresCompAction() { $this->em()->getFilters()->enable('historique')->init([ diff --git a/module/Application/src/Application/Entity/Db/Privilege.php b/module/Application/src/Application/Entity/Db/Privilege.php index 40250dc087..765c90aed8 100644 --- a/module/Application/src/Application/Entity/Db/Privilege.php +++ b/module/Application/src/Application/Entity/Db/Privilege.php @@ -25,6 +25,7 @@ class Privilege const INTERVENANT_RECHERCHE = 'intervenant-recherche'; const INTERVENANT_FICHE = 'intervenant-fiche'; const INTERVENANT_CALCUL_HETD = 'intervenant-calcul-hetd'; + const INTERVENANT_EDITION = 'intervenant-edition'; const MISE_EN_PAIEMENT_VISUALISATION = 'mise-en-paiement-visualisation'; const MISE_EN_PAIEMENT_DEMANDE = 'mise-en-paiement-demande'; const MISE_EN_PAIEMENT_EXPORT_CSV = 'mise-en-paiement-export-csv'; @@ -49,6 +50,7 @@ class Privilege + /** * @var string */ diff --git a/module/Application/src/Application/Form/Intervenant/AjouterModifier.php b/module/Application/src/Application/Form/Intervenant/AjouterModifier.php deleted file mode 100644 index f7b6175b0b..0000000000 --- a/module/Application/src/Application/Form/Intervenant/AjouterModifier.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -namespace Application\Form\Intervenant; - -/** - * Description of AjouterModifier - * - * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> - */ -class AjouterModifier extends \Zend\Form\Form -{ - -} \ No newline at end of file diff --git a/module/Application/src/Application/Form/Intervenant/EditionForm.php b/module/Application/src/Application/Form/Intervenant/EditionForm.php new file mode 100644 index 0000000000..1cbe4fcdd2 --- /dev/null +++ b/module/Application/src/Application/Form/Intervenant/EditionForm.php @@ -0,0 +1,106 @@ +<?php + +namespace Application\Form\Intervenant; + +use Application\Entity\Db\Intervenant; +use Zend\Form\Form; +use Zend\Stdlib\Hydrator\HydratorInterface; + +/** + * Description of EditionForm + * + * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> + */ +class EditionForm extends Form +{ + + public function init() + { + + $hydrator = new IntervenantFormHydrator; + $this->setHydrator($hydrator); + + $this->add([ + 'name' => 'montant-indemnite-fc', + 'options' => [ + 'label' => "Montant de l'indemnité de formation continue (€) :", + ], + 'attributes' => [ + 'value' => '0', + 'title' => "Nombre d'heures", + 'step' => 'any', + 'min' => 0, + ], + 'type' => 'Number', + ]); + + $this->add([ + 'name' => 'id', + 'type' => 'Hidden', + ]); + + $this->add([ + 'name' => 'submit', + 'type' => 'Submit', + 'attributes' => [ + 'value' => 'Appliquer', + 'class' => 'btn btn-primary', + ], + ]); + } + + + + /** + * Should return an array specification compatible with + * {@link Zend\InputFilter\Factory::createInputFilter()}. + * + * @return array + */ + public function getInputFilterSpecification() + { + return [ + 'montant-indemnite-fc' => [ + 'required' => false, + ], + ]; + } +} + + + + + +class IntervenantFormHydrator implements HydratorInterface +{ + + /** + * @param array $data + * @param Intervenant $object + * + * @return object + */ + public function hydrate(array $data, $object) + { + $object->setMontantIndemniteFc($data['montant-indemnite-fc']); + + return $object; + } + + + + /** + * @param Intervenant $object + * + * @return array + */ + public function extract($object) + { + $data = [ + 'id' => $object->getId(), + 'montant-indemnite-fc' => $object->getMontantIndemniteFc(), + ]; + + return $data; + } +} \ No newline at end of file diff --git a/module/Application/src/Application/Form/Intervenant/Interfaces/EditionFormAwareInterface.php b/module/Application/src/Application/Form/Intervenant/Interfaces/EditionFormAwareInterface.php new file mode 100755 index 0000000000..4535b4c829 --- /dev/null +++ b/module/Application/src/Application/Form/Intervenant/Interfaces/EditionFormAwareInterface.php @@ -0,0 +1,28 @@ +<?php + +namespace Application\Form\Intervenant\Interfaces; + +use Application\Form\Intervenant\EditionForm; +use RuntimeException; + +/** + * Description of EditionFormAwareInterface + * + * @author UnicaenCode + */ +interface EditionFormAwareInterface +{ + /** + * @param EditionForm $formIntervenantEdition + * @return self + */ + public function setFormIntervenantEdition( EditionForm $formIntervenantEdition ); + + + + /** + * @return EditionFormAwareInterface + * @throws RuntimeException + */ + public function getFormIntervenantEdition(); +} \ No newline at end of file diff --git a/module/Application/src/Application/Form/Intervenant/Traits/EditionFormAwareTrait.php b/module/Application/src/Application/Form/Intervenant/Traits/EditionFormAwareTrait.php new file mode 100755 index 0000000000..6fccaf043f --- /dev/null +++ b/module/Application/src/Application/Form/Intervenant/Traits/EditionFormAwareTrait.php @@ -0,0 +1,59 @@ +<?php + +namespace Application\Form\Intervenant\Traits; + +use Application\Form\Intervenant\EditionForm; +use Application\Module; +use RuntimeException; + +/** + * Description of EditionFormAwareTrait + * + * @author UnicaenCode + */ +trait EditionFormAwareTrait +{ + /** + * @var EditionForm + */ + private $formIntervenantEdition; + + + + + + /** + * @param EditionForm $formIntervenantEdition + * @return self + */ + public function setFormIntervenantEdition( EditionForm $formIntervenantEdition ) + { + $this->formIntervenantEdition = $formIntervenantEdition; + return $this; + } + + + + /** + * @return EditionForm + * @throws RuntimeException + */ + public function getFormIntervenantEdition() + { + if (empty($this->formIntervenantEdition)){ + $serviceLocator = Module::$serviceLocator; + if (! $serviceLocator) { + if (!method_exists($this, 'getServiceLocator')) { + throw new RuntimeException('La classe ' . get_class($this) . ' n\'a pas accès au ServiceLocator.'); + } + + $serviceLocator = $this->getServiceLocator(); + if (method_exists($serviceLocator, 'getServiceLocator')) { + $serviceLocator = $serviceLocator->getServiceLocator(); + } + } + $this->formIntervenantEdition = $serviceLocator->get('FormElementManager')->get('IntervenantEditionForm'); + } + return $this->formIntervenantEdition; + } +} \ No newline at end of file diff --git a/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php b/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php index fd3d8721f1..6d748407d0 100644 --- a/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php +++ b/module/Application/src/Application/View/Helper/Intervenant/IntervenantViewHelper.php @@ -2,6 +2,7 @@ namespace Application\View\Helper\Intervenant; +use Application\Util; use Zend\View\Helper\AbstractHtmlElement; use Application\Entity\Db\Intervenant; use Application\Entity\Db\Traits\IntervenantAwareTrait; @@ -59,27 +60,28 @@ class IntervenantViewHelper extends AbstractHtmlElement "NOM prénom" => $entity, "Civilité" => $entity->getCiviliteToString(), "Date de naissance" => $entity->getDateNaissanceToString(), - "Ville de naissance" => $entity->getVilleNaissanceLibelle() ?: "(Inconnue)", + "Ville de naissance" => $entity->getVilleNaissanceLibelle() ?: '<span class="inconnu">(Inconnue)</span>', "Pays de naissance" => $entity->getPaysNaissanceLibelle(), "N° INSEE" => $entity->getNumeroInsee(), ], 'coordonnees' => [ - "Email" => $entity->getEmail() ?: "(Inconnu)", - "Téléphone mobile" => $entity->getTelMobile() ?: "(Inconnu)", - "Téléphone pro" => $entity->getTelPro() ?: "(Inconnu)", + "Email" => $entity->getEmail() ?: '<span class="inconnu">(Inconnu)</span>', + "Téléphone mobile" => $entity->getTelMobile() ?: '<span class="inconnu">(Inconnu)</span>', + "Téléphone pro" => $entity->getTelPro() ?: '<span class="inconnu">(Inconnu)</span>', "Adresse" => nl2br($entity->getAdressePrincipale()), ], 'metier' => [ - "Type d'intervenant" => $entity->getStatut()->getTypeIntervenant(), - "Statut de l'intervenant" => $entity->getStatut(), - "N° {$entity->getSource()}" => $entity->getSourceCode(), - "Affectation principale" => $entity->getStructure() ?: "(Inconnue)", - "Affectation recherche" => count($aff = $entity->getAffectation()) ? implode(" ; ", $aff->toArray()) : "(Inconnue)", - "Discipline" => $entity->getDiscipline() ?: "(Inconnue)", - "Grade" => $entity->getGrade() ?: "(Aucun ou inconnu)", + "Type d'intervenant" => $entity->getStatut()->getTypeIntervenant(), + "Statut de l'intervenant" => $entity->getStatut(), + "N° {$entity->getSource()}" => $entity->getSourceCode(), + "Affectation principale" => $entity->getStructure() ?: '<span class="inconnu">(Inconnue)</span>', + "Affectation recherche" => count($aff = $entity->getAffectation()) ? implode(" ; ", $aff->toArray()) : '<span class="inconnu">(Inconnue)</span>', + "Discipline" => $entity->getDiscipline() ?: '<span class="inconnu">(Inconnue)</span>', + "Grade" => $entity->getGrade() ?: '<span class="inconnu">(Aucun ou inconnu)</span>', + "Montant de l'indemnité FC" => $entity->getMontantIndemniteFc() !== null ? \UnicaenApp\Util::formattedEuros($entity->getMontantIndemniteFc()) : '<span class="inconnu">(Inconnue)</span>', ], 'divers' => [ - "Id" => $entity->getId(), + "Id" => $entity->getId(), //"Id de connexion" => ($u = $entity->getUtilisateur()) ? $u->getUsername() : "(Aucun)", ], ]; diff --git a/module/Application/view/application/intervenant/fiche.phtml b/module/Application/view/application/intervenant/fiche.phtml new file mode 100644 index 0000000000..69b279f3f0 --- /dev/null +++ b/module/Application/view/application/intervenant/fiche.phtml @@ -0,0 +1,9 @@ +<?php +/* @var $intervenant \Application\Entity\Db\Intervenant */ +/* @var $role Application\Acl\Role */ + +?> + +<?php echo $this->intervenant($intervenant); ?> +<hr /> +<?php echo $this->partial('application/intervenant/partial/feuille-de-route.phtml', compact('intervenant','role')); diff --git a/module/Application/view/application/intervenant/saisir.phtml b/module/Application/view/application/intervenant/saisir.phtml new file mode 100644 index 0000000000..a46a501b82 --- /dev/null +++ b/module/Application/view/application/intervenant/saisir.phtml @@ -0,0 +1,18 @@ +<?php + +/* @var $intervenant \Application\Entity\Db\Intervenant */ +/* @var $form Application\Form\Intervenant\IntervenantForm */ +/* @var $errors array */ + + +echo $this->form()->openTag($form->prepare()); + +if ($errors) { + echo $this->messenger()->setMessages([UnicaenApp\View\Helper\Messenger::ERROR => $errors]); +} + +echo $this->formControlGroup($form->get('montant-indemnite-fc')); +echo $this->formRow($form->get('submit')); +echo $this->formHidden($form->get('id')); + +echo $this->form()->closeTag(); \ No newline at end of file diff --git a/module/Application/view/application/intervenant/voir.phtml b/module/Application/view/application/intervenant/voir.phtml index 15fb93c094..ede26977e1 100644 --- a/module/Application/view/application/intervenant/voir.phtml +++ b/module/Application/view/application/intervenant/voir.phtml @@ -1,9 +1,34 @@ -<?php $this->headTitle()->append($intervenant->getNomUsuel())->append("Fiche") ?> +<?php -<h1 class="page-header"><?php echo $intervenant ?> <small><?php echo $intervenant->getStatut()->getTypeIntervenant() ?></small></h1> +/* @var $intervenant \Application\Entity\Db\Intervenant */ +/* @var $role \Application\Acl\Role */ -<?php echo $this->intervenant($intervenant) ?> +$this->headTitle()->append($intervenant->getNomUsuel())->append("Fiche"); -<hr /> +?> -<?php echo $this->partial('application/intervenant/partial/feuille-de-route.phtml', compact('intervenant','role')); \ No newline at end of file + <h1 class="page-header"><?php echo $intervenant ?> + <small><?php echo $intervenant->getStatut()->getTypeIntervenant() ?></small> + </h1> + +<?php + +$tabs = [ + [ + 'id' => 'fiche', + 'label' => '<span class="glyphicon glyphicon-eye-open"></span> Fiche', + 'content' => $this->partial('application/intervenant/fiche.phtml', compact('intervenant', 'role')), + 'url' => $this->url('intervenant/fiche', ['intervenant' => $intervenant->getSourceCode()]), + 'force-refresh' => true, + ], +]; + +if ($this->isAllowed('privilege/' . \Application\Entity\Db\Privilege::INTERVENANT_EDITION)) { + $tabs[] = [ + 'id' => 'edition', + 'label' => '<span class="glyphicon glyphicon-pencil"></span> Édition', + 'url' => $this->url('intervenant/saisir', ['intervenant' => $intervenant->getSourceCode()]), + ]; +} + +echo $this->tabajax($tabs); diff --git a/public/css/app.css b/public/css/app.css index fa998858f4..fd796d3637 100755 --- a/public/css/app.css +++ b/public/css/app.css @@ -355,6 +355,11 @@ ul.privileges-form li label { color: white; } +.inconnu { + font-style: italic; + color: gray; +} + div#navbar pre { display: none; } diff --git a/public/js/app.js b/public/js/app.js index e5951c2e3b..271e18e8b6 100755 --- a/public/js/app.js +++ b/public/js/app.js @@ -130,14 +130,17 @@ $.widget("ose.intervenantRecherche", { { var that = this; - this.element.find( "#critere" ).autocomplete({ + this.getElementCritere().autocomplete({ source: function( event, ui ) { that.rechercher(event.term); return {}; } }); + + this.getElementCritere().focus(); }, + getElementCritere: function(){ return this.element.find( "#critere" ); }, getElementRecherche : function () { return this.element.find('.recherche'); }, }); -- GitLab