Subversion Repositories Applications.bazar

Rev

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

Rev 39 Rev 42
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.3 2005-10-21 16:15:04 florian Exp $
22
// CVS : $Id: bazar.fonct.cal.php,v 1.4 2005-10-31 17:10:56 ddelon 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.3 $ $Date: 2005-10-21 16:15:04 $
32
*@version       $Revision: 1.4 $ $Date: 2005-10-31 17:10:56 $
33
// +------------------------------------------------------------------------------------------------------+
33
// +------------------------------------------------------------------------------------------------------+
34
*/
34
*/
35
 
35
 
36
// +------------------------------------------------------------------------------------------------------+
36
// +------------------------------------------------------------------------------------------------------+
37
// |                                            ENTETE du PROGRAMME                                       |
37
// |                                            ENTETE du PROGRAMME                                       |
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
39
 
39
 
40
require_once 'Calendar/Month/Weekdays.php';
40
require_once 'Calendar/Month/Weekdays.php';
41
require_once 'Calendar/Day.php';
41
require_once 'Calendar/Day.php';
42
require_once 'Calendar/Decorator.php'; 
42
require_once 'Calendar/Decorator.php'; 
43
 
43
 
44
 
44
 
45
// +------------------------------------------------------------------------------------------------------+
45
// +------------------------------------------------------------------------------------------------------+
46
// |                                           LISTE de FONCTIONS                                         |
46
// |                                           LISTE de FONCTIONS                                         |
47
// +------------------------------------------------------------------------------------------------------+
47
// +------------------------------------------------------------------------------------------------------+
48
 
48
 
49
 
49
 
50
// Classe Utilitaire pour Calendrier
50
// Classe Utilitaire pour Calendrier
51
 
51
 
52
class DiaryEvent extends Calendar_Decorator {
52
class DiaryEvent extends Calendar_Decorator {
53
	var $entry=array();
53
	var $entry=array();
54
	function DiaryEvent($calendar) {
54
	function DiaryEvent($calendar) {
55
		Calendar_Decorator::Calendar_Decorator($calendar);
55
		Calendar_Decorator::Calendar_Decorator($calendar);
56
	}
56
	}
57
	function setEntry($entry) {
57
	function setEntry($entry) {
58
		$this->entry[]=$entry;
58
		$this->entry[]=$entry;
59
		
59
		
60
	}
60
	}
61
	function getEntry() {
61
	function getEntry() {
62
		return $this->entry;
62
		return $this->entry;
63
	}
63
	}
64
} 
64
} 
65
 
65
 
-
 
66
 
-
 
67
// $type : calendrier
-
 
68
// $type : calendrier_appplette
66
 
69
 
