/**
  * 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();
 }
Example #2
0
<?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'))
echo CHtml::ajaxSubmitButton($model->isNewRecord ? Yii::t('waterrequest', 'Add') : Yii::t('waterrequest', 'Save changes'), $editing ? CController::createUrl('waterRequestGeometryZones/update', array('id' => $model->id)) : CController::createUrl('waterRequestGeometryZones/create', array('id' => $geom_model->id)), array('dataType' => 'json', 'success' => 'function(response){newWRGZresponseHandler(response);}', 'error' => 'function(response){console.log(response);}'), array('id' => 'submitta'));
?>
	</div>
Example #3
0
 public function calculateWaterDemand($geom = null)
 {
     $zone = $this->zone_name;
     while ($zone != null) {
         $formula = WaterRequestFormulas::model()->find('zone=:zone', array(':zone' => $zone));
         if ($formula) {
             break;
         }
         $zone = Zones::parentZone($zone);
     }
     //Yii::log('ctype_digit='.print_r(ctype_digit($geom_id),true).' geom_id='.$geom_id , CLogger::LEVEL_INFO, 'calculateWaterDemand');  // 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_id)){
     			$comuni = Geometry::Get_City_State_ByWKT($geom_id);
     		}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, 'calculateWaterDemand');
         // 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, 'calculateWaterDemand');
         // DEBUG
         return -1;
     }
     $dg = $water_supply->daily_maximum_water_supply;
     $da = $water_supply->yearly_average_water_supply;
     $fformula = str_ireplace(array('ae', 'dg', 'da'), array($this->pe, $dg, $da), $formula->formula);
     //TODO: mettere nel config il valore delle stringe ae, dg e da
     $ret = Math::safe_eval($fformula);
     if (is_numeric($ret)) {
         return $ret;
     }
     return -1;
 }
Example #4
0
File: Zones.php Project: Gnafu/wiz
 /**
  * Returns the formula associated with the area
  */
 public function getFormula()
 {
     $formula = null;
     $zone = $this->name;
     while ($zone != null) {
         $formula = WaterRequestFormulas::model()->find('zone=:zone', array(':zone' => $zone));
         if ($formula) {
             break;
         }
         $zone = Zones::parentZone($zone);
     }
     return $formula;
 }