From 78e6472bb750eb0d0bfd8f54758970a56da1d035 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Thu, 13 Dec 2012 06:34:30 +0000 Subject: [PATCH] * finish task #971. --- module/bug/control.php | 4 +++- module/common/lang/en.php | 4 ++++ module/common/lang/zh-cn.php | 4 ++++ module/file/view/export.html.php | 1 + module/story/control.php | 6 ++++-- module/task/control.php | 4 +++- module/testcase/control.php | 9 +++++++-- module/todo/control.php | 6 ++++-- www/js/my.full.js | 24 ++++++++++++++++++++++++ 9 files changed, 54 insertions(+), 8 deletions(-) diff --git a/module/bug/control.php b/module/bug/control.php index 91f21d308d..92f7263d80 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -917,7 +917,9 @@ class bug extends control } /* Get bugs. */ - $bugs = $this->dao->select('*')->from(TABLE_BUG)->where($this->session->bugQueryCondition)->orderBy($orderBy)->fetchAll('id'); + $bugs = $this->dao->select('*')->from(TABLE_BUG)->where($this->session->bugQueryCondition) + ->beginIF($this->post->exportType == 'selected')->andWhere('id')->in($this->cookie->checkedItem)->fi() + ->orderBy($orderBy)->fetchAll('id'); /* Get users, products and projects. */ $users = $this->loadModel('user')->getPairs('noletter'); diff --git a/module/common/lang/en.php b/module/common/lang/en.php index 28093fbced..15f0594f01 100644 --- a/module/common/lang/en.php +++ b/module/common/lang/en.php @@ -35,6 +35,7 @@ $lang->link = 'Link'; $lang->unlink = 'Unlink'; $lang->import = 'Import'; $lang->export = 'Export'; +$lang->exportType = 'Exprot Type'; $lang->setFileName = 'Filename:'; $lang->activate = 'Activate'; $lang->submitting = 'Saving...'; @@ -114,6 +115,9 @@ $lang->exportFileTypeList['csv'] = 'csv'; $lang->exportFileTypeList['xml'] = 'xml'; $lang->exportFileTypeList['html'] = 'html'; +$lang->exportTypeList['all'] = 'Export ALL'; +$lang->exportTypeList['selected'] = 'Export Checked'; + /* Support charset. */ $lang->exportEncodeList['gbk'] = 'GBK'; $lang->exportEncodeList['big5'] = 'BIG5'; diff --git a/module/common/lang/zh-cn.php b/module/common/lang/zh-cn.php index d7e0110d93..9f6dc03edf 100644 --- a/module/common/lang/zh-cn.php +++ b/module/common/lang/zh-cn.php @@ -35,6 +35,7 @@ $lang->link = '关联'; $lang->unlink = '移除'; $lang->import = '导入'; $lang->export = '导出'; +$lang->exportType = '导出类型'; $lang->setFileName = '文件名:'; $lang->activate = '激活'; $lang->submitting = '稍候...'; @@ -114,6 +115,9 @@ $lang->exportFileTypeList['csv'] = 'csv'; $lang->exportFileTypeList['xml'] = 'xml'; $lang->exportFileTypeList['html'] = 'html'; +$lang->exportTypeList['all'] = '导出全部'; +$lang->exportTypeList['selected'] = '导出选中'; + /* 支持的编码格式。*/ $lang->exportEncodeList['gbk'] = 'GBK'; $lang->exportEncodeList['big5'] = 'BIG5'; diff --git a/module/file/view/export.html.php b/module/file/view/export.html.php index f3626de72b..4a07af54b1 100644 --- a/module/file/view/export.html.php +++ b/module/file/view/export.html.php @@ -49,6 +49,7 @@ function switchEncode(fileType) export;?> + ' . $lang->exportType . ':' . html::radio('exportType', $lang->exportTypeList, ($this->cookie->checkedItem) ? 'selected' : 'all') . '

