diff --git a/Models/Employee.php b/Models/Employee.php index 20fc7e7..a26909d 100755 --- a/Models/Employee.php +++ b/Models/Employee.php @@ -35,7 +35,7 @@ class Employee implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Account profile. diff --git a/Models/EmployeeEducationHistory.php b/Models/EmployeeEducationHistory.php index 8d55bcc..9cf1e49 100755 --- a/Models/EmployeeEducationHistory.php +++ b/Models/EmployeeEducationHistory.php @@ -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, diff --git a/Models/EmployeeHistory.php b/Models/EmployeeHistory.php index b2e882c..7987000 100755 --- a/Models/EmployeeHistory.php +++ b/Models/EmployeeHistory.php @@ -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, diff --git a/Models/EmployeeWorkHistory.php b/Models/EmployeeWorkHistory.php index 2b1df73..10b28c0 100755 --- a/Models/EmployeeWorkHistory.php +++ b/Models/EmployeeWorkHistory.php @@ -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, diff --git a/Theme/Backend/department-list.tpl.php b/Theme/Backend/department-list.tpl.php index af6c9c3..5306ec6 100755 --- a/Theme/Backend/department-list.tpl.php +++ b/Theme/Backend/department-list.tpl.php @@ -43,9 +43,9 @@ echo $this->getData('nav')->render(); ?> getHtml('Parent'); ?> $value) : ++$c; - $url = UriFactory::build('{/base}/hr/department/single?{?}&id=' . $value->getId()); ?> + $url = UriFactory::build('{/base}/hr/department/single?{?}&id=' . $value->id); ?> - getId(); ?> + id; ?> printHtml($value->name); ?> printHtml($value->parent->name); ?> diff --git a/Theme/Backend/staff-list.tpl.php b/Theme/Backend/staff-list.tpl.php index abca035..0b88b83 100755 --- a/Theme/Backend/staff-list.tpl.php +++ b/Theme/Backend/staff-list.tpl.php @@ -42,21 +42,20 @@ echo $this->getData('nav')->render(); ?> getHtml('Status'); ?> $value) : ++$c; - $url = UriFactory::build('{/base}/humanresource/staff/profile?{?}&id=' . $value->getId()); ?> + $url = UriFactory::build('{/base}/humanresource/staff/profile?{?}&id=' . $value->id); ?> <?= $this->getHtml('IMG_alt_staff'); ?> - getId(); ?> + src="profile->image->id === 0 ? + UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') : + UriFactory::build('{/base}/' . $value->profile->image->getPath()); ?>"> + id; ?> printHtml( \sprintf('%3$s %2$s %1$s', $value->profile->account->name1, $value->profile->account->name2, $value->profile->account->name3) ); ?> printHtml($value->getNewestHistory()->unit->name); ?> printHtml($value->getNewestHistory()->position->name); ?> printHtml($value->getNewestHistory()->department->name); ?> - getNewestHistory() instanceof NullEmployeeHistory) ? $this->getHtml('Active') : $this->getHtml('Inactive'); ?> + getNewestHistory()->id > 0 ? $this->getHtml('Active') : $this->getHtml('Inactive'); ?> getHtml('Empty', '0', '0'); ?> diff --git a/Theme/Backend/staff-profile.tpl.php b/Theme/Backend/staff-profile.tpl.php index f1924bc..08c266d 100755 --- a/Theme/Backend/staff-profile.tpl.php +++ b/Theme/Backend/staff-profile.tpl.php @@ -52,8 +52,8 @@ echo $this->getData('nav')->render(); ?> alt="getHtml('ProfileImage'); ?>" itemprop="logo" loading="lazy" src="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(); ?> +01 12345-4567 getHtml('Status'); ?> - getHtml('Active') : $this->getHtml('Inactive'); ?> + id > 0 ? $this->getHtml('Active') : $this->getHtml('Inactive'); ?> diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index a8f3bcd..d3be785 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -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( diff --git a/tests/Models/EmployeeEducationHistoryTest.php b/tests/Models/EmployeeEducationHistoryTest.php index c906a7f..8207af8 100755 --- a/tests/Models/EmployeeEducationHistoryTest.php +++ b/tests/Models/EmployeeEducationHistoryTest.php @@ -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); diff --git a/tests/Models/EmployeeHistoryMapperTest.php b/tests/Models/EmployeeHistoryMapperTest.php index d2ebb55..9539191 100755 --- a/tests/Models/EmployeeHistoryMapperTest.php +++ b/tests/Models/EmployeeHistoryMapperTest.php @@ -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); } } diff --git a/tests/Models/EmployeeMapperTest.php b/tests/Models/EmployeeMapperTest.php index eb5cd4a..0f79b0a 100755 --- a/tests/Models/EmployeeMapperTest.php +++ b/tests/Models/EmployeeMapperTest.php @@ -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); } } diff --git a/tests/Models/EmployeeTest.php b/tests/Models/EmployeeTest.php index 337654e..bb10f0c 100755 --- a/tests/Models/EmployeeTest.php +++ b/tests/Models/EmployeeTest.php @@ -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); diff --git a/tests/Models/EmployeeWorkHistoryTest.php b/tests/Models/EmployeeWorkHistoryTest.php index 31d2aee..1992364 100755 --- a/tests/Models/EmployeeWorkHistoryTest.php +++ b/tests/Models/EmployeeWorkHistoryTest.php @@ -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); diff --git a/tests/Models/EmplyeeHistoryTest.php b/tests/Models/EmplyeeHistoryTest.php index 7b2e07a..a66de0c 100755 --- a/tests/Models/EmplyeeHistoryTest.php +++ b/tests/Models/EmplyeeHistoryTest.php @@ -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); diff --git a/tests/Models/NullEmployeeEducationHistoryTest.php b/tests/Models/NullEmployeeEducationHistoryTest.php index cfa0224..971317e 100755 --- a/tests/Models/NullEmployeeEducationHistoryTest.php +++ b/tests/Models/NullEmployeeEducationHistoryTest.php @@ -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); } } diff --git a/tests/Models/NullEmployeeHistoryTest.php b/tests/Models/NullEmployeeHistoryTest.php index a454408..af546ab 100755 --- a/tests/Models/NullEmployeeHistoryTest.php +++ b/tests/Models/NullEmployeeHistoryTest.php @@ -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); } } diff --git a/tests/Models/NullEmployeeTest.php b/tests/Models/NullEmployeeTest.php index 2589ba8..7301315 100755 --- a/tests/Models/NullEmployeeTest.php +++ b/tests/Models/NullEmployeeTest.php @@ -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); } } diff --git a/tests/Models/NullEmployeeWorkHistoryTest.php b/tests/Models/NullEmployeeWorkHistoryTest.php index 3f8b01f..27265ce 100755 --- a/tests/Models/NullEmployeeWorkHistoryTest.php +++ b/tests/Models/NullEmployeeWorkHistoryTest.php @@ -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); } }