From 41bb468a4c5f193ebe76d9aeb709c5a93a2f37f3 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 9 Sep 2025 11:52:07 +0800 Subject: [PATCH 01/20] * [task#149051,doing,0.1h] add doc table fields for install. --- db/zentao.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/zentao.sql b/db/zentao.sql index 4a57c7993f..c767ff82db 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -809,7 +809,10 @@ CREATE TABLE IF NOT EXISTS `zt_doc` ( `template` varchar(30) NOT NULL DEFAULT '', `templateType` varchar(30) NOT NULL DEFAULT '', `templateDesc` text NULL, + `objects` text COLLATE 'utf8mb4_general_ci' NULL, `chapterType` varchar(30) NOT NULL DEFAULT '', + `cycle` char(10) COLLATE 'utf8mb4_general_ci' NOT NULL DEFAULT '', + `cycleConfig` text COLLATE 'utf8mb4_general_ci' NULL, `module` varchar(30) NOT NULL DEFAULT '', `title` varchar(255) NOT NULL DEFAULT '', `keywords` varchar(255) NOT NULL DEFAULT '', From 291657284e779426fdb4d17c4e2c953199ed016c Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 9 Sep 2025 11:54:38 +0800 Subject: [PATCH 02/20] * [task#149051,doing,0.3h] add langage items and config. --- module/weekly/config.php | 8 ++++++++ module/weekly/lang/de.php | 16 ++++++++++++---- module/weekly/lang/en.php | 16 ++++++++++++---- module/weekly/lang/fr.php | 16 ++++++++++++---- module/weekly/lang/zh-cn.php | 16 ++++++++++++---- 5 files changed, 56 insertions(+), 16 deletions(-) create mode 100644 module/weekly/config.php diff --git a/module/weekly/config.php b/module/weekly/config.php new file mode 100644 index 0000000000..d503e95475 --- /dev/null +++ b/module/weekly/config.php @@ -0,0 +1,8 @@ +weekly->charts['weekly_term'] = array('date' => '$thisWeek'); +$config->weekly->charts['weekly_staff'] = array('date' => '$thisWeek'); +$config->weekly->charts['project_progress_summary'] = array(); +$config->weekly->charts['task_basicStatistic_finished'] = array('date' => '$thisWeek'); +$config->weekly->charts['task_basicStatistic_unfinished'] = array('date' => '$thisWeek'); +$config->weekly->charts['task_basicStatistic_workplan'] = array('date' => '$nextWeek'); +$config->weekly->charts['project_basicStatistic_workload'] = array(); diff --git a/module/weekly/lang/de.php b/module/weekly/lang/de.php index a93317c186..33c1ecdc8c 100644 --- a/module/weekly/lang/de.php +++ b/module/weekly/lang/de.php @@ -22,10 +22,12 @@ $lang->weekly->postponed = 'Work unfinished this week'; $lang->weekly->nextWeek = 'Work planned for next week'; $lang->weekly->workloadByType = 'Workload Summary'; -$lang->weekly->term = 'Reporting Cycle'; -$lang->weekly->project = $lang->projectCommon . ' Name'; -$lang->weekly->master = 'Project Manager '; -$lang->weekly->staff = 'Weekly Effort'; +$lang->weekly->term = 'Reporting Cycle'; +$lang->weekly->project = $lang->projectCommon . ' Name'; +$lang->weekly->master = 'Project Manager '; +$lang->weekly->staff = 'Weekly Effort'; +$lang->weekly->projectCommon = 'Project'; +$lang->weekly->template = 'Weekly Report Template'; $lang->weekly->weekDesc = 'Week % s (% s ~% s)'; $lang->weekly->progress = 'Progress of the ' . $lang->projectCommon; @@ -42,6 +44,10 @@ $lang->weekly->totalCount = 'Total : %u tasks'; $lang->weekly->exportWeeklyReport = 'Export Weekly Report'; +$lang->weekly->builtInScopes = array(); +$lang->weekly->builtInScopes['rnd'] = array(); +$lang->weekly->builtInScopes['rnd']['project'] = 'Project'; + $lang->weekly->reportHelpNotice = <<PV Planned Value Calculation method: @@ -143,3 +149,5 @@ Calculation method: SV(%) = -1 * (1 - (EV / PV))%

CV(%) Schedule Variance

Calculation method: CV(%) = -1 * (1 - (EV / AC))% EOD; + +$lang->weekly->builtinContent = '

Weekly report: The project is managed by , the number of people involved is .

'; diff --git a/module/weekly/lang/en.php b/module/weekly/lang/en.php index a93317c186..33c1ecdc8c 100644 --- a/module/weekly/lang/en.php +++ b/module/weekly/lang/en.php @@ -22,10 +22,12 @@ $lang->weekly->postponed = 'Work unfinished this week'; $lang->weekly->nextWeek = 'Work planned for next week'; $lang->weekly->workloadByType = 'Workload Summary'; -$lang->weekly->term = 'Reporting Cycle'; -$lang->weekly->project = $lang->projectCommon . ' Name'; -$lang->weekly->master = 'Project Manager '; -$lang->weekly->staff = 'Weekly Effort'; +$lang->weekly->term = 'Reporting Cycle'; +$lang->weekly->project = $lang->projectCommon . ' Name'; +$lang->weekly->master = 'Project Manager '; +$lang->weekly->staff = 'Weekly Effort'; +$lang->weekly->projectCommon = 'Project'; +$lang->weekly->template = 'Weekly Report Template'; $lang->weekly->weekDesc = 'Week % s (% s ~% s)'; $lang->weekly->progress = 'Progress of the ' . $lang->projectCommon; @@ -42,6 +44,10 @@ $lang->weekly->totalCount = 'Total : %u tasks'; $lang->weekly->exportWeeklyReport = 'Export Weekly Report'; +$lang->weekly->builtInScopes = array(); +$lang->weekly->builtInScopes['rnd'] = array(); +$lang->weekly->builtInScopes['rnd']['project'] = 'Project'; + $lang->weekly->reportHelpNotice = <<PV Planned Value Calculation method: @@ -143,3 +149,5 @@ Calculation method: SV(%) = -1 * (1 - (EV / PV))%

CV(%) Schedule Variance

Calculation method: CV(%) = -1 * (1 - (EV / AC))% EOD; + +$lang->weekly->builtinContent = '

Weekly report: The project is managed by , the number of people involved is .

'; diff --git a/module/weekly/lang/fr.php b/module/weekly/lang/fr.php index a93317c186..33c1ecdc8c 100644 --- a/module/weekly/lang/fr.php +++ b/module/weekly/lang/fr.php @@ -22,10 +22,12 @@ $lang->weekly->postponed = 'Work unfinished this week'; $lang->weekly->nextWeek = 'Work planned for next week'; $lang->weekly->workloadByType = 'Workload Summary'; -$lang->weekly->term = 'Reporting Cycle'; -$lang->weekly->project = $lang->projectCommon . ' Name'; -$lang->weekly->master = 'Project Manager '; -$lang->weekly->staff = 'Weekly Effort'; +$lang->weekly->term = 'Reporting Cycle'; +$lang->weekly->project = $lang->projectCommon . ' Name'; +$lang->weekly->master = 'Project Manager '; +$lang->weekly->staff = 'Weekly Effort'; +$lang->weekly->projectCommon = 'Project'; +$lang->weekly->template = 'Weekly Report Template'; $lang->weekly->weekDesc = 'Week % s (% s ~% s)'; $lang->weekly->progress = 'Progress of the ' . $lang->projectCommon; @@ -42,6 +44,10 @@ $lang->weekly->totalCount = 'Total : %u tasks'; $lang->weekly->exportWeeklyReport = 'Export Weekly Report'; +$lang->weekly->builtInScopes = array(); +$lang->weekly->builtInScopes['rnd'] = array(); +$lang->weekly->builtInScopes['rnd']['project'] = 'Project'; + $lang->weekly->reportHelpNotice = <<PV Planned Value Calculation method: @@ -143,3 +149,5 @@ Calculation method: SV(%) = -1 * (1 - (EV / PV))%

CV(%) Schedule Variance

Calculation method: CV(%) = -1 * (1 - (EV / AC))% EOD; + +$lang->weekly->builtinContent = '

Weekly report: The project is managed by , the number of people involved is .

'; diff --git a/module/weekly/lang/zh-cn.php b/module/weekly/lang/zh-cn.php index 70b4e58ae2..9f275457f9 100644 --- a/module/weekly/lang/zh-cn.php +++ b/module/weekly/lang/zh-cn.php @@ -22,10 +22,12 @@ $lang->weekly->postponed = '本周未完成工作'; $lang->weekly->nextWeek = '下周工作计划'; $lang->weekly->workloadByType = '工作量统计'; -$lang->weekly->term = '报告周期'; -$lang->weekly->project = $lang->projectCommon . '名称'; -$lang->weekly->master = '项目经理 '; -$lang->weekly->staff = '本周投入人数'; +$lang->weekly->term = '报告周期'; +$lang->weekly->project = $lang->projectCommon . '名称'; +$lang->weekly->master = '项目经理 '; +$lang->weekly->staff = '本周投入人数'; +$lang->weekly->projectCommon = '项目'; +$lang->weekly->template = '周报模板'; $lang->weekly->weekDesc = '第 %s 周( %s ~ %s)'; $lang->weekly->progress = $lang->projectCommon . '当前进展状况'; @@ -42,6 +44,10 @@ $lang->weekly->totalCount = '总计 : %u 个任务'; $lang->weekly->exportWeeklyReport = '导出周报'; +$lang->weekly->builtInScopes = array(); +$lang->weekly->builtInScopes['rnd'] = array(); +$lang->weekly->builtInScopes['rnd']['project'] = '项目'; + $lang->weekly->reportHelpNotice = <<PV 计划完成的工作 计算方式: @@ -144,3 +150,5 @@ $lang->weekly->blockHelpNotice = <<CV(%) 成本偏差率 计算方式:CV(%) = -1 * (1 - (EV / AC))% EOD; + +$lang->weekly->builtinContent = '

周报: 项目由项目经理 负责,投入人数为 。

'; From 6128ab6c5b23bad766af89256a78b2d9a680b9b6 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 9 Sep 2025 11:56:40 +0800 Subject: [PATCH 03/20] * [task#149051,doing,0.3h] add scope and docblock data. --- module/weekly/model.php | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/module/weekly/model.php b/module/weekly/model.php index 3bfb860783..2e8a8d986d 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -591,4 +591,54 @@ class weeklyModel extends model return $data; } + + /** + * 设置内置项目周报模板。 + * Set builtin weekly report template. + * + * @access public + * @return bool + */ + public function addBuiltinWeeklyTemplate() + { + /* Set scope and class data. */ + $scopeID = $this->addBuiltinScope(); + return !dao::isError(); + } + + /** + * 添加内置报告模板范围。 + * Set scope. + * + * @access public + * @return int + */ + public function addBuiltinScope(): int + { + /* Set scope data. */ + $scope = new stdClass(); + $scope->type = 'reportTemplate'; + $scope->main = '1'; + $scope->vision = $this->config->vision; + $scope->addedBy = 'system'; + $scope->addedDate = helper::now(); + foreach($this->lang->weekly->builtInScopes as $vision => $scopeList) + { + $scopeMaps = array(); + $scope->vision = $vision; + foreach($scopeList as $scopeKey => $scopeName) + { + if(empty($scopeName)) continue; + + $scope->name = $scopeName; + $this->dao->insert(TABLE_DOCLIB)->data($scope)->exec(); + + $scopeID = $this->dao->lastInsertID(); + $scopeMaps[$scopeKey] = $scopeID; + } + if(!empty($scopeMaps)) $this->loadModel('setting')->setItem("system.reporttemplate.builtInScopeMaps@{$vision}", json_encode($scopeMaps)); + } + + return $scopeID; + } } From 18a9efd5eddd393bbbf7858eba18830d10467ef2 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 9 Sep 2025 11:57:29 +0800 Subject: [PATCH 04/20] * [task#149051,doing,0.3h] add category and docblock data. --- module/weekly/model.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/module/weekly/model.php b/module/weekly/model.php index 2e8a8d986d..dc4981781d 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -603,6 +603,22 @@ class weeklyModel extends model { /* Set scope and class data. */ $scopeID = $this->addBuiltinScope(); + $categoryID = $this->addBuildinCategory($scopeID); + + /* Set docblock data. */ + $blockIdList = array(); + $docBlock = new stdclass(); + foreach($this->config->weekly->charts as $chartKey => $chartContent) + { + $docBlock->type = $chartKey; + $docBlock->content = json_encode($chartContent); + $this->dao->insert(TABLE_DOCBLOCK)->data($docBlock)->exec(); + $blockIdList[$chartKey] = $this->dao->lastInsertId(); + } + + /* Set doc and doc content data. */ + $this->setTemplateData($scopeID, $categoryID, $blockIdList); + return !dao::isError(); } @@ -641,4 +657,28 @@ class weeklyModel extends model return $scopeID; } + + /** + * 添加内置报告模板分类。 + * Add builtin report template category. + * + * @param int $scopeID + * @access public + * @return int + */ + public function addBuildinCategory(int $scopeID): int + { + /* Set category data. */ + $category = new stdClass(); + $category->root = $scopeID; + $category->name = $this->lang->weekly->projectCommon; + $category->grade = 1; + $category->type = 'reportTemplate'; + $this->dao->insert(TABLE_MODULE)->data($category)->exec(); + + $categoryID = $this->dao->lastInsertID(); + $this->dao->update(TABLE_MODULE)->set(`path`)->eq(",{$categoryID},")->where('id')->eq($categoryID)->exec(); + + return $categoryID; + } } From d1ad135041797b7d3b1d009f20f1f86c082c5d44 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 9 Sep 2025 13:24:56 +0800 Subject: [PATCH 05/20] * [task#149051,doing,1h] add template data. --- module/weekly/model.php | 42 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/module/weekly/model.php b/module/weekly/model.php index dc4981781d..da6ffab81e 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -616,8 +616,8 @@ class weeklyModel extends model $blockIdList[$chartKey] = $this->dao->lastInsertId(); } - /* Set doc and doc content data. */ - $this->setTemplateData($scopeID, $categoryID, $blockIdList); + /* Set template data. */ + $this->addBuiltinTemplate($scopeID, $categoryID, $blockIdList); return !dao::isError(); } @@ -681,4 +681,42 @@ class weeklyModel extends model return $categoryID; } + + /** + * 添加内置报告模板。 + * Add builtin report template. + * + * @param int $libID + * @param int $moduleID + * @param array $blockIdList + * @access public + * @return bool + */ + public function addBuiltinTemplate(int $libID, int $moduleID, array $blockIdList): bool + { + $now = helper::now(); + $cycleConfig = array('trunon' => 'on', 'frequency' => 'week', 'acl' => 'open', 'readGroups' => array(), 'readUsers' => array(), 'groups' => array(), 'users' => array()); + $objects = $this->dao->select('id')->from(TABLE_WORKFLOWGROUP)->where('type')->eq('project')->andWhere('projectModel')->eq('waterfall')->andWhere('status')->eq('normal')->andWhere('vision')->eq($this->config->vision)->andWhere('deleted')->eq(0)->fetchPairs('id'); + + $template = new stdclass(); + $template->libID = $libID; + $template->moduleID = $moduleID; + $template->title = $this->lang->weekly->project . $this->lang->weekly->template; + $template->type = 'text'; + $template->status = 'normal'; + $template->acl = 1; + $template->builtIn = 'open'; + $template->templateType = 'reportTemplate'; + $template->cycle = 'week'; + $template->cycleConfig = json_encode($cycleConfig); + $template->objects = ',' . implode(',', $objects) . ','; + $template->addedBy = 'system'; + $template->addedDate = $now; + $this->dao->insert(TABLE_DOC)->data($template)->exec(); + + $templateID = $this->dao->lastInsertID(); + $this->dao->update(TABLE_DOC)->set('`path`')->eq(",{$templateID},")->set('`order`')->eq($templateID)->where('id')->eq($templateID)->exec(); + + return !dao::isError(); + } } From 837b0345c5444038a5ea6e08474bf5426aaf1b88 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 9 Sep 2025 14:40:09 +0800 Subject: [PATCH 06/20] * [task#149051,doing,0.5h] process send message error and ignore report template action under the open/biz version. --- module/action/config.php | 1 + module/action/model.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/module/action/config.php b/module/action/config.php index 60ad91f7aa..6a87cfd412 100755 --- a/module/action/config.php +++ b/module/action/config.php @@ -92,6 +92,7 @@ $config->action->needGetRelateField = ',branch,story,epic,requirement,prod $config->action->noLinkModules = ',doclib,module,webhook,gitlab,instance,gitea,gogs,sonarqube,pipeline,jenkins,kanban,kanbanspace,kanbancolumn,kanbanlane,kanbanregion,kanbancard,execution,project,traincategory,apistruct,program,product,user,entry,repo,pivot,scene,boardspace,auditplan,auditresult,productline,chapter,doc,'; $config->action->ignoreObjectType4Dynamic = 'kanbanregion,kanbanlane,kanbancolumn'; $config->action->ignoreActions4Dynamic = 'disconnectxuanxuan,reconnectxuanxuan,loginxuanxuan,logoutxuanxuan,editmr,removemr,syncdoingbyticket,syncdoingbystory,syncdoingbyuserstory,syncdoingbyepic,syncdoingbytask,syncdoingbybug,syncdoingbytodo,syncdoingbydemand'; +if(in_array($config->edition, array('open', 'biz'))) $config->action->ignoreObjectType4Dynamic .= ',reporttemplate'; $config->action->latestDateList = array('today', 'yesterday', 'thisWeek', 'lastWeek', 'thisMonth'); diff --git a/module/action/model.php b/module/action/model.php index 455f0b9db5..b2598e85e5 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -127,7 +127,7 @@ class actionModel extends model $this->file->updateObjectID($uid, $objectID, $objectType); - $this->loadModel('message')->send(strtolower($objectType), $objectID, $actionType, $actionID, $actor, $extra); + if(empty($this->app->installing) && empty($this->app->upgrading)) $this->loadModel('message')->send(strtolower($objectType), $objectID, $actionType, $actionID, $actor, $extra); $this->saveIndex($objectType, $objectID, $actionType); From fad5c3ddb938593716fa8002fa4258eeb0520e0e Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 9 Sep 2025 15:05:07 +0800 Subject: [PATCH 07/20] * [task#149051,doing,0.2h] change language items. --- module/weekly/lang/de.php | 13 ++++++------- module/weekly/lang/en.php | 13 ++++++------- module/weekly/lang/fr.php | 13 ++++++------- module/weekly/lang/zh-cn.php | 13 ++++++------- 4 files changed, 24 insertions(+), 28 deletions(-) diff --git a/module/weekly/lang/de.php b/module/weekly/lang/de.php index 33c1ecdc8c..ecb226bfe4 100644 --- a/module/weekly/lang/de.php +++ b/module/weekly/lang/de.php @@ -22,12 +22,11 @@ $lang->weekly->postponed = 'Work unfinished this week'; $lang->weekly->nextWeek = 'Work planned for next week'; $lang->weekly->workloadByType = 'Workload Summary'; -$lang->weekly->term = 'Reporting Cycle'; -$lang->weekly->project = $lang->projectCommon . ' Name'; -$lang->weekly->master = 'Project Manager '; -$lang->weekly->staff = 'Weekly Effort'; -$lang->weekly->projectCommon = 'Project'; -$lang->weekly->template = 'Weekly Report Template'; +$lang->weekly->term = 'Reporting Cycle'; +$lang->weekly->project = $lang->projectCommon . ' Name'; +$lang->weekly->master = 'Project Manager '; +$lang->weekly->staff = 'Weekly Effort'; +$lang->weekly->projectTemplate = "{$lang->projectCommon} Weekly Report Template"; $lang->weekly->weekDesc = 'Week % s (% s ~% s)'; $lang->weekly->progress = 'Progress of the ' . $lang->projectCommon; @@ -150,4 +149,4 @@ Calculation method: SV(%) = -1 * (1 - (EV / PV))% Calculation method: CV(%) = -1 * (1 - (EV / AC))% EOD; -$lang->weekly->builtinContent = '

Weekly report: The project is managed by , the number of people involved is .

'; +$lang->weekly->builtinRawContent = '{"type":"page","meta":{"id":"DzzHUxGuzi","title":"Project Weekly Report Template","createDate":1757395000965,"tags":[]},"blocks":{"type":"block","id":"cJZg7QCPpE","flavour":"affine:page","version":2,"props":{"title":{"$blocksuite:internal:text$":true,"delta":[{"insert":"Project Weekly Report Template"}]}},"children":[{"type":"block","id":"aS-yFwCosD","flavour":"affine:note","version":1,"props":{"xywh":"[0,0,498,92]","background":"--affine-note-background-white","index":"a0","lockedBySelf":false,"hidden":false,"displayMode":"both","edgeless":{"style":{"borderRadius":8,"borderSize":4,"borderStyle":"none","shadowType":"--affine-note-shadow-box"}}},"children":[{"type":"block","id":"YCy8XkfbbP","flavour":"affine:paragraph","version":1,"props":{"align":"left","type":"text","text":{"$blocksuite:internal:text$":true,"delta":[{"insert":" ","attributes":{"holder":{"id":"tsoxyETETF","name":"weekly_term","text":"Report Term","hint":"Filter: “Date Range”BetweenThis Week","data":{"type":"weekly_term","blockID":2746,"hint":"Filter: “Date Range”BetweenThis Week","text":"Report Term"}}}},{"insert":" weekly report: "},{"insert":" ","attributes":{"holder":{"id":"q1YcO2kmC7","name":"property_name","text":"Name","hint":"Name"}}},{"insert":" is managed by the project manager "},{"insert":" ","attributes":{"holder":{"id":"eefTgQguvL","name":"property_PM","text":"Manager","hint":"Manager"}}},{"insert":", the number of people involved is "},{"insert":" ","attributes":{"holder":{"id":"jwupyH0HTa","name":"weekly_staff","text":"Staff Number","hint":"Filter: “Date Range”BetweenThis Week","data":{"type":"weekly_staff","blockID":2747,"hint":"Filter: “Date Range”BetweenThis Week","text":"Staff Number"}}}},{"insert":"."}]},"collapsed":false},"children":[]},{"type":"block","id":"cL0cyfMcnI","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=project_progress_summary&blockID=__TML_ZENTAOCHART__{project_progress_summary}","clearBeforeLoad":false,"isTemplate":true,"title":"Project Progress Summary"}},"children":[]},{"type":"block","id":"FqBsfENZPf","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_finished&blockID=__TML_ZENTAOCHART__{task_basicStatistic_finished}","clearBeforeLoad":false,"isTemplate":true,"title":"Finished Tasks"}},"children":[]},{"type":"block","id":"egherwGMIV","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_unfinished&blockID=__TML_ZENTAOCHART__{task_basicStatistic_unfinished}","clearBeforeLoad":false,"isTemplate":true,"title":"Unfinished Tasks"}},"children":[]},{"type":"block","id":"xfmvHk6o3o","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_workplan&blockID=__TML_ZENTAOCHART__{task_basicStatistic_workplan}","clearBeforeLoad":false,"isTemplate":true,"title":"Work Plan"}},"children":[]},{"type":"block","id":"ZZ4Jsuq4Bq","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=project_basicStatistic_workload&blockID=__TML_ZENTAOCHART__{project_basicStatistic_workload}","clearBeforeLoad":false,"isTemplate":true,"title":"Project Plan Workload Statistic"}},"children":[]},{"type":"block","id":"BPy4La92az","flavour":"affine:paragraph","version":1,"props":{"align":"left","type":"text","text":{"$blocksuite:internal:text$":true,"delta":[]},"collapsed":false},"children":[]}]}]}}'; diff --git a/module/weekly/lang/en.php b/module/weekly/lang/en.php index 33c1ecdc8c..ecb226bfe4 100644 --- a/module/weekly/lang/en.php +++ b/module/weekly/lang/en.php @@ -22,12 +22,11 @@ $lang->weekly->postponed = 'Work unfinished this week'; $lang->weekly->nextWeek = 'Work planned for next week'; $lang->weekly->workloadByType = 'Workload Summary'; -$lang->weekly->term = 'Reporting Cycle'; -$lang->weekly->project = $lang->projectCommon . ' Name'; -$lang->weekly->master = 'Project Manager '; -$lang->weekly->staff = 'Weekly Effort'; -$lang->weekly->projectCommon = 'Project'; -$lang->weekly->template = 'Weekly Report Template'; +$lang->weekly->term = 'Reporting Cycle'; +$lang->weekly->project = $lang->projectCommon . ' Name'; +$lang->weekly->master = 'Project Manager '; +$lang->weekly->staff = 'Weekly Effort'; +$lang->weekly->projectTemplate = "{$lang->projectCommon} Weekly Report Template"; $lang->weekly->weekDesc = 'Week % s (% s ~% s)'; $lang->weekly->progress = 'Progress of the ' . $lang->projectCommon; @@ -150,4 +149,4 @@ Calculation method: SV(%) = -1 * (1 - (EV / PV))% Calculation method: CV(%) = -1 * (1 - (EV / AC))% EOD; -$lang->weekly->builtinContent = '

