T1356: Filter tasks on printout the same as on the tasks list
This commit is contained in:
parent
d9e82e0acd
commit
21d577b712
2 changed files with 17 additions and 47 deletions
|
@ -139,6 +139,7 @@ function rcube_tasklist_ui(settings)
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
if (rcmail.env.action == 'print' && rcmail.task == 'tasks') {
|
if (rcmail.env.action == 'print' && rcmail.task == 'tasks') {
|
||||||
|
filtermask = rcmail.env.filtermask;
|
||||||
data_ready({data: rcmail.env.tasks});
|
data_ready({data: rcmail.env.tasks});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1097,45 +1097,15 @@ class tasklist extends rcube_plugin
|
||||||
*/
|
*/
|
||||||
public function fetch_tasks()
|
public function fetch_tasks()
|
||||||
{
|
{
|
||||||
$f = intval(rcube_utils::get_input_value('filter', rcube_utils::INPUT_GPC));
|
$mask = intval(rcube_utils::get_input_value('filter', rcube_utils::INPUT_GPC));
|
||||||
$search = rcube_utils::get_input_value('q', rcube_utils::INPUT_GPC);
|
$search = rcube_utils::get_input_value('q', rcube_utils::INPUT_GPC);
|
||||||
$lists = rcube_utils::get_input_value('lists', rcube_utils::INPUT_GPC);
|
$lists = rcube_utils::get_input_value('lists', rcube_utils::INPUT_GPC);
|
||||||
$filter = array('mask' => $f, 'search' => $search);
|
$filter = array('mask' => $mask, 'search' => $search);
|
||||||
/*
|
|
||||||
// convert magic date filters into a real date range
|
|
||||||
switch ($f) {
|
|
||||||
case self::FILTER_MASK_TODAY:
|
|
||||||
$today = new DateTime('now', $this->timezone);
|
|
||||||
$filter['from'] = $filter['to'] = $today->format('Y-m-d');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case self::FILTER_MASK_TOMORROW:
|
$data = $this->tasks_data($this->driver->list_tasks($filter, $lists));
|
||||||
$tomorrow = new DateTime('now + 1 day', $this->timezone);
|
|
||||||
$filter['from'] = $filter['to'] = $tomorrow->format('Y-m-d');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case self::FILTER_MASK_OVERDUE:
|
|
||||||
$yesterday = new DateTime('yesterday', $this->timezone);
|
|
||||||
$filter['to'] = $yesterday->format('Y-m-d');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case self::FILTER_MASK_WEEK:
|
|
||||||
$today = new DateTime('now', $this->timezone);
|
|
||||||
$filter['from'] = $today->format('Y-m-d');
|
|
||||||
$weekend = new DateTime('now + 7 days', $this->timezone);
|
|
||||||
$filter['to'] = $weekend->format('Y-m-d');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case self::FILTER_MASK_LATER:
|
|
||||||
$date = new DateTime('now + 8 days', $this->timezone);
|
|
||||||
$filter['from'] = $date->format('Y-m-d');
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$data = $this->tasks_data($this->driver->list_tasks($filter, $lists), $f);
|
|
||||||
$this->rc->output->command('plugin.data_ready', array(
|
$this->rc->output->command('plugin.data_ready', array(
|
||||||
'filter' => $f,
|
'filter' => $mask,
|
||||||
'lists' => $lists,
|
'lists' => $lists,
|
||||||
'search' => $search,
|
'search' => $search,
|
||||||
'data' => $data,
|
'data' => $data,
|
||||||
|
@ -1167,16 +1137,17 @@ class tasklist extends rcube_plugin
|
||||||
*/
|
*/
|
||||||
public function print_tasks_list($attrib)
|
public function print_tasks_list($attrib)
|
||||||
{
|
{
|
||||||
$f = intval(rcube_utils::get_input_value('filter', rcube_utils::INPUT_GPC));
|
$mask = intval(rcube_utils::get_input_value('filter', rcube_utils::INPUT_GPC));
|
||||||
$search = rcube_utils::get_input_value('q', rcube_utils::INPUT_GPC);
|
$search = rcube_utils::get_input_value('q', rcube_utils::INPUT_GPC);
|
||||||
$lists = rcube_utils::get_input_value('lists', rcube_utils::INPUT_GPC);
|
$lists = rcube_utils::get_input_value('lists', rcube_utils::INPUT_GPC);
|
||||||
$filter = array('mask' => $f, 'search' => $search);
|
$filter = array('mask' => $mask, 'search' => $search);
|
||||||
|
|
||||||
$data = $this->tasks_data($this->driver->list_tasks($filter, $lists), $f);
|
$data = $this->tasks_data($this->driver->list_tasks($filter, $lists));
|
||||||
|
|
||||||
// we'll build the tasks table in javascript on page load
|
// we'll build the tasks table in javascript on page load
|
||||||
// where we have sorting methods, etc.
|
// where we have sorting methods, etc.
|
||||||
$this->rc->output->set_env('tasks', $data);
|
$this->rc->output->set_env('tasks', $data);
|
||||||
|
$this->rc->output->set_env('filtermask', $mask);
|
||||||
|
|
||||||
return $this->ui->tasks_resultview($attrib);
|
return $this->ui->tasks_resultview($attrib);
|
||||||
}
|
}
|
||||||
|
@ -1184,7 +1155,7 @@ class tasklist extends rcube_plugin
|
||||||
/**
|
/**
|
||||||
* Prepare and sort the given task records to be sent to the client
|
* Prepare and sort the given task records to be sent to the client
|
||||||
*/
|
*/
|
||||||
private function tasks_data($records, $f)
|
private function tasks_data($records)
|
||||||
{
|
{
|
||||||
$data = $this->task_tree = $this->task_titles = array();
|
$data = $this->task_tree = $this->task_titles = array();
|
||||||
|
|
||||||
|
@ -1195,8 +1166,6 @@ class tasklist extends rcube_plugin
|
||||||
|
|
||||||
$this->encode_task($rec);
|
$this->encode_task($rec);
|
||||||
|
|
||||||
// apply filter; don't trust the driver on this :-)
|
|
||||||
if ((!$f && !$this->driver->is_complete($rec)) || ($rec['mask'] & $f))
|
|
||||||
$data[] = $rec;
|
$data[] = $rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1535,7 +1504,7 @@ class tasklist extends rcube_plugin
|
||||||
|
|
||||||
$updates = $this->driver->list_tasks($filter, $lists);
|
$updates = $this->driver->list_tasks($filter, $lists);
|
||||||
if (!empty($updates)) {
|
if (!empty($updates)) {
|
||||||
$this->rc->output->command('plugin.refresh_tasks', $this->tasks_data($updates, 255), true);
|
$this->rc->output->command('plugin.refresh_tasks', $this->tasks_data($updates), true);
|
||||||
|
|
||||||
// update counts
|
// update counts
|
||||||
$counts = $this->driver->count_tasks($lists);
|
$counts = $this->driver->count_tasks($lists);
|
||||||
|
|
Loading…
Add table
Reference in a new issue