<?php

$this->widget(
    'ext.PlGrid.PlGridView',
    array(
        'id' => 'phonesettings-credentials-grid',
        'headerTitle' => 'PHONESETTINGS_CREDENTIALS_NAVBAR_TITLE', // optional
        'dataProvider' => $this->phoneSettingsCredentialsSearch(),
        'summaryText' => false,
        'hideHeader' => true,
        'hideHeaderButtons' => true,
        'summaryText' => '&nbsp;',
        'filter' => $model,
        'columns' => array(
            array(
                'name' => 'short',
                'type' => 'raw',
                'header' => $model->getAttributeLabel('short'),
                'headerHtmlOptions' => array('data-translation-id' => 'PHONESETTINGS_USER_MODEL_SHORT'),
            ),
            array(
                'class' => 'ext.PlGrid.PlCButtonColumn',
                'template' => '{ajaxPin} {ajaxPassword}',
                'buttons' => array(
                    'ajaxPin' => array(
                        'visible' => '$row==0',
                        'label' => '<i class="icon-pencil"></i>',
                        'imageUrl' => false,
                        'options' => array(
                            'title' => __('PHONESETTINGS_PIN_BUTTON'),
                            'data-translation-id' => 'PHONESETTINGS_PIN_BUTTON',
                        ),
                        'url' => 'Yii::app()->createUrl('
                        . '     "phonesettingsCredentials/default/ajaxPin",'
                        . ' array("id"=>"' . $model->id . '")'
                        . ')',
                        'click' => 'js:function(){
                            $.get(this.href, function(data){

                                $("#phonesettings-credentials-grid_Modal .modal-body").html(data);

                                $("#phonesettings-credentials-grid_Modal .modal-header h4")
                                    .html("' . __('PHONESETTINGS_CREDENTIALS_PIN_HEADER_UPDATE') . '");

                                $("#phonesettings-credentials-grid_Modal").modal("show");
                                return false;
                            });
                            return false;
                        }',
                    ),
                    'ajaxPassword' => array(
                        'visible' => '$row==1',
                        'label' => '<i class="icon-pencil"></i>',
                        'imageUrl' => false,
                        'options' => array(
                            'title' => __('PHONESETTINGS_PASSWORD_BUTTON'),
                            'data-translation-id' => 'PHONESETTINGS_PASSWORD_BUTTON',
                        ),
                        'url' => 'Yii::app()->createUrl('
                        . '         "phonesettingsCredentials/default/ajaxPassword",'
                        . '         array("id"=>"' . $model->id . '"'
                        . '     )'
                        . ')',
                        'click' => 'js:function(){
                                    $.get(this.href, function(data){
                                        $("#phonesettings-credentials-grid_Modal .modal-body").html(data);
                                        $("#phonesettings-credentials-grid_Modal .modal-header h4")
                                            .html("' . __('PHONESETTINGS_CREDENTIALS_PASSWORD_HEADER_UPDATE') . '");
                                        $("#phonesettings-credentials-grid_Modal").modal("show");
                                        return false;
                                    });
                            return false;
                        }',
                    ),
                ),
            )
        ),
    )
);
