Fix archive events.
[platal.git] / modules / xnetevents / xnetevents.inc.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
c441aabe 3 * Copyright (C) 2003-2014 Polytechnique.org *
0337d704 4 * http://opensource.polytechnique.org/ *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
c860774b
NI
22// {{{ function get_event_order()
23/* get the order to paste the events
24 * @param $asso_id: group's id
25 */
26function get_event_order($asso_id)
27{
28 $order = XDB::fetchOneCell('SELECT g.event_order
29 FROM groups as g
30 WHERE id = {?}',
31 $asso_id);
32 return $order;
33}
34// }}}
35
36// {{{ function get_events()
37/* get the events of the given group ordered by the standard order for the group
38 * @param $asso_id: group's id
39 * @param $order: order to paste the events (asc or desc)
13fc173c 40 * @param $archive: whether to get the archived events (1) or the actuals (0)
c860774b 41 */
13fc173c 42function get_events($asso_id, $order, $archive)
c860774b
NI
43{
44 if ($order != 'asc' && $order != 'desc') {
45 $order = 'desc';
46 }
47 $evts = XDB::fetchAllAssoc('eid', "SELECT ge.eid, ge.uid, ge.intitule, ge.debut, ge.fin, ge.show_participants, ge.deadline_inscription, ge.accept_nonmembre, ge.paiement_id
48 FROM group_events as ge
13fc173c 49 WHERE asso_id = {?} and archive = {?}
c860774b 50 ORDER BY ge.debut $order",
13fc173c 51 $asso_id, $archive);
c860774b
NI
52 return $evts;
53}
54// }}}
55
56// {{{ function get_event() (detail, for subs page only for now)
57/* get event details
58 * @param $eid: event's id
59 */
60function get_event($eid)
61{
62 $evt = XDB::fetchOneAssoc('SELECT ge.uid, ge.intitule, ge.descriptif, ge.debut, ge.fin, ge.deadline_inscription, ge.accept_nonmembre, ge.paiement_id
63 FROM group_events as ge
64 WHERE eid = {?}',
65 $eid);
66 if (!is_null($evt['deadline_inscription']) && strtotime($evt['deadline_inscription']) < time()) {
67 $evt['inscr_open'] = false;
68 } else {
69 $evt['inscr_open'] = true;
70 }
71 $evt['organizer'] = User::getSilent($evt['uid'])->profile();
72 $evt['date'] = make_event_date($evt['debut'], $evt['fin']);
73
74 return $evt;
75}
76// }}}
77
78// {{{ function get_event_items()
79/** get items of the given event
80 *
81 * @param $eid : event's id
82 *
83 */
84function get_event_items($eid)
85{
86 $evt = XDB::fetchAllAssoc('item_id', 'SELECT gei.item_id, gei.titre, gei.details, gei.montant
87 FROM group_event_items as gei
88 WHERE eid = {?}',
89 $eid);
90 return $evt;
91}
92// }}}
93
94// {{{ function get_event_subscription()
95/* get all participations if uid is not specified, only the user's participation if uid specified
96 * @param $eid: event's id
97 * @param $uid: user's id
98 */
99function get_event_subscription($eid, $uid = null)
100{
101 if (!is_null($uid)) {
102 $where = ' and gep.uid = '.$uid;
103 }
104 else {
105 $where = '';
106 }
107 $sub = XDB::fetchAllAssoc('item_id','SELECT gep.item_id, gep.nb, gep.paid FROM group_event_participants as gep
108 WHERE gep.eid = {?}'.$where,
109 $eid);
110 return $sub;
111}
112// }}}
113
114// {{{ function get_event_telepaid()
115/* get the total payments made by a user for an event
116 * @param $eid: event's id
117 * @param $uid: user's id
118 */
119function get_event_telepaid($eid, $uid)
120{
121 $telepaid = XDB::fetchOneCell('SELECT SUM(pt.amount)
122 FROM payment_transactions AS pt
123 LEFT JOIN group_events as ge ON (ge.paiement_id = pt.ref)
124 WHERE ge.eid = {?} AND pt.uid = {?}',
125 $eid, $uid);
126 return $telepaid;
127}
128// }}}
129
0337d704 130// {{{ function get_event_detail()
d6d580ec 131
2ac0bcee 132function get_event_detail($eid, $item_id = false, $asso_id = null)
d6d580ec 133{
0337d704 134 global $globals;
2ac0bcee
FB
135 if (is_null($asso_id)) {
136 $asso_id = $globals->asso('id');
137 }
3092eea7
SJ
138 if (!$item_id) {
139 $where = '';
140 $group_by = 'e.eid';
141 } else {
142 $where = XDB::format(' AND ei.item_id = {?}', $item_id);
143 $group_by = 'ei.item_id';
144 }
e48b1c76 145 $evt = XDB::fetchOneAssoc('SELECT SUM(nb) AS nb_tot, COUNT(DISTINCT ep.uid) AS nb, e.*, SUM(IF(nb > 0, 1, 0)) AS user_count,
7852229b
SJ
146 IF(e.deadline_inscription,
147 e.deadline_inscription >= LEFT(NOW(), 10),
148 1) AS inscr_open,
0ea9f32b 149 LEFT(e.debut, 10) AS first_day, LEFT(e.fin, 10) AS last_day,
7852229b
SJ
150 LEFT(NOW(), 10) AS now,
151 ei.titre, e.subscription_notification
152 FROM group_events AS e
153 INNER JOIN group_event_items AS ei ON (e.eid = ei.eid)
154 LEFT JOIN group_event_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id)
3092eea7
SJ
155 WHERE (e.eid = {?} OR e.short_name = {?}) AND e.asso_id = {?}' . $where . '
156 GROUP BY ' . $group_by,
157 $eid, $eid, $asso_id);
d6d580ec 158
df1cf596 159 if (!$evt) {
d6d580ec 160 return null;
161 }
df1cf596
FB
162 if ($GLOBALS['IS_XNET_SITE'] && $evt['accept_nonmembre'] == 0 && !is_member() && !may_update()) {
163 return false;
164 }
0337d704 165
0337d704 166 if (!$item_id) {
f9e8637a
FB
167 /* Don't try to be to smart here, in case we're getting the global summary, we cannot have
168 * a general formula to estimate the total number of comers since 'moments' may (or may not be)
169 * disjuncted. As a consequence, we can only provides the number of user having fullfiled the
170 * registration procedure.
171 */
172 $evt['user_count'] = $evt['nb_tot'] = $evt['nb'];
0337d704 173 $evt['titre'] = '';
174 $evt['item_id'] = 0;
80575e7c
SJ
175 $evt['csv_name'] = urlencode($evt['intitule']);
176 } else {
177 $evt['csv_name'] = urlencode($evt['intitule'] . '.' . $evt['titre']);
0337d704 178 }
d6d580ec 179
07eb5b0e
FB
180 $evt['moments'] = XDB::fetchAllAssoc('SELECT titre, details, montant, ei.item_id, nb,
181 ep.paid, FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment
eb41eda9
FB
182 FROM group_event_items AS ei
183 LEFT JOIN group_event_participants AS ep ON (ep.eid = ei.eid AND ep.item_id = ei.item_id
07eb5b0e
FB
184 AND uid = {?})
185 WHERE ei.eid = {?}',
186 S::i('uid'), $evt['eid']);
d6d580ec 187 $evt['topay'] = 0;
98a7e9dc 188 $evt['paid'] = 0;
2ac0bcee 189 $evt['notify_payment'] = false;
d6d580ec 190 foreach ($evt['moments'] as $m) {
191 $evt['topay'] += $m['nb'] * $m['montant'];
98a7e9dc 192 if ($m['montant']) {
54ac7230 193 $evt['money'] = true;
98a7e9dc 194 }
51f1911c 195 $evt['paid'] += $m['paid'];
2ac0bcee 196 $evt['notify_payment'] = $evt['notify_payment'] || $m['notify_payment'];
d6d580ec 197 }
198
a7c0d514 199 $montant = XDB::fetchOneCell('SELECT SUM(amount) AS sum_amount
b3cd1320 200 FROM payment_transactions AS t
07eb5b0e
FB
201 WHERE ref = {?} AND uid = {?}',
202 $evt['paiement_id'], S::v('uid'));
a7c0d514
DB
203 $evt['telepaid'] = $montant;
204 $evt['paid'] += $montant;
ed996b5a 205 $evt['organizer'] = User::getSilent($evt['uid']);
d6d580ec 206
c860774b 207 $evt['date'] = make_event_date($evt['debut'], $evt['fin']);
20c5c7e6 208
b6f69874 209 $evt['show_participants'] = ($evt['show_participants'] && $GLOBALS['IS_XNET_SITE'] && (is_member() || may_update()));
5a6bcfb7 210
0337d704 211 return $evt;
212}
d6d580ec 213
0337d704 214// }}}
215
216// {{{ function get_event_participants()
8270d13a 217function get_event_participants(&$evt, $item_id, array $tri = array(), $limit = null, $offset = 0)
07eb5b0e 218{
0337d704 219 global $globals;
ed21e24a 220
ed21e24a 221 $eid = $evt['eid'];
2ac0bcee 222 $money = $evt['money'] && (function_exists('may_update')) && may_update();
ed21e24a 223 $pay_id = $evt['paiement_id'];
224
c81e03c0 225 $append = $item_id ? XDB::format(' AND ep.item_id = {?}', $item_id) : '';
07eb5b0e
FB
226 $query = XDB::fetchAllAssoc('uid', 'SELECT ep.uid, SUM(ep.paid) AS paid, SUM(ep.nb) AS nb,
227 FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment
eb41eda9 228 FROM group_event_participants AS ep
07eb5b0e
FB
229 WHERE ep.eid = {?} AND nb > 0 ' . $append . '
230 GROUP BY ep.uid', $eid);
c8763ca3 231 $uf = new UserFilter(new PFC_True(), $tri);
8270d13a 232 $users = User::getBulkUsersWithUIDs($uf->filter(array_keys($query), new PlLimit($limit, $offset)));
07eb5b0e
FB
233 $tab = array();
234 foreach ($users as $user) {
235 $uid = $user->id();
236 $tab[$uid] = $query[$uid];
237 $tab[$uid]['user'] = $user;
238 }
ed21e24a 239
0337d704 240 if ($item_id) {
07eb5b0e 241 return $tab;
0337d704 242 }
ed21e24a 243
e01ebe65
FB
244 $evt['adminpaid'] = 0;
245 $evt['telepaid'] = 0;
246 $evt['topay'] = 0;
247 $evt['paid'] = 0;
07eb5b0e 248 foreach ($tab as $uid=>&$u) {
5dcca1b1 249 $u['adminpaid'] = (float)$u['paid'];
0337d704 250 $u['montant'] = 0;
2ac0bcee 251 if ($money && $pay_id) {
a7c0d514 252 $montant = XDB::fetchOneCell('SELECT SUM(amount)
b3cd1320 253 FROM payment_transactions AS t
07eb5b0e
FB
254 WHERE ref = {?} AND uid = {?}',
255 $pay_id, $uid);
a7c0d514 256 $u['paid'] += $montant;
2ac0bcee 257 }
58591700 258 $u['telepayment'] = $u['paid'] - $u['adminpaid'];
07eb5b0e 259 $res_ = XDB::iterator('SELECT ep.nb, ep.item_id, ei.montant
eb41eda9
FB
260 FROM group_event_participants AS ep
261 INNER JOIN group_event_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id)
07eb5b0e
FB
262 WHERE ep.eid = {?} AND ep.uid = {?}',
263 $eid, $uid);
0337d704 264 while ($i = $res_->next()) {
265 $u[$i['item_id']] = $i['nb'];
f9e8637a 266 $u['montant'] += $i['montant'] * $i['nb'];
0337d704 267 }
e01ebe65
FB
268 $evt['telepaid'] += $u['telepayment'];
269 $evt['adminpaid'] += $u['adminpaid'];
270 $evt['paid'] += $u['paid'];
271 $evt['topay'] += $u['montant'];
0337d704 272 }
273 return $tab;
274}
275// }}}
276
c860774b
NI
277// {{{ function subscribe()
278/** set or update the user's subscription
279 *
280 * @param $uid: user's id
281 * @param $eid: event's id
282 * @param $subs: user's new subscription
283 *
284 */
285function subscribe($uid, $eid, $subs = array())
286{
287 global $globals;
288 // get items
289 $items = get_event_items($eid);
290 // get previous subscription
291 $old_subs = get_event_subscription($eid, $uid);
292 $participate = false;
293 $updated = false;
294 // TODO : change the way to deal with manual payment
295 $paid = 0;
296 foreach ($old_subs as $item_id => $s) {
297 $paid += $s['paid'];
298 }
299 $paid_updated = false;
300 // for each item of the event
301 foreach ($items as $item_id => $details) {
302 // check if there is an old subscription
303 if (array_key_exists($item_id, $old_subs)) {
304 echo 'prev exists ';
305 // compares new and old subscription
306 if ($old_subs[$item_id]['nb'] != $subs[$item_id]) {
307 echo 'different ';
308 if ($subs[$item_id] != 0) {
309 echo "je m'inscris ";
310 XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
311 VALUES ({?}, {?}, {?}, {?}, {?}, {?})
312 ON DUPLICATE KEY UPDATE nb = VALUES(nb), flags = VALUES(flags), paid = VALUES(paid)',
313 $eid, $uid, $item_id, $subs[$item_id],(Env::has('notify_payment') ? 'notify_payment' : 0), (!$paid_updated ? $paid : 0));
314 $participate = true;
315 $paid_updated = true;
316 } else { // we do not store non-subscription to event items
317 echo "je me desinscris ";
318 XDB::execute('DELETE FROM group_event_participants
319 WHERE eid = {?} AND uid = {?} AND item_id = {?}',
320 $eid, $uid, $item_id);
321 }
322 $updated = true;
323 }
324 } else { // if no old subscription
325 echo 'no prev ';
326 if ($subs[$item_id] != 0) {
327 echo 'subscribe ';
328 XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
329 VALUES ({?}, {?}, {?}, {?}, {?}, {?})',
330 $eid, $uid, $item_id, $subs[$item_id], '', 0);
331 $participate = true;
332 $updated = true;
333 }
334 }
335 }
336 // item 0 stores whether the user participates globally or not, if he has to be notified when payment is created and his manual payment
337 /*
338 if (array_key_exists(0, $old_subs)) {
339 XDB::execute('UPDATE group_event_participants
340 SET nb = {?}
341 WHERE eid = {?}, uid = {?}, item_id = 0',
342 ($participate ? 1 : 0), $eid, $uid);
343 } else {
344 XDB::execute('INSERT INTO group_event_participants (eid, uid, item_id, nb, flags, paid)
345 VALUES ({?}, {?}, {?}, {?}, {?}, {?})',
346 $eid, $uid, 0, ($participate ? 1 : 0), (Env::has('notify_payment') ? 'notify_payment' : ''), 0);
347 }
348 */
349 // if subscription is updated, we have to update the event aliases
350 if ($updated) {
351 echo "inscription mise a jour ";
352 $short_name = get_event_detail($eid)['short_name'];
353 subscribe_lists_event($uid, $short_name, ($participate ? 1 : -1), 0);
354 }
355 return $updated;
356}
357// }}}
358
359// TODO : correct this function to be compatible with subscribe() (use $eid, remove useless argument)
360// TODO : correct other calls
0337d704 361// {{{ function subscribe_lists_event()
50208d22
SJ
362/** Subscribes user to various event related mailing lists.
363 *
364 * @param $uid: user's id.
7852229b 365 * @param short_name: event's short_name, which corresponds to the beginning of the emails.
50208d22
SJ
366 * @param participate: indicates if the user takes part at the event or not;
367 * -1 means he did not answer, 0 means no, and 1 means yes.
368 * @param paid: has the user already payed anything?
369 * 0 means no, a positive amount means yes.
370 * @param payment: is this function called from a payment page?
371 * If true, only payment related lists should be updated.
372 */
7852229b 373function subscribe_lists_event($uid, $short_name, $participate, $paid, $payment = false)
9193e8f7 374{
7852229b
SJ
375 global $globals;
376 require_once 'emails.inc.php';
0337d704 377
7852229b
SJ
378 if (is_null($short_name)) {
379 return;
0337d704 380 }
381
50208d22
SJ
382 /** If $payment is not null, we do not retrieve the value of $participate,
383 * thus we do not alter participant and absent lists.
384 */
385 if ($payment === true) {
386 if ($paid > 0) {
7e82b545
SJ
387 delete_from_list_alias($uid, $short_name . $globals->xnet->unpayed_list, $globals->xnet->evts_domain, 'event');
388 add_to_list_alias($uid, $short_name . $globals->xnet->payed_list, $globals->xnet->evts_domain, 'event');
50208d22
SJ
389 }
390 } else {
391 switch ($participate) {
392 case -1:
7e82b545
SJ
393 delete_from_list_alias($uid, $short_name . $globals->xnet->participant_list, $globals->xnet->evts_domain, 'event');
394 delete_from_list_alias($uid, $short_name . $globals->xnet->unpayed_list, $globals->xnet->evts_domain, 'event');
395 delete_from_list_alias($uid, $short_name . $globals->xnet->payed_list, $globals->xnet->evts_domain, 'event');
396 add_to_list_alias($uid, $short_name . $globals->xnet->absent_list, $globals->xnet->evts_domain, 'event');
50208d22
SJ
397 break;
398 case 0:
7e82b545
SJ
399 delete_from_list_alias($uid, $short_name . $globals->xnet->participant_list, $globals->xnet->evts_domain, 'event');
400 delete_from_list_alias($uid, $short_name . $globals->xnet->absent_list, $globals->xnet->evts_domain, 'event');
401 delete_from_list_alias($uid, $short_name . $globals->xnet->unpayed_list, $globals->xnet->evts_domain, 'event');
402 delete_from_list_alias($uid, $short_name . $globals->xnet->payed_list, $globals->xnet->evts_domain, 'event');
50208d22
SJ
403 break;
404 case 1:
7e82b545
SJ
405 add_to_list_alias($uid, $short_name . $globals->xnet->participant_list, $globals->xnet->evts_domain, 'event');
406 delete_from_list_alias($uid, $short_name . $globals->xnet->absent_list, $globals->xnet->evts_domain, 'event');
50208d22 407 if ($paid > 0) {
7e82b545
SJ
408 delete_from_list_alias($uid, $short_name . $globals->xnet->unpayed_list, $globals->xnet->evts_domain, 'event');
409 add_to_list_alias($uid, $short_name . $globals->xnet->payed_list, $globals->xnet->evts_domain, 'event');
50208d22 410 } else {
7e82b545
SJ
411 add_to_list_alias($uid, $short_name . $globals->xnet->unpayed_list, $globals->xnet->evts_domain, 'event');
412 delete_from_list_alias($uid, $short_name . $globals->xnet->payed_list, $globals->xnet->evts_domain, 'event');
50208d22
SJ
413 }
414 break;
1cf7d38b 415 }
9193e8f7 416 }
0337d704 417}
418// }}}
419
20c5c7e6 420// {{{ function event_change_shortname()
26ba053e 421function event_change_shortname($page, $eid, $old, $new)
5070a22d 422{
423 global $globals;
7852229b 424 require_once 'emails.inc.php';
5070a22d 425
f56e5e53 426 if (is_null($old)) {
427 $old = '';
428 }
a7de4ef7 429 // Quelques vérifications sur l'alias (caractères spéciaux)
2179ffa2 430 if ($new && !preg_match( "/^[a-zA-Z0-9\-.]{3,20}$/", $new)) {
a7d35093 431 $page->trigError("Le raccourci demandé n'est pas valide.
a7de4ef7 432 Vérifie qu'il comporte entre 3 et 20 caractères
433 et qu'il ne contient que des lettres non accentuées,
434 des chiffres ou les caractères - et .");
5070a22d 435 return $old;
4aae4d2c 436 } elseif ($new && (is_int($new) || ctype_digit($new))) {
940ae3a0
SJ
437 $page->trigError("Le raccourci demandé ne peut être accepté car il
438 ne contient que des chiffres. Rajoute-lui par exemple
439 une lettre.");
440 return $old;
5070a22d 441 }
442
a7de4ef7 443 //vérifier que l'alias n'est pas déja pris
5070a22d 444 if ($new && $old != $new) {
9193e8f7 445 $res = XDB::query('SELECT COUNT(*)
eb41eda9 446 FROM group_events
9193e8f7 447 WHERE short_name = {?}',
448 $new);
5070a22d 449 if ($res->fetchOneCell() > 0) {
a7d35093 450 $page->trigError("Le raccourci demandé est déjà utilisé. Choisis en un autre.");
5070a22d 451 return $old;
452 }
453 }
454
455 if ($old == $new) {
456 return $new;
457 }
458
459 if ($old && $new) {
460 // if had a previous shortname change the old lists
7852229b
SJ
461 foreach (explode(',', $globals->xnet->event_lists) as $suffix) {
462 XDB::execute('UPDATE email_virtual
463 SET email = {?}
464 WHERE type = \'event\' AND email = {?}',
465 $new . $suffix, $old . $suffix);
5070a22d 466 }
7852229b 467
5070a22d 468 return $new;
469 }
470
471 if (!$old && $new) {
472 // if we have a first new short_name create the lists
9ff5b337
SJ
473 $lastid = array();
474 $where = array(
2335f07e
SJ
475 $globals->xnet->participant_list => 'g.nb > 0',
476 $globals->xnet->payed_list => '(g.paid > 0 OR p.amount > 0)',
477 $globals->xnet->unpayed_list => 'g.nb > 0 AND g.paid = 0 AND p.amount IS NULL'
9ff5b337
SJ
478 );
479
7852229b 480 foreach (array($globals->xnet->participant_list, $globals->xnet->payed_list, $globals->xnet->unpayed_list) as $suffix) {
2335f07e
SJ
481 $uids = XDB::fetchColumn('SELECT g.uid
482 FROM group_event_participants AS g
483 INNER JOIN group_events AS e ON (g.eid = e.eid)
484 LEFT JOIN payment_transactions AS p ON (e.paiement_id = p.ref AND g.uid = p.uid)
485 WHERE g.eid = {?} AND ' . $where[$suffix],
7852229b 486 $eid);
7e82b545
SJ
487 foreach ($uids as $uid) {
488 add_to_list_alias($uid, $new . $suffix, $globals->xnet->evts_domain, 'event');
7852229b 489 }
9ff5b337 490 }
2335f07e 491
7852229b
SJ
492 $uids = XDB::fetchColumn('SELECT m.uid
493 FROM group_members AS m
494 LEFT JOIN group_event_participants AS e ON (e.uid = m.uid AND e.eid = {?})
495 WHERE m.asso_id = {?} AND e.uid IS NULL',
496 $eid, $globals->asso('id'));
7e82b545
SJ
497 foreach ($uids as $uid) {
498 add_to_list_alias($uid, $new . $globals->xnet->absent_list, $globals->xnet->evts_domain, 'event');
9ff5b337 499 }
5070a22d 500
501 return $new;
502 }
503
504 if ($old && !$new) {
505 // if we delete the old short name, delete the lists
7852229b
SJ
506 foreach (explode(',', $globals->xnet->event_lists) as $suffix) {
507 delete_list_alias($old . $suffix, $globals->xnet->evts_domain);
5070a22d 508 }
7852229b 509
5070a22d 510 return $new;
511 }
512
513 // cannot happen
514 return $old;
515}
20c5c7e6
SJ
516// }}}
517
518// {{{ function make_event_date()
c860774b 519function make_event_date($debut, $fin)
20c5c7e6 520{
c860774b
NI
521 $start = strtotime($debut);
522 $end = strtotime($fin);
523// $first_day = $e['first_day'];
524// $last_day = $e['last_day'];
525 $first_day = strftime("%d %B %Y", $start);
526 $last_day = strftime("%d %B %Y", $end);
20c5c7e6
SJ
527 $date = "";
528 if ($start && $end != $start) {
529 if ($first_day == $last_day) {
530 $date .= "le " . strftime("%d %B %Y", $start) . " de "
531 . strftime("%H:%M", $start) . " à " . strftime("%H:%M", $end);
532 } else {
533 $date .= "du " . strftime("%d %B %Y à %H:%M", $start)
534 . "\nau " . strftime("%d %B %Y à %H:%M", $end);
535 }
536 } else {
537 $date .= "le " . strftime("%d %B %Y à %H:%M", $start);
538 }
c860774b 539 return $date;
20c5c7e6
SJ
540}
541// }}}
5070a22d 542
448c8cdc 543// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8:
0337d704 544?>