From 2876f490f8f453b13257142c09b82e6bfe9d9671 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 28 Sep 2016 22:07:54 +0200 Subject: [PATCH 01/11] Preparing for query extension implementing media for task/task elements and preparing for unit parent display. --- Models/DepartmentMapper.php | 7 +++++++ Models/PositionMapper.php | 7 +++++++ Models/UnitMapper.php | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/Models/DepartmentMapper.php b/Models/DepartmentMapper.php index 25bd3d0..a3522b4 100644 --- a/Models/DepartmentMapper.php +++ b/Models/DepartmentMapper.php @@ -33,6 +33,13 @@ class DepartmentMapper extends DataMapperAbstract 'organization_department_unit' => ['name' => 'organization_department_unit', 'type' => 'int', 'internal' => 'unit'], ]; + protected static $belongsTo = [ + 'account' => [ + 'mapper' => UnitMapper::class, + 'dest' => 'organization_department_unit', + ], + ]; + /** * Primary table. * diff --git a/Models/PositionMapper.php b/Models/PositionMapper.php index df6ee5a..b67ea58 100644 --- a/Models/PositionMapper.php +++ b/Models/PositionMapper.php @@ -33,6 +33,13 @@ class PositionMapper extends DataMapperAbstract 'organization_position_parent' => ['name' => 'organization_position_parent', 'type' => 'int', 'internal' => 'parent'], ]; + protected static $belongsTo = [ + 'account' => [ + 'mapper' => PositionMapper::class, + 'dest' => 'organization_position_parent', + ], + ]; + /** * Primary table. * diff --git a/Models/UnitMapper.php b/Models/UnitMapper.php index f7148c7..23f4245 100644 --- a/Models/UnitMapper.php +++ b/Models/UnitMapper.php @@ -32,6 +32,13 @@ class UnitMapper extends DataMapperAbstract 'organization_unit_parent' => ['name' => 'organization_unit_parent', 'type' => 'int', 'internal' => 'parent'], ]; + protected static $belongsTo = [ + 'account' => [ + 'mapper' => UnitMapper::class, + 'dest' => 'organization_uni_parent', + ], + ]; + /** * Primary table. * From 9500ba9f768445b9dc03fcbf73469aeb18708553 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 2 Oct 2016 12:07:05 +0200 Subject: [PATCH 02/11] Core adjustments for pending issues --- Admin/Installer.php | 3 ++ Admin/Routes/Web/Api.php | 24 +++++++++++++ Admin/Routes/Web/Backend.php | 19 ----------- Controller.php | 56 +++++++++++++++++++++++++++++++ Models/Department.php | 12 +++++++ Models/DepartmentMapper.php | 1 + Models/Position.php | 12 +++++++ Models/PositionMapper.php | 1 + Models/Status.php | 38 +++++++++++++++++++++ Models/Unit.php | 12 +++++++ Models/UnitMapper.php | 1 + Theme/Backend/unit-create.tpl.php | 2 +- 12 files changed, 161 insertions(+), 20 deletions(-) create mode 100644 Admin/Routes/Web/Api.php create mode 100644 Models/Status.php diff --git a/Admin/Installer.php b/Admin/Installer.php index 70432ef..b675b8b 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -49,6 +49,7 @@ class Installer extends InstallerAbstract `organization_unit_name` varchar(50) DEFAULT NULL, `organization_unit_description` varchar(255) DEFAULT NULL, `organization_unit_parent` int(11) DEFAULT NULL, + `organization_unit_status` int(3) DEFAULT NULL, PRIMARY KEY (`organization_unit_id`), KEY `organization_unit_parent` (`organization_unit_parent`) )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' @@ -65,6 +66,7 @@ class Installer extends InstallerAbstract `organization_department_name` varchar(30) DEFAULT NULL, `organization_department_description` varchar(255) DEFAULT NULL, `organization_department_parent` int(11) DEFAULT NULL, + `organization_department_status` int(3) DEFAULT NULL, `organization_department_unit` int(11) NOT NULL, PRIMARY KEY (`organization_department_id`), KEY `organization_department_parent` (`organization_department_parent`), @@ -84,6 +86,7 @@ class Installer extends InstallerAbstract `organization_position_name` varchar(50) DEFAULT NULL, `organization_position_description` varchar(255) DEFAULT NULL, `organization_position_parent` int(11) DEFAULT NULL, + `organization_position_status` int(3) DEFAULT NULL, PRIMARY KEY (`organization_position_id`), KEY `organization_position_parent` (`organization_position_parent`) )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' diff --git a/Admin/Routes/Web/Api.php b/Admin/Routes/Web/Api.php new file mode 100644 index 0000000..cff7c8e --- /dev/null +++ b/Admin/Routes/Web/Api.php @@ -0,0 +1,24 @@ + [ + [ + 'dest' => '\Modules\Organization\Controller:apiPositionCreate', + 'verb' => RouteVerb::SET, + ], + ], + '^.*/api/organization/department.*$' => [ + [ + 'dest' => '\Modules\Organization\Controller:apiDepartmentCreate', + 'verb' => RouteVerb::SET, + ], + ], + '^.*/api/organization/unit.*$' => [ + [ + 'dest' => '\Modules\Organization\Controller:apiUnitCreate', + 'verb' => RouteVerb::SET, + ], + ], +]; diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index 428da30..47b2ee1 100644 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -57,23 +57,4 @@ return [ 'verb' => RouteVerb::GET, ], ], - - '^.*/api/organization/position.*$' => [ - [ - 'dest' => '\Modules\Organization\Controller:apiPositionCreate', - 'verb' => RouteVerb::SET, - ], - ], - '^.*/api/organization/department.*$' => [ - [ - 'dest' => '\Modules\Organization\Controller:apiDepartmentCreate', - 'verb' => RouteVerb::SET, - ], - ], - '^.*/api/organization/unit.*$' => [ - [ - 'dest' => '\Modules\Organization\Controller:apiUnitCreate', - 'verb' => RouteVerb::SET, - ], - ], ]; diff --git a/Controller.php b/Controller.php index 78cddd4..044a150 100644 --- a/Controller.php +++ b/Controller.php @@ -15,10 +15,12 @@ */ namespace Modules\Organization; +use Model\Message\FormValidation; use Modules\Organization\Models\Department; use Modules\Organization\Models\DepartmentMapper; use Modules\Organization\Models\Position; use Modules\Organization\Models\PositionMapper; +use Modules\Organization\Models\Status; use Modules\Organization\Models\Unit; use Modules\Organization\Models\UnitMapper; use phpOMS\Message\RequestAbstract; @@ -263,8 +265,26 @@ class Controller extends ModuleAbstract implements WebInterface public function apiUnitCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) { + $val = []; + if ( + $val['name'] = empty($request->getData('name')) + || $val['parent'] = ( + $request->getData('parent') !== null + && !is_numeric($request->getData('parent')) + ) + || $val['status'] = ( + $request->getData('status') === null + || !Status::isValidValue((int) $request->getData('status')) + ) + ) { + $response->set('unit_create_validation', new FormValidation($val)); + + return; + } + $unit = new Unit(); $unit->setName($request->getData('name')); + $unit->setStatus((int) $request->getData('status')); $unit->setDescription($request->getData('desc')); UnitMapper::create($unit); @@ -274,8 +294,26 @@ class Controller extends ModuleAbstract implements WebInterface public function apiPositionCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) { + $val = []; + if ( + $val['name'] = empty($request->getData('name')) + || $val['parent'] = ( + $request->getData('parent') !== null + && !is_numeric($request->getData('parent')) + ) + || $val['status'] = ( + $request->getData('status') === null + || !Status::isValidValue((int) $request->getData('status')) + ) + ) { + $response->set('position_create_validation', new FormValidation($val)); + + return; + } + $position = new Position(); $position->setName($request->getData('name')); + $position->setStatus((int) $request->getData('status')); $position->setDescription($request->getData('desc')); PositionMapper::create($position); @@ -285,8 +323,26 @@ class Controller extends ModuleAbstract implements WebInterface public function apiDepartmentCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) { + $val = []; + if ( + $val['name'] = empty($request->getData('name')) + || $val['parent'] = ( + $request->getData('parent') !== null + && !is_numeric((int) $request->getData('parent')) + ) + || $val['status'] = ( + $request->getData('status') === null + || !Status::isValidValue($request->getData('status')) + ) + ) { + $response->set('department_create_validation', new FormValidation($val)); + + return; + } + $department = new Department(); $department->setName($request->getData('name')); + $department->setStatus((int) $request->getData('status')); $department->setDescription($request->getData('desc')); DepartmentMapper::create($department); diff --git a/Models/Department.php b/Models/Department.php index 1cdcf2d..97e1873 100644 --- a/Models/Department.php +++ b/Models/Department.php @@ -23,6 +23,8 @@ class Department protected $parent = null; + protected $status = Status::INACTIVE; + protected $unit = 1; protected $description = ''; @@ -52,6 +54,16 @@ class Department $this->parent = $parent; } + public function getStatus() : int + { + return $this->status; + } + + public function setStatus(int $status) + { + $this->status = $status; + } + public function getUnit() : int { return $this->unit; diff --git a/Models/DepartmentMapper.php b/Models/DepartmentMapper.php index 25bd3d0..0790d87 100644 --- a/Models/DepartmentMapper.php +++ b/Models/DepartmentMapper.php @@ -30,6 +30,7 @@ class DepartmentMapper extends DataMapperAbstract 'organization_department_name' => ['name' => 'organization_department_name', 'type' => 'string', 'internal' => 'name'], 'organization_department_description' => ['name' => 'organization_department_description', 'type' => 'string', 'internal' => 'description'], 'organization_department_parent' => ['name' => 'organization_department_parent', 'type' => 'int', 'internal' => 'parent'], + 'organization_department_status' => ['name' => 'organization_department_status', 'type' => 'int', 'internal' => 'status'], 'organization_department_unit' => ['name' => 'organization_department_unit', 'type' => 'int', 'internal' => 'unit'], ]; diff --git a/Models/Position.php b/Models/Position.php index a37f649..5223f63 100644 --- a/Models/Position.php +++ b/Models/Position.php @@ -27,6 +27,8 @@ class Position implements ArrayableInterface, \JsonSerializable private $description = ''; + protected $status = Status::INACTIVE; + public function getId() : int { return $this->id; @@ -52,6 +54,16 @@ class Position implements ArrayableInterface, \JsonSerializable $this->parent = $parent; } + public function getStatus() : int + { + return $this->status; + } + + public function setStatus(int $status) + { + $this->status = $status; + } + public function getDescription() : string { return $this->description; diff --git a/Models/PositionMapper.php b/Models/PositionMapper.php index df6ee5a..9b441c3 100644 --- a/Models/PositionMapper.php +++ b/Models/PositionMapper.php @@ -31,6 +31,7 @@ class PositionMapper extends DataMapperAbstract 'organization_position_name' => ['name' => 'organization_position_name', 'type' => 'string', 'internal' => 'name'], 'organization_position_description' => ['name' => 'organization_position_description', 'type' => 'string', 'internal' => 'description'], 'organization_position_parent' => ['name' => 'organization_position_parent', 'type' => 'int', 'internal' => 'parent'], + 'organization_position_status' => ['name' => 'organization_position_status', 'type' => 'int', 'internal' => 'status'], ]; /** diff --git a/Models/Status.php b/Models/Status.php new file mode 100644 index 0000000..1826a9c --- /dev/null +++ b/Models/Status.php @@ -0,0 +1,38 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Organization\Models; + +use phpOMS\Datatypes\Enum; + +/** + * Accept status enum. + * + * @category Calendar + * @package Modules + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class Status extends Enum +{ + const ACTIVE = 1; + + const INACTIVE = 2; + + const HIDDEN = 4; +} diff --git a/Models/Unit.php b/Models/Unit.php index 6fe6f18..62ebeb2 100644 --- a/Models/Unit.php +++ b/Models/Unit.php @@ -27,6 +27,8 @@ class Unit implements ArrayableInterface, \JsonSerializable private $description = ''; + protected $status = Status::INACTIVE; + public function getId() : int { return $this->id; @@ -52,6 +54,16 @@ class Unit implements ArrayableInterface, \JsonSerializable $this->parent = $parent; } + public function getStatus() : int + { + return $this->status; + } + + public function setStatus(int $status) + { + $this->status = $status; + } + public function getDescription() : string { return $this->description; diff --git a/Models/UnitMapper.php b/Models/UnitMapper.php index f7148c7..df38f35 100644 --- a/Models/UnitMapper.php +++ b/Models/UnitMapper.php @@ -30,6 +30,7 @@ class UnitMapper extends DataMapperAbstract 'organization_unit_name' => ['name' => 'organization_unit_name', 'type' => 'string', 'internal' => 'name'], 'organization_unit_description' => ['name' => 'organization_unit_description', 'type' => 'string', 'internal' => 'description'], 'organization_unit_parent' => ['name' => 'organization_unit_parent', 'type' => 'int', 'internal' => 'parent'], + 'organization_unit_status' => ['name' => 'organization_unit_status', 'type' => 'int', 'internal' => 'status'], ]; /** diff --git a/Theme/Backend/unit-create.tpl.php b/Theme/Backend/unit-create.tpl.php index bc5658f..7f9af81 100644 --- a/Theme/Backend/unit-create.tpl.php +++ b/Theme/Backend/unit-create.tpl.php @@ -22,7 +22,7 @@ echo $this->getData('nav')->render(); ?>

