Create better minimized version

This commit is contained in:
Dennis Eichhorn 2017-08-11 20:26:03 +02:00
parent 5bde21e683
commit 3c848bc8ae
6 changed files with 58 additions and 33 deletions

View File

@ -315,4 +315,24 @@ class Calendar
return $events;
}
/**
* Has event on date
*
* @param \DateTime $date Date of the event
*
* @return bool
*
* @since 1.0.0
*/
public function hasEventOnDate(\DateTime $date) : bool
{
foreach ($this->events as $event) {
if ($event->getCreatedAt()->format('Y-m-d') === $date->format('Y-m-d')) {
return true;
}
}
return false;
}
}

View File

@ -10,6 +10,7 @@
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
* @todo only load events of 3 month or 1 year?!
*/
declare(strict_types=1);
namespace Modules\Calendar\Models;

View File

@ -35,23 +35,25 @@ $calendar = $this->getData('calendar');
<?php $current = $calendar->getDate()->getMonthCalendar(0); $isActiveMonth = false;
for($i = 0; $i < 6; $i++) : ?>
<ul class="days">
<?php for($j = 0; $j < 7; $j++) : $isActiveMonth = ($current[$i*7+$j] === 1) ? !$isActiveMonth : $isActiveMonth; ?>
<?php if($isActiveMonth) : ?>
<li class="day">
<div class="date"><?= $current[$i*7+$j]; ?></div>
<?php else: ?>
<li class="day other-month">
<div class="date"><?= $current[$i*7+$j]; ?></div>
<?php endif; ?>
<?php
$events = $calendar->getEventByDate(new \DateTime('now'));
foreach($events as $event) : ?>
<div id="event-tag-<?= htmlspecialchars($event->getId(), ENT_COMPAT, 'utf-8'); ?>" class="event">
<div class="event-desc"><?= htmlspecialchars($event->getName(), ENT_COMPAT, 'utf-8'); ?></div>
<div class="event-time">2:00pm to 5:00pm</div>
</div>
<?php endforeach; ?>
<?php endfor; ?>
<?php for($j = 0; $j < 7; $j++) :
$isActiveMonth = ((int) $current[$i*7+$j]->format('d') === 1) ? !$isActiveMonth : $isActiveMonth;
?>
<?php if($isActiveMonth) :?>
<li class="day">
<div class="date"><?= $current[$i*7+$j]->format('d'); ?></div>
<?php else: ?>
<li class="day other-month">
<div class="date"><?= $current[$i*7+$j]->format('d'); ?></div>
<?php endif; ?>
<?php
$events = $calendar->getEventByDate($current[$i*7+$j]);
foreach($events as $event) : ?>
<div id="event-tag-<?= htmlspecialchars($event->getId(), ENT_COMPAT, 'utf-8'); ?>" class="event">
<div class="event-desc"><?= htmlspecialchars($event->getName(), ENT_COMPAT, 'utf-8'); ?></div>
<div class="event-time">2:00pm to 5:00pm</div>
</div>
<?php endforeach; ?>
<?php endfor; ?>
</li>
</ul>
<?php endfor;?>

View File

@ -61,6 +61,9 @@
background: #dfdfdf; }
.m-calendar.m-calendar-mini .days li {
height: auto; }
.m-calendar .has-event {
font-weight: bold;
background: #009aaf; }
@media (max-width: 768px) {
.m-calendar .weekdays, .m-calendar .other-month {

View File

@ -91,6 +91,11 @@
height: auto;
}
}
.has-event {
font-weight: bold;
background: #009aaf;
}
}
@media(max-width: 768px) {

View File

@ -20,24 +20,18 @@ $calendar = $this->getData('calendar');
<?php $current = $calendar->getDate()->getMonthCalendar(0); $isActiveMonth = false;
for($i = 0; $i < 6; $i++) : ?>
<ul class="days">
<?php for($j = 0; $j < 7; $j++) : $isActiveMonth = ($current[$i*7+$j] === 1) ? !$isActiveMonth : $isActiveMonth; ?>
<?php for($j = 0; $j < 7; $j++) :
$isActiveMonth = ((int) $current[$i*7+$j]->format('d') === 1) ? !$isActiveMonth : $isActiveMonth;
?>
<?php if($isActiveMonth) :?>
<li class="day">
<div class="date"><?= $current[$i*7+$j]; ?></div>
<li class="day<?= $calendar->hasEventOnDate($current[$i*7+$j]) ? ' has-event' : '';?>">
<div class="date"><?= $current[$i*7+$j]->format('d'); ?></div>
<?php else: ?>
<li class="day other-month">
<div class="date"><?= $current[$i*7+$j]; ?></div>
<?php endif; ?>
<?php
$events = $calendar->getEventByDate(new \DateTime('now'));
foreach($events as $event) : ?>
<div id="event-tag-<?= htmlspecialchars($event->getId(), ENT_COMPAT, 'utf-8'); ?>" class="event">
<div class="event-desc"><?= htmlspecialchars($event->getName(), ENT_COMPAT, 'utf-8'); ?></div>
<div class="event-time">2:00pm to 5:00pm</div>
</div>
<?php endforeach; ?>
<?php endfor; ?>
</li>
<li class="day other-month<?= $calendar->hasEventOnDate($current[$i*7+$j]) ? ' has-event' : '';?>">
<div class="date"><?= $current[$i*7+$j]->format('d'); ?></div>
<?php endif; ?>
<?php endfor; ?>
</li>
</ul>
<?php endfor;?>
</div>