remove some getter/setter

This commit is contained in:
Dennis Eichhorn 2020-11-24 17:31:20 +01:00
parent d50116d884
commit 447b702672
28 changed files with 302 additions and 711 deletions

View File

@ -51,7 +51,7 @@ final class Installer extends InstallerAbstract
private static function installDefaultUnit() : void private static function installDefaultUnit() : void
{ {
$unit = new Unit(); $unit = new Unit();
$unit->setName('Orange Management'); $unit->name = 'Orange Management';
UnitMapper::create($unit); UnitMapper::create($unit);
} }

View File

@ -111,7 +111,7 @@ final class ApiController extends Controller
/** @var Unit $old */ /** @var Unit $old */
$old = clone UnitMapper::get((int) $request->getData('id')); $old = clone UnitMapper::get((int) $request->getData('id'));
$new = $this->updateUnitFromRequest($request); $new = $this->updateUnitFromRequest($request);
$this->updateModel($request->getHeader()->getAccount(), $old, $new, UnitMapper::class, 'unit', $request->getOrigin()); $this->updateModel($request->header->account, $old, $new, UnitMapper::class, 'unit', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully updated.', $new); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully updated.', $new);
} }
@ -128,12 +128,12 @@ final class ApiController extends Controller
{ {
/** @var Unit $unit */ /** @var Unit $unit */
$unit = UnitMapper::get((int) $request->getData('id')); $unit = UnitMapper::get((int) $request->getData('id'));
$unit->setName((string) ($request->getData('name') ?? $unit->getName())); $unit->name = (string) ($request->getData('name') ?? $unit->name);
$unit->setDescriptionRaw((string) ($request->getData('description') ?? $unit->getDescriptionRaw())); $unit->descriptionRaw = (string) ($request->getData('description') ?? $unit->descriptionRaw);
$unit->setDescription(Markdown::parse((string) ($request->getData('description') ?? $unit->getDescriptionRaw()))); $unit->description = Markdown::parse((string) ($request->getData('description') ?? $unit->descriptionRaw));
$parent = (int) $request->getData('parent'); $parent = (int) $request->getData('parent');
$unit->setParent(!empty($parent) ? new NullUnit($parent) : $unit->getParent()); $unit->parent = !empty($parent) ? new NullUnit($parent) : $unit->parent;
$unit->setStatus((int) ($request->getData('status') ?? $unit->getStatus())); $unit->setStatus((int) ($request->getData('status') ?? $unit->getStatus()));
return $unit; return $unit;
@ -156,7 +156,7 @@ final class ApiController extends Controller
{ {
/** @var Unit $unit */ /** @var Unit $unit */
$unit = UnitMapper::get((int) $request->getData('id')); $unit = UnitMapper::get((int) $request->getData('id'));
$this->deleteModel($request->getHeader()->getAccount(), $unit, UnitMapper::class, 'unit', $request->getOrigin()); $this->deleteModel($request->header->account, $unit, UnitMapper::class, 'unit', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully deleted.', $unit); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully deleted.', $unit);
} }
@ -177,17 +177,17 @@ final class ApiController extends Controller
{ {
if (!empty($val = $this->validateUnitCreate($request))) { if (!empty($val = $this->validateUnitCreate($request))) {
$response->set('unit_create', new FormValidation($val)); $response->set('unit_create', new FormValidation($val));
$response->getHeader()->setStatusCode(RequestStatusCode::R_400); $response->header->status = RequestStatusCode::R_400;
return; return;
} }
$unit = $this->createUnitFromRequest($request); $unit = $this->createUnitFromRequest($request);
$this->createModel($request->getHeader()->getAccount(), $unit, UnitMapper::class, 'unit', $request->getOrigin()); $this->createModel($request->header->account, $unit, UnitMapper::class, 'unit', $request->getOrigin());
if ($this->app->appSettings->get(null, SettingsEnum::GROUP_GENERATE_AUTOMATICALLY_UNIT)['content'] === '1') { if ($this->app->appSettings->get(null, SettingsEnum::GROUP_GENERATE_AUTOMATICALLY_UNIT)['content'] === '1') {
$newRequest = new HttpRequest(); $newRequest = new HttpRequest();
$newRequest->setData('name', 'org:unit:' . \strtolower($unit->getName())); $newRequest->setData('name', 'org:unit:' . \strtolower($unit->name));
$newRequest->setData('status', GroupStatus::ACTIVE); $newRequest->setData('status', GroupStatus::ACTIVE);
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data); $this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data);
} }
@ -207,12 +207,12 @@ final class ApiController extends Controller
private function createUnitFromRequest(RequestAbstract $request) : Unit private function createUnitFromRequest(RequestAbstract $request) : Unit
{ {
$unit = new Unit(); $unit = new Unit();
$unit->setName((string) $request->getData('name')); $unit->name = (string) $request->getData('name');
$unit->setDescriptionRaw((string) ($request->getData('description') ?? '')); $unit->descriptionRaw = (string) ($request->getData('description') ?? '');
$unit->setDescription(Markdown::parse((string) ($request->getData('description') ?? ''))); $unit->description = Markdown::parse((string) ($request->getData('description') ?? ''));
$parent = (int) $request->getData('parent'); $parent = (int) $request->getData('parent');
$unit->setParent(!empty($parent) ? new NullUnit($parent) : null); $unit->parent = new NullUnit($parent);
$unit->setStatus((int) $request->getData('status')); $unit->setStatus((int) $request->getData('status'));
return $unit; return $unit;
@ -236,7 +236,7 @@ final class ApiController extends Controller
$uploadedFiles = $request->getFiles() ?? []; $uploadedFiles = $request->getFiles() ?? [];
if (empty($uploadedFiles)) { if (empty($uploadedFiles)) {
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Unit', 'Invalid unit image', $uploadedFiles); $this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Unit', 'Invalid unit image', $uploadedFiles);
$response->getHeader()->setStatusCode(RequestStatusCode::R_400); $response->header->status = RequestStatusCode::R_400;
return; return;
} }
@ -248,14 +248,14 @@ final class ApiController extends Controller
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles( $uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
$request->getData('name') ?? '', $request->getData('name') ?? '',
$uploadedFiles, $uploadedFiles,
$request->getHeader()->getAccount(), $request->header->account,
'Modules/Media/Files', 'Modules/Media/Files',
'/Modules/Organization' '/Modules/Organization'
); );
$unit->setImage(\reset($uploaded)); $unit->image = \reset($uploaded);
$this->updateModel($request->getHeader()->getAccount(), $old, $unit, UnitMapper::class, 'unit', $request->getOrigin()); $this->updateModel($request->header->account, $old, $unit, UnitMapper::class, 'unit', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit image successfully updated', $unit); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit image successfully updated', $unit);
} }
@ -324,7 +324,7 @@ final class ApiController extends Controller
{ {
/** @var Position $position */ /** @var Position $position */
$position = PositionMapper::get((int) $request->getData('id')); $position = PositionMapper::get((int) $request->getData('id'));
$this->deleteModel($request->getHeader()->getAccount(), $position, PositionMapper::class, 'position', $request->getOrigin()); $this->deleteModel($request->header->account, $position, PositionMapper::class, 'position', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Position', 'Position successfully deleted.', $position); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Position', 'Position successfully deleted.', $position);
} }
@ -346,7 +346,7 @@ final class ApiController extends Controller
/** @var Position $old */ /** @var Position $old */
$old = clone PositionMapper::get((int) $request->getData('id')); $old = clone PositionMapper::get((int) $request->getData('id'));
$new = $this->updatePositionFromRequest($request); $new = $this->updatePositionFromRequest($request);
$this->updateModel($request->getHeader()->getAccount(), $old, $new, PositionMapper::class, 'position', $request->getOrigin()); $this->updateModel($request->header->account, $old, $new, PositionMapper::class, 'position', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Position', 'Position successfully updated.', $new); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Position', 'Position successfully updated.', $new);
} }
@ -363,15 +363,15 @@ final class ApiController extends Controller
{ {
/** @var Position $position */ /** @var Position $position */
$position = PositionMapper::get((int) $request->getData('id')); $position = PositionMapper::get((int) $request->getData('id'));
$position->setName((string) ($request->getData('name') ?? $position->getName())); $position->name = (string) ($request->getData('name') ?? $position->name);
$position->setDescriptionRaw((string) ($request->getData('description') ?? $position->getDescriptionRaw())); $position->descriptionRaw = (string) ($request->getData('description') ?? $position->descriptionRaw);
$position->setDescription(Markdown::parse((string) ($request->getData('description') ?? $position->getDescriptionRaw()))); $position->description = Markdown::parse((string) ($request->getData('description') ?? $position->descriptionRaw));
$parent = (int) $request->getData('parent'); $parent = (int) $request->getData('parent');
$position->setParent(!empty($parent) ? new NullPosition($parent) : $position->getParent()); $position->parent = !empty($parent) ? new NullPosition($parent) : $position->parent;
$department = (int) $request->getData('department'); $department = (int) $request->getData('department');
$position->setDepartment(!empty($department) ? new NullDepartment($department) : $position->getDepartment()); $position->department = !empty($department) ? new NullDepartment($department) : $position->department;
$position->setStatus((int) ($request->getData('status') ?? $position->getStatus())); $position->setStatus((int) ($request->getData('status') ?? $position->getStatus()));
return $position; return $position;
@ -394,17 +394,17 @@ final class ApiController extends Controller
{ {
if (!empty($val = $this->validatePositionCreate($request))) { if (!empty($val = $this->validatePositionCreate($request))) {
$response->set('position_create', new FormValidation($val)); $response->set('position_create', new FormValidation($val));
$response->getHeader()->setStatusCode(RequestStatusCode::R_400); $response->header->status = RequestStatusCode::R_400;
return; return;
} }
$position = $this->createPositionFromRequest($request); $position = $this->createPositionFromRequest($request);
$this->createModel($request->getHeader()->getAccount(), $position, PositionMapper::class, 'position', $request->getOrigin()); $this->createModel($request->header->account, $position, PositionMapper::class, 'position', $request->getOrigin());
if ($this->app->appSettings->get(null, SettingsEnum::GROUP_GENERATE_AUTOMATICALLY_POSITION)['content'] === '1') { if ($this->app->appSettings->get(null, SettingsEnum::GROUP_GENERATE_AUTOMATICALLY_POSITION)['content'] === '1') {
$newRequest = new HttpRequest(); $newRequest = new HttpRequest();
$newRequest->setData('name', 'org:pos:' . \strtolower($position->getName())); $newRequest->setData('name', 'org:pos:' . \strtolower($position->name));
$newRequest->setData('status', GroupStatus::ACTIVE); $newRequest->setData('status', GroupStatus::ACTIVE);
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data); $this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data);
} }
@ -424,16 +424,16 @@ final class ApiController extends Controller
private function createPositionFromRequest(RequestAbstract $request) : Position private function createPositionFromRequest(RequestAbstract $request) : Position
{ {
$position = new Position(); $position = new Position();
$position->setName((string) ($request->getData('name'))); $position->name = (string) ($request->getData('name'));
$position->setStatus((int) $request->getData('status')); $position->setStatus((int) $request->getData('status'));
$position->setDescriptionRaw((string) ($request->getData('description') ?? '')); $position->descriptionRaw = (string) ($request->getData('description') ?? '');
$position->setDescription(Markdown::parse((string) ($request->getData('description') ?? ''))); $position->description = Markdown::parse((string) ($request->getData('description') ?? ''));
$parent = (int) $request->getData('parent'); $parent = (int) $request->getData('parent');
$position->setParent(!empty($parent) ? new NullPosition($parent) : null); $position->parent = new NullPosition($parent);
$department = (int) $request->getData('department'); $department = (int) $request->getData('department');
$position->setDepartment(!empty($department) ? new NullDepartment($department) : null); $position->department = new NullDepartment($department);
return $position; return $position;
} }
@ -503,7 +503,7 @@ final class ApiController extends Controller
/** @var Department $old */ /** @var Department $old */
$old = clone DepartmentMapper::get((int) $request->getData('id')); $old = clone DepartmentMapper::get((int) $request->getData('id'));
$new = $this->updateDepartmentFromRequest($request); $new = $this->updateDepartmentFromRequest($request);
$this->updateModel($request->getHeader()->getAccount(), $old, $new, DepartmentMapper::class, 'department', $request->getOrigin()); $this->updateModel($request->header->account, $old, $new, DepartmentMapper::class, 'department', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Department', 'Department successfully updated.', $new); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Department', 'Department successfully updated.', $new);
} }
@ -520,16 +520,16 @@ final class ApiController extends Controller
{ {
/** @var Department $department */ /** @var Department $department */
$department = DepartmentMapper::get((int) $request->getData('id')); $department = DepartmentMapper::get((int) $request->getData('id'));
$department->setName((string) ($request->getData('name') ?? $department->getName())); $department->name = (string) ($request->getData('name') ?? $department->name);
$department->setDescriptionRaw((string) ($request->getData('description') ?? $department->getDescriptionRaw())); $department->descriptionRaw = (string) ($request->getData('description') ?? $department->descriptionRaw);
$department->setDescription(Markdown::parse((string) ($request->getData('description') ?? $department->getDescriptionRaw()))); $department->description = Markdown::parse((string) ($request->getData('description') ?? $department->descriptionRaw));
$parent = (int) $request->getData('parent'); $parent = (int) $request->getData('parent');
$department->setParent(!empty($parent) ? new NullDepartment($parent) : $department->getParent()); $department->parent = !empty($parent) ? new NullDepartment($parent) : $department->parent;
$department->setStatus((int) ($request->getData('status') ?? $department->getStatus())); $department->setStatus((int) ($request->getData('status') ?? $department->getStatus()));
$unit = (int) $request->getData('unit'); $unit = (int) $request->getData('unit');
$department->setUnit(!empty($unit) ? new NullUnit($unit) : $department->getUnit()); $department->unit = !empty($unit) ? new NullUnit($unit) : $department->unit;
return $department; return $department;
} }
@ -551,7 +551,7 @@ final class ApiController extends Controller
{ {
/** @var Department $department */ /** @var Department $department */
$department = DepartmentMapper::get((int) $request->getData('id')); $department = DepartmentMapper::get((int) $request->getData('id'));
$this->deleteModel($request->getHeader()->getAccount(), $department, DepartmentMapper::class, 'department', $request->getOrigin()); $this->deleteModel($request->header->account, $department, DepartmentMapper::class, 'department', $request->getOrigin());
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Department', 'Department successfully deleted.', $department); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Department', 'Department successfully deleted.', $department);
} }
@ -572,17 +572,17 @@ final class ApiController extends Controller
{ {
if (!empty($val = $this->validateDepartmentCreate($request))) { if (!empty($val = $this->validateDepartmentCreate($request))) {
$response->set('department_create', new FormValidation($val)); $response->set('department_create', new FormValidation($val));
$response->getHeader()->setStatusCode(RequestStatusCode::R_400); $response->header->status = RequestStatusCode::R_400;
return; return;
} }
$department = $this->createDepartmentFromRequest($request); $department = $this->createDepartmentFromRequest($request);
$this->createModel($request->getHeader()->getAccount(), $department, DepartmentMapper::class, 'department', $request->getOrigin()); $this->createModel($request->header->account, $department, DepartmentMapper::class, 'department', $request->getOrigin());
if ($this->app->appSettings->get(null, SettingsEnum::GROUP_GENERATE_AUTOMATICALLY_DEPARTMENT)['content'] === '1') { if ($this->app->appSettings->get(null, SettingsEnum::GROUP_GENERATE_AUTOMATICALLY_DEPARTMENT)['content'] === '1') {
$newRequest = new HttpRequest(); $newRequest = new HttpRequest();
$newRequest->setData('name', 'org:dep:' . \strtolower($department->getName())); $newRequest->setData('name', 'org:dep:' . \strtolower($department->name));
$newRequest->setData('status', GroupStatus::ACTIVE); $newRequest->setData('status', GroupStatus::ACTIVE);
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data); $this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data);
} }
@ -602,14 +602,14 @@ final class ApiController extends Controller
private function createDepartmentFromRequest(RequestAbstract $request) : Department private function createDepartmentFromRequest(RequestAbstract $request) : Department
{ {
$department = new Department(); $department = new Department();
$department->setName((string) $request->getData('name')); $department->name = (string) $request->getData('name');
$department->setStatus((int) $request->getData('status')); $department->setStatus((int) $request->getData('status'));
$parent = (int) $request->getData('parent'); $parent = (int) $request->getData('parent');
$department->setParent(!empty($parent) ? new NullDepartment($parent) : null); $department->parent = new NullDepartment($parent);
$department->setUnit(new NullUnit((int) ($request->getData('unit') ?? 1))); $department->unit = new NullUnit((int) ($request->getData('unit') ?? 1));
$department->setDescriptionRaw((string) ($request->getData('description') ?? '')); $department->descriptionRaw = (string) ($request->getData('description') ?? '');
$department->setDescription(Markdown::parse((string) ($request->getData('description') ?? ''))); $department->description = Markdown::parse((string) ($request->getData('description') ?? ''));
return $department; return $department;
} }
@ -629,9 +629,9 @@ final class ApiController extends Controller
*/ */
public function apiUnitFind(RequestAbstract $request, ResponseAbstract $response, $data = null) : void public function apiUnitFind(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{ {
$response->getHeader()->set('Content-Type', MimeType::M_JSON, true); $response->header->set('Content-Type', MimeType::M_JSON, true);
$response->set( $response->set(
$request->getUri()->__toString(), $request->uri->__toString(),
\array_values( \array_values(
UnitMapper::find((string) ($request->getData('search') ?? '')) UnitMapper::find((string) ($request->getData('search') ?? ''))
) )
@ -653,9 +653,9 @@ final class ApiController extends Controller
*/ */
public function apiDepartmentFind(RequestAbstract $request, ResponseAbstract $response, $data = null) : void public function apiDepartmentFind(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{ {
$response->getHeader()->set('Content-Type', MimeType::M_JSON, true); $response->header->set('Content-Type', MimeType::M_JSON, true);
$response->set( $response->set(
$request->getUri()->__toString(), $request->uri->__toString(),
\array_values( \array_values(
DepartmentMapper::find((string) ($request->getData('search') ?? '')) DepartmentMapper::find((string) ($request->getData('search') ?? ''))
) )
@ -677,9 +677,9 @@ final class ApiController extends Controller
*/ */
public function apiPositionFind(RequestAbstract $request, ResponseAbstract $response, $data = null) : void public function apiPositionFind(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{ {
$response->getHeader()->set('Content-Type', MimeType::M_JSON, true); $response->header->set('Content-Type', MimeType::M_JSON, true);
$response->set( $response->set(
$request->getUri()->__toString(), $request->uri->__toString(),
\array_values( \array_values(
PositionMapper::find((string) ($request->getData('search') ?? '')) PositionMapper::find((string) ($request->getData('search') ?? ''))
) )

View File

@ -151,9 +151,9 @@ final class BackendController extends Controller
foreach ($components as $component) { foreach ($components as $component) {
$ref = null; $ref = null;
if ($component instanceof Department) { if ($component instanceof Department) {
$ref = $component->getUnit()->getId(); $ref = $component->unit->getId();
} elseif ($component instanceof Position) { } elseif ($component instanceof Position) {
$ref = $component->getDepartment()->getId(); $ref = $component->department->getId();
} }
if (!isset($tree[$ref])) { if (!isset($tree[$ref])) {
@ -166,9 +166,9 @@ final class BackendController extends Controller
$tree[$ref][$component->getId()]['obj'] = $component; $tree[$ref][$component->getId()]['obj'] = $component;
$parent = $component->getParent()->getId(); $parent = $component->parent->getId();
if (!($component instanceof Position) // parent could be in different department then ignore if (!($component instanceof Position) // parent could be in different department then ignore
|| $component->getParent()->getDepartment()->getId() === $component->getDepartment()->getId() || $component->parent->department->getId() === $component->department->getId()
) { ) {
if (!isset($tree[$ref][$parent])) { if (!isset($tree[$ref][$parent])) {
$tree[$ref][$parent] = ['obj' => null, 'children' => [], 'index' => 0]; $tree[$ref][$parent] = ['obj' => null, 'children' => [], 'index' => 0];

View File

@ -40,15 +40,15 @@ class Department implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $name = ''; public string $name = '';
/** /**
* Parent * Parent
* *
* @var null|self * @var self
* @since 1.0.0 * @since 1.0.0
*/ */
protected ?self $parent = null; public self $parent;
/** /**
* Status * Status
@ -64,7 +64,7 @@ class Department implements \JsonSerializable, ArrayableInterface
* @var Unit * @var Unit
* @since 1.0.0 * @since 1.0.0
*/ */
protected Unit $unit; public Unit $unit;
/** /**
* Description. * Description.
@ -72,7 +72,7 @@ class Department implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $description = ''; public string $description = '';
/** /**
* Description. * Description.
@ -80,7 +80,7 @@ class Department implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $descriptionRaw = ''; public string $descriptionRaw = '';
/** /**
* Constructor * Constructor
@ -91,7 +91,9 @@ class Department implements \JsonSerializable, ArrayableInterface
*/ */
public function __construct(string $name = '') public function __construct(string $name = '')
{ {
$this->setName($name); $this->name = $name;
$this->parent = new NullDepartment();
$this->unit = new NullUnit();
} }
/** /**
@ -106,58 +108,6 @@ class Department implements \JsonSerializable, ArrayableInterface
return $this->id; return $this->id;
} }
/**
* Get name
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/**
* Set name
*
* @param string $name Name
*
* @return void
*
* @since 1.0.0
*/
public function setName(string $name) : void
{
$this->name = $name;
}
/**
* Get parent
*
* @return Department
*
* @since 1.0.0
*/
public function getParent() : self
{
return $this->parent ?? new NullDepartment();
}
/**
* Set parent
*
* @param null|self $parent Parent
*
* @return void
*
* @since 1.0.0
*/
public function setParent(?self $parent) : void
{
$this->parent = $parent;
}
/** /**
* Get status * Get status
* *
@ -184,84 +134,6 @@ class Department implements \JsonSerializable, ArrayableInterface
$this->status = $status; $this->status = $status;
} }
/**
* Get unit
*
* @return Unit
*
* @since 1.0.0
*/
public function getUnit() : Unit
{
return $this->unit ?? new NullUnit();
}
/**
* Set unit
*
* @param Unit $unit Unit
*
* @return void
*
* @since 1.0.0
*/
public function setUnit(Unit $unit) : void
{
$this->unit = $unit;
}
/**
* Get description
*
* @return string
*
* @since 1.0.0
*/
public function getDescription() : string
{
return $this->description;
}
/**
* Set description
*
* @param string $desc Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescription(string $desc) : void
{
$this->description = $desc;
}
/**
* Get description
*
* @return string
*
* @since 1.0.0
*/
public function getDescriptionRaw() : string
{
return $this->descriptionRaw;
}
/**
* Set description
*
* @param string $desc Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescriptionRaw(string $desc) : void
{
$this->descriptionRaw = $desc;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -34,6 +34,6 @@ final class NullDepartment extends Department
public function __construct(int $id = 0) public function __construct(int $id = 0)
{ {
$this->id = $id; $this->id = $id;
parent::__construct(); $this->unit = new NullUnit();
} }
} }

View File

@ -14,6 +14,8 @@ declare(strict_types=1);
namespace Modules\Organization\Models; namespace Modules\Organization\Models;
use Modules\Media\Models\NullMedia;
/** /**
* Organization null class. * Organization null class.
* *
@ -34,6 +36,6 @@ final class NullUnit extends Unit
public function __construct(int $id = 0) public function __construct(int $id = 0)
{ {
$this->id = $id; $this->id = $id;
parent::__construct(); $this->image = new NullMedia();
} }
} }

View File

@ -40,23 +40,23 @@ class Position implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Parent * Parent
* *
* @var null|Position * @var Position
* @since 1.0.0 * @since 1.0.0
*/ */
private ?self $parent = null; public self $parent;
/** /**
* Department * Department
* *
* @var null|Department * @var Department
* @since 1.0.0 * @since 1.0.0
*/ */
private ?Department $department = null; public Department $department;
/** /**
* Description. * Description.
@ -64,7 +64,7 @@ class Position implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $description = ''; public string $description = '';
/** /**
* Description. * Description.
@ -72,7 +72,7 @@ class Position implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $descriptionRaw = ''; public string $descriptionRaw = '';
/** /**
* Status * Status
@ -82,6 +82,17 @@ class Position implements \JsonSerializable, ArrayableInterface
*/ */
protected int $status = Status::INACTIVE; protected int $status = Status::INACTIVE;
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
$this->parent = new NullPosition();
$this->department = new NullDepartment();
}
/** /**
* Get id * Get id
* *
@ -94,84 +105,6 @@ class Position implements \JsonSerializable, ArrayableInterface
return $this->id; return $this->id;
} }
/**
* Get name
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/**
* Set name
*
* @param string $name Name
*
* @return void
*
* @since 1.0.0
*/
public function setName(string $name) : void
{
$this->name = $name;
}
/**
* Get parent
*
* @return Position
*
* @since 1.0.0
*/
public function getParent() : self
{
return $this->parent ?? new NullPosition();
}
/**
* Set parent
*
* @param null|Position $parent Parent
*
* @return void
*
* @since 1.0.0
*/
public function setParent(?self $parent) : void
{
$this->parent = $parent;
}
/**
* Get parent
*
* @return Department
*
* @since 1.0.0
*/
public function getDepartment() : Department
{
return $this->department ?? new NullDepartment();
}
/**
* Set department
*
* @param null|Department $department Department
*
* @return void
*
* @since 1.0.0
*/
public function setDepartment(?Department $department) : void
{
$this->department = $department;
}
/** /**
* Get status * Get status
* *
@ -198,58 +131,6 @@ class Position implements \JsonSerializable, ArrayableInterface
$this->status = $status; $this->status = $status;
} }
/**
* Get description
*
* @return string
*
* @since 1.0.0
*/
public function getDescription() : string
{
return $this->description;
}
/**
* Set description
*
* @param string $desc Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescription(string $desc) : void
{
$this->description = $desc;
}
/**
* Get description
*
* @return string
*
* @since 1.0.0
*/
public function getDescriptionRaw() : string
{
return $this->descriptionRaw;
}
/**
* Set description
*
* @param string $desc Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescriptionRaw(string $desc) : void
{
$this->descriptionRaw = $desc;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -42,7 +42,7 @@ class Unit implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Unit image. * Unit image.
@ -50,7 +50,7 @@ class Unit implements \JsonSerializable, ArrayableInterface
* @var Media * @var Media
* @since 1.0.0 * @since 1.0.0
*/ */
protected Media $image; public Media $image;
/** /**
* Parent * Parent
@ -58,7 +58,7 @@ class Unit implements \JsonSerializable, ArrayableInterface
* @var null|Unit * @var null|Unit
* @since 1.0.0 * @since 1.0.0
*/ */
private ?self $parent = null; public ?self $parent = null;
/** /**
* Description. * Description.
@ -66,7 +66,7 @@ class Unit implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $description = ''; public string $description = '';
/** /**
* Description. * Description.
@ -74,7 +74,7 @@ class Unit implements \JsonSerializable, ArrayableInterface
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
protected string $descriptionRaw = ''; public string $descriptionRaw = '';
/** /**
* Status * Status
@ -92,6 +92,7 @@ class Unit implements \JsonSerializable, ArrayableInterface
public function __construct() public function __construct()
{ {
$this->image = new NullMedia(); $this->image = new NullMedia();
$this->parent = new NullUnit();
} }
/** /**
@ -106,84 +107,6 @@ class Unit implements \JsonSerializable, ArrayableInterface
return $this->id; return $this->id;
} }
/**
* Get name
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/**
* Set name
*
* @param string $name Name
*
* @return void
*
* @since 1.0.0
*/
public function setName(string $name) : void
{
$this->name = $name;
}
/**
* Get unit image.
*
* @return Media
*
* @since 1.0.0
*/
public function getImage() : Media
{
return $this->image ?? new NullMedia();
}
/**
* Set unit image.
*
* @param Media $image Profile image
*
* @return void
*
* @since 1.0.0
*/
public function setImage(Media $image) : void
{
$this->image = $image;
}
/**
* Get parent
*
* @return Unit
*
* @since 1.0.0
*/
public function getParent() : self
{
return $this->parent ?? new NullUnit();
}
/**
* Set parent
*
* @param null|Unit $parent Parent
*
* @return void
*
* @since 1.0.0
*/
public function setParent(?self $parent) : void
{
$this->parent = $parent;
}
/** /**
* Get status * Get status
* *
@ -210,58 +133,6 @@ class Unit implements \JsonSerializable, ArrayableInterface
$this->status = $status; $this->status = $status;
} }
/**
* Get description
*
* @return string
*
* @since 1.0.0
*/
public function getDescription() : string
{
return $this->description;
}
/**
* Set description
*
* @param string $desc Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescription(string $desc) : void
{
$this->description = $desc;
}
/**
* Get description
*
* @return string
*
* @since 1.0.0
*/
public function getDescriptionRaw() : string
{
return $this->descriptionRaw;
}
/**
* Set description
*
* @param string $desc Description
*
* @return void
*
* @since 1.0.0
*/
public function setDescriptionRaw(string $desc) : void
{
$this->descriptionRaw = $desc;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -44,7 +44,7 @@ class DepartmentTagSelectorView extends View
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Is required * Is required
@ -78,18 +78,6 @@ class DepartmentTagSelectorView extends View
return $this->id; return $this->id;
} }
/**
* Get name
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/** /**
* Is required? * Is required?
* *

View File

@ -40,7 +40,7 @@
</div> </div>
<div class="box" id="<?= $this->printHtml($this->getId()); ?>-tags" data-limit="0" data-active="true"> <div class="box" id="<?= $this->printHtml($this->getId()); ?>-tags" data-limit="0" data-active="true">
<template id="<?= $this->printHtml($this->getId()); ?>-tagTemplate"> <template id="<?= $this->printHtml($this->getId()); ?>-tagTemplate">
<span class="tag red" data-tpl-value="/id" data-value="" data-uuid="" data-name="<?= $this->printHtml($this->getName()); ?>"> <span class="tag red" data-tpl-value="/id" data-value="" data-uuid="" data-name="<?= $this->printHtml($this->name); ?>">
<i class="fa fa-times"></i> <i class="fa fa-times"></i>
<span data-tpl-text="/id" data-name="id" data-tpl-value="/id" data-value=""></span> <span data-tpl-text="/id" data-name="id" data-tpl-value="/id" data-value=""></span>
<span data-tpl-text="/name" data-tpl-value="/name" data-value=""></span> <span data-tpl-text="/name" data-tpl-value="/name" data-value=""></span>

View File

@ -44,7 +44,7 @@ class PositionTagSelectorView extends View
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Is required * Is required
@ -78,18 +78,6 @@ class PositionTagSelectorView extends View
return $this->id; return $this->id;
} }
/**
* Get name
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/** /**
* Is required? * Is required?
* *

View File

@ -40,7 +40,7 @@
</div> </div>
<div class="box" id="<?= $this->printHtml($this->getId()); ?>-tags" data-limit="0" data-active="true"> <div class="box" id="<?= $this->printHtml($this->getId()); ?>-tags" data-limit="0" data-active="true">
<template id="<?= $this->printHtml($this->getId()); ?>-tagTemplate"> <template id="<?= $this->printHtml($this->getId()); ?>-tagTemplate">
<span class="tag red" data-tpl-value="/id" data-value="" data-uuid="" data-name="<?= $this->printHtml($this->getName()); ?>"> <span class="tag red" data-tpl-value="/id" data-value="" data-uuid="" data-name="<?= $this->printHtml($this->name); ?>">
<i class="fa fa-times"></i> <i class="fa fa-times"></i>
<span data-tpl-text="/id" data-name="id" data-tpl-value="/id" data-value=""></span> <span data-tpl-text="/id" data-name="id" data-tpl-value="/id" data-value=""></span>
<span data-tpl-text="/name" data-tpl-value="/name" data-value=""></span> <span data-tpl-text="/name" data-tpl-value="/name" data-value=""></span>

View File

@ -44,7 +44,7 @@ class UnitTagSelectorView extends View
* @var string * @var string
* @since 1.0.0 * @since 1.0.0
*/ */
private string $name = ''; public string $name = '';
/** /**
* Is required * Is required
@ -90,18 +90,6 @@ class UnitTagSelectorView extends View
return $this->isRequired; return $this->isRequired;
} }
/**
* Get name
*
* @return string
*
* @since 1.0.0
*/
public function getName() : string
{
return $this->name;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -40,7 +40,7 @@
</div> </div>
<div class="box" id="<?= $this->printHtml($this->getId()); ?>-tags" data-limit="0" data-active="true"> <div class="box" id="<?= $this->printHtml($this->getId()); ?>-tags" data-limit="0" data-active="true">
<template id="<?= $this->printHtml($this->getId()); ?>-tagTemplate"> <template id="<?= $this->printHtml($this->getId()); ?>-tagTemplate">
<span class="tag red" data-tpl-value="/id" data-value="" data-uuid="" data-name="<?= $this->printHtml($this->getName()); ?>"> <span class="tag red" data-tpl-value="/id" data-value="" data-uuid="" data-name="<?= $this->printHtml($this->name); ?>">
<i class="fa fa-times"></i> <i class="fa fa-times"></i>
<span data-tpl-text="/id" data-name="id" data-tpl-value="/id" data-value=""></span> <span data-tpl-text="/id" data-name="id" data-tpl-value="/id" data-value=""></span>
<span data-tpl-text="/name" data-tpl-value="/name" data-value=""></span> <span data-tpl-text="/name" data-tpl-value="/name" data-value=""></span>

View File

@ -38,12 +38,12 @@ echo $this->getData('nav')->render(); ?>
<td><?= $this->getHtml('Unit'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <td><?= $this->getHtml('Unit'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tbody> <tbody>
<?php $c = 0; foreach ($departments as $key => $value) : ++$c; <?php $c = 0; foreach ($departments as $key => $value) : ++$c;
$url = \phpOMS\Uri\UriFactory::build('{/prefix}organization/department/profile?{?}&id=' . $value->getId()); ?> $url = UriFactory::build('{/prefix}organization/department/profile?{?}&id=' . $value->getId()); ?>
<tr tabindex="0" data-href="<?= $url; ?>"> <tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getId()); ?></a> <td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getId()); ?></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getName()); ?></a> <td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
<td data-label="<?= $this->getHtml('Parent'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getParent()->getName()); ?></a> <td data-label="<?= $this->getHtml('Parent'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->parent->name); ?></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getUnit()->getName()); ?></a> <td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->unit->name); ?></a>
<?php endforeach; ?> <?php endforeach; ?>
<?php if ($c === 0) : ?> <?php if ($c === 0) : ?>
<tr> <tr>

View File

@ -30,7 +30,7 @@ echo $this->getData('nav')->render(); ?>
<div class="portlet-body"> <div class="portlet-body">
<table class="layout wf-100" style="table-layout: fixed"> <table class="layout wf-100" style="table-layout: fixed">
<tr><td><label for="iName"><?= $this->getHtml('Name'); ?></label> <tr><td><label for="iName"><?= $this->getHtml('Name'); ?></label>
<tr><td><input type="text" name="name" id="iName" value="<?= $this->printHtml($department->getName()); ?>"> <tr><td><input type="text" name="name" id="iName" value="<?= $this->printHtml($department->name); ?>">
<tr><td><label for="iParent"><?= $this->getHtml('Parent'); ?></label> <tr><td><label for="iParent"><?= $this->getHtml('Parent'); ?></label>
<tr><td><?= $this->getData('department-selector')->render('iParent', 'parent', false); ?> <tr><td><?= $this->getData('department-selector')->render('iParent', 'parent', false); ?>
<tr><td><label for="iUnit"><?= $this->getHtml('Unit'); ?></label> <tr><td><label for="iUnit"><?= $this->getHtml('Unit'); ?></label>
@ -45,8 +45,8 @@ echo $this->getData('nav')->render(); ?>
'department-editor', 'department-editor',
'description', 'description',
'iDepartment', 'iDepartment',
$department->getDescriptionRaw(), $department->descriptionRaw,
$department->getDescription() $department->description
); ?> ); ?>
</table> </table>
</div> </div>

View File

@ -28,7 +28,7 @@ $unitRoot = $unitTree[null][0]['children'];
<?php foreach ($unitRoot as $unitEle) : ?> <?php foreach ($unitRoot as $unitEle) : ?>
<div class="row"> <div class="row">
<?php while (!empty($unitEle) && $unitEle['obj'] !== null) { <?php while (!empty($unitEle) && $unitEle['obj'] !== null) {
$unitTree[null][$unitEle['obj']->getParent()->getId()]['index'] = $unitTree[null][$unitEle['obj']->getParent()->getId()]['index'] + 1; $unitTree[null][$unitEle['obj']->parent->getId()]['index'] = $unitTree[null][$unitEle['obj']->parent->getId()]['index'] + 1;
?> ?>
<?php while (!empty($unitEle)) { <?php while (!empty($unitEle)) {
$unitId = $unitEle['obj']->getId(); ?> $unitId = $unitEle['obj']->getId(); ?>
@ -42,7 +42,7 @@ $unitRoot = $unitTree[null][0]['children'];
$depRoot = $depTree[$unitId][0]['children'] ?? []; foreach ($depRoot as $depEle) : ?> $depRoot = $depTree[$unitId][0]['children'] ?? []; foreach ($depRoot as $depEle) : ?>
<div class="row" style="margin: 0 auto;"> <div class="row" style="margin: 0 auto;">
<?php while (!empty($depEle) && $depEle['obj'] !== null) { <?php while (!empty($depEle) && $depEle['obj'] !== null) {
$depTree[$unitId][$depEle['obj']->getParent()->getId()]['index'] = $depTree[$unitId][$depEle['obj']->getParent()->getId()]['index'] + 1; $depTree[$unitId][$depEle['obj']->parent->getId()]['index'] = $depTree[$unitId][$depEle['obj']->parent->getId()]['index'] + 1;
?> ?>
<?php while (!empty($depEle)) { ?> <?php while (!empty($depEle)) { ?>
<div class="departments"> <div class="departments">
@ -58,9 +58,9 @@ $unitRoot = $unitTree[null][0]['children'];
foreach ($posRoot as $posEle) : ?> foreach ($posRoot as $posEle) : ?>
<?php while (!empty($posEle) && $posEle['obj'] !== null) { <?php while (!empty($posEle) && $posEle['obj'] !== null) {
if (isset($posTree[$depId][$posEle['obj']->getParent()->getId()])) { if (isset($posTree[$depId][$posEle['obj']->parent->getId()])) {
// here is a bug or somewhere else... the index is not moved correctly $c is always 0 // here is a bug or somewhere else... the index is not moved correctly $c is always 0
$posTree[$depId][$posEle['obj']->getParent()->getId()]['index'] = $posTree[$depId][$posEle['obj']->getParent()->getId()]['index'] + $c + 1; $posTree[$depId][$posEle['obj']->parent->getId()]['index'] = $posTree[$depId][$posEle['obj']->parent->getId()]['index'] + $c + 1;
} }
$c = 0; while (!empty($posEle)) { ?> $c = 0; while (!empty($posEle)) { ?>
@ -87,7 +87,7 @@ $unitRoot = $unitTree[null][0]['children'];
do { do {
++$toCloseDep; ++$toCloseDep;
$parentDep = $parentDep->getParent(); $parentDep = $parentDep->parent;
$parentDepId = $parentDep->getId(); $parentDepId = $parentDep->getId();
} while ($parentDepId !== 0 } while ($parentDepId !== 0
&& !isset($depTree[$unitId][$parentDepId]['children'][($depTree[$unitId][$parentDepId]['index'] ?? 0) + 1]) && !isset($depTree[$unitId][$parentDepId]['children'][($depTree[$unitId][$parentDepId]['index'] ?? 0) + 1])
@ -115,7 +115,7 @@ $unitRoot = $unitTree[null][0]['children'];
do { do {
++$toCloseUnit; ++$toCloseUnit;
$parentUnit = $parentUnit->getParent(); $parentUnit = $parentUnit->parent;
$parentUnitId = $parentUnit->getId(); $parentUnitId = $parentUnit->getId();
} while ($parentUnitId !== 0 } while ($parentUnitId !== 0
&& !isset($unitTree[null][$parentUnitId]['children'][($unitTree[null][$parentUnitId]['index'] ?? 0) + 1]) && !isset($unitTree[null][$parentUnitId]['children'][($unitTree[null][$parentUnitId]['index'] ?? 0) + 1])

View File

@ -41,9 +41,9 @@ echo $this->getData('nav')->render(); ?>
$url = \phpOMS\Uri\UriFactory::build('{/prefix}organization/position/profile?{?}&id=' . $value->getId()); ?> $url = \phpOMS\Uri\UriFactory::build('{/prefix}organization/position/profile?{?}&id=' . $value->getId()); ?>
<tr tabindex="0" data-href="<?= $url; ?>"> <tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getId()); ?></a> <td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getId()); ?></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getName()); ?></a> <td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
<td data-label="<?= $this->getHtml('Parent'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getParent()->getName()); ?></a> <td data-label="<?= $this->getHtml('Parent'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->parent->name); ?></a>
<td data-label="<?= $this->getHtml('Department'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getDepartment()->getName()); ?></a> <td data-label="<?= $this->getHtml('Department'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->department->name); ?></a>
<?php endforeach; ?> <?php endforeach; ?>
<?php if ($count === 0) : ?> <?php if ($count === 0) : ?>
<tr><td colspan="5" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?> <tr><td colspan="5" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>

View File

@ -30,7 +30,7 @@ echo $this->getData('nav')->render(); ?>
<div class="portlet-body"> <div class="portlet-body">
<table class="layout wf-100" style="table-layout: fixed"> <table class="layout wf-100" style="table-layout: fixed">
<tr><td><label for="iName"><?= $this->getHtml('Name'); ?></label> <tr><td><label for="iName"><?= $this->getHtml('Name'); ?></label>
<tr><td><input type="text" name="name" id="iName" value="<?= $this->printHtml($position->getName()); ?>"> <tr><td><input type="text" name="name" id="iName" value="<?= $this->printHtml($position->name); ?>">
<tr><td><label for="iParent"><?= $this->getHtml('Parent'); ?></label> <tr><td><label for="iParent"><?= $this->getHtml('Parent'); ?></label>
<tr><td><?= $this->getData('position-selector')->render('iParent', 'parent', false); ?> <tr><td><?= $this->getData('position-selector')->render('iParent', 'parent', false); ?>
<tr><td><label for="iDepartment"><?= $this->getHtml('Department'); ?></label> <tr><td><label for="iDepartment"><?= $this->getHtml('Department'); ?></label>
@ -45,8 +45,8 @@ echo $this->getData('nav')->render(); ?>
'position-editor', 'position-editor',
'description', 'description',
'iPosition', 'iPosition',
$position->getDescriptionRaw(), $position->descriptionRaw,
$position->getDescription() $position->description
); ?> ); ?>
</table> </table>
</div> </div>

View File

@ -42,11 +42,11 @@ echo $this->getData('nav')->render(); ?>
$url = UriFactory::build('{/prefix}organization/unit/profile?{?}&id=' . $value->getId()); ?> $url = UriFactory::build('{/prefix}organization/unit/profile?{?}&id=' . $value->getId()); ?>
<tr tabindex="0" data-href="<?= $url; ?>"> <tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getId()); ?></a> <td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getId()); ?></a>
<td><a href="<?= $url; ?>"><img class="profile-image" src="<?= $value->getImage() instanceof NullMedia ? <td><a href="<?= $url; ?>"><img class="profile-image" src="<?= $value->image instanceof NullMedia ?
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') : UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') :
UriFactory::build('{/prefix}' . $value->getImage()->getPath()); ?>"></a> UriFactory::build('{/prefix}' . $value->image->getPath()); ?>"></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getName()); ?></a> <td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
<td data-label="<?= $this->getHtml('Parent'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getParent()->getName()); ?></a> <td data-label="<?= $this->getHtml('Parent'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->parent->name); ?></a>
<?php endforeach; ?> <?php endforeach; ?>
</table> </table>
<div class="portlet-foot"> <div class="portlet-foot">

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
use Modules\Media\Models\NullMedia; use Modules\Media\Models\NullMedia;
use phpOMS\Uri\UriFactory; use phpOMS\Uri\UriFactory;
use Modules\Organization\Models\Status;
/** /**
* @var \phpOMS\Views\View $this * @var \phpOMS\Views\View $this
@ -36,9 +37,9 @@ echo $this->getData('nav')->render(); ?>
alt="<?= $this->getHtml('Logo'); ?>" alt="<?= $this->getHtml('Logo'); ?>"
itemprop="logo" loading="lazy" itemprop="logo" loading="lazy"
src="<?= src="<?=
$unit->getImage() instanceof NullMedia ? $unit->image instanceof NullMedia ?
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') : UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') :
UriFactory::build('{/prefix}' . $unit->getImage()->getPath()); ?>" UriFactory::build('{/prefix}' . $unit->image->getPath()); ?>"
width="40x"> width="40x">
</a> </a>
</div> </div>
@ -47,21 +48,21 @@ echo $this->getData('nav')->render(); ?>
<div class="portlet-body"> <div class="portlet-body">
<table class="layout wf-100" style="table-layout: fixed"> <table class="layout wf-100" style="table-layout: fixed">
<tr><td><label for="iName"><?= $this->getHtml('Name'); ?></label> <tr><td><label for="iName"><?= $this->getHtml('Name'); ?></label>
<tr><td><input type="text" name="name" id="iName" value="<?= $this->printHtml($unit->getName()); ?>"> <tr><td><input type="text" name="name" id="iName" value="<?= $this->printHtml($unit->name); ?>">
<tr><td><label for="iParent"><?= $this->getHtml('Parent'); ?></label> <tr><td><label for="iParent"><?= $this->getHtml('Parent'); ?></label>
<tr><td><?= $this->getData('unit-selector')->render('iParent', 'parent', false); ?> <tr><td><?= $this->getData('unit-selector')->render('iParent', 'parent', false); ?>
<tr><td><label for="iStatus"><?= $this->getHtml('Status'); ?></label> <tr><td><label for="iStatus"><?= $this->getHtml('Status'); ?></label>
<tr><td><select name="status" id="iStatus"> <tr><td><select name="status" id="iStatus">
<option value="<?= $this->printHtml(\Modules\Organization\Models\Status::ACTIVE); ?>"<?= \Modules\Organization\Models\Status::ACTIVE === $unit->getStatus() ? ' selected' : ''; ?>><?= $this->getHtml('Active'); ?> <option value="<?= $this->printHtml(Status::ACTIVE); ?>"<?= Status::ACTIVE === $unit->getStatus() ? ' selected' : ''; ?>><?= $this->getHtml('Active'); ?>
<option value="<?= $this->printHtml(\Modules\Organization\Models\Status::INACTIVE); ?>"<?= \Modules\Organization\Models\Status::INACTIVE === $unit->getStatus() ? ' selected' : ''; ?>><?= $this->getHtml('Inactive'); ?> <option value="<?= $this->printHtml(Status::INACTIVE); ?>"<?= Status::INACTIVE === $unit->getStatus() ? ' selected' : ''; ?>><?= $this->getHtml('Inactive'); ?>
</select> </select>
<tr><td><?= $this->getData('editor')->render('unit-editor'); ?> <tr><td><?= $this->getData('editor')->render('unit-editor'); ?>
<tr><td><?= $this->getData('editor')->getData('text')->render( <tr><td><?= $this->getData('editor')->getData('text')->render(
'unit-editor', 'unit-editor',
'description', 'description',
'iUnit', 'iUnit',
$unit->getDescriptionRaw(), $unit->descriptionRaw,
$unit->getDescription() $unit->description
); ?> ); ?>
</table> </table>
</div> </div>

View File

@ -91,12 +91,12 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('id', '1'); $request->setData('id', '1');
$this->module->apiUnitGet($request, $response); $this->module->apiUnitGet($request, $response);
self::assertEquals('Orange-Management', $response->get('')['response']->getName()); self::assertEquals('Orange-Management', $response->get('')['response']->name);
self::assertGreaterThan(0, $response->get('')['response']->getId()); self::assertGreaterThan(0, $response->get('')['response']->getId());
} }
@ -109,14 +109,14 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('id', '1'); $request->setData('id', '1');
$request->setData('name', 'OMS'); $request->setData('name', 'OMS');
$this->module->apiUnitSet($request, $response); $this->module->apiUnitSet($request, $response);
$this->module->apiUnitGet($request, $response); $this->module->apiUnitGet($request, $response);
self::assertEquals('OMS', $response->get('')['response']->getName()); self::assertEquals('OMS', $response->get('')['response']->name);
} }
/** /**
@ -128,12 +128,12 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('search', 'OMS'); $request->setData('search', 'OMS');
$this->module->apiUnitFind($request, $response); $this->module->apiUnitFind($request, $response);
self::assertEquals('OMS', $response->get('')[0]->getName()); self::assertEquals('OMS', $response->get('')[0]->name);
self::assertGreaterThan(0, $response->get('')[0]->getId()); self::assertGreaterThan(0, $response->get('')[0]->getId());
} }
@ -146,14 +146,14 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('name', 'test'); $request->setData('name', 'test');
$request->setData('status', Status::INACTIVE); $request->setData('status', Status::INACTIVE);
$request->setData('description', 'test description'); $request->setData('description', 'test description');
$this->module->apiUnitCreate($request, $response); $this->module->apiUnitCreate($request, $response);
self::assertEquals('test', $response->get('')['response']->getName()); self::assertEquals('test', $response->get('')['response']->name);
self::assertGreaterThan(0, $response->get('')['response']->getId()); self::assertGreaterThan(0, $response->get('')['response']->getId());
// test delete // test delete
@ -172,11 +172,11 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$this->module->apiUnitCreate($request, $response); $this->module->apiUnitCreate($request, $response);
self::assertEquals(RequestStatusCode::R_400, $response->getHeader()->getStatusCode()); self::assertEquals(RequestStatusCode::R_400, $response->header->status);
} }
protected static $departmentId = 0; protected static $departmentId = 0;
@ -190,7 +190,7 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('name', 'test'); $request->setData('name', 'test');
$request->setData('status', Status::INACTIVE); $request->setData('status', Status::INACTIVE);
$request->setData('unit', 1); $request->setData('unit', 1);
@ -198,7 +198,7 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$this->module->apiDepartmentCreate($request, $response); $this->module->apiDepartmentCreate($request, $response);
self::assertEquals('test', $response->get('')['response']->getName()); self::assertEquals('test', $response->get('')['response']->name);
self::assertGreaterThan(0, $response->get('')['response']->getId()); self::assertGreaterThan(0, $response->get('')['response']->getId());
self::$departmentId = $response->get('')['response']->getId(); self::$departmentId = $response->get('')['response']->getId();
@ -213,12 +213,12 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('search', 'test'); $request->setData('search', 'test');
$this->module->apiDepartmentFind($request, $response); $this->module->apiDepartmentFind($request, $response);
self::assertEquals('test', $response->get('')[0]->getName()); self::assertEquals('test', $response->get('')[0]->name);
self::assertGreaterThan(0, $response->get('')[0]->getId()); self::assertGreaterThan(0, $response->get('')[0]->getId());
} }
@ -231,11 +231,11 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$this->module->apiDepartmentCreate($request, $response); $this->module->apiDepartmentCreate($request, $response);
self::assertEquals(RequestStatusCode::R_400, $response->getHeader()->getStatusCode()); self::assertEquals(RequestStatusCode::R_400, $response->header->status);
} }
/** /**
@ -247,12 +247,12 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('id', self::$departmentId); $request->setData('id', self::$departmentId);
$this->module->apiDepartmentGet($request, $response); $this->module->apiDepartmentGet($request, $response);
self::assertEquals('test', $response->get('')['response']->getName()); self::assertEquals('test', $response->get('')['response']->name);
self::assertGreaterThan(0, $response->get('')['response']->getId()); self::assertGreaterThan(0, $response->get('')['response']->getId());
} }
@ -265,14 +265,14 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('id', self::$departmentId); $request->setData('id', self::$departmentId);
$request->setData('name', 'Production'); $request->setData('name', 'Production');
$this->module->apiDepartmentSet($request, $response); $this->module->apiDepartmentSet($request, $response);
$this->module->apiDepartmentGet($request, $response); $this->module->apiDepartmentGet($request, $response);
self::assertEquals('Production', $response->get('')['response']->getName()); self::assertEquals('Production', $response->get('')['response']->name);
} }
/** /**
@ -284,7 +284,7 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('id', self::$departmentId); $request->setData('id', self::$departmentId);
$this->module->apiDepartmentDelete($request, $response); $this->module->apiDepartmentDelete($request, $response);
@ -302,14 +302,14 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('name', 'test'); $request->setData('name', 'test');
$request->setData('status', Status::INACTIVE); $request->setData('status', Status::INACTIVE);
$request->setData('description', 'test description'); $request->setData('description', 'test description');
$this->module->apiPositionCreate($request, $response); $this->module->apiPositionCreate($request, $response);
self::assertEquals('test', $response->get('')['response']->getName()); self::assertEquals('test', $response->get('')['response']->name);
self::assertGreaterThan(0, $response->get('')['response']->getId()); self::assertGreaterThan(0, $response->get('')['response']->getId());
self::$positionId = $response->get('')['response']->getId(); self::$positionId = $response->get('')['response']->getId();
} }
@ -323,12 +323,12 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('search', 'test'); $request->setData('search', 'test');
$this->module->apiPositionFind($request, $response); $this->module->apiPositionFind($request, $response);
self::assertEquals('test', $response->get('')[0]->getName()); self::assertEquals('test', $response->get('')[0]->name);
self::assertGreaterThan(0, $response->get('')[0]->getId()); self::assertGreaterThan(0, $response->get('')[0]->getId());
} }
@ -341,11 +341,11 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$this->module->apiPositionCreate($request, $response); $this->module->apiPositionCreate($request, $response);
self::assertEquals(RequestStatusCode::R_400, $response->getHeader()->getStatusCode()); self::assertEquals(RequestStatusCode::R_400, $response->header->status);
} }
/** /**
@ -357,12 +357,12 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('id', self::$positionId); $request->setData('id', self::$positionId);
$this->module->apiPositionGet($request, $response); $this->module->apiPositionGet($request, $response);
self::assertEquals('test', $response->get('')['response']->getName()); self::assertEquals('test', $response->get('')['response']->name);
self::assertGreaterThan(0, $response->get('')['response']->getId()); self::assertGreaterThan(0, $response->get('')['response']->getId());
} }
@ -375,14 +375,14 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('id', self::$positionId); $request->setData('id', self::$positionId);
$request->setData('name', 'Test'); $request->setData('name', 'Test');
$this->module->apiPositionSet($request, $response); $this->module->apiPositionSet($request, $response);
$this->module->apiPositionGet($request, $response); $this->module->apiPositionGet($request, $response);
self::assertEquals('Test', $response->get('')['response']->getName()); self::assertEquals('Test', $response->get('')['response']->name);
} }
/** /**
@ -394,7 +394,7 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('id', self::$positionId); $request->setData('id', self::$positionId);
$this->module->apiPositionDelete($request, $response); $this->module->apiPositionDelete($request, $response);
@ -412,7 +412,7 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$response = new HttpResponse(); $response = new HttpResponse();
$request = new HttpRequest(new HttpUri('')); $request = new HttpRequest(new HttpUri(''));
$request->getHeader()->setAccount(1); $request->header->account = 1;
$request->setData('name', 'Organization Logo'); $request->setData('name', 'Organization Logo');
$request->setData('id', 1); $request->setData('id', 1);
@ -427,8 +427,8 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
]); ]);
$this->module->apiUnitImageSet($request, $response); $this->module->apiUnitImageSet($request, $response);
$image = UnitMapper::get(1)->getImage(); $image = UnitMapper::get(1)->image;
self::assertEquals('Organization Logo', $image->getName()); self::assertEquals('Organization Logo', $image->name);
} }
/** /**
@ -442,6 +442,6 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
$this->module->apiUnitImageSet($request, $response); $this->module->apiUnitImageSet($request, $response);
self::assertEquals(RequestStatusCode::R_400, $response->getHeader()->getStatusCode()); self::assertEquals(RequestStatusCode::R_400, $response->header->status);
} }
} }

View File

@ -31,18 +31,18 @@ class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
public function testCRUD() : void public function testCRUD() : void
{ {
$department = new Department(); $department = new Department();
$department->setName('Management'); $department->name = 'Management';
$department->setDescription('Description'); $department->description = 'Description';
$department->setUnit(new NullUnit(1)); $department->unit = new NullUnit(1);
$id = DepartmentMapper::create($department); $id = DepartmentMapper::create($department);
$departmentR = DepartmentMapper::get($id); $departmentR = DepartmentMapper::get($id);
self::assertEquals($id, $departmentR->getId()); self::assertEquals($id, $departmentR->getId());
self::assertEquals($department->getName(), $departmentR->getName()); self::assertEquals($department->name, $departmentR->name);
self::assertEquals($department->getDescription(), $departmentR->getDescription()); self::assertEquals($department->description, $departmentR->description);
self::assertInstanceOf('Modules\Organization\Models\NullDepartment', $departmentR->getParent()); self::assertInstanceOf('Modules\Organization\Models\NullDepartment', $departmentR->parent);
self::assertEquals($department->getUnit()->getId(), $departmentR->getUnit()->getId()); self::assertEquals($department->unit->getId(), $departmentR->unit->getId());
} }
/** /**
@ -57,66 +57,66 @@ class DepartmentMapperTest extends \PHPUnit\Framework\TestCase
/* 2 */ /* 2 */
$department = new Department(); $department = new Department();
$department->setName('HR'); $department->name = 'HR';
$department->setDescription('Description'); $department->description = 'Description';
$department->setParent(new NullDepartment($first)); $department->parent = new NullDepartment($first);
$department->setUnit(new NullUnit(1)); $department->unit = new NullUnit(1);
DepartmentMapper::create($department); DepartmentMapper::create($department);
/* 3 */ /* 3 */
$department = new Department(); $department = new Department();
$department->setName('QM'); $department->name = 'QM';
$department->setDescription('Description'); $department->description = 'Description';
$department->setParent(new NullDepartment($first)); $department->parent = new NullDepartment($first);
$department->setUnit(new NullUnit(1)); $department->unit = new NullUnit(1);
DepartmentMapper::create($department); DepartmentMapper::create($department);
/* 4 */ /* 4 */
$department = new Department(); $department = new Department();
$department->setName('Sales'); $department->name = 'Sales';
$department->setDescription('Description'); $department->description = 'Description';
$department->setParent(new NullDepartment($first)); $department->parent = new NullDepartment($first);
$department->setUnit(new NullUnit(1)); $department->unit = new NullUnit(1);
DepartmentMapper::create($department); DepartmentMapper::create($department);
/* 5 */ /* 5 */
$department = new Department(); $department = new Department();
$department->setName('Shipping'); $department->name = 'Shipping';
$department->setDescription('Description'); $department->description = 'Description';
$department->setParent(new NullDepartment($first + 3)); $department->parent = new NullDepartment($first + 3);
$department->setUnit(new NullUnit(1)); $department->unit = new NullUnit(1);
DepartmentMapper::create($department); DepartmentMapper::create($department);
/* 6 */ /* 6 */
$department = new Department(); $department = new Department();
$department->setName('Purchase'); $department->name = 'Purchase';
$department->setDescription('Description'); $department->description = 'Description';
$department->setParent(new NullDepartment($first)); $department->parent = new NullDepartment($first);
$department->setUnit(new NullUnit(1)); $department->unit = new NullUnit(1);
DepartmentMapper::create($department); DepartmentMapper::create($department);
/* 7 */ /* 7 */
$department = new Department(); $department = new Department();
$department->setName('Arrival'); $department->name = 'Arrival';
$department->setDescription('Description'); $department->description = 'Description';
$department->setParent(new NullDepartment($first + 5)); $department->parent = new NullDepartment($first + 5);
$department->setUnit(new NullUnit(1)); $department->unit = new NullUnit(1);
DepartmentMapper::create($department); DepartmentMapper::create($department);
/* 8 */ /* 8 */
$department = new Department(); $department = new Department();
$department->setName('Accounting'); $department->name = 'Accounting';
$department->setDescription('Description'); $department->description = 'Description';
$department->setParent(new NullDepartment($first)); $department->parent = new NullDepartment($first);
$department->setUnit(new NullUnit(1)); $department->unit = new NullUnit(1);
DepartmentMapper::create($department); DepartmentMapper::create($department);
/* 9 */ /* 9 */
$department = new Department(); $department = new Department();
$department->setName('Production'); $department->name = 'Production';
$department->setDescription('Description'); $department->description = 'Description';
$department->setParent(new NullDepartment($first)); $department->parent = new NullDepartment($first);
$department->setUnit(new NullUnit(1)); $department->unit = new NullUnit(1);
DepartmentMapper::create($department); DepartmentMapper::create($department);
} }
} }

View File

@ -38,11 +38,11 @@ class DepartmentTest extends \PHPUnit\Framework\TestCase
public function testDefault() : void public function testDefault() : void
{ {
self::assertEquals(0, $this->department->getId()); self::assertEquals(0, $this->department->getId());
self::assertEquals('', $this->department->getName()); self::assertEquals('', $this->department->name);
self::assertEquals('', $this->department->getDescription()); self::assertEquals('', $this->department->description);
self::assertEquals('', $this->department->getDescriptionRaw()); self::assertEquals('', $this->department->descriptionRaw);
self::assertInstanceOf(NullDepartment::class, $this->department->getParent()); self::assertInstanceOf(NullDepartment::class, $this->department->parent);
self::assertEquals(0, $this->department->getUnit()->getId()); self::assertEquals(0, $this->department->unit->getId());
self::assertEquals(Status::INACTIVE, $this->department->getStatus()); self::assertEquals(Status::INACTIVE, $this->department->getStatus());
} }
@ -52,8 +52,8 @@ class DepartmentTest extends \PHPUnit\Framework\TestCase
*/ */
public function testNameInputOutput() : void public function testNameInputOutput() : void
{ {
$this->department->setName('Name'); $this->department->name = 'Name';
self::assertEquals('Name', $this->department->getName()); self::assertEquals('Name', $this->department->name);
} }
/** /**
@ -62,8 +62,8 @@ class DepartmentTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDescriptionInputOutput() : void public function testDescriptionInputOutput() : void
{ {
$this->department->setDescription('Description'); $this->department->description = 'Description';
self::assertEquals('Description', $this->department->getDescription()); self::assertEquals('Description', $this->department->description);
} }
/** /**
@ -72,8 +72,8 @@ class DepartmentTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDescriptionRawInputOutput() : void public function testDescriptionRawInputOutput() : void
{ {
$this->department->setDescriptionRaw('DescriptionRaw'); $this->department->descriptionRaw = 'DescriptionRaw';
self::assertEquals('DescriptionRaw', $this->department->getDescriptionRaw()); self::assertEquals('DescriptionRaw', $this->department->descriptionRaw);
} }
/** /**
@ -92,8 +92,8 @@ class DepartmentTest extends \PHPUnit\Framework\TestCase
*/ */
public function testParentInputOutput() : void public function testParentInputOutput() : void
{ {
$this->department->setParent(new NullDepartment(1)); $this->department->parent = new NullDepartment(1);
self::assertEquals(1, $this->department->getParent()->getId()); self::assertEquals(1, $this->department->parent->getId());
} }
/** /**
@ -102,8 +102,8 @@ class DepartmentTest extends \PHPUnit\Framework\TestCase
*/ */
public function testUnitInputOutput() : void public function testUnitInputOutput() : void
{ {
$this->department->setUnit(new NullUnit(1)); $this->department->unit = new NullUnit(1);
self::assertEquals(1, $this->department->getUnit()->getId()); self::assertEquals(1, $this->department->unit->getId());
} }
/** /**
@ -112,12 +112,12 @@ class DepartmentTest extends \PHPUnit\Framework\TestCase
*/ */
public function testSerialize() : void public function testSerialize() : void
{ {
$this->department->setName('Name'); $this->department->name = 'Name';
$this->department->setDescription('Description'); $this->department->description = 'Description';
$this->department->setDescriptionRaw('DescriptionRaw'); $this->department->descriptionRaw = 'DescriptionRaw';
$this->department->setStatus(Status::ACTIVE); $this->department->setStatus(Status::ACTIVE);
$this->department->setParent($p = new NullDepartment(1)); $this->department->parent = ($p = new NullDepartment(1));
$this->department->setUnit($u = new NullUnit(1)); $this->department->unit = ($u = new NullUnit(1));
self::assertEquals($this->department->toArray(), $this->department->jsonSerialize()); self::assertEquals($this->department->toArray(), $this->department->jsonSerialize());
self::assertEquals( self::assertEquals(

View File

@ -30,16 +30,16 @@ class PositionMapperTest extends \PHPUnit\Framework\TestCase
public function testCRUD() : void public function testCRUD() : void
{ {
$position = new Position(); $position = new Position();
$position->setName('CEO'); $position->name = 'CEO';
$position->setDescription('Description'); $position->description = 'Description';
$id = PositionMapper::create($position); $id = PositionMapper::create($position);
$positionR = PositionMapper::get($id); $positionR = PositionMapper::get($id);
self::assertEquals($id, $positionR->getId()); self::assertEquals($id, $positionR->getId());
self::assertEquals($position->getName(), $positionR->getName()); self::assertEquals($position->name, $positionR->name);
self::assertEquals($position->getDescription(), $positionR->getDescription()); self::assertEquals($position->description, $positionR->description);
self::assertInstanceOf('Modules\Organization\Models\NullPosition', $positionR->getParent()); self::assertInstanceOf('Modules\Organization\Models\NullPosition', $positionR->parent);
} }
/** /**
@ -54,58 +54,58 @@ class PositionMapperTest extends \PHPUnit\Framework\TestCase
/* 4 */ /* 4 */
$position = new Position(); $position = new Position();
$position->setName('CFO'); $position->name = 'CFO';
$position->setDescription('Description'); $position->description = 'Description';
$position->setParent(new NullPosition($first)); $position->parent = new NullPosition($first);
$id = PositionMapper::create($position); $id = PositionMapper::create($position);
/* 5 */ /* 5 */
$position = new Position(); $position = new Position();
$position->setName('Accountant'); $position->name = 'Accountant';
$position->setDescription('Description'); $position->description = 'Description';
$position->setParent(new NullPosition($id)); $position->parent = new NullPosition($id);
PositionMapper::create($position); PositionMapper::create($position);
/* 6 */ /* 6 */
$position = new Position(); $position = new Position();
$position->setName('Controller'); $position->name = 'Controller';
$position->setDescription('Description'); $position->description = 'Description';
$position->setParent(new NullPosition($id)); $position->parent = new NullPosition($id);
PositionMapper::create($position); PositionMapper::create($position);
/* 7 */ /* 7 */
$position = new Position(); $position = new Position();
$position->setName('Sales Director'); $position->name = 'Sales Director';
$position->setDescription('Description'); $position->description = 'Description';
$position->setParent(new NullPosition($first)); $position->parent = new NullPosition($first);
PositionMapper::create($position); PositionMapper::create($position);
/* 8 */ /* 8 */
$position = new Position(); $position = new Position();
$position->setName('Purchase Director'); $position->name = 'Purchase Director';
$position->setDescription('Description'); $position->description = 'Description';
$position->setParent(new NullPosition($first)); $position->parent = new NullPosition($first);
PositionMapper::create($position); PositionMapper::create($position);
/* 9 */ /* 9 */
$position = new Position(); $position = new Position();
$position->setName('Territory Manager'); $position->name = 'Territory Manager';
$position->setDescription('Description'); $position->description = 'Description';
$position->setParent(new NullPosition($first + 4)); $position->parent = new NullPosition($first + 4);
PositionMapper::create($position); PositionMapper::create($position);
/* 10 */ /* 10 */
$position = new Position(); $position = new Position();
$position->setName('Territory Sales Assistant'); $position->name = 'Territory Sales Assistant';
$position->setDescription('Description'); $position->description = 'Description';
$position->setParent(new NullPosition($first + 6)); $position->parent = new NullPosition($first + 6);
PositionMapper::create($position); PositionMapper::create($position);
/* 11 */ /* 11 */
$position = new Position(); $position = new Position();
$position->setName('Domestic Sales Manager'); $position->name = 'Domestic Sales Manager';
$position->setDescription('Description'); $position->description = 'Description';
$position->setParent(new NullPosition($first + 4)); $position->parent = new NullPosition($first + 4);
PositionMapper::create($position); PositionMapper::create($position);
} }
} }

View File

@ -38,11 +38,11 @@ class PositionTest extends \PHPUnit\Framework\TestCase
public function testDefault() : void public function testDefault() : void
{ {
self::assertEquals(0, $this->position->getId()); self::assertEquals(0, $this->position->getId());
self::assertEquals('', $this->position->getName()); self::assertEquals('', $this->position->name);
self::assertEquals('', $this->position->getDescription()); self::assertEquals('', $this->position->description);
self::assertEquals('', $this->position->getDescriptionRaw()); self::assertEquals('', $this->position->descriptionRaw);
self::assertInstanceOf(NullPosition::class, $this->position->getParent()); self::assertInstanceOf(NullPosition::class, $this->position->parent);
self::assertEquals(0, $this->position->getDepartment()->getId()); self::assertEquals(0, $this->position->department->getId());
self::assertEquals(Status::INACTIVE, $this->position->getStatus()); self::assertEquals(Status::INACTIVE, $this->position->getStatus());
} }
@ -52,8 +52,8 @@ class PositionTest extends \PHPUnit\Framework\TestCase
*/ */
public function testNameInputOutput() : void public function testNameInputOutput() : void
{ {
$this->position->setName('Name'); $this->position->name = 'Name';
self::assertEquals('Name', $this->position->getName()); self::assertEquals('Name', $this->position->name);
} }
/** /**
@ -62,8 +62,8 @@ class PositionTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDescriptionInputOutput() : void public function testDescriptionInputOutput() : void
{ {
$this->position->setDescription('Description'); $this->position->description = 'Description';
self::assertEquals('Description', $this->position->getDescription()); self::assertEquals('Description', $this->position->description);
} }
/** /**
@ -72,8 +72,8 @@ class PositionTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDescriptionRawInputOutput() : void public function testDescriptionRawInputOutput() : void
{ {
$this->position->setDescriptionRaw('DescriptionRaw'); $this->position->descriptionRaw = 'DescriptionRaw';
self::assertEquals('DescriptionRaw', $this->position->getDescriptionRaw()); self::assertEquals('DescriptionRaw', $this->position->descriptionRaw);
} }
/** /**
@ -92,8 +92,8 @@ class PositionTest extends \PHPUnit\Framework\TestCase
*/ */
public function testParentInputOutput() : void public function testParentInputOutput() : void
{ {
$this->position->setParent(new NullPosition(1)); $this->position->parent = new NullPosition(1);
self::assertEquals(1, $this->position->getParent()->getId()); self::assertEquals(1, $this->position->parent->getId());
} }
/** /**
@ -102,8 +102,8 @@ class PositionTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDepartmentInputOutput() : void public function testDepartmentInputOutput() : void
{ {
$this->position->setDepartment(new NullDepartment(1)); $this->position->department = new NullDepartment(1);
self::assertEquals(1, $this->position->getDepartment()->getId()); self::assertEquals(1, $this->position->department->getId());
} }
/** /**
@ -112,12 +112,12 @@ class PositionTest extends \PHPUnit\Framework\TestCase
*/ */
public function testSerialize() : void public function testSerialize() : void
{ {
$this->position->setName('Name'); $this->position->name = 'Name';
$this->position->setDescription('Description'); $this->position->description = 'Description';
$this->position->setDescriptionRaw('DescriptionRaw'); $this->position->descriptionRaw = 'DescriptionRaw';
$this->position->setStatus(Status::ACTIVE); $this->position->setStatus(Status::ACTIVE);
$this->position->setParent($p = new NullPosition(1)); $this->position->parent = ($p = new NullPosition(1));
$this->position->setDepartment($d = new NullDepartment(1)); $this->position->department = ($d = new NullDepartment(1));
self::assertEquals($this->position->toArray(), $this->position->jsonSerialize()); self::assertEquals($this->position->toArray(), $this->position->jsonSerialize());
self::assertEquals( self::assertEquals(

View File

@ -30,16 +30,16 @@ class UnitMapperTest extends \PHPUnit\Framework\TestCase
public function testCRUD() : void public function testCRUD() : void
{ {
$unit = new Unit(); $unit = new Unit();
$unit->setName('Scrooge Inc.'); $unit->name = 'Scrooge Inc.';
$unit->setDescription('Description'); $unit->description = 'Description';
$unit->setParent(new NullUnit(1)); $unit->parent = new NullUnit(1);
$id = UnitMapper::create($unit); $id = UnitMapper::create($unit);
$unitR = UnitMapper::get($id); $unitR = UnitMapper::get($id);
self::assertEquals($id, $unitR->getId()); self::assertEquals($id, $unitR->getId());
self::assertEquals($unit->getName(), $unitR->getName()); self::assertEquals($unit->name, $unitR->name);
self::assertEquals($unit->getDescription(), $unitR->getDescription()); self::assertEquals($unit->description, $unitR->description);
self::assertEquals($unit->getParent()->getId(), $unitR->getParent()->getId()); self::assertEquals($unit->parent->getId(), $unitR->parent->getId());
} }
} }

View File

@ -38,11 +38,11 @@ class UnitTest extends \PHPUnit\Framework\TestCase
public function testDefault() : void public function testDefault() : void
{ {
self::assertEquals(0, $this->unit->getId()); self::assertEquals(0, $this->unit->getId());
self::assertEquals('', $this->unit->getName()); self::assertEquals('', $this->unit->name);
self::assertEquals('', $this->unit->getDescription()); self::assertEquals('', $this->unit->description);
self::assertEquals('', $this->unit->getDescriptionRaw()); self::assertEquals('', $this->unit->descriptionRaw);
self::assertInstanceOf('Modules\Organization\Models\NullUnit', $this->unit->getParent()); self::assertInstanceOf('Modules\Organization\Models\NullUnit', $this->unit->parent);
self::assertInstanceOf('Modules\Media\Models\NullMedia', $this->unit->getImage()); self::assertInstanceOf('Modules\Media\Models\NullMedia', $this->unit->image);
self::assertEquals(Status::INACTIVE, $this->unit->getStatus()); self::assertEquals(Status::INACTIVE, $this->unit->getStatus());
} }
@ -52,8 +52,8 @@ class UnitTest extends \PHPUnit\Framework\TestCase
*/ */
public function testNameInputOutput() : void public function testNameInputOutput() : void
{ {
$this->unit->setName('Name'); $this->unit->name = 'Name';
self::assertEquals('Name', $this->unit->getName()); self::assertEquals('Name', $this->unit->name);
} }
/** /**
@ -72,8 +72,8 @@ class UnitTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDescriptionInputOutput() : void public function testDescriptionInputOutput() : void
{ {
$this->unit->setDescription('Description'); $this->unit->description = 'Description';
self::assertEquals('Description', $this->unit->getDescription()); self::assertEquals('Description', $this->unit->description);
} }
/** /**
@ -82,8 +82,8 @@ class UnitTest extends \PHPUnit\Framework\TestCase
*/ */
public function testDescriptionRawInputOutput() : void public function testDescriptionRawInputOutput() : void
{ {
$this->unit->setDescriptionRaw('DescriptionRaw'); $this->unit->descriptionRaw = 'DescriptionRaw';
self::assertEquals('DescriptionRaw', $this->unit->getDescriptionRaw()); self::assertEquals('DescriptionRaw', $this->unit->descriptionRaw);
} }
/** /**
@ -92,8 +92,8 @@ class UnitTest extends \PHPUnit\Framework\TestCase
*/ */
public function testParentInputOutput() : void public function testParentInputOutput() : void
{ {
$this->unit->setParent(new NullUnit(1)); $this->unit->parent = new NullUnit(1);
self::assertEquals(1, $this->unit->getParent()->getId()); self::assertEquals(1, $this->unit->parent->getId());
} }
/** /**
@ -102,8 +102,8 @@ class UnitTest extends \PHPUnit\Framework\TestCase
*/ */
public function testImageInputOutput() : void public function testImageInputOutput() : void
{ {
$this->unit->setImage(new NullMedia(1)); $this->unit->image = new NullMedia(1);
self::assertEquals(1, $this->unit->getImage()->getId()); self::assertEquals(1, $this->unit->image->getId());
} }
/** /**
@ -112,12 +112,12 @@ class UnitTest extends \PHPUnit\Framework\TestCase
*/ */
public function testSerialize() : void public function testSerialize() : void
{ {
$this->unit->setName('Name'); $this->unit->name = 'Name';
$this->unit->setDescription('Description'); $this->unit->description = 'Description';
$this->unit->setDescriptionRaw('DescriptionRaw'); $this->unit->descriptionRaw = 'DescriptionRaw';
$this->unit->setStatus(Status::ACTIVE); $this->unit->setStatus(Status::ACTIVE);
$this->unit->setParent($p = new NullUnit(1)); $this->unit->parent = ($p = new NullUnit(1));
$this->unit->setImage($i = new NullMedia(1)); $this->unit->image = ($i = new NullMedia(1));
self::assertEquals($this->unit->toArray(), $this->unit->jsonSerialize()); self::assertEquals($this->unit->toArray(), $this->unit->jsonSerialize());
self::assertEquals( self::assertEquals(