TaskTypesModel.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\models;
  3. use Yii;
  4. use yii\base\Model;
  5. use yii\web\Response;
  6. use app\models\entity\Projecttypes;
  7. /**
  8. * ContactForm is the model behind the contact form.
  9. */
  10. class ProjectTypesModel extends Model
  11. {
  12. public function GrabTasktypes($chooseSubtasks = "all", $action = 0)
  13. {
  14. global $link, $companyID;
  15. //$str = "select * from tasktypes where company=$companyID";
  16. $str = "select p_r.id,p_r.name,p_r.input_keyword,p_r.company,p_r.tasktypes
  17. from project_types p_r
  18. join projectstypes_tasktypes p_t on p_t.project_types_id = p_r.id
  19. join tasktypes t on t.id = p_t.tasktypes_id
  20. where p_r.company = $companyID" ;
  21. if ($chooseSubtasks == "subs")
  22. $str .= " and main_task = 0";
  23. else if ($chooseSubtasks == "tasks")
  24. $str .= " and main_task = 1";
  25. if ($action > 0) {
  26. $ttstring = GrabTasktypesStringFromAction($action);
  27. //$str .= " and id in ($ttstring)";
  28. $str .= " and p_r.id = $action";
  29. }
  30. $str .= ' ORDER BY id desc';
  31. // echo "grab str ".$str." <br>action ".$action;
  32. // echo "grab TT11 ";
  33. $query1 = mysqli_query($link, $str);
  34. $subtaskarr = array();
  35. while ($res1 = mysqli_fetch_array($query1)) {
  36. //echo "grab TT ".$res1['id']." tt.id ".$res1['tt.id'];
  37. // print_r($res1);
  38. // echo "<br><br>";
  39. $tasktype_id = $res1['id'];
  40. $subtaskarr[$tasktype_id] = $res1;
  41. }
  42. return $subtaskarr;
  43. }
  44. }