コード例 #1
0
 /**
  * List all related WaterRequestGeometryZoneProperties.
  * This is only a proxy function, the real rendering is done by the WaterRequestGeometryZoneProperties view.
  */
 public function actionShowPropsForm($zone_type)
 {
     $prop_model = new WaterRequestGeometryZoneProperties();
     $params = array();
     $zone = $zone_type;
     while ($zone != null) {
         $params = ZonesWaterRequestParameters::model()->active_parameters()->findAll('zone=:zone', array(':zone' => $zone));
         if ($params) {
             break;
         }
         $zone = Zones::parentZone($zone);
     }
     echo $this->renderPartial('//waterRequestGeometryZoneProperties/_not_a_form', array('model' => $prop_model, 'params' => $params));
     //echo $this->renderPartial('//waterRequestGeometryZoneProperties/_properties', array('model'=>$prop_model, 'zone_type'=>$zone_type, 'params'=>$params));
     Yii::app()->end();
 }
コード例 #2
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id the identifier of the model to be updated
  * @param string $zone the name of zone associate with the module
  */
 public function actionUpdate($id, $zone)
 {
     $model = $this->loadModel($id);
     $model->zone_request_parameters = ZonesWaterRequestParameters::model()->findByPk(array('parameter' => $id, 'zone' => $zone));
     if (isset($_POST['WaterRequestParameters'])) {
         $model->attributes = $_POST['WaterRequestParameters'];
         if ($model->save()) {
             if ($model->zone_request_parameters->delete()) {
                 $model->zone_request_parameters = new ZonesWaterRequestParameters();
                 $model->zone_request_parameters->attributes = $_POST['ZonesWaterRequestParameters'];
                 $model->zone_request_parameters->parameter = $model->name;
                 if ($model->zone_request_parameters->save()) {
                     $this->redirect(array('view', 'id' => $model->name));
                 }
             }
         }
     }
     $this->render('update', array('model' => $model));
 }
コード例 #3
0
ファイル: _popupform.php プロジェクト: Gnafu/wiz
echo $form->error($model, 'zone_name');
?>
	</div>
	
<?php 
if (!$editing) {
    ?>
	<div class="zone_parameter">&nbsp;</div>
<?php 
} else {
    ?>
	<div class="zone_parameter">
	<?php 
    $zone = $model->zone_name;
    while ($zone != null) {
        $params = ZonesWaterRequestParameters::model()->active_parameters()->findAll('zone=:zone', array(':zone' => $zone));
        if ($params) {
            break;
        }
        $zone = Zones::parentZone($zone);
    }
    echo $this->renderPartial('//waterRequestGeometryZoneProperties/_properties_edit', array('params' => $params, 'local' => $model->properties()));
    ?>
	</div>
<?php 
}
?>
	
	<div class="row buttons">
		<?php 
//echo CHtml::submitButton(Yii::t('waterrequest', 'Save changes'))
コード例 #4
0
 public function calculatePE($parameter, $value, $geom = null)
 {
     $zone = $this->zone_name;
     //var_dump($this->properties);
     //$properties = $this->properties->find('geometry_zone=:geometry_zone',array(':geometry_zone'=>$this->id));
     while ($zone != null) {
         //$parameter = $properties->parameter;
         $conversion_index = ZonesWaterRequestParameters::model()->active_parameters()->find('parameter=:parameter AND zone=:zone', array(':parameter' => $parameter, ':zone' => $zone));
         if ($conversion_index) {
             break;
         }
         $zone = Zones::parentZone($zone);
     }
     //Yii::log($conversion_index->zone.' = '.$conversion_index->value ,CLogger::LEVEL_INFO,"WRGZones->CalculatePE()");
     // Se trovo che la PE si calcola senza bisogno di DG o DA, restituisco direttamente il numero
     if (is_numeric($conversion_index->value)) {
         return $value * $conversion_index->value;
     }
     //Yii::log('ctype_digit='.(ctype_digit($geom_id)?'true':'false').' geom_id='.$geom_id , CLogger::LEVEL_INFO, 'calculatePE');  // DEBUG
     if ($geom == null) {
         $comuni = Geometry::Get_City_State($this->wr_geometry_id);
     } else {
         $comuni = Geometry::Get_City_State_ByWKT($geom);
     }
     /*	
     		if(!ctype_digit($geom)){
     			$comuni = Geometry::Get_City_State_ByWKT($geom);
     		}else{
     			$comuni = Geometry::Get_City_State($this->wr_geometry_id);
     		}*/
     if (count($comuni)) {
         $city_state = $comuni[0]['nome'];
     } else {
         Yii::log('non trovo il comune. geom_id=' . $geom, CLogger::LEVEL_INFO, 'calculatePE');
         // DEBUG
         $city_state = 'Pisa';
     }
     $water_supply = WaterSupply::model()->find('lower(city_state)=:city_state', array(':city_state' => strtolower($city_state)));
     if (!$water_supply) {
         Yii::log('Manca la WaterSupply. $city_state=' . $city_state, CLogger::LEVEL_INFO, 'calculatePE');
         // DEBUG
         return -1;
     }
     $dg = $water_supply->daily_maximum_water_supply;
     $da = $water_supply->yearly_average_water_supply;
     $val = str_ireplace(array('dg', 'da'), array($dg, $da), $conversion_index->value);
     //TODO: mettere nel config il valore delle stringe dg e da
     $ret = $value * Math::safe_eval($val);
     if (is_numeric($ret)) {
         return $ret;
     }
     return -1;
 }
コード例 #5
0
ファイル: _form.php プロジェクト: Gnafu/wiz
?>
		<?php 
echo $form->hiddenField($model, 'geometry_zone');
?>
		<?php 
echo $form->error($model, 'geometry_zone');
?>
	</div>

	<div class="row">
		<?php 
echo $form->labelEx($model, 'parameter');
?>
		<?php 
//echo $form->textField($model,'parameter',array('size'=>60,'maxlength'=>255));
echo $form->dropDownList($model, 'parameter', CHtml::listData(ZonesWaterRequestParameters::model()->findAll('zone=:zone_type AND active=:active', array(':active' => true, ':zone_type' => $zone_type)), 'parameter', 'parameter'), array('empty' => 'Select Parameter'));
?>
		<?php 
echo $form->error($model, 'parameter');
?>
	</div>
	<br/>
	<div class="row">
		<?php 
echo $form->labelEx($model, 'value');
?>
		<?php 
echo $form->textField($model, 'value', array('size' => 60, 'maxlength' => 255));
?>
		<?php 
echo $form->error($model, 'value');