Page 1 sur 1

eBrigade

Posté : 13 janv. 2015, 16:06
par Dexter.o
Bonjour à tous,

J'utilise eBrigade pour la gestion des planning sapeur pompier de ma caserne et je voudrais que dans la page des saisies je puisse bloquer la saisie, justement, de certains jours à la demande.
Image.

Je vous avoue que je ne sais pas ou chercher, je mets le fichier php et le js en dessous , si une âme charitable à pitié de moi... :priere:

Merci d'avance.
<?php

  # project: eBrigade
  # homepage: http://sourceforge.net/projects/ebrigade/
  # version: 3.3

  # Copyright (C) 2004, 2014 Nicolas MARCHE
  # This program is free software; you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
  # the Free Software Foundation; either version 2 of the License, or
  # (at your option) any later version.
  #
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU General Public License for more details.
  # You should have received a copy of the GNU General Public License
  # along with this program; if not, write to the Free Software
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  
include_once ("config.php");
check_all(38);
$id=$_SESSION['id'];

if ( $gardes == 1 ) {
	if (! isset($_SESSION["month"])) {
		$m1=date("n");
		$y1=date("Y");
		// afficher le mois suivant
		if ( $m1 == 12 )  {
			$m1 = 1;
			$y1= $y1 +1;
		}
		else $m1 = $m1 +1;
		$_SESSION["month"]=$m1;
		$_SESSION["year"]=$y1;
	}
}
get_session_parameters();

if ( $month > 12 ) {
	$month=date('n');
	$_SESSION['month'] = $month;
}

if (isset($_GET["self"])) $person=$id;
else if (isset($_GET["person"])) $person=intval($_GET["person"]);
else $person=0;
if ( $person == 0 ) $person=$id;

$section=$_SESSION['SES_SECTION'];

$moislettres=moislettres($month);
writehead();

echo "<script type=\"text/javascript\" src=\"js/dispo.js\"></script>";

//=====================================================================
// formulaire
//=====================================================================
$yearnext=date("Y") +1;
$yearcurrent=date("Y");
$yearprevious = date("Y") - 1;

echo "<body>";
echo "<form>";

echo "<table  class='noBorder'><tr><td>";
echo "année 
<select name='menu1' onchange=\"fillmenu(this.form,this.form.menu1,this.form.menu2,'".$person."')\">";
if ($year > $yearprevious) echo "<option value='$yearprevious'>".$yearprevious."</option>";
else echo "<option value='$yearprevious' selected>".$yearprevious."</option>";
if ($year <> $yearcurrent) echo "<option value='$yearcurrent' >".$yearcurrent."</option>";
else echo "<option value='$yearcurrent' selected>".$yearcurrent."</option>";
if ($year < $yearnext)  echo "<option value='$yearnext' >".$yearnext."</option>";
else echo "<option value='$yearnext' selected>".$yearnext."</option>";
echo  "</select></td>";

echo "<td>mois <select name='menu2' onchange=\"fillmenu(this.form,this.form.menu1,this.form.menu2,'".$person."')\">";
$m=1;
while ($m <=12) {
      $monmois = $mois[$m - 1 ];
      if ( $m == $month ) echo  "<option value='$m' selected >".$monmois."</option>\n";
      else echo  "<option value= $m >".$monmois."</option>\n";
      $m=$m+1;
}
echo  "</select>";
echo "</td></tr></table>";

echo "<div align=center><font size=4><b>Disponibilités pour $moislettres $year de</b></font><br>";
echo "<select id='filtre' name='filtre' onchange=\"redirect(document.getElementById('filtre').value,'".$month."','".$year."', 'saisie')\">";
$query="select p.P_ID, p.P_PRENOM, p.P_NOM , s.S_CODE 
		from pompier p, section s
		where p.P_SECTION = s.S_ID
		and p.P_OLD_MEMBER = 0 
		and p.P_STATUT <> 'EXT'";

if (( $nbsections == 0 ) and (! check_rights($_SESSION['id'], 24))) {
	$query .= " and P_SECTION in (".get_family($section).")";
}

$query .= " order by P_NOM";
$result=mysqli_query($dbc,$query);

