/** * Profile settings. * @return string|\yii\web\Response * @throws NotFoundHttpException */ public function actionSettings() { $id = Yii::$app->user->identity->getId(); // user ID. /** @var userProfile $model */ $model = UserProfile::find()->where(['user_id' => $id])->one(); if (!$model) { throw new NotFoundHttpException('Profile is not found!'); } // previous avatar name: $oldAvatar = $model->avatar; if ($model->load(Yii::$app->request->post())) { // process uploaded image file instance: $image = $model->uploadImage($id); // revert back if no valid file instance uploaded: if ($image === false) { $model->avatar = $oldAvatar; } if ($model->save()) { if ($image !== false) { // upload only if valid uploaded file instance found: $path = Yii::getAlias('@avatars'); $name = $id . '.' . $image->extension; $image->saveAs($path . DIRECTORY_SEPARATOR . $name); $model->avatar = $name; } Yii::$app->session->setFlash('message', 'Your profile has been updated!'); return $this->refresh(); } else { // error in saving model: Yii::$app->session->setFlash('error', 'AAn error occurred when saving data :('); } } return $this->render('index', ['model' => $model, 'blockName' => 'settings']); }
?> <div class="wrap"> <?php NavBar::begin(['brandLabel' => Yii::$app->name, 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]); if (!Yii::$app->user->isGuest) { $MainMenu = [['label' => Yii::t('app', 'Patients'), 'options' => ['class' => 'dropdown'], 'linkOptions' => ['class' => 'dropdown', 'data-toggle' => 'dropdown'], 'items' => [['label' => Yii::t('app', 'Ledger'), 'url' => ['/patients/ledger']], ['label' => Yii::t('app', 'List'), 'url' => ['/patients/list']], ['label' => Yii::t('app', 'New'), 'url' => ['/patients/new']], ['label' => Yii::t('app', 'Search'), 'url' => ['/patients/search']]]], ['label' => Yii::t('app', 'Billing'), 'options' => ['class' => 'dropdown'], 'linkOptions' => ['class' => 'dropdown', 'data-toggle' => 'dropdown'], 'items' => [['label' => Yii::t('app', 'Manager'), 'url' => ['/billing/manager']], ['label' => Yii::t('app', 'Payments'), 'url' => ['/billing/payments']], ['label' => Yii::t('app', 'Statements'), 'url' => ['/billing/statements']], ['label' => Yii::t('app', 'Copays Received'), 'url' => ['/billing/copays-received']]]], ['label' => Yii::t('app', 'Messages'), 'url' => ['/messages/index']], ['label' => Yii::t('app', 'Reports'), 'options' => ['class' => 'dropdown'], 'linkOptions' => ['class' => 'dropdown', 'data-toggle' => 'dropdown'], 'items' => [['label' => Yii::t('app', 'List'), 'url' => ['/reports/list']], ['label' => Yii::t('app', 'Eligibility'), 'url' => ['/reports/eligibility']], ['label' => Yii::t('app', 'Eligibility Response'), 'url' => ['/reports/eligibility-response']]]], ['label' => Yii::t('app', 'News'), 'url' => ['/news/index']]]; $AdminMenu = [['label' => Yii::t('app', 'Administration'), 'options' => ['class' => 'dropdown'], 'linkOptions' => ['class' => 'dropdown', 'data-toggle' => 'dropdown'], 'items' => [['label' => Yii::t('app', 'Address Book'), 'url' => ['/administration/address-book']], ['label' => Yii::t('app', 'Codes'), 'url' => ['/administration/codes']], ['label' => Yii::t('app', 'Facilities'), 'url' => ['/administration/facilities']], ['label' => Yii::t('app', 'Globals'), 'url' => ['/administration/globals']], ['label' => Yii::t('app', 'HL7 Import'), 'url' => ['/administration/hl7-import']], ['label' => Yii::t('app', 'Past Encounters List'), 'url' => ['/administration/past-encounters-list']], ['label' => Yii::t('app', 'Patient Reminders'), 'url' => ['/administration/patient-reminders']], ['label' => Yii::t('app', 'Practice'), 'url' => ['/administration/practice']]]]]; // We would add extra functionality to the user menu. If the user // has pre-filled the profile we would replace the username with // the full name from the DB. //Gets the username $usrname = Yii::$app->user->identity->username; //Check for full name $usrreal = ''; $usertmp = UserProfile::find()->where(['user_id' => Yii::$app->user->identity->id])->one(); $usrreal = $usertmp->fname . ' ' . $usertmp->lname; //Setup name acording to DB result. if ($usrreal) { $usrname = $usrreal; } $UserMenu = [['label' => Yii::t('app', 'Welcome, <strong>{username}</strong>!', ['username' => $usrname]), 'options' => ['class' => 'dropdown'], 'linkOptions' => ['class' => 'dropdown', 'data-toggle' => 'dropdown'], 'items' => [['label' => Yii::t('app', 'My Profile'), 'url' => ['/user-profile/view']], ['label' => Yii::t('app', 'Password'), 'url' => ['/pgmbilling/request-password-reset']], ['label' => Yii::t('app', 'Preferences'), 'url' => ['/user-preset/view']], ['label' => Yii::t('app', '<b class="fa fa-power-off"></b> Logout'), 'url' => ['/pgmbilling/logout'], 'linkOptions' => ['data-method' => 'post']]]]]; echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-left dropdown'], 'encodeLabels' => false, 'activateParents' => true, 'items' => $MainMenu]); echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right dropdown'], 'encodeLabels' => false, 'activateParents' => true, 'items' => $AdminMenu]); echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right dropdown'], 'encodeLabels' => false, 'activateParents' => true, 'items' => $UserMenu]); } NavBar::end(); ?> <div class="container">
/** * Lists all UserProfile models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => UserProfile::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }