tasks.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <?
  2. if (!$logged_me_in_successfully234)
  3. return;
  4. $array_children = array();
  5. $array_parent = array();
  6. if ($new == "3")
  7. {
  8. DeleteTask($task_id);
  9. echo "<span style='color:red'><b>Задача $task_id удалена!</b></span>";
  10. }
  11. else if ($new == '2')
  12. {
  13. if ($task_id == 'undefined')
  14. $task_id = '';
  15. if (!isset($task_id) || $task_id=='')
  16. {
  17. ;
  18. //echo "<span style='color: blue'>Все задачи выданы в работу! ";
  19. }
  20. else
  21. echo "<span style='color: blue'>Задача <b>".$task_id."</b> выдана в работу! ";
  22. $accsused = TasksAssign($task_id,true);
  23. echo "<span style='color: blue'>Задачи назначены <b>".sizeof(reset($accsused[0]))."</b> сотрудникам </span> ";
  24. }
  25. if ($new == '6')//revoke
  26. {
  27. Account::ClearTasksFromAccount($task_id);
  28. }
  29. if ($new == '7')//confirm
  30. {
  31. TaskConfirm($num, $id, $tid, $confirm_data);
  32. }
  33. if ($new == '8')//confirm
  34. {
  35. TaskReopen($tid);
  36. }
  37. if ($new == '9')//confirm
  38. {
  39. DeletePic($path);
  40. }
  41. if ($new == '5')
  42. {
  43. // echo 'new task type '.$newtasktype;
  44. $tasktypesarr = array( GrabTasktype($newtasktype) );
  45. CreateTasks($tasktypesarr);
  46. }
  47. //echo "sort1 $sorttasks $sort";
  48. if (!isset($sort))
  49. {
  50. $sort = $_SESSION['sorttasks'];
  51. if (!isset($sort)) {
  52. $sort = 1;
  53. }
  54. }
  55. if ($sort == 3)
  56. $sort = 2;
  57. $_SESSION['sorttasks'] = $sort;
  58. //echo "scr ".$scroll;
  59. echo "<input type='hidden' id='scroll' value=$scroll>";
  60. //echo "sort $sorttasks $sort";
  61. $active1 = '';
  62. $active234 = '';
  63. $active5 = '';
  64. $sort_status = 0;
  65. switch ($sort)
  66. {
  67. case '1': $active1 = 'control-btn_active'; $sort_status = 1; break;
  68. case '2':
  69. case '3':
  70. case '4': $active234 = 'control-btn_active'; break;
  71. case '5': $active5 = 'control-btn_active'; $sort_status = 5; break;
  72. }
  73. echo
  74. "
  75. <div class='main__content'>
  76. <div class='content__menu'>
  77. <h2 class='content__title content__menu__title'>
  78. Задачи
  79. </h2>
  80. <div class='content__filter'>
  81. <img src='ProSysNew/search.svg' alt='search' class='content__search'>
  82. <div class='content__controls'>
  83. <button class='control-btn control-btn_blue content__filter__btn $active1' onclick='SortElements(1, \"tasks\")'>К исполнению</button>
  84. <button class='control-btn control-btn_yellow content__filter__btn $active234' onclick='SortElements(2, \"tasks\")'>В работе</button>
  85. <button class='control-btn control-btn_green content__filter__btn $active5' onclick='SortElements(5, \"tasks\")'>Готово</button>
  86. </div>
  87. </div>";
  88. echo '<div class="content__menu__list">';
  89. echo ' <div class="content__menu__newproj content__menu__newproj_active" onclick = "NewTask()">
  90. <div class="content__menu__newproj__plus">
  91. +
  92. </div>
  93. <div class="content__menu__newproj__text">
  94. Новая задача
  95. </div>
  96. </div><br>';
  97. //304
  98. //А 11364783
  99. //Б 11364791
  100. //Заполнение $array_parent парент тасками существующих типов
  101. if ($sort_status > 0)
  102. //$parents = $entityManager->getRepository('Task')->findBy(array('parent_id' => 0, "status" => $sort_status), array('id' => 'DESC'));
  103. $parents = $entityManager->getRepository('Task')->findBy(array('parent_id' => 0, "status" => $sort_status), array('id' => 'DESC'), 200000);
  104. else
  105. //$parents = $entityManager->getRepository('Task')->findBy(array('parent_id' => 0), array('id' => 'DESC'));
  106. $parents = $entityManager->getRepository('Task')->findBy(array('parent_id' => 0), array('id' => 'DESC'), 200000);
  107. //\Doctrine\Common\Util\Debug::dump($parents);
  108. //if (sizeof($tasktypes)> 0) {
  109. // $query = mysqli_query($link, "select * from tasks where parent_id=0 and type in (" . $arrIds . ") ORDER BY id DESC");
  110. // {
  111. // while ($res1 = mysqli_fetch_array($query)) {
  112. // $status = GetTaskStatus($res1['id']);
  113. // if ($status == intval($sort)) {
  114. // $array_parent[$res1['id']] = $res1;
  115. // }
  116. // }
  117. // }
  118. //Заполнение $array_children сабтасками по адйи тасков из $array_parent
  119. $tasktypes = GrabTasktypes();
  120. $tasktypesIds = GrabTasktypesIDs();
  121. foreach ($parents as $parent) {
  122. if (!in_array(intval($parent->type), $tasktypesIds))
  123. continue;
  124. $status = GetTaskStatus($parent->id);
  125. if ($status == intval($sort)) {
  126. $array_parent[$parent->id] = $parent;
  127. $children = $entityManager->getRepository('Task')->findBy(array('parent_id' => $parent->id));
  128. $array_children[$parent->id] = $children;
  129. }
  130. }
  131. // foreach ($array_parent as $parent_id => $res) {
  132. // $children = array();
  133. // $query = mysqli_query($link, "select * from tasks where parent_id=" . $parent_id." ORDER BY priority ASC");
  134. // while ($res1 = mysqli_fetch_array($query)) {
  135. // array_push($children, $res1);
  136. // }
  137. // $array_children[$parent_id] = $children;
  138. // }
  139. $_SESSION['array_children'] = $array_children;
  140. $_SESSION['array_parent'] = $array_parent;
  141. $_SESSION['actid'] = $activeid;
  142. //MAIN TASKS
  143. foreach ($array_children as $parent_id => $children)
  144. {
  145. EchoTask2($array_parent[$parent_id], $activeid, true);
  146. }
  147. if (sizeof($parent_id) > 0) {
  148. if ($sort != 5 && $sort != 3 && $sort != 2)
  149. echo '<br><p><button class="control-bigbtn content__main__toexec-btn" onclick="FindStaff()">Все в работу!</button></p>';
  150. }
  151. echo '</div></div>';
  152. //PARENT TITLE IN CHILDREN LIST
  153. echo '<div class="content__main">';
  154. if (isset($activeid)) {
  155. if ($sort == 5) {
  156. echo '<p><a class="xlsbuttontop"href ="#"><button class="control-bigbtn content__main__toexec-btn" >Скачать XLS акт</button></a></p>';
  157. }
  158. }
  159. echo '<h2 class="content__title content__main__title">';
  160. $taskid = 0;
  161. echo "<br><p class='content__menu__task-text'><span class='content__main__item__del' onclick='DelTask($activeid)'>Удалить задачу и подзадачи</span></p>";
  162. if (isset($activeid)) {
  163. $btntype = 'control-btn_blue';
  164. $txt = 'К исполнению';
  165. switch ($sort)
  166. {
  167. case '2':
  168. case '3':
  169. case '4': $btntype = 'control-btn_yellow'; $txt = 'В работе'; break;
  170. case '5': $btntype = 'control-btn_green'; $txt = 'Готово'; break;
  171. }
  172. echo "</h2><div class='control-btn $btntype content__main__state'>$txt</div>";
  173. }
  174. else {
  175. if ($new != '4')
  176. echo '<p class="content__menu__task-text">Задача не выбрана</p>';
  177. else
  178. {
  179. echo '<p>Создать новую задачу</p>';
  180. echo "<form method='post' action='?act=tasks&new=5'>";
  181. echo "<select class='form-input content__main__form__goal' name='newtasktype'>";
  182. // var_dump($tasktypes);
  183. foreach ($tasktypes as $tasktype)
  184. {
  185. if ($tasktype->main_task == '1') {
  186. $ttype = $tasktype->id;
  187. $ttname = $tasktype->name;
  188. echo "<p class='content__menu__task-text'><option value = '".$ttype."'>[" . $ttype . "] " . $ttname . "</option></p>";
  189. }
  190. }
  191. echo "</select>";
  192. echo "<br><input type='submit' value='Создать!'><br>";
  193. echo "</form>";
  194. }
  195. }
  196. $array_type = [];
  197. $array_id = [];
  198. foreach ($array_children as $parent_id => $children)
  199. {
  200. // var_dump($children);
  201. if ($activeid == $parent_id)
  202. {
  203. foreach ($children as $res1) {
  204. EchoTask2($res1, $activeid, false);
  205. $array_type[] = $res1->type;
  206. $array_id[] = $res1->id;
  207. }
  208. }
  209. }
  210. $type = implode(',',$array_type);
  211. $id = implode(',',$array_id);
  212. if (isset($activeid)) {
  213. if ($sort == 5) {
  214. echo '<p><a class="xlsbutton" href = XLSList.php?activeid='.$activeid.'&type='.$type.'&id='.$id.'><button class="control-bigbtn content__main__toexec-btn" >Скачать XLS акт</button></a></p>';
  215. echo '<p><a href = XLSdef.php><button class="control-bigbtn content__main__toexec-btn" >Скачать XLS отчет</button></a></p>';
  216. }
  217. else if ($sort == 1) {
  218. echo "<button class='control-bigbtn content__main__toexec-btn' onclick='FindStaff($taskid)'>
  219. Отправить в работу</button>";
  220. }
  221. }
  222. echo '</div></div>';
  223. //}
  224. ?>