From ae336cfe4ab1f950abc8fdb83300cef6a860a7c6 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 14 Feb 2016 23:10:58 +0100 Subject: [PATCH] Organization + calendar fixes/extensions --- Admin/Install/Navigation.install.json | 12 ++--- Admin/Install/Navigation.php | 3 ++ Admin/Installer.php | 23 ++++++++-- Controller.php | 18 ++++---- Models/Department.php | 28 ++++++++++-- Models/Position.php | 61 +++++++++++++++++++++++++ Models/PositionMapper.php | 51 +++++++++++++++++++++ Models/Unit.php | 22 +++++++-- Models/UnitMapper.php | 11 ----- Theme/Backend/department-create.tpl.php | 10 ++-- Theme/Backend/department-list.tpl.php | 8 ++-- Theme/Backend/position-create.tpl.php | 14 +++--- Theme/Backend/position-list.tpl.php | 6 +-- Theme/Backend/position-profile.tpl.php | 14 +++--- Theme/Backend/unit-create.tpl.php | 14 +++--- Theme/Backend/unit-list.tpl.php | 6 +-- Theme/Backend/unit-profile.tpl.php | 14 +++--- info.json | 2 +- 18 files changed, 234 insertions(+), 83 deletions(-) create mode 100644 Models/Position.php create mode 100644 Models/PositionMapper.php diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json index 5a8feae..0625a14 100644 --- a/Admin/Install/Navigation.install.json +++ b/Admin/Install/Navigation.install.json @@ -29,7 +29,7 @@ "children": [ { "id": 1004702101, - "pid": "88fc57eb9222e9a8eab2c6b165cb93eac7891f2e", + "pid": "bed7df3aff1a2bcb0b5e761764a93f84c2793daf", "type": 3, "subtype": 1, "name": "List", @@ -44,7 +44,7 @@ }, { "id": 1004702102, - "pid": "88fc57eb9222e9a8eab2c6b165cb93eac7891f2e", + "pid": "bed7df3aff1a2bcb0b5e761764a93f84c2793daf", "type": 3, "subtype": 1, "name": "Create", @@ -75,7 +75,7 @@ "children": [ { "id": 1004703101, - "pid": "15cb2fef4a6e948711453fc1d5522842ee9452c4", + "pid": "fab21c089971de13f680a30c8fdd0a8edc97af6a", "type": 3, "subtype": 1, "name": "List", @@ -90,7 +90,7 @@ }, { "id": 1004703102, - "pid": "15cb2fef4a6e948711453fc1d5522842ee9452c4", + "pid": "fab21c089971de13f680a30c8fdd0a8edc97af6a", "type": 3, "subtype": 1, "name": "Create", @@ -121,7 +121,7 @@ "children": [ { "id": 1004704101, - "pid": "be240e5a87cf255e73a2ae91aaf4af5930a3604b", + "pid": "67b1a05950026df723a6c35c7801234c978e85f2", "type": 3, "subtype": 1, "name": "List", @@ -136,7 +136,7 @@ }, { "id": 1004704102, - "pid": "be240e5a87cf255e73a2ae91aaf4af5930a3604b", + "pid": "67b1a05950026df723a6c35c7801234c978e85f2", "type": 3, "subtype": 1, "name": "Create", diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index 8b472f9..53a7305 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -29,6 +29,9 @@ use phpOMS\DataStorage\Database\Pool; */ class Navigation { + /** + * {@inheritdoc} + */ public static function install(Pool $dbPool) { $navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true); diff --git a/Admin/Installer.php b/Admin/Installer.php index 8daec4c..2f11f16 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -45,12 +45,9 @@ class Installer extends InstallerAbstract $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;' @@ -80,6 +77,22 @@ class Installer extends InstallerAbstract 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_position` ( + `organization_position_id` int(11) NOT NULL AUTO_INCREMENT, + `organization_position_name` varchar(50) DEFAULT NULL, + `organization_position_description` varchar(255) DEFAULT NULL, + `organization_position_parent` int(11) DEFAULT NULL, + PRIMARY KEY (`organization_position_id`), + KEY `organization_position_parent` (`organization_position_parent`) + )ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;' + )->execute(); + + $dbPool->get('core')->con->prepare( + 'ALTER TABLE `' . $dbPool->get('core')->prefix . 'organization_position` + ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'organization_position_ibfk_1` FOREIGN KEY (`organization_position_parent`) REFERENCES `' . $dbPool->get('core')->prefix . 'organization_position` (`organization_position_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, @@ -104,8 +117,8 @@ class Installer extends InstallerAbstract )->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);' + 'INSERT INTO `' . $dbPool->get('core')->prefix . 'organization_unit` (`organization_unit_name`, `organization_unit_description`, `organization_unit_parent`) VALUES + (\'Default\', \'Default unit.\', NULL);' )->execute(); break; } diff --git a/Controller.php b/Controller.php index fc9f925..4e4d9ef 100644 --- a/Controller.php +++ b/Controller.php @@ -98,17 +98,17 @@ class Controller extends ModuleAbstract implements WebInterface * @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/organization/unit/list.*$' => [['dest' => '\Modules\Organization\Controller:viewUnitList', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/organization/unit/profile.*$' => [['dest' => '\Modules\Organization\Controller:viewUnitProfile', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/organization/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/organization/department/list.*$' => [['dest' => '\Modules\Organization\Controller:viewDepartmentList', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/organization/department/profile.*$' => [['dest' => '\Modules\Organization\Controller:viewDepartmentProfile', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/organization/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],], + '^.*/backend/organization/position/list.*$' => [['dest' => '\Modules\Organization\Controller:viewPositionList', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/organization/position/profile.*$' => [['dest' => '\Modules\Organization\Controller:viewPositionProfile', 'method' => 'GET', 'type' => ViewLayout::MAIN],], + '^.*/backend/organization/position/create.*$' => [['dest' => '\Modules\Organization\Controller:viewPositionCreate', 'method' => 'GET', 'type' => ViewLayout::MAIN],], ]; /** diff --git a/Models/Department.php b/Models/Department.php index 7d18c5a..35b0dad 100644 --- a/Models/Department.php +++ b/Models/Department.php @@ -21,9 +21,9 @@ class Department protected $name = ''; - protected $parent = 0; + protected $parent = null; - protected $unit = 0; + protected $unit = 1; protected $description = ''; @@ -37,18 +37,38 @@ class Department return $this->name; } - public function getParent() : int + public function setName(string $name) + { + return $this->name = $name; + } + + public function getParent() { return $this->parent; } + public function setParent(int $parent) + { + $this->parent = $parent; + } + public function getUnit() : int { - return $this->parent; + return $this->unit; + } + + public function setUnit(int $unit) + { + $this->unit = $unit; } public function getDescription() : string { return $this->description; } + + public function setDescription(string $desc) + { + $this->description = $desc; + } } diff --git a/Models/Position.php b/Models/Position.php new file mode 100644 index 0000000..41c7968 --- /dev/null +++ b/Models/Position.php @@ -0,0 +1,61 @@ + + * @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 Position +{ + private $id = 0; + + private $name = ''; + + private $parent = null; + + private $description = ''; + + public function getId() : int + { + return $this->id; + } + + public function getName() : string + { + return $this->name; + } + + public function setName(string $name) + { + $this->name = $name; + } + + public function getParent() + { + return $this->parent; + } + + public function setParent(int $parent) { + $this->parent = $parent; + } + + public function getDescription() : string + { + return $this->description; + } + + public function setDescription(string $desc) + { + $this->description = $desc; + } +} diff --git a/Models/PositionMapper.php b/Models/PositionMapper.php new file mode 100644 index 0000000..df6ee5a --- /dev/null +++ b/Models/PositionMapper.php @@ -0,0 +1,51 @@ + + * @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 PositionMapper extends DataMapperAbstract +{ + + /** + * Columns. + * + * @var array + * @since 1.0.0 + */ + protected static $columns = [ + 'organization_position_id' => ['name' => 'organization_position_id', 'type' => 'int', 'internal' => 'id'], + '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'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static $table = 'organization_position'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static $primaryField = 'organization_position_id'; +} diff --git a/Models/Unit.php b/Models/Unit.php index 81d75d9..6ded14b 100644 --- a/Models/Unit.php +++ b/Models/Unit.php @@ -17,13 +17,13 @@ namespace Modules\Organization\Models; class Unit { - protected $id = 0; + private $id = 0; - protected $name = ''; + private $name = ''; - protected $parent = 0; + private $parent = 0; - protected $description = ''; + private $description = ''; public function getId() : int { @@ -35,13 +35,27 @@ class Unit return $this->name; } + public function setName(string $name) + { + $this->name = $name; + } + public function getParent() : int { return $this->parent; } + public function setParent(int $parent) { + $this->parent = $parent; + } + public function getDescription() : string { return $this->description; } + + public function setDescription(string $desc) + { + $this->description = $desc; + } } diff --git a/Models/UnitMapper.php b/Models/UnitMapper.php index 651325f..1ba2906 100644 --- a/Models/UnitMapper.php +++ b/Models/UnitMapper.php @@ -28,12 +28,9 @@ class UnitMapper extends DataMapperAbstract */ 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'], ]; /** @@ -51,12 +48,4 @@ class UnitMapper extends DataMapperAbstract * @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/Theme/Backend/department-create.tpl.php b/Theme/Backend/department-create.tpl.php index 634600e..0f921e4 100644 --- a/Theme/Backend/department-create.tpl.php +++ b/Theme/Backend/department-create.tpl.php @@ -20,18 +20,18 @@ echo $this->getData('nav')->render(); ?>
-

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

+

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

-
+
-
+
-
+
-
+
diff --git a/Theme/Backend/department-list.tpl.php b/Theme/Backend/department-list.tpl.php index bb78b0b..a85c99e 100644 --- a/Theme/Backend/department-list.tpl.php +++ b/Theme/Backend/department-list.tpl.php @@ -28,13 +28,13 @@ echo $this->getData('nav')->render(); ?>
- + diff --git a/Theme/Backend/position-create.tpl.php b/Theme/Backend/position-create.tpl.php index 7712f40..6827d07 100644 --- a/Theme/Backend/position-create.tpl.php +++ b/Theme/Backend/position-create.tpl.php @@ -20,20 +20,20 @@ echo $this->getData('nav')->render(); ?>
-

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

+

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

l11n->lang['Business']['Departments']; ?>l11n->lang['Organization']['Departments']; ?>
l11n->lang[0]['ID']; ?> - l11n->lang['Business']['Name']; ?> - l11n->lang['Business']['Parent']; ?> - l11n->lang['Business']['Unit']; ?> + l11n->lang['Organization']['Name']; ?> + l11n->lang['Organization']['Parent']; ?> + l11n->lang['Organization']['Unit']; ?>
render(); ?>
-
+
-
+
-
+
-
+
diff --git a/Theme/Backend/position-list.tpl.php b/Theme/Backend/position-list.tpl.php index 85f055a..b4a3b87 100644 --- a/Theme/Backend/position-list.tpl.php +++ b/Theme/Backend/position-list.tpl.php @@ -28,12 +28,12 @@ echo $this->getData('nav')->render(); ?>
- + diff --git a/Theme/Backend/position-profile.tpl.php b/Theme/Backend/position-profile.tpl.php index 2a30aca..3562b49 100644 --- a/Theme/Backend/position-profile.tpl.php +++ b/Theme/Backend/position-profile.tpl.php @@ -22,20 +22,20 @@ $unit = $this->getData('unit'); echo $this->getData('nav')->render(); ?>
-

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

+

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

l11n->lang['Business']['Positions']; ?>l11n->lang['Organization']['Positions']; ?>
l11n->lang[0]['ID']; ?> - l11n->lang['Business']['Name']; ?> - l11n->lang['Business']['Parent']; ?> + l11n->lang['Organization']['Name']; ?> + l11n->lang['Organization']['Parent']; ?>
render(); ?>
-
+
-
+
-
+
-
+
diff --git a/Theme/Backend/unit-create.tpl.php b/Theme/Backend/unit-create.tpl.php index 9048f4b..410576b 100644 --- a/Theme/Backend/unit-create.tpl.php +++ b/Theme/Backend/unit-create.tpl.php @@ -20,20 +20,20 @@ echo $this->getData('nav')->render(); ?>
-

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

+

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

-
+
-
+
-
+
-
+
diff --git a/Theme/Backend/unit-list.tpl.php b/Theme/Backend/unit-list.tpl.php index 0a95e01..e910590 100644 --- a/Theme/Backend/unit-list.tpl.php +++ b/Theme/Backend/unit-list.tpl.php @@ -28,12 +28,12 @@ echo $this->getData('nav')->render(); ?>
- + diff --git a/Theme/Backend/unit-profile.tpl.php b/Theme/Backend/unit-profile.tpl.php index 4501ff4..17f3768 100644 --- a/Theme/Backend/unit-profile.tpl.php +++ b/Theme/Backend/unit-profile.tpl.php @@ -22,20 +22,20 @@ $unit = $this->getData('unit'); echo $this->getData('nav')->render(); ?>
-

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

+

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

l11n->lang['Business']['Units']; ?>l11n->lang['Organization']['Units']; ?>
l11n->lang[0]['ID']; ?> - l11n->lang['Business']['Name']; ?> - l11n->lang['Business']['Parent']; ?> + l11n->lang['Organization']['Name']; ?> + l11n->lang['Organization']['Parent']; ?>
render(); ?>
-
+
-
+
-
+
-
+
diff --git a/info.json b/info.json index cba2063..ee96a33 100644 --- a/info.json +++ b/info.json @@ -24,7 +24,7 @@ "load": [ { "pid": [ - "d22b06b478e3622168a943f8df016bf745dfdccc" + "4b04e005b108e41e107bf2e16b858588275200f3" ], "type": 4, "for": "Organization",