Subversion Repositories Applications.bazar

Rev

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

Rev 19 Rev 30
Line 30... Line 30...
30
 
30
 
31
// Le fait que vous puissiez accéder à cet en-tête signifie que vous avez 
31
// Le fait que vous puissiez accéder à cet en-tête signifie que vous avez 
32
// pris connaissance de la licence CeCILL, et que vous en avez accepté les
32
// pris connaissance de la licence CeCILL, et que vous en avez accepté les
33
// termes.
33
// termes.
34
// ----
34
// ----
35
// CVS : $Id: bazar.calendrier.php,v 1.4 2005-10-01 11:21:39 ddelon Exp $
35
// CVS : $Id: bazar.calendrier.php,v 1.5 2005-10-12 17:20:33 ddelon Exp $
36
/**
36
/**
37
* bazar_calendrier : programme affichant les evenements du bazar sous forme de Calendrier
37
* bazar_calendrier : programme affichant les evenements du bazar sous forme de Calendrier
38
*
38
*
39
*
39
*
40
*@package Bazar
40
*@package Bazar
41
//Auteur original :
41
//Auteur original :
42
*@author        David DELON <david.delon@clapas.net>
42
*@author        David DELON <david.delon@clapas.net>
43
*@version       $Revision: 1.4 $ $Date: 2005-10-01 11:21:39 $
43
*@version       $Revision: 1.5 $ $Date: 2005-10-12 17:20:33 $
44
// +------------------------------------------------------------------------------------------------------+
44
// +------------------------------------------------------------------------------------------------------+
45
*/
-
 
46
 
-
 
47
// TODO : afficher evenement sur plusieur jours
-
 
48
// TODO : traduction entete mois calendrier
-
 
49
// Parametrage EVENEMENT : template 
-
 
50
 
-
 
51
// Fonction Calendrier de Pear 
-
 
52
 
-
 
53
require_once 'Calendar/Month/Weekdays.php';
45
*/
54
require_once 'Calendar/Day.php';
46
if (!defined('BAZ_VOIR_FICHE')) {
55
require_once 'Calendar/Decorator.php'; 
47
	define ('BAZ_VOIR_FICHE', 8); 
56
 
-
 
57
define ('BAZ_VOIR_FICHE', 8) ;
48
}
58
include_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar
49
include_once 'configuration/baz_config.inc.php'; //fichier de configuration de Bazar
Line 59... Line -...
59
include_once 'bibliotheque/bazar.fonct.php'; //fichier des fonctions de Bazar
-
 
60
 
-
 
61
 
-
 
62
 
-
 
63
// Classe Utilitaire pour Calendrier
-
 
64
 
-
 
65
class DiaryEvent extends Calendar_Decorator {
50
include_once 'bibliotheque/bazar.fonct.php'; //fichier des fonctions de Bazar
66
	var $entry=array();
-
 
67
	function DiaryEvent($calendar) {
-
 
68
		Calendar_Decorator::Calendar_Decorator($calendar);
-
 
69
	}
-
 
70
	function setEntry($entry) {
-
 
71
		$this->entry[]=$entry;
-
 
72
		
-
 
73
	}
-
 
74
	function getEntry() {
-
 
Line 75... Line 51...
75
		return $this->entry;
51
 
Line 76... Line -...
76
	}
-
 
77
} 
-
 
78
 
-
 
79
 
-
 
