Skip to content

Commit

Permalink
Corrections et évolutions multiples
Browse files Browse the repository at this point in the history
- Ajout de l'affichage du PDF des la validation des demandes d'absence et de congés dans le récapitulatif des demandes
- Activation de la récupération des congés sur arrêt de maladie (à partir de 01/09/2024)
- Activation des nouvelles règles de calcul du solde des congés (à partir du 01/09/2024)
- Corrections mineures/fiabilisation
  • Loading branch information
pacomte-Paris1 committed Sep 4, 2024
1 parent 1c13d89 commit 825ab27
Show file tree
Hide file tree
Showing 20 changed files with 210 additions and 121 deletions.
4 changes: 2 additions & 2 deletions CRON/cron-xml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ then
echo "Avant generation de l'historique des CET" >>$logfile
php php/demande_cet.php >>$logfile 2>>$logfile
fi
php php/mail_alerte_reliquats.php >>$logfile
php php/mail_alerte_teletravail.php >>$logfile
php php/mail_alerte_reliquats.php >>$logfile 2>>$logfile
php php/mail_alerte_teletravail.php >>$logfile 2>>$logfile

php php/switch_synchronisation.php inactif >>$logfile

Expand Down
3 changes: 2 additions & 1 deletion CRON/php/import_absence_xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@

