mirror of
https://github.com/Karaka-Management/oms-Organization.git
synced 2026-01-28 15:48:40 +00:00
Core adjustments for pending issues
This commit is contained in:
parent
e60ad59329
commit
9500ba9f76
|
|
@ -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;'
|
||||
|
|
|
|||
24
Admin/Routes/Web/Api.php
Normal file
24
Admin/Routes/Web/Api.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
return [
|
||||
'^.*/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,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
@ -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,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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'],
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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'],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
38
Models/Status.php
Normal file
38
Models/Status.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.0
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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 <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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'],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<section class="box w-33">
|
||||
<header><h1><?= $this->getText('Unit'); ?></h1></header>
|
||||
<div class="inner">
|
||||
<form>
|
||||
<form method="POST" action="<?= \phpOMS\Uri\UriFactory::build('{/base}{/rootPath}{/lang}/api/organization/unit'); ?>">
|
||||
<table class="layout wf-100">
|
||||
<tr><td><label for="iName"><?= $this->getText('Name'); ?></label>
|
||||
<tr><td><input type="text" name="name" id="iName" placeholder=" Orange Management" required>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user