예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Glprep::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['glprep_id' => SORT_DESC]]]);
     $query->joinWith(['idPreparat']);
     $this->load($params);
     // Отображает список препаратов глаукомного пациента в его карте
     if (isset($params['id'])) {
         $Glaukuchet = Glaukuchet::findOne(['id_patient' => $params['id']]);
         $query->andFilterWhere(['id_glaukuchet' => empty($Glaukuchet) ? -1 : $Glaukuchet->primaryKey]);
     } else {
         $query->andFilterWhere(['id_glaukuchet' => -1]);
     }
     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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['glprep_id' => $this->glprep_id, 'id_glaukuchet' => $this->id_glaukuchet, 'id_preparat' => $this->id_preparat, 'glprep_rlocat' => $this->glprep_rlocat]);
     $query->andFilterWhere(['LIKE', 'idPreparat.preparat_name', $this->getAttribute('idPreparat.preparat_name')]);
     Proc::AssignRelatedAttributes($dataProvider, ['idPreparat.preparat_name']);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Finds the Glprep model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Glprep the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Glprep::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #3
0
 /**
  * Deletes an existing Patient model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param string $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     if (Yii::$app->request->isAjax) {
         $transaction = Yii::$app->db->beginTransaction();
         try {
             $Glaukuchet = Glaukuchet::findOne(['id_patient' => $id]);
             if (!empty($Glaukuchet)) {
                 Glprep::deleteAll(['id_glaukuchet' => $Glaukuchet->primaryKey]);
                 Glaukuchet::deleteAll(['id_patient' => $id]);
             }
             echo $this->findModel($id)->delete();
             $transaction->commit();
         } catch (Exception $e) {
             $transaction->rollBack();
             throw new Exception($e->getMessage());
         }
     }
 }
예제 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGlpreps()
 {
     return $this->hasMany(Glprep::className(), ['id_glaukuchet' => 'glaukuchet_id'])->from(['glpreps' => Glprep::tableName()]);
 }
예제 #5
0
 public static function VariablesValues($attribute, $value = NULL)
 {
     $values = ['patient_pol' => Patient::VariablesValues($attribute), 'fias_city' => [$value => Fias::GetCityByAOGUID($value)], 'fias_street' => [$value => Fias::GetStreetByAOGUID($value)], 'glaukuchet_detect' => Glaukuchet::VariablesValues($attribute), 'glaukuchet_deregreason' => Glaukuchet::VariablesValues($attribute), 'glaukuchet_stage' => Glaukuchet::VariablesValues($attribute), 'glaukuchet_invalid' => Glaukuchet::VariablesValues($attribute), 'glaukuchet_id_employee' => [$value => Employee::getEmployeeByID($value)], 'employee_id_person' => [$value => Authuser::getAuthuserByID($value)], 'employee_id_dolzh' => [$value => Dolzh::getDolzhByID($value)], 'employee_id_podraz' => [$value => Podraz::getPodrazByID($value)], 'employee_id_build' => [$value => Build::getBuildByID($value)], 'glprep_id_preparat' => [$value => Preparat::getPreparatByID($value)], 'glprep_rlocat' => Glprep::VariablesValues($attribute)];
     return isset($values[$attribute]) ? $values[$attribute] : NULL;
 }