<?php
$columns = array();
$renderEnum = array('role', 'type');
$renderBool = array('active', 'register_state');


$renderNot = array(
    'username',
    'password',
    'role',
    'current_ip',
    'expires',
    'last_contact',
    'device_name',
    'state',
    'tcp_transport',
    'allowed_codecs',
    'scriptExtension'
);

foreach ($model->attributes as $attributeName => $attributeValue) {

    if (in_array($attributeName, $renderNot)) {
        continue;
    }
    if (in_array($attributeName, $renderEnum)) {
        $columns[] = array(
            'name' => $attributeName,
            'header' => $model->getAttributeLabel($attributeName),
            'headerHtmlOptions' => array('data-translation-id' => 'EXTERNAL_HOST_MODEL_' . strtoupper($attributeName)),
            'value' => array($this, 'renderEnum'),
            'enableCustomDropdownFilter' => true,
            'filter' => $this->getDropDownData($attributeName),
        );
    } else if (in_array($attributeName, $renderBool)) {
        $columns[] = array(
            'name' => $attributeName,
            'header' => $model->getAttributeLabel($attributeName),
            'type' => 'raw',
            'headerHtmlOptions' => array('data-translation-id' => 'EXTERNAL_HOST_MODEL_' . strtoupper($attributeName)),
            'value' => array($this, 'renderBool'),
            'disableSearchField' => true,
        );
    } else {
        $columns[] = array(
            'name' => $attributeName,
            'header' => $model->getAttributeLabel($attributeName),
            'headerHtmlOptions' => array('data-translation-id' => 'EXTERNAL_HOST_MODEL_' . strtoupper($attributeName)),
        );
    }
}
$columns[] = array(
    'class' => 'ext.PlGrid.PlCButtonColumn',
    'template' => '{ajaxUpdate}{delete}',
);


$this->widget('ext.PlGrid.PlGridView', $this->getExternalHostGridViewSettings($model, $columns));
?>
<script>
    $(".icon-info").live("mouseover", function () {
        $(this).popover('show');
    });
</script>