bugrecordestimate.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * The bug recordWorkhour entry point of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package entries
  9. * @version 1
  10. * @link https://www.zentao.net
  11. */
  12. class bugRecordEstimateEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $bugID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($bugID)
  22. {
  23. if($this->config->edition == 'open') return $this->send400('ZenTaoPMS does not have bug effort function.');
  24. $control = $this->loadController('effort', 'createForObject');
  25. $control->createForObject('bug', $bugID);
  26. $data = $this->getData();
  27. if(!$data) return $this->error('error');
  28. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  29. $effort = $data->data->efforts;
  30. return $this->send(200, array('effort' => $effort));
  31. }
  32. /**
  33. * POST method.
  34. *
  35. * @param int $bugID
  36. * @access public
  37. * @return string
  38. */
  39. public function post($bugID)
  40. {
  41. if($this->config->edition == 'open') return $this->send400('ZenTaoPMS does not have bug effort function.');
  42. $control = $this->loadController('effort', 'createForObject');
  43. $fields = 'id,dates,consumed,objectType,objectID,work';
  44. $this->batchSetPost($fields);
  45. $control->createForObject('bug', $bugID);
  46. $data = $this->getData();
  47. if(!$data) return $this->send400('error');
  48. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  49. $bug = $this->loadModel('bug')->getByID($bugID);
  50. return $this->send(200, $this->format($bug, 'openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,reviewedBy:user,reviewedDate:time,lastEditedBy:user,lastEditedDate:time,closedBy:user,closedDate:time,deleted:bool,mailto:userList'));
  51. }
  52. }