Commit 2e1ad914 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Mise en place fonction reporting

parent 884c0fdc
......@@ -48,6 +48,15 @@ return [
],
],
],
'reporting' => [
'type' => 'Literal',
'options' => [
'route' => '/reporting',
'defaults' => [
'action' => 'reporting',
],
],
],
],
],
],
......@@ -68,21 +77,26 @@ return [
'border-color' => '#9B9B9B',
'order' => 120,
'pages' => [
'annees' => [
'annees' => [
'label' => "Années",
'route' => 'parametres/annees',
'resource' => PrivilegeController::getResourceId('Application\Controller\Parametre', 'annees'),
],
'generaux' => [
'generaux' => [
'label' => "Paramètres généraux",
'route' => 'parametres/generaux',
'resource' => PrivilegeController::getResourceId('Application\Controller\Parametre', 'generaux'),
],
'campagnes-saisie' => [
'campagnes-saisie' => [
'label' => "Campagnes de saisie des services",
'route' => 'parametres/campagnes-saisie',
'resource' => PrivilegeController::getResourceId('Application\Controller\Parametre', 'campagnes-saisie'),
],
'reporting-instance' => [
'label' => "Reporting instance OSE",
'route' => 'parametres/reporting',
'resource' => PrivilegeController::getResourceId('Application\Controller\Parametre', 'reporting'),
],
],
],
],
......@@ -98,7 +112,7 @@ return [
PrivilegeController::class => [
[
'controller' => 'Application\Controller\Parametre',
'action' => ['index'],
'action' => ['index', 'reporting'],
'privileges' => [
Privileges::PARAMETRES_GENERAL_VISUALISATION,
],
......
......@@ -2,17 +2,21 @@
namespace Application\Controller;
use Application\Entity\Db\Indicateur;
use Application\Form\CampagneSaisieFieldset;
use Application\Form\Traits\CampagneSaisieFormAwareTrait;
use Application\Form\Traits\ParametresFormAwareTrait;
use Application\Provider\Privilege\Privileges;
use Application\Service\Traits\AnneeServiceAwareTrait;
use Application\Service\Traits\CampagneSaisieServiceAwareTrait;
use Application\Service\Traits\ContextServiceAwareTrait;
use Application\Service\Traits\EtablissementServiceAwareTrait;
use Application\Service\Traits\ParametresServiceAwareTrait;
use Application\Service\Traits\TypeIntervenantServiceAwareTrait;
use Application\Service\Traits\TypeVolumeHoraireServiceAwareTrait;
use UnicaenApp\View\Helper\AppInfos;
use Zend\View\Model\JsonModel;
use Zend\View\Renderer\PhpRenderer;
/**
......@@ -31,6 +35,7 @@ class ParametreController extends AbstractController
use CampagneSaisieServiceAwareTrait;
use CampagneSaisieFormAwareTrait;
use ContextServiceAwareTrait;
public function indexAction()
......@@ -44,25 +49,23 @@ class ParametreController extends AbstractController
{
$canEdit = $this->isAllowed(Privileges::getResourceId(Privileges::PARAMETRES_ANNEES_EDITION));
if ($this->getRequest()->isPost()){
if ($this->getRequest()->isPost()) {
$anneeId = $this->params()->fromPost('annee');
$annee = $this->getServiceAnnee()->get($anneeId);
$annee = $this->getServiceAnnee()->get($anneeId);
$annee->setActive(!$annee->isActive());
$this->getServiceAnnee()->save($annee);
return new JsonModel([
'message' => 'Action effectuée',
'status' => 'success',
'status' => 'success',
]);
}else{
} else {
$annees = $this->getServiceAnnee()->getList();
return compact('annees', 'canEdit');
}
}
......@@ -82,8 +85,8 @@ class ParametreController extends AbstractController
$campagne = $this->getServiceCampagneSaisie()->getBy($ti, $tvh);
$form = $this->getFormCampagneSaisie();
if (!$canEdit){
foreach( $form->getElements() as $element ){
if (!$canEdit) {
foreach ($form->getElements() as $element) {
$element->setAttribute('disabled', true);
}
}
......@@ -91,13 +94,13 @@ class ParametreController extends AbstractController
$form->bind($campagne);
$forms[$ti->getId()][$tvh->getId()] = $form;
if ($canEdit && $ti == $typeIntervenant && $tvh == $typeVolumeHoraire){
$form->requestSave($this->getRequest(), function() use ($campagne){
if (!$campagne->getDateDebut() && !$campagne->getDateFin() && !$campagne->getMessageIntervenant() && !$campagne->getMessageAutres()){
if ($canEdit && $ti == $typeIntervenant && $tvh == $typeVolumeHoraire) {
$form->requestSave($this->getRequest(), function () use ($campagne) {
if (!$campagne->getDateDebut() && !$campagne->getDateFin() && !$campagne->getMessageIntervenant() && !$campagne->getMessageAutres()) {
$this->getServiceCampagneSaisie()->delete($campagne);
}elseif(!$campagne->getMessageIntervenant() && ($campagne->getDateDebut() || $campagne->getDateFin() || $campagne->getMessageAutres())) {
} elseif (!$campagne->getMessageIntervenant() && ($campagne->getDateDebut() || $campagne->getDateFin() || $campagne->getMessageAutres())) {
$this->flashMessenger()->addErrorMessage('Il est obligatoire de saisir un message à destination des intervenants');
}else{
} else {
$this->getServiceCampagneSaisie()->save($campagne);
}
});
......@@ -160,4 +163,27 @@ class ParametreController extends AbstractController
return compact('form', 'canEdit');
}
public function reportingAction()
{
$version = $this->appInfos()->getVersion();
$reporting['version'] = $this->appInfos()->getVersion();
$reporting['php_version'] = phpversion();
$reporting['php_extension'] = get_loaded_extensions();
$reporting['agent'] = $_SERVER['HTTP_USER_AGENT'];
$select = "SELECT table_name FROM user_tables";
$connection = $this->em()->getConnection();
$tables = $connection->fetchAll($select);
$reporting['bdd_nb_tables'] = count($tables);
$reporting['bdd_tables'] = [];
foreach ($tables as $table) {
$reporting['bdd_tables'][] = $table['TABLE_NAME'];
}
return compact('reporting');
}
}
\ No newline at end of file
<h1 class="page-header">Reporting instance OSE</h1>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Variables</th>
<th>Valeurs</th>
</tr>
</thead>
<tbody>
<tr>
<td>Version de OSE</td>
<td><?= $reporting['version']; ?></td>
</tr>
<tr>
<td>Version de PHP</td>
<td><?= $reporting['php_version']; ?></td>
</tr>
<tr>
<td>Extensions PHP</td>
<td><?= implode(', ', $reporting['php_extension']); ?></td>
</tr>
<tr>
<td>Système exploitation et navigateur</td>
<td><?= $reporting['agent']; ?></td>
</tr>
<tr>
<td>Nombre de tables</td>
<td><?= $reporting['bdd_nb_tables']; ?></td>
</tr>
<tr>
<td>Liste des tables</td>
<td>
<ul>
<?php foreach ($reporting['bdd_tables'] as $table): ?>
<li><?= $table ?></li>
<?php endforeach; ?>
</ul>
</td>
</tr>
</tbody>
</table>
Markdown is supported
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