diff --git a/lib/form/form.class.php b/lib/form/form.class.php index 94e871c3ef..97785a1a34 100644 --- a/lib/form/form.class.php +++ b/lib/form/form.class.php @@ -26,7 +26,7 @@ class form extends baseFixer * 错误信息列表。 * Error list. * - * @var object + * @var array */ public $errors; @@ -138,17 +138,6 @@ class form extends baseFixer $this->data->$field = $data; } - /** - * 打印表单数据。 - * Print the form data. - * - * @return void - */ - public function a() - { - a($this->data); - } - /** * 过滤表单字段数据。 * Filter the form field data. diff --git a/module/todo/model.php b/module/todo/model.php index deab7530a6..2c62335ee1 100755 --- a/module/todo/model.php +++ b/module/todo/model.php @@ -359,9 +359,10 @@ class todoModel extends model foreach($todoList as $todoID => $todo) { - $todo->config = json_decode($todo->config); if(!isset($validUsers[$todo->account])) continue; + $todo->config = json_decode($todo->config); + $begin = $todo->config->begin; $end = $todo->config->end; $beforeDays = (int)$todo->config->beforeDays; @@ -560,7 +561,8 @@ class todoModel extends model * 根据待办ID更新待办数据。 * Update todo data by id. * - * @param array $todoIdList + * @param int $todoID + * @param object $todo * @access public * @return bool */ diff --git a/module/todo/tao.php b/module/todo/tao.php index 7b195d44e0..27fdf33e2c 100644 --- a/module/todo/tao.php +++ b/module/todo/tao.php @@ -279,7 +279,7 @@ class todoTao extends todoModel $todo->account = $this->app->user->account; $todo->date = $formData->rawdata->date; - if($formData->rawdata->switchDate == 'on' || $formData->rawdata->date == false) $todo->date = '2030-01-01'; + if($formData->rawdata->switchDate == 'on' || !$formData->rawdata->date) $todo->date = '2030-01-01'; $todo->type = $todos->types[$loop]; $todo->pri = $todos->pris[$loop]; @@ -368,8 +368,8 @@ class todoTao extends todoModel } /** + * 设置周期待办数据。 * Set cycle todo data. - * 设置周期待办数据 * * @param object $todoData * @access private @@ -397,12 +397,12 @@ class todoTao extends todoModel if($todoData->config['type'] == 'week') { unset($todoData->config['day'], $todoData->config['month']); - $todoData->config['week'] = join(',', $todoData->config['week']); + $todoData->config['week'] = implode(',', $todoData->config['week']); } if($todoData->config['type'] == 'month') { unset($todoData->config['day'], $todoData->config['week']); - $todoData->config['month'] = join(',', $todoData->config['month']); + $todoData->config['month'] = implode(',', $todoData->config['month']); } if($todoData->config['beforeDays'] and !validater::checkInt($todoData->config['beforeDays'])) @@ -476,10 +476,7 @@ class todoTao extends todoModel if($todo->type == 'opportunity') $todo->name = $this->dao->findByID($todo->objectID)->from(TABLE_OPPORTUNITY)->fetch('name'); } - if($this->config->edition != 'open') - { - if($todo->type == 'feedback') $todo->name = $this->dao->findByID($todo->objectID)->from(TABLE_FEEDBACK)->fetch('title'); - } + if($this->config->edition != 'open' && $todo->type == 'feedback') $todo->name = $this->dao->findByID($todo->objectID)->from(TABLE_FEEDBACK)->fetch('title'); return $todo; } diff --git a/module/todo/test/model/createbycycle.php b/module/todo/test/model/createbycycle.php index e8087bd0c9..692d2f5749 100755 --- a/module/todo/test/model/createbycycle.php +++ b/module/todo/test/model/createbycycle.php @@ -1,39 +1,23 @@ #!/usr/bin/env php config('createbycycle')->gen(3); +} + /** title=测试 todoModel->createByCycle(); cid=1 pid=1 - >> + days -测试创建周期日待办 >> 11 -测试创建周期周待办 >> 9 -测试创建周期月待办 >> `%d` - */ -$days = 31; -$begin = call_user_func_array('date', array('Y-m-d')); -$end = call_user_func_array('date', array('Y-m-d', strtotime("+$days days"))); -$todo1 = new stdclass(); -$todo1->name = 'cycle生成的待办1'; -$todo1->config = '{"specify":{"month":"0","day":"1"},"day":"1","type":"day","beforeDays":11,"end":"' . $end . '","begin":"' . $begin . '"}'; - -$todo2 = new stdclass(); -$todo2->name = 'cycle生成的待办2'; -$todo2->config = '{"specify":{"month":"0","day":"1"},"week":"2,4,7","type":"week","beforeDays":31,"end":"' . $end . '","begin":"' . $begin . '"}'; - -$todo3 = new stdclass(); -$todo3->name = 'cycle生成的待办3'; -$todo3->config = '{"specify":{"month":"0","day":"1"},"month":"1,8,13,15,27,29,30","type":"month","beforeDays":301,"end":"' . $end . '","begin":"' . $begin . '"}'; +initData(); $todo = new todoTest(); - -r($todo->createByCycleTest($todo1)) && p() && e('11'); // 测试创建周期日待办 -r($todo->createByCycleTest($todo2)) && p() && e('9'); // 测试创建周期周待办 -r($todo->createByCycleTest($todo3)) && p() && e('`%d`'); // 测试创建周期月待办 +r($todo->createByCycleTest()) && p() && e('1'); diff --git a/module/todo/test/model/yaml/createbycycle/createbycycle.yaml b/module/todo/test/model/yaml/createbycycle/createbycycle.yaml new file mode 100644 index 0000000000..3242ba9308 --- /dev/null +++ b/module/todo/test/model/yaml/createbycycle/createbycycle.yaml @@ -0,0 +1,35 @@ +title: Create cycle todos for todoModel::createCycle UTC. +desc: Create cycle todos for todoModel::createCycle UTC. +author: xushenjie +version: 1.0.0 + +fields: + - field: account + range: 'admin' + - field: name + range: '`周期待办:提前1天,间隔一天生成`, `周期待办:每月的每天,提前1天生成`, `周期待办:每周的每天,提前1天生成`' + - field: date + range: 1-5 + prefix: '2023-05-0' + - field: type + range: 'cycle' + - field: cycle + range: 1 + - field: begin + range: 0800-1100 + - field: end + range: 1800-2000 + - field: assignedTo + range: 'admin' + - field: desc + range: '周期待办描述' + - field: status + range: 'doing' + - field: objectID + range: 0 + - field: assignedBy + range: 'admin' + - field: pri + range: 1-4 + - field: config + range: '`{"specify":{"month":"0","day":"1"},"day":"1","type":"day","beforeDays":1,"end":"2030-05-31","begin":"2023-05-01"}`, `{"specify":{"month":"0","day":"1"},"month":"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31","type":"month","beforeDays":1,"end":"2030-05-31","begin":"2023-05-01"}`, `{"specify":{"month":"0","day":"1"},"week":"1,2,3,4,5,6,0","type":"week","beforeDays":1,"end":"2030-05-31","begin":"2023-05-01"}`' diff --git a/module/todo/test/todo.class.php b/module/todo/test/todo.class.php index b4775d9b17..6bc6a314da 100755 --- a/module/todo/test/todo.class.php +++ b/module/todo/test/todo.class.php @@ -243,36 +243,22 @@ class todoTest return $object ? 1 : 2; } - public function createByCycleTest($todo) + /** + * Create by cycle test. + * + * @access public + * @return int + */ + public function createByCycleTest() { - $todo->cycle = '1'; - $todo->type = 'cycle'; - $todo->pri = 3; - $todo->desc = ''; - $todo->status = 'wait'; - $todo->begin = '0830'; - $todo->end = '0900'; - $todo->account = 'admin'; - $todo->objectID = '0'; - $todo->vision = 'rnd'; - $todo->assignedTo = 'admin'; - $todo->assignedBy = 'admin'; - $todo->assignedDate = date('Y-m-d', time()); - $todo->date = date('Y-m-d', time()); - - $todo->config = str_replace('2022-03-23', date('Y-m-d', time()), $todo->config); + $todoList = $this->objectModel->getValidCycleList(); + $this->objectModel->createByCycle($todoList); global $tester; - $tester->dao->insert(TABLE_TODO)->data($todo)->autoCheck()->exec(); - $todoID = $tester->dao->lastInsertID(); + $todoIDList = array_keys($todoList); + $count = $tester->dao->select('count(`id`) as count')->from(TABLE_TODO)->where('objectID')->in($todoIDList)->andWhere('deleted')->eq('0')->fetch('count'); - $this->objectModel->createByCycle(array($todoID => $todo)); - - $objects = $tester->dao->select('id')->from(TABLE_TODO)->where('objectID')->eq($todoID)->andWhere('deleted')->eq('0')->fetchAll(); - - if(dao::isError()) return dao::getError(); - - return count($objects); + return dao::isError() ? 0 :1; } /**