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

Symfony PHP Discussion :

Calendrier type Agenda


Sujet :

Symfony PHP

  1. #1
    Membre averti
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Août 2011
    Messages
    754
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 30
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Août 2011
    Messages : 754
    Points : 376
    Points
    376
    Par défaut Calendrier type Agenda
    Bonjour à tous,

    je cherche à représenter des réservations de ma base de donnée dans un calendrier, un peu sous la forme d'un emploi du temps (car se sont des réservations courtes ne dépassant pas 2h de temps) par semaine et par jour comme l'on pourrait le voir pour des cours par exemple.

    En cravachant deux trois jours j'imagine que je pourrais bricoler quelque chose, mais je me dis que ce genre de chose doit bien exister déjà quelque part, sous la forme d'un template, bundle ou autre, mais bizarrement je ne trouve rien qui me satisfasse pour le moment.


    Dans l'idéal ce que je cherche c'est un truc qui ferait déjà certains calculs en plus du design.

    Par exemple si en base de donnée j'ai une réservation le 08/01/17 de 15h à 17h. Je voudrais quelque chose qui si je lui demande de m'afficher la semaine 2 de janvier (en considérant que le dimanche du jour de l'an était la première semaine d'un jour) me fera figurer cette réservation dans un tableau représentant l'ensemble de la semaine.


    Voilà, comme je vous ai dis, c'est pas bien compliqué à faire je pense, mais ça prendra du temps, donc si vous avez un truc en réserve que je pourrai reprendre ce serait génial

  2. #2
    Membre émérite
    Avatar de badaze
    Homme Profil pro
    Chef de projets info
    Inscrit en
    Septembre 2002
    Messages
    1 412
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Ain (Rhône Alpes)

    Informations professionnelles :
    Activité : Chef de projets info
    Secteur : Transports

    Informations forums :
    Inscription : Septembre 2002
    Messages : 1 412
    Points : 2 522
    Points
    2 522
    Par défaut
    J'ai écrit ça il y a quelques années. A adapter. Fonctionne très bien avec Firefox.

    Nom : Capture .JPG
