Merge branch 'master' of https://github.com/apuc/guild
This commit is contained in:
@ -89,11 +89,6 @@ class Answer extends \yii\db\ActiveRecord
|
||||
->viaTable('question', ['id' => 'question_id']);
|
||||
}
|
||||
|
||||
// public function getUserQuestionnaire()
|
||||
// {
|
||||
// return $this->hasOne(\backend\modules\questionnaire\models\UserQuestionnaire::className(), ['id'])
|
||||
// }
|
||||
|
||||
static function numCorrectAnswers($question_id)
|
||||
{
|
||||
return Answer::find()
|
||||
|
@ -11,6 +11,8 @@ use Yii;
|
||||
* @property int $mark_id
|
||||
* @property int $entity_type
|
||||
* @property int $entity_id
|
||||
*
|
||||
* @property Mark $mark
|
||||
*/
|
||||
class MarkEntity extends \yii\db\ActiveRecord
|
||||
{
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveQuery;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
@ -23,9 +22,11 @@ use yii\helpers\ArrayHelper;
|
||||
*
|
||||
* @property FieldsValue[] $fieldsValues
|
||||
* @property Company $company
|
||||
* @property User $owner
|
||||
* @property ProjectUser[] $projectUsers
|
||||
* @property Mark[] $mark
|
||||
* @property MarkEntity[] $markEntity
|
||||
* @property ProjectTask[] $projectTask
|
||||
*/
|
||||
class Project extends \yii\db\ActiveRecord
|
||||
{
|
||||
@ -55,8 +56,8 @@ class Project extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
['name', 'unique'],
|
||||
[['name', 'status'], 'required'],
|
||||
[['name', 'owner_id', 'status'], 'required'],
|
||||
[['owner_id', 'name'], 'unique', 'targetAttribute' => ['owner_id', 'name']],
|
||||
[['description'], 'string'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['status'], 'exist', 'skipOnError' => true, 'targetClass' => Status::class, 'targetAttribute' => ['status' => 'id']],
|
||||
@ -88,7 +89,7 @@ class Project extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getFieldsValues()
|
||||
{
|
||||
@ -96,7 +97,7 @@ class Project extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getCompany()
|
||||
{
|
||||
@ -104,7 +105,7 @@ class Project extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getColumns()
|
||||
{
|
||||
@ -114,7 +115,15 @@ class Project extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getProjectTask(): ActiveQuery
|
||||
{
|
||||
return $this->hasMany(ProjectTask::class, ['project_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
@ -122,7 +131,7 @@ class Project extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getHh()
|
||||
{
|
||||
@ -130,7 +139,7 @@ class Project extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getProjectUsers()
|
||||
{
|
||||
@ -138,7 +147,7 @@ class Project extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getMark()
|
||||
{
|
||||
@ -147,7 +156,7 @@ class Project extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getMarkEntity()
|
||||
{
|
||||
|
@ -65,6 +65,7 @@ class ProjectColumn extends \yii\db\ActiveRecord
|
||||
return [
|
||||
[['title', 'project_id'], 'required'],
|
||||
[['project_id', 'status', 'priority'], 'integer'],
|
||||
['title', 'unique', 'targetAttribute' => ['title','project_id' => 'status']],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['title'], 'string', 'max' => 255],
|
||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
||||
|
53
common/models/ProjectRole.php
Normal file
53
common/models/ProjectRole.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "project_role".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $title
|
||||
*
|
||||
* @property ProjectUser[] $projectUsers
|
||||
*/
|
||||
class ProjectRole extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'project_role';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['title'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'title' => 'Название роли',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getProjectUsers()
|
||||
{
|
||||
return $this->hasMany(ProjectUser::className(), ['project_role_id' => 'id']);
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ use yii\helpers\ArrayHelper;
|
||||
* @property int $user_id
|
||||
* @property int $executor_id
|
||||
* @property int $priority
|
||||
* @property int $execution_priority
|
||||
* @property string $description
|
||||
* @property string $dead_line
|
||||
*
|
||||
@ -28,14 +29,55 @@ use yii\helpers\ArrayHelper;
|
||||
* @property User $user
|
||||
* @property UserCard $card
|
||||
* @property UserCard $cardIdCreator
|
||||
* @property Company $company
|
||||
* @property ProjectColumn $column
|
||||
* @property User $executor
|
||||
* @property Mark[] $mark
|
||||
* @property MarkEntity[] $markEntity
|
||||
* @property ProjectTaskUser[] $taskUsers
|
||||
*/
|
||||
class ProjectTask extends ActiveRecord
|
||||
{
|
||||
const STATUS_ACTIVE = 1;
|
||||
const STATUS_DISABLE = 0;
|
||||
const STATUS_ACTIVE = 1;
|
||||
const STATUS_ARCHIVE = 2;
|
||||
const STATUS_AT_WORK = 3;
|
||||
|
||||
const PRIORITY_LOW = 0;
|
||||
const PRIORITY_MEDIUM = 1;
|
||||
const PRIORITY_HIGH = 2;
|
||||
|
||||
const DAY_IN_UNIX_TIME = 86340; // 23:59:59
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function priorityList() :array
|
||||
{
|
||||
return [
|
||||
self::PRIORITY_LOW => 'Низкий',
|
||||
self::PRIORITY_MEDIUM => 'Средний',
|
||||
self::PRIORITY_HIGH => 'Высокий',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int[]
|
||||
*/
|
||||
public static function openTaskStatusList(): array
|
||||
{
|
||||
return [self::STATUS_ACTIVE, self::STATUS_AT_WORK];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $priority
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getPriority($priority): string
|
||||
{
|
||||
return ArrayHelper::getValue(self::priorityList(), $priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@ -64,10 +106,12 @@ class ProjectTask extends ActiveRecord
|
||||
{
|
||||
return [
|
||||
[['project_id', 'status', 'title', 'description',], 'required'],
|
||||
[['project_id', 'status', 'column_id', 'user_id', 'executor_id', 'priority'], 'integer'],
|
||||
[['project_id', 'status', 'column_id', 'user_id', 'executor_id', 'priority', 'execution_priority'], 'integer'],
|
||||
[['created_at', 'updated_at', 'dead_line'], 'safe'],
|
||||
['execution_priority', 'in', 'range' => [self::PRIORITY_LOW, self::PRIORITY_MEDIUM, self::PRIORITY_HIGH]],
|
||||
['title', 'unique', 'targetAttribute' => ['title', 'project_id'], 'message' => 'Такая задача уже создана'],
|
||||
[['title'], 'string', 'max' => 255],
|
||||
['status', 'in', 'range' => [self::STATUS_DISABLE, self::STATUS_ACTIVE, self::STATUS_ARCHIVE, self::STATUS_AT_WORK]],
|
||||
[['description'], 'string', 'max' => 1500],
|
||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||||
@ -94,6 +138,77 @@ class ProjectTask extends ActiveRecord
|
||||
'executor_id' => 'Исполнитель',
|
||||
'priority' => 'Приоритет',
|
||||
'dead_line' => 'Срок выполнения задачи',
|
||||
'execution_priority' => 'Приоритет выполнения',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function fields(): array
|
||||
{
|
||||
return [
|
||||
'id',
|
||||
'project_id',
|
||||
'project_name' => function () {
|
||||
return $this->project->name ?? null;
|
||||
},
|
||||
'title',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'dead_line',
|
||||
'description',
|
||||
'status',
|
||||
'column_id',
|
||||
'user_id',
|
||||
'user' => function () {
|
||||
return [
|
||||
"fio" => $this->user->userCard->fio ?? ($this->user->id ?? ''),
|
||||
"avatar" => $this->user->userCard->photo ?? '',
|
||||
];
|
||||
},
|
||||
'executor_id',
|
||||
'priority',
|
||||
'executor' => function () {
|
||||
if ($this->executor) {
|
||||
return [
|
||||
"fio" => $this->executor->userCard->fio ?? $this->executor->username,
|
||||
"avatar" => $this->executor->userCard->photo ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
'comment_count' => function () {
|
||||
return $this->getCommentCount();
|
||||
},
|
||||
'taskUsers',
|
||||
'mark',
|
||||
'execution_priority'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool|int|string|null
|
||||
*/
|
||||
public function getCommentCount()
|
||||
{
|
||||
return Comment::find()->where(['entity_id' => $this->id, 'entity_type' => 2, 'status' => Comment::STATUS_ACTIVE])->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function extraFields(): array
|
||||
{
|
||||
return [
|
||||
'timers',
|
||||
'column' => function () {
|
||||
return [
|
||||
'column_title' => $this->column->title ?? null
|
||||
];
|
||||
},
|
||||
'mark'
|
||||
];
|
||||
}
|
||||
|
||||
@ -124,6 +239,15 @@ class ProjectTask extends ActiveRecord
|
||||
return $this->hasOne(Project::className(), ['id' => 'project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getCompany(): ActiveQuery
|
||||
{
|
||||
return $this->hasOne(Company::class,['id' => 'company_id'])
|
||||
->via('project');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
@ -184,4 +308,71 @@ class ProjectTask extends ActiveRecord
|
||||
return ArrayHelper::map(
|
||||
self::find()->joinWith(['user', 'project'])->where(['project_id' => $task_id])->all(), 'id', 'user.username');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTaskUsersToStr(): string
|
||||
{
|
||||
$participants = '';
|
||||
foreach ($this->taskUsers as $taskUser) {
|
||||
$participants .= $taskUser->user->userCard->fio ?? $taskUser->user->username;
|
||||
$participants .= ', ';
|
||||
}
|
||||
return $participants;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMarkTitleToStr(): string
|
||||
{
|
||||
$tags = '';
|
||||
foreach ($this->markEntity as $markEntity) {
|
||||
$tags .= $markEntity->mark->title . ', ';
|
||||
}
|
||||
return $tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $companyId
|
||||
* @param int|null $userId
|
||||
* @param int|null $projectId
|
||||
* @param int|null $fromDate
|
||||
* @param int|null $toDate
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public static function genQueryToImport(
|
||||
int $companyId = null,
|
||||
int $userId = null,
|
||||
int $projectId = null,
|
||||
int $fromDate = null,
|
||||
int $toDate = null
|
||||
): ActiveQuery
|
||||
{
|
||||
$query = ProjectTask::find();
|
||||
|
||||
if ($companyId) {
|
||||
$query->joinWith('company')
|
||||
->andWhere(['company.id' => $companyId]);
|
||||
}
|
||||
|
||||
if ($userId) {
|
||||
$query->andWhere(['project_task.user_id' => $userId]);
|
||||
}
|
||||
|
||||
if ($projectId) {
|
||||
$query->andWhere(['project_task.project_id' => $projectId]);
|
||||
}
|
||||
|
||||
if ($fromDate) {
|
||||
$query->andFilterWhere(['>=', 'project_task.created_at', date("Y-m-d H:i:s", $fromDate)]);
|
||||
}
|
||||
|
||||
if ($toDate) {
|
||||
$query->andFilterWhere(['<=', 'project_task.created_at', date("Y-m-d H:i:s", ($toDate + self::DAY_IN_UNIX_TIME))]);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ use yii\db\ActiveQuery;
|
||||
* @property int $task_id
|
||||
* @property int $user_id
|
||||
*
|
||||
* @property ProjectUser $projectUser
|
||||
* @property ProjectTask $task
|
||||
* @property User $user
|
||||
*/
|
||||
class ProjectTaskUser extends \yii\db\ActiveRecord
|
||||
{
|
||||
|
@ -14,14 +14,28 @@ use yii\helpers\ArrayHelper;
|
||||
* @property int $card_id
|
||||
* @property int $project_id
|
||||
* @property int $user_id
|
||||
* @property int $project_role_id
|
||||
* @property int $status
|
||||
*
|
||||
* @property Project $project
|
||||
* @property UserCard $card
|
||||
* @property User $user
|
||||
* @property ProjectRole $projectRole
|
||||
* @property ProjectTaskUser[] $taskUsers
|
||||
*/
|
||||
class ProjectUser extends \yii\db\ActiveRecord
|
||||
{
|
||||
public const STATUS_INACTIVE = 0;
|
||||
public const STATUS_ACTIVE = 1;
|
||||
|
||||
public static function statusList() :array
|
||||
{
|
||||
return [
|
||||
self::STATUS_INACTIVE => 'Не активен',
|
||||
self::STATUS_ACTIVE => 'Активен',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -39,10 +53,13 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
[['user_id', 'project_id', 'card_id'], 'required'],
|
||||
['user_id', 'unique', 'targetAttribute' => ['user_id', 'project_id'], 'message'=>'Сотрудник уже назначен на этот проект'],
|
||||
['card_id', 'unique', 'targetAttribute' => ['card_id', 'project_id'], 'message'=>'Сотрудник уже назначен на этот проект'],
|
||||
[['card_id', 'project_id', 'user_id'], 'integer'],
|
||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::className(), 'targetAttribute' => ['project_id' => 'id']],
|
||||
[['card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['card_id' => 'id']],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||||
[['card_id', 'project_id', 'user_id', 'project_role_id', 'status'], 'integer'],
|
||||
[['status'], 'default', 'value'=> self::STATUS_ACTIVE],
|
||||
['status', 'in', 'range' => [self::STATUS_INACTIVE, self::STATUS_ACTIVE]],
|
||||
[['project_id'], 'exist', 'skipOnError' => true, 'targetClass' => Project::class, 'targetAttribute' => ['project_id' => 'id']],
|
||||
[['card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::class, 'targetAttribute' => ['card_id' => 'id']],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::class, 'targetAttribute' => ['user_id' => 'id']],
|
||||
[['project_role_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProjectRole::class, 'targetAttribute' => ['project_role_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
@ -56,6 +73,8 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
'card_id' => 'Карточка',
|
||||
'project_id' => 'Проект',
|
||||
'user_id' => 'Сотрудник',
|
||||
'project_role_id' => 'Роль на проекте',
|
||||
'status' => 'Статус'
|
||||
];
|
||||
}
|
||||
|
||||
@ -64,7 +83,7 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getProject()
|
||||
{
|
||||
return $this->hasOne(Project::className(), ['id' => 'project_id']);
|
||||
return $this->hasOne(Project::class, ['id' => 'project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,7 +91,7 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getCard()
|
||||
{
|
||||
return $this->hasOne(UserCard::className(), ['id' => 'card_id']);
|
||||
return $this->hasOne(UserCard::class, ['id' => 'card_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,7 +99,7 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->hasOne(User::className(), ['id' => 'user_id']);
|
||||
return $this->hasOne(User::class, ['id' => 'user_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,7 +107,7 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getTasks()
|
||||
{
|
||||
return $this->hasMany(ProjectTask::className(), ['project_user_id' => 'id']);
|
||||
return $this->hasMany(ProjectTask::class, ['project_user_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,7 +115,15 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getTasksByProject()
|
||||
{
|
||||
return $this->hasMany(ProjectTask::className(), ['project_id' => 'project_id']);
|
||||
return $this->hasMany(ProjectTask::class, ['project_id' => 'project_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getProjectRole(): ActiveQuery
|
||||
{
|
||||
return $this->hasOne(ProjectRole::class, ['id' => 'project_role_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,7 +131,7 @@ class ProjectUser extends \yii\db\ActiveRecord
|
||||
*/
|
||||
public function getTaskUsers()
|
||||
{
|
||||
return $this->hasMany(ProjectTaskUser::className(), ['project_user_id' => 'id']);
|
||||
return $this->hasMany(ProjectTaskUser::class, ['project_user_id' => 'id']);
|
||||
}
|
||||
|
||||
public static function usersByProjectArr($project_id): array
|
||||
|
@ -133,7 +133,6 @@ class Question extends \yii\db\ActiveRecord
|
||||
{
|
||||
return self::find()->where(['questionnaire_id' => $questionnaire_id])
|
||||
->andWhere(['status' => '1'])
|
||||
->AsArray()
|
||||
->all();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ use yii\helpers\ArrayHelper;
|
||||
* @property int $category_id
|
||||
* @property string $title
|
||||
* @property int $status
|
||||
* @property string $description
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property string $time_limit
|
||||
@ -55,7 +56,7 @@ class Questionnaire extends ActiveRecord
|
||||
[['category_id', 'status'], 'integer'],
|
||||
[['created_at', 'updated_at', 'time_limit'], 'safe'],
|
||||
['title', 'unique'],
|
||||
[['title'], 'string', 'max' => 255],
|
||||
[['title', 'description'], 'string', 'max' => 255],
|
||||
['status', 'default', 'value' => true],
|
||||
[['category_id'], 'exist', 'skipOnError' => true, 'targetClass' => QuestionnaireCategory::className(), 'targetAttribute' => ['category_id' => 'id']],
|
||||
];
|
||||
@ -70,6 +71,7 @@ class Questionnaire extends ActiveRecord
|
||||
'id' => 'ID',
|
||||
'category_id' => 'Категория',
|
||||
'title' => 'Название анкеты',
|
||||
'description' => 'Описание',
|
||||
'status' => 'Статус',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
|
@ -14,6 +14,8 @@ use Yii;
|
||||
* @property string $difficulties
|
||||
* @property string $tomorrow
|
||||
* @property int $user_card_id
|
||||
* @property int $project_id
|
||||
* @property int $company_id
|
||||
* @property int $status
|
||||
*
|
||||
* @property UserCard $userCard
|
||||
@ -36,11 +38,13 @@ class Reports extends \yii\db\ActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['user_card_id', 'status'], 'integer'],
|
||||
[['user_card_id', 'status', 'company_id', 'project_id'], 'integer'],
|
||||
[['_task'], 'checkIsArray'],
|
||||
[['user_card_id', 'created_at'], 'required'],
|
||||
[['today', 'difficulties', 'tomorrow', 'created_at'], 'string', 'max' => 255],
|
||||
[['user_card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::className(), 'targetAttribute' => ['user_card_id' => 'id']],
|
||||
[['user_card_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserCard::class, 'targetAttribute' => ['user_card_id' => 'id']],
|
||||
[['project_id'], 'exist', 'skipOnEmpty' => true, 'targetClass' => Project::class, 'targetAttribute' => ['project_id' => 'id']],
|
||||
[['company_id'], 'exist', 'skipOnEmpty' => true, 'targetClass' => Company::class, 'targetAttribute' => ['company_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
@ -56,7 +60,9 @@ class Reports extends \yii\db\ActiveRecord
|
||||
'difficulties' => 'Какие сложности возникли?',
|
||||
'tomorrow' => 'Что планируется сделать завтра?',
|
||||
'user_card_id' => 'Пользователь',
|
||||
'status' => 'Статус'
|
||||
'status' => 'Статус',
|
||||
'project_id' => 'ID проекта',
|
||||
'company_id' => 'ID компании'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "test_task".
|
||||
*
|
||||
|
@ -231,6 +231,6 @@ class User extends ActiveRecord implements IdentityInterface, UserRbacInterface
|
||||
|
||||
public function getProjectUser()
|
||||
{
|
||||
return $this->hasMany(ProjectUser::className(), ['user_id' => 'id']);
|
||||
return $this->hasMany(ProjectUser::class, ['user_id' => 'id']);
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,11 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use Exception;
|
||||
use phpDocumentor\Reflection\Types\This;
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveQuery;
|
||||
use yii\db\Expression;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/**
|
||||
@ -45,6 +42,7 @@ use yii\helpers\ArrayHelper;
|
||||
*
|
||||
* @property FieldsValue[] $fieldsValues
|
||||
* @property ProjectUser[] $projectUsers
|
||||
* @property CardSkill[] $skillValues
|
||||
* @property ResumeTemplate $resumeTemplate
|
||||
* @property Position $position
|
||||
* @property Status $status0
|
||||
@ -246,6 +244,13 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
return $this->hasMany(CardSkill::class, ['card_id' => 'id'])->with('skill');
|
||||
}
|
||||
|
||||
public function getSkillsName()
|
||||
{
|
||||
return $this->getSkillValues()
|
||||
->leftJoin('skill', 'card_skill.skill_id = skill.id')
|
||||
->select('skill.name')->column();
|
||||
}
|
||||
|
||||
public static function getNameSkills()
|
||||
{
|
||||
return ArrayHelper::map(Skill::find()->all(), 'id', 'name');
|
||||
|
@ -26,6 +26,8 @@ use \backend\modules\questionnaire\models\Answer;
|
||||
* @property int $score
|
||||
* @property int $status
|
||||
* @property double $percent_correct_answers
|
||||
* @property string $testing_date
|
||||
* @property string $start_testing
|
||||
*
|
||||
* @property Questionnaire $questionnaire
|
||||
* @property User $user
|
||||
@ -63,7 +65,7 @@ class UserQuestionnaire extends ActiveRecord
|
||||
[['questionnaire_id', 'user_id', 'status'], 'required'],
|
||||
[['questionnaire_id', 'user_id', 'score', 'status'], 'integer'],
|
||||
[['percent_correct_answers'], 'number'],
|
||||
[['created_at', 'updated_at', 'testing_date'], 'safe'],
|
||||
[['created_at', 'updated_at', 'testing_date', 'start_testing'], 'safe'],
|
||||
[['uuid'], 'string', 'max' => 36],
|
||||
[['uuid'], 'unique'],
|
||||
[['questionnaire_id'], 'exist', 'skipOnError' => true, 'targetClass' => Questionnaire::className(), 'targetAttribute' => ['questionnaire_id' => 'id']],
|
||||
@ -98,6 +100,7 @@ class UserQuestionnaire extends ActiveRecord
|
||||
'created_at' => 'Дата создания',
|
||||
'updated_at' => 'Дата обновления',
|
||||
'testing_date' => 'Дата тестирования',
|
||||
'start_testing' => 'Дата начала тестирования',
|
||||
'percent_correct_answers' => 'Процент правильных ответов',
|
||||
];
|
||||
}
|
||||
@ -179,18 +182,9 @@ class UserQuestionnaire extends ActiveRecord
|
||||
|
||||
public static function findActiveUserQuestionnaires($user_id): array
|
||||
{
|
||||
$models = self::find()
|
||||
return self::find()
|
||||
->where(['user_id' => $user_id])
|
||||
->andWhere(['not', ['user_questionnaire.status' => 0]])
|
||||
->all();
|
||||
|
||||
$modelsArr = array();
|
||||
foreach ($models as $model) {
|
||||
$modelsArr[] = array_merge($model->toArray(), [
|
||||
'questionnaire_title' => $model->getQuestionnaireTitle()
|
||||
]);
|
||||
}
|
||||
|
||||
return $modelsArr;
|
||||
}
|
||||
}
|
||||
|
78
common/models/UserTgBotDialog.php
Normal file
78
common/models/UserTgBotDialog.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Expression;
|
||||
|
||||
/**
|
||||
* This is the model class for table "user_tg_bot_dialog".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $dialog_id
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*
|
||||
* @property User $user
|
||||
*/
|
||||
class UserTgBotDialog extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'user_tg_bot_dialog';
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => TimestampBehavior::class,
|
||||
'createdAtAttribute' => 'created_at',
|
||||
'updatedAtAttribute' => 'updated_at',
|
||||
'value' => new Expression('NOW()'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['user_id', 'dialog_id'], 'integer'],
|
||||
[['dialog_id'], 'required'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['dialog_id'], 'unique'],
|
||||
[['user_id'], 'unique'],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'user_id' => 'User ID',
|
||||
'dialog_id' => 'Dialog ID',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->hasOne(User::className(), ['id' => 'user_id']);
|
||||
}
|
||||
}
|
89
common/models/UserTgBotToken.php
Normal file
89
common/models/UserTgBotToken.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveQuery;
|
||||
use yii\db\Expression;
|
||||
|
||||
/**
|
||||
* This is the model class for table "user_tg_bot_token".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property string $token
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property string $expired_at
|
||||
*
|
||||
* @property User $user
|
||||
*/
|
||||
class UserTgBotToken extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'user_tg_bot_token';
|
||||
}
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => TimestampBehavior::class,
|
||||
'createdAtAttribute' => 'created_at',
|
||||
'updatedAtAttribute' => 'updated_at',
|
||||
'value' => new Expression('NOW()'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['user_id'], 'integer'],
|
||||
[['token'], 'required'],
|
||||
[['created_at', 'updated_at', 'expired_at'], 'safe'],
|
||||
[['token'], 'string', 'max' => 255],
|
||||
[['token'], 'unique'],
|
||||
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'user_id' => 'User ID',
|
||||
'token' => 'Token',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'expired_at' => 'Expired At',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActiveQuery
|
||||
*/
|
||||
public function getUser()
|
||||
{
|
||||
return $this->hasOne(User::className(), ['id' => 'user_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tokenValue
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkExistsByToken(string $tokenValue): bool
|
||||
{
|
||||
return self::find()->where(['token' => $tokenValue])->exists();
|
||||
}
|
||||
}
|
23
common/models/email/Email.php
Normal file
23
common/models/email/Email.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace common\models\email;
|
||||
|
||||
class Email
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $sendTo;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public string $subject;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $mailLayout;
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $params;
|
||||
}
|
20
common/models/email/RegistrationEmail.php
Normal file
20
common/models/email/RegistrationEmail.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace common\models\email;
|
||||
|
||||
use common\models\User;
|
||||
use Yii;
|
||||
|
||||
class RegistrationEmail extends Email
|
||||
{
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->sendTo = $user->email;
|
||||
$this->subject = 'Account registration at ' . Yii::$app->name;
|
||||
$this->mailLayout = ['html' => 'signup-html', 'text' => 'signup-text'];
|
||||
$this->params = ['user' => $user];
|
||||
}
|
||||
}
|
20
common/models/email/ResetPasswordEmail.php
Normal file
20
common/models/email/ResetPasswordEmail.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace common\models\email;
|
||||
|
||||
use common\models\User;
|
||||
use Yii;
|
||||
|
||||
class ResetPasswordEmail extends Email
|
||||
{
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->sendTo = $user->email;
|
||||
$this->subject = 'Password reset for ' . Yii::$app->name;
|
||||
$this->mailLayout = ['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text']; //+
|
||||
$this->params = ['user' => $user];//+
|
||||
}
|
||||
}
|
44
common/models/forms/TasksImportForm.php
Normal file
44
common/models/forms/TasksImportForm.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace common\models\forms;
|
||||
use yii\base\Model;
|
||||
|
||||
class TasksImportForm extends Model
|
||||
{
|
||||
public $companyId;
|
||||
public $userId;
|
||||
public $projectId;
|
||||
public $fromDate;
|
||||
public $toDate;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['companyId', 'userId', 'projectId'], 'integer'],
|
||||
['fromDate', 'date', 'format' => 'php:Y-m-d', 'timestampAttribute' => 'fromDate'],
|
||||
['toDate', 'date', 'format' => 'php:Y-m-d', 'timestampAttribute' => 'toDate'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'companyId' => 'ID компании',
|
||||
'userId' => 'ID пользователя',
|
||||
'projectId' => 'ID проекта',
|
||||
'fromDate' => 'Дата начала поиска',
|
||||
'toDate' => 'Дата конца поиска',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function formName(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user