Skip to content

Commit

Permalink
Debut du traitement de la demande d'avis sur une demande de congés/d'…
Browse files Browse the repository at this point in the history
…absence
  • Loading branch information
pacomte-Paris1 committed May 31, 2024
1 parent ef05cec commit d38971b
Show file tree
Hide file tree
Showing 10 changed files with 436 additions and 50 deletions.
85 changes: 83 additions & 2 deletions html/class/agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . "<br>";
$erreur = mysqli_error($this->dbconnect);
if ($erreur != "") {
$errlog = "Agent->estconsultant (AGENT) : " . $erreur;
echo $errlog . "<br/>";
error_log(basename(__FILE__) . " " . $this->fonctions->stripAccents($errlog));
return FALSE;
}
return (mysqli_num_rows($query) != 0);
}


/**
*
Expand Down Expand Up @@ -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 <a href='" . preg_replace('/([^:])(\/{2,})/', '$1/', $this->fonctions->get_g2t_url()) . "'>G2T</a><br><br>Cordialement<br><br>" . ucwords(mb_strtolower($this->prenom . " " . $this->nom),'UTF-8') . "\r\n";
$msg .= "Cliquez sur le lien <a href='" . preg_replace('/([^:])(\/{2,})/', '$1/', $this->fonctions->get_g2t_url()) . "'>G2T</a><br><br>Cordialement<br><br>";
// 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 .= "<label style='font-size: 0.75em;'>Ce message est envoyé automatiquement par l'application G2T.<br>";
$msg .= "Merci de ne pas répondre à cet e-mail.<br>La boîte aux lettres qui a généré cet e-mail ne traite pas les réponses.</label><br>";
}
$msg .= "\r\n";
}

// $msg .= htmlentities("$message",ENT_IGNORE,"ISO8859-15") ."<br><br>Cordialement<br><br>" . ucwords(strtolower("$PRENOM $NOM")) ."\r\n";
Expand Down Expand Up @@ -1502,6 +1530,32 @@ function structgestliste()
return $structliste;
}

function agentconsultantliste() :array
{
$agentliste = array();
if ($this->estconsultant()) {
// echo "Je suis consultant...<br>";
$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 . "<br>";
$erreur = mysqli_error($this->dbconnect);
if ($erreur != "") {
$errlog = "Agent->agentconsultantliste (AGENT) : " . $erreur;
echo $errlog . "<br/>";
error_log(basename(__FILE__) . " " . $this->fonctions->stripAccents($errlog));
}
while ($result = mysqli_fetch_row($query)) {
// echo "Je charge la structure " . $result[0] . " <br>";
$agent = new agent($this->dbconnect);
$agent->load("$result[0]");
$agentliste[$agent->agentid()] = $agent;
unset($agent);
}
}
return $agentliste;
}

/**
*
* @param
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -2870,6 +2924,15 @@ function demandeslistehtmlpourvalidation($debut_interval, $fin_interval, $agenti
}
$htmltext = $htmltext . " <td class='cellulesimple' $datatitle>" . $demande->nbrejrsdemande() . $datatitleindicator . "</td>";
$htmltext = $htmltext . " <td class='cellulesimple'>";

// 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 . " <select name='statut[" . $demande->id() . "]' id='statut[" . $demande->id() . "]' onchange='demandestatutchange(this," . $demande->id() . ");'>";
$htmltext = $htmltext . " <option ";
if (isset($statutliste[$demande->id()]) and $statutliste[$demande->id()] == demande::DEMANDE_VALIDE)
Expand All @@ -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) . "</option>";

$complement = new complement($this->dbconnect);
$complement->load($this->agentid,complement::AVIS_CONGES_LABEL);
if ($complement->agentid()==$this->agentid and $complement->valeur()!="")
{
$htmltext = $htmltext . " <option ";
if (isset($statutliste[$demande->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) . "</option>";
}


$htmltext = $htmltext . " <option ";
if (isset($statutliste[$demande->id()]) and $statutliste[$demande->id()] == demande::DEMANDE_ATTENTE)
{
Expand Down
1 change: 1 addition & 0 deletions html/class/complement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions html/class/demande.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
65 changes: 60 additions & 5 deletions html/class/fonctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] !!! <br>";
}
}

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] !!! <br>";
}
else
{
echo "teletravailstatutlibelle : le statut n'est pas connu [statut = $statut] !!! <br>";
}
}

/**
Expand Down Expand Up @@ -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;
}
}

?>
Loading

0 comments on commit d38971b

Please sign in to comment.