diff --git a/db/update2.3.sql b/db/update2.3.sql index 8a6b8e50dd..8e72ada7a1 100644 --- a/db/update2.3.sql +++ b/db/update2.3.sql @@ -6,5 +6,5 @@ ALTER TABLE `zt_case` ADD `runAccount` VARCHAR( 30 ) CHARACTER SET utf8 COLLATE -- adjust the working hours. ALTER TABLE `zt_project` ADD `days` SMALLINT UNSIGNED NOT NULL AFTER `end`; ALTER TABLE `zt_team` CHANGE `joinDate` `join` DATE NOT NULL DEFAULT '0000-00-00'; -ALTER TABLE `zt_team` CHANGE `workingHour` `hours` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '0' -ALTER TABLE `zt_team` ADD `days` SMALLINT UNSIGNED NOT NULL AFTER `joinDate` ; +ALTER TABLE `zt_team` CHANGE `workingHour` `hours` TINYINT( 3 ) UNSIGNED NOT NULL DEFAULT '0'; +ALTER TABLE `zt_team` ADD `days` SMALLINT UNSIGNED NOT NULL AFTER `join` ; diff --git a/module/bug/js/browse.js b/module/bug/js/browse.js index e17f4624b6..c2eff61362 100644 --- a/module/bug/js/browse.js +++ b/module/bug/js/browse.js @@ -20,8 +20,3 @@ $(document).ready(function() $("#browsecss").attr('href', ''); } }); - -$(document).ready(function() -{ - if($('a.export').size()) $("a.export").colorbox({width:400, height:200, iframe:true, transition:'elastic', speed:350, scrolling:true}); -}) diff --git a/module/my/control.php b/module/my/control.php index b8d8bc4dcc..7e37ab190a 100644 --- a/module/my/control.php +++ b/module/my/control.php @@ -77,10 +77,11 @@ class my extends control $this->view->position[] = $this->lang->my->todo; /* Assign. */ - $this->view->dates = $this->loadModel('todo')->buildDateList(); - $this->view->todos = $this->todo->getList($type, $account, $status); - $this->view->date = (int)$type == 0 ? $this->todo->today() : $type; - $this->view->type = $type; + $this->view->dates = $this->loadModel('todo')->buildDateList(); + $this->view->todos = $this->todo->getList($type, $account, $status); + $this->view->date = (int)$type == 0 ? $this->todo->today() : $type; + $this->view->type = $type; + $this->view->account = $this->app->user->account; $this->view->importFeature = ($type == 'before' or $type == TODOMODEL::DAY_IN_FEATURE); $this->display(); diff --git a/module/my/view/todo.html.php b/module/my/view/todo.html.php index c3b25205de..d74611569c 100644 --- a/module/my/view/todo.html.php +++ b/module/my/view/todo.html.php @@ -25,7 +25,12 @@ ?> -
createLink('todo', 'create', "date=$date"), $lang->todo->create);?>
+
+ export, '', 'class="export"'); + echo html::a($this->createLink('todo', 'create', "date=$date"), $lang->todo->create); + ?> +
diff --git a/module/product/js/browse.js b/module/product/js/browse.js index 988a1320c4..71b68ef6e2 100644 --- a/module/product/js/browse.js +++ b/module/product/js/browse.js @@ -7,8 +7,3 @@ function browseByModule() $('#featurebar .active').removeClass('active'); $('#bymoduleTab').addClass('active'); } - -$(document).ready(function() -{ - if($('a.export').size()) $("a.export").colorbox({width:400, height:200, iframe:true, transition:'elastic', speed:350, scrolling:true}); -}) diff --git a/module/project/js/task.js b/module/project/js/task.js index c18b92ba44..cdaccc8e08 100644 --- a/module/project/js/task.js +++ b/module/project/js/task.js @@ -2,8 +2,3 @@ $(function() { $('#' + browseType + 'Tab').addClass('active'); }); - -$(document).ready(function() -{ - if($('a.export').size()) $("a.export").colorbox({width:400, height:200, iframe:true, transition:'elastic', speed:350, scrolling:true}); -}) diff --git a/module/story/control.php b/module/story/control.php index b22c6c8671..ae69a87af3 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -50,7 +50,6 @@ class story extends control { $product = $this->product->getById($productID); $products = $this->product->getPairs(); - a($products); } else { diff --git a/module/testcase/js/browse.js b/module/testcase/js/browse.js index 3379b5f155..9fda8fcd75 100644 --- a/module/testcase/js/browse.js +++ b/module/testcase/js/browse.js @@ -29,6 +29,5 @@ $(document).ready(function() $(document).ready(function() { - if($('a.export').size()) $("a.export").colorbox({width:400, height:200, iframe:true, transition:'elastic', speed:350, scrolling:true}); $(".results").colorbox({width:900, height:600, iframe:true, transition:'none'}); }) diff --git a/module/todo/config.php b/module/todo/config.php index 4ca0b21d0e..65c2d5fc4c 100644 --- a/module/todo/config.php +++ b/module/todo/config.php @@ -8,3 +8,5 @@ $config->todo->times->delta = 10; $config->todo->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); $config->todo->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); + +$config->todo->list->exportFields = 'id, account, date, begin, end, type, idvalue, pri, name, desc, status, private'; diff --git a/module/todo/control.php b/module/todo/control.php index b85998f252..bcb60fba85 100644 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -187,4 +187,66 @@ class todo extends control $this->dao->update(TABLE_TODO)->set('date')->eq($today)->where('id')->in($todos)->exec(); die(js::reload('parent')); } + + /** + * Get data to export + * + * @param string $productID + * @param string $orderBy + * @access public + * @return void + */ + public function export($account, $orderBy) + { + if($_POST) + { + $todoLang = $this->lang->todo; + $todoConfig = $this->config->todo; + + /* Create field lists. */ + $fields = explode(',', $todoConfig->list->exportFields); + foreach($fields as $key => $fieldName) + { + $fieldName = trim($fieldName); + $fields[$fieldName] = isset($todoLang->$fieldName) ? $todoLang->$fieldName : $fieldName; + unset($fields[$key]); + } + unset($fields['idvalue']); + unset($fields['private']); + + /* Get bugs. */ + $todos = $this->dao->select('*')->from(TABLE_TODO)->where($this->session->todoReportCondition)->orderBy($orderBy)->fetchAll('id'); + + /* Get users, bugs, tasks and times. */ + $users = $this->loadModel('user')->getPairs('noletter'); + $bugs = $this->loadModel('bug')->getUserBugPairs($account); + $tasks = $this->loadModel('task')->getUserTaskPairs($account); + $times = $this->todo->buildTimeList($this->config->todo->times->begin, $this->config->todo->times->end, $this->config->todo->times->delta); + + foreach($todos as $todo) + { + /* fill some field with useful value. */ + if(isset($users[$todo->account])) $todo->account = $users[$todo->account]; + if(isset($times[$todo->begin])) $todo->begin = $times[$todo->begin]; + if(isset($times[$todo->end])) $todo->end = $times[$todo->end]; + if($todo->type == 'bug') $todo->name = $bugs[$todo->idvalue]; + if($todo->type == 'task') $todo->name = $tasks[$todo->idvalue]; + if(isset($todoLang->typeList->{$todo->type})) $todo->type = $todoLang->typeList->{$todo->type}; + if(isset($todoLang->priList[$todo->pri])) $todo->pri = $todoLang->priList[$todo->pri]; + if(isset($todoLang->statusList[$todo->status])) $todo->status = $todoLang->statusList[$todo->status]; + if($todo->private == 1) $todo->desc = $this->lang->todo->thisIsPrivate; + + /* drop some field that is not needed. */ + unset($todo->company); + unset($todo->idvalue); + unset($todo->private); + } + + $this->post->set('fields', $fields); + $this->post->set('rows', $todos); + $this->fetch('file', 'export2' . $this->post->fileType, $_POST); + } + + $this->display(); + } } diff --git a/module/todo/model.php b/module/todo/model.php index 3e789b1b9e..9a9a70e51f 100644 --- a/module/todo/model.php +++ b/module/todo/model.php @@ -159,6 +159,12 @@ class todoModel extends model ->orderBy('date, status, begin') ->beginIF($limit > 0)->limit($limit)->fi() ->query(); + + /* Set session. */ + $sql = explode('WHERE', $this->dao->get()); + $sql = explode('ORDER', $sql[1]); + $this->session->set('todoReportCondition', $sql[0]); + while($todo = $stmt->fetch()) { if($todo->type == 'task') $todo->name = $this->dao->findById($todo->idvalue)->from(TABLE_TASK)->fetch('name'); diff --git a/module/todo/view/export.html.php b/module/todo/view/export.html.php new file mode 100755 index 0000000000..baf4ec75a1 --- /dev/null +++ b/module/todo/view/export.html.php @@ -0,0 +1,13 @@ + + * @package todo + * @version $Id$ + * @link http://www.zentao.net + */ +?> + diff --git a/www/js/my.full.js b/www/js/my.full.js index 0a19758836..67c3171363 100644 --- a/www/js/my.full.js +++ b/www/js/my.full.js @@ -535,6 +535,12 @@ function setProjectListLink() if($('#submenuall').size()) $("#submenuall").colorbox({width:1000, height:600, iframe:true, transition:'elastic', speed:350, scrolling:true}); } +/* Set the colorbox of export. */ +function setExport() +{ + if($('.export').size()) $(".export").colorbox({width:400, height:200, iframe:true, transition:'elastic', speed:350, scrolling:true}); +} + /** * Auto checked the checkbox of a row. * @@ -757,6 +763,7 @@ $(document).ready(function() setSubversionLink(); setProductListLink(); setProjectListLink(); + setExport(); autoCheck(); togglesearch(); saveWindowSize();