commit
45b6bb480a
@ -15,6 +15,7 @@ class AppAsset extends AssetBundle
|
||||
'css/site.css',
|
||||
];
|
||||
public $js = [
|
||||
'js/site.js',
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
|
@ -41,6 +41,9 @@ return [
|
||||
'notes' => [
|
||||
'class' => 'backend\modules\notes\Notes',
|
||||
],
|
||||
'calendar' => [
|
||||
'class' => 'backend\modules\calendar\Calendar',
|
||||
],
|
||||
],
|
||||
'components' => [
|
||||
'request' => [
|
||||
|
@ -4,6 +4,7 @@
|
||||
namespace app\modules\accesses\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use common\models\FieldsValueNew;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
@ -17,5 +18,73 @@ use Yii;
|
||||
|
||||
class Accesses extends \common\models\Accesses
|
||||
{
|
||||
public $fields;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$fieldValue = FieldsValueNew::find()->where(
|
||||
[
|
||||
'item_id' => \Yii::$app->request->get('id'),
|
||||
'item_type' => FieldsValueNew::TYPE_ACCESS,
|
||||
]
|
||||
)
|
||||
->all();
|
||||
$array = [];
|
||||
if (!empty($fieldValue)) {
|
||||
foreach ($fieldValue as $item) {
|
||||
array_push(
|
||||
$array,
|
||||
[
|
||||
'field_id' => $item->field_id,
|
||||
'value' => $item->value,
|
||||
'order' => $item->order,
|
||||
'type_file' => $item->type_file,
|
||||
'field_name' => $item->field->name
|
||||
]
|
||||
);
|
||||
}
|
||||
$this->fields = $array;
|
||||
} else {
|
||||
$this->fields = [
|
||||
[
|
||||
'field_id' => null,
|
||||
'value' => null,
|
||||
'order' => null,
|
||||
'field_name' => null,
|
||||
'type_file' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
$post = \Yii::$app->request->post('Aceesses');
|
||||
|
||||
if ($post['fields']) {
|
||||
FieldsValueNew::deleteAll(['item_id' => $this->id, 'item_type' => FieldsValueNew::TYPE_ACCESS]);
|
||||
foreach ($post['fields'] as $item) {
|
||||
$item['value'] = urldecode($item['value']);
|
||||
|
||||
$fieldsValue = new FieldsValueNew();
|
||||
$fieldsValue->field_id = $item['field_id'];
|
||||
$fieldsValue->value = $item['value'];
|
||||
$fieldsValue->order = $item['order'];
|
||||
$fieldsValue->item_id = $this->id;
|
||||
$fieldsValue->item_type = FieldsValueNew::TYPE_ACCESS;
|
||||
if (is_file(Yii::getAlias('@frontend') . '/web/' . $item['value'])) {
|
||||
$fieldsValue->type_file = 'file';
|
||||
} else {
|
||||
$fieldsValue->type_file = 'text';
|
||||
}
|
||||
|
||||
$fieldsValue->save();
|
||||
}
|
||||
}
|
||||
|
||||
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ class AccessesSearch extends Accesses
|
||||
{
|
||||
return [
|
||||
[['id'], 'integer'],
|
||||
[['name', 'access'], 'safe'],
|
||||
[['name', 'login', 'password', 'link', 'project', 'info'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -62,7 +62,11 @@ class AccessesSearch extends Accesses
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name])
|
||||
->andFilterWhere(['like', 'access', $this->access]);
|
||||
->andFilterWhere(['like', 'login', $this->login])
|
||||
->andFilterWhere(['like', 'password', $this->password])
|
||||
->andFilterWhere(['like', 'link', $this->link])
|
||||
->andFilterWhere(['like', 'project', $this->project])
|
||||
->andFilterWhere(['like', 'info', $this->info]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use mihaildev\elfinder\InputFile;
|
||||
use unclead\multipleinput\MultipleInput;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use kartik\select2\Select2;
|
||||
@ -16,29 +18,38 @@ use kartik\select2\Select2;
|
||||
|
||||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'access')->textarea(['maxlength' => true]) ?>
|
||||
<?= $form->field($model, 'login')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<?= Select2::widget(
|
||||
[
|
||||
'model' => $model,
|
||||
'attribute' => '_projects',
|
||||
'data' => \yii\helpers\ArrayHelper::map(\common\models\Project::find()->all(), 'id', 'name'),
|
||||
'options' => ['placeholder' => '...', 'class' => 'form-control', 'multiple' => true],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
]
|
||||
) ?>
|
||||
</div>
|
||||
</div>
|
||||
<?= $form->field($model, 'password')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'link')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'project')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'info')->textarea(['maxlength' => true]) ?>
|
||||
|
||||
<!-- <div class="row">-->
|
||||
<!-- <div class="col-xs-12">-->
|
||||
<!-- --><?php
|
||||
// echo Select2::widget(
|
||||
// [
|
||||
// 'model' => $model,
|
||||
// 'attribute' => '_projects',
|
||||
// 'data' => \yii\helpers\ArrayHelper::map(\common\models\Project::find()->all(), 'id', 'name'),
|
||||
// 'options' => ['placeholder' => '...', 'class' => 'form-control', 'multiple' => true],
|
||||
// 'pluginOptions' => [
|
||||
// 'allowClear' => true
|
||||
// ],
|
||||
// ]
|
||||
// ) ?>
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<text>Пользователи</text>
|
||||
<?= Select2::widget(
|
||||
<?php
|
||||
echo Select2::widget(
|
||||
[
|
||||
'model'=> $model,
|
||||
'attribute' => '_users',
|
||||
@ -47,13 +58,12 @@ use kartik\select2\Select2;
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
]
|
||||
) ?>
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
<?= '<br>' . Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
@ -19,8 +19,6 @@ use yii\widgets\ActiveForm;
|
||||
|
||||
<?= $form->field($model, 'name') ?>
|
||||
|
||||
<?= $form->field($model, 'access') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Поиск', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Сброс', ['class' => 'btn btn-default']) ?>
|
||||
|
@ -24,10 +24,11 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
|
||||
'name',
|
||||
'access',
|
||||
'login',
|
||||
'password',
|
||||
'link',
|
||||
'project',
|
||||
[
|
||||
'attribute' => 'userCard.fio',
|
||||
'format' => 'raw',
|
||||
@ -35,15 +36,13 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
return $model->getUserCardName();
|
||||
},
|
||||
],
|
||||
|
||||
[
|
||||
'attribute' => 'projects.name',
|
||||
'format' => 'raw',
|
||||
'value' => function(\common\models\Accesses $model){
|
||||
return $model->getProjectName();
|
||||
},
|
||||
],
|
||||
|
||||
// [
|
||||
// 'attribute' => 'projects.name',
|
||||
// 'format' => 'raw',
|
||||
// 'value' => function(\common\models\Accesses $model){
|
||||
// return $model->getProjectName();
|
||||
// },
|
||||
// ],
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
|
@ -30,21 +30,25 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'name',
|
||||
'access',
|
||||
[
|
||||
'attribute' => 'userCard.fio',
|
||||
'format' => 'raw',
|
||||
'value' => function(\common\models\Accesses $model){
|
||||
return $model->getUserCardName();
|
||||
},
|
||||
],
|
||||
[
|
||||
'attribute' => 'projects.name',
|
||||
'format' => 'raw',
|
||||
'value' => function(\common\models\Accesses $model){
|
||||
return $model->getProjectName();
|
||||
},
|
||||
],
|
||||
'login',
|
||||
'password',
|
||||
'link',
|
||||
'project',
|
||||
'info',
|
||||
// [
|
||||
// 'attribute' => 'userCard.fio',
|
||||
// 'format' => 'raw',
|
||||
// 'value' => function(\common\models\Accesses $model){
|
||||
// return $model->getUserCardName();
|
||||
// },
|
||||
// ],
|
||||
// [
|
||||
// 'attribute' => 'projects.name',
|
||||
// 'format' => 'raw',
|
||||
// 'value' => function(\common\models\Accesses $model){
|
||||
// return $model->getProjectName();
|
||||
// },
|
||||
// ],
|
||||
],
|
||||
]) ?>
|
||||
|
||||
|
24
backend/modules/calendar/Calendar.php
Normal file
24
backend/modules/calendar/Calendar.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\calendar;
|
||||
|
||||
/**
|
||||
* calendar module definition class
|
||||
*/
|
||||
class Calendar extends \yii\base\Module
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $controllerNamespace = 'backend\modules\calendar\controllers';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
}
|
46
backend/modules/calendar/controllers/CalendarController.php
Normal file
46
backend/modules/calendar/controllers/CalendarController.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\calendar\controllers;
|
||||
|
||||
use backend\modules\card\models\UserCardSearch;
|
||||
use common\classes\Debug;
|
||||
use Yii;
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\web\Controller;
|
||||
|
||||
/**
|
||||
* Default controller for the `calendar` module
|
||||
*/
|
||||
class CalendarController extends Controller
|
||||
{
|
||||
/**
|
||||
* Renders the index view for the module
|
||||
* @return string
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new UserCardSearch();
|
||||
$user_card = \common\models\UserCard::find()->all();
|
||||
$user_array = array();
|
||||
try {
|
||||
if($_GET['month'] == 00)
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
else {
|
||||
foreach ($user_card as $value) {
|
||||
if (substr(substr($value->dob, 5), 0, 2) == $_GET['month'])
|
||||
array_push($user_array, $value);
|
||||
}
|
||||
$dataProvider = new ArrayDataProvider([
|
||||
'allModels' => $user_array,
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
}
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
}
|
42
backend/modules/calendar/views/calendar/index.php
Normal file
42
backend/modules/calendar/views/calendar/index.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/* @var $searchModel backend\modules\card\models\UserCardSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
use yii\grid\GridView;
|
||||
use yii\widgets\Pjax;
|
||||
?>
|
||||
|
||||
<p>
|
||||
<select id="options" class="btn btn-secondary dropdown-toggle">
|
||||
<option selected="selected" value="?month=00">Выберите месяц</option>
|
||||
<option value="?month=00">Показать все</option>
|
||||
<option value="?month=01">январь</option>
|
||||
<option value="?month=02">февраль</option>
|
||||
<option value="?month=03">март</option>
|
||||
<option value="?month=04">апрель</option>
|
||||
<option value="?month=05">май</option>
|
||||
<option value="?month=06">июнь</option>
|
||||
<option value="?month=07">июль</option>
|
||||
<option value="?month=08">август</option>
|
||||
<option value="?month=09">сентябрь</option>
|
||||
<option value="?month=10">октябрь</option>
|
||||
<option value="?month=11">ноябрь</option>
|
||||
<option value="?month=12">декабрь</option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
Pjax::begin(['id' => 'reload']);
|
||||
echo GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
'fio',
|
||||
'dob',
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]);
|
||||
Pjax::end();
|
||||
?>
|
@ -47,9 +47,21 @@ class UserCardController extends Controller
|
||||
$searchModel = new UserCardSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
$total = 0;
|
||||
if(Yii::$app->request->queryParams)
|
||||
foreach (Yii::$app->request->queryParams as $params)
|
||||
$total = \common\models\UserCard::find()->filterWhere([
|
||||
'fio' => $params['fio'],
|
||||
'email' => $params['email'],
|
||||
'status' => $params['status'],
|
||||
'skills' => $params['skills'],
|
||||
])->sum('salary');
|
||||
else $total = \common\models\UserCard::find()->sum('salary');
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
'total' => $total,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ class UserCard extends \common\models\UserCard
|
||||
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
public function generateUser($email, $status)
|
||||
public static function generateUser($email, $status)
|
||||
{
|
||||
$user = new User();
|
||||
$auth_key = Yii::$app->security->generateRandomString();
|
||||
@ -126,13 +126,13 @@ class UserCard extends \common\models\UserCard
|
||||
return $user->id;
|
||||
}
|
||||
|
||||
public function genereateLinlkOnUser($user_card, $user_id)
|
||||
public static function genereateLinlkOnUser($user_card, $user_id)
|
||||
{
|
||||
$user_card->id_user = $user_id;
|
||||
$user_card->save();
|
||||
}
|
||||
|
||||
public function generateUserForUserCard($card_id = null)
|
||||
public static function generateUserForUserCard($card_id = null)
|
||||
{
|
||||
$userCardQuery = UserCard::find();
|
||||
$card_id ? $userCardQuery->where(['id' => $card_id]) : $userCardQuery->where(['id_user' => NULL]);
|
||||
|
@ -8,6 +8,7 @@ use yii\widgets\ListView;
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\modules\card\models\UserCardSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
/* @var $total */
|
||||
|
||||
$this->title = 'Профили';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
@ -19,7 +20,8 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
<?= Html::a('Сгенерировать пользователей', ['generate'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
<?php
|
||||
echo GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
@ -83,5 +85,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
]);
|
||||
echo "<h3>Сумма зарплат: " . $total . "</h3>";
|
||||
?>
|
||||
</div>
|
@ -47,6 +47,7 @@
|
||||
['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday'], 'active' => \Yii::$app->controller->id == 'holiday'],
|
||||
['label' => 'Доступы', 'icon' => 'key', 'url' => ['/accesses/accesses'], 'active' => \Yii::$app->controller->id == 'accesses'],
|
||||
['label' => 'Заметки', 'icon' => 'sticky-note', 'url' => ['/notes/notes'], 'active' => \Yii::$app->controller->id == 'notes'],
|
||||
['label' => 'Календарь ДР', 'icon' => 'calendar', 'url' => ['/calendar/calendar'], 'active' => \Yii::$app->controller->id == 'calendar'],
|
||||
|
||||
/*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']],
|
||||
['label' => 'Debug', 'icon' => 'dashboard', 'url' => ['/debug']],
|
||||
|
7
backend/web/js/site.js
Normal file
7
backend/web/js/site.js
Normal file
@ -0,0 +1,7 @@
|
||||
$(function(){
|
||||
$('#options').change(function(){
|
||||
month = $('#options :selected').val();
|
||||
history.pushState({}, '', month);
|
||||
$.pjax.reload({container:"#reload"});
|
||||
})
|
||||
});
|
@ -11,7 +11,11 @@ use yii\helpers\ArrayHelper;
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $access
|
||||
* @property string $login
|
||||
* @property string $password
|
||||
* @property string $link
|
||||
* @property string $project
|
||||
* @property string $info
|
||||
*/
|
||||
class Accesses extends \yii\db\ActiveRecord
|
||||
{
|
||||
@ -32,8 +36,8 @@ class Accesses extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name'], 'string', 'max' => 255],
|
||||
[['access'], 'string'],
|
||||
[['name', 'login', 'password', 'link', 'project' ], 'string', 'max' => 255],
|
||||
[['info'], 'string'],
|
||||
[['_projects'], 'safe'],
|
||||
[['_users'], 'safe'],
|
||||
];
|
||||
@ -47,7 +51,11 @@ class Accesses extends \yii\db\ActiveRecord
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => 'Название',
|
||||
'access' => 'Доступ',
|
||||
'login' => 'Логин',
|
||||
'password' => 'Пароль',
|
||||
'link' => 'Ссылка',
|
||||
'project' => 'Проект',
|
||||
'info' => 'Дополнительная информация',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ class FieldsValueNew extends \yii\db\ActiveRecord
|
||||
const TYPE_COMPANY = 2;
|
||||
const TYPE_BALANCE = 3;
|
||||
const TYPE_NOTE = 4;
|
||||
const TYPE_ACCESS = 5;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -23,6 +23,7 @@ class UseField extends \yii\db\ActiveRecord
|
||||
const USE_COMPANY = 2;
|
||||
const USE_BALANCE = 3;
|
||||
const USE_NOTE = 4;
|
||||
const USE_ACCESS = 5;
|
||||
|
||||
|
||||
/**
|
||||
@ -72,7 +73,8 @@ class UseField extends \yii\db\ActiveRecord
|
||||
self::USE_PROJECT => 'Проект',
|
||||
self::USE_COMPANY => 'Компания',
|
||||
self::USE_BALANCE => 'Баланс',
|
||||
self::USE_NOTE => 'Заметка'
|
||||
self::USE_NOTE => 'Заметка',
|
||||
self::USE_ACCESS => 'Доступ'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles dropping columns from table `{{%accesses}}`.
|
||||
*/
|
||||
class m200121_115737_drop_access_column_from_accesses_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->dropColumn('{{%accesses}}', 'access');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->addColumn('{{%accesses}}', 'access', $this->string());
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles adding columns to table `{{%accesses}}`.
|
||||
*/
|
||||
class m200121_120006_add_login_column_to_accesses_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->addColumn('{{%accesses}}', 'login', $this->string());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropColumn('{{%accesses}}', 'login');
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Handles adding columns to table `{{%accesses}}`.
|
||||
*/
|
||||
class m200121_120121_add_password_column_to_accesses_table extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$this->addColumn('{{%accesses}}', 'password', $this->string());
|
||||
$this->addColumn('{{%accesses}}', 'link', $this->string());
|
||||
$this->addColumn('{{%accesses}}', 'project', $this->string());
|
||||
$this->addColumn('{{%accesses}}', 'info', $this->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
$this->dropColumn('{{%accesses}}', 'password');
|
||||
$this->dropColumn('{{%accesses}}', 'link');
|
||||
$this->dropColumn('{{%accesses}}', 'project');
|
||||
$this->dropColumn('{{%accesses}}', 'info');
|
||||
}
|
||||
}
|
124
frontend/modules/access/controllers/AccessController.php
Executable file → Normal file
124
frontend/modules/access/controllers/AccessController.php
Executable file → Normal file
@ -3,28 +3,128 @@
|
||||
namespace frontend\modules\access\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Accesses;
|
||||
use frontend\modules\access\models\AccessSearch;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* AccessController implements the CRUD actions for Accesses model.
|
||||
*/
|
||||
class AccessController extends Controller
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['POST'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Accesses models.
|
||||
* @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,
|
||||
],
|
||||
$dataProvider = new ActiveDataProvider(['query' => Accesses::find()
|
||||
->where(['user_card.id_user' => Yii::$app->user->identity->id])
|
||||
->innerJoin('user_card_accesses', 'accesses.id = user_card_accesses.accesses_id')
|
||||
->innerJoin('user_card', 'user_card_accesses.user_card_id = user_card.id')
|
||||
]);
|
||||
|
||||
return $this->render('index', compact('dataProvider', $dataProvider));
|
||||
return $this->render('index', [
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single Accesses model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Accesses model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new \frontend\modules\access\models\Access();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Accesses model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
}
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Accesses model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Accesses model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return Accesses the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = Accesses::findOne($id)) !== null) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
|
29
frontend/modules/access/models/Access.php
Normal file
29
frontend/modules/access/models/Access.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace frontend\modules\access\models;
|
||||
|
||||
|
||||
use common\classes\Debug;
|
||||
use common\models\UserCardAccesses;
|
||||
use frontend\modules\card\models\UserCard;
|
||||
use Yii;
|
||||
|
||||
class Access extends \common\models\Accesses
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
}
|
||||
|
||||
public function afterSave($insert, $changedAttributes)
|
||||
{
|
||||
parent::afterSave($insert, $changedAttributes); // TODO: Change the autogenerated stub
|
||||
|
||||
$user_card = UserCard::findOne(['id_user' => Yii::$app->user->identity->id]);
|
||||
$user_card_access = new UserCardAccesses();
|
||||
$user_card_access->user_card_id = $user_card->id;
|
||||
$user_card_access->accesses_id = $this->id;
|
||||
$user_card_access->save();
|
||||
}
|
||||
}
|
73
frontend/modules/access/models/AccessSearch.php
Normal file
73
frontend/modules/access/models/AccessSearch.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\modules\access\models;
|
||||
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Accesses;
|
||||
|
||||
/**
|
||||
* AccessSearch represents the model behind the search form of `common\models\Accesses`.
|
||||
*/
|
||||
class AccessSearch extends Accesses
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id'], 'integer'],
|
||||
[['name', 'login', 'password', 'link', 'project', 'info'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Accesses::find();
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name])
|
||||
->andFilterWhere(['like', 'login', $this->login])
|
||||
->andFilterWhere(['like', 'password', $this->password])
|
||||
->andFilterWhere(['like', 'link', $this->link])
|
||||
->andFilterWhere(['like', 'project', $this->project])
|
||||
->andFilterWhere(['like', 'info', $this->info]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
33
frontend/modules/access/views/access/_form.php
Normal file
33
frontend/modules/access/views/access/_form.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Accesses */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="accesses-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'login')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'password')->passwordInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'link')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'project')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'info')->textarea(['rows' => 6]) ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
39
frontend/modules/access/views/access/_search.php
Normal file
39
frontend/modules/access/views/access/_search.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model frontend\modules\access\models\AccessSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="accesses-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id') ?>
|
||||
|
||||
<?= $form->field($model, 'name') ?>
|
||||
|
||||
<?= $form->field($model, 'login') ?>
|
||||
|
||||
<?= $form->field($model, 'password') ?>
|
||||
|
||||
<?= $form->field($model, 'link') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'project') ?>
|
||||
|
||||
<?php // echo $form->field($model, 'info') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Поиск', ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton('Сброс', ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
18
frontend/modules/access/views/access/create.php
Normal file
18
frontend/modules/access/views/access/create.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Accesses */
|
||||
|
||||
$this->title = 'Добавить';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Accesses', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="accesses-create">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
31
frontend/modules/access/views/access/index.php
Executable file → Normal file
31
frontend/modules/access/views/access/index.php
Executable file → Normal file
@ -1,14 +1,37 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
$this->title = 'Доступы';
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel frontend\modules\access\models\AccessSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
echo GridView::widget([
|
||||
$this->title = 'Доступы';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="accesses-index">
|
||||
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Добавить', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
'id',
|
||||
'name',
|
||||
'access',
|
||||
'login',
|
||||
'password',
|
||||
'link',
|
||||
'project',
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{view} {update}',
|
||||
],
|
||||
]);
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
||||
|
19
frontend/modules/access/views/access/update.php
Normal file
19
frontend/modules/access/views/access/update.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Accesses */
|
||||
|
||||
$this->title = 'Изменить';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Доступы', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
|
||||
$this->params['breadcrumbs'][] = 'Изменить';
|
||||
?>
|
||||
<div class="accesses-update">
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
40
frontend/modules/access/views/access/view.php
Normal file
40
frontend/modules/access/views/access/view.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Accesses */
|
||||
|
||||
$this->title = $model->name;
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Accesses', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
\yii\web\YiiAsset::register($this);
|
||||
?>
|
||||
<div class="accesses-view">
|
||||
<p>
|
||||
<?= Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a('Удалить', ['delete', 'id' => $model->id], [
|
||||
'class' => 'btn btn-danger',
|
||||
'data' => [
|
||||
'confirm' => 'Вы уверенны, что хотите удалить эту запись?',
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
<?= Html::a('Список', ['index'], ['class' => 'btn btn-primary']) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id',
|
||||
'name',
|
||||
'login',
|
||||
'password',
|
||||
'link',
|
||||
'project',
|
||||
'info:ntext',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
@ -15,6 +15,22 @@ use yii\helpers\ArrayHelper;
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'fio')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'gender')->dropDownList($model->genders, ['prompt' => 'Выберите']) ?>
|
||||
|
||||
<?= $form->field($model, 'dob')->input(
|
||||
'date',
|
||||
[
|
||||
'placeholder' => 'Zadejte svůj Datum narození',
|
||||
'language' => 'en',
|
||||
"data-format" => "DD MMMM YYYY",
|
||||
|
||||
]
|
||||
) ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<?= $form->field($model, 'skill')->widget(
|
||||
|
@ -57,8 +57,6 @@ $this->title = 'Профиль';
|
||||
<?php foreach ($skills as $skill) : ?>
|
||||
<span class="btn btn-default btn-sm"><?= $skill['skill']->name; ?></span>
|
||||
<?php endforeach; ?>
|
||||
<br><br>
|
||||
<?= Html::a('Добавить', ['/card/user-card/update', 'id' => $model->id], ['class' => 'btn btn-success']); ?>
|
||||
|
||||
<h2>Дополнительные сведения</h2>
|
||||
|
||||
@ -80,4 +78,6 @@ $this->title = 'Профиль';
|
||||
],
|
||||
]); ?>
|
||||
|
||||
<?= Html::a('Изменить', ['/card/user-card/update', 'id' => $model->id], ['class' => 'btn btn-success']); ?>
|
||||
|
||||
</div>
|
||||
|
0
frontend/web/log.txt
Executable file
0
frontend/web/log.txt
Executable file
Loading…
Reference in New Issue
Block a user