/**
  * Finds the ProjectManager model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProjectManager the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProjectManager::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #2
0
 /**
  * Figure it out the person role and returns an
  * object of that type.
  */
 public function getUserRole()
 {
     $rol = null;
     if (Yii::$app->user->can('projectManager')) {
         return $rol = ProjectManager::findOne(['user_id' => $this->id]);
     }
     if (Yii::$app->user->can('socialServiceManager')) {
         return $rol = SocialServiceManager::findOne(['user_id' => $this->id]);
     }
     if (Yii::$app->user->can('student')) {
         return $rol = Student::findOne(['user_id' => $this->id]);
     }
     return $rol;
 }
 /**
  * @return mixed|\yii\web\Response
  */
 public function actionPrintEvidenceReport()
 {
     $student = Student::findOne(['user_id' => Yii::$app->user->id]);
     date_default_timezone_set("America/Mexico_City");
     try {
         $searchModel = new StudentEvidenceSearch();
         $dataProviderAccepted = $searchModel->search(Yii::$app->request->queryParams, StudentEvidence::$ACCEPTED);
         $registration = Registration::findOne(['student_id' => $student->id]);
         $person = Person::findOne(User::findOne(Yii::$app->user->id)->person_id);
         $project = Project::findOne($registration->project_id);
         $projectM = ProjectManager::findOne($project->manager_id);
         // get your HTML raw content without any layouts or scripts
         $content = $this->render('studentEvidencePDF', ['registration' => $registration, 'student' => $student, 'person' => $person, 'project' => $project, 'projectM' => $projectM, 'searchModel' => $searchModel, 'dataProviderAccepted' => $dataProviderAccepted]);
         $formatter = \Yii::$app->formatter;
         // setup kartik\mpdf\Pdf component
         $pdf = new Pdf(['mode' => Pdf::MODE_UTF8, 'format' => Pdf::FORMAT_LETTER, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => 'Reporte de avances'], 'methods' => ['SetFooter' => ['Fecha de expedición: ' . $formatter->asDate(date('d-F-Y'))]]]);
         // return the pdf output as per the destination setting
         return $pdf->render();
     } catch (InvalidConfigException $e) {
         Yii::$app->getSession()->setFlash('danger', 'No tienes proyectos asignados');
         return $this->redirect(Url::home());
     }
 }