67
function GestionAffichageCalendrier($prefixe_cal) {
70
function GestionAffichageCalendrier($type='calendrier') {
68
	
71
	
69
	
72
	
70
	$retour='';
73
	$retour='';
71
 
74
 
72
	$url = $GLOBALS['_GEN_commun']['url'] ;
75
	$url = $GLOBALS['_GEN_commun']['url'] ;
73
	$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
76
	$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
74
	$auth = &$GLOBALS['_GEN_commun']['pear_auth'] ;
77
	$auth = &$GLOBALS['_GEN_commun']['pear_auth'] ;
75
	
78
	
76
	if (!isset($_GET['y'])) { 
79
	if (!isset($_GET['y'])) { 
77
		$_GET['y'] = date('Y');
80
		$_GET['y'] = date('Y');
78
	}
81
	}
79
	
82
	
80
	if (!isset($_GET['m'])) { 
83
	if (!isset($_GET['m'])) { 
81
		$_GET['m'] = date('m');
84
		$_GET['m'] = date('m');
82
	}
85
	}
83
	
86
	
84
	
87
	
85
	// 	Construction Mois en Cours 
88
	// 	Construction Mois en Cours 
86
	$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
89
	$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
87
 
90
 
88
	$curStamp=$month->getTimeStamp();
91
	$curStamp=$month->getTimeStamp();
89
	$url->addQueryString ('y', date('Y',$curStamp));
92
	$url->addQueryString ('y', date('Y',$curStamp));
90
	$url->addQueryString ('m', date('n',$curStamp));
93
	$url->addQueryString ('m', date('n',$curStamp));
91
	$url->addQueryString ('d', date('j',$curStamp));
94
	$url->addQueryString ('d', date('j',$curStamp));
92
	$cur = $url->getUrl();
95
	$cur = $url->getUrl();
93
	
96
	
94
	// Navigation 
97
	// Navigation 
95
	$prevStamp = $month->prevMonth(true);
98
	$prevStamp = $month->prevMonth(true);
96
	$url->addQueryString ('y', date('Y',$prevStamp));
99
	$url->addQueryString ('y', date('Y',$prevStamp));
97
	$url->addQueryString ('m', date('n',$prevStamp));
100
	$url->addQueryString ('m', date('n',$prevStamp));
98
	$url->addQueryString ('d', date('j',$prevStamp));
101
	$url->addQueryString ('d', date('j',$prevStamp));
99
	$prev = $url->getUrl();
102
	$prev = $url->getUrl();
100
	$nextStamp = $month->nextMonth(true);
103
	$nextStamp = $month->nextMonth(true);
101
	$url->addQueryString ('y', date('Y',$nextStamp));
104
	$url->addQueryString ('y', date('Y',$nextStamp));
102
	$url->addQueryString ('m', date('n',$nextStamp));
105
	$url->addQueryString ('m', date('n',$nextStamp));
103
	$url->addQueryString ('d', date('j',$nextStamp));
106
	$url->addQueryString ('d', date('j',$nextStamp));
104
	$next = $url->getUrl();
107
	$next = $url->getUrl();
105
 
108
 
106
	$fr_month=array("1"=>BAZ_JANVIER,"2"=>BAZ_FEVRIER,"3"=>BAZ_MARS,"4"=>BAZ_AVRIL,"5"=>BAZ_MAI,"6"=>BAZ_JUIN,"7"=>BAZ_JUILLET,"8"=>BAZ_AOUT,"9"=>BAZ_SEPTEMBRE,"10"=>BAZ_OCTOBRE,"11"=>BAZ_NOVEMBRE,"12"=>BAZ_DECEMBRE);
109
	$fr_month=array("1"=>BAZ_JANVIER,"2"=>BAZ_FEVRIER,"3"=>BAZ_MARS,"4"=>BAZ_AVRIL,"5"=>BAZ_MAI,"6"=>BAZ_JUIN,"7"=>BAZ_JUILLET,"8"=>BAZ_AOUT,"9"=>BAZ_SEPTEMBRE,"10"=>BAZ_OCTOBRE,"11"=>BAZ_NOVEMBRE,"12"=>BAZ_DECEMBRE);
107
 
110
 
108
	$retour.= "<div class=\"navi\">";
111
	$retour.= "<div class=\"navi\">";
109
	$retour.= "<a href=\"".$prev."\"> &lt;&lt; </a>"; 
112
	$retour.= "<a href=\"".$prev."\"> &lt;&lt; </a>"; 
110
 
113
 
111
	$retour.= "&nbsp;&nbsp;";
114
	$retour.= "&nbsp;&nbsp;";
112
	$retour.= "<a href=\"".$cur;
115
	$retour.= "<a href=\"".$cur;
113
	$retour.= "\"> ";
116
	$retour.= "\"> ";
114
	$retour.= $fr_month[(date('n',$curStamp))]; 
117
	$retour.= $fr_month[(date('n',$curStamp))]; 
115
	$retour.= "&nbsp;";
118
	$retour.= "&nbsp;";
116
	$retour.= (date('Y',$curStamp));
119
	$retour.= (date('Y',$curStamp));
117
	$retour.= "</a>";
120
	$retour.= "</a>";
118
	$retour.= "&nbsp;&nbsp;";
121
	$retour.= "&nbsp;&nbsp;";
119
	$retour.= "<a href=\"".$next."\"> &gt;&gt; </a>";
122
	$retour.= "<a href=\"".$next."\"> &gt;&gt; </a>";
120
 
123
 
121
	$retour.= "</div>";
124
	$retour.= "</div>";
122
 
125
 
123
	$retour.="<br></br>";
126
	$retour.="<br></br>";
124
 
127
 
-
 
128
	// Vue Mois calendrier ou vue applette
125
		// Vue Mois 
129
		
126
	if (!isset($_GET['id_fiche'])) {
130
	if ((!isset($_GET['id_fiche']) && ($type=='calendrier')) || ($type=='calendrier_applette')){
127
			
131
			
128
		// Recherche evenement de la periode selectionnée 
132
		// Recherche evenement de la periode selectionnée 
129
		
133
		
130
	 	// TODO : Selectionner element du mois en cours 
134
	 	// TODO : Selectionner element du mois en cours 
131
	 	
135
	 	
132
	    $requete_evenements = "SELECT DISTINCT bf_id_fiche, bf_titre, bf_lieu_evenement, day(bf_date_debut_evenement) as bf_jour_debut_evenement , bf_date_fin_evenement, bf_description FROM bazar_fiche, bazar_nature where year(bf_date_debut_evenement) =".date('Y',$curStamp)." and month(bf_date_debut_evenement)=".date('m',$curStamp)." and bf_ce_nature=bn_id_nature and bn_label_nature='Évènements'";
136
	    $requete_evenements = "SELECT DISTINCT bf_id_fiche, bf_titre, bf_lieu_evenement, day(bf_date_debut_evenement) as bf_jour_debut_evenement , bf_date_fin_evenement, bf_description FROM bazar_fiche, bazar_nature where year(bf_date_debut_evenement) =".date('Y',$curStamp)." and month(bf_date_debut_evenement)=".date('m',$curStamp)." and bf_ce_nature=bn_id_nature and bn_label_nature='Évènements'";
133
	            
137
	            
134
	            
138
	            
135
	   	$resultat_evenement = $db->query($requete_evenements);
139
	   	$resultat_evenement = $db->query($requete_evenements);
136
	   	
140
	   	
137
	    (DB::isError($resultat_evenement))
141
	    (DB::isError($resultat_evenement))
138
	    ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements))
142
	    ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements))
