* Finish task #99189.
This commit is contained in:
@@ -34,7 +34,7 @@ class left_period_of_project extends baseCalc
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->result[$row->id] = $row->end - date('Y-m-d');
|
||||
$this->result[$row->id] = strtotime($row->end) - strtotime(date('Y-m-d'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-9
@@ -14,7 +14,7 @@
|
||||
* 收集方式:realtime
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @author qixinzhi <qixinzhi@easycorp.ltd>
|
||||
* @author zhouxin <zhouxin@easycorp.ltd>
|
||||
* @package
|
||||
* @uses func
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
@@ -22,21 +22,18 @@
|
||||
*/
|
||||
class planned_period_of_project extends baseCalc
|
||||
{
|
||||
public $dataset = null;
|
||||
public $dataset = 'getAllProjects';
|
||||
|
||||
public $fieldList = array();
|
||||
|
||||
//public funtion getStatement($dao)
|
||||
//{
|
||||
//}
|
||||
public $fieldList = array('id', 'begin', 'end');
|
||||
|
||||
public function calculate($row)
|
||||
{
|
||||
$this->result[$row->id] = (strtotime($row->end) - strtotime($row->begin))/86400;
|
||||
}
|
||||
|
||||
public function getResult($options = array())
|
||||
{
|
||||
$records = $this->getRecords(array('value'));
|
||||
$records = $this->getRecords(array('project', 'value'));
|
||||
return $this->filterByOptions($records, $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 7) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 4) . '/calc.class.php';
|
||||
|
||||
zdTable('project')->config('project_status', $useCommon = true, $levels = 4)->gen(100);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=planed_period_of_project
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('100'); // 测试分组数。
|
||||
|
||||
r($calc->getResult(array('project' => 1))) && p('0:value') && e('365'); // 测试项目1的计划工期
|
||||
r($calc->getResult(array('project' => 2))) && p('0:value') && e('365'); // 测试项目2的计划工期
|
||||
r($calc->getResult(array('project' => 3))) && p('0:value') && e('365'); // 测试项目3的计划工期
|
||||
@@ -19,6 +19,14 @@ fields:
|
||||
range: "20110101 000000-20210101 230000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
- field: begin
|
||||
range: "20100101 000000-20210101 230000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD
|
||||
- field: end
|
||||
range: "20110101 000000-20210101 230000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD
|
||||
- field: deleted
|
||||
range: 0{100},1{100}
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user