Subversion Repositories Applications.bazar

Rev

Rev 411 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 411 Rev 419
Line 17... Line 17...
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.24.2.4 2008-04-16 12:37:15 alexandre_tb Exp $
22
// CVS : $Id: bazar.fonct.cal.php,v 1.29 2008-10-29 10:38:51 alexandre_tb Exp $
23
/**
23
/**
24
*
24
*
25
* Fonctions calendrier du module bazar
25
* Fonctions calendrier du module bazar
26
*
26
*
-
 
27
* TODO : ajouter la gestion du multilinguisme
-
 
28
* 
27
*@package bazar
29
*@package bazar
28
//Auteur original :
30
//Auteur original :
29
*@author        David Delon <david.delon@clapas.net>
31
*@author        David Delon <david.delon@clapas.net>
30
//Autres auteurs :
32
//Autres auteurs :
31
*@copyright     Tela-Botanica 2000-2004
33
*@copyright     Tela-Botanica 2000-2004
32
*@version       $Revision: 1.24.2.4 $ $Date: 2008-04-16 12:37:15 $
34
*@version       $Revision: 1.29 $ $Date: 2008-10-29 10:38:51 $
33
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
34
*/
36
*/
Line 35... Line 37...
35
 
37
 
36
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
Line 128... Line 130...
128
	$url->addQueryString('y', date('Y',$curStamp));
130
	$url->addQueryString('y', date('Y',$curStamp));
129
	$url->addQueryString('m', date('n',$curStamp));
131
	$url->addQueryString('m', date('n',$curStamp));
130
	$url->addQueryString('d', date('j',$curStamp));
132
	$url->addQueryString('d', date('j',$curStamp));
131
	$cur = $url->getUrl();
133
	$cur = $url->getUrl();
Line -... Line 134...
-
 
134
 
-
 
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
	}
132
 
143
 
133
	// Gestion de l'affichage des titres des évènements
144
	// Gestion de l'affichage des titres des évènements
