added export module (#538)
This commit is contained in:
48
src/Repository/Query/ExportQuery.php
Normal file
48
src/Repository/Query/ExportQuery.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Repository\Query;
|
||||
|
||||
/**
|
||||
* Can be used for export queries.
|
||||
*/
|
||||
class ExportQuery extends TimesheetQuery
|
||||
{
|
||||
public const TYPE_HTML = 'html';
|
||||
public const TYPE_CSV = 'csv';
|
||||
public const TYPE_PDF = 'pdf';
|
||||
public const TYPE_XLSX = 'xlsx';
|
||||
public const TYPE_ODS = 'ods';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return ExportQuery
|
||||
*/
|
||||
public function setType(string $type)
|
||||
{
|
||||
if (in_array($type, [self::TYPE_PDF, self::TYPE_CSV, self::TYPE_HTML, self::TYPE_XLSX, self::TYPE_ODS])) {
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,8 @@ class InvoiceQuery extends TimesheetQuery
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* TODO can this be removed ???
|
||||
*
|
||||
* @var InvoiceTemplate[]
|
||||
*/
|
||||
protected $templates = [];
|
||||
|
||||
@@ -21,6 +21,8 @@ class TimesheetQuery extends ActivityQuery
|
||||
public const STATE_ALL = 1;
|
||||
public const STATE_RUNNING = 2;
|
||||
public const STATE_STOPPED = 3;
|
||||
public const STATE_EXPORTED = 4;
|
||||
public const STATE_NOT_EXPORTED = 5;
|
||||
|
||||
/**
|
||||
* Overwritten for different default order
|
||||
@@ -44,6 +46,10 @@ class TimesheetQuery extends ActivityQuery
|
||||
* @var int
|
||||
*/
|
||||
protected $state = self::STATE_ALL;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $exported = self::STATE_ALL;
|
||||
/**
|
||||
* @var DateRange
|
||||
*/
|
||||
@@ -84,10 +90,10 @@ class TimesheetQuery extends ActivityQuery
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Activity $activity
|
||||
* @param Activity|int $activity
|
||||
* @return TimesheetQuery
|
||||
*/
|
||||
public function setActivity(Activity $activity = null)
|
||||
public function setActivity($activity = null)
|
||||
{
|
||||
$this->activity = $activity;
|
||||
|
||||
@@ -108,7 +114,7 @@ class TimesheetQuery extends ActivityQuery
|
||||
*/
|
||||
public function setState($state)
|
||||
{
|
||||
if (!is_int($state) && $state != (int) $state) {
|
||||
if (!is_int($state) && $state !== (int) $state) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -120,6 +126,32 @@ class TimesheetQuery extends ActivityQuery
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getExported()
|
||||
{
|
||||
return $this->exported;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $exported
|
||||
* @return TimesheetQuery
|
||||
*/
|
||||
public function setExported($exported)
|
||||
{
|
||||
if (!is_int($exported) && $exported !== (int) $exported) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$exported = (int) $exported;
|
||||
if (in_array($exported, [self::STATE_ALL, self::STATE_EXPORTED, self::STATE_NOT_EXPORTED], true)) {
|
||||
$this->exported = $exported;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user