139
	    : '';
143
	    : '';
140
	
144
	
141
		$calcom="";
145
		$calcom="";
142
		
146
		
143
		$selection=array();
147
		$selection=array();
144
		$evenements=array();
148
		$evenements=array();
145
		 
149
		 
146
		$prev_curday_ymd=0;
150
		$prev_curday_ymd=0;
147
		
151
		
148
	    while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
152
	    while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
149
	    	
153
	    	
150
			$curday_ymd=date('Ym',$curStamp).$ligne_evenements->bf_jour_debut_evenement;
154
			$curday_ymd=date('Ym',$curStamp).$ligne_evenements->bf_jour_debut_evenement;
151
			if ($curday_ymd!=$prev_curday_ymd) {
155
			if ($curday_ymd!=$prev_curday_ymd) {
152
				$Day = new Calendar_Day(date('Y',$curStamp),date('m',$curStamp), $ligne_evenements->bf_jour_debut_evenement);
156
				$Day = new Calendar_Day(date('Y',$curStamp),date('m',$curStamp), $ligne_evenements->bf_jour_debut_evenement);
153
				$DiaryEvent = new DiaryEvent($Day);
157
				$DiaryEvent = new DiaryEvent($Day);
154
				$prev_curday_ymd=$curday_ymd;
158
				$prev_curday_ymd=$curday_ymd;
155
			}
159
			}
156
			
160
			
157
			$DiaryEvent->setEntry($ligne_evenements);
161
			$DiaryEvent->setEntry($ligne_evenements);
158
			
162
			
159
			// Add the decorator to the selection
163
			// Add the decorator to the selection
160
			$selection[] = $DiaryEvent;
