Subversion Repositories Applications.bazar

Rev

Rev 399 | Rev 468 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
30 ddelon 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
399 alexandre_ 22
// CVS : $Id: bazar.fonct.cal.php,v 1.29 2008-10-29 10:38:51 alexandre_tb Exp $
30 ddelon 23
/**
24
*
25
* Fonctions calendrier du module bazar
26
*
383 jp_milcent 27
* TODO : ajouter la gestion du multilinguisme
446 aurelien 28
*
30 ddelon 29
*@package bazar
30
//Auteur original :
31
*@author        David Delon <david.delon@clapas.net>
32
//Autres auteurs :
33
*@copyright     Tela-Botanica 2000-2004
399 alexandre_ 34
*@version       $Revision: 1.29 $ $Date: 2008-10-29 10:38:51 $
30 ddelon 35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
225 neiluj 41
 
55 florian 42
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Month/Weekdays.php';
43
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Day.php';
446 aurelien 44
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Decorator.php';
30 ddelon 45
 
46
// +------------------------------------------------------------------------------------------------------+
47
// |                                           LISTE de FONCTIONS                                         |
48
// +------------------------------------------------------------------------------------------------------+
49
 
50
// Classe Utilitaire pour Calendrier
51
class DiaryEvent extends Calendar_Decorator {
205 jp_milcent 52
	var $entry = array();
53
	function DiaryEvent($calendar)
54
	{
30 ddelon 55
		Calendar_Decorator::Calendar_Decorator($calendar);
56
	}
205 jp_milcent 57
	function setEntry($entry)
58
	{
59
		$this->entry[] = $entry;
446 aurelien 60
 
30 ddelon 61
	}
205 jp_milcent 62
	function getEntry()
63
	{
30 ddelon 64
		return $this->entry;
65
	}
446 aurelien 66
}
30 ddelon 67
 
68
 
42 ddelon 69
// $type : calendrier
70
// $type : calendrier_appplette
258 alexandre_ 71
function GestionAffichageCalendrier($arguments = array(), $type = 'calendrier') {
290 alexandre_ 72
	$script = '';
258 alexandre_ 73
	// recuperation des arguments de l applette
74
	$balise = isset ($arguments[0]) ? $arguments[0] : '';
75
    $tab_arguments = $arguments;
336 alexandre_ 76
	if (is_string ($tab_arguments)) {
77
		$tab_arguments = substr($tab_arguments, 1);
78
	} else {
446 aurelien 79
		unset($tab_arguments[0]);
336 alexandre_ 80
	}
258 alexandre_ 81
	if (is_array($tab_arguments)) {
82
	    foreach($tab_arguments as $argument) {
83
	    	if ($argument != '') {
84
		    	$tab_parametres = explode('=', $argument, 2);
267 florian 85
		    	if (is_array($tab_parametres)) {
446 aurelien 86
		    		$options[$tab_parametres[0]] =
87
		    		(isset($tab_parametres[1])? trim($tab_parametres[1], '"') : '') ;
267 florian 88
		    	}
258 alexandre_ 89
	    	}
90
	    }
91
	}
446 aurelien 92
 
258 alexandre_ 93
    if (!isset($options['template'])) {
94
		$options['template'] = BAZ_CHEMIN_SQUELETTE.BAZ_SQUELETTE_DEFAUT;
95
	} else {
96
		if (file_exists(BAZ_CHEMIN_SQUELETTE.$options['template'])) {
97
			$options['template'] = BAZ_CHEMIN_SQUELETTE.$options['template'];
98
		}
99
	}
446 aurelien 100
 
208 jp_milcent 101
	$retour = '';
225 neiluj 102
 
30 ddelon 103
	$url = $GLOBALS['_GEN_commun']['url'] ;
205 jp_milcent 104
	$db =& $GLOBALS['_GEN_commun']['pear_db'] ;
105
	$auth =& $GLOBALS['_GEN_commun']['pear_auth'] ;
446 aurelien 106
 
279 alexandre_ 107
	// Nettoyage de l'url de la query string
108
	$chaine_url = $url->getQueryString();
109
	$tab_params = explode('&amp;', $chaine_url);
110
	if (count($tab_params) == 0) {
111
		$tab_params = explode('&', $chaine_url);
112
	}
113
	foreach ($tab_params as $param) {
114
		$tab_parametre = explode('=', $param);
115
		$url->removeQueryString($tab_parametre[0]);
116
	}
446 aurelien 117
 
118
	if (!isset($_GET['y'])) {
30 ddelon 119
		$_GET['y'] = date('Y');
120
	}
446 aurelien 121
 
122
	if (!isset($_GET['m'])) {
30 ddelon 123
		$_GET['m'] = date('m');
124
	}
446 aurelien 125
 
126
	// 	Construction Mois en Cours
30 ddelon 127
	$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
128
 
205 jp_milcent 129
	$curStamp = $month->getTimeStamp();
130
	$url->addQueryString('y', date('Y',$curStamp));
131
	$url->addQueryString('m', date('n',$curStamp));
132
	$url->addQueryString('d', date('j',$curStamp));
30 ddelon 133
	$cur = $url->getUrl();
279 alexandre_ 134
 
383 jp_milcent 135
	// Gestion de l'affichage du filtre des natures d'évènements
136
	$cal_num_annonce = BAZ_NUM_ANNONCE_CALENDRIER;
137
	$ficnat_id = null;
138
	if (isset($_GET['ficnat']) && $_GET['ficnat'] != '*') {
139
		$ficnat_id = $_GET['ficnat'];
140
		$url->addQueryString('ficnat', $_GET['ficnat']);
141
		$cal_num_annonce = $_GET['ficnat'];
142
	}
143
 
279 alexandre_ 144
	// Gestion de l'affichage des titres des évènements
145
	if (isset($_GET['ctt']) && $_GET['ctt'] == '1') {
146
		$url->addQueryString('tt', '0');
147
		if (isset($_GET['tt']) && $_GET['tt'] == '0') {
148
			$url->addQueryString('tt', '1');
149
		}
150
		$tc_lien = $url->getUrl();
151
	} else {
152
		$url->addQueryString('tt', '0');
153
		if (isset($_GET['tt']) && $_GET['tt'] == '0') {
154
			$url->addQueryString('tt', '1');
155
		}
156
		$url->addQueryString('ctt', '1');
157
		$tc_lien = $url->getUrl();
158
	}
159
	$url->removeQueryString('ctt');
160
	$url->removeQueryString('tt');
161
	$tc_txt = 'Afficher les titres complets des évènements';
162
	if (isset($_GET['tt']) && $_GET['tt'] == '0') {
163
		$tc_txt = 'Tronquer les titres des évènements';
164
		$url->addQueryString('tt', $_GET['tt']);
165
	}
383 jp_milcent 166
 
167
	//	Gestion des champs cachés pour le formulaire de filtre
168
	// Attention  à la position dans le fichier...
169
	$ficnat_chps_cache = $url->querystring;
446 aurelien 170
	unset($ficnat_chps_cache['ficnat']);
171
 
172
	// Navigation
30 ddelon 173
	$prevStamp = $month->prevMonth(true);
205 jp_milcent 174
	$url->addQueryString('y', date('Y',$prevStamp));
175
	$url->addQueryString('m', date('n',$prevStamp));
176
	$url->addQueryString('d', date('j',$prevStamp));
30 ddelon 177
	$prev = $url->getUrl();
446 aurelien 178
 
30 ddelon 179
	$nextStamp = $month->nextMonth(true);
205 jp_milcent 180
	$url->addQueryString('y', date('Y',$nextStamp));
181
	$url->addQueryString('m', date('n',$nextStamp));
182
	$url->addQueryString('d', date('j',$nextStamp));
30 ddelon 183
	$next = $url->getUrl();
446 aurelien 184
 
279 alexandre_ 185
	// Suppression du paramêtre de troncage des titres
186
	$url->removeQueryString('tt');
446 aurelien 187
 
205 jp_milcent 188
	$fr_month = array(	"1"=>BAZ_JANVIER,"2"=>BAZ_FEVRIER,"3"=>BAZ_MARS,"4"=>BAZ_AVRIL,"5"=>BAZ_MAI,"6"=>BAZ_JUIN,
189
						"7"=>BAZ_JUILLET,"8"=>BAZ_AOUT,"9"=>BAZ_SEPTEMBRE,"10"=>BAZ_OCTOBRE,"11"=>BAZ_NOVEMBRE,"12"=>BAZ_DECEMBRE);
30 ddelon 190
 
383 jp_milcent 191
	// Récupération des infos sur les natures des fiches pour le filtre
192
	$requete_nature_fiche = 'SELECT DISTINCT bn_id_nature, bn_ce_i18n, bn_label_nature '.
193
							'FROM bazar_nature '.
194
							'WHERE bn_id_nature IN ('.BAZ_NUM_ANNONCE_CALENDRIER.') ';
195
	$resultat_nature_fiche = $db->query($requete_nature_fiche);
196
	(DB::isError($resultat_nature_fiche)) ? trigger_error(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_nature_fiche->getMessage(), $requete_nature_fiche), E_USER_WARNING) : '';
446 aurelien 197
 
384 jp_milcent 198
	// Ajout du javascript et des styles du bazar
383 jp_milcent 199
	if (defined('PAP_VERSION')) { //si on est dans Papyrus
200
		GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
201
		GEN_stockerFichierScript('domLib', '/api/js/domtooltip/domLib.js');
202
		GEN_stockerFichierScript('domTT', '/api/js/domtooltip/domTT.js');
446 aurelien 203
 
383 jp_milcent 204
		// DomToolTip
205
		$script = 'var domTT_styleClass = "niceTitle";'."\n";
206
		$script .= 'function nicetitleDecorator(el) {'."\n";
207
		$script .= '	var result = el.title;'."\n";
208
		$script .= '	result = result.replace(new RegExp("\n", "g"), "<br />");'."\n";
209
		$script .= '	//if (el.href) {'."\n";
210
		$script .= '		//result += "<p>" + el.href + "<\/p>";'."\n";
211
		$script .= '	//}'."\n";
212
		$script .= '	return result;'."\n";
213
		$script .= '}'."\n";
214
		$script .= 'domTT_replaceTitles(nicetitleDecorator);'."\n";
215
		GEN_stockerCodeScript('var domTT_styleClass = "niceTitle";'."\n");
216
	}
446 aurelien 217
 
279 alexandre_ 218
	// Titre
219
	if ($type == 'calendrier') {
383 jp_milcent 220
		$retour .= '<div id="cal_entete">'."\n";
446 aurelien 221
		$retour .= '<span class="cal_navigation">'."\n";
222
		$retour .= '<a id="cal_precedent_lien" href="'.$prev.'" title="Allez au mois précédent"><img id="cal_precedent_img" src="client/bazar/images/cal_precedent.png" alt="&lt;&lt;"/></a>'."\n";
383 jp_milcent 223
		$retour .= '&nbsp;&nbsp;'."\n";
279 alexandre_ 224
		$retour .= '<span id="cal_encadre_mois_courrant"><a id="cal_mois_courrant" href="'.$cur.'">';
446 aurelien 225
		$retour .= $fr_month[(date('n',$curStamp))];
279 alexandre_ 226
		$retour .= '&nbsp;';
227
		$retour .= (date('Y',$curStamp));
383 jp_milcent 228
		$retour .= '</a></span>'."\n";
229
		$retour .= '&nbsp;&nbsp;'."\n";
230
		$retour .= '<a id="cal_suivant_lien" href="'.$next.'" title="Allez au mois suivant"><img id="cal_suivant_img" src="client/bazar/images/cal_suivant.png" alt="&gt;&gt;"/></a>'."\n";
231
		$retour .= '</span>'."\n";
232
		$retour .= '<h1 id="cal_titre"><img id="cal_titre_img" src="client/bazar/images/cal_titre.png" alt="Calendrier"/></h1>'."\n";
233
		$retour .= '</div>'."\n";
446 aurelien 234
 
383 jp_milcent 235
		$retour .= '<form action="'.$tc_lien.'" method="get">'."\n";
236
		$retour .= '<a href="'.$tc_lien.'">'.$tc_txt.'</a>'."\n";
237
		$retour .= '<fieldset>'."\n";
238
		$retour .= '<legend>'.'Filtrer : '.'</legend>'."\n";
239
		$retour .= '<select id="ficnat" name="ficnat" class="filtre_'.((!is_null($ficnat_id)) ? $ficnat_id: 'tous').'"  onchange="javascript:this.form.submit();">'."\n";
446 aurelien 240
 
383 jp_milcent 241
		$retour .= '<option id="filtre_tous" value="*" ';
242
		if (isset($_GET['ficnat']) && '*' == $_GET['ficnat']) {
243
			$retour .= 'selected="selected" ';
244
		}
245
		$retour .= '>'.'Tout afficher'.'</option>';
446 aurelien 246
 
383 jp_milcent 247
		while ($ligne_nature_fiche = $resultat_nature_fiche->fetchRow(DB_FETCHMODE_OBJECT)) {
248
			$opt = '<option class="filtre_'.$ligne_nature_fiche->bn_id_nature.'" value="'.$ligne_nature_fiche->bn_id_nature.'" ';
249
			if (isset($_GET['ficnat']) && $ligne_nature_fiche->bn_id_nature == $_GET['ficnat']) {
250
				$opt .= 'selected="selected" ';
251
			}
252
			$opt .= '>';
446 aurelien 253
 
383 jp_milcent 254
			$retour .= $opt.$ligne_nature_fiche->bn_label_nature.'</option>'."\n";
255
		}
446 aurelien 256
 
383 jp_milcent 257
		$retour .= '</select>'."\n";
258
		$retour .= '<input id="ficnat_ok" type="submit" value="'.'OK'.'" onload="javascript:this.setAttribute(\'style\', \'display:none;\')"/>'."\n";
259
		$script_ok = 	'if (document.getElementById(\'ficnat_ok\')) {'.
260
						'	document.getElementById(\'ficnat_ok\').style.display = \'none\';'.
261
						'}';
262
		$retour.= '<script type="text/javascript">//<![CDATA['."\n".$script_ok.'//]]></script>'."\n";
263
		foreach ($ficnat_chps_cache as $cle => $val) {
264
			$retour .= '<input id="'.$cle.'" name="'.$cle.'" type="hidden" value="'.$val.'" />'."\n";
265
		}
266
		$retour .= '</fieldset>'."\n";
267
		$retour .= '</form>'."\n";
446 aurelien 268
 
279 alexandre_ 269
	} else {
270
		// Appel du template
271
		ob_start();
272
		include $options['template'];
273
		$retour .= ob_get_contents();
274
		ob_end_clean();
275
	}
42 ddelon 276
	// Vue Mois calendrier ou vue applette
446 aurelien 277
 
279 alexandre_ 278
	if ((!isset($_GET['id_fiche']) && $type == 'calendrier') || ($type == 'calendrier_applette')){
290 alexandre_ 279
//		trigger_error('ICI', E_USER_NOTICE);
446 aurelien 280
		// Recherche evenement de la periode selectionnée
279 alexandre_ 281
		$ts_jour_fin_mois = $month->nextMonth('timestamp');
446 aurelien 282
		$ts_jour_debut_mois = $month->thisMonth('timestamp');;
383 jp_milcent 283
	    $requete_evenements = 	"SELECT DISTINCT bf_id_fiche, bf_titre, bf_lieu_evenement, ".
284
	    						"	DAY(bf_date_debut_evenement) AS bf_jour_debut_evenement, bf_date_debut_evenement, ".
285
	    						"	bf_date_fin_evenement, bf_description, bn_id_nature ".
185 jp_milcent 286
								"FROM bazar_fiche, bazar_nature ".
279 alexandre_ 287
								"WHERE bf_date_debut_evenement < '".date('Y-m-d', $ts_jour_fin_mois)."' ".
288
								"AND bf_date_fin_evenement >= '".date('Y-m-d', $ts_jour_debut_mois)."' ".
185 jp_milcent 289
								"AND bf_ce_nature = bn_id_nature ".
383 jp_milcent 290
								"AND bn_id_nature IN (".$cal_num_annonce.") ".
263 alexandre_ 291
								"AND bf_statut_fiche = 1 ".
292
								"ORDER BY bf_jour_debut_evenement";
446 aurelien 293
 
30 ddelon 294
	   	$resultat_evenement = $db->query($requete_evenements);
446 aurelien 295
 
279 alexandre_ 296
	    (DB::isError($resultat_evenement)) ? trigger_error(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements), E_USER_WARNING) : '';
297
 
298
		$selection = array();
299
		$evenements = array();
300
		$annee = date('Y', $curStamp);
301
		$mois = date('m', $curStamp);
302
		$tablo_jours = array();
30 ddelon 303
	    while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
279 alexandre_ 304
			list($annee_debut, $mois_debut, $jour_debut) = explode('-', $ligne_evenements->bf_date_debut_evenement);
305
			list($annee_fin, $mois_fin, $jour_fin) = explode('-', $ligne_evenements->bf_date_fin_evenement);
446 aurelien 306
 
279 alexandre_ 307
			$Calendrier = new Calendar($annee_debut, $mois_debut, $jour_debut);
308
			$ts_jour_suivant = $Calendrier->thisDay('timestamp');
309
			$ts_jour_fin = mktime(0,0,0,$mois_fin, $jour_fin, $annee_fin);
446 aurelien 310
 
311
			$naviguer = true;
312
	    	while ($naviguer && ($ts_jour_suivant <= $ts_jour_fin)) {
313
				// Si le jours suivant est inferieur a la date de fin du mois courrant, on continue...
314
				if ($ts_jour_suivant < $ts_jour_fin_mois) {
315
					$cle_j = date('Y-m-d', $ts_jour_suivant);
316
					if (!isset($tablo_jours[$cle_j])) {
317
						$tablo_jours[$cle_j]['Calendar_Day'] = new Calendar_Day(date('Y', $ts_jour_suivant),date('m', $ts_jour_suivant), date('d', $ts_jour_suivant));
318
						$tablo_jours[$cle_j]['Diary_Event'] = new DiaryEvent($tablo_jours[$cle_j]['Calendar_Day']);
279 alexandre_ 319
					}
446 aurelien 320
					$tablo_jours[$cle_j]['Diary_Event']->setEntry($ligne_evenements);
321
 
322
					$ts_jour_suivant = $Calendrier->nextDay('timestamp');
323
					//echo "ici$ts_jour_suivant-";
324
					$Calendrier->setTimestamp($ts_jour_suivant);
325
					//echo "la".$Calendrier->thisDay('timestamp')."-";
326
				} else {
327
					$naviguer = false;
279 alexandre_ 328
				}
329
	    	}
30 ddelon 330
		}
446 aurelien 331
 
332
 
279 alexandre_ 333
		// Add the decorator to the selection
334
		foreach ($tablo_jours as $jour) {
446 aurelien 335
			$selection[] = $jour['Diary_Event'];
279 alexandre_ 336
		}
446 aurelien 337
 
30 ddelon 338
		// Affichage Calendrier
339
		$month->build($selection);
279 alexandre_ 340
		if ($type == 'calendrier') {
341
			$retour.= '<table class="calendrier">'.
342
				'<colgroup>'.
343
					'<col class="cal_lundi"/>'.
344
					'<col class="cal_mardi"/>'.
345
					'<col class="cal_mercredi"/>'.
346
					'<col class="cal_jeudi"/>'.
347
					'<col class="cal_vendredi"/>'.
348
					'<col class="cal_samedi"/>'.
349
					'<col class="cal_dimanche"/>'.
350
				'</colgroup>'.
351
				'<thead>'.
352
			 	"<tr>
446 aurelien 353
 
42 ddelon 354
			  <th> ". BAZ_LUNDI ."</th>
355
			  <th> ". BAZ_MARDI ."</th>
356
			  <th> ". BAZ_MERCREDI ."</th>
357
			  <th> ". BAZ_JEUDI ."</th>
358
			  <th> ". BAZ_VENDREDI ."</th>
359
			  <th> ". BAZ_SAMEDI ."</th>
360
			  <th> ". BAZ_DIMANCHE ."</th>
361
			 </tr>
279 alexandre_ 362
			 ".'</thead>'.'<tbody>';
363
		} else {
364
			$retour.= '<table class="calendrier_applette">'.
365
				'<colgroup>'.
366
					'<col class="cal_lundi"/>'.
367
					'<col class="cal_mardi"/>'.
368
					'<col class="cal_mercredi"/>'.
369
					'<col class="cal_jeudi"/>'.
370
					'<col class="cal_vendredi"/>'.
371
					'<col class="cal_samedi"/>'.
372
					'<col class="cal_dimanche"/>'.
373
				'</colgroup>'.
374
				'<thead>'.
375
			 "<tr>
446 aurelien 376
 
42 ddelon 377
			  <th> ". BAZ_LUNDI_COURT ."</th>
378
			  <th> ". BAZ_MARDI_COURT ."</th>
379
			  <th> ". BAZ_MERCREDI_COURT ."</th>
380
			  <th> ". BAZ_JEUDI_COURT ."</th>
381
			  <th> ". BAZ_VENDREDI_COURT ."</th>
382
			  <th> ". BAZ_SAMEDI_COURT ."</th>
383
			  <th> ". BAZ_DIMANCHE_COURT ."</th>
384
			 </tr>
279 alexandre_ 385
			 ".'</thead>'.'<tbody>';
42 ddelon 386
		}
446 aurelien 387
 
30 ddelon 388
		$todayStamp=time();
389
		$today_ymd=date('Ymd',$todayStamp);
279 alexandre_ 390
 
446 aurelien 391
		// Other month : mois
30 ddelon 392
		while ($day = $month->fetch() ) {
279 alexandre_ 393
			$dayStamp = $day->thisDay(true);
394
			$day_ymd = date('Ymd',$dayStamp);
395
			if ( $day->isEmpty() ) {
396
				$class = "cal_ma other_month";
397
			} else {
398
				if (($day_ymd < $today_ymd)) {
399
					$class= "cal_mp previous_month";
400
				} else {
401
					 if ($day_ymd == $today_ymd) {
402
					 	$class= "cal_jc current_day";
403
					 } else {
404
						$class="cal_mc current_month";
405
					 }
30 ddelon 406
				}
279 alexandre_ 407
			}
446 aurelien 408
 
279 alexandre_ 409
			$url->addQueryString ('y', date('Y',$dayStamp));
410
			$url->addQueryString ('m', date('n',$dayStamp));
411
			$url->addQueryString ('d', date('j',$dayStamp));
412
			$link = $url->getUrl();
446 aurelien 413
 
279 alexandre_ 414
			// isFirst() to find start of week
415
			if ($day->isFirst()) {
416
				$retour.= ( "<tr>\n" );
417
			}
418
			if ($type == 'calendrier') {
419
				$retour.= "<td class=\"".$class."\">".'<span class="cal_j">'.$day->thisDay().'</span>'."\n";
420
				if ($day->isSelected() ) {
421
					$evenements = $day->getEntry();
422
					$evenements_nbre = count($evenements);
423
					$evenemt_xhtml = '';
424
					while ($ligne_evenement = array_pop($evenements)) {
425
						$id_fiches = array();
426
						$id_fiches[] = $ligne_evenement->bf_id_fiche;
42 ddelon 427
						$url->addQueryString ('id_fiches',$id_fiches);
30 ddelon 428
						$link = $url->getUrl();
446 aurelien 429
 
279 alexandre_ 430
						if (!isset($_GET['tt']) || (isset($_GET['tt']) && $_GET['tt'] == '1')) {
431
							$titre_taille = strlen($ligne_evenement->bf_titre);
432
							$titre = ($titre_taille > 20)?substr($ligne_evenement->bf_titre, 0, 20).'...':$ligne_evenement->bf_titre;
433
						} else {
434
							$titre = $ligne_evenement->bf_titre;
435
						}
383 jp_milcent 436
						$evenemt_xhtml .= '<li class="tooltip nature_'.$ligne_evenement->bn_id_nature.'" title="'.str_replace('"', '\'', $ligne_evenement->bf_titre).'"><a class="cal_evenemt" href="'.$link.'">'.$titre.'</a></li>'."\n";
42 ddelon 437
						$url->removeQueryString ('id_fiches');
30 ddelon 438
					}
279 alexandre_ 439
					if ($evenements_nbre > 0) {
440
						$retour .= '<ul class="cal_evenemt_liste">';
441
						$retour .= $evenemt_xhtml;
442
						$retour .= '</ul>';
443
					}
30 ddelon 444
				}
279 alexandre_ 445
			} else {
297 alexandre_ 446
				$lien_date= "<td class=\"".$class."\">".$day->thisDay();
279 alexandre_ 447
				if ($day->isSelected() ) {
383 jp_milcent 448
					$evenements = $day->getEntry();
449
					$id_fiches = array();
450
					$info_fiches = null;
451
					while ($ligne_evenement = array_pop($evenements)) {
452
						$id_fiches[] = $ligne_evenement->bf_id_fiche;
453
						$info_fiches .= '&rArr; '.str_replace('"', '\'', $ligne_evenement->bf_titre)."\n";
279 alexandre_ 454
					}
383 jp_milcent 455
					$url->addQueryString('id_fiches', $id_fiches);
279 alexandre_ 456
					$link = $url->getUrl();
383 jp_milcent 457
					$lien_date = '<td class="'.$class.'"><a href="'.$link.'" class="tooltip" title="'.$info_fiches.'">'.$day->thisDay()."</a>\n";
458
					$url->removeQueryString('id_fiches');
279 alexandre_ 459
				}
383 jp_milcent 460
				$retour .= $lien_date;
30 ddelon 461
			}
279 alexandre_ 462
			$retour.= ( "</td>\n" );
446 aurelien 463
 
279 alexandre_ 464
			// isLast() to find end of week
465
			if ( $day->isLast() ) {
466
				$retour.= ( "</tr>\n" );
467
			}
42 ddelon 468
		}
279 alexandre_ 469
			$retour.= "</tbody></table>";
470
	}
471
	$retour.= '<script type="text/javascript">//<![CDATA['."\n".$script.'//]]></script>'."\n";
472
	// Vue detail
446 aurelien 473
 
279 alexandre_ 474
	if ((isset($_GET['id_fiches']))) {
475
		// Ajout d'un titre pour la page avec la date
399 alexandre_ 476
		$jours = array ('dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi') ;
279 alexandre_ 477
		$mois = array ('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre',
478
						'octobre', 'novembre', 'décembre') ;
479
		$timestamp = strtotime ($_GET['y'].'/'.$_GET['m'].'/'.$_GET['d']) ;
446 aurelien 480
 
279 alexandre_ 481
		$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_NAVIGATION'] = '';
482
		$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_TETE'] = '';
483
		$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] = '<h1>'.$jours[date('w', $timestamp)].
484
						' '.$_GET['d'].' '.$mois[$_GET['m']-1].' '.$_GET['y'].'</h1>' ;
485
		$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] .= baz_voir_fiches(0,$_GET['id_fiches'] );
297 alexandre_ 486
 
279 alexandre_ 487
		$GLOBALS['_GEN_commun']['info_menu'] = '';
446 aurelien 488
 
297 alexandre_ 489
		// Un lien pour retourner au calendrier
490
		$url->removeQueryString('id_fiches');
491
		$url->removeQueryString('y');
492
		$url->removeQueryString('m');
493
		$url->removeQueryString('d');
494
		$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_PIED'] = '<div class="retour"><a href="'.$url->getURL().'">Retour au calendrier</a></div>';
279 alexandre_ 495
	}
496
 
497
	// Nettoyage de l'url
498
	$url->removeQueryString('id_fiches');
499
	$url->removeQueryString('y');
500
	$url->removeQueryString('m');
501
	$url->removeQueryString('d');
446 aurelien 502
 
503
 
279 alexandre_ 504
	return $retour;
505
}
30 ddelon 506
?>