Merge pull request #19 from apuc/user_generate

User generate
This commit is contained in:
kavalar 2019-11-15 13:30:50 +02:00 committed by GitHub
commit c9baee8d5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 517 additions and 249 deletions

View File

@ -69,7 +69,7 @@ return [
'enablePrettyUrl' => true, 'enablePrettyUrl' => true,
'showScriptName' => false, 'showScriptName' => false,
'rules' => [ 'rules' => [
'' => '/card/user-card' '' => '/card/user-card',
], ],
], ],

View File

@ -5,6 +5,7 @@ namespace backend\modules\card\controllers;
use common\classes\Debug; use common\classes\Debug;
use common\models\AdditionalFields; use common\models\AdditionalFields;
use common\models\CardSkill; use common\models\CardSkill;
use common\models\User;
use common\models\FieldsValue; use common\models\FieldsValue;
use common\models\FieldsValueNew; use common\models\FieldsValueNew;
use common\models\Status; use common\models\Status;
@ -71,10 +72,14 @@ class UserCardController extends Controller
$skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all(); $skills = CardSkill::find()->where(['card_id' => $id])->with('skill')->all();
$id_current_user = $this->findModel($id)->id_user;
return $this->render('view', [ return $this->render('view', [
'model' => $this->findModel($id), 'model' => $this->findModel($id),
'modelFildValue' => $dataProvider, 'modelFildValue' => $dataProvider,
'skills' => $skills, 'skills' => $skills,
// 'userData' => $userData,
'userData' => User::findOne($id_current_user),
]); ]);
} }
@ -88,6 +93,8 @@ class UserCardController extends Controller
$model = new UserCard(); $model = new UserCard();
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
UserCard::generateUserForUserCard($model->id);
return $this->redirect(['view', 'id' => $model->id]); return $this->redirect(['view', 'id' => $model->id]);
} }
@ -134,6 +141,17 @@ class UserCardController extends Controller
return $this->redirect(['index']); return $this->redirect(['index']);
} }
/**
* Lists all UserCard models.
* @return mixed
*/
public function actionGenerate()
{
$massage = UserCard::generateUserForUserCard();
return $this->render('generate', ['massage' => $massage]);
}
/** /**
* Finds the UserCard model based on its primary key value. * Finds the UserCard model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown. * If the model is not found, a 404 HTTP exception will be thrown.

View File

@ -2,9 +2,11 @@
namespace backend\modules\card\models; namespace backend\modules\card\models;
use Yii;
use backend\modules\settings\models\Skill; use backend\modules\settings\models\Skill;
use common\classes\Debug; use common\classes\Debug;
use common\models\CardSkill; use common\models\CardSkill;
use common\models\User;
use common\models\FieldsValue; use common\models\FieldsValue;
use common\models\FieldsValueNew; use common\models\FieldsValueNew;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
@ -22,21 +24,25 @@ class UserCard extends \common\models\UserCard
[ [
'item_id' => \Yii::$app->request->get('id'), 'item_id' => \Yii::$app->request->get('id'),
'item_type' => FieldsValueNew::TYPE_PROFILE, 'item_type' => FieldsValueNew::TYPE_PROFILE,
]) ]
)
->all(); ->all();
$array = []; $array = [];
if(!empty($fieldValue)){ if (!empty($fieldValue)) {
foreach ($fieldValue as $item){ foreach ($fieldValue as $item) {
array_push($array, array_push(
['field_id' => $item->field_id, $array,
[
'field_id' => $item->field_id,
'value' => $item->value, 'value' => $item->value,
'order' => $item->order, 'order' => $item->order,
'type_file' => $item->type_file, 'type_file' => $item->type_file,
'field_name' => $item->field->name]); 'field_name' => $item->field->name
]
);
} }
$this->fields = $array; $this->fields = $array;
} } else {
else{
$this->fields = [ $this->fields = [
[ [
'field_id' => null, 'field_id' => null,
@ -48,28 +54,28 @@ class UserCard extends \common\models\UserCard
]; ];
} }
$skill = ArrayHelper::getColumn(CardSkill::find()->where(['card_id' => \Yii::$app->request->get('id')])->all(), $skill = ArrayHelper::getColumn(
'skill_id'); CardSkill::find()->where(['card_id' => \Yii::$app->request->get('id')])->all(),
'skill_id'
);
if (!empty($skill)) { if (!empty($skill)) {
$this->skill = $skill; $this->skill = $skill;
} }
} }
public function afterSave($insert, $changedAttributes) public function afterSave($insert, $changedAttributes)
{ {
$post = \Yii::$app->request->post('UserCard'); $post = \Yii::$app->request->post('UserCard');
if($post['fields']){ if ($post['fields']) {
FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_PROFILE]); FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_PROFILE]);
foreach ( $post['fields'] as $item) { foreach ($post['fields'] as $item) {
$fildsValue = new FieldsValueNew(); $fildsValue = new FieldsValueNew();
$fildsValue->field_id = $item['field_id']; $fildsValue->field_id = $item['field_id'];
$fildsValue->value = $item['value']; $fildsValue->value = $item['value'];
$fildsValue->type_file = 'text'; $fildsValue->type_file = 'text';
if(substr($item['value'],0,1) == '/'){ if (substr($item['value'], 0, 1) == '/') {
$fildsValue->type_file = 'file'; $fildsValue->type_file = 'file';
} }
$fildsValue->order = $item['order']; $fildsValue->order = $item['order'];
@ -80,10 +86,10 @@ class UserCard extends \common\models\UserCard
} }
} }
if($post['skill']){ if ($post['skill']) {
CardSkill::deleteAll(['card_id' => $this->id]); CardSkill::deleteAll(['card_id' => $this->id]);
foreach ( $post['skill'] as $item) { foreach ($post['skill'] as $item) {
$skill = new CardSkill(); $skill = new CardSkill();
$skill->skill_id = $item; $skill->skill_id = $item;
$skill->card_id = $this->id; $skill->card_id = $this->id;
@ -95,4 +101,59 @@ class UserCard extends \common\models\UserCard
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
} }
public function generateUser($email, $status)
{
$user = new User();
$auth_key = Yii::$app->security->generateRandomString();
$password = Yii::$app->security->generateRandomString(12);
$password_hash = Yii::$app->security->generatePasswordHash($password);
$user->username = $email;
$user->auth_key = $auth_key;
$user->password_hash = $password_hash;
$user->email = $email;
if ($status == 1) $user->status = 10;
$user->save();
$log = "Логин: " . $email . " Пароль: " . $password . " | ";
file_put_contents("log.txt", $log, FILE_APPEND | LOCK_EX);
return $user->id;
}
public function genereateLinlkOnUser($user_card, $user_id)
{
$user_card->id_user = $user_id;
$user_card->save();
}
public function generateUserForUserCard($card_id = null)
{
$userCardQuery = UserCard::find();
$card_id ? $userCardQuery->where(['id' => $card_id]) : $userCardQuery->where(['id_user' => NULL]);
$user_card_array = $userCardQuery->all();
$user_array = User::find()->select(['id', 'email'])->all();
foreach ($user_card_array as $user_card_value) {
foreach ($user_array as $user_value)
if ($user_card_value->email == $user_value->email) {
$user_id = $user_value->id;
break;
} else $user_id = NULL;
if ($user_id) {
UserCard::genereateLinlkOnUser($user_card_value, $user_id);
} else {
$user_id = UserCard::generateUser($user_card_value->email, $user_card_value->status);
UserCard::genereateLinlkOnUser($user_card_value, $user_id);
}
}
if ($user_card_array) return "Данные успешно сгенерированы";
else return "Нет данных для генерации";
}
} }

View File

@ -28,7 +28,7 @@ use yii\widgets\ActiveForm;
<div class="row" style="padding-bottom: 15px"> <div class="row" style="padding-bottom: 15px">
<div class="imgUpload col-xs-6"> <div class="imgUpload col-xs-6">
<div class="media__upload_img"><img src="<?= $model->photo; ?>" width="100px"/></div> <div class="media__upload_img"><img src="<?= $model->photo; ?>" width="100px" /></div>
<?php <?php
echo InputFile::widget([ echo InputFile::widget([
'language' => 'ru', 'language' => 'ru',
@ -47,13 +47,13 @@ use yii\widgets\ActiveForm;
?> ?>
</div> </div>
<div class="col-xs-6"> <div class="col-xs-6">
<!--<div class="media__upload_img"><img src="<?/*= $model->photo; */?>" width="100px"/></div>--> <!--<div class="media__upload_img"><img src="<?/*= $model->photo; */ ?>" width="100px"/></div>-->
<?php <?php
echo InputFile::widget([ echo InputFile::widget([
'language' => 'ru', 'language' => 'ru',
'controller' => 'elfinder', 'controller' => 'elfinder',
// вставляем название контроллера, по умолчанию равен elfinder // вставляем название контроллера, по умолчанию равен elfinder
'filter' => ['image','application/zip','application/pdf','application/msword','application/vnd.openxmlformats-officedocument.wordprocessingml.document'], 'filter' => ['image', 'application/zip', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
// фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con.. // фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con..
'name' => 'UserCard[resume]', 'name' => 'UserCard[resume]',
'id' => 'usercard-resume', 'id' => 'usercard-resume',
@ -73,31 +73,36 @@ use yii\widgets\ActiveForm;
</div> </div>
<div class="col-xs-6"> <div class="col-xs-6">
<?= $form->field($model, 'gender')->dropDownList($model->genders, <?= $form->field($model, 'gender')->dropDownList(
[ $model->genders,
'prompt' => 'Выберите' [
]) ?> 'prompt' => 'Выберите'
]
) ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-xs-6"> <div class="col-xs-6">
<?= $form->field($model, 'dob')->input('date', <?= $form->field($model, 'dob')->input(
[ 'date',
'placeholder' => 'Zadejte svůj Datum narození',
'language' => 'en',
"data-format" => "DD MMMM YYYY",
]) ?>
</div>
<div class="col-xs-6">
<?= $form->field($model, 'status')
->dropDownList(\common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROFILE),
[ [
'prompt' => 'Выберите' 'placeholder' => 'Zadejte svůj Datum narození',
'language' => 'en',
"data-format" => "DD MMMM YYYY",
] ]
) ?> ) ?>
</div> </div>
<div class="col-xs-6">
<?= $form->field($model, 'status')
->dropDownList(
\common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROFILE),
[
'prompt' => 'Выберите'
]
) ?>
</div>
</div> </div>
<div class="row"> <div class="row">
@ -116,10 +121,11 @@ use yii\widgets\ActiveForm;
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<?= $form->field($model, 'skill')->widget(Select2::class, <?= $form->field($model, 'skill')->widget(
Select2::class,
[ [
'data' => \yii\helpers\ArrayHelper::map(\common\models\Skill::find()->all(),'id', 'name'), 'data' => \yii\helpers\ArrayHelper::map(\common\models\Skill::find()->all(), 'id', 'name'),
'options' => ['placeholder' => '...','class' => 'form-control', 'multiple' => true], 'options' => ['placeholder' => '...', 'class' => 'form-control', 'multiple' => true],
'pluginOptions' => [ 'pluginOptions' => [
'allowClear' => true 'allowClear' => true
], ],
@ -130,49 +136,52 @@ use yii\widgets\ActiveForm;
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<?= $form->field($model, 'fields')->widget(MultipleInput::class, [ <?= $form->field($model, 'fields')->widget(MultipleInput::class, [
'cloneButton' => true, 'cloneButton' => true,
'columns' => [ 'columns' => [
[ [
'name' => 'field_id', 'name' => 'field_id',
'type' => 'dropDownList', 'type' => 'dropDownList',
'title' => 'Поле', 'title' => 'Поле',
'defaultValue' => null, 'defaultValue' => null,
'items' => \yii\helpers\ArrayHelper::map(\backend\modules\settings\models\AdditionalFields::find() 'items' => \yii\helpers\ArrayHelper::map(
->joinWith('useFields') \backend\modules\settings\models\AdditionalFields::find()
->where(['`use_field`.`use`' => \common\models\UseStatus::USE_PROFILE]) ->joinWith('useFields')
->all(), ->where(['`use_field`.`use`' => \common\models\UseStatus::USE_PROFILE])
'id', 'name'), ->all(),
'options' => ['prompt' => 'Выберите'] 'id',
], 'name'
[ ),
'name' => 'value', 'options' => ['prompt' => 'Выберите']
'title' => 'Значение', ],
'type' => InputFile::className(), [
'options' => [ 'name' => 'value',
'language' => 'ru', 'title' => 'Значение',
'controller' => 'elfinder', 'type' => InputFile::className(),
// вставляем название контроллера, по умолчанию равен elfinder 'options' => [
// фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con.. 'language' => 'ru',
'name' => 'fields[value]', 'controller' => 'elfinder',
'id' => 'fields-value', // вставляем название контроллера, по умолчанию равен elfinder
'options' => ['class' => 'form-control itemImg', 'maxlength' => '255'], // фильтр файлов, можно задать массив фильтров https://github.com/Studio-42/elFinder/wiki/Client-con..
'buttonOptions' => ['class' => 'btn btn-primary'], 'name' => 'fields[value]',
'value' => $model->fields[0]['value'], 'id' => 'fields-value',
'buttonName' => 'Выбрать файл', 'options' => ['class' => 'form-control itemImg', 'maxlength' => '255'],
'buttonOptions' => ['class' => 'btn btn-primary'],
'value' => $model->fields[0]['value'],
'buttonName' => 'Выбрать файл',
],
],
[
'name' => 'order',
'title' => 'Приоритет',
'enableError' => true,
'options' => [
'class' => 'input-priority'
]
], ],
], ],
[ ])->label('Дополнительно');
'name' => 'order', ?>
'title' => 'Приоритет',
'enableError' => true,
'options' => [
'class' => 'input-priority'
]
],
],
])->label('Дополнительно');
?>
</div> </div>
</div> </div>

View File

@ -0,0 +1,3 @@
<?php
echo $massage;

View File

@ -16,6 +16,7 @@ $this->params['breadcrumbs'][] = $this->title;
<p> <p>
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?> <?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
<?= Html::a('Сгенерировать пользователей', ['generate'], ['class' => 'btn btn-success']) ?>
</p> </p>
<?= GridView::widget([ <?= GridView::widget([
@ -28,8 +29,8 @@ $this->params['breadcrumbs'][] = $this->title;
[ [
'label' => 'photo', 'label' => 'photo',
'format' => 'raw', 'format' => 'raw',
'value' => function($model){ 'value' => function ($model) {
return Html::img(Url::to($model->photo),[ return Html::img(Url::to($model->photo), [
'style' => 'width:100px;' 'style' => 'width:100px;'
]); ]);
}, },
@ -42,14 +43,14 @@ $this->params['breadcrumbs'][] = $this->title;
//'dob', //'dob',
[ [
'attribute' => 'status', 'attribute' => 'status',
'value' => function($model){ 'value' => function ($model) {
return $model->status0->name; return $model->status0->name;
}, },
'filter' => kartik\select2\Select2::widget([ 'filter' => kartik\select2\Select2::widget([
'model' => $searchModel, 'model' => $searchModel,
'attribute' => 'status', 'attribute' => 'status',
'data' => \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROFILE), 'data' => \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROFILE),
'options' => ['placeholder' => 'Начните вводить...','class' => 'form-control'], 'options' => ['placeholder' => 'Начните вводить...', 'class' => 'form-control'],
'pluginOptions' => [ 'pluginOptions' => [
'allowClear' => true 'allowClear' => true
], ],
@ -58,22 +59,21 @@ $this->params['breadcrumbs'][] = $this->title;
//'created_at', //'created_at',
//'updated_at', //'updated_at',
[ [
'label' => 'Навыки', 'label' => 'Навыки',
'format' => 'raw', 'format' => 'raw',
'value' => function($model){ 'value' => function ($model) {
$str = ''; $str = '';
foreach ($model->skillValues as $item) foreach ($model->skillValues as $item) {
{ $str .= $item->skill->name . ', ';
$str .= $item->skill->name . ', '; }
} $str = substr($str, 0, -2);
$str = substr( $str, 0, -2); return $str;
return $str; },
},
'filter' => kartik\select2\Select2::widget([ 'filter' => kartik\select2\Select2::widget([
'attribute' => 'skills', 'attribute' => 'skills',
'model' => $searchModel, 'model' => $searchModel,
'data' => \common\models\UserCard::getNameSkills(), 'data' => \common\models\UserCard::getNameSkills(),
'options' => ['multiple' => true,'placeholder' => 'Выбрать параметр','class' => 'form-control'], 'options' => ['multiple' => true, 'placeholder' => 'Выбрать параметр', 'class' => 'form-control'],
'pluginOptions' => [ 'pluginOptions' => [
'allowClear' => true 'allowClear' => true
], ],

View File

@ -6,6 +6,7 @@ use yii\widgets\DetailView;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model backend\modules\card\models\UserCard */ /* @var $model backend\modules\card\models\UserCard */
/* @var $userData common\models\User */
/* @var $skills \common\models\CardSkill */ /* @var $skills \common\models\CardSkill */
/* @var $skill \common\models\Skill */ /* @var $skill \common\models\Skill */
@ -27,14 +28,14 @@ $this->params['breadcrumbs'][] = $this->title;
[ [
'attribute' => 'Photo', 'attribute' => 'Photo',
'format' => 'raw', 'format' => 'raw',
'value' => function($model){ 'value' => function ($model) {
return Html::tag('img', null, ['src' => $model->photo, 'width' => '100px']); return Html::tag('img', null, ['src' => $model->photo, 'width' => '100px']);
} }
], ],
[ [
'attribute' => 'Resume', 'attribute' => 'Resume',
'format' => 'raw', 'format' => 'raw',
'value' => function($model){ 'value' => function ($model) {
return Html::a('Скачать', $model->resume, ['target' => '_blank']); return Html::a('Скачать', $model->resume, ['target' => '_blank']);
} }
], ],
@ -62,21 +63,21 @@ $this->params['breadcrumbs'][] = $this->title;
<h2>Навыки</h2> <h2>Навыки</h2>
<?php foreach ($skills as $skill): ?> <?php foreach ($skills as $skill) : ?>
<span class="btn btn-default btn-sm"><?= $skill['skill']->name; ?></span> <span class="btn btn-default btn-sm"><?= $skill['skill']->name; ?></span>
<?php endforeach; ?> <?php endforeach; ?>
<h2>Дополнительные сведения</h2> <h2>Дополнительные сведения</h2>
<?= GridView::widget([ <?= GridView::widget([
'dataProvider' => $modelFildValue, 'dataProvider' => $modelFildValue,
'layout'=>"{items}", 'layout' => "{items}",
'columns' => [ 'columns' => [
'field.name:text:Поле', 'field.name:text:Поле',
[ [
'attribute' => 'value', 'attribute' => 'value',
'format' => 'raw', 'format' => 'raw',
'value' => function($model){ 'value' => function ($model) {
if ($model->type_file == 'file'){ if ($model->type_file == 'file') {
return $model->value . ' (' . Html::a('Скачать', $model->value, ['target' => '_blank', 'download' => 'download']) . ')'; return $model->value . ' (' . Html::a('Скачать', $model->value, ['target' => '_blank', 'download' => 'download']) . ')';
} }
return $model->value; return $model->value;
@ -84,4 +85,5 @@ $this->params['breadcrumbs'][] = $this->title;
], ],
], ],
]); ?> ]); ?>
</div> </div>

View File

@ -1,4 +1,5 @@
<?php <?php
use yii\helpers\Html; use yii\helpers\Html;
/* @var $this \yii\web\View */ /* @var $this \yii\web\View */
@ -20,20 +21,22 @@ use yii\helpers\Html;
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<!-- Messages: style can be found in dropdown.less--> <!-- Messages: style can be found in dropdown.less-->
<li class="dropdown messages-menu"> <!-- <li class="dropdown messages-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-envelope-o"></i> <i class="fa fa-envelope-o"></i>
<span class="label label-success">4</span> <span class="label label-success">4</span>
</a> </a> -->
<ul class="dropdown-menu"> <!-- <ul class="dropdown-menu">
<li class="header">You have 4 messages</li> <li class="header">You have 4 messages</li>
<li> <li> -->
<!-- inner menu: contains the actual data --> <!-- inner menu: contains the actual data -->
<ul class="menu"> <!-- <ul class="menu">
<li><!-- start message --> <li> -->
<a href="#"> <!-- start message -->
<!-- <a href="#">
<div class="pull-left"> <div class="pull-left">
<img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="img-circle" <img src="<? //= $directoryAsset
?>/img/user2-160x160.jpg" class="img-circle"
alt="User Image"/> alt="User Image"/>
</div> </div>
<h4> <h4>
@ -42,12 +45,13 @@ use yii\helpers\Html;
</h4> </h4>
<p>Why not buy a new awesome theme?</p> <p>Why not buy a new awesome theme?</p>
</a> </a>
</li> </li> -->
<!-- end message --> <!-- end message -->
<li> <!-- <li>
<a href="#"> <a href="#">
<div class="pull-left"> <div class="pull-left">
<img src="<?= $directoryAsset ?>/img/user3-128x128.jpg" class="img-circle" <img src="<? //= $directoryAsset
?>/img/user3-128x128.jpg" class="img-circle"
alt="user image"/> alt="user image"/>
</div> </div>
<h4> <h4>
@ -60,7 +64,8 @@ use yii\helpers\Html;
<li> <li>
<a href="#"> <a href="#">
<div class="pull-left"> <div class="pull-left">
<img src="<?= $directoryAsset ?>/img/user4-128x128.jpg" class="img-circle" <img src="<? //= $directoryAsset
?>/img/user4-128x128.jpg" class="img-circle"
alt="user image"/> alt="user image"/>
</div> </div>
<h4> <h4>
@ -73,7 +78,8 @@ use yii\helpers\Html;
<li> <li>
<a href="#"> <a href="#">
<div class="pull-left"> <div class="pull-left">
<img src="<?= $directoryAsset ?>/img/user3-128x128.jpg" class="img-circle" <img src="<? //= $directoryAsset
?>/img/user3-128x128.jpg" class="img-circle"
alt="user image"/> alt="user image"/>
</div> </div>
<h4> <h4>
@ -86,7 +92,8 @@ use yii\helpers\Html;
<li> <li>
<a href="#"> <a href="#">
<div class="pull-left"> <div class="pull-left">
<img src="<?= $directoryAsset ?>/img/user4-128x128.jpg" class="img-circle" <img src="<? //= $directoryAsset
?>/img/user4-128x128.jpg" class="img-circle"
alt="user image"/> alt="user image"/>
</div> </div>
<h4> <h4>
@ -96,21 +103,21 @@ use yii\helpers\Html;
<p>Why not buy a new awesome theme?</p> <p>Why not buy a new awesome theme?</p>
</a> </a>
</li> </li>
</ul> </ul> -->
</li> <!-- </li>
<li class="footer"><a href="#">See All Messages</a></li> <li class="footer"><a href="#">See All Messages</a></li>
</ul> </ul> -->
</li> <!-- </li> -->
<li class="dropdown notifications-menu"> <!-- <li class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bell-o"></i> <i class="fa fa-bell-o"></i>
<span class="label label-warning">10</span> <span class="label label-warning">10</span>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="header">You have 10 notifications</li> <li class="header">You have 10 notifications</li>
<li> <li> -->
<!-- inner menu: contains the actual data --> <!-- inner menu: contains the actual data -->
<ul class="menu"> <!-- <ul class="menu">
<li> <li>
<a href="#"> <a href="#">
<i class="fa fa-users text-aqua"></i> 5 new members joined today <i class="fa fa-users text-aqua"></i> 5 new members joined today
@ -142,104 +149,100 @@ use yii\helpers\Html;
</li> </li>
<li class="footer"><a href="#">View all</a></li> <li class="footer"><a href="#">View all</a></li>
</ul> </ul>
</li> </li> -->
<!-- Tasks: style can be found in dropdown.less --> <!-- Tasks: style can be found in dropdown.less -->
<li class="dropdown tasks-menu"> <!-- <li class="dropdown tasks-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-flag-o"></i> <i class="fa fa-flag-o"></i>
<span class="label label-danger">9</span> <span class="label label-danger">9</span>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="header">You have 9 tasks</li> <li class="header">You have 9 tasks</li>
<li> <!-->
<!-- inner menu: contains the actual data --> <!-- inner menu: contains the actual data -->
<ul class="menu"> <!-- <ul class="menu">
<li><!-- Task item --> <li> -->
<a href="#"> <!-- Task item -->
<!-- <a href="#">
<h3> <h3>
Design some buttons Design some buttons
<small class="pull-right">20%</small> <small class="pull-right">20%</small>
</h3> </h3>
<div class="progress xs"> <div class="progress xs">
<div class="progress-bar progress-bar-aqua" style="width: 20%" <div class="progress-bar progress-bar-aqua" style="width: 20%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">20% Complete</span> <span class="sr-only">20% Complete</span>
</div> </div>
</div> </div>
</a> </a>
</li> </li> -->
<!-- end task item --> <!-- end task item -->
<li><!-- Task item --> <!-- <li> -->
<a href="#"> <!-- Task item -->
<!-- <a href="#">
<h3> <h3>
Create a nice theme Create a nice theme
<small class="pull-right">40%</small> <small class="pull-right">40%</small>
</h3> </h3>
<div class="progress xs"> <div class="progress xs">
<div class="progress-bar progress-bar-green" style="width: 40%" <div class="progress-bar progress-bar-green" style="width: 40%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">40% Complete</span> <span class="sr-only">40% Complete</span>
</div> </div>
</div> </div>
</a> </a> -->
</li>
<!-- end task item --> <!-- end task item -->
<li><!-- Task item --> <!-- <li> -->
<a href="#"> <!-- Task item -->
<!-- <a href="#">
<h3> <h3>
Some task I need to do Some task I need to do
<small class="pull-right">60%</small> <small class="pull-right">60%</small>
</h3> </h3>
<div class="progress xs"> <div class="progress xs">
<div class="progress-bar progress-bar-red" style="width: 60%" <div class="progress-bar progress-bar-red" style="width: 60%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">60% Complete</span> <span class="sr-only">60% Complete</span>
</div> </div>
</div> </div>
</a> </a> -->
</li>
<!-- end task item --> <!-- end task item -->
<li><!-- Task item --> <!-- <li> -->
<a href="#"> <!-- Task item -->
<!-- <a href="#">
<h3> <h3>
Make beautiful transitions Make beautiful transitions
<small class="pull-right">80%</small> <small class="pull-right">80%</small>
</h3> </h3>
<div class="progress xs"> <div class="progress xs">
<div class="progress-bar progress-bar-yellow" style="width: 80%" <div class="progress-bar progress-bar-yellow" style="width: 80%" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
role="progressbar" aria-valuenow="20" aria-valuemin="0"
aria-valuemax="100">
<span class="sr-only">80% Complete</span> <span class="sr-only">80% Complete</span>
</div> </div>
</div> </div>
</a> </a> -->
</li>
<!-- end task item --> <!-- end task item -->
</ul> <!-- </ul> -->
</li>
<li class="footer"> <!-- <li class="footer">
<a href="#">View all tasks</a> <a href="#">View all tasks</a>
</li> </li>
</ul> </ul>
</li> </li> -->
<!-- User Account: style can be found in dropdown.less --> <!-- User Account: style can be found in dropdown.less -->
<li class="dropdown user user-menu"> <li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="user-image" alt="User Image"/> <img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="user-image" alt="User Image" />
<span class="hidden-xs">Alexander Pierce</span> <span class="hidden-xs"><?= Yii::$app->user->identity->username ?></span>
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<!-- User image --> <!-- User image -->
<li class="user-header"> <li class="user-header">
<img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="img-circle" <img src="<?= $directoryAsset ?>/img/user2-160x160.jpg" class="img-circle" alt="User Image" />
alt="User Image"/>
<p> <p>
Alexander Pierce - Web Developer <?= Yii::$app->user->identity->username ?> - Web Developer
<small>Member since Nov. 2012</small> <small>Member since Nov. 2012</small>
</p> </p>
</li> </li>

View File

@ -1,14 +1,15 @@
<aside class="main-sidebar"> <aside class="main-sidebar">
<section class="sidebar"> <section class="sidebar">
<?php <?php
$userStatuses = \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROFILE); $userStatuses = \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROFILE);
$menuItems = [['label' => 'Все', 'icon' => 'user', 'url' => ['/card/user-card']]]; $menuItems = [['label' => 'Все', 'icon' => 'user', 'url' => ['/card/user-card']]];
foreach($userStatuses as $key => $status){ foreach ($userStatuses as $key => $status) {
$menuItems[] = ['label' => $status, 'icon' => 'user', 'url' => ['/card/user-card?UserCardSearch[status]=' . $key]]; $menuItems[] = ['label' => $status, 'icon' => 'user', 'url' => ['/card/user-card?UserCardSearch[status]=' . $key]];
} }
$projectStatuses = \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROJECT); $projectStatuses = \common\models\Status::getStatusesArray(\common\models\UseStatus::USE_PROJECT);
$projectItems = [['label' => 'Все', 'icon' => 'files-o', 'url' => ['/project/project']]]; $projectItems = [['label' => 'Все', 'icon' => 'files-o', 'url' => ['/project/project']]];
foreach($projectStatuses as $key => $status){ foreach ($projectStatuses as $key => $status) {
$projectItems[] = ['label' => $status, 'icon' => 'user', 'url' => ['/project/project?ProjectSearch[status]=' . $key]]; $projectItems[] = ['label' => $status, 'icon' => 'user', 'url' => ['/project/project?ProjectSearch[status]=' . $key]];
} }
?> ?>
@ -20,30 +21,31 @@
[ [
'label' => 'Настройки', 'icon' => 'gears', 'url' => '#', 'label' => 'Настройки', 'icon' => 'gears', 'url' => '#',
'items' => [ 'items' => [
['label' => 'Статусы', 'icon' => 'anchor', 'url' => ['/settings/status']], ['label' => 'Статусы', 'icon' => 'anchor', 'url' => ['/settings/status'], 'active' => \Yii::$app->controller->id == 'status'],
['label' => 'Доп. поля', 'icon' => 'file-text-o', 'url' => ['/settings/additional-fields']], ['label' => 'Доп. поля', 'icon' => 'file-text-o', 'url' => ['/settings/additional-fields'], 'active' => \Yii::$app->controller->id == 'additional-fields'],
['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position']], ['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position'], 'active' => \Yii::$app->controller->id == 'position'],
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill']], ['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill'], 'active' => \Yii::$app->controller->id == 'skill'],
] ]
], ],
[ [
'label' => 'Профили', 'icon' => 'users', 'url' => '#', 'label' => 'Профили', 'icon' => 'users', 'url' => '#', 'active' => \Yii::$app->controller->id == 'user-card',
'items' => $menuItems, 'items' => $menuItems,
], ],
[ 'label' => 'Проекты', 'icon' => 'files-o', 'url' => ['#'], [
'label' => 'Проекты', 'icon' => 'files-o', 'url' => ['#'], 'active' => \Yii::$app->controller->id == 'project',
'items' => $projectItems, 'items' => $projectItems,
], ],
['label' => 'Компании', 'icon' => 'files-o', 'url' => ['/company/company']], ['label' => 'Компании', 'icon' => 'files-o', 'url' => ['/company/company']],
[ [
'label' => 'Hh.ru', 'icon' => 'user-circle', 'url' => '#', 'label' => 'Hh.ru', 'icon' => 'user-circle', 'url' => '#',
'items' => [ 'items' => [
['label' => 'Компании', 'icon' => 'building', 'url' => ['/hh/hh']], ['label' => 'Компании', 'icon' => 'building', 'url' => ['/hh/hh'], 'active' => \Yii::$app->controller->id == 'hh'],
['label' => 'Вакансии', 'icon' => 'user-md', 'url' => ['/hh/hh-job']], ['label' => 'Вакансии', 'icon' => 'user-md', 'url' => ['/hh/hh-job'], 'active' => \Yii::$app->controller->id == 'hh-job'],
], ],
], ],
['label' => 'Баланс', 'icon' => 'dollar', 'url' => ['/balance/balance']], ['label' => 'Баланс', 'icon' => 'dollar', 'url' => ['/balance/balance'], 'active' => \Yii::$app->controller->id == 'balance'],
['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday']], ['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday'], 'active' => \Yii::$app->controller->id == 'holiday'],
['label' => 'Доступы', 'icon' => '', 'url' => ['/accesses/accesses']], ['label' => 'Доступы', 'icon' => '', 'url' => ['/accesses/accesses'], 'active' => \Yii::$app->controller->id == 'accesses'],
/*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']], /*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']],
['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug']], ['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug']],

View File

@ -1,3 +1,4 @@
/index.php /index.php
/index-test.php /index-test.php
/robots.txt /robots.txt
/log.txt

View File

@ -10,7 +10,7 @@
} }
.itemImg, .itemImgs{ .itemImg, .itemImgs{
float: left!important; float: left !important;
display: inline-block; display: inline-block;
width: 30%!important; width: 30%!important;
} }

View File

@ -1,4 +1,5 @@
<?php <?php
namespace common\models; namespace common\models;
use Yii; use Yii;
@ -26,7 +27,6 @@ class User extends ActiveRecord implements IdentityInterface
const STATUS_DELETED = 0; const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10; const STATUS_ACTIVE = 10;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -12,6 +12,7 @@ use yii\helpers\ArrayHelper;
* This is the model class for table "user_card". * This is the model class for table "user_card".
* *
* @property int $id * @property int $id
* @property int $id_user
* @property string $fio * @property string $fio
* @property string $passport * @property string $passport
* @property string $photo * @property string $photo
@ -63,7 +64,7 @@ class UserCard extends \yii\db\ActiveRecord
{ {
return [ return [
[['fio', 'status', 'gender'], 'required'], [['fio', 'status', 'gender'], 'required'],
[['gender', 'status', 'position_id'], 'integer'], [['gender', 'status', 'position_id', 'id_user'], 'integer'],
[['dob', 'created_at', 'updated_at', 'deleted_at'], 'safe'], [['dob', 'created_at', 'updated_at', 'deleted_at'], 'safe'],
[['fio', 'passport', 'photo', 'email', 'resume'], 'string', 'max' => 255], [['fio', 'passport', 'photo', 'email', 'resume'], 'string', 'max' => 255],
[['salary'], 'string', 'max' => 100], [['salary'], 'string', 'max' => 100],
@ -79,6 +80,7 @@ class UserCard extends \yii\db\ActiveRecord
{ {
return [ return [
'id' => 'ID', 'id' => 'ID',
'id_user' => 'ID пользователя',
'fio' => 'ФИО', 'fio' => 'ФИО',
'passport' => 'Паспорт', 'passport' => 'Паспорт',
'photo' => 'Фото', 'photo' => 'Фото',
@ -150,7 +152,7 @@ class UserCard extends \yii\db\ActiveRecord
public static function getNameSkills() public static function getNameSkills()
{ {
return ArrayHelper::map(Skill::find()->all(),'id', 'name'); return ArrayHelper::map(Skill::find()->all(), 'id', 'name');
} }
public static function getUserList() public static function getUserList()

View File

@ -0,0 +1,57 @@
<?php
use yii\db\Migration;
/**
* Handles adding columns to table `{{%user_card}}`.
* Has foreign keys to the tables:
*
* - `{{%user}}`
*/
class m191114_124130_add_id_user_column_to_user_card_table extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('{{%user_card}}', 'id_user', $this->integer());
// creates index for column `id_user`
$this->createIndex(
'{{%idx-user_card-id_user}}',
'{{%user_card}}',
'id_user'
);
// add foreign key for table `{{%user}}`
$this->addForeignKey(
'{{%fk-user_card-id_user}}',
'{{%user_card}}',
'id_user',
'{{%user}}',
'id',
'CASCADE'
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
// drops foreign key for table `{{%user}}`
$this->dropForeignKey(
'{{%fk-user_card-id_user}}',
'{{%user_card}}'
);
// drops index for column `id_user`
$this->dropIndex(
'{{%idx-user_card-id_user}}',
'{{%user_card}}'
);
$this->dropColumn('{{%user_card}}', 'id_user');
}
}

View File

@ -11,6 +11,13 @@ return [
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'bootstrap' => ['log'], 'bootstrap' => ['log'],
'controllerNamespace' => 'frontend\controllers', 'controllerNamespace' => 'frontend\controllers',
'modules' => [
'access' => [
'class' => 'frontend\modules\access\Access',
],
],
'components' => [ 'components' => [
'request' => [ 'request' => [
'csrfParam' => '_csrf-frontend', 'csrfParam' => '_csrf-frontend',
@ -41,8 +48,7 @@ return [
'urlManager' => [ 'urlManager' => [
'enablePrettyUrl' => true, 'enablePrettyUrl' => true,
'showScriptName' => false, 'showScriptName' => false,
'rules' => [ 'rules' => [],
],
], ],
], ],

View File

@ -0,0 +1,24 @@
<?php
namespace frontend\modules\access;
/**
* access module definition class
*/
class Access extends \yii\base\Module
{
/**
* {@inheritdoc}
*/
public $controllerNamespace = 'frontend\modules\access\controllers';
/**
* {@inheritdoc}
*/
public function init()
{
parent::init();
// custom initialization code goes here
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace frontend\modules\access\controllers;
use common\classes\Debug;
use common\models\Accesses;
use Yii;
use yii\web\Controller;
use yii\data\ActiveDataProvider;
class AccessController extends Controller
{
/**
* @return mixed
*/
public function actionIndex()
{
$id_user = Yii::$app->user->id;
$query = "SELECT accesses.name, accesses.access FROM `accesses`, `user_card`, `user_card_accesses` WHERE user_card.id_user =" . $id_user . " AND user_card_accesses.user_card_id = user_card.id AND accesses.id = user_card_accesses.accesses_id ";
$access = Accesses::findBySql($query);
$dataProvider = new ActiveDataProvider([
'query' => $access,
'pagination' => [
'pageSize' => 200,
],
]);
return $this->render('index', compact('dataProvider', $dataProvider));
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace frontend\modules\access\controllers;
use yii\web\Controller;
/**
* Default controller for the `access` module
*/
class DefaultController extends Controller
{
/**
* Renders the index view for the module
* @return string
*/
public function actionIndex()
{
return $this->render('index');
}
}

View File

@ -0,0 +1,13 @@
<?php
use yii\grid\GridView;
use yii\widgets\DetailView;
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'name',
'access',
],
]);

View File

@ -0,0 +1,12 @@
<div class="access-default-index">
<h1><?= $this->context->action->uniqueId ?></h1>
<p>
This is the view content for action "<?= $this->context->action->id ?>".
The action belongs to the controller "<?= get_class($this->context) ?>"
in the "<?= $this->context->module->id ?>" module.
</p>
<p>
You may customize this page by editing the following file:<br>
<code><?= __FILE__ ?></code>
</p>
</div>

View File

@ -15,6 +15,7 @@ AppAsset::register($this);
<?php $this->beginPage() ?> <?php $this->beginPage() ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>"> <html lang="<?= Yii::$app->language ?>">
<head> <head>
<meta charset="<?= Yii::$app->charset ?>"> <meta charset="<?= Yii::$app->charset ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
@ -23,61 +24,64 @@ AppAsset::register($this);
<title><?= Html::encode($this->title) ?></title> <title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?> <?php $this->head() ?>
</head> </head>
<body> <body>
<?php $this->beginBody() ?> <?php $this->beginBody() ?>
<div class="wrap"> <div class="wrap">
<?php <?php
NavBar::begin([ NavBar::begin([
'brandLabel' => Yii::$app->name, 'brandLabel' => Yii::$app->name,
'brandUrl' => Yii::$app->homeUrl, 'brandUrl' => Yii::$app->homeUrl,
'options' => [ 'options' => [
'class' => 'navbar-inverse navbar-fixed-top', 'class' => 'navbar-inverse navbar-fixed-top',
], ],
]); ]);
$menuItems = [ $menuItems = [
['label' => 'Home', 'url' => ['/site/index']], ['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']], ['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']], ['label' => 'Contact', 'url' => ['/site/contact']],
]; ];
if (Yii::$app->user->isGuest) { if (Yii::$app->user->isGuest) {
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']]; $menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']]; $menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
} else { } else {
$menuItems[] = '<li>' $menuItems[] = ['label' => 'Access', 'url' => ['/access/access/index']];
. Html::beginForm(['/site/logout'], 'post') $menuItems[] = '<li>'
. Html::submitButton( . Html::beginForm(['/site/logout'], 'post')
'Logout (' . Yii::$app->user->identity->username . ')', . Html::submitButton(
['class' => 'btn btn-link logout'] 'Logout (' . Yii::$app->user->identity->username . ')',
) ['class' => 'btn btn-link logout']
. Html::endForm() )
. '</li>'; . Html::endForm()
} . '</li>';
echo Nav::widget([ }
'options' => ['class' => 'navbar-nav navbar-right'], echo Nav::widget([
'items' => $menuItems, 'options' => ['class' => 'navbar-nav navbar-right'],
]); 'items' => $menuItems,
NavBar::end(); ]);
?> NavBar::end();
?>
<div class="container"> <div class="container">
<?= Breadcrumbs::widget([ <?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?> ]) ?>
<?= Alert::widget() ?> <?= Alert::widget() ?>
<?= $content ?> <?= $content ?>
</div>
</div> </div>
</div>
<footer class="footer"> <footer class="footer">
<div class="container"> <div class="container">
<p class="pull-left">&copy; <?= Html::encode(Yii::$app->name) ?> <?= date('Y') ?></p> <p class="pull-left">&copy; <?= Html::encode(Yii::$app->name) ?> <?= date('Y') ?></p>
<p class="pull-right"><?= Yii::powered() ?></p> <p class="pull-right"><?= Yii::powered() ?></p>
</div> </div>
</footer> </footer>
<?php $this->endBody() ?> <?php $this->endBody() ?>
</body> </body>
</html> </html>
<?php $this->endPage() ?> <?php $this->endPage() ?>