Bonsoir

j'ai réalisé un planning horaire à l'aide d'un script que j'ai trouvé sur le net.
j'ai donc créé ma table :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
CREATE TABLE IF NOT EXISTS `T_planning` (
  `Id_contact` int(3) NOT NULL default '0',
  `Date_planning` varchar(10) NOT NULL default '',
  `Heure_debut_planning` time NOT NULL default '00:00:00',
  `Heure_fin_planning` time default NULL,
  `Details_planning` varchar(150) default NULL,
  `Lieu_planning` varchar(25) default NULL,
  `Societe_planning` varchar(25) default NULL,
  `Duree_planning` time default NULL,
  `Id_type` int(2) default NULL,
  PRIMARY KEY  (`Id_contact`,`Date_planning`,`Heure_debut_planning`),
  KEY `fk_planning_type` (`Id_type`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
j'arrivais bien à insérer des rdv jusqu'au moment ou j'ai essayé de gérer en fonction des heures:

Dont voici juste le bout de code pour les heures

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 
$dat=$_POST['Date_planning'];
					$l=$_POST['Lieu_planning'];
					$e=$_POST['Details_planning'];
					$societe=$_POST['Societe_planning'];
					$heure_debut=$_POST['Heure1'].':'.$_POST['Minute1'];
					$duree=$_POST['Heu1'].':'.$_POST['Min1'];
					$heure_fin=($_POST['Heure1']+$_POST['Heu1']).':'.($_POST['Minute1']+$_POST['Min1']);
					$d=$_GET['Date_planning'];
 
					$d_l=explode('-',$dat);
					$mois=$d_l[1];
					$anne=$d_l[0];
					$lien="&annee=".$anne."&mois=".$mois;
 
 
					if (!empty($_POST['Details_planning'])&&!empty($_POST['Lieu_planning'])&&!empty($_POST['Societe_planning'])&&!empty($_POST['idcontact'])&&!empty($_POST['idtype']))
					{	
						$c=$_POST["idcontact"];									
						$req=mysql_query("select max(Heure_debut_planning) as maxi from T_planning where Date_planning='$d' and Id_contact='$c'");
						$resultat=mysql_fetch_array($req);
						$maxi=$resultat['maxi'];
 
					if($heure_debut+$duree<=$maxi)
					{
						Echo "<script>alert('Un rdv a déja été pris sur cette plage horaire!!!!');</script>";
					}
					else							
					{
						$sql1="select Heure_debut_planning, Heure_fin_planning from T_planning where Date_planning='$d' order by Id_contact, Heure_debut_planning";
						$req1=mysql_query($sql1);
						$result1=mysql_fetch_array($req1);
 
 
						while($result1)
						{
							If($result1['Heure_debut_planning']<=$heure_debut)
							{
								If($heure_debut<$result1['Heure_fin_planning'])
								{
									Echo "<script>alert('Un rdv a déja été pris sur cette plage horaire!!!!');</script>";
								}
								else
								{
									$sql2="select Heure_debut_planning, Heure_fin_planning from T_planning where Date_planning='$d' order by Id_contact, Heure_debut_planning";
									$req2=mysql_query($sql2);
									$result2=mysql_fetch_array($req2);
									while($result2)
									{
										If(($heure_debut+$duree)<=$result2['Heure_debut_planning'])
										{
											Echo "<script>alert('Un rdv a déja été pris sur cette plage horaire!!!!');</script>";
										}
										else
										{
											$sql3="INSERT INTO T_planning(Id_contact,Date_planning,Heure_debut_planning,Heure_fin_planning,Details_planning, Lieu_planning,Societe_planning,Duree_planning,Id_type) values( ".$_POST["idcontact"].",'$dat','$heure_debut','$heure_fin','$e' , '$l' , '$societe' ,'$duree', " .$_POST["idtype"]. ");";
										}
									}
								}
							}
						}
					}							
							mysql_query ($sql3);
 
						/*echo '<script language="Javascript">
						<!--
						document.location.replace("planning_gestion.php?Date_planning='.$dat.'");
						// -->
						</script>'; 
					*/
					}
					else
					{
						Echo "<script>alert('veuillez saisir tous les champs!!!!');</script>";
						echo '<script language="Javascript">
								<!--
									history.go(-1);
								// -->
							  </script>';
					}
Et voici ce qui apparait dans le navigateur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
<form name="ajout"  method="post"><input type='hidden' id='Date_planning' name='Date_planning' value='<?php echo $d; ?>'>
<table style="padding:20px">
		<?php if($mod==0){?><tr><td width="150px"><strong>Heure:</strong></td><td>
		<select name="Heure1" style="maxlenght:5px">
		<?php 
			for($i=8;$i<=9;$i++) 
			{ 
				echo "<option value=".$i.">0".$i."</option>" ; 
			}; 
			for($j=10;$j<=20;$j++) 
			{ 
				echo "<option value=".$j.">".$j."</option>" ; 
			}; 
		?>
		</select>   
		h 
		<select name="Minute1" > 
		<?php 
			for($i=0;$i<10;$i++) 
			{ 
				echo "<option value=".$i.">0".$i."</option>"; 
			}; 
			for($i=10;$i<60;$i++) 
			{ 
				echo "<option value=".$i.">".$i."</option>"; 
			}; 
		?> 
		</select> </td></tr>
		<tr><td width="150px"><strong>Durée estimée:</strong></td><td>
		<select name="Heu1">
		<?php 
			for($i=0;$i<=9;$i++) 
			{ 
				echo "<option value=".$i.">0".$i."</option>" ; 
			}; 
			for($i=10;$i<=15;$i++) 
			{ 
				echo "<option value=".$i.">".$i."</option>" ; 
			}; 
		?>
		</select>   
		h 
		<select name="Min1"> 
		<?php 
			for($i=0;$i<10;$i++) 
			{ 
				echo "<option value=".$i.">0".$i."</option>"; 
			}; 
			for($i=10;$i<60;$i++) 
			{ 
				echo "<option value=".$i.">".$i."</option>"; 
			};  
		?> 
		</select> </td></tr>
		<?php 
		} 
 
.... // reste du formulaire
J'ai un message d'erreur:
"Fatal error: Maximum execution time of 30 seconds exceeded in W:\var\www\Exemples\intranet2\planning_gestion.php on line 169"

ps: peut etre que ma gestion des heures en fonctions des autres est fausses j'ai eu du mal a trouver la logique ....

En tout cas merci d'avance