jobs_old.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?
  2. if (!$logged_me_in_successfully234)
  3. return;
  4. if (!isset($jobamount))
  5. $jobamount = 5;
  6. if ($new == "1")
  7. {
  8. $Subtaskarr = GrabTasktypes("subs");
  9. echo '<form onsubmit="return CheckSubtasks(this);" action="?act=jobs" method="post">
  10. <b>Введите данные новой должности:</b>
  11. <br>
  12. <p>Название: <input name="jobname"></p>
  13. <p><b>Доступные типы команд:</b><br>';
  14. echo "<div id='taskcont'>";
  15. ShowTasksSelect($Subtaskarr, 0, 'selectstring', "subtask");
  16. echo "</div>";
  17. echo '<input type="submit" value="Добавить">
  18. <input type=\'hidden\' name=\'new\' value=\'2\'>
  19. </form>';
  20. echo '<p></p><a href="?act=jobs">Вернуться к списку должностей</a></p>';
  21. }
  22. else
  23. {
  24. if ($new == "2")
  25. {
  26. $subtask_arr = FillArrayString("subtask", true);
  27. echo "<span style='color:green'><b>Запись добавлена!</b></span>";
  28. $jobtype = new Jobtype();
  29. foreach ($subtask_arr as $tasktype_id)
  30. {
  31. if ($tasktype_id) {
  32. $tasktype = Tasktype::Find($tasktype_id);
  33. $jobtype->name = $jobname;
  34. $jobtype->setCompany($companyID);
  35. $jobtype->addTasktype($tasktype);
  36. $tasktype->Save();
  37. }
  38. }
  39. $jobtype->Save();
  40. }
  41. else if ($new == "3")
  42. {
  43. $pt = Jobtype::Find($del_id);
  44. $tts = $pt->getTaskTypes();
  45. foreach ($tts as $tt) {
  46. $pt->deleteTasktype($tt);
  47. $tt->Save();
  48. }
  49. Jobtype::Delete($del_id);
  50. echo "<span style='color:red'><b>Должность $del_id удалена!</b></span>";
  51. mysqli_query($link, "delete from jobtypes where id =".$del_id);
  52. }
  53. //CHANGE tasktype of jobtype!
  54. if ($new == "5")
  55. {
  56. $newtask_jobtype = Jobtype::Find($newtask_jobid);
  57. UpdateTaskType($newtask_jobtype, $taskvalue, $index, $oldtype);
  58. }
  59. //add new tasktype to jobtype!
  60. else if ($new == "4")
  61. {
  62. AddTaskType($new_task_jobid, $new_tasktype_id, $tasktypesarr);
  63. }
  64. echo "<h3>Должности компании ".$companyname.":</h3> <form id='form1' name='form1' method='post'>";
  65. $jobtypes = $entityManager->getRepository('Jobtype')->findBy(array('company' => $companyID));
  66. foreach ($jobtypes as $jobtype) {
  67. //Tasktype::ConvertTasktypes($jobtype);
  68. $job_id = $jobtype->id;
  69. $jobname = $jobtype->name;
  70. echo "<div style='border: solid; width: 500px; border-width: 1px; border-color: #9cb2c4; border-radius: 15px; margin:5px; margin-right:20px; padding: 15px'>";
  71. echo "<h4>".$jobname." [$job_id]</h4>";
  72. EchoTasks($jobtype); //селект со списком типов команд для данной должности
  73. $ttypes = $jobtype->getTaskTypes();
  74. $projecttypes = array();
  75. $ptids = array();
  76. $ptstring = '';
  77. foreach ($ttypes as $ttype) {
  78. $parents = FindParentTaskType($ttype->id);
  79. foreach ($parents as $parent) {
  80. $mytt = Tasktype::Find($parent['id']);
  81. $myprojecttypes = FindActions($parent['id']);
  82. foreach ($mytt->getProjecttypes() as $pt) {
  83. if (!$ptids[$pt->id]) {
  84. $ptids[$pt->id] = 1;
  85. $ptstring .= "<br>[$pt->id. $pt->name] ";
  86. }
  87. }
  88. }
  89. }
  90. echo "<br><b>Доступные типы проектов:</b> $ptstring<br>";
  91. echo "<br><b>Доступные типы задач</b><br>";
  92. echo "<br><input type='button' onclick='ShowTaskTypes($job_id, \"$tasktypes\")' value='Добавить команду'>";
  93. echo " <input type='button' onclick='DelJob($job_id)' value='Удалить'>";
  94. echo "</div>";
  95. echo "<br>";
  96. }
  97. echo "</form>";
  98. echo "
  99. <form id='form2' name='form2' method='post'>
  100. <input type='submit' value='Добавить новую должность'>
  101. <input type='hidden' name='new' value='1'>
  102. </form>
  103. ";
  104. EchoEdit();
  105. }
  106. function UpdateTaskType(Jobtype $newtask_jobtype, $taskvalue, $jobindex, $oldtype)
  107. {
  108. $tasks = $newtask_jobtype->getTaskTypes();
  109. $oldtask = Tasktype::Find($oldtype);
  110. $tasks->removeElement($oldtask);
  111. if ($taskvalue != 'deletetasktype') {
  112. $newtasktype = Tasktype::Find($taskvalue);
  113. $newtask_jobtype->addTasktype($newtasktype);
  114. $newtasktype->Save();
  115. }
  116. $newtask_jobtype->Save();
  117. }
  118. function AddTaskType($job_id, $new_tasktype_id, $tasktypes)
  119. {
  120. //$new_task_jobid - должность
  121. //$new_tasktype_id - тип задачи
  122. $newtasktype = Tasktype::Find($new_tasktype_id);
  123. $jobtype = Jobtype::Find($job_id);
  124. $jobtype->addTasktype($newtasktype);
  125. $jobtype->Save();
  126. global $link;
  127. //echo "AddJob ".$acc_id." job id ".$new_jobtype_id." job_ids ".$job_ids;
  128. $tasktypes .= ','.$new_tasktype_id;
  129. mysqli_query($link, "update jobtypes set tasktypes='".$tasktypes."' where id=".$job_id);
  130. echo "<span style='color: darkolivegreen'>Команда добавлена!</span><br><br>";
  131. }
  132. //селект со списком типов команд для данной должности
  133. function EchoTasks($jobtype)
  134. {
  135. $account_jobindex = 0; //
  136. $jobtasktypes = $jobtype->getTaskTypes();
  137. $alltasktypes = GrabTasktypes("subs"); //массив id
  138. $job_id = $jobtype->id;
  139. foreach ($jobtasktypes as $tasktype)
  140. {
  141. echo " <select id='jobs' name='jobs' onchange='if (!ChangeTaskType(".$job_id.", this.value, $account_jobindex, $tasktype->id)) this.form.reset();'>";
  142. echo "<option value='deletetasktype'>----Очистить тип----</option>";
  143. foreach ($alltasktypes as $type) {
  144. $sel = "";
  145. if ($tasktype->id == $type->id)
  146. $sel = "selected";
  147. echo "<option ".$sel." value='" . $type->id . "'>" . $type->id.". ".$type->name . "</option>";
  148. }
  149. echo "</select>";
  150. $account_jobindex++;
  151. }
  152. }
  153. function EchoEdit()//, $job_ids_account)
  154. {
  155. $alltasktypes = GrabTasktypes("subs"); //массив id
  156. echo "<div id='tasks_block' style=\"display: none; margin-left: 0px; padding: 10px; background-color: white; border-color: #E1E1E1; border: solid; border-width: 1px; position: fixed; top: 100px;left: 300px \">";
  157. echo "<span style='color: green'><b>Выберите добавляемую команду:</b></span>";
  158. echo "<form id='form3' name='form3' method='post'>";
  159. echo " <select name='new_tasktype_id'>";
  160. foreach ($alltasktypes as $tasktype)
  161. {
  162. echo "<option value='" . $tasktype->id . "'>" . $tasktype->name . "</option>";
  163. //echo 'jobtype '.$jobtype['name'];
  164. }
  165. echo "</select>";
  166. echo "<input type='submit' value='Добавить'>
  167. <input type='hidden' name='new' value='4'>
  168. <input type='hidden' name='new_task_jobid' value=''>
  169. <input type='hidden' name='tasktypes' value=''>";
  170. echo "</form></div><br>";
  171. }
  172. ?>