response_tasktypes.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. function formAllTaskTypes($index, $job_id, $tasktypeId)
  3. {
  4. global $alltasktypes;
  5. $strSelect = " <select class='selectdiv' disabled id='jobs_".$job_id."_".$index."' onchange='if (!ChangeTaskType(".$job_id.", this.value, $index, $tasktypeId)) this.form.reset();'>";
  6. $strSelect .= "<option value='deletetasktype'>----Очистить тип----</option>";
  7. foreach ($alltasktypes as $type) {
  8. $sel = "";
  9. if ($tasktypeId == $type->id)
  10. $sel = "selected";
  11. $strSelect .= "<option ".$sel." value='" . $type->id . "'>" . $type->id.". ".$type->name . "</option>";
  12. }
  13. $strSelect .= '</select>';
  14. return $strSelect;
  15. }
  16. if (isset($editjobs))
  17. {
  18. $jobtype = Jobtype::Find($jobid);
  19. $companyID = $jobtype->getCompany();
  20. $retarr = array();
  21. $retarr["jobid"] = $jobid;
  22. if ($jobtype) {
  23. $alltasktypes = GrabTasktypes("subs"); //массив id
  24. $ttypes = $jobtype->getTaskTypes();
  25. $index = 0;
  26. foreach ($ttypes as $ttype) {
  27. $strSelect = formAllTaskTypes($index, $jobid, $ttype->id);
  28. $retarr["tasktypes"][] = array("id" => $ttype->id, "html"=> $strSelect);
  29. $index++;
  30. }
  31. }
  32. $json = json_encode($retarr, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
  33. echo $json;
  34. }