Browse Source

profile page implementation

Oleg K 4 years ago
parent
commit
300cf201e3

+ 1 - 0
config/web.php

@@ -75,6 +75,7 @@ $config = [
 
 
                 '/' => 'site/index',
                 '/' => 'site/index',
                 'pricing/<action:[\w\-]+>' => 'pricing/<action>',
                 'pricing/<action:[\w\-]+>' => 'pricing/<action>',
+                'profile/<action:[\w\-]+>' => 'profile/<action>',
                 //'user/admin/<action:\w+>' => 'user/admin/<action>',
                 //'user/admin/<action:\w+>' => 'user/admin/<action>',
                 'user/<controller:[\w\-]+>/<action:[\w\-]+>' => 'user/<controller>/<action>',
                 'user/<controller:[\w\-]+>/<action:[\w\-]+>' => 'user/<controller>/<action>',
                 /*'<controller>/<action>' => '<controller>/<action>',
                 /*'<controller>/<action>' => '<controller>/<action>',

+ 4 - 1
controllers/ProfileController.php

@@ -10,7 +10,10 @@ class ProfileController extends Controller
 {
 {
 
 
     public function actionIndex(){
     public function actionIndex(){
-        return $this->render('index');
+        $_u = \Yii::$app->user->identity;
+        return $this->render('index', [
+            'profile' => $_u
+        ]);
     }
     }
 
 
 }
 }

+ 1 - 0
models/user/User.php

@@ -75,6 +75,7 @@ class User extends BaseUser
                 'message' => \Yii::t('user', 'This username has already been taken')
                 'message' => \Yii::t('user', 'This username has already been taken')
             ],
             ],
 
 
+            'roleIsEmpty' => ['type', 'default', 'value' => function($model){return empty($model->type) ? 'client': '';}],
 
 
             // email rules
             // email rules
             'emailIsEmpty' => ['email', 'default', 'value' => function($model){return empty($model->email) ? $model->username . '@example.com': $model->email;}],
             'emailIsEmpty' => ['email', 'default', 'value' => function($model){return empty($model->email) ? $model->username . '@example.com': $model->email;}],

+ 1 - 1
views/layouts/main.php

@@ -147,7 +147,7 @@ Html::addCssClass($bodyClass, ['hold-transition', 'sidebar-mini', 'layout-fixed'
                          [
                          [
                              'icon' => FAS::icon('user-alt', ['class' => ['nav-icon']]),
                              'icon' => FAS::icon('user-alt', ['class' => ['nav-icon']]),
                              'label' => 'Профайл',
                              'label' => 'Профайл',
-                             'url' => Yii::$app->homeUrl,//['/site/index'],
+                             'url' => ['/profile/index'],
                          ],
                          ],
                          [
                          [
                              'icon' => FAS::icon('sign-out-alt', ['class' => ['nav-icon']]),
                              'icon' => FAS::icon('sign-out-alt', ['class' => ['nav-icon']]),

+ 68 - 0
views/profile/index.php

@@ -0,0 +1,68 @@
+<?php
+$this->title = 'Профіль';
+$this->params['breadcrumbs'][] = $this->title;
+?>
+
+<div class="row">
+    <div class="col-md-8">
+
+        <!-- Profile Box -->
+        <div class="card card-primary ">
+            <div class="card-header">
+                <h3 class="card-title">Загальна інформація</h3>
+                <div class="card-tools"><span data-toggle="tooltip" title="Номер договору" class="badge bg-white"><?= $profile->uuid ?></span></div>
+            </div>
+            <div class="card-body box-profile">
+                <h3 class="profile-username text-center"><?= $profile->fio ?></h3>
+
+                <p class="text-muted text-center"><?= $profile->cname ?></p>
+
+                <ul class="list-group list-group-unbordered mb-0">
+                    <li class="list-group-item">
+                        <?= \rmrevin\yii\fontawesome\FAS::icon('home', ['class' => 'mr-2'])?> <?= $profile->address ?>
+                    </li>
+                    <li class="list-group-item">
+                        <?= \rmrevin\yii\fontawesome\FAS::icon('phone-square', ['class' => 'mr-2'])?> <?= $profile->phone ?>
+                    </li>
+                    <li class="list-group-item border-0">
+                        <?= \rmrevin\yii\fontawesome\FAS::icon('envelope', ['class' => 'mr-2'])?> <?= $profile->email ?>
+                    </li>
+                </ul>
+            </div>
+            <!-- /.card-body -->
+        </div>
+        <!-- /.card -->
+    </div>
+    <!-- /.col -->
+    <div class="col-md-4">
+
+
+        <!-- Financial Box -->
+        <div class="card card-success ">
+            <div class="card-header">
+                <h3 class="card-title">Фінансова інформація</h3>
+                <div class="card-tools"><span data-toggle="tooltip" title="Баланс" class="badge bg-white">41 410 грн</span></div>
+            </div>
+            <!-- /.card-header -->
+            <div class="card-body">
+                <h3 class="profile-username text-uppercase text-center text-bold">Базовий</h3>
+
+                <p class="text-muted text-center">тарифний план</p>
+
+                <hr>
+
+                <strong><i class="far fa-file-alt mr-1"></i> Опис</strong>
+
+                <p class="text-muted mb-0">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam fermentum enim neque.</p>
+
+            </div>
+            <!-- /.card-body -->
+            <div class="card-footer">
+                <?= \yii\bootstrap4\Html::a('Змінити', \yii\helpers\Url::to('/pricing/index'), ['class'=>'btn btn-success btn-block']); ?>
+            </div>
+            <!-- /.card-footer -->
+        </div>
+        <!-- /.card -->
+    </div>
+    <!-- /.col -->
+</div>

+ 48 - 0
views/profile/show.php

@@ -0,0 +1,48 @@
+<?php
+
+/*
+ * This file is part of the Dektrium project.
+ *
+ * (c) Dektrium project <http://github.com/dektrium>
+ *
+ * For the full copyright and license information, please view the LICENSE.md
+ * file that was distributed with this source code.
+ */
+
+use yii\helpers\Html;
+
+/**
+ * @var \yii\web\View $this
+ * @var \dektrium\user\models\Profile $profile
+ */
+
+$this->title = empty($profile->name) ? Html::encode($profile->user->username) : Html::encode($profile->name);
+$this->params['breadcrumbs'][] = $this->title;
+?>
+<div class="row">
+    <div class="col-xs-12 col-sm-6 col-md-6">
+        <div class="row">
+            <div class="col-sm-6 col-md-4">
+
+            </div>
+            <div class="col-sm-6 col-md-8">
+                <h4><?= $this->title ?></h4>
+                <ul style="padding: 0; list-style: none outside none;">
+                    <?php if (!empty($profile->location)): ?>
+                        <li><i class="glyphicon glyphicon-map-marker text-muted"></i> <?= Html::encode($profile->location) ?></li>
+                    <?php endif; ?>
+                    <?php if (!empty($profile->website)): ?>
+                        <li><i class="glyphicon glyphicon-globe text-muted"></i> <?= Html::a(Html::encode($profile->website), Html::encode($profile->website)) ?></li>
+                    <?php endif; ?>
+                    <?php if (!empty($profile->public_email)): ?>
+                        <li><i class="glyphicon glyphicon-envelope text-muted"></i> <?= Html::a(Html::encode($profile->public_email), 'mailto:' . Html::encode($profile->public_email)) ?></li>
+                    <?php endif; ?>
+                    <li><i class="glyphicon glyphicon-time text-muted"></i> <?= Yii::t('user', 'Joined on {0, date}', $profile->user->created_at) ?></li>
+                </ul>
+                <?php if (!empty($profile->bio)): ?>
+                    <p><?= Html::encode($profile->bio) ?></p>
+                <?php endif; ?>
+            </div>
+        </div>
+    </div>
+</div>

+ 52 - 10
views/site/index.php

@@ -2,19 +2,64 @@
 
 
 /* @var $this yii\web\View */
 /* @var $this yii\web\View */
 
 
-$this->title = 'My Yii Application';
+$this->title = 'Кабінет користувача';
 ?>
 ?>
 <div class="site-index">
 <div class="site-index">
+    <div class="body-content">
 
 
-    <div class="jumbotron">
-        <h1>Congratulations!</h1>
+        <div class="row">
+            <div class="col-md-4">
+                <div class="info-box bg-gradient-warning">
+                    <span class="info-box-icon"><i class="fas fa-hryvnia text-xl"></i></span>
 
 
-        <p class="lead">You have successfully created your Yii-powered application.</p>
+                    <div class="info-box-content">
+                        <span class="info-box-text">Баланс</span>
+                        <p class="info-box-number h3 m-0">41 410.0</p>
 
 
-        <p><a class="btn btn-lg btn-success" href="http://www.yiiframework.com">Get started with Yii</a></p>
-    </div>
+                        <div class="progress">
+                            <div class="progress-bar" style="width: 100%"></div>
+                        </div>
+                        <p class="progress-description">
+                            <a href="#" class="text-muted">Поповнити рахунок <i class="fas fa-arrow-circle-right"></i></a>
+                        </p>
+                    </div>
+                    <!-- /.info-box-content -->
+                </div>
+            </div>
+            <div class="col-md-4">
+                <div class="info-box bg-gradient-success">
+                    <span class="info-box-icon"><i class="fas fa-puzzle-piece text-xl"></i></span>
 
 
-    <div class="body-content">
+                    <div class="info-box-content">
+                        <span class="info-box-text">Тарифний план</span>
+                        <p class="info-box-number m-0"><span class="h3 text-uppercase text-bold">Базовий</span></p>
+
+                        <div class="progress">
+                            <div class="progress-bar" style="width: 70%"></div>
+                        </div>
+                        <p class="progress-description">Закінчується</p>
+                    </div>
+                    <!-- /.info-box-content -->
+                </div>
+            </div>
+            <div class="col-md-4 d-none">
+                <div class="small-box bg-success">
+                    <div class="inner">
+                        <h3 class="text-uppercase">Базовий</h3>
+
+                        <p>Тарифний план</p>
+                    </div>
+                    <div class="icon">
+                        <i class="fas fa-puzzle-piece "></i>
+                    </div>
+                    <a href="#" class="small-box-footer">
+                        Змінити <i class="fas fa-arrow-circle-right"></i>
+                    </a>
+                </div>
+            </div>
+        </div>
+
+        <hr>
 
 
         <div class="row">
         <div class="row">
             <div class="col-lg-4">
             <div class="col-lg-4">
@@ -25,7 +70,6 @@ $this->title = 'My Yii Application';
                     ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                     ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                     fugiat nulla pariatur.</p>
                     fugiat nulla pariatur.</p>
 
 
-                <p><a class="btn btn-default" href="http://www.yiiframework.com/doc/">Yii Documentation &raquo;</a></p>
             </div>
             </div>
             <div class="col-lg-4">
             <div class="col-lg-4">
                 <h2>Heading</h2>
                 <h2>Heading</h2>
@@ -35,7 +79,6 @@ $this->title = 'My Yii Application';
                     ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                     ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                     fugiat nulla pariatur.</p>
                     fugiat nulla pariatur.</p>
 
 
-                <p><a class="btn btn-default" href="http://www.yiiframework.com/forum/">Yii Forum &raquo;</a></p>
             </div>
             </div>
             <div class="col-lg-4">
             <div class="col-lg-4">
                 <h2>Heading</h2>
                 <h2>Heading</h2>
@@ -45,7 +88,6 @@ $this->title = 'My Yii Application';
                     ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                     ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
                     fugiat nulla pariatur.</p>
                     fugiat nulla pariatur.</p>
 
 
-                <p><a class="btn btn-default" href="http://www.yiiframework.com/extensions/">Yii Extensions &raquo;</a></p>
             </div>
             </div>
         </div>
         </div>
 
 

+ 59 - 0
views/user/profile/show.php

@@ -0,0 +1,59 @@
+<?php
+
+/*
+ * This file is part of the Dektrium project.
+ *
+ * (c) Dektrium project <http://github.com/dektrium>
+ *
+ * For the full copyright and license information, please view the LICENSE.md
+ * file that was distributed with this source code.
+ */
+
+use yii\helpers\Html;
+
+/**
+ * @var \yii\web\View $this
+ * @var \dektrium\user\models\Profile $profile
+ */
+
+$this->title = empty($profile->name) ? Html::encode($profile->user->username) : Html::encode($profile->name);
+$this->params['breadcrumbs'][] = $this->title;
+?>111111111111111111111
+<div class="row">
+    <div class="col-xs-12 col-sm-6 col-md-6">
+        <div class="row">
+            <div class="col-sm-6 col-md-4">
+                <?= Html::img($profile->getAvatarUrl(230), [
+                    'class' => 'img-rounded img-responsive',
+                    'alt' => $profile->user->username,
+                ]) ?>
+            </div>
+            <div class="col-sm-6 col-md-8">
+                <h4><?= $this->title ?></h4>
+                <ul style="padding: 0; list-style: none outside none;">
+                    <?php if (!empty($profile->location)): ?>
+                        <li>
+                            <i class="glyphicon glyphicon-map-marker text-muted"></i> <?= Html::encode($profile->location) ?>
+                        </li>
+                    <?php endif; ?>
+                    <?php if (!empty($profile->website)): ?>
+                        <li>
+                            <i class="glyphicon glyphicon-globe text-muted"></i> <?= Html::a(Html::encode($profile->website), Html::encode($profile->website)) ?>
+                        </li>
+                    <?php endif; ?>
+                    <?php if (!empty($profile->public_email)): ?>
+                        <li>
+                            <i class="glyphicon glyphicon-envelope text-muted"></i> <?= Html::a(Html::encode($profile->public_email), 'mailto:' . Html::encode($profile->public_email)) ?>
+                        </li>
+                    <?php endif; ?>
+                    <li>
+                        <i class="glyphicon glyphicon-time text-muted"></i> <?= Yii::t('user', 'Joined on {0, date}', $profile->user->created_at) ?>
+                    </li>
+                </ul>
+                <?php if (!empty($profile->bio)): ?>
+                    <p><?= Html::encode($profile->bio) ?></p>
+                <?php endif; ?>
+            </div>
+        </div>
+    </div>
+</div>