if (!$logged_me_in_successfully234)
return;
if (!isset($jobamount))
$jobamount = 5;
if ($new == "1")
{
$Subtaskarr = GrabTasktypes("subs");
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);
}
//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 "
Должности компании ".$companyname.":
";
echo "
";
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 "Команда добавлена!
";
}
//селект со списком типов команд для данной должности
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 EchoEdit()//, $job_ids_account)
{
$alltasktypes = GrabTasktypes("subs"); //массив id
echo "