164
			$selection[] = $DiaryEvent;
161
				
165
				
162
		}
166
		}
163
			
167
			
164
		// Affichage Calendrier
168
		// Affichage Calendrier
165
		
169
		
166
		
170
		
167
		$month->build($selection);
171
		$month->build($selection);
-
 
172
	
168
	
173
		if ($type=='calendrier') {
169
		$retour.= "<table class=\"calendar\">
174
			$retour.= "<table class=\"calendar\">
170
		 <tr>
175
			 <tr>
171
		
176
			
172
		  <th> ". BAZ_LUNDI ."</th>
177
			  <th> ". BAZ_LUNDI ."</th>
173
		  <th> ". BAZ_MARDI ."</th>
178
			  <th> ". BAZ_MARDI ."</th>
174
		  <th> ". BAZ_MERCREDI ."</th>
179
			  <th> ". BAZ_MERCREDI ."</th>
175
		  <th> ". BAZ_JEUDI ."</th>
180
			  <th> ". BAZ_JEUDI ."</th>
176
		  <th> ". BAZ_VENDREDI ."</th>
181
			  <th> ". BAZ_VENDREDI ."</th>
177
		  <th> ". BAZ_SAMEDI ."</th>
182
			  <th> ". BAZ_SAMEDI ."</th>
-
 
183
			  <th> ". BAZ_DIMANCHE ."</th>
-
 
184
			 </tr>
-
 
185
			 ";
-
 
186
		}
-
 
187
		else {
-
 
188
			$retour.= "<table class=\"calendar\">
-
 
189
			 <tr>
-
 
190
			
-
 
191
			  <th> ". BAZ_LUNDI_COURT ."</th>
-
 
192
			  <th> ". BAZ_MARDI_COURT ."</th>
-
 
193
			  <th> ". BAZ_MERCREDI_COURT ."</th>
-
 
194
			  <th> ". BAZ_JEUDI_COURT ."</th>
-
 
195
			  <th> ". BAZ_VENDREDI_COURT ."</th>
-
 
196
			  <th> ". BAZ_SAMEDI_COURT ."</th>
178
		  <th> ". BAZ_DIMANCHE ."</th>
197
			  <th> ". BAZ_DIMANCHE_COURT ."</th>
179
		 </tr>
198
			 </tr>
-
 
199
			 ";
-
 
200
		}
180
		 ";
201
		
181
		
202
			
182
		$todayStamp=time();
203
		$todayStamp=time();
183
		
204
		
184
		$today_ymd=date('Ymd',$todayStamp);
205
		$today_ymd=date('Ymd',$todayStamp);
185
	
206
	
186
		// Other month : mois 
207
		// Other month : mois 
187
		//
208
		//
188
		
209
		
