make id public, organigram impl. media password/encryption, settings bug fix, Money->FloatInt change, ...

This commit is contained in:
Dennis Eichhorn 2023-05-06 11:42:06 +00:00
parent f1e30cae23
commit 6aeab67f12
18 changed files with 41 additions and 42 deletions

View File

@ -35,7 +35,7 @@ class Employee implements \JsonSerializable
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public int $id = 0;
/**
* Account profile.

View File

@ -34,7 +34,7 @@ class EmployeeEducationHistory implements \JsonSerializable
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public int $id = 0;
/**
* Employee
@ -161,7 +161,7 @@ class EmployeeEducationHistory implements \JsonSerializable
{
return [
'id' => $this->id,
'employee' => !\is_int($this->employee) ? $this->employee->getId() : $this->employee,
'employee' => !\is_int($this->employee) ? $this->employee->id : $this->employee,
'educationTitle' => $this->educationTitle,
'passed' => $this->passed,
'score' => $this->score,

View File

@ -39,7 +39,7 @@ class EmployeeHistory implements \JsonSerializable
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public int $id = 0;
/**
* Employee
@ -184,7 +184,7 @@ class EmployeeHistory implements \JsonSerializable
{
return [
'id' => $this->id,
'employee' => !\is_int($this->employee) ? $this->employee->getId() : $this->employee,
'employee' => !\is_int($this->employee) ? $this->employee->id : $this->employee,
'unit' => $this->unit,
'department' => $this->department,
'position' => $this->position,

View File

@ -34,7 +34,7 @@ class EmployeeWorkHistory implements \JsonSerializable
* @var int
* @since 1.0.0
*/
protected int $id = 0;
public int $id = 0;
/**
* Employee
@ -157,7 +157,7 @@ class EmployeeWorkHistory implements \JsonSerializable
{
return [
'id' => $this->id,
'employee' => !\is_int($this->employee) ? $this->employee->getId() : $this->employee,
'employee' => !\is_int($this->employee) ? $this->employee->id : $this->employee,
'jobTitle' => $this->jobTitle,
'start' => $this->start,
'end' => $this->end,

View File

@ -43,9 +43,9 @@ echo $this->getData('nav')->render(); ?>
<td><?= $this->getHtml('Parent'); ?>
<tbody>
<?php $c = 0; foreach ($departments as $key => $value) : ++$c;
$url = UriFactory::build('{/base}/hr/department/single?{?}&id=' . $value->getId()); ?>
$url = UriFactory::build('{/base}/hr/department/single?{?}&id=' . $value->id); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->id; ?></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->parent->name); ?></a>

View File

@ -42,21 +42,20 @@ echo $this->getData('nav')->render(); ?>
<td><?= $this->getHtml('Status'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tbody>
<?php $c = 0; foreach ($employees as $key => $value) : ++$c;
$url = UriFactory::build('{/base}/humanresource/staff/profile?{?}&id=' . $value->getId()); ?>
$url = UriFactory::build('{/base}/humanresource/staff/profile?{?}&id=' . $value->id); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><img alt="<?= $this->getHtml('IMG_alt_staff'); ?>" width="30" loading="lazy" class="profile-image"
src="<?=
$value->profile->image instanceof NullMedia ?
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') :
UriFactory::build('{/base}/' . $value->profile->image->getPath()); ?>"></a>
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->getId(); ?></a>
src="<?= $value->profile->image->id === 0 ?
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') :
UriFactory::build('{/base}/' . $value->profile->image->getPath()); ?>"></a>
<td data-label="<?= $this->getHtml('ID', '0', '0'); ?>"><a href="<?= $url; ?>"><?= $value->id; ?></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml(
\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()->unit->name); ?>
<td><?= $this->printHtml($value->getNewestHistory()->position->name); ?>
<td><?= $this->printHtml($value->getNewestHistory()->department->name); ?>
<td><?= !($value->getNewestHistory() instanceof NullEmployeeHistory) ? $this->getHtml('Active') : $this->getHtml('Inactive'); ?>
<td><?= $value->getNewestHistory()->id > 0 ? $this->getHtml('Active') : $this->getHtml('Inactive'); ?>
<?php endforeach; ?>
<?php if ($c === 0) : ?>
<tr><td colspan="6" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>

View File

@ -52,8 +52,8 @@ echo $this->getData('nav')->render(); ?>
alt="<?= $this->getHtml('ProfileImage'); ?>"
itemprop="logo" loading="lazy"
src="<?=
$employee->image instanceof NullMedia ?
($employee->profile->image instanceof NullMedia ?
$employee->image->id === 0 ?
($employee->profile->image->id === 0 ?
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') :
UriFactory::build('{/base}/' . $employee->profile->image->getPath())) :
UriFactory::build('{/base}/' . $employee->image->getPath()); ?>"
@ -98,7 +98,7 @@ echo $this->getData('nav')->render(); ?>
<td itemprop="telephone">+01 12345-4567
<tr>
<th><?= $this->getHtml('Status'); ?>
<td><span class="tag green"><?= !($recentHistory instanceof NullEmployeeHistory) ? $this->getHtml('Active') : $this->getHtml('Inactive'); ?></span>
<td><span class="tag green"><?= $recentHistory->id > 0 ? $this->getHtml('Active') : $this->getHtml('Inactive'); ?></span>
</table>
<!-- @formatter:on -->
</div>

View File

@ -129,7 +129,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
// can create multiple accounts if profiles is a list of ids e.g. 1,2,3
$this->module->apiEmployeeCreate($request, $response);
self::assertGreaterThan(0, self::$employee = $response->get('')['response'][0]->getId());
self::assertGreaterThan(0, self::$employee = $response->get('')['response'][0]->id);
}
/**
@ -145,7 +145,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
$request->setData('name1', 'NewEmployee');
$this->module->apiEmployeeCreate($request, $response);
self::assertGreaterThan(0, self::$employee = $response->get('')['response']->getId());
self::assertGreaterThan(0, self::$employee = $response->get('')['response']->id);
}
/**
@ -225,7 +225,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
$request->setData('department', 1);
$request->setData('position', 1);
$this->module->apiEmployeeHistoryCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
$start = clone $end;
$end = DateTime::generateDateTime(
@ -285,7 +285,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
$request->setData('state', '');
$this->module->apiEmployeeWorkHistoryCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
$start = clone $end;
$end = DateTime::generateDateTime(
@ -346,7 +346,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase
$request->setData('state', '');
$this->module->apiEmployeeEducationHistoryCreate($request, $response);
self::assertGreaterThan(0, $response->get('')['response']->getId());
self::assertGreaterThan(0, $response->get('')['response']->id);
$start = clone $end;
$end = DateTime::generateDateTime(

View File

@ -37,7 +37,7 @@ final class EmployeeEducationHistoryTest extends \PHPUnit\Framework\TestCase
*/
public function testDefault() : void
{
self::assertEquals(0, $this->history->getId());
self::assertEquals(0, $this->history->id);
self::assertNull($this->history->end);
self::assertEquals(0, $this->history->employee);
self::assertEquals('', $this->history->educationTitle);

View File

@ -35,10 +35,10 @@ final class EmployeeHistoryMapperTest extends \PHPUnit\Framework\TestCase
$history = new EmployeeHistory($employee);
$id = EmployeeHistoryMapper::create()->execute($history);
self::assertGreaterThan(0, $history->getId());
self::assertEquals($id, $history->getId());
self::assertGreaterThan(0, $history->id);
self::assertEquals($id, $history->id);
$historyR = EmployeeHistoryMapper::get()->where('id', $history->getId())->execute();
self::assertEquals($history->employee->getId(), $historyR->employee->getId());
$historyR = EmployeeHistoryMapper::get()->where('id', $history->id)->execute();
self::assertEquals($history->employee->id, $historyR->employee->id);
}
}

View File

@ -31,7 +31,7 @@ final class EmployeeMapperTest extends \PHPUnit\Framework\TestCase
*/
public function testCR() : void
{
if (($profile = ProfileMapper::get()->where('account', 1)->execute())->getId() === 0) {
if (($profile = ProfileMapper::get()->where('account', 1)->execute())->id === 0) {
$profile = new Profile();
$profile->account = AccountMapper::get()->where('id', 1)->execute();
@ -43,11 +43,11 @@ final class EmployeeMapperTest extends \PHPUnit\Framework\TestCase
$employee = new Employee($profile);
$id = EmployeeMapper::create()->execute($employee);
self::assertGreaterThan(0, $employee->getId());
self::assertEquals($id, $employee->getId());
self::assertGreaterThan(0, $employee->id);
self::assertEquals($id, $employee->id);
$employeeR = EmployeeMapper::get()->where('id', $employee->getId())->execute();
self::assertEquals($employee->profile->getId(), $employeeR->profile->getId());
self::assertGreaterThan(0, EmployeeMapper::get()->with('profile')->where('profile/account', 1)->limit(1)->execute()->getId());
$employeeR = EmployeeMapper::get()->where('id', $employee->id)->execute();
self::assertEquals($employee->profile->id, $employeeR->profile->id);
self::assertGreaterThan(0, EmployeeMapper::get()->with('profile')->where('profile/account', 1)->limit(1)->execute()->id);
}
}

View File

@ -40,7 +40,7 @@ final class EmployeeTest extends \PHPUnit\Framework\TestCase
*/
public function testDefault() : void
{
self::assertEquals(0, $this->employee->getId());
self::assertEquals(0, $this->employee->id);
self::assertGreaterThan(0, \strlen($this->employee->getSemiPrivateHash()));
self::assertFalse($this->employee->compareSemiPrivateHash('123'));
self::assertInstanceOf('\Modules\Media\Models\NullMedia', $this->employee->image);

View File

@ -37,7 +37,7 @@ final class EmployeeWorkHistoryTest extends \PHPUnit\Framework\TestCase
*/
public function testDefault() : void
{
self::assertEquals(0, $this->history->getId());
self::assertEquals(0, $this->history->id);
self::assertNull($this->history->end);
self::assertEquals(0, $this->history->employee);
self::assertEquals('', $this->history->jobTitle);

View File

@ -37,7 +37,7 @@ final class EmployeeHistoryTest extends \PHPUnit\Framework\TestCase
*/
public function testDefault() : void
{
self::assertEquals(0, $this->history->getId());
self::assertEquals(0, $this->history->id);
self::assertNull($this->history->end);
self::assertEquals(0, $this->history->employee);
self::assertInstanceOf('\Modules\Organization\Models\NullPosition', $this->history->position);

View File

@ -37,6 +37,6 @@ final class NullEmployeeEducationHistoryTest extends \PHPUnit\Framework\TestCase
public function testId() : void
{
$null = new NullEmployeeEducationHistory(2);
self::assertEquals(2, $null->getId());
self::assertEquals(2, $null->id);
}
}

View File

@ -37,6 +37,6 @@ final class NullEmployeeHistoryTest extends \PHPUnit\Framework\TestCase
public function testId() : void
{
$null = new NullEmployeeHistory(2);
self::assertEquals(2, $null->getId());
self::assertEquals(2, $null->id);
}
}

View File

@ -37,6 +37,6 @@ final class NullEmployeeTest extends \PHPUnit\Framework\TestCase
public function testId() : void
{
$null = new NullEmployee(2);
self::assertEquals(2, $null->getId());
self::assertEquals(2, $null->id);
}
}

View File

@ -37,6 +37,6 @@ final class NullEmployeeWorkHistoryTest extends \PHPUnit\Framework\TestCase
public function testId() : void
{
$null = new NullEmployeeWorkHistory(2);
self::assertEquals(2, $null->getId());
self::assertEquals(2, $null->id);
}
}