add admin timetable
This commit is contained in:
92
common/modules/event/models/copy/CopyWeekSearch.php
Normal file
92
common/modules/event/models/copy/CopyWeekSearch.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace common\modules\event\models\copy;
|
||||
|
||||
use common\components\DateUtil;
|
||||
use common\modules\event\manager\EventManager;
|
||||
use common\modules\event\models\timetable\TimeTableMonth;
|
||||
use customerapi\models\available\EventInterval;
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use Yii;
|
||||
use common\models\Event;
|
||||
use yii\base\Model;
|
||||
use yii\data\ArrayDataProvider;
|
||||
|
||||
/**
|
||||
* @property string $sourceDateString
|
||||
* @property string $targetDateString
|
||||
* @property integer $timestampSource
|
||||
* @property integer $timestampTarget
|
||||
* @property EventInterval $sourceInterval
|
||||
* @property EventInterval $targetInterval
|
||||
* @property TimeTableMonth $sourceTimeTable
|
||||
* @property TimeTableMonth $targetTimeTable
|
||||
* @property string[] $tableHeaders
|
||||
*/
|
||||
class CopyWeekSearch extends Model
|
||||
{
|
||||
|
||||
public $sourceDateString;
|
||||
public $timestampSource;
|
||||
|
||||
public $targetDateString;
|
||||
public $timestampTarget;
|
||||
|
||||
public $sourceInterval;
|
||||
public $targetInterval;
|
||||
|
||||
public $sourceTimeTable;
|
||||
public $targetTimeTable;
|
||||
|
||||
public $tableHeaders;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['sourceDateString',], 'date', 'format' => Yii::$app->formatter->dateFormat, 'timestampAttribute' => 'timestampSource', 'timeZone' => 'UTC'],
|
||||
[['targetDateString',], 'date', 'format' => Yii::$app->formatter->dateFormat, 'timestampAttribute' => 'timestampTarget', 'timeZone' => 'UTC'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'sourceDateString' => 'Forrás Dátum',
|
||||
'targetDateString' => 'Cél Dátum',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
|
||||
$sourceDate = null;
|
||||
$targetDate = null;
|
||||
$this->load($params);
|
||||
if ($this->validate()) {
|
||||
|
||||
$sourceDate = new DateTime();
|
||||
$sourceDate->setTimestamp($this->timestampSource);
|
||||
|
||||
$targetDate = new DateTime();
|
||||
$targetDate->setTimestamp($this->timestampTarget);
|
||||
}
|
||||
$this->sourceInterval = EventInterval::createInterval($sourceDate,7,7);
|
||||
$this->targetInterval = EventInterval::createInterval($targetDate,7,7);
|
||||
|
||||
$eventManager = new EventManager();
|
||||
$this->sourceTimeTable = $eventManager->loadTimeTable($this->sourceInterval);
|
||||
$this->targetTimeTable = $eventManager->loadTimeTable($this->targetInterval);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user