2017 © Pedro Peláez
 

yii2-extension yii2-fullcalendar

Yii2 widget for fullcalendar

image

edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  • Thursday, January 4, 2018
  • by edofre
  • Repository
  • 8 Watchers
  • 16 Stars
  • 3,868 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 20 Versions
  • 5 % Grown

The README.md

Yii2 fullcalendar component

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

To install, either run, (*3)

$ php composer.phar require edofre/yii2-fullcalendar "V1.0.11"

or add, (*4)

"edofre/yii2-fullcalendar": "V1.0.11"

to the require section of your composer.json file., (*5)

Usage

Fullcalendar can be created as following, all options are optional, below is just an example of most options

= edofre\fullcalendar\Fullcalendar::widget([
        'options'       => [
            'id'       => 'calendar',
            'language' => 'nl',
        ],
        'clientOptions' => [
            'weekNumbers' => true,
            'selectable'  => true,
            'defaultView' => 'agendaWeek',
            'eventResize' => new JsExpression("
                function(event, delta, revertFunc, jsEvent, ui, view) {
                    console.log(event);
                }
            "),

        ],
        'events'        => Url::to(['calendar/events', 'id' => $uniqid]),
    ]);
?>

Events can be added in three ways, PHP array, Javascript array or JSON feed

PHP array

 'Appointment #' . rand(1, 999),
            'start' => '2016-03-18T14:00:00',
        ]),
        // Everything editable
        new Event([
            'id'               => uniqid(),
            'title'            => 'Appointment #' . rand(1, 999),
            'start'            => '2016-03-17T12:30:00',
            'end'              => '2016-03-17T13:30:00',
            'editable'         => true,
            'startEditable'    => true,
            'durationEditable' => true,
        ]),
        // No overlap
        new Event([
            'id'               => uniqid(),
            'title'            => 'Appointment #' . rand(1, 999),
            'start'            => '2016-03-17T15:30:00',
            'end'              => '2016-03-17T19:30:00',
            'overlap'          => false, // Overlap is default true
            'editable'         => true,
            'startEditable'    => true,
            'durationEditable' => true,
        ]),
        // Only duration editable
        new Event([
            'id'               => uniqid(),
            'title'            => 'Appointment #' . rand(1, 999),
            'start'            => '2016-03-16T11:00:00',
            'end'              => '2016-03-16T11:30:00',
            'startEditable'    => false,
            'durationEditable' => true,
        ]),
        // Only start editable
        new Event([
            'id'               => uniqid(),
            'title'            => 'Appointment #' . rand(1, 999),
            'start'            => '2016-03-15T14:00:00',
            'end'              => '2016-03-15T15:30:00',
            'startEditable'    => true,
            'durationEditable' => false,
        ]),
    ];
?>

= edofre\fullcalendar\Fullcalendar::widget([
        'events'        => $events
    ]);
?>

Javascript array

<?= edofre\fullcalendar\Fullcalendar::widget([
       'events'        => new JsExpression('[
            {
                "id":null,
                "title":"Appointment #776",
                "allDay":false,
                "start":"2016-03-18T14:00:00",
                "end":null,
                "url":null,
                "className":null,
                "editable":false,
                "startEditable":false,
                "durationEditable":false,
                "rendering":null,
                "overlap":true,
                "constraint":null,
                "source":null,
                "color":null,
                "backgroundColor":"grey",
                "borderColor":"black",
                "textColor":null
            },
            {
                "id":"56e74da126014",
                "title":"Appointment #928",
                "allDay":false,
                "start":"2016-03-17T12:30:00",
                "end":"2016-03-17T13:30:00",
                "url":null,
                "className":null,
                "editable":true,
                "startEditable":true,
                "durationEditable":true,
                "rendering":null,
                "overlap":true,
                "constraint":null,
                "source":null,
                "color":null,
                "backgroundColor":"grey",
                "borderColor":"black",
                "textColor":null
            },
            {
                "id":"56e74da126050",
                "title":"Appointment #197",
                "allDay":false,
                "start":"2016-03-17T15:30:00",
                "end":"2016-03-17T19:30:00",
                "url":null,
                "className":null,
                "editable":true,
                "startEditable":true,
                "durationEditable":true,
                "rendering":null,
                "overlap":false,
                "constraint":null,
                "source":null,
                "color":null,
                "backgroundColor":"grey",
                "borderColor":"black",
                "textColor":null
            },
            {
                "id":"56e74da126080",
                "title":"Appointment #537",
                "allDay":false,
                "start":"2016-03-16T11:00:00",
                "end":"2016-03-16T11:30:00",
                "url":null,
                "className":null,
                "editable":false,
                "startEditable":false,
                "durationEditable":true,
                "rendering":null,
                "overlap":true,
                "constraint":null,
                "source":null,
                "color":null,
                "backgroundColor":"grey",
                "borderColor":"black",
                "textColor":null
            },
            {
                "id":"56e74da1260a7",
                "title":"Appointment #465",
                "allDay":false,
                "start":"2016-03-15T14:00:00",
                "end":"2016-03-15T15:30:00",
                "url":null,
                "className":null,
                "editable":false,
                "startEditable":true,
                "durationEditable":false,
                "rendering":null,
                "overlap":true,
                "constraint":null,
                "source":null,
                "color":null,
                "backgroundColor":"grey",
                "borderColor":"black",
                "textColor":null
            },
        ]'),
    ]);
