<?php

cs()->registerScriptFile(Yii::app()->baseUrl . '/js/jquery.minicolors.js', CClientScript::POS_HEAD);

$this->widget('ext.PlGrid.PlGridView', array(
    'id' => 'calendar-grid',
    'headerTitle' => 'Header_title', // optional
    'addButtonTitle' => 'ADD_NEW_CALENDAR', // optional
    'searchButtonTitle' => 'SEARCH_CALENDAR', // optional
    'modalCreateHeader' => 'CALENDAR_HEADER_CREATE', // optional
    'modalUpdateHeader' => 'CALENDAR_HEADER_UPDATE', // optional
    'headerAttribute' => 'title', //TEST
    'itemsCssClass' => 'plTable items',
    'modalSize' => 'large', // null, 'large', 'small', 'huge'
    'dataProvider' => $model->search(),
    'filter' => $model,
    'columns' => array(
        array(
            'name' => 'title',
            'header' => $model->getAttributeLabel('title'),
            'headerHtmlOptions' => array('data-translation-id' => 'CALENDAR_MODEL_TITLE')
        ),
        array(
            'name' => 'type',
            'value' => array($model, 'renderCalenderType'),
            'header' => $model->getAttributeLabel('type'),
            'headerHtmlOptions' => array('data-translation-id' => 'CALENDAR_MODEL_TYPE'),
            'enableCustomDropdownFilter' => true,
            'filter' => $model->humanReadableSearchFilterForType(),
        ),
        array(
            'name' => 'color',
            'header' => $model->getAttributeLabel('color'),
            'headerHtmlOptions' => array(
                'data-translation-id' => 'CALENDAR_MODEL_COLOR',
            ),
            'type' => 'raw',
            'value' => array($this, 'renderGridCellColor'),
            'htmlOptions' => array(
                'width' => '60px',
            ),
            'disableSearchField' => true
        ),
        array(
            'class' => 'ext.PlGrid.PlCButtonColumn',
            'template' => '{ajaxUpdate}{delete}',
            'buttons' => array(
                'ajaxUpdate' => array(
                    'label' => '<i class="icon-pencil"></i>',
                    'imageUrl' => false,
                    'options' => array(
                        'title' => 'Update',
                    ),
                    'url' => 'Yii::app()->createUrl("adminCalendar/default/update", array("id"=>"$data->id"))',
                    'click' => 'js:function(){
            						$.get(this.href, function(data){
            						$(".modal-body").html(data);
            						$("#modalHeader").html("' . __('CALENDAR_HEADER_UPDATE') . '");
            						$("#newCalendarModal").modal("show");
            						return false;
            						});
            						return false;
            						}',
                ),
            ),
        )
    ),
        )
);
