/** * Deletes an existing Clients model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param string $id * @return mixed */ public function actionDelete($id) { if ($this->findModel($id)->delete()) { Tasks::deleteAll('client = :client', [':client' => $id]); Contacts::deleteAll('client = :client', [':client' => $id]); } return $this->redirect(['index']); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Contacts::find(); $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, 'client' => $this->client]); $query->andFilterWhere(['like', 'fio', $this->fio])->andFilterWhere(['like', 'dolg', $this->dolg])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Contacts::find(); $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(['contact_id' => $this->contact_id, 'datetime' => $this->datetime, 'user_id' => $this->user_id, 'organization_id' => $this->organization_id, 'person_id' => $this->person_id]); $query->andFilterWhere(['like', 'topic', $this->topic])->andFilterWhere(['like', 'notes', $this->notes])->andFilterWhere(['like', 'result', $this->result])->andFilterWhere(['like', 'result_description', $this->result_description]); return $dataProvider; }
public function record() { global $mail; $result = Contacts::recordContact($_POST); if ($result) { $message = "Nome: {$_POST['name']}\nAssunto: {$_POST['subject']}\nComentário:\n{$_POST['comment']}"; mail($mail['email'], $mail['subject'], $message); } if ($result) { $this->view('success'); } else { $this->view('error'); } }
/** * @return \yii\db\ActiveQuery */ public function getContacts() { return $this->hasMany(Contacts::className(), ['organization_id' => 'organization_id']); }
/** * @return \yii\db\ActiveQuery */ public function getContacts() { return $this->hasMany(Contacts::className(), ['C_ID' => 'C_ID']); }
/** * Finds the Contacts model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return Contacts the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Contacts::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Finds the Contacts model based on its primary key value. * @param integer $id * @return Contacts the loaded model */ protected function findModel($id) { if (($model = Contacts::find()->where(['idContact' => $id])->one()) !== null) { return $model; } else { return false; } }
public function delete($idContact) { $result = Contacts::deleteContact($idContact); $this->view('admin'); }
/** * @return \yii\db\ActiveQuery */ public function getResultedInContact() { return $this->hasOne(Contacts::className(), ['contact_id' => 'resulted_in_contact_id']); }
public function getContacts() { return $this->hasMany(Contacts::className(), ['client' => 'id']); }