Skip to content
Snippets Groups Projects
Commit 9211e7b4 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Merge branch 'develop' of https://git.unicaen.fr/open-source/OSE

parents 0fc9ebf9 07495afa
No related branches found
No related tags found
No related merge requests found
...@@ -31,17 +31,6 @@ return [ ...@@ -31,17 +31,6 @@ return [
], ],
], ],
], ],
'index2' => [
'type' => 'Segment',
'options' => [
'route' => '/index2/:structure',
'constraints' => [
],
'defaults' => [
'action' => 'index2',
],
],
],
'delete' => [ 'delete' => [
'type' => 'Segment', 'type' => 'Segment',
'options' => [ 'options' => [
...@@ -81,7 +70,7 @@ return [ ...@@ -81,7 +70,7 @@ return [
'label' => 'Structure', 'label' => 'Structure',
'icon' => 'fa fa-graduation-cap', 'icon' => 'fa fa-graduation-cap',
'route' => 'structure', 'route' => 'structure',
'resource' => PrivilegeController::getResourceId('Application\Controller\Structure', 'index2'), 'resource' => PrivilegeController::getResourceId('Application\Controller\Structure', 'index'),
'order' => 80, 'order' => 80,
'border-color' => '#BBCF55', 'border-color' => '#BBCF55',
], ],
...@@ -102,7 +91,7 @@ return [ ...@@ -102,7 +91,7 @@ return [
PrivilegeController::class => [ PrivilegeController::class => [
[ [
'controller' => 'Application\Controller\Structure', 'controller' => 'Application\Controller\Structure',
'action' => ['index2'], 'action' => ['index'],
'privileges' => Privileges::STRUCTURES_ADMINISTRATION_VISUALISATION, 'privileges' => Privileges::STRUCTURES_ADMINISTRATION_VISUALISATION,
], ],
[ [
......
...@@ -20,7 +20,7 @@ class StructureController extends AbstractController ...@@ -20,7 +20,7 @@ class StructureController extends AbstractController
use StructureSaisieFormAwareTrait; use StructureSaisieFormAwareTrait;
public function index2Action() public function indexAction()
{ {
$this->em()->getFilters()->enable('historique')->init([ $this->em()->getFilters()->enable('historique')->init([
Structure::class, Structure::class,
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
<field name="libelleLong" type="string" column="LIBELLE_LONG" length="60" nullable="false"/> <field name="libelleLong" type="string" column="LIBELLE_LONG" length="60" nullable="false"/>
<field name="sourceCode" type="string" column="SOURCE_CODE" length="100" nullable="true"/> <field name="sourceCode" type="string" column="SOURCE_CODE" length="100" nullable="true"/>
<field name="enseignement" type="boolean" column="ENSEIGNEMENT" nullable="false"/> <field name="enseignement" type="boolean" column="ENSEIGNEMENT" nullable="false"/>
<field name="plafondReferentiel" type="float" column="PLAFOND_REFERENTIEL" precision="126" scale="0" nullable="true"/>
<field name="affAdresseContrat" type="boolean" column="AFF_ADRESSE_CONTRAT" nullable="false"/>
<many-to-one field="source" target-entity="UnicaenImport\Entity\Db\Source"> <many-to-one field="source" target-entity="UnicaenImport\Entity\Db\Source">
<join-columns> <join-columns>
<join-column name="SOURCE_ID" referenced-column-name="ID"/> <join-column name="SOURCE_ID" referenced-column-name="ID"/>
......
...@@ -64,6 +64,21 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw ...@@ -64,6 +64,21 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw
*/ */
protected $enseignement; protected $enseignement;
/**
* @var float
*/
protected $plafondReferentiel;
/**
* @var boolean
*/
protected $affAdresseContrat;
/**
* @var string
*/
protected $sourceCode;
function __construct() function __construct()
...@@ -166,6 +181,28 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw ...@@ -166,6 +181,28 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw
} }
/**
* @return string
*/
public function getSourceCode()
{
return $this->sourceCode;
}
/**
* @param string $sourceCode
*
* @return Structure
*/
public function setSourceCode($sourceCode)
{
$this->sourceCode = $sourceCode;
return $this;
}
/** /**
* Add elementPedagogique * Add elementPedagogique
...@@ -283,6 +320,58 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw ...@@ -283,6 +320,58 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw
/**
* Set plafondReferentiel
*
* @param string $plafondReferentiel
*
* @return Structure
*/
public function setPlafondReferentiel($plafondReferentiel)
{
$this->plafondReferentiel = $plafondReferentiel;
return $this;
}
/**
* Get plafondReferentiel
*
* @return float
*/
public function getPlafondReferentiel()
{
return $this->plafondReferentiel;
}
/**
* @return bool
*/
public function isAffAdresseContrat()
{
return $this->affAdresseContrat;
}
/**
* @param bool $affAdresseContrat
*
* @return Structure
*/
public function setAffAdresseContrat($affAdresseContrat)
{
$this->affAdresseContrat = $affAdresseContrat;
return $this;
}
/** /**
* Retourne la représentation littérale de cet objet. * Retourne la représentation littérale de cet objet.
* *
...@@ -342,6 +431,8 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw ...@@ -342,6 +431,8 @@ class Structure implements HistoriqueAwareInterface, ResourceInterface, ImportAw
$this->setEntityManager($objectManager); $this->setEntityManager($objectManager);
} }
function __sleep() function __sleep()
{ {
return []; return [];
......
<?php
namespace Application\Form\Structure;
use Application\Form\AbstractForm;
use Zend\Form\Element\Csrf;
use Zend\Stdlib\Hydrator\HydratorInterface;
use Application\Service\Traits\SourceServiceAwareTrait;
use Application\Filter\FloatFromString;
use Application\Filter\StringFromFloat;
/**
* Description of StructureSaisieForm
*
* @author ZVENIGOROSKY Alexandre <alexandre.zvenigorosky@unicaen.fr>
*/
class StructureSaisieForm extends AbstractForm
{
use SourceServiceAwareTrait;
public function init()
{
$hydrator = new StructureHydrator();
$this->setHydrator($hydrator);
$this->setAttribute('action', $this->getCurrentUrl());
$this->add([
'name' => 'code',
'options' => [
'label' => "Code",
],
'type' => 'Text',
]);
$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' => 'enseignement',
'options' => [
'label' => "Enseignement",
],
'type' => 'Checkbox',
]);
$this->add([
'name' => 'source-code',
'options' => [
'label' => "Source Code",
],
'type' => 'Text',
]);
$this->add([
'name' => 'plafond-referentiel',
'options' => [
'label' => "Plafond Referentiel",
],
'type' => 'Text',
]);
$this->add([
'name' => 'aff-adresse-contrat',
'options' => [
'label' => "Aff Adresse Contrat",
],
'type' => 'Checkbox',
]);
$this->add([
'name' => 'source',
'options' => [
'label' => 'Source',
],
'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 [
'code' => [
'required' => true,
],
'libelle-court' => [
'required' => true,
],
'libelle-long' => [
'required' => true,
],
'enseignement' => [
'required' => true,
],
'source' => [
'required' => true,
],
'aff-adresse-contrat' => [
'required' => true,
],
'plafond-referentiel' => [
'required' => true,
'validators' => [
new \Zend\Validator\Callback([
'messages' => [\Zend\Validator\Callback::INVALID_VALUE => '%value% doit être >= 0'],
'callback' => function ($value) {
if ($value == null) return true;
return (FloatFromString::run($value) >= 0.0 ? true : false);
}]),
],
],
];
}
}
class StructureHydrator implements HydratorInterface
{
use SourceServiceAwareTrait;
/**
* Hydrate $object with the provided $data.
*
* @param array $data
* @param \Application\Entity\Db\Structure $object
*
* @return object
*/
public function hydrate(array $data, $object)
{
$object->setCode($data['code']);
$object->setLibelleCourt($data['libelle-court']);
$object->setLibelleLong($data['libelle-long']);
$object->setEnseignement($data['enseignement']);
$object->setSourceCode($data['source-code']);
$object->setPlafondReferentiel(FloatFromString::run($data['plafond-referentiel']));
$object->setAffAdresseContrat($data['aff-adresse-contrat']);
if (array_key_exists('source', $data)) {
$object->setSource($this->getServiceSource()->get($data['source']));
}
return $object;
}
/**
* Extract values from an object
*
* @param \Application\Entity\Db\Structure $object
*
* @return array
*/
public function extract($object)
{
$data = [
'id' => $object->getId()
, 'code' => $object->getCode()
, 'libelle-court' => $object->getLibelleCourt()
, 'libelle-long' => $object->getLibelleLong()
, 'enseignement' => $object->isEnseignement()
, 'source-code' => $object->getSourceCode()
, 'plafond-referentiel' => StringFromFloat::run($object->getPlafondReferentiel())
, 'aff-adresse-contrat' => $object->isAffAdresseContrat()
, 'source' => ($s = $object->getSource()) ? $s->getId() : null,
];
return $data;
}
}
<?php
namespace Application\Form\Structure\Traits;
use Application\Form\Structure\StructureSaisieForm;
/**
* Description of StructureSaisieFormAwareTrait
*
* @author UnicaenCode
*/
trait StructureSaisieFormAwareTrait
{
/**
* @var StructureSaisieForm
*/
private $formStructureSaisie;
/**
* @param StructureSaisieForm $formStructureSaisie
*
* @return self
*/
public function setFormStructureSaisie(StructureSaisieForm $formStructureSaisie)
{
$this->formStructureSaisie = $formStructureSaisie;
return $this;
}
/**
* Retourne un nouveau formulaire ou fieldset systématiquement, sauf si ce dernier a été fourni manuellement.
*
* @return StructureSaisieForm
*/
public function getFormStructureSaisie()
{
if (!empty($this->formStructureSaisie)) {
return $this->formStructureSaisie;
}
return \Application::$container->get('FormElementManager')->get(StructureSaisieForm::class);
}
}
<?php
/**
* @var $this \Application\View\Renderer\PhpRenderer
* @var $structures \Application\Entity\Db\Structure[]
*/
use Application\Provider\Privilege\Privileges;
use UnicaenApp\Util;
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("STRUCTUREs");
$canEdit = $this->isAllowed(Privileges::getResourceId(Privileges::STRUCTURES_ADMINISTRATION_EDITION));
?>
<h1 class="page-header">STRUCTUREs</h1>
<table class="table table-bordered table-sort">
<thead>
<th style="word-wrap: break-word ; ">Code</th>
<th style="word-wrap: break-word ; ">Libelle Court</th>
<th style="word-wrap: break-word ; ">Libelle Long</th>
<th style="word-wrap: break-word ; ">Enseignement</th>
<th style="word-wrap: break-word ; ">Source</th>
<th style="word-wrap: break-word ; ">Source Code</th>
<th style="word-wrap: break-word ; ">Plafond Referentiel</th>
<th style="word-wrap: break-word ; ">Aff Adresse Contrat</th>
<?php if ($canEdit) echo '<th>Actions</th>' ?>
</thead>
<tbody>
<?php foreach ($structures as $fr): ?>
<tr>
<td style="word-wrap: break-word ; "><?= $fr->getCode() ?></td>
<td style="word-wrap: break-word ; "><?= $fr->getLibelleCourt() ?></td>
<td style="word-wrap: break-word ; "><?= $fr->getLibelleLong() ?></td>
<td style="word-wrap: break-word ; "><?= affBooleen($fr->isEnseignement()) ?></td>
<td style="word-wrap: break-word ; "><?= $fr->getSource() ?></td>
<td style="word-wrap: break-word ; "><?= $fr->getSourceCode() ?></td>
<td style="word-wrap: break-word ; "><?= ($fr->getPlafondReferentiel()) ? Util::formattedNumber($fr->getPlafondReferentiel()) :'' ?></td>
<td style="word-wrap: break-word ; "><?= affBooleen($fr->isAffAdresseContrat()) ?></td>
<?php if ($canEdit) { ?>
<td style="text-align:center;width:1px;white-space: nowrap">
<a class="ajax-modal" data-event="structure-saisie"
href="<?= $this->url('structure/saisie', ['structure' => $fr->getId()]) ?>"
title="Modifier la Structure">
<span class="glyphicon glyphicon-edit"></span></a>
<a class="pop-ajax"
href="<?= $this->url('structure/delete', ['structure' => $fr->getId()]) ?>"
title="Supprimer la Structure"
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>
</a>
</td>
<?php } ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if ($canEdit): ?>
<a class="btn btn-primary ajax-modal" data-event="structure-saisie"
href="<?= $this->url('structure/saisie') ?>"
title="Ajouter une STRUCTURE">
<span class="glyphicon glyphicon-edit"></span>
Ajouter une STRUCTURE</a>
<script type="text/javascript">
$(function () {
$("body").on("structure-saisie", function (event, data) {
window.location.reload();
});
});
</script>
<?php endif ?>
<?php
/**
* @var $this \Application\View\Renderer\PhpRenderer
* @var $form \Application\Form\Structure\StructureSaisieForm
*/
echo $this->messenger()->addCurrentMessagesFromFlashMessenger();
echo $this->form()->openTag($form); ?>
<div class="row">
<div class="col-md-3">
<?= $this->formControlGroup($form->get('code')) ?>
</div>
<div class="col-md-9">
<?= $this->formControlGroup($form->get('libelle-court')) ?>
</div>
</div>
<div class="row">
<div class="col-md-9">
<?= $this->formControlGroup($form->get('libelle-long')) ?>
</div>
</div>
<div class="row">
<div class="col-md-3">
<?= $this->formControlGroup($form->get('enseignement')) ?>
</div>
<div class="col-md-6">
<?= $this->formControlGroup($form->get('source')) ?>
</div>
<div class="col-md-3">
<?= $this->formControlGroup($form->get('source-code')); ?>
</div>
</div>
<div class="row">
<div class="col-md-6">
<?= $this->formControlGroup($form->get('aff-adresse-contrat')) ?>
</div>
<div class="col-md-6">
<?= $this->formControlGroup($form->get('plafond-referentiel')) ?>
</div>
</div>
<?php
echo $this->formSubmit($form->get('submit'));
echo $this->formControlGroup($form->get('security'));
echo $this->form()->closeTag();
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment