Commit a55d31cf authored by Alexandre Zvenigorosky's avatar Alexandre Zvenigorosky
Browse files

Merge branches 'Modulateurs-Statuts' and 'v8' of...

Merge branches 'Modulateurs-Statuts' and 'v8' of https://git.unicaen.fr/open-source/OSE into Modulateurs-Statuts

# Conflicts:
#	module/Application/src/Application/Controller/ModulateurController.php
#	module/Application/view/application/modulateur/index.phtml
parent 64c2ad5d
......@@ -80,6 +80,7 @@ class AppConfig
if ('development' == $env) {
$modules[] = 'ZendDeveloperTools';
$modules[] = 'UnicaenCode';
}
if (self::inConsole() || 'development' == $env){
......@@ -133,4 +134,4 @@ class AppConfig
AppConfig::init();
return AppConfig::getGlobal();
\ No newline at end of file
return AppConfig::getGlobal();
......@@ -77,10 +77,10 @@ return [
Privileges::TYPE_INTERVENTION_VISUALISATION,
Privileges::PIECE_JUSTIFICATIVE_GESTION_VISUALISATION,
Privileges::PLAFONDS_GESTION_VISUALISATION,
Privileges::CENTRES_COUTS_ADMINISTRATION_VISUALISATION,
Privileges::ETAT_SORTIE_ADMINISTRATION_VISUALISATION,
Privileges::TYPE_INTERVENTION_VISUALISATION,
Privileges::MODULATEUR_VISUALISATION,
Privileges::ODF_TYPES_DIPLOME_VISUALISATION,
],
'assertion' => Assertion\GestionAssertion::class,
],
......
<?php
namespace Application;
use Application\Provider\Privilege\Privileges;
use UnicaenAuth\Guard\PrivilegeController;
return [
'router' => [
'routes' => [
'groupe-type-formation' => [
'type' => 'Literal',
'options' => [
'route' => '/groupe-type-formation',
'defaults' => [
'controller' => 'Application\Controller\GroupeTypeFormation',
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'delete' => [
'type' => 'Segment',
'options' => [
'route' => '/delete/:groupe-type-formation',
'constraints' => [
'groupe-type-formation' => '[0-9]*',
],
'defaults' => [
'action' => 'delete',
],
],
],
'saisie' => [
'type' => 'Segment',
'options' => [
'route' => '/saisie/[:groupe-type-formation]',
'constraints' => [
'groupe-type-formation' => '[0-9]*',
],
'defaults' => [
'action' => 'saisie',
],
],
],
'type-formation-delete' => [
'type' => 'Segment',
'options' => [
'route' => '/type-formation-delete/:type-formation',
'constraints' => [
'type-formation' => '[0-9]*',
],
'defaults' => [
'action' => 'type-formation-delete',
],
],
],
'type-formation-saisie' => [
'type' => 'Segment',
'options' => [
'route' => '/type-formation-saisie/:groupe-type-formation[/:type-formation]',
'constraints' => [
'groupe-type-formation' => '[0-9]*',
'type-formation' => '[0-9]*',
],
'defaults' => [
'action' => 'type-formation-saisie',
],
],
],
],
],
],
],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'groupe-type-formation' => [
'label' => 'Diplômes',
'icon' => 'fa fa-graduation-cap',
'route' => 'groupe-type-formation',
'resource' => PrivilegeController::getResourceId('Application\Controller\GroupeTypeFormation', 'index'),
'order' => 80,
'border-color' => '#BBCF55',
],
],
],
],
],
],
],
'bjyauthorize' => [
'guards' => [
PrivilegeController::class => [
[
'controller' => 'Application\Controller\GroupeTypeFormation',
'action' => ['index'],
'privileges' => Privileges::ODF_TYPES_DIPLOME_EDITION,
],
[
'controller' => 'Application\Controller\GroupeTypeFormation',
'action' => ['saisie', 'delete', 'type-formation-saisie', 'type-formation-delete'],
'privileges' => Privileges::ODF_TYPES_DIPLOME_EDITION,
],
],
],
],
'controllers' => [
'invokables' => [
'Application\Controller\GroupeTypeFormation' => Controller\GroupeTypeFormationController::class,
],
],
'service_manager' => [
'invokables' => [
Service\GroupeTypeFormationService::class => Service\GroupeTypeFormationService::class,
Service\GroupeTypeFormationService::class => Service\TypeFormationService::class,
],
],
'view_helpers' => [
],
'form_elements' => [
'invokables' => [
Form\GroupeTypeFormation\TypeFormationSaisieForm::class => Form\GroupeTypeFormation\TypeFormationSaisieForm::class,
Form\GroupeTypeFormation\GroupeTypeFormationSaisieForm::class => Form\GroupeTypeFormation\GroupeTypeFormationSaisieForm::class,
],
],
];
<?php
namespace Application\Controller;
use Application\Entity\Db\GroupeTypeFormation;
use Application\Service\Traits\GroupeTypeFormationServiceAwareTrait;
use Application\Entity\Db\TypeFormation;
use Application\Service\Traits\TypeFormationServiceAwareTrait;
use Application\Exception\DbException;
use Application\Form\GroupeTypeFormation\Traits\GroupeTypeFormationSaisieFormAwareTrait;
use Application\Form\GroupeTypeFormation\Traits\TypeFormationSaisieFormAwareTrait;
use UnicaenApp\View\Model\MessengerViewModel;
class GroupeTypeFormationController extends AbstractController
{
use GroupeTypeFormationServiceAwareTrait;
use TypeFormationServiceAwareTrait;
use GroupeTypeFormationSaisieFormAwareTrait;
use TypeFormationSaisieFormAwareTrait;
public function indexAction()
{
$this->em()->getFilters()->enable('historique')->init([
GroupeTypeFormation::class,
]);
$this->em()->getFilters()->enable('historique')->init([
TypeFormation::class,
]);
$groupeTypeFormations = $this->getServiceGroupeTypeFormation()->getList();
$typeFormations = $this->getServiceTypeFormation()->getList();
return compact('groupeTypeFormations', 'typeFormations');
}
public function saisieAction()
{
/* @var $groupeTypeFormation GroupeTypeFormation */
$groupeTypeFormation = $this->getEvent()->getParam('groupe-type-formation');
$form = $this->getFormGroupeTypeFormationSaisie();
if (empty($groupeTypeFormation)) {
$title = 'Création d\'une nouvelle GroupeTypeFormation';
$groupeTypeFormation = $this->getServiceGroupeTypeFormation()->newEntity();
} else {
$title = 'Édition d\'une GroupeTypeFormation';
}
$form->bindRequestSave($groupeTypeFormation, $this->getRequest(), function (GroupeTypeFormation $fr) {
try {
$this->getServiceGroupeTypeFormation()->save($fr);
$this->flashMessenger()->addSuccessMessage('Enregistrement effectué');
} catch (\Exception $e) {
$e = DbException::translate($e);
$this->flashMessenger()->addErrorMessage($e->getMessage() . ':' . $fr->getId());
}
});
return compact('form', 'title');
}
public function deleteAction()
{
$groupeTypeFormation = $this->getEvent()->getParam('groupe-type-formation');
try {
$this->getServiceGroupeTypeFormation()->delete($groupeTypeFormation);
$this->flashMessenger()->addSuccessMessage("GroupeTypeFormation supprimée avec succès.");
} catch (\Exception $e) {
$this->flashMessenger()->addErrorMessage(DbException::translate($e)->getMessage());
}
return new MessengerViewModel(compact('groupeTypeFormation'));
}
public function typeFormationSaisieAction()
{
/* @var $groupeTypeFormation GroupeTypeFormation */
/* @var $typeFormation TypeFormation */
$groupeTypeFormation = $this->getEvent()->getParam('groupe-type-formation');
$typeFormation = $this->getEvent()->getParam('type-formation');
$form = $this->getFormTypeFormationSaisie();
if (empty($typeFormation)) {
$title = 'Création d\'un nouveau type de formation';
$typeFormation = $this->getServiceTypeFormation()->newEntity()
->setGroupe($groupeTypeFormation);
$typeFormation->setServiceStatutaire(true);
} else {
$title = 'Édition d\'un Type de Formation';
}
$form->bindRequestSave($typeFormation, $this->getRequest(), function (TypeFormation $tf) {
try {
$this->getServiceTypeFormation()->save($tf);
$this->flashMessenger()->addSuccessMessage('Enregistrement effectué');
} catch (\Exception $e) {
$e = DbException::translate($e);
$this->flashMessenger()->addErrorMessage($e->getMessage() . ':' . $tf->getId());
}
});
return compact('form', 'title');
}
public function typeFormationDeleteAction()
{
/* @var $typeFormation TypeFormation */
$typeFormation = $this->getEvent()->getParam('type-formation');
try {
$this->getServiceTypeFormation()->delete($typeFormation);
$this->flashMessenger()->addSuccessMessage("Type de Formation supprimée avec succès.");
} catch (\Exception $e) {
$this->flashMessenger()->addErrorMessage(DbException::translate($e)->getMessage());
}
return new MessengerViewModel(compact('type de formation'));
}
}
......@@ -165,9 +165,9 @@ class TypeFormation implements HistoriqueAwareInterface, ImportAwareInterface
/**
* @param bool $serviceStatutaire
*
* @return FonctionReferentiel
* @return TypeFormation
*/
public function setServiceStatutaire(bool $serviceStatutaire): FonctionReferentiel
public function setServiceStatutaire(bool $serviceStatutaire): TypeFormation
{
$this->serviceStatutaire = $serviceStatutaire;
......
<?php
namespace Application\Form\GroupeTypeFormation;
use Application\Form\AbstractForm;
use Zend\Form\Element\Csrf;
use Zend\Stdlib\Hydrator\HydratorInterface;
use Application\Service\Traits\SourceServiceAwareTrait;
/**
* Description of GroupeTypeFormationSaisieForm
*
* @author ZVENIGOROSKY Alexandre <alexandre.zvenigorosky@unicaen.fr>
*/
class GroupeTypeFormationSaisieForm extends AbstractForm
{
use SourceServiceAwareTrait;
public function init()
{
$hydrator = new GroupeTypeFormationHydrator();
$this->setHydrator($hydrator);
$this->setAttribute('action', $this->getCurrentUrl());
$this->add([
'name' => 'libelle-court',
'options' => [
'label' => "Libelle Court",
],
'type' => 'Text',
]);
$this->add([
'name' => 'libelle-long',
'options' => [
'label' => "Libelle Long",
],
'type' => 'Text',
]);
$this->add([
'name' => 'ordre',
'options' => [
'label' => "Ordre",
],
'type' => 'Text',
]);
$this->add([
'name' => 'pertinence-niveau',
'options' => [
'label' => "Pertinence Niveau",
],
'type' => 'Text',
]);
$this->add([
'name' => 'source-code',
'options' => [
'label' => "Source Code",
],
'type' => 'Text',
]);
$this->add([
'name' => 'source',
'options' => [
'label' => 'Source2',
],
'attributes' => [
'class' => 'selectpicker',
'data-live-search' => 'true',
],
'type' => 'Select',
]);
$this->get('source')
->setValueOptions(\UnicaenApp\Util::collectionAsOptions($this->getServiceSource()->getList()));
$this->add(new Csrf('security'));
$this->add([
'name' => 'submit',
'type' => 'Submit',
'attributes' => [
'value' => "Enregistrer",
'class' => 'btn btn-primary',
],
]);
return $this;
}
/**
* Should return an array specification compatible with
* {@link Zend\InputFilter\Factory::createInputFilter()}.
*
* @return array
*/
public function getInputFilterSpecification()
{
return [
'libelle-court' => [
'required' => true,
],
'libelle-long' => [
'required' => true,
],
'ordre' => [
'required' => true,
],
'pertinence-niveau' => [
'required' => true,
],
'source' => [
'required' => true,
],
];
}
}
class GroupeTypeFormationHydrator implements HydratorInterface
{
use SourceServiceAwareTrait;
/**
* Hydrate $object with the provided $data.
*
* @param array $data
* @param \Application\Entity\Db\GroupeTypeFormation $object
*
* @return object
*/
public function hydrate(array $data, $object)
{
$object->setLibelleCourt($data['libelle-court']);
$object->setLibelleLong($data['libelle-long']);
$object->setOrdre($data['ordre']);
$object->setPertinenceNiveau($data['pertinence-niveau']);
$object->setSourceCode($data['source-code']);
if (array_key_exists('source', $data)) {
$object->setSource($this->getServiceSource()->get($data['source']));
}
return $object;
}
/**
* Extract values from an object
*
* @param \Application\Entity\Db\GroupeTypeFormation $object
*
* @return array
*/
public function extract($object)
{
$data = [
'id' => $object->getId()
,'libelle-court' => $object->getLibelleCourt()
,'libelle-long' => $object->getLibelleLong()
,'ordre' => $object->getOrdre()
,'pertinence-niveau' => $object->getPertinenceNiveau()
,'source-code' => $object->getSourceCode()
,'source' => ($s = $object->getSource()) ? $s->getId() : null,
];
return $data;
}
}
\ No newline at end of file
<?php
namespace Application\Form\GroupeTypeFormation\Traits;
use Application\Form\GroupeTypeFormation\GroupeTypeFormationSaisieForm;
/**
* Description of GroupeTypeFormationSaisieFormAwareTrait
*
* @author UnicaenCode
*/
trait GroupeTypeFormationSaisieFormAwareTrait
{
/**
* @var GroupeTypeFormationSaisieForm
*/
private $formGroupeTypeFormationSaisie;
/**
* @param GroupeTypeFormationSaisieForm $formGroupeTypeFormationSaisie
*
* @return self
*/
public function setFormGroupeTypeFormationSaisie(GroupeTypeFormationSaisieForm $formGroupeTypeFormationSaisie)
{
$this->formGroupeTypeFormationSaisie = $formGroupeTypeFormationSaisie;
return $this;
}
/**
* Retourne un nouveau formulaire ou fieldset systématiquement, sauf si ce dernier a été fourni manuellement.
*
* @return GroupeTypeFormationSaisieForm
*/
public function getFormGroupeTypeFormationSaisie()
{
if (!empty($this->formGroupeTypeFormationSaisie)) {
return $this->formGroupeTypeFormationSaisie;
}
return \Application::$container->get('FormElementManager')->get(GroupeTypeFormationSaisieForm::class);
}
}
<?php
namespace Application\Form\GroupeTypeFormation\Traits;
use Application\Form\GroupeTypeFormation\TypeFormationSaisieForm;
/**
* Description of TypeFormationSaisieFormAwareTrait
*
* @author UnicaenCode
*/
trait TypeFormationSaisieFormAwareTrait
{
/**
* @var TypeFormationSaisieForm
*/
private $formTypeFormationSaisie;
/**
* @param TypeFormationSaisieForm $formTypeFormationSaisie
*
* @return self
*/
public function setFormTypeFormationSaisie(TypeFormationSaisieForm $formTypeFormationSaisie)
{
$this->formTypeFormationSaisie = $formTypeFormationSaisie;
return $this;
}
/**
* Retourne un nouveau formulaire ou fieldset systématiquement, sauf si ce dernier a été fourni manuellement.
*
* @return TypeFormationSaisieForm
*/
public function getFormTypeFormationSaisie()
{
if (!empty($this->formTypeFormationSaisie)) {
return $this->formTypeFormationSaisie;