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 static function generateTimeline($seed = '2013-07-01')
 {
     for ($i = 0; $i < 1826; $i++) {
         $date = strtotime("+{$i} day", strtotime($seed));
         $month = date("M", $date);
         if ($month == 'Jul' || $month == 'Aug' || $month == 'Sep') {
             $quarter = 'Q1';
         } elseif ($month == 'Oct' || $month == 'Nov' || $month == 'Dec') {
             $quarter = 'Q2';
         } elseif ($month == 'Jan' || $month == 'Feb' || $month == 'Mar') {
             $quarter = 'Q3';
         } elseif ($month == 'Apr' || $month == 'May' || $month == 'Jun') {
             $quarter = 'Q4';
         }
         $year = date('Y', $date);
         //                     echo date("dmy", $date);
         //                     echo $month;
         //                     echo $quarter;
         //                     echo $year;
         $model = new TimeDimension();
         $model->daytimekey = date("dmy", $date);
         $model->daymonth = $month;
         $model->dayquarter = $quarter;
         $model->dayyear = $year;
         $model->save();
     }
     echo 'Done generating timeline!';
 }