134
	if (isset($_GET['ctt']) && $_GET['ctt'] == '1') {
145
	if (isset($_GET['ctt']) && $_GET['ctt'] == '1') {
135
		$url->addQueryString('tt', '0');
146
		$url->addQueryString('tt', '0');
136
		if (isset($_GET['tt']) && $_GET['tt'] == '0') {
147
		if (isset($_GET['tt']) && $_GET['tt'] == '0') {
Line 150... Line 161...
150
	$tc_txt = 'Afficher les titres complets des évènements';
161
	$tc_txt = 'Afficher les titres complets des évènements';
151
	if (isset($_GET['tt']) && $_GET['tt'] == '0') {
162
	if (isset($_GET['tt']) && $_GET['tt'] == '0') {
152
		$tc_txt = 'Tronquer les titres des évènements';
163
		$tc_txt = 'Tronquer les titres des évènements';
153
		$url->addQueryString('tt', $_GET['tt']);
164
		$url->addQueryString('tt', $_GET['tt']);
154
	}
165
	}
-
 
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;
-
 
170
	unset($ficnat_chps_cache['ficnat']); 
Line 155... Line 171...
155
	
171
	
156
	// Navigation 
172
	// Navigation 
157
	$prevStamp = $month->prevMonth(true);
173
	$prevStamp = $month->prevMonth(true);
158
	$url->addQueryString('y', date('Y',$prevStamp));
174
	$url->addQueryString('y', date('Y',$prevStamp));
Line 170... Line 186...
170
	$url->removeQueryString('tt');
186
	$url->removeQueryString('tt');
Line 171... Line 187...
171
	
187
	
172
	$fr_month = array(	"1"=>BAZ_JANVIER,"2"=>BAZ_FEVRIER,"3"=>BAZ_MARS,"4"=>BAZ_AVRIL,"5"=>BAZ_MAI,"6"=>BAZ_JUIN,
188
	$fr_month = array(	"1"=>BAZ_JANVIER,"2"=>BAZ_FEVRIER,"3"=>BAZ_MARS,"4"=>BAZ_AVRIL,"5"=>BAZ_MAI,"6"=>BAZ_JUIN,
Line -... Line 189...
-
 
189
						"7"=>BAZ_JUILLET,"8"=>BAZ_AOUT,"9"=>BAZ_SEPTEMBRE,"10"=>BAZ_OCTOBRE,"11"=>BAZ_NOVEMBRE,"12"=>BAZ_DECEMBRE);
-
 
190
 
-
 
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) : '';
-
 
197
	
-
 
198
	// Ajout du javascript et des styles du bazar
-
 
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');
-
 
203
		
-
 
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");
173
						"7"=>BAZ_JUILLET,"8"=>BAZ_AOUT,"9"=>BAZ_SEPTEMBRE,"10"=>BAZ_OCTOBRE,"11"=>BAZ_NOVEMBRE,"12"=>BAZ_DECEMBRE);
216
	}
174
 
217
	
175
	// Titre
-
 
176
	if ($type == 'calendrier') {
-
 
177
		// Ajout des styles du bazar
-
 
178
		if (defined('PAP_VERSION')) { //si on est dans Papyrus
-
 
179
			GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
-
 
180
			GEN_stockerFichierScript('domLib', '/api/js/domtooltip/domLib.js');
-
 
181
			GEN_stockerFichierScript('domTT', '/api/js/domtooltip/domTT.js');
-
 
182
			// DomToolTip
-
 
183
			$script = 'var domTT_styleClass = "niceTitle";'."\n";
-
 
184
			$script .= 'function nicetitleDecorator(el) {'."\n";
-
 
185
			$script .= '	var result = el.title;'."\n";
-
 
186
			$script .= '	result = result.replace(new RegExp("\n", "g"), "<br />");'."\n";
-
 
187
			$script .= '	if (el.href) {'."\n";
-
 
188
			$script .= '		result += "<p>" + el.href + "</p>";'."\n";
-
 
189
			$script .= '	}'."\n";
-
 
190
			$script .= '	return result;'."\n";
-
 
191
			$script .= '}'."\n";
-
 
192
			$script .= 'domTT_replaceTitles(nicetitleDecorator);'."\n";
-
 
193
			GEN_stockerCodeScript('var domTT_styleClass = "niceTitle";'."\n");
218
	// Titre
194
		}
219
	if ($type == 'calendrier') {
195
		$retour .= '<div id="cal_entete">';
220
		$retour .= '<div id="cal_entete">'."\n";
196
		$retour .= '<span class="cal_navigation">';	
221
		$retour .= '<span class="cal_navigation">'."\n";	
197
		$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>'; 
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"; 
198
		$retour .= '&nbsp;&nbsp;';
223
		$retour .= '&nbsp;&nbsp;'."\n";
199
		$retour .= '<span id="cal_encadre_mois_courrant"><a id="cal_mois_courrant" href="'.$cur.'">';
224
		$retour .= '<span id="cal_encadre_mois_courrant"><a id="cal_mois_courrant" href="'.$cur.'">';
200
		$retour .= $fr_month[(date('n',$curStamp))]; 
225
		$retour .= $fr_month[(date('n',$curStamp))]; 
201
		$retour .= '&nbsp;';
226
		$retour .= '&nbsp;';
202
		$retour .= (date('Y',$curStamp));
227
		$retour .= (date('Y',$curStamp));
203
		$retour .= '</a></span>';
228
		$retour .= '</a></span>'."\n";
204
		$retour .= '&nbsp;&nbsp;';
229
		$retour .= '&nbsp;&nbsp;'."\n";
205
		$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>';
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";
206
		$retour .= '</span>';
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";
-
 
234
		
-
 
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";
-
 
240
		
-
 
241
		$retour .= '<option id="filtre_tous" value="*" ';
-
 
242
		if (isset($_GET['ficnat']) && '*' == $_GET['ficnat']) {
-
 
243
			$retour .= 'selected="selected" ';
-
 
244
		}
-
 
245
		$retour .= '>'.'Tout afficher'.'</option>';
-
 
246
		
-
 
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 .= '>';
-
 
253
			
-
 
254
			$retour .= $opt.$ligne_nature_fiche->bn_label_nature.'</option>'."\n";
-
 
255
		}
-
 
256
		
-
 
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
		}
Line 207... Line -...
207
		$retour .= '<h1 id="cal_titre"><img id="cal_titre_img" src="client/bazar/images/cal_titre.png" alt="Calendrier"/></h1>';
-
 
208
		$retour .= '</div>';
266
		$retour .= '</fieldset>'."\n";
209
		
267
		$retour .= '</form>'."\n";
210
		$retour .= '<p>'.'<a href="'.$tc_lien.'">'.$tc_txt.'</a>'.'</p>';
268
		
211
	} else {
269
	} else {
212
		// Appel du template
270
		// Appel du template
Line 220... Line 278...
220
	if ((!isset($_GET['id_fiche']) && $type == 'calendrier') || ($type == 'calendrier_applette')){
278
	if ((!isset($_GET['id_fiche']) && $type == 'calendrier') || ($type == 'calendrier_applette')){
221
//		trigger_error('ICI', E_USER_NOTICE);
279
//		trigger_error('ICI', E_USER_NOTICE);
222
		// Recherche evenement de la periode selectionnée 
280
		// Recherche evenement de la periode selectionnée 
223
		$ts_jour_fin_mois = $month->nextMonth('timestamp');
281
		$ts_jour_fin_mois = $month->nextMonth('timestamp');
224
		$ts_jour_debut_mois = $month->thisMonth('timestamp');; 
282
		$ts_jour_debut_mois = $month->thisMonth('timestamp');; 
-
 
283
	    $requete_evenements = 	"SELECT DISTINCT bf_id_fiche, bf_titre, bf_lieu_evenement, ".
225
	    $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 ".
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 ".
226
								"FROM bazar_fiche, bazar_nature ".
286
								"FROM bazar_fiche, bazar_nature ".
227
								"WHERE bf_date_debut_evenement < '".date('Y-m-d', $ts_jour_fin_mois)."' ".
287
								"WHERE bf_date_debut_evenement < '".date('Y-m-d', $ts_jour_fin_mois)."' ".
228
								"AND bf_date_fin_evenement >= '".date('Y-m-d', $ts_jour_debut_mois)."' ".
288
								"AND bf_date_fin_evenement >= '".date('Y-m-d', $ts_jour_debut_mois)."' ".
229
								"AND bf_ce_nature = bn_id_nature ".
289
								"AND bf_ce_nature = bn_id_nature ".
230
								"AND bn_id_nature IN (".BAZ_NUM_ANNONCE_CALENDRIER.") ".
290
								"AND bn_id_nature IN (".$cal_num_annonce.") ".
231
								"AND bf_statut_fiche = 1 ".
291
								"AND bf_statut_fiche = 1 ".
232
								"ORDER BY bf_jour_debut_evenement";
292
								"ORDER BY bf_jour_debut_evenement";
Line 233... Line 293...
233
		
293
		
Line 282... Line 342...
282
					$tablo_jours[$cle_j]['Diary_Event'] = new DiaryEvent($tablo_jours[$cle_j]['Calendar_Day']);
342
					$tablo_jours[$cle_j]['Diary_Event'] = new DiaryEvent($tablo_jours[$cle_j]['Calendar_Day']);
283
				}
343
				}
284
				$tablo_jours[$cle_j]['Diary_Event']->setEntry($ligne_evenements);
344
				$tablo_jours[$cle_j]['Diary_Event']->setEntry($ligne_evenements);
285
	    	}
345
	    	}
