mirror of
https://github.com/Karaka-Management/oms-EventManagement.git
synced 2026-01-29 17:28:41 +00:00
todo implementations
This commit is contained in:
parent
39fadb5ac0
commit
f0953c41b9
|
|
@ -31,18 +31,23 @@
|
|||
"foreignTable": "calendar",
|
||||
"foreignKey": "calendar_id"
|
||||
},
|
||||
"eventmanagement_event_costs": {
|
||||
"name": "eventmanagement_event_costs",
|
||||
"eventmanagement_event_budgetcosts": {
|
||||
"name": "eventmanagement_event_budgetcosts",
|
||||
"type": "INT",
|
||||
"null": false
|
||||
},
|
||||
"eventmanagement_event_budget": {
|
||||
"name": "eventmanagement_event_budget",
|
||||
"eventmanagement_event_budgetearnings": {
|
||||
"name": "eventmanagement_event_budgetearnings",
|
||||
"type": "INT",
|
||||
"null": false
|
||||
},
|
||||
"eventmanagement_event_earnings": {
|
||||
"name": "eventmanagement_event_earnings",
|
||||
"eventmanagement_event_actualcosts": {
|
||||
"name": "eventmanagement_event_actualcosts",
|
||||
"type": "INT",
|
||||
"null": false
|
||||
},
|
||||
"eventmanagement_event_actualearnings": {
|
||||
"name": "eventmanagement_event_actualearnings",
|
||||
"type": "INT",
|
||||
"null": false
|
||||
},
|
||||
|
|
@ -106,6 +111,37 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"eventmanagement_event_accountrel": {
|
||||
"name": "eventmanagement_event_accountrel",
|
||||
"fields": {
|
||||
"eventmanagement_event_accountrel_id": {
|
||||
"name": "eventmanagement_event_accountrel_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"eventmanagement_event_accountrel_event": {
|
||||
"name": "eventmanagement_event_accountrel_event",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "eventmanagement_event",
|
||||
"foreignKey": "eventmanagement_event_id"
|
||||
},
|
||||
"eventmanagement_event_accountrel_type": {
|
||||
"name": "eventmanagement_event_accountrel_type",
|
||||
"type": "INT",
|
||||
"null": false
|
||||
},
|
||||
"eventmanagement_event_accountrel_account": {
|
||||
"name": "eventmanagement_event_accountrel_account",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "account",
|
||||
"foreignKey": "account_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"eventmanagement_task_relation": {
|
||||
"name": "eventmanagement_task_relation",
|
||||
"fields": {
|
||||
|
|
@ -131,5 +167,197 @@
|
|||
"foreignKey": "eventmanagement_event_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"eventmanagement_event_attr_type": {
|
||||
"name": "eventmanagement_event_attr_type",
|
||||
"fields": {
|
||||
"eventmanagement_event_attr_type_id": {
|
||||
"name": "eventmanagement_event_attr_type_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"eventmanagement_event_attr_type_name": {
|
||||
"name": "eventmanagement_event_attr_type_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"eventmanagement_event_attr_type_fields": {
|
||||
"name": "eventmanagement_event_attr_type_fields",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"eventmanagement_event_attr_type_custom": {
|
||||
"name": "eventmanagement_event_attr_type_custom",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"eventmanagement_event_attr_type_required": {
|
||||
"description": "Every event must have this attribute type if set to true.",
|
||||
"name": "eventmanagement_event_attr_type_required",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"eventmanagement_event_attr_type_pattern": {
|
||||
"description": "This is a regex validation pattern.",
|
||||
"name": "eventmanagement_event_attr_type_pattern",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"eventmanagement_event_attr_type_l11n": {
|
||||
"name": "eventmanagement_event_attr_type_l11n",
|
||||
"fields": {
|
||||
"eventmanagement_event_attr_type_l11n_id": {
|
||||
"name": "eventmanagement_event_attr_type_l11n_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"eventmanagement_event_attr_type_l11n_title": {
|
||||
"name": "eventmanagement_event_attr_type_l11n_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false
|
||||
},
|
||||
"eventmanagement_event_attr_type_l11n_type": {
|
||||
"name": "eventmanagement_event_attr_type_l11n_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "eventmanagement_event_attr_type",
|
||||
"foreignKey": "eventmanagement_event_attr_type_id"
|
||||
},
|
||||
"eventmanagement_event_attr_type_l11n_lang": {
|
||||
"name": "eventmanagement_event_attr_type_l11n_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": false,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
}
|
||||
}
|
||||
},
|
||||
"eventmanagement_event_attr_value": {
|
||||
"name": "eventmanagement_event_attr_value",
|
||||
"fields": {
|
||||
"eventmanagement_event_attr_value_id": {
|
||||
"name": "eventmanagement_event_attr_value_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"eventmanagement_event_attr_value_default": {
|
||||
"name": "eventmanagement_event_attr_value_default",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"eventmanagement_event_attr_value_type": {
|
||||
"name": "eventmanagement_event_attr_value_type",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"eventmanagement_event_attr_value_valueStr": {
|
||||
"name": "eventmanagement_event_attr_value_valueStr",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"eventmanagement_event_attr_value_valueInt": {
|
||||
"name": "eventmanagement_event_attr_value_valueInt",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"eventmanagement_event_attr_value_valueDec": {
|
||||
"name": "eventmanagement_event_attr_value_valueDec",
|
||||
"type": "DECIMAL(19,5)",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"eventmanagement_event_attr_value_valueDat": {
|
||||
"name": "eventmanagement_event_attr_value_valueDat",
|
||||
"type": "DATETIME",
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"eventmanagement_event_attr_value_lang": {
|
||||
"name": "eventmanagement_event_attr_value_lang",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "language",
|
||||
"foreignKey": "language_639_1"
|
||||
},
|
||||
"eventmanagement_event_attr_value_country": {
|
||||
"name": "eventmanagement_event_attr_value_country",
|
||||
"type": "VARCHAR(2)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "country",
|
||||
"foreignKey": "country_code2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"eventmanagement_event_attr_default": {
|
||||
"name": "eventmanagement_event_attr_default",
|
||||
"fields": {
|
||||
"eventmanagement_event_attr_default_id": {
|
||||
"name": "eventmanagement_event_attr_default_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"eventmanagement_event_attr_default_type": {
|
||||
"name": "eventmanagement_event_attr_default_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "eventmanagement_event_attr_type",
|
||||
"foreignKey": "eventmanagement_event_attr_type_id"
|
||||
},
|
||||
"eventmanagement_event_attr_default_value": {
|
||||
"name": "eventmanagement_event_attr_default_value",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "eventmanagement_event_attr_value",
|
||||
"foreignKey": "eventmanagement_event_attr_value_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"eventmanagement_event_attr": {
|
||||
"name": "eventmanagement_event_attr",
|
||||
"fields": {
|
||||
"eventmanagement_event_attr_id": {
|
||||
"name": "eventmanagement_event_attr_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"eventmanagement_event_attr_event": {
|
||||
"name": "eventmanagement_event_attr_event",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "eventmanagement_event",
|
||||
"foreignKey": "eventmanagement_event_id"
|
||||
},
|
||||
"eventmanagement_event_attr_type": {
|
||||
"name": "eventmanagement_event_attr_type",
|
||||
"type": "INT(11)",
|
||||
"null": false,
|
||||
"foreignTable": "eventmanagement_event_attr_type",
|
||||
"foreignKey": "eventmanagement_event_attr_type_id"
|
||||
},
|
||||
"eventmanagement_event_attr_value": {
|
||||
"name": "eventmanagement_event_attr_value",
|
||||
"type": "INT(11)",
|
||||
"null": true,
|
||||
"default": null,
|
||||
"foreignTable": "eventmanagement_event_attr_value",
|
||||
"foreignKey": "eventmanagement_event_attr_value_id"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
85
Models/AccountRelation.php
Normal file
85
Models/AccountRelation.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use Modules\Admin\Models\Account;
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
|
||||
/**
|
||||
* Promotion class.
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class AccountRelation
|
||||
{
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Promotion
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $event = 0;
|
||||
|
||||
/**
|
||||
* Account
|
||||
*
|
||||
* @var Account
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public Account $account;
|
||||
|
||||
/**
|
||||
* Account relation type
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $type = AccountRelationType::VISITOR;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name Event name/title
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->account = new NullAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id.
|
||||
*
|
||||
* @return int Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
70
Models/AccountRelationMapper.php
Normal file
70
Models/AccountRelationMapper.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use Modules\Admin\Models\AccountMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Mapper class.
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class AccountRelationMapper 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 = [
|
||||
'marketing_event_accountrel_id' => ['name' => 'marketing_event_accountrel_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'marketing_event_accountrel_event' => ['name' => 'marketing_event_accountrel_event', 'type' => 'int', 'internal' => 'event'],
|
||||
'marketing_event_accountrel_type' => ['name' => 'marketing_event_accountrel_type', 'type' => 'int', 'internal' => 'type'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 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 = [
|
||||
'account' => [
|
||||
'mapper' => AccountMapper::class,
|
||||
'external' => 'marketing_event_accountrel_account',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'marketing_event_accountrel';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'marketing_event_accountrel_id';
|
||||
}
|
||||
32
Models/AccountRelationType.php
Normal file
32
Models/AccountRelationType.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Account relation type enum.
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class AccountRelationType extends Enum
|
||||
{
|
||||
public const VISITOR = 1;
|
||||
|
||||
public const SPEAKER = 2;
|
||||
}
|
||||
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\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Attribute value type enum.
|
||||
*
|
||||
* @package Modules\EventManagement\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;
|
||||
}
|
||||
|
|
@ -94,15 +94,7 @@ class Event
|
|||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public Money $costs;
|
||||
|
||||
/**
|
||||
* Budget.
|
||||
*
|
||||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public Money $budget;
|
||||
public Money $budgetCosts;
|
||||
|
||||
/**
|
||||
* Earnings.
|
||||
|
|
@ -110,7 +102,23 @@ class Event
|
|||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public Money $earnings;
|
||||
public Money $budgetEarnings;
|
||||
|
||||
/**
|
||||
* Costs.
|
||||
*
|
||||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public Money $actualCosts;
|
||||
|
||||
/**
|
||||
* Earnings.
|
||||
*
|
||||
* @var Money
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public Money $actualEarnings;
|
||||
|
||||
/**
|
||||
* Tasks.
|
||||
|
|
@ -160,6 +168,22 @@ class Event
|
|||
*/
|
||||
public Account $createdBy;
|
||||
|
||||
/**
|
||||
* Account relations
|
||||
*
|
||||
* @var AccountRelation[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $accountRelations = [];
|
||||
|
||||
/**
|
||||
* Attributes.
|
||||
*
|
||||
* @var int[]|EventAttribute[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $attributes = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -172,9 +196,10 @@ class Event
|
|||
$this->start = new \DateTime('now');
|
||||
$this->end = (new \DateTime('now'))->modify('+1 month');
|
||||
$this->calendar = new Calendar();
|
||||
$this->costs = new Money();
|
||||
$this->budget = new Money();
|
||||
$this->earnings = new Money();
|
||||
$this->budgetCosts = new Money();
|
||||
$this->budgetEarnings = new Money();
|
||||
$this->actualCosts = new Money();
|
||||
$this->actualEarnings = new Money();
|
||||
$this->createdAt = new \DateTimeImmutable('now');
|
||||
$this->createdBy = new NullAccount();
|
||||
|
||||
|
|
@ -347,6 +372,46 @@ class Event
|
|||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add account relation
|
||||
*
|
||||
* @param AccountRelation $accRel Account relation
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addAccount(AccountRelation $accRel) : void
|
||||
{
|
||||
$this->accountRelations[] = $accRel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attribute to item
|
||||
*
|
||||
* @param EventAttribute $attribute Note
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addAttribute(EventAttribute $attribute) : void
|
||||
{
|
||||
$this->attributes[] = $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attributes
|
||||
*
|
||||
* @return int[]|EventAttribute[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getAttributes() : array
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -360,9 +425,10 @@ class Event
|
|||
'name' => $this->name,
|
||||
'description' => $this->description,
|
||||
'calendar' => $this->calendar,
|
||||
'costs' => $this->costs,
|
||||
'budget' => $this->budget,
|
||||
'earnings' => $this->earnings,
|
||||
'budgetCosts' => $this->budgetCosts,
|
||||
'budgetEarnings' => $this->budgetEarnings,
|
||||
'actualCosts' => $this->actualCosts,
|
||||
'actualEarnings' => $this->actualEarnings,
|
||||
'tasks' => $this->tasks,
|
||||
'media' => $this->media,
|
||||
'progress' => $this->progress,
|
||||
|
|
|
|||
104
Models/EventAttribute.php
Normal file
104
Models/EventAttribute.php
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
|
||||
/**
|
||||
* Event class.
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class EventAttribute implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* Id.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Event this attribute belongs to
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $event = 0;
|
||||
|
||||
/**
|
||||
* Attribute type the attribute belongs to
|
||||
*
|
||||
* @var EventAttributeType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public EventAttributeType $type;
|
||||
|
||||
/**
|
||||
* Attribute value the attribute belongs to
|
||||
*
|
||||
* @var EventAttributeValue
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public EventAttributeValue $value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = new NullEventAttributeType();
|
||||
$this->value = new NullEventAttributeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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/EventAttributeMapper.php
Normal file
74
Models/EventAttributeMapper.php
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Event mapper class.
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class EventAttributeMapper 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 = [
|
||||
'eventmanagement_event_attr_id' => ['name' => 'eventmanagement_event_attr_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'eventmanagement_event_attr_event' => ['name' => 'eventmanagement_event_attr_event', 'type' => 'int', 'internal' => 'event'],
|
||||
'eventmanagement_event_attr_type' => ['name' => 'eventmanagement_event_attr_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'eventmanagement_event_attr_value' => ['name' => 'eventmanagement_event_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' => EventAttributeTypeMapper::class,
|
||||
'external' => 'eventmanagement_event_attr_type',
|
||||
],
|
||||
'value' => [
|
||||
'mapper' => EventAttributeValueMapper::class,
|
||||
'external' => 'eventmanagement_event_attr_value',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'eventmanagement_event_attr';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'eventmanagement_event_attr_id';
|
||||
}
|
||||
172
Models/EventAttributeType.php
Normal file
172
Models/EventAttributeType.php
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Event Attribute Type class.
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class EventAttributeType 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 EventAttributeTypeL11n
|
||||
*/
|
||||
private string | EventAttributeTypeL11n $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|EventAttributeTypeL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | EventAttributeTypeL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($l11n instanceof EventAttributeTypeL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof EventAttributeTypeL11n) {
|
||||
$this->l11n->title = $l11n;
|
||||
} else {
|
||||
$this->l11n = new EventAttributeTypeL11n();
|
||||
$this->l11n->title = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getL11n() : string
|
||||
{
|
||||
return $this->l11n instanceof EventAttributeTypeL11n ? $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/EventAttributeTypeL11n.php
Normal file
136
Models/EventAttributeTypeL11n.php
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Event class.
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class EventAttributeTypeL11n implements \JsonSerializable, ArrayableInterface
|
||||
{
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Event ID.
|
||||
*
|
||||
* @var int|EventAttributeType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int | EventAttributeType $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|EventAttributeType $type Attribute type
|
||||
* @param string $title Localized title
|
||||
* @param string $language Language
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int | EventAttributeType $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/EventAttributeTypeL11nMapper.php
Normal file
57
Models/EventAttributeTypeL11nMapper.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Event mapper class.
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class EventAttributeTypeL11nMapper 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 = [
|
||||
'eventmanagement_event_attr_type_l11n_id' => ['name' => 'eventmanagement_event_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'eventmanagement_event_attr_type_l11n_title' => ['name' => 'eventmanagement_event_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
'eventmanagement_event_attr_type_l11n_type' => ['name' => 'eventmanagement_event_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'eventmanagement_event_attr_type_l11n_lang' => ['name' => 'eventmanagement_event_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'eventmanagement_event_attr_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'eventmanagement_event_attr_type_l11n_id';
|
||||
}
|
||||
83
Models/EventAttributeTypeMapper.php
Normal file
83
Models/EventAttributeTypeMapper.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Event mapper class.
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class EventAttributeTypeMapper 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 = [
|
||||
'eventmanagement_event_attr_type_id' => ['name' => 'eventmanagement_event_attr_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'eventmanagement_event_attr_type_name' => ['name' => 'eventmanagement_event_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||
'eventmanagement_event_attr_type_fields' => ['name' => 'eventmanagement_event_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
|
||||
'eventmanagement_event_attr_type_custom' => ['name' => 'eventmanagement_event_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
|
||||
'eventmanagement_event_attr_type_pattern' => ['name' => 'eventmanagement_event_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'],
|
||||
'eventmanagement_event_attr_type_required' => ['name' => 'eventmanagement_event_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' => EventAttributeTypeL11nMapper::class,
|
||||
'table' => 'eventmanagement_event_attr_type_l11n',
|
||||
'self' => 'eventmanagement_event_attr_type_l11n_type',
|
||||
'column' => 'title',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
'defaults' => [
|
||||
'mapper' => EventAttributeValueMapper::class,
|
||||
'table' => 'eventmanagement_event_attr_default',
|
||||
'self' => 'eventmanagement_event_attr_default_type',
|
||||
'external' => 'eventmanagement_event_attr_default_value',
|
||||
'conditional' => false,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'eventmanagement_event_attr_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'eventmanagement_event_attr_type_id';
|
||||
}
|
||||
255
Models/EventAttributeValue.php
Normal file
255
Models/EventAttributeValue.php
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use phpOMS\Contract\ArrayableInterface;
|
||||
use phpOMS\Localization\ISO3166TwoEnum;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Event attribute value class.
|
||||
*
|
||||
* The relation with the type/item is defined in the EventAttribute class.
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class EventAttributeValue 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/EventAttributeValueMapper.php
Normal file
62
Models/EventAttributeValueMapper.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https: //orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
|
||||
/**
|
||||
* Event mapper class.
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https: //orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class EventAttributeValueMapper 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 = [
|
||||
'eventmanagement_event_attr_value_id' => ['name' => 'eventmanagement_event_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'eventmanagement_event_attr_value_default' => ['name' => 'eventmanagement_event_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
||||
'eventmanagement_event_attr_value_type' => ['name' => 'eventmanagement_event_attr_value_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'eventmanagement_event_attr_value_valueStr' => ['name' => 'eventmanagement_event_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
|
||||
'eventmanagement_event_attr_value_valueInt' => ['name' => 'eventmanagement_event_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
|
||||
'eventmanagement_event_attr_value_valueDec' => ['name' => 'eventmanagement_event_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
|
||||
'eventmanagement_event_attr_value_valueDat' => ['name' => 'eventmanagement_event_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
|
||||
'eventmanagement_event_attr_value_lang' => ['name' => 'eventmanagement_event_attr_value_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
'eventmanagement_event_attr_value_country' => ['name' => 'eventmanagement_event_attr_value_country', 'type' => 'string', 'internal' => 'country'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $table = 'eventmanagement_event_attr_value';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'eventmanagement_event_attr_value_id';
|
||||
}
|
||||
|
|
@ -45,9 +45,10 @@ final class EventMapper extends DataMapperAbstract
|
|||
'eventmanagement_event_end' => ['name' => 'eventmanagement_event_end', 'type' => 'DateTime', 'internal' => 'end'],
|
||||
'eventmanagement_event_progress' => ['name' => 'eventmanagement_event_progress', 'type' => 'int', 'internal' => 'progress'],
|
||||
'eventmanagement_event_progress_type' => ['name' => 'eventmanagement_event_progress_type', 'type' => 'int', 'internal' => 'progressType'],
|
||||
'eventmanagement_event_costs' => ['name' => 'eventmanagement_event_costs', 'type' => 'Serializable', 'internal' => 'costs'],
|
||||
'eventmanagement_event_budget' => ['name' => 'eventmanagement_event_budget', 'type' => 'Serializable', 'internal' => 'budget'],
|
||||
'eventmanagement_event_earnings' => ['name' => 'eventmanagement_event_earnings', 'type' => 'Serializable', 'internal' => 'earnings'],
|
||||
'eventmanagement_event_budgetcosts' => ['name' => 'eventmanagement_event_budgetcosts', 'type' => 'Serializable', 'internal' => 'budgetCosts'],
|
||||
'eventmanagement_event_budgetearnings' => ['name' => 'eventmanagement_event_budgetearnings', 'type' => 'Serializable', 'internal' => 'budgetEarnings'],
|
||||
'eventmanagement_event_actualcosts' => ['name' => 'eventmanagement_event_actualcosts', 'type' => 'Serializable', 'internal' => 'actualCosts'],
|
||||
'eventmanagement_event_actualearnings' => ['name' => 'eventmanagement_event_actualearnings', 'type' => 'Serializable', 'internal' => 'actualEarnings'],
|
||||
'eventmanagement_event_created_by' => ['name' => 'eventmanagement_event_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||
'eventmanagement_event_created_at' => ['name' => 'eventmanagement_event_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
||||
];
|
||||
|
|
@ -71,6 +72,13 @@ final class EventMapper extends DataMapperAbstract
|
|||
'external' => 'eventmanagement_event_media_dst',
|
||||
'self' => 'eventmanagement_event_media_src',
|
||||
],
|
||||
'attributes' => [
|
||||
'mapper' => EventAttributeMapper::class,
|
||||
'table' => 'eventmanagement_event_attr',
|
||||
'self' => 'eventmanagement_event_attr_event',
|
||||
'conditional' => true,
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
39
Models/NullEventAttribute.php
Normal file
39
Models/NullEventAttribute.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullEventAttribute extends EventAttribute
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullEventAttributeType.php
Normal file
38
Models/NullEventAttributeType.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullEventAttributeType extends EventAttributeType
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullEventAttributeTypeL11n.php
Normal file
38
Models/NullEventAttributeTypeL11n.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullEventAttributeTypeL11n extends EventAttributeTypeL11n
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
38
Models/NullEventAttributeValue.php
Normal file
38
Models/NullEventAttributeValue.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://orange-management.org
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\EventManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\EventManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://orange-management.org
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullEventAttributeValue extends EventAttributeValue
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
}
|
||||
|
|
@ -46,9 +46,10 @@ final class EventMapperTest extends \PHPUnit\Framework\TestCase
|
|||
$money = new Money();
|
||||
$money->setString('1.23');
|
||||
|
||||
$event->costs = $money;
|
||||
$event->budget = $money;
|
||||
$event->earnings = $money;
|
||||
$event->budgetCosts = $money;
|
||||
$event->budgetEarnings = $money;
|
||||
$event->actualCosts = $money;
|
||||
$event->actualEarnings = $money;
|
||||
|
||||
$task = new Task();
|
||||
$task->title = 'EventTask 1';
|
||||
|
|
@ -84,9 +85,10 @@ final class EventMapperTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals($event->countTasks(), $eventR->countTasks());
|
||||
self::assertEquals($event->start->format('Y-m-d'), $eventR->start->format('Y-m-d'));
|
||||
self::assertEquals($event->end->format('Y-m-d'), $eventR->end->format('Y-m-d'));
|
||||
self::assertEquals($event->costs->getAmount(), $eventR->costs->getAmount());
|
||||
self::assertEquals($event->budget->getAmount(), $eventR->budget->getAmount());
|
||||
self::assertEquals($event->earnings->getAmount(), $eventR->earnings->getAmount());
|
||||
self::assertEquals($event->budgetCosts->getAmount(), $eventR->budgetCosts->getAmount());
|
||||
self::assertEquals($event->budgetEarnings->getAmount(), $eventR->budgetEarnings->getAmount());
|
||||
self::assertEquals($event->actualCosts->getAmount(), $eventR->actualCosts->getAmount());
|
||||
self::assertEquals($event->actualEarnings->getAmount(), $eventR->actualEarnings->getAmount());
|
||||
self::assertEquals($event->progress, $eventR->progress);
|
||||
self::assertEquals($event->getProgressType(), $eventR->getProgressType());
|
||||
|
||||
|
|
|
|||
|
|
@ -47,9 +47,10 @@ final class EventTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertInstanceOf('\Modules\Calendar\Models\Calendar', $this->event->calendar);
|
||||
self::assertEquals((new \DateTime('now'))->format('Y-m-d'), $this->event->start->format('Y-m-d'));
|
||||
self::assertEquals((new \DateTime('now'))->modify('+1 month')->format('Y-m-d'), $this->event->end->format('Y-m-d'));
|
||||
self::assertEquals(0, $this->event->costs->getInt());
|
||||
self::assertEquals(0, $this->event->budget->getInt());
|
||||
self::assertEquals(0, $this->event->earnings->getInt());
|
||||
self::assertEquals(0, $this->event->budgetCosts->getInt());
|
||||
self::assertEquals(0, $this->event->actualCosts->getInt());
|
||||
self::assertEquals(0, $this->event->budgetEarnings->getInt());
|
||||
self::assertEquals(0, $this->event->actualEarnings->getInt());
|
||||
self::assertFalse($this->event->removeTask(2));
|
||||
self::assertEmpty($this->event->getTasks());
|
||||
self::assertEmpty($this->event->getMedia());
|
||||
|
|
@ -78,45 +79,6 @@ final class EventTest extends \PHPUnit\Framework\TestCase
|
|||
$this->event->setType(999);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\EventManagement\Models\Event
|
||||
* @group module
|
||||
*/
|
||||
public function testCostsInputOutput() : void
|
||||
{
|
||||
$money = new Money();
|
||||
$money->setString('1.23');
|
||||
|
||||
$this->event->costs = $money;
|
||||
self::assertEquals($money->getAmount(), $this->event->costs->getAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\EventManagement\Models\Event
|
||||
* @group module
|
||||
*/
|
||||
public function testBudgetInputOutput() : void
|
||||
{
|
||||
$money = new Money();
|
||||
$money->setString('1.23');
|
||||
|
||||
$this->event->budget = $money;
|
||||
self::assertEquals($money->getAmount(), $this->event->budget->getAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\EventManagement\Models\Event
|
||||
* @group module
|
||||
*/
|
||||
public function testEarningsInputOutput() : void
|
||||
{
|
||||
$money = new Money();
|
||||
$money->setString('1.23');
|
||||
|
||||
$this->event->earnings = $money;
|
||||
self::assertEquals($money->getAmount(), $this->event->earnings->getAmount());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\EventManagement\Models\Event
|
||||
* @group module
|
||||
|
|
@ -192,9 +154,10 @@ final class EventTest extends \PHPUnit\Framework\TestCase
|
|||
'end' => $this->event->end,
|
||||
'name' => 'Name',
|
||||
'description' => 'Description',
|
||||
'costs' => new Money(),
|
||||
'budget' => new Money(),
|
||||
'earnings' => new Money(),
|
||||
'budgetCosts' => new Money(),
|
||||
'budgetEarnings' => new Money(),
|
||||
'actualCosts' => new Money(),
|
||||
'actualEarnings' => new Money(),
|
||||
'tasks' => [],
|
||||
'media' => [],
|
||||
'progress' => 10,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user