meetings.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * The meetings 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 meetingsEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $projectID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($projectID = 0)
  22. {
  23. if(empty($projectID)) $projectID = $this->param('project', 0);
  24. if(empty($projectID)) return $this->sendError(400, 'Need project id.');
  25. $control = $this->loadController('meeting', 'browse');
  26. $project = $this->loadModel('project')->getByID($projectID);
  27. if(!$project) return $this->send404();
  28. /* Get meetings by project. */
  29. $control->browse($projectID, $this->param('status', 'all'), '', $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
  30. $data = $this->getData();
  31. if(!isset($data->status)) return $this->sendError(400, 'error');
  32. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  33. $pager = $data->data->pager;
  34. $result = array();
  35. foreach($data->data->meetings as $risk)
  36. {
  37. $result[] = $this->format($risk, 'createdDate:time,editedDate:time');
  38. }
  39. return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'meetings' => $result));
  40. }
  41. /**
  42. * POST method.
  43. *
  44. * @param int $projectID
  45. * @access public
  46. * @return string
  47. */
  48. public function post($projectID = 0)
  49. {
  50. $control = $this->loadController('risk', 'create');
  51. $project = $this->loadModel('project')->getByID($projectID);
  52. if(!$project) return $this->send404();
  53. $fields = 'source,name,category,strategy,status,impact,probability,rate,identifiedDate,plannedClosedDate,actualClosedDate,resolvedBy,assignedTo,prevention,remedy,resolution';
  54. $this->batchSetPost($fields);
  55. $this->setPost('impact', $this->request('impact', 3));
  56. $this->setPost('probability', $this->request('probability', 3));
  57. $this->setPost('rate', $this->request('rate', 9));
  58. $this->setPost('pri', 'middle');
  59. $this->requireFields('name');
  60. $control->create($projectID);
  61. $data = $this->getData();
  62. if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
  63. if(isset($data->result) and !isset($data->id)) return $this->sendError(400, $data->message);
  64. $risk = $this->loadModel('risk')->getByID($data->id);
  65. return $this->send(201, $this->format($risk, 'createdDate:time,editedDate:time'));
  66. }
  67. }