prepare for timerecording module

This commit is contained in:
Dennis Eichhorn 2019-10-06 17:50:44 +02:00
parent 114d01964b
commit d55ccb853a
11 changed files with 313 additions and 125 deletions

View File

@ -9,17 +9,28 @@
"primary": true,
"autoincrement": true
},
"hr_staff_account": {
"name": "hr_staff_account",
"hr_staff_profile": {
"name": "hr_staff_profile",
"type": "INT",
"null": false,
"foreignTable": "account",
"foreignKey": "account_id"
"foreignTable": "profile_account",
"foreignKey": "profile_account_id"
},
"hr_staff_smiPHash": {
"name": "hr_staff_smiPHash",
"type": "VARCHAR(256)",
"type": "VARBINARY(255)",
"null": false
},
"hr_staff_image": {
"name": "hr_staff_image",
"type": "INT",
"default": null,
"null": true,
"foreignTable": "media",
"foreignKey": "media_id",
"annotations": {
"gdpr": true
}
}
}
},

View File

@ -19,7 +19,6 @@ use Modules\HumanResourceManagement\Models\EmployeeMapper;
use Modules\HumanResourceManagement\Models\EmployeeHistory;
use Modules\HumanResourceManagement\Models\EmployeeHistoryMapper;
use phpOMS\Localization\ISO639x1Enum;
use phpOMS\Message\NotificationLevel;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
@ -53,7 +52,7 @@ final class ApiController extends Controller
*/
public function apiEmployeeCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
{
if ($request->getData('accounts') !== null) {
if ($request->getData('profiles') !== null) {
$this->apiEmployeeFromAccountCreate($request, $response, $data);
}
@ -87,7 +86,7 @@ final class ApiController extends Controller
}
/**
* Validate employee from account create request
* Validate employee from profile create request
*
* @param RequestAbstract $request Request
*
@ -98,7 +97,7 @@ final class ApiController extends Controller
private function validateEmployeeFromAccountCreate(RequestAbstract $request) : array
{
$val = [];
if (($val['account'] = empty($request->getData('account')))) {
if (($val['profile'] = empty($request->getData('profiles')))) {
return $val;
}
@ -106,7 +105,7 @@ final class ApiController extends Controller
}
/**
* Method to create employee from account from request.
* Method to create employee from profile from request.
*
* @param RequestAbstract $request Request
*
@ -116,7 +115,7 @@ final class ApiController extends Controller
*/
private function createEmployeeFromAccountFromRequest(RequestAbstract $request) : array
{
$accounts = $request->getData('cc') ?? [];
$accounts = $request->getData('profiles') ?? [];
if (!\is_array($accounts)) {
$accounts = [$accounts];
}

View File

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Modules\HumanResourceManagement\Models;
use Modules\Media\Models\NullMedia;
use phpOMS\Contract\ArrayableInterface;
/**
@ -43,6 +44,14 @@ class Employee implements ArrayableInterface, \JsonSerializable
*/
private $profile = null;
/**
* Employee image.
*
* @var null|int|Media
* @since 1.0.0
*/
private $image = null;
/**
* Employee department/position history.
*
@ -88,7 +97,7 @@ class Employee implements ArrayableInterface, \JsonSerializable
/**
* Constructor.
*
* @param null|Profile $profile Account profile to initialize this employee with
* @param null|int|Profile $profile Account profile to initialize this employee with
*
* @since 1.0.0
*/
@ -99,9 +108,9 @@ class Employee implements ArrayableInterface, \JsonSerializable
}
/**
* Get account id.
* Get id.
*
* @return int Account id
* @return int Employee id
*
* @since 1.0.0
*/
@ -122,6 +131,32 @@ class Employee implements ArrayableInterface, \JsonSerializable
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.
*

View File

@ -33,20 +33,43 @@ use phpOMS\Contract\ArrayableInterface;
*/
class EmployeeHistory implements ArrayableInterface, \JsonSerializable
{
private $id = 0;
/**
* ID.
*
* @var int
* @since 1.0.0
*/
protected int $id = 0;
private $employee = null;
private $unit = null;
private $unit = 0;
private $department = null;
private $department = 0;
private $position = null;
private $position = 0;
private $start = null;
private $end = null;
/**
* Constructor.
*
* @since 1.0.0
*/
public function __construct()
{
$this->start = new \DateTime('now');
}
/**
* Get id.
*
* @return int Model id
*
* @since 1.0.0
*/
public function getId() : int
{
return $this->id;

View File

@ -37,8 +37,9 @@ final class EmployeeMapper extends DataMapperAbstract
*/
protected static array $columns = [
'hr_staff_id' => ['name' => 'hr_staff_id', 'type' => 'int', 'internal' => 'id'],
'hr_staff_account' => ['name' => 'hr_staff_account', 'type' => 'int', 'internal' => 'account'],
'hr_staff_profile' => ['name' => 'hr_staff_profile', 'type' => 'int', 'internal' => 'profile'],
'hr_staff_smiPHash' => ['name' => 'hr_staff_smiPHash', 'type' => 'string', 'internal' => 'semiPrivateHash'],
'hr_staff_image' => ['name' => 'hr_staff_image', 'type' => 'int', 'internal' => 'image', 'annotations' => ['gdpr' => true]],
];
/**
@ -48,9 +49,9 @@ final class EmployeeMapper extends DataMapperAbstract
* @since 1.0.0
*/
protected static array $belongsTo = [
'account' => [
'profile' => [
'mapper' => ProfileMapper::class,
'src' => 'hr_staff_account',
'src' => 'hr_staff_profile',
],
];
@ -61,7 +62,7 @@ final class EmployeeMapper extends DataMapperAbstract
* @since 1.0.0
*/
protected static array $hasMany = [
'company' => [
'companyHistory' => [
'mapper' => EmployeeHistoryMapper::class,
'table' => 'hr_staff_history',
'dst' => 'hr_staff_history_staff',

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
return ['HumanResourceManagement' => [
'Account' => 'Account',
'Active' => 'Active',

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
/**
* @var \phpOMS\Views\View $this
*/

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,8 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use \Modules\HumanResourceManagement\Models\EmployeeActivityStatus;

View File

@ -1,4 +1,7 @@
<?php declare(strict_types=1);
use Modules\HumanResourceManagement\Models\NullEmployeeHistory;
/**
* Orange Management
*
@ -21,27 +24,31 @@ echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="default">
<table id="employeeList" class="default">
<caption><?= $this->getHtml('Staff') ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead>
<tr>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td class="wf-100"><?= $this->getHtml('Name') ?>
<td><?= $this->getHtml('Unit') ?>
<td><?= $this->getHtml('Position') ?>
<td><?= $this->getHtml('Department') ?>
<td><?= $this->getHtml('Status') ?>
<td><?= $this->getHtml('ID', '0', '0'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td class="wf-100"><?= $this->getHtml('Name') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Unit') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Position') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Department') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Status') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tfoot>
<tr><td colspan="5">
<tr><td colspan="6">
<tbody>
<?php $c = 0; foreach ($employees as $key => $value) : ++$c;
$url = \phpOMS\Uri\UriFactory::build('{/prefix}humanresource/staff/profile?{?}&id=' . $value->getId()); ?>
<tr 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->getAccount()->getName1()); ?></a>
<td data-label="<?= $this->getHtml('Name') ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->getProfile()->getAccount()->getName1()); ?></a>
<td><?= $value->getNewestHistory()->getUnit()->getName(); ?>
<td><?= $value->getNewestHistory()->getPosition()->getName(); ?>
<td><?= $value->getNewestHistory()->getDepartment()->getName(); ?>
<td><?= !($value->getNewestHistory() instanceof NullEmployeeHistory) ? $this->getHtml('Active') : $this->getHtml('Inactive'); ?>
<?php endforeach; ?>
<?php if ($c === 0) : ?>
<tr><td colspan="5" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<tr><td colspan="6" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>

View File

@ -1,4 +1,4 @@
<?php declare(strict_types=1);
<?php
/**
* Orange Management
*
@ -10,6 +10,11 @@
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
use Modules\Media\Models\NullMedia;
use phpOMS\Uri\UriFactory;
$employee = $this->getData('employee');
$history = $employee->getHistorY();
@ -17,96 +22,195 @@ $recentHistory = $employee->getNewestHistory();
echo $this->getData('nav')->render(); ?>
<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->getAccount()->getName3()); ?></span>, <span itemprop="givenName"><?= $this->printHtml($employee->getAccount()->getName1()); ?></span></h1></header>
<div class="inner">
<!-- @formatter:off -->
<table class="list">
<tr>
<th><?= $this->getHtml('Position') ?>
<td itemprop="jobTitle"><?= $this->printHtml($recentHistory->getPosition()->getName()); ?>
<tr>
<th><?= $this->getHtml('Department') ?>
<td itemprop="jobTitle"><?= $this->printHtml($recentHistory->getDepartment()->getName()); ?>
<tr>
<th><?= $this->getHtml('Unit') ?>
<td itemprop="jobTitle"><?= $this->printHtml($recentHistory->getUnit()->getName()); ?>
<tr>
<th><?= $this->getHtml('Birthday') ?>
<td itemprop="birthDate">06.09.1934
<tr>
<th><?= $this->getHtml('Email') ?>
<td itemprop="email"><a href="mailto:>donald.duck@email.com<"><?= $this->printHtml($employee->getAccount()->getEmail()); ?></a>
<tr>
<th>Address
<td>
<tr>
<th class="vT">Private
<td itemprop="address">SMALLSYS INC<br>795 E DRAGRAM<br>TUCSON AZ 85705<br>USA
<tr>
<th class="vT">Work
<td itemprop="address">SMALLSYS INC<br>795 E DRAGRAM<br>TUCSON AZ 85705<br>USA
<tr>
<th><?= $this->getHtml('Phone') ?>
<td>
<tr>
<th>Private
<td itemprop="telephone">+01 12345-4567
<tr>
<th>Mobile
<td itemprop="telephone">+01 12345-4567
<tr>
<th>Work
<td itemprop="telephone">+01 12345-4567
<tr>
<th><?= $this->getHtml('Status') ?>
<td><span class="tag green"><?= $this->printHtml($employee->getAccount()->getStatus()); ?></span>
<div class="tabview tab-2">
<div class="box wf-100 col-xs-12">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->getHtml('General'); ?></label></li>
<li><label for="c-tab-2"><?= $this->getHtml('Clocking'); ?></label></li>
<li><label for="c-tab-3"><?= $this->getHtml('Documents'); ?></label></li>
<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>
</ul>
</div>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-2" 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>
<div class="inner">
<!-- @formatter:off -->
<span class="rf">
<img class="m-profile rf"
alt="<?= $this->getHtml('ProfileImage'); ?>"
itemprop="logo"
data-lazyload="<?=
$employee->getImage() instanceof NullMedia ?
$employee->getProfile()->getImage() 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()); ?>"
>
</span>
<table class="list">
<tr>
<th><?= $this->getHtml('Position') ?>
<td itemprop="jobTitle"><?= $this->printHtml($recentHistory->getPosition()->getName()); ?>
<tr>
<th><?= $this->getHtml('Department') ?>
<td itemprop="jobTitle"><?= $this->printHtml($recentHistory->getDepartment()->getName()); ?>
<tr>
<th><?= $this->getHtml('Unit') ?>
<td itemprop="jobTitle"><?= $this->printHtml($recentHistory->getUnit()->getName()); ?>
<tr>
<th><?= $this->getHtml('Birthday') ?>
<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>
<tr>
<th>Address
<td>
<tr>
<th class="vT">Private
<td itemprop="address">SMALLSYS INC<br>795 E DRAGRAM<br>TUCSON AZ 85705<br>USA
<tr>
<th class="vT">Work
<td itemprop="address">SMALLSYS INC<br>795 E DRAGRAM<br>TUCSON AZ 85705<br>USA
<tr>
<th><?= $this->getHtml('Phone') ?>
<td>
<tr>
<th>Private
<td itemprop="telephone">+01 12345-4567
<tr>
<th>Mobile
<td itemprop="telephone">+01 12345-4567
<tr>
<th>Work
<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>
</table>
<!-- @formatter:on -->
</div>
</section>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100 x-overflow">
<table id="historyList" class="default">
<caption><?= $this->getHtml('History') ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead>
<td><?= $this->getHtml('Start') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('End') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Unit') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Department') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Position') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tfoot>
<tbody>
<?php foreach ($history as $hist) : ?>
<tr><td><?= $hist->getStart()->format('Y-m-d'); ?>
<td><?= $hist->getEnd() === null ? '' : $hist->getEnd()->format('Y-m-d'); ?>
<td><?= $this->printHtml($hist->getUnit()->getName()); ?>
<td><?= $this->printHtml($hist->getDepartment()->getName()); ?>
<td><?= $this->printHtml($hist->getPosition()->getName()); ?>
<?php endforeach; ?>
</table>
<!-- @formatter:on -->
</div>
</div>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Clocking') ?></h1></header>
<div class="inner">
</div>
<input type="radio" id="c-tab-2" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Clocking') ?></h1></header>
<div class="inner">
</div>
</section>
</div>
</div>
</section>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Clocking') ?></h1></header>
<div class="inner">
</div>
<input type="radio" id="c-tab-3" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Clocking') ?></h1></header>
<div class="inner">
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-4" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Clocking') ?></h1></header>
<div class="inner">
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-5" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Clocking') ?></h1></header>
<div class="inner">
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-6" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Clocking') ?></h1></header>
<div class="inner">
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-7" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Clocking') ?></h1></header>
<div class="inner">
</div>
</section>
</div>
</div>
</div>
<input type="radio" id="c-tab-8" name="tabular-2">
<div class="tab">
<div class="row">
<div class="col-xs-12">
<section class="box wf-100">
<header><h1><?= $this->getHtml('Clocking') ?></h1></header>
<div class="inner">
</div>
</section>
</div>
</div>
</section>
</div>
<div class="col-xs-12 col-md-6">
<div class="box wf-100 x-overflow">
<table id="taskList" class="default">
<caption><?= $this->getHtml('History') ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead>
<td><?= $this->getHtml('Start') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('End') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Unit') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Department') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td><?= $this->getHtml('Position') ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tfoot>
<tbody>
<?php foreach ($history as $hist) : ?>
<tr><td><?= $hist->getStart()->format('Y-m-d'); ?>
<td><?= $hist->getEnd() === null ? '' : $hist->getEnd()->format('Y-m-d'); ?>
<td><?= $this->printHtml($hist->getUnit()->getName()); ?>
<td><?= $this->printHtml($hist->getDepartment()->getName()); ?>
<td><?= $this->printHtml($hist->getPosition()->getName()); ?>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>

View File

@ -18,10 +18,12 @@
"directory": "HumanResourceManagement",
"dependencies": {
"Admin": "1.0.0",
"Organization": "1.0.0"
"Organization": "1.0.0",
"Media": "1.0.0"
},
"providing": {
"Navigation": "*"
"Navigation": "*",
"Media": "1.0.0"
},
"load": [
{