phpcs fixes

This commit is contained in:
Dennis Eichhorn 2019-10-06 17:50:12 +02:00
parent f715c7363f
commit dfb15ac655
10 changed files with 548 additions and 41 deletions

View File

@ -19,6 +19,11 @@
"type": "TEXT",
"null": true
},
"projectmanagement_project_description_raw": {
"name": "projectmanagement_project_description_raw",
"type": "TEXT",
"null": true
},
"projectmanagement_project_calendar": {
"name": "projectmanagement_project_calendar",
"type": "INT",

27
Models/NullProject.php Normal file
View File

@ -0,0 +1,27 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @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 NullProject extends Employee
{
}

View File

@ -28,37 +28,133 @@ use phpOMS\Localization\Money;
*/
class Project
{
private $id = 0;
/**
* ID.
*
* @var int
* @since 1.0.0
*/
private int $id = 0;
private $start = null;
/**
* Start date.
*
* @var \DateTime
* @since 1.0.0
*/
private \DateTime $start;
private $end = null;
/**
* End date.
*
* @var \DateTime
* @since 1.0.0
*/
private \DateTime $end;
private $name = '';
/**
* Estimated end date.
*
* @var \DateTime
* @since 1.0.0
*/
private \DateTime $endEstimated;
private $description = '';
/**
* Project name.
*
* @var string
* @since 1.0.0
*/
private string $name = '';
private $calendar = null;
/**
* Project description.
*
* @var string
* @since 1.0.0
*/
private string $description = '';
private $costs = null;
/**
* Project raw description.
*
* @var string
* @since 1.0.0
*/
private string $descriptionRaw = '';
private $budget = null;
/**
* Calendar.
*
* @var Calendar
* @since 1.0.0
*/
private Calendar $calendar;
private $earnings = null;
/**
* Current total costs.
*
* @var Money
* @since 1.0.0
*/
private Money $costs;
private $progress = 0;
/**
* Budget costs.
*
* @var Money
* @since 1.0.0
*/
private Money $budgetCosts;
private $progressType = ProgressType::MANUAL;
/**
* Budget earnings.
*
* @var Money
* @since 1.0.0
*/
private Money $budgetEarnings;
private $media = [];
/**
* Current total earnings.
*
* @var Money
* @since 1.0.0
*/
private Money $earnings;
/**
* Progress percentage.
*
* @var int
* @since 1.0.0
*/
private int $progress = 0;
/**
* Progress calculation.
*
* @var int
* @since 1.0.0
*/
private int $progressType = ProgressType::MANUAL;
/**
* Media files.
*
* @var Media[]
* @since 1.0.0
*/
private array $media = [];
/**
* Created at.
*
* @var null|\DateTime
* @var \DateTime
* @since 1.0.0
*/
private ?\DateTime $createdAt = null;
private \DateTime $createdAt;
/**
* Created by.
@ -68,14 +164,29 @@ class Project
*/
private $createdBy = 0;
/**
* Tasks.
*
* @var Tasks[]
* @since 1.0.0
*/
private $tasks = [];
/**
* Constructor.
*
* @param string $name Name of the project
*
* @since 1.0.0
*/
public function __construct(string $name = '')
{
$this->start = new \DateTime('now');
$this->end = new \DateTime('now');
$this->end->modify('+1 month');
$this->createdAt = new \DateTime('now');
$this->estimatedEnd = clone $this->end;
$this->createdAt = new \DateTime('now');
$this->calendar = new Calendar();
@ -86,21 +197,77 @@ class Project
$this->setName($name);
}
/**
* Get id.
*
* @return int
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;
}
public function getMedia() : array
/**
* Get all media files.
*
* @return Media[]
*
* @since 1.0.0
*/
public function getMedias() : array
{
return $this->media;
}
/**
* Add media
*
* @param int|Media $media Media
*
* @return void
*
* @since 1.0.0
*/
public function addMedia($media) : void
{
$this->media[] = $media;
if ($media->getId() !== 0) {
$this->media[$media->getId()] = $media;
} else {
$this->media[] = $media;
}
}
/**
* Remove media
*
* @param int $id Media id
*
* @return bool
*
* @since 1.0.0
*/
public function removeMedia(int $id) : bool
{
if (isset($this->media[$id])) {
unset($this->media[$id]);
return true;
}
return false;
}
/**
* Add task
*
* @param int|Task $task Task
*
* @return void
*
* @since 1.0.0
*/
public function addTask(Task $task) : void
{
if ($task->getId() !== 0) {
@ -110,6 +277,15 @@ class Project
}
}
/**
* Remove task
*
* @param int $id Task id
*
* @return bool
*
* @since 1.0.0
*/
public function removeTask(int $id) : bool
{
if (isset($this->tasks[$id])) {
@ -121,118 +297,398 @@ class Project
return false;
}
/**
* Get progress
*
* @return int
*
* @since 1.0.0
*/
public function getProgress() : int
{
return $this->progress;
}
/**
* Set progress
*
* @param int $progress Progress
*
* @return void
*
* @since 1.0.0
*/
public function setProgress(int $progress) : void
{
$this->progress = $progress;
}
/**
* Get progress type
*
* @return int
*
* @since 1.0.0
*/
public function getProgressType() : int
{
return $this->progressType;
}
/**
* Set progress type
*
* @param int $type Progress type
*
* @return void
*
* @since 1.0.0
*/
public function setProgressType(int $type) : void
{
$this->progressType = $type;
}
/**
* Get task
*
* @param int $id Task id
*
* @return Task
*
* @since 1.0.0
*/
public function getTask(int $id) : Task
{
return $this->tasks[$id] ?? new Task();
}
/**
* Get media
*
* @param int $id Media id
*
* @return Media
*
* @since 1.0.0
*/
public function getMedia(int $id) : Media
{
return $this->media[$id] ?? new Task();
}
/**
* Get tasks
*
* @return Task[]
*
* @since 1.0.0
*/
public function getTasks() : array
{
return $this->tasks;
}
/**
* Count tasks
*
* @return int
*
* @since 1.0.0
*/
public function countTasks() : int
{
return \count($this->tasks);
}
/**
* Count media
*
* @return int
*
* @since 1.0.0
*/
public function countMedia() : int
{
return \count($this->media);
}
/**
* Get start date
*
* @return \DateTime
*
* @since 1.0.0
*/
public function getStart() : \DateTime
{
return $this->start;
}
/**
* Set start date
*
* @param \DateTime $start Start date
*
* @return void
*
* @since 1.0.0
*/
public function setStart(\DateTime $start) : void
{
$this->start = $start;
}
/**
* Set end date
*
* @param \DateTime $end End date
*
* @return void
*
* @since 1.0.0
*/
public function setEnd(\DateTime $end) : void
{
$this->end = $end;
}
/**
* Get end date
*
* @return \DateTime
*
* @since 1.0.0
*/
public function getEnd() : \DateTime
{
return $this->end;
}
/**
* Set estimated end date
*
* @param \DateTime $end End date
*
* @return void
*
* @since 1.0.0
*/
public function setEstimatedEnd(\DateTime $end) : void
{
$this->end = $end;
}
/**
* Get estimated end date
*
* @return \DateTime
*
* @since 1.0.0
*/
public function getEstimatedEnd() : \DateTime
{
return $this->end;
}
/**
* Get calendar
*
* @return Calendar
*
* @since 1.0.0
*/
public function getCalendar() : Calendar
{
return $this->calendar;
}
/**
* Get name
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/**
* Set name
*
* @param string $name Project name
*
* @return void
*
* @since 1.0.0
*/
public function setName(string $name) : void
{
$this->name = $name;
$this->calendar->setName($name);
}
/**
* Get description
*
* @return string
*
* @since 1.0.0
*/
public function getDescription() : string
{
return $this->description;
}
/**
* Set Description
*
* @param string $description Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescription(string $description) : void
{
$this->description = $description;
}
/**
* Get description
*
* @return string
*
* @since 1.0.0
*/
public function getDescriptionRaw() : string
{
return $this->descriptionRaw;
}
/**
* Set Description
*
* @param string $description Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescriptionRaw(string $description) : void
{
$this->descriptionRaw = $description;
}
/**
* Get costs
*
* @return Money
*
* @sicne 1.0.0
*/
public function getCosts() : Money
{
return $this->costs;
}
public function getBudget() : Money
/**
* Get budget costs
*
* @return Money
*
* @sicne 1.0.0
*/
public function getBudgetCosts() : Money
{
return $this->budget;
return $this->budgetCosts;
}
/**
* Get budget earnings
*
* @return Money
*
* @sicne 1.0.0
*/
public function getBudgetEarnings() : Money
{
return $this->budgetEarnings;
}
/**
* Get earnings
*
* @return Money
*
* @sicne 1.0.0
*/
public function getEarnings() : Money
{
return $this->earnings;
}
/**
* Set costs
*
* @param Money $costs Costs
*
* @return void
*
* @since 1.0.0
*/
public function setCosts(Money $costs) : void
{
$this->costs = $costs;
}
public function setBudget(Money $budget) : void
/**
* Set budget costs
*
* @param Money $budget Budget
*
* @return void
*
* @since 1.0.0
*/
public function setBudgetCosts(Money $budget) : void
{
$this->budget = $budget;
$this->budgetCosts = $budget;
}
/**
* Set budget earnings
*
* @param Money $budget Budget
*
* @return void
*
* @since 1.0.0
*/
public function setBudgetEarnings(Money $budget) : void
{
$this->budgetEarnings = $budget;
}
/**
* Set earnings
*
* @param Money $earnings Earnings
*
* @return void
*
* @since 1.0.0
*/
public function setEarnings(Money $earnings) : void
{
$this->earnings = $earnings;
}
/**
* Get created at
*
* @return \DateTime
*
* @since 1.0.0
@ -243,6 +699,8 @@ class Project
}
/**
* Get created by
*
* @return int
*
* @since 1.0.0
@ -253,7 +711,9 @@ class Project
}
/**
* @param $createdBy Creator
* Set created by
*
* @param int $createdBy Creator
*
* @since 1.0.0
*/

View File

@ -37,19 +37,22 @@ final class ProjectMapper extends DataMapperAbstract
* @since 1.0.0
*/
protected static array $columns = [
'projectmanagement_project_id' => ['name' => 'projectmanagement_project_id', 'type' => 'int', 'internal' => 'id'],
'projectmanagement_project_name' => ['name' => 'projectmanagement_project_name', 'type' => 'string', 'internal' => 'name'],
'projectmanagement_project_description' => ['name' => 'projectmanagement_project_description', 'type' => 'string', 'internal' => 'description'],
'projectmanagement_project_calendar' => ['name' => 'projectmanagement_project_calendar', 'type' => 'int', 'internal' => 'calendar'],
'projectmanagement_project_costs' => ['name' => 'projectmanagement_project_costs', 'type' => 'Serializable', 'internal' => 'costs'],
'projectmanagement_project_budget' => ['name' => 'projectmanagement_project_budget', 'type' => 'Serializable', 'internal' => 'budget'],
'projectmanagement_project_earnings' => ['name' => 'projectmanagement_project_earnings', 'type' => 'Serializable', 'internal' => 'earnings'],
'projectmanagement_project_start' => ['name' => 'projectmanagement_project_start', 'type' => 'DateTime', 'internal' => 'start'],
'projectmanagement_project_end' => ['name' => 'projectmanagement_project_end', 'type' => 'DateTime', 'internal' => 'end'],
'projectmanagement_project_progress' => ['name' => 'projectmanagement_project_progress', 'type' => 'int', 'internal' => 'progress'],
'projectmanagement_project_progress_type' => ['name' => 'projectmanagement_project_progress_type', 'type' => 'int', 'internal' => 'progressType'],
'projectmanagement_project_created_by' => ['name' => 'projectmanagement_project_created_by', 'type' => 'int', 'internal' => 'createdBy'],
'projectmanagement_project_created_at' => ['name' => 'projectmanagement_project_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'],
'projectmanagement_project_id' => ['name' => 'projectmanagement_project_id', 'type' => 'int', 'internal' => 'id'],
'projectmanagement_project_name' => ['name' => 'projectmanagement_project_name', 'type' => 'string', 'internal' => 'name'],
'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_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'],
'projectmanagement_project_progress' => ['name' => 'projectmanagement_project_progress', 'type' => 'int', 'internal' => 'progress'],
'projectmanagement_project_progress_type' => ['name' => 'projectmanagement_project_progress_type', 'type' => 'int', 'internal' => 'progressType'],
'projectmanagement_project_created_by' => ['name' => 'projectmanagement_project_created_by', 'type' => 'int', 'internal' => 'createdBy'],
'projectmanagement_project_created_at' => ['name' => 'projectmanagement_project_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'],
];
/**

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
return ['Navigation' => [
'ProjectManagement' => 'Project Management',
]];

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,5 +10,7 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
$MODLANG[1] = [
];

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
return ['ProjectManagement' => [
'Active' => 'Active',
'Actual' => 'Actual',

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
echo $this->getData('nav')->render(); ?>

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
$footerView = new \phpOMS\Views\PaginationView($this->app, $this->request, $this->response);
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
$project = $this->getData('project');
echo $this->getData('nav')->render(); ?>