public function actionView() { $id = \Yii::$app->getRequest()->get()['match']; $vacancy = \Yii::$app->getRequest()->get()['vacancy']; $person = Person::findOne($id); return $this->render("view", ["person" => $person]); }
/** * Finds the model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Person::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('Страница не найдена'); } }
public function actionDelete($id) { $person = Person::findOne($id); if ($person == null) { throw new \yii\web\NotFoundHttpException('This record does not exists.'); } $person->delete(); \Yii::$app->session->addFlash('success', 'Record deleted successfully.'); header("Location: /persons/web"); exit; }
public function actionResponse() { $session = new Session(); $session->open(); $tud = $session['tud']; // First try to find id $person = Person::findOne(['tud_id' => $tud['uid']]); if ($person) { $person->updatePerson($tud); return $this->login($person); } // Then try to find emailaddress (Which is also a valid identifier) $person = Person::findOne(['emailaddress' => $tud['email']]); if ($person) { $person->updatePerson($tud); return $this->login($person); } return $this->create($tud); }
use yii\grid\GridView; use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $searchModel app\models\ProjectManagerSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Eliminar responsables de proyecto'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="project-manager-index"> <div class="well well-sm"> <h1><?php echo Html::encode($this->title); ?> </h1> </div> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'Nombre', 'value' => function ($dataProvider) { $user = \app\models\User::findOne(['id' => $dataProvider->user_id]); $person = \app\models\Person::findOne(['id' => $user->person_id]); return $person->name . ' ' . $person->lastname; }], 'organization', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['delete', 'user_id' => $model['user_id']], ['title' => Yii::t('app', 'Delete'), 'data-confirm' => Yii::t('app', '¿Estas seguro que deseas eliminar?'), 'data-method' => 'post']); }]]]]); ?> </div>
</div> <div class="col-xs-4"> <?php echo $projectM->organization; ?> <br> <?php echo $project->dependency; ?> <br> <?php echo Person::findOne(\app\models\User::findOne($projectM->user_id)->person_id)->name . ' ' . Person::findOne(\app\models\User::findOne($projectM->user_id)->person_id)->lastname; ?> <br> <?php echo Person::findOne(\app\models\User::findOne($projectM->user_id)->person_id)->name . ' ' . Person::findOne(\app\models\User::findOne($projectM->user_id)->person_id)->lastname; ?> <br> </div> </div> <div class="row" style="margin: 9em 0 0 0"> <div class="col-xs-5"> <p class="text-center">Firma y Sello</p> <p class="text-center" style="margin: 1.4em 0">_________________________</p> </div> <div class="col-xs-5"> <p class="text-center">Firma</p> <p class="text-center" style="margin: 1.4em 0">_________________________</p> </div> </div>
/** * Show homepage choices * @return mixed */ public function actionIndex() { // TODO: Real current user $user = \app\models\Person::findOne(1); return $this->render('index', ['user' => $user]); }
/** * Finds the Person model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $firstname * @param string $lastname * @param string $dob * @return Person the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($firstname, $lastname, $dob) { if (($model = Person::findOne(['firstname' => $firstname, 'lastname' => $lastname, 'dob' => $dob])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionResetPassword() { $this->layout = 'frontend'; // Redirect if not match if (!isset($_GET['auth_key'])) { return $this->redirect(Yii::$app->params['siteUrl']); } $auth_key = $_GET['auth_key']; $model = \app\models\Person::findOne(['auth_key' => $auth_key]); // Redirect if not match if (!$model) { return $this->redirect(Yii::$app->params['siteUrl']); } // Set scenario $model->scenario = 'passwordReset'; if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('passwordResetComplete'); return $this->redirect(['/login']); } return $this->render('reset-password', ['model' => $model]); }
use yii\grid\GridView; use app\models\Person; use yii\helpers\Url; $this->title = "Matches"; $this->params['breadcrumbs'][] = ['label' => 'Employee', 'url' => ['employee/index']]; $this->params['breadcrumbs'][] = $this->title; ?> <h1> <?php echo $this->title; ?> </h1> <div class="vacancy-overview"> <?php echo GridView::widget(array('dataProvider' => $provider, 'columns' => [['attribute' => 'Match Score', 'value' => 'score'], ['attribute' => 'Name', 'value' => 'name'], ['attribute' => 'Email', 'value' => 'emailaddress'], ['attribute' => 'Review AVG', 'content' => function ($model, $key, $index, $column) { $person = Person::findOne($model['id']); return $person->getReviewScore(); }]], 'rowOptions' => function ($model, $key, $index, $grid) { return ['data-id' => $model['id']]; })); ?> </div> <style> .grid-view tbody tr:hover { cursor:pointer; text-decoration: underline; }
public function actionPrint() { $person = null; $billPersonal = null; if (isset($_GET['p'], $_GET['s'])) { $ids = explode(',', $_GET['s']); $person = Person::findOne($_GET['p']); $billPersonal = BillPersonal::getAsociated($_GET['p'], $ids); if ($person !== null && count($billPersonal) > 0) { $content = $this->renderPartial('print', ['person' => $person, 'billPersonal' => $billPersonal]); $pdf = new Pdf(['mode' => Pdf::MODE_UTF8, 'format' => Pdf::FORMAT_A4, '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' => Yii::t('app', 'Bill') . ' ' . Yii::t('app', 'Report')], 'methods' => ['SetHeader' => [Yii::t('app', 'Summary')], 'SetFooter' => ['{PAGENO}']]]); return $pdf->render(); } } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @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()); } }
public function actionDelete($id) { Person::findOne($id)->delete(); return $this->redirect(['/dashboard']); }
public function actionList($id, $list) { $model = $this->findModel($id); // Get segment parameter and apply $segment = Yii::$app->request->get('segment'); // Get role parameter and apply $role = Yii::$app->request->get('role'); // Get related model (people) $query = $model->getPeople($list, $segment, $role); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 250]]); // Get list text from list id's if ($list == 1) { $list_type = 'Availability'; } if ($list == 2) { $list_type = 'Final'; } //Check if list action was submitted if ($selection = Yii::$app->request->post('selection')) { // Figure out what needs to be done $action = Yii::$app->request->post('action'); switch ($action) { // Move to final list case 'list-move': foreach ($selection as $person) { $query = new Query(); $query->createCommand()->update('person_project', ['list' => 2], ['user_id' => $person, 'project_id' => $id, 'list' => $list])->execute(); } return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); break; // Send Message // Send Message case 'send-message': // Check if a file was uploaded // Loop through checked users foreach ($selection as $person) { $person_model = Person::findOne($person); $message = new \app\models\Message(); $message->user_id = $person_model->id; $message->project_id = $id; $message->message = Yii::$app->request->post('message'); $message->attachment = \yii\web\UploadedFile::getInstanceByName('attachment'); $message->time = time(); $message->status = 1; $message->type = 'email'; //Set email to proper address / check if a family member and send there instead $email = $person_model->email; if (!$email && $person_model->family_id) { $family_leader = Person::findOne($person_model->family_id); $email = $family_leader->email; } if ($message->save() && $email && filter_var($email, FILTER_VALIDATE_EMAIL)) { // Create mail item $mail = Yii::$app->mailer->compose('/mail/message', ['message' => $message, 'person' => $person_model])->setTo($email)->setSubject('New Message From FrontRunner Casting'); // Set from address if ($model->reply_to) { $mail->setFrom($model->reply_to); } else { $mail->setFrom('*****@*****.**'); } // Add mail item to array $messages[] = $mail; } } //endforeach // Try to send messages if (isset($messages)) { try { Yii::$app->mailer->sendMultiple($messages); Yii::$app->session->setFlash('messagesSent'); } catch (\Swift_SwiftException $exception) { Yii::$app->session->setFlash('error', 'Messages could not be sent. Please try again.'); } } // Redirect back to list return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); break; // Basic text message // Basic text message case 'send-text-message': Yii::$app->session->setFlash('messagesSent'); $message = Yii::$app->request->post('text-message'); // Send Message with twilio $model->sendText($selection, $message); // Redirect back to list return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); break; // Send availability check email // Send availability check email case 'availability-check': foreach ($selection as $person) { // Change status to requested $query = new Query(); $query->createCommand()->update('person_project', ['availability' => 2], ['user_id' => $person, 'project_id' => $id, 'list' => $list])->execute(); // Get person model $person_model = Person::findOne($person); // Send Availability Check email $message = new \app\models\Message(); $message->user_id = $person_model->id; $message->project_id = $id; $message->message = Yii::$app->request->post('availability-message'); $message->attachment = \yii\web\UploadedFile::getInstanceByName('attachment'); $message->time = time(); $message->status = 3; $message->type = 'email'; // Insert specific available / unavailable links for user $person_project_id = PersonProject::find()->where(['project_id' => $id, 'user_id' => $person_model->id])->one(); $message->message = str_replace('[person_project_id]', $person_project_id->id, $message->message); //Set email to proper address / check if a family member and send there instead $email = $person_model->email; if (!$email && $person_model->family_id) { $family_leader = Person::findOne($person_model->family_id); $email = $family_leader->email; } if ($message->save() && $person_model && $email && filter_var($email, FILTER_VALIDATE_EMAIL)) { // Create mail item $mail = Yii::$app->mailer->compose('/mail/message', ['message' => $message, 'person' => $person_model])->setTo($email)->setSubject('FrontRunner Casting - Availability Request for ' . $person_model->fname . ' ' . $person_model->lname); // Set from address if ($model->reply_to) { $mail->setFrom($model->reply_to); } else { $mail->setFrom('*****@*****.**'); } // Add mail item to array $messages[] = $mail; } //end if message is valid and saved } //end for each // Try to send messages if (isset($messages)) { try { Yii::$app->mailer->sendMultiple($messages); Yii::$app->session->setFlash('messagesSent'); } catch (\Swift_SwiftException $exception) { Yii::$app->session->setFlash('error', 'Messages could not be sent. Please try again. ' . $exception); } } // Redirect back to list return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); break; // Update database to show requested // Update database to show requested case 'confirmation-check': foreach ($selection as $person) { $query = new Query(); $query->createCommand()->update('person_project', ['confirmed' => 2], ['user_id' => $person, 'project_id' => $id, 'list' => $list])->execute(); $person_model = Person::findOne($person); // Send Availability Check email $message = new \app\models\Message(); $message->user_id = $person_model->id; $message->project_id = $id; $message->message = Yii::$app->request->post('confirmation-message'); $message->attachment = \yii\web\UploadedFile::getInstanceByName('confirmation-attachment'); $message->time = time(); $message->status = 3; $message->type = 'email'; // Insert specific available / unavailable links for user $person_project_id = PersonProject::find()->where(['project_id' => $id, 'user_id' => $person_model->id])->one(); $message->message = str_replace('[person_project_id]', $person_project_id->id, $message->message); //Set email to proper address / check if a family member and send there instead $email = $person_model->email; if (!$email && $person_model->family_id) { $family_leader = Person::findOne($person_model->family_id); $email = $family_leader->email; } if ($message->save() && $email && filter_var($email, FILTER_VALIDATE_EMAIL)) { // Create mail item $mail = Yii::$app->mailer->compose('/mail/message', ['message' => $message, 'person' => $person_model])->setTo($email)->setSubject('FrontRunner Casting - Confirmation Request for ' . $person_model->fname . ' ' . $person_model->lname); // Set from address if ($model->reply_to) { $mail->setFrom($model->reply_to); } else { $mail->setFrom('*****@*****.**'); } // Add mail item to array $messages[] = $mail; } // Try to send messages if (isset($messages)) { try { Yii::$app->mailer->sendMultiple($messages); Yii::$app->session->setFlash('messagesSent'); } catch (\Swift_SwiftException $exception) { Yii::$app->session->setFlash('error', 'Messages could not be sent. Please try again. ' . $exception); } } } // Redirect back to list return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); break; // Text message confirmation check // Text message confirmation check case 'confirmation-check-text': Yii::$app->session->setFlash('messagesSent'); // Send Message with twilio $model->sendText(Yii::$app->request->post('confirmation-text-message')); // Redirect back to list return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); break; // Manually set as available // Manually set as available case 'availability-available': foreach ($selection as $person) { $query = new Query(); $query->createCommand()->update('person_project', ['availability' => 3], ['user_id' => $person, 'project_id' => $id, 'list' => $list])->execute(); } return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); break; // Manually set as unavailable // Manually set as unavailable case 'availability-unavailable': foreach ($selection as $person) { $query = new Query(); $query->createCommand()->update('person_project', ['availability' => 4], ['user_id' => $person, 'project_id' => $id, 'list' => $list])->execute(); } return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); break; // Manually set as confirmed // Manually set as confirmed case 'confirmation-confirmed': foreach ($selection as $person) { $query = new Query(); $query->createCommand()->update('person_project', ['confirmed' => 1], ['user_id' => $person, 'project_id' => $id, 'list' => $list])->execute(); } return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); break; // Manually set as confirmed // Manually set as confirmed case 'confirmation-unconfirmed': foreach ($selection as $person) { $query = new Query(); $query->createCommand()->update('person_project', ['confirmed' => 0], ['user_id' => $person, 'project_id' => $id, 'list' => $list])->execute(); } return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); break; // Move to another project // Move to another project case 'project-move': foreach ($selection as $person) { $person_project = new \app\models\PersonProject(); $person_project->user_id = $person; $person_project->project_id = Yii::$app->request->post('sent-to-project'); $person_project->list = 1; $person_project->availability = 1; if ($person_project->save()) { Yii::$app->session->setFlash('peopleMoved'); } } // Redirect back to list return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); # Send Availability Check email break; // Remove from list // Remove from list case 'list-remove': foreach ($selection as $person) { $query = new Query(); $query->createCommand()->delete('person_project', ['user_id' => $person, 'project_id' => $id, 'list' => $list])->execute(); } return $this->redirect(['/project/list', 'id' => $id, 'list' => $list]); break; } } return $this->render('list', ['model' => $model, 'dataProvider' => $dataProvider, 'list_type' => $list_type, 'list_type_id' => $list]); }
/* @var $searchModel app\models\SocialServiceManagerSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Eliminar responsables de servicio social'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="social-service-manager-index"> <div class="well well-sm"> <h1><?php echo Html::encode($this->title); ?> </h1> </div> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'Nombre', 'value' => function ($dataProvider) { $user = User::findOne(['id' => $dataProvider->user_id]); $person = Person::findOne(['id' => $user->person_id]); return $person->name . ' ' . $person->lastname; }], ['attribute' => 'Facultad', 'value' => function ($dataProvider) { $faculty = \app\models\Faculty::findOne(['id' => $dataProvider->faculty_id]); //$person = Person::findOne (['id' => $user->person_id]); return $faculty->name; }], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['delete' => function ($url, $model) { return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['delete', 'user_id' => $model['user_id']], ['title' => Yii::t('app', 'Delete'), 'data-confirm' => Yii::t('app', '¿Estas seguro que deseas eliminar?'), 'data-method' => 'post']); }]]]]); ?> </div>
/** * @param ActiveDataProvider $dataProvider * @return ActiveDataProvider */ private function setPersonName($dataProvider) { $copy = clone $dataProvider; for ($i = 0; $i < sizeof($dataProvider->getModels()); $i++) { $userId = $dataProvider->getModels()[$i]['student']['user_id']; $user = User::findOne($userId); $person = Person::findOne($user['person_id']); $copy->getModels()[$i]['student']['user_id'] = $person['name']; } return $copy; }
/** * Finds the Person model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Person the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Person::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
echo $this->render('navAdmin'); } else { if (Yii::$app->user->can('projectManager')) { echo $this->render('navProjectManager'); } else { if (Yii::$app->user->can('socialServiceManager')) { echo $this->render('navSocialServiceManager'); } else { if (Yii::$app->user->can('student')) { echo $this->render('navStudent'); } } } } } $navItems = [!Yii::$app->user->isGuest ? ['label' => "Bienvenido: " . Person::findOne(User::findOne(Yii::$app->user->id)->person_id)->name, 'url' => Url::to(['site/index'])] : ['label' => '', 'url' => ['site/index']]]; if (Yii::$app->user->can('student') or Yii::$app->user->can('projectManager')) { $arrayNotifications = []; if ($notifications->count() == 0) { array_push($arrayNotifications, ['label' => 'No tienes nuevas notificaciones', 'options' => ['class' => 'content']]); } else { foreach ($notifications->all() as $notification) { array_push($arrayNotifications, ['label' => $notification->description, 'url' => Url::to(['/site/view-notification', 'id' => $notification->id])]); } } array_push($navItems, ['label' => $notifications->count() == 0 ? 'Notificaciones' : 'Notificaciones <span class="badge">' . $notifications->count() . '</span>', 'encode' => false, 'items' => $arrayNotifications]); } array_push($navItems, Yii::$app->user->isGuest ? ['label' => 'Iniciar sesión', 'url' => ['/user/security/login']] : ['label' => 'Cerrar sesión (' . Yii::$app->user->identity->username . ')', 'url' => ['/user/security/logout'], 'linkOptions' => ['data-method' => 'post']]); echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $navItems]); NavBar::end(); ?>