diff --git a/module/productplan/js/view.ui.js b/module/productplan/js/view.ui.js index fe93d47680..dbec9bbcd9 100644 --- a/module/productplan/js/view.ui.js +++ b/module/productplan/js/view.ui.js @@ -31,8 +31,9 @@ window.showLink = function(obj) $(document).on('click', '.batch-btn', function() { - const type = $(this).data('type'); - const dtable = zui.DTable.query($('#' + type + 'DTable')); + const $this = $(this); + const type = $this.data('type'); + const dtable = zui.DTable.query($this); const checkedList = dtable.$.getChecks(); if(!checkedList.length) return; diff --git a/module/program/config/dtable.php b/module/program/config/dtable.php index 6fae5a3540..5c8a71d49b 100644 --- a/module/program/config/dtable.php +++ b/module/program/config/dtable.php @@ -46,7 +46,9 @@ $config->program->dtable->fieldList['end']['sortType'] = true; $config->program->dtable->fieldList['progress']['name'] = 'progress'; $config->program->dtable->fieldList['progress']['title'] = $lang->program->progressAB; $config->program->dtable->fieldList['progress']['minWidth'] = 100; -$config->program->dtable->fieldList['progress']['type'] = 'circleProgress'; +$config->program->dtable->fieldList['progress']['sortType'] = false; +$config->program->dtable->fieldList['progress']['type'] = 'progress'; +$config->program->dtable->fieldList['progress']['align'] = 'center'; $config->program->dtable->fieldList['actions']['name'] = 'actions'; $config->program->dtable->fieldList['actions']['title'] = $lang->actions; @@ -193,6 +195,7 @@ $config->program->projectView->dtable->fieldList['name']['name'] = 'name $config->program->projectView->dtable->fieldList['name']['title'] = $lang->nameAB; $config->program->projectView->dtable->fieldList['name']['width'] = 200; $config->program->projectView->dtable->fieldList['name']['type'] = 'link'; +$config->program->projectView->dtable->fieldList['name']['link'] = "RAWJSRAWJS"; $config->program->projectView->dtable->fieldList['name']['flex'] = 1; $config->program->projectView->dtable->fieldList['name']['nestedToggle'] = true; $config->program->projectView->dtable->fieldList['name']['checkbox'] = true; @@ -281,7 +284,7 @@ $config->program->projectView->dtable->fieldList['realEnd']['group'] = 7; $config->program->projectView->dtable->fieldList['progress']['name'] = 'progress'; $config->program->projectView->dtable->fieldList['progress']['title'] = $lang->program->progressAB; $config->program->projectView->dtable->fieldList['progress']['minWidth'] = 100; -$config->program->projectView->dtable->fieldList['progress']['type'] = 'circleProgress'; +$config->program->projectView->dtable->fieldList['progress']['type'] = 'progress'; $config->program->projectView->dtable->fieldList['progress']['show'] = true; $config->program->projectView->dtable->fieldList['progress']['group'] = 8; diff --git a/module/program/control.php b/module/program/control.php index 34e7132d67..d78837e901 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -165,7 +165,7 @@ class program extends control $program = $this->program->getByID($programID); $path = explode(',', $program->path); $path = array_filter($path); - $programID = current($path); + $programID = (int)current($path); $this->view->program = $program; } @@ -747,7 +747,7 @@ class program extends control * @access public * @return void */ - public function view($programID) + public function view(int $programID) { $programID = (int)$programID; $program = $this->program->getByID($programID); diff --git a/module/program/js/browse.ui.js b/module/program/js/browse.ui.js index d4deb14d69..009b38ca0e 100644 --- a/module/program/js/browse.ui.js +++ b/module/program/js/browse.ui.js @@ -1,8 +1,8 @@ window.footerGenerator = function() { - const count = this.layout.allRows.filter((x) => x.data.type === "product").length; + const count = this.layout.allRows.filter((x) => x.data.type === "product").length; const statistic = summeryTpl.replace('%s', ' ' + count + ' '); - return [{children: statistic, className: "text-dark"}, "flex", "pager"]; + return ['checkbox', 'toolbar', {html: statistic, className: "text-dark"}, "flex", "pager"]; } window.renderCell = function(result, {col, row}) @@ -27,3 +27,15 @@ window.renderCell = function(result, {col, row}) return result; } + +$(document).on('click', '.batch-btn', function() +{ + const $this = $(this); + const dtable = zui.DTable.query($this); + const checkedList = dtable.$.getChecks(); + if(!checkedList.length) return; + + const postData = new FormData(); + checkedList.forEach((id) => postData.append('projectIdList[]', id)); + postAndLoadPage($(this).data('url'), postData); +}) diff --git a/module/program/model.php b/module/program/model.php index a256718adb..9451ae8eb7 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -27,7 +27,7 @@ class programModel extends model * @access public * @return int */ - public function saveState($programID = 0, $programs = array()) + public function saveState(int $programID = 0, array $programs = array()): int { if($programID > 0) $this->session->set('program', (int)$programID); if($programID == 0 and $this->cookie->lastProgram) $this->session->set('program', (int)$this->cookie->lastProgram); @@ -38,7 +38,7 @@ class programModel extends model if($programID && strpos(",{$this->app->user->view->programs},", ",{$this->session->program},") === false) $this->accessDenied(); } - return $this->session->program; + return (int)$this->session->program; } /** diff --git a/module/program/ui/browse.html.php b/module/program/ui/browse.html.php index 1b88243939..f7c006cbb4 100644 --- a/module/program/ui/browse.html.php +++ b/module/program/ui/browse.html.php @@ -2,7 +2,6 @@ namespace zin; $cols = array_values($config->program->projectView->dtable->fieldList); - $data = array(); foreach($programs as $program) { @@ -28,14 +27,18 @@ foreach($programs as $program) } /* Calculate budget.*/ - $programBudget = $this->loadModel('project')->getBudgetWithUnit($program->budget); + $programBudget = $this->loadModel('project')->getBudgetWithUnit($program->budget); $program->budget = $program->budget != 0 ? zget($lang->project->currencySymbol, $program->budgetUnit) . ' ' . $programBudget : $lang->project->future; /* Progress. */ if(isset($progressList[$program->id])) $program->progress = round($progressList[$program->id]); + $program->isParent = false; + if($program->parent > 0 and isset($programs[$program->parent])) $programs[$program->parent]->isParent = true; + /* Set invested hours. */ if(!isset($program->invested)) $program->invested = 0; + if(str_contains($program->end, LONG_TIME)) $program->end = $lang->program->longTime; /* Actions. */ $program->actions = array(); @@ -52,20 +55,13 @@ foreach($programs as $program) $data[] = $program; } -jsVar('langManDay', $lang->program->manDay); -jsVar('langPostponed', empty($program->end) ? $lang->project->statusList['delay'] : sprintf($lang->project->delayInfo, helper::diffDate(helper::today(), $program->end))); -jsVar('summeryTpl', $summary); +jsVar('langManDay', $lang->program->manDay); +jsVar('summeryTpl', $summary); featureBar ( set::current($status), set::linkParams("status={key}&orderBy=$orderBy"), - (hasPriv('project', 'batchEdit') && $programType != 'bygrid' && $hasProject === true) ? item - ( - set::type('checkbox'), - set::text($lang->project->edit), - set::checked($this->cookie->editProject) - ) : NULL, li(searchToggle(set::module('program'))) ); @@ -87,16 +83,19 @@ toolbar ])), ); +$footToolbar = common::hasPriv('project', 'batchEdit') ? array('items' => array(array('text' => $lang->project->edit, 'class' => 'btn batch-btn size-sm primary', 'data-url' => createLink('project', 'batchEdit')))) : null; dtable ( set::cols($cols), set::data($data), set::nested(true), set::onRenderCell(jsRaw('window.renderCell')), + set::canRowCheckable(jsRaw("function(rowID){return this.getRowInfo(rowID).data.type == 'project';}")), set::footPager(usePager()), set::footer(jsRaw('function(){return window.footerGenerator.call(this);}')), set::customCols(true), - set::userMap($this->loadModel('user')->getPairs('noletter|pofirst')) + set::userMap($this->loadModel('user')->getPairs('noletter|pofirst')), + set::footToolbar($footToolbar), ); render(); diff --git a/module/story/model.php b/module/story/model.php index 88a99ee1fb..1f589f2113 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -5738,6 +5738,7 @@ class storyModel extends model { $story->actions = $this->buildActionButtonList($story, 'browse'); $story->estimate = $story->estimate . $this->config->hourUnit; + $story->isParent = isset($story->children); $story->taskCount = zget(zget($options, 'storyTasks', array()), $story->id, 0); $story->bugCount = zget(zget($options, 'storyBugs', array()), $story->id, 0);