Add search within a range of dates for completion and modification
This commit is contained in:
@@ -42,10 +42,10 @@ abstract class BaseDateRangeFilter extends BaseFilter
|
||||
protected function applyDateFilter($field)
|
||||
{
|
||||
$dates = explode('..', $this->value);
|
||||
|
||||
if(count($dates)=== 2){
|
||||
$timestampFrom = $this->dateParser->getTimestamp($dates[0]);
|
||||
$timestampTo = $this->dateParser->getTimestamp($dates[1]);
|
||||
|
||||
if(count($dates)=== 2){
|
||||
$timestampFrom = $this->dateParser->getTimestamp($dates[0]." 00:00");
|
||||
$timestampTo = $this->dateParser->getTimestamp($dates[1]." 00:00");
|
||||
|
||||
$this->query->gte($field, $timestampFrom);
|
||||
$this->query->lte($field, $timestampTo + 86399);
|
||||
|
||||
38
app/Filter/TaskCompletionDateRangeFilter.php
Normal file
38
app/Filter/TaskCompletionDateRangeFilter.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Filter;
|
||||
|
||||
use Kanboard\Core\Filter\FilterInterface;
|
||||
use Kanboard\Model\TaskModel;
|
||||
|
||||
/**
|
||||
* Filter tasks by completion date
|
||||
*
|
||||
* @package filter
|
||||
* @author Kamil Ściana
|
||||
*/
|
||||
class TaskCompletionDateRangeFilter extends BaseDateRangeFilter implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* Get search attribute
|
||||
*
|
||||
* @access public
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return array('completedRange');
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply filter
|
||||
*
|
||||
* @access public
|
||||
* @return FilterInterface
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$this->applyDateFilter(TaskModel::TABLE.'.date_completed');
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
38
app/Filter/TaskModificationDateRangeFilter.php
Normal file
38
app/Filter/TaskModificationDateRangeFilter.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Filter;
|
||||
|
||||
use Kanboard\Core\Filter\FilterInterface;
|
||||
use Kanboard\Model\TaskModel;
|
||||
|
||||
/**
|
||||
* Filter tasks by modification date
|
||||
*
|
||||
* @package filter
|
||||
* @author Kamil Ściana
|
||||
*/
|
||||
class TaskModificationDateRangeFilter extends BaseDateRangeFilter implements FilterInterface
|
||||
{
|
||||
/**
|
||||
* Get search attribute
|
||||
*
|
||||
* @access public
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return array('updatedRange', 'modifiedRange');
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply filter
|
||||
*
|
||||
* @access public
|
||||
* @return FilterInterface
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$this->applyDateFilter(TaskModel::TABLE.'.date_modification');
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user