Affichages : 2155
Taille : 124,8 Ko

    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
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
     
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Untitled</title>
    <?php 
     $altezzaRiga = 45;
    ?>
    <style type="text/css">
    <!--
    .table   {border: 3px solid black;vertical-align:top}
    .riga    {height:<?php print $altezzaRiga;?>px;alignment:top;}
    .td      {border: 1px dotted gray;vertical-align:top}
    .td_ora  {border: 1px solid black;}
     
    -->
    </style>
    </head>
    <body>
    <?php 
      //======== simolazione dei dati del db
      //=== Primo evento 
      $i                      = 0;
      $id_note[$i]            = 101;    
      $data_inizio[$i]        = 2.15;
      $data_fine[$i]          = 2.30;
      $TESTO_NOTE[$i]         = "Evento dalle 2.15 alle 2.30";
      $colore[$i]             = "blue";
      $timestamp_datimiei[$i] = $data_inizio[$i];
      $timestamp_datafine[$i] = $data_fine[$i];
     
      //=== Secondo evento 
      $i                      = 1;
      $id_note[$i]            = 213;    
      $data_inizio[$i]        = 8;
      $data_fine[$i]          = 11;
      $TESTO_NOTE[$i]         = "Evento dalle 8 alle 11";
      $colore[$i]             = "yellow";
      $timestamp_datimiei[$i] = $data_inizio[$i];
      $timestamp_datafine[$i] = $data_fine[$i];
     
      //=== Terzo evento 
      $i                      = 2;
      $id_note[$i]            = 346;    
      $data_inizio[$i]        = 15;
      $data_fine[$i]          = 18;
      $TESTO_NOTE[$i]         = "Evento dalle 15 alle 18";
      $colore[$i]             = "green";
      $timestamp_datimiei[$i] = $data_inizio[$i];
      $timestamp_datafine[$i] = $data_fine[$i];
     
      //=== Quarto evento 
      $i                      = 3;
      $id_note[$i]            = 488;    
      $data_inizio[$i]        = 20;
      $data_fine[$i]          = 22;
      $TESTO_NOTE[$i]         = "Evento dalle 20 alle 22";
      $colore[$i]             = "#ff7f50";
      $timestamp_datimiei[$i] = $data_inizio[$i];
      $timestamp_datafine[$i] = $data_fine[$i];
     
      //=== Quinto evento 
      $i                      = 4;
      $id_note[$i]            = 567;    
      $data_inizio[$i]        = 3.35;
      $data_fine[$i]          = 4;
      $TESTO_NOTE[$i]         = "Evento dalle 3.35 alle 4";
      $colore[$i]             = "orange";
      $timestamp_datimiei[$i] = $data_inizio[$i];
      $timestamp_datafine[$i] = $data_fine[$i]; 	
     
      //=== Sesto evento 
      $i                      = 5;
      $id_note[$i]            = 616;    
      $data_inizio[$i]        = 7;
      $data_fine[$i]          = 8;
      $TESTO_NOTE[$i]         = "Evento dalle 7 alle 8";
      $colore[$i]             = "cyan";
      $timestamp_datimiei[$i] = $data_inizio[$i];
      $timestamp_datafine[$i] = $data_fine[$i]; 	
     
      //=== Settimo evento 
      $i                      = 6;
      $id_note[$i]            = 703;    
      $data_inizio[$i]        = 11;
      $data_fine[$i]          = 13;
      $TESTO_NOTE[$i]         = "Evento dalle 11 alle 13";
      $colore[$i]             = "maroon";
      $timestamp_datimiei[$i] = $data_inizio[$i];
      $timestamp_datafine[$i] = $data_fine[$i]; 	
     
      //=== Ottavo evento 
      $i                      = 7;
      $id_note[$i]            = 703;    
      $data_inizio[$i]        = 10;
      $data_fine[$i]          = 14;
      $TESTO_NOTE[$i]         = "Evento dalle 10 alle 14";
      $colore[$i]             = "lightblue";
      $timestamp_datimiei[$i] = $data_inizio[$i];
      $timestamp_datafine[$i] = $data_fine[$i]; 		
     
      //=== Nono evento 
      $i                      = 8;
      $id_note[$i]            = 703;    
      $data_inizio[$i]        = 12.15;
      $data_fine[$i]          = 15;
      $TESTO_NOTE[$i]         = "Evento dalle 12.15 alle 15";
      $colore[$i]             = "cadetblue";
      $timestamp_datimiei[$i] = $data_inizio[$i];
      $timestamp_datafine[$i] = $data_fine[$i]; 		
     
      //=== decimo evento 
      $i                      = 9;
      $id_note[$i]            = 213;    
      $data_inizio[$i]        = 6.20;
      $data_fine[$i]          = 12.15;
      $TESTO_NOTE[$i]         = "Evento dalle 6.20 alle 12.15";
      $colore[$i]             = "cornflowerblue";
      $timestamp_datimiei[$i] = $data_inizio[$i];
      $timestamp_datafine[$i] = $data_fine[$i];
     
      //=== Primo evento 
      $i                      = 10;
      $id_note[$i]            = 101;    
      $data_inizio[$i]        = 2.35;
      $data_fine[$i]          = 7.55;
      $TESTO_NOTE[$i]         = "Evento dalle 2.35 alle 7.55";
      $colore[$i]             = "pink";
      $timestamp_datimiei[$i] = $data_inizio[$i];
      $timestamp_datafine[$i] = $data_fine[$i];  
     
     //===============================
     //=== Salvo il numero degli eventi
      $numEventi = $i;
      //=== Preparo l'array delle ore
     $arrayOre = array();
     $arrayJ   = array();
     for($index=0;$index < 24;$index++) {
      $arrayOre[$index] = -1;
      if($index<10) {
        $arrayJ[$index] = "0" . $index . ":00:00";
       } else {
        $arrayJ[$index] = $index . ":00:00";
       } // if($index<10) 
     } // for($index=0;$index < 24;$index++)  
     
     //=== In ogni ora "occupata" metto l'indice dell'evento
     for($index=0;$index <= $numEventi;$index++) {
       for($index2=$data_inizio[$index];$index2<$data_fine[$index];$index2++) {
          if ($index2==$data_inizio[$index]) {
    	    $index2 = (int) $index2;
    	  }
     
          if ($index2==$data_fine[$index]) {
    	    $index2 = (int) $index2 + 1;
    	  }	  
     
    	  if ($arrayOre[$index2] == -1) {
          $arrayOre[$index2] = $index;
    		} else {
    		  //--- Se c'è più di un evento per l'ora lo aggiungo
    			//    avro' la forma evento1,evento2,evento3
    		  $arrayOre[$index2] .= ','.$index;
    		} // if ($arrayOre[$index2] == -1)
      } // for($index2=$data_inizio[$index];$index2<$data_fine[$index]...
     } // for($index=0;$index <= $numEventi;$index++) 
     
      //=== Faccio la conta degli eventi per ora e cerco la profondità
      $maxEventsPerHour = 0;
      for($index=0;$index < 24;$index++) {
    	 if ($arrayOre[$index] != -1) {
    	   $arrTmp = explode(',',$arrayOre[$index]);
    		 $conta  = count($arrTmp);
    		 if ( $conta > $maxEventsPerHour) {
    		  $maxEventsPerHour = $conta;
    		 } // if ( $conta > $maxEventsPerHour) 
     
    		 foreach($arrTmp as $key => $idEvent) {
    		   if (!isset($arrMaxPosEvent[$idEvent])) {
    			   $arrMaxPosEvent[$idEvent] = $key;
    			 } else {
    			   if ($key > $arrMaxPosEvent[$idEvent]) {
    				  $arrMaxPosEvent[$idEvent] = $key;
    				 } // if ($key > $arrMaxPosEvent[$value]) 
    			 } // if (!isset($arrMaxPosEvent[$value]))
    		 } // foreach($arrTmp as $key => $value)
     
    	 } // if ($arrayOre[$index] != -1) 
    	} // for($index=0;$index < 24;$index++)  
     
    	//=== Mi creo un array delle posizioni di ogni evento nella tabella finale
    	$arrEventPosition = array();
      for($index=0;$index < 24;$index++) {
    	 for($pos=0;$pos<$maxEventsPerHour;$pos++) {
    	  $arrEventPosition[$index][$pos] = 'x';
    	 } // for($pos=0;$pos<=$maxEventsPerHour;$pos++)
    	} // for($index=0;$index < 24;$index++) 	 
     
      for($index=0;$index < 24;$index++) {
    	  if ($arrayOre[$index] != -1) {
    	    $arrTmp = explode(',',$arrayOre[$index]);
    			foreach($arrTmp as $key => $idEvent) {
    			  $idPosition = $arrMaxPosEvent[$idEvent];
    			  $arrEventPosition[$index][$idPosition] = $idEvent;
    			} // foreach($arrTmp as $key => $idEvent)
    		} // if ($arrayOre[$index] != -1) {
    	} // for($index=0;$index < 24;$index++) 	
    ?>
    <table cellspacing="0" cellpadding="0" class="table">
    <?php 
     $idIndex = 0;
     for($index=0;$index < 24;$index++) {
      $curId = $arrayOre[$index];
      $J     = $arrayJ[$index];
      if ($curId != -1) {
    	  print "<tr class='riga'>\n";
    		print "<td class='td_ora'>$J</td>\n";
    	    $arrayHourEvents = $arrEventPosition[$index];
    		foreach($arrayHourEvents as $key => $curEventId) {
    		 if ($curEventId == 'x') {
    		   print "<td class='td'>&nbsp;</td>\n";  
    		 } else {
               $color  = $colore[$curEventId];
               $testo  = $TESTO_NOTE[$curEventId];	
               //--- calcolo dell'altezza e posizione del div
    		   $ora_corrente = (int) substr($J, 0, 2);
    		   //--- data inizio
    		   $diL          = $data_inizio[$curEventId];
    		   $di           = (int) $diL;
    		   $minuti_di    = (int) (($diL - $di) * 100);
     
    		   //--- data fine
    		   $dfL          = $data_fine[$curEventId];
               $df           = (int) $dfL;
    		   $minuti_df    = (int) (($dfL - $df) * 100);
     
    		   //--- Posizione e altezza di default
    		   $top          = 0;
    		   $alt          = 100;
     
    		   if ($ora_corrente == $di) {
    		     if ($minuti_di != 0) {
    			   $top = (int) (($minuti_di / 60) * 100);
    			   $alt = (int) (100 - $top);
    			 }
    		   }
     
    		   if ($ora_corrente == $df) {
    		     if ($minuti_df != 0) {
    			   //$walt = (int) (((60 - $minuti_df - $minuti_di) / 60) * 100);	
    			   $walt = (int) (((60 - $minuti_df) / 60) * 100);		
    			   $alt  = $alt - $walt;
    			 } 
    		   } 
     
    		   $top = (int) $top;
    		   $alt = (int) $alt;
    		   $idIndex++;
    		   print "<td class='td'>";
    		   print "<div style='display:none;' id='oraid_$idIndex'>$testo</div>";
    		   print "<div style='background-color:$color;height:$alt%;position:relative;top:${top}%;width:100%' 
    		   onclick=\"javascript:location='modifica_pagina.htm?id=$curEventId'\" title='$testo'>$testo</div>";
    		   print "</td>";
    		   $TESTO_NOTE[$curEventId] = "&nbsp;";
    		 } // if ($curEventId == 'x')
    		} // foreach($arrayHourEvents as $key => $curEventId)
    		print "</tr>\n";
      } else {
        print "<tr class='riga' onclick=\"javascript:location='nuova_pagina.htm?timestamp=$index'\">\n";
        print "<td class='td_ora'>$J </td>\n"; 
    	for ($max=0;$max<$maxEventsPerHour;$max++) {
    	  print "<td class='td'>&nbsp;</td>\n"; 
    	}
        print "</tr>\n";  
      } // if ($curId != -1)
     }  
     ?>
    </table> 
    </body>
    </html>
    Cela ne sert à rien d'optimiser quelque chose qui ne fonctionne pas.

    Mon site : www.emmella.fr

    Je recherche le manuel de l'Olivetti Logos 80B.

  3. #3
    Membre éprouvé
    Homme Profil pro
    Développeur Web
    Inscrit en
    Novembre 2013
    Messages
    739
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Novembre 2013
    Messages : 739
    Points : 1 022
    Points
    1 022
    Par défaut
    Bonjour,
    la solution pret à porter sous Symfony ça peut ne pas exister .
    Si je suis obligé à écrire du code, il faut le faire et surtout avec la bonne architecture.
    Le darg'n'drop existe avec Jquery et c'est simple . Les calendriers et les agendas aussi.
    L'interaction front=>Base de données se fait avec Ajax ( pas de sourcils)
    Les traitements particuliers ( contexte du projet) à faire dans un package service .
    Malheureusement les bundles Symfony sont peut par rapport a d'autres frameworks et CMS
    Une fois tu as commencé à coder les choses deviennent plus claires pour toi et en cas de blocage technique fait nous signe

  4. #4
    Membre averti
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Août 2011
    Messages
    754
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 30
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Août 2011
    Messages : 754
    Points : 376
    Points
    376
    Par défaut
    Pas de solution miracle alors dommage !

    Merci quand même pour vos indications, je reviendrais vers vous si j'ai des soucis.

  5. #5
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2014
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juillet 2014
    Messages : 3
    Points : 4
    Points
    4
    Par défaut Calendrier Symfony / fullcalendar.js
    Bonjour,

    Je pense que pour vous c'est trop tard mais des solutions existes bien sous symfony.

    https://github.com/tattali/CalendarBundle

    Compatible avec Symfony 3.4 en version flex et Symfony 4.0+

Discussions similaires

  1. calendrier ou agenda numéric
    Par capoo dans le forum VB 6 et antérieur
    Réponses: 1
    Dernier message: 14/03/2008, 19h52
  2. [Calendrier] Exploiter le calendrier Google Agenda dans un site web PHP
    Par Malacéine dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 1
    Dernier message: 14/09/2007, 12h20
  3. [CXI]:Rendu calendrier type calendar
    Par jaskoula dans le forum SAP Crystal Reports
    Réponses: 1
    Dernier message: 05/07/2007, 14h16
  4. REcherche calendrier type sncf
    Par zulot dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 19/02/2007, 14h53
  5. [C#] Calendrier journalier / Agenda
    Par jacpapac dans le forum Windows Forms
    Réponses: 3
    Dernier message: 14/09/2006, 17h20

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