Example #1
0
 private function setModel()
 {
     if (!$this->_model) {
         $objetito = Periodos::model()->findByAttributes(array('activo' => '1'));
         if (is_null($objetito)) {
             throw new CHttpException(500, __CLASS__ . '   No se ha activado nigun periodo ');
         }
         if (!$this->HoyDentroDe($objetito->inicio, $objetito->final)) {
             throw new CHttpException(500, __CLASS__ . '  La fecha actual no se encuentra dentro del periodo activo ');
         }
         $this->_model = $objetito;
     }
     return $this->_model;
 }
  		<?php 
    echo $form->labelEx($totalFlujoCajas, 'anos');
    ?>
  		<?php 
    echo $form->dropDownList($totalFlujoCajas, 'anos', array('1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, '10' => 10), array('empty' => 'año'));
    ?>
  	   <?php 
    echo $form->error($totalFlujoCajas, 'anos');
    ?>

  	  <?php 
    echo $form->labelEx($totalFlujoCajas, 'periodo_id');
    ?>
  		<?php 
    echo $form->dropDownList($totalFlujoCajas, 'periodo_id', CHtml::listData(Periodos::model()->findAll(), 'id', 'nombre'), array('empty' => 'Seleccione'), array('widgetOptions' => array('htmlOptions' => array('class' => 'span5'))));
    ?>
  		<?php 
    echo $form->error($totalFlujoCajas, 'periodo_id');
    ?>


  		<?php 
    echo CHtml::button('Cargar', array('submit' => array('flujocajas/create')));
    ?>
																	        
	<?php 
} else {
    ?>

 public function actionUpdate($id)
 {
     $this->limpiarSessions();
     $model = new Flujocajas();
     $totalFlujoCajas = new Totalflujocajas();
     if (!isset(Yii::app()->session['modelos']) && !isset(Yii::app()->session['totalFlujoCajas'])) {
         $totalFlujoCajas = Totalflujocajas::model()->find('proyecto_id=?', array($id));
         $flujoCajas = Flujocajas::model()->findAll('proyecto_id=?', array($id));
         if ($totalFlujoCajas && $flujoCajas) {
             Yii::app()->session['totalFlujoCajas'] = $totalFlujoCajas;
             $periodo = Periodos::model()->find('id=?', array($totalFlujoCajas->periodo_id));
             if (count($flujoCajas) == ($totalFlujoCajas->anos + 1) * $periodo->valor) {
                 //Se cargo bien
                 $modelos[][] = new Flujocajas();
                 foreach ($flujoCajas as $key => $value) {
                     $modelos[$value->ano][$value->periodo] = $value;
                 }
                 Yii::app()->session['modelos'] = $modelos;
                 Yii::app()->session['totalFlujoCajas'] = $totalFlujoCajas;
                 Yii::app()->session['ano'] = 0;
                 Yii::app()->session['periodo'] = 0;
                 Yii::app()->session['periodoSel'] = $periodo->valor;
                 Yii::app()->session['anoSel'] = $totalFlujoCajas->anos;
             } else {
                 //problema en la carga
             }
             $this->render('update', array('model' => Yii::app()->session['modelos'][Yii::app()->session['ano']][Yii::app()->session['periodo']], 'total' => Yii::app()->session['totalFlujoCajas']));
         }
     }
 }
Example #4
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Periodos the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Periodos::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #5
0
 public static function consultaGetIdPeriodoActual()
 {
     $format = "Y-m-d";
     $timestamp = time();
     $fechaA = date($format, $timestamp);
     $seleccionar = Periodos::where('perInicio', '<=', $fechaA)->where('perFin', '>=', $fechaA)->get(array('perId'))->toArray();
     return $seleccionar;
 }