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

Suppression de la notion de type de dotation

parent 62afcae1
......@@ -25,10 +25,15 @@ $ddlConfig = [
\BddAdmin\Ddl\DdlTrigger::class => $ddlConfig[\BddAdmin\Ddl\DdlTrigger::class],
]; // Pour le moment, travail uniquement sur ces 3 structures de données. Pour les autres, cela viendra plus tard.
$ddlConfig[\BddAdmin\Ddl\DdlView::class]['includes'] = [ // afin d'être sûr qu'elles seront supprimées, car devenues inutiles
'V_FORMULE_LOCAL_I_PARAMS',
'V_FORMULE_LOCAL_VH_PARAMS',
];
$ddlConfig[\BddAdmin\Ddl\DdlView::class]['includes'][] = 'V_FORMULE_LOCAL_I_PARAMS';
$ddlConfig[\BddAdmin\Ddl\DdlView::class]['includes'][] = 'V_FORMULE_LOCAL_VH_PARAMS';
if (!isset($ddlConfig[\BddAdmin\Ddl\DdlTable::class]['includes'])){ // provisoire, en attendant que les tables soient gérées automatiquement
$ddlConfig[\BddAdmin\Ddl\DdlTable::class]['includes'] = [];
}
$ddlConfig[\BddAdmin\Ddl\DdlTable::class]['includes'][] = 'TYPE_DOTATION';
/* Mise en place du logging en mode console */
......
......@@ -40,7 +40,6 @@ return [
'Application\Entity\Db\Interfaces\RoleAwareInterface' => __DIR__ . '/src/Application/Entity/Db/Interfaces/RoleAwareInterface.php',
'Application\Entity\Db\Interfaces\AnneeAwareInterface' => __DIR__ . '/src/Application/Entity/Db/Interfaces/AnneeAwareInterface.php',
'Application\Entity\Db\Interfaces\PerimetreAwareInterface' => __DIR__ . '/src/Application/Entity/Db/Interfaces/PerimetreAwareInterface.php',
'Application\Entity\Db\Interfaces\TypeDotationAwareInterface' => __DIR__ . '/src/Application/Entity/Db/Interfaces/TypeDotationAwareInterface.php',
'Application\Entity\Db\Interfaces\StatutIntervenantAwareInterface' => __DIR__ . '/src/Application/Entity/Db/Interfaces/StatutIntervenantAwareInterface.php',
'Application\Entity\Db\Interfaces\VIndicAttenteValidRefAutreAwareInterface' => __DIR__ . '/src/Application/Entity/Db/Interfaces/VIndicAttenteValidRefAutreAwareInterface.php',
'Application\Entity\Db\Interfaces\TypeVolumeHoraireAwareInterface' => __DIR__ . '/src/Application/Entity/Db/Interfaces/TypeVolumeHoraireAwareInterface.php',
......@@ -180,7 +179,6 @@ return [
'Application\Entity\Db\Traits\VolumeHoraireEnsAwareTrait' => __DIR__ . '/src/Application/Entity/Db/Traits/VolumeHoraireEnsAwareTrait.php',
'Application\Entity\Db\Traits\PieceJointeAwareTrait' => __DIR__ . '/src/Application/Entity/Db/Traits/PieceJointeAwareTrait.php',
'Application\Entity\Db\Traits\NotificationIndicateurAwareTrait' => __DIR__ . '/src/Application/Entity/Db/Traits/NotificationIndicateurAwareTrait.php',
'Application\Entity\Db\Traits\TypeDotationAwareTrait' => __DIR__ . '/src/Application/Entity/Db/Traits/TypeDotationAwareTrait.php',
'Application\Entity\Db\Traits\GroupeTypeFormationAwareTrait' => __DIR__ . '/src/Application/Entity/Db/Traits/GroupeTypeFormationAwareTrait.php',
'Application\Entity\Db\Traits\TblAgrementAwareTrait' => __DIR__ . '/src/Application/Entity/Db/Traits/TblAgrementAwareTrait.php',
'Application\Entity\Db\Traits\TypeModulateurAwareTrait' => __DIR__ . '/src/Application/Entity/Db/Traits/TypeModulateurAwareTrait.php',
......@@ -308,7 +306,6 @@ return [
'Application\Entity\Db\TblService' => __DIR__ . '/src/Application/Entity/Db/TblService.php',
'Application\Entity\Db\ElementModulateur' => __DIR__ . '/src/Application/Entity/Db/ElementModulateur.php',
'Application\Entity\Db\WfEtape' => __DIR__ . '/src/Application/Entity/Db/WfEtape.php',
'Application\Entity\Db\TypeDotation' => __DIR__ . '/src/Application/Entity/Db/TypeDotation.php',
'Application\Entity\Db\TypePieceJointeStatut' => __DIR__ . '/src/Application/Entity/Db/TypePieceJointeStatut.php',
'Application\Entity\Db\VServiceValide' => __DIR__ . '/src/Application/Entity/Db/VServiceValide.php',
'Application\Entity\Db\TblClotureRealise' => __DIR__ . '/src/Application/Entity/Db/TblClotureRealise.php',
......
......@@ -86,44 +86,6 @@ return [
],
],
],
'type-dotation' => [
'type' => 'Segment',
'options' => [
'route' => '/type-dotation',
'constraints' => [
],
'defaults' => [
'action' => 'type-dotation',
],
],
'may_terminate' => true,
],
'type-dotation-saisie' => [
'type' => 'Segment',
'options' => [
'route' => '/type-dotation-saisie[/:typeDotation]',
'constraints' => [
'typeDotation' => '[0-9]*',
],
'defaults' => [
'action' => 'type-dotation-saisie',
],
],
'may_terminate' => true,
],
'type-dotation-delete' => [
'type' => 'Segment',
'options' => [
'route' => '/type-dotation-delete/:typeDotation',
'constraints' => [
'typeDotation' => '[0-9]*',
],
'defaults' => [
'action' => 'type-dotation-delete',
],
],
'may_terminate' => true,
],
],
],
],
......@@ -161,13 +123,6 @@ return [
'route' => 'budget/export',
'resource' => PrivilegeController::getResourceId('Application\Controller\Budget', 'export'),
],
'type-dotation' => [
'label' => 'Types de dotation',
'title' => 'Types de dotations',
'route' => 'budget/type-dotation',
'withtarget' => true,
'resource' => PrivilegeController::getResourceId('Application\Controller\Budget', 'type-dotation'),
],
],
],
],
......@@ -259,7 +214,6 @@ return [
'form_elements' => [
'invokables' => [
Form\Budget\DotationSaisieForm::class => Form\Budget\DotationSaisieForm::class,
Form\Budget\TypeDotationSaisieForm::class => Form\Budget\TypeDotationSaisieForm::class,
],
],
'service_manager' => [
......@@ -267,7 +221,6 @@ return [
Service\TypeRessourceService::class => Service\TypeRessourceService::class,
Service\DotationService::class => Service\DotationService::class,
Assertion\BudgetAssertion::class => Assertion\BudgetAssertion::class,
Service\TypeDotationService::class => Service\TypeDotationService::class,
],
],
'controllers' => [
......
......@@ -15,10 +15,7 @@ use Application\Service\Traits\StructureServiceAwareTrait;
use Application\Service\Traits\TypeRessourceServiceAwareTrait;
use UnicaenApp\View\Model\CsvModel;
use Zend\Form\Element\Select;
use Application\Entity\Db\TypeDotation;
use Application\Service\Traits\TypeDotationServiceAwareTrait;
use Application\Service\Traits\SourceServiceAwareTrait;
use Application\Form\Budget\Traits\TypeDotationSaisieFormAwareTrait;
/**
......@@ -34,8 +31,6 @@ class BudgetController extends AbstractController
use DotationSaisieFormAwareTrait;
use AnneeServiceAwareTrait;
use MiseEnPaiementServiceAwareTrait;
use TypeDotationServiceAwareTrait;
use TypeDotationSaisieFormAwareTrait;
use SourceServiceAwareTrait;
......@@ -337,55 +332,4 @@ class BudgetController extends AbstractController
return $structureElement;
}
public function typeDotationAction()
{
$this->em()->getFilters()->enable('historique')->init([
TypeDotation::class,
]);
$typeDotations = $this->getServiceTypeDotation()->getList();
return compact('typeDotations');
}
public function typeDotationSaisieAction()
{
/* @var $typeDotation TypeDotation */
$typeDotation = $this->getEvent()->getParam('typeDotation');
$form = $this->getFormTypeDotationSaisie();
if (empty($typeDotation)) {
$title = 'Création d\'un nouveau type de dotation';
$typeDotation = $this->getServiceTypeDotation()->newEntity();
} else {
$title = 'Édition d\'un type de dotation';
}
$form->bindRequestSave($typeDotation,$this->getRequest(),function(TypeDotation $td){
try {
$this->getServiceTypeDotation()->save($td);
$this->flashMessenger()->addSuccessMessage('Enregistrement effectué');
} catch (\Exception $e) {
$this->flashMessenger()->addErrorMessage($this->translate($e));
}
});
$title = 'Saisie d\'un type de dotation';
return compact('title', 'form');
}
public function typeDotationDeleteAction()
{
/* @var $typeDotation TypeDotation */
$typeDotation = $this->getEvent()->getParam('typeDotation');
try {
$this->getServiceTypeDotation()->delete($typeDotation);
$this->flashMessenger()->addSuccessMessage("Type de dotation supprimé avec succès.");
} catch (\Exception $e) {
$this->flashMessenger()->addErrorMessage($this->translate($e));
}
return new \UnicaenApp\View\Model\MessengerViewModel(compact('typeDotation'));
}
}
\ No newline at end of file
<?php
namespace Application\Entity\Db\Interfaces;
use Application\Entity\Db\TypeDotation;
/**
* Description of TypeDotationAwareInterface
*
* @author UnicaenCode
*/
interface TypeDotationAwareInterface
{
/**
* @param TypeDotation $typeDotation
* @return self
*/
public function setTypeDotation( TypeDotation $typeDotation = null );
/**
* @return TypeDotation
*/
public function getTypeDotation();
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Application\Entity\Db\TypeDotation" table="TYPE_DOTATION">
<indexes>
<index name="IDX_FAEA07E7AA6D6F1E" columns="TYPE_RESSOURCE_ID"/>
<index name="IDX_FAEA07E759860CDC" columns="HISTO_CREATEUR_ID"/>
<index name="IDX_FAEA07E77E9E2204" columns="HISTO_DESTRUCTEUR_ID"/>
<index name="IDX_FAEA07E763F06898" columns="HISTO_MODIFICATEUR_ID"/>
<index name="IDX_FAEA07E7E9B3446E" columns="SOURCE_ID"/>
</indexes>
<id name="id" type="integer" column="ID">
<generator strategy="SEQUENCE"/>
</id>
<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"/>
<field name="libelle" type="string" column="LIBELLE" length="200" nullable="false"/>
<field name="sourceCode" type="string" column="SOURCE_CODE" length="100" nullable="true"/>
<many-to-one field="source" target-entity="UnicaenImport\Entity\Db\Source">
<join-columns>
<join-column name="SOURCE_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="histoModificateur" target-entity="Application\Entity\Db\Utilisateur">
<join-columns>
<join-column name="HISTO_MODIFICATEUR_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="histoDestructeur" target-entity="Application\Entity\Db\Utilisateur">
<join-columns>
<join-column name="HISTO_DESTRUCTEUR_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="histoCreateur" target-entity="Application\Entity\Db\Utilisateur">
<join-columns>
<join-column name="HISTO_CREATEUR_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<many-to-one field="typeRessource" target-entity="Application\Entity\Db\TypeRessource">
<join-columns>
<join-column name="TYPE_RESSOURCE_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
</entity>
</doctrine-mapping>
<?php
namespace Application\Entity\Db\Traits;
use Application\Entity\Db\TypeDotation;
/**
* Description of TypeDotationAwareTrait
*
* @author UnicaenCode
*/
trait TypeDotationAwareTrait
{
/**
* @var TypeDotation
*/
private $typeDotation;
/**
* @param TypeDotation $typeDotation
* @return self
*/
public function setTypeDotation( TypeDotation $typeDotation = null )
{
$this->typeDotation = $typeDotation;
return $this;
}
/**
* @return TypeDotation
*/
public function getTypeDotation()
{
return $this->typeDotation;
}
}
\ No newline at end of file
<?php
namespace Application\Entity\Db;
use Application\Entity\Db\Traits\TypeRessourceAwareTrait;
use UnicaenApp\Entity\HistoriqueAwareInterface;
use UnicaenApp\Entity\HistoriqueAwareTrait;
use UnicaenImport\Entity\Db\Interfaces\ImportAwareInterface;
use UnicaenImport\Entity\Db\Traits\ImportAwareTrait;
/**
* TypeDotation
*/
class TypeDotation implements HistoriqueAwareInterface, ImportAwareInterface
{
use HistoriqueAwareTrait;
use ImportAwareTrait;
use TypeRessourceAwareTrait;
const CODE_DOTATION_INITIALE = 'dotation-initiale';
/**
* @var string
*/
private $libelle;
/**
* @var integer
*/
private $id;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set libelle
*
* @param string $libelle
*
* @return TypeDotation
*/
public function setLibelle($libelle)
{
$this->libelle = $libelle;
return $this;
}
/**
* Get libelle
*
* @return string
*/
public function getLibelle()
{
return $this->libelle;
}
public function isDotationInitiale()
{
return $this->getSourceCode() == self::CODE_DOTATION_INITIALE;
}
}
<?php
namespace Application\Form\Budget\Traits;
use Application\Form\Budget\TypeDotationSaisieForm;
/**
* Description of TypeDotationSaisieFormAwareTrait
*
* @author UnicaenCode
*/
trait TypeDotationSaisieFormAwareTrait
{
/**
* @var TypeDotationSaisieForm
*/
private $formTypeDotationSaisie;
/**
* @param TypeDotationSaisieForm $formTypeDotationSaisie
*
* @return self
*/
public function setFormTypeDotationSaisie(TypeDotationSaisieForm $formTypeDotationSaisie)
{
$this->formTypeDotationSaisie = $formTypeDotationSaisie;
return $this;
}
/**
* Retourne un nouveau formulaire ou fieldset systématiquement, sauf si ce dernier a été fourni manuellement.
*
* @return TypeDotationSaisieForm
*/
public function getFormTypeDotationSaisie()
{
if (!empty($this->formTypeDotationSaisie)) {
return $this->formTypeDotationSaisie;
}
return \Application::$container->get('FormElementManager')->get(TypeDotationSaisieForm::class);
}
}
\ No newline at end of file
<?php
namespace Application\Form\Budget;
use Application\Entity\Db\Traits\TypeRessourceAwareTrait;
use Application\Form\AbstractForm;
use Application\Service\Traits\TypeDotationServiceAwareTrait;
use Application\Service\Traits\TypeRessourceServiceAwareTrait;
use Zend\Form\Element\Csrf;
use Application\Service\Traits\ContextServiceAwareTrait;
use Zend\Stdlib\Hydrator\HydratorInterface;
use UnicaenApp\Service\EntityManagerAwareInterface;
use UnicaenImport\Entity\Db\Source;
/**
* Description of TypeDotationSaisieForm
*
* @author ZVENIGOROSKY Alexandre <alexandre.zvenigorosky at unicaen.fr>
*/
class TypeDotationSaisieForm extends AbstractForm
{
use TypeDotationServiceAwareTrait;
use ContextServiceAwareTrait;
use TypeRessourceServiceAwareTrait;
public function init()
{
$hydrator=new TypeDotationHydrator();
$hydrator->setServiceTypeRessource($this->getServiceTypeRessource());
$this->setHydrator($hydrator);
$this->setAttribute('action', $this->getCurrentUrl());
$this->add([
'name' => 'id',
'type' => 'hidden',
]);
$this->add([
'name' => 'libelle',
'options' => [
'label' => "Libelle",
],
'type' => 'Text'
]);
$this->add([
'name' => 'source-code',
'options' => [
'label' => "Code",
],
'type' => 'Text',
]);
$this->add([
'name' => 'type-ressource',
'options' => [
'label' => 'Type de ressource',
],
'type' => 'Select',
]);
$this->add([
'name' => 'submit',
'type' => 'Submit',
'attributes' => [
'value' => 'Enregistrer',
'class' => 'btn btn-primary',
],
]);
// peuplement des types de ressource
$this->get('type-ressource')
->setValueOptions(\UnicaenApp\Util::collectionAsOptions($this->getServiceTypeRessource()->getList()));
return $this;
}
/**
* Should return an array specification compatible with
* {@link Zend\InputFilter\Factory::createInputFilter()}.
*
* @return array
*/
public function getInputFilterSpecification()
{
return [
'libelle' => [
'required' => true,
],
'source-code' => [
'required' => false,
],
'type-ressource' => [
'required' => true,
],
];
}
}
class TypeDotationHydrator implements HydratorInterface
{
use TypeRessourceAwareTrait;
use TypeRessourceServiceAwareTrait;
/**
* Hydrate $object with the provided $data.
*
* @param array $data
* @param \Application\Entity\Db\TypeDotation $object
*
* @return object
*/
public function hydrate(array $data, $object)
{
$object->setLibelle($data['libelle']);
$object->setSourceCode($data['source-code']);
$object->setSource($this->getTypeRessource());
if (array_key_exists('type-ressource', $data)) {
$object->setTypeRessource($this->getServiceTypeRessource()->get($data['type-ressource']));
}
return $object;
}
/**
* Extract values from an object
*
* @param \Application\Entity\Db\TypeDotation $object
*
* @return array
*/
public function extract($object)
{
$data = [
'id' => $object->getId(),
'libelle' => $object->getLibelle(),
'source-code' => $object->getSourceCode(),
'type-ressource' => ($s = $object->getTypeRessource()) ? $s->getId() : null,
];
return $data;
}
}
\ No newline at end of file