Merge pull request #108 from apuc/for_managers_show_only_employees
For managers show only employees
This commit is contained in:
commit
c65b7d10cc
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace backend\modules\card\models;
|
namespace backend\modules\card\models;
|
||||||
|
|
||||||
use common\classes\Debug;
|
use backend\modules\employee\models\ManagerEmployee;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
@ -42,10 +42,24 @@ class UserCardSearch extends UserCard
|
|||||||
*
|
*
|
||||||
* @return ActiveDataProvider
|
* @return ActiveDataProvider
|
||||||
*/
|
*/
|
||||||
public function search($params)
|
public function search($params): ActiveDataProvider
|
||||||
{
|
{
|
||||||
|
if (Yii::$app->user->can('show_all_profiles')) {
|
||||||
$query = UserCard::find();
|
$query = UserCard::find();
|
||||||
$query->where(['id'])->distinct()
|
} else {
|
||||||
|
$userCard = UserCard::find()
|
||||||
|
->where(['id_user' => Yii::$app->user->id])
|
||||||
|
->one();
|
||||||
|
|
||||||
|
$employeeIdList = ManagerEmployee::find()
|
||||||
|
->where(['manager_id' => $userCard->manager->id])
|
||||||
|
->select('user_card_id')
|
||||||
|
->column();
|
||||||
|
|
||||||
|
$query = UserCard::find()->where(['in', 'user_card.id', $employeeIdList]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query->distinct()
|
||||||
->leftJoin('card_skill', 'card_skill.card_id=user_card.id')
|
->leftJoin('card_skill', 'card_skill.card_id=user_card.id')
|
||||||
->leftJoin('skill', 'skill.id=card_skill.skill_id');
|
->leftJoin('skill', 'skill.id=card_skill.skill_id');
|
||||||
|
|
||||||
@ -61,7 +75,7 @@ class UserCardSearch extends UserCard
|
|||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query->where(['deleted_at' => null]);
|
$query->andWhere(['deleted_at' => null]);
|
||||||
|
|
||||||
if (isset($params['month'])) {
|
if (isset($params['month'])) {
|
||||||
$query->andFilterWhere(['=', 'MONTH(dob)', $params['month']]);
|
$query->andFilterWhere(['=', 'MONTH(dob)', $params['month']]);
|
||||||
|
@ -20,8 +20,9 @@ use yii\widgets\ActiveForm;
|
|||||||
'data' => Manager::find()->select(['fio', 'manager.id'])
|
'data' => Manager::find()->select(['fio', 'manager.id'])
|
||||||
->joinWith('userCard')->indexBy('manager.id')->column(),
|
->joinWith('userCard')->indexBy('manager.id')->column(),
|
||||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||||
|
'hideSearch' => false,
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
'allowClear' => true
|
'allowClear' => true,
|
||||||
],
|
],
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
@ -30,9 +31,11 @@ use yii\widgets\ActiveForm;
|
|||||||
'data' => UserCard::find()->select(['fio', 'user_card.id'])
|
'data' => UserCard::find()->select(['fio', 'user_card.id'])
|
||||||
->joinWith('manager')->where(['manager.user_card_id' => null])->indexBy('user_card.id')->column(),
|
->joinWith('manager')->where(['manager.user_card_id' => null])->indexBy('user_card.id')->column(),
|
||||||
'options' => ['placeholder' => '...','class' => 'form-control'],
|
'options' => ['placeholder' => '...','class' => 'form-control'],
|
||||||
|
'hideSearch' => false,
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
'allowClear' => true,
|
'allowClear' => true,
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
|
'closeOnSelect' => false
|
||||||
],
|
],
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
|
@ -43,6 +43,10 @@ YiiAsset::register($this);
|
|||||||
],
|
],
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
Сотрудники менеджера
|
||||||
|
</h2>
|
||||||
|
|
||||||
<?= GridView::widget([
|
<?= GridView::widget([
|
||||||
'dataProvider' => $managerEmployeeDataProvider,
|
'dataProvider' => $managerEmployeeDataProvider,
|
||||||
'columns' => [
|
'columns' => [
|
||||||
|
@ -93,6 +93,7 @@ class RbacController extends Controller
|
|||||||
$profileEditor = $auth->getRole('profileEditor');
|
$profileEditor = $auth->getRole('profileEditor');
|
||||||
|
|
||||||
if(!$auth->getPermission('test')) {
|
if(!$auth->getPermission('test')) {
|
||||||
|
echo "create permission: test\n";
|
||||||
$test = $auth->createPermission('test');
|
$test = $auth->createPermission('test');
|
||||||
$test->description = 'Модуль "Тестовые задания"';
|
$test->description = 'Модуль "Тестовые задания"';
|
||||||
$auth->add($test);
|
$auth->add($test);
|
||||||
@ -100,6 +101,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('questionnaire')) {
|
if(!$auth->getPermission('questionnaire')) {
|
||||||
|
echo "create permission: questionnaire\n";
|
||||||
$questionnaire = $auth->createPermission('questionnaire');
|
$questionnaire = $auth->createPermission('questionnaire');
|
||||||
$questionnaire->description = 'Модуль "Анкеты": Создание, редактирование анкет, категорий анкет, вопросов, проверка ответов пользователей';
|
$questionnaire->description = 'Модуль "Анкеты": Создание, редактирование анкет, категорий анкет, вопросов, проверка ответов пользователей';
|
||||||
$auth->add($questionnaire);
|
$auth->add($questionnaire);
|
||||||
@ -107,6 +109,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('interview')) {
|
if(!$auth->getPermission('interview')) {
|
||||||
|
echo "create permission: interview\n";
|
||||||
$interview = $auth->createPermission('interview');
|
$interview = $auth->createPermission('interview');
|
||||||
$interview->description = 'Модуль "Запрос интервью"';
|
$interview->description = 'Модуль "Запрос интервью"';
|
||||||
$auth->add($interview);
|
$auth->add($interview);
|
||||||
@ -114,6 +117,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('options')) {
|
if(!$auth->getPermission('options')) {
|
||||||
|
echo "create permission: options\n";
|
||||||
$options = $auth->createPermission('options');
|
$options = $auth->createPermission('options');
|
||||||
$options->description = 'Модуль "Опции"';
|
$options->description = 'Модуль "Опции"';
|
||||||
$auth->add($options);
|
$auth->add($options);
|
||||||
@ -121,12 +125,14 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('reports')) {
|
if(!$auth->getPermission('reports')) {
|
||||||
|
echo "create permission: reports\n";
|
||||||
$reports = $auth->createPermission('reports');
|
$reports = $auth->createPermission('reports');
|
||||||
$reports->description = 'Модуль "Отчёты"';
|
$reports->description = 'Модуль "Отчёты"';
|
||||||
$auth->add($reports);
|
$auth->add($reports);
|
||||||
$auth->addChild($admin, $reports);
|
$auth->addChild($admin, $reports);
|
||||||
}
|
}
|
||||||
if(!$auth->getPermission('calendar')) {
|
if(!$auth->getPermission('calendar')) {
|
||||||
|
echo "create permission: calendar\n";
|
||||||
$calendar = $auth->createPermission('calendar');
|
$calendar = $auth->createPermission('calendar');
|
||||||
$calendar->description = 'Модуль "Календарь ДР"';
|
$calendar->description = 'Модуль "Календарь ДР"';
|
||||||
$auth->add($calendar);
|
$auth->add($calendar);
|
||||||
@ -134,6 +140,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('notes')) {
|
if(!$auth->getPermission('notes')) {
|
||||||
|
echo "create permission: notes\n";
|
||||||
$notes = $auth->createPermission('notes');
|
$notes = $auth->createPermission('notes');
|
||||||
$notes->description = 'Модуль "Заметки"';
|
$notes->description = 'Модуль "Заметки"';
|
||||||
$auth->add($notes);
|
$auth->add($notes);
|
||||||
@ -141,6 +148,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('accesses')) {
|
if(!$auth->getPermission('accesses')) {
|
||||||
|
echo "create permission: accesses\n";
|
||||||
$accesses = $auth->createPermission('accesses');
|
$accesses = $auth->createPermission('accesses');
|
||||||
$accesses->description = 'Модуль "Доступы"';
|
$accesses->description = 'Модуль "Доступы"';
|
||||||
$auth->add($accesses);
|
$auth->add($accesses);
|
||||||
@ -148,6 +156,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('achievements')) {
|
if(!$auth->getPermission('achievements')) {
|
||||||
|
echo "create permission: achievements\n";
|
||||||
$achievements = $auth->createPermission('achievements');
|
$achievements = $auth->createPermission('achievements');
|
||||||
$achievements->description = 'Модуль "Достижения"';
|
$achievements->description = 'Модуль "Достижения"';
|
||||||
$auth->add($achievements);
|
$auth->add($achievements);
|
||||||
@ -155,12 +164,14 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('holiday')) {
|
if(!$auth->getPermission('holiday')) {
|
||||||
|
echo "create permission: holiday\n";
|
||||||
$holiday = $auth->createPermission('holiday');
|
$holiday = $auth->createPermission('holiday');
|
||||||
$holiday->description = 'Модуль "Отпуска"';
|
$holiday->description = 'Модуль "Отпуска"';
|
||||||
$auth->add($holiday);
|
$auth->add($holiday);
|
||||||
$auth->addChild($admin, $holiday);
|
$auth->addChild($admin, $holiday);
|
||||||
}
|
}
|
||||||
if(!$auth->getPermission('balance')) {
|
if(!$auth->getPermission('balance')) {
|
||||||
|
echo "create permission: balance\n";
|
||||||
$balance = $auth->createPermission('balance');
|
$balance = $auth->createPermission('balance');
|
||||||
$balance->description = 'Модуль "Баланс"';
|
$balance->description = 'Модуль "Баланс"';
|
||||||
$auth->add($balance);
|
$auth->add($balance);
|
||||||
@ -168,6 +179,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('hh')) {
|
if(!$auth->getPermission('hh')) {
|
||||||
|
echo "create permission: hh\n";
|
||||||
$hh = $auth->createPermission('hh');
|
$hh = $auth->createPermission('hh');
|
||||||
$hh->description = 'Модуль "Hh.ru"';
|
$hh->description = 'Модуль "Hh.ru"';
|
||||||
$auth->add($hh);
|
$auth->add($hh);
|
||||||
@ -175,6 +187,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('company')) {
|
if(!$auth->getPermission('company')) {
|
||||||
|
echo "create permission: company\n";
|
||||||
$company = $auth->createPermission('company');
|
$company = $auth->createPermission('company');
|
||||||
$company->description = 'Модуль "Компании"';
|
$company->description = 'Модуль "Компании"';
|
||||||
$auth->add($company);
|
$auth->add($company);
|
||||||
@ -182,6 +195,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('task')) {
|
if(!$auth->getPermission('task')) {
|
||||||
|
echo "create permission: task\n";
|
||||||
$task = $auth->createPermission('task');
|
$task = $auth->createPermission('task');
|
||||||
$task->description = 'Модуль "Задачи"';
|
$task->description = 'Модуль "Задачи"';
|
||||||
$auth->add($task);
|
$auth->add($task);
|
||||||
@ -189,6 +203,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('project')) {
|
if(!$auth->getPermission('project')) {
|
||||||
|
echo "create permission: project\n";
|
||||||
$project = $auth->createPermission('project');
|
$project = $auth->createPermission('project');
|
||||||
$project->description = 'Модуль "Проекты"';
|
$project->description = 'Модуль "Проекты"';
|
||||||
$auth->add($project);
|
$auth->add($project);
|
||||||
@ -196,6 +211,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('document')) {
|
if(!$auth->getPermission('document')) {
|
||||||
|
echo "create permission: document\n";
|
||||||
$documents = $auth->createPermission('document');
|
$documents = $auth->createPermission('document');
|
||||||
$documents->description = 'Модуль "Документы": Создание, редактирование документов, их полей и шаблонов';
|
$documents->description = 'Модуль "Документы": Создание, редактирование документов, их полей и шаблонов';
|
||||||
$auth->add($documents);
|
$auth->add($documents);
|
||||||
@ -203,6 +219,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('employee')) {
|
if(!$auth->getPermission('employee')) {
|
||||||
|
echo "create permission: employee\n";
|
||||||
$employee = $auth->createPermission('employee');
|
$employee = $auth->createPermission('employee');
|
||||||
$employee->description = 'Модуль "Сотрудники"';
|
$employee->description = 'Модуль "Сотрудники"';
|
||||||
$auth->add($employee);
|
$auth->add($employee);
|
||||||
@ -210,6 +227,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('card')) {
|
if(!$auth->getPermission('card')) {
|
||||||
|
echo "create permission: card\n";
|
||||||
$card = $auth->createPermission('card');
|
$card = $auth->createPermission('card');
|
||||||
$card->description = 'Модуль "Профили"';
|
$card->description = 'Модуль "Профили"';
|
||||||
$auth->add($card);
|
$auth->add($card);
|
||||||
@ -218,6 +236,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('settings')) {
|
if(!$auth->getPermission('settings')) {
|
||||||
|
echo "create permission: settings\n";
|
||||||
$settings = $auth->createPermission('settings');
|
$settings = $auth->createPermission('settings');
|
||||||
$settings->description = 'Модуль "Настройки"';
|
$settings->description = 'Модуль "Настройки"';
|
||||||
$auth->add($settings);
|
$auth->add($settings);
|
||||||
@ -225,6 +244,7 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('settings/skill')) {
|
if(!$auth->getPermission('settings/skill')) {
|
||||||
|
echo "create permission: settings/skill\n";
|
||||||
$skills = $auth->createPermission('settings/skill');
|
$skills = $auth->createPermission('settings/skill');
|
||||||
$skills->description = 'Навыки';
|
$skills->description = 'Навыки';
|
||||||
$auth->add($skills);
|
$auth->add($skills);
|
||||||
@ -233,13 +253,19 @@ class RbacController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$auth->getPermission('settings/mark')) {
|
if(!$auth->getPermission('settings/mark')) {
|
||||||
|
echo "create permission: settings/mark\n";
|
||||||
$mark = $auth->createPermission('settings/mark');
|
$mark = $auth->createPermission('settings/mark');
|
||||||
$mark->description = 'Метки';
|
$mark->description = 'Метки';
|
||||||
$auth->add($mark);
|
$auth->add($mark);
|
||||||
$auth->addChild($admin, $mark);
|
$auth->addChild($admin, $mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
var_dump($auth->getPermission('settings/mark'));
|
if(!$auth->getPermission('show_all_profiles')) {
|
||||||
|
echo "create permission: show_all_profiles\n";
|
||||||
|
$showAllProfiles = $auth->createPermission('show_all_profiles');
|
||||||
|
$showAllProfiles->description = 'Показ всех сотрудников в модуле Профили';
|
||||||
|
$auth->add($showAllProfiles);
|
||||||
|
$auth->addChild($admin, $showAllProfiles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user