while ($row=@mysqli_fetch_array($result)) {
      $P_NOM=$row["P_NOM"];
      $P_PRENOM=$row["P_PRENOM"];
      $P_ID=$row["P_ID"];
      $S_CODE=$row["S_CODE"];
      echo "<option value='".$P_ID."'";
      if ($P_ID == $person ) echo " selected ";
      if ( $nbsections <> 1 ) $cmt=' ('.$S_CODE.')';
      else $cmt ='';
      echo ">".strtoupper($P_NOM)." ".ucfirst($P_PRENOM).$cmt."</option>\n";
}
echo "</select>";
echo "</form>";

// READY = saisie dispo bloque


$query2="select count(1) as NB from planning_garde_status where EQ_ID = 0 and
       PGS_STATUS='READY' and PGS_MONTH  =".$month."  and PGS_YEAR=".$year;
$result2=mysqli_query($dbc,$query2);
$row2=@mysqli_fetch_array($result2);
$NB2=$row2["NB"];

// permettre de fermer les dispos pour le mois suivant
if ( $gardes == 1  and check_rights($_SESSION['id'],7)) {
	if ( $NB2 > 0 ) {
		echo "<table  class='noBorder'><TR>
            <td><img src=images/warn.png height=48><td>
            <td>La saisie des disponibilités pour ce mois est bloquée.";
              
		echo " <input type='button' value='ouvrir' name='ouvrir' 
				onclick=\"redirect('".$person."','".$month."','".$year."','ouvrir')\"
				title=\"Ouvrir la saisie des disponibilités par le personnel pour ".moislettres($month)." ".$year."\">";
	    echo "</td></tr></table>";
	}
	else if ( $NB2 == 0 ) {
      echo " <input type='button' value='fermer' name='fermer' 
	  		onclick=\"redirect('".$person."','".$month."','".$year."','fermer')\"
			  title=\"fermer la saisie des disponibilités par le personnel pour ".moislettres($month)." ".$year."\">";
	}
}
else if ( $NB2 > 0 ) {
 	echo "<table  class='noBorder'><TR>
            <td ><img src=images/warn.png><td>
            <td >La saisie des disponibilités pour ce mois est bloquée.
			</td></tr></table>";
}


//=====================================================================
// calcul : quel est le mois prochain et combien de jours possède t'il
//=====================================================================
//nb de jours du mois
$d=nbjoursdumois($month, $year);

$query="select P_SECTION from pompier where P_ID=".$person;
$result=mysqli_query($dbc,$query);
$row=@mysqli_fetch_array($result);
$P_SECTION=$row["P_SECTION"];

$disabled='disabled';

if ( check_rights($_SESSION['id'], 10, $P_SECTION )) $disabled="";
elseif ( $person == $_SESSION['id'] ) {
	// dates futures, dispos ouvertes
    if ((date("n") <= $month  and date("Y") == $year) or date("Y") < $year) $disabled="";
    // mais si les dispos sont bloquées, alors on ne peut plus modifier les dispos
	if (( $NB2 > 0 ) and ( $gardes == 1 )) $disabled='disabled';  
}

//=====================================================================
// affiche le tableau
//=====================================================================

echo "<form name=dispo action='save_dispo.php'>";

$queryA="select DP_NAME, DP_CODE, DP_NAME, DP_ID
		from disponibilite_periode ";
if ( $dispo_periodes == 1 ) $queryA .=" where DP_ID= 1";
if ( $dispo_periodes == 2 ) $queryA .=" where DP_ID in (1,4)";
if ( $dispo_periodes == 3 ) $queryA .=" where DP_ID in (1,2,4)";	
$queryA .=" group by DP_ID order by DP_ID";		
$resultA=mysqli_query($dbc,$queryA);

echo "Tout cocher : ";
while ($rowA=@mysqli_fetch_array($resultA)) {
	$DP_ID=$rowA['DP_ID'];
	$DP_NAME=convert_period_name($DP_ID,$rowA['DP_NAME'],$dispo_periodes);
	echo $DP_NAME." <input type='checkbox' name='CheckAll".$DP_ID."' onclick=\"CheckAll('".$DP_ID."',this.checked);\" $disabled title=\"".$DP_NAME.": tout cocher\" />";
}

$i=1;
echo "<input type='hidden' name='nbjours' value=$d size='20'>";
echo "<input type='hidden' name='person' value=$person size='20'>";
echo "<input type='hidden' name='month' value=$month size='20'>";
echo "<input type='hidden' name='year' value=$year size='20'>";

