Subversion Repositories Applications.bazar

Rev

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

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