//echo "datefinformate = $datefinformate Date J - 2 ans = " . (date('Y')-2) . date("md") . " typeabsence = $typeabsence \n";
// Si l'arret s'est terminé il y a moins de 2 ans et que c'est un type d'absence M (<=> maladie)
if ($datefinformate > (date('Y')-2) . date("md") and strcasecmp($typeabsence,'M')==0 and false)
//if ($datefinformate > (date('Y')-2) . date("md") and strcasecmp($typeabsence,'M')==0 and false)
if ($datefinformate > (date('Y')-2) . date("md") and strcasecmp($typeabsence,'M')==0 and date('Ymd') >= '20240901')
{
echo "L'arret date de moins de 2 ans et c'est une maladie (typeabsence = $typeabsence) \n";
$agent = new agent($dbcon);
Expand Down
26 changes: 21 additions & 5 deletions CRON/php/import_structure_xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ class XMLstructure

$listestructcrees = array();

$xml = simplexml_load_file("$filename");
$agentnode = $xml->xpath('STRUCTURE');
foreach ($agentnode as $node)
{
$xml = simplexml_load_file("$filename");
$agentnode = $xml->xpath('STRUCTURE');
foreach ($agentnode as $node)
{
echo "---------------------------------------------------\n";
$XMLstructure = new XMLstructure();
$XMLstructure->code_struct = trim($node->xpath('STRUCTID')[0]);
Expand Down Expand Up @@ -398,7 +398,7 @@ class XMLstructure
$estinclue = 0;
}

$sql = "SELECT * FROM STRUCTURE WHERE STRUCTUREID='" . $XMLstructure->code_struct . "'";
$sql = "SELECT ISINCLUDED FROM STRUCTURE WHERE STRUCTUREID='" . $XMLstructure->code_struct . "'";
$query = mysqli_query($dbcon, $sql);
$erreur_requete = mysqli_error($dbcon);
if ($erreur_requete != "")
Expand Down Expand Up @@ -434,6 +434,14 @@ class XMLstructure
}
else
{
// On récupère la valeur de ISINCLUDED dans la base de données
$result = mysqli_fetch_row($query);
// Si l'inclusion de la structure dans la base de donnée est FALSE et que dans le fichier il est passé à TRUE
if ($fonctions->convertvaluetobool(trim($result[0]))==false and $fonctions->convertvaluetobool($estinclue)==true)
{
// On mémorise le changement de l'inclusion pour activer ou la structure (voir fin de la procédure)
$listestructcrees["$XMLstructure->code_struct"] = $XMLstructure->code_struct;
}
echo "Mise a jour d'une structure : $XMLstructure->nom_long_struct (Id = $XMLstructure->code_struct) \n";
$sql = sprintf("UPDATE STRUCTURE SET NOMLONG='%s',
NOMCOURT='%s',
Expand Down Expand Up @@ -592,16 +600,24 @@ class XMLstructure
}
}

echo "------------------------------------------------------------ \n";
echo "On parcourt toutes les structures que l'on vient de creer ou qui on une inclusion modifiee \n";
// On parcourt toutes les structures que l'on vient de créer ou qui on une inclusion modifiée
foreach ($listestructcrees as $structid)
{
$structure = new structure($dbcon);
$structure->load($structid);
$structureenglobante = $structure->structureenglobante();
if ($fonctions->convertvaluetobool($structureenglobante->isdeployed()))
{
echo "La structure racine " . $structureenglobante->id() . " de $structid est déployée => On la déploie aussi. \n";
$structure->isdeployed($structureenglobante->isdeployed());
$structure->store();
}
else
{
echo "La structure racine " . $structureenglobante->id() . " de $structid n'est pas déployée => On ne la déploie pas. \n";
}
}


Expand Down
25 changes: 17 additions & 8 deletions CRON/php/mail_alerte_teletravail.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
echo "\nDébut de l'envoi des mail des alertes de fin de convention de télétravail " . date("d/m/Y H:i:s") . "\n";

echo "La date du jour est : $date \n";
$datefinconvention = date("Y-m-d",strtotime($date."+ 1 months"));
echo "La date de fin des conventions à tester est $datefinconvention\n";
$datefinconvention_1mois = date("Y-m-d",strtotime($date."+ 1 months"));
$datefinconvention_2mois = date("Y-m-d",strtotime($date."+ 2 months"));
echo "Les dates de fin des conventions à tester sont $datefinconvention_1mois et $datefinconvention_2mois \n";

$listeagent = $fonctions->listeagentteletravail($datefinconvention,$datefinconvention,false);
$listeagent = $fonctions->listeagentteletravail($datefinconvention_1mois,$datefinconvention_1mois,false);
$listeagent = array_merge((array)$listeagent,(array)$fonctions->listeagentteletravail($datefinconvention_2mois,$datefinconvention_2mois,false));
$listeagent = array_unique($listeagent);

foreach ((array)$listeagent as $agentid)
{
Expand All @@ -24,7 +27,9 @@
$agent = new agent($dbcon);
if ($agent->load($agentid)) // Si le chargement de l'agent est ok
{
$teletravailliste = $agent->teletravailliste($datefinconvention,$datefinconvention);
$teletravailliste = $agent->teletravailliste($datefinconvention_1mois,$datefinconvention_1mois);
$teletravailliste = array_merge((array)$teletravailliste,(array)$agent->teletravailliste($datefinconvention_2mois,$datefinconvention_2mois));
$teletravailliste = array_unique($teletravailliste);
foreach ((array)$teletravailliste as $conventionid)
{
$convention = new teletravail($dbcon);
Expand All @@ -36,17 +41,21 @@
// {
// $force = true;
// }
if (($convention->statut()==teletravail::TELETRAVAIL_VALIDE and $fonctions->formatdatedb($convention->datefin()) == $fonctions->formatdatedb($datefinconvention)) or $force)
if (($convention->statut()==teletravail::TELETRAVAIL_VALIDE
and ($fonctions->formatdatedb($convention->datefin()) == $fonctions->formatdatedb($datefinconvention_1mois)
or $fonctions->formatdatedb($convention->datefin()) == $fonctions->formatdatedb($datefinconvention_2mois)))
or $force)
{
// On doit envoyer un mail de rappel à l'agent !
echo "Id de la convention teletravail = $conventionid Statut convention = " . $convention->statut() . " Id de l'agent = $agentid : ";
echo "Id de la convention teletravail = $conventionid Statut convention = " . $convention->statut() . " Id de l'agent = $agentid date fin = " . $convention->datefin() . " : ";
echo "Tout est ok... On peut envoyer le mail \n";
$corpsdumail="Votre convention de télétravail arrive bientôt à son terme.\n";
$corpsdumail=$corpsdumail . "Si vous souhaitez renouveler votre convention de télétravail, veuillez prendre contact avec le service de la DRH afin de connaitre les modalités.\n";
$corpsdumail=$corpsdumail . "Dans le cas contraire, vous ne serez plus en télétravail après le " . $fonctions->formatdate($convention->datefin()) . ".\n";
$corpsdumail=$corpsdumail . "\n";

$agentcron->sendmail($agent, "Alerte : Fin de votre convention de télétravail", $corpsdumail, null, null, true);
//echo "Avant l'envoi \n";
$agentcron->sendmail($agent, "Alerte : Fin de votre convention de télétravail", $corpsdumail, null, null, false);
//echo "Apres l'envoi \n";
}
else
{
Expand Down
27 changes: 17 additions & 10 deletions CRON/php/synchro_conventions_teletravail.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,27 @@
////////////////////////////
// Dans le cas d'une délégation, le responsable peut quand même vouloir recevoir les demandes
// On regarde donc s'il y a une délégation dans structure du responsable (obtenu avec agent::getsignataire)
$delegation = $structresp->getdelegation(true);
if ($fonctions->convertvaluetobool($delegation->continuesendtoresp))
if (!is_null($structresp))
{
$responsable = $structresp->responsablesiham();
if (is_null($responsable) or $responsable===false)
$delegation = $structresp->getdelegation(true);
if ($fonctions->convertvaluetobool($delegation->continuesendtoresp))
{
echo "On n'envoie pas de rappel au responsable SIHAM de la structure car il n'est pas défini \n";
}
else
{
echo "On envoie un rappel au responsable SIHAM de la structure de l'agent => Responsable = " . $responsable->identitecomplete() . " \n";
$tabdestinataireg2t[$responsable->agentid()] = $responsable;
$responsable = $structresp->responsablesiham();
if (is_null($responsable) or $responsable===false)
{
echo "On n'envoie pas de rappel au responsable SIHAM de la structure car il n'est pas défini \n";
}
else
{
echo "On envoie un rappel au responsable SIHAM de la structure de l'agent => Responsable = " . $responsable->identitecomplete() . " \n";
$tabdestinataireg2t[$responsable->agentid()] = $responsable;
}
}
}
else
{
echo "La structure est inconnue => Pas de recherche de délégation \n";
}
}
else
{
Expand Down
9 changes: 5 additions & 4 deletions html/affiche_jourscomplementaires.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@
continue;
}
// On affiche les informations des récupérations qui sont valables durant la période 01/09/XXXX et 31/08/(XXXX+1)
$dbconstante = 'VALIDRECUP';
$validrecup = '2';
if ($fonctions->testexistdbconstante($dbconstante)) { $validrecup = $fonctions->liredbconstante($dbconstante); }
//$dbconstante = 'VALIDRECUP';
//$validrecup = '2';
//if ($fonctions->testexistdbconstante($dbconstante)) { $validrecup = $fonctions->liredbconstante($dbconstante); }
//$findatevalidite = date('Ymd',strtotime('+' . $validrecup . ' month',strtotime($fonctions->formatdatedb($commentaireconge->dateajout))));

$findatevalidite = date('Ymd',strtotime('+' . $validrecup . ' month',strtotime($fonctions->formatdatedb($commentaireconge->dateajout))));
$findatevalidite = $fonctions->finvaliditerecuperation($commentaireconge->dateajout);
if (($findatevalidite < $datedebutanneeuniv) or ($fonctions->formatdatedb($commentaireconge->dateajout)>$datefinanneeuniv))
{
// Cette récupération n'est pas dans la période universitaire => On ne l'affiche pas
Expand Down
17 changes: 17 additions & 0 deletions html/affiche_pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
if (isset($_POST["typepdf"]))
$typepdf = $_POST["typepdf"];


if ($typepdf == 'listedemande') {
//header('Content-Disposition: attachment; filename="liste_demandes.pdf"');
if ($listeagent != "") {
Expand Down Expand Up @@ -81,6 +82,22 @@
}
}

if (isset($_POST["nomdemandepdf"]))
{
$fullpdffilename = $_POST["nomdemandepdf"];
// get size of the binary file
$filesize = filesize("$fullpdffilename");
// open file for reading in binary mode
$fp = fopen("$fullpdffilename", 'rb');
// read the entire file into a binary string
$binary = fread($fp, $filesize);
// finally close the file
fclose($fp);
header('Content-Disposition: attachment; filename="demande.pdf"');
echo $binary;
}


if (isset($_POST["userpdf"])) {
//header('Content-Disposition: attachment; filename="planning_agent.pdf"');
if (strcasecmp($_POST["userpdf"], "yes") == 0) {
Expand Down
10 changes: 6 additions & 4 deletions html/ajouter_conges.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,12 @@
//$corpmail = $corpmail . "Votre solde de jours complémentaires est maintenant de : " . ($solde->droitaquis() - $solde->droitpris()) . " jour(s).\n";
//$cronuser->sendmail($agent, "Ajout de jours complémentaires", $corpmail);
$commentaireconge = $fonctions->lirecommentaire($commentaireid);
$dbconstante = 'VALIDRECUP';
$validrecup = '2';
if ($fonctions->testexistdbconstante($dbconstante)) { $validrecup = $fonctions->liredbconstante($dbconstante); }
$findatevalidite = date('d/m/Y',strtotime('+' . $validrecup . ' month',strtotime($fonctions->formatdatedb($commentaireconge->dateajout))));
//$dbconstante = 'VALIDRECUP';
//$validrecup = '2';
//if ($fonctions->testexistdbconstante($dbconstante)) { $validrecup = $fonctions->liredbconstante($dbconstante); }
//$findatevalidite = date('d/m/Y',strtotime('+' . $validrecup . ' month',strtotime($fonctions->formatdatedb($commentaireconge->dateajout))));

$findatevalidite = $fonctions->finvaliditerecuperation($commentaireconge->dateajout);

$corpmail = $user->identitecomplete() . " vient de vous ajouter $nbr_jours_conges jour(s) de récupération.\n";
$corpmail = $corpmail . "Le motif de cet ajout est : \n" . $commentaire_supp . ".\n\n";
Expand Down
40 changes: 36 additions & 4 deletions html/class/agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,35 @@ function demandeslistehtml($datedebut, $datefin, $structureid = null, $showlink
$htmltext = $htmltext . $demande->nbrejrsdemande() . $datatitleindicator;
$htmltext = $htmltext . "</td>";
$htmltext = $htmltext . "<td>";
$htmltext = $htmltext . $this->fonctions->demandestatutlibelle($demande->statut());
$fullpdffilename = '';
if ($demande->statut()==demande::DEMANDE_VALIDE)
{
//var_dump($this->fonctions->formatdatedb($demande->datestatut()));
$pdfdossierdate = date('Y-m', strtotime($this->fonctions->formatdatedb($demande->datestatut())));
$pdfpath = $this->fonctions->pdfpath() . '/' . $pdfdossierdate . '/';
$filelist = array();
//var_dump("$pdfpath");
if (file_exists("$pdfpath"))
{
$filelist = scandir("$pdfpath");
}
//var_dump($filelist);
$pdffilenamelist = preg_grep('/^demande_num' . $demande->id() . '_/i',$filelist);
if (count($pdffilenamelist)>0)
{
$fullpdffilename = $pdfpath . reset($pdffilenamelist);
$htmltext = $htmltext . "<form name='form_demandePDF_" . $demande->id() . "' id='form_demandePDF_" . $demande->id() . "' method='post' action='affiche_pdf.php' target='_blank'>";
$htmltext = $htmltext . "<input type='hidden' name='nomdemandepdf' value='$fullpdffilename' />"; // nom du PDF à afficher
$htmltext = $htmltext . "</form>";
$htmltext = $htmltext . "<a href='javascript:document.form_demandePDF_" . $demande->id() . ".submit();'>" . $this->fonctions->demandestatutlibelle($demande->statut()) . "</a>";

}
}
if ($fullpdffilename == '')
{
$htmltext = $htmltext . $this->fonctions->demandestatutlibelle($demande->statut());
}

$htmltext = $htmltext . "</td>";
$datatitle = '';
if (strlen($demande->motifrefus()) != 0)
Expand Down Expand Up @@ -4369,7 +4397,11 @@ function synchroteletravail()
function calculsoldeannuel($anneeref = null, $maj_solde = true, $loginfo = false, $displayinfo = false)
{


if (date('Ymd') >= '20240901')
{
return $this->newcalculsoldeannuel($anneeref,$maj_solde,$loginfo,$displayinfo);
}

if ($loginfo == true) {
error_log(basename(__FILE__) . $this->fonctions->stripAccents(" ###############################################################"));
error_log(basename(__FILE__) . $this->fonctions->stripAccents(" On est sur l'agent : " . $this->identitecomplete() . " (id = " . $this->agentid . ")"));
Expand Down Expand Up @@ -4398,7 +4430,7 @@ function calculsoldeannuel($anneeref = null, $maj_solde = true, $loginfo = false

$agentcomplement = new complement($this->dbconnect);
$agentcomplement->load($this->agentid(),complement::FORCE_SOLDE_LABEL . $anneeref);
// Si le complément existe et qu'on a réussi à le chager
// Si le complément existe et qu'on a réussi à le charger
if ($agentcomplement->agentid()==$this->agentid())
{
if ($loginfo == true)
Expand Down Expand Up @@ -5226,7 +5258,7 @@ function newcalculsoldeannuel($anneeref = null, $maj_solde = true, $loginfo = fa

$agentcomplement = new complement($this->dbconnect);
$agentcomplement->load($this->agentid(),complement::FORCE_SOLDE_LABEL . $anneeref);
// Si le complément existe et qu'on a réussi à le chager
// Si le complément existe et qu'on a réussi à le charger
if ($agentcomplement->agentid()==$this->agentid())
{
$this->fonctions->log_traces($loginfo,$displayinfo,"Le solde $anneeref de l'agent " . $this->identitecomplete() . " est forcé => On ne fait pas de calcul.");
Expand Down
Loading

0 comments on commit 825ab27

Please sign in to comment.