* Code for task #90779.

This commit is contained in:
caoyanyi
2023-04-11 16:11:55 +08:00
parent ac9837abcb
commit 185550fcf4
7 changed files with 95 additions and 19 deletions
+1
View File
@@ -2042,6 +2042,7 @@ class block extends control
*/
public function printDocStatisticBlock()
{
$this->view->statistic = $this->loadModel('doc')->getStatisticInfo();
}
/**
@@ -0,0 +1,65 @@
<?php
/**
* The statistic view file of block module of ZenTaoPMS.
*
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Yanyi Cao <caoyanyi@easycorp.ltd>
* @package block
* @version $Id$
* @link http://www.zentao.net
*/
?>
<style>
.block-statistic .flex {display: flex; flex-wrap: nowrap; flex-direction: row; justify-content: space-between; flex: auto;}
.block-statistic .flex-column {flex-direction: column; padding-left: 10px;}
.block-statistic .statistic {flex: 0 1 32%;}
.block-statistic .created {flex: 0 1 48%;}
.block-statistic .edited {flex: 0 1 16%; padding-left: 20px;}
.block-statistic .divider {border-right: 1px solid #eee; padding-right: 35px;}
.block-statistic .title-line {height: 32px;}
.block-statistic .panel-title {display: none;}
.block-statistic .panel-body {margin-top: -32px; padding: 30px;}
.block-statistic .tile-title {white-space: nowrap;}
</style>
<div class="panel-body flex">
<div class='flex flex-column statistic'>
<h4 class="title-line"><?php echo $lang->doc->docStatistic;?></h4>
<div class='flex'>
<div class="tile">
<div class="tile-amount text-primary"><?php echo (int)$statistic->totalDocs;?></div>
<div class="tile-title"><?php echo $lang->doc->allDoc;?></div>
</div>
<div class="tile divider">
<div class="tile-amount text-primary"><?php echo (int)$statistic->todayEditedDocs;?></div>
<div class="tile-title"><?php echo $lang->doc->todayEdited;?></div>
</div>
</div>
</div>
<div class='flex flex-column created'>
<h4 class="title-line"><?php echo $lang->doc->openedByMe;?></h4>
<div class='flex'>
<div class="tile">
<div class="tile-amount text-primary"><?php echo (int)$statistic->myDocs;?></div>
<div class="tile-title"><?php echo $lang->doc->docCreated;?></div>
</div>
<div class="tile">
<div class="tile-amount text-primary"><?php echo (int)$statistic->myDoc->docViews;?></div>
<div class="tile-title"><?php echo $lang->doc->docViews;?></div>
</div>
<div class="tile divider">
<div class="tile-amount text-primary"><?php echo (int)$statistic->myDoc->docCollects;?></div>
<div class="tile-title"><?php echo $lang->doc->docCollects;?></div>
</div>
</div>
</div>
<div class='flex flex-column edited'>
<h4 class="title-line"><?php echo $lang->doc->editedByMe;?></h4>
<div class='flex'>
<div class="tile">
<div class="tile-amount text-primary"><?php echo (int)$statistic->myEditedDocs;?></div>
<div class="tile-title"><?php echo $lang->doc->docEdited;?></div>
</div>
</div>
</div>
</div>
+5
View File
@@ -145,6 +145,11 @@ $lang->doc->tableContents = 'Catalog';
$lang->doc->addCatalog = 'Add Catalog';
$lang->doc->editCatalog = 'Edit Catalog';
$lang->doc->deleteCatalog = 'Delete Catalog';
$lang->doc->docStatistic = 'Statistic';
$lang->doc->docCreated = 'Created Documents';
$lang->doc->docEdited = 'Edited Documents';
$lang->doc->docViews = 'Page Views';
$lang->doc->docCollects = 'Collection';
/* Methods list */
$lang->doc->index = 'Dashboard';
+5
View File
@@ -145,6 +145,11 @@ $lang->doc->tableContents = 'Directory';
$lang->doc->addCatalog = 'Add Catalog';
$lang->doc->editCatalog = 'Edit Catalog';
$lang->doc->deleteCatalog = 'Delete Catalog';
$lang->doc->docStatistic = 'Statistic';
$lang->doc->docCreated = 'Created Documents';
$lang->doc->docEdited = 'Edited Documents';
$lang->doc->docViews = 'Page Views';
$lang->doc->docCollects = 'Collection';
/* Methods list */
$lang->doc->index = 'Dashboard';
+5
View File
@@ -145,6 +145,11 @@ $lang->doc->tableContents = 'Catalog';
$lang->doc->addCatalog = 'Add Catalog';
$lang->doc->editCatalog = 'Edit Catalog';
$lang->doc->deleteCatalog = 'Delete Catalog';
$lang->doc->docStatistic = 'Statistic';
$lang->doc->docCreated = 'Created Documents';
$lang->doc->docEdited = 'Edited Documents';
$lang->doc->docViews = 'Page Views';
$lang->doc->docCollects = 'Collection';
/* Methods list */
$lang->doc->index = 'Dashboard';
+8 -3
View File
@@ -128,9 +128,9 @@ $lang->doc->team = '团队';
$lang->doc->moduleDoc = '按模块浏览';
$lang->doc->searchDoc = '搜索';
$lang->doc->fast = '快速访问';
$lang->doc->allDoc = '所有文档';
$lang->doc->openedByMe = '由我创建';
$lang->doc->editedByMe = '由我编辑';
$lang->doc->allDoc = '全部文档';
$lang->doc->openedByMe = '我的创建';
$lang->doc->editedByMe = '我的编辑';
$lang->doc->orderByOpen = '最近添加';
$lang->doc->orderByEdit = '最近更新';
$lang->doc->orderByVisit = '最近访问';
@@ -145,6 +145,11 @@ $lang->doc->tableContents = '目录';
$lang->doc->addCatalog = '添加目录';
$lang->doc->editCatalog = '编辑目录';
$lang->doc->deleteCatalog = '删除目录';
$lang->doc->docStatistic = '文档统计';
$lang->doc->docCreated = '创建的文档';
$lang->doc->docEdited = '编辑的文档';
$lang->doc->docViews = '被浏览量';
$lang->doc->docCollects = '被收藏量';
/* 方法列表。*/
$lang->doc->index = '仪表盘';
+6 -16
View File
@@ -2145,29 +2145,19 @@ class docModel extends model
{
$allLibs = array_keys($this->getLibs('all'));
$docIdList = $this->getPrivDocs($allLibs);
$myDocList = $this->dao->select('id')->from(TABLE_DOC)->where('addedBy')->eq($this->app->user->account)->fetchPairs('id');
$today = date('Y-m-d');
$lately = date('Y-m-d', strtotime('-3 day'));
$statisticInfo = $this->dao->select("count(id) as totalDocs, count(IF(editedDate like '{$today}%', 1, null)) as todayEditedDocs,
count(IF(editedDate > '{$lately}', 1, null)) as lastEditedDocs, count(IF(addedDate > '{$lately}', 1, null)) as lastAddedDocs,
count(IF(addedBy = '{$this->app->user->account}', 1, null)) as myDocs")->from(TABLE_DOC)
$today = date('Y-m-d');
$statistic = $this->dao->select("count(id) as totalDocs, count(IF(editedDate like '{$today}%', 1, null)) as todayEditedDocs,
count(IF(editedBy = '{$this->app->user->account}', 1, null)) as myEditedDocs, count(IF(addedBy = '{$this->app->user->account}', 1, null)) as myDocs")->from(TABLE_DOC)
->where('deleted')->eq(0)
->andWhere('vision')->eq($this->config->vision)
->andWhere('id')->in($docIdList)
->fetch();
$statisticInfo->myCollection = $this->dao->select('count(*) as count')->from(TABLE_DOCACTION)
->where('doc')->in($docIdList)
->andWhere('action')->eq('collect')
->andWhere('actor')->eq($this->app->user->account)
->fetch('count');
$statisticInfo->pastEditedDocs = $statisticInfo->totalDocs - $statisticInfo->todayEditedDocs;
$statisticInfo->lastEditedProgress = $statisticInfo->totalDocs ? round($statisticInfo->lastEditedDocs / $statisticInfo->totalDocs, 2) * 100 : 0;
$statisticInfo->lastAddedProgress = $statisticInfo->totalDocs ? round($statisticInfo->lastAddedDocs / $statisticInfo->totalDocs, 2) * 100 : 0;
$statisticInfo->myCollectionProgress = $statisticInfo->totalDocs ? round($statisticInfo->myCollection / $statisticInfo->totalDocs, 2) * 100 : 0;
$statisticInfo->myDocsProgress = $statisticInfo->totalDocs ? round($statisticInfo->myDocs / $statisticInfo->totalDocs, 2) * 100 : 0;
$statistic->myDoc = $this->dao->select("count(IF(`action` = 'view', 1, null)) as docViews, count(IF(`action` = 'collect', 1, null)) as docCollects")->from(TABLE_DOCACTION)->where('doc')->in($myDocList)->fetch();
return $statisticInfo;
return $statistic;
}
/**