From 6009d573e4ba6a8764211c1299b0c5cbf311ba80 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 4 Feb 2016 18:43:37 +0100 Subject: [PATCH] Renaming business to organization --- Admin/Activate.php | 43 +++ Admin/Deactivate.php | 43 +++ Admin/Install/Navigation.install.json | 156 +++++++++++ Admin/Install/Navigation.php | 40 +++ Admin/Installer.php | 113 ++++++++ Admin/Uninstall.php | 54 ++++ Admin/Update.php | 46 ++++ Controller.php | 305 ++++++++++++++++++++++ Models/Department.php | 54 ++++ Models/DepartmentMapper.php | 52 ++++ Models/Unit.php | 47 ++++ Models/UnitMapper.php | 62 +++++ README.md | 1 + Theme/Backend/Lang/Navigation.en.lang.php | 21 ++ Theme/Backend/Lang/en.lang.php | 27 ++ Theme/Backend/department-create.tpl.php | 40 +++ Theme/Backend/department-list.tpl.php | 54 ++++ Theme/Backend/department-profile.php | 0 Theme/Backend/position-create.tpl.php | 42 +++ Theme/Backend/position-list.tpl.php | 48 ++++ Theme/Backend/position-profile.tpl.php | 44 ++++ Theme/Backend/unit-create.tpl.php | 42 +++ Theme/Backend/unit-list.tpl.php | 48 ++++ Theme/Backend/unit-profile.tpl.php | 44 ++++ info.json | 53 ++++ 25 files changed, 1479 insertions(+) create mode 100644 Admin/Activate.php create mode 100644 Admin/Deactivate.php create mode 100644 Admin/Install/Navigation.install.json create mode 100644 Admin/Install/Navigation.php create mode 100644 Admin/Installer.php create mode 100644 Admin/Uninstall.php create mode 100644 Admin/Update.php create mode 100644 Controller.php create mode 100644 Models/Department.php create mode 100644 Models/DepartmentMapper.php create mode 100644 Models/Unit.php create mode 100644 Models/UnitMapper.php create mode 100644 README.md create mode 100644 Theme/Backend/Lang/Navigation.en.lang.php create mode 100644 Theme/Backend/Lang/en.lang.php create mode 100644 Theme/Backend/department-create.tpl.php create mode 100644 Theme/Backend/department-list.tpl.php create mode 100644 Theme/Backend/department-profile.php create mode 100644 Theme/Backend/position-create.tpl.php create mode 100644 Theme/Backend/position-list.tpl.php create mode 100644 Theme/Backend/position-profile.tpl.php create mode 100644 Theme/Backend/unit-create.tpl.php create mode 100644 Theme/Backend/unit-list.tpl.php create mode 100644 Theme/Backend/unit-profile.tpl.php create mode 100644 info.json diff --git a/Admin/Activate.php b/Admin/Activate.php new file mode 100644 index 0000000..e017dc4 --- /dev/null +++ b/Admin/Activate.php @@ -0,0 +1,43 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Organization\Admin; + + +use phpOMS\DataStorage\Database\Pool; +use phpOMS\Module\ActivateAbstract; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Activate extends ActivateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function activate(Pool $dbPool, array $info) + { + parent::activate($dbPool, $info); + } +} diff --git a/Admin/Deactivate.php b/Admin/Deactivate.php new file mode 100644 index 0000000..2c9e2bd --- /dev/null +++ b/Admin/Deactivate.php @@ -0,0 +1,43 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Organization\Admin; + + +use phpOMS\DataStorage\Database\Pool; +use phpOMS\Module\DeactivateAbstract; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Deactivate extends DeactivateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function deactivate(Pool $dbPool, array $info) + { + parent::deactivate($dbPool, $info); + } +} diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json new file mode 100644 index 0000000..5a8feae --- /dev/null +++ b/Admin/Install/Navigation.install.json @@ -0,0 +1,156 @@ +[ + { + "id": 1004701001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 0, + "name": "Organization", + "uri": null, + "target": "self", + "icon": "fa fa-database", + "order": 2, + "from": "Organization", + "permission": null, + "parent": 0, + "children": [ + { + "id": 1004702001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Units", + "uri": "/{/lang}/backend/organization/unit/list", + "target": "self", + "icon": null, + "order": 1, + "from": "Organization", + "permission": null, + "parent": 1004701001, + "children": [ + { + "id": 1004702101, + "pid": "88fc57eb9222e9a8eab2c6b165cb93eac7891f2e", + "type": 3, + "subtype": 1, + "name": "List", + "uri": "/{/lang}/backend/organization/unit/list", + "target": "self", + "icon": null, + "order": 5, + "from": "Organization", + "permission": null, + "parent": 1004702001, + "children": [] + }, + { + "id": 1004702102, + "pid": "88fc57eb9222e9a8eab2c6b165cb93eac7891f2e", + "type": 3, + "subtype": 1, + "name": "Create", + "uri": "/{/lang}/backend/organization/unit/create", + "target": "self", + "icon": null, + "order": 25, + "from": "Organization", + "permission": null, + "parent": 1004702001, + "children": [] + } + ] + }, + { + "id": 1004703001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Departments", + "uri": "/{/lang}/backend/organization/department/list", + "target": "self", + "icon": null, + "order": 5, + "from": "Organization", + "permission": null, + "parent": 1004701001, + "children": [ + { + "id": 1004703101, + "pid": "15cb2fef4a6e948711453fc1d5522842ee9452c4", + "type": 3, + "subtype": 1, + "name": "List", + "uri": "/{/lang}/backend/organization/department/list", + "target": "self", + "icon": null, + "order": 5, + "from": "Organization", + "permission": null, + "parent": 1004703001, + "children": [] + }, + { + "id": 1004703102, + "pid": "15cb2fef4a6e948711453fc1d5522842ee9452c4", + "type": 3, + "subtype": 1, + "name": "Create", + "uri": "/{/lang}/backend/organization/department/create", + "target": "self", + "icon": null, + "order": 25, + "from": "Organization", + "permission": null, + "parent": 1004703001, + "children": [] + } + ] + }, + { + "id": 1004704001, + "pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd", + "type": 2, + "subtype": 1, + "name": "Positions", + "uri": "/{/lang}/backend/organization/position/list", + "target": "self", + "icon": null, + "order": 20, + "from": "Organization", + "permission": null, + "parent": 1004701001, + "children": [ + { + "id": 1004704101, + "pid": "be240e5a87cf255e73a2ae91aaf4af5930a3604b", + "type": 3, + "subtype": 1, + "name": "List", + "uri": "/{/lang}/backend/organization/position/list", + "target": "self", + "icon": null, + "order": 5, + "from": "Organization", + "permission": null, + "parent": 1004704001, + "children": [] + }, + { + "id": 1004704102, + "pid": "be240e5a87cf255e73a2ae91aaf4af5930a3604b", + "type": 3, + "subtype": 1, + "name": "Create", + "uri": "/{/lang}/backend/organization/position/create", + "target": "self", + "icon": null, + "order": 25, + "from": "Organization", + "permission": null, + "parent": 1004704001, + "children": [] + } + ] + } + ] + } +] diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php new file mode 100644 index 0000000..8b472f9 --- /dev/null +++ b/Admin/Install/Navigation.php @@ -0,0 +1,40 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Organization\Admin\Install; +use phpOMS\DataStorage\Database\Pool; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Navigation +{ + public static function install(Pool $dbPool) + { + $navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); + + $class = '\\Modules\\Navigation\\Admin\\Installer'; + /** @var $class \Modules\Navigation\Admin\Installer */ + $class::installExternal($dbPool, $navData); + } +} diff --git a/Admin/Installer.php b/Admin/Installer.php new file mode 100644 index 0000000..223893b --- /dev/null +++ b/Admin/Installer.php @@ -0,0 +1,113 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Organization\Admin; + +use phpOMS\DataStorage\Database\DatabaseType; +use phpOMS\DataStorage\Database\Pool; +use phpOMS\Module\InstallerAbstract; + +/** + * Organization install class. + * + * @category Modules + * @package Modules\Business + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Installer extends InstallerAbstract +{ + + /** + * {@inheritdoc} + */ + public static function install(Pool $dbPool, array $info) + { + parent::install($dbPool, $info); + + switch ($dbPool->get('core')->getType()) { + case DatabaseType::MYSQL: + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'organization_unit` ( + `organization_unit_id` int(11) NOT NULL AUTO_INCREMENT, + `organization_unit_status` tinyint(2) DEFAULT NULL, + `organization_unit_matchcode` varchar(50) DEFAULT NULL, + `organization_unit_name` varchar(50) DEFAULT NULL, + `organization_unit_description` varchar(255) DEFAULT NULL, + `organization_unit_parent` int(11) DEFAULT NULL, + `organization_unit_created` datetime DEFAULT NULL, + PRIMARY KEY (`organization_unit_id`), + KEY `organization_unit_parent` (`organization_unit_parent`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'organization_unit` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'organization_unit_ibfk_1` FOREIGN KEY (`organization_unit_parent`) REFERENCES `' . $dbPool->get('core')->prefix . 'organization_unit` (`organization_unit_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'organization_department` ( + `organization_department_id` int(11) NOT NULL AUTO_INCREMENT, + `organization_department_name` varchar(30) DEFAULT NULL, + `organization_department_description` varchar(255) DEFAULT NULL, + `organization_department_parent` int(11) DEFAULT NULL, + `organization_department_unit` int(11) NOT NULL, + PRIMARY KEY (`organization_department_id`), + KEY `organization_department_parent` (`organization_department_parent`), + KEY `organization_department_unit` (`organization_department_unit`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'organization_department` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'organization_department_ibfk_1` FOREIGN KEY (`organization_department_parent`) REFERENCES `' . $dbPool->get('core')->prefix . 'organization_department` (`organization_department_id`), + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'organization_department_ibfk_2` FOREIGN KEY (`organization_department_unit`) REFERENCES `' . $dbPool->get('core')->prefix . 'organization_unit` (`organization_unit_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'organization_address` ( + `organization_address_id` int(11) NOT NULL AUTO_INCREMENT, + `organization_address_status` tinyint(2) DEFAULT NULL, + `organization_address_matchcode` varchar(50) DEFAULT NULL, + `organization_address_name` varchar(50) DEFAULT NULL, + `organization_address_fao` varchar(30) DEFAULT NULL, + `organization_address_addr` varchar(50) DEFAULT NULL, + `organization_address_city` varchar(20) DEFAULT NULL, + `organization_address_zip` varchar(20) DEFAULT NULL, + `organization_address_state` varchar(20) DEFAULT NULL, + `organization_address_country` varchar(30) DEFAULT NULL, + `organization_address_unit` int(11) DEFAULT NULL, + PRIMARY KEY (`organization_address_id`), + KEY `organization_address_unit` (`organization_address_unit`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'organization_address` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'organization_address_ibfk_1` FOREIGN KEY (`organization_address_unit`) REFERENCES `' . $dbPool->get('core')->prefix . 'organization_unit` (`organization_unit_id`);' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'INSERT INTO `' . $dbPool->get('core')->prefix . 'organization_unit` (`organization_unit_status`, `organization_unit_matchcode`, `organization_unit_name`, `organization_unit_description`, `organization_unit_parent`) VALUES + (1, \'default\', \'Default\', \'Default unit.\', NULL);' + )->execute(); + break; + } + } +} diff --git a/Admin/Uninstall.php b/Admin/Uninstall.php new file mode 100644 index 0000000..8a5007b --- /dev/null +++ b/Admin/Uninstall.php @@ -0,0 +1,54 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Organization\Admin; + + +use phpOMS\DataStorage\Database\Pool; +use phpOMS\DataStorage\Database\Schema\Builder; +use phpOMS\Module\UninstallAbstract; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Uninstall extends UninstallAbstract +{ + + /** + * {@inheritdoc} + */ + public static function uninstall(Pool $dbPool, array $info) + { + parent::uninstall($dbPool, $info); + + $query = new Builder($dbPool->get()); + + $query->prefix($dbPool->get('core')->getPrefix())->drop( + 'organization_address', + 'organization_department', + 'organization_unit' + ); + + $dbPool->get()->con->prepare($query->toSql())->execute(); + } +} diff --git a/Admin/Update.php b/Admin/Update.php new file mode 100644 index 0000000..7951ae4 --- /dev/null +++ b/Admin/Update.php @@ -0,0 +1,46 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Organization\Admin; + + +use phpOMS\DataStorage\Database\Pool; +use phpOMS\Module\UpdateAbstract; +use phpOMS\System\FileSystem; + +/** + * Navigation class. + * + * @category Modules + * @package Modules\Admin + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Update extends UpdateAbstract +{ + + /** + * {@inheritdoc} + */ + public static function update(Pool $dbPool, array $info) + { + FileSystem::deletePath(__DIR__ . '/Update'); + mkdir('Update'); + parent::update($dbPool, $info); + } +} diff --git a/Controller.php b/Controller.php new file mode 100644 index 0000000..aac17ad --- /dev/null +++ b/Controller.php @@ -0,0 +1,305 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace Modules\Organization; + +use Modules\Organization\Models\DepartmentMapper; +use Modules\Organization\Models\UnitMapper; +use Modules\Navigation\Models\Navigation; +use Modules\Navigation\Views\NavigationView; +use phpOMS\Contract\RenderableInterface; +use phpOMS\Message\RequestAbstract; +use phpOMS\Message\RequestDestination; +use phpOMS\Message\ResponseAbstract; +use phpOMS\Module\ModuleAbstract; +use phpOMS\Module\WebInterface; +use phpOMS\Views\View; +use phpOMS\Views\ViewLayout; + +/** + * Organization Controller class. + * + * @category Modules + * @package Modules\Organization + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +class Controller extends ModuleAbstract implements WebInterface +{ + + /** + * Module path. + * + * @var string + * @since 1.0.0 + */ + const MODULE_PATH = __DIR__; + + /** + * Module version. + * + * @var string + * @since 1.0.0 + */ + const MODULE_VERSION = '1.0.0'; + + /** + * Module name. + * + * @var string + * @since 1.0.0 + */ + const MODULE_NAME = 'Organization'; + + /** + * Localization files. + * + * @var string + * @since 1.0.0 + */ + protected static $localization = [ + RequestDestination::BACKEND => [''], + ]; + + /** + * Providing. + * + * @var string + * @since 1.0.0 + */ + protected static $providing = []; + + /** + * Dependencies. + * + * @var string + * @since 1.0.0 + */ + protected static $dependencies = [ + ]; + + /** + * Routing elements. + * + * @var array + * @since 1.0.0 + */ + protected static $routes = [ + '^.*/backend/business/unit/list.*$' => [['dest' => '\Modules\Organization\Controller:viewUnitList', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/business/unit/profile.*$' => [['dest' => '\Modules\Organization\Controller:viewUnitProfile', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/business/unit/create.*$' => [['dest' => '\Modules\Organization\Controller:viewUnitCreate', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + + '^.*/backend/business/department/list.*$' => [['dest' => '\Modules\Organization\Controller:viewDepartmentList', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/business/department/profile.*$' => [['dest' => '\Modules\Organization\Controller:viewDepartmentProfile', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/business/department/create.*$' => [['dest' => '\Modules\Organization\Controller:viewDepartmentCreate', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + + '^.*/backend/business/position/list.*$' => [['dest' => '\Modules\Organization\Controller:viewPositionList', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/business/position/profile.*$' => [['dest' => '\Modules\Organization\Controller:viewPositionProfile', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/business/position/create.*$' => [['dest' => '\Modules\Organization\Controller:viewPositionCreate', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + ]; + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewUnitList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Organization/Theme/Backend/unit-list'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004702001, $request, $response)); + + $unitMapper = new UnitMapper($this->app->dbPool->get()); + $view->addData('list:elements', $unitMapper->getAll()); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewUnitProfile(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Organization/Theme/Backend/unit-profile'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004702001, $request, $response)); + + $unitMapper = new UnitMapper($this->app->dbPool->get()); + $view->addData('unit', $unitMapper->get((int) $request->getData('id'))); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewUnitCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Organization/Theme/Backend/unit-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004702001, $request, $response)); + + $unitMapper = new UnitMapper($this->app->dbPool->get()); + $view->addData('unit', $unitMapper->get((int) $request->getData('id'))); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewDepartmentList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Organization/Theme/Backend/department-list'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004703001, $request, $response)); + + $departmentMapper = new DepartmentMapper($this->app->dbPool->get()); + $view->addData('list:elements', $departmentMapper->getAll()); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewDepartmentProfile(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Organization/Theme/Backend/department-profile'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004703001, $request, $response)); + + $departmentMapper = new DepartmentMapper($this->app->dbPool->get()); + $view->addData('unit', $departmentMapper->get((int) $request->getData('id'))); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewDepartmentCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Organization/Theme/Backend/department-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004703001, $request, $response)); + + $unitMapper = new UnitMapper($this->app->dbPool->get()); + $view->addData('unit', $unitMapper->get((int) $request->getData('id'))); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewPositionList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Organization/Theme/Backend/position-list'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004704001, $request, $response)); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewPositionProfile(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Organization/Theme/Backend/position-profile'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004704001, $request, $response)); + + return $view; + } + + /** + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ + public function viewPositionCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app, $request, $response); + $view->setTemplate('/Modules/Organization/Theme/Backend/position-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004704001, $request, $response)); + + return $view; + } + +} diff --git a/Models/Department.php b/Models/Department.php new file mode 100644 index 0000000..7d18c5a --- /dev/null +++ b/Models/Department.php @@ -0,0 +1,54 @@ + + * @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; + +class Department +{ + protected $id = 0; + + protected $name = ''; + + protected $parent = 0; + + protected $unit = 0; + + protected $description = ''; + + public function getId() : int + { + return $this->id; + } + + public function getName() : string + { + return $this->name; + } + + public function getParent() : int + { + return $this->parent; + } + + public function getUnit() : int + { + return $this->parent; + } + + public function getDescription() : string + { + return $this->description; + } +} diff --git a/Models/DepartmentMapper.php b/Models/DepartmentMapper.php new file mode 100644 index 0000000..e84800e --- /dev/null +++ b/Models/DepartmentMapper.php @@ -0,0 +1,52 @@ + + * @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\DataStorage\Database\DataMapperAbstract; + +class DepartmentMapper extends DataMapperAbstract +{ + + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + protected static $columns = [ + 'organization_department_id' => ['name' => 'organization_department_id', 'type' => 'int', 'internal' => 'id'], + '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_unit' => ['name' => 'organization_department_unit', 'type' => 'int', 'internal' => 'unit'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'organization_department'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'organization_department_id'; +} diff --git a/Models/Unit.php b/Models/Unit.php new file mode 100644 index 0000000..81d75d9 --- /dev/null +++ b/Models/Unit.php @@ -0,0 +1,47 @@ + + * @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; + +class Unit +{ + protected $id = 0; + + protected $name = ''; + + protected $parent = 0; + + protected $description = ''; + + public function getId() : int + { + return $this->id; + } + + public function getName() : string + { + return $this->name; + } + + public function getParent() : int + { + return $this->parent; + } + + public function getDescription() : string + { + return $this->description; + } +} diff --git a/Models/UnitMapper.php b/Models/UnitMapper.php new file mode 100644 index 0000000..651325f --- /dev/null +++ b/Models/UnitMapper.php @@ -0,0 +1,62 @@ + + * @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\DataStorage\Database\DataMapperAbstract; + +class UnitMapper extends DataMapperAbstract +{ + + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + protected static $columns = [ + 'organization_unit_id' => ['name' => 'organization_unit_id', 'type' => 'int', 'internal' => 'id'], + 'organization_unit_status' => ['name' => 'organization_unit_status', 'type' => 'int', 'internal' => 'status'], + 'organization_unit_matchcode' => ['name' => 'organization_unit_matchcode', 'type' => 'string', 'internal' => 'matchcode'], + '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_created' => ['name' => 'organization_unit_created', 'type' => 'DateTime', 'internal' => 'createdAt'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'organization_unit'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'organization_unit_id'; + + /** + * Created at column + * + * @var string + * @since 1.0.0 + */ + protected static $createdAt = 'organization_unit_created'; +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..0722c4c --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Business # diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php new file mode 100644 index 0000000..b7a3930 --- /dev/null +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -0,0 +1,21 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +$MODLANG['Navigation'] = [ + 'Business' => 'Business', + 'Departments' => 'Departments', + 'Positions' => 'Positions', + 'Units' => 'Units', +]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php new file mode 100644 index 0000000..795a9f6 --- /dev/null +++ b/Theme/Backend/Lang/en.lang.php @@ -0,0 +1,27 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +$MODLANG['Business'] = [ + 'Active' => 'Active', + 'Department' => 'Department', + 'Departments' => 'Departments', + 'Description' => 'Description', + 'Inactive' => 'Inactive', + 'Name' => 'Name', + 'Parent' => 'Parent', + 'Status' => 'Status', + 'Unit' => 'Unit', + 'Units' => 'Units', +]; diff --git a/Theme/Backend/department-create.tpl.php b/Theme/Backend/department-create.tpl.php new file mode 100644 index 0000000..634600e --- /dev/null +++ b/Theme/Backend/department-create.tpl.php @@ -0,0 +1,40 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +echo $this->getData('nav')->render(); ?> + +
+

l11n->lang['Business']['Department']; ?>

+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Theme/Backend/department-list.tpl.php b/Theme/Backend/department-list.tpl.php new file mode 100644 index 0000000..bb78b0b --- /dev/null +++ b/Theme/Backend/department-list.tpl.php @@ -0,0 +1,54 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response); +$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); + +$footerView->setPages(1 / 25); +$footerView->setPage(1); +$footerView->setResults(1); + +echo $this->getData('nav')->render(); ?> + +
+ + + + + + + getData('list:elements') as $key => $value) : $c++; + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/business/department/profile?id=' . $value->getId()); ?> + + +
l11n->lang['Business']['Departments']; ?>
l11n->lang[0]['ID']; ?> + l11n->lang['Business']['Name']; ?> + l11n->lang['Business']['Parent']; ?> + l11n->lang['Business']['Unit']; ?> +
render(); ?> +
getId(); ?> + getName(); ?> + getParent(); ?> + getUnit(); ?> + + +
l11n->lang[0]['Empty']; ?> + +
+
diff --git a/Theme/Backend/department-profile.php b/Theme/Backend/department-profile.php new file mode 100644 index 0000000..e69de29 diff --git a/Theme/Backend/position-create.tpl.php b/Theme/Backend/position-create.tpl.php new file mode 100644 index 0000000..7712f40 --- /dev/null +++ b/Theme/Backend/position-create.tpl.php @@ -0,0 +1,42 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +echo $this->getData('nav')->render(); ?> + +
+

l11n->lang['Business']['Position']; ?>

+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Theme/Backend/position-list.tpl.php b/Theme/Backend/position-list.tpl.php new file mode 100644 index 0000000..85f055a --- /dev/null +++ b/Theme/Backend/position-list.tpl.php @@ -0,0 +1,48 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response); +$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); + +$footerView->setPages(1 / 25); +$footerView->setPage(1); +$footerView->setResults(1); + +echo $this->getData('nav')->render(); ?> + +
+ + + + + + + getData('list:elements') as $key => $value) : + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/business/unit/profile?id=' . $value->getId()); ?> + +
l11n->lang['Business']['Positions']; ?>
l11n->lang[0]['ID']; ?> + l11n->lang['Business']['Name']; ?> + l11n->lang['Business']['Parent']; ?> +
render(); ?> +
getId(); ?> + getName(); ?> + getParent(); ?> + +
+
diff --git a/Theme/Backend/position-profile.tpl.php b/Theme/Backend/position-profile.tpl.php new file mode 100644 index 0000000..2a30aca --- /dev/null +++ b/Theme/Backend/position-profile.tpl.php @@ -0,0 +1,44 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +$unit = $this->getData('unit'); + +echo $this->getData('nav')->render(); ?> + +
+

l11n->lang['Business']['Position']; ?>

+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Theme/Backend/unit-create.tpl.php b/Theme/Backend/unit-create.tpl.php new file mode 100644 index 0000000..9048f4b --- /dev/null +++ b/Theme/Backend/unit-create.tpl.php @@ -0,0 +1,42 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +echo $this->getData('nav')->render(); ?> + +
+

l11n->lang['Business']['Unit']; ?>

+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Theme/Backend/unit-list.tpl.php b/Theme/Backend/unit-list.tpl.php new file mode 100644 index 0000000..0a95e01 --- /dev/null +++ b/Theme/Backend/unit-list.tpl.php @@ -0,0 +1,48 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response); +$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); + +$footerView->setPages(1 / 25); +$footerView->setPage(1); +$footerView->setResults(1); + +echo $this->getData('nav')->render(); ?> + +
+ + + + + + + getData('list:elements') as $key => $value) : + $url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/business/unit/profile?id=' . $value->getId()); ?> + +
l11n->lang['Business']['Units']; ?>
l11n->lang[0]['ID']; ?> + l11n->lang['Business']['Name']; ?> + l11n->lang['Business']['Parent']; ?> +
render(); ?> +
getId(); ?> + getName(); ?> + getParent(); ?> + +
+
diff --git a/Theme/Backend/unit-profile.tpl.php b/Theme/Backend/unit-profile.tpl.php new file mode 100644 index 0000000..4501ff4 --- /dev/null +++ b/Theme/Backend/unit-profile.tpl.php @@ -0,0 +1,44 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +/** + * @var \phpOMS\Views\View $this + */ + +$unit = $this->getData('unit'); + +echo $this->getData('nav')->render(); ?> + +
+

l11n->lang['Business']['Unit']; ?>

+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/info.json b/info.json new file mode 100644 index 0000000..cba2063 --- /dev/null +++ b/info.json @@ -0,0 +1,53 @@ +{ + "name": { + "id": 1004700000, + "internal": "Organization", + "external": "OMS Organization" + }, + "version": "1.0.0", + "requirements": { + "phpOMS": "1.0.0", + "phpOMS-db": "1.0.0" + }, + "creator": { + "name": "Orange Management", + "website": "www.spl1nes.com" + }, + "description": "The buisness module.", + "directory": "Organization", + "dependencies": { + "Admin" : "1.0.0" + }, + "providing": { + "Navigation": "*" + }, + "load": [ + { + "pid": [ + "d22b06b478e3622168a943f8df016bf745dfdccc" + ], + "type": 4, + "for": "Organization", + "file": "Organization", + "from": "Admin" + }, + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + ], + "type": 5, + "for": "Organization", + "file": "", + "from": "Admin" + }, + { + "pid": [ + "754a08ddf8bcb1cf22f310f09206dd783d42f7dd" + ], + "type": 5, + "from": "Organization", + "for": "Navigation", + "file": "Navigation" + } + ] +}