Weekly report: The project is managed by , the number of people involved is .

'; +$lang->weekly->builtinRawContent = '{"type":"page","meta":{"id":"DzzHUxGuzi","title":"Project Weekly Report Template","createDate":1757395000965,"tags":[]},"blocks":{"type":"block","id":"cJZg7QCPpE","flavour":"affine:page","version":2,"props":{"title":{"$blocksuite:internal:text$":true,"delta":[{"insert":"Project Weekly Report Template"}]}},"children":[{"type":"block","id":"aS-yFwCosD","flavour":"affine:note","version":1,"props":{"xywh":"[0,0,498,92]","background":"--affine-note-background-white","index":"a0","lockedBySelf":false,"hidden":false,"displayMode":"both","edgeless":{"style":{"borderRadius":8,"borderSize":4,"borderStyle":"none","shadowType":"--affine-note-shadow-box"}}},"children":[{"type":"block","id":"YCy8XkfbbP","flavour":"affine:paragraph","version":1,"props":{"align":"left","type":"text","text":{"$blocksuite:internal:text$":true,"delta":[{"insert":" ","attributes":{"holder":{"id":"tsoxyETETF","name":"weekly_term","text":"Report Term","hint":"Filter: “Date Range”BetweenThis Week","data":{"type":"weekly_term","blockID":2746,"hint":"Filter: “Date Range”BetweenThis Week","text":"Report Term"}}}},{"insert":" weekly report: "},{"insert":" ","attributes":{"holder":{"id":"q1YcO2kmC7","name":"property_name","text":"Name","hint":"Name"}}},{"insert":" is managed by the project manager "},{"insert":" ","attributes":{"holder":{"id":"eefTgQguvL","name":"property_PM","text":"Manager","hint":"Manager"}}},{"insert":", the number of people involved is "},{"insert":" ","attributes":{"holder":{"id":"jwupyH0HTa","name":"weekly_staff","text":"Staff Number","hint":"Filter: “Date Range”BetweenThis Week","data":{"type":"weekly_staff","blockID":2747,"hint":"Filter: “Date Range”BetweenThis Week","text":"Staff Number"}}}},{"insert":"."}]},"collapsed":false},"children":[]},{"type":"block","id":"cL0cyfMcnI","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=project_progress_summary&blockID=__TML_ZENTAOCHART__{project_progress_summary}","clearBeforeLoad":false,"isTemplate":true,"title":"Project Progress Summary"}},"children":[]},{"type":"block","id":"FqBsfENZPf","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_finished&blockID=__TML_ZENTAOCHART__{task_basicStatistic_finished}","clearBeforeLoad":false,"isTemplate":true,"title":"Finished Tasks"}},"children":[]},{"type":"block","id":"egherwGMIV","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_unfinished&blockID=__TML_ZENTAOCHART__{task_basicStatistic_unfinished}","clearBeforeLoad":false,"isTemplate":true,"title":"Unfinished Tasks"}},"children":[]},{"type":"block","id":"xfmvHk6o3o","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_workplan&blockID=__TML_ZENTAOCHART__{task_basicStatistic_workplan}","clearBeforeLoad":false,"isTemplate":true,"title":"Work Plan"}},"children":[]},{"type":"block","id":"ZZ4Jsuq4Bq","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=project_basicStatistic_workload&blockID=__TML_ZENTAOCHART__{project_basicStatistic_workload}","clearBeforeLoad":false,"isTemplate":true,"title":"Project Plan Workload Statistic"}},"children":[]},{"type":"block","id":"BPy4La92az","flavour":"affine:paragraph","version":1,"props":{"align":"left","type":"text","text":{"$blocksuite:internal:text$":true,"delta":[]},"collapsed":false},"children":[]}]}]}}'; diff --git a/module/weekly/lang/fr.php b/module/weekly/lang/fr.php index 33c1ecdc8c..ecb226bfe4 100644 --- a/module/weekly/lang/fr.php +++ b/module/weekly/lang/fr.php @@ -22,12 +22,11 @@ $lang->weekly->postponed = 'Work unfinished this week'; $lang->weekly->nextWeek = 'Work planned for next week'; $lang->weekly->workloadByType = 'Workload Summary'; -$lang->weekly->term = 'Reporting Cycle'; -$lang->weekly->project = $lang->projectCommon . ' Name'; -$lang->weekly->master = 'Project Manager '; -$lang->weekly->staff = 'Weekly Effort'; -$lang->weekly->projectCommon = 'Project'; -$lang->weekly->template = 'Weekly Report Template'; +$lang->weekly->term = 'Reporting Cycle'; +$lang->weekly->project = $lang->projectCommon . ' Name'; +$lang->weekly->master = 'Project Manager '; +$lang->weekly->staff = 'Weekly Effort'; +$lang->weekly->projectTemplate = "{$lang->projectCommon} Weekly Report Template"; $lang->weekly->weekDesc = 'Week % s (% s ~% s)'; $lang->weekly->progress = 'Progress of the ' . $lang->projectCommon; @@ -150,4 +149,4 @@ Calculation method: SV(%) = -1 * (1 - (EV / PV))% Calculation method: CV(%) = -1 * (1 - (EV / AC))% EOD; -$lang->weekly->builtinContent = '

