| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- /**
- * The control file of serverroom of ZenTaoPMS.
- *
- * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) 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 Jiangxiu Peng <pengjiangxiu@cnezsoft.com>
- * @package serverroom
- * @link https://www.zentao.net
- */
- class serverroom extends control
- {
- /**
- * 机房列表。
- * Server room.
- *
- * @param string $browseType
- * @param int $param
- * @param string $orderBy
- * @param int $recTotal
- * @param int $recPerPage
- * @param int $pageID
- * @access public
- * @return void
- */
- public function browse($browseType = 'all', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
- {
- $browseType = strtolower($browseType);
- $param = (int)$param;
- $this->app->loadClass('pager', true);
- $pager = pager::init($recTotal, $recPerPage, $pageID);
- $serverRoomList = $this->serverroom->getList($browseType, $param, $orderBy, $pager);
- /* Build the search form. */
- $actionURL = $this->createLink('serverroom', 'browse', "browseType=bySearch&queryID=myQueryID");
- $this->config->serverroom->search['actionURL'] = $actionURL;
- $this->config->serverroom->search['queryID'] = $param;
- $this->config->serverroom->search['onMenuBar'] = 'no';
- $this->loadModel('search')->setSearchParams($this->config->serverroom->search);
- $this->view->title = $this->lang->serverroom->common;
- $this->view->pager = $pager;
- $this->view->param = $param;
- $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted');
- $this->view->orderBy = $orderBy;
- $this->view->browseType = $browseType;
- $this->view->serverRoomList = $serverRoomList;
- $this->display();
- }
- /**
- * 添加机房。
- * Create server room.
- *
- * @access public
- * @return void
- */
- public function create()
- {
- if($_POST)
- {
- $room = form::data($this->config->serverroom->form->create)
- ->add('createdBy', $this->app->user->account)
- ->get();
- $createID = $this->serverroom->create($room);
- if(dao::isError()) return $this->sendError(dao::getError());
- $this->loadModel('action')->create('serverRoom', $createID, 'created');
- return $this->sendSuccess(array('load' => $this->createLink('serverroom', 'browse')));
- }
- $this->view->title = $this->lang->serverroom->create;
- $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted|noclosed');
- $this->display();
- }
- /**
- * 编辑机房。
- * Edit server room.
- *
- * @param int $roomID
- * @access public
- * @return void
- */
- public function edit($roomID)
- {
- if($_POST)
- {
- $room = form::data($this->config->serverroom->form->edit)
- ->add('editedBy', $this->app->user->account)
- ->get();
- $changes = $this->serverroom->update($roomID, $room);
- if(dao::isError()) return $this->sendError(dao::getError());
- if($changes)
- {
- $actionID = $this->loadModel('action')->create('serverRoom', $roomID, 'Edited');
- $this->action->logHistory($actionID, $changes);
- }
- return $this->sendSuccess(array('load' => isInModal() ? true : inLink('browse')));
- }
- $this->view->title = $this->lang->serverroom->editAction;
- $this->view->serverRoom = $this->serverroom->fetchByID($roomID);
- $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted|noclosed');
- $this->display();
- }
- /**
- * 查看机房信息。
- * View server room.
- *
- * @param int $roomID
- * @access public
- * @return void
- */
- public function view($roomID)
- {
- $this->view->title = $this->lang->serverroom->view;
- $this->view->serverRoom = $this->serverroom->fetchByID($roomID);
- $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted');
- $this->view->actions = $this->loadModel('action')->getList('serverroom', $roomID);
- $this->display();
- }
- /**
- * 删除机房。
- * Delete server room.
- *
- * @param int $roomID
- * @access public
- * @return void
- */
- public function delete($roomID)
- {
- $this->serverroom->delete(TABLE_SERVERROOM, $roomID);
- if(dao::isError()) return $this->sendError(dao::getError());
- return $this->sendSuccess(array('message' => $this->lang->deleteSuccess, 'load' => true));
- }
- }
|