Commit aa7ec438 authored by lecluse's avatar lecluse
Browse files

#2574

parent f8c09b4a
......@@ -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
......@@ -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([
......
......@@ -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
*/
......
<?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
<?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
<?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
<?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
......@@ -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)",
],
];
......
<?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'));
<?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
<?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);
......@@ -355,6 +355,11 @@ ul.privileges-form li label {
color: white;
}
.inconnu {
font-style: italic;
color: gray;
}
div#navbar pre {
display: none;
}
......
......@@ -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'); },
});
......
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