project_types.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <?
  2. if (!$logged_me_in_successfully234)
  3. return;
  4. EchoScriptName(basename(__FILE__, '.php'));
  5. if (isset($assign_id) && isset($assign_act)) {
  6. if (StartProject($assign_act, $assign_id))
  7. TasksAssign('', true);
  8. }
  9. if ($new == "2") {
  10. $subtask_array = FillArrayString("subtask",true);
  11. $pt = new ProjectType();
  12. $pt->company = $companyID;
  13. $pt->name = $project_type_name;
  14. $priority = 0;
  15. // $series = LocoSeries::Find($loco_type);
  16. // if ($series != null) {
  17. // $pt->addSeries($series);
  18. // }
  19. foreach($subtask_array as $subtask){
  20. $priority++;
  21. $tt = Tasktype::Find($subtask);
  22. $pttt = new ProjecttypeTasktype();
  23. $pttt->priority = $priority;
  24. $pttt->projecttype = $pt;
  25. $pttt->tasktype = $tt;
  26. $pt->addTasktype($pttt);
  27. $tt->addProjectype($pttt);
  28. }
  29. $pt->Save();
  30. echo "<span style='color:green'><b>Запись добавлена!</b></span>";
  31. }
  32. else if ($new == "3") {
  33. /** @var ProjectType $pt */
  34. $pt = ProjectType::Find($del_id);
  35. if ($pt != null) {
  36. $tts = $pt->getProjecttypesTasktypes();
  37. foreach ($tts as $tt) {
  38. $pt->removeTasktype($tt);
  39. }
  40. ProjectType::Delete($del_id);
  41. echo "<span style='color:red'><b>Тип проекта $del_id, его проекты и задачи удалены!</b></span>";
  42. }
  43. }
  44. else if ($new == "5") {
  45. //mysqli_query($link, "delete from projects_locotech");
  46. //echo "<span style='color: green'>Все проекты удалены!</span>";
  47. echo "<span style='color: green'>Удаление всех проектов временно отключено!</span>";
  48. }
  49. //echo "sort1 $sorttasks $sort";
  50. if (!isset($sort))
  51. {
  52. $sort = $_SESSION['sorttasks'];
  53. if (!isset($sort)) {
  54. $sort = 1;
  55. }
  56. }
  57. $_SESSION['sorttasks'] = $sort;
  58. //echo "scr ".$scroll;
  59. echo "<input type='hidden' id='scroll' value=$scroll>";
  60. echo "<input type='hidden' id='activeptid' value=$activeid>";
  61. //echo "sort $sorttasks $sort";
  62. $active1 = '';
  63. $active2 = '';
  64. $active3 = '';
  65. $active4 = '';
  66. $active5 = '';
  67. switch ($sort)
  68. {
  69. case '1': $active1 = 'control-btn_active'; break;
  70. case '2': $active2 = 'control-btn_active'; break;
  71. case '3': $active3 = 'control-btn_active'; break;
  72. case '4': $active4 = 'control-btn_active'; break;
  73. case '5': $active5 = 'control-btn_active'; break;
  74. }
  75. echo
  76. "
  77. <div class='main__content'>
  78. <div class='content__menu'>
  79. <h2 class='content__title content__menu__title'>
  80. Типы проектов
  81. </h2>
  82. <div class='content__filter'>
  83. <img src='ProSysNew/search.svg' alt='search' class='content__search'>
  84. </div>";
  85. echo '<div class="content__menu__list">';
  86. echo ' <div class="content__menu__newproj content__menu__newproj_active" onclick = "NewListElement(\'project_types\')">
  87. <div class="content__menu__newproj__plus">
  88. +
  89. </div>
  90. <div class="content__menu__newproj__text">
  91. Новый тип проекта
  92. </div>
  93. </div><br>';
  94. EchoProjectTypes($sort);
  95. echo '</div>';
  96. echo '</div>';
  97. //PARENT TITLE IN CHILDREN LIST
  98. if ($new == 1)
  99. AddNewProjectType();
  100. else {
  101. $projects = getProjectsByAction($activeid);
  102. $action = FindAction($activeid);
  103. $acname = $action['name'];
  104. if ($activeid != null)
  105. $types = ProjectType::GrabTasktypesByProjectType($activeid);
  106. if ($activeid)
  107. {
  108. echo "<div class='content__main'><h2 class=\"content__title content__main__title\">$activeid. $acname</h2>
  109. <p class='content__main__form__text'><span style='color: black'>Добавленные типы задач:</span></p>
  110. <p class='content__main__form__text'>";
  111. //print_r($types);
  112. //echo "types: ".sizeof($types);
  113. if (sizeof($types) > 0) {
  114. //if (intval($types[0]) > 0) {
  115. $num = 0;
  116. //foreach ($types as $tid) {
  117. foreach ($types as $tasktype) {
  118. $num++;
  119. $tid = $tasktype->id;
  120. echo "$num. [$tid] <a href = '?act=tasktypes&activeid=" . $tid . "&sort=0'>" . $tasktype->name . "</a>";
  121. echo '<br>';
  122. }
  123. }
  124. // echo '<p class="content__main__form__text">
  125. // Добавить серию локомотива</p>';
  126. // $series = LocoSeries::GetAllNames();
  127. // echo' <select id="loco_type" class="form-input content__main__form__series" name="loco_type">';
  128. // foreach ($series as $serie) {
  129. // echo "<option value = '$serie' >$serie</option >";
  130. // }
  131. // echo '</select>';
  132. // echo " <input id='addseriestopt' type='button' value='Добавить'>";
  133. $ptype = ProjectType::Find($activeid);
  134. if ($ptype)
  135. {
  136. echo '<div id="result"></div>';
  137. }
  138. echo "<br><span style='color: black'>Созданные проекты:</span><br><br>";
  139. //echo "projects ".sizeof($projects);
  140. foreach ($projects as $proj)
  141. {
  142. $sort = $proj["status"];
  143. echo "<a href='?act=projects&activeid=".$proj["id"]."&sort=".$sort."'>№ ".$proj["id"]." от ".$proj["created"]."</a><br>";
  144. }
  145. echo "<br><input type='button' onclick='DelProjType($activeid)' value='Удалить тип проекта, проекты данного типа и их задачи'>";
  146. echo '</p></div>';
  147. }
  148. }
  149. echo '</div>'; //main__content
  150. function FillProjects()
  151. {
  152. global $companyID, $link;
  153. $query1 = mysqli_query($link, "select * from project_types where company=$companyID");
  154. while ($res1 = mysqli_fetch_array($query1)) {
  155. $project = new Project();
  156. $project->id = $res1['id'];
  157. }
  158. }
  159. function EchoProjectTypes($sort)
  160. {
  161. //echo "sort $sort";
  162. global $companyID, $link, $activeid;
  163. $query1 = mysqli_query($link, "select * from projecttypes where company=$companyID order by id desc");
  164. while ($res1 = mysqli_fetch_array($query1)) {
  165. $data_id = $res1['id'];
  166. $class = 'content__menu__project';
  167. if ($activeid == $data_id)
  168. $class .= ' content__menu__project_active';
  169. else
  170. $class .= ' list';
  171. $action_data = FindAction($data_id);
  172. echo "<div onclick='SelectProjectType($data_id)' class='$class'>";
  173. echo "<div class=\"content__menu__project-title\">";
  174. echo $data_id.". ".$action_data["name"];
  175. echo "</div>";
  176. echo '<div class="content__menu___project-text">';
  177. echo '<br><br></div>';
  178. echo '</div>';
  179. }
  180. }
  181. //new project
  182. function AddNewProjectType()
  183. {
  184. echo
  185. '<div class="content__main">
  186. <h2 class="content__title content__new__title">
  187. Введите данные <br>
  188. для нового типа проекта
  189. </h2>
  190. <form action="?act=project_types" method="post" class="content__main__form" onsubmit="ClearTaskCont()">
  191. <div class="content__main__form__item">
  192. <p class="content__main__form__text">
  193. Имя нового типа проекта
  194. <textarea class="form-input content__main__form__depot" name="project_type_name" ></textarea>';
  195. // echo '<select id="series" style="width: 600px;" class="form-input content__main__form__series" name="loco_type">
  196. // <option value="0"><Выберите серию локомотива></option>
  197. // </select>';
  198. echo "<div style ='line-height: 30px; height: 35px; margin:0px;margin-left:130px;border: solid; border-width:1px;border-color: white'>";
  199. echo "<div id='alg1' class='round red' onclick='SelectAlg(1)'>1</div>";
  200. echo "<div id='alg2' class='round deepskyblue' onclick='SelectAlg(2)'>2</div>";
  201. echo "<div id='alg3' class='round deepskyblue' onclick='SelectAlg(3)'>3</div>";
  202. echo "<div id='alg4' class='round deepskyblue' onclick='SelectAlg(4)'>4</div>";
  203. echo "<div id='alg_new' style='font-size: 25px' class='round deepskyblue' onclick='alert(\"Функция в разработке!\")'>+</div>";
  204. echo '</p></div><p class="content__main__form__text">Добавьте последовательность типов задач:</p>';
  205. $Subtaskarr = GrabTasktypes("tasks");
  206. // echo "sublen ".sizeof($Subtaskarr);
  207. echo "<input id='algsel' type='hidden' name='1'>";
  208. echo "<div id='taskcont1' style='display: block'>";
  209. ShowTasksSelect($Subtaskarr, 0, 'selectstring', "subtask", true);
  210. echo "</div>";
  211. echo "<div id='taskcont2' style='display: none'>";
  212. ShowTasksSelect($Subtaskarr, 0, 'selectstring', "subtask_1", true);
  213. echo "</div>";
  214. echo "<div id='taskcont3' style='display: none'>";
  215. ShowTasksSelect($Subtaskarr, 0, 'selectstring', "subtask_2", true);
  216. echo "</div>";
  217. echo "<div id='taskcont4' style='display: none'>";
  218. ShowTasksSelect($Subtaskarr, 0, 'selectstring', "subtask_3", true);
  219. echo "</div>";
  220. echo '</div>
  221. <input type="submit" value="Добавить в новые">
  222. <input type="hidden" name="new" value="2">
  223. </form>
  224. </div>
  225. ';
  226. }
  227. ?>