Weekly report: The project is managed by , the number of people involved is .

'; +$lang->weekly->builtinRawContent = '{"type":"page","meta":{"id":"DzzHUxGuzi","title":"Project Weekly Report Template","createDate":1757395000965,"tags":[]},"blocks":{"type":"block","id":"cJZg7QCPpE","flavour":"affine:page","version":2,"props":{"title":{"$blocksuite:internal:text$":true,"delta":[{"insert":"Project Weekly Report Template"}]}},"children":[{"type":"block","id":"aS-yFwCosD","flavour":"affine:note","version":1,"props":{"xywh":"[0,0,498,92]","background":"--affine-note-background-white","index":"a0","lockedBySelf":false,"hidden":false,"displayMode":"both","edgeless":{"style":{"borderRadius":8,"borderSize":4,"borderStyle":"none","shadowType":"--affine-note-shadow-box"}}},"children":[{"type":"block","id":"YCy8XkfbbP","flavour":"affine:paragraph","version":1,"props":{"align":"left","type":"text","text":{"$blocksuite:internal:text$":true,"delta":[{"insert":" ","attributes":{"holder":{"id":"tsoxyETETF","name":"weekly_term","text":"Report Term","hint":"Filter: “Date Range”BetweenThis Week","data":{"type":"weekly_term","blockID":2746,"hint":"Filter: “Date Range”BetweenThis Week","text":"Report Term"}}}},{"insert":" weekly report: "},{"insert":" ","attributes":{"holder":{"id":"q1YcO2kmC7","name":"property_name","text":"Name","hint":"Name"}}},{"insert":" is managed by the project manager "},{"insert":" ","attributes":{"holder":{"id":"eefTgQguvL","name":"property_PM","text":"Manager","hint":"Manager"}}},{"insert":", the number of people involved is "},{"insert":" ","attributes":{"holder":{"id":"jwupyH0HTa","name":"weekly_staff","text":"Staff Number","hint":"Filter: “Date Range”BetweenThis Week","data":{"type":"weekly_staff","blockID":2747,"hint":"Filter: “Date Range”BetweenThis Week","text":"Staff Number"}}}},{"insert":"."}]},"collapsed":false},"children":[]},{"type":"block","id":"cL0cyfMcnI","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=project_progress_summary&blockID=__TML_ZENTAOCHART__{project_progress_summary}","clearBeforeLoad":false,"isTemplate":true,"title":"Project Progress Summary"}},"children":[]},{"type":"block","id":"FqBsfENZPf","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_finished&blockID=__TML_ZENTAOCHART__{task_basicStatistic_finished}","clearBeforeLoad":false,"isTemplate":true,"title":"Finished Tasks"}},"children":[]},{"type":"block","id":"egherwGMIV","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_unfinished&blockID=__TML_ZENTAOCHART__{task_basicStatistic_unfinished}","clearBeforeLoad":false,"isTemplate":true,"title":"Unfinished Tasks"}},"children":[]},{"type":"block","id":"xfmvHk6o3o","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_workplan&blockID=__TML_ZENTAOCHART__{task_basicStatistic_workplan}","clearBeforeLoad":false,"isTemplate":true,"title":"Work Plan"}},"children":[]},{"type":"block","id":"ZZ4Jsuq4Bq","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=project_basicStatistic_workload&blockID=__TML_ZENTAOCHART__{project_basicStatistic_workload}","clearBeforeLoad":false,"isTemplate":true,"title":"Project Plan Workload Statistic"}},"children":[]},{"type":"block","id":"BPy4La92az","flavour":"affine:paragraph","version":1,"props":{"align":"left","type":"text","text":{"$blocksuite:internal:text$":true,"delta":[]},"collapsed":false},"children":[]}]}]}}'; diff --git a/module/weekly/lang/zh-cn.php b/module/weekly/lang/zh-cn.php index 9f275457f9..a37f61ee76 100644 --- a/module/weekly/lang/zh-cn.php +++ b/module/weekly/lang/zh-cn.php @@ -22,12 +22,11 @@ $lang->weekly->postponed = '本周未完成工作'; $lang->weekly->nextWeek = '下周工作计划'; $lang->weekly->workloadByType = '工作量统计'; -$lang->weekly->term = '报告周期'; -$lang->weekly->project = $lang->projectCommon . '名称'; -$lang->weekly->master = '项目经理 '; -$lang->weekly->staff = '本周投入人数'; -$lang->weekly->projectCommon = '项目'; -$lang->weekly->template = '周报模板'; +$lang->weekly->term = '报告周期'; +$lang->weekly->project = $lang->projectCommon . '名称'; +$lang->weekly->master = '项目经理 '; +$lang->weekly->staff = '本周投入人数'; +$lang->weekly->projectTemplate = "{$lang->projectCommon}周报模板"; $lang->weekly->weekDesc = '第 %s 周( %s ~ %s)'; $lang->weekly->progress = $lang->projectCommon . '当前进展状况'; @@ -151,4 +150,4 @@ $lang->weekly->blockHelpNotice = <<weekly->builtinContent = '

