From c22ed99d5f3c39ad8a310093dafc7611d1ec9218 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 26 Mar 2022 15:01:45 +0100 Subject: [PATCH] undo serialize deprecation and switch to installExternal api calls --- Controller/BackendController.php | 24 ++++++++++++-- Models/Employee.php | 3 +- Models/EmployeeEducationHistory.php | 3 +- Models/EmployeeHistory.php | 3 +- Models/EmployeeWorkHistory.php | 3 +- ...f-single.tpl.php => staff-profile.tpl.php} | 32 +++++++++++-------- 6 files changed, 45 insertions(+), 23 deletions(-) rename Theme/Backend/{staff-single.tpl.php => staff-profile.tpl.php} (91%) diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 02e9517..5f26975 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -17,6 +17,7 @@ namespace Modules\HumanResourceManagement\Controller; use Modules\HumanResourceManagement\Models\EmployeeMapper; use Modules\Organization\Models\DepartmentMapper; use phpOMS\Contract\RenderableInterface; +use phpOMS\DataStorage\Database\Query\OrderType; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Views\View; @@ -100,10 +101,29 @@ final class BackendController extends Controller public function viewHrStaffProfile(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); - $view->setTemplate('/Modules/HumanResourceManagement/Theme/Backend/staff-single'); + $view->setTemplate('/Modules/HumanResourceManagement/Theme/Backend/staff-profile'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1002402001, $request, $response)); - $employee = EmployeeMapper::get()->where('id', (int) $request->getData('id'))->execute(); + $employee = EmployeeMapper::get() + ->with('profile') + ->with('profile/account') + ->with('companyHistory') + ->with('companyHistory/unit') + ->with('companyHistory/department') + ->with('companyHistory/position') + ->with('educationHistory') + ->with('educationHistory/unit') + ->with('educationHistory/department') + ->with('educationHistory/position') + ->with('workHistory') + ->with('workHistory/unit') + ->with('workHistory/department') + ->with('workHistory/position') + ->where('id', (int) $request->getData('id')) + ->sort('companyHistory/start', OrderType::DESC) + ->sort('educationHistory/start', OrderType::DESC) + ->sort('workHistory/start', OrderType::DESC) + ->execute(); $view->addData('employee', $employee); diff --git a/Models/Employee.php b/Models/Employee.php index 92f1f3a..b405af0 100755 --- a/Models/Employee.php +++ b/Models/Employee.php @@ -18,7 +18,6 @@ use Modules\Media\Models\Media; use Modules\Media\Models\NullMedia; use Modules\Profile\Models\NullProfile; use Modules\Profile\Models\Profile; -use phpOMS\Contract\ArrayableInterface; /** * Employee class. @@ -28,7 +27,7 @@ use phpOMS\Contract\ArrayableInterface; * @link https://karaka.app * @since 1.0.0 */ -class Employee implements \JsonSerializable, ArrayableInterface +class Employee implements \JsonSerializable { /** * Employee ID. diff --git a/Models/EmployeeEducationHistory.php b/Models/EmployeeEducationHistory.php index 3f6dd14..d4716c7 100755 --- a/Models/EmployeeEducationHistory.php +++ b/Models/EmployeeEducationHistory.php @@ -16,7 +16,6 @@ namespace Modules\HumanResourceManagement\Models; use Modules\Admin\Models\Address; use Modules\Media\Models\Media; -use phpOMS\Contract\ArrayableInterface; /** * Employee class. @@ -26,7 +25,7 @@ use phpOMS\Contract\ArrayableInterface; * @link https://karaka.app * @since 1.0.0 */ -class EmployeeEducationHistory implements \JsonSerializable, ArrayableInterface +class EmployeeEducationHistory implements \JsonSerializable { /** * ID. diff --git a/Models/EmployeeHistory.php b/Models/EmployeeHistory.php index 17a8053..fd22b6f 100755 --- a/Models/EmployeeHistory.php +++ b/Models/EmployeeHistory.php @@ -21,7 +21,6 @@ use Modules\Organization\Models\NullPosition; use Modules\Organization\Models\NullUnit; use Modules\Organization\Models\Position; use Modules\Organization\Models\Unit; -use phpOMS\Contract\ArrayableInterface; /** * Employee class. @@ -31,7 +30,7 @@ use phpOMS\Contract\ArrayableInterface; * @link https://karaka.app * @since 1.0.0 */ -class EmployeeHistory implements \JsonSerializable, ArrayableInterface +class EmployeeHistory implements \JsonSerializable { /** * ID. diff --git a/Models/EmployeeWorkHistory.php b/Models/EmployeeWorkHistory.php index 6080fb7..04713f9 100755 --- a/Models/EmployeeWorkHistory.php +++ b/Models/EmployeeWorkHistory.php @@ -16,7 +16,6 @@ namespace Modules\HumanResourceManagement\Models; use Modules\Admin\Models\Address; use Modules\Media\Models\Media; -use phpOMS\Contract\ArrayableInterface; /** * Employee class. @@ -26,7 +25,7 @@ use phpOMS\Contract\ArrayableInterface; * @link https://karaka.app * @since 1.0.0 */ -class EmployeeWorkHistory implements \JsonSerializable, ArrayableInterface +class EmployeeWorkHistory implements \JsonSerializable { /** * ID. diff --git a/Theme/Backend/staff-single.tpl.php b/Theme/Backend/staff-profile.tpl.php similarity index 91% rename from Theme/Backend/staff-single.tpl.php rename to Theme/Backend/staff-profile.tpl.php index 2efc258..830e40c 100755 --- a/Theme/Backend/staff-single.tpl.php +++ b/Theme/Backend/staff-profile.tpl.php @@ -18,8 +18,8 @@ use phpOMS\Uri\UriFactory; $employee = $this->getData('employee'); $history = $employee->getHistory(); -$education = $employee->getEducationHistory(); -$work = $employee->getWorkHistory(); +$educationHistory = $employee->getEducationHistory(); +$workHistory = $employee->getWorkHistory(); $recentHistory = $employee->getNewestHistory(); echo $this->getData('nav')->render(); ?> @@ -33,8 +33,9 @@ echo $this->getData('nav')->render(); ?>
  • -
  • -
  • +
  • +
  • +
  • @@ -118,8 +119,8 @@ echo $this->getData('nav')->render(); ?> getHtml('Position'); ?> - getStart()->format('Y-m-d'); ?> - getEnd() === null ? '' : $hist->getEnd()->format('Y-m-d'); ?> + start->format('Y-m-d'); ?> + end === null ? '' : $hist->end->format('Y-m-d'); ?> printHtml($hist->unit->name); ?> printHtml($hist->department->name); ?> printHtml($hist->position->name); ?> @@ -190,6 +191,11 @@ echo $this->getData('nav')->render(); ?>
    request->uri->fragment === 'c-tab-7' ? ' checked' : ''; ?>> +
    +
    +
    +
    + request->uri->fragment === 'c-tab-7' ? ' checked' : ''; ?>>
    @@ -202,9 +208,9 @@ echo $this->getData('nav')->render(); ?> getHtml('Title'); ?> getHtml('Address'); ?> - - getStart()->format('Y-m-d'); ?> - getEnd() === null ? '' : $hist->getEnd()->format('Y-m-d'); ?> + + start->format('Y-m-d'); ?> + end === null ? '' : $hist->end->format('Y-m-d'); ?> printHtml($hist->educationTitle); ?> printHtml($hist->address->name); ?> @@ -213,7 +219,7 @@ echo $this->getData('nav')->render(); ?>
    - request->uri->fragment === 'c-tab-8' ? ' checked' : ''; ?>> + request->uri->fragment === 'c-tab-8' ? ' checked' : ''; ?>>
    @@ -226,9 +232,9 @@ echo $this->getData('nav')->render(); ?> getHtml('Title'); ?> getHtml('Address'); ?> - - getStart()->format('Y-m-d'); ?> - getEnd() === null ? '' : $hist->getEnd()->format('Y-m-d'); ?> + + start->format('Y-m-d'); ?> + end === null ? '' : $hist->end->format('Y-m-d'); ?> printHtml($hist->jobTitle); ?> printHtml($hist->address->name); ?>