Введите данные новой должности:

Название:

Доступные типы команд:
'; echo "

"; ShowTasksSelect($Subtaskarr, 0, 'selectstring', "subtask"); echo "
"; echo ' '; echo '

Вернуться к списку должностей

'; } else { if ($new == "2") { $subtask_arr = FillArrayString("subtask", true); echo "Запись добавлена!"; $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 "Должность $del_id удалена!"; mysqli_query($link, "delete from jobtypes where id =".$del_id); } if ($new == "5") { //CHANGE tasktype of jobtype! $newtask_jobtype = Jobtype::Find($newtask_jobid); UpdateTaskType($newtask_jobtype, $taskvalue, $index, $oldtype); } else if ($new == "4") { //add new tasktype to jobtype! AddTaskType($new_task_jobid, $new_tasktype_id, $tasktypesarr); } $alltasktypes = GrabTasktypes("subs"); $str = ""; foreach ($alltasktypes as $type) { $str .= ""; } echo ""; echo "

Должности компании ".$companyname.":

"; $str = "select j.id, t.company, j.name, t.id as tid, t.name as tname from jobtypes_tasktypes jt join tasktypes t on jt.tasktype_id=t.id RIGHT JOIN jobtypes j on jt.jobtype_id = j.id where j.company=".$companyID; $query = mysqli_query($link, $str); for ($myarr = array(); $res = mysqli_fetch_object($query); $myarr[] = $res); $jobids = array(); echo "
"; foreach ($myarr as $jobtype) { $job_id = $jobtype->id; if ($jobtype->company && $jobtype->company != $companyID) continue; //Tasktype::ConvertTasktypes($jobtype); $jobname = $jobtype->name; $tasktypes = (object) [ 'id' => $jobtype->tid, 'name' => $jobtype->tname, 'jobname' => $jobtype->name, ]; $jobids[$job_id][] = $tasktypes; } $alltasktypes = GrabTasktypes("subs"); //массив id foreach ($jobids as $job_id=>$tasktypes) { echo "
"; echo "

" . $tasktypes[0]->jobname . " [$job_id]

"; EchoTasks2($job_id, $tasktypes, $alltasktypes); //селект со списком типов команд для данной должности $projecttypes = array(); $ptids = array(); $ptstring = ''; foreach ($tasktypes 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 .= "
[$pt->id. $pt->name] "; } } } } echo "
Доступные типы проектов: $ptstring
"; echo "
Доступные типы задач
"; echo "
"; echo "
"; echo " "; echo "
"; echo "
"; } echo "
"; echo "
"; echo ' '; EchoEdit(); } function EchoTasks2($job_id, $tasktypes, $alltasktypes) { $account_jobindex = 0; // $index = 0; foreach ($tasktypes as $tasktype) { echo "
"; $account_jobindex++; } } //селект со списком типов команд для данной должности function EchoTasks($jobtype) { $account_jobindex = 0; // $jobtasktypes = $jobtype->getTaskTypes(); $alltasktypes = GrabTasktypes("subs"); //массив id $job_id = $jobtype->id; foreach ($jobtasktypes as $tasktype) { echo " "; $account_jobindex++; } } 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 "Команда добавлена!

"; } function EchoEdit()//, $job_ids_account) { $alltasktypes = GrabTasktypes("subs"); //массив id echo "
"; echo "Выберите добавляемую команду:"; echo "
"; echo " "; echo " "; echo "

"; } ?>