TasksModel.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. use yii\base\Model;
  5. use app\models\entity\ProjectsLocotech;
  6. use app\models\entity\Tasks;
  7. use app\models\entity\Tasktypes;
  8. use app\models\entity\Accounts;
  9. use app\models\CheckPointTypeModel;
  10. use app\models\CheckPointModel;
  11. use app\models\entity\Jobtypes;
  12. use app\models\entity\Commands;
  13. /**
  14. * This is the model class for table "s_regions".
  15. *
  16. * The followings are the available columns in table 's_regions':
  17. * @property integer $rg_id
  18. * @property string $rg_name
  19. */
  20. class TasksModel extends MainModel
  21. {
  22. public $createTasks;
  23. public $createTasksMessage;
  24. public $createType = [];
  25. public function GetTaskStatus($taskid)
  26. {
  27. $task = $this->GrabTask( $taskid );
  28. $parent = intval($task->parent_id);
  29. if ($parent > 0)
  30. return intval($task->status);
  31. else
  32. {
  33. $tasks = $this->GrabSubTasks( $taskid );
  34. $assigned = 0;
  35. $accepted = 0;
  36. $hold = 0;
  37. $done = 0;
  38. $lentasks = sizeof($tasks);
  39. foreach ($tasks as $task)
  40. {
  41. $status = intval( $task->status );
  42. switch ($status) {
  43. case 2:
  44. $assigned++;
  45. break;
  46. case 3:
  47. $accepted++;
  48. break;
  49. case 4:
  50. $hold++;
  51. break;
  52. case 5:
  53. $done++;
  54. break;
  55. }
  56. }
  57. if ($done == $lentasks && $lentasks > 0)
  58. {
  59. return 5;
  60. }
  61. elseif ($accepted > 0)
  62. {
  63. return 2;
  64. }
  65. elseif ($assigned > 0)
  66. return 2;
  67. else
  68. return 1;
  69. }
  70. }
  71. // работает
  72. public function GetTasksForProject($projectid, $status=0, $inactiveproject=0, $subs = 0)
  73. {
  74. global $link;
  75. // $taskstring = $this->GetTasksFromProjectString($projectid);
  76. $projectsLocotechEntity = ProjectsLocotech::findOne($projectid);
  77. $taskstring = $projectsLocotechEntity->tasks;
  78. if ( $inactiveproject != 0 ) {
  79. $countTaskEntity = Tasks::find()->where(['and',['id' => $taskstring],['or','status=2','status=3']])->count();
  80. if ( $countTaskEntity ) {
  81. $count = intval($countTaskEntity);
  82. if ( $count > 0 ) {
  83. echo "Found started tasks!";
  84. return;
  85. }
  86. }
  87. }
  88. if ( $subs > 0 ) {
  89. $tasksarr = explode(",", $taskstring);
  90. foreach ($tasksarr as $task_id)
  91. {
  92. $parent = $this->GrabTask($task_id);
  93. if ( $parent->status == $status ) {
  94. return $this->GrabSubTasks($task_id);
  95. }
  96. }
  97. }
  98. if ($status != 0) {
  99. $tasksEntity = Tasks::find()->where(['and', ['id' =>$taskstring],['status' => $status]])->all();
  100. } else {
  101. if( !empty($taskstring)) {
  102. $tasksEntity = Tasks::find()->where(['in', 'id', $taskstring ])->all();
  103. }
  104. }
  105. $ret = array();
  106. if ( !empty($tasksEntity) ) {
  107. foreach( $tasksEntity as $task){
  108. $tempArray = [];
  109. foreach($task as $item){
  110. $tempArray[] = $item;
  111. }
  112. array_push($ret, $tempArray);
  113. }
  114. }
  115. return $ret;
  116. }
  117. public function GetTasksFromProjectString($projectid)
  118. {
  119. $projectsLocotechEntity = ProjectsLocotech::findOne($projectid);
  120. $ret = array();
  121. if ($projectsLocotechEntity)
  122. {
  123. $ret = $projectsLocotechEntity->tasks;
  124. }
  125. return $ret;
  126. }
  127. public function GrabTask($task_id)
  128. {
  129. $tasksEntity = Tasks::findOne($task_id);
  130. if ( $tasksEntity ) {
  131. //$result = sizeof($tasksEntity);
  132. return $tasksEntity;
  133. }
  134. return null;
  135. }
  136. public function GrabSubTasks($parent_id)
  137. {
  138. $subtasks = array();
  139. $tasksEntity = Tasks::find()->where(['parent_id' => $parent_id])->all();
  140. foreach ( $tasksEntity as $task) {
  141. array_push($subtasks, $task);
  142. }
  143. return $subtasks;
  144. }
  145. // работает
  146. public function GrabTasktypes( $chooseSubtasks = "all" )
  147. {
  148. $companyId = Yii::$app->params['api']['companyId'];
  149. $tasktypesEntity = new Tasktypes();
  150. if ($chooseSubtasks == "subs") {
  151. $result = $tasktypesEntity::find()->where(['and','company' => $companyId,'main_task' => 0])->orderBy(['id' => DESC])->all();
  152. } else if ( $chooseSubtasks == "tasks" ) {
  153. $result = $tasktypesEntity::find()->where(['and','company' => $companyId,'main_task' => 1])->orderBy(['id' => DESC])->all();
  154. } else {
  155. $result = $tasktypesEntity::find()->where(['company' => $companyId])->orderBy(['id' => 'DESC'])->all();
  156. }
  157. if ( 0 == count($result) ) {
  158. return [];
  159. }
  160. return $result;
  161. }
  162. public function CreateTasks($tasktypesarr, $input_id=0)
  163. {
  164. global $link;
  165. // echo "CreateTasks $input_id";
  166. // print_r($tasktypesarr);
  167. // $query = mysqli_query($link, "select * from input_tables where id=".$input_id);
  168. // if ($res = mysqli_fetch_array($query)) {
  169. //
  170. // }
  171. $maintasks = array();
  172. foreach ($tasktypesarr as $tasktype_data)
  173. {
  174. if ($tasktype_data->main_task == '1')
  175. {
  176. $tasktype = $tasktype_data->id;
  177. // $tasktype_data = array_values($tasktypesarr)[0];//!!!! только первый эелмент берется
  178. // echo "subtasks ".$tasktype_data['subtasks']." tasktype ".$tasktype;
  179. $subtaskarr = explode(",", $tasktype_data->subtasks);
  180. // echo $action_data['name'] . "! Входная таблица " . $assign_id;
  181. $result = mysqli_query($link, "INSERT INTO tasks (type, status, priority, created, input_id) VALUES ($tasktype, 1, 0, NOW(), $input_id)"); //создание глобальной задачи
  182. if (mysqli_affected_rows($link) >0 )
  183. {
  184. $parent_id = mysqli_insert_id($link);
  185. array_push($maintasks, $parent_id);
  186. // $query1 = mysqli_query($link, "select MAX(id) from tasks");
  187. // if ($res1 = mysqli_fetch_row($query1)) {
  188. // $parent_id = $res1[0];
  189. //// echo "created parent_id ".$parent_id;
  190. // }
  191. $priority = 1;
  192. foreach ($subtaskarr as $sub) {
  193. $str = "insert into tasks (type, parent_id, priority, status, created, input_id) values ($sub, $parent_id, $priority, 1, NOW(), $input_id)";
  194. //echo "$str<br>";
  195. $sub_id = mysqli_insert_id($link);
  196. //создаем парентов
  197. $types = \CheckPointTypes\CheckPointType::GetCheckPointTypesByTask($sub);
  198. if (sizeof($types) > 0) {
  199. $q = mysqli_query($link, "select MAX(id) from tasks");
  200. if ($res = mysqli_fetch_row($q))
  201. {
  202. $myid = $res[0];
  203. foreach ($types as $typeID) {
  204. echo "create type " . $typeID['cp_type_id'];
  205. //var_dump($typeID['cp_type_id']);die();
  206. $cpt = \CheckPointTypes\CheckPointType::CreateFromID($typeID['cp_type_id']);
  207. if ($cpt != null)
  208. $cp = \CheckPoints\CheckPoint::CreateFromType($cpt, null, $myid+1);
  209. }
  210. }
  211. }
  212. mysqli_query($link, $str); //создание подзадач
  213. $priority++;
  214. }
  215. }
  216. }
  217. }
  218. if (sizeof($maintasks) > 0) {
  219. echo " <span style='color: green'>Задачи созданы для проекта $input_id!</span>";
  220. $taskstring = implode(",",$maintasks);
  221. AddTasksToProject($taskstring, $input_id);
  222. }
  223. else
  224. echo '<span style="color: red;"> Нет ни одной основной задачи!</span><br>';
  225. }
  226. // работает
  227. public function CreateTasksExtra($tasktypesarr, $input_id=0)
  228. {
  229. $checkpointModel = new CheckPointTypeModel();
  230. $tasksEntitySelect = new Tasks();
  231. $maintasks = array();
  232. foreach ( $tasktypesarr as $tasktype_data ) {
  233. if ( $tasktype_data->main_task == '1') {
  234. $tasktype = $tasktype_data->id;
  235. $subtaskarr = explode(",", $tasktype_data->subtasks);
  236. $testksEntity = new Tasks();
  237. $testksEntity->type = $tasktype;
  238. $testksEntity->status = 1;
  239. $testksEntity->priority = 0;
  240. $testksEntity->created = date("Y-m-d H:i:s");
  241. $testksEntity->input_id = $input_id;
  242. if ( $testksEntity->save() ) {
  243. $parent_id = $testksEntity->id;
  244. array_push($maintasks, $parent_id);
  245. $priority = 1;
  246. foreach ( $subtaskarr as $sub ) {
  247. if ( null == $sub ) {
  248. continue;
  249. }
  250. $testksEntitySub = new Tasks();
  251. $testksEntitySub->type = $sub;
  252. $testksEntitySub->parent_id = $parent_id;
  253. $testksEntitySub->priority = $priority;
  254. $testksEntitySub->status = 1;
  255. $testksEntitySub->created = date("Y-m-d H:i:s");
  256. $testksEntitySub->input_id = $input_id;
  257. $testksEntitySub->save();
  258. $sub_id = $testksEntitySub->id;
  259. $types = $checkpointModel::GetCheckPointTypesByTask($sub);
  260. if (count($types) > 0) {
  261. $id = Tasks::find()->max('id');
  262. $tasksEntity = Tasks::findOne($id);
  263. if ( $tasksEntity ) {
  264. $myid = $tasksEntity->id;
  265. foreach ($types as $typeID) {
  266. $this->message['createType'][] = $typeID->cp_type_id;
  267. $cpt = $checkpointModel->CreateFromID($typeID->cp_type_id);
  268. if ($cpt != null){
  269. $cp = CheckPointModel::CreateFromType($cpt, null, $myid+1);
  270. }
  271. }
  272. }
  273. }
  274. $priority++;
  275. }
  276. }
  277. }
  278. }
  279. if (sizeof($maintasks) > 0) {
  280. //echo " <span style='color: green'>Задачи созданы для проекта $input_id!</span>";
  281. $this->createTasks = $input_id;
  282. $taskstring = implode(",",$maintasks);
  283. $this->AddTasksToProject($taskstring, $input_id);
  284. } else {
  285. //echo '<span style="color: red;"> Нет ни одной основной задачи!</span><br>';
  286. $this->message['createTasksMessage'] = 'Нет ни одной основной задачи!';
  287. }
  288. }
  289. // работает
  290. public function AddTasksToProject($taskstring, $input_id)
  291. {
  292. $projectsLocotechEntity = ProjectsLocotech::findOne($input_id);
  293. $projectsLocotechEntity->tasks = $taskstring;
  294. $projectsLocotechEntity->update();
  295. }
  296. public function TasksAssign($task_id, $execute, $project_id = 0)
  297. {
  298. //1 ищем акки без тасков
  299. //2 определяем должности акков
  300. //3 определяем доступные задачи по должностям
  301. //2 берем активные (невыданные) задачи
  302. //2 выдаем подходящим аккам их подзадачи
  303. //tofix: удаление подзадач глобалов похоже не происходит на каком-то этапе
  304. //tofix: выдавать подзадачи с глобалами
  305. //tofix: подзадачи согласно проекту, а не все подряд подходящие сотруднику
  306. //global $link, $companyID;
  307. $accountModel = new AccountModel();
  308. $companyID = Yii::$app->params['api']['companyId'];
  309. $freeaccounts = array();
  310. $accountnames = array();
  311. //get free accs (without active tasks)
  312. $accountsEntity = Accounts::find()->where(['active_task_ids' => ''])->all();
  313. //$str = "select * from accounts where active_task_ids = ''";
  314. //$query1 = mysqli_query($link, $str);
  315. $online_counter = 0;
  316. foreach ($accountsEntity as $account) {
  317. $last_seen_mobile = $account->last_seen_mobile;
  318. $online_mobile = $accountModel->OnlineAccountCheck($last_seen_mobile);
  319. if (!$online_mobile)
  320. continue;
  321. else
  322. $online_counter++;
  323. //var_dump($account->id);
  324. $jobtypes = [];
  325. foreach ($account->accountsJobtypes as $value) {
  326. $jobtypes[] = $value->jobtype_id;
  327. }
  328. //$jobtypes = explode(",",$account->jobtypes);
  329. $acc_id = $account->id;
  330. $accountnames[$acc_id] = $account->name;
  331. $freeaccounts[$acc_id] = $jobtypes;
  332. }
  333. if ($online_counter == 0)
  334. {
  335. $this->message['TasksAssign'] = 'Задачи не выданы в работу! Нет подходящих исполнителей онлайн';
  336. //echo "<h3><span style='color:red'>Задачи не выданы в работу! Нет подходящих исполнителей онлайн</span></h3>";
  337. }
  338. $assigned_tasks = array();
  339. $accsused = array();
  340. if ($task_id =='' || !isset($task_id))
  341. {
  342. if ($project_id == 0) {
  343. $opentasks = $this->GrabOpenTasks('subtasks'); //array of mysql res, tasks status=1
  344. } else {
  345. $opentasks = $this->GetTasksForProject($project_id, 1, 1, 1);
  346. }
  347. } else {
  348. //$opentasks = GrabTasksFromGlobal($task_id);
  349. $opentasks = Tasks::find()->where(['and', 'parent_id = '. $task_id , 'status = 1'])->all();
  350. }
  351. // echo 'opentasks len '.sizeof($opentasks);
  352. // echo 'opentasks '.implode(",",$opentasks);
  353. // echo 'subtasks '.sizeof(array_values($subtasks));
  354. // print_r($opentasks);
  355. //echo '<br>';
  356. $assigned_accs = array();
  357. //account array with available jobtype list
  358. //$i=0;
  359. foreach ($freeaccounts as $acc_id => $jobtypes)
  360. {
  361. $parent_id = 0;
  362. $assigned_accs[$acc_id] = array();
  363. if (!in_array($acc_id, $accsused))
  364. {
  365. // echo '<br><b>free account: acc_id ' . $acc_id.'</b>';
  366. $jobtasks = array();
  367. $jobtypes = array_filter($jobtypes);
  368. // if($i == 6){print_r($jobtypes); die();}
  369. //$i++;
  370. foreach ($jobtypes as $job_type) {
  371. $jobtasks = array_merge($jobtasks, $this->GrabJobTaskTypes($job_type));
  372. }
  373. //echo '<br>jobtasks ' . implode(",", $jobtasks).'<br>';
  374. foreach ($opentasks as $opentask)
  375. {
  376. $taskid = $opentask->id;
  377. $exists = array_key_exists($taskid, $assigned_tasks);
  378. //echo ' key exists '.$taskid.' '.($exists == true).'<br>';
  379. if (!$exists) {
  380. // echo '!exists';
  381. if ( in_array( $opentask->type, $jobtasks ) ) {
  382. // echo ' job available task type '.$opentask['type'].' ';
  383. $pid = intval($opentask->parent_id);
  384. if ($pid != $parent_id && in_array($acc_id, $accsused)) {//parent change = stop for this acc
  385. //echo "cont1";
  386. continue;
  387. }
  388. else
  389. $parent_id = $pid;
  390. $parent = $this->GrabTask($parent_id);
  391. $parenttype = $parent['type'];
  392. $tasktype = intval($opentask->type);
  393. // echo "tt $tasktype";
  394. $tgrab = Tasktypes::findOne($parenttype);//GrabTasktype($parenttype);
  395. //$tsize = sizeof($tgrab);
  396. if ($tsize == null)
  397. $this->DeleteTasksByType($parenttype);
  398. //фикс блуждающих подзадач без парента и тасктипа парента
  399. if (($parent_id > 0 && $this->GrabTask($parent_id) == null) || $tsize == 0)
  400. {
  401. //echo "skip2 id $parent_id<br>";
  402. continue;
  403. }
  404. $res = $this->Assign($accsused, $assigned_tasks, $assigned_accs, $acc_id, $taskid, $execute);
  405. }
  406. }
  407. }
  408. if ($execute)
  409. {
  410. $parent_updated = false;
  411. foreach ($assigned_accs as $acc)
  412. {
  413. if (sizeof($assigned_accs[$acc_id]) == 0)
  414. continue;
  415. $tasks = implode(',', $acc);
  416. foreach ($acc as $tsk) {
  417. if (in_array($tsk, $assigned_accs[$acc_id])) {
  418. $tasksEntity = Tasks::findOne($tsk);
  419. $tasksEntity->status = 2;
  420. $tasksEntity->assignees_arr = $acc_id;
  421. $tasksEntity->update(); //создание подзадач
  422. ElasticLog::command((int)$task_id, 'Назначение');
  423. }
  424. }
  425. if ($parent_id != 0) {
  426. $tasks = $parent_id.','.$tasks;
  427. }
  428. $accountsEntity = Accounts::findOne($tsk);
  429. $accountsEntity->active_task_ids = $tasks;
  430. $accountsEntity->update(); //создание подзадач
  431. if ($parent_id != 0 && !$parent_updated) {
  432. $parent_updated = true;
  433. $tasksEntity = Tasks::findOne($parent_id);
  434. $tasksEntity->status = 2;
  435. $tasksEntity->update();
  436. $proj = getProjectByTask($parent_id);
  437. $projectsLocotechEntity = ProjectsLocotech::findOne($proj->id);
  438. $projectsLocotechEntity->status = 2;
  439. $projectsLocotechEntity->update();
  440. }
  441. }
  442. }
  443. }
  444. }
  445. //echo 'Assigned_tasks len '.sizeof($assigned_tasks).' opentasks len '.sizeof($opentasks);
  446. //echo "Задачи назначены ".sizeof($accsused)." сотрудникам: ";
  447. // foreach ($accsused as $acc)
  448. // {
  449. // echo $accountnames[$acc].", ";
  450. // }
  451. return $accsused;
  452. }
  453. public function GrabOpenTasks($flag = 'all') {
  454. if ($flag == 'subtasks') {
  455. $tasksEntity = Tasks::find()->where(['and','status = 1', 'parent_id > 0' ]);
  456. } else {
  457. $tasksEntity = Tasks::find()->where(['and','status = 1', 'parent_id = 0' ]);
  458. }
  459. $alltasks = array();
  460. foreach ($tasksEntity as $task) {
  461. $id = $task->id;
  462. $parent_id = $task->parent_id;
  463. if ($flag == 'subtasks' && GrabTask($parent_id) == null)
  464. {
  465. echo "parent_id skip $parent_id<br>";
  466. continue;
  467. }
  468. array_push($alltasks, $task);
  469. if ($flag == 'all') { //subtasks in main select
  470. $subs = $this->GrabSubTasks($id);
  471. $alltasks = array_merge($alltasks, $subs);
  472. }
  473. }
  474. return $alltasks;
  475. }
  476. public function GrabJobTaskTypes($job_id)
  477. {
  478. $jobtypesEntity = Jobtypes::findOne($job_id);
  479. $subtaskarr = array();
  480. /*
  481. foreach ( $jobtypesEntity->tasktype as $task ) {
  482. $subtaskarr[] = $task->id;
  483. }
  484. */
  485. foreach ( $jobtypesEntity->jobtypesTasktypes as $task ) {
  486. $subtaskarr[] = $task->tasktype_id;
  487. }
  488. return array_filter($subtaskarr);
  489. }
  490. public function DeleteTasksByType($task_type, $full=true)
  491. {
  492. $tasksEntity = Tasks::find()->where(['type' => $task_type])->all();
  493. foreach ( $tasksEntity as $task ) {
  494. $this->DeleteTask($task->id);
  495. }
  496. }
  497. public function DeleteTask($task_id, $full = true)
  498. {
  499. if ( $full ) {
  500. $tasksEntity = Tasks::find()->where(['parent_id' => $task_id])->all();
  501. foreach ($tasksEntity as $sub) {
  502. $this->DeleteTask($sub->id, false);
  503. }
  504. }
  505. $accid = Tasks::findOne($task_id);//GetAccountFromTask($task_id);
  506. $this->ClearTasksFromAccount($accid->assignees_arr);
  507. $tasksEntity = Tasks::findOne($task_id);
  508. $tasksEntity->delete();
  509. }
  510. public function ClearTasksFromAccount($acc_id, $debugtext = true)
  511. {
  512. $accountsEntity = Accounts::findOne($acc_id);
  513. if ( $accountsEntity ) {
  514. $mytasks = explode(',',$accountsEntity->active_task_ids);
  515. }
  516. $tasksacc = $this->GrabTasksForAccount($acc_id);
  517. if ( sizeof($tasksacc) > 0 && $debugtext ) {
  518. //echo "<span style='color:red'><b> Задачи аккаунта $acc_id очищены!</b></span>";
  519. $commandsEntity = new Commands();
  520. $commandsEntity->account_id = $acc_id;
  521. $commandsEntity->cmd = "21";
  522. $commandsEntity->created = date('Y-m-d H:i:s');
  523. $commandsEntity->save();
  524. }
  525. foreach ( $tasksacc as $mtask ) {
  526. $tasksEntity = Tasks::findOne($mtask->id);
  527. $tasksEntity->status = 1;
  528. $tasksEntity->control_map_checked = 0;
  529. $tasksEntity->accepted_time = null;
  530. $tasksEntity->confirm_data = '';
  531. $tasksEntity->finished_time = null;
  532. $tasksEntity->assignees_arr = '';
  533. $tasksEntity->update();
  534. }
  535. if ( null != $acc_id ) {
  536. $accountEntity = Accounts::findOne($acc_id);
  537. $accountEntity->active_task_ids = '';
  538. $accountEntity->update();
  539. }
  540. }
  541. public function GrabTasksForAccount($acc_id, $status=0)
  542. {
  543. if ( $status != 0 ) {
  544. $tasksEntity = Tasks::find()->where(['assignees_arr' => $acc_id])
  545. ->andWhere(['status' => $status])
  546. ->andWhere(['<' , 'status', '5'])
  547. ->all();
  548. } else {
  549. $tasksEntity = Tasks::find()->where(['assignees_arr' => $acc_id])
  550. ->andWhere(['<' , 'status', '5'])
  551. ->all();
  552. }
  553. return $tasksEntity;
  554. }
  555. public function Assign(&$accsused, &$assigned_tasks, &$assigned_accs, $acc_id, $taskid, $execute=false)
  556. {
  557. if ( !in_array($acc_id, $accsused) ) {
  558. array_push($accsused, $acc_id);
  559. }
  560. $assigned_tasks[$taskid] = $acc_id;
  561. array_push($assigned_accs[$acc_id],$taskid);
  562. return false;
  563. }
  564. public function getProjectByTask($taskId)
  565. {
  566. $tasksEntity = Tasks::findOne($taskId);
  567. if ( $tasksEntity ) {
  568. return ProjectsLocotech::findOne($tasksEntity->input_id);
  569. }
  570. return null;
  571. }
  572. }