mirror of
https://github.com/Karaka-Management/oms-Calendar.git
synced 2026-01-25 05:58:40 +00:00
Create better minimized version
This commit is contained in:
parent
5bde21e683
commit
3c848bc8ae
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;?>
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -91,6 +91,11 @@
|
|||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.has-event {
|
||||
font-weight: bold;
|
||||
background: #009aaf;
|
||||
}
|
||||
}
|
||||
|
||||
@media(max-width: 768px) {
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user