30 |
ddelon |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.1 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This library is free software; you can redistribute it and/or |
|
|
|
9 |
// | modify it under the terms of the GNU Lesser General Public |
|
|
|
10 |
// | License as published by the Free Software Foundation; either |
|
|
|
11 |
// | version 2.1 of the License, or (at your option) any later version. |
|
|
|
12 |
// | |
|
|
|
13 |
// | This library is distributed in the hope that it will be useful, |
|
|
|
14 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
15 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
16 |
// | Lesser General Public License for more details. |
|
|
|
17 |
// | |
|
|
|
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 |
|
|
|
20 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
21 |
// +------------------------------------------------------------------------------------------------------+
|
147 |
alexandre_ |
22 |
// CVS : $Id: bazar.fonct.cal.php,v 1.10 2006-09-14 14:15:35 alexandre_tb Exp $
|
30 |
ddelon |
23 |
/**
|
|
|
24 |
*
|
|
|
25 |
* Fonctions calendrier du module bazar
|
|
|
26 |
*
|
|
|
27 |
*@package bazar
|
|
|
28 |
//Auteur original :
|
|
|
29 |
*@author David Delon <david.delon@clapas.net>
|
|
|
30 |
//Autres auteurs :
|
|
|
31 |
*@copyright Tela-Botanica 2000-2004
|
147 |
alexandre_ |
32 |
*@version $Revision: 1.10 $ $Date: 2006-09-14 14:15:35 $
|
30 |
ddelon |
33 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
34 |
*/
|
|
|
35 |
|
|
|
36 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
37 |
// | ENTETE du PROGRAMME |
|
|
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
39 |
|
55 |
florian |
40 |
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Month/Weekdays.php';
|
|
|
41 |
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Day.php';
|
|
|
42 |
require_once PAP_CHEMIN_RACINE.'api/pear/Calendar/Decorator.php';
|
30 |
ddelon |
43 |
|
|
|
44 |
|
|
|
45 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
46 |
// | LISTE de FONCTIONS |
|
|
|
47 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
// Classe Utilitaire pour Calendrier
|
|
|
51 |
|
|
|
52 |
class DiaryEvent extends Calendar_Decorator {
|
|
|
53 |
var $entry=array();
|
|
|
54 |
function DiaryEvent($calendar) {
|
|
|
55 |
Calendar_Decorator::Calendar_Decorator($calendar);
|
|
|
56 |
}
|
|
|
57 |
function setEntry($entry) {
|
|
|
58 |
$this->entry[]=$entry;
|
|
|
59 |
|
|
|
60 |
}
|
|
|
61 |
function getEntry() {
|
|
|
62 |
return $this->entry;
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
|
42 |
ddelon |
67 |
// $type : calendrier
|
|
|
68 |
// $type : calendrier_appplette
|
|
|
69 |
|
|
|
70 |
function GestionAffichageCalendrier($type='calendrier') {
|
30 |
ddelon |
71 |
|
|
|
72 |
|
|
|
73 |
$retour='';
|
|
|
74 |
|
|
|
75 |
$url = $GLOBALS['_GEN_commun']['url'] ;
|
|
|
76 |
$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
|
|
|
77 |
$auth = &$GLOBALS['_GEN_commun']['pear_auth'] ;
|
|
|
78 |
|
|
|
79 |
if (!isset($_GET['y'])) {
|
|
|
80 |
$_GET['y'] = date('Y');
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
if (!isset($_GET['m'])) {
|
|
|
84 |
$_GET['m'] = date('m');
|
|
|
85 |
}
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
// Construction Mois en Cours
|
|
|
89 |
$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
|
|
|
90 |
|
|
|
91 |
$curStamp=$month->getTimeStamp();
|
|
|
92 |
$url->addQueryString ('y', date('Y',$curStamp));
|
|
|
93 |
$url->addQueryString ('m', date('n',$curStamp));
|
|
|
94 |
$url->addQueryString ('d', date('j',$curStamp));
|
|
|
95 |
$cur = $url->getUrl();
|
|
|
96 |
|
|
|
97 |
// Navigation
|
|
|
98 |
$prevStamp = $month->prevMonth(true);
|
|
|
99 |
$url->addQueryString ('y', date('Y',$prevStamp));
|
|
|
100 |
$url->addQueryString ('m', date('n',$prevStamp));
|
|
|
101 |
$url->addQueryString ('d', date('j',$prevStamp));
|
|
|
102 |
$prev = $url->getUrl();
|
|
|
103 |
$nextStamp = $month->nextMonth(true);
|
|
|
104 |
$url->addQueryString ('y', date('Y',$nextStamp));
|
|
|
105 |
$url->addQueryString ('m', date('n',$nextStamp));
|
|
|
106 |
$url->addQueryString ('d', date('j',$nextStamp));
|
|
|
107 |
$next = $url->getUrl();
|
|
|
108 |
|
|
|
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);
|
|
|
110 |
|
|
|
111 |
$retour.= "<div class=\"navi\">";
|
|
|
112 |
$retour.= "<a href=\"".$prev."\"> << </a>";
|
|
|
113 |
|
|
|
114 |
$retour.= " ";
|
|
|
115 |
$retour.= "<a href=\"".$cur;
|
|
|
116 |
$retour.= "\"> ";
|
|
|
117 |
$retour.= $fr_month[(date('n',$curStamp))];
|
|
|
118 |
$retour.= " ";
|
|
|
119 |
$retour.= (date('Y',$curStamp));
|
|
|
120 |
$retour.= "</a>";
|
|
|
121 |
$retour.= " ";
|
|
|
122 |
$retour.= "<a href=\"".$next."\"> >> </a>";
|
|
|
123 |
|
|
|
124 |
$retour.= "</div>";
|
|
|
125 |
|
|
|
126 |
$retour.="<br></br>";
|
|
|
127 |
|
42 |
ddelon |
128 |
// Vue Mois calendrier ou vue applette
|
|
|
129 |
|
|
|
130 |
if ((!isset($_GET['id_fiche']) && ($type=='calendrier')) || ($type=='calendrier_applette')){
|
30 |
ddelon |
131 |
|
|
|
132 |
// Recherche evenement de la periode selectionnée
|
|
|
133 |
|
|
|
134 |
// TODO : Selectionner element du mois en cours
|
|
|
135 |
|
78 |
alexandre_ |
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) =".
|
|
|
137 |
date('Y',$curStamp)." and month(bf_date_debut_evenement)=".
|
137 |
alexandre_ |
138 |
date('m',$curStamp)." and bf_ce_nature=bn_id_nature and bn_id_nature='".BAZ_NUM_ANNONCE_CALENDRIER."'";
|
30 |
ddelon |
139 |
|
|
|
140 |
|
|
|
141 |
$resultat_evenement = $db->query($requete_evenements);
|
|
|
142 |
|
|
|
143 |
(DB::isError($resultat_evenement))
|
|
|
144 |
? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements))
|
|
|
145 |
: '';
|
|
|
146 |
|
|
|
147 |
$calcom="";
|
|
|
148 |
|
|
|
149 |
$selection=array();
|
|
|
150 |
$evenements=array();
|
|
|
151 |
|
|
|
152 |
$prev_curday_ymd=0;
|
|
|
153 |
|
|
|
154 |
while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
|
|
|
155 |
|
|
|
156 |
$curday_ymd=date('Ym',$curStamp).$ligne_evenements->bf_jour_debut_evenement;
|
|
|
157 |
if ($curday_ymd!=$prev_curday_ymd) {
|
|
|
158 |
$Day = new Calendar_Day(date('Y',$curStamp),date('m',$curStamp), $ligne_evenements->bf_jour_debut_evenement);
|
|
|
159 |
$DiaryEvent = new DiaryEvent($Day);
|
|
|
160 |
$prev_curday_ymd=$curday_ymd;
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
$DiaryEvent->setEntry($ligne_evenements);
|
|
|
164 |
|
|
|
165 |
// Add the decorator to the selection
|
|
|
166 |
$selection[] = $DiaryEvent;
|
|
|
167 |
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
// Affichage Calendrier
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
$month->build($selection);
|
|
|
174 |
|
42 |
ddelon |
175 |
if ($type=='calendrier') {
|
|
|
176 |
$retour.= "<table class=\"calendar\">
|
|
|
177 |
<tr>
|
|
|
178 |
|
|
|
179 |
<th> ". BAZ_LUNDI ."</th>
|
|
|
180 |
<th> ". BAZ_MARDI ."</th>
|
|
|
181 |
<th> ". BAZ_MERCREDI ."</th>
|
|
|
182 |
<th> ". BAZ_JEUDI ."</th>
|
|
|
183 |
<th> ". BAZ_VENDREDI ."</th>
|
|
|
184 |
<th> ". BAZ_SAMEDI ."</th>
|
|
|
185 |
<th> ". BAZ_DIMANCHE ."</th>
|
|
|
186 |
</tr>
|
|
|
187 |
";
|
|
|
188 |
}
|
|
|
189 |
else {
|
|
|
190 |
$retour.= "<table class=\"calendar\">
|
|
|
191 |
<tr>
|
|
|
192 |
|
|
|
193 |
<th> ". BAZ_LUNDI_COURT ."</th>
|
|
|
194 |
<th> ". BAZ_MARDI_COURT ."</th>
|
|
|
195 |
<th> ". BAZ_MERCREDI_COURT ."</th>
|
|
|
196 |
<th> ". BAZ_JEUDI_COURT ."</th>
|
|
|
197 |
<th> ". BAZ_VENDREDI_COURT ."</th>
|
|
|
198 |
<th> ". BAZ_SAMEDI_COURT ."</th>
|
|
|
199 |
<th> ". BAZ_DIMANCHE_COURT ."</th>
|
|
|
200 |
</tr>
|
|
|
201 |
";
|
|
|
202 |
}
|
30 |
ddelon |
203 |
|
42 |
ddelon |
204 |
|
30 |
ddelon |
205 |
$todayStamp=time();
|
|
|
206 |
|
|
|
207 |
$today_ymd=date('Ymd',$todayStamp);
|
|
|
208 |
|
|
|
209 |
// Other month : mois
|
|
|
210 |
//
|
|
|
211 |
|
|
|
212 |
while ($day = $month->fetch() ) {
|
|
|
213 |
|
|
|
214 |
$dayStamp = $day->thisDay(true);
|
|
|
215 |
$day_ymd=date('Ymd',$dayStamp);
|
|
|
216 |
|
|
|
217 |
if ( $day->isEmpty() ) {
|
|
|
218 |
$class = "other_month";
|
|
|
219 |
}
|
|
|
220 |
else {
|
|
|
221 |
if (($day_ymd < $today_ymd)) {
|
|
|
222 |
$class= "previous_month";
|
|
|
223 |
}
|
|
|
224 |
else {
|
|
|
225 |
if ($day_ymd == $today_ymd) {
|
|
|
226 |
$class= "current_day";
|
|
|
227 |
}
|
|
|
228 |
else {
|
|
|
229 |
$class="current_month";
|
|
|
230 |
}
|
|
|
231 |
}
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
$url->addQueryString ('y', date('Y',$dayStamp));
|
|
|
235 |
$url->addQueryString ('m', date('n',$dayStamp));
|
|
|
236 |
$url->addQueryString ('d', date('j',$dayStamp));
|
|
|
237 |
|
|
|
238 |
$link = $url->getUrl();
|
|
|
239 |
|
|
|
240 |
// isFirst() to find start of week
|
|
|
241 |
if ($day->isFirst())
|
|
|
242 |
$retour.= ( "<tr>\n" );
|
|
|
243 |
|
42 |
ddelon |
244 |
//$retour.= ( "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n" );
|
30 |
ddelon |
245 |
|
42 |
ddelon |
246 |
if ($type=='calendrier') {
|
|
|
247 |
$retour.= "<td class=\"".$class."\">".$day->thisDay()."\n";
|
|
|
248 |
if ($day->isSelected() ) {
|
|
|
249 |
$evenements=$day->getEntry();
|
|
|
250 |
while ($ligne_evenement=array_pop($evenements)) {
|
|
|
251 |
$id_fiches=array();
|
|
|
252 |
$id_fiches[]=$ligne_evenement->bf_id_fiche;
|
|
|
253 |
$url->addQueryString ('id_fiches',$id_fiches);
|
|
|
254 |
$link = $url->getUrl();
|
|
|
255 |
$retour.= "<a href=\"".$link."\">".$ligne_evenement->bf_titre."</a>\n";
|
|
|
256 |
$url->removeQueryString ('id_fiches');
|
|
|
257 |
}
|
|
|
258 |
}
|
|
|
259 |
}
|
|
|
260 |
else {
|
|
|
261 |
$lien_date= "<td class=\"".$class."\">".$day->thisDay()."\n";
|
|
|
262 |
if ($day->isSelected() ) {
|
|
|
263 |
$evenements=$day->getEntry();
|
|
|
264 |
$id_fiches=array();
|
|
|
265 |
while ($ligne_evenement=array_pop($evenements)) {
|
|
|
266 |
$id_fiches[]=$ligne_evenement->bf_id_fiche;
|
|
|
267 |
}
|
|
|
268 |
$url->addQueryString ('id_fiches',$id_fiches);
|
30 |
ddelon |
269 |
$link = $url->getUrl();
|
42 |
ddelon |
270 |
$lien_date= "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n";
|
|
|
271 |
$url->removeQueryString ('id_fiches');
|
30 |
ddelon |
272 |
}
|
42 |
ddelon |
273 |
$retour.=$lien_date;
|
30 |
ddelon |
274 |
}
|
|
|
275 |
|
|
|
276 |
$retour.= ( "</td>\n" );
|
|
|
277 |
|
|
|
278 |
// isLast() to find end of week
|
|
|
279 |
if ( $day->isLast() )
|
|
|
280 |
$retour.= ( "</tr>\n" );
|
|
|
281 |
}
|
|
|
282 |
|
|
|
283 |
$retour.= "</table>";
|
|
|
284 |
|
42 |
ddelon |
285 |
|
|
|
286 |
}
|
30 |
ddelon |
287 |
|
42 |
ddelon |
288 |
// Vue detail
|
|
|
289 |
|
|
|
290 |
if ((isset($_GET['id_fiches']))) {
|
85 |
alexandre_ |
291 |
// Ajout des styles du bazar
|
|
|
292 |
if (defined('PAP_VERSION')) { //si on est dans Papyrus
|
|
|
293 |
GEN_stockerStyleExterne( 'bazar_interne', 'client/bazar/bazar.interne.css');
|
|
|
294 |
}
|
|
|
295 |
|
|
|
296 |
// Ajout d'un titre pour la page avec la date
|
|
|
297 |
$jours = array ('lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche') ;
|
|
|
298 |
$mois = array ('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre',
|
|
|
299 |
'octobre', 'novembre', 'décembre') ;
|
|
|
300 |
$timestamp = strtotime ($_GET['y'].'/'.$_GET['m'].'/'.$_GET['d']) ;
|
|
|
301 |
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] = '<h1>'.$jours[date('w', $timestamp)].
|
147 |
alexandre_ |
302 |
' '.$_GET['d'].' '.$mois[$_GET['m']-1].' '.$_GET['y'].'</h1>' ;
|
85 |
alexandre_ |
303 |
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] .= baz_voir_fiches(0,$_GET['id_fiches'] );
|
30 |
ddelon |
304 |
}
|
42 |
ddelon |
305 |
|
|
|
306 |
return $retour;
|
30 |
ddelon |
307 |
|
|
|
308 |
}
|
|
|
309 |
|
|
|
310 |
?>
|