<?php
/* @var $this EjerciciosContablesController */
/* @var $model EjerciciosContables */
/* @var $form CActiveForm */
?>

<div class="form">
    <div >
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	'id'=>'ejercicios-contables-seleccionaPeriodo-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// See class documentation of CActiveForm for details on this,
	// you need to use the performAjaxValidation()-method described there.
	'enableAjaxValidation'=>false,
        //'type'=>'horizontal',
)); ?>
 
<?php
  $this->widget('bootstrap.widgets.TbAlert', array(
        'block'=>true, // display a larger alert block?
        'fade'=>true, // use transitions?
        'closeText'=>'&times;', // close link text - if set to false, no close link is displayed
        'alerts'=>array( // configurations per alert type
        'error'=>array('block'=>true, 'fade'=>true, 'Text'=>'&times;'), // success, info, warning, error or danger
        ),
    )); 
  $this->widget('bootstrap.widgets.TbAlert', array(
        'block'=>true, // display a larger alert block?
        'fade'=>true, // use transitions?
        'closeText'=>'&times;', // close link text - if set to false, no close link is displayed
        'alerts'=>array( // configurations per alert type
        'success'=>array('block'=>true, 'fade'=>true, 'Text'=>'&times;'), // success, info, warning, error or danger
        ),
    )); 
?>
  <?php //echo $this->renderPartial('_form', array('model'=>$model)); 

        foreach(Yii::app()->user->getFlashes() as $key => $message) {
            echo '<div class="flash-' . $key . '">' . $message . "</div>\n";            
        }
        ?>        
        
    <br>
    <br>
    <h3>Período actual</h3>
     
    <?php 
    function estatus($valor){
        if($valor==1) $valor="ABIERTO";
        if($valor==2) $valor="PRE-CIERRE";
        if($valor==3) $valor="CIERRE DEFINITIVO";

        return $valor;
    } 
    
    $act= EjerciciosContables::model()->find("activo=1");
    if($act!=null){
    $this->widget('bootstrap.widgets.TbDetailView',array(
	'data'=>$act,
	'attributes'=>array(
		//'id',
		'nombre_periodo',
		//'fecha_inicio',
		//'fecha_fin',
		array(
                'label'=>'Fecha inicio',
                'value'=>date('d-m-Y',strtotime($act->fecha_inicio))
                 ),
		array(
                'label'=>'Fecha fin',
                'value'=>date('d-m-Y',strtotime($act->fecha_fin))
                 ),
		array(
                'label'=>'Estatus del período',
                'value'=>estatus($act->estatus)
                 ),
	),
    )); } ?>
    </div>
        <?php $this->widget('bootstrap.widgets.TbAlert', array(
                'block'=>true, // display a larger alert block?
                'fade'=>true, // use transitions?
                'closeText'=>'&times;', // close link text - if set to false, no close link is displayed
                'alerts'=>array( // configurations per alert type
                    'success'=>array('block'=>true, 'fade'=>true, 'Text'=>'&times;'), // success, info, warning, error or danger
                ),
            )); ?>
	
	<?php echo $form->errorSummary($model); ?>
       
	<div class="row-fluid">
		<?php echo $form->labelEx($model,'id'); ?>
		<?php 
                 echo $form->dropDownList($model,'id',
                CHtml::listData(EjerciciosContables::model()->findAll(array('condition'=>'activo!=1')),'id','nombre_periodo','est.descripcion'),array('prompt'=>'-- Seleccione --'));
                ?>
		<?php echo $form->error($model,'id'); ?>
	</div>



	<div class="row-fluid buttons">
		<?php $this->widget('bootstrap.widgets.TbButton', array(
			'buttonType'=>'submit',
			'type'=>'primary',
                        //'htmlOptions'=>array('onclick'=>'envia()'),
			'label'=>'Guardar',
		)); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->