widget.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. global $myUser;
  3. require_once(__DIR__.SLASH.'Planning.class.php');
  4. require_once(__DIR__.SLASH.'PlanningEvent.class.php');
  5. require_once(__DIR__.SLASH.'PlanningShare.class.php');
  6. require_once(__DIR__.SLASH.'PlanningEventType.class.php');
  7. $query ='SELECT * FROM {{table}} WHERE planning IN(SELECT id FROM '.Planning::tableName().' p WHERE p.owner=? AND p.default=1 ) and startDate >=? ORDER BY startDate LIMIT 10';
  8. $results = PlanningEvent::staticQuery($query,array($myUser->login, mktime(0,0,0) ),true);
  9. $days = array();
  10. foreach ($results as $result) {
  11. $days[date('dmY',$result->startDate)][] = $result;
  12. }
  13. ?>
  14. <div class="planningContainer">
  15. <div class="planningHeader"></div>
  16. <ul class="planning-widget-list">
  17. <?php
  18. if(count($days)!=0):
  19. foreach($days as $day=>$events):
  20. if(count($events)==0) continue;
  21. ?>
  22. <li class="day"><i class="far fa-calendar-alt"></i> <?php echo day_name(date('N',$events[0]->startDate)).' <span>'.date('d',$events[0]->startDate).'</span> '.month_name(date('m',$events[0]->startDate)).' '.date('Y',$events[0]->startDate); ?></li>
  23. <?php foreach($events as $event):
  24. $excerpt = '';
  25. if($event->description!='') $excerpt = '<i class="far fa-comment"></i> '.$event->description;
  26. if($event->address()!='') $excerpt = '<i class="fas fa-location-arrow"></i> '.$event->address();
  27. ?>
  28. <li class="event"><a href="index.php?module=planning&start=<?php echo date('Ymd',$event->startDate); ?>&event=<?php echo $event->id; ?>"><span><?php echo date('H:i',$event->startDate); ?></span> <?php echo $event->label; ?></a> <small class="text-muted ml-2"><?php echo $excerpt; ?></small></li>
  29. <?php endforeach; ?>
  30. <?php endforeach;
  31. else: ?>
  32. <li class="day">Aucun rendez vous à venir</li>
  33. <?php endif; ?>
  34. </ul>
  35. <a href="index.php?module=planning" class="btn btn-light block m-2" ><i class="far fa-calendar"></i> Voir le planning</a>
  36. </div>