Tasks.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace app\models\entity;
  3. use yii\db\ActiveRecord;
  4. /**
  5. * This is the model class for table "tasks".
  6. *
  7. * @property int $id
  8. * @property bool $status [tinyint(3) unsigned] пояснения в таблице имен статусов
  9. * @property int $parent_id [int(10) unsigned]
  10. * @property int $project_id [int(10) unsigned] внешний ключ к таблице projects_locotech
  11. * @property int $scenario_id [int(10) unsigned] внешний ключ к ar_scenarios
  12. * @property int $type [int(10) unsigned]
  13. * @property int $assignees_arr [int(255) unsigned]
  14. * @property bool $priority [tinyint(3) unsigned]
  15. * @property int $input_id [int(10) unsigned] номер задания во входной таблице
  16. * @property string $created [datetime]
  17. * @property string $assigned [datetime]
  18. * @property string $accepted_time [datetime]
  19. * @property string $finished_time [datetime]
  20. * @property string $expires [datetime]
  21. * @property string $followers_arr [varchar(255)]
  22. * @property int $assignedby [int(10) unsigned]
  23. * @property string $text [varchar(255)]
  24. * @property string $viewed_by_arr [varchar(255)]
  25. * @property string $working_arr [varchar(255)]
  26. * @property string $confirm_data [varchar(255)]
  27. * @property bool $control_map_checked [tinyint(3) unsigned]
  28. * @property int $account_id [int(10) unsigned]
  29. * @property int $asusg_job_mapped_id [int(10) unsigned]
  30. * @property int $object_id [int(55) unsigned]
  31. * @property int $preferred_assignee [int(10) unsigned]
  32. *
  33. * @property Tasktypes $tasktypes
  34. * @property Accounts $accounts
  35. */
  36. class Tasks extends ActiveRecord
  37. {
  38. /**
  39. * @return string название таблицы, сопоставленной с этим ActiveRecord-классом.
  40. */
  41. public static function tableName()
  42. {
  43. return '{{tasks}}';
  44. }
  45. public function getProject()
  46. {
  47. return $this->hasOne(ProjectsLocotech::class, ['id' => 'input_id']);
  48. }
  49. public function getAccounts()
  50. {
  51. return $this->hasOne(Accounts::class, ['id' => 'assignees_arr']);
  52. }
  53. public function getTasktypes()
  54. {
  55. return $this->hasOne(Tasktypes::class, ['id' => 'type']);
  56. }
  57. public function getTasktypesjobtype()
  58. {
  59. return $this->hasOne(TasktypesJobtype::class, ['tasktype_id' => 'type']);
  60. }
  61. public function getPhase()
  62. {
  63. return $this->hasMany(Phase::class, ['task_id' => 'id']);
  64. }
  65. public function getAsusgjob2launch()
  66. {
  67. return $this->hasOne(AsusgJob2Launch::class, ['id' => 'asusg_job_mapped_id']);
  68. }
  69. public function getCommandId()
  70. {
  71. if ($this->parent_id == 0) {
  72. return 0;
  73. }
  74. return $this->id;
  75. }
  76. public function getTaskId()
  77. {
  78. if ($this->parent_id == 0) {
  79. return $this->id;
  80. }
  81. return 0;
  82. }
  83. public function asArray()
  84. {
  85. return [
  86. 'command_id' => $this->getCommandId(),
  87. 'task_id' => $this->getTaskId(),
  88. 'scenario_id' => $this->scenario_id,
  89. 'command_name' => $this->tasktypes->name
  90. ];
  91. }
  92. /**
  93. * @return Tasks[]
  94. */
  95. public function getCommands()
  96. {
  97. return Tasks::findAll(['parent_id' => $this->id]);
  98. }
  99. }