From 1bc779acd9dc77e1c9d1fd1ea24d8ec5f3f88471 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Wed, 22 Jun 2022 16:20:14 +0800 Subject: [PATCH] * Finish task#57851. --- module/doc/model.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/module/doc/model.php b/module/doc/model.php index 7fe3134a2a..53c33f13e0 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1432,10 +1432,21 @@ class docModel extends model ->fetchPairs('product', 'projectCount'); } + $docCountPairs = $this->dao->select('lib, count(id) as docCount')->from(TABLE_DOC) + ->where('lib')->in(array_keys($objectLibs)) + ->andWhere('vision')->eq($this->config->vision) + ->andWhere('type')->notin('chapter') + ->andWhere('deleted')->eq(0) + ->groupBy('lib') + ->fetchPairs('lib'); + $libs = array(); foreach($objectLibs as $lib) { if($this->checkPrivLib($lib)) $libs[$lib->id] = $lib; + + $docCount = zget($docCountPairs, $lib->id, 0); + $libs[$lib->id]->docCount = $docCount > 99 ? '99+' : $docCount; } $itemCounts = $this->statLibCounts(array_keys($libs)); @@ -2353,12 +2364,15 @@ EOT; foreach($libs as $key => $lib) { $selected = $key == $libID ? 'selected' : ''; - $output .= html::a(inlink($methodName, "type=$type&objectID=$objectID&libID=$key"), $lib->name, '', "class='$selected' data-app='{$this->app->tab}'"); + $docCount = isset($lib->docCount) ? $lib->docCount : 0; + $output .= html::a(inlink($methodName, "type=$type&objectID=$objectID&libID=$key"), "$lib->name ($docCount)", '', "class='$selected' data-app='{$this->app->tab}' title='$lib->name ($docCount)' style='display: flex; justify-content: start;'"); } if($type != 'custom' and $type != 'book') { - $selected = empty($libID) ? 'selected' : ''; - $output .= html::a(inlink('showFiles', "type=$type&objectID=$objectID"), $this->lang->doclib->files, '', "class='$selected' data-app='{$this->app->tab}'"); + $files = $this->getLibFiles($type, $objectID, 't1.id_desc'); + $fileCount = count($files) > 99 ? '99+' : count($files); + $selected = empty($libID) ? 'selected' : ''; + $output .= html::a(inlink('showFiles', "type=$type&objectID=$objectID"), "{$this->lang->doclib->files} ($fileCount)", '', "class='$selected' data-app='{$this->app->tab}' title='{$this->lang->doclib->files} ($fileCount)'"); } $output .= ""; }