/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Factors2::find()->orderBy('id'); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere([ 'id' => $this->id, ]); $query->andFilterWhere(['ilike', 'code', $this->code]) ->andFilterWhere(['ilike', 'name', $this->name]) ->andFilterWhere(['ilike', 'period', $this->period]); return $dataProvider; }
/** * Finds the Factors2 model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Factors2 the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Factors2::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getFactors() { return $this->hasOne(Factors2::className(), ['id'=>'factor']); }
/** * check factors in file * @param type $factors_str * @return type */ public static function checkFactors($factors_str,$pril) { $factors_arr=explode(',',$factors_str); foreach($factors_arr as $code) { if($pril==1) { $factor=Factors1::find()->where(['code'=>$code])->one(); } else { $factor=Factors2::find()->where(['code'=>$code])->one(); } return self::checkFactor($factor,$code,$pril); } }
/** * есть ли ретикулоциты * @param type $factors1 * @param type $factors2 * @return boolean */ protected function defineProc($factors1, $factors2, $proc_cond_arr) { $proc_cond = "and name not like '%*%'"; foreach ($proc_cond_arr as $el) { if (is_array($el)) { $el_str = implode("' or name like '", $el); $proc_cond .= " and ( name like '{$el_str}' )"; } else { $proc_cond .= " and name like '{$el}'"; } } foreach ($factors1 as $factor) { $factor_model = Factors1::find()->where(['code' => $factor])->one(); if ($factor_model) { $proc = Procedures1::find()->where("factor={$factor_model->id}" . $proc_cond)->one(); if ($proc) { $procedure = Procedures::find()->where(['procedure' => $proc->name])->one(); if ($procedure && $procedure->place) { return $procedure->place; } return 'каб.'; } } } foreach ($factors2 as $factor) { $factor_model = Factors2::find()->where(['code' => $factor])->one(); if ($factor_model) { $proc = Procedures2::find()->where("factor={$factor_model->id}" . $proc_cond)->one(); if ($proc) { $procedure = Procedures::find()->where(['procedure' => $proc->name])->one(); if ($procedure && $procedure->place) { return $procedure->place; } return 'каб.'; } } } return false; }