productplan.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * The productplan 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 productplanEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $planID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($planID)
  22. {
  23. $fields = $this->param('fields');
  24. $control = $this->loadController('productplan', 'view');
  25. $control->view($planID);
  26. $data = $this->getData();
  27. if(!$data or !isset($data->status)) return $this->send400('error');
  28. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  29. $plan = $data->data->plan;
  30. $plan->stories = $data->data->planStories;
  31. $plan->bugs = $data->data->planBugs;
  32. $plan = $this->format($plan, 'begin:date,end:date,deleted:bool,stories:array,bugs:array');
  33. return $this->send(200, $plan);
  34. }
  35. /**
  36. * PUT method.
  37. *
  38. * @param int $planID
  39. * @access public
  40. * @return string
  41. */
  42. public function put($planID)
  43. {
  44. $control = $this->loadController('productplan', 'edit');
  45. $oldPlan = $this->loadModel('productplan')->getByID($planID);
  46. /* Set $_POST variables. */
  47. $fields = 'title,begin,end,desc';
  48. $this->batchSetPost($fields, $oldPlan);
  49. $this->setPost('product', $oldPlan->product);
  50. $this->setPost('status', $oldPlan->status);
  51. $control->edit($planID);
  52. $data = $this->getData();
  53. if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
  54. /* Get plan info. */
  55. $control = $this->loadController('productplan', 'view');
  56. $control->view($planID);
  57. $data = $this->getData();
  58. if(!$data or !isset($data->status)) return $this->send400('error');
  59. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  60. $plan = $this->productplan->getByID($planID);
  61. return $this->send(200, $this->format($plan, 'begin:date,end:date,deleted:bool,stories:array,bugs:array'));
  62. }
  63. /**
  64. * DELETE method.
  65. *
  66. * @param int $productID
  67. * @access public
  68. * @return string
  69. */
  70. public function delete($planID)
  71. {
  72. $control = $this->loadController('productplan', 'delete');
  73. $control->delete($planID, 'yes');
  74. $this->getData();
  75. return $this->sendSuccess(200, 'success');
  76. }
  77. }