* Add ticket api.
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* The ticket entry point of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package entries
|
||||
* @version 1
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class ticketEntry extends entry
|
||||
{
|
||||
/**
|
||||
* GET method.
|
||||
*
|
||||
* @param int $ticketID
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function get($ticketID)
|
||||
{
|
||||
$control = $this->loadController('ticket', 'view');
|
||||
$control->view($ticketID);
|
||||
|
||||
$data = $this->getData();
|
||||
|
||||
$ticket = $data->data->ticket;
|
||||
|
||||
$ticket->productName = $data->data->product;
|
||||
$ticket->moduleName = isset($data->data->modulePath[0]->name) ? $data->data->modulePath[0]->name : '/';
|
||||
|
||||
if(!$data or !isset($data->status)) return $this->send400('error');
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
|
||||
|
||||
$ticket->actions = $this->loadModel('action')->processActionForAPI($data->data->actions, $data->data->users, $this->lang->ticket);
|
||||
return $this->send(200, $this->format($ticket, 'activatedDate:time,openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,mailto:userList,resolvedBy:user,resolvedDate:time,closedBy:user,closedDate:time,lastEditedBy:user,lastEditedDate:time,deadline:date,deleted:bool'));
|
||||
}
|
||||
|
||||
/**
|
||||
* PUT method.
|
||||
*
|
||||
* @param int $ticketID
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function put($ticketID)
|
||||
{
|
||||
$oldTicket = $this->loadModel('ticket')->getById($ticketID);
|
||||
|
||||
$fields = 'module,product,type,openedBuild,assignedTo,deadline,title,desc,status,notify,uid';
|
||||
$this->batchSetPost($fields, $oldTicket);
|
||||
|
||||
$control = $this->loadController('ticket', 'edit');
|
||||
$control->edit($ticketID);
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
|
||||
if(!isset($data->result)) return $this->sendError(400, 'error');
|
||||
|
||||
$ticket = $this->ticket->getByID($ticketID);
|
||||
|
||||
return $this->send(200, $this->format($ticket, 'openedBy:user,openedDate:time,activatedBy:user,activatedDate:time,finishedBy:user,finishedDate:time,closedBy:user,closedDate:time,editedBy:user,editedDate:time,deadline:time,assignedTo:user,mailto:userList,deleted:bool'));
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE method.
|
||||
*
|
||||
* @param int $ticketID
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function delete($ticketID)
|
||||
{
|
||||
$control = $this->loadController('ticket', 'delete');
|
||||
$control->delete($ticketID, 'yes');
|
||||
|
||||
$this->getData();
|
||||
return $this->sendSuccess(200, 'success');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* The ticketsEntry entry point of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
|
||||
* @package entries
|
||||
* @version 1
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class ticketsEntry extends entry
|
||||
{
|
||||
/**
|
||||
* GET method.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
if(strpos(strtolower($this->param('fields')), 'moduleandproduct') !== false) return $this->getModuleAndProduct();
|
||||
|
||||
$control = $this->loadController('ticket', 'browse');
|
||||
$control->browse($this->param('status', 'wait'), 0, $this->param('orderBy', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
|
||||
$data = $this->getData();
|
||||
|
||||
if(!$data or !isset($data->status)) return $this->sendError(400, 'error');
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
$tickets = $data->data->tickets;
|
||||
$pager = $data->data->pager;
|
||||
|
||||
$result = array();
|
||||
foreach($tickets as $ticket)
|
||||
{
|
||||
$result[] = $this->format($ticket, 'openedBy:user,openedDate:time,activatedBy:user,activatedDate:time,finishedBy:user,finishedDate:time,closedBy:user,closedDate:time,editedBy:user,editedDate:time,deadline:time,assignedTo:user,mailto:userList,deleted:bool');
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data['page'] = $pager->pageID;
|
||||
$data['total'] = $pager->recTotal;
|
||||
$data['limit'] = $pager->recPerPage;
|
||||
$data['tickets'] = $result;
|
||||
|
||||
return $this->send(200, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST method.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function post()
|
||||
{
|
||||
$fields = 'module,product,type,openedBuild,assignedTo,deadline,title,desc,status,notify,uid';
|
||||
$this->batchSetPost($fields);
|
||||
|
||||
$control = $this->loadController('ticket', 'create');
|
||||
$this->requireFields('title,product,module');
|
||||
$control->create();
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
$ticket = $this->loadModel('ticket')->getByID($data->id);
|
||||
|
||||
return $this->send(201, $this->format($ticket, 'openedBy:user,openedDate:time,activatedBy:user,activatedDate:time,finishedBy:user,finishedDate:time,closedBy:user,closedDate:time,editedBy:user,editedDate:time,deadline:time,assignedTo:user,mailto:userList,deleted:bool'));
|
||||
}
|
||||
|
||||
/**
|
||||
* GET method.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getModuleAndProduct()
|
||||
{
|
||||
$control = $this->loadController('ticket', 'create');
|
||||
$control->create();
|
||||
|
||||
$data = $this->getData();
|
||||
|
||||
$modules = $data->data->modules;
|
||||
$products = $data->data->products;
|
||||
|
||||
$data = array();
|
||||
$data['modules'] = $modules;
|
||||
$data['products'] = $products;
|
||||
|
||||
return $this->send(200, $data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,11 @@ $routes['/feedbacks/:id'] = 'feedback';
|
||||
$routes['/feedbacks/:id/assign'] = 'feedbackAssignto';
|
||||
$routes['/feedbacks/:id/close'] = 'feedbackClose';
|
||||
|
||||
$routes['/tickets'] = 'tickets';
|
||||
$routes['/tickets/:id'] = 'ticket';
|
||||
$routes['/tickets/:id/assign'] = 'ticketAssignto';
|
||||
$routes['/tickets/:id/close'] = 'ticketClose';
|
||||
|
||||
$routes['/options/:type'] = 'options';
|
||||
|
||||
$routes['/configurations'] = 'configs';
|
||||
|
||||
+304
-77
File diff suppressed because one or more lines are too long
+1068
-10
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
a:1:{i:0;O:8:"stdClass":12:{s:2:"id";s:2:"14";s:3:"lib";s:2:"24";s:4:"name";s:4:"user";s:4:"type";s:4:"json";s:4:"desc";s:0:"";s:7:"version";s:1:"2";s:9:"attribute";s:537:"[{"field":"id","paramsType":"int","required":"","desc":"","structType":"json","sub":1,"key":"kwoq04srulxevt93a3h","children":[]},{"field":"account","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0a387on1wpuwntd","children":[]},{"field":"realname","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0i4g80qyu8lqp28","children":[]},{"field":"avatar","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0le57o2p6vxc8ov","children":[]}]";s:7:"addedBy";s:5:"admin";s:9:"addedDate";s:19:"2022-06-28 09:51:30";s:8:"editedBy";s:5:"admin";s:10:"editedDate";s:19:"2022-06-28 09:51:30";s:7:"deleted";s:1:"0";}}
|
||||
a:1:{i:0;O:8:"stdClass":12:{s:2:"id";s:1:"1";s:3:"lib";s:3:"833";s:4:"name";s:4:"user";s:4:"type";s:4:"json";s:4:"desc";s:0:"";s:7:"version";s:1:"2";s:9:"attribute";s:537:"[{"field":"id","paramsType":"int","required":"","desc":"","structType":"json","sub":1,"key":"kwoq04srulxevt93a3h","children":[]},{"field":"account","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0a387on1wpuwntd","children":[]},{"field":"realname","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0i4g80qyu8lqp28","children":[]},{"field":"avatar","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0le57o2p6vxc8ov","children":[]}]";s:7:"addedBy";s:6:"wwccss";s:9:"addedDate";s:19:"2022-12-22 10:35:42";s:8:"editedBy";s:6:"wwccss";s:10:"editedDate";s:19:"2022-12-22 10:35:42";s:7:"deleted";s:1:"0";}}
|
||||
@@ -1 +1 @@
|
||||
a:3:{i:0;O:8:"stdClass":8:{s:2:"id";s:2:"21";s:4:"name";s:4:"user";s:4:"type";s:4:"json";s:4:"desc";s:0:"";s:9:"attribute";s:537:"[{"field":"id","paramsType":"int","required":"","desc":"","structType":"json","sub":1,"key":"kwoq04srulxevt93a3h","children":[]},{"field":"account","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0a387on1wpuwntd","children":[]},{"field":"realname","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0i4g80qyu8lqp28","children":[]},{"field":"avatar","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0le57o2p6vxc8ov","children":[]}]";s:7:"version";s:1:"1";s:7:"addedBy";s:5:"admin";s:9:"addedDate";s:19:"2022-06-28 09:51:30";}i:1;O:8:"stdClass":8:{s:2:"id";s:2:"20";s:4:"name";s:3:"aaa";s:4:"type";s:8:"formData";s:4:"desc";s:0:"";s:9:"attribute";s:137:"[{"field":"aaa","paramsType":"object","required":"","desc":"","structType":"formData","sub":1,"key":"l11gznwwu2chih9mc28","children":[]}]";s:7:"version";s:1:"1";s:7:"addedBy";s:5:"admin";s:9:"addedDate";s:19:"2022-06-28 09:51:30";}i:2;O:8:"stdClass":8:{s:2:"id";s:2:"19";s:4:"name";s:4:"user";s:4:"type";s:4:"json";s:4:"desc";s:0:"";s:9:"attribute";s:537:"[{"field":"id","paramsType":"int","required":"","desc":"","structType":"json","sub":1,"key":"kwoq04srulxevt93a3h","children":[]},{"field":"account","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0a387on1wpuwntd","children":[]},{"field":"realname","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0i4g80qyu8lqp28","children":[]},{"field":"avatar","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0le57o2p6vxc8ov","children":[]}]";s:7:"version";s:1:"2";s:7:"addedBy";s:5:"admin";s:9:"addedDate";s:19:"2022-06-28 09:51:30";}}
|
||||
a:3:{i:0;O:8:"stdClass":8:{s:2:"id";s:1:"1";s:4:"name";s:4:"user";s:4:"type";s:4:"json";s:4:"desc";s:0:"";s:9:"attribute";s:537:"[{"field":"id","paramsType":"int","required":"","desc":"","structType":"json","sub":1,"key":"kwoq04srulxevt93a3h","children":[]},{"field":"account","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0a387on1wpuwntd","children":[]},{"field":"realname","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0i4g80qyu8lqp28","children":[]},{"field":"avatar","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0le57o2p6vxc8ov","children":[]}]";s:7:"version";s:1:"1";s:7:"addedBy";s:6:"wwccss";s:9:"addedDate";s:19:"2022-12-22 10:35:42";}i:1;O:8:"stdClass":8:{s:2:"id";s:1:"2";s:4:"name";s:3:"aaa";s:4:"type";s:8:"formData";s:4:"desc";s:0:"";s:9:"attribute";s:137:"[{"field":"aaa","paramsType":"object","required":"","desc":"","structType":"formData","sub":1,"key":"l11gznwwu2chih9mc28","children":[]}]";s:7:"version";s:1:"1";s:7:"addedBy";s:6:"wwccss";s:9:"addedDate";s:19:"2022-12-22 10:35:42";}i:2;O:8:"stdClass":8:{s:2:"id";s:1:"3";s:4:"name";s:4:"user";s:4:"type";s:4:"json";s:4:"desc";s:0:"";s:9:"attribute";s:537:"[{"field":"id","paramsType":"int","required":"","desc":"","structType":"json","sub":1,"key":"kwoq04srulxevt93a3h","children":[]},{"field":"account","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0a387on1wpuwntd","children":[]},{"field":"realname","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0i4g80qyu8lqp28","children":[]},{"field":"avatar","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0le57o2p6vxc8ov","children":[]}]";s:7:"version";s:1:"2";s:7:"addedBy";s:6:"wwccss";s:9:"addedDate";s:19:"2022-12-22 10:35:42";}}
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+3758
File diff suppressed because one or more lines are too long
+1476
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
a:1:{i:0;O:8:"stdClass":12:{s:2:"id";s:1:"1";s:3:"lib";s:3:"833";s:4:"name";s:4:"user";s:4:"type";s:4:"json";s:4:"desc";s:0:"";s:7:"version";s:1:"2";s:9:"attribute";s:537:"[{"field":"id","paramsType":"int","required":"","desc":"","structType":"json","sub":1,"key":"kwoq04srulxevt93a3h","children":[]},{"field":"account","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0a387on1wpuwntd","children":[]},{"field":"realname","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0i4g80qyu8lqp28","children":[]},{"field":"avatar","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0le57o2p6vxc8ov","children":[]}]";s:7:"addedBy";s:6:"wwccss";s:9:"addedDate";s:19:"2022-12-22 10:35:42";s:8:"editedBy";s:6:"wwccss";s:10:"editedDate";s:19:"2022-12-22 10:35:42";s:7:"deleted";s:1:"0";}}
|
||||
@@ -0,0 +1 @@
|
||||
a:3:{i:0;O:8:"stdClass":8:{s:2:"id";s:1:"1";s:4:"name";s:4:"user";s:4:"type";s:4:"json";s:4:"desc";s:0:"";s:9:"attribute";s:537:"[{"field":"id","paramsType":"int","required":"","desc":"","structType":"json","sub":1,"key":"kwoq04srulxevt93a3h","children":[]},{"field":"account","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0a387on1wpuwntd","children":[]},{"field":"realname","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0i4g80qyu8lqp28","children":[]},{"field":"avatar","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0le57o2p6vxc8ov","children":[]}]";s:7:"version";s:1:"1";s:7:"addedBy";s:6:"wwccss";s:9:"addedDate";s:19:"2022-12-22 10:35:42";}i:1;O:8:"stdClass":8:{s:2:"id";s:1:"2";s:4:"name";s:3:"aaa";s:4:"type";s:8:"formData";s:4:"desc";s:0:"";s:9:"attribute";s:137:"[{"field":"aaa","paramsType":"object","required":"","desc":"","structType":"formData","sub":1,"key":"l11gznwwu2chih9mc28","children":[]}]";s:7:"version";s:1:"1";s:7:"addedBy";s:6:"wwccss";s:9:"addedDate";s:19:"2022-12-22 10:35:42";}i:2;O:8:"stdClass":8:{s:2:"id";s:1:"3";s:4:"name";s:4:"user";s:4:"type";s:4:"json";s:4:"desc";s:0:"";s:9:"attribute";s:537:"[{"field":"id","paramsType":"int","required":"","desc":"","structType":"json","sub":1,"key":"kwoq04srulxevt93a3h","children":[]},{"field":"account","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0a387on1wpuwntd","children":[]},{"field":"realname","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0i4g80qyu8lqp28","children":[]},{"field":"avatar","paramsType":"string","required":"","desc":"","structType":"json","sub":1,"key":"kwoq0le57o2p6vxc8ov","children":[]}]";s:7:"version";s:1:"2";s:7:"addedBy";s:6:"wwccss";s:9:"addedDate";s:19:"2022-12-22 10:35:42";}}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user