/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = EmpDocs::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['emp_docs_id' => $this->emp_docs_id, 'emp_docs_category_id' => $this->emp_docs_category_id, 'emp_docs_submited_at' => $this->emp_docs_submited_at, 'emp_docs_status' => $this->emp_docs_status, 'emp_docs_emp_master_id' => $this->emp_docs_emp_master_id, 'created_by' => $this->created_by]); $query->andFilterWhere(['like', 'emp_docs_details', $this->emp_docs_details])->andFilterWhere(['like', 'emp_docs_path', $this->emp_docs_path]); return $dataProvider; }
public function actionEmployeeProfilePdf($eid) { $nationality = $empAdd = []; $empMaster = EmpMaster::findOne($eid); $empDocs = EmpDocs::find()->where(['emp_docs_emp_master_id' => $eid])->join('join', 'document_category dc', 'dc.doc_category_id = emp_docs_category_id AND dc.is_status <> 2')->all(); $empInfo = EmpInfo::find()->where(['emp_info_emp_master_id' => $eid])->one(); if ($empMaster->emp_master_nationality_id !== null) { $nationality = Nationality::findOne($empMaster->emp_master_nationality_id)->nationality_name; } if ($empMaster->emp_master_emp_address_id !== null) { $empAdd = EmpAddress::findOne($empMaster->emp_master_emp_address_id); } $html = $this->renderPartial('/emp-master/empprofilepdf', ['empDocs' => $empDocs, 'empMaster' => $empMaster, 'empInfo' => $empInfo, 'nationality' => $nationality, 'empAdd' => $empAdd]); $fName = $empInfo->emp_first_name . "_" . $empInfo->emp_last_name . "_" . date('Ymd_His'); return Yii::$app->pdf->exportData(Yii::t('emp', 'Employee Profile'), $fName, $html); }
/** * Finds the EmpDocs model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return EmpDocs the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = EmpDocs::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getEmpDocs() { return $this->hasMany(EmpDocs::className(), ['emp_docs_emp_master_id' => 'emp_master_id']); }
public function actionDeleteDoc($emp_doc_id) { $emp_docs = EmpDocs::findOne($emp_doc_id); if ($emp_docs !== NULL) { $emp_docs->delete(); } else { throw new NotFoundHttpException('The requested page does not exist.'); } return $this->redirect(['view', 'id' => $emp_docs->emp_docs_emp_master_id, '#' => 'documents']); }