mirror of
https://github.com/Karaka-Management/oms-ProjectManagement.git
synced 2026-01-24 13:38:39 +00:00
todo implementations
This commit is contained in:
parent
b9faddf05a
commit
6f976b7a26
|
|
@ -31,8 +31,8 @@
|
|||
"foreignTable": "calendar",
|
||||
"foreignKey": "calendar_id"
|
||||
},
|
||||
"projectmanagement_project_costs": {
|
||||
"name": "projectmanagement_project_costs",
|
||||
"projectmanagement_project_actualcosts": {
|
||||
"name": "projectmanagement_project_actualcosts",
|
||||
"type": "INT",
|
||||
"null": false
|
||||
},
|
||||
|
|
@ -46,8 +46,8 @@
|
|||
"type": "INT",
|
||||
"null": false
|
||||
},
|
||||
"projectmanagement_project_earnings": {
|
||||
"name": "projectmanagement_project_earnings",
|
||||
"projectmanagement_project_actualearnings": {
|
||||
"name": "projectmanagement_project_actualearnings",
|
||||
"type": "INT",
|
||||
"null": false
|
||||
},
|
||||
|
|
@ -141,5 +141,197 @@
|
|||
"foreignKey": "projectmanagement_project_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"projectmanagement_project_attr_type": {
|
||||
"name": "projectmanagement_project_attr_type",
|
||||
"fields": {
|
||||
"projectmanagement_project_attr_type_id": {
|
||||
"name": "projectmanagement_project_attr_type_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"projectmanagement_project_attr_type_name": {
|
||||
"name": "projectmanagement_project_attr_type_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"projectmanagement_project_attr_type_fields": {
|
||||
"name": "projectmanagement_project_attr_type_fields",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"projectmanagement_project_attr_type_custom": {
|
||||
"name": "projectmanagement_project_attr_type_custom",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"projectmanagement_project_attr_type_required": {
|
||||
"description": "Every project must have this attribute type if set to true.",
|
||||
"name": "projectmanagement_project_attr_type_required",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"projectmanagement_project_attr_type_pattern": {
|
||||
"description": "This is a regex validation pattern.",
|
||||
"name": "projectmanagement_project_attr_type_pattern",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"projectmanagement_project_attr_type_l11n": {
|
||||
"name": "projectmanagement_project_attr_type_l11n",
|
||||
"fields": {
|
||||
"projectmanagement_project_attr_type_l11n_id": {
|
||||
"name": "projectmanagement_project_attr_type_l11n_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"projectmanagement_project_attr_type_l11n_title": {
|
||||
"name": "projectmanagement_project_attr_type_l11n_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"projectmanagement_project_attr_type_l11n_type": {
|
||||
"name": "projectmanagement_project_attr_type_l11n_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "projectmanagement_project_attr_type",
|
||||
"foreignKey": "projectmanagement_project_attr_type_id"
|
||||
},
|
||||
"projectmanagement_project_attr_type_l11n_lang": {
|
||||
"name": "projectmanagement_project_attr_type_l11n_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": false,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"projectmanagement_project_attr_value": {
|
||||
"name": "projectmanagement_project_attr_value",
|
||||
"fields": {
|
||||
"projectmanagement_project_attr_value_id": {
|
||||
"name": "projectmanagement_project_attr_value_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"projectmanagement_project_attr_value_default": {
|
||||
"name": "projectmanagement_project_attr_value_default",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"projectmanagement_project_attr_value_type": {
|
||||
"name": "projectmanagement_project_attr_value_type",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"projectmanagement_project_attr_value_valueStr": {
|
||||
"name": "projectmanagement_project_attr_value_valueStr",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"projectmanagement_project_attr_value_valueInt": {
|
||||
"name": "projectmanagement_project_attr_value_valueInt",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"projectmanagement_project_attr_value_valueDec": {
|
||||
"name": "projectmanagement_project_attr_value_valueDec",
|
||||
"type": "DECIMAL(19,5)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"projectmanagement_project_attr_value_valueDat": {
|
||||
"name": "projectmanagement_project_attr_value_valueDat",
|
||||
"type": "DATETIME",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"projectmanagement_project_attr_value_lang": {
|
||||
"name": "projectmanagement_project_attr_value_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
},
|
||||
"projectmanagement_project_attr_value_country": {
|
||||
"name": "projectmanagement_project_attr_value_country",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "country",
|
||||
"foreignKey": "country_code2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"projectmanagement_project_attr_default": {
|
||||
"name": "projectmanagement_project_attr_default",
|
||||
"fields": {
|
||||
"projectmanagement_project_attr_default_id": {
|
||||
"name": "projectmanagement_project_attr_default_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"projectmanagement_project_attr_default_type": {
|
||||
"name": "projectmanagement_project_attr_default_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "projectmanagement_project_attr_type",
|
||||
"foreignKey": "projectmanagement_project_attr_type_id"
|
||||
},
|
||||
"projectmanagement_project_attr_default_value": {
|
||||
"name": "projectmanagement_project_attr_default_value",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "projectmanagement_project_attr_value",
|
||||
"foreignKey": "projectmanagement_project_attr_value_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"projectmanagement_project_attr": {
|
||||
"name": "projectmanagement_project_attr",
|
||||
"fields": {
|
||||
"projectmanagement_project_attr_id": {
|
||||
"name": "projectmanagement_project_attr_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"projectmanagement_project_attr_project": {
|
||||
"name": "projectmanagement_project_attr_project",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "projectmanagement_project",
|
||||
"foreignKey": "projectmanagement_project_id"
|
||||
},
|
||||
"projectmanagement_project_attr_type": {
|
||||
"name": "projectmanagement_project_attr_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "projectmanagement_project_attr_type",
|
||||
"foreignKey": "projectmanagement_project_attr_type_id"
|
||||
},
|
||||
"projectmanagement_project_attr_value": {
|
||||
"name": "projectmanagement_project_attr_value",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "projectmanagement_project_attr_value",
|
||||
"foreignKey": "projectmanagement_project_attr_value_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Models/AttributeValueType.php
Normal file
36
Models/AttributeValueType.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Attribute value type enum.
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class AttributeValueType extends Enum
|
||||
{
|
||||
public const _INT = 1;
|
||||
|
||||
public const _STRING = 2;
|
||||
|
||||
public const _FLOAT = 3;
|
||||
|
||||
public const _DATETIME = 4;
|
||||
}
|
||||
39
Models/NullProjectAttribute.php
Normal file
39
Models/NullProjectAttribute.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullProjectAttribute extends ProjectAttribute
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullProjectAttributeType.php
Normal file
38
Models/NullProjectAttributeType.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullProjectAttributeType extends ProjectAttributeType
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullProjectAttributeTypeL11n.php
Normal file
38
Models/NullProjectAttributeTypeL11n.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullProjectAttributeTypeL11n extends ProjectAttributeTypeL11n
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullProjectAttributeValue.php
Normal file
38
Models/NullProjectAttributeValue.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullProjectAttributeValue extends ProjectAttributeValue
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
|
@ -95,14 +95,6 @@ class Project
|
|||
*/
|
||||
public Calendar $calendar;
|
||||
|
||||
/**
|
||||
* Current total costs.
|
||||
*
|
||||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public Money $costs;
|
||||
|
||||
/**
|
||||
* Budget costs.
|
||||
*
|
||||
|
|
@ -119,13 +111,21 @@ class Project
|
|||
*/
|
||||
public Money $budgetEarnings;
|
||||
|
||||
/**
|
||||
* Current total costs.
|
||||
*
|
||||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public Money $actualCosts;
|
||||
|
||||
/**
|
||||
* Current total earnings.
|
||||
*
|
||||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public Money $earnings;
|
||||
public Money $actualEarnings;
|
||||
|
||||
/**
|
||||
* Progress percentage.
|
||||
|
|
@ -175,6 +175,14 @@ class Project
|
|||
*/
|
||||
private $tasks = [];
|
||||
|
||||
/**
|
||||
* Attributes.
|
||||
*
|
||||
* @var int[]|ProjectAttribute[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $attributes = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -194,10 +202,10 @@ class Project
|
|||
|
||||
$this->calendar = new Calendar();
|
||||
|
||||
$this->costs = new Money();
|
||||
$this->actualCosts = new Money();
|
||||
$this->actualEarnings = new Money();
|
||||
$this->budgetCosts = new Money();
|
||||
$this->budgetEarnings = new Money();
|
||||
$this->earnings = new Money();
|
||||
|
||||
$this->setName($name);
|
||||
}
|
||||
|
|
@ -373,6 +381,32 @@ class Project
|
|||
$this->calendar->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attribute to item
|
||||
*
|
||||
* @param ProjectAttribute $attribute Note
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addAttribute(ProjectAttribute $attribute) : void
|
||||
{
|
||||
$this->attributes[] = $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attributes
|
||||
*
|
||||
* @return int[]|ProjectAttribute[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getAttributes() : array
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -385,10 +419,10 @@ class Project
|
|||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'calendar' => $this->calendar,
|
||||
'costs' => $this->costs,
|
||||
'budgetCosts' => $this->budgetCosts,
|
||||
'budgetEarnings' => $this->budgetEarnings,
|
||||
'earnings' => $this->earnings,
|
||||
'actualCosts' => $this->actualCosts,
|
||||
'actualEarnings' => $this->actualEarnings,
|
||||
'tasks' => $this->tasks,
|
||||
'media' => $this->media,
|
||||
'progress' => $this->progress,
|
||||
|
|
|
|||
104
Models/ProjectAttribute.php
Normal file
104
Models/ProjectAttribute.php
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
|
||||
/**
|
||||
* Project class.
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ProjectAttribute implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* Id.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Project this attribute belongs to
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $project = 0;
|
||||
|
||||
/**
|
||||
* Attribute type the attribute belongs to
|
||||
*
|
||||
* @var ProjectAttributeType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ProjectAttributeType $type;
|
||||
|
||||
/**
|
||||
* Attribute value the attribute belongs to
|
||||
*
|
||||
* @var ProjectAttributeValue
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ProjectAttributeValue $value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = new NullProjectAttributeType();
|
||||
$this->value = new NullProjectAttributeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'item' => $this->item,
|
||||
'type' => $this->type,
|
||||
'value' => $this->value,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
74
Models/ProjectAttributeMapper.php
Normal file
74
Models/ProjectAttributeMapper.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Project mapper class.
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ProjectAttributeMapper extends DataMapperAbstract
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
'projectmanagement_project_attr_id' => ['name' => 'projectmanagement_project_attr_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'projectmanagement_project_attr_project' => ['name' => 'projectmanagement_project_attr_project', 'type' => 'int', 'internal' => 'project'],
|
||||
'projectmanagement_project_attr_type' => ['name' => 'projectmanagement_project_attr_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'projectmanagement_project_attr_value' => ['name' => 'projectmanagement_project_attr_value', 'type' => 'int', 'internal' => 'value'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $ownsOne = [
|
||||
'type' => [
|
||||
'mapper' => ProjectAttributeTypeMapper::class,
|
||||
'external' => 'projectmanagement_project_attr_type',
|
||||
],
|
||||
'value' => [
|
||||
'mapper' => ProjectAttributeValueMapper::class,
|
||||
'external' => 'projectmanagement_project_attr_value',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'projectmanagement_project_attr';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'projectmanagement_project_attr_id';
|
||||
}
|
||||
172
Models/ProjectAttributeType.php
Normal file
172
Models/ProjectAttributeType.php
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Project Attribute Type class.
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ProjectAttributeType implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* Id
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Name/string identifier by which it can be found/categorized
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $name = ''; // @todo: currently not filled, should be used as identifier or if not required removed (at the moment it seems like it is useless?!)
|
||||
|
||||
/**
|
||||
* Which field data type is required (string, int, ...) in the value
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $fields = 0;
|
||||
|
||||
/**
|
||||
* Is a custom value allowed (e.g. custom string)
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public bool $custom = false;
|
||||
|
||||
public string $validationPattern = '';
|
||||
|
||||
public bool $isRequired = false;
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var ProjectAttributeTypeL11n
|
||||
*/
|
||||
private string | ProjectAttributeTypeL11n $l11n;
|
||||
|
||||
/**
|
||||
* Possible default attribute values
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private array $defaults = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name Name/identifier of the attribute type
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(string $name = '')
|
||||
{
|
||||
$this->setL11n($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set l11n
|
||||
*
|
||||
* @param string|ProjectAttributeTypeL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | ProjectAttributeTypeL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($l11n instanceof ProjectAttributeTypeL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof ProjectAttributeTypeL11n) {
|
||||
$this->l11n->title = $l11n;
|
||||
} else {
|
||||
$this->l11n = new ProjectAttributeTypeL11n();
|
||||
$this->l11n->title = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getL11n() : string
|
||||
{
|
||||
return $this->l11n instanceof ProjectAttributeTypeL11n ? $this->l11n->title : $this->l11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fields
|
||||
*
|
||||
* @param int $fields Fields
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setFields(int $fields) : void
|
||||
{
|
||||
$this->fields = $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'validationPattern' => $this->validationPattern,
|
||||
'custom' => $this->custom,
|
||||
'isRequired' => $this->isRequired,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
136
Models/ProjectAttributeTypeL11n.php
Normal file
136
Models/ProjectAttributeTypeL11n.php
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Project class.
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ProjectAttributeTypeL11n implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Project ID.
|
||||
*
|
||||
* @var int|ProjectAttributeType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int | ProjectAttributeType $type = 0;
|
||||
|
||||
/**
|
||||
* Language.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $language = ISO639x1Enum::_EN;
|
||||
|
||||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $title = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int|ProjectAttributeType $type Attribute type
|
||||
* @param string $title Localized title
|
||||
* @param string $language Language
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int | ProjectAttributeType $type = 0, string $title = '', string $language = ISO639x1Enum::_EN)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->title = $title;
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getLanguage() : string
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
*
|
||||
* @param string $language Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setLanguage(string $language) : void
|
||||
{
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'type' => $this->type,
|
||||
'language' => $this->language,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
57
Models/ProjectAttributeTypeL11nMapper.php
Normal file
57
Models/ProjectAttributeTypeL11nMapper.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Project mapper class.
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ProjectAttributeTypeL11nMapper extends DataMapperAbstract
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
'projectmanagement_project_attr_type_l11n_id' => ['name' => 'projectmanagement_project_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'projectmanagement_project_attr_type_l11n_title' => ['name' => 'projectmanagement_project_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
'projectmanagement_project_attr_type_l11n_type' => ['name' => 'projectmanagement_project_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'projectmanagement_project_attr_type_l11n_lang' => ['name' => 'projectmanagement_project_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'projectmanagement_project_attr_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'projectmanagement_project_attr_type_l11n_id';
|
||||
}
|
||||
83
Models/ProjectAttributeTypeMapper.php
Normal file
83
Models/ProjectAttributeTypeMapper.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Project mapper class.
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ProjectAttributeTypeMapper extends DataMapperAbstract
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
'projectmanagement_project_attr_type_id' => ['name' => 'projectmanagement_project_attr_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'projectmanagement_project_attr_type_name' => ['name' => 'projectmanagement_project_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||
'projectmanagement_project_attr_type_fields' => ['name' => 'projectmanagement_project_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
|
||||
'projectmanagement_project_attr_type_custom' => ['name' => 'projectmanagement_project_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
|
||||
'projectmanagement_project_attr_type_pattern' => ['name' => 'projectmanagement_project_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'],
|
||||
'projectmanagement_project_attr_type_required' => ['name' => 'projectmanagement_project_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $hasMany = [
|
||||
'l11n' => [
|
||||
'mapper' => ProjectAttributeTypeL11nMapper::class,
|
||||
'table' => 'projectmanagement_project_attr_type_l11n',
|
||||
'self' => 'projectmanagement_project_attr_type_l11n_type',
|
||||
'column' => 'title',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
'defaults' => [
|
||||
'mapper' => ProjectAttributeValueMapper::class,
|
||||
'table' => 'projectmanagement_project_attr_default',
|
||||
'self' => 'projectmanagement_project_attr_default_type',
|
||||
'external' => 'projectmanagement_project_attr_default_value',
|
||||
'conditional' => false,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'projectmanagement_project_attr_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'projectmanagement_project_attr_type_id';
|
||||
}
|
||||
255
Models/ProjectAttributeValue.php
Normal file
255
Models/ProjectAttributeValue.php
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO3166TwoEnum;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Project attribute value class.
|
||||
*
|
||||
* The relation with the type/item is defined in the ProjectAttribute class.
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ProjectAttributeValue implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* Id
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Type of the attribute
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $type = 0;
|
||||
|
||||
/**
|
||||
* Int value
|
||||
*
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?int $valueInt = null;
|
||||
|
||||
/**
|
||||
* String value
|
||||
*
|
||||
* @var null|string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?string $valueStr = null;
|
||||
|
||||
/**
|
||||
* Decimal value
|
||||
*
|
||||
* @var null|float
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?float $valueDec = null;
|
||||
|
||||
/**
|
||||
* DateTime value
|
||||
*
|
||||
* @var null|\DateTimeInterface
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?\DateTimeInterface $valueDat = null;
|
||||
|
||||
/**
|
||||
* Is a default value which can be selected
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public bool $isDefault = false;
|
||||
|
||||
/**
|
||||
* Language
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $language = ISO639x1Enum::_EN;
|
||||
|
||||
/**
|
||||
* Country
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $country = ISO3166TwoEnum::_USA;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $type Type
|
||||
* @param mixed $value Value
|
||||
* @param string $language Language
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $type = 0, $value = '', string $language = ISO639x1Enum::_EN)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->language = $language;
|
||||
|
||||
$this->setValue($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param int|string|float|\DateTimeInterface $value Value
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setValue(mixed $value) : void
|
||||
{
|
||||
if (\is_string($value)) {
|
||||
$this->valueStr = $value;
|
||||
} elseif (\is_int($value)) {
|
||||
$this->valueInt = $value;
|
||||
} elseif (\is_float($value)) {
|
||||
$this->valueDec = $value;
|
||||
} elseif ($value instanceof \DateTimeInterface) {
|
||||
$this->valueDat = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value
|
||||
*
|
||||
* @return null|int|string|float|\DateTimeInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getValue() : mixed
|
||||
{
|
||||
if (!empty($this->valueStr)) {
|
||||
return $this->valueStr;
|
||||
} elseif (!empty($this->valueInt)) {
|
||||
return $this->valueInt;
|
||||
} elseif (!empty($this->valueDec)) {
|
||||
return $this->valueDec;
|
||||
} elseif ($this->valueDat instanceof \DateTimeInterface) {
|
||||
return $this->valueDat;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
*
|
||||
* @param string $language Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setLanguage(string $language) : void
|
||||
{
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getLanguage() : string
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set country
|
||||
*
|
||||
* @param string $country Country
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setCountry(string $country) : void
|
||||
{
|
||||
$this->country = $country;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get country
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getCountry() : string
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'valueInt' => $this->valueInt,
|
||||
'valueStr' => $this->valueStr,
|
||||
'valueDec' => $this->valueDec,
|
||||
'valueDat' => $this->valueDat,
|
||||
'isDefault' => $this->isDefault,
|
||||
'language' => $this->language,
|
||||
'country' => $this->country,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
62
Models/ProjectAttributeValueMapper.php
Normal file
62
Models/ProjectAttributeValueMapper.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https: //orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ProjectManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Project mapper class.
|
||||
*
|
||||
* @package Modules\ProjectManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https: //orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ProjectAttributeValueMapper extends DataMapperAbstract
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $columns = [
|
||||
'projectmanagement_project_attr_value_id' => ['name' => 'projectmanagement_project_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'projectmanagement_project_attr_value_default' => ['name' => 'projectmanagement_project_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
||||
'projectmanagement_project_attr_value_type' => ['name' => 'projectmanagement_project_attr_value_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'projectmanagement_project_attr_value_valueStr' => ['name' => 'projectmanagement_project_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
|
||||
'projectmanagement_project_attr_value_valueInt' => ['name' => 'projectmanagement_project_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
|
||||
'projectmanagement_project_attr_value_valueDec' => ['name' => 'projectmanagement_project_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
|
||||
'projectmanagement_project_attr_value_valueDat' => ['name' => 'projectmanagement_project_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
|
||||
'projectmanagement_project_attr_value_lang' => ['name' => 'projectmanagement_project_attr_value_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
'projectmanagement_project_attr_value_country' => ['name' => 'projectmanagement_project_attr_value_country', 'type' => 'string', 'internal' => 'country'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'projectmanagement_project_attr_value';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'projectmanagement_project_attr_value_id';
|
||||
}
|
||||
|
|
@ -42,10 +42,10 @@ final class ProjectMapper extends DataMapperAbstract
|
|||
'projectmanagement_project_description' => ['name' => 'projectmanagement_project_description', 'type' => 'string', 'internal' => 'description'],
|
||||
'projectmanagement_project_description_raw' => ['name' => 'projectmanagement_project_description_raw', 'type' => 'string', 'internal' => 'descriptionRaw'],
|
||||
'projectmanagement_project_calendar' => ['name' => 'projectmanagement_project_calendar', 'type' => 'int', 'internal' => 'calendar'],
|
||||
'projectmanagement_project_costs' => ['name' => 'projectmanagement_project_costs', 'type' => 'Serializable', 'internal' => 'costs'],
|
||||
'projectmanagement_project_budgetcosts' => ['name' => 'projectmanagement_project_budgetcosts', 'type' => 'Serializable', 'internal' => 'budgetCosts'],
|
||||
'projectmanagement_project_budgetearnings' => ['name' => 'projectmanagement_project_budgetearnings', 'type' => 'Serializable', 'internal' => 'budgetEarnings'],
|
||||
'projectmanagement_project_earnings' => ['name' => 'projectmanagement_project_earnings', 'type' => 'Serializable', 'internal' => 'earnings'],
|
||||
'projectmanagement_project_actualearnings' => ['name' => 'projectmanagement_project_actualearnings', 'type' => 'Serializable', 'internal' => 'actualEarnings'],
|
||||
'projectmanagement_project_actualcosts' => ['name' => 'projectmanagement_project_actualcosts', 'type' => 'Serializable', 'internal' => 'actualCosts'],
|
||||
'projectmanagement_project_start' => ['name' => 'projectmanagement_project_start', 'type' => 'DateTime', 'internal' => 'start'],
|
||||
'projectmanagement_project_end' => ['name' => 'projectmanagement_project_end', 'type' => 'DateTime', 'internal' => 'end'],
|
||||
'projectmanagement_project_endestimated' => ['name' => 'projectmanagement_project_endestimated', 'type' => 'DateTime', 'internal' => 'endEstimated'],
|
||||
|
|
@ -74,6 +74,13 @@ final class ProjectMapper extends DataMapperAbstract
|
|||
'external' => 'projectmanagement_project_media_dst',
|
||||
'self' => 'projectmanagement_project_media_src',
|
||||
],
|
||||
'attributes' => [
|
||||
'mapper' => ProjectAttributeMapper::class,
|
||||
'table' => 'projectmanagement_project_attr',
|
||||
'self' => 'projectmanagement_project_attr_project',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ final class ProjectMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$money = new Money();
|
||||
$money->setString('1.23');
|
||||
|
||||
$project->costs = $money;
|
||||
$project->budgetCosts = $money;
|
||||
$project->budgetEarnings = $money;
|
||||
$project->earnings = $money;
|
||||
$project->actualCosts = $money;
|
||||
$project->actualEarnings = $money;
|
||||
|
||||
$task = new Task();
|
||||
$task->title = 'ProjectTask 1';
|
||||
|
|
@ -80,10 +80,10 @@ final class ProjectMapperTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
self::assertEquals($project->getName(), $projectR->getName());
|
||||
self::assertEquals($project->description, $projectR->description);
|
||||
self::assertEquals($project->costs->getAmount(), $projectR->costs->getAmount());
|
||||
self::assertEquals($project->budgetEarnings->getAmount(), $projectR->budgetEarnings->getAmount());
|
||||
self::assertEquals($project->budgetCosts->getAmount(), $projectR->budgetCosts->getAmount());
|
||||
self::assertEquals($project->earnings->getAmount(), $projectR->earnings->getAmount());
|
||||
self::assertEquals($project->actualCosts->getAmount(), $projectR->actualCosts->getAmount());
|
||||
self::assertEquals($project->actualEarnings->getAmount(), $projectR->actualEarnings->getAmount());
|
||||
self::assertEquals($project->createdAt->format('Y-m-d'), $projectR->createdAt->format('Y-m-d'));
|
||||
self::assertEquals($project->start->format('Y-m-d'), $projectR->start->format('Y-m-d'));
|
||||
self::assertEquals($project->end->format('Y-m-d'), $projectR->end->format('Y-m-d'));
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ final class ProjectTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(0, $this->project->createdBy->getId());
|
||||
self::assertEquals('', $this->project->getName());
|
||||
self::assertEquals('', $this->project->description);
|
||||
self::assertEquals(0, $this->project->costs->getInt());
|
||||
self::assertEquals(0, $this->project->budgetCosts->getInt());
|
||||
self::assertEquals(0, $this->project->budgetEarnings->getInt());
|
||||
self::assertEquals(0, $this->project->earnings->getInt());
|
||||
self::assertEquals(0, $this->project->actualCosts->getInt());
|
||||
self::assertEquals(0, $this->project->actualEarnings->getInt());
|
||||
self::assertEquals(0, $this->project->progress);
|
||||
self::assertEquals([], $this->project->getMedia());
|
||||
self::assertEquals(ProgressType::MANUAL, $this->project->getProgressType());
|
||||
|
|
@ -179,10 +179,10 @@ final class ProjectTest extends \PHPUnit\Framework\TestCase
|
|||
'end' => $this->project->end,
|
||||
'name' => 'Name',
|
||||
'description' => 'Description',
|
||||
'costs' => new Money(),
|
||||
'budgetCosts' => new Money(),
|
||||
'budgetEarnings' => new Money(),
|
||||
'earnings' => new Money(),
|
||||
'actualCosts' => new Money(),
|
||||
'actualEarnings' => new Money(),
|
||||
'tasks' => [],
|
||||
'media' => [],
|
||||
'progress' => 10,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user