Initial commit
This commit is contained in:
41
frontend/views/user/_form.php
Normal file
41
frontend/views/user/_form.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\Html;
|
||||
use yii\bootstrap5\ActiveForm;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var common\models\User $model */
|
||||
/** @var array $salesAgents */
|
||||
/** @var yii\widgets\ActiveForm $form */
|
||||
?>
|
||||
|
||||
<div class="user-form">
|
||||
|
||||
<?php
|
||||
$form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'email')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'status')->dropDownList($model->getStatusName(true)) ?>
|
||||
|
||||
<?= $form->field($model, 'role')->dropDownList(
|
||||
ArrayHelper::map(Yii::$app->authManager->getRoles(), 'name', 'name'),
|
||||
['prompt' => '-- Select role --']
|
||||
) ?>
|
||||
|
||||
<?= $form->field($model, 'sales_agent_id')->label(Yii::t('app', 'Sales Agent'))->dropDownList(
|
||||
$salesAgents,
|
||||
['prompt' => '-- Select Sales Agent --']
|
||||
) ?>
|
||||
|
||||
<br/>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
24
frontend/views/user/create.php
Normal file
24
frontend/views/user/create.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var common\models\User $model */
|
||||
/** @var array $salesAgents */
|
||||
|
||||
$this->title = Yii::t('app', 'Create User');
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Users'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="user-create">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>A new password will be emailed to the user upon creation. The user will not need to validate their email address.</p>
|
||||
<p>If you want them to validate their email, have them sign up on the home page.</p>
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
'salesAgents' => $salesAgents,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
97
frontend/views/user/index.php
Normal file
97
frontend/views/user/index.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
use common\models\User;
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
use yii\grid\ActionColumn;
|
||||
use yii\grid\GridView;
|
||||
use common\models\SalesAgent;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var yii\data\ActiveDataProvider $dataProvider */
|
||||
/** @var common\models\search\User $searchModel */
|
||||
|
||||
$this->title = Yii::t('app', 'Users');
|
||||
?>
|
||||
<div class="user-index container1">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= Html::a(Yii::t('app', 'Create User'), ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'layout' => "{items}\n{summary}{pager}",
|
||||
'tableOptions' => [
|
||||
'class' => 'custom-table',
|
||||
],
|
||||
'headerRowOptions' => [
|
||||
'class' => 'table-header',
|
||||
],
|
||||
'rowOptions' => [
|
||||
'class' => 'align-middle',
|
||||
],
|
||||
'columns' => [
|
||||
'email:email',
|
||||
[
|
||||
'attribute' => 'status',
|
||||
'label' => 'Status',
|
||||
'value' => function ($model) {
|
||||
return $model->getStatusName();
|
||||
},
|
||||
'filter' => [
|
||||
User::STATUS_ACTIVE => 'Active',
|
||||
User::STATUS_INACTIVE => 'Inactive',
|
||||
User::STATUS_UNVERIFIED => 'Unverified',
|
||||
User::STATUS_VERIFIED => 'Verified (not active)',
|
||||
],
|
||||
],
|
||||
[
|
||||
'attribute' => 'salesAgentName',
|
||||
'label' => Yii::t('app', 'Sales Agent'),
|
||||
'format' => 'raw',
|
||||
'value' => function ($model) {
|
||||
return $model->salesAgent
|
||||
? Html::a($model->salesAgent->name, Url::to(['sales-agent/view', 'id' => $model->salesAgent->id]))
|
||||
: Yii::t('app', 'None assigned');
|
||||
},
|
||||
'filter' => \yii\helpers\ArrayHelper::map(SalesAgent::find()->all(), 'name', 'name'),
|
||||
],
|
||||
[
|
||||
'attribute' => 'role',
|
||||
'label' => 'Role',
|
||||
'value' => function ($model) {
|
||||
$roles = Yii::$app->authManager->getRolesByUser($model->id);
|
||||
return !empty($roles) ? reset($roles)->name : null;
|
||||
},
|
||||
'filter' => \yii\helpers\ArrayHelper::map(
|
||||
Yii::$app->authManager->getRoles(),
|
||||
'name',
|
||||
'name'
|
||||
),
|
||||
],
|
||||
'created_at:datetime',
|
||||
'updated_at:datetime',
|
||||
[
|
||||
'class' => ActionColumn::class,
|
||||
'urlCreator' => function ($action, User $model, $key, $index, $column) {
|
||||
return Url::toRoute([$action, 'id' => $model->id]);
|
||||
},
|
||||
],
|
||||
],
|
||||
'pager' => [
|
||||
'class' => 'yii\widgets\LinkPager',
|
||||
'nextPageLabel' => '►',
|
||||
'prevPageLabel' => '◄',
|
||||
'firstPageLabel' => 'First',
|
||||
'lastPageLabel' => 'Last',
|
||||
'maxButtonCount' => 5,
|
||||
'options' => ['class' => 'pagination'],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
</div>
|
||||
22
frontend/views/user/update.php
Normal file
22
frontend/views/user/update.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var common\models\User $model */
|
||||
/** @var array $salesAgents */
|
||||
|
||||
$this->title = Yii::t('app', 'Update User: {name}', [
|
||||
'name' => $model->email,
|
||||
]);
|
||||
?>
|
||||
<div class="user-update container1">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
'salesAgents' => $salesAgents
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
51
frontend/views/user/view.php
Normal file
51
frontend/views/user/view.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\helpers\Url;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/** @var yii\web\View $this */
|
||||
/** @var common\models\User $model */
|
||||
|
||||
$this->title = $model->email;
|
||||
\yii\web\YiiAsset::register($this);
|
||||
?>
|
||||
|
||||
<div class="user-view mt-3">
|
||||
<div class="card shadow-sm rounded-lg p-4">
|
||||
<h2 class="mb-3"><?= Html::encode($this->title) ?></h2>
|
||||
|
||||
<div class="d-flex gap-2 mb-4">
|
||||
<?php if (Yii::$app->user->can('updateDelete')): ?>
|
||||
<?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
|
||||
'class' => 'btn btn-danger',
|
||||
'data' => [
|
||||
'confirm' => Yii::t('app', 'Are you sure you want to delete this user?'),
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<p><strong>ID:</strong> <?= Html::encode($model->id) ?></p>
|
||||
<p><strong>Email:</strong> <?= Html::encode($model->email) ?></p>
|
||||
<p><strong>Status:</strong> <?= Html::encode($model->statusName) ?></p>
|
||||
<p><strong>Role:</strong> <?= Html::encode($model->role) ?></p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<p><strong>Sales Agent:</strong>
|
||||
<?php if (!empty($model->salesAgent)): ?>
|
||||
<?= Html::a(Html::encode($model->salesAgent->name), Url::to(['sales-agent/view', 'id' => $model->salesAgent->id]), ['class' => 'text-decoration-none']) ?>
|
||||
<?php else: ?>
|
||||
<?= Yii::t('app', 'None assigned') ?>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
<p><strong>Created At:</strong> <?= Yii::$app->formatter->asDatetime($model->created_at) ?></p>
|
||||
<p><strong>Updated At:</strong> <?= Yii::$app->formatter->asDatetime($model->updated_at) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user