286
		}
346
		}
287
		
-
 
288
		// Add the decorator to the selection
347
		// Add the decorator to the selection
289
		foreach ($tablo_jours as $jour) {
348
		foreach ($tablo_jours as $jour) {
290
			$selection[] = $jour['Diary_Event'];
349
			$selection[] = $jour['Diary_Event'];				
291
		}
350
		}
292
		
351
	
293
		// Affichage Calendrier
352
		// Affichage Calendrier
294
		$month->build($selection);
353
		$month->build($selection);
295
		if ($type == 'calendrier') {
354
		if ($type == 'calendrier') {
296
			$retour.= '<table class="calendrier">'.
355
			$retour.= '<table class="calendrier">'.
297
				'<colgroup>'.
356
				'<colgroup>'.
Line 386... Line 445...
386
							$titre_taille = strlen($ligne_evenement->bf_titre);
445
							$titre_taille = strlen($ligne_evenement->bf_titre);
387
							$titre = ($titre_taille > 20)?substr($ligne_evenement->bf_titre, 0, 20).'...':$ligne_evenement->bf_titre;
446
							$titre = ($titre_taille > 20)?substr($ligne_evenement->bf_titre, 0, 20).'...':$ligne_evenement->bf_titre;
388
						} else {
447
						} else {
389
							$titre = $ligne_evenement->bf_titre;
448
							$titre = $ligne_evenement->bf_titre;
390
						}
449
						}
