IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

créer un planning d’événements


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti Avatar de Roiser
    Homme Profil pro
    Etudiant - MIAGE
    Inscrit en
    Juillet 2017
    Messages
    29
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Etudiant - MIAGE
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2017
    Messages : 29
    Par défaut créer un planning d’événements
    Bonjours je me suis remis depuis peu au php, j'essaie de faire un site fictif sur un festival de modélisme et je bloque depuis un peu sur un problème de planning.
    Je m'explique, pendant la totalité du festival plusieurs événement sont prévus j'essaie donc d'en faire un planning récapitulant tous les événements avec leurs horaires.

    d'abord pour créer ce tableau je me sert de ces deux tables :
    Code sql : 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
    CREATE TABLE `t_festival_fes` (
      `fes_nom` varchar(50) NOT NULL,
      `fes_lieu` varchar(45) NOT NULL,
      `fes_datedebut` date NOT NULL,
      `fes_datefin` date NOT NULL,
      `fes_horaireouverture` time NOT NULL,
      `fes_horairefermeture` time NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
     
    CREATE TABLE `t_evenement_even` (
      `even_id` int(11) NOT NULL,
      `even_nom` varchar(50) NOT NULL,
      `even_descriptif` longtext NOT NULL,
      `even_datehorairedebut` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      `even_datehorairefin` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `lieu_id` int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    ensuite après avoir récupérer quelques requête je créé mon tableau grace a PHP ce qui donne ceci :

    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
     
     
    //fonction permettant de mettre une horaire (H : min : sec) en seconde
    		function timetosec($str_time)
    		{
    			$str_time = preg_replace("/^([\d]{1,2})\:([\d]{2})$/", "00:$1:$2", $str_time);
     
    			sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);
     
    			return $hours * 3600 + $minutes * 60 + $seconds;
    		}
     
    		//fonction permettant de mettre un entier de seconde en heure (H : min)
    		function sectotime($str_time)
    		{
    			$m=(int)$str_time%3600;
    			$h=(int)$str_time/3600;
    			if ($h<10)
    			{
    				$h='0'.$h;
    			}
    			if ($m<10)
    			{
    				$m='0'.$m;
    			}
    			return $h.':'.$m;
    		}
     
    			$date1 = strtotime($temps->fes_datedebut);
    			$date2 = strtotime($temps->fes_datefin);
    			$heure1= timetosec($temps->fes_horaireouverture);
    			$heure2= timetosec($temps->fes_horairefermeture);
     
    		?>
            <table class="bordered centered">
    			<thead>
    				<tr>
    					<th></th>
    					<?php 
    					setlocale (LC_TIME, 'fr_FR.utf8','fra'); 
    					for ($i = $date1; $i <= $date2; $i=$i+86400) {echo '<th>'.strftime("%A %d %B", $i).'</th>';}
    					?>
    				</tr>
    			</thead>
    			</tbody>
    					<?php 
    					$compt = false;
    					for ($i = $heure1; $i <= $heure2-1; $i=$i+3600) { ?>
    						<tr>
    							<?php
    							echo '<td  style="height:100px;vertical-align:top;">'.sectotime($i).'</td>'; 
    							if ($compt == false)
    							{
    								for ($j = $date1; $j <= $date2; $j=$j+86400)
    								{
    									?><td rowspan="<?php echo ($heure2-$heure1-1)/3600 ;  ?>" height="<?php echo ($heure2-$heure1-1)/36 ; ?>px" <?php
    									foreach ($evenements as $evenement)
    									{
    										if ( (strtotime($evenement['even_datehorairedebut'])>= $j)&&(strtotime($evenement['even_datehorairedebut'])< $j+86400) )
    										{
    											$taille = (timetosec(substr($evenement['even_datehorairefin'],11,8))-timetosec(substr($evenement['even_datehorairedebut'],11,8)))/36 ;
    											echo '><input style="height:'.$taille.'px;top:0px;" class="waves-effect waves-light btn" type="button" value="'.$evenement['even_nom'].'&#10&#13 '.substr($evenement['even_datehorairedebut'],11,5).' - '.substr($evenement['even_datehorairefin'],11,5).'" onclick='.base_url().'index.php/programme/detail/'.$evenement['even_id'].'/' ;
     
    										}
    									}
    									$compt= true;
    									echo '></td>' ;
    								}
    							}
     
    							?>
    						</tr>
    					<?php } ?>			
    			</tbody>
            </table>
        <?php
        }?>
    Cela me gènere le code HTML suivant :

    Code html : 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
    <table class="bordered centered">
    			<thead>
    				<tr>
    					<th></th>
    					<th>vendredi 08 juin</th>
    					<th>samedi 09 juin</th>
    					<th>dimanche 10 juin</th>				
    				</tr>
    			</thead>
    			</tbody>
    				<tr>
    					<td  style="height:100px;vertical-align:top;">08:00</td>
    					<td rowspan="10" height="1000px" >
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste Groupe A&#10&#13 08:00 - 10:00" onclick=http://localhost/aerauto/index.php/programme/detail/1/>
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste Groupe B&#10&#13 10:15 - 12:15" onclick=http://localhost/aerauto/index.php/programme/detail/2/>
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste Groupe C&#10&#13 13:30 - 15:30" onclick=http://localhost/aerauto/index.php/programme/detail/3/>
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste Groupe D&#10&#13 15:45 - 17:45" onclick=http://localhost/aerauto/index.php/programme/detail/4/>
    					</td>
    					<td rowspan="10" height="1000px" >
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste petite finale&#10&#13 15:15 - 17:15" onclick=http://localhost/aerauto/index.php/programme/detail/5/>
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture cross Groupe A&#10&#13 08:00 - 10:00" onclick=http://localhost/aerauto/index.php/programme/detail/7/>
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture cross Groupe B&#10&#13 10:15 - 12:15" onclick=http://localhost/aerauto/index.php/programme/detail/8/>
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Course de voilier miniature&#10&#13 13:00 - 15:00" onclick=http://localhost/aerauto/index.php/programme/detail/10/>
    					</td>
    					<td rowspan="10" height="1000px" >
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste finale&#10&#13 13:00 - 15:00" onclick=http://localhost/aerauto/index.php/programme/detail/6/>
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture cross finale&#10&#13 15:45 - 17:45" onclick=http://localhost/aerauto/index.php/programme/detail/9/>
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Concours de voltige &#10&#13 10:00 - 12:00" onclick=http://localhost/aerauto/index.php/programme/detail/11/>
    						<input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Concours de maquettes&#10&#13 08:00 - 10:00" onclick=http://localhost/aerauto/index.php/programme/detail/12/>
    					</td>	
    				</tr><tr>
    					<td  style="height:100px;vertical-align:top;">09:00</td>						
    				</tr><tr>
    					<td  style="height:100px;vertical-align:top;">10:00</td>						
    				</tr><tr>
    					<td  style="height:100px;vertical-align:top;">11:00</td>					
    				</tr><tr>
    					<td  style="height:100px;vertical-align:top;">12:00</td>						
    				</tr><tr>
    					<td  style="height:100px;vertical-align:top;">13:00</td>						
    				</tr><tr>
    					<td  style="height:100px;vertical-align:top;">14:00</td>						
    				</tr><tr>
    					<td  style="height:100px;vertical-align:top;">15:00</td>						
    				</tr><tr>
    					<td  style="height:100px;vertical-align:top;">16:00</td>				
    				</tr><tr>
    					<td  style="height:100px;vertical-align:top;">17:00</td>
    				</tr>		
    			</tbody>
    </table>

    soit l'image suivante :

    Nom : planning v1.png
