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 |
// +------------------------------------------------------------------------------------------------------+
|
235 |
alexandre_ |
22 |
// CVS : $Id: bazar.fonct.cal.php,v 1.17.2.1 2007-05-09 13:56:49 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
|
235 |
alexandre_ |
32 |
*@version $Revision: 1.17.2.1 $ $Date: 2007-05-09 13:56:49 $
|
30 |
ddelon |
33 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
34 |
*/
|
|
|
35 |
|
|
|
36 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
37 |
// | ENTETE du PROGRAMME |
|
|
|
38 |
// +------------------------------------------------------------------------------------------------------+
|
225 |
neiluj |
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 |
// | LISTE de FONCTIONS |
|
|
|
46 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
47 |
|
|
|
48 |
// Classe Utilitaire pour Calendrier
|
|
|
49 |
class DiaryEvent extends Calendar_Decorator {
|
205 |
jp_milcent |
50 |
var $entry = array();
|
|
|
51 |
function DiaryEvent($calendar)
|
|
|
52 |
{
|
30 |
ddelon |
53 |
Calendar_Decorator::Calendar_Decorator($calendar);
|
|
|
54 |
}
|
205 |
jp_milcent |
55 |
function setEntry($entry)
|
|
|
56 |
{
|
|
|
57 |
$this->entry[] = $entry;
|
30 |
ddelon |
58 |
|
|
|
59 |
}
|
205 |
jp_milcent |
60 |
function getEntry()
|
|
|
61 |
{
|
30 |
ddelon |
62 |
return $this->entry;
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
|
42 |
ddelon |
67 |
// $type : calendrier
|
|
|
68 |
// $type : calendrier_appplette
|
205 |
jp_milcent |
69 |
function GestionAffichageCalendrier($type = 'calendrier') {
|
30 |
ddelon |
70 |
|
208 |
jp_milcent |
71 |
$retour = '';
|
225 |
neiluj |
72 |
|
30 |
ddelon |
73 |
$url = $GLOBALS['_GEN_commun']['url'] ;
|
205 |
jp_milcent |
74 |
$db =& $GLOBALS['_GEN_commun']['pear_db'] ;
|
|
|
75 |
$auth =& $GLOBALS['_GEN_commun']['pear_auth'] ;
|
30 |
ddelon |
76 |
|
|
|
77 |
if (!isset($_GET['y'])) {
|
|
|
78 |
$_GET['y'] = date('Y');
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
if (!isset($_GET['m'])) {
|
|
|
82 |
$_GET['m'] = date('m');
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
// Construction Mois en Cours
|
|
|
86 |
$month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
|
|
|
87 |
|
205 |
jp_milcent |
88 |
$curStamp = $month->getTimeStamp();
|
|
|
89 |
$url->addQueryString('y', date('Y',$curStamp));
|
|
|
90 |
$url->addQueryString('m', date('n',$curStamp));
|
|
|
91 |
$url->addQueryString('d', date('j',$curStamp));
|
30 |
ddelon |
92 |
$cur = $url->getUrl();
|
|
|
93 |
|
|
|
94 |
// Navigation
|
|
|
95 |
$prevStamp = $month->prevMonth(true);
|
205 |
jp_milcent |
96 |
$url->addQueryString('y', date('Y',$prevStamp));
|
|
|
97 |
$url->addQueryString('m', date('n',$prevStamp));
|
|
|
98 |
$url->addQueryString('d', date('j',$prevStamp));
|
30 |
ddelon |
99 |
$prev = $url->getUrl();
|
205 |
jp_milcent |
100 |
|
30 |
ddelon |
101 |
$nextStamp = $month->nextMonth(true);
|
205 |
jp_milcent |
102 |
$url->addQueryString('y', date('Y',$nextStamp));
|
|
|
103 |
$url->addQueryString('m', date('n',$nextStamp));
|
|
|
104 |
$url->addQueryString('d', date('j',$nextStamp));
|
30 |
ddelon |
105 |
$next = $url->getUrl();
|
205 |
jp_milcent |
106 |
|
|
|
107 |
$fr_month = array( "1"=>BAZ_JANVIER,"2"=>BAZ_FEVRIER,"3"=>BAZ_MARS,"4"=>BAZ_AVRIL,"5"=>BAZ_MAI,"6"=>BAZ_JUIN,
|
|
|
108 |
"7"=>BAZ_JUILLET,"8"=>BAZ_AOUT,"9"=>BAZ_SEPTEMBRE,"10"=>BAZ_OCTOBRE,"11"=>BAZ_NOVEMBRE,"12"=>BAZ_DECEMBRE);
|
30 |
ddelon |
109 |
|
225 |
neiluj |
110 |
$retour.= "<div class=\"navi\">";
|
|
|
111 |
$retour.= "<a href=\"".$prev."\"> << </a>";
|
|
|
112 |
|
|
|
113 |
$retour.= " ";
|
|
|
114 |
$retour.= "<a href=\"".$cur;
|
|
|
115 |
$retour.= "\"> ";
|
|
|
116 |
$retour.= $fr_month[(date('n',$curStamp))];
|
|
|
117 |
$retour.= " ";
|
|
|
118 |
$retour.= (date('Y',$curStamp));
|
|
|
119 |
$retour.= "</a>";
|
|
|
120 |
$retour.= " ";
|
|
|
121 |
$retour.= "<a href=\"".$next."\"> >> </a>";
|
|
|
122 |
|
|
|
123 |
$retour.= "</div>";
|
|
|
124 |
|
|
|
125 |
$retour.="<br></br>";
|
|
|
126 |
|
42 |
ddelon |
127 |
// Vue Mois calendrier ou vue applette
|
|
|
128 |
|
|
|
129 |
if ((!isset($_GET['id_fiche']) && ($type=='calendrier')) || ($type=='calendrier_applette')){
|
30 |
ddelon |
130 |
|
|
|
131 |
// Recherche evenement de la periode selectionnée
|
225 |
neiluj |
132 |
|
|
|
133 |
// TODO : Selectionner element du mois en cours
|
|
|
134 |
|
|
|
135 |
$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 ".
|
185 |
jp_milcent |
136 |
"FROM bazar_fiche, bazar_nature ".
|
225 |
neiluj |
137 |
"WHERE YEAR(bf_date_debut_evenement) = ".date('Y',$curStamp)." ".
|
|
|
138 |
"AND month(bf_date_debut_evenement) = ".date('m',$curStamp)." ".
|
185 |
jp_milcent |
139 |
"AND bf_ce_nature = bn_id_nature ".
|
213 |
jp_milcent |
140 |
"AND bn_id_nature IN (".BAZ_NUM_ANNONCE_CALENDRIER.") ".
|
235 |
alexandre_ |
141 |
"AND bf_statut_fiche = 1 ".
|
|
|
142 |
"ORDER BY bf_jour_debut_evenement";
|
225 |
neiluj |
143 |
|
30 |
ddelon |
144 |
$resultat_evenement = $db->query($requete_evenements);
|
225 |
neiluj |
145 |
|
30 |
ddelon |
146 |
(DB::isError($resultat_evenement))
|
|
|
147 |
? die(BOG_afficherErreurSql(__FILE__, __LINE__, $resultat_evenement->getMessage(), $requete_evenements))
|
|
|
148 |
: '';
|
225 |
neiluj |
149 |
|
|
|
150 |
$calcom="";
|
|
|
151 |
|
|
|
152 |
$selection=array();
|
|
|
153 |
$evenements=array();
|
|
|
154 |
|
|
|
155 |
$prev_curday_ymd=0;
|
|
|
156 |
|
30 |
ddelon |
157 |
while ($ligne_evenements = $resultat_evenement->fetchRow(DB_FETCHMODE_OBJECT)) {
|
225 |
neiluj |
158 |
|
|
|
159 |
$curday_ymd=date('Ym',$curStamp).$ligne_evenements->bf_jour_debut_evenement;
|
|
|
160 |
if ($curday_ymd!=$prev_curday_ymd) {
|
|
|
161 |
$Day = new Calendar_Day(date('Y',$curStamp),date('m',$curStamp), $ligne_evenements->bf_jour_debut_evenement);
|
|
|
162 |
$DiaryEvent = new DiaryEvent($Day);
|
|
|
163 |
$prev_curday_ymd=$curday_ymd;
|
|
|
164 |
}
|
30 |
ddelon |
165 |
|
225 |
neiluj |
166 |
$DiaryEvent->setEntry($ligne_evenements);
|
30 |
ddelon |
167 |
|
225 |
neiluj |
168 |
// Add the decorator to the selection
|
|
|
169 |
$selection[] = $DiaryEvent;
|
|
|
170 |
|
30 |
ddelon |
171 |
}
|
|
|
172 |
|
|
|
173 |
// Affichage Calendrier
|
225 |
neiluj |
174 |
|
|
|
175 |
|
30 |
ddelon |
176 |
$month->build($selection);
|
225 |
neiluj |
177 |
|
|
|
178 |
if ($type=='calendrier') {
|
|
|
179 |
$retour.= "<table class=\"calendar\">
|
|
|
180 |
<tr>
|
42 |
ddelon |
181 |
|
|
|
182 |
<th> ". BAZ_LUNDI ."</th>
|
|
|
183 |
<th> ". BAZ_MARDI ."</th>
|
|
|
184 |
<th> ". BAZ_MERCREDI ."</th>
|
|
|
185 |
<th> ". BAZ_JEUDI ."</th>
|
|
|
186 |
<th> ". BAZ_VENDREDI ."</th>
|
|
|
187 |
<th> ". BAZ_SAMEDI ."</th>
|
|
|
188 |
<th> ". BAZ_DIMANCHE ."</th>
|
|
|
189 |
</tr>
|
225 |
neiluj |
190 |
";
|
42 |
ddelon |
191 |
}
|
|
|
192 |
else {
|
225 |
neiluj |
193 |
$retour.= "<table class=\"calendar\">
|
|
|
194 |
<tr>
|
42 |
ddelon |
195 |
|
|
|
196 |
<th> ". BAZ_LUNDI_COURT ."</th>
|
|
|
197 |
<th> ". BAZ_MARDI_COURT ."</th>
|
|
|
198 |
<th> ". BAZ_MERCREDI_COURT ."</th>
|
|
|
199 |
<th> ". BAZ_JEUDI_COURT ."</th>
|
|
|
200 |
<th> ". BAZ_VENDREDI_COURT ."</th>
|
|
|
201 |
<th> ". BAZ_SAMEDI_COURT ."</th>
|
|
|
202 |
<th> ". BAZ_DIMANCHE_COURT ."</th>
|
|
|
203 |
</tr>
|
225 |
neiluj |
204 |
";
|
42 |
ddelon |
205 |
}
|
30 |
ddelon |
206 |
|
42 |
ddelon |
207 |
|
30 |
ddelon |
208 |
$todayStamp=time();
|
|
|
209 |
|
|
|
210 |
$today_ymd=date('Ymd',$todayStamp);
|
|
|
211 |
|
|
|
212 |
// Other month : mois
|
|
|
213 |
//
|
|
|
214 |
|
|
|
215 |
while ($day = $month->fetch() ) {
|
|
|
216 |
|
|
|
217 |
$dayStamp = $day->thisDay(true);
|
|
|
218 |
$day_ymd=date('Ymd',$dayStamp);
|
|
|
219 |
|
|
|
220 |
if ( $day->isEmpty() ) {
|
225 |
neiluj |
221 |
$class = "other_month";
|
30 |
ddelon |
222 |
}
|
|
|
223 |
else {
|
|
|
224 |
if (($day_ymd < $today_ymd)) {
|
225 |
neiluj |
225 |
$class= "previous_month";
|
30 |
ddelon |
226 |
}
|
|
|
227 |
else {
|
|
|
228 |
if ($day_ymd == $today_ymd) {
|
225 |
neiluj |
229 |
$class= "current_day";
|
30 |
ddelon |
230 |
}
|
|
|
231 |
else {
|
225 |
neiluj |
232 |
$class="current_month";
|
30 |
ddelon |
233 |
}
|
|
|
234 |
}
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
$url->addQueryString ('y', date('Y',$dayStamp));
|
|
|
238 |
$url->addQueryString ('m', date('n',$dayStamp));
|
|
|
239 |
$url->addQueryString ('d', date('j',$dayStamp));
|
225 |
neiluj |
240 |
|
30 |
ddelon |
241 |
$link = $url->getUrl();
|
|
|
242 |
|
|
|
243 |
// isFirst() to find start of week
|
225 |
neiluj |
244 |
if ($day->isFirst())
|
30 |
ddelon |
245 |
$retour.= ( "<tr>\n" );
|
225 |
neiluj |
246 |
|
|
|
247 |
//$retour.= ( "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n" );
|
|
|
248 |
|
|
|
249 |
if ($type=='calendrier') {
|
|
|
250 |
$retour.= "<td class=\"".$class."\">".$day->thisDay()."\n";
|
42 |
ddelon |
251 |
if ($day->isSelected() ) {
|
225 |
neiluj |
252 |
$evenements=$day->getEntry();
|
|
|
253 |
while ($ligne_evenement=array_pop($evenements)) {
|
|
|
254 |
$id_fiches=array();
|
|
|
255 |
$id_fiches[]=$ligne_evenement->bf_id_fiche;
|
42 |
ddelon |
256 |
$url->addQueryString ('id_fiches',$id_fiches);
|
|
|
257 |
$link = $url->getUrl();
|
225 |
neiluj |
258 |
$retour.= "<a href=\"".$link."\">".$ligne_evenement->bf_titre."</a>\n";
|
42 |
ddelon |
259 |
$url->removeQueryString ('id_fiches');
|
|
|
260 |
}
|
|
|
261 |
}
|
225 |
neiluj |
262 |
}
|
|
|
263 |
else {
|
42 |
ddelon |
264 |
$lien_date= "<td class=\"".$class."\">".$day->thisDay()."\n";
|
|
|
265 |
if ($day->isSelected() ) {
|
|
|
266 |
$evenements=$day->getEntry();
|
|
|
267 |
$id_fiches=array();
|
|
|
268 |
while ($ligne_evenement=array_pop($evenements)) {
|
|
|
269 |
$id_fiches[]=$ligne_evenement->bf_id_fiche;
|
|
|
270 |
}
|
|
|
271 |
$url->addQueryString ('id_fiches',$id_fiches);
|
30 |
ddelon |
272 |
$link = $url->getUrl();
|
42 |
ddelon |
273 |
$lien_date= "<td class=\"".$class."\"><a href=\"".$link."\">".$day->thisDay()."</a>\n";
|
|
|
274 |
$url->removeQueryString ('id_fiches');
|
30 |
ddelon |
275 |
}
|
42 |
ddelon |
276 |
$retour.=$lien_date;
|
30 |
ddelon |
277 |
}
|
|
|
278 |
|
|
|
279 |
$retour.= ( "</td>\n" );
|
|
|
280 |
|
|
|
281 |
// isLast() to find end of week
|
|
|
282 |
if ( $day->isLast() )
|
|
|
283 |
$retour.= ( "</tr>\n" );
|
|
|
284 |
}
|
|
|
285 |
|
225 |
neiluj |
286 |
$retour.= "</table>";
|
30 |
ddelon |
287 |
|
42 |
ddelon |
288 |
|
|
|
289 |
}
|
225 |
neiluj |
290 |
|
42 |
ddelon |
291 |
// Vue detail
|
|
|
292 |
|
|
|
293 |
if ((isset($_GET['id_fiches']))) {
|
225 |
neiluj |
294 |
// Ajout des styles du bazar
|
|
|
295 |
if (defined('PAP_VERSION')) { //si on est dans Papyrus
|
|
|
296 |
GEN_stockerStyleExterne( 'bazar_interne2', 'client/bazar/bazar.interne.css');
|
|
|
297 |
}
|
|
|
298 |
|
85 |
alexandre_ |
299 |
// Ajout d'un titre pour la page avec la date
|
235 |
alexandre_ |
300 |
$jours = array ( 'dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi') ;
|
85 |
alexandre_ |
301 |
$mois = array ('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre',
|
|
|
302 |
'octobre', 'novembre', 'décembre') ;
|
|
|
303 |
$timestamp = strtotime ($_GET['y'].'/'.$_GET['m'].'/'.$_GET['d']) ;
|
|
|
304 |
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] = '<h1>'.$jours[date('w', $timestamp)].
|
147 |
alexandre_ |
305 |
' '.$_GET['d'].' '.$mois[$_GET['m']-1].' '.$_GET['y'].'</h1>' ;
|
85 |
alexandre_ |
306 |
$GLOBALS['_PAPYRUS_']['rendu']['CONTENU_CORPS'] .= baz_voir_fiches(0,$_GET['id_fiches'] );
|
30 |
ddelon |
307 |
}
|
205 |
jp_milcent |
308 |
|
|
|
309 |
// Nettoyage de l'url
|
|
|
310 |
$url->removeQueryString('id_fiches');
|
|
|
311 |
$url->removeQueryString('y');
|
|
|
312 |
$url->removeQueryString('m');
|
|
|
313 |
$url->removeQueryString('d');
|
42 |
ddelon |
314 |
|
|
|
315 |
return $retour;
|
30 |
ddelon |
316 |
}
|
|
|
317 |
?>
|