From 058e4ecf73ed047347f5eed81863bcfabb2a2ed6 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 24 Oct 2022 16:00:11 +0800 Subject: [PATCH] * Finish task #73291. --- module/common/view/header.lite.html.php | 18 ++++-- module/program/config.php | 42 ++++++++++++++ module/program/lang/de.php | 1 + module/program/lang/en.php | 1 + module/program/lang/fr.php | 1 + module/program/lang/zh-cn.php | 1 + module/program/model.php | 73 +++++++++++++++++++++++++ module/program/ui/browse.html.php | 52 ++++++------------ 8 files changed, 149 insertions(+), 40 deletions(-) mode change 100755 => 100644 module/common/view/header.lite.html.php diff --git a/module/common/view/header.lite.html.php b/module/common/view/header.lite.html.php old mode 100755 new mode 100644 index d6aa8a5340..12989f6419 --- a/module/common/view/header.lite.html.php +++ b/module/common/view/header.lite.html.php @@ -1,4 +1,4 @@ -getExtViewFile(__FILE__)){include $extView; return helper::cd();} $clientLang = $app->getClientLang(); $webRoot = $this->app->getWebRoot(); @@ -25,16 +25,24 @@ $commonLang = array('zh-cn', 'zh-tw', 'en', 'fr', 'de'); $timestamp = time(); css::import($themeRoot . 'zui/css/min.css?t=' . $timestamp); - css::import($defaultTheme . 'style.css?t=' . $timestamp); + if(defined('ZUI3')) + { + css::import('https://ztui.sh.oop.cc/assets/style.4d294030.css'); + css::import('https://ztui.sh.oop.cc/zui/zui.css'); + } + css::import($defaultTheme . 'style.css?t=' . $timestamp); css::import($langTheme); + if(strpos($clientTheme, 'default') === false) css::import($clientTheme . 'style.css?t=' . $timestamp); js::import($jsRoot . 'jquery/lib.js'); js::import($jsRoot . 'zui/min.js?t=' . $timestamp); + + if(defined('ZUI3')) js::import('https://ztui.sh.oop.cc/zui/zui.umd.cjs'); + if(!in_array($clientLang, $commonLang)) js::import($jsRoot . 'zui/lang.' . $clientLang . '.min.js?t=' . $timestamp); js::import($jsRoot . 'my.full.js?t=' . $timestamp); - } else { @@ -81,10 +89,10 @@ $xuanExtFile = $extensionRoot . 'xuan/common/ext/view/header.xuanxuan.html.hook. if(file_exists($xuanExtFile)) include $xuanExtFile; ?> -app->getViewType() == 'xhtml' ? 'allow-self-open' : ''; if(isset($pageBodyClass)) $bodyClass = $bodyClass . ' ' . $pageBodyClass; -if($this->moduleName == 'index' && $this->methodName == 'index') $bodyClass .= ' menu-' . ($this->cookie->hideMenu ? 'hide' : 'show'); +if($this->app->moduleName == 'index' && $this->app->methodName == 'index') $bodyClass .= ' menu-' . ($this->cookie->hideMenu ? 'hide' : 'show'); if(strpos($_SERVER['HTTP_USER_AGENT'], 'xuanxuan') !== false) $bodyClass .= ' xxc-embed'; ?> diff --git a/module/program/config.php b/module/program/config.php index 15afcb8278..82617bc9a5 100644 --- a/module/program/config.php +++ b/module/program/config.php @@ -50,3 +50,45 @@ $config->program->search['params']['lastEditedDate'] = array('operator' => '=', $config->program->search['params']['realBegan'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); $config->program->search['params']['realEnd'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); $config->program->search['params']['closedDate'] = array('operator' => '=', 'control' => 'input', 'values' => '', 'class' => 'date'); + +/* Data table field config. */ +global $lang; +$config->program->dtable = new stdclass(); + +$config->program->dtable->fieldList['name']['name'] = 'name'; +$config->program->dtable->fieldList['name']['title'] = $lang->nameAB; +$config->program->dtable->fieldList['name']['type'] = 'html'; +$config->program->dtable->fieldList['name']['flex'] = 1; + +$config->program->dtable->fieldList['status']['name'] = 'status'; +$config->program->dtable->fieldList['status']['title'] = $lang->program->status; +$config->program->dtable->fieldList['status']['width'] = 65; +$config->program->dtable->fieldList['status']['type'] = 'html'; + +$config->program->dtable->fieldList['pm']['name'] = 'pm'; +$config->program->dtable->fieldList['pm']['title'] = $lang->program->PM; +$config->program->dtable->fieldList['pm']['width'] = 100; +$config->program->dtable->fieldList['pm']['type'] = 'html'; + +$config->program->dtable->fieldList['budget']['name'] = 'budget'; +$config->program->dtable->fieldList['budget']['title'] = $lang->program->budget; +$config->program->dtable->fieldList['budget']['width'] = 100; + +$config->program->dtable->fieldList['begin']['name'] = 'begin'; +$config->program->dtable->fieldList['begin']['title'] = $lang->program->begin; +$config->program->dtable->fieldList['begin']['width'] = 100; + +$config->program->dtable->fieldList['end']['name'] = 'end'; +$config->program->dtable->fieldList['end']['title'] = $lang->program->end; +$config->program->dtable->fieldList['end']['width'] = 100; + +$config->program->dtable->fieldList['progress']['name'] = 'progress'; +$config->program->dtable->fieldList['progress']['title'] = $lang->program->progressAB; +$config->program->dtable->fieldList['progress']['width'] = 100; +$config->program->dtable->fieldList['progress']['type'] = 'circleProgress'; + +$config->program->dtable->fieldList['actions']['name'] = 'actions'; +$config->program->dtable->fieldList['actions']['title'] = $lang->actions; +$config->program->dtable->fieldList['actions']['width'] = 160; +$config->program->dtable->fieldList['actions']['type'] = 'html'; +$config->program->dtable->fieldList['actions']['fixed'] = 'right'; diff --git a/module/program/lang/de.php b/module/program/lang/de.php index eee8d70de7..cb566bc543 100644 --- a/module/program/lang/de.php +++ b/module/program/lang/de.php @@ -84,6 +84,7 @@ $lang->program->exRateNotNegative = 'The『exchange rate』should not be n $lang->program->changePRJUnit = 'Update the budget unit of the project'; $lang->program->progress = 'Progress'; +$lang->program->progressAB = 'Progress'; $lang->program->children = 'Child'; $lang->program->allInvest = 'Input'; $lang->program->teamCount = 'Team'; diff --git a/module/program/lang/en.php b/module/program/lang/en.php index 62c84da556..4a9576a94a 100644 --- a/module/program/lang/en.php +++ b/module/program/lang/en.php @@ -84,6 +84,7 @@ $lang->program->exRateNotNegative = 'The『exchange rate』should not be n $lang->program->changePRJUnit = 'Update the budget unit of the project'; $lang->program->progress = 'Progress'; +$lang->program->progressAB = 'Progress'; $lang->program->children = 'Add Child'; $lang->program->allInvest = 'Input'; $lang->program->teamCount = 'Team'; diff --git a/module/program/lang/fr.php b/module/program/lang/fr.php index 395d896a50..ecef17d4f9 100644 --- a/module/program/lang/fr.php +++ b/module/program/lang/fr.php @@ -84,6 +84,7 @@ $lang->program->exRateNotNegative = 'The『exchange rate』should not be n $lang->program->changePRJUnit = 'Update the budget unit of the project'; $lang->program->progress = 'Progress'; +$lang->program->progressAB = 'Progress'; $lang->program->children = 'Child'; $lang->program->allInvest = 'Input'; $lang->program->teamCount = 'Team'; diff --git a/module/program/lang/zh-cn.php b/module/program/lang/zh-cn.php index be8d971ddc..0f1c22ae01 100644 --- a/module/program/lang/zh-cn.php +++ b/module/program/lang/zh-cn.php @@ -84,6 +84,7 @@ $lang->program->exRateNotNegative = '『汇率』不能是负数。'; $lang->program->changePRJUnit = '更新项目预算单位'; $lang->program->progress = '项目进度'; +$lang->program->progressAB = '进度'; $lang->program->children = '添加子项目集'; $lang->program->allInvest = '项目集总投入'; $lang->program->teamCount = '总人数'; diff --git a/module/program/model.php b/module/program/model.php index 6f75035472..f4ad85f3e3 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1593,4 +1593,77 @@ class programModel extends model } return $menu; } + + /** + * Build datatable cell. + * + * @param array $field + * @param object $program + * @param array $users + * @param array $userIdPairs + * @param array $PMList + * @param array $progressList + * @access public + * @return string + */ + public function buildCell($field, $program, $users, $usersAvatar, $userIdPairs, $PMList, $progressList) + { + $id = $field['name']; + $html = ''; + switch($id) + { + case 'name': + if($program->type == 'program') $icon = ' icon-program'; + if($program->type == 'project') $icon = ' icon-common icon-' . $program->model; + $class = $program->type == 'program' ? ' table-nest-toggle' : ''; + $html = ""; + + if($program->type == 'program') + { + $html .= ""; + $html .= ($this->app->user->admin or strpos(",{$this->app->user->view->programs},", ",$program->id,") !== false) ? html::a(helper::createLink('program', 'product', "programID=$program->id"), $program->name) : $program->name; + } + else + { + $projectType = $this->lang->project->{$program->model}; + $html .= html::a(helper::createLink('project', 'index', "projectID=$program->id", '', '', $program->id), $program->name, '', "class='text-ellipsis text-primary' title='{$program->name} ($projectType)'"); + + if($program->status != 'done' and $program->status != 'closed' and $program->status != 'suspended') + { + $delay = helper::diffDate(helper::today(), $program->end); + if($delay > 0) $html .= "{$this->lang->project->statusList['delay']}"; + } + } + break; + case 'status': + $html = "" . zget($this->lang->project->statusList, $program->status, '') . ''; + break; + case 'pm': + if(!empty($program->PM)) + { + $userName = zget($users, $program->PM); + $html = html::smallAvatar(array('avatar' => $usersAvatar[$program->PM], 'account' => $program->PM, 'name' => $userName), (($program->type == 'program' and $program->grade == 1 )? 'avatar-circle avatar-top avatar-' : 'avatar-circle avatar-') . zget($userIdPairs, $program->PM)); + $userID = isset($PMList[$program->PM]) ? $PMList[$program->PM]->id : ''; + $html .= html::a(helper::createLink('user', 'profile', "userID=$userID", '', true), $userName, '', "title='{$userName}' data-toggle='modal' data-type='iframe' data-width='600'"); + } + break; + case 'budget': + $programBudget = $this->project->getBudgetWithUnit($program->budget); + $html = $program->budget != 0 ? zget($this->lang->project->currencySymbol, $program->budgetUnit) . ' ' . $programBudget : $this->lang->project->future; + break; + case 'begin': + $html = $program->begin; + break; + case 'end': + $html = $program->end == LONG_TIME ? $this->lang->program->longTime : $program->end; + break; + case 'progress': + $html = round($progressList[$program->id]); + break; + case 'actions': + $html = $this->buildOperateMenu($program, 'browse'); + break; + } + return $html; + } } diff --git a/module/program/ui/browse.html.php b/module/program/ui/browse.html.php index 16f49df1b4..a7bcdd66cf 100644 --- a/module/program/ui/browse.html.php +++ b/module/program/ui/browse.html.php @@ -1,6 +1,5 @@ lang->program->featureBar['browse'] as $key => $label) @@ -21,6 +20,7 @@ if(common::hasPriv('project', 'create')) $button = button(' ' . $this->lang->project->create)->link($this->createLink('project', 'createGuide', "programID=0&from=PGM"))->misc('class="btn btn-secondary" data-toggle="modal" data-target="#guideDialog"'); $actionbar->append($button); } + if(isset($lang->pageActions)) { $actionbar->append($lang->pageActions); @@ -32,49 +32,23 @@ $menu->actionbar = $actionbar; /* Table. */ $table = dtable(); -$table->col('name', $this->lang->nameAB)->flex(1); -$table->col('status', $this->lang->program->status)->width(60)->type('html'); -$table->col('pm', $this->lang->program->PM)->width(100)->type('html'); -$table->col('budget', $this->lang->project->budget)->width(60); -$table->col('begin', $this->lang->project->begin)->width(60); -$table->col('end', $this->lang->project->end)->width(60); -$table->col('progress', $this->lang->project->progress)->width(100)->type('html'); -$table->col('actions', $this->lang->actions)->width(60); +$table->buildCols($this->config->program->dtable->fieldList); $rows = array(); $this->loadModel('project'); foreach($programs as $program) { $row = new stdclass(); - $row->name = $program->name; - $row->status = '' . zget($lang->project->statusList, $program->status, '') . ''; + foreach($this->config->program->dtable->fieldList as $field) + { + $fieldName = $field['name']; + $row->$fieldName = $this->program->buildCell($field, $program, $users, $usersAvatar, $userIdPairs, $PMList, $progressList); + } + $row->parent = $program->parent; - - $row->pm = ''; - if(!empty($program->PM)) - { - $userName = zget($users, $program->PM); - $row->pm .= html::smallAvatar(array('avatar' => $usersAvatar[$program->PM], 'account' => $program->PM, 'name' => $userName), (($program->type == 'program' and $program->grade == 1 )? 'avatar-circle avatar-top avatar-' : 'avatar-circle avatar-') . zget($userIdPairs, $program->PM)); - $userID = isset($PMList[$program->PM]) ? $PMList[$program->PM]->id : ''; - $row->pm .= html::a($this->createLink('user', 'profile', "userID=$userID", '', true), $userName, '', "title='{$userName}' data-toggle='modal' data-type='iframe' data-width='600'"); - } - - $programBudget = $this->project->getBudgetWithUnit($program->budget); - $row->budget = $program->budget != 0 ? zget($lang->project->currencySymbol, $program->budgetUnit) . ' ' . $programBudget : $this->lang->project->future; - $row->begin = $program->begin; - $row->end = $program->end == LONG_TIME ? $lang->program->longTime : $program->end; - - $row->progress = ''; - if(isset($progressList[$program->id])) - { - $row->progress = "
"; - $row->progress = "
" . round($progressList[$program->id]) . "
"; - } - - $row->actions = array(); - $rows[] = $row; } + $table->search($status, $moduleName); $table->data($rows); @@ -87,3 +61,11 @@ $page->top->menu = $menu; $page->right->content = $content; $page->x(); + +js::set('status', $status); +js::set('orderBy', $orderBy); +js::set('edit', $lang->edit); +js::set('selectAll', $lang->selectAll); +js::set('hasProject', $hasProject); +js::set('checkedProjects', $lang->program->checkedProjects); +js::set('cilentLang', $this->app->getClientLang());