Location: PHPKode > projects > EmploiNet : a timetable web manager > EmploiNet/v0.8.0/edt/Planification/reparti.php3
<?
include("../../BarreDeMenu.php3");
include("../../Session/security.php");
// Entete
if (!isset($display)) $display=1;
buildHeader("Emploi du temps semaine",$display);

// Verification de la session
$autorisation_list[0]=0; // Administrateur
$autorisation_list[1]=3; // Gestionnaire
$user_type = validateSession($id_session);
if ($user_type == -1 || !security($id_session,$autorisation_list))
{
  print("Accès refusé");
  print("<DIV ALIGN=RIGHT><A HREF=\"javascript:history.go(-1);\">Retour</A></DIV>\n");
}
else
{
  // Barre de menu
  buildMenuBar($id_session,$user_type,"reparti.php3",false);
  // Ouverture de la connexion avec la base de donnees
  $connection = openConnection($databaseName);
  // Verifie si le nombre de promotions est egal a 1
  if ($user_type==3 && !isset($id_promotion[0])) 
    {
      $user_id = getUserID($id_session);
      $connection = openConnection($databaseName);
      $result = mysql_query("SELECT distinct(promotion.id_promotion),
			diplome.libelle as L1,promotion.libelle as L2 
			FROM promotion,diplome,gerer
			WHERE gerer.id_gestionnaire=$user_id AND promotion.id_promotion=gerer.id_promotion
			AND diplome.id_diplome=promotion.id_diplome ORDER BY diplome.libelle");
      $index_max = mysql_num_rows($result);
      if ($index_max == 1)
	{
	  $a_record = mysql_fetch_array($result);
	  $id_promotion[0] = $a_record["id_promotion"];
	  $id_groupe = -1;
	}
    }
  // Variables globales
  $G_id_matiere;
  $G_nom;
  $G_nb_matieres;
  if (isset($id_promotion)) $n = count($id_promotion); // nombre de promotions selectionnees
  else $n = 0;
  // Constantes
  $week_number = 10;	
  if (!isset($week_shift)) $week_shift = 0;
  $trainning_number = 7;
  if (!isset($trainning_shift)) $trainning_shift = 0;
  // Traitement des evenements Promotion, Groupe et scrolling 
  switch ($choice)
    {
    case -1: // changement de promotion
      {
	unset($id_periode);
	unset($grille);
	unset($nb_lignes);
	unset($nb_total_heures);
	unset($somme_heures);
	$trainning_shift=0;
	$id_groupe = -1;
	break;
      }
    case -2: // changement de groupe
      {
	unset($grille);
	unset($nb_lignes);
	unset($nb_total_heures);
	unset($somme_heures);
	$trainning_shift=0;
	if ($id_groupe != -1)
	  {
	    $result2 = mysql_query("SELECT * FROM associer WHERE id_groupe=$id_groupe[0]");
	    $n = mysql_num_rows($result2);
	    for ($i=0;$i<$n;$i++)
	      {
		$une_promotion = mysql_fetch_array($result2);
		$id_promotion[$i] = $une_promotion["id_promotion"];
	      }
	  }
	break; 
      }
    case -3: // changement de periode
      {
	unset($grille);
	unset($nb_lignes);
	unset($nb_total_heures);
	unset($somme_heures);
	$trainning_shift=0;
	break;
      }
		
    case -10: // Decalage de la fenetre
      {
	unset($grille);
	unset($nb_lignes);
	unset($nb_total_heures);
	unset($somme_heures);
	$week_shift-=5;
	if ($week_shift<0) $week_shift=0;
	break;
      }
    case -11: // Decalage de la fenetre
      {
	unset($grille);
	unset($nb_lignes);
	unset($nb_total_heures);
	unset($somme_heures);
	$week_shift+=5;
	break;
      }
    case -12: // Decalage de la fenetre
      {
	unset($grille);
	unset($nb_lignes);
	unset($nb_total_heures);
	unset($somme_heures);
	$trainning_shift-=2;
	if ($trainning_shift<0) $trainning_shift=0;
	break;
      }
    case -13: // Decalage de la fenetre
      {
	unset($grille);
	unset($nb_lignes);
	unset($nb_total_heures);
	unset($somme_heures);
	$trainning_shift+=2;
	break;
      }
    }
  // Chargement de la liste des matieres suivies par la promotion ou le groupe
  // et dont les heures ont ete affectes (table diviser)
  // Si une promotion ou un groupe est selectionne
  if ($n > 0)
    {
      if (!isset($id_periode)) {
	$request=mysql_query("SELECT id_periode FROM periode WHERE id_promotion=$id_promotion[0] AND numero=1");
	$result=mysql_fetch_array($request);
	$id_periode=$result["id_periode"];
      }
      // Si un groupe est selectionne
      if ($id_groupe != -1) 
	{
	  $request = "SELECT DISTINCT(matiere.id_matiere),matiere.nom 
			FROM matiere,suivipargroupe,diviser 
			WHERE suivipargroupe.id_groupe = $id_groupe 
			AND suivipargroupe.id_matiere = matiere.id_matiere 
			AND diviser.id_matiere = matiere.id_matiere AND matiere.id_periode=$id_periode";
	  $result = mysql_query($request);
	}
      // Si une promotion est selectionnee
      else 
	{
	  $request = "SELECT DISTINCT(matiere.id_matiere),matiere.nom 
			FROM matiere,suiviparpromotion,diviser 
			WHERE suiviparpromotion.id_promotion = $id_promotion[0] 
			AND suiviparpromotion.id_matiere = matiere.id_matiere 
			AND diviser.id_matiere = matiere.id_matiere AND matiere.id_periode=$id_periode";
	  $result = mysql_query($request); 
	
	}
      // Chargement des matieres dans les variables globales G_id_matiere et G_nom
      $G_nb_matieres = mysql_num_rows($result); 
      for ($i = 0;$i < $G_nb_matieres;$i++)
	{
	  $une_matiere = mysql_fetch_array($result);
	  $G_id_matiere[$i] = $une_matiere["id_matiere"];
	  $G_nom[$i] = $une_matiere["nom"];
	}
    }
	
  /*******************************************************************************/	
  /************************** Fonctions JavaScript *******************************/
  /******/	
  /******/	

  print("<script language=\"JavaScript\">\n");

  print("function usr_delete(id)\n");
  print("{\n");
  print("  document.form1.choice.value=-7;\n");
  print("  document.form1.index.value=id;\n");
  print("  document.form1.submit();\n");
  print("}\n");

  print("function usr_inc1(id)\n");
  print("{\n");
  print("  document.form1.choice.value=-8;\n");
  print("  document.form1.index.value=id;\n");
  print("  document.form1.submit();\n");
  print("}\n");

  print("function usr_dec(id)\n");
  print("{\n");
  print("  document.form1.choice.value=-4;\n");
  print("  document.form1.index.value=id;\n");
  print("  document.form1.submit();\n");
  print("}\n");

  print("function usr_inc(id)\n");
  print("{\n");
  print("  document.form1.choice.value=-5;\n");
  print("  document.form1.index.value=id;\n");
  print("  document.form1.submit();\n");
  print("}\n");

  print("function usr_new(id)\n");
  print("{\n");
  print("  document.form1.choice.value=-6;\n");
  print("  document.form1.index.value=id;\n");
  print("  document.form1.submit();\n");
  print("}\n");
	
  print("</script>\n");
	
  /*******************************************************************************/	
  /******************************* Formulaire *************************************/
  /*******************************************************************************/	

  print("<form name=\"form1\" action=\"reparti.php3\" method=post>\n");
  print("      <input type=\"hidden\" name=\"login\" value=\"$login\">\n");
  print("      <input type=\"hidden\" name=\"choice\" value=\"-1\">\n");
  print("      <input type=\"hidden\" name=\"id_session\" value=\"$id_session\">\n");
  print("      <input type=\"hidden\" name=\"user_type\" value=\"$user_type\">\n");
  print("      <input type=\"hidden\" name=\"user_id\" value=\"$user_id\">\n");
  print("      <input type=\"hidden\" name=\"display\" value=\"$display\">\n");
  if ($display==1) print("      <input type=\"hidden\" name=\"id_promotion2\" value=\"\">\n");
  print("      <input type=\"hidden\" name=\"index\" value=\"$index\">\n");
  print("      <input type=\"hidden\" name=\"duree\">\n");
  print("      <input type=\"hidden\" name=\"week_shift\" value=\"$week_shift\">\n");
  print("      <input type=\"hidden\" name=\"trainning_shift\" value=\"$trainning_shift\">\n");

  print("  <table align=center border=0 cellspacing=0 cellpading=0 width=700 bgcolor=\"#C0C000\">\n");
  print("        <tr>\n");
  // Liste des promotions	
  print("          <td valign=top width=100 nowrap rowspan=2><font size=3><i>Promotion :</i></font></td>\n");
  print("          <td width=250 rowspan=2>\n");
  include("../../Liste/liste_promotion.php");
  print("          </td>\n");
	
  // Liste des groupes associes a la promotion selectionnee
  print("          <td valign=top width=100 nowrap><font size=3><i>Groupe :</i></font></td>\n");
  print("          <td valign=top width=250>\n");
  include("../../Liste/liste_groupe.php");
  print("          </td>\n");

  print("        </tr>\n");

  // Periode
  print("        <tr>\n");
  print("          <td valign=top width=100 nowrap><font size=3><i>P&eacute;riode :</i></font></td>\n");
  print("          <td valign=top width=250>\n");
  include("../../Liste/liste_periode.php");
  print("          </td>\n");
  print("        </tr>\n");

  print("      </table><br>\n");

  if ($n > 0 && $G_nb_matieres > 0)
    {
      $result = mysql_query("select numero_semaine_debut,nb_semaines from periode where id_promotion=".($id_promotion[0])." and id_periode=$id_periode");
      $une_promotion = mysql_fetch_array($result);
      $premiere_semaine = $une_promotion["numero_semaine_debut"];
      $nb_semaines = $une_promotion["nb_semaines"];
      $derniere_semaine = $premiere_semaine + $nb_semaines;

      // Reduction du nombre de semaines afin de tenir sur un seul ecran
      if ($week_shift+$week_number>$nb_semaines) $premiere_semaine = $derniere_semaine-$week_number;
      else $premiere_semaine += $week_shift;
      $nb_semaines = ($nb_semaines <= $week_number)?$nb_semaines:$week_number;

      /*******************************************************************************/	
      /************************ Traitement des modifications *************************/
      /*******************************************************************************/	

      // indice de la matiere
      $z1 = floor($index/(5*$nb_semaines)); 
      $id_matiere2 = $G_id_matiere[$z1];

      // indice du type de la seance (indice ligne)
      $z2 = floor(($index-$z1*5*$nb_semaines)/$nb_semaines)+1;

      // indice de la semaine
      $z3 = $premiere_semaine+$index-$z1*5*$nb_semaines-($z2-1)*$nb_semaines;
      $z3 = ($z3>52)?$z3-52:$z3;

      switch ($choice)
	{
	case -4: // -0.5
	  {
	    $result = mysql_query("select nb_heures,id_reparti from reparti where id_matiere=$id_matiere2 and semaine=$z3 and id_type_seance = $z2 and id_groupe=$id_groupe");
	    $reparti = mysql_fetch_array($result);
	    $nb_heures = $reparti["nb_heures"];
	    if ($nb_heures > 0.5) mysql_query("update reparti set nb_heures=".($nb_heures-0.5)." where id_reparti=".($reparti["id_reparti"]));	
	    else 
	      {
		mysql_query("DELETE FROM reparti WHERE id_reparti=".($reparti["id_reparti"]));	
		if ($id_groupe!=-1)
		  mysql_query("DELETE FROM repartigroupe WHERE id_reparti=".($reparti["id_reparti"]));	
		else
		  mysql_query("DELETE FROM repartipromotion WHERE id_reparti=".($reparti["id_reparti"]));	
	      }
	    break;
	  }
	case -5: // +0.5
	  {
	    $result = mysql_query("select nb_heures,id_reparti from reparti where id_matiere=$id_matiere2 and semaine=$z3 and id_type_seance = $z2 and id_groupe=$id_groupe");
	    $reparti = mysql_fetch_array($result);
	    $nb_heures = $reparti["nb_heures"];
	    mysql_query("update reparti set nb_heures=".($nb_heures+0.5)." where id_reparti=".($reparti["id_reparti"]));	
	    break;
	  }
	case -6: // 1
	  {
	    $request = "select * from reparti where id_matiere=$id_matiere2 and semaine=$z3 and id_type_seance = $z2 and id_groupe=$id_groupe";
	    $result = mysql_query($request);
	    if ($result == 0 || mysql_num_rows($result) == 0)
	      {
		// determination de la cle de la table reparti
		$result = mysql_query("select * from id");
		$id = mysql_fetch_array($result);  
		mysql_query("update id set id_reparti=".($id["id_reparti"]+1));

		// verifie si la semaine precedente ce cours a ete programme
		// si c'est le cas alors le nombre d'heures programmees sera egal au nombre
		// d'heures programmees la semaine precedente
		$z = 1;
		$result = mysql_query("select nb_heures from reparti where id_matiere=$id_matiere2 and semaine=".($z3-1)." and id_type_seance = $z2 and id_groupe=$id_groupe");
		if ($result != 0 && mysql_num_rows($result) == 1)
		  {
		    $a_record = mysql_fetch_array($result);
		    $z = $a_record["nb_heures"];
		  }
		// mise a jour de la table reparti
		mysql_query("INSERT INTO reparti VALUES(".($id["id_reparti"]+1).",$id_matiere2,$z2,$z3,$z,$id_groupe)");

		// mise a jour de la table repartigroupe ou repartipromotion
		// selon si on programme un cours a un groupe ou a une promotion
		if ($id_groupe!=-1)
		  mysql_query("INSERT INTO repartigroupe VALUES (".$id_groupe.",".($id["id_reparti"]+1).")");
		else 
		  mysql_query("INSERT INTO repartipromotion VALUES (".$id_promotion[0].",".($id["id_reparti"]+1).")");
	      }
	    break;
	  }
	case -7: // RAZ
	  {
	    $result = mysql_query("select nb_heures,id_reparti from reparti where id_matiere=$id_matiere2 and semaine=$z3 and id_type_seance = $z2 and id_groupe=$id_groupe");
	    $reparti = mysql_fetch_array($result);
	    mysql_query("DELETE FROM reparti WHERE id_reparti=".($reparti["id_reparti"]));	
	    if ($id_groupe!=-1)
	      mysql_query("DELETE FROM repartigroupe WHERE id_reparti=".($reparti["id_reparti"]));	
	    else
	      mysql_query("DELETE FROM repartipromotion WHERE id_reparti=".($reparti["id_reparti"]));	
	    break;
	  }
	case -8: // +1
	  {
	    $result = mysql_query("select nb_heures,id_reparti from reparti where id_matiere=$id_matiere2 and semaine=$z3 and id_type_seance = $z2 and id_groupe=$id_groupe");
	    $reparti = mysql_fetch_array($result);
	    $nb_heures = $reparti["nb_heures"];
	    mysql_query("update reparti set nb_heures=".($nb_heures+1)." where id_reparti=".($reparti["id_reparti"]));	
	    break;
	  }
	case -9: // Valeur
	  {
	    $result = mysql_query("select nb_heures,id_reparti from reparti where id_matiere=$id_matiere2 and semaine=$z3 and id_type_seance = $z2 and id_groupe=$id_groupe");
	    $reparti = mysql_fetch_array($result);
	    mysql_query("update reparti set nb_heures=".($duree)." where id_reparti=".($reparti["id_reparti"]));	
	    break;
	  }
	}

      // Masquage de l'entete
      if ($display==1)      
	{
	  print("<SCRIPT LANGUAGE=\"JavaScript\">\n");            
	  print("  function masquer_entete()\n");
	  print("  {\n");
	  print("    document.form1.display.value=0;\n");
	  print("    document.form1.choice.value=0;\n");
	  print("    document.form1.submit();\n");
	  print("  }\n");
	  print("</SCRIPT>\n\n");
	  print("<DIV ALIGN=RIGHT><FONT SIZE=2><I><A HREF=\"javascript:masquer_entete();\">Masquer ^</A></I></FONT></DIV><BR>\n");
	}

      /*******************************************************************************/	
      /******************************** Grille ***************************************/
      /*******************************************************************************/	

      print("  <table align=center border=1 cellspacing=0 cellpading=0 bgcolor=\"#C0C000\">\n");
      // Entete de la grille
      print("              <tr valign=BOTTOM>\n");
      print("                <td valign=center align=center colspan=2 rowspan=2><font size=3><i>Mati&egrave;re</i></font></td>\n");
      if ($week_shift==0) print("				   <td valign=middle align=center>&nbsp;</td>\n");
      else print("				   <td valign=middle align=center><img src=\"../../img/Previous.gif\" OnClick=\"choice.value=-10; submit();\"></td>\n");
      for ($i=$premiere_semaine;$i<$premiere_semaine+$nb_semaines;$i++)
	{
	  print("                  <td align=center rowspan=2><font size=2><i>Semaine<BR>".(($i>52)?$i-52:$i)."</i></font></td>\n");
	}
      if ($premiere_semaine+$nb_semaines == $derniere_semaine) print("				   <td valign=middle align=center rowspan=2>&nbsp;</td>\n");
      else print("				   <td valign=middle align=center rowspan=2><img src=\"../../img/Next.gif\" OnClick=\"choice.value=-11; submit();\"></td>\n");
      print("              </tr>\n");
      print("              <tr valign=BOTTOM>\n");
      if ($trainning_shift==0) print("				    <td valign=middle align=center>&nbsp;</td>\n");

      else print("				    <td valign=middle align=center><img src=\"../../img/Previous2.gif\" OnClick=\"choice.value=-12; submit();\"></td>\n");

      print("              </tr>\n");
      // intitules et nombre des types de seances
      $type_seance = array(1=>"C","TD","TDm","TP","Examen");
      $nb_types_seance = 5;
      /********** Variables d'optimisation ***********/
      /**** optimisation des valeurs de la grille ****/
      // variable indiquant si la grille est deja definie
      $grille_defined = isset($grille);
      // si la grille est deja definie alors recuperation des valeurs dans un tableau
      if ($grille_defined) $grille_explode = explode(":",$grille);
      // variable contenant les valeurs de la grille
      $grille = "";
      // indice pour le parcours de la grille
      $g = 0;		
      /**** optimisation du nombre de lignes par matiere ****/
      $nb_lignes_defined = isset($nb_lignes);
      if ($nb_lignes_defined) $nb_lignes_explode = explode(":",$nb_lignes);
      else $nb_lignes = "";
      /**** optimisation du nombre total d'heures a programmer par matiere ****/
      $nb_total_heures_defined = isset($nb_total_heures);
      if ($nb_total_heures_defined) $nb_total_heures_explode = explode(":",$nb_total_heures);
      else $nb_total_heures = "";
      // indice pour le parcours du tableau des heures a programmer
      $h = 0;		
      /**** optimisation du nombre total d'heures programmees par matiere ****/
      $somme_heures_defined = isset($somme_heures);
      if ($somme_heures_defined) $somme_heures_explode = explode(":",$somme_heures);
      $somme_heures = "";
      // indice pour le parcours du tableau des heures programmees
      $t = 0;		
      // found = true des que la cellule modifiee est trouve afin d'eviter un test
      $found = false; 
      /********** Trace de la grille *************/
      $v = ($trainning_shift + $trainning_number < $G_nb_matieres)?$trainning_shift + $trainning_number:$G_nb_matieres;
      for ($i = $trainning_shift;$i < $v;$i++)
	{
	  print("              <tr valign=BOTTOM>\n");
	  // determination du nombre de lignes
	  if ($nb_lignes_defined) $nb = $nb_lignes_explode[$i-$trainning_shift];
	  else
	    {
	      $result = mysql_query("SELECT COUNT(*) FROM diviser WHERE id_matiere=$G_id_matiere[$i]");
	      $a_record = mysql_fetch_array($result);
	      $nb = $a_record["COUNT(*)"];
	      $nb_lignes .= $nb.":";
	    }
	  print("                <td valign=middle nowrap rowspan=$nb>\n");
	  print("                   <font size=3><i>$G_nom[$i]</i></font>\n");
	  print("				 	  <input type=hidden name=\"nom[$i]\" value=\"$G_nom[$i]\">\n");
	  print("				 	  <input type=hidden name=\"id_matiere[$i]\" value=$G_id_matiere[$i]>\n");
	  print("                </td>\n");
	  // Pour tout type de seance
	  for ($k = 1;$k <= $nb_types_seance;$k++)
	    {
	      // variable pour optimiser le calcul de l'indice affecte a chaque cellule de la grille
	      $w1 = $i*$nb_semaines*$nb_types_seance+($k-1)*$nb_semaines;
				
	      // nombre d'heures a programmer
	      if ($nb_total_heures_defined) $nb_total_heures1 = $nb_total_heures_explode[$h];
	      else
		{				
		  $result = mysql_query("select nb_heures from diviser 
					where id_matiere=$G_id_matiere[$i] and id_type_seance = $k");
		  if (mysql_num_rows($result)>0)
		    {
		      $a_record = mysql_fetch_array($result);
		      $nb_total_heures1 = $a_record["nb_heures"];
		    }
		  else $nb_total_heures1 = 0;
		  $nb_total_heures .= $nb_total_heures1.":";
		}
	      $h++;
	      // si le nombre d'heures a programmer est superieur a 0					
	      if ($nb_total_heures1 > 0)
		{
		  if ($somme_heures_defined) 
		    {
		      if (!$found && ($choice <= -4 && $choice >= -8) && $i == $z1 && $k == $z2)
			{
			  $result = mysql_query("select sum(nb_heures) from reparti 
							where id_matiere=$G_id_matiere[$i] and id_type_seance = $k 
							and id_groupe=$id_groupe");	    		
			  $a_record = mysql_fetch_array($result);
			  $nb_total_heures2 = $a_record["sum(nb_heures)"];
			}
		      else $nb_total_heures2 = $somme_heures_explode[$t];
		    }
		  else
		    {
		      $result = mysql_query("select sum(nb_heures) from reparti 
						where id_matiere=$G_id_matiere[$i] and id_type_seance = $k 
						and id_groupe=$id_groupe");	    		
		      $a_record = mysql_fetch_array($result);
		      $nb_total_heures2 = $a_record["sum(nb_heures)"];
		    }
		  $somme_heures .= $nb_total_heures2.":";
		  $t++;
		  print("                <td align=center>");
		  // Toutes les heures sont-elles programmees ?
		  if ($nb_total_heures1 == $nb_total_heures2) // Oui !
		    {
		      // Petit carre indicateur vert
		      switch ($k)
			{
			case 1:print("<img src=\"../../img/CGreen.gif\">\n");break;
			case 2:print("<img src=\"../../img/TDGreen.gif\">\n");break;
			case 3:print("<img src=\"../../img/TDmGreen.gif\">\n");break;
			case 4:print("<img src=\"../../img/TPGreen.gif\">\n");break;
			case 5:print("<img src=\"../../img/ExamenGreen.gif\">\n");break;
			}
		    }
		  else // Toutes les heures ne sont pas programmees !
		    {
		      // Calcul de la difference
		      $delta = $nb_total_heures1 - $nb_total_heures2;
		      // Construction du message en fonction du nombre d'heures restant 
		      // a programmer ou de trop programmees
		      if ($delta <= 1) 
			{
			  if ($delta == 1) $message = "'Il reste une heure à programmer.'";
			  else
			    {
			      if ($delta == 0.5) $message = "'Il reste une 1/2 heure à programmer.'";
			      else
				{
				  if ($delta == -1) $message = "'Il y a une heure de programmer en trop.'";
				  else
				    {
				      if ($delta == -0.5) $message = "'Il y a une 1/2 heure de programmer en trop.'";
				      else $message = "'Il y a ".abs($delta)." heures de programmer en trop.'";
				    }
				}
			    }
			}
		      else $message = "'Il reste $delta heures à programmer.'";
						
		      // Petit carre indicateur rouge car tous les heures ne sont pas programmees
		      switch ($k)
			{
			case 1:print("<img src=\"../../img/CRed.gif\" OnClick=\"alert($message);\">\n");break;
			case 2:print("<img src=\"../../img/TDRed.gif\" OnClick=\"alert($message);\">\n");break;
			case 3:print("<img src=\"../../img/TDmRed.gif\" OnClick=\"alert($message);\">\n");break;
			case 4:print("<img src=\"../../img/TPRed.gif\" OnClick=\"alert($message);\">\n");break;
			case 5:print("<img src=\"../../img/ExamenRed.gif\" OnClick=\"alert($message);\">\n");break;
			}	
						
		    }
		  print("</td>\n");
		
		  // Colonne vide pour synchro avec l'entete			
		  print("				   <td valign=middle align=center>&nbsp;</td>\n");

		  // Pour chaque semaine
		  for ($j = 1;$j <= $nb_semaines;$j++)
		    {
		      // variable pour optimiser le calcul de l'indice affecte a chaque cellule de la grille
		      $w2 = $w1 + $j - 1;
		      // numero de la semaine
		      $s = $premiere_semaine+$j-1;
		      $s = ($s>52)?$s-52:$s;

		      // la grille est-elle deja definie ?
		      if ($grille_defined)
			{
			  // s'il y a eu des changements et que l'on est sur la case modifiee
			  if (!$found && ($choice <= -4 && $choice >= -8) && $i == $z1 && $k == $z2 && $s == $z3)
			    {
			      $result = mysql_query("select nb_heures from reparti where id_matiere=$G_id_matiere[$i] and semaine=$s and id_type_seance = $k and id_groupe=$id_groupe");
			      if ($result != 0 && mysql_num_rows($result) > 0) 
				{
				  $a_record = mysql_fetch_array($result);
				  $nb_heures = $a_record["nb_heures"];
				}
			      else $nb_heures = 0;
			      $found = true;
			    }
			  else $nb_heures = $grille_explode[$g];
			  $grille .= $nb_heures.":";
			}
		      else
			{
			  $result = mysql_query("select nb_heures from reparti where id_matiere=$G_id_matiere[$i] and semaine=$s and id_type_seance = $k and id_groupe=$id_groupe");
			  if ($result != 0 && mysql_num_rows($result) > 0) 
			    {
			      $a_record = mysql_fetch_array($result);
			      $nb_heures = $a_record["nb_heures"];
			    }
			  else $nb_heures = 0;
			  $grille .= $nb_heures.":";
			}
		      $g++;
		      if ($nb_heures>0)
			{
			  $nb_heures = floor($nb_heures)+($nb_heures-floor($nb_heures));
			  print("                  <td align=center valign=middle bgcolor=\"#C0C000\" nowrap>\n");
			  print("                    <map name=\"map_".$w2."_l\">\n");
			  print("                      <area shape=rect coords=\"1,2,10,9\" onClick=\"usr_delete($w2);\">\n");
			  print("                      <area shape=rect coords=\"1,11,10,18\" onClick=\"usr_dec($w2);\">\n");
			  print("                    </map>\n");
			  print("                    <img src=\"../../img/Heure_left.gif\" border=0 usemap=\"#map_".$w2."_l\">\n"); 
			  print("                    <font size=2><b>$nb_heures</b></font>");
			  print("                    <map name=\"map_".$w2."_r\">\n");
			  print("                      <area shape=rect coords=\"1,2,10,9\" onClick=\"usr_inc1($w2);\">\n");
			  print("                      <area shape=rect coords=\"1,11,10,18\" onClick=\"usr_inc($w2);\">\n");
			  print("                    </map>\n");
			  print("                    <img src=\"../../img/Heure_right.gif\" border=0 usemap=\"#map_".$w2."_r\">\n"); 
			  print("                  </td>\n");
			}
		      else print("                  <td bgcolor=\"#ffffff\"><img src=\"../../img/Blanc.gif\" OnClick=\"usr_new($w2);\"></td>\n");
		    }
		  print("				   <td valign=middle align=center>&nbsp;</td>\n");
		  print("              </tr>\n");
		}
	    }
	}
      print("				<tr>\n");
      print("					<td colspan=2>&nbsp;</td>\n");
      if ($v == $G_nb_matieres) print("				    <td valign=middle align=center>&nbsp;</td>\n");
      else print("				    <td valign=middle align=center><img src=\"../../img/Next2.gif\" OnClick=\"choice.value=-13; submit();\"></td>\n");
      print("					<td colspan=".($week_number+1).">&nbsp;</td>\n");
      print("				</tr>\n");
      print("             </table>\n");

      // Variables d'optimisation
      print("  <input type=\"hidden\" name=\"grille\" value=\"$grille\">\n");
      print("  <input type=\"hidden\" name=\"nb_lignes\" value=\"$nb_lignes\">\n");
      print("  <input type=\"hidden\" name=\"nb_total_heures\" value=\"$nb_total_heures\">\n");
      print("  <input type=\"hidden\" name=\"somme_heures\" value=\"$somme_heures\">\n");
    }	
  print("</form>\n");
	
  /******/	
  /******/	
  /*******************************************************************************/	
  /*******************************************************************************/	

}
buildEndOfPage();  
?>
Return current item: EmploiNet : a timetable web manager