diff --git a/html/class/agent.php b/html/class/agent.php
index 5d03d46..e36da87 100644
--- a/html/class/agent.php
+++ b/html/class/agent.php
@@ -859,6 +859,23 @@ function estadministrateur()
$complement->load($this->agentid, "ESTADMIN");
return (strcasecmp($complement->valeur(), "O") == 0);
}
+
+ function estconsultant()
+ {
+ $sql = "SELECT AGENTID FROM COMPLEMENT WHERE COMPLEMENTID = ? AND VALEUR = ?";
+ $params = array($this->fonctions->my_real_escape_utf8(complement::AVIS_CONGES_LABEL), $this->fonctions->my_real_escape_utf8($this->agentid));
+ $query = $this->fonctions->prepared_select($sql, $params);
+ // echo "sql = " . $sql . " ";
+ $erreur = mysqli_error($this->dbconnect);
+ if ($erreur != "") {
+ $errlog = "Agent->estconsultant (AGENT) : " . $erreur;
+ echo $errlog . " ";
+ error_log(basename(__FILE__) . " " . $this->fonctions->stripAccents($errlog));
+ return FALSE;
+ }
+ return (mysqli_num_rows($query) != 0);
+ }
+
/**
*
@@ -1206,7 +1223,18 @@ function sendmail($destinataire = null, $objet = null, $message = null, $piecejo
// => Pas de référence à l'application
if (is_object($destinataire))
{
- $msg .= "Cliquez sur le lien fonctions->get_g2t_url()) . "'>G2T Cordialement " . ucwords(mb_strtolower($this->prenom . " " . $this->nom),'UTF-8') . "\r\n";
+ $msg .= "Cliquez sur le lien fonctions->get_g2t_url()) . "'>G2T Cordialement ";
+ // Si l'expéditeur n'est pas le CRON de G2T
+ if (strcasecmp($this->agentid(), SPECIAL_USER_IDCRONUSER)!=0)
+ {
+ $msg .= ucwords(mb_strtolower($this->prenom . " " . $this->nom),'UTF-8');
+ }
+ else
+ {
+ $msg .= "Ce message est envoyé automatiquement par l'application G2T. ";
+ $msg .= "Merci de ne pas répondre à cet e-mail. La boîte aux lettres qui a généré cet e-mail ne traite pas les réponses. ";
+ }
+ $msg .= "\r\n";
}
// $msg .= htmlentities("$message",ENT_IGNORE,"ISO8859-15") ." Cordialement " . ucwords(strtolower("$PRENOM $NOM")) ."\r\n";
@@ -1502,6 +1530,32 @@ function structgestliste()
return $structliste;
}
+ function agentconsultantliste() :array
+ {
+ $agentliste = array();
+ if ($this->estconsultant()) {
+ // echo "Je suis consultant... ";
+ $sql = "SELECT AGENTID FROM COMPLEMENT WHERE COMPLEMENTID = ? AND VALEUR = ?";
+ $params = array($this->fonctions->my_real_escape_utf8(complement::AVIS_CONGES_LABEL), $this->fonctions->my_real_escape_utf8($this->agentid));
+ $query = $this->fonctions->prepared_select($sql, $params);
+ // echo "sql = " . $sql . " ";
+ $erreur = mysqli_error($this->dbconnect);
+ if ($erreur != "") {
+ $errlog = "Agent->agentconsultantliste (AGENT) : " . $erreur;
+ echo $errlog . " ";
+ error_log(basename(__FILE__) . " " . $this->fonctions->stripAccents($errlog));
+ }
+ while ($result = mysqli_fetch_row($query)) {
+ // echo "Je charge la structure " . $result[0] . " ";
+ $agent = new agent($this->dbconnect);
+ $agent->load("$result[0]");
+ $agentliste[$agent->agentid()] = $agent;
+ unset($agent);
+ }
+ }
+ return $agentliste;
+ }
+
/**
*
* @param
@@ -2766,7 +2820,7 @@ function demandeslistehtmlpourgestion($debut_interval, $fin_interval, $agentid =
* optional deprecated parameter => not used in code
* @return string the html text of the array
*/
- function demandeslistehtmlpourvalidation($debut_interval, $fin_interval, $agentid = null, $structureid = null, $cleelement = null)
+ function demandeslistehtmlpourvalidation($debut_interval, $fin_interval, $agentid = null, $mode = 'resp')
{
$longueurmaxmotif = $this->fonctions->logueurmaxcolonne('DEMANDE','MOTIFREFUS');
@@ -2870,6 +2924,15 @@ function demandeslistehtmlpourvalidation($debut_interval, $fin_interval, $agenti
}
$htmltext = $htmltext . "
" . $demande->nbrejrsdemande() . $datatitleindicator . " ";
$htmltext = $htmltext . " ";
+
+ // Si on a demandé l'avis => On force le statut à "En attente" pour éviter de reposter la demande d'avis
+ // en cas d'enregistrement d'une modification sur une autre demande
+ // En théorie déjà fait dans la page 'valider_demande.php' mais par sécurité on le remet ici
+ if (isset($statutliste[$demande->id()]) and $statutliste[$demande->id()] == demande::DEMANDE_AVIS)
+ {
+ $statutliste[$demande->id()] = demande::DEMANDE_ATTENTE;
+ }
+
$htmltext = $htmltext . " ";
$htmltext = $htmltext . " id()]) and $statutliste[$demande->id()] == demande::DEMANDE_VALIDE)
@@ -2892,6 +2955,24 @@ function demandeslistehtmlpourvalidation($debut_interval, $fin_interval, $agenti
$htmltext = $htmltext . " selected ";
}
$htmltext = $htmltext . " value='" . demande::DEMANDE_REFUSE . "'>" . $this->fonctions->demandestatutlibelle(demande::DEMANDE_REFUSE) . " ";
+
+ $complement = new complement($this->dbconnect);
+ $complement->load($this->agentid,complement::AVIS_CONGES_LABEL);
+ if ($complement->agentid()==$this->agentid and $complement->valeur()!="")
+ {
+ $htmltext = $htmltext . " id()]) and $statutliste[$demande->id()] == demande::DEMANDE_AVIS)
+ {
+ $htmltext = $htmltext . " selected ";
+ }
+ elseif (!isset($statutliste[$demande->id()]) and strcasecmp($demande->statut(), demande::DEMANDE_AVIS) == 0)
+ {
+ $htmltext = $htmltext . " selected ";
+ }
+ $htmltext = $htmltext . " value='" . demande::DEMANDE_AVIS ."'>" . $this->fonctions->demandestatutlibelle(demande::DEMANDE_AVIS) . " ";
+ }
+
+
$htmltext = $htmltext . " id()]) and $statutliste[$demande->id()] == demande::DEMANDE_ATTENTE)
{
diff --git a/html/class/complement.php b/html/class/complement.php
index c695e88..a969132 100644
--- a/html/class/complement.php
+++ b/html/class/complement.php
@@ -15,6 +15,7 @@ class complement
{
public const TT_EXCLU_LABEL = 'TT_EXCLU_';
public const FORCE_SOLDE_LABEL = 'FORCE_SOLDE_';
+ public const AVIS_CONGES_LABEL = 'AVISCONGES';
private $agentid = null;
diff --git a/html/class/demande.php b/html/class/demande.php
index 9b09e0c..b31005a 100644
--- a/html/class/demande.php
+++ b/html/class/demande.php
@@ -9,6 +9,7 @@ class demande
public const DEMANDE_REFUSE = "r";
public const DEMANDE_ATTENTE = "a";
public const DEMANDE_ANNULE = "x";
+ public const DEMANDE_AVIS = "c";
private $demandeid = null;
diff --git a/html/class/fonctions.php b/html/class/fonctions.php
index 24bec8f..515cfb9 100644
--- a/html/class/fonctions.php
+++ b/html/class/fonctions.php
@@ -1078,29 +1078,53 @@ public function ouinonlibelle($codeouinon = null)
public function demandestatutlibelle($statut = null)
{
if (strcasecmp($statut, demande::DEMANDE_VALIDE) == 0)
+ {
return "Validée";
+ }
elseif (strcmp($statut, demande::DEMANDE_REFUSE) == 0)
+ {
return "Refusée";
+ }
elseif (strcmp($statut, demande::DEMANDE_ANNULE) == 0)
+ {
return "Annulée";
+ }
elseif (strcasecmp($statut, demande::DEMANDE_ATTENTE) == 0)
+ {
return "En attente";
+ }
+ elseif (strcasecmp($statut, demande::DEMANDE_AVIS) == 0)
+ {
+ return "Demande d'avis";
+ }
else
+ {
echo "Demandestatutlibelle : le statut n'est pas connu [statut = $statut] !!! ";
+ }
}
public function teletravailstatutlibelle($statut = null)
{
if (strcasecmp($statut, teletravail::TELETRAVAIL_VALIDE) == 0)
+ {
return "Validée";
- elseif (strcmp($statut, teletravail::TELETRAVAIL_REFUSE) == 0)
+ }
+ elseif (strcmp($statut, teletravail::TELETRAVAIL_REFUSE) == 0)
+ {
return "Refusée";
- elseif (strcmp($statut, teletravail::TELETRAVAIL_ANNULE) == 0)
+ }
+ elseif (strcmp($statut, teletravail::TELETRAVAIL_ANNULE) == 0)
+ {
return "Annulée";
- elseif (strcasecmp($statut, teletravail::TELETRAVAIL_ATTENTE) == 0)
+ }
+ elseif (strcasecmp($statut, teletravail::TELETRAVAIL_ATTENTE) == 0)
+ {
return "En attente";
- else
- echo "teletravailstatutlibelle : le statut n'est pas connu [statut = $statut] !!! ";
+ }
+ else
+ {
+ echo "teletravailstatutlibelle : le statut n'est pas connu [statut = $statut] !!! ";
+ }
}
/**
@@ -5262,6 +5286,37 @@ function dernierjourmoisprecedent($date)
return date("Ymd",strtotime($annee.$mois."01" . " - 1 day"));
}
+
+ function mailbody_avis(demande $demande) : string
+ {
+ $corpmail = "";
+ $agent = $demande->agent();
+ $resp = $agent->getsignataire();
+ if (!is_null($resp) and ($resp!==false))
+ {
+ $corpmail = "Une demande";
+ if ($this->estunconge($demande->type()))
+ {
+ $corpmail = $corpmail . " de congés ";
+ }
+ else
+ {
+ $corpmail = $corpmail . " d'absence ";
+ }
+ $corpmail = $corpmail . "(" . $demande->typelibelle() . ") de " . $agent->identitecomplete() . " du " . $demande->datedebut() . " au " . $demande->datefin() . " (" . $demande->nbrejrsdemande();
+ if ($demande->nbrejrsdemande()>1)
+ {
+ $corpmail = $corpmail . " jours";
+ }
+ else
+ {
+ $corpmail = $corpmail . " jour";
+ }
+ $corpmail = $corpmail . ") nécessite votre attention.";
+ $corpmail = $corpmail . "\n\nMerci d'indiquer à " . $resp->identitecomplete() . " votre avis.\n";
+ }
+ return $corpmail;
+ }
}
?>
\ No newline at end of file
diff --git a/html/class/structure.php b/html/class/structure.php
index c09cce2..56db0a8 100644
--- a/html/class/structure.php
+++ b/html/class/structure.php
@@ -969,7 +969,7 @@ function planning($mois_annee_debut, $mois_annee_fin, $showsousstruct = null, $i
return $planningservice;
}
- function planninghtml($mois_annee_debut, $showsousstruct = null, $noiretblanc = false, $includeteletravail = false, $dbclickable = false, $includecongeabsence = true) // mois_annee_debut => Le format doit être MM/YYYY
+ function planninghtml($mois_annee_debut, $showsousstruct = null, $noiretblanc = false, $includeteletravail = false, $dbclickable = false, $includecongeabsence = true, $agentlist = null) // mois_annee_debut => Le format doit être MM/YYYY
{
// echo "Je debute planninghtml ";
//list ($jour, $indexmois, $annee) = split('[/.-]', '01/' . $mois_annee_debut);
@@ -979,9 +979,23 @@ function planninghtml($mois_annee_debut, $showsousstruct = null, $noiretblanc =
echo $this->fonctions->showmessage(fonctions::MSGWARNING, "Les informations antérieures à la date du jour ont été masquées.");
}
- $planningservice = $this->planning($mois_annee_debut, $mois_annee_debut, $showsousstruct,$includeteletravail,$includecongeabsence);
+ if (is_null($agentlist) or count((array)$agentlist)==0)
+ {
+ $planningservice = $this->planning($mois_annee_debut, $mois_annee_debut, $showsousstruct,$includeteletravail,$includecongeabsence);
+ }
+ else
+ {
+ //var_dump("J'ai une liste d'agent");
+ $planningservice = array();
+ foreach($agentlist as $membre)
+ {
+ //var_dump("L'agent est " . $membre->identitecomplete());
+ $planningservice[] = $membre->planning('01/' . $mois_annee_debut, $this->fonctions->nbr_jours_dans_mois($indexmois, $annee). "/" . $mois_annee_debut, $includeteletravail, $includecongeabsence);
+ }
+ //var_dump("Il y a " . count($planningservice) . " éléments dans planningservice");
+ }
- if (! is_array($planningservice)) {
+ if (! is_array($planningservice) or count((array)$planningservice)==0) {
return ""; // Si aucun élément du planning => On retourne vide
}
@@ -1027,7 +1041,14 @@ function planninghtml($mois_annee_debut, $showsousstruct = null, $noiretblanc =
$nbcolonneaajouter = 1;
}
$htmltext = $htmltext . "";
- $htmltext = $htmltext . "Gestion des dossiers pour la structure " . $this->nomlong() . " (" . $this->nomcourt() . ") ";
+ if (is_null($agentlist) or count((array)$agentlist)==0)
+ {
+ $htmltext = $htmltext . "Gestion des dossiers pour la structure " . $this->nomlong() . " (" . $this->nomcourt() . ") ";
+ }
+ else // On a indiquer une liste d'agent spécifique
+ {
+ $htmltext = $htmltext . "Planning des agents ";
+ }
$monthname = $this->fonctions->nommois("01/" . $mois_annee_debut) . " " . date("Y", strtotime($this->fonctions->formatdatedb("01/" . $mois_annee_debut)));
// echo "Nom du mois = " . $monthname . " ";
$htmltext = $htmltext . "" . $monthname . " ";
@@ -1217,28 +1238,31 @@ function planninghtml($mois_annee_debut, $showsousstruct = null, $noiretblanc =
}
$htmltext = $htmltext . " ";
- $htmltext = $htmltext . "";
-
+ $htmltext = $htmltext . "";
+ }
// $htmltext = $htmltext . "