'?> setFileName;?> exportFileTypeList, '', 'onchange=switchEncode(this.value)');?> diff --git a/module/story/control.php b/module/story/control.php index 97a2f69256..a8d2206769 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -866,11 +866,13 @@ class story extends control $stories = array(); if($this->session->storyOnlyCondition == 'true') { - $stories = $this->dao->select('*')->from(TABLE_STORY)->where($this->session->storyQueryCondition)->orderBy($orderBy)->fetchAll('id', false); + $stories = $this->dao->select('*')->from(TABLE_STORY)->where($this->session->storyQueryCondition) + ->beginIF($this->post->exportType == 'selected')->andWhere('id')->in($this->cookie->checkedItem)->fi() + ->orderBy($orderBy)->fetchAll('id', false); } else { - $stmt = $this->dbh->query($this->session->storyQueryCondition . " ORDER BY " . strtr($orderBy, '_', ' ')); + $stmt = $this->dbh->query($this->session->storyQueryCondition . ($this->post->exportType == 'selected' ? " AND id IN({$this->cookie->checkedItem})" : '') . " ORDER BY " . strtr($orderBy, '_', ' ')); while($row = $stmt->fetch()) $stories[$row->id] = $row; } diff --git a/module/task/control.php b/module/task/control.php index d44fe0bf2f..a78f295b65 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -770,7 +770,9 @@ class task extends control } /* Get tasks. */ - $tasks = $this->dao->select('*')->from(TABLE_TASK)->alias('t1')->where($this->session->taskQueryCondition)->orderBy($orderBy)->fetchAll('id'); + $tasks = $this->dao->select('*')->from(TABLE_TASK)->alias('t1')->where($this->session->taskQueryCondition) + ->beginIF($this->post->exportType == 'selected')->andWhere('t1.id')->in($this->cookie->checkedItem)->fi() + ->orderBy($orderBy)->fetchAll('id'); /* Get users and projects. */ $users = $this->loadModel('user')->getPairs('noletter'); diff --git a/module/testcase/control.php b/module/testcase/control.php index d522f0f154..9b3ef91e1e 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -533,11 +533,15 @@ class testcase extends control if($taskID) { $caseIDList = $this->dao->select('`case`')->from(TABLE_TESTRUN)->where('task')->eq($taskID)->fetchPairs(); - $cases = $this->dao->select('*')->from(TABLE_CASE)->where($this->session->testcaseQueryCondition)->andWhere('id')->in($caseIDList)->orderBy($orderBy)->fetchAll('id'); + $cases = $this->dao->select('*')->from(TABLE_CASE)->where($this->session->testcaseQueryCondition)->andWhere('id')->in($caseIDList) + ->beginIF($this->post->exportType == 'selected')->andWhere('id')->in($this->cookie->checkedItem)->fi() + ->orderBy($orderBy)->fetchAll('id'); } else { - $cases = $this->dao->select('*')->from(TABLE_CASE)->where($this->session->testcaseQueryCondition)->orderBy($orderBy)->fetchAll('id'); + $cases = $this->dao->select('*')->from(TABLE_CASE)->where($this->session->testcaseQueryCondition) + ->beginIF($this->post->exportType == 'selected')->andWhere('id')->in($this->cookie->checkedItem)->fi() + ->orderBy($orderBy)->fetchAll('id'); } } else @@ -548,6 +552,7 @@ class testcase extends control while($row = $stmt->fetch()) { $caseID = isset($row->case) ? $row->case : $row->id; + if($this->post->exportType == 'selected' and strpos(",{$this->cookie->checkedItem},", ",$caseID,") === false) continue; $cases[$caseID] = $row; $row->id = $caseID; } diff --git a/module/todo/control.php b/module/todo/control.php index f4baba9a9b..73f2e58d28 100644 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -331,7 +331,9 @@ class todo extends control unset($fields['private']); /* Get bugs. */ - $todos = $this->dao->select('*')->from(TABLE_TODO)->where($this->session->todoReportCondition)->orderBy($orderBy)->fetchAll('id'); + $todos = $this->dao->select('*')->from(TABLE_TODO)->where($this->session->todoReportCondition) + ->beginIF($this->post->exportType == 'selected')->andWhere('id')->in($this->cookie->checkedItem)->fi() + ->orderBy($orderBy)->fetchAll('id'); /* Get users, bugs, tasks and times. */ $users = $this->loadModel('user')->getPairs('noletter'); @@ -347,7 +349,7 @@ class todo extends control if(isset($times[$todo->end])) $todo->end = $times[$todo->end]; if($todo->type == 'bug') $todo->name = isset($bugs[$todo->idvalue]) ? $bugs[$todo->idvalue] : ''; if($todo->type == 'task') $todo->name = isset($tasks[$todo->idvalue]) ? $tasks[$todo->idvalue] : ''; - if(isset($todoLang->typeList->{$todo->type})) $todo->type = $todoLang->typeList->{$todo->type}; + 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; diff --git a/www/js/my.full.js b/www/js/my.full.js index 24e309b82a..d9a2381c94 100644 --- a/www/js/my.full.js +++ b/www/js/my.full.js @@ -796,6 +796,29 @@ function selectItem(SelectID) } } +/** + * Save checked item to cookie when click a object. + * + * @param string $obj + * @access public + * @return void + */ +function getCheckedItem(obj) +{ + $(obj).click(function(){ + var checkeds = ''; + $(':checkbox').each(function(){ + if($(this).attr('checked')) + { + var checkedVal = parseInt($(this).val()); + if(checkedVal != 0) checkeds = checkeds + checkedVal + ','; + } + }) + if(checkeds != '') checkeds = checkeds.substring(0, checkeds.length - 1); + $.cookie('checkedItem', checkeds, {expires:config.cookieLife, path:config.webRoot}); + }) +} + /* Ping the server every some minutes to keep the session. */ needPing = true; @@ -819,6 +842,7 @@ $(document).ready(function() togglesearch(); saveWindowSize(); loadFixedCSS(); + getCheckedItem('.export'); $(window).resize(function(){saveWindowSize()}); // When window resized, call it again. if(needPing) setTimeout('setPing()', 1000 * 60); // After 5 minutes, begin ping. });