<?php 
Yii::app()->clientScript->registerScript('tablaAmortizacion','
			$(document).ready(function() {
                            $(\'#unidades-grid\').selGridView(\'addSelection\', ['.$model->unidades.']);
			});');
?>
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	'id'=>'unidad-usuario-form',
	'enableAjaxValidation'=>false,
)); ?>
	<p class="help-block"><span class="required">*</span> campos de llenado obligatorio.</p>

	<?php echo $form->errorSummary($model); ?>

	<?php echo $form->dropDownListRow($model,'idusuario',
	                  CHtml::listData(CrugeUserI::model()->findAll(array('condition'=>"state= 1 order by username asc",
	                        'join'=> "INNER JOIN cruge_authassignment ca ON t.iduser = ca.userid and ca.itemname not in ('usuario_asociado')")),'iduser','username'), 
	                  array('prompt' => '--Seleccione--', 'class'=>'span5')); ?>

	<fieldset>
                <legend>Seleccionar unidad</legend>    
                <?php  $this->widget('ext.selgridview.BootSelGridView', array(
                    'id'=>'unidades-grid',
                    'dataProvider'=>$modelUnidad->search(),
        //            'filter'=>$modelReporteCredito,
                    'selectableRows'=>100,
                    'columns'=>array(
                            array(
                            'id'=>'seleccion',
                            'class' => 'CCheckBoxColumn',
//                            'checked'=> '($data->idcredito=s=r'.(($model->idcredito!="")?$model->idcredito :0).')?true:false'
                            ),
                            array(
                               // 'header'=>'Empresa',
                                'name'=>'idlugartrabajo',
                                'value'=>'$data->empresa->descripcion'
                            ),
                            array(
                              //  'header'=>'Unidad',
                                'name'=>'idunidad',
                                'value'=>'$data->descripcion'
                            ),
                            'codigo',
                    ),
                    )); ?>
            </fieldset>  

	<div class="form-actions">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
			'label'=>$model->isNewRecord ? 'Guardar' : 'Modificar',
		)); ?>
	</div>

<?php $this->endWidget(); ?>
