undo serialize deprecation and switch to installExternal api calls

This commit is contained in:
Dennis Eichhorn 2022-03-26 15:01:45 +01:00
parent bb1a6b2204
commit c22ed99d5f
6 changed files with 45 additions and 23 deletions

View File

@ -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);

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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(); ?>
<li><label for="c-tab-4"><?= $this->getHtml('Contracts'); ?></label></li>
<li><label for="c-tab-5"><?= $this->getHtml('Remarks'); ?></label></li>
<li><label for="c-tab-6"><?= $this->getHtml('Evaluations'); ?></label></li>
<li><label for="c-tab-7"><?= $this->getHtml('Education'); ?></label></li>
<li><label for="c-tab-8"><?= $this->getHtml('Work'); ?></label></li>
<li><label for="c-tab-7"><?= $this->getHtml('Salary'); ?></label></li>
<li><label for="c-tab-8"><?= $this->getHtml('Education'); ?></label></li>
<li><label for="c-tab-9"><?= $this->getHtml('Work'); ?></label></li>
</ul>
</div>
<div class="tab-content">
@ -118,8 +119,8 @@ echo $this->getData('nav')->render(); ?>
<td><?= $this->getHtml('Position'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tbody>
<?php foreach ($history as $hist) : ?>
<tr><td><?= $hist->getStart()->format('Y-m-d'); ?>
<td><?= $hist->getEnd() === null ? '' : $hist->getEnd()->format('Y-m-d'); ?>
<tr><td><?= $hist->start->format('Y-m-d'); ?>
<td><?= $hist->end === null ? '' : $hist->end->format('Y-m-d'); ?>
<td><?= $this->printHtml($hist->unit->name); ?>
<td><?= $this->printHtml($hist->department->name); ?>
<td><?= $this->printHtml($hist->position->name); ?>
@ -190,6 +191,11 @@ echo $this->getData('nav')->render(); ?>
</div>
</div>
<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>
</div>
<input type="radio" id="c-tab-8" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-7' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12">
@ -202,9 +208,9 @@ echo $this->getData('nav')->render(); ?>
<td><?= $this->getHtml('Title'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Address'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tbody>
<?php foreach ($education as $hist) : ?>
<tr><td><?= $hist->getStart()->format('Y-m-d'); ?>
<td><?= $hist->getEnd() === null ? '' : $hist->getEnd()->format('Y-m-d'); ?>
<?php foreach ($educationHistory as $hist) : ?>
<tr><td><?= $hist->start->format('Y-m-d'); ?>
<td><?= $hist->end === null ? '' : $hist->end->format('Y-m-d'); ?>
<td><?= $this->printHtml($hist->educationTitle); ?>
<td><?= $this->printHtml($hist->address->name); ?>
<?php endforeach; ?>
@ -213,7 +219,7 @@ echo $this->getData('nav')->render(); ?>
</div>
</div>
</div>
<input type="radio" id="c-tab-8" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-8' ? ' checked' : ''; ?>>
<input type="radio" id="c-tab-9" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-8' ? ' checked' : ''; ?>>
<div class="tab">
<div class="row">
<div class="col-xs-12">
@ -226,9 +232,9 @@ echo $this->getData('nav')->render(); ?>
<td><?= $this->getHtml('Title'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Address'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tbody>
<?php foreach ($work as $hist) : ?>
<tr><td><?= $hist->getStart()->format('Y-m-d'); ?>
<td><?= $hist->getEnd() === null ? '' : $hist->getEnd()->format('Y-m-d'); ?>
<?php foreach ($workHistory as $hist) : ?>
<tr><td><?= $hist->start->format('Y-m-d'); ?>
<td><?= $hist->end === null ? '' : $hist->end->format('Y-m-d'); ?>
<td><?= $this->printHtml($hist->jobTitle); ?>
<td><?= $this->printHtml($hist->address->name); ?>
<?php endforeach; ?>