0x1998 - MANAGER
Edit File: activite.php
<?php include "config/auth-config.php"; include "config/authcheck.php"; include "config/garde.php"; // JE DEFINI LA VARIABLE $_SESSION['id'] qui définit de quel user je regarde le calendrier $_SESSION['id'] = !isset($_SESSION['id']) ? $_SESSION['user'] : $_SESSION['id']; // $liste=autor_liste($_SESSION['id']); $categorie=$_SESSION['categorie']; //----------------------------------------------------------- // Calcul des obligations de service $sql="select presence from user_type where id='".$_SESSION['id']."'"; $result=mysqli_query($link,$sql); $a_row=mysqli_fetch_array($result); $presence_mois=($a_row['presence']*185); $presence_quadri=$presence_mois*4; mysqli_free_result($result); //----------------------------------------------------------- if (isset($_GET['current_month'])) $current_month=$_GET['current_month']; if (isset($_GET['current_year'])) $current_year=$_GET['current_year']; // VERIFICATION if ($categorie!='Med' && !verif_autor($_SESSION['user'],8)) { $msg="Vos autorisations sont insuffisantes pour cette action"; echo "<meta http-equiv=\"refresh\" content=\"0;url=accueil.php?msg=$msg\"> "; die(); } if ( (isset($current_month) && $current_month=="") || !isset($current_month)) { $current_month=date("m",time()); $current_year=date("Y",time()); } if ($current_month=="0") { $current_month="12"; $current_year=$current_year-1; } else if ($current_month>="13") { $current_month=$current_month-12; $current_year=$current_year+1; } if (strlen($current_month)==1) { $current_month="0".$current_month; } $next_month=$current_month+1; $firstday_nextmonth=mktime(12,0,0,$next_month,1,$current_year); $firstday_currentmonth=mktime(0,0,0,$current_month,1,$current_year); $lastday_previousmonth=$firstday_currentmonth-86400; $lastday_currentmonth=$firstday_nextmonth - 86400; $get_lastday_previousmonth=getdate($lastday_previousmonth); $get_lastday_currentmonth=getdate($lastday_currentmonth); $get_firstday_nextmonth=getdate($firstday_nextmonth); $get_firstday_currentmonth=getdate($firstday_currentmonth); $currentmonth_firstday=$get_firstday_currentmonth['wday']; $previousmonth_lastday=$get_lastday_previousmonth['mday']; $currentmonth_lastday=$get_lastday_currentmonth['mday']; $requete="select limit_bloc from limite_dispo where limit_month='".$current_month."' AND limit_year='".$current_year."' and limit_categorie='".$categorie."' and limit_type='activite'"; $result = mysqli_query($link,$requete) or die("requete impossible ...$requete"); $b_row=mysqli_fetch_array($result); if ($b_row[0]!='Y') { $depot=1; } else { $depot=0; $msg = " gelées par l'administrateur !"; } $mois_encours=array(1=>"Janvier", 2=>"Février", 3=>"Mars", 4=>"Avril", 5=>"Mai", 6=>"Juin", 7=>"Juillet", 8=>"Août", 9=>"Septembre", 10=>"Octobre", 11=>"Novembre", 12=>"Décembre"); $bb=date("n",$firstday_currentmonth); // CHARGEMENT DES VALEURS ------------------- // // MATIN $sql="select day(activite_date) as jour, list_activite_abrege, list_activite_label from activite inner join list_activite on activite_activite=list_activite_id where `activite_user`='".$_SESSION['id']."' and month(activite_date)='".$current_month."' and year(activite_date)='".$current_year."' and activite_type='M' order by jour"; $result=mysqli_query($link,$sql); while ($a_row=mysqli_fetch_array($result)) { $index=$a_row[0]; $matin[$index]=$a_row[1]; $colormatin[$index]=$a_row[2]; } //--------------------------------- // // APRES MIDI $sql="select day(activite_date) as jour, list_activite_abrege, list_activite_label from activite inner join list_activite on activite_activite=list_activite_id where `activite_user`='".$_SESSION['id']."' and month(activite_date)='".$current_month."' and year(activite_date)='".$current_year."' and activite_type='AM' order by jour"; $result=mysqli_query($link,$sql); while ($a_row=mysqli_fetch_array($result)) { $index=$a_row[0]; $apres_midi[$index]=$a_row[1]; $colorapres_midi[$index]=$a_row[2]; } //--------------------------------- //SOIR $sql="select day(activite_date) as jour, list_activite_abrege, list_activite_label from activite inner join list_activite on activite_activite=list_activite_id where `activite_user`='".$_SESSION['id']."' and month(activite_date)='".$current_month."' and year(activite_date)='".$current_year."' and activite_type='S' order by jour"; $result=mysqli_query($link,$sql); while ($a_row=mysqli_fetch_array($result)) { $index=$a_row[0]; $soir[$index]=$a_row[1]; $colorsoir[$index]=$a_row[2]; } //--------------------------------- // NUIT $sql="select day(activite_date) as jour, list_activite_abrege, list_activite_label from activite inner join list_activite on activite_activite=list_activite_id where `activite_user`='".$_SESSION['id']."' and month(activite_date)='".$current_month."' and year(activite_date)='".$current_year."' and activite_type='N' order by jour"; $result=mysqli_query($link,$sql); while ($a_row=mysqli_fetch_array($result)) { $index=$a_row[0]; $nuit[$index]=$a_row[1]; $colornuit[$index]=$a_row[2]; } //--------------------------------- ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <head> <title>Activité</title> <?php entete(); ?> <link href="config/stylePage.css" rel="stylesheet" type="text/css" /> <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> <script type="text/javascript"> $(document).ready(function() { $('#update').on('change', function() { change=this.value; if (change!='') $('.update').val(change); }); $("#conges").click(function(){ $("#myModalLabel").html("<center>Congés</center>"); var loadurl='modal_conges.php?'; var targ="#modal-body"; $.get(loadurl, function(data) { $(targ).html(data); $("#modal").modal('show'); }); }); $("#session").click(function(){ $("#myModalLabel").html("<center>Session</center>"); var loadurl='modal_session.php'; var targ="#modal-body"; $.get(loadurl, function(data) { $(targ).html(data); $("#modal").modal('show'); }); }) }); function envoiForm2() { $.ajaxSetup({async: false}); if (!validForm('sessionz','0')) return false; $.post( "garde_do.php", $( "#sessionz" ).serialize(), function(html) {$("#modal").modal('hide'); window.location.reload(); } ); return false; } function envoiForm3() { $.ajaxSetup({async: false}); $.post( "garde_do.php", $( "#modifJour" ).serialize(), function(html) {$("#modal").modal('hide'); window.location.reload(); } ); return false; } function change(month,year) { window.location.href="activite.php?current_month="+month+"¤t_year="+year; } function verifTextarea() { maxlength=150; if (document.activite.rem.value.length > maxlength) { alert('Votre remarque ne doit pas dépasser '+maxlength+' caractères!'); return false; } } function badge(jour,mois,annee,js) { // On test si depot=1 sinon il ne se passe rien var depot=document.activite['depot'].value; if (depot==1) { $("#myModalLabel").html("<center>"+jour+"/"+mois+"/"+annee+"</center>"); var loadurl='modal_jour.php?annee='+annee+'&mois='+mois+'&jour='+jour+'&js='+js; var targ="#modal-body"; $.get(loadurl, function(data) { $(targ).html(data); $("#modal").modal('show'); }); } else alert("L'écran a été gelé, vous ne pouvez plus faire de modification"); } function closeModal() { $("#modal").modal('hide'); } </script> </head> <body> <div class="col-md-12 "> <div class="panel panel-primary"> <div class="panel-heading"> <h3><center>Activité</center></h3> </div> <div class="panel-body"> <?php if (isset($_GET['msg'])) { $msg=$_GET['msg']; echo "<tr><td class=\"intro\"><font color=red><center>$msg</center></font></td></tr>"; } // DEBUT du FORMULAIRE echo " <div class=\"row\"> <div class=\"col-md-12\"><center> Bienvenue ".$liste['nom']; if (autor($_SESSION['user'],8)) { echo " <span class=\"glyphicon glyphicon-user\" aria-hidden=\"true\" title=\"cliquez pour changer d'utilisateur\" id=\"session\"></span>"; } echo" <div style=\"text-align:center; font-weight:bold;\">Activité de ".$mois_encours[$bb]." ".$current_year."</div> "; if (autor($_SESSION['user'],8)) { print " <div style=\"text-align:center;\"> <form method=\"post\" name=\"limit_dispo\" action=\"insertEnreg.php\" > Geler les activités : NON <input type=\"radio\" name=\"lvalue[0]\" value=\"N\" "; if ($b_row[0]!='Y') echo " checked"; echo " /> OUI <input type=\"radio\" name=\"lvalue[0]\" value=\"Y\" "; if ($b_row[0]=='Y') echo " checked"; echo " /> <input type=\"hidden\" name=\"lvalue[1]\" value=\"$current_month\" /> <input type=\"hidden\" name=\"lvalue[2]\" value=\"$current_year\" /> <input type=\"hidden\" name=\"lvalue[3]\" value=\"$categorie\" /> <input type=\"submit\" class=\"btn btn-primary\" name=\"enregLimitActivite\" value=\"Enregistrer\" /> </form><br/></div>"; } echo" </center></div> </div>"; // PANEL N°2-1 echo" <div class=\"col-md-9\"> <div class=\"row\"> <div class=\"col-md-12\"> <div class=\"panel panel-primary\"> <div class=\"panel-body\"><center>"; // TABLEAU DES DISPOS .... print " <form method=\"post\" name=\"activite\" action=\"insertEnreg.php\" onsubmit=\"return verifTextarea()\" > <input type=\"hidden\" name=\"mois\" value=\"".$current_month."\" /> <input type=\"hidden\" name=\"annee\" value=\"".$current_year."\" /> <input type=\"hidden\" name=\"depot\" value=\"".$depot."\" /> <table class=\"table table-bordered\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" > <tr> <td width=\"110\" style=\"text-align:center;\">Lun</td> <td width=\"110\" style=\"text-align:center;\">Mar</td> <td width=\"110\" style=\"text-align:center;\">Mer</td> <td width=\"110\" style=\"text-align:center;\">Jeu</td> <td width=\"110\" style=\"text-align:center;\">Ven</td> <td width=\"110\" style=\"text-align:center;\">Sam</td> <td width=\"110\" style=\"text-align:center;\">Dim</td></tr> <tr>"; //------------------------------------ // Grisage des premières cellules //------------------------------------ $java=2; $compteur=1; $previous_month=$current_month-1; $previous_year=$current_year; if ($previous_month==0) { $previous_month=12; $previous_year=$current_year-1; } $js=$currentmonth_firstday; if ($js=="0") $js="7"; if ($js!=1) { $jjs=1; for ($counter2=$js-1;$counter2>=1;$counter2--) { creatcell ("#D8D8D8","#D8D8D8","","","","","","",$previousmonth_lastday+1-$counter2,$jjs,"2",$compteur); $compteur++; $java=$java+1; $jjs++; } } //------------------------------------ // Cellules du mois en cours //------------------------------------ for ($counter3=1;$counter3<=$currentmonth_lastday;$counter3++) { $couleurmatin=(isset($colormatin[$counter3])) ? $colormatin[$counter3]:''; $couleurapres_midi=(isset($colorapres_midi[$counter3])) ? $colorapres_midi[$counter3]:''; $couleursoir=(isset($colorsoir[$counter3]))? $colorsoir[$counter3] :''; $couleurnuit=(isset($colornuit[$counter3]))? $colornuit[$counter3] :''; $valmatin=(isset($matin[$counter3])) ? $matin[$counter3]:''; $valapres_midi=(isset($apres_midi[$counter3])) ? $apres_midi[$counter3]:''; $valsoir=(isset($soir[$counter3])) ? $soir[$counter3]:''; $valnuit=(isset($nuit[$counter3])) ? $nuit[$counter3]: ''; creatcell ($couleurmatin,$couleurapres_midi,$couleursoir,$couleurnuit,$valmatin,$valapres_midi,$valsoir,$valnuit,$counter3,$js,"1",$compteur); $compteur++; $java=$java+5; if ($js=="7") { echo "</tr><tr>"; $js="1"; } else { $js=$js+1; } } $jj=1; //------------------------------------ // Cellules du mois suivant //------------------------------------ $next_year=$current_year; if ($next_month==13) { $next_month=1; $next_year++; } if ($js!=1) { for ($counter4=$js;$counter4<=7;$counter4++) { creatcell ("#D8D8D8","#D8D8D8","#D8D8D8","#D8D8D8","","","","",$jj,$counter4,"2",$compteur); $jj++; $compteur++; } } echo " </tr></table>"; $query="select du_rem from dispo_user where du_year='".$current_year."' AND du_user='".$_SESSION['id']."' AND du_month='".$current_month."' AND du_type='activite'"; $result=mysqli_query($link,$query); $a_row=mysqli_fetch_array($result); echo" <br/> <center> Remarques : <br/> <textarea placeholder=\" 150 caractères maximum ! Soyez concis\" name=\"rem\" rows=\"3\" cols=\"40\" class=\"form-control\">".$a_row[0]."</textarea> <br/>"; if ($depot==1) echo "<input type=\"submit\" name=\"enregActiviteNew\" value=\"Enregistrer\" class=\"btn btn-primary\" />"; echo " </center></form><br/>"; echo '<table align="center"><tr>'; echo "<td align=\"left\"> "; print "<a href=\"#\" onclick='change($current_month-1,$current_year)'>Mois précédent</a> "; echo '</td><td align="center">'; print "<select size=\"1\" class=\"form-control\" name=\"Mois\" onchange=\"change(this[this.selectedIndex].value,$current_year)\">"; for ($counter=1;$counter<13;$counter++) { $mois=date("n",mktime(0,0,0,$counter,1,$current_year)); print "<option "; if ($counter==$current_month) { print "selected=\"selected\" "; } print "value=\"$counter\">$mois_encours[$mois]</option>"; } print "</select></td><td align=\"right\"> <a href=\"javascript:change($current_month+1,$current_year)\">Mois suivant</a> </td></tr></table>"; // FIN PANEL 2.1 echo " </center></div> </div> </div>"; // fin div col=12 echo " <div class=\"col-md-12\"> <center><button class=\"btn btn-default\" onclick=\"location.href = 'accueil.php'\">Retour à l'accueil</button></center> </div> </div></div> "; // DEBUT DU PANEL 2.2 echo" <div class=\"col-md-3\"> <div class=\"panel panel-primary\"> <div class=\"panel-heading\"> <center>Légende</center> </div> <div class=\"panel-body\"><center><small> Ast : Astreinte</br> Med : Médicalisation</br> Mis : Mission<br/> Reg : Régulation<br/> Ren : Renfort<br/> Tr : Transport<br/> CA / RTT / RTa : Absence </small> <span class=\"glyphicon glyphicon-exclamation-sign\" aria-hidden=\"true\" title=\"cliquez pour plus d'explications\" id=\"conges\"></span>"; // FIN DU PANEL 2.2 echo " </center></div> </div>"; ?> <div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title" id="myModalLabel"></h4> </div> <div class="modal-body" id="modal-body"> <center><img src="./config/ajax-bar.gif" /> <br/> Merci de patienter </center> </div> </div> </div> </div> <?php // DEBUT DU PANEL 2.3 $intitule="Votre actvité du mois"; echo" <div class=\"panel panel-primary\"> <div class=\"panel-heading\"> <center>".$intitule."</center> </div> <div class=\"panel-body\">"; include_stats($current_month,$current_year); echo" </center></div> </div>"; // DEBUT DU PANEL 2.4 $intitule="Votre actvité du quadrimestre"; echo" <div class=\"panel panel-primary\"> <div class=\"panel-heading\"> <center>".$intitule."</center> </div> <div class=\"panel-body\">"; include_stats_quadri($current_month,$current_year); echo" </center></div> </div>"; echo" </div>"; // FIN DU FORMULAIRE ET DE LA CELLULE ?> </div> </div> </div> </body> </html> <?php // FONCTIONS function creatcell($colormatin,$colorapres_midi,$colorsoir,$colornuit,$valmatin,$valapres_midi,$valsoir,$valnuit,$text,$js,$sel,$compteur) { global $listeSelect; global $java; global $current_year; global $current_month; global $categorie; //$nbre_select=count($listeSelect[0]); print "<td width=\"100\" valign=\"top\" bgcolor=\"#FFFFFF\" class=\"calendar\"> <div class=\"row\"> <div class=\"col-md-7\"> <div class=\"row\">"; // --- Jour // Les 2 sont égaux if ($valmatin==$valapres_midi && $valmatin!="") { echo"<div class=\"col-md-12\" align=\"center\"><span class=\"label label-".$colormatin."\">".$valmatin." Jour</span></div>"; } elseif ($valmatin==$valapres_midi && $valmatin=="") { echo"<div class=\"col-md-12\" align=\"center\"><p></div>"; } else { echo "<div class=\"col-md-6\" align=\"center\"><span class=\"label label-".$colormatin."\">".$valmatin."</span></div> <div class=\"col-md-6\" align=\"center\"><span class=\"label label-".$colorapres_midi."\">".$valapres_midi."</span></div>"; } echo" </div> <div><p></div> <div class=\"row\">"; // Les 2 sont égaux if ($valsoir==$valnuit && $valsoir!="") { echo"<div class=\"col-md-12\" align=\"center\"><span class=\"label label-".$colorsoir."\">".$valsoir." Nuit</span></div>"; } elseif ($valsoir==$valnuit && $valsoir=="") { echo"<div class=\"col-md-12\" align=\"center\"><p></div>"; } else { echo "<div class=\"col-md-6\" align=\"center\"><span class=\"label label-".$colorsoir."\">".$valsoir."</span></div> <div class=\"col-md-6\" align=\"center\"><span class=\"label label-".$colornuit."\">".$valnuit."</span></div> "; } echo" </div> </div> <div class=\"col-md-2\"> <span class=\"badge\" "; if ($sel==1) echo "style=\"cursor: pointer;\" onclick=\"badge('".$text."','".$current_month."','".$current_year."','".$js."')\" "; echo ">".$text."</span> </div> </div> </td>"; } function include_stats($month,$year) { global $link, $presence_mois; $id=$_SESSION['id']; $query="select if((activite_type='AM' or activite_type='M'),'J','N') as type, count(distinct(activite_date)), sum(if((activite_type='M' or activite_type='AM'), list_activite_presenceJ, list_activite_presenceN)) as volume from activite, list_activite where activite_activite=list_activite_id and activite_user='".$id."' and month(activite_date)='".$month."' and year(activite_date)='".$year."' and activite_activite<>11 and activite_activite<>15 group by type"; $result=mysqli_query($link,$query); while ($a_row=mysqli_fetch_array($result)) { $index=$a_row[0]; $stats0[$index]=$a_row[1]; $volume0[$index]=$a_row['volume']; } echo" <table class=\"table table-bordered\" style=\"font-size:12px;\"> <tr> <th style=\"text-align: center;\">Type</th> <th>Nombre</th> <th>Heures</th> </tr>"; if (isset($stats0)) { $total=0; foreach ($stats0 as $key => $value) { if ($key=='J') $legende='Jour'; else if ($key=='N') $legende='Nuit'; echo" <tr> <td>".$legende."</td> <td>".$value."</td> <td>".$volume0[$key]."</td> </tr>"; $total=$total+$volume0[$key]; } echo "<tr><td></td><td>Total</td><td>".$total." (Obligation : ".$presence_mois.")</td></tr>"; } echo "</table>"; } function include_stats_quadri($month,$year) { global $mois_encours, $link, $presence_quadri; if ($month<=4) {$firstmonth=1; $lastmonth=4;} else if ($month>4 && $month<=8) {$firstmonth=5; $lastmonth=8;} else if ($month>8) {$firstmonth=9; $lastmonth=12;}; $id=$_SESSION['id']; /* $query="select month(activite_date) as 'Mois', sum(if((activite_type='M' or activite_type='AM'), list_activite_presenceJ, list_activite_presenceN)) as 'volume' from activite, list_activite where activite_activite=list_activite_id and activite_user='".$id."' and (month(activite_date)>='".$firstmonth."' and month(activite_date)<='".$lastmonth."') and year(activite_date)='".$year."' group by Mois"; */ $query="select * from solde_activite where activite_user=".$id." and year=".$year." and month>=".$firstmonth." and month<=".$lastmonth; $result=mysqli_query($link,$query); while ($a_row=mysqli_fetch_array($result)) { $index=$a_row[1]; $volume0[$index]=$a_row['Total']; $volume1[$index]=$a_row['Total P']; $volume2[$index]=$a_row['Total NC']; } echo" <table class=\"table table-bordered\" style=\"font-size:12px;\"> <tr> <th>Mois</th> <th>Total</th> <th>Posté</th> <th>NC</th> </tr>"; if (isset($volume0)) { $total=0; foreach ($volume0 as $key => $value) { echo" <tr> <td>".$mois_encours[$key]."</td> <td>".$value."</td> <td>".$volume1[$key]."</td> <td>".$volume2[$key]."</td> </tr>"; $total=$total+$volume0[$key]; } echo "<tr><td>Total</td><td colspan=3>".$total." (Obligation : ".$presence_quadri.")</td></tr>"; } echo "</table>"; } function rechClass($valeur,$moyenne) { if ($valeur<$moyenne-5) { $class="class='danger'"; } elseif ($moyenne-5<=$valeur && $valeur<=$moyenne+5) { $class="class='warning'"; } elseif($valeur>$moyenne+5) { $class="class='success'"; } return $class; } mysqli_close($link); ?>