?>

JSON feed

<?= edofre\fullcalendar\Fullcalendar::widget([
        'events'        => Url::to(['calendar/events', 'id' => $uniqid]),
    ]);
?>

Your controller action would then return an array as following, (*6)

    /**
     * @param $id
     * @param $start
     * @param $end
     * @return array
     */
    public function actionEvents($id, $start, $end)
    {
        \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

        return [
            // minimum
            new Event([
                'title' => 'Appointment #' . rand(1, 999),
                'start' => '2016-03-18T14:00:00',
            ]),
            // Everything editable
            new Event([
                'id'               => uniqid(),
                'title'            => 'Appointment #' . rand(1, 999),
                'start'            => '2016-03-17T12:30:00',
                'end'              => '2016-03-17T13:30:00',
                'editable'         => true,
                'startEditable'    => true,
                'durationEditable' => true,
            ]),
            // No overlap
            new Event([
                'id'               => uniqid(),
                'title'            => 'Appointment #' . rand(1, 999),
                'start'            => '2016-03-17T15:30:00',
                'end'              => '2016-03-17T19:30:00',
                'overlap'          => false, // Overlap is default true
                'editable'         => true,
                'startEditable'    => true,
                'durationEditable' => true,
            ]),
            // Only duration editable
            new Event([
                'id'               => uniqid(),
                'title'            => 'Appointment #' . rand(1, 999),
                'start'            => '2016-03-16T11:00:00',
                'end'              => '2016-03-16T11:30:00',
                'startEditable'    => false,
                'durationEditable' => true,
            ]),
            // Only start editable
            new Event([
                'id'               => uniqid(),
                'title'            => 'Appointment #' . rand(1, 999),
                'start'            => '2016-03-15T14:00:00',
                'end'              => '2016-03-15T15:30:00',
                'startEditable'    => true,
                'durationEditable' => false,
            ]),
        ];
    }

Callbacks

Callbacks have to be wrapped in a JsExpression() object. For example if you want to use the eventResize you would add the following to the fullcalendar clientOptions, (*7)

<?= edofre\fullcalendar\Fullcalendar::widget([
        'clientOptions' => [
            'eventResize' => new JsExpression("
                function(event, delta, revertFunc, jsEvent, ui, view) {
                    console.log(event.id);
                    console.log(delta);
                }
            "),
        ],
    ]);
?>

The Versions

04/01 2018

dev-master

9999999-dev https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

04/01 2018

v1.0.11.x-dev

1.0.11.9999999-dev https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

04/01 2018

V1.0.11

1.0.11.0 https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

06/10 2017

v1.0.10.x-dev

1.0.10.9999999-dev https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

06/10 2017

V1.0.10

1.0.10.0 https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

20/06 2017

v1.0.9.x-dev

1.0.9.9999999-dev https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

20/06 2017

V1.0.9

1.0.9.0 https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

30/03 2017

v1.0.8.x-dev

1.0.8.9999999-dev https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

30/03 2017

V1.0.8

1.0.8.0 https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

26/02 2017

v1.0.7.x-dev

1.0.7.9999999-dev https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

26/02 2017

V1.0.7

1.0.7.0 https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

28/12 2016

V1.0.6

1.0.6.0 https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

28/12 2016

v1.0.6.x-dev

1.0.6.9999999-dev https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

23/12 2016

v1.0.5.x-dev

1.0.5.9999999-dev https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

23/12 2016

V1.0.5

1.0.5.0 https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

24/11 2016

v1.0.4.x-dev

1.0.4.9999999-dev https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

24/11 2016

V1.0.4

1.0.4.0 https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

18/11 2016

v1.0.3.x-dev

1.0.3.9999999-dev https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

18/11 2016

V1.0.3

1.0.3.0 https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar

05/06 2016

V1.0.2

1.0.2.0 https://github.com/edofre/yii2-fullcalendar

Yii2 widget for fullcalendar

  Sources   Download

MIT

The Requires

 

by Edo Freriks

javascript calendar event fullcalendar