<?php
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('param-escenarios-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h3 style="text-align: center"><?= $modelCategoria->denominacion ?></h3>
<em>Seleccione las variables globales a asociar a esta categoria.</em>

<?php $this->widget('bootstrap.widgets.TbGridView', array(
    'id' => 'param-escenarios-grid',
    'dataProvider' => $model->search($modelCategoria->id),
    'filter' => $model,
    'columns' => array(
        'nombre',
        array(
            'name' => 'activada',
            'filter' => false,
            'value' => function ($model) {
                return $model->id_cv
                    ? '<span style="color: #13cb24; font-weight: bold;">Sí</span>'
                    : '<span style="font-weight: bold;">No</span>';
            },
            'type' => 'raw',
            'htmlOptions' => array('style' => 'width:100px; text-align:center;'),
        ),
        array(
            'class' => 'bootstrap.widgets.TbButtonColumn',
            'template' => '{add_variable} {remover_variable}',
            'htmlOptions' => array('style' => 'width:100px;text-align:center;'),
            'buttons' => array(
                'add_variable' => array(
                    'icon' => 'icon-ok',
                    'visible' => '! $data->id_cv',
                    'url' => function ($model) use ($modelCategoria) {
                        return CHtml::normalizeUrl(array('addVariable', 'idC' => $modelCategoria->id, 'idV' => $model->id));
                    },
                    'options' => array(
                        'title' => 'Añadir variable',
                    ),
                ),
                'remover_variable' => array(
                    'icon' => 'icon-remove',
                    'visible' => '$data->id_cv',
                    'url' => function ($model) use ($modelCategoria) {
                        return CHtml::normalizeUrl(array('removerVariable', 'idC' => $modelCategoria->id, 'idV' => $model->id_cv));
                    },
                    'options' => array(
                        'title' => 'Remover variable',
                    ),
                ),
            ),
        ),
    ),
)); ?>