80
function afficherContenuCorps() {
-
 
81
	
-
 
82
		// Ajout d'une feuille de style externe
-
 
83
	GEN_stockerStyleExterne ('wikini', 'client/bazar/presentations/styles/calendrier.css') ;
-
 
84
	
-
 
85
	$retour='';
-
 
86
 
-
 
87
	$url = $GLOBALS['_GEN_commun']['url'] ;
-
 
88
	$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
-
 
89
	$auth = &$GLOBALS['_GEN_commun']['pear_auth'] ;
-
 
90
	
-
 
91
	if (!isset($_GET['y'])) { 
-
 
92
		$_GET['y'] = date('Y');
-
 
93
	}
-
 
94
	
-
 
95
	if (!isset($_GET['m'])) { 
-
 
96
		$_GET['m'] = date('m');
-
 
97
	}
-
 
98
	
-
 
99
	
-
 
100
	// 	Construction Mois en Cours 
-
 
101
	$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
-
 
102
 
-
 
103
	$curStamp=$month->getTimeStamp();
-
 
104
	$url->addQueryString ('y', date('Y',$curStamp));
-
 
105
	$url->addQueryString ('m', date('n',$curStamp));
-
 
106
	$url->addQueryString ('d', date('j',$curStamp));
-
 
107
	$cur = $url->getUrl();
-
 
108
	
-
 
109
	// Navigation 
-
 
110
	$prevStamp = $month->prevMonth(true);
-
 
111
	$url->addQueryString ('y', date('Y',$prevStamp));
-
 
112
	$url->addQueryString ('m', date('n',$prevStamp));
-
 
113
	$url->addQueryString ('d', date('j',$prevStamp));
-
 
114
	$prev = $url->getUrl();
-
 
115
	$nextStamp = $month->nextMonth(true);
-
 
116
	$url->addQueryString ('y', date('Y',$nextStamp));
-
 
117
	$url->addQueryString ('m', date('n',$nextStamp));
-
 
118
	$url->addQueryString ('d', date('j',$nextStamp));
-
 
119
	$next = $url->getUrl();
-
 
120
 
-
 
121
	$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);
-
 
122
 
-
 
123
	$retour.= "<div class=\"navi\">";
-
 
124
	$retour.= "<a href=\"".$prev."\"> &lt;&lt; </a>"; 
-
 
125
 
-
 
126
	$retour.= "&nbsp;&nbsp;";
-
 
127
	$retour.= "<a href=\"".$cur;
-
 
128
	$retour.= "\"> ";
-
 
129
	$retour.= $fr_month[(date('n',$curStamp))]; 
-
 
130
	$retour.= "&nbsp;";
-
 
131
	$retour.= (date('Y',$curStamp));
-
 
132
	$retour.= "</a>";
-
 
133
	$retour.= "&nbsp;&nbsp;";
-
 
134
	$retour.= "<a href=\"".$next."\"> &gt;&gt; </a>";
-
 
135
 
-
 
136
	$retour.= "</div>";
-
 
137
 
-
 
138
	$retour.="<br></br>";
-
 
139
 
-
 
140
		// Vue Mois 
-
 
141
	if (!isset($_GET['id_fiche'])) {
52
 
142
			
-
 
143
		// Recherche evenement de la periode selectionnée 
-
 
144
		
-
 
145
	 	// TODO : Selectionner element du mois en cours 
-
 
146
	 	
-
 
147
	    $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'";
-
 
148
	            
-
 
149
	            
-
 
150
	   	$resultat_evenement = $db->query($requete_evenements);
-
 
151
	   	
-
 
152
	    (DB::isError($resultat_evenement))
-
 
153
	    ? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements))
-
 
154
	    : '';
-
 
155
	
-
 
156
		$calcom="";
-
 
157
		
-
 
158
		$selection=array();
-
 
159
		$evenements=array();
-
 
160
		 
-
 
161
		$prev_curday_ymd=0;
-
 
162
		
-
 
163
	    while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
-
 
164
	    	
-
 
165
			$curday_ymd=date('Ym',$curStamp).$ligne_evenements->bf_jour_debut_evenement;
-
 
166
			if ($curday_ymd!=$prev_curday_ymd) {
-
 
167
				$Day = new Calendar_Day(date('Y',$curStamp),date('m',$curStamp), $ligne_evenements->bf_jour_debut_evenement);
-
 
168
				$DiaryEvent = new DiaryEvent($Day);
-
 
169
				$prev_curday_ymd=$curday_ymd;
-
 
170
			}
