123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <?
- if (!$logged_me_in_successfully234)
- return;
- if (!isset($jobamount))
- $jobamount = 5;
- if ($new == "1")
- {
- $Subtaskarr = GrabTasktypes("subs");
- echo '<form onsubmit="return CheckSubtasks(this);" action="?act=jobs" method="post">
- <b>Введите данные новой должности:</b>
- <br>
- <p>Название: <input name="jobname"></p>
- <p><b>Доступные типы команд:</b><br>';
- echo "<div id='taskcont'>";
- ShowTasksSelect($Subtaskarr, 0, 'selectstring', "subtask");
- echo "</div>";
- echo '<input type="submit" value="Добавить">
- <input type=\'hidden\' name=\'new\' value=\'2\'>
- </form>';
- echo '<p></p><a href="?act=jobs">Вернуться к списку должностей</a></p>';
- }
- else
- {
- if ($new == "2")
- {
- $subtask_arr = FillArrayString("subtask", true);
- echo "<span style='color:green'><b>Запись добавлена!</b></span>";
- $jobtype = new Jobtype();
- foreach ($subtask_arr as $tasktype_id)
- {
- if ($tasktype_id) {
- $tasktype = Tasktype::Find($tasktype_id);
- $jobtype->name = $jobname;
- $jobtype->setCompany($companyID);
- $jobtype->addTasktype($tasktype);
- $tasktype->Save();
- }
- }
- $jobtype->Save();
- }
- else if ($new == "3")
- {
- $pt = Jobtype::Find($del_id);
- $tts = $pt->getTaskTypes();
- foreach ($tts as $tt) {
- $pt->deleteTasktype($tt);
- $tt->Save();
- }
- Jobtype::Delete($del_id);
- echo "<span style='color:red'><b>Должность $del_id удалена!</b></span>";
- mysqli_query($link, "delete from jobtypes where id =".$del_id);
- }
- //CHANGE tasktype of jobtype!
- if ($new == "5")
- {
- $newtask_jobtype = Jobtype::Find($newtask_jobid);
- UpdateTaskType($newtask_jobtype, $taskvalue, $index, $oldtype);
- }
- //add new tasktype to jobtype!
- else if ($new == "4")
- {
- AddTaskType($new_task_jobid, $new_tasktype_id, $tasktypesarr);
- }
- echo "<h3>Должности компании ".$companyname.":</h3> <form id='form1' name='form1' method='post'>";
- $jobtypes = $entityManager->getRepository('Jobtype')->findBy(array('company' => $companyID));
- foreach ($jobtypes as $jobtype) {
- //Tasktype::ConvertTasktypes($jobtype);
- $job_id = $jobtype->id;
- $jobname = $jobtype->name;
- echo "<div style='border: solid; width: 500px; border-width: 1px; border-color: #9cb2c4; border-radius: 15px; margin:5px; margin-right:20px; padding: 15px'>";
- echo "<h4>".$jobname." [$job_id]</h4>";
- EchoTasks($jobtype); //селект со списком типов команд для данной должности
- $ttypes = $jobtype->getTaskTypes();
- $projecttypes = array();
- $ptids = array();
- $ptstring = '';
- foreach ($ttypes as $ttype) {
- $parents = FindParentTaskType($ttype->id);
- foreach ($parents as $parent) {
- $mytt = Tasktype::Find($parent['id']);
- $myprojecttypes = FindActions($parent['id']);
- foreach ($mytt->getProjecttypes() as $pt) {
- if (!$ptids[$pt->id]) {
- $ptids[$pt->id] = 1;
- $ptstring .= "<br>[$pt->id. $pt->name] ";
- }
- }
- }
- }
- echo "<br><b>Доступные типы проектов:</b> $ptstring<br>";
- echo "<br><b>Доступные типы задач</b><br>";
- echo "<br><input type='button' onclick='ShowTaskTypes($job_id, \"$tasktypes\")' value='Добавить команду'>";
- echo " <input type='button' onclick='DelJob($job_id)' value='Удалить'>";
- echo "</div>";
- echo "<br>";
- }
- echo "</form>";
- echo "
- <form id='form2' name='form2' method='post'>
- <input type='submit' value='Добавить новую должность'>
- <input type='hidden' name='new' value='1'>
- </form>
- ";
- EchoEdit();
- }
- function UpdateTaskType(Jobtype $newtask_jobtype, $taskvalue, $jobindex, $oldtype)
- {
- $tasks = $newtask_jobtype->getTaskTypes();
- $oldtask = Tasktype::Find($oldtype);
- $tasks->removeElement($oldtask);
- if ($taskvalue != 'deletetasktype') {
- $newtasktype = Tasktype::Find($taskvalue);
- $newtask_jobtype->addTasktype($newtasktype);
- $newtasktype->Save();
- }
- $newtask_jobtype->Save();
- }
- function AddTaskType($job_id, $new_tasktype_id, $tasktypes)
- {
- //$new_task_jobid - должность
- //$new_tasktype_id - тип задачи
- $newtasktype = Tasktype::Find($new_tasktype_id);
- $jobtype = Jobtype::Find($job_id);
- $jobtype->addTasktype($newtasktype);
- $jobtype->Save();
- global $link;
- //echo "AddJob ".$acc_id." job id ".$new_jobtype_id." job_ids ".$job_ids;
- $tasktypes .= ','.$new_tasktype_id;
- mysqli_query($link, "update jobtypes set tasktypes='".$tasktypes."' where id=".$job_id);
- echo "<span style='color: darkolivegreen'>Команда добавлена!</span><br><br>";
- }
- //селект со списком типов команд для данной должности
- function EchoTasks($jobtype)
- {
- $account_jobindex = 0; //
- $jobtasktypes = $jobtype->getTaskTypes();
- $alltasktypes = GrabTasktypes("subs"); //массив id
- $job_id = $jobtype->id;
- foreach ($jobtasktypes as $tasktype)
- {
- echo " <select id='jobs' name='jobs' onchange='if (!ChangeTaskType(".$job_id.", this.value, $account_jobindex, $tasktype->id)) this.form.reset();'>";
- echo "<option value='deletetasktype'>----Очистить тип----</option>";
- foreach ($alltasktypes as $type) {
- $sel = "";
- if ($tasktype->id == $type->id)
- $sel = "selected";
- echo "<option ".$sel." value='" . $type->id . "'>" . $type->id.". ".$type->name . "</option>";
- }
- echo "</select>";
- $account_jobindex++;
- }
- }
- function EchoEdit()//, $job_ids_account)
- {
- $alltasktypes = GrabTasktypes("subs"); //массив id
- 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 \">";
- echo "<span style='color: green'><b>Выберите добавляемую команду:</b></span>";
- echo "<form id='form3' name='form3' method='post'>";
- echo " <select name='new_tasktype_id'>";
- foreach ($alltasktypes as $tasktype)
- {
- echo "<option value='" . $tasktype->id . "'>" . $tasktype->name . "</option>";
- //echo 'jobtype '.$jobtype['name'];
- }
- echo "</select>";
- echo "<input type='submit' value='Добавить'>
- <input type='hidden' name='new' value='4'>
- <input type='hidden' name='new_task_jobid' value=''>
- <input type='hidden' name='tasktypes' value=''>";
- echo "</form></div><br>";
- }
- ?>
|