/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = StuDocs::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(['stu_docs_id' => $this->stu_docs_id, 'stu_docs_category_id' => $this->stu_docs_category_id, 'stu_docs_submited_at' => $this->stu_docs_submited_at, 'stu_docs_status' => $this->stu_docs_status, 'stu_docs_stu_master_id' => $this->stu_docs_stu_master_id, 'created_by' => $this->created_by]); $query->andFilterWhere(['like', 'stu_docs_details', $this->stu_docs_details])->andFilterWhere(['like', 'stu_docs_path', $this->stu_docs_path]); return $dataProvider; }
public function actionStudentProfilePdf($sid) { $nationality = $stuAdd = []; $stuMaster = StuMaster::findOne($sid); $stuDocs = StuDocs::find()->where(['stu_docs_stu_master_id' => $sid])->join('join', 'document_category dc', 'dc.doc_category_id = stu_docs_category_id AND dc.is_status <> 2')->all(); $stuInfo = StuInfo::find()->where(['stu_info_stu_master_id' => $sid])->one(); $stuCourse = Courses::findOne($stuMaster->stu_master_course_id); $stuBatch = Batches::findOne($stuMaster->stu_master_batch_id); $stuSection = Section::findOne($stuMaster->stu_master_section_id); $stuGuard = StuGuardians::findAll(['guardia_stu_master_id' => $sid]); $sDocs = new StuDocs(); if ($stuMaster->stu_master_nationality_id !== null) { $nationality = Nationality::findOne($stuMaster->stu_master_nationality_id)->nationality_name; } if ($stuMaster->stu_master_stu_address_id !== null) { $stuAdd = StuAddress::findOne($stuMaster->stu_master_stu_address_id); } $html = $this->renderPartial('/stu-master/stuprofilepdf', ['stuDocs' => $stuDocs, 'stuMaster' => $stuMaster, 'stuInfo' => $stuInfo, 'nationality' => $nationality, 'stuBatch' => $stuBatch, 'stuCourse' => $stuCourse, 'stuSection' => $stuSection, 'stuAdd' => $stuAdd, 'stuGuard' => $stuGuard, 'sDocs' => $sDocs]); $fName = $stuInfo->stu_first_name . "_" . $stuInfo->stu_last_name . "_" . date('Ymd-His'); return Yii::$app->pdf->exportData(Yii::t('report', 'Student Report'), $fName, $html); }
public function actionDocsDownload($stu_doc_id) { $path = Yii::getAlias('@webroot') . '/data/stu_docs/'; $model = StuDocs::find()->where(['stu_docs_id' => $stu_doc_id])->one(); $file = $path . $model->stu_docs_path; $ext = substr(strrchr($model->stu_docs_path, '.'), 1); if (!empty($model) && file_exists($file)) { return Yii::$app->response->sendFile($file, date('Y-m-dHis') . "." . $ext); } else { throw new NotFoundHttpException('The requested page does not exist.'); } }