Beispiel #1
0
 private static function _getRank($indicatorName, $indicatorValue, $id, $idSpec)
 {
     echo $indicatorName . " " . $indicatorValue;
     $mathRules = IndicatorMath::find()->where(['indicator' => $indicatorName])->andWhere(['like', 'id_specjalizacja', $idSpec])->one();
     if (!$mathRules) {
         $mathRules = IndicatorMath::find()->where(['indicator' => $indicatorName])->andWhere(['id_specjalizacja' => ''])->one();
     }
     if ($mathRules) {
         if ($indicatorValue < 0) {
             if (isset($mathRules->minus2) && $indicatorValue < -$mathRules->minus2) {
                 return -2;
             } elseif ($indicatorValue < -$mathRules->minus1) {
                 return -1;
             } else {
                 return 0;
             }
         } elseif ($indicatorValue > 0) {
             if (isset($mathRules->plus2) && $indicatorValue > $mathRules->plus2) {
                 return 2;
             } elseif ($indicatorValue > $mathRules->plus1) {
                 return 1;
             } else {
                 return 0;
             }
         } else {
             return 0;
         }
     } else {
         return 0;
     }
 }
 public function getMaths()
 {
     return $this->hasMany(IndicatorMath::className(), ['indicator' => 'indicator']);
 }
 /**
  * Finds the IndicatorMath model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return IndicatorMath the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = IndicatorMath::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }