mirror of
https://github.com/Karaka-Management/oms-HumanResourceManagement.git
synced 2026-01-28 19:58:40 +00:00
remove some getter/setter
This commit is contained in:
parent
29ee4f20c6
commit
93e6d2175c
|
|
@ -77,13 +77,13 @@ final class ApiController extends Controller
|
|||
{
|
||||
if (!empty($val = $this->validateEmployeeFromAccountCreate($request))) {
|
||||
$response->set('employee_create', new FormValidation($val));
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_400);
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$employees = $this->createEmployeeFromAccountFromRequest($request);
|
||||
$this->createModels($request->getHeader()->getAccount(), $employees, EmployeeMapper::class, 'employee', $request->getOrigin());
|
||||
$this->createModels($request->header->account, $employees, EmployeeMapper::class, 'employee', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Employee', 'Employee(s) successfully created', $employees);
|
||||
}
|
||||
|
||||
|
|
@ -144,13 +144,13 @@ final class ApiController extends Controller
|
|||
{
|
||||
if (!empty($val = $this->validateEmployeeNewCreate($request))) {
|
||||
$response->set('employee_create', new FormValidation($val));
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_400);
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$employee = $this->createEmployeeNewFromRequest($request);
|
||||
$this->createModel($request->getHeader()->getAccount(), $employee, EmployeeMapper::class, 'employee', $request->getOrigin());
|
||||
$this->createModel($request->header->account, $employee, EmployeeMapper::class, 'employee', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Employee', 'Employee successfully created', $employee);
|
||||
}
|
||||
|
||||
|
|
@ -185,13 +185,13 @@ final class ApiController extends Controller
|
|||
private function createEmployeeNewFromRequest(RequestAbstract $request) : Employee
|
||||
{
|
||||
$account = new Account();
|
||||
$account->setName1((string) ($request->getData('name1') ?? ''));
|
||||
$account->setName2((string) ($request->getData('name2') ?? ''));
|
||||
$account->setName3((string) ($request->getData('name3') ?? ''));
|
||||
$account->setName3((string) ($request->getData('email') ?? ''));
|
||||
$account->name1 = (string) ($request->getData('name1') ?? '');
|
||||
$account->name2 = (string) ($request->getData('name2') ?? '');
|
||||
$account->name3 = (string) ($request->getData('name3') ?? '');
|
||||
$account->name3 = (string) ($request->getData('email') ?? '');
|
||||
|
||||
$profile = new Profile($account);
|
||||
$profile->setBirthday(new \DateTime((string) ($request->getData('birthday') ?? 'now')));
|
||||
$profile->birthday = new \DateTime((string) ($request->getData('birthday') ?? 'now'));
|
||||
|
||||
$employee = new Employee($profile);
|
||||
|
||||
|
|
@ -215,13 +215,13 @@ final class ApiController extends Controller
|
|||
{
|
||||
if (!empty($val = $this->validateEmployeeHistoryCreate($request))) {
|
||||
$response->set('history_create', new FormValidation($val));
|
||||
$response->getHeader()->setStatusCode(RequestStatusCode::R_400);
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$history = $this->createEmployeeHistoryFromRequest($request);
|
||||
$this->createModel($request->getHeader()->getAccount(), $history, EmployeeHistoryMapper::class, 'history', $request->getOrigin());
|
||||
$this->createModel($request->header->account, $history, EmployeeHistoryMapper::class, 'history', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'History', 'History successfully created', $history);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class Employee implements \JsonSerializable, ArrayableInterface
|
|||
* @var null|int|Profile
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $profile = null;
|
||||
public $profile = null;
|
||||
|
||||
/**
|
||||
* Employee image.
|
||||
|
|
@ -51,7 +51,7 @@ class Employee implements \JsonSerializable, ArrayableInterface
|
|||
* @var null|int|Media
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private $image = null;
|
||||
public $image = null;
|
||||
|
||||
/**
|
||||
* Employee department/position history.
|
||||
|
|
@ -110,6 +110,7 @@ class Employee implements \JsonSerializable, ArrayableInterface
|
|||
{
|
||||
$this->profile = $profile;
|
||||
$this->semiPrivateHash = \random_bytes(self::SEMI_PRIVATE_HASH_LENGTH);
|
||||
$this->image = new NullMedia();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -124,44 +125,6 @@ class Employee implements \JsonSerializable, ArrayableInterface
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get profile.
|
||||
*
|
||||
* @return null|int|Profile
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getProfile()
|
||||
{
|
||||
return $this->profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image.
|
||||
*
|
||||
* @return int|Media
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getImage()
|
||||
{
|
||||
return $this->image ?? new NullMedia();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image.
|
||||
*
|
||||
* @param null|int|Media $image Employee image
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setImage($image) : void
|
||||
{
|
||||
$this->image = $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update semi private hash.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use Modules\Admin\Models\AccountMapper;
|
|||
use Modules\Profile\Models\ProfileMapper;
|
||||
use phpOMS\DataStorage\Database\DataMapperAbstract;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
|
||||
/**
|
||||
* Employe mapper class.
|
||||
|
|
@ -55,6 +56,19 @@ final class EmployeeMapper extends DataMapperAbstract
|
|||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static array $ownsOne = [
|
||||
'image' => [
|
||||
'mapper' => MediaMapper::class,
|
||||
'external' => 'hr_staff_image',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ echo $this->getData('nav')->render(); ?>
|
|||
$url = \phpOMS\Uri\UriFactory::build('{/prefix}hr/department/single?{?}&id=' . $value->getId()); ?>
|
||||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getId()); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getName()); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Employees'); ?>">
|
||||
<td data-label="<?= $this->getHtml('Parent'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getParent()->getName()); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Parent'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->parent->getName()); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($c === 0) : ?>
|
||||
<tr><td colspan="4" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<div class="b b-1 c24-1 c24" id="i24-1-1">
|
||||
<header><h1><?= $this->printHtml($this->app->accountManager->get($request->getHeader()->getAccount())->getL11n()->lang['HumanResourceManagement']['Vacation']); ?></h1></header>
|
||||
<header><h1><?= $this->printHtml($this->app->accountManager->get($request->header->account)->l11n->lang['HumanResourceManagement']['Vacation']); ?></h1></header>
|
||||
|
||||
<div class="bc-1">
|
||||
<div class="cT">
|
||||
|
|
@ -26,13 +26,13 @@
|
|||
<!-- @formatter:on -->
|
||||
<div class="cT">
|
||||
<a tabindex="0" href="<?= \phpOMS\Uri\UriFactory::build('{/prefix}sales/analysis/clients/dashboard'); ?>"
|
||||
class="button"><?= $this->printHtml($this->app->accountManager->get($request->getHeader()->getAccount())->getL11n()->lang[0]['More']); ?></a>
|
||||
class="button"><?= $this->printHtml($this->app->accountManager->get($request->header->account)->l11n->lang[0]['More']); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="b b-1 c24-1 c24" id="i24-1-1">
|
||||
<header><h1><?= $this->printHtml($this->app->accountManager->get($request->getHeader()->getAccount())->getL11n()->lang['HumanResourceManagement']['Shifts']); ?></h1></header>
|
||||
<header><h1><?= $this->printHtml($this->app->accountManager->get($request->header->account)->l11n->lang['HumanResourceManagement']['Shifts']); ?></h1></header>
|
||||
|
||||
<div class="bc-1">
|
||||
<div class="cT">
|
||||
|
|
@ -59,13 +59,13 @@
|
|||
<!-- @formatter:on -->
|
||||
<div class="cT">
|
||||
<a tabindex="0" href=""
|
||||
class="button"><?= $this->printHtml($this->app->accountManager->get($request->getHeader()->getAccount())->getL11n()->lang[0]['More']); ?></a>
|
||||
class="button"><?= $this->printHtml($this->app->accountManager->get($request->header->account)->l11n->lang[0]['More']); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="b b-1 c24-1 c24" id="i24-1-1">
|
||||
<header><h1><?= $this->printHtml($this->app->accountManager->get($request->getHeader()->getAccount())->getL11n()->lang['HumanResourceManagement']['Personnel']); ?></h1></header>
|
||||
<header><h1><?= $this->printHtml($this->app->accountManager->get($request->header->account)->l11n->lang['HumanResourceManagement']['Personnel']); ?></h1></header>
|
||||
|
||||
<div class="bc-1">
|
||||
<div class="cT">
|
||||
|
|
@ -92,7 +92,7 @@
|
|||
<!-- @formatter:on -->
|
||||
<div class="cT">
|
||||
<a tabindex="0" href=""
|
||||
class="button"><?= $this->printHtml($this->app->accountManager->get($request->getHeader()->getAccount())->getL11n()->lang[0]['More']); ?></a>
|
||||
class="button"><?= $this->printHtml($this->app->accountManager->get($request->header->account)->l11n->lang[0]['More']); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<tr tabindex="0" data-href="<?= $url; ?>">
|
||||
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getId()); ?></a>
|
||||
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml(
|
||||
\sprintf('%3$s %2$s %1$s', $value->getProfile()->getAccount()->getName1(), $value->getProfile()->getAccount()->getName2(), $value->getProfile()->getAccount()->getName3())
|
||||
\sprintf('%3$s %2$s %1$s', $value->profile->account->name1, $value->profile->account->name2, $value->profile->account->name3)
|
||||
); ?></a>
|
||||
<td><?= $this->printHtml($value->getNewestHistory()->getUnit()->getName()); ?>
|
||||
<td><?= $this->printHtml($value->getNewestHistory()->getPosition()->getName()); ?>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
use Modules\Media\Models\NullMedia;
|
||||
use phpOMS\Uri\UriFactory;
|
||||
use Modules\HumanResourceManagement\Models\NullEmployeeHistory;
|
||||
|
||||
$employee = $this->getData('employee');
|
||||
$history = $employee->getHistorY();
|
||||
|
|
@ -35,12 +36,12 @@ echo $this->getData('nav')->render(); ?>
|
|||
</ul>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->getUri()->getFragment() === 'c-tab-1' ? ' checked' : ''; ?>>
|
||||
<input type="radio" id="c-tab-1" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<section itemscope itemtype="http://schema.org/Person" class="box wf-100">
|
||||
<header><h1><span itemprop="familyName"><?= $this->printHtml($employee->getProfile()->getAccount()->getName2()); ?></span>, <span itemprop="givenName"><?= $this->printHtml($employee->getProfile()->getAccount()->getName1()); ?></span></h1></header>
|
||||
<header><h1><span itemprop="familyName"><?= $this->printHtml($employee->profile->account->name2); ?></span>, <span itemprop="givenName"><?= $this->printHtml($employee->profile->account->name1); ?></span></h1></header>
|
||||
<div class="inner">
|
||||
<!-- @formatter:off -->
|
||||
<span class="rf">
|
||||
|
|
@ -48,11 +49,11 @@ echo $this->getData('nav')->render(); ?>
|
|||
alt="<?= $this->getHtml('ProfileImage'); ?>"
|
||||
itemprop="logo" loading="lazy"
|
||||
src="<?=
|
||||
$employee->getImage() instanceof NullMedia ?
|
||||
$employee->getProfile()->getImage() instanceof NullMedia ?
|
||||
$employee->image instanceof NullMedia ?
|
||||
$employee->profile->image instanceof NullMedia ?
|
||||
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') :
|
||||
UriFactory::build('{/prefix}' . $employee->getProfile()->getImage()->getPath()) :
|
||||
UriFactory::build('{/prefix}' . $employee->getImage()->getPath()); ?>"
|
||||
UriFactory::build('{/prefix}' . $employee->profile->image->getPath()) :
|
||||
UriFactory::build('{/prefix}' . $employee->image->getPath()); ?>"
|
||||
>
|
||||
</span>
|
||||
<table class="list">
|
||||
|
|
@ -70,7 +71,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<td itemprop="birthDate">06.09.1934
|
||||
<tr>
|
||||
<th><?= $this->getHtml('Email'); ?>
|
||||
<td itemprop="email"><a href="mailto:<?= $this->printHtml($employee->getProfile()->getAccount()->getEmail()); ?>"><?= $this->printHtml($employee->getProfile()->getAccount()->getEmail()); ?></a>
|
||||
<td itemprop="email"><a href="mailto:<?= $this->printHtml($employee->profile->account->getEmail()); ?>"><?= $this->printHtml($employee->profile->account->getEmail()); ?></a>
|
||||
<tr>
|
||||
<th>Address
|
||||
<td>
|
||||
|
|
@ -127,7 +128,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->getUri()->getFragment() === 'c-tab-2' ? ' checked' : ''; ?>>
|
||||
<input type="radio" id="c-tab-2" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
|
@ -139,7 +140,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-3" name="tabular-2"<?= $this->request->getUri()->getFragment() === 'c-tab-3' ? ' checked' : ''; ?>>
|
||||
<input type="radio" id="c-tab-3" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-3' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
|
@ -151,7 +152,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-4" name="tabular-2"<?= $this->request->getUri()->getFragment() === 'c-tab-4' ? ' checked' : ''; ?>>
|
||||
<input type="radio" id="c-tab-4" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-4' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
|
@ -163,7 +164,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-5" name="tabular-2"<?= $this->request->getUri()->getFragment() === 'c-tab-5' ? ' checked' : ''; ?>>
|
||||
<input type="radio" id="c-tab-5" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
|
@ -175,7 +176,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-6" name="tabular-2"<?= $this->request->getUri()->getFragment() === 'c-tab-6' ? ' checked' : ''; ?>>
|
||||
<input type="radio" id="c-tab-6" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-6' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
|
@ -187,7 +188,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-7" name="tabular-2"<?= $this->request->getUri()->getFragment() === 'c-tab-7' ? ' checked' : ''; ?>>
|
||||
<input type="radio" id="c-tab-7" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-7' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
|
@ -199,7 +200,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type="radio" id="c-tab-8" name="tabular-2"<?= $this->request->getUri()->getFragment() === 'c-tab-8' ? ' checked' : ''; ?>>
|
||||
<input type="radio" id="c-tab-8" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-8' ? ' checked' : ''; ?>>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ class EmployeeMapperTest extends \PHPUnit\Framework\TestCase
|
|||
if (($profile = ProfileMapper::getFor(1, 'account'))->getId() === 0) {
|
||||
$profile = new Profile();
|
||||
|
||||
$profile->setAccount(AccountMapper::get(1));
|
||||
$profile->setBirthday($date = new \DateTime('now'));
|
||||
$profile->account = AccountMapper::get(1);
|
||||
$profile->birthday = ($date = new \DateTime('now'));
|
||||
|
||||
$id = ProfileMapper::create($profile);
|
||||
}
|
||||
|
|
@ -47,6 +47,6 @@ class EmployeeMapperTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals($id, $employee->getId());
|
||||
|
||||
$employeeR = EmployeeMapper::get($employee->getId());
|
||||
self::assertEquals($employee->getProfile()->getId(), $employeeR->getProfile()->getId());
|
||||
self::assertEquals($employee->profile->getId(), $employeeR->profile->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class EmployeeTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(0, $employee->getId());
|
||||
self::assertGreaterThan(0, \strlen($employee->getSemiPrivateHash()));
|
||||
self::assertFalse($employee->compareSemiPrivateHash('123'));
|
||||
self::assertInstanceOf('\Modules\Media\Models\NullMedia', $employee->getImage());
|
||||
self::assertInstanceOf('\Modules\Media\Models\NullMedia', $employee->image);
|
||||
self::assertInstanceOf('\Modules\HumanResourceManagement\Models\NullEmployeeHistory', $employee->getNewestHistory());
|
||||
self::assertEquals([], $employee->getHistory());
|
||||
self::assertEquals([], $employee->getEducationHistory());
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user