189
		while ($day = $month->fetch() ) {
210
		while ($day = $month->fetch() ) {
190
				
211
				
191
				$dayStamp = $day->thisDay(true);
212
				$dayStamp = $day->thisDay(true);
192
				$day_ymd=date('Ymd',$dayStamp);
213
				$day_ymd=date('Ymd',$dayStamp);
193
				
214
				
194
				if ( $day->isEmpty() ) {
215
				if ( $day->isEmpty() ) {
195
						$class = "other_month";
216
						$class = "other_month";
196
				}
217
				}
197
				else {
218
				else {
198
					if (($day_ymd < $today_ymd)) {
219
					if (($day_ymd < $today_ymd)) {
199
						$class= "previous_month";
220
						$class= "previous_month";
200
					}
221
					}
201
					else {
222
					else {
202
						 if ($day_ymd == $today_ymd) {
223
						 if ($day_ymd == $today_ymd) {
203
						 	$class= "current_day";
224
						 	$class= "current_day";
204
						 }
225
						 }
205
						 else {
226
						 else {
206
							$class="current_month";
227
							$class="current_month";
207
						 }
228
						 }
208
					}
229
					}
209
				}
230
				}
210
				
231
				
211
				$url->addQueryString ('y', date('Y',$dayStamp));
232
				$url->addQueryString ('y', date('Y',$dayStamp));
212
				$url->addQueryString ('m', date('n',$dayStamp));
233
				$url->addQueryString ('m', date('n',$dayStamp));
213
				$url->addQueryString ('d', date('j',$dayStamp));
234
				$url->addQueryString ('d', date('j',$dayStamp));
214
				
235
				
215
				$link = $url->getUrl();
236
				$link = $url->getUrl();
216
			
237
			
217
				// isFirst() to find start of week
238
				// isFirst() to find start of week
218
				if ($day->isFirst())
239
				if ($day->isFirst())
219
					$retour.= ( "<tr>\n" );
240
					$retour.= ( "<tr>\n" );
220
				
241
				
-
 
242
				//$retour.= ( "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n" );
-
 
243
				
221
				$retour.= ( "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n" );
244
				if ($type=='calendrier') {
-
 
245
					$retour.= "<td class=\"".$class."\">".$day->thisDay()."\n";
-
 
246
					if ($day->isSelected() ) {
-
 
247
						$evenements=$day->getEntry();
-
 
248
						while ($ligne_evenement=array_pop($evenements)) {
-
 
249
							$id_fiches=array();
-
 
250
							$id_fiches[]=$ligne_evenement->bf_id_fiche;
-
 
251
							$url->addQueryString ('id_fiches',$id_fiches);
-
 
252
							$link = $url->getUrl();
-
 
253
							$retour.= "<a href=\"".$link."\">".$ligne_evenement->bf_titre."</a>\n";
-
 
254
							$url->removeQueryString ('id_fiches');
-
 
255
						}
-
 
256
					}
-
 
257
				}
-
 
258
				else {
222
				
259
					$lien_date= "<td class=\"".$class."\">".$day->thisDay()."\n";
-
 
260
					if ($day->isSelected() ) {
223
				if ($day->isSelected() ) {
261
						$evenements=$day->getEntry();
-
 
262
						$id_fiches=array();
-
 
263
						while ($ligne_evenement=array_pop($evenements)) {
224
					$evenements=$day->getEntry();
264
							$id_fiches[]=$ligne_evenement->bf_id_fiche;
225
					while ($ligne_evenement=array_pop($evenements)) {
265
						}
226
						$url->addQueryString ('id_fiche',$ligne_evenement->bf_id_fiche);
266
						$url->addQueryString ('id_fiches',$id_fiches);
-
 
267
						$link = $url->getUrl();
227
						$link = $url->getUrl();
268
						$lien_date= "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n";
228
						$retour.= ( "<a href=\"".$link."\">".$ligne_evenement->bf_titre."</a>\n" );
-
 
-
 
269
						$url->removeQueryString ('id_fiches');
229
					}
270
					}
230
					
271
					$retour.=$lien_date;
231
				}
272
				}
232
				
273
				
233
				$retour.= ( "</td>\n" );
274
				$retour.= ( "</td>\n" );
234
				
275
				
235
				// isLast() to find end of week
276
				// isLast() to find end of week
236
				if ( $day->isLast() )
277
				if ( $day->isLast() )
237
					$retour.= ( "</tr>\n" );
278
					$retour.= ( "</tr>\n" );
238
			}
279
			}
239
		
280
		
240
			$retour.= "</table>";
281
			$retour.= "</table>";
241
			
-
 
242
			return $retour;
282
			
243
		
283
			
244
		}
284
		}
245
		else {
285
		
-
 
286
		// Vue detail
246
			// Vue jour
287
		
247
			if (isset($_GET['id_fiche'])) {
288
		if ((isset($_GET['id_fiches']))) {
248
				return 	$retour.baz_voir_fiche(0, $_GET['id_fiche']);
-
 
249
			}
289
				$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] = baz_voir_fiches(0,$_GET['id_fiches'] );
-
 
290
		}
-
 
291
			
250
		}
-
 
251
		
292
		return $retour;
252
		;	
293
		
253
	}
294
	}
254
 
295
 
255
?>
296
?>