changes in manager and manager_employee, replaced user_id to card_id
This commit is contained in:
@ -75,7 +75,7 @@ return [
|
||||
'components' => [
|
||||
'request' => [
|
||||
'csrfParam' => '_csrf-backend',
|
||||
'baseUrl' => '', // /secure
|
||||
'baseUrl' => '/secure',
|
||||
'parsers' => [
|
||||
'application/json' => 'yii\web\JsonParser',
|
||||
'text/xml' => 'yii/web/XmlParser',
|
||||
|
@ -57,7 +57,7 @@ class ManagerController extends Controller
|
||||
$model = $this->findModel($id);
|
||||
$managerEmployeeSearchModel = new ManagerEmployeeSearch();
|
||||
$managerEmployeeDataProvider = new ActiveDataProvider([
|
||||
'query' => $model->getManagerEmployees()->with('user'),
|
||||
'query' => $model->getManagerEmployees()->with('userCard'),
|
||||
'pagination' => [
|
||||
'pageSize' => 20,
|
||||
],
|
||||
|
@ -5,6 +5,7 @@ namespace backend\modules\employee\controllers;
|
||||
use Yii;
|
||||
use backend\modules\employee\models\ManagerEmployee;
|
||||
use backend\modules\employee\models\ManagerEmployeeSearch;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
@ -64,12 +65,31 @@ class ManagerEmployeeController extends Controller
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new ManagerEmployee();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id]);
|
||||
|
||||
|
||||
|
||||
$post = $post = \Yii::$app->request->post('ManagerEmployee');
|
||||
|
||||
if (!empty($post)) {
|
||||
$user_card_id_arr = ArrayHelper::getValue($post,'user_card_id');
|
||||
|
||||
foreach ($user_card_id_arr as $user_card_id) {
|
||||
$emtModel = new ManagerEmployee();
|
||||
$emtModel->manager_id = $post['manager_id'];
|
||||
$emtModel->user_card_id = $user_card_id;
|
||||
|
||||
if (!$emtModel->save()) {
|
||||
return $this->render('create', [
|
||||
'model' => $emtModel,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
$model = new ManagerEmployee();
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
|
@ -17,7 +17,7 @@ class ManagerEmployeeSearch extends ManagerEmployee
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'manager_id', 'employee_id'], 'integer'],
|
||||
[['id', 'manager_id', 'user_card_id'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ class ManagerEmployeeSearch extends ManagerEmployee
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = ManagerEmployee::find()->joinWith(['user', 'manager']);
|
||||
$query = ManagerEmployee::find()->joinWith(['userCard', 'manager']);
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
@ -59,7 +59,7 @@ class ManagerEmployeeSearch extends ManagerEmployee
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'manager_id' => $this->manager_id,
|
||||
'employee_id' => $this->employee_id,
|
||||
'user_card_id' => $this->user_card_id,
|
||||
]);
|
||||
|
||||
return $dataProvider;
|
||||
|
@ -17,7 +17,7 @@ class ManagerSearch extends Manager
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'user_id'], 'integer'],
|
||||
[['id', 'user_card_id'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ class ManagerSearch extends Manager
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Manager::find()->with('user');
|
||||
$query = Manager::find()->with('userCard');
|
||||
|
||||
// add conditions that should always apply here
|
||||
|
||||
@ -58,7 +58,7 @@ class ManagerSearch extends Manager
|
||||
// grid filtering conditions
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'user_id' => $this->user_id,
|
||||
'user_card_id' => $this->user_card_id,
|
||||
]);
|
||||
|
||||
return $dataProvider;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\card\models\UserCard;
|
||||
use backend\modules\employee\models\Manager;
|
||||
use common\models\User;
|
||||
use kartik\select2\Select2;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
@ -17,26 +17,27 @@ use yii\widgets\ActiveForm;
|
||||
|
||||
<?= $form->field($model, 'manager_id')->widget(Select2::className(),
|
||||
[
|
||||
'data' => Manager::find()->select(['username', 'manager.id'])
|
||||
->joinWith('user')->indexBy('manager.id')->column(),
|
||||
'data' => Manager::find()->select(['fio', 'manager.id'])
|
||||
->joinWith('userCard')->indexBy('manager.id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<?= $form->field($model, 'employee_id')->widget(Select2::className(),
|
||||
<?= $form->field($model, 'user_card_id')->widget(Select2::className(),
|
||||
[
|
||||
'data' => User::find()->select(['username', 'user.id'])
|
||||
->joinWith('manager')->where(['manager.user_id' => null])->indexBy('user.id')->column(),
|
||||
'data' => UserCard::find()->select(['fio', 'user_card.id'])
|
||||
->joinWith('manager')->where(['manager.user_card_id' => null])->indexBy('user_card.id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
'allowClear' => true,
|
||||
'multiple' => true,
|
||||
],
|
||||
]) ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||
<?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\card\models\UserCard;
|
||||
use common\models\ManagerEmployee;
|
||||
use common\models\User;
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
@ -24,15 +26,17 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
[
|
||||
'attribute' => 'manager_id',
|
||||
'filter' => User::find()->select(['username', 'user.id'])
|
||||
->joinWith('manager')->where(['not',['manager.user_id' => null]])->indexBy('user.id')->column(),
|
||||
'value' => 'manager.user.username',
|
||||
'filter' => UserCard::find()->select(['fio', 'user_card.id'])
|
||||
->joinWith('manager')->where(['not',['manager.user_card_id' => null]])
|
||||
->indexBy('user_card.id')->column(),
|
||||
'value' => 'manager.userCard.fio',
|
||||
],
|
||||
[
|
||||
'attribute' => 'employee_id',
|
||||
'filter' => User::find()->select(['username', 'user.id'])
|
||||
->joinWith('manager')->where(['manager.user_id' => null])->indexBy('user.id')->column(),
|
||||
'value' => 'user.username',
|
||||
'attribute' => 'user_card_id',
|
||||
'filter' => ManagerEmployee::find()->select(['fio', 'manager_employee.id'])
|
||||
->joinWith('userCard')
|
||||
->indexBy('manager_employee.id')->column(),
|
||||
'value' => 'userCard.fio',
|
||||
],
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
|
@ -36,11 +36,11 @@ YiiAsset::register($this);
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'manager_id',
|
||||
'value' => ArrayHelper::getValue($model,'manager.user.username'),
|
||||
'value' => ArrayHelper::getValue($model,'manager.userCard.fio'),
|
||||
],
|
||||
[
|
||||
'attribute' => 'employee_id',
|
||||
'value' => ArrayHelper::getValue($model,'user.username'),
|
||||
'value' => ArrayHelper::getValue($model,'userCard.fio'),
|
||||
],
|
||||
],
|
||||
]) ?>
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\card\models\UserCard;
|
||||
use common\models\User;
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
@ -14,10 +15,11 @@ use kartik\select2\Select2;
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'user_id')->widget(Select2::className(),
|
||||
<?= $form->field($model, 'user_card_id')->widget(Select2::className(),
|
||||
[
|
||||
'data' => User::find()->select(['username', 'user.id'])
|
||||
->joinWith('manager')->where(['manager.user_id' => null])->indexBy('user.id')->column(),
|
||||
'data' => UserCard::find()->select(['user_card.fio', 'user_card.id'])
|
||||
->joinWith('manager')->where(['manager.user_card_id' => null])
|
||||
->indexBy('user_card.id')->column(),
|
||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => true
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\card\models\UserCard;
|
||||
use common\models\User;
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
@ -23,9 +24,9 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
[
|
||||
'attribute' => 'user_id',
|
||||
'filter' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'user.username',
|
||||
'attribute' => 'user_card_id',
|
||||
'filter' => UserCard::find()->select(['fio', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'userCard.fio',
|
||||
|
||||
],
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use backend\modules\card\models\UserCard;
|
||||
use common\models\User;
|
||||
use kartik\grid\GridView;
|
||||
use yii\helpers\ArrayHelper;
|
||||
@ -37,7 +38,7 @@ YiiAsset::register($this);
|
||||
'id',
|
||||
[
|
||||
'attribute' => 'user_id',
|
||||
'value' => ArrayHelper::getValue($model,'user.username'),
|
||||
'value' => ArrayHelper::getValue($model,'userCard.fio'),
|
||||
],
|
||||
],
|
||||
]) ?>
|
||||
@ -47,9 +48,9 @@ YiiAsset::register($this);
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
[
|
||||
'attribute' => 'user_id',
|
||||
'filter' => User::find()->select(['username', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'user.username',
|
||||
'attribute' => 'user_card_id',
|
||||
'filter' => UserCard::find()->select(['fio', 'id'])->indexBy('id')->column(),
|
||||
'value' => 'userCard.fio',
|
||||
],
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
|
@ -21,8 +21,9 @@ use yii\widgets\ActiveForm;
|
||||
->where(['!=', 'question_type_id', '1'])
|
||||
->indexBy('id')
|
||||
->column(),
|
||||
'options' => ['placeholder' => 'Выберите проект'],
|
||||
'pluginOptions' => [
|
||||
'allowClear' => false
|
||||
'allowClear' => false,
|
||||
],
|
||||
]) ?>
|
||||
|
||||
|
@ -71,7 +71,7 @@ YiiAsset::register($this);
|
||||
|
||||
[
|
||||
'attribute' => 'project_user_id',
|
||||
'value' => 'projectUser.user.username'
|
||||
'value' => 'projectUser.card.fio'
|
||||
],
|
||||
|
||||
[
|
||||
|
@ -27,7 +27,7 @@
|
||||
['label' => 'Должность', 'icon' => 'spotify', 'url' => ['/settings/position'], 'active' => \Yii::$app->controller->id == 'position'],
|
||||
['label' => 'Навыки', 'icon' => 'flask', 'url' => ['/settings/skill'], 'active' => \Yii::$app->controller->id == 'skill'],
|
||||
],
|
||||
//TODO 'visible' => Yii::$app->user->can('confidential_information')
|
||||
'visible' => Yii::$app->user->can('confidential_information')
|
||||
],
|
||||
[
|
||||
'label' => 'Профили', 'icon' => 'address-book-o', 'url' => '#', 'active' => \Yii::$app->controller->id == 'user-card',
|
||||
@ -39,12 +39,12 @@
|
||||
['label' => 'Менеджеры', 'icon' => 'user-circle-o', 'url' => ['/employee/manager'], 'active' => \Yii::$app->controller->id == 'manager'],
|
||||
['label' => 'Работники', 'icon' => 'user', 'url' => ['/employee/manager-employee'], 'active' => \Yii::$app->controller->id == 'manager-employee'],
|
||||
],
|
||||
//TODO 'visible' => Yii::$app->user->can('confidential_information')
|
||||
'visible' => Yii::$app->user->can('confidential_information')
|
||||
],
|
||||
[
|
||||
'label' => 'Проекты', 'icon' => 'cubes', 'url' => ['#'], //'active' => \Yii::$app->controller->id == 'project',
|
||||
'items' => $projectItems,
|
||||
//TODO 'visible' => Yii::$app->user->can('confidential_information')
|
||||
'visible' => Yii::$app->user->can('confidential_information')
|
||||
],
|
||||
[
|
||||
'label' => 'Задачи', 'icon' => 'tasks', 'url' => '#',
|
||||
@ -53,7 +53,7 @@
|
||||
['label' => 'Исполнители задачи', 'icon' => 'users', 'url' => ['/task/task-user'], 'active' => \Yii::$app->controller->id == 'task-user'],
|
||||
],
|
||||
|
||||
//TODO 'visible' => Yii::$app->user->can('confidential_information')
|
||||
'visible' => Yii::$app->user->can('confidential_information')
|
||||
],
|
||||
['label' => 'Компании', 'icon' => 'building', 'url' => ['/company/company'], 'active' => \Yii::$app->controller->id == 'company', 'visible' => Yii::$app->user->can('confidential_information')],
|
||||
[
|
||||
@ -62,7 +62,7 @@
|
||||
['label' => 'Компании', 'icon' => 'building', 'url' => ['/hh/hh'], 'active' => \Yii::$app->controller->id == 'hh'],
|
||||
['label' => 'Вакансии', 'icon' => 'user-md', 'url' => ['/hh/hh-job'], 'active' => \Yii::$app->controller->id == 'hh-job'],
|
||||
],
|
||||
//TODO 'visible' => Yii::$app->user->can('confidential_information')
|
||||
'visible' => Yii::$app->user->can('confidential_information')
|
||||
],
|
||||
['label' => 'Баланс', 'icon' => 'dollar', 'url' => ['/balance/balance'], 'active' => \Yii::$app->controller->id == 'balance', 'visible' => Yii::$app->user->can('confidential_information')],
|
||||
['label' => 'Отпуска', 'icon' => 'plane', 'url' => ['/holiday/holiday'], 'active' => \Yii::$app->controller->id == 'holiday', 'visible' => Yii::$app->user->can('confidential_information')],
|
||||
@ -77,7 +77,7 @@
|
||||
'icon' => 'list-alt',
|
||||
'url' => ['/interview/interview'],
|
||||
'active' => \Yii::$app->controller->id == 'interview',
|
||||
//TODO 'visible' => Yii::$app->user->can('confidential_information'),
|
||||
'visible' => Yii::$app->user->can('confidential_information'),
|
||||
'badge' => '<span class="badge badge-info right">4</span>'
|
||||
],
|
||||
[
|
||||
@ -91,7 +91,7 @@
|
||||
['label' => 'Анкеты пользователей', 'icon' => 'drivers-license', 'url' => ['/questionnaire/user-questionnaire'], 'active' => \Yii::$app->controller->id == 'user-questionnaire'],
|
||||
['label' => 'Ответы пользователей', 'icon' => 'comments', 'url' => ['/questionnaire/user-response'], 'active' => \Yii::$app->controller->id == 'user-response'],
|
||||
],
|
||||
//TODO 'visible' => Yii::$app->user->can('confidential_information')
|
||||
'visible' => Yii::$app->user->can('confidential_information')
|
||||
],
|
||||
|
||||
/*['label' => 'Gii', 'icon' => 'file-code-o', 'url' => ['/gii']],
|
||||
|
Reference in New Issue
Block a user