Subversion Repositories Applications.bazar

Rev

Rev 290 | Rev 336 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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