Subversion Repositories Applications.bazar

Rev

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

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