Update calendar templates

This commit is contained in:
Dennis Eichhorn 2017-08-11 20:08:52 +02:00
parent 73fdc8c285
commit 5bde21e683
4 changed files with 48 additions and 36 deletions

View File

@ -32,20 +32,19 @@ $calendar = $this->getData('calendar');
<li><?= $this->getHtml('Friday'); ?> <li><?= $this->getHtml('Friday'); ?>
<li><?= $this->getHtml('Saturday'); ?> <li><?= $this->getHtml('Saturday'); ?>
</ul> </ul>
<?php $current = new \phpOMS\Datatypes\SmartDateTime($calendar->getDate()->format('Y') . '-' . $calendar->getDate()->format('m') . '-' . '01'); <?php $current = $calendar->getDate()->getMonthCalendar(0); $isActiveMonth = false;
for($i = 0; $i < 6; $i++) : ?> for($i = 0; $i < 6; $i++) : ?>
<ul class="days"> <ul class="days">
<?php for($j = 0; $j < 7; $j++) : ?> <?php for($j = 0; $j < 7; $j++) : $isActiveMonth = ($current[$i*7+$j] === 1) ? !$isActiveMonth : $isActiveMonth; ?>
<?php if($calendar->getDate()->getFirstDayOfMonth() <= $i*7+$j+1 && $calendar->getDate()->getDaysOfMonth() >= $i*7+$j+1) : ?> <?php if($isActiveMonth) : ?>
<li class="day"> <li class="day">
<div class="date"><?= ($i*7+$j+1); ?></div> <div class="date"><?= $current[$i*7+$j]; ?></div>
<?php else: ?> <?php else: ?>
<li class="day other-month"> <li class="day other-month">
<div class="date"><?= $current->createModify(0, 0, -2)->format('d'); ?></div> <div class="date"><?= $current[$i*7+$j]; ?></div>
<?php endif; ?> <?php endif; ?>
<?php <?php
$events = $calendar->getEventByDate($current); $events = $calendar->getEventByDate(new \DateTime('now'));
$current->smartModify(0, 0, 1);
foreach($events as $event) : ?> foreach($events as $event) : ?>
<div id="event-tag-<?= htmlspecialchars($event->getId(), ENT_COMPAT, 'utf-8'); ?>" class="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-desc"><?= htmlspecialchars($event->getName(), ENT_COMPAT, 'utf-8'); ?></div>

View File

@ -54,9 +54,13 @@
overflow: hidden; } overflow: hidden; }
.m-calendar .event-time { .m-calendar .event-time {
font-size: 0.7rem; } font-size: 0.7rem; }
.m-calendar .other-month { .m-calendar .day {
background: #f5f5f5; background: #fff;
color: #666; } color: #666; }
.m-calendar .day.other-month {
background: #dfdfdf; }
.m-calendar.m-calendar-mini .days li {
height: auto; }
@media (max-width: 768px) { @media (max-width: 768px) {
.m-calendar .weekdays, .m-calendar .other-month { .m-calendar .weekdays, .m-calendar .other-month {

View File

@ -77,9 +77,19 @@
font-size: 0.7rem; font-size: 0.7rem;
} }
.other-month { .day {
background: #f5f5f5; background: #fff;
color: #666; color: #666;
&.other-month {
background: #dfdfdf;
}
}
&.m-calendar-mini {
.days li {
height: auto;
}
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
$calendar = $this->getData('calendar'); $calendar = $this->getData('calendar');
?> ?>
<div id="calendar" class="m-calendar col-xs-12 col-md-6" draggable="true" data-action='[ <div id="calendar" class="m-calendar m-calendar-mini col-xs-12 col-md-6" draggable="true" data-action='[
{ {
"listener": "click", "selector": "#calendar span.tag", "action": [ "listener": "click", "selector": "#calendar span.tag", "action": [
{"key": 1, "type": "dom.popup", "tpl": "calendar-event-popup-tpl", "aniIn": "fadeIn"} {"key": 1, "type": "dom.popup", "tpl": "calendar-event-popup-tpl", "aniIn": "fadeIn"}
@ -17,28 +17,27 @@ $calendar = $this->getData('calendar');
<li><?= $this->getHtml('Friday'); ?> <li><?= $this->getHtml('Friday'); ?>
<li><?= $this->getHtml('Saturday'); ?> <li><?= $this->getHtml('Saturday'); ?>
</ul> </ul>
<?php $current = new \phpOMS\Datatypes\SmartDateTime($calendar->getDate()->format('Y') . '-' . $calendar->getDate()->format('m') . '-' . '01'); <?php $current = $calendar->getDate()->getMonthCalendar(0); $isActiveMonth = false;
for($i = 0; $i < 6; $i++) : ?> for($i = 0; $i < 6; $i++) : ?>
<ul class="days"> <ul class="days">
<?php for($j = 0; $j < 7; $j++) : ?> <?php for($j = 0; $j < 7; $j++) : $isActiveMonth = ($current[$i*7+$j] === 1) ? !$isActiveMonth : $isActiveMonth; ?>
<?php if($calendar->getDate()->getFirstDayOfMonth() <= $i*7+$j+1 && $calendar->getDate()->getDaysOfMonth() >= $i*7+$j+1) : ?> <?php if($isActiveMonth) :?>
<li class="day"> <li class="day">
<div class="date"><?= ($i*7+$j+1); ?></div> <div class="date"><?= $current[$i*7+$j]; ?></div>
<?php else: ?> <?php else: ?>
<li class="day other-month"> <li class="day other-month">
<div class="date"><?= $current->createModify(0, 0, -2)->format('d'); ?></div> <div class="date"><?= $current[$i*7+$j]; ?></div>
<?php endif; ?> <?php endif; ?>
<?php <?php
$events = $calendar->getEventByDate($current); $events = $calendar->getEventByDate(new \DateTime('now'));
$current->smartModify(0, 0, 1); foreach($events as $event) : ?>
foreach($events as $event) : ?> <div id="event-tag-<?= htmlspecialchars($event->getId(), ENT_COMPAT, 'utf-8'); ?>" class="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-desc"><?= htmlspecialchars($event->getName(), ENT_COMPAT, 'utf-8'); ?></div> <div class="event-time">2:00pm to 5:00pm</div>
<div class="event-time">2:00pm to 5:00pm</div> </div>
</div> <?php endforeach; ?>
<?php endforeach; ?> <?php endfor; ?>
<?php endfor; ?> </li>
</li> </ul>
</ul> <?php endfor;?>
<?php endfor;?>
</div> </div>