getText('Unit'); ?>

-
+
From 61567348c65f5e1ee456f8b7d0fab5eb5a5f7c66 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 9 Oct 2016 20:07:30 +0200 Subject: [PATCH 03/11] Fix install --- Admin/Install/Navigation.php | 2 +- Admin/Installer.php | 4 ++-- Controller.php | 30 +++++++++++++++--------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index 53a7305..fa8d40a 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -32,7 +32,7 @@ class Navigation /** * {@inheritdoc} */ - public static function install(Pool $dbPool) + public static function install(string $path, Pool $dbPool) { $navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); diff --git a/Admin/Installer.php b/Admin/Installer.php index b675b8b..c1a85d0 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -37,9 +37,9 @@ class Installer extends InstallerAbstract /** * {@inheritdoc} */ - public static function install(Pool $dbPool, InfoManager $info) + public static function install(string $path, Pool $dbPool, InfoManager $info) { - parent::install($dbPool, $info); + parent::install($path, $dbPool, $info); switch ($dbPool->get('core')->getType()) { case DatabaseType::MYSQL: diff --git a/Controller.php b/Controller.php index 044a150..9301742 100644 --- a/Controller.php +++ b/Controller.php @@ -267,15 +267,15 @@ class Controller extends ModuleAbstract implements WebInterface { $val = []; if ( - $val['name'] = empty($request->getData('name')) - || $val['parent'] = ( + ($val['name'] = empty($request->getData('name'))) + || ($val['parent'] = ( $request->getData('parent') !== null && !is_numeric($request->getData('parent')) - ) - || $val['status'] = ( + )) + || ($val['status'] = ( $request->getData('status') === null || !Status::isValidValue((int) $request->getData('status')) - ) + )) ) { $response->set('unit_create_validation', new FormValidation($val)); @@ -296,15 +296,15 @@ class Controller extends ModuleAbstract implements WebInterface { $val = []; if ( - $val['name'] = empty($request->getData('name')) - || $val['parent'] = ( + ($val['name'] = empty($request->getData('name'))) + || ($val['parent'] = ( $request->getData('parent') !== null && !is_numeric($request->getData('parent')) - ) - || $val['status'] = ( + )) + || ($val['status'] = ( $request->getData('status') === null || !Status::isValidValue((int) $request->getData('status')) - ) + )) ) { $response->set('position_create_validation', new FormValidation($val)); @@ -325,14 +325,14 @@ class Controller extends ModuleAbstract implements WebInterface { $val = []; if ( - $val['name'] = empty($request->getData('name')) - || $val['parent'] = ( + ($val['name'] = empty($request->getData('name'))) + || ($val['parent'] = ( $request->getData('parent') !== null && !is_numeric((int) $request->getData('parent')) - ) - || $val['status'] = ( + )) + || ($val['status'] = ( $request->getData('status') === null - || !Status::isValidValue($request->getData('status')) + || !Status::isValidValue($request->getData('status'))) ) ) { $response->set('department_create_validation', new FormValidation($val)); From e8601e9d8b08e560133e4d67084af950f03c0046 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 17 Oct 2016 22:00:09 +0200 Subject: [PATCH 04/11] Localization fix --- Theme/Backend/department-profile.php | 2 +- Theme/Backend/position-profile.tpl.php | 2 +- Theme/Backend/unit-profile.tpl.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Theme/Backend/department-profile.php b/Theme/Backend/department-profile.php index c31dfa7..c51790d 100644 --- a/Theme/Backend/department-profile.php +++ b/Theme/Backend/department-profile.php @@ -37,7 +37,7 @@ echo $this->getData('nav')->render(); ?>
-
+
diff --git a/Theme/Backend/position-profile.tpl.php b/Theme/Backend/position-profile.tpl.php index d5d680f..237d815 100644 --- a/Theme/Backend/position-profile.tpl.php +++ b/Theme/Backend/position-profile.tpl.php @@ -37,7 +37,7 @@ echo $this->getData('nav')->render(); ?> - + diff --git a/Theme/Backend/unit-profile.tpl.php b/Theme/Backend/unit-profile.tpl.php index 48af8db..82a86d3 100644 --- a/Theme/Backend/unit-profile.tpl.php +++ b/Theme/Backend/unit-profile.tpl.php @@ -37,7 +37,7 @@ echo $this->getData('nav')->render(); ?> - + From 7f5e9a8b850df09c52f2b2c0c0c2a6bf7fb0444d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 29 Oct 2016 20:44:52 +0200 Subject: [PATCH 05/11] Adjust database pool name --- Admin/Activate.php | 4 ++-- Admin/Deactivate.php | 4 ++-- Admin/Install/Navigation.php | 4 ++-- Admin/Installer.php | 4 ++-- Admin/Uninstall.php | 4 ++-- Admin/Update.php | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Admin/Activate.php b/Admin/Activate.php index c2c3ab0..25f1790 100644 --- a/Admin/Activate.php +++ b/Admin/Activate.php @@ -16,7 +16,7 @@ namespace Modules\Organization\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\ActivateAbstract; use phpOMS\Module\InfoManager; @@ -37,7 +37,7 @@ class Activate extends ActivateAbstract /** * {@inheritdoc} */ - public static function activate(Pool $dbPool, InfoManager $info) + public static function activate(DatabasePool $dbPool, InfoManager $info) { parent::activate($dbPool, $info); } diff --git a/Admin/Deactivate.php b/Admin/Deactivate.php index 4e109c2..2fb6928 100644 --- a/Admin/Deactivate.php +++ b/Admin/Deactivate.php @@ -16,7 +16,7 @@ namespace Modules\Organization\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\DeactivateAbstract; use phpOMS\Module\InfoManager; @@ -37,7 +37,7 @@ class Deactivate extends DeactivateAbstract /** * {@inheritdoc} */ - public static function deactivate(Pool $dbPool, InfoManager $info) + public static function deactivate(DatabasePool $dbPool, InfoManager $info) { parent::deactivate($dbPool, $info); } diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index fa8d40a..bc2da57 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -14,7 +14,7 @@ * @link http://orange-management.com */ namespace Modules\Organization\Admin\Install; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; /** * Navigation class. @@ -32,7 +32,7 @@ class Navigation /** * {@inheritdoc} */ - public static function install(string $path, Pool $dbPool) + public static function install(string $path, DatabasePool $dbPool) { $navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); diff --git a/Admin/Installer.php b/Admin/Installer.php index c1a85d0..e92b558 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -16,7 +16,7 @@ namespace Modules\Organization\Admin; use phpOMS\DataStorage\Database\DatabaseType; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\InfoManager; use phpOMS\Module\InstallerAbstract; @@ -37,7 +37,7 @@ class Installer extends InstallerAbstract /** * {@inheritdoc} */ - public static function install(string $path, Pool $dbPool, InfoManager $info) + public static function install(string $path, DatabasePool $dbPool, InfoManager $info) { parent::install($path, $dbPool, $info); diff --git a/Admin/Uninstall.php b/Admin/Uninstall.php index 3480584..44c2a22 100644 --- a/Admin/Uninstall.php +++ b/Admin/Uninstall.php @@ -16,7 +16,7 @@ namespace Modules\Organization\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\DataStorage\Database\Schema\Builder; use phpOMS\Module\UninstallAbstract; @@ -37,7 +37,7 @@ class Uninstall extends UninstallAbstract /** * {@inheritdoc} */ - public static function uninstall(Pool $dbPool, InfoManager $info) + public static function uninstall(DatabasePool $dbPool, InfoManager $info) { parent::uninstall($dbPool, $info); diff --git a/Admin/Update.php b/Admin/Update.php index c310c15..ddf5899 100644 --- a/Admin/Update.php +++ b/Admin/Update.php @@ -16,7 +16,7 @@ namespace Modules\Organization\Admin; -use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\DatabasePool; use phpOMS\Module\UpdateAbstract; use phpOMS\System\File\Directory; @@ -37,7 +37,7 @@ class Update extends UpdateAbstract /** * {@inheritdoc} */ - public static function update(Pool $dbPool, array $info) + public static function update(DatabasePool $dbPool, array $info) { Directory::deletePath(__DIR__ . '/Update'); mkdir('Update'); From 62c349d3d326c17006ca3baeb4627fd36b558b48 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 5 Nov 2016 22:23:48 +0100 Subject: [PATCH 06/11] Create units --- Controller.php | 31 ++++++++++++++++++++----------- Models/Unit.php | 4 ++-- Theme/Backend/unit-create.tpl.php | 4 ++-- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Controller.php b/Controller.php index 9301742..966b167 100644 --- a/Controller.php +++ b/Controller.php @@ -263,29 +263,38 @@ class Controller extends ModuleAbstract implements WebInterface return $view; } - public function apiUnitCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) + private function validateUnitCreate(RequestAbstract $request) : array { $val = []; if ( - ($val['name'] = empty($request->getData('name'))) + ($val['name'] = empty($request->getData('name'))) || ($val['parent'] = ( - $request->getData('parent') !== null - && !is_numeric($request->getData('parent')) - )) - || ($val['status'] = ( - $request->getData('status') === null - || !Status::isValidValue((int) $request->getData('status')) - )) + !empty($request->getData('parent')) + && !is_numeric($request->getData('parent')) + )) + || ($val['status'] = ( + $request->getData('status') === null + || !Status::isValidValue((int) $request->getData('status')) + )) ) { - $response->set('unit_create_validation', new FormValidation($val)); + return $val; + } + + return []; + } + + public function apiUnitCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + if (!empty($val = $this->validateUnitCreate($request))) { + $response->set('unit_create', new FormValidation($val)); return; } $unit = new Unit(); $unit->setName($request->getData('name')); + $unit->setDescription($request->getData('description') ?? ''); $unit->setStatus((int) $request->getData('status')); - $unit->setDescription($request->getData('desc')); UnitMapper::create($unit); diff --git a/Models/Unit.php b/Models/Unit.php index 62ebeb2..a30fd33 100644 --- a/Models/Unit.php +++ b/Models/Unit.php @@ -23,7 +23,7 @@ class Unit implements ArrayableInterface, \JsonSerializable private $name = ''; - private $parent = 0; + private $parent = null; private $description = ''; @@ -44,7 +44,7 @@ class Unit implements ArrayableInterface, \JsonSerializable $this->name = $name; } - public function getParent() : int + public function getParent() { return $this->parent; } diff --git a/Theme/Backend/unit-create.tpl.php b/Theme/Backend/unit-create.tpl.php index 7f9af81..6a827f3 100644 --- a/Theme/Backend/unit-create.tpl.php +++ b/Theme/Backend/unit-create.tpl.php @@ -30,8 +30,8 @@ echo $this->getData('nav')->render(); ?> From 50991ef65551c9d8f1946571b1f1f6ead36a46a1 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 6 Nov 2016 22:22:07 +0100 Subject: [PATCH 07/11] Fixing doc blocks --- Models/DepartmentMapper.php | 2 +- Models/PositionMapper.php | 2 +- Models/UnitMapper.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Models/DepartmentMapper.php b/Models/DepartmentMapper.php index 2f6ca5c..f532697 100644 --- a/Models/DepartmentMapper.php +++ b/Models/DepartmentMapper.php @@ -22,7 +22,7 @@ class DepartmentMapper extends DataMapperAbstract /** * Columns. * - * @var array + * @var array * @since 1.0.0 */ protected static $columns = [ diff --git a/Models/PositionMapper.php b/Models/PositionMapper.php index 989a391..a153e8d 100644 --- a/Models/PositionMapper.php +++ b/Models/PositionMapper.php @@ -23,7 +23,7 @@ class PositionMapper extends DataMapperAbstract /** * Columns. * - * @var array + * @var array * @since 1.0.0 */ protected static $columns = [ diff --git a/Models/UnitMapper.php b/Models/UnitMapper.php index 485b408..9735d0f 100644 --- a/Models/UnitMapper.php +++ b/Models/UnitMapper.php @@ -22,7 +22,7 @@ class UnitMapper extends DataMapperAbstract /** * Columns. * - * @var array + * @var array * @since 1.0.0 */ protected static $columns = [ From 65788f9a139fb1b7affbc121bc6706f303de6cf8 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 15 Nov 2016 16:54:43 +0100 Subject: [PATCH 08/11] Fixed organization CRD --- Controller.php | 65 ++++++++++++------- Theme/Backend/department-create.tpl.php | 2 +- Theme/Backend/department-list.tpl.php | 2 +- ...profile.php => department-profile.tpl.php} | 2 +- Theme/Backend/position-create.tpl.php | 6 +- Theme/Backend/position-list.tpl.php | 2 +- Theme/Backend/position-profile.tpl.php | 8 +-- Theme/Backend/unit-create.tpl.php | 2 +- 8 files changed, 55 insertions(+), 34 deletions(-) rename Theme/Backend/{department-profile.php => department-profile.tpl.php} (96%) diff --git a/Controller.php b/Controller.php index 966b167..a93880c 100644 --- a/Controller.php +++ b/Controller.php @@ -222,6 +222,8 @@ class Controller extends ModuleAbstract implements WebInterface $view->setTemplate('/Modules/Organization/Theme/Backend/position-list'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004704001, $request, $response)); + $view->addData('list:elements', PositionMapper::getAll()); + return $view; } @@ -241,6 +243,8 @@ class Controller extends ModuleAbstract implements WebInterface $view->setTemplate('/Modules/Organization/Theme/Backend/position-profile'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004704001, $request, $response)); + $view->addData('position', PositionMapper::get((int) $request->getData('id'))); + return $view; } @@ -301,21 +305,30 @@ class Controller extends ModuleAbstract implements WebInterface $response->set('unit', $unit->jsonSerialize()); } - public function apiPositionCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) + private function validatePositionCreate(RequestAbstract $request) : array { $val = []; if ( - ($val['name'] = empty($request->getData('name'))) + ($val['name'] = empty($request->getData('name'))) || ($val['parent'] = ( - $request->getData('parent') !== null - && !is_numeric($request->getData('parent')) - )) - || ($val['status'] = ( - $request->getData('status') === null - || !Status::isValidValue((int) $request->getData('status')) - )) + !empty($request->getData('parent')) + && !is_numeric($request->getData('parent')) + )) + || ($val['status'] = ( + $request->getData('status') === null + || !Status::isValidValue((int) $request->getData('status')) + )) ) { - $response->set('position_create_validation', new FormValidation($val)); + return $val; + } + + return []; + } + + public function apiPositionCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + if (!empty($val = $this->validatePositionCreate($request))) { + $response->set('position_create', new FormValidation($val)); return; } @@ -323,28 +336,36 @@ class Controller extends ModuleAbstract implements WebInterface $position = new Position(); $position->setName($request->getData('name')); $position->setStatus((int) $request->getData('status')); - $position->setDescription($request->getData('desc')); + $position->setDescription($request->getData('description') ?? ''); PositionMapper::create($position); $response->set('position', $position->jsonSerialize()); } - public function apiDepartmentCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) + private function validateDepartmentCreate(RequestAbstract $request) : array { $val = []; if ( - ($val['name'] = empty($request->getData('name'))) + ($val['name'] = empty($request->getData('name'))) || ($val['parent'] = ( - $request->getData('parent') !== null - && !is_numeric((int) $request->getData('parent')) - )) - || ($val['status'] = ( - $request->getData('status') === null - || !Status::isValidValue($request->getData('status'))) - ) + !empty($request->getData('parent')) + && !is_numeric($request->getData('parent')) + )) + || ($val['unit'] = ( + !is_numeric((int) $request->getData('unit')) + )) ) { - $response->set('department_create_validation', new FormValidation($val)); + return $val; + } + + return []; + } + + public function apiDepartmentCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) + { + if (!empty($val = $this->validateDepartmentCreate($request))) { + $response->set('department_create', new FormValidation($val)); return; } @@ -352,7 +373,7 @@ class Controller extends ModuleAbstract implements WebInterface $department = new Department(); $department->setName($request->getData('name')); $department->setStatus((int) $request->getData('status')); - $department->setDescription($request->getData('desc')); + $department->setDescription($request->getData('description') ?? ''); DepartmentMapper::create($department); diff --git a/Theme/Backend/department-create.tpl.php b/Theme/Backend/department-create.tpl.php index 63da223..a9683dc 100644 --- a/Theme/Backend/department-create.tpl.php +++ b/Theme/Backend/department-create.tpl.php @@ -22,7 +22,7 @@ echo $this->getData('nav')->render(); ?>

getText('Department'); ?>

-
+ getData('list:elements') as $key => $value) : $c++; - $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/business/department/profile?id=' . $value->getId()); ?> + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/organization/department/profile?id=' . $value->getId()); ?>
diff --git a/Theme/Backend/department-list.tpl.php b/Theme/Backend/department-list.tpl.php index 0ec3185..7f4d2a8 100644 --- a/Theme/Backend/department-list.tpl.php +++ b/Theme/Backend/department-list.tpl.php @@ -39,7 +39,7 @@ echo $this->getData('nav')->render(); ?>
render(); ?>
getId(); ?> getName(); ?> diff --git a/Theme/Backend/department-profile.php b/Theme/Backend/department-profile.tpl.php similarity index 96% rename from Theme/Backend/department-profile.php rename to Theme/Backend/department-profile.tpl.php index c51790d..5b4936e 100644 --- a/Theme/Backend/department-profile.php +++ b/Theme/Backend/department-profile.tpl.php @@ -22,7 +22,7 @@ $department = $this->getData('department'); echo $this->getData('nav')->render(); ?>
-

getText('Position'); ?>

+

getText('Department'); ?>

diff --git a/Theme/Backend/position-create.tpl.php b/Theme/Backend/position-create.tpl.php index 20bcbf7..64d38be 100644 --- a/Theme/Backend/position-create.tpl.php +++ b/Theme/Backend/position-create.tpl.php @@ -22,7 +22,7 @@ echo $this->getData('nav')->render(); ?>

getText('Position'); ?>

- +
$value) : $count++; - $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/business/unit/profile?id=' . $value->getId()); ?> + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/organization/position/profile?id=' . $value->getId()); ?>
@@ -30,8 +30,8 @@ echo $this->getData('nav')->render(); ?>
diff --git a/Theme/Backend/position-list.tpl.php b/Theme/Backend/position-list.tpl.php index 135dec5..4590659 100644 --- a/Theme/Backend/position-list.tpl.php +++ b/Theme/Backend/position-list.tpl.php @@ -40,7 +40,7 @@ echo $this->getData('nav')->render(); ?>
render(); ?>
getId(); ?> getName(); ?> diff --git a/Theme/Backend/position-profile.tpl.php b/Theme/Backend/position-profile.tpl.php index 237d815..a778d8d 100644 --- a/Theme/Backend/position-profile.tpl.php +++ b/Theme/Backend/position-profile.tpl.php @@ -17,7 +17,7 @@ * @var \phpOMS\Views\View $this */ -$unit = $this->getData('unit'); +$position = $this->getData('position'); echo $this->getData('nav')->render(); ?> @@ -27,16 +27,16 @@ echo $this->getData('nav')->render(); ?>
-
+
-
+
-
+
diff --git a/Theme/Backend/unit-create.tpl.php b/Theme/Backend/unit-create.tpl.php index 6a827f3..8ebd9b0 100644 --- a/Theme/Backend/unit-create.tpl.php +++ b/Theme/Backend/unit-create.tpl.php @@ -22,7 +22,7 @@ echo $this->getData('nav')->render(); ?>

getText('Unit'); ?>

-
+
From d71a321e3cdad894a121f641293050ebf8e19409 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 7 Dec 2016 20:23:04 +0100 Subject: [PATCH 09/11] Prepare const visibility --- Controller.php | 6 +++--- Models/Status.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Controller.php b/Controller.php index a93880c..5201335 100644 --- a/Controller.php +++ b/Controller.php @@ -49,7 +49,7 @@ class Controller extends ModuleAbstract implements WebInterface * @var string * @since 1.0.0 */ - const MODULE_PATH = __DIR__; + /* public */ const MODULE_PATH = __DIR__; /** * Module version. @@ -57,7 +57,7 @@ class Controller extends ModuleAbstract implements WebInterface * @var string * @since 1.0.0 */ - const MODULE_VERSION = '1.0.0'; + /* public */ const MODULE_VERSION = '1.0.0'; /** * Module name. @@ -65,7 +65,7 @@ class Controller extends ModuleAbstract implements WebInterface * @var string * @since 1.0.0 */ - const MODULE_NAME = 'Organization'; + /* public */ const MODULE_NAME = 'Organization'; /** * Providing. diff --git a/Models/Status.php b/Models/Status.php index 1826a9c..39cf217 100644 --- a/Models/Status.php +++ b/Models/Status.php @@ -30,9 +30,9 @@ use phpOMS\Datatypes\Enum; */ abstract class Status extends Enum { - const ACTIVE = 1; + /* public */ const ACTIVE = 1; - const INACTIVE = 2; + /* public */ const INACTIVE = 2; - const HIDDEN = 4; + /* public */ const HIDDEN = 4; } From 4ae251084647521c5848ab16be44db2aff289092 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Wed, 7 Dec 2016 20:56:15 +0100 Subject: [PATCH 10/11] Increase php version requirement --- Admin/Activate.php | 2 +- Admin/Deactivate.php | 2 +- Admin/Install/Navigation.php | 2 +- Admin/Installer.php | 2 +- Admin/Uninstall.php | 2 +- Admin/Update.php | 2 +- Controller.php | 2 +- Models/Department.php | 2 +- Models/DepartmentMapper.php | 2 +- Models/Position.php | 2 +- Models/PositionMapper.php | 2 +- Models/Status.php | 2 +- Models/Unit.php | 2 +- Models/UnitMapper.php | 2 +- Theme/Backend/Lang/Navigation.en.lang.php | 2 +- Theme/Backend/Lang/en.lang.php | 2 +- Theme/Backend/department-create.tpl.php | 2 +- Theme/Backend/department-list.tpl.php | 2 +- Theme/Backend/department-profile.tpl.php | 2 +- Theme/Backend/position-create.tpl.php | 2 +- Theme/Backend/position-list.tpl.php | 2 +- Theme/Backend/position-profile.tpl.php | 2 +- Theme/Backend/unit-create.tpl.php | 2 +- Theme/Backend/unit-list.tpl.php | 2 +- Theme/Backend/unit-profile.tpl.php | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Admin/Activate.php b/Admin/Activate.php index 25f1790..8340b2d 100644 --- a/Admin/Activate.php +++ b/Admin/Activate.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Admin/Deactivate.php b/Admin/Deactivate.php index 2fb6928..0a83ec4 100644 --- a/Admin/Deactivate.php +++ b/Admin/Deactivate.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index bc2da57..e6577f9 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Admin/Installer.php b/Admin/Installer.php index e92b558..b710067 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Admin/Uninstall.php b/Admin/Uninstall.php index 44c2a22..f271dc6 100644 --- a/Admin/Uninstall.php +++ b/Admin/Uninstall.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Admin/Update.php b/Admin/Update.php index ddf5899..7b828e1 100644 --- a/Admin/Update.php +++ b/Admin/Update.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Controller.php b/Controller.php index 5201335..dd7b608 100644 --- a/Controller.php +++ b/Controller.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Models/Department.php b/Models/Department.php index 97e1873..3c8f88c 100644 --- a/Models/Department.php +++ b/Models/Department.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Models/DepartmentMapper.php b/Models/DepartmentMapper.php index f532697..2da838c 100644 --- a/Models/DepartmentMapper.php +++ b/Models/DepartmentMapper.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Models/Position.php b/Models/Position.php index 5223f63..2b66201 100644 --- a/Models/Position.php +++ b/Models/Position.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Models/PositionMapper.php b/Models/PositionMapper.php index a153e8d..de97190 100644 --- a/Models/PositionMapper.php +++ b/Models/PositionMapper.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Models/Status.php b/Models/Status.php index 39cf217..04ca91e 100644 --- a/Models/Status.php +++ b/Models/Status.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Models/Unit.php b/Models/Unit.php index a30fd33..4f14a26 100644 --- a/Models/Unit.php +++ b/Models/Unit.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Models/UnitMapper.php b/Models/UnitMapper.php index 9735d0f..3fb42fe 100644 --- a/Models/UnitMapper.php +++ b/Models/UnitMapper.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index 90617f7..bd7900b 100644 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 253169f..5b85acb 100644 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/department-create.tpl.php b/Theme/Backend/department-create.tpl.php index a9683dc..1ad4b88 100644 --- a/Theme/Backend/department-create.tpl.php +++ b/Theme/Backend/department-create.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/department-list.tpl.php b/Theme/Backend/department-list.tpl.php index 7f4d2a8..175156f 100644 --- a/Theme/Backend/department-list.tpl.php +++ b/Theme/Backend/department-list.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/department-profile.tpl.php b/Theme/Backend/department-profile.tpl.php index 5b4936e..567686d 100644 --- a/Theme/Backend/department-profile.tpl.php +++ b/Theme/Backend/department-profile.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/position-create.tpl.php b/Theme/Backend/position-create.tpl.php index 64d38be..ffd674e 100644 --- a/Theme/Backend/position-create.tpl.php +++ b/Theme/Backend/position-create.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/position-list.tpl.php b/Theme/Backend/position-list.tpl.php index 4590659..1d16510 100644 --- a/Theme/Backend/position-list.tpl.php +++ b/Theme/Backend/position-list.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/position-profile.tpl.php b/Theme/Backend/position-profile.tpl.php index a778d8d..cf18fbc 100644 --- a/Theme/Backend/position-profile.tpl.php +++ b/Theme/Backend/position-profile.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/unit-create.tpl.php b/Theme/Backend/unit-create.tpl.php index 8ebd9b0..bdb71e9 100644 --- a/Theme/Backend/unit-create.tpl.php +++ b/Theme/Backend/unit-create.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/unit-list.tpl.php b/Theme/Backend/unit-list.tpl.php index b824f30..676aaab 100644 --- a/Theme/Backend/unit-list.tpl.php +++ b/Theme/Backend/unit-list.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD diff --git a/Theme/Backend/unit-profile.tpl.php b/Theme/Backend/unit-profile.tpl.php index 82a86d3..14ca196 100644 --- a/Theme/Backend/unit-profile.tpl.php +++ b/Theme/Backend/unit-profile.tpl.php @@ -2,7 +2,7 @@ /** * Orange Management * - * PHP Version 7.0 + * PHP Version 7.1 * * @category TBD * @package TBD From 2599e9adfb1b19ffcafbe991ae967b4d7115a7ed Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 22 Jan 2017 21:08:46 +0100 Subject: [PATCH 11/11] Fixing json serialization and reporter --- Models/Department.php | 4 ++-- Models/Position.php | 4 ++-- Models/Unit.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Models/Department.php b/Models/Department.php index 3c8f88c..157be34 100644 --- a/Models/Department.php +++ b/Models/Department.php @@ -104,7 +104,7 @@ class Department */ public function __toString() { - return $this->jsonSerialize(); + return json_encode($this->toArray()); } /** @@ -117,6 +117,6 @@ class Department */ public function jsonSerialize() { - return json_encode($this->toArray()); + return $this->toArray(); } } diff --git a/Models/Position.php b/Models/Position.php index 2b66201..2de467d 100644 --- a/Models/Position.php +++ b/Models/Position.php @@ -93,7 +93,7 @@ class Position implements ArrayableInterface, \JsonSerializable */ public function __toString() { - return $this->jsonSerialize(); + return json_encode($this->toArray()); } /** @@ -106,6 +106,6 @@ class Position implements ArrayableInterface, \JsonSerializable */ public function jsonSerialize() { - return json_encode($this->toArray()); + return $this->toArray(); } } diff --git a/Models/Unit.php b/Models/Unit.php index 4f14a26..2729f44 100644 --- a/Models/Unit.php +++ b/Models/Unit.php @@ -93,7 +93,7 @@ class Unit implements ArrayableInterface, \JsonSerializable */ public function __toString() { - return $this->jsonSerialize(); + return json_encode($this->toArray()); } /** @@ -106,6 +106,6 @@ class Unit implements ArrayableInterface, \JsonSerializable */ public function jsonSerialize() { - return json_encode($this->toArray()); + return $this->toArray(); } }