mirror of
https://github.com/Karaka-Management/oms-AssetManagement.git
synced 2026-01-10 14:28:39 +00:00
fix templates
This commit is contained in:
parent
147bf50478
commit
f2a5970ebc
|
|
@ -42,21 +42,6 @@
|
|||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"parent": 1006601001,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"id": 1006604001,
|
||||
"pid": "/accounting/asset",
|
||||
"type": 3,
|
||||
"subtype": 1,
|
||||
"name": "Entries",
|
||||
"uri": "{/base}/accounting/asset/entry/list",
|
||||
"target": "self",
|
||||
"icon": null,
|
||||
"order": 15,
|
||||
"from": "AssetManagement",
|
||||
"permission": { "permission": 2, "type": null, "element": null },
|
||||
"parent": 1006601001,
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,14 @@
|
|||
"null": true,
|
||||
"foreignTable": "unit",
|
||||
"foreignKey": "unit_id"
|
||||
},
|
||||
"assetmgmt_asset_equipment": {
|
||||
"name": "assetmgmt_asset_equipment",
|
||||
"type": "INT",
|
||||
"default": null,
|
||||
"null": true,
|
||||
"foreignTable": "equipmgmt_equipment",
|
||||
"foreignKey": "equipmgmt_equipment_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -55,30 +55,6 @@ return [
|
|||
],
|
||||
],
|
||||
],
|
||||
'^/accounting/asset/entry/list(\?.*$|$)' => [
|
||||
[
|
||||
'dest' => '\Modules\AssetManagement\Controller\BackendController:viewAssetManagementEntryList',
|
||||
'verb' => RouteVerb::GET,
|
||||
'active' => true,
|
||||
'permission' => [
|
||||
'module' => BackendController::MODULE_NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => PermissionCategory::ASSET,
|
||||
],
|
||||
],
|
||||
],
|
||||
'^/accounting/asset/entry/view(\?.*$|$)' => [
|
||||
[
|
||||
'dest' => '\Modules\AssetManagement\Controller\BackendController:viewAssetManagementEntryView',
|
||||
'verb' => RouteVerb::GET,
|
||||
'active' => true,
|
||||
'permission' => [
|
||||
'module' => BackendController::MODULE_NAME,
|
||||
'type' => PermissionType::READ,
|
||||
'state' => PermissionCategory::ASSET,
|
||||
],
|
||||
],
|
||||
],
|
||||
'^/accounting/asset/create(\?.*$|$)' => [
|
||||
[
|
||||
'dest' => '\Modules\AssetManagement\Controller\BackendController:viewAssetManagementCreate',
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use Modules\AssetManagement\Models\AssetMapper;
|
|||
use Modules\AssetManagement\Models\AssetTypeMapper;
|
||||
use Modules\AssetManagement\Models\Attribute\AssetAttributeTypeL11nMapper;
|
||||
use Modules\AssetManagement\Models\Attribute\AssetAttributeTypeMapper;
|
||||
use Modules\Attribute\Models\NullAttributeType;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use Modules\Media\Models\MediaTypeMapper;
|
||||
use Modules\Organization\Models\UnitMapper;
|
||||
|
|
@ -105,14 +106,57 @@ final class BackendController extends Controller
|
|||
* @since 1.0.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function viewAssetManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
|
||||
public function viewAssetManagementAssetTable(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
|
||||
{
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->setTemplate('/Modules/AssetManagement/Theme/Backend/asset-view');
|
||||
$view->setTemplate('/Modules/AssetManagement/Theme/Backend/asset-table');
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006601001, $request, $response);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routing end-point for application behavior.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return RenderableInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function viewAssetManagementCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
|
||||
{
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->setTemplate('/Modules/AssetManagement/Theme/Backend/asset-create');
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006601001, $request, $response);
|
||||
|
||||
$view->data['hasEquipmentManagement'] = $this->app->moduleManager->isActive('EquipmentManagement');
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routing end-point for application behavior.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return RenderableInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function viewAssetManagementAttributeType(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
|
||||
{
|
||||
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeView($this->app->l11nManager, $request, $response);
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006601001, $request, $response);
|
||||
|
||||
/** @var \Modules\Attribute\Models\AttributeType $attribute */
|
||||
$attribute = AssetAttributeTypeMapper::get()
|
||||
$view->attribute = AssetAttributeTypeMapper::get()
|
||||
->with('l11n')
|
||||
->with('defaults')
|
||||
->with('defaults/l11n')
|
||||
|
|
@ -121,12 +165,11 @@ final class BackendController extends Controller
|
|||
->where('defaults/l11n/language', [$response->header->l11n->language, null])
|
||||
->execute();
|
||||
|
||||
$l11ns = AssetAttributeTypeL11nMapper::getAll()
|
||||
$view->l11ns = AssetAttributeTypeL11nMapper::getAll()
|
||||
->where('ref', $attribute->id)
|
||||
->executeGetArray();
|
||||
|
||||
$view->data['attribute'] = $attribute;
|
||||
$view->data['l11ns'] = $l11ns;
|
||||
$view->path = 'accounting/asset';
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
@ -150,7 +193,7 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/AssetManagement/Theme/Backend/asset-view');
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008402001, $request, $response);
|
||||
|
||||
$asset = AssetMapper::get()
|
||||
$view->data['asset'] = AssetMapper::get()
|
||||
->with('attributes')
|
||||
->with('attributes/type')
|
||||
->with('attributes/value')
|
||||
|
|
@ -166,8 +209,6 @@ final class BackendController extends Controller
|
|||
->where('attributes/value/l11n/language', [$response->header->l11n->language, null])
|
||||
->execute();
|
||||
|
||||
$view->data['asset'] = $asset;
|
||||
|
||||
// @feature Create a new read mapper function that returns relation models instead of its own model
|
||||
// https://github.com/Karaka-Management/phpOMS/issues/320
|
||||
$query = new Builder($this->app->dbPool->get());
|
||||
|
|
@ -181,29 +222,23 @@ final class BackendController extends Controller
|
|||
->on(MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD, '=', MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['self'])
|
||||
->leftJoin(MediaTypeMapper::TABLE)
|
||||
->on(MediaMapper::HAS_MANY['types']['table'] . '.' . MediaMapper::HAS_MANY['types']['external'], '=', MediaTypeMapper::TABLE . '.' . MediaTypeMapper::PRIMARYFIELD)
|
||||
->where(AssetMapper::HAS_MANY['files']['self'], '=', $asset->id)
|
||||
->where(AssetMapper::HAS_MANY['files']['self'], '=', $view->data['asset']->id)
|
||||
->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'asset_profile_image');
|
||||
|
||||
$assetImage = MediaMapper::get()
|
||||
$view->data['assetImage'] = MediaMapper::get()
|
||||
->with('types')
|
||||
->where('id', $results)
|
||||
->limit(1)
|
||||
->execute();
|
||||
|
||||
$view->data['assetImage'] = $assetImage;
|
||||
|
||||
$assetTypes = AssetTypeMapper::getAll()
|
||||
$view->data['types'] = AssetTypeMapper::getAll()
|
||||
->with('l11n')
|
||||
->where('l11n/language', $response->header->l11n->language)
|
||||
->executeGetArray();
|
||||
|
||||
$view->data['types'] = $assetTypes;
|
||||
|
||||
$units = UnitMapper::getAll()
|
||||
$view->data['units'] = UnitMapper::getAll()
|
||||
->executeGetArray();
|
||||
|
||||
$view->data['units'] = $units;
|
||||
|
||||
$view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response);
|
||||
$view->data['attributeView']->data['default_localization'] = $this->app->l11nServer;
|
||||
|
||||
|
|
@ -212,4 +247,31 @@ final class BackendController extends Controller
|
|||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Routing end-point for application behavior.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return RenderableInterface Returns a renderable object
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function viewAssetManagementAttributeTypeList(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
|
||||
{
|
||||
$view = new \Modules\Attribute\Theme\Backend\Components\AttributeTypeListView($this->app->l11nManager, $request, $response);
|
||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006601001, $request, $response);
|
||||
|
||||
$view->attributes = AssetAttributeTypeMapper::getAll()
|
||||
->with('l11n')
|
||||
->where('l11n/language', $response->header->l11n->language)
|
||||
->executeGetArray();
|
||||
|
||||
$view->path = 'accounting/asset';
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ class Asset implements \JsonSerializable
|
|||
|
||||
public \DateTimeImmutable $createdAt;
|
||||
|
||||
public int $equipment = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ final class AssetMapper extends DataMapperFactory
|
|||
'assetmgmt_asset_status' => ['name' => 'assetmgmt_asset_status', 'type' => 'int', 'internal' => 'status'],
|
||||
'assetmgmt_asset_info' => ['name' => 'assetmgmt_asset_info', 'type' => 'string', 'internal' => 'info'],
|
||||
'assetmgmt_asset_unit' => ['name' => 'assetmgmt_asset_unit', 'type' => 'int', 'internal' => 'unit'],
|
||||
'assetmgmt_asset_equipment' => ['name' => 'assetmgmt_asset_equipment', 'type' => 'int', 'internal' => 'equipment'],
|
||||
'assetmgmt_asset_type' => ['name' => 'assetmgmt_asset_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'assetmgmt_asset_responsible' => ['name' => 'assetmgmt_asset_responsible', 'type' => 'int', 'internal' => 'responsible'],
|
||||
'assetmgmt_asset_created_at' => ['name' => 'assetmgmt_asset_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ declare(strict_types=1);
|
|||
|
||||
return ['AssetManagement' => [
|
||||
'Assets' => 'Assets',
|
||||
'Asset' => 'Asset',
|
||||
'Equipment' => 'Equipment',
|
||||
'CreateEquipment' => 'Create Equipment',
|
||||
'Number' => 'Number',
|
||||
'Status' => 'Status',
|
||||
'Name' => 'Name',
|
||||
'Type' => 'Type',
|
||||
|
|
|
|||
91
Theme/Backend/asset-create.tpl.php
Normal file
91
Theme/Backend/asset-create.tpl.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.2
|
||||
*
|
||||
* @package Modules\AssetManagement
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use Modules\AssetManagement\Models\AssetStatus;
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
||||
$assetStatus = AssetStatus::getConstants();
|
||||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
echo $this->data['nav']->render();
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6">
|
||||
<section class="portlet">
|
||||
<form id="iUnitUploadForm" action="<?= UriFactory::build('{/api}accounting/asset?csrf={$CSRF}'); ?>" method="put">
|
||||
<div class="portlet-head"><?= $this->getHtml('Asset'); ?></div>
|
||||
<div class="portlet-body">
|
||||
<div class="form-group">
|
||||
<label for="iAssetStatus"><?= $this->getHtml('Status'); ?></label>
|
||||
<select id="iAssetStatus" name="asset_status">
|
||||
<?php foreach ($assetStatus as $status) : ?>
|
||||
<option value="<?= $status; ?>"><?= $this->getHtml(':status' . $status); ?>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetNumber"><?= $this->getHtml('Number'); ?></label>
|
||||
<input type="text" id="iAssetNumber" name="number" value="">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="iAssetName"><?= $this->getHtml('Name'); ?></label>
|
||||
<input type="text" id="iAssetName" name="name" value="" required>
|
||||
</div>
|
||||
|
||||
<?php if ($this->data['hasEquipmentManagement'] ?? false) : ?>
|
||||
<div id="iEquipmentGroup" class="form-group vh">
|
||||
<label for="iAssetEquipment"><?= $this->getHtml('Equipment'); ?></label>
|
||||
<input type="number" id="iAssetEquipment" name="equipment" value="">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="checkbox" for="iAssetCreateEquipment">
|
||||
<input id="iAssetCreateEquipment" type="checkbox" name="create_equipment" value="1"
|
||||
data-action='[
|
||||
{"key": 1, "listener": "change", "action": [
|
||||
{"key": 1, "type": "dom.get", "base": "", "selector": "#iAssetCreateEquipment"},
|
||||
{"key": 2, "type": "if", "conditions": [
|
||||
{
|
||||
"comp": "==",
|
||||
"value": "1",
|
||||
"jump": 3
|
||||
},
|
||||
{
|
||||
"comp": "",
|
||||
"value": "0",
|
||||
"jump": 5
|
||||
}
|
||||
]},
|
||||
{"key": 3, "type": "dom.attr.change", "subtype": "add", "attr": "class", "value": "vh", "base": "", "selector": "#iEquipmentGroup"},
|
||||
{"key": 4, "type": "jump", "jump": 6},
|
||||
{"key": 5, "type": "dom.attr.change", "subtype": "remove", "attr": "class", "value": "vh", "base": "", "selector": "#iEquipmentGroup"}
|
||||
]}
|
||||
]' checked>
|
||||
<span class="checkmark"></span>
|
||||
<?= $this->getHtml('CreateEquipment'); ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="portlet-foot">
|
||||
<input id="iCreateSubmit" type="Submit" value="<?= $this->getHtml('Create', '0', '0'); ?>">
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -36,7 +36,7 @@ echo $this->data['nav']->render();
|
|||
<div class="tabview tab-2">
|
||||
<div class="box">
|
||||
<ul class="tab-links">
|
||||
<li><label for="c-tab-1"><?= $this->getHtml('Profile'); ?></label>
|
||||
<li><label for="c-tab-1"><?= $this->getHtml('Asset'); ?></label>
|
||||
<li><label for="c-tab-2"><?= $this->getHtml('Attributes'); ?></label>
|
||||
<li><label for="c-tab-3"><?= $this->getHtml('Files'); ?></label>
|
||||
<li><label for="c-tab-4"><?= $this->getHtml('Notes'); ?></label>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user