Bonjour à tous,
Je suis en stage en entreprise et je dois refaire certaines fonctionnalités de l'Intranet.
La partie Gestion des congés étant trop compliquée pour mon niveau(débutant), je me base sur le travail de l'Informaticien ayant programmé le premier site.
Cependant, je n'arrive pas à comprendre et afficher la partie calendrier des congés.
Si quelqu'un pouvait m'éclairer le code suivant:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="../../style.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
</head>
<body>
<table>
<?php
if (!$mois_relatif)
$mois_relatif = 0;
$requete = "SELECT MONTH(DATE_ADD(NOW(), INTERVAL $mois_relatif MONTH)) AS mois, YEAR(DATE_ADD(NOW(), INTERVAL $mois_relatif MONTH)) AS annee, DAY(LAST_DAY(DATE_ADD(NOW(), INTERVAL $mois_relatif MONTH))) AS fin_mois";
$result = mysql_db_query('phpconges', $requete);
$row = mysql_fetch_array($result);
$mois = $row['mois'];
$annee = $row['annee'];
$fin_mois = $row['fin_mois'];
switch ($mois)
{
case 1:
$nom_mois = "Janvier";
break;
case 2:
$nom_mois = "Février";
break;
case 3:
$nom_mois = "Mars";
break;
case 4:
$nom_mois = "Avril";
break;
case 5:
$nom_mois = "Mai";
break;
case 6:
$nom_mois = "Juin";
break;
case 7:
$nom_mois = "Juillet";
break;
case 8:
$nom_mois = "Août";
break;
case 9:
$nom_mois = "Septembre";
break;
case 10:
$nom_mois = "Octobre";
break;
case 11:
$nom_mois = "Novembre";
break;
case 12:
$nom_mois = "Décembre";
break;
}
// Jours fériés
$feries = array(array());
$sj = 24 * 3600;
$feries[1][1] = "F";
$feries[5][1] = "F";
$feries[5][8] = "F";
$feries[7][14] = "F";
$feries[8][15] = "F";
$feries[11][1] = "F";
$feries[11][11] = "F";
$feries[12][25] = "F";
$feries[12][26] = "F";
$vendredi_saint = easter_date($annee) - 2 * $sj;
$feries[(int)date("m",$vendredi_saint)][(int)date("d",$vendredi_saint)] = "F";
$lundi_paques = easter_date($annee) + 1 * $sj;
$feries[(int)date("m",$lundi_paques)][(int)date("d",$lundi_paques)] = "F";
$ascension = easter_date($annee) + 39 * $sj;
$feries[(int)date("m",$ascension)][(int)date("d",$ascension)] = "F";
$lundi_pentecote = easter_date($annee) + 50 * $sj;
$feries[(int)date("m",$lundi_pentecote)][(int)date("d",$lundi_pentecote)] = "F";
// Initialisation du tableau pour les absences et les congés
$tableau_mois = array(array(array()));
// Congés
$requete = "SELECT ind_salarie,
IF(dernier < '$annee-$mois-01', 0, DAY(dernier)) AS d,
IF(dernier >= '$annee-$mois-01', dernier_matin, 'F') AS d_matin,
IF(reprise > '$annee-$mois-$fin_mois', $fin_mois + 1, DAY(reprise)) AS r,
IF(reprise <= '$annee-$mois-$fin_mois', reprise_matin, 'T') AS r_matin
FROM conges
WHERE reprise >= '$annee-$mois-01' AND dernier <= '$annee-$mois-$fin_mois'
AND DATE_ADD(dernier, INTERVAL 1 DAY) <= reprise";
if ($result = mysql_db_query('phpconges', $requete))
{
while($row = mysql_fetch_array($result))
{
$d = $row['d'];
$r = $row['r'];
$ind_salarie = $row['ind_salarie'];
if ($row['d_matin'] == 'T')
$tableau_mois[$ind_salarie][$d][1] = "C";
for ($k = $d + 1;$k <= $r - 1;$k++)
{
$tableau_mois[$ind_salarie][$k][0] = "C";
$tableau_mois[$ind_salarie][$k][1] = "C";
}
if ($row['r_matin'] == 'F')
$tableau_mois[$ind_salarie][$r][0] = "C";
}
}
// Absences
$requete = "SELECT ind_salarie, IF (motif LIKE '%maladie',1,0) AS maladie,
IF(dernier < '$annee-$mois-01', 0, DAY(dernier)) AS d,
IF(dernier >= '$annee-$mois-01', dernier_matin, 'F') AS d_matin,
IF(reprise > '$annee-$mois-$fin_mois', $fin_mois + 1, DAY(reprise)) AS r,
IF(reprise <= '$annee-$mois-$fin_mois', reprise_matin, 'T') AS r_matin
FROM absences
WHERE reprise >= '$annee-$mois-01' AND dernier <= '$annee-$mois-$fin_mois'
AND DATE_ADD(dernier, INTERVAL 1 DAY) <= reprise";
if ($result = mysql_db_query('phpconges', $requete))
{
while($row = mysql_fetch_array($result))
{
$d = $row['d'];
$r = $row['r'];
$ind_salarie = $row['ind_salarie'];
if ($row['maladie'])
$code_absence = "M";
else
$code_absence = "A";
if ($row['d_matin'] == 'T')
$tableau_mois[$ind_salarie][$d][1] = $code_absence;
for ($k = $d + 1;$k <= $r - 1;$k++)
{
$tableau_mois[$ind_salarie][$k][0] = $code_absence;
$tableau_mois[$ind_salarie][$k][1] = $code_absence;
}
if ($row['r_matin'] == 'F')
$tableau_mois[$ind_salarie][$r][0] = $code_absence;
}
}
// Affichage du tableau
$mois_precedant = $mois_relatif - 1;
$mois_suivant = $mois_relatif + 1;
echo "<table width='950'>";
echo "<tr><th></th><th colspan='$fin_mois'><a href='./?mois_relatif=$mois_precedant'><<</a> $nom_mois $annee <a href='./?mois_relatif=$mois_suivant'>>></a></th></tr>";
$requete = "SELECT ind, prenom, nom FROM salaries ORDER BY nom, prenom";
if ($result = mysql_db_query('phpconges', $requete))
{
while ($row = mysql_fetch_array($result))
{
echo ("<tr><th>".$row['nom']." ".$row['prenom']."</th>");
for($k = 1;$k <= $fin_mois; $k++)
{
$jour_semaine = date("w",mktime(0,0,0,$mois,$k,$annee));
if ($jour_semaine == 6 || $jour_semaine == 0)
{
echo ("<td style='padding: 0; width: 23px'>");
echo ("<table style='margin: 0; width: 100%; border: none'>");
echo ("<tr><td style='background: #808080; font-size: 70%; padding: 0px 0px 0px 3px; border: none'>$k</td></tr>");
echo ("<tr><td style='background: #808080; font-size: 70%; padding: 0px 0px 0px 3px; border: none'> </td></tr>");
echo ("</table>");
echo ("</td>");
}
else
{
if ($feries[$mois][$k])
{
echo ("<td style='padding: 0; width: 23px'>");
echo ("<table style='margin: 0; width: 100%; border: none'>");
echo ("<tr><td title='Férié' style='background: yellow; font-size: 70%; padding: 0px 0px 0px 3px; border: none'>$k</td></tr>");
echo ("<tr><td title='Férié' style='background: yellow; font-size: 70%; padding: 0px 0px 0px 3px; border: none'> </td></tr>");
echo ("</table>");
echo ("</td>");
}
else
{
echo ("<td style='padding: 0; width: 23px'>");
echo ("<table style='margin: 0; width: 100%; border: none'><tr>");
switch ($tableau_mois[$row['ind']][$k][0])
{
case "C":
echo ("<td title='Congé' style='background: green; font-size: 70%; padding: 0px 0px 0px 3px; border: none'>$k</td>");
break;
case "A":
echo ("<td title='Absence' style='background: yellow; font-size: 70%; padding: 0px 0px 0px 3px; border: none'>$k</td>");
break;
case "M":
echo ("<td title='Arrêt maladie' style='background: red; font-size: 70%; padding: 0px 0px 0px 3px; border: none'>$k</td>");
break;
default:
echo ("<td style='background: white; font-size: 70%; padding: 0px 0px 0px 3px; border: none'>$k</td>");
}
echo ("</tr><tr>");
switch ($tableau_mois[$row['ind']][$k][1])
{
case "C":
echo ("<td title='Congé' style='background: green; font-size: 70%; padding: 0px 0px 0px 3px; border: none'> </td>");
break;
case "A":
echo ("<td title='Absence' style='background: yellow; font-size: 70%; padding: 0px 0px 0px 3px; border: none'> </td>");
break;
case "M":
echo ("<td title='Arrêt maladie' style='background: red; font-size: 70%; padding: 0px 0px 0px 3px; border: none'> </td>");
break;
default:
echo ("<td style='background: white; font-size: 70%; padding: 0px 0px 0px 3px; border: none'> </td>");
}
echo ("</tr></table>");
echo ("</td>");
}
}
}
echo ("</tr>");
}
}
echo "<tr><th></th><th colspan='$fin_mois'><a href='./?mois_relatif=$mois_precedant'><<</a> $nom_mois $annee <a href='./?mois_relatif=$mois_suivant'>>></a></th></tr>";
?>
</table>
</body>
</html>
D'avance merci.