echo "<p>
<table cellspacing=0 border=0 >
    <tr height=10>
      <td width='50' class=TabHeader align=center>Lu</font></td>
      <td bgcolor=$mydarkcolor width='0'></td>
      <td width='50' class=TabHeader align=center>Ma</td>
      <td bgcolor=$mydarkcolor width='0'></td>
      <td width='50' class=TabHeader align=center>Me</td>
      <td bgcolor=$mydarkcolor width='0'></td>
      <td width='50' class=TabHeader align=center>Je</td>
      <td bgcolor=$mydarkcolor width='0'></td>
      <td width='50' class=TabHeader align=center>Ve</td>
      <td bgcolor=$mydarkcolor width='0'></td>
      <td width='50' class=TabHeader align=center>Sa</td>
      <td bgcolor=$mydarkcolor width='0'></td>
      <td width='50' class=TabHeader align=center>Di</td>
    </tr>
";

$CURDATE=date('Y').date('m').date('d');

$l=1;
$i=1;
// le mois commence par un $jj
$jj=date("w", mktime(0, 0, 0, $month,$i,$year));
$i=1;$k=$i;
if ( $jj == 0 ) $jj=7; // on affecte 7 au dimanche, (lundi=1)

while ( $l <= 6 ) { // boucle des semaines
	echo "\n    <tr height=20 >\n";
    // cases vides en début de mois
    while ( $k < $jj ) {
      	    echo "<td width='50' bgcolor=$mylightcolor >
     	    	  <table  class='noBorder'>
	  	      <tr height=30 >
    	 	      </tr>
		  </table>
	     	  </td>\n";
 	     if ( $k < 7 ) echo "<td bgcolor=$mydarkcolor  width='0'></td>\n";
    	     $k=$k+1;
    }
      
    // jours de 1 à $d variable $i
    while (( $jj <= 7 ) &&  ($i <= $d)) { // boucle des jours de la semaine
		$checked = array();
		
		$DAYDATE=$year.str_pad($month, 2, '0', STR_PAD_LEFT).str_pad($i, 2, '0', STR_PAD_LEFT);
		
		for ( $z=1; $z <= 4; $z++ ) {
			$checked[$z]='';
		}
	
		$query="select PERIOD_ID from disponibilite
      	    where P_ID=".$person."
      	    and D_DATE='".$year."-".$month."-".$i."'";
		$result=mysqli_query($dbc,$query);
     	while ( $row=@mysqli_fetch_array($result)) {
			$checked[$row[0]]='checked';
		}
		
		$_dt= mktime(0,0,0,$month,$i,$year);
		if (dateCheckFree($_dt)) $mycolor=$yellow ; else  $mycolor=$white;
		if (($nbsections == 3 ) and ( get_section_pro_jour( 1,$year, $month, $i) == $P_SECTION )) $mycolor="#00CC00";
		if ( is_out($person, $year, $month, $i) <> 0 ) $mycolor="#FF0000";
		if ( $DAYDATE < $CURDATE ) $disableddate='disabled';
		else $disableddate='';
		
		echo "<td bgcolor=$mycolor>
     	    	<table  class='noBorder'>
				<tr height=10>
					<td align=center colspan=4><b>".$i."</b></td>
				</tr>
	    	    <tr height=20>";
		if ( $dispo_periodes == 1 )
            echo " 	<td width='50' align=center colspan=4><input type='checkbox' name='1_".$i."' value='1' onClick=\"updateTotal(this,total1)\" $disableddate $disabled $checked[1] title='dispo 24h '></td>";		
		if ( $dispo_periodes == 2 )
            echo " 	<td width='25' class=small2 colspan=2>A<br><input type='checkbox' name='1_".$i."' value='1' onClick=\"updateTotal(this,total1)\" $disableddate $disabled $checked[1] title='dispo Astreinte'></td>
	    	      	<td width='25' class=small2 colspan=2>A/G<br><input type='checkbox' name='4_".$i."' value='1' onClick=\"updateTotal(this,total4)\" $disableddate  $disabled $checked[4] title='dispo Ast/garde'></td>";
		if ( $dispo_periodes == 3 )
            echo " 	<td width='15' class=small2 colspan=2>M<br><input type='checkbox' name='1_".$i."' value='1' onClick=\"updateTotal(this,total1)\" $disableddate $disabled $checked[1] title='dispo matin'></td>
					<td width='15' class=small2 >AM<br><input type='checkbox' name='2_".$i."' value='1' onClick=\"updateTotal(this,total2)\" $disableddate $disabled $checked[2] title='dispo après-midi'></td>
	    	      	<td width='15' class=small2 >N<br><input type='checkbox' name='4_".$i."' value='1' onClick=\"updateTotal(this,total4)\" $disableddate $disabled $checked[4] title='dispo nuit'></td>";
		if ( $dispo_periodes == 4 )
            echo " 	<td width='12' class=small2 colspan=2>AJ<br><input type='checkbox' name='1_".$i."' value='1' onClick=\"updateTotal(this,total1)\" $disableddate $disabled $checked[1] title='dispo Astreinte jour'></td>
					<td width='12' class=small2 >AN<br><input type='checkbox' name='2_".$i."' value='1' onClick=\"updateTotal(this,total2)\" $disableddate $disabled $checked[2] title='dispo Astreinte nuit'></td>
					<td width='12' class=small2 >GJ<br><input type='checkbox' name='3_".$i."' value='1' onClick=\"updateTotal(this,total3)\" $disableddate $disabled $checked[3] title='dispo Garde jour'></td>
	    	      	<td width='12' class=small2 colspan=2>GN<br><input type='checkbox' name='4_".$i."' value='1' onClick=\"updateTotal(this,total4)\" $disableddate $disabled $checked[4] title='dispo Garde nuit'></td>";
	    echo "</tr>
			</table>
	     	</td>";
		if ( $jj < 7 ) echo "<td bgcolor='$mydarkcolor'  width='0'></td>\n";
		$jj=$jj+1;
		$i=$i+1;
	}
    // cases vides en fin de tableau
    while (( $i <= ( 7 * $l +1 ) - $k ) && ( $i > $d )) {
      	    echo "<td width='50' bgcolor=$mylightcolor >
     	    	 <table  class='noBorder'>
	  	      <tr height=30>
    	 	      </tr>
		  </table>
	     	  </td>\n";
	     if ( date("w", mktime(0, 0, 0, $month,$i,  $year)) <> 0 )	
		 	echo "<td bgcolor=$mydarkcolor  width='0'></td>\n";
    	 $i=$i+1;
    }

    echo "    </tr>\n";
    if ( $i > $d ) $l=7;
    else $l=$l+1;
    $jj=1;

	if ( $l <= 6 ) echo "<tr height=1><td bgcolor=$mydarkcolor width=350 colspan=13></td></tr>\n";	
}

