Commit 6f61fa4a 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 f9ac0c87
......@@ -81,6 +81,7 @@ return [
Privileges::ETAT_SORTIE_ADMINISTRATION_VISUALISATION,
Privileges::TYPE_INTERVENTION_VISUALISATION,
Privileges::MODULATEUR_VISUALISATION,
Privileges::MOTIFS_MODIFICATION_SERVICE_DU_VISUALISATION,
],
'assertion' => Assertion\GestionAssertion::class,
],
......
<?php
namespace Application;
use Application\Provider\Privilege\Privileges;
use UnicaenAuth\Guard\PrivilegeController;
return [
'router' => [
'routes' => [
'motif-modification-service' => [
'type' => 'Literal',
'options' => [
'route' => '/motif-modification-service',
'defaults' => [
'controller' => 'Application\Controller\MotifModificationService',
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'delete' => [
'type' => 'Segment',
'options' => [
'route' => '/delete/:motif-modification-service',
'constraints' => [
'motif-modification-service' => '[0-9]*',
],
'defaults' => [
'action' => 'delete',
],
],
],
'saisie' => [
'type' => 'Segment',
'options' => [
'route' => '/saisie/[:motif-modification-service]',
'constraints' => [
'motif-modification-service' => '[0-9]*',
],
'defaults' => [
'action' => 'saisie',
],
],
],
],
],
],
],
'navigation' => [
'default' => [
'home' => [
'pages' => [
'administration' => [
'pages' => [
'motif-modification-service' => [
'label' => 'Motif de Modification du Service Dû',
'icon' => 'fa fa-graduation-cap',
'route' => 'motif-modification-service',
'resource' => PrivilegeController::getResourceId('Application\Controller\MotifModificationService', 'index'),
'order' => 80,
'border-color' => '#BBCF55',
],
],
],
],
],
],
],
'bjyauthorize' => [
'guards' => [
PrivilegeController::class => [
[
'controller' => 'Application\Controller\MotifModificationService',
'action' => ['index'],
'privileges' => Privileges::MOTIFS_MODIFICATION_SERVICE_DU_VISUALISATION,
],
[
'controller' => 'Application\Controller\MotifModificationService',
'action' => ['saisie','delete'],
'privileges' => Privileges::MOTIFS_MODIFICATION_SERVICE_DU_EDITION,
],
],
],
],
'controllers' => [
'invokables' => [
'Application\Controller\MotifModificationService' => Controller\MotifModificationServiceController::class,
],
],
'service_manager' => [
'invokables' => [
Service\MotifModificationServiceService::class => Service\MotifModificationServiceService::class,
],
],
'view_helpers' => [
],
'form_elements' => [
'invokables' => [
Form\MotifModificationService\MotifModificationServiceSaisieForm::class => Form\MotifModificationService\MotifModificationServiceSaisieForm::class,
],
],
];
<?php
namespace Application\Controller;
use Application\Service\Traits\MotifModificationServiceServiceAwareTrait;
use Application\Entity\Db\MotifModificationServiceDu;
use Application\Form\MotifModificationService\Traits\MotifModificationServiceSaisieFormAwareTrait;
use UnicaenApp\View\Model\MessengerViewModel;
class MotifModificationServiceController extends AbstractController
{
use MotifModificationServiceServiceAwareTrait;
use MotifModificationServiceSaisieFormAwareTrait;
public function indexAction()
{
$this->em()->getFilters()->enable('historique')->init([
MotifModificationServiceDu::class,
]);
$motifModificationServices = $this->getServiceMotifModificationService()->getList();
return compact('motifModificationServices');
}
public function saisieAction()
{
/* @var $motifModificationService MotifModificationServiceDu */
$motifModificationServiceDu = $this->getEvent()->getParam('motif-modification-service');
$form = $this->getFormMotifModificationServiceSaisie();
if (empty($motifModificationServiceDu)) {
$title = 'Création d\'un nouveau Motif de Modification de Service Dû';
$motifModificationServiceDu = $this->getServiceMotifModificationService()->newEntity();
} else {
$title = 'Édition d\'un Motif de Modification de Service Dû';
}
$form->bindRequestSave($motifModificationServiceDu, $this->getRequest(), function (MotifModificationServiceDu $fr) {
try {
$this->getServiceMotifModificationService()->save($fr);
$this->flashMessenger()->addSuccessMessage('Enregistrement effectué');
} catch (\Exception $e) {
$this->flashMessenger()->addErrorMessage($this->translate($e));
}
});
return compact('form', 'title');
}
public function deleteAction()
{
$motifModificationServiceDu = $this->getEvent()->getParam('motif-modification-service');
try {
$this->getServiceMotifModificationService()->delete($motifModificationServiceDu);
$this->flashMessenger()->addSuccessMessage("Motif de Modification de Service supprimé avec succès.");
} catch (\Exception $e) {
$this->flashMessenger()->addErrorMessage(DbException::translate($e)->getMessage());
}
return new MessengerViewModel(compact('motifModificationService'));
}
}
......@@ -8,8 +8,10 @@
</indexes>
<id name="id" type="integer" column="ID">
<generator strategy="SEQUENCE"/>
<sequence-generator sequence-name="MOTIF_MODIFICATION_SERV_ID_SEQ" allocation-size="1"/>
</id>
<field name="code" type="string" column="CODE" length="3" nullable="false"/>
<field name="multiplicateur" type="integer" column="MULTIPLICATEUR" precision="38" nullable="false"/>
<field name="histoCreation" type="datetime" column="HISTO_CREATION" nullable="false"/>
<field name="histoDestruction" type="datetime" column="HISTO_DESTRUCTION" nullable="true"/>
<field name="histoModification" type="datetime" column="HISTO_MODIFICATION" nullable="false"/>
......
......@@ -32,6 +32,10 @@ class MotifModificationServiceDu implements HistoriqueAwareInterface
*/
protected $decharge;
/**
* @var float
*/
protected $multiplicateur;
/**
......@@ -124,8 +128,32 @@ class MotifModificationServiceDu implements HistoriqueAwareInterface
return $this;
}
/**
* Set multiplicateur
*
* @param int $multiplicateur
*
* @return MotifModificationService
*/
public function setMultiplicateur($multiplicateur)
{
$this->multiplicateur = $multiplicateur;
return $this;
}
/**
* Get mutiplicateur
*
* @return int
*/
public function getMultiplicateur()
{
return $this->multiplicateur;
}
/**
* Retourne la représentation littérale de cet objet.
*
......
<?php
namespace Application\Form\MotifModificationService;
use Application\Form\AbstractForm;
use Zend\Form\Element\Csrf;
use Zend\Stdlib\Hydrator\HydratorInterface;
/**
* Description of MotifModificationServiceSaisieForm
*
* @author ZVENIGOROSKY Alexandre <alexandre.zvenigorosky@unicaen.fr>
*/
class MotifModificationServiceSaisieForm extends AbstractForm
{
public function init()
{
$hydrator = new MotifModificationServiceHydrator();
$this->setHydrator($hydrator);
$this->setAttribute('action', $this->getCurrentUrl());
$this->add([
'name' => 'code',
'options' => [
'label' => "Code",
],
'type' => 'Text',
]);
$this->add([
'name' => 'libelle',
'options' => [
'label' => "Libelle",
],
'type' => 'Text',
]);
$this->add([
'name' => 'multiplicateur',
'options' => [
'label' => "Multiplicateur",
],
'type' => 'Text',
]);
$this->add([
'name' => 'decharge',
'options' => [
'label' => "Decharge",
],
'type' => 'Checkbox',
]);
$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 [
'code' => [
'required' => true,
],
'libelle' => [
'required' => true,
],
'multiplicateur' => [
'required' => true,
],
'decharge' => [
'required' => true,
],
];
}
}
class MotifModificationServiceHydrator implements HydratorInterface
{
/**
* Hydrate $object with the provided $data.
*
* @param array $data
* @param \Application\Entity\Db\MotifModificationServiceDu $object
*
* @return object
*/
public function hydrate(array $data, $object)
{
$object->setCode($data['code']);
$object->setLibelle($data['libelle']);
$object->setMultiplicateur($data['multiplicateur']);
$object->setDecharge($data['decharge']);
return $object;
}
/**
* Extract values from an object
*
* @param \Application\Entity\Db\MotifModificationServiceDu $object
*
* @return array
*/
public function extract($object)
{
$data = [
'id' => $object->getId()
, 'code' => $object->getCode()
, 'libelle' => $object->getLibelle()
, 'multiplicateur' => $object->getMultiplicateur()
, 'decharge' => $object->getDecharge()
,
];
return $data;
}
}
\ No newline at end of file
<?php
namespace Application\Form\MotifModificationService\Traits;
use Application\Form\MotifModificationService\MotifModificationServiceSaisieForm;
/**
* Description of MotifModificationServiceSaisieFormAwareTrait
*
* @author UnicaenCode
*/
trait MotifModificationServiceSaisieFormAwareTrait
{
/**
* @var MotifModificationServiceSaisieForm
*/
private $formMotifModificationServiceSaisie;
/**
* @param MotifModificationServiceSaisieForm $formMotifModificationServiceSaisie
*
* @return self
*/
public function setFormMotifModificationServiceSaisie(MotifModificationServiceSaisieForm $formMotifModificationServiceSaisie)
{
$this->formMotifModificationServiceSaisie = $formMotifModificationServiceSaisie;
return $this;
}
/**
* Retourne un nouveau formulaire ou fieldset systématiquement, sauf si ce dernier a été fourni manuellement.
*
* @return MotifModificationServiceSaisieForm
*/
public function getFormMotifModificationServiceSaisie()
{
if (!empty($this->formMotifModificationServiceSaisie)) {
return $this->formMotifModificationServiceSaisie;
}
return \Application::$container->get('FormElementManager')->get(MotifModificationServiceSaisieForm::class);
}
}
<?php
namespace Application\Service;
use Doctrine\ORM\QueryBuilder;
/**
* Description of MotifModificationServiceDu
*
*/
class MotifModificationServiceService extends AbstractEntityService
{
/**
* retourne la classe des entit?s
*
* @return string
* @throws RuntimeException
*/
public function getEntityClass()
{
return \Application\Entity\Db\MotifModificationServiceDu::class;
}
/**
* Retourne l'alias d'entit? courante
*
* @return string
*/
public function getAlias()
{
return 'fr';
}
public function getList(QueryBuilder $qb = null, $alias = null)
{
list($qb, $alias) = $this->initQuery();
return parent::getList($qb, $alias);
}
}
<?php
namespace Application\Service\Traits;
use Application\Service\MotifModificationServiceService;
/**
* Description of MotifModificationServiceAwareTrait
*
* @author UnicaenCode
*/
trait MotifModificationServiceServiceAwareTrait
{
/**
* @var MotifModificationServiceService
*/
private $serviceMotifModificationService;
/**
* @param MotifModificationServiceService $serviceMotifModificationService
*
* @return self
*/
public function setServiceMotifModificationService(MotifModificationServiceService $serviceMotifModificationService)
{
$this->serviceMotifModificationService = $serviceMotifModificationService;
return $this;
}
/**
* @return MotifModificationServiceService
*/
public function getServiceMotifModificationService()
{
if (empty($this->serviceMotifModificationService)) {
$this->serviceMotifModificationService = \Application::$container->get(MotifModificationServiceService::class);
}
return $this->serviceMotifModificationService;
}
}
<?php
/**
* @var $this \Application\View\Renderer\PhpRenderer
* @var $motifModificationServices \Application\Entity\Db\MotifModificationService[]
*/
use Application\Provider\Privilege\Privileges;
function affBooleen($flg)
{
// affiche booléen avec des glypheIcon
return ($flg ? '<span class="glyphicon glyphicon-ok text-success"></span>' : '<span class="glyphicon glyphicon-remove text-danger refuse"></span>');
}
$this->headTitle()->append("MOTIF_MODIFICATION_SERVICEs");
$canEdit = $this->isAllowed(Privileges::getResourceId(Privileges::MOTIFS_MODIFICATION_SERVICE_DU_EDITION));
?>
<h1 class="page-header">MOTIF_MODIFICATION_SERVICEs</h1>
<table class="table table-bordered table-sort">
<thead>
<th style="word-wrap: break-word ; ">Code</th>
<th style="word-wrap: break-word ; ">Libelle</th>
<th style="word-wrap: break-word ; ">Multiplicateur</th>
<th style="word-wrap: break-word ; ">Decharge</th>
<?php if ($canEdit) echo '<th>Actions</th>' ?>
</thead>
<tbody>
<?php foreach ($motifModificationServices as $fr): ?>
<tr>
<td style="word-wrap: break-word ; "><?= $fr->getCode() ?></td>
<td style="word-wrap: break-word ; "><?= $fr->getLibelle() ?></td>
<td style="word-wrap: break-word ; "><?= $fr->getMultiplicateur() ?></td>
<td style="word-wrap: break-word ; "><?= affBooleen($fr->getDecharge()) ?></td>
<?php if ($canEdit) { ?>
<td style="text-align:center;width:1px;white-space: nowrap">
<a class="ajax-modal" data-event="motif-modification-service-saisie"
href="<?= $this->url('motif-modification-service/saisie', ['motif-modification-service' => $fr->getId()]) ?>"
title="Modifier la MotifModificationService">
<span class="glyphicon glyphicon-edit"></span></a>
<a class="pop-ajax"
href="<?= $this->url('motif-modification-service/delete', ['motif-modification-service' => $fr->getId()]) ?>"
title="Supprimer la MotifModificationService"
data-content="<p class='lead text-danger'><strong>Attention!</strong> Confirmez-vous cette suppression ?</p>"
data-confirm="true"
data-confirm-button="Oui"
data-cancel-button="Non"
data-submit-reload="true"
>
<span class="glyphicon glyphicon-remove"></span>