PHP code example of professionalweb / schedule-widget-yii2
1. Go to this page and download the library: Download professionalweb/schedule-widget-yii2 library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
professionalweb / schedule-widget-yii2 example snippets
use professionalweb\ScheduleWidget\ScheduleWidget;
echo ScheduleWidget::widget([
'clientOptions' => [
'daily' => 'true',
'column-magnet' => 'column',
'time-frames-magnet' => false
],
'plugins' => [
ScheduleWidget::PLUGIN_MOVABLE => [],
ScheduleWidget::PLUGIN_TABLE => [
'headers' => [
'model.name' => 'Name'
]
],
ScheduleWidget::PLUGIN_TOOLTIP => []
],
'events' => [
ScheduleWidget::EVENT_TASK_MOVEEND => new JsExpression('function(task){'
.'console.log(task.row.model);'
.'}')
],
'data' => '[
{"name":"Row №1","sortable":"false","tasks":[]},
{"name":"Row №2","sortable":"false","tasks":[]},
{"name":"Row №3","sortable":"false","tasks":[
{"name":"Task №1","from":"2015 04 16","to":"2015 04 23"}
]
}
]'
]);
$result = [];
$eventRow = new Row();
$eventRow->name = Yii::t('app', 'Rent');
$result[] = $eventRow;
foreach (Room::find()->all() as $room) {
$rowRent = new Row();
$rowRent->name = $room->ROOM_NUMBER;
$rowRent->parent = $eventRow->name;
foreach (Event::find()->andWhere(['ROOM_ID' => $room->id)->all() as $event) {
$task = new Task();
$task->name = $event->CLIENT_NAME;
$task->from = Yii::$app->formatter->asDate($event->START_DATE,
'Y-MM-dd');
$task->to = Yii::$app->formatter->asDate($event->END_DATE,
'Y-MM-dd');
$task->classes = ['event-row'];
$rowRent->tasks[] = $task;
}
$result[] = $rowRent;
}
'events' => [
ScheduleWidget::EVENT_TASK_ROW_CHANGE => new JsExpression('function(task){'
.'if(task.row.model.parent===\'Rent\') {'
.'task.$element.addClass(\'event-row\');'
.'task.$element.removeClass(\'request-row\');'
.'} else {'
.'task.$element.removeClass(\'event-row\');'
.'task.$element.addClass(\'request-row\');'
.'}'
.'}'),
ScheduleWidget::EVENT_TASK_DBLCLICK => new JsExpression('function(task){console.log(task);}')
]
ScheduleWidget::PLUGIN_TOOLTIP => [
'date-format'=>'\'DD.MM.YYYY\'',
'content' => '\'<div ng-bind-html="task.model.name | unsafe"></div>{{getFromLabel() +" - "+getToLabel()}}\''
],