周报: 项目由项目经理 负责,投入人数为 。

'; +$lang->weekly->builtinRawContent = '{"type":"page","meta":{"id":"pGFGrn8mbr","title":"项目周报模板","createDate":1757379096204,"tags":[]},"blocks":{"type":"block","id":"Z3C1batqB7","flavour":"affine:page","version":2,"props":{"title":{"$blocksuite:internal:text$":true,"delta":[{"insert":"项目周报模板"}]}},"children":[{"type":"block","id":"kDFfXsGBPr","flavour":"affine:note","version":1,"props":{"xywh":"[0,0,498,92]","background":"--affine-note-background-white","index":"a0","lockedBySelf":false,"hidden":false,"displayMode":"both","edgeless":{"style":{"borderRadius":8,"borderSize":4,"borderStyle":"none","shadowType":"--affine-note-shadow-box"}}},"children":[{"type":"block","id":"A8QUW_uBSE","flavour":"affine:paragraph","version":1,"props":{"align":"left","type":"text","text":{"$blocksuite:internal:text$":true,"delta":[{"insert":" ","attributes":{"holder":{"id":"yqEBqqGHil","name":"weekly_term","text":"报告周期","hint":"筛选条件:“date”介于本周","data":{"type":"weekly_term","blockID":2737,"hint":"筛选条件:“date”介于本周","text":"报告周期"}}}},{"insert":"周报:"},{"insert":" ","attributes":{"holder":{"id":"PcqpwqBES3","name":"property_name","text":"项目名称","hint":"项目名称"}}},{"insert":"项目由项目经理"},{"insert":" ","attributes":{"holder":{"id":"p7Gw9A-ktu","name":"property_PM","text":"负责人","hint":"负责人"}}},{"insert":"负责,投入人数为"},{"insert":" ","attributes":{"holder":{"id":"uZ3j7QvSxb","name":"weekly_staff","text":"投入人数","hint":"筛选条件:“date”介于本周","data":{"type":"weekly_staff","blockID":2738,"hint":"筛选条件:“date”介于本周","text":"投入人数"}}}},{"insert":"。"}]},"collapsed":false},"children":[]},{"type":"block","id":"V5pHY6-x0A","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=project_progress_summary&blockID=__TML_ZENTAOCHART__{project_progress_summary}","clearBeforeLoad":false,"isTemplate":true,"title":"项目进展状况"}},"children":[]},{"type":"block","id":"cbuO57uG59","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_finished&blockID=__TML_ZENTAOCHART__{task_basicStatistic_finished}","clearBeforeLoad":false,"isTemplate":true,"title":"已完成任务情况"}},"children":[]},{"type":"block","id":"r3Mi7MQ4Jq","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_unfinished&blockID=__TML_ZENTAOCHART__{task_basicStatistic_unfinished}","clearBeforeLoad":false,"isTemplate":true,"title":"未完成任务情况"}},"children":[]},{"type":"block","id":"jrqVmVb0Ze","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=task_basicStatistic_workplan&blockID=__TML_ZENTAOCHART__{task_basicStatistic_workplan}","clearBeforeLoad":false,"isTemplate":true,"title":"工作计划"}},"children":[]},{"type":"block","id":"RhBxuJ6tj-","flavour":"affine:embed-zui-custom","version":1,"props":{"index":"a0","xywh":"[0,0,0,0]","lockedBySelf":false,"rotate":0,"content":{"fetcher":"/index.php?m=reporttemplate&f=ajaxZentaoChart&type=project_basicStatistic_workload&blockID=__TML_ZENTAOCHART__{project_basicStatistic_workload}","clearBeforeLoad":false,"isTemplate":true,"title":"项目计划工作量统计"}},"children":[]},{"type":"block","id":"mpqkXURxFF","flavour":"affine:paragraph","version":1,"props":{"align":"left","type":"text","text":{"$blocksuite:internal:text$":true,"delta":[]},"collapsed":false},"children":[]}]}]}}'; From d935b28837a60ce0f7c36bc5a75e7bce10172d13 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 9 Sep 2025 15:05:59 +0800 Subject: [PATCH 08/20] * [task#149051,doing,1h] process template content. --- module/weekly/model.php | 61 +++++++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/module/weekly/model.php b/module/weekly/model.php index da6ffab81e..350d03b794 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -671,13 +671,13 @@ class weeklyModel extends model /* Set category data. */ $category = new stdClass(); $category->root = $scopeID; - $category->name = $this->lang->weekly->projectCommon; + $category->name = $this->lang->projectCommon; $category->grade = 1; $category->type = 'reportTemplate'; $this->dao->insert(TABLE_MODULE)->data($category)->exec(); $categoryID = $this->dao->lastInsertID(); - $this->dao->update(TABLE_MODULE)->set(`path`)->eq(",{$categoryID},")->where('id')->eq($categoryID)->exec(); + $this->dao->update(TABLE_MODULE)->set('`path`')->eq(",{$categoryID},")->where('id')->eq($categoryID)->exec(); return $categoryID; } @@ -695,17 +695,17 @@ class weeklyModel extends model public function addBuiltinTemplate(int $libID, int $moduleID, array $blockIdList): bool { $now = helper::now(); - $cycleConfig = array('trunon' => 'on', 'frequency' => 'week', 'acl' => 'open', 'readGroups' => array(), 'readUsers' => array(), 'groups' => array(), 'users' => array()); + $cycleConfig = array('turnon' => 'on', 'frequency' => 'week', 'acl' => 'open', 'readGroups' => array(), 'readUsers' => array(), 'groups' => array(), 'users' => array()); $objects = $this->dao->select('id')->from(TABLE_WORKFLOWGROUP)->where('type')->eq('project')->andWhere('projectModel')->eq('waterfall')->andWhere('status')->eq('normal')->andWhere('vision')->eq($this->config->vision)->andWhere('deleted')->eq(0)->fetchPairs('id'); $template = new stdclass(); - $template->libID = $libID; - $template->moduleID = $moduleID; - $template->title = $this->lang->weekly->project . $this->lang->weekly->template; + $template->lib = $libID; + $template->module = $moduleID; + $template->title = $this->lang->weekly->projectTemplate; $template->type = 'text'; $template->status = 'normal'; - $template->acl = 1; - $template->builtIn = 'open'; + $template->acl = 'open'; + $template->builtIn = 1; $template->templateType = 'reportTemplate'; $template->cycle = 'week'; $template->cycleConfig = json_encode($cycleConfig); @@ -716,7 +716,52 @@ class weeklyModel extends model $templateID = $this->dao->lastInsertID(); $this->dao->update(TABLE_DOC)->set('`path`')->eq(",{$templateID},")->set('`order`')->eq($templateID)->where('id')->eq($templateID)->exec(); + $this->dao->update(TABLE_DOCBLOCK)->set('doc')->eq($templateID)->where('id')->in(array_values($blockIdList))->exec(); return !dao::isError(); } + + /** + * 获取内置项目周报模板内容。 + * Get builtin project weekly report template content. + * + * @param array $blockIdList + * @access public + * @return string + */ + public function getBuildinRawContent(array $blockIdList): string + { + $blockCodes = array(); + foreach($blockIdList as $blockKey => $blockID) $blockCodes[] = '{' . $blockKey . '}'; + + $rawContent = json_decode($this->lang->weekly->builtinRawContent); + foreach($rawContent as $content) + { + if(isset($content->id)) $content->id = uniqid(); + if(isset($content->createDate)) $content->createDate = time(); + if(empty($content->children)) continue; + + foreach($content->children as $childList) + { + if(isset($childList->id)) $childList->id = uniqid(); + if(empty($childList->children)) continue; + foreach($childList->children as $child) + { + if(isset($child->id)) $child->id = uniqid(); + if(!empty($child->props->text->delta)) + { + foreach($child->props->text->delta as $delta) + { + if(isset($delta->attributes->holder->id)) $delta->attributes->holder->id = uniqid(); + if(isset($delta->attributes->holder->name) && isset($blockIdList[$delta->attributes->holder->name])) $delta->attributes->holder->name = "{$delta->attributes->holder->name}_{$blockIdList[$delta->attributes->holder->name]}"; + if(isset($delta->attributes->holder->data->blockID)) $delta->attributes->holder->data->blockID = $blockIdList[$delta->attributes->holder->data->type]; + } + } + if(!empty($child->props->content)) $child->props->content->fetcher = str_replace($blockCodes, array_values($blockIdList), $child->props->content->fetcher); + } + } + } + + return json_encode($rawContent); + } } From 50f237a8dc4c0f51b15e504458848fc1db70ec43 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 9 Sep 2025 15:06:23 +0800 Subject: [PATCH 09/20] * [task#149051,doing,0.3h] add template content data. --- module/weekly/model.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/module/weekly/model.php b/module/weekly/model.php index 350d03b794..b99b8d15d3 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -718,6 +718,18 @@ class weeklyModel extends model $this->dao->update(TABLE_DOC)->set('`path`')->eq(",{$templateID},")->set('`order`')->eq($templateID)->where('id')->eq($templateID)->exec(); $this->dao->update(TABLE_DOCBLOCK)->set('doc')->eq($templateID)->where('id')->in(array_values($blockIdList))->exec(); + $templateContent = new stdclass(); + $templateContent->doc = $templateID; + $templateContent->title = $template->title; + $templateContent->type = 'doc'; + $templateContent->version = 1; + $templateContent->rawContent = $this->getBuildinRawContent($blockIdList); + $templateContent->addedBy = 'system'; + $templateContent->addedDate = $now; + $this->dao->insert(TABLE_DOCCONTENT)->data($templateContent)->exec(); + + $this->loadModel('action')->create('reportTemplate', $templateID, 'Created', '', '', 'system'); + return !dao::isError(); } From 99557f629173a91ba5ba96df9cf62deb7459edf6 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 9 Sep 2025 15:06:50 +0800 Subject: [PATCH 10/20] * [task#149051,doing,0.1h] add built-in weekly report data. --- module/install/control.php | 1 + 1 file changed, 1 insertion(+) diff --git a/module/install/control.php b/module/install/control.php index 4419a8fb5c..1703bcf66c 100644 --- a/module/install/control.php +++ b/module/install/control.php @@ -309,6 +309,7 @@ class install extends control $mode = form::data()->get()->mode; $this->loadModel('setting')->setItem('system.common.global.mode', $mode); $this->loadModel('custom')->disableFeaturesByMode($mode); + $this->loadModel('weekly')->addBuiltinWeeklyTemplate(); return $this->send(array('result' => 'success', 'load' => inlink('step5'))); } From 95644e813eb81790bc4cac0e4ae322e9db180dc3 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 10 Sep 2025 09:11:14 +0800 Subject: [PATCH 11/20] * [task#149051,doing,0.2h] add desc for template. --- module/weekly/lang/de.php | 3 ++- module/weekly/lang/en.php | 3 ++- module/weekly/lang/fr.php | 3 ++- module/weekly/lang/zh-cn.php | 3 ++- module/weekly/model.php | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/module/weekly/lang/de.php b/module/weekly/lang/de.php index ecb226bfe4..f13c5f21ce 100644 --- a/module/weekly/lang/de.php +++ b/module/weekly/lang/de.php @@ -39,7 +39,8 @@ $lang->weekly->ac = 'Actual Cost(AC)'; $lang->weekly->sv = 'Schedule Variance(SV%)'; $lang->weekly->cv = 'Cost Variance(CV%)'; -$lang->weekly->totalCount = 'Total : %u tasks'; +$lang->weekly->totalCount = 'Total : %u tasks'; +$lang->weekly->builtinDesc = "The system's built-in {$lang->projectCommon} weekly report template automatically generates this week's report under the {$lang->projectCommon} every Monday."; $lang->weekly->exportWeeklyReport = 'Export Weekly Report'; diff --git a/module/weekly/lang/en.php b/module/weekly/lang/en.php index ecb226bfe4..f13c5f21ce 100644 --- a/module/weekly/lang/en.php +++ b/module/weekly/lang/en.php @@ -39,7 +39,8 @@ $lang->weekly->ac = 'Actual Cost(AC)'; $lang->weekly->sv = 'Schedule Variance(SV%)'; $lang->weekly->cv = 'Cost Variance(CV%)'; -$lang->weekly->totalCount = 'Total : %u tasks'; +$lang->weekly->totalCount = 'Total : %u tasks'; +$lang->weekly->builtinDesc = "The system's built-in {$lang->projectCommon} weekly report template automatically generates this week's report under the {$lang->projectCommon} every Monday."; $lang->weekly->exportWeeklyReport = 'Export Weekly Report'; diff --git a/module/weekly/lang/fr.php b/module/weekly/lang/fr.php index ecb226bfe4..f13c5f21ce 100644 --- a/module/weekly/lang/fr.php +++ b/module/weekly/lang/fr.php @@ -39,7 +39,8 @@ $lang->weekly->ac = 'Actual Cost(AC)'; $lang->weekly->sv = 'Schedule Variance(SV%)'; $lang->weekly->cv = 'Cost Variance(CV%)'; -$lang->weekly->totalCount = 'Total : %u tasks'; +$lang->weekly->totalCount = 'Total : %u tasks'; +$lang->weekly->builtinDesc = "The system's built-in {$lang->projectCommon} weekly report template automatically generates this week's report under the {$lang->projectCommon} every Monday."; $lang->weekly->exportWeeklyReport = 'Export Weekly Report'; diff --git a/module/weekly/lang/zh-cn.php b/module/weekly/lang/zh-cn.php index a37f61ee76..e0cc96061a 100644 --- a/module/weekly/lang/zh-cn.php +++ b/module/weekly/lang/zh-cn.php @@ -39,7 +39,8 @@ $lang->weekly->ac = '实际花费的成本(AC)'; $lang->weekly->sv = '进度偏差率(SV%)'; $lang->weekly->cv = '成本偏差率(CV%)'; -$lang->weekly->totalCount = '总计 : %u 个任务'; +$lang->weekly->totalCount = '总计 : %u 个任务'; +$lang->weekly->builtinDesc = "系统内置的{$lang->projectCommon}周报模板,每周一在{$lang->projectCommon}下自动生成本周周报。"; $lang->weekly->exportWeeklyReport = '导出周报'; diff --git a/module/weekly/model.php b/module/weekly/model.php index b99b8d15d3..822447c240 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -707,6 +707,7 @@ class weeklyModel extends model $template->acl = 'open'; $template->builtIn = 1; $template->templateType = 'reportTemplate'; + $template->templateDesc = $this->lang->weekly->builtinDesc; $template->cycle = 'week'; $template->cycleConfig = json_encode($cycleConfig); $template->objects = ',' . implode(',', $objects) . ','; From 2eb5716acb448a37cf028616c58b6963518ebfc4 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 10 Sep 2025 09:47:11 +0800 Subject: [PATCH 12/20] * [unittest] add unittest for addBuiltinScope method. --- module/weekly/model.php | 16 ++++++++---- .../weekly/test/lib/weekly.unittest.class.php | 15 +++++++++++ module/weekly/test/model/addbuiltinscope.php | 26 +++++++++++++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 module/weekly/test/model/addbuiltinscope.php diff --git a/module/weekly/model.php b/module/weekly/model.php index 822447c240..9019361bae 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -601,8 +601,11 @@ class weeklyModel extends model */ public function addBuiltinWeeklyTemplate() { - /* Set scope and class data. */ - $scopeID = $this->addBuiltinScope(); + /* Set scope data. */ + $scopeID = $this->addBuiltinScope(); + if(!$scopeID) return true; + + /* Set category data. */ $categoryID = $this->addBuildinCategory($scopeID); /* Set docblock data. */ @@ -624,13 +627,16 @@ class weeklyModel extends model /** * 添加内置报告模板范围。 - * Set scope. + * Add builtin report template scope. * * @access public - * @return int + * @return int|bool */ - public function addBuiltinScope(): int + public function addBuiltinScope(): int|bool { + $scope = $this->dao->select('id')->from(TABLE_DOCLIB)->where('type')->eq('reportTemplate')->andWhere('main')->eq(1)->andWhere('vision')->eq($this->config->vision)->fetch(); + if($scope) return false; + /* Set scope data. */ $scope = new stdClass(); $scope->type = 'reportTemplate'; diff --git a/module/weekly/test/lib/weekly.unittest.class.php b/module/weekly/test/lib/weekly.unittest.class.php index a4e4e11e64..40b65ca250 100644 --- a/module/weekly/test/lib/weekly.unittest.class.php +++ b/module/weekly/test/lib/weekly.unittest.class.php @@ -373,4 +373,19 @@ class weeklyTest return $objects; } + + /** + * 添加内置报告模板范围。 + * Add builtin report template scope. + * + * @access public + * @return bool|object + */ + public function addBuiltinScopeTest(): bool|object + { + $scopeID = $this->objectModel->addBuiltinScope(); + if(!$scopeID) return false; + + return $this->objectModel->dao->select('*')->from(TABLE_DOCLIB)->where('id')->eq($scopeID)->fetch(); + } } diff --git a/module/weekly/test/model/addbuiltinscope.php b/module/weekly/test/model/addbuiltinscope.php new file mode 100644 index 0000000000..a04b890cdc --- /dev/null +++ b/module/weekly/test/model/addbuiltinscope.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +addBuiltinScope(); +timeout=0 +cid=1 + +- 测试添加内置范围 + - 属性name @项目 + - 属性type @reportTemplate + - 属性main @1 + - 属性addedBy @system +- 测试重复添加内置范围 @0 + +*/ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/weekly.unittest.class.php'; + +zenData('doclib')->gen(0); +zenData('user')->gen(5); +su('admin'); + +$weeklyTester = new weeklyTest(); +r($weeklyTester->addBuiltinScopeTest()) && p('name,type,main,addedBy') && e('项目,reportTemplate,1,system'); // 测试添加内置范围 +r($weeklyTester->addBuiltinScopeTest()) && p() && e('0'); // 测试重复添加内置范围 From c7d35e3ca4720824732ef6addd15053151cc5a02 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 10 Sep 2025 09:55:07 +0800 Subject: [PATCH 13/20] * [unittest] add unittest for addBuiltinCategory method. --- module/weekly/model.php | 4 +-- .../weekly/test/lib/weekly.unittest.class.php | 16 +++++++++++- .../weekly/test/model/addbuiltincategory.php | 26 +++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 module/weekly/test/model/addbuiltincategory.php diff --git a/module/weekly/model.php b/module/weekly/model.php index 9019361bae..02f8d3abeb 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -606,7 +606,7 @@ class weeklyModel extends model if(!$scopeID) return true; /* Set category data. */ - $categoryID = $this->addBuildinCategory($scopeID); + $categoryID = $this->addBuiltinCategory($scopeID); /* Set docblock data. */ $blockIdList = array(); @@ -672,7 +672,7 @@ class weeklyModel extends model * @access public * @return int */ - public function addBuildinCategory(int $scopeID): int + public function addBuiltinCategory(int $scopeID): int { /* Set category data. */ $category = new stdClass(); diff --git a/module/weekly/test/lib/weekly.unittest.class.php b/module/weekly/test/lib/weekly.unittest.class.php index 40b65ca250..dcc0b51d52 100644 --- a/module/weekly/test/lib/weekly.unittest.class.php +++ b/module/weekly/test/lib/weekly.unittest.class.php @@ -376,7 +376,7 @@ class weeklyTest /** * 添加内置报告模板范围。 - * Add builtin report template scope. + * Add built-in report template scope. * * @access public * @return bool|object @@ -388,4 +388,18 @@ class weeklyTest return $this->objectModel->dao->select('*')->from(TABLE_DOCLIB)->where('id')->eq($scopeID)->fetch(); } + + /** + * 添加内置分类。 + * Add built-in category. + * + * @access public + * @return object + */ + public function addBuiltinCategoryTest(): object + { + $scopeID = $this->objectModel->addBuiltinScope(); + $categroyID = $this->objectModel->addBuiltinCategory($scopeID); + return $this->objectModel->dao->select('*')->from(TABLE_MODULE)->where('id')->eq($categroyID)->fetch(); + } } diff --git a/module/weekly/test/model/addbuiltincategory.php b/module/weekly/test/model/addbuiltincategory.php new file mode 100644 index 0000000000..46522a51fe --- /dev/null +++ b/module/weekly/test/model/addbuiltincategory.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +addBuiltinCategory(); +timeout=0 +cid=1 + +- 测试添加内置分类 + - 属性id @1 + - 属性root @1 + - 属性name @项目 + - 属性grade @1 + - 属性type @reportTemplate + +*/ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/weekly.unittest.class.php'; + +zenData('doclib')->gen(0); +zenData('module')->gen(0); +zenData('user')->gen(5); +su('admin'); + +$weeklyTester = new weeklyTest(); +r($weeklyTester->addBuiltinCategoryTest()) && p('id,root,name,grade,type') && e('1,1,项目,1,reportTemplate'); // 测试添加内置分类 From cbc5a5c72e91d95d6038dacf5ccdd44b88ef91b6 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 10 Sep 2025 10:02:07 +0800 Subject: [PATCH 14/20] * [unittest] add unittest for addBuiltinTemplate method. --- module/weekly/model.php | 2 +- .../weekly/test/lib/weekly.unittest.class.php | 17 ++++++++++ .../weekly/test/model/addbuiltintemplate.php | 33 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 module/weekly/test/model/addbuiltintemplate.php diff --git a/module/weekly/model.php b/module/weekly/model.php index 02f8d3abeb..ddabc1cd29 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -773,7 +773,7 @@ class weeklyModel extends model { if(isset($delta->attributes->holder->id)) $delta->attributes->holder->id = uniqid(); if(isset($delta->attributes->holder->name) && isset($blockIdList[$delta->attributes->holder->name])) $delta->attributes->holder->name = "{$delta->attributes->holder->name}_{$blockIdList[$delta->attributes->holder->name]}"; - if(isset($delta->attributes->holder->data->blockID)) $delta->attributes->holder->data->blockID = $blockIdList[$delta->attributes->holder->data->type]; + if(isset($delta->attributes->holder->data->blockID) && isset($blockIdList[$delta->attributes->holder->data->type])) $delta->attributes->holder->data->blockID = $blockIdList[$delta->attributes->holder->data->type]; } } if(!empty($child->props->content)) $child->props->content->fetcher = str_replace($blockCodes, array_values($blockIdList), $child->props->content->fetcher); diff --git a/module/weekly/test/lib/weekly.unittest.class.php b/module/weekly/test/lib/weekly.unittest.class.php index dcc0b51d52..566c6c10a3 100644 --- a/module/weekly/test/lib/weekly.unittest.class.php +++ b/module/weekly/test/lib/weekly.unittest.class.php @@ -402,4 +402,21 @@ class weeklyTest $categroyID = $this->objectModel->addBuiltinCategory($scopeID); return $this->objectModel->dao->select('*')->from(TABLE_MODULE)->where('id')->eq($categroyID)->fetch(); } + + /** + * 添加内置报告模板。 + * Add builtin report template. + * + * @access public + * @return array|object + */ + public function addBuiltinTemplateTest(): array|object + { + $scopeID = $this->objectModel->addBuiltinScope(); + $categroyID = $this->objectModel->addBuiltinCategory($scopeID); + $this->objectModel->addBuiltinTemplate($scopeID, $categroyID, array()); + + if(dao::isError()) return dao::getError(); + return $this->objectModel->dao->select('*')->from(TABLE_DOC)->fetch(); + } } diff --git a/module/weekly/test/model/addbuiltintemplate.php b/module/weekly/test/model/addbuiltintemplate.php new file mode 100644 index 0000000000..884c251467 --- /dev/null +++ b/module/weekly/test/model/addbuiltintemplate.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +addBuiltinTemplate(); +timeout=0 +cid=1 + +- 测试添加内置模板 + - 属性title @项目周报模板 + - 属性type @text + - 属性status @normal + - 属性acl @open + - 属性builtIn @1 + - 属性templateType @reportTemplate + - 属性cycle @week + - 属性addedBy @system + +*/ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/weekly.unittest.class.php'; + +zenData('action')->gen(0); +zenData('doclib')->gen(0); +zenData('module')->gen(0); +zenData('workflowgroup')->gen(0); +zenData('doc')->gen(0); +zenData('doccontent')->gen(0); +zenData('user')->gen(5); +su('admin'); + +$weeklyTester = new weeklyTest(); +r($weeklyTester->addBuiltinTemplateTest()) && p('title,type,status,acl,builtIn,templateType,cycle,addedBy') && e('项目周报模板,text,normal,open,1,reportTemplate,week,system'); // 测试添加内置模板 From 7d4df9105e799db292f295b883cd3967ca78168d Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 10 Sep 2025 10:10:53 +0800 Subject: [PATCH 15/20] * [unittest] add unittest for getBuildinRawContent method. --- .../weekly/test/lib/weekly.unittest.class.php | 13 +++++++++ .../test/model/getbuildinrawcontent.php | 29 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 module/weekly/test/model/getbuildinrawcontent.php diff --git a/module/weekly/test/lib/weekly.unittest.class.php b/module/weekly/test/lib/weekly.unittest.class.php index 566c6c10a3..65fac248ff 100644 --- a/module/weekly/test/lib/weekly.unittest.class.php +++ b/module/weekly/test/lib/weekly.unittest.class.php @@ -419,4 +419,17 @@ class weeklyTest if(dao::isError()) return dao::getError(); return $this->objectModel->dao->select('*')->from(TABLE_DOC)->fetch(); } + + /** + * 获取内置项目周报模板内容。 + * Get builtin project weekly report template content. + * + * @access public + * @return array + */ + public function getBuildinRawContentTest(): array + { + $content = $this->objectModel->getBuildinRawContent(array()); + return json_decode($content, true); + } } diff --git a/module/weekly/test/model/getbuildinrawcontent.php b/module/weekly/test/model/getbuildinrawcontent.php new file mode 100644 index 0000000000..5269f480f1 --- /dev/null +++ b/module/weekly/test/model/getbuildinrawcontent.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +getBuildinRawContent(); +timeout=0 +cid=1 + +- 检查模板标题属性title @项目周报模板 +- 获取holder数据 + - 属性name @weekly_term + - 属性text @报告周期 + - 属性hint @筛选条件:“date”介于本周 +- 检查区块数量 @6 + +*/ + +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/weekly.unittest.class.php'; + +zenData('user')->gen(5); +su('admin'); + +$weeklyTester = new weeklyTest(); +$content = $weeklyTester->getBuildinRawContentTest(); + +r($content['meta']) && p('title') && e('项目周报模板'); // 检查模板标题 +r($content['blocks']['children'][0]['children'][0]['props']['text']['delta'][0]['attributes']['holder']) && p('name,text,hint') && e('weekly_term,报告周期,筛选条件:“date”介于本周'); // 获取holder数据 +r(count($content['blocks'])) && p() && e('6'); // 检查区块数量 From 13c67981adb7f4026299818fc793952d7237f212 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 10 Sep 2025 10:19:49 +0800 Subject: [PATCH 16/20] * [unittest] add unittest for addBuiltinWeeklyTemplate. --- module/weekly/model.php | 6 ++-- .../weekly/test/lib/weekly.unittest.class.php | 15 ++++++++ .../test/model/addbuiltinweeklytemplate.php | 35 +++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 module/weekly/test/model/addbuiltinweeklytemplate.php diff --git a/module/weekly/model.php b/module/weekly/model.php index ddabc1cd29..1c7e09a388 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -593,8 +593,8 @@ class weeklyModel extends model } /** - * 设置内置项目周报模板。 - * Set builtin weekly report template. + * 添加内置项目周报模板。 + * Add builtin project weekly report template. * * @access public * @return bool @@ -603,7 +603,7 @@ class weeklyModel extends model { /* Set scope data. */ $scopeID = $this->addBuiltinScope(); - if(!$scopeID) return true; + if(!$scopeID) return false; /* Set category data. */ $categoryID = $this->addBuiltinCategory($scopeID); diff --git a/module/weekly/test/lib/weekly.unittest.class.php b/module/weekly/test/lib/weekly.unittest.class.php index 65fac248ff..3942ee0f58 100644 --- a/module/weekly/test/lib/weekly.unittest.class.php +++ b/module/weekly/test/lib/weekly.unittest.class.php @@ -432,4 +432,19 @@ class weeklyTest $content = $this->objectModel->getBuildinRawContent(array()); return json_decode($content, true); } + + /** + * 添加内置项目周报模板。 + * Add builtin project weekly report template. + * + * @access public + * @return bool|object + */ + public function addBuiltinWeeklyTemplateTest():bool|object + { + $result = $this->objectModel->addBuiltinWeeklyTemplate(); + if(!$result) return false; + + return $this->objectModel->dao->select('*')->from(TABLE_DOC)->fetch(); + } } diff --git a/module/weekly/test/model/addbuiltinweeklytemplate.php b/module/weekly/test/model/addbuiltinweeklytemplate.php new file mode 100644 index 0000000000..e955303a7a --- /dev/null +++ b/module/weekly/test/model/addbuiltinweeklytemplate.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +addBuiltinWeeklyTemplate(); +timeout=0 +cid=1 + +- 测试添加内置周报模板 + - 属性title @项目周报模板 + - 属性type @text + - 属性status @normal + - 属性acl @open + - 属性builtIn @1 + - 属性templateType @reportTemplate + - 属性cycle @week + - 属性addedBy @system +- 测试重复添加内置周报模板 @0 + +*/ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/weekly.unittest.class.php'; + +zenData('docblock')->gen(0); +zenData('doclib')->gen(0); +zenData('module')->gen(0); +zenData('workflowgroup')->gen(0); +zenData('doc')->gen(0); +zenData('doccontent')->gen(0); +zenData('user')->gen(5); +su('admin'); + +$weeklyTester = new weeklyTest(); +r($weeklyTester->addBuiltinWeeklyTemplateTest()) && p('title,type,status,acl,builtIn,templateType,cycle,addedBy') && e('项目周报模板,text,normal,open,1,reportTemplate,week,system'); // 测试添加内置周报模板 +r($weeklyTester->addBuiltinWeeklyTemplateTest()) && p() && e('0'); // 测试重复添加内置周报模板 From 2bdb555df6492fd88455c7d345fa69a93e2ba1cc Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 10 Sep 2025 10:30:00 +0800 Subject: [PATCH 17/20] * [unittest] add unittest for getReportData method. --- module/weekly/test/model/getreportdata.php | 30 ++++++++++++++++++++++ module/weekly/test/yaml/project.yaml | 18 +++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 module/weekly/test/model/getreportdata.php create mode 100644 module/weekly/test/yaml/project.yaml diff --git a/module/weekly/test/model/getreportdata.php b/module/weekly/test/model/getreportdata.php new file mode 100644 index 0000000000..c639016231 --- /dev/null +++ b/module/weekly/test/model/getreportdata.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php +getReportData(); +timeout=0 +cid=1 + +- 检查是否存在pv属性 @1 +- 检查是否存在ev属性 @1 +- 检查是否存在project属性 @1 +- 检查是否存在staff属性 @1 +- 检查是否存在progress属性 @1 + +*/ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +zenData('project')->loadYaml('project')->gen(5); +zenData('task')->loadYaml('task')->gen(30); +zenData('user')->gen(5); +su('admin'); + +global $tester; +$weeklyModel = $tester->loadModel('weekly'); +$result = $weeklyModel->getReportData(1); + +r(isset($result->pv)) && p() && e('1'); // 检查是否存在pv属性 +r(isset($result->ev)) && p() && e('1'); // 检查是否存在ev属性 +r(isset($result->project)) && p() && e('1'); // 检查是否存在project属性 +r(isset($result->staff)) && p() && e('1'); // 检查是否存在staff属性 +r(isset($result->progress)) && p() && e('1'); // 检查是否存在progress属性 diff --git a/module/weekly/test/yaml/project.yaml b/module/weekly/test/yaml/project.yaml new file mode 100644 index 0000000000..a1d346a4aa --- /dev/null +++ b/module/weekly/test/yaml/project.yaml @@ -0,0 +1,18 @@ +title: project. +desc: project data. +author: Sun Guangming +version: "1.0" +fields: + - field: id + range: 1-100 + - field: name + note: "名称" + fields: + - field: name1 + range: 敏捷项目,瀑布项目,看板项目 + - field: name2 + range: 1-100 + - field: model + range: scrum,waterfall,kanban + - field: type + range: project From c7af75d3e5c1f959a64b61508f3e1bf69b414ecc Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 10 Sep 2025 10:43:01 +0800 Subject: [PATCH 18/20] * [task#149051,doing,0.1h] add objectID condition. --- module/weekly/model.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/weekly/model.php b/module/weekly/model.php index 1c7e09a388..8640920e0d 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -702,7 +702,8 @@ class weeklyModel extends model { $now = helper::now(); $cycleConfig = array('turnon' => 'on', 'frequency' => 'week', 'acl' => 'open', 'readGroups' => array(), 'readUsers' => array(), 'groups' => array(), 'users' => array()); - $objects = $this->dao->select('id')->from(TABLE_WORKFLOWGROUP)->where('type')->eq('project')->andWhere('projectModel')->eq('waterfall')->andWhere('status')->eq('normal')->andWhere('vision')->eq($this->config->vision)->andWhere('deleted')->eq(0)->fetchPairs('id'); + + $objects = $this->dao->select('id')->from(TABLE_WORKFLOWGROUP)->where('type')->eq('project')->andWhere('projectModel')->eq('waterfall')->andWhere('status')->eq('normal')->andWhere('vision')->eq($this->config->vision)->andWhere('objectID')->eq(0)->andWhere('deleted')->eq(0)->fetchPairs('id'); $template = new stdclass(); $template->lib = $libID; From 16b14efbc47ef1b30f616e01ef4bfc2e1cefc7f6 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 10 Sep 2025 10:45:27 +0800 Subject: [PATCH 19/20] * [task#149051,doing,0.1h] remove the encoding definition. --- db/zentao.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/zentao.sql b/db/zentao.sql index c767ff82db..784bb6ba55 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -809,10 +809,10 @@ CREATE TABLE IF NOT EXISTS `zt_doc` ( `template` varchar(30) NOT NULL DEFAULT '', `templateType` varchar(30) NOT NULL DEFAULT '', `templateDesc` text NULL, - `objects` text COLLATE 'utf8mb4_general_ci' NULL, + `objects` text NULL, `chapterType` varchar(30) NOT NULL DEFAULT '', - `cycle` char(10) COLLATE 'utf8mb4_general_ci' NOT NULL DEFAULT '', - `cycleConfig` text COLLATE 'utf8mb4_general_ci' NULL, + `cycle` char(10) NOT NULL DEFAULT '', + `cycleConfig` text NULL, `module` varchar(30) NOT NULL DEFAULT '', `title` varchar(255) NOT NULL DEFAULT '', `keywords` varchar(255) NOT NULL DEFAULT '', From ba9c443c427548006975edd78d7cf3a1ef18b49a Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 10 Sep 2025 10:50:18 +0800 Subject: [PATCH 20/20] * [refac] refactor code. --- module/weekly/model.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/module/weekly/model.php b/module/weekly/model.php index 8640920e0d..354e456d85 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -637,6 +637,8 @@ class weeklyModel extends model $scope = $this->dao->select('id')->from(TABLE_DOCLIB)->where('type')->eq('reportTemplate')->andWhere('main')->eq(1)->andWhere('vision')->eq($this->config->vision)->fetch(); if($scope) return false; + $this->loadModel('setting'); + /* Set scope data. */ $scope = new stdClass(); $scope->type = 'reportTemplate'; @@ -654,14 +656,12 @@ class weeklyModel extends model $scope->name = $scopeName; $this->dao->insert(TABLE_DOCLIB)->data($scope)->exec(); - - $scopeID = $this->dao->lastInsertID(); - $scopeMaps[$scopeKey] = $scopeID; + $scopeMaps[$scopeKey] = $this->dao->lastInsertID(); } - if(!empty($scopeMaps)) $this->loadModel('setting')->setItem("system.reporttemplate.builtInScopeMaps@{$vision}", json_encode($scopeMaps)); + if(!empty($scopeMaps)) $this->setting->setItem("system.reporttemplate.builtInScopeMaps@{$vision}", json_encode($scopeMaps)); } - return $scopeID; + return array_push($scopeMaps); } /**