This commit is contained in:
Dennis Eichhorn 2017-10-03 20:24:29 +02:00
parent d397a8cea3
commit a70302d761
4 changed files with 93 additions and 37 deletions

View File

@ -146,9 +146,13 @@ class Controller extends ModuleAbstract implements WebInterface
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/Calendar/Theme/Backend/dashboard-calendar');
$calendarView = new \Modules\Calendar\Theme\Backend\Components\Calendar\BaseView($this->app, $request, $response);
$calendarView->setTemplate('/Modules/Calendar/Theme/Backend/Components/Calendar/mini');
$view->addData('calendar', $calendarView);
$calendar = CalendarMapper::get(1);
$calendar->setDate(new SmartDateTime($request->getData('date') ?? 'now'));
$view->addData('calendar', $calendar);
$view->addData('cal', $calendar);
return $view;
}

View File

@ -0,0 +1,38 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Calendar\Theme\Backend\Components\Calendar;
use phpOMS\Views\View;
use phpOMS\ApplicationAbstract;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
class BaseView extends View
{
protected $calendar = [];
public function __construct(ApplicationAbstract $app, RequestAbstract $request, ResponseAbstract $response)
{
parent::__construct($app, $request, $response);
$this->setTemplate('/Modules/Calendar/Theme/Backend/Components/Calendar/mini');
}
public function render(...$data) : string
{
$this->calendar = $data[0];
return parent::render();
}
}

View File

@ -0,0 +1,36 @@
<div id="calendar" class="m-calendar m-calendar-mini" data-action='[
{
"listener": "click", "selector": "#calendar span.tag", "action": [
{"key": 1, "type": "dom.popup", "tpl": "calendar-event-popup-tpl", "aniIn": "fadeIn"}
]
}
]'>
<div class="box wf-100">
<ul class="weekdays green">
<li><?= $this->getHtml('Sunday', 'Calendar'); ?>
<li><?= $this->getHtml('Monday', 'Calendar'); ?>
<li><?= $this->getHtml('Tuesday', 'Calendar'); ?>
<li><?= $this->getHtml('Wednesday', 'Calendar'); ?>
<li><?= $this->getHtml('Thursday', 'Calendar'); ?>
<li><?= $this->getHtml('Friday', 'Calendar'); ?>
<li><?= $this->getHtml('Saturday', 'Calendar'); ?>
</ul>
<?php $current = $this->calendar->getDate()->getMonthCalendar(0); $isActiveMonth = false;
for($i = 0; $i < 6; $i++) : ?>
<ul class="days">
<?php for($j = 0; $j < 7; $j++) :
$isActiveMonth = ((int) $current[$i*7+$j]->format('d') === 1) ? !$isActiveMonth : $isActiveMonth;
?>
<?php if($isActiveMonth) :?>
<li class="day<?= $this->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<?= $this->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>
</div>

View File

@ -1,39 +1,17 @@
<?php
$calendar = $this->getData('calendar');
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
?>
<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": [
{"key": 1, "type": "dom.popup", "tpl": "calendar-event-popup-tpl", "aniIn": "fadeIn"}
]
}
]'>
<div class="box wf-100">
<ul class="weekdays green">
<li><?= $this->getHtml('Sunday'); ?>
<li><?= $this->getHtml('Monday'); ?>
<li><?= $this->getHtml('Tuesday'); ?>
<li><?= $this->getHtml('Wednesday'); ?>
<li><?= $this->getHtml('Thursday'); ?>
<li><?= $this->getHtml('Friday'); ?>
<li><?= $this->getHtml('Saturday'); ?>
</ul>
<?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 = ((int) $current[$i*7+$j]->format('d') === 1) ? !$isActiveMonth : $isActiveMonth;
?>
<?php if($isActiveMonth) :?>
<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<?= $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>
<div id="calendar" class="ol-xs-12 col-md-6" draggable="true">
<?= $this->getData('calendar')->render($this->getData('cal')); ?>
</div>