add admin timetable
This commit is contained in:
13
common/modules/event/models/timetable/TimeTableModel.php
Normal file
13
common/modules/event/models/timetable/TimeTableModel.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace common\modules\event\models\timetable;
|
||||
use yii\base\Model;
|
||||
|
||||
/**
|
||||
* Class TimeTableModel
|
||||
* @property TimeTableMonth $timeTableMonth
|
||||
*/
|
||||
class TimeTableModel extends Model
|
||||
{
|
||||
public $timeTableMonth;
|
||||
}
|
||||
32
common/modules/event/models/timetable/TimeTableMonth.php
Normal file
32
common/modules/event/models/timetable/TimeTableMonth.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace common\modules\event\models\timetable;
|
||||
|
||||
use customerapi\models\available\EventInterval;
|
||||
use yii\data\ArrayDataProvider;
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
|
||||
|
||||
/**
|
||||
* Class TimeTableMonth
|
||||
* @property EventInterval $interval
|
||||
* @property TimeTableMonthDay[] $days
|
||||
* @property TimeTableMonthWeek[] $weeks
|
||||
*/
|
||||
class TimeTableMonth
|
||||
{
|
||||
public $interval;
|
||||
public $days = array();
|
||||
public $weekDayNames = array();
|
||||
public $weeks;
|
||||
|
||||
|
||||
public function getWeeksArrayDataProvider()
|
||||
{
|
||||
return new ArrayDataProvider([
|
||||
'allModels' => $this->weeks
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
20
common/modules/event/models/timetable/TimeTableMonthDay.php
Normal file
20
common/modules/event/models/timetable/TimeTableMonthDay.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace common\modules\event\models\timetable;
|
||||
|
||||
use \DateTime;
|
||||
|
||||
/**
|
||||
* Class TimeTableMonthDay
|
||||
* @param DateTime $date
|
||||
* @param TimeTableMonthDayEvent[] $events
|
||||
* @param boolean $actives
|
||||
*/
|
||||
class TimeTableMonthDay
|
||||
{
|
||||
public $date;
|
||||
public $events = array();
|
||||
public $active;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace common\modules\event\models\timetable;
|
||||
|
||||
use common\models\Event;
|
||||
|
||||
/**
|
||||
* Class TimeTableMonthDayEvent
|
||||
* @property Event $event
|
||||
*/
|
||||
class TimeTableMonthDayEvent
|
||||
{
|
||||
public $event;
|
||||
}
|
||||
50
common/modules/event/models/timetable/TimeTableMonthWeek.php
Normal file
50
common/modules/event/models/timetable/TimeTableMonthWeek.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php /** @noinspection ALL */
|
||||
|
||||
namespace common\modules\event\models\timetable;
|
||||
|
||||
use customerapi\models\available\EventInterval;
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
|
||||
|
||||
/**
|
||||
* Class TimeTableMonthWeek
|
||||
* @property EventInterval $interval
|
||||
* @property TimeTableMonthDay $monday
|
||||
* @property TimeTableMonthDay $tuesday
|
||||
* @property TimeTableMonthDay $wednesday
|
||||
* @property TimeTableMonthDay $thursday
|
||||
* @property TimeTableMonthDay $friday
|
||||
* @property TimeTableMonthDay $saturday
|
||||
* @property TimeTableMonthDay $sunday
|
||||
* @property integer $weekNumber
|
||||
*/
|
||||
class TimeTableMonthWeek
|
||||
{
|
||||
|
||||
|
||||
public $monday;
|
||||
public $tuesday;
|
||||
public $wednesday;
|
||||
public $thursday;
|
||||
public $friday;
|
||||
public $saturday;
|
||||
public $sunday;
|
||||
|
||||
public $weekNumber;
|
||||
|
||||
/**Get the week day bay property name
|
||||
* @param $weekDay
|
||||
* @return mixed
|
||||
*/
|
||||
public function getWeekDay($weekDay)
|
||||
{
|
||||
|
||||
$days = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
|
||||
$days = array_combine($days, $days);
|
||||
$objectAttribute = $days[$weekDay];
|
||||
/** @var TimeTableMonthDay $day */
|
||||
return $this->$objectAttribute;
|
||||
}
|
||||
|
||||
}
|
||||
86
common/modules/event/models/timetable/TimeTableSearch.php
Normal file
86
common/modules/event/models/timetable/TimeTableSearch.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace common\modules\event\models\timetable;
|
||||
|
||||
use common\components\DateUtil;
|
||||
use common\modules\event\manager\EventManager;
|
||||
use customerapi\models\available\EventInterval;
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ArrayDataProvider;
|
||||
|
||||
/**
|
||||
* @property string[] $tableHeaders
|
||||
* @property TimeTableModel $tableModel
|
||||
*/
|
||||
class TimeTableSearch extends Model
|
||||
{
|
||||
|
||||
public $startDateString;
|
||||
public $timestampStart;
|
||||
|
||||
|
||||
public $tableHeaders;
|
||||
public $tableModel;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['startDateString',], 'date', 'format' => Yii::$app->formatter->dateFormat, 'timestampAttribute' => 'timestampStart', 'timeZone' => 'UTC'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'startDateString' => 'Dátum'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ArrayDataProvider
|
||||
* @throws Exception
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
|
||||
$today = null;
|
||||
$this->load($params);
|
||||
if ($this->validate()) {
|
||||
$today = new DateTime( );
|
||||
$today->setTimestamp($this->timestampStart);
|
||||
}
|
||||
$interval = EventInterval::createInterval($today);
|
||||
|
||||
$em = new EventManager();
|
||||
$timeTable = $em->loadTimeTable($interval);
|
||||
$this->tableModel = new TimeTableModel();
|
||||
$this->tableModel->timeTableMonth = $timeTable;
|
||||
|
||||
/** @var DateTime[] $displayDates */
|
||||
$displayDates = $interval->getAllDisplayDates();
|
||||
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$timeTable->weekDayNames[] = DateUtil::getLocalDayName($displayDates[$i]->format('w'));
|
||||
}
|
||||
|
||||
$this->tableHeaders = [''];
|
||||
$this->tableHeaders = array_merge($this->tableHeaders, $timeTable->weekDayNames);
|
||||
|
||||
$dataProvider = new ArrayDataProvider([
|
||||
'allModels' => $timeTable->weeks
|
||||
]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user