public function triggerNotification($frequency)
 {
     $indicators = Indicator::model()->findAll();
     foreach ($indicators as $indicator) {
         if ($indicator->indicatorFrequency) {
             if ($indicator->indicatorFrequency[0]->code == $frequency) {
                 echo 'found one: ' . 'indicator ID: ' . $indicator->indicatorFrequency[0]->code . "\r\n";
                 foreach ($indicator->indicatorFramework as $framework) {
                     $mapper = EamsFrameworkIndicatorMapping::model()->find('indicator_id=:i AND framework_id=:f', array(':i' => $indicator->id, ':f' => $framework->id));
                     //Initialize facts table: indicator value to be filled after notification has been sent
                     $fact = new EamsFacts();
                     $fact->framework_ind_id = $mapper->id;
                     $fact->time_id = TimeDimension::getTimeIdByDate(date('dmy'));
                     echo '<pre>';
                     print_r($fact);
                     print_r($mapper);
                     echo "\r\n";
                     if ($fact->save()) {
                         echo "Saved\r\n";
                     }
                 }
             }
         }
     }
 }
예제 #2
0
 public function actionIndex()
 {
     $indicators = Indicator::model()->findAll();
     $this->render('index', array('indicators' => $indicators));
 }
예제 #3
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 Indicator the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Indicator::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }