Skip to content

Commit

Permalink
Un responsable ne peut plus être gestionnaire de la structure dont il…
Browse files Browse the repository at this point in the history
… est responsable.
  • Loading branch information
pacomte-Paris1 committed Sep 18, 2024
1 parent 47d0e7c commit 5887626
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
39 changes: 39 additions & 0 deletions CRON/php/import_structure_xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,45 @@ class XMLstructure
}


////////////////////////////////////////////////////
// On supprime la fonction de gestionnaire car le responsable de la structure ne peut être gestionnaire de cette même structure
//
$cronuser = new agent($dbcon);
$cronuser->load(SPECIAL_USER_IDCRONUSER);
echo "------------------------------------------------------------ \n";
echo "On supprime les gestionnaires qui sont responsables de la même structure \n";
$sql = "SELECT STRUCTURE.STRUCTUREID, STRUCTURE.GESTIONNAIREID
FROM STRUCTURE
WHERE STRUCTURE.GESTIONNAIREID = STRUCTURE.RESPONSABLEID
AND STRUCTURE.DATECLOTURE > '" . $fonctions->formatdatedb(date("d/m/Y")) . "'
AND STRUCTURE.GESTIONNAIREID != '' ";
//echo "SQL = $sql \n";
$query = mysqli_query($dbcon, $sql);
$erreur_requete = mysqli_error($dbcon);
if ($erreur_requete != "")
{
echo "Error : SELECT STRUCTURE.GESTIONNAIREID => $erreur_requete \n";
}
while ($result = mysqli_fetch_row($query))
{
$gestionnaireid = $result[1];
$structureid = $result[0];
$structure = new structure($dbcon);
$structure->load($structureid);
$gestionnaire = new agent($dbcon);
$gestionnaire->load($gestionnaireid);
$structure->gestionnaire("");
$structure->store();
echo "Le gestionnaire de la structure " . $structure->id() . " (" . $gestionnaire->identitecomplete() . ") a été supprimé => Il est responsable de cette structure. \n";
$corpsdumail="Votre fonction 'Gestionnaire G2T' a été supprimée pour la structure '" . $structure->nomlong() . "' \n";
$corpsdumail=$corpsdumail . "car en tant que responsable G2T de la structure vous ne pouvez être défini comme gestionnaire G2T de cette même structure.\n";
$corpsdumail=$corpsdumail . "\n";
$corpsdumail=$corpsdumail . "Nous vous invitons à déclarer un nouveau gestionnaire G2T respectant cette règle de gestion.\n";
$corpsdumail=$corpsdumail . "\n";
$cronuser->sendmail($gestionnaire,"Suppression de la fonction de gestionnaire G2T", $corpsdumail,null,null,false);
}


///////////////////////////////////////////////////
// On ajoute les responsables / les gestionnaires à partir de LDAP s'il n'existent pas dans la base
// On supprime les agents qui ont comme typepopulation => 'Import automatique LDAP'
Expand Down
17 changes: 14 additions & 3 deletions html/gestion_dossier.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,22 @@
}
}
//echo "Agentid pour le gestionnaire vaut : $agentid <br>";
$structure = new structure($dbcon);
$structure->load($structureid);
$responsable = $structure->responsable();
if ($agentid == $responsable->agentid())
{
$errlog = "Le responsable de la structure " . $structure->nomlong() . " (" . $structure->nomcourt() . ") ne peut être défini comme gestionnaire.";
error_log(basename(__FILE__) . " " . $fonctions->stripAccents($errlog));
echo $fonctions->showmessage(fonctions::MSGERROR, "$errlog");
$agentid = "";
$structure->gestionnaire("");
$structure->store();
}

// Si le agentid n'est pas vide ou null
if ($agentid != '' and (! is_null($agentid))) {
elseif ($agentid != '' and (! is_null($agentid))) {
// $structureid = str_replace("'", "", $structureid);
$structure = new structure($dbcon);
$structure->load($structureid);
$structure->gestionnaire($agentid);
$structure->store();
}
Expand Down
12 changes: 11 additions & 1 deletion html/gestion_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,18 @@
}
}

$responsable = $structure->responsable();
if ($agentid == $responsable->agentid())
{
$errlog = "Le responsable de la structure " . $structure->nomlong() . " (" . $structure->nomcourt() . ") ne peut être défini comme gestionnaire.";
error_log(basename(__FILE__) . " " . $fonctions->stripAccents($errlog));
echo $fonctions->showmessage(fonctions::MSGERROR, "$errlog");
$agentid = "";
$structure->gestionnaire("");
}

// Si le agentid n'est pas vide ou null
if ($agentid != '' and (! is_null($agentid)))
elseif ($agentid != '' and (! is_null($agentid)))
{
// echo "On fixe le gestionnaire !!!!<br>";
$errlog = "On fixe le gestionnaire de la structure " . $structure->nomcourt() . " à $agentid";
Expand Down

0 comments on commit 5887626

Please sign in to comment.