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

Refonte du processus intervenant

parent de260d03
No related branches found
No related tags found
No related merge requests found
Showing
with 390 additions and 327 deletions
...@@ -104,3 +104,15 @@ INSERT INTO parametre ( ...@@ -104,3 +104,15 @@ INSERT INTO parametre (
sysdate, sysdate,
(select id from utilisateur where username='oseappli') (select id from utilisateur where username='oseappli')
); );
INSERT INTO PRIVILEGE (ID, CATEGORIE_ID, CODE, LIBELLE, ORDRE)
SELECT
privilege_id_seq.nextval id,
(SELECT id FROM CATEGORIE_PRIVILEGE WHERE code = t1.c ) CATEGORIE_ID,
t1.p CODE,
t1.l LIBELLE,
(SELECT count(*) FROM PRIVILEGE WHERE categorie_id = (SELECT id FROM CATEGORIE_PRIVILEGE WHERE code = t1.c )) + rownum ORDRE
FROM (
SELECT 'enseignement' c, 'import-intervenant-previsionnel-agenda' p, 'Import service prévisionnel depuis agenda' l FROM dual
UNION ALL SELECT 'enseignement' c, 'import-intervenant-realise-agenda' p, 'Import service réalisé depuis agenda' l FROM dual
) t1;
\ No newline at end of file
...@@ -8,13 +8,7 @@ INSERT INTO CATEGORIE_PRIVILEGE ( ...@@ -8,13 +8,7 @@ INSERT INTO CATEGORIE_PRIVILEGE (
'Plafonds' 'Plafonds'
); );
INSERT INTO PRIVILEGE ( INSERT INTO PRIVILEGE (ID, CATEGORIE_ID, CODE, LIBELLE, ORDRE)
ID,
CATEGORIE_ID,
CODE,
LIBELLE,
ORDRE
)
SELECT SELECT
privilege_id_seq.nextval id, privilege_id_seq.nextval id,
(SELECT id FROM CATEGORIE_PRIVILEGE WHERE code = t1.c ) CATEGORIE_ID, (SELECT id FROM CATEGORIE_PRIVILEGE WHERE code = t1.c ) CATEGORIE_ID,
...@@ -23,27 +17,12 @@ SELECT ...@@ -23,27 +17,12 @@ SELECT
(SELECT count(*) FROM PRIVILEGE WHERE categorie_id = (SELECT id FROM CATEGORIE_PRIVILEGE WHERE code = t1.c )) + rownum ORDRE (SELECT count(*) FROM PRIVILEGE WHERE categorie_id = (SELECT id FROM CATEGORIE_PRIVILEGE WHERE code = t1.c )) + rownum ORDRE
FROM ( FROM (
SELECT 'enseignement' c, 'import-intervenant-previsionnel-agenda' p, 'Import service prévisionnel depuis agenda' l FROM dual
UNION ALL SELECT 'enseignement' c, 'import-intervenant-realise-agenda' p, 'Import service réalisé depuis agenda' l FROM dual
SELECT 'import' c, 'sources-visualisation' p, 'Sources (visualisation)' l FROM dual
union SELECT 'import' c, 'sources-edition' p, 'Sources (édition)' l FROM dual
--UNION SELECT 'modulateur' c, 'edition' p, 'Édition' l FROM dual
--UNION SELECT 'chargens' c, 'formation-choix-edition' p, 'Édition des formations (choix liens)' l FROM dual
/* UNION SELECT 'chargens' c, 'seuil-etablissement-edition' p, 'Édition des seuil (établissement)' l FROM dual
UNION SELECT 'chargens' c, 'seuil-composante-visualisation' p, 'Visualisation des seuils (composantes)' l FROM dual
UNION SELECT 'chargens' c, 'seuil-composante-edition' p, 'Édition des seuil (composantes)' l FROM dual
UNION SELECT 'chargens' c, 'scenario-visualisation' p, 'Visualisation des scénarios' l FROM dual
UNION SELECT 'chargens' c, 'scenario-duplication' p, 'Duplication de scénario' l FROM dual
UNION SELECT 'chargens' c, 'scenario-composante-edition' p, 'Édition des scénarios (composantes)' l FROM dual
UNION SELECT 'chargens' c, 'formation-visualisation' p, 'Visualisation des formations' l FROM dual
UNION SELECT 'chargens' c, 'formation-effectifs-edition' p, 'Édition des formations (effectifs)' l FROM dual
UNION SELECT 'chargens' c, 'formation-assiduite-edition' p, 'Édition des formations (assiduité)' l FROM dual
UNION SELECT 'chargens' c, 'formation-seuils-edition' p, 'Édition des formations (seuils)' l FROM dual*/
) t1; ) t1;
delete from privilege where id = 123; delete from privilege where code = 'import-intervenant-agenda';
/* Liste... */ /* Liste... */
select select
......
...@@ -279,6 +279,14 @@ return [ ...@@ -279,6 +279,14 @@ return [
], ],
'assertion' => Assertion\ServiceAssertion::class, 'assertion' => Assertion\ServiceAssertion::class,
], ],
/*[
'controller' => 'Application\Controller\Service',
'action' => ['import-agenda'],
'privileges' => [
Privileges::ENSEIGNEMENT_IMPORT_INTERVENANT_PREVISIONNEL_AGENDA,
],
'assertion' => Assertion\ServiceAssertion::class,
],*/
[ [
'controller' => 'Application\Controller\Service', 'controller' => 'Application\Controller\Service',
'action' => ['validation'], 'action' => ['validation'],
......
...@@ -172,6 +172,10 @@ class ServiceAssertion extends AbstractAssertion ...@@ -172,6 +172,10 @@ class ServiceAssertion extends AbstractAssertion
return $this->assertEnseignements($role); return $this->assertEnseignements($role);
break; break;
case 'Application\Controller\Service.importAgenda':
return $this->assertImportAgenda($role);
break;
} }
return true; return true;
...@@ -189,6 +193,14 @@ class ServiceAssertion extends AbstractAssertion ...@@ -189,6 +193,14 @@ class ServiceAssertion extends AbstractAssertion
protected function assertImportAgenda(Role $role)
{
return true;
//return $this->assertEtapeAtteignable(WfEtape::CODE_SERVICE_SAISIE);
}
protected function assertServiceVisualisation(Role $role, Service $service) protected function assertServiceVisualisation(Role $role, Service $service)
{ {
$wfEtape = $this->getWorkflowEtape($service->getTypeVolumeHoraire(), 'saisie'); $wfEtape = $this->getWorkflowEtape($service->getTypeVolumeHoraire(), 'saisie');
......
...@@ -89,7 +89,7 @@ class IntervenantController extends AbstractController ...@@ -89,7 +89,7 @@ class IntervenantController extends AbstractController
]); ]);
$critere = $this->params()->fromPost('critere'); $critere = $this->params()->fromPost('critere');
$intervenants = $this->getProcessusIntervenant()->rechercher($critere, 21); $intervenants = $this->getProcessusIntervenant()->recherche()->rechercher($critere, 21);
return compact('intervenants'); return compact('intervenants');
} }
...@@ -478,7 +478,7 @@ class IntervenantController extends AbstractController ...@@ -478,7 +478,7 @@ class IntervenantController extends AbstractController
/* @var $intervenant \Application\Entity\Db\Intervenant */ /* @var $intervenant \Application\Entity\Db\Intervenant */
if ($intervenant) { if ($intervenant) {
$data = $this->getProcessusIntervenant()->getSuppressionData($intervenant); $data = $this->getProcessusIntervenant()->suppression()->getData($intervenant);
} else { } else {
$data = null; $data = null;
} }
...@@ -488,7 +488,7 @@ class IntervenantController extends AbstractController ...@@ -488,7 +488,7 @@ class IntervenantController extends AbstractController
if ($ids) { if ($ids) {
try { try {
if ($data) $data = $this->getProcessusIntervenant()->deleteRecursive($data, $ids); if ($data) $data = $this->getProcessusIntervenant()->suppression()->deleteRecursive($data, $ids);
if ($intervenant) { if ($intervenant) {
$this->getServiceWorkflow()->calculerTableauxBord(null, $intervenant); $this->getServiceWorkflow()->calculerTableauxBord(null, $intervenant);
} }
......
...@@ -23,7 +23,7 @@ class RechercheController extends AbstractController ...@@ -23,7 +23,7 @@ class RechercheController extends AbstractController
return new JsonModel([]); return new JsonModel([]);
} }
$res = $this->getProcessusIntervenant()->rechercher($term); $res = $this->getProcessusIntervenant()->recherche()->rechercher($term);
$result = []; $result = [];
foreach ($res as $key => $r) { foreach ($res as $key => $r) {
......
...@@ -375,6 +375,16 @@ class ServiceController extends AbstractController ...@@ -375,6 +375,16 @@ class ServiceController extends AbstractController
public function importAgendaPrevisionnelAction()
{
$intervenant = $this->getEvent()->getParam('intervenant');
$this->getServiceService()->setPrevusFromAgenda($intervenant);
return new MessengerViewModel();
}
public function constatationAction() public function constatationAction()
{ {
$this->initFilters(); $this->initFilters();
......
...@@ -4,7 +4,6 @@ namespace Application\Processus\Factory; ...@@ -4,7 +4,6 @@ namespace Application\Processus\Factory;
use Application\Processus\IntervenantProcessus; use Application\Processus\IntervenantProcessus;
use Application\Service\ContextService;
use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface; use Zend\ServiceManager\ServiceLocatorInterface;
...@@ -28,7 +27,6 @@ class IntervenantProcessusFactory implements FactoryInterface ...@@ -28,7 +27,6 @@ class IntervenantProcessusFactory implements FactoryInterface
$processus = new IntervenantProcessus; $processus = new IntervenantProcessus;
$processus->setEntityManager($serviceLocator->get(\Application\Constants::BDD)); $processus->setEntityManager($serviceLocator->get(\Application\Constants::BDD));
$processus->setServiceContext($serviceLocator->get(ContextService::class));
return $processus; return $processus;
} }
......
<?php
namespace Application\Processus\Intervenant;
use Application\Service\Traits\ContextServiceAwareTrait;
use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenApp\Util;
class RechercheProcessus
{
use EntityManagerAwareTrait;
use ContextServiceAwareTrait;
/**
* @param string $critere
* @param integer $limit
*
* @return array
*/
public function rechercher($critere, $limit = 50)
{
if (strlen($critere) < 2) return [];
$anneeId = (int)$this->getServiceContext()->getAnnee()->getId();
$critere = Util::reduce($critere);
$criteres = explode('_', $critere);
$sql = '
WITH vrec AS (
SELECT
i.id,
i.source_code,
i.nom_usuel,
i.nom_patronymique,
i.prenom,
i.date_naissance,
s.libelle_court structure,
c.libelle_long civilite,
i.critere_recherche critere,
i.annee_id
FROM
intervenant i
JOIN structure s ON s.id = i.structure_id
JOIN civilite c ON c.id = i.civilite_id
WHERE
i.histo_destruction IS NULL
UNION ALL
SELECT
null id,
i.source_code,
i.nom_usuel,
i.nom_patronymique,
i.prenom,
i.date_naissance,
s.libelle_court structure,
c.libelle_long civilite,
i.critere_recherche critere,
i.annee_id
FROM
src_intervenant i
JOIN structure s ON s.id = i.structure_id
JOIN civilite c ON c.id = i.civilite_id
)
SELECT * FROM vrec WHERE
rownum <= ' . (int)$limit . ' AND annee_id = ' . $anneeId;
$sqlCri = '';
$criCode = 0;
foreach ($criteres as $c) {
$cc = (int)$c;
if (0 === $cc) {
if ($sqlCri != '') $sqlCri .= ' AND ';
$sqlCri .= 'critere LIKE q\'[%' . $c . '%]\'';
} else {
$criCode = $cc;
}
}
$orc = [];
if ($sqlCri != '') {
$orc[] = '(' . $sqlCri . ')';
}
if ($criCode) {
$orc[] = 'source_code LIKE \'%' . $criCode . '%\'';
}
$orc = implode(' OR ', $orc);
$sql .= ' AND (' . $orc . ') ORDER BY nom_usuel, prenom';
$intervenants = [];
try {
$stmt = $this->getEntityManager()->getConnection()->executeQuery($sql);
while ($r = $stmt->fetch()) {
$intervenants[$r['SOURCE_CODE']] = [
'civilite' => $r['CIVILITE'],
'nom' => $r['NOM_USUEL'],
'prenom' => $r['PRENOM'],
'date-naissance' => new \DateTime($r['DATE_NAISSANCE']),
'structure' => $r['STRUCTURE'],
'numero-personnel' => $r['SOURCE_CODE'],
];
}
} catch (\Exception $e) {
// à traiter si la vue source intervenant n'existe pas!!
}
return $intervenants;
}
}
\ No newline at end of file
<?php
namespace Application\Processus\Intervenant;
use Application\Entity\Db\Intervenant;
use Application\Entity\Db\TblService;
use Application\Service\Traits\IntervenantServiceAwareTrait;
use UnicaenApp\Service\EntityManagerAwareTrait;
class ServiceProcessus
{
use EntityManagerAwareTrait;
use IntervenantServiceAwareTrait;
public function canPrevuToPrevu(Intervenant $intervenant)
{
$intervenant = $this->getServiceIntervenant()->getPrecedent($intervenant);
if (!$intervenant) return false;
$dql = "
SELECT
s
FROM
" . TblService::class . " s
JOIN s.typeVolumeHoraire tvh
WHERE
s.intervenant = :intervenant
AND tvh.code = 'PREVU'
AND s.valide > 0
";
$query = $this->getEntityManager()->createQuery($dql)->setMaxResults(1);
$query->setParameters(compact('intervenant'));
$s = $query->getResult();
return count($s) > 0;
}
}
\ No newline at end of file
...@@ -29,11 +29,8 @@ use Application\Service\Traits\VolumeHoraireServiceAwareTrait; ...@@ -29,11 +29,8 @@ use Application\Service\Traits\VolumeHoraireServiceAwareTrait;
use Application\Service\Traits\VolumeHoraireReferentielServiceAwareTrait; use Application\Service\Traits\VolumeHoraireReferentielServiceAwareTrait;
class SuppressionDataProcessus class SuppressionProcessus
{ {
private static $instance;
use IntervenantAwareTrait; use IntervenantAwareTrait;
use DossierServiceAwareTrait; use DossierServiceAwareTrait;
use ModificationServiceDuServiceAwareTrait; use ModificationServiceDuServiceAwareTrait;
...@@ -61,26 +58,18 @@ class SuppressionDataProcessus ...@@ -61,26 +58,18 @@ class SuppressionDataProcessus
public static function run(Intervenant $intervenant) public function getData(Intervenant $intervenant)
{ {
if (!self::$instance) { $this->setIntervenant($intervenant);
self::$instance = new self;
}
self::$instance->setIntervenant($intervenant); return $this->makeData();
return self::$instance->makeData();
} }
public static function delete(IntervenantSuppressionData $isd, array $ids) public function deleteRecursive(IntervenantSuppressionData $isd, array $ids)
{ {
if (!self::$instance) { return $this->deleteData($isd, $ids);
self::$instance = new self;
}
return self::$instance->deleteData($isd, $ids);
} }
......
...@@ -2,14 +2,9 @@ ...@@ -2,14 +2,9 @@
namespace Application\Processus; namespace Application\Processus;
use Application\Entity\Db\EtatVolumeHoraire; use Application\Processus\Intervenant\RechercheProcessus;
use Application\Entity\Db\Intervenant; use Application\Processus\Intervenant\SuppressionProcessus;
use Application\Entity\Db\TblService; use Application\Processus\Intervenant\ServiceProcessus as IntervenantServiceProcessus;
use Application\Entity\Db\TypeVolumeHoraire;
use Application\Entity\IntervenantSuppressionData;
use Application\Processus\Intervenant\SuppressionDataProcessus;
use Application\Service\Traits\ContextServiceAwareTrait;
use UnicaenApp\Util;
/** /**
...@@ -19,151 +14,54 @@ use UnicaenApp\Util; ...@@ -19,151 +14,54 @@ use UnicaenApp\Util;
*/ */
class IntervenantProcessus extends AbstractProcessus class IntervenantProcessus extends AbstractProcessus
{ {
use ContextServiceAwareTrait;
/** /**
* @param string $critere * @var RechercheProcessus
* @param integer $limit
*
* @return array
*/ */
public function rechercher($critere, $limit = 50) protected $recherche;
{
if (strlen($critere) < 2) return [];
$anneeId = (int)$this->getServiceContext()->getAnnee()->getId();
$critere = Util::reduce($critere);
$criteres = explode('_', $critere);
$sql = '
WITH vrec AS (
SELECT
i.id,
i.source_code,
i.nom_usuel,
i.nom_patronymique,
i.prenom,
i.date_naissance,
s.libelle_court structure,
c.libelle_long civilite,
i.critere_recherche critere,
i.annee_id
FROM
intervenant i
JOIN structure s ON s.id = i.structure_id
JOIN civilite c ON c.id = i.civilite_id
WHERE
i.histo_destruction IS NULL
UNION ALL
SELECT
null id,
i.source_code,
i.nom_usuel,
i.nom_patronymique,
i.prenom,
i.date_naissance,
s.libelle_court structure,
c.libelle_long civilite,
i.critere_recherche critere,
i.annee_id
FROM
src_intervenant i
JOIN structure s ON s.id = i.structure_id
JOIN civilite c ON c.id = i.civilite_id
)
SELECT * FROM vrec WHERE
rownum <= ' . (int)$limit . ' AND annee_id = ' . $anneeId;
$sqlCri = '';
$criCode = 0;
foreach ($criteres as $c) {
$cc = (int)$c;
if (0 === $cc) {
if ($sqlCri != '') $sqlCri .= ' AND ';
$sqlCri .= 'critere LIKE q\'[%' . $c . '%]\'';
} else {
$criCode = $cc;
}
}
$orc = [];
if ($sqlCri != '') {
$orc[] = '(' . $sqlCri . ')';
}
if ($criCode) {
$orc[] = 'source_code LIKE \'%' . $criCode . '%\'';
}
$orc = implode(' OR ', $orc);
$sql .= ' AND (' . $orc . ') ORDER BY nom_usuel, prenom';
$intervenants = [];
try {
$stmt = $this->getEntityManager()->getConnection()->executeQuery($sql);
while ($r = $stmt->fetch()) {
$intervenants[$r['SOURCE_CODE']] = [
'civilite' => $r['CIVILITE'],
'nom' => $r['NOM_USUEL'],
'prenom' => $r['PRENOM'],
'date-naissance' => new \DateTime($r['DATE_NAISSANCE']),
'structure' => $r['STRUCTURE'],
'numero-personnel' => $r['SOURCE_CODE'],
];
}
}catch(\Exception $e){
// à traiter si la vue source intervenant n'existe pas!!
}
return $intervenants;
}
/**
* @var SuppressionProcessus
*/
protected $suppression;
/** /**
* @param Intervenant $intervenant * @var IntervenantServiceProcessus
* @param TypeVolumeHoraire $typeVolumehoraire
* @param EtatVolumeHoraire $etatVolumeHoraire
*
* @return boolean
*/ */
public function hasHeuresEnseignement(Intervenant $intervenant, TypeVolumeHoraire $typeVolumeHoraire, EtatVolumeHoraire $etatVolumeHoraire) protected $service;
{
$heuresCol = $etatVolumeHoraire->isValide() ? 'valide' : 'nbvh';
$dql = "
SELECT
s
FROM
" . TblService::class . " s
WHERE
s.intervenant = :intervenant
AND s.typeVolumeHoraire = :typeVolumeHoraire
AND s.$heuresCol > 0
";
$query = $this->getEntityManager()->createQuery($dql)->setMaxResults(1);
$query->setParameters(compact('intervenant', 'typeVolumeHoraire'));
$s = $query->getResult(); public function recherche(): RechercheProcessus
{
if (!$this->recherche) {
$this->recherche = new RechercheProcessus;
$this->recherche->setEntityManager($this->getEntityManager());
}
return count($s) > 0; return $this->recherche;
} }
public function getSuppressionData(Intervenant $intervenant) public function suppression(): SuppressionProcessus
{ {
return SuppressionDataProcessus::run($intervenant); if (!$this->suppression) {
$this->suppression = new SuppressionProcessus;
}
return $this->suppression;
} }
public function deleteRecursive(IntervenantSuppressionData $isd, array $ids) public function service(): IntervenantServiceProcessus
{ {
return SuppressionDataProcessus::delete($isd, $ids); if (!$this->service) {
$this->service = new IntervenantServiceProcessus;
$this->service->setEntityManager($this->getEntityManager());
}
return $this->service;
} }
} }
\ No newline at end of file
...@@ -71,6 +71,8 @@ class Privileges extends \UnicaenAuth\Provider\Privilege\Privileges { ...@@ -71,6 +71,8 @@ class Privileges extends \UnicaenAuth\Provider\Privilege\Privileges {
const ENSEIGNEMENT_EXPORT_CSV = 'enseignement-export-csv'; const ENSEIGNEMENT_EXPORT_CSV = 'enseignement-export-csv';
const ENSEIGNEMENT_EXPORT_PDF = 'enseignement-export-pdf'; const ENSEIGNEMENT_EXPORT_PDF = 'enseignement-export-pdf';
const ENSEIGNEMENT_EXTERIEUR = 'enseignement-exterieur'; const ENSEIGNEMENT_EXTERIEUR = 'enseignement-exterieur';
const ENSEIGNEMENT_IMPORT_INTERVENANT_PREVISIONNEL_AGENDA = 'enseignement-import-intervenant-previsionnel-agenda';
const ENSEIGNEMENT_IMPORT_INTERVENANT_REALISE_AGENDA = 'enseignement-import-intervenant-realise-agenda';
const ENSEIGNEMENT_VALIDATION = 'enseignement-validation'; const ENSEIGNEMENT_VALIDATION = 'enseignement-validation';
const ENSEIGNEMENT_VISUALISATION = 'enseignement-visualisation'; const ENSEIGNEMENT_VISUALISATION = 'enseignement-visualisation';
const IMPORT_ECARTS = 'import-ecarts'; const IMPORT_ECARTS = 'import-ecarts';
......
...@@ -246,11 +246,7 @@ class Liste extends AbstractViewHelper ...@@ -246,11 +246,7 @@ class Liste extends AbstractViewHelper
$out .= '</div>'; $out .= '</div>';
$out .= '</div>'; $out .= '</div>';
} elseif ($this->prevuToPrevu){ } elseif ($this->prevuToPrevu){
$iPrec = $this->getServiceIntervenant()->getPrecedent($this->prevuToPrevu); if ($this->getProcessusIntervenant()->service()->canPrevuToPrevu($this->prevuToPrevu )) {
$tvh = $this->getServiceTypeVolumeHoraire()->getPrevu();
$evh = $this->getServiceEtatVolumeHoraire()->getValide();
$hasHeures = $iPrec ? $this->getProcessusIntervenant()->hasHeuresEnseignement($iPrec, $tvh, $evh ) : false;
if ($hasHeures) {
$attribs = [ $attribs = [
'class' => 'btn btn-warning prevu-to-prevu-show', 'class' => 'btn btn-warning prevu-to-prevu-show',
'data-toggle' => 'modal', 'data-toggle' => 'modal',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment