From 4fe2e5f2787b96dbbd276b9e0b7d7cec5780a4a4 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Mon, 17 Aug 2020 14:41:58 +0800 Subject: [PATCH] * Move stage method to zentaopms. --- config/zentaopms.php | 3 +- db/update20.0.sql | 21 +++++ module/programplan/control.php | 4 - module/programplan/model.php | 45 +-------- module/programplan/view/create.html.php | 7 +- module/programplan/view/edit.html.php | 4 - module/programplan/view/tags | 41 --------- module/stage/control.php | 92 +++++++++++++++++++ .../stage/ext/view/create.cmmi.html.hook.php | 1 + module/stage/ext/view/edit.cmmi.html.hook.php | 1 + module/stage/lang/zh-cn.php | 24 +++++ module/stage/model.php | 34 +++++++ module/stage/view/browse.html.php | 8 ++ module/stage/view/create.html.php | 39 ++++++++ module/stage/view/edit.html.php | 39 ++++++++ module/stage/view/settype.html.php | 64 +++++++++++++ 16 files changed, 328 insertions(+), 99 deletions(-) delete mode 100644 module/programplan/view/tags create mode 100644 module/stage/control.php create mode 100644 module/stage/ext/view/create.cmmi.html.hook.php create mode 100644 module/stage/ext/view/edit.cmmi.html.hook.php create mode 100644 module/stage/lang/zh-cn.php create mode 100644 module/stage/model.php create mode 100644 module/stage/view/browse.html.php create mode 100644 module/stage/view/create.html.php create mode 100644 module/stage/view/edit.html.php create mode 100644 module/stage/view/settype.html.php diff --git a/config/zentaopms.php b/config/zentaopms.php index f400b7384f..e50cb15514 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -193,7 +193,8 @@ define('TABLE_RELATION', '`' . $config->db->prefix . 'relation`'); define('TABLE_REPOHISTORY', '`' . $config->db->prefix . 'repohistory`'); define('TABLE_REPOFILES', '`' . $config->db->prefix . 'repofiles`'); define('TABLE_REPOBRANCH', '`' . $config->db->prefix . 'repobranch`'); -if(!defined('TABLE_LANG')) define('TABLE_LANG', '`' . $config->db->prefix . 'lang`'); +if(!defined('TABLE_LANG')) define('TABLE_LANG', '`' . $config->db->prefix . 'lang`'); +if(!defined('TABLE_STAGE')) define('TABLE_STAGE', '`' . $config->db->prefix . 'stage`'); $config->objectTables['product'] = TABLE_PRODUCT; $config->objectTables['story'] = TABLE_STORY; diff --git a/db/update20.0.sql b/db/update20.0.sql index f606df6c0b..54b088b70d 100644 --- a/db/update20.0.sql +++ b/db/update20.0.sql @@ -36,3 +36,24 @@ ALTER TABLE `zt_usergroup` ADD `program` text NOT NULL; ALTER TABLE `zt_userview` ADD `programs` mediumtext COLLATE 'utf8_general_ci' NOT NULL AFTER `account`; ALTER TABLE `zt_user` ADD `type` char(30) NOT NULL AFTER `account`; + +CREATE TABLE `zt_stage` ( + `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `percent` varchar(255) NOT NULL, + `type` varchar(255) NOT NULL, + `createdBy` varchar(30) NOT NULL, + `createdDate` datetime NOT NULL, + `editedBy` varchar(30) NOT NULL, + `editedDate` datetime NOT NULL, + `deleted` enum('0','1') NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +INSERT INTO `zt_stage` (`name`,`percent`,`type`,`createdBy`,`createdDate`,`editedBy`,`editedDate`,`deleted`) VALUES +('需求','10','request','admin','2020-02-08 21:08:30','admin','2020-02-12 13:50:27','0'), +('设计','10','design','admin','2020-02-08 21:08:30','admin','2020-02-12 13:50:27','0'), +('开发','50','dev','admin','2020-02-08 21:08:30','admin','2020-02-12 13:50:27','0'), +('测试','15','qa','admin','2020-02-08 21:08:30','admin','2020-02-12 13:50:27','0'), +('发布','10','release','admin','2020-02-08 21:08:30','admin','2020-02-12 13:50:27','0'), +('总结评审','5','review','admin','2020-02-08 21:08:45','admin','2020-02-12 13:50:27','0'); diff --git a/module/programplan/control.php b/module/programplan/control.php index e0fb781323..8d22fc731c 100644 --- a/module/programplan/control.php +++ b/module/programplan/control.php @@ -9,8 +9,6 @@ class programplan extends control public function commonAction($programID, $productID = 0, $extra = '') { - //$this->loadModel('project')->saveState($programID, array()); - $products = $this->loadModel('product')->getPairs($programID); $productID = $this->product->saveState($productID, $products); $this->product->setMenu($products, $productID, 0, 0, '', $extra); @@ -89,7 +87,6 @@ class programplan extends control $this->view->stages = $stages; $this->view->plans = $plans; $this->view->planID = $planID; - $this->view->documentList = $this->programplan->getDocumentList(); $this->view->type = 'lists'; $this->display(); @@ -116,7 +113,6 @@ class programplan extends control $this->app->loadLang('stage'); $this->view->title = $this->lang->programplan->edit; $this->view->position[] = $this->lang->programplan->edit; - $this->view->documentList = $this->programplan->getDocumentList(); $this->view->parentStage = $this->programplan->getParentStageList($planID, $plan->product); $this->view->plan = $plan; $this->view->isParent = $this->programplan->isParent($planID); diff --git a/module/programplan/model.php b/module/programplan/model.php index 2276dee908..c9a2ed9f6b 100644 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -3,30 +3,7 @@ class programplanModel extends model { public function setMenu($programID, $productID) { - $baselines = ""; - $subMenu = array(); - if(!empty($baselines)) - { - foreach($baselines as $id => $version) - { - $link = array(); - $link['module'] = 'programplan'; - $link['method'] = 'browse'; - $link['vars'] = "program=$programID&productID=$productID&type=gantt&orderBy=id_desc&baselineID=$id"; - - $menu = new stdclass(); - $menu->name = $id; - $menu->link = $link; - $menu->text = $version; - $menu->subModule = ''; - $menu->alias = ''; - $menu->hidden = false; - $subMenu[$id] = $menu; - } - - $this->lang->programplan->menu->gantt['subMenu'] = $subMenu; - $this->lang->programplan->menu->gantt['class'] = 'dropdown dropdown-hover'; - } + return true; } public function getByID($planID) @@ -92,22 +69,11 @@ class programplanModel extends model public function getPlans($programID = 0, $productID = 0, $orderBy = 'id_asc') { - $plans = $this->getList($programID, $productID, 0, 'all', $orderBy); - - $documentList = $this->getDocumentList(); + $plans = $this->getList($programID, $productID, 0, 'all', $orderBy); $parents = array(); foreach($plans as $planID => $plan) { - $document = ''; - if(!empty($plan->output)) - { - $output = explode(',', $plan->output); - foreach($output as $title) if(isset($documentList[$title])) $document .= $documentList[$title]; - } - - $plan->output = empty($plan->output) ? '' : $document; - $plan->parent == 0 ? $parents[$planID] = $plan : $children[$plan->parent][] = $plan; } @@ -719,13 +685,6 @@ class programplanModel extends model ->fetchPairs(); } - public function getDocumentList() - { - return $document = $this->dao->select('*')->from(TABLE_OUTPUT) - ->where('deleted')->eq(0) - ->fetchPairs('id', 'name'); - } - public function isParent($planID) { $children = $this->dao->select('id')->from(TABLE_PROJECT)->where('parent')->eq($planID)->andWhere('deleted')->eq('0')->fetch(); diff --git a/module/programplan/view/create.html.php b/module/programplan/view/create.html.php index 6a00d32458..782eecd4e9 100644 --- a/module/programplan/view/create.html.php +++ b/module/programplan/view/create.html.php @@ -21,7 +21,6 @@ programplan->end;?> programplan->realStarted;?> programplan->realFinished;?> - programplan->output;?> actions;?> @@ -43,7 +42,6 @@ - @@ -72,7 +70,6 @@ output) ? 0 : explode(',', $plan->output);?> - @@ -96,7 +93,6 @@ - @@ -107,7 +103,7 @@ - + @@ -132,7 +128,6 @@ - diff --git a/module/programplan/view/edit.html.php b/module/programplan/view/edit.html.php index 35675fe76e..97f7e4c55f 100644 --- a/module/programplan/view/edit.html.php +++ b/module/programplan/view/edit.html.php @@ -61,10 +61,6 @@ js::set('parentID', $plan->parent); programplan->realFinished;?> realFinished, "class='form-control form-date'");?> - - programplan->output;?> - output, "class='form-control chosen ' multiple");?> - diff --git a/module/programplan/view/tags b/module/programplan/view/tags deleted file mode 100644 index 8b46215599..0000000000 --- a/module/programplan/view/tags +++ /dev/null @@ -1,41 +0,0 @@ -!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ -!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ -!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ -!_TAG_PROGRAM_NAME Exuberant Ctags // -!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ -!_TAG_PROGRAM_VERSION 5.9~svn20110310 // -afterFinish gantt.html.php /^ var afterFinish = function(canvas)$/;" j -afterFinish gantt.html.php /^ var afterFinish = function(url)$/;" j -canvas.onerror gantt.html.php /^ canvas.onerror = function()$/;" j -columns list.html.php /^ $columns = 0;$/;" v -delayHandleFullscreen gantt.html.php /^ var delayHandleFullscreen = function()$/;" j -drawGanttToCanvas gantt.html.php /^function drawGanttToCanvas(exportType, sucessCallback, errorCallback)$/;" f -exportGantt gantt.html.php /^function exportGantt(exportType)$/;" f -gantt.templates.grid_file gantt.html.php /^ gantt.templates.grid_file = function(item) {$/;" j -gantt.templates.grid_folder gantt.html.php /^ gantt.templates.grid_folder = function(item) {$/;" j -gantt.templates.scale_cell_class gantt.html.php /^ gantt.templates.scale_cell_class = function(date)$/;" j -gantt.templates.timeline_cell_class gantt.html.php /^ gantt.templates.timeline_cell_class = function(item, date)$/;" j -ganttContainer gantt.html.php /^ var $ganttContainer = $('#ganttContainer');$/;" v -ganttDataArea gantt.html.php /^ var $ganttDataArea = $ganttView.find('.gantt_data_area');$/;" v -ganttDridData gantt.html.php /^ var $ganttDridData = $ganttView.find('.gantt_grid_data');$/;" v -ganttView gantt.html.php /^ var $ganttView = $('#ganttView');$/;" v -getByIdForGantt gantt.html.php /^function getByIdForGantt(list, id)$/;" f -getRemoteScript gantt.html.php /^function getRemoteScript(url, sucessCallback, errorCallback)$/;" f -grid_file gantt.html.php /^ gantt.templates.grid_file = function(item) {$/;" j -grid_folder gantt.html.php /^ gantt.templates.grid_folder = function(item) {$/;" j -handleFullscreen gantt.html.php /^ var handleFullscreen = function()$/;" j -mainContent gantt.html.php /^ var $mainContent = $('#mainContent');$/;" v -onerror gantt.html.php /^ canvas.onerror = function()$/;" j -resizeGanttView gantt.html.php /^ var resizeGanttView = function()$/;" j -scale_cell_class gantt.html.php /^ gantt.templates.scale_cell_class = function(date)$/;" j -setting list.html.php /^ $setting = $this->datatable->getSetting('programplan');$/;" v -success gantt.html.php /^ success: function(result)$/;" j -task gantt.html.php /^ var $task = $(this).closest('.gantt_row_task');$/;" v -template gantt.html.php /^ {name: 'percent', align: 'center', resize: true, width:70, template: function(plan)$/;" j -timeline_cell_class gantt.html.php /^ gantt.templates.timeline_cell_class = function(item, date)$/;" j -toggle list.html.php /^ var $toggle = $(this);$/;" v -updateCriticalPath gantt.html.php /^function updateCriticalPath()$/;" f -updateProgress gantt.html.php /^function updateProgress(progress)$/;" f -vars list.html.php /^ $vars = "programID=$programID&productID=$productID&type=lists&orderBy=%s";$/;" v -widths list.html.php /^ $widths = $this->datatable->setFixedFieldWidth($setting);$/;" v -zoomTasks gantt.html.php /^function zoomTasks(node)$/;" f diff --git a/module/stage/control.php b/module/stage/control.php new file mode 100644 index 0000000000..00dba56607 --- /dev/null +++ b/module/stage/control.php @@ -0,0 +1,92 @@ +view->title = $this->lang->stage->common . $this->lang->colon . $this->lang->stage->browse; + $this->view->position[] = $this->lang->stage->common; + $this->view->position[] = $this->lang->stage->browse; + + $this->display(); + } + + public function create() + { + if($_POST) + { + $stageID = $this->stage->create(); + + $response['result'] = 'success'; + $response['message'] = $this->lang->saveSuccess; + if(!$stageID) + { + $response['result'] = 'fail'; + $response['message'] = dao::getError(); + $this->send($response); + } + + $this->loadModel('action')->create('stage', $stageID, 'Opened'); + $response['locate'] = inlink('browse'); + $this->send($response); + } + + $this->view->title = $this->lang->stage->common . $this->lang->colon . $this->lang->stage->create; + $this->view->position[] = $this->lang->stage->common; + $this->view->position[] = $this->lang->stage->create; + + $this->display(); + } + + public function edit($stageID = 0) + { + $stage = $this->stage->getByID($stageID); + if($_POST) + { + $changes = $this->stage->update($stageID); + + $response['result'] = 'success'; + $response['message'] = $this->lang->saveSuccess; + if(dao::isError()) + { + $response['result'] = 'fail'; + $response['message'] = dao::getError(); + $this->send($response); + } + + $actionID = $this->loadModel('action')->create('stage', $stageID, 'Edited'); + if(!empty($changes)) $this->action->logHistory($actionID, $changes); + $response['locate'] = inlink('view', "stageID=$stageID"); + $this->send($response); + } + + $this->view->title = $this->lang->stage->common . $this->lang->colon . $this->lang->stage->edit; + $this->view->position[] = $this->lang->stage->common; + $this->view->position[] = $this->lang->stage->edit; + $this->view->stage = $stage; + + $this->display(); + } + + public function setType() + { + $this->loadModel('custom'); + if($_POST) + { + $data = fixer::input('post')->get(); + $this->custom->deleteItems("lang=all&module=stage§ion=typeList"); + foreach($data->keys as $index => $key) + { + $value = $data->values[$index]; + if(!$value or !$key) continue; + $this->custom->setItem("all.stage.typeList.{$key}", $value); + } + $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('stage', 'settype'))); + } + + $this->view->title = $this->lang->stage->common . $this->lang->colon . $this->lang->stage->setType; + $this->view->position[] = $this->lang->stage->common; + $this->view->position[] = $this->lang->stage->setType; + $this->display(); + } +} diff --git a/module/stage/ext/view/create.cmmi.html.hook.php b/module/stage/ext/view/create.cmmi.html.hook.php new file mode 100644 index 0000000000..6120b9e1a2 --- /dev/null +++ b/module/stage/ext/view/create.cmmi.html.hook.php @@ -0,0 +1 @@ + diff --git a/module/stage/ext/view/edit.cmmi.html.hook.php b/module/stage/ext/view/edit.cmmi.html.hook.php new file mode 100644 index 0000000000..6120b9e1a2 --- /dev/null +++ b/module/stage/ext/view/edit.cmmi.html.hook.php @@ -0,0 +1 @@ + diff --git a/module/stage/lang/zh-cn.php b/module/stage/lang/zh-cn.php new file mode 100644 index 0000000000..b6bf0f6b09 --- /dev/null +++ b/module/stage/lang/zh-cn.php @@ -0,0 +1,24 @@ +stage->browse = '浏览列表'; +$lang->stage->create = '新建'; +$lang->stage->batchCreate = '批量新建'; +$lang->stage->edit = '编辑'; +$lang->stage->delete = '删除'; +$lang->stage->view = '阶段详情'; + + +/* Fields. */ +$lang->stage->common = '阶段'; +$lang->stage->name = '阶段名称'; +$lang->stage->type = '阶段分类'; +$lang->stage->percent = '工作量比例'; +$lang->stage->setType = '设置类型'; + +$lang->stage->typeList['request'] = '需求'; +$lang->stage->typeList['design'] = '设计'; +$lang->stage->typeList['dev'] = '开发'; +$lang->stage->typeList['qa'] = '测试'; +$lang->stage->typeList['release'] = '发布'; +$lang->stage->typeList['review'] = '总结评审'; +$lang->stage->typeList['other'] = '其他'; diff --git a/module/stage/model.php b/module/stage/model.php new file mode 100644 index 0000000000..34f2a54c19 --- /dev/null +++ b/module/stage/model.php @@ -0,0 +1,34 @@ +add('createdBy', $this->app->user->account) + ->add('createdDate', helper::today()) + ->get(); + + $this->dao->insert(TABLE_STAGE)->data($stage)->autoCheck()->exec(); + + if(!dao::isError()) return $this->dao->lastInsertID(); + return false; + } + + public function getStages() + { + return $this->dao->select('*')->from(TABLE_STAGE)->where('deleted')->eq(0)->fetchAll('id'); + } + + public function getPairs() + { + $stages = $this->getStages(); + + $pairs = array(); + foreach($stages as $stageID => $stage) + { + $pairs[$stageID] = $stage->name; + } + + return $pairs; + } +} diff --git a/module/stage/view/browse.html.php b/module/stage/view/browse.html.php new file mode 100644 index 0000000000..58884631b2 --- /dev/null +++ b/module/stage/view/browse.html.php @@ -0,0 +1,8 @@ + + + diff --git a/module/stage/view/create.html.php b/module/stage/view/create.html.php new file mode 100644 index 0000000000..3b07b46f95 --- /dev/null +++ b/module/stage/view/create.html.php @@ -0,0 +1,39 @@ + +
+
+
+

stage->create;?>

+
+
+ + + + + + + + + + + + + + + + + + + + + +
stage->name;?>
stage->percent;?> +
+ + % +
+
stage->type;?>stage->typeList, '', "class='form-control chosen'");?>
+ +
+
+
+ diff --git a/module/stage/view/edit.html.php b/module/stage/view/edit.html.php new file mode 100644 index 0000000000..9675f496a7 --- /dev/null +++ b/module/stage/view/edit.html.php @@ -0,0 +1,39 @@ + +
+
+
+

stage->edit;?>

+
+
+ + + + + + + + + + + + + + + + + + + + + +
stage->name;?>name, "class='form-control'");?>
stage->percent;?> +
+ percent, "class='form-control'");?> + % +
+
stage->type;?>stage->typeList, $stage->type, "class='form-control chosen'");?>
+ +
+
+
+ diff --git a/module/stage/view/settype.html.php b/module/stage/view/settype.html.php new file mode 100644 index 0000000000..6e1692e36f --- /dev/null +++ b/module/stage/view/settype.html.php @@ -0,0 +1,64 @@ + + + + + + + + + + + + + +EOT; +?> + +
+
+
+ + + + + + + + + + stage->typeList as $key => $value):?> + + + + + + + + + + + +
custom->key;?>custom->value;?>
+ + + + + +
+
+
+
+ +