mirror of
https://github.com/Karaka-Management/oms-Organization.git
synced 2026-02-17 16:58:41 +00:00
prepare for auto group generation
This commit is contained in:
parent
b3da440eb9
commit
57899d5721
|
|
@ -18,10 +18,12 @@ use Modules\Organization\Models\Department;
|
||||||
use Modules\Organization\Models\DepartmentMapper;
|
use Modules\Organization\Models\DepartmentMapper;
|
||||||
use Modules\Organization\Models\Position;
|
use Modules\Organization\Models\Position;
|
||||||
use Modules\Organization\Models\PositionMapper;
|
use Modules\Organization\Models\PositionMapper;
|
||||||
|
use Modules\Organization\Models\SettingsEnum;
|
||||||
use Modules\Organization\Models\Status;
|
use Modules\Organization\Models\Status;
|
||||||
use Modules\Organization\Models\Unit;
|
use Modules\Organization\Models\Unit;
|
||||||
use Modules\Organization\Models\UnitMapper;
|
use Modules\Organization\Models\UnitMapper;
|
||||||
|
use phpOMS\Account\GroupStatus;
|
||||||
|
use phpOMS\Message\Http\Request;
|
||||||
use phpOMS\Message\NotificationLevel;
|
use phpOMS\Message\NotificationLevel;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\Message\ResponseAbstract;
|
use phpOMS\Message\ResponseAbstract;
|
||||||
|
|
@ -183,6 +185,14 @@ final class ApiController extends Controller
|
||||||
|
|
||||||
$unit = $this->createUnitFromRequest($request);
|
$unit = $this->createUnitFromRequest($request);
|
||||||
$this->createModel($request->getHeader()->getAccount(), $unit, UnitMapper::class, 'unit');
|
$this->createModel($request->getHeader()->getAccount(), $unit, UnitMapper::class, 'unit');
|
||||||
|
|
||||||
|
if ($this->app->appSettings->get(SettingsEnum::GROUP_GENERATE_AUTOMATICALLY_UNIT) === '1') {
|
||||||
|
$newRequest = new Request();
|
||||||
|
$newRequest->setData('name', 'org:unit:' . \strtolower($unit->getName()));
|
||||||
|
$newRequest->setData('status', GroupStatus::ACTIVE);
|
||||||
|
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data);
|
||||||
|
}
|
||||||
|
|
||||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully created.', $unit);
|
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Unit', 'Unit successfully created.', $unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -346,6 +356,14 @@ final class ApiController extends Controller
|
||||||
|
|
||||||
$position = $this->createPositionFromRequest($request);
|
$position = $this->createPositionFromRequest($request);
|
||||||
$this->createModel($request->getHeader()->getAccount(), $position, PositionMapper::class, 'position');
|
$this->createModel($request->getHeader()->getAccount(), $position, PositionMapper::class, 'position');
|
||||||
|
|
||||||
|
if ($this->app->appSettings->get(SettingsEnum::GROUP_GENERATE_AUTOMATICALLY_POSITION) === '1') {
|
||||||
|
$newRequest = new Request();
|
||||||
|
$newRequest->setData('name', 'org:pos:' . \strtolower($position->getName()));
|
||||||
|
$newRequest->setData('status', GroupStatus::ACTIVE);
|
||||||
|
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data);
|
||||||
|
}
|
||||||
|
|
||||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Position', 'Position successfully created.', $position);
|
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Position', 'Position successfully created.', $position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -511,6 +529,14 @@ final class ApiController extends Controller
|
||||||
|
|
||||||
$department = $this->createDepartmentFromRequest($request);
|
$department = $this->createDepartmentFromRequest($request);
|
||||||
$this->createModel($request->getHeader()->getAccount(), $department, DepartmentMapper::class, 'department');
|
$this->createModel($request->getHeader()->getAccount(), $department, DepartmentMapper::class, 'department');
|
||||||
|
|
||||||
|
if ($this->app->appSettings->get(SettingsEnum::GROUP_GENERATE_AUTOMATICALLY_DEPARTMENT) === '1') {
|
||||||
|
$newRequest = new Request();
|
||||||
|
$newRequest->setData('name', 'org:dep:' . \strtolower($department->getName()));
|
||||||
|
$newRequest->setData('status', GroupStatus::ACTIVE);
|
||||||
|
$this->app->moduleManager->get('Admin')->apiGroupCreate($newRequest, $response, $data);
|
||||||
|
}
|
||||||
|
|
||||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Department', 'Department successfully created.', $department);
|
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Department', 'Department successfully created.', $department);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
32
Models/SettingsEnum.php
Normal file
32
Models/SettingsEnum.php
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Orange Management
|
||||||
|
*
|
||||||
|
* PHP Version 7.4
|
||||||
|
*
|
||||||
|
* @package Modules\Organization\Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
*/
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Modules\Organization\Models;
|
||||||
|
|
||||||
|
use phpOMS\Stdlib\Base\Enum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module settings enum.
|
||||||
|
*
|
||||||
|
* @package Modules\Organization\Models
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @link https://orange-management.org
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
abstract class SettingsEnum extends Enum
|
||||||
|
{
|
||||||
|
public const GROUP_GENERATE_AUTOMATICALLY_UNIT = 1004700001;
|
||||||
|
public const GROUP_GENERATE_AUTOMATICALLY_DEPARTMENT = 1004700002;
|
||||||
|
public const GROUP_GENERATE_AUTOMATICALLY_POSITION = 1004700003;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user