-
 
171
			
-
 
172
			$DiaryEvent->setEntry($ligne_evenements);
-
 
173
			
-
 
174
			// Add the decorator to the selection
-
 
175
			$selection[] = $DiaryEvent;
-
 
176
				
-
 
177
		}
-
 
178
			
-
 
179
		// Affichage Calendrier
-
 
180
		
-
 
181
		
-
 
182
		$month->build($selection);
-
 
183
	
-
 
184
		$retour.= "<table class=\"calendar\">
-
 
185
		 <tr>
-
 
186
		
-
 
187
		  <th> ". BAZ_LUNDI ."</th>
-
 
188
		  <th> ". BAZ_MARDI ."</th>
-
 
189
		  <th> ". BAZ_MERCREDI ."</th>
-
 
190
		  <th> ". BAZ_JEUDI ."</th>
-
 
191
		  <th> ". BAZ_VENDREDI ."</th>
-
 
192
		  <th> ". BAZ_SAMEDI ."</th>
-
 
193
		  <th> ". BAZ_DIMANCHE ."</th>
-
 
Line 194... Line -...
194
		 </tr>
-
 
195
		 ";
-
 
196
		
-
 
197
		$todayStamp=time();
-
 
198
		
-
 
199
		$today_ymd=date('Ymd',$todayStamp);
-
 
200
	
-
 
201
		// Other month : mois 
-
 
202
		//
-
 
203
		
-
 
204
		while ($day = $month->fetch() ) {
-
 
205
				
-
 
206
				$dayStamp = $day->thisDay(true);
-
 
207
				$day_ymd=date('Ymd',$dayStamp);
-
 
208
				
-
 
209
				if ( $day->isEmpty() ) {
-
 
210
						$class = "other_month";
-
 
211
				}
-
 
212
				else {
-
 
213
					if (($day_ymd < $today_ymd)) {
-
 
214
						$class="previous_month";
-
 
215
					}
-
 
216
					else {
-
 
217
						 if ($day_ymd == $today_ymd) {
-
 
218
						 	$class="current_day";
-
 
219
						 }
-
 
220
						 else {
-
 
221
							$class="current_month";
-
 
222
						 }
-
 
223
					}
-
 
224
				}
-
 
225
				
-
 
226
				$url->addQueryString ('y', date('Y',$dayStamp));
-
 
227
				$url->addQueryString ('m', date('n',$dayStamp));
-
 
228
				$url->addQueryString ('d', date('j',$dayStamp));
-
 
229
				
-
 
230
				$link = $url->getUrl();
-
 
231
			
-
 
232
				// isFirst() to find start of week
-
 
233
				if ($day->isFirst())
-
 
234
					$retour.= ( "<tr>\n" );
-
 
235
				
-
 
236
				$retour.= ( "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n" );
-
 
237
				
-
 
238
				if ($day->isSelected() ) {
-
 
239
					$evenements=$day->getEntry();
-
 
240
					while ($ligne_evenement=array_pop($evenements)) {
-
 
241
						$url->addQueryString ('id_fiche',$ligne_evenement->bf_id_fiche);
-
 
242
						$link = $url->getUrl();
-
 
243
						$retour.= ( "<a href=\"".$link."\">".$ligne_evenement->bf_titre."</a>\n" );
-
 
244
					}
-
 
245
					
-
 
246
				}
-
 
247
				
-
 
248
				$retour.= ( "</td>\n" );
-
 
249
				
-
 
250
				// isLast() to find end of week
-
 
251
				if ( $day->isLast() )
-
 
252
					$retour.= ( "</tr>\n" );
-
 
253
			}
-
 
254
		
-
 
255
			$retour.= "</table>";
-
 
256
			
-
 
257
			return $retour;
-
 
258
		
-
 
259
		}
53
include_once 'bibliotheque/bazar.fonct.cal.php'; //fichier des fonctions de Bazar
Line 260... Line 54...
260
		else {
54