Affichages : 764
Taille : 147,6 Ko


    Voici le problème j'aimerai ordonner maintenant mes événements afin que les horaires correspondent a ma première colonne.

    Merci de votre attention,
    En espérant que vous pourrez m'aider,
    Roiser

  2. #2
    Expert confirmé
    Avatar de mathieu
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    10 670
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 10 670
    Par défaut
    Une 1re étape serait de trier les évènements par date de début.
    Vous n'avez pas indiqué la requête SQL qui récupère les évènements mais je pense que vous pouvez faire le tri dans cette requête.

  3. #3
    Membre averti Avatar de Roiser
    Homme Profil pro
    Etudiant - MIAGE
    Inscrit en
    Juillet 2017
    Messages
    29
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Etudiant - MIAGE
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2017
    Messages : 29
    Par défaut
    J'ai modifié ma requête (c'est celle que je met ci-dessous) je les ai rangez dans l'ordre chronologique cependant je bloque toujours pour bien les positionner dans mon tableau
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    $this->db->select('even_nom,even_id,even_datehorairedebut,even_datehorairefin');
    $this->db->from('t_evenement_even');
    $this->db->order_by("even_datehorairedebut	", "asc");
    $query = $this->db->get();
    return $query->result_array();
    Nom : planning V2.png
Affichages : 619
Taille : 32,7 Ko
    Cordialement,
    Roiser

  4. #4
    Expert confirmé
    Avatar de mathieu
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    10 670
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 10 670
    Par défaut
    Je pense qu'avant de passer à la génération du calendrier en PHP, vous devriez préparer une petite maquette en HTML et CSS.
    Vous verrez mieux si les évènements seront dans les cases du tableau ou si ce seront par exemple des zones flottantes qui seront positionnées en CSS.

Discussions similaires

  1. Créer un planning
    Par bobosh dans le forum IHM
    Réponses: 1
    Dernier message: 12/08/2008, 12h52
  2. Réponses: 19
    Dernier message: 27/11/2007, 23h54
  3. Comment grouper et créer un plan en VBA Excel ?
    Par vacknov dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 24/11/2007, 07h00
  4. Créer un planning sur access...
    Par SpyesX dans le forum Access
    Réponses: 2
    Dernier message: 05/11/2005, 08h33
  5. grouper/créer un plan sous Excel
    Par EFCAugure dans le forum API, COM et SDKs
    Réponses: 6
    Dernier message: 06/10/2004, 16h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo