* @package * @uses func * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html) * @Link https://www.zentao.net */ class left_period_of_project extends baseCalc { public $dataset = 'getAllProjects'; public $fieldList = array('t1.id', 't1.status', 't1.end'); public $result = array(); public function calculate($row) { if($row->status == 'closed') { $this->result[$row->id] = 0; } else { $diff = strtotime($row->end) - strtotime(date('Y-m-d')); if($diff <= 0) { $this->result[$row->id] = 0; } else { $this->result[$row->id] = $diff / 86400; } } } public function getResult($options = array()) { $records = $this->getRecords(array('project', 'value')); return $this->filterByOptions($records, $options); } }