391
						$evenemt_xhtml .= '<li class="tooltip" title="'.$ligne_evenement->bf_titre.'"><a class="cal_evenemt" href="'.$link.'">'.$titre.'</a></li>'."\n";
450
						$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";
392
						$url->removeQueryString ('id_fiches');
451
						$url->removeQueryString ('id_fiches');
393
					}
452
					}
394
					if ($evenements_nbre > 0) {
453
					if ($evenements_nbre > 0) {
395
						$retour .= '<ul class="cal_evenemt_liste">';
454
						$retour .= '<ul class="cal_evenemt_liste">';
396
						$retour .= $evenemt_xhtml;
455
						$retour .= $evenemt_xhtml;
Line 398... Line 457...
398
					}
457
					}
399
				}
458
				}
400
			} else {
459
			} else {
401
				$lien_date= "<td class=\"".$class."\">".$day->thisDay();
460
				$lien_date= "<td class=\"".$class."\">".$day->thisDay();
402
				if ($day->isSelected() ) {
461
				if ($day->isSelected() ) {
403
					$evenements=$day->getEntry();
462
					$evenements = $day->getEntry();
404
					$id_fiches=array();
463
					$id_fiches = array();
-
 
464
					$info_fiches = null;
405
					while ($ligne_evenement=array_pop($evenements)) {
465
					while ($ligne_evenement = array_pop($evenements)) {
406
						$id_fiches[]=$ligne_evenement->bf_id_fiche;
466
						$id_fiches[] = $ligne_evenement->bf_id_fiche;
-
 
467
						$info_fiches .= '&rArr; '.str_replace('"', '\'', $ligne_evenement->bf_titre)."\n";
407
					}
468
					}
408
					$url->addQueryString ('id_fiches',$id_fiches);
469
					$url->addQueryString('id_fiches', $id_fiches);
409
					$link = $url->getUrl();
470
					$link = $url->getUrl();
410
					$lien_date= "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n";
471
					$lien_date = '<td class="'.$class.'"><a href="'.$link.'" class="tooltip" title="'.$info_fiches.'">'.$day->thisDay()."</a>\n";
411
					$url->removeQueryString ('id_fiches');
472
					$url->removeQueryString('id_fiches');
412
				}
473
				}
413
				$retour.=$lien_date;
474
				$retour .= $lien_date;
414
			}
475
			}
415
			$retour.= ( "</td>\n" );
476
			$retour.= ( "</td>\n" );
Line 416... Line 477...
416
			
477
			
417
			// isLast() to find end of week
478
			// isLast() to find end of week