/** * after find * @return parent */ public function afterFind() { $rel_pat=Patients::find()->where(['firm_id'=>$this->id])->one(); if($rel_pat) { $this->talon=$rel_pat->talon; } return parent::afterFind(); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params,$firm_id=false) { $query = Patients::find()->orderBy('surname'); $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, 'birthday' => $this->birthday, 'passport_series' => $this->passport_series, 'passport_number' => $this->passport_number, 'passport_given_date' => $this->passport_given_date, 'passport_given_date' => $this->talon, 'firm_id' => $firm_id?$firm_id:$this->firm_id, ]); $query->andFilterWhere(['ilike', 'surname', $this->surname]) ->andFilterWhere(['ilike', 'name', $this->name]) ->andFilterWhere(['ilike', 'patron', $this->patron]) ->andFilterWhere(['ilike', 'snils', $this->snils]) ->andFilterWhere(['ilike', 'sex', $this->sex]) ->andFilterWhere(['ilike', 'spec', $this->spec]) ->andFilterWhere(['ilike', 'phone', $this->phone]) ->andFilterWhere(['ilike', 'factors1', $this->factors1]) ->andFilterWhere(['ilike', 'factors2', $this->factors2]) ->andFilterWhere(['ilike', 'seniority', $this->seniority]) ->andFilterWhere(['ilike', 'dep', $this->dep]) ->andFilterWhere(['ilike', 'prof', $this->prof]) ->andFilterWhere(['ilike', 'addresse_reg', $this->addresse_reg]) ->andFilterWhere(['ilike', 'addresse_fact', $this->addresse_fact]) ->andFilterWhere(['ilike', 'disability', $this->disability]) ->andFilterWhere(['ilike', 'passport_given_who', $this->passport_given_who]) ->andFilterWhere(['ilike', 'insurance_company', $this->insurance_company]) ->andFilterWhere(['ilike', 'insurance_number', $this->insurance_number]) ->andFilterWhere(['ilike', 'living_lpu', $this->living_lpu]) ->andFilterWhere(['ilike', 'firm', $this->firm]) ->andFilterWhere(['ilike', 'descr', $this->descr]) ->andFilterWhere(['ilike', 'file', $this->file]); return $dataProvider; }
/** * dividing patients to groups to print * @param type $id * @return type */ public function actionToprint($id) { $model = $this->findModel($id); $patients = Patients::find()->where(['firm_id' => $id])->orderBy('surname,name,patron')->all(); $pat_groups = $group = $group_ids = []; $i = 0; foreach ($patients as $j => $patient) { $group[] = $patient; $group_ids[] = $patient['id']; ++$i; if ($i == 10 || $j == count($patients) - 1) { $pat_groups[] = [$group, $group_ids]; $group = []; $group_ids = []; $i = 0; } } return $this->render('toprint', ['model' => $model, 'pat_groups' => $pat_groups]); }
/** * @param integer $id * @param integer $firm * @return boolean */ public function actionPrint($id = false, $firm = false, array $ids = []) { if ($firm) { $condition = ['firm_id' => $firm]; } elseif ($id) { $condition = ['id' => $id]; } elseif ($ids) { $condition = ['id' => $ids]; } else { return false; } $models = Patients::find()->where($condition)->all(); if (!$models) { return false; } $this->_print($models); }