<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
	'enableAjaxValidation' => false,
    'type' => 'horizontal',
)); ?>
	<div class="control-group">
        <p class="help-block">Los campos con <span class="required">*</span> son obligatorios.</p>
    </div>
	<?php echo $form->errorSummary($model); ?>
    <div class="control-group">
        <?php echo $form->labelEx($model, 'fecha_apertura', array('class' => 'control-label')); ?>
        <div class="controls">
            <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                'model' => $model,
                'attribute' => 'fecha_apertura',
                'value' => $model->fecha_apertura,
                'language' => 'es',
                'htmlOptions' => array('readonly' => 'readonly'),
                'options' => array(
                    'autoSize' => true,
                    'dateFormat' => 'dd-mm-yy',
                    'buttonImage' => Yii::app()->baseUrl.'/images/calendar.png',
                    'buttonImageOnly' => true,
                    'buttonText' => 'Fecha',
                    'selectOtherMonths' => true,
                    'showAnim' => 'slide',
                    'showButtonPanel' => true,
                    'showOn' => 'button',
                    'changeMonth' => 'true',
                    'changeYear' => 'true',
                    'yearRange' => '1900:+0D',
                ),
            )) ?>
        </div>
    </div>
    <div class="control-group">
        <?php echo $form->labelEx($model, 'fecha_cierre', array('class' => 'control-label')); ?>
        <div class="controls">
            <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                'model' => $model,
                'attribute' => 'fecha_cierre',
                'value' => $model->fecha_cierre,
                'language' => 'es',
                'htmlOptions' => array('readonly' => 'readonly'),
                'options' => array(
                    'autoSize' => true,
                    'dateFormat' => 'dd-mm-yy',
                    'buttonImage' => Yii::app()->baseUrl.'/images/calendar.png',
                    'buttonImageOnly' => true,
                    'buttonText' => 'Fecha',
                    'selectOtherMonths' => true,
                    'showAnim' => 'slide',
                    'showButtonPanel' => true,
                    'showOn' => 'button',
                    'changeMonth' => 'true',
                    'changeYear' => 'true',
                    'yearRange' => '1900:+0D',
                ),
            )) ?>
        </div>
    </div>
    <div class="form-actions">
        <?php if ($model->cerrado()): ?>
        <?php $this->widget('bootstrap.widgets.TbButton', array(
            'buttonType' => 'submit',
            'type' => 'primary',
            'label' => 'Aperturar',
        )); ?>

        <?php else: ?>
        <a 
            class="btn btn-danger" 
            href="<?= CHtml::normalizeUrl(array('cerrarProceso', 'id' => $model->id)) ?>" 
            onclick="if(! confirm('¿Seguro que desea cerrar el proceso de modificaciones de Aportes Extra?')) { return false };">Cerrar</a>
        <?php endif ?>
            
    </div>
<?php $this->endWidget(); ?>

<?php $this->widget('bootstrap.widgets.TbGridView',array(
    'id' => 'lugar-trabajo-grid',
    'dataProvider' => $model->search($modelTxt->id),
    'columns' => array(
        'fecha_apertura:date',
        'fecha_cierre:date',
        array(
            'name' => 'estatus',
            'value' => function($model) {
                return $model->estatus == 1 ? 'Abierto' : 'Cerrado';
            }
        ),
    ),
)); ?>