Commit 5f9913a7 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Refactor completude au profit de TBL_DOSSIER.php et adaptation...

Refactor completude au profit de TBL_DOSSIER.php et adaptation IntervenantDossierController.php et DossierService.php
parent 222cec2a
<?php
$c->print("Veuillez saisir l'année :");
$annee = $c->getInput();
$c->print("Veuillez saisir un id d'intervenant, si vide tous les intervenants de l'année seront pris en compte :");
$intervenant = $c->getInput();
if (!$annee && !$intervenant) {
$c->println("Aucun Paramètre");
} elseif (!$annee || ($intervenant && $annee)) {
$c->println("Calcul de la complétude du dossier de l'intervenant : " . $intervenant);
$oa->exec("calcul-completude-dossier --intervenant=$intervenant");
$c->println("Complétude du dossier recalculée");
} elseif (!$intervenant) {
$c->println("Calcul de la complétude de tous les dossiers de l'année : " . $annee);
$oa->exec("calcul-completude-dossier --annee=$annee");
$c->println("Complétude des dossiers recalculée");
}
......@@ -172,13 +172,6 @@ class MigrationDossier extends AbstractMigration
$console->println("Nombre de dossiers migrés : " . $nbDossierMigration);
//Mise à jour sequence
$bdd->majSequences($this->manager->getRef());
//Reste à faire de recalculer la complétude des dossiers 2019 et 2020 au minimum
$console->println("Recalcul de la complétude des dossiers pour l'année 2019");
$annee = '2019';
$oa->exec("calcul-completude-dossier --annee=$annee");
$console->println("Recalcul de la complétude des dossiers pour l'année 2020");
$annee = '2020';
$oa->exec("calcul-completude-dossier --annee=$annee");
//Recalcule le tableau de bord des dossier
$console->println("Calcul du tableau de bord TBL_DOSSIER");
$bdd->exec('BEGIN unicaen_tbl.calculer(\'dossier\'); END;');
......
......@@ -213,18 +213,6 @@ return [
'position' => 17,
'commentaire' => NULL,
],
'COMPLETUDE' => [
'name' => 'COMPLETUDE',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => FALSE,
'default' => '0',
'position' => 43,
'commentaire' => 'Etat avancement du dossier',
],
'DATE_NAISSANCE' => [
'name' => 'DATE_NAISSANCE',
'type' => 'date',
......
......@@ -21,18 +21,6 @@ return [
'position' => 2,
'commentaire' => NULL,
],
'COMPLETUDE' => [
'name' => 'COMPLETUDE',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 7,
'commentaire' => NULL,
],
'DOSSIER_ID' => [
'name' => 'DOSSIER_ID',
'type' => 'int',
......@@ -93,6 +81,114 @@ return [
'position' => 6,
'commentaire' => NULL,
],
'COMPLETUDE_IDENTITE' => [
'name' => 'COMPLETUDE_IDENTITE',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => 0,
'position' => 7,
'commentaire' => NULL,
],
'COMPLETUDE_IDENTITE_COMP' => [
'name' => 'COMPLETUDE_IDENTITE_COMP',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => 0,
'position' => 8,
'commentaire' => NULL,
],
'COMPLETUDE_CONTACT' => [
'name' => 'COMPLETUDE_CONTACT',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => 0,
'position' => 9,
'commentaire' => NULL,
],
'COMPLETUDE_ADRESSE' => [
'name' => 'COMPLETUDE_ADRESSE',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => 0,
'position' => 10,
'commentaire' => NULL,
],
'COMPLETUDE_INSEE' => [
'name' => 'COMPLETUDE_INSEE',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => 0,
'position' => 11,
'commentaire' => NULL,
],
'COMPLETUDE_IBAN' => [
'name' => 'COMPLETUDE_IBAN',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => 0,
'position' => 12,
'commentaire' => NULL,
],
'COMPLETUDE_EMPLOYEUR' => [
'name' => 'COMPLETUDE_EMPLOYEUR',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => 0,
'position' => 13,
'commentaire' => NULL,
],
'COMPLETUDE_AUTRES' => [
'name' => 'COMPLETUDE_AUTRES',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => 0,
'position' => 14,
'commentaire' => NULL,
],
'COMPLETUDE_STATUT' => [
'name' => 'COMPLETUDE_STATUT',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => 0,
'position' => 15,
'commentaire' => NULL,
],
],
];
......
......@@ -9,6 +9,15 @@ FROM
JOIN intervenant i ON i.id = d.intervenant_id
WHERE
d.dossier_id IS NOT NULL
AND d.completude = 1
/*Complétude des différents bloc dossier*/
AND d.completude_identite = 1
AND d.completude_identite_comp = 1
AND d.completude_contact = 1
AND d.completude_adresse = 1
AND d.completude_insee = 1
AND d.completude_iban = 1
AND d.completude_employeur = 1
AND d.completude_autres = 1
AND d.completude_statut = 1
AND d.validation_id IS NULL
AND d.peut_saisir_dossier = 1
\ No newline at end of file
......@@ -5,18 +5,126 @@ SELECT
si.peut_saisir_dossier,
d.id dossier_id,
v.id validation_id,
d.completude completude
/*Complétude statut*/
CASE WHEN si.code = 'AUTRES' THEN 0
ELSE 1 END completude_statut,
/*Complétude identité*/
CASE WHEN
(
d.civilite_id IS NOT NULL
AND d.nom_usuel IS NOT NULL
AND d.prenom IS NOT NULL
) THEN 1 ELSE 0 END completude_identite,
/*Complétude identité complémentaire*/
CASE WHEN si.dossier_identite_comp = 0 THEN 1
ELSE
CASE WHEN
(
d.date_naissance IS NOT NULL
AND NOT (OSE_DIVERS.str_reduce(pn.LIBELLE) = 'france' AND d.departement_naissance_id IS NULL)
AND d.commune_naissance IS NOT NULL
) THEN 1 ELSE 0 END
END completude_identite_comp,
/*Complétude contact*/
CASE WHEN si.dossier_contact = 0 THEN 1
ELSE
(
CASE WHEN
(
(CASE WHEN si.dossier_email_perso = 1 THEN
CASE WHEN d.email_perso IS NOT NULL THEN 1 ELSE 0 END
ELSE
CASE WHEN d.email_pro IS NOT NULL OR d.email_perso IS NOT NULL THEN 1 ELSE 0 END
END) = 1
AND
(CASE WHEN si.dossier_tel_perso = 1 THEN
CASE WHEN d.tel_perso IS NOT NULL AND d.tel_pro IS NOT NULL THEN 1 ELSE 0 END
ELSE
CASE WHEN d.tel_pro IS NOT NULL OR d.tel_perso IS NOT NULL THEN 1 ELSE 0 END
END) = 1
) THEN 1 ELSE 0 END
) END completude_contact,
/*Complétude adresse*/
CASE WHEN si.dossier_adresse = 0 THEN 1
ELSE
(
CASE WHEN
(
d.adresse_precisions IS NOT NULL
OR d.adresse_lieu_dit IS NOT NULL
OR (d.adresse_voie IS NOT NULL AND d.adresse_numero IS NOT NULL)
) AND
(
d.adresse_commune IS NOT NULL
AND d.adresse_code_postal IS NOT NULL
) THEN 1 ELSE 0 END
) END completude_adresse,
/*Complétude INSEE*/
CASE WHEN si.dossier_insee = 0 THEN 1
ELSE
(
CASE WHEN
(
d.numero_insee IS NOT NULL OR COALESCE(d.numero_insee_provisoire,0) = 1
) THEN 1 ELSE 0 END
) END completude_insee,
/*Complétude IBAN*/
CASE WHEN si.dossier_iban = 0 THEN 1
ELSE
(
CASE WHEN
(
(d.iban IS NOT NULL
AND d.bic IS NOT NULL)
OR COALESCE(d.rib_hors_sepa,0) = 1
) THEN 1 ELSE 0 END
) END completude_iban,
/*Complétude employeur*/
CASE WHEN si.dossier_employeur = 0 THEN 1
ELSE
(
CASE WHEN
(
d.employeur_id IS NOT NULL
) THEN 1 ELSE 0 END
) END completude_employeur,
/*Complétude champs autres*/
CASE WHEN
(
NOT (d.autre_1 IS NULL AND COALESCE(dca1.obligatoire,0) = 1)
AND NOT (d.autre_2 IS NULL AND COALESCE(dca2.obligatoire,0) = 1)
AND NOT (d.autre_3 IS NULL AND COALESCE(dca3.obligatoire,0) = 1)
AND NOT (d.autre_4 IS NULL AND COALESCE(dca4.obligatoire,0) = 1)
AND NOT (d.autre_5 IS NULL AND COALESCE(dca5.obligatoire,0) = 1)
) THEN 1 ELSE 0 END completude_autres
FROM
intervenant i
JOIN statut_intervenant si ON si.id = i.statut_id
LEFT JOIN intervenant_dossier d ON d.intervenant_id = i.id
AND d.histo_destruction IS NULL
LEFT JOIN pays pn ON pn.id = d.pays_naissance_id
JOIN type_validation tv ON tv.code = 'DONNEES_PERSO_PAR_COMP'
LEFT JOIN validation v ON v.intervenant_id = i.id
AND v.type_validation_id = tv.id
AND v.histo_destruction IS NULL
/*Champs autre 1*/
LEFT JOIN dossier_champ_autre_par_statut dcas1 ON dcas1.dossier_champ_autre_id = 1 AND dcas1.statut_id = si.id
LEFT JOIN dossier_champ_autre dca1 ON dca1.id = 1 AND dcas1.dossier_champ_autre_id = dca1.id
/*Champs autre 2*/
LEFT JOIN dossier_champ_autre_par_statut dcas2 ON dcas2.dossier_champ_autre_id = 2 AND dcas2.statut_id = si.id
LEFT JOIN dossier_champ_autre dca2 ON dca2.id = 2 AND dcas2.dossier_champ_autre_id = dca2.id
/*Champs autre 3*/
LEFT JOIN dossier_champ_autre_par_statut dcas3 ON dcas3.dossier_champ_autre_id = 3 AND dcas3.statut_id = si.id
LEFT JOIN dossier_champ_autre dca3 ON dca3.id = 3 AND dcas3.dossier_champ_autre_id = dca3.id
/*Champs autre 4*/
LEFT JOIN dossier_champ_autre_par_statut dcas4 ON dcas4.dossier_champ_autre_id = 4 AND dcas4.statut_id = si.id
LEFT JOIN dossier_champ_autre dca4 ON dca4.id = 4 AND dcas4.dossier_champ_autre_id = dca4.id
/*Champs autre 5*/
LEFT JOIN dossier_champ_autre_par_statut dcas5 ON dcas5.dossier_champ_autre_id = 5 AND dcas5.statut_id = si.id
LEFT JOIN dossier_champ_autre dca5 ON dca5.id = 5 AND dcas5.dossier_champ_autre_id = dca5.id
WHERE
i.histo_destruction IS NULL
/*@INTERVENANT_ID=i.id*/
/*@INTERVENANT_ID=i.id*/
/*@ANNEE_ID=i.annee_id*/
\ No newline at end of file
......@@ -64,8 +64,14 @@ class IntervenantDossierController extends AbstractController
throw new \LogicException('Intervenant non précisé ou inexistant');
}
/* Récupération du dossier de l'intervenant */
$intervenantDossier = $this->getServiceDossier()->getByIntervenant($intervenant);
$intervenantDossier = $this->getServiceDossier()->getByIntervenant($intervenant);
/*Si dossier n'a pas encore d'id alors on le save et on calcule la completude*/
if (!$intervenantDossier->getId()) {
$this->getServiceDossier()->save($intervenantDossier);
$this->updateTableauxBord($intervenantDossier->getIntervenant());
}
$intervenantDossierValidation = $this->getServiceDossier()->getValidation($intervenant);
//$tblDossierIntervenant = $this->getServiceDossier()->getCompletude($intervenantDossier);
/* Initialisation du formulaire */
$form = $this->getIntervenantDossierForm($intervenant);
$form->bind($intervenantDossier);
......@@ -76,8 +82,6 @@ class IntervenantDossierController extends AbstractController
$form->setData($data);
if ($form->isValid()) {
/* Traitement du formulaire */
$completude = $this->getServiceDossier()->isComplete($intervenantDossier);
$intervenantDossier->setCompletude($completude);
$intervenantDossier = $this->getServiceDossier()->save($intervenantDossier);
//Alimentation de la table INDIC_MODIF_DOSSIER
$this->getServiceDossier()->updateIndicModifDossier($intervenant, $intervenantDossier);
......@@ -88,8 +92,7 @@ class IntervenantDossierController extends AbstractController
$form = $this->getIntervenantDossierForm($intervenant);
$form->bind($intervenantDossier);
$this->flashMessenger()->addSuccessMessage('Enregistrement de vos données effectué');
return $this->redirect()->toUrl($this->url()->fromRoute('intervenant/dossier', [], [], true));
//return $this->redirect()->toUrl($this->url()->fromRoute('intervenant/dossier', [], [], true));
} else {
$this->flashMessenger()->addErrorMessage("Vos données n'ont pas été enregistré, veuillez vérifier les erreurs.");
}
......@@ -150,15 +153,14 @@ class IntervenantDossierController extends AbstractController
throw new \LogicException('Intervenant non précisé ou inexistant');
}
$intervenantDossier = $this->getServiceDossier()->getByIntervenant($intervenant);
$completude = $this->getServiceDossier()->isComplete($intervenantDossier);
$intervenantDossier->setCompletude($completude);
$statutIntervenant = $this->getServiceStatutIntervenant()->get($data['DossierStatut']['statut']);
$statutIntervenant = $this->getServiceStatutIntervenant()->get($data['DossierStatut']['statut']);
if ($statutIntervenant) {
$intervenantDossier->setStatut($statutIntervenant);
$this->getServiceDossier()->save($intervenantDossier);
$intervenant->setStatut($statutIntervenant);
$intervenant->setSyncStatut(false);
$this->getServiceIntervenant()->save($intervenant);
$this->updateTableauxBord($intervenant);
}
}
......@@ -289,20 +291,6 @@ class IntervenantDossierController extends AbstractController
public function calculCompletudeDossierAction()
{
$anneeId = $this->getRequest()->getParam('annee');
$intervenantId = $this->getRequest()->getParam('intervenant');
$intervenant = $this->getServiceIntervenant()->get($intervenantId);
$annee = $this->getServiceAnnee()->get($anneeId);
$serviceDossier = $this->getServiceDossier()->updateCompletudeByAnnee($annee, $intervenant);
}
private function updateTableauxBord(Intervenant $intervenant, $validation = false)
{
$this->getServiceWorkflow()->calculerTableauxBord([
......
......@@ -157,11 +157,6 @@ class IntervenantDossier implements HistoriqueAwareInterface, ResourceInterface,
*/
protected $intervenant;
/**
* @var integer|null
*/
protected $completude;
/**
......@@ -812,34 +807,6 @@ class IntervenantDossier implements HistoriqueAwareInterface, ResourceInterface,
/**
* Set completude
*
* @param integer $completude
*
* @return IntervenantDossier
*/
public function setCompletude(int $completude): IntervenantDossier
{
$this->completude = $completude;
return $this;
}
/**
* Get completude
*
* @return integer|null
*/
public function getCompletude(): ?int
{
return $this->completude;
}
/**
* @param Intervenant|null $intervenant
*
......
......@@ -63,7 +63,6 @@
<field name="autre3" type="string" column="AUTRE_3" length="1000" nullable="true"/>
<field name="autre4" type="string" column="AUTRE_4" length="1000" nullable="true"/>
<field name="autre5" type="string" column="AUTRE_5" length="1000" nullable="true"/>
<field name="completude" type="integer" column="COMPLETUDE" nullable="false"/>
<many-to-one field="employeur" target-entity="Application\Entity\Db\Employeur">
......
......@@ -40,5 +40,16 @@
<join-column name="ANNEE_ID" referenced-column-name="ID"/>
</join-columns>
</many-to-one>
<field name="completudeIdentite" type="boolean" column="COMPLETUDE_IDENTITE" nullable="false"/>
<field name="completudeIdentiteComp" type="boolean" column="COMPLETUDE_IDENTITE_COMP" nullable="false"/>
<field name="completudeContact" type="boolean" column="COMPLETUDE_CONTACT" nullable="false"/>
<field name="completudeAdresse" type="boolean" column="COMPLETUDE_ADRESSE" nullable="false"/>
<field name="completudeInsee" type="boolean" column="COMPLETUDE_INSEE" nullable="false"/>
<field name="completudeIban" type="boolean" column="COMPLETUDE_IBAN" nullable="false"/>
<field name="completudeEmployeur" type="boolean" column="COMPLETUDE_EMPLOYEUR" nullable="false"/>
<field name="completudeAutres" type="boolean" column="COMPLETUDE_AUTRES" nullable="false"/>
<field name="completudeStatut" type="boolean" column="COMPLETUDE_STATUT" nullable="false"/>
</entity>
</doctrine-mapping>
......@@ -37,6 +37,51 @@ class TblDossier
*/
private $annee;
/**
* @var boolean
*/
protected $completudeIdentite;
/**
* @var boolean
*/
protected $completudeIdentiteComp;
/**
* @var boolean
*/
protected $completudeContact;
/**
* @var boolean
*/
protected $completudeAdresse;
/**
* @var boolean
*/
protected $completudeInsee;
/**
* @var boolean
*/
protected $completudeIban;
/**
* @var boolean
*/
protected $completudeEmployeur;
/**
* @var boolean
*/
protected $completudeAutres;
/**
* @var boolean
*/
protected $completudeStatut;
/**
......@@ -108,5 +153,122 @@ class TblDossier
{
return $this->annee;
}
/**
* Get complétude identité
*
* @return boolean
*/
public function getCompletudeIdentite()
{
return $this->completudeIdentite;
}
/**
* Get complétude identité complementaire
*
* @return boolean
*/
public function getCompletudeIdentiteComp()
{
return $this->completudeIdentiteComp;
}
/**
* Get complétude contact
*
* @return boolean
*/
public function getCompletudeContact()
{
return $this->completudeContact;
}
/**
* Get complétude adresse
*
* @return boolean
*/
public function getCompletudeAdresse()
{
return $this->completudeAdresse;
}