echo "</table>";

// légende
echo "<p><table class='noBorder'><tr height=12>";
if ( $nbsections == 3 ) {
	echo "<td bgcolor=#00CC00 width=14 style='border: 1px solid;'></td>
     <td class=small> Section de garde </td>";
}
echo "<td bgcolor=#FF0000 width=14 style='border: 1px solid;'></td>
     <td class=small> Absent </td>";

echo "<td bgcolor=#FFFF99 width=14 style='border: 1px solid;'></td>
    <td class=small> WE/Férié </td>";

echo "<td bgcolor=#FFFFFF width=14 style='border: 1px solid;'></td>
    <td class=small> Semaine </td>";
	
echo "</tr></table>";

echo "<p><table class='noBorder'><tr>";
			
	
$resultA=mysqli_query($dbc,$queryA);
while ($rowA=@mysqli_fetch_array($resultA)) {
	$DP_ID=$rowA['DP_ID'];
	$DP_NAME=convert_period_name($DP_ID,$rowA['DP_NAME'],$dispo_periodes);

	$query2="select count(1) as NB from disponibilite  
		where P_ID=".$person."
		and D_DATE >='".$year."-".$month."-01'
		and D_DATE <='".$year."-".$month."-".$d."'
		and PERIOD_ID =".$DP_ID;
	$result2=mysqli_query($dbc,$query2);
	$row2=@mysqli_fetch_array($result2);
	echo "<td><b>".$DP_NAME.":</b> 
		<input id='total".$DP_ID."' name='total".$DP_ID."' 
			value='".$row2['NB']."' readonly style='FONT-SIZE: 10pt;border:0px; color:$mydarkcolor; font-weight:bold;' size=2>
		</td>";
}

// la personne habilitée peut valider les dispos
if ( $disabled == "") {
     	  echo "<td align=center> <input type='submit' value='Valider'></td>";
}
echo "</tr></table>";


