Make organization output use belongsTo

This commit is contained in:
Dennis Eichhorn 2017-07-27 20:38:07 +02:00
parent 016e31b077
commit 990062fbe9
13 changed files with 81 additions and 10 deletions

View File

@ -38,6 +38,10 @@ class DepartmentMapper extends DataMapperAbstract
'mapper' => UnitMapper::class,
'dest' => 'organization_department_unit',
],
'parent' => [
'mapper' => DepartmentMapper::class,
'dest' => 'organization_department_parent',
],
];
/**

19
Models/NullDepartment.php Normal file
View File

@ -0,0 +1,19 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Organization\Models;
class NullDepartment extends Department
{
}

19
Models/NullPosition.php Normal file
View File

@ -0,0 +1,19 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Organization\Models;
class NullPosition extends Position
{
}

19
Models/NullUnit.php Normal file
View File

@ -0,0 +1,19 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Organization\Models;
class NullUnit extends Unit
{
}

View File

@ -60,7 +60,7 @@ class Position implements ArrayableInterface, \JsonSerializable
return $this->department;
}
public function setDepartment(int $department)
public function setDepartment($department)
{
$this->department = $department;
}

View File

@ -35,10 +35,14 @@ class PositionMapper extends DataMapperAbstract
];
protected static $belongsTo = [
'account' => [
'parent' => [
'mapper' => PositionMapper::class,
'dest' => 'organization_position_parent',
],
'department' => [
'mapper' => DepartmentMapper::class,
'dest' => 'organization_position_department',
],
];
/**

View File

@ -37,6 +37,10 @@ class UnitMapper extends DataMapperAbstract
'mapper' => UnitMapper::class,
'dest' => 'organization_uni_parent',
],
'parent' => [
'mapper' => UnitMapper::class,
'dest' => 'organization_unit_parent',
],
];
/**

View File

@ -43,8 +43,8 @@ echo $this->getData('nav')->render(); ?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= htmlspecialchars($value->getId(), ENT_COMPAT, 'utf-8'); ?></a>
<td><a href="<?= $url; ?>"><?= htmlspecialchars($value->getName(), ENT_COMPAT, 'utf-8'); ?></a>
<td><a href="<?= $url; ?>"><?= htmlspecialchars($value->getParent(), ENT_COMPAT, 'utf-8'); ?></a>
<td><a href="<?= $url; ?>"><?= htmlspecialchars($value->getUnit(), ENT_COMPAT, 'utf-8'); ?></a>
<td><a href="<?= $url; ?>"><?= htmlspecialchars($value->getParent()->getName(), ENT_COMPAT, 'utf-8'); ?></a>
<td><a href="<?= $url; ?>"><?= htmlspecialchars($value->getUnit()->getName(), ENT_COMPAT, 'utf-8'); ?></a>
<?php endforeach; ?>
<?php if($c === 0) : ?>
<tr>

View File

@ -29,7 +29,7 @@ echo $this->getData('nav')->render(); ?>
<tr><td><label for="iName"><?= $this->getHtml('Name') ?></label>
<tr><td><input type="text" name="name" id="iName" value="<?= htmlspecialchars($department->getName(), ENT_COMPAT, 'utf-8'); ?>">
<tr><td><label for="iParent"><?= $this->getHtml('Parent') ?></label>
<tr><td><input type="text" name="parent" id="iParent" value="<?= htmlspecialchars($department->getParent(), ENT_COMPAT, 'utf-8'); ?>">
<tr><td><input type="text" name="parent" id="iParent" value="<?= htmlspecialchars($department->getParent()->getName(), ENT_COMPAT, 'utf-8'); ?>">
<tr><td><label for="iStatus"><?= $this->getHtml('Status') ?></label>
<tr><td><select name="status" id="iStatus">
<option><?= $this->getHtml('Active') ?>

View File

@ -36,6 +36,7 @@ echo $this->getData('nav')->render(); ?>
<td><?= $this->getHtml('ID', 0, 0); ?>
<td class="wf-100"><?= $this->getHtml('Name') ?>
<td><?= $this->getHtml('Parent') ?>
<td><?= $this->getHtml('Department') ?>
<tfoot>
<tr><td colspan="3"><?= $footerView->render(); ?>
<tbody>
@ -44,7 +45,8 @@ echo $this->getData('nav')->render(); ?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><?= htmlspecialchars($value->getId(), ENT_COMPAT, 'utf-8'); ?></a>
<td><a href="<?= $url; ?>"><?= htmlspecialchars($value->getName(), ENT_COMPAT, 'utf-8'); ?></a>
<td><a href="<?= $url; ?>"><?= htmlspecialchars($value->getParent(), ENT_COMPAT, 'utf-8'); ?></a>
<td><a href="<?= $url; ?>"><?= htmlspecialchars($value->getParent()->getName(), ENT_COMPAT, 'utf-8'); ?></a>
<td><a href="<?= $url; ?>"><?= 1//htmlspecialchars($value->getDepartment()->getName(), ENT_COMPAT, 'utf-8'); ?></a>
<?php endforeach; ?>
<?php if($count === 0) : ?>
<tr><td colspan="5" class="empty"><?= $this->getHtml('Empty', 0, 0); ?>

View File

@ -29,7 +29,7 @@ echo $this->getData('nav')->render(); ?>
<tr><td><label for="iName"><?= $this->getHtml('Name') ?></label>
<tr><td><input type="text" name="name" id="iName" value="<?= htmlspecialchars($position->getName(), ENT_COMPAT, 'utf-8'); ?>">
<tr><td><label for="iParent"><?= $this->getHtml('Parent') ?></label>
<tr><td><input type="text" name="parent" id="iParent" value="<?= htmlspecialchars($position->getParent(), ENT_COMPAT, 'utf-8'); ?>">
<tr><td><input type="text" name="parent" id="iParent" value="<?= htmlspecialchars($position->getParent()->getName(), ENT_COMPAT, 'utf-8'); ?>">
<tr><td><label for="iStatus"><?= $this->getHtml('Status') ?></label>
<tr><td><select name="status" id="iStatus">
<option><?= $this->getHtml('Active') ?>

View File

@ -40,9 +40,9 @@ echo $this->getData('nav')->render(); ?>
<?php foreach ($this->getData('list:elements') as $key => $value) :
$url = \phpOMS\Uri\UriFactory::build('{/base}/{/lang}/backend/organization/unit/profile?{?}&id=' . $value->getId()); ?>
<tr data-href="<?= $url; ?>">
<td data-label="<?= $this->getHtml('ID', 0, 0); ?>"><a href="<?= $url; ?>"><?= htmlspecialchars($value->getId() ?></a>
<td data-label="<?= $this->getHtml('ID', 0, 0); ?>"><a href="<?= $url; ?>"><?= htmlspecialchars($value->getId()); ?></a>
<td data-label="<?= $this->getHtml('Name') ?>"><a href="<?= $url; ?>"><?= htmlspecialchars($value->getName(), ENT_COMPAT, 'utf-8'); ?></a>
<td data-label="<?= $this->getHtml('Parent') ?>"><a href="<?= $url; ?>"><?= htmlspecialchars($value->getParent(), ENT_COMPAT, 'utf-8'); ?></a>
<td data-label="<?= $this->getHtml('Parent') ?>"><a href="<?= $url; ?>"><?= htmlspecialchars($value->getParent()->getName(), ENT_COMPAT, 'utf-8'); ?></a>
<?php endforeach; ?>
</table>
</div>

View File

@ -29,7 +29,7 @@ echo $this->getData('nav')->render(); ?>
<tr><td><label for="iName"><?= $this->getHtml('Name') ?></label>
<tr><td><input type="text" name="name" id="iName" value="<?= htmlspecialchars($unit->getName(), ENT_COMPAT, 'utf-8'); ?>">
<tr><td><label for="iParent"><?= $this->getHtml('Parent') ?></label>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" name="parent" id="iParent" value="<?= htmlspecialchars($unit->getParent(), ENT_COMPAT, 'utf-8'); ?>" required></span>
<tr><td><span class="input"><button type="button" formaction=""><i class="fa fa-book"></i></button><input type="text" name="parent" id="iParent" value="<?= htmlspecialchars($unit->getParent()->getName(), ENT_COMPAT, 'utf-8'); ?>" required></span>
<tr><td><label for="iStatus"><?= $this->getHtml('Status') ?></label>
<tr><td><select name="status" id="iStatus">
<option><?= $this->getHtml('Active') ?>