tasktypes.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <?
  2. use CheckPointTypes\CheckPointType;
  3. use Tasks\Task;
  4. if (!$logged_me_in_successfully234)
  5. return;
  6. if (!isset($sort))
  7. {
  8. $sort = $_SESSION['sorttasks'];
  9. if (!isset($sort)) {
  10. $sort = 1;
  11. }
  12. }
  13. $_SESSION['sorttasks'] = $sort;
  14. if ($new != "2" && $new != "3")
  15. $taskarr = GrabTasktypes();
  16. if ($new == "2") {
  17. $subtask_string = FillArrayString("subtask");
  18. //$subtask_string = implode(",", $subtask_arr);
  19. $main_task = $sort;
  20. if ($main_task)
  21. {
  22. $confirmtype = 0;
  23. $timecomplete = 0;
  24. }
  25. echo "<span style='color:green'><b>Тип задачи добавлен!</b></span>";
  26. $names = 'creator_id, name, description, company, subtasks, main_task, confirmtype, time_to_complete_minutes, object_name, control_map, letter';
  27. $values = $id.",'$taskname','$description',$companyID,'$subtask_string',$main_task,$confirmtype,$timecomplete,'$object_name','$control','$letter'";
  28. if (strlen($action)>0) {
  29. $names .= ', action';
  30. $values .= ",".$action;
  31. }
  32. $str = "insert into tasktypes (".$names.") values (".$values.")";
  33. mysqli_query($link, $str);
  34. $lastid = mysqli_insert_id($link);
  35. $taskarr = GrabTasktypes();
  36. if ( $_FILES )
  37. {
  38. // var_dump($_FILES);
  39. $file = $_FILES['filename'];
  40. $rootPath = $_SERVER['DOCUMENT_ROOT'];
  41. $videoPath = $rootPath."/guides/$lastid/";
  42. if(!is_dir($videoPath))
  43. {
  44. mkdir($videoPath);
  45. }
  46. //Временно!!!
  47. // echo "fname ".$file['name'];
  48. // echo "tmp_name ".$file['tmp_name'];
  49. $namearr = explode(".", $file['name'][0]);
  50. $ext = end($namearr);
  51. if ($ext == "mp4" || $ext == "pdf" || $ext == "jpg" || $ext == "jpeg" || $ext == "avi")
  52. $file['name'][0] = "video.mp4";
  53. $target = $videoPath.$file['name'][0];
  54. move_uploaded_file( $file['tmp_name'][0], $target);
  55. }
  56. }
  57. else if ($new == "3") {
  58. echo "<span style='color:red'><b>Тип задач $task_id удален!</b></span>";
  59. DeleteTasksByType($task_id);
  60. ClearTaskTypeFromJobs($task_id);
  61. mysqli_query($link, "delete from tasktypes where id =".$task_id);
  62. mysqli_query($link, "delete from checkpoint_types_for_tasks where tasktype_id=$task_id");
  63. $taskarr = GrabTasktypes();
  64. }
  65. echo "<input type='hidden' id='scroll' value=$scroll>";
  66. $active1 = '';
  67. $active0 = '';
  68. switch ($sort)
  69. {
  70. case '0': $active0 = 'control-btn_active'; break;
  71. case '1': $active1 = 'control-btn_active'; break;
  72. default: $active1 = 'control-btn_active'; $sort = '1';
  73. }
  74. $taskword = "задач";
  75. if ($sort == '0')
  76. $taskword = "команд";
  77. echo
  78. "
  79. <div class='main__content'>
  80. <div class='content__menu'>
  81. <h2 class='content__title content__menu__title'>
  82. Типы задач
  83. </h2>
  84. <div class='content__filter'>
  85. <img src='ProSysNew/search.svg' alt='search' class='content__search'>
  86. <div class='content__controls'>
  87. <button class='control-btn control-btn_green content__filter__btn $active1' onclick='SortElements(1, \"tasktypes\")'>Задачи</button>
  88. <button class='control-btn control-btn_yellow content__filter__btn $active0' onclick='SortElements(0, \"tasktypes\")'>Команды</button>
  89. </div>
  90. </div>";
  91. echo '<div class="content__menu__list">';
  92. echo " <div class='content__menu__newproj content__menu__newproj_active' onclick = 'NewListElement(\"tasktypes\")'>
  93. <div class='content__menu__newproj__plus'>
  94. +
  95. </div>
  96. <div class='content__menu__newproj__text'>
  97. Новый тип $taskword
  98. </div>
  99. </div><br>";
  100. EchoTasktypes($sort, $taskarr);
  101. echo '</div>';
  102. echo '</div>';
  103. //PARENT TITLE IN CHILDREN LIST
  104. if ($new == 1)
  105. AddNewTaskType();
  106. else {
  107. $ttype = GrabTasktype($activeid);
  108. $ttypend = GetTaskNameAndDesc($activeid);
  109. $acttname = $ttypend[0];
  110. $ttdesc = $ttypend[1];
  111. $actionid = $ttype['ProjectType'];
  112. $action = FindAction($actionid);
  113. $acname = $action['name'];
  114. $main = $ttype['main_task'];
  115. $control = $ttype['control_map'];
  116. $subs = explode(',',$ttype['subtasks']);
  117. if ($activeid)
  118. {
  119. echo "<div class='content__main'>
  120. <h2 id='activeTaskTypeId' data-activeid='$activeid' class=\"content__title content__main__title\">$activeid. $acttname<p class='content__main__form__text black'>$ttdesc </p></h2>";
  121. if ($main) {
  122. $mytt = Tasktype::Find($activeid);
  123. $letter = $mytt->letter;
  124. if ($letter)
  125. $lettername = "[Секция $letter]";
  126. echo "<h3>$lettername</h3>";
  127. echo "<p class='content__main__form__text black'><b>Типы проекта с данным типом задач:</b></p>";
  128. foreach ($mytt->getProjecttypes() as $ptype) {
  129. $actionid = $ptype->id;
  130. $acname = $ptype->name;
  131. echo "<p class='content__main__form__text black'><a href='?act=project_types&activeid=$actionid'>$actionid. $acname </a><br></p>";
  132. }
  133. echo "<br>";
  134. }
  135. // switch ($letter)
  136. // {
  137. // case "А": $selectedA = "selected"; break;
  138. // case "Б": $selectedB = "selected"; break;
  139. // case "В": $selectedV = "selected"; break;
  140. // case "Г": $selectedG = "selected"; break;
  141. // }
  142. // echo "Буква секции:
  143. // <select id='letter_tasktype' class='form-input content__main__form__series' name='letter'>
  144. // <option value='0'><Выберите букву секции></option>
  145. // <option $selectedA value='А'>А</option>
  146. // <option $selectedB value='Б'>Б</option>
  147. // <option $selectedV value='В'>В</option>
  148. // <option $selectedG value='Г'>Г</option>
  149. // </select>";
  150. if (!$main) {
  151. EchoCheckPoints($activeid);
  152. }
  153. $confirmtype = $ttype['confirmtype'];
  154. $confirmtypename = getConfirmTypeName($confirmtype);
  155. $zone = $ttype['zone_required_id'];
  156. echo "<br><p class='content__main__form__text black'><b>Способ подтверждения задачи:</b> $confirmtypename<br>";
  157. echo "<br><p class='content__main__form__text black'><b>Выполнить в зоне:</b> $zone (".GetZoneName($zone).")<br>";
  158. $time = intval($ttype['time_to_complete_minutes']);
  159. echo "<div id='result'></div>";
  160. echo "<br><p class='content__main__form__text black'><b>Время на выполнение:</b> $time минут<br>";
  161. if ($main) {
  162. echo "<p class='content__main__form__text black'><b>Добавленные типы команд:</b> <br></p>";
  163. echo "<p class='content__main__form__text'>";
  164. $num = 0;
  165. foreach ($subs as $typeid)
  166. {
  167. $type = GrabTasktype($typeid);
  168. $tid = $type['id'];
  169. $taction = $type['ProjectType'];
  170. $num++;
  171. if ($type['main_task'])
  172. echo "[Главная] ";
  173. echo "<a href = '?act=tasktypes&activeid=" . $tid . "&sort=0'>$num. " . $type['name'] . " [" . $type['id'] . "]</a>";
  174. echo '<br>';
  175. }
  176. echo "</p>";
  177. }
  178. if (!$main) {
  179. $addcmd = " для данной команды";
  180. }
  181. echo "<br><p class='content__main__form__text black'><b>Активные задачи$addcmd:</b><br>";
  182. $tasks = GrabTasksByType($activeid);
  183. foreach ($tasks as $task)
  184. {
  185. $type = $task['type'];
  186. $id = $task['id'];
  187. $ttname = GetTaskNameAndDesc($type)[0];
  188. //$sort = $task['status'];
  189. $sort = GetTaskStatus($id);
  190. if ($task['parent_id'] == '0')
  191. {
  192. echo "<a href = '?act=tasks&activeid=".$id."&sort=".$sort."'>".$id.". $ttname</a><br>";
  193. }
  194. else
  195. {
  196. echo "<a href = '?act=tasks&activeid=" . $task['parent_id'] . "&sort=" . $sort . "'>" . $task['parent_id'].". $acttname</a><br>";
  197. }
  198. }
  199. echo "</p>";
  200. $imgpath = GetVideoPathFromTasktype($activeid);
  201. $files1 = scandir($imgpath);
  202. if (sizeof($files1) > 2)
  203. {
  204. echo "<br>
  205. <div style='overflow: auto; '>";
  206. foreach ($files1 as $file )
  207. {
  208. $x = pathinfo($file)['extension'];
  209. if($file === '.' || $file === '..') {continue;}
  210. echo '<br>';
  211. if ($x == 'mp4' || $x == 'jpg' || $x == 'jpeg' || $x == 'pdf' || $x == 'avi') {
  212. echo "<div style='float:left'><p class='content__main__form__text black'><a href=\"javascript:openvideo('" . $imgpath . $file . "');\">$file</a></p></div>";
  213. // echo "<a href='$imgpath$file'>$file</a>";
  214. }
  215. echo '<br>';
  216. }
  217. echo '</div><br></p>';
  218. }
  219. echo "<br><input type='button' onclick='DelTaskType($activeid)' value='Удалить тип и задачи данного типа'>";
  220. echo '</div>';
  221. }
  222. }
  223. echo '</div>'; //main__content
  224. function EchoCheckPoints($activeid)
  225. {
  226. include "checkpoints.php";
  227. \CheckPoints\CheckPoint::EchoTypes($activeid);
  228. }
  229. function GetCheckListTypes($task_id)
  230. {
  231. global $link;
  232. $query = mysqli_query($link, "select * from checkpoint_types where parent_task_type = $task_id");
  233. $arr = array();
  234. while ($res = mysqli_fetch_array($query)) {
  235. array_push($arr, $res);
  236. }
  237. return $arr;
  238. }
  239. function EchoTaskTypes($sort, $arr, $chooseSubtasks = false)
  240. {
  241. global $activeid;
  242. foreach ($arr as $tasktype)
  243. {
  244. $tasktype_id = $tasktype->id;
  245. $taskname = $tasktype->name;
  246. $description = $tasktype->description;
  247. $main = $tasktype->main_task;
  248. $letter = $tasktype->letter;
  249. if ($letter)
  250. $letter = "[Секция $letter]";
  251. if ($main != $sort)
  252. continue;
  253. $completeTime = intval($tasktype->time_to_complete_minutes);
  254. $class = 'content__menu__project';
  255. if ($activeid == $tasktype_id)
  256. $class .= ' content__menu__project_active';
  257. else
  258. $class .= ' list';
  259. $myid = " id='active'";
  260. echo "<div onclick='SelectElement($tasktype_id, \"tasktypes\")' class='$class'";
  261. if ($activeid == $tasktype_id && !$main)
  262. echo $myid;
  263. echo ">";
  264. echo "<div class=\"content__menu__project-title\">";
  265. echo $tasktype_id.". $taskname $letter<br>";
  266. echo "</div>";
  267. echo "<input id='active_task_type' type='hidden' value='$activeid'>";
  268. echo '<div class="content__menu___project-text">';
  269. if ($description != '')
  270. echo " [$description]<br>";
  271. if (!$main)
  272. echo "<b>На выполнение:</b> ".$completeTime." минут";
  273. echo '<br><br></div></div>';
  274. }
  275. }
  276. //new project
  277. function AddNewTaskType()
  278. {
  279. global $companyID, $sort, $taskword, $Subtaskarr, $c_action, $numsel;
  280. if (!isset($c_action))
  281. $c_action = 2;
  282. $confirmtypes = GrabConfirmTypes(intval($companyID));
  283. echo "<div class=\"content__main\">
  284. <h2 class=\"content__title content__new__title\">
  285. Введите данные <br>
  286. нового типа $taskword
  287. </h2>";
  288. echo
  289. '<input type="hidden" name="MAX_FILE_SIZE" value="20000000">
  290. <form action="?act=tasktypes" method="post" class="content__main__form" enctype="multipart/form-data">
  291. <div class="content__main__form__item">';
  292. // echo ' <p class="content__main__form__text">
  293. // Тип объекта
  294. // </p>';
  295. // echo
  296. // '<select class="form-input content__main__form__series" name="object_name">
  297. // <option value="Э5К">Э5К</option>
  298. // <option value="2ЭС5К">2ЭС5К</option>
  299. // <option value="3ЭС5К3">3ЭС5К</option>
  300. // </select>
  301. // ';
  302. echo '</div>';
  303. if ($sort == '0') //КОМАНДЫ
  304. {
  305. echo "<p class='content__main__form__text'>Способ подтверджения выполнения команды:</p>
  306. <select class='form-input content__main__form__goal' name='confirmtype'>";
  307. foreach ($confirmtypes as $res) {
  308. echo "<option value='" . $res["id"] . "'>" . $res["name"] . "</option>";
  309. }
  310. echo "</select>
  311. <br><p class='content__main__form__text'>
  312. Время на выполнение (минуты)</p>";
  313. echo "<input type='text' name='timecomplete'>";
  314. }
  315. //ЗАДАЧИ
  316. else {
  317. // echo '<p class="content__main__form__text">Буква секции:
  318. // <select class="form-input content__main__form__series" name="letter">
  319. // <option value="А">А</option>
  320. // <option value="Б">Б</option>
  321. // <option value="В">В</option>
  322. // <option value="Г">Г</option>
  323. // </select>
  324. // </p> ';
  325. echo '<p class="content__main__form__text">
  326. Команды (подзадачи):
  327. </p> ';
  328. if (!isset($numsel))
  329. $numsel = 1;
  330. $Subtaskarr = GrabTasktypes(true);
  331. $sublen = sizeof($Subtaskarr);
  332. echo "<div id='taskcont'>";
  333. ShowTasksSelect($Subtaskarr, 0, 'selectstring', "subtask");
  334. echo "</div>";
  335. }
  336. echo '<div class="content__main__form__item"><br>
  337. <p class="content__main__form__text">Имя:
  338. <input class="form-input content__main__form__goal" type = "text" name="taskname" value="">
  339. </p>
  340. <p class="content__main__form__text">
  341. Описание
  342. </p>
  343. <textarea style="width: 500px" name="description" rows="3"></textarea>
  344. <input type="hidden" name="new" value="2">
  345. <input type="hidden" name="main_task" value="0">';
  346. echo '</div>';
  347. if ($sort == '0') {
  348. echo '<input type="submit" value="Добавить в новые:"">
  349. <label for="videoload" >Выберите файлы</label>
  350. <input id="videoload" type="file" name="filename[]" accept=".mp4,.avi,.jpg,.jpeg,.pdf" multiple>';
  351. }
  352. else
  353. echo '<input type="submit" value="Добавить в новые">';
  354. echo '</form>';
  355. echo " </div>";
  356. echo "
  357. <script>
  358. $('#videoload').change(function() {
  359. if ($(this).val() != '') $(this).prev().text('Выбрано файлов: ' + $(this)[0].files.length);
  360. else $(this).prev().text('Выберите файлы');
  361. });
  362. </script>
  363. ";
  364. }
  365. ?>