echo "</form></div>";
?>
  

[javascript]//-- Global Variables
var RowsInForm = 5

function fillmenu(frm, menu1,menu2,person) {
year=frm.menu1.options[frm.menu1.selectedIndex].value;
month=frm.menu2.options[frm.menu2.selectedIndex].value;
url = "dispo.php?month="+month+"&year="+year+"&person="+person;
self.location.href = url;
}

//=====================================================================
// Mise à jour des totaux
//=====================================================================

//-- Updates the totals in the lower part of table.
function updateTotal(mybox,totalbox) {
var V = parseInt(totalbox.value);
if ( mybox.checked ) {
totalbox.value = V + 1;
}
else {
totalbox.value = V - 1;
}
}

//=====================================================================
// choix personne
//=====================================================================
function redirect(p1,p2,p3,p4) {
if ( p4 == 'saisie' ) {
url="dispo.php?person="+p1+"&month="+p2+"&year="+p3;
self.location.href=url;
}
if ( p4 == 'ouvrir' ) {
if ( confirm ("Attention : Vous allez permettre la saisie des disponibilités pour le mois "+p2+"/"+p3+" par tout le personnel.\nLes agents pourront de nouveau modifier leur disponibilités.\nConfirmer ?" )) {
cible="tableau_garde_status.php?month="+p2+"&year="+p3+"&action=ouvrir&section=0";
self.location.href = cible;
}
}
if ( p4 == 'fermer' ) {
if ( confirm ("Attention : Vous allez bloquer la saisie des disponibilités pour le mois "+p2+"/"+p3+".\nLes agents ne pourront plus saisir ou modifier leur disponibilités pour le mois suivant.\nConfirmer ?" )) {
cible="tableau_garde_status.php?month="+p2+"&year="+p3+"&action=fermer&section=0";
self.location.href = cible;
}
}

}

//=====================================================================
// check all
//=====================================================================
function CheckAll(field,checkValue){
var dForm = document.dispo;
var F = 'total'+field;
var V = document.getElementById(F).value;

// Vérif du compteur
document.getElementById(F).value = ((checkValue!=true)? V:0 );

// Parcours des jours et mise à jour des cases à cocher
for (i=0;i<dForm.length;i++)
{
var element = dForm;
if (element.type=='checkbox'){
var G = 'total'+element.name.substring(0,1);
var B = document.getElementById(G);
if (element.name.substring(0,1)==field){
if ( element.disabled == false ) {
element.checked = ((checkValue!=true)?false:true);
updateTotal(element,B);
}
}
}
}
}[/javascript]

Re: eBrigade

Posté : 16 janv. 2015, 00:18
par Dexter.o
Personnes pour m'aider ou j'ai pas poser les bonnes questions ?

Re: eBrigade

Posté : 16 janv. 2015, 02:20
par @rthur
Bonjour Dexter.o,

Je déplace ton sujet dans un forum plus approprié ce qui devrait je l'espère te permettre d'avoir des réponses :)

Re: eBrigade

Posté : 16 janv. 2015, 19:33
par sirakawa
Je réponds en espérant trouver dans quel forum il a été déplacé.
J'ai vu qu'il n'y a pas l'ombre d'un support sur SourceForge pour Ebrigade. Ca veut dire qu'il faudrait se palucher tout le code:
Une idée :
voir la structure de la table et ajouter un champ 'bloque" puis trouver le moyen de le mettre à jour (un script à ajouter) et de l'utilser (un script à modifier)

Re: eBrigade

Posté : 17 janv. 2015, 01:10
par Dexter.o
Merci sirakawa pour ton intérêt.

Je suis allé voir la structure de la table "disponibilité" mais je n'ai pas vu de type "bloque"

Pour ce qui est de créer ou de modifier un scripte il me faudra beaucoup d'aide car je suis à la rue .... :oops:

J'ai pris contact avec un développeur de eBrigade qui me dit:
Une nouvelle version 3.3 est disponible depuis le mois dernier. Dans cette nouvelle version, la saisie des disponibilités est bloquée pour les jours du passé.

Par contre il n’y a pas de possibilité pour bloquer des jours au choix.

Tu peux essayer de développer cette fonction, pour cela il faudra modifier le fichier dispo.php
Je suis en 3.3.

Mais ton idée me parait bien ...