echo $form->labelEx($model, 'codigoaf'); ?> <?php echo $form->textField($model, 'codigoaf', array('size' => 14, 'maxlength' => 14)); ?> <?php echo $form->error($model, 'codigoaf'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'codarea'); ?> <?php $datos = CHtml::listData(Areas::model()->findAll(array('order' => 'area')), 'codarea', 'area'); echo $form->DropDownList($model, 'codarea', $datos, array('empty' => '--Seleccione un area--')); ?> <?php echo $form->error($model, 'codarea'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'codep'); ?> <?php //echo $form->textField($model,'codep',array('size'=>3,'maxlength'=>3)); ?>
<?php } ?> <?php echo $form->error($model, 'serie'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'codarea'); ?> <?php $datos1 = CHtml::listData(Areas::model()->findAll(), 'codarea', 'area'); echo $form->DropDownList($model, 'codarea', $datos1, array('empty' => '--Seleccione un area--')); ?> <?php echo $form->error($model, 'codarea'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'hidfondo'); if ($model->isNewRecord) { ?> <?php
/** * 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 Areas the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Areas::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
echo $form->labelEx($model, 'name'); ?> <?php echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 255)); ?> <?php echo $form->error($model, 'name'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'areas'); ?> <?php $data = CHtml::listData(Areas::model()->findAll(), "id", "name"); echo $form->dropDownList($model, 'areas', $data, array('multiple' => 'multiple', 'size' => '5')); ?> <?php echo $form->error($model, 'areas'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?> </div> <?php $this->endWidget();
public function actionStat() { $stat = array(); $start_date = strtotime("2015-03-01"); $end_date = strtotime("2015-04-10"); $areas = Areas::model()->with('stations')->findAll(); foreach ($areas as $area) { $stations = $area->stations; $stat[$area->id]["area_name"] = $area->name; foreach ($stations as $station) { $q = "\n\t\t\t\t\tSELECT AVG(temperature) AS avg_temp, MONTH(FROM_UNIXTIME(date)) as measurement_month, DAY(FROM_UNIXTIME(date)) as measurement_day, DATE(FROM_UNIXTIME(date)) as measurement_date\n\t\t\t\t\tFROM tbl_measurements_hr\n\t\t\t\t\tWHERE stationid = :stationid\n\t\t\t\t\tGROUP BY measurement_month, measurement_day\n\t\t\t\t"; $command = Yii::app()->db->createCommand($q); $command->bindValue(":stationid", $station->id, PDO::PARAM_STR); $avg = $command->queryAll(); $ordered = array(); foreach ($avg as $data) { $ordered[$data["measurement_month"]][] = $data; } $stat[$area->id]["stations"][$station->id]["station_name"] = $station->name; $stat[$area->id]["stations"][$station->id]["stat"] = $ordered; } } $this->render('stat', array('stat' => $stat)); }