mirror of
https://github.com/Karaka-Management/oms-AssetManagement.git
synced 2026-01-11 14:48:40 +00:00
general fixes
This commit is contained in:
parent
f2a5970ebc
commit
572819d2f7
|
|
@ -89,6 +89,7 @@ final class ApiController extends Controller
|
||||||
$asset->type = new NullBaseStringL11nType((int) ($request->getDataInt('type') ?? 0));
|
$asset->type = new NullBaseStringL11nType((int) ($request->getDataInt('type') ?? 0));
|
||||||
$asset->status = AssetStatus::tryFromValue($request->getDataInt('status')) ?? AssetStatus::INACTIVE;
|
$asset->status = AssetStatus::tryFromValue($request->getDataInt('status')) ?? AssetStatus::INACTIVE;
|
||||||
$asset->unit = $request->getDataInt('unit') ?? $this->app->unitId;
|
$asset->unit = $request->getDataInt('unit') ?? $this->app->unitId;
|
||||||
|
$asset->equipment = $request->getDataInt('equipment');
|
||||||
|
|
||||||
return $asset;
|
return $asset;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,16 +81,62 @@ final class BackendController extends Controller
|
||||||
public function viewAssetManagementView(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
|
public function viewAssetManagementView(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
|
||||||
{
|
{
|
||||||
$view = new View($this->app->l11nManager, $request, $response);
|
$view = new View($this->app->l11nManager, $request, $response);
|
||||||
|
|
||||||
$view->setTemplate('/Modules/AssetManagement/Theme/Backend/asset-view');
|
$view->setTemplate('/Modules/AssetManagement/Theme/Backend/asset-view');
|
||||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006601001, $request, $response);
|
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008402001, $request, $response);
|
||||||
|
|
||||||
$view->data['asset'] = AssetMapper::get()
|
$view->data['asset'] = AssetMapper::get()
|
||||||
|
->with('attributes')
|
||||||
|
->with('attributes/type')
|
||||||
|
->with('attributes/value')
|
||||||
|
->with('attributes/type/l11n')
|
||||||
|
->with('attributes/value/l11n')
|
||||||
|
->with('files')
|
||||||
|
->with('files/types')
|
||||||
->with('type')
|
->with('type')
|
||||||
->with('type/l11n')
|
->with('type/l11n')
|
||||||
|
->where('id', (int) $request->getData('id'))
|
||||||
->where('type/l11n/language', $response->header->l11n->language)
|
->where('type/l11n/language', $response->header->l11n->language)
|
||||||
->where('id', (int) $request->getData('int'))
|
->where('attributes/type/l11n/language', $response->header->l11n->language)
|
||||||
|
->where('attributes/value/l11n/language', [$response->header->l11n->language, null])
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
// @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());
|
||||||
|
$results = $query->selectAs(AssetMapper::HAS_MANY['files']['external'], 'file')
|
||||||
|
->from(AssetMapper::TABLE)
|
||||||
|
->leftJoin(AssetMapper::HAS_MANY['files']['table'])
|
||||||
|
->on(AssetMapper::HAS_MANY['files']['table'] . '.' . AssetMapper::HAS_MANY['files']['self'], '=', AssetMapper::TABLE . '.' . AssetMapper::PRIMARYFIELD)
|
||||||
|
->leftJoin(MediaMapper::TABLE)
|
||||||
|
->on(AssetMapper::HAS_MANY['files']['table'] . '.' . AssetMapper::HAS_MANY['files']['external'], '=', MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD)
|
||||||
|
->leftJoin(MediaMapper::HAS_MANY['types']['table'])
|
||||||
|
->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'], '=', $view->data['asset']->id)
|
||||||
|
->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'asset_profile_image');
|
||||||
|
|
||||||
|
$view->data['assetImage'] = MediaMapper::get()
|
||||||
|
->with('types')
|
||||||
|
->where('id', $results)
|
||||||
|
->limit(1)
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$view->data['types'] = AssetTypeMapper::getAll()
|
||||||
|
->with('l11n')
|
||||||
|
->where('l11n/language', $response->header->l11n->language)
|
||||||
|
->executeGetArray();
|
||||||
|
|
||||||
|
$view->data['units'] = UnitMapper::getAll()
|
||||||
|
->executeGetArray();
|
||||||
|
|
||||||
|
$view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response);
|
||||||
|
$view->data['attributeView']->data['default_localization'] = $this->app->l11nServer;
|
||||||
|
|
||||||
|
$view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response);
|
||||||
|
$view->data['asset-notes'] = new \Modules\Editor\Theme\Backend\Components\Compound\BaseView($this->app->l11nManager, $request, $response);
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,80 +220,6 @@ final class BackendController extends Controller
|
||||||
return $view;
|
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 viewAssetManagementAssetView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface
|
|
||||||
{
|
|
||||||
$view = new View($this->app->l11nManager, $request, $response);
|
|
||||||
|
|
||||||
$view->setTemplate('/Modules/AssetManagement/Theme/Backend/asset-view');
|
|
||||||
$view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1008402001, $request, $response);
|
|
||||||
|
|
||||||
$view->data['asset'] = AssetMapper::get()
|
|
||||||
->with('attributes')
|
|
||||||
->with('attributes/type')
|
|
||||||
->with('attributes/value')
|
|
||||||
->with('attributes/type/l11n')
|
|
||||||
->with('attributes/value/l11n')
|
|
||||||
->with('files')
|
|
||||||
->with('files/types')
|
|
||||||
->with('type')
|
|
||||||
->with('type/l11n')
|
|
||||||
->where('id', (int) $request->getData('id'))
|
|
||||||
->where('type/l11n/language', $response->header->l11n->language)
|
|
||||||
->where('attributes/type/l11n/language', $response->header->l11n->language)
|
|
||||||
->where('attributes/value/l11n/language', [$response->header->l11n->language, null])
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
// @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());
|
|
||||||
$results = $query->selectAs(AssetMapper::HAS_MANY['files']['external'], 'file')
|
|
||||||
->from(AssetMapper::TABLE)
|
|
||||||
->leftJoin(AssetMapper::HAS_MANY['files']['table'])
|
|
||||||
->on(AssetMapper::HAS_MANY['files']['table'] . '.' . AssetMapper::HAS_MANY['files']['self'], '=', AssetMapper::TABLE . '.' . AssetMapper::PRIMARYFIELD)
|
|
||||||
->leftJoin(MediaMapper::TABLE)
|
|
||||||
->on(AssetMapper::HAS_MANY['files']['table'] . '.' . AssetMapper::HAS_MANY['files']['external'], '=', MediaMapper::TABLE . '.' . MediaMapper::PRIMARYFIELD)
|
|
||||||
->leftJoin(MediaMapper::HAS_MANY['types']['table'])
|
|
||||||
->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'], '=', $view->data['asset']->id)
|
|
||||||
->where(MediaTypeMapper::TABLE . '.' . MediaTypeMapper::getColumnByMember('name'), '=', 'asset_profile_image');
|
|
||||||
|
|
||||||
$view->data['assetImage'] = MediaMapper::get()
|
|
||||||
->with('types')
|
|
||||||
->where('id', $results)
|
|
||||||
->limit(1)
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
$view->data['types'] = AssetTypeMapper::getAll()
|
|
||||||
->with('l11n')
|
|
||||||
->where('l11n/language', $response->header->l11n->language)
|
|
||||||
->executeGetArray();
|
|
||||||
|
|
||||||
$view->data['units'] = UnitMapper::getAll()
|
|
||||||
->executeGetArray();
|
|
||||||
|
|
||||||
$view->data['attributeView'] = new \Modules\Attribute\Theme\Backend\Components\AttributeView($this->app->l11nManager, $request, $response);
|
|
||||||
$view->data['attributeView']->data['default_localization'] = $this->app->l11nServer;
|
|
||||||
|
|
||||||
$view->data['media-upload'] = new \Modules\Media\Theme\Backend\Components\Upload\BaseView($this->app->l11nManager, $request, $response);
|
|
||||||
$view->data['asset-notes'] = new \Modules\Editor\Theme\Backend\Components\Compound\BaseView($this->app->l11nManager, $request, $response);
|
|
||||||
|
|
||||||
return $view;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Routing end-point for application behavior.
|
* Routing end-point for application behavior.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class Asset implements \JsonSerializable
|
||||||
|
|
||||||
public \DateTimeImmutable $createdAt;
|
public \DateTimeImmutable $createdAt;
|
||||||
|
|
||||||
public int $equipment = 0;
|
public ?int $equipment = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ echo $this->data['nav']->render();
|
||||||
<li><label for="c-tab-2"><?= $this->getHtml('Attributes'); ?></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-3"><?= $this->getHtml('Files'); ?></label>
|
||||||
<li><label for="c-tab-4"><?= $this->getHtml('Notes'); ?></label>
|
<li><label for="c-tab-4"><?= $this->getHtml('Notes'); ?></label>
|
||||||
<li><label for="c-tab-5"><?= $this->getHtml('Inspections'); ?></label>
|
|
||||||
<li><label for="c-tab-8"><?= $this->getHtml('Costs'); ?></label>
|
<li><label for="c-tab-8"><?= $this->getHtml('Costs'); ?></label>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -144,7 +143,7 @@ echo $this->data['nav']->render();
|
||||||
$asset->attributes,
|
$asset->attributes,
|
||||||
$this->data['attributeTypes'] ?? [],
|
$this->data['attributeTypes'] ?? [],
|
||||||
$this->data['units'] ?? [],
|
$this->data['units'] ?? [],
|
||||||
'{/api}fleet/asset/attribute?csrf={$CSRF}',
|
'{/api}accounting/asset/attribute?csrf={$CSRF}',
|
||||||
$asset->id
|
$asset->id
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
|
@ -161,59 +160,6 @@ echo $this->data['nav']->render();
|
||||||
<?= $this->data['asset-notes']->render('asset-notes', '', $asset->notes); ?>
|
<?= $this->data['asset-notes']->render('asset-notes', '', $asset->notes); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="radio" id="c-tab-5" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-5' ? ' checked' : ''; ?>>
|
|
||||||
<div class="tab">
|
|
||||||
<div class="row">
|
|
||||||
<a class="button" href="<?= UriFactory::build('{/base}/fleet/inspection/create?asset=' . $asset->id); ?>"><?= $this->getHtml('Create', '0', '0'); ?></a>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-xs-12 col-md-6">
|
|
||||||
<section class="portlet">
|
|
||||||
<div class="portlet-head"><?= $this->getHtml('Upcoming'); ?></div>
|
|
||||||
<table id="upcomingInspections" class="default sticky">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td><?= $this->getHtml('Date'); ?>
|
|
||||||
<td class="wf-100"><?= $this->getHtml('Type'); ?>
|
|
||||||
<td><?= $this->getHtml('Responsible'); ?>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($this->data['inspections'] as $inspection) :
|
|
||||||
// @todo handle old inspections in the past? maybe use a status?!
|
|
||||||
if ($inspection->next === null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td><?= $inspection->next->format('Y-m-d H:i'); ?>
|
|
||||||
<td><?= $this->printHtml($inspection->type->getL11n()); ?>
|
|
||||||
<td>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-xs-12 col-md-6">
|
|
||||||
<section class="portlet">
|
|
||||||
<div class="portlet-head"><?= $this->getHtml('History'); ?></div>
|
|
||||||
<table id="historicInspections" class="default sticky">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td><?= $this->getHtml('Date'); ?>
|
|
||||||
<td class="wf-100"><?= $this->getHtml('Type'); ?>
|
|
||||||
<td><?= $this->getHtml('Responsible'); ?>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($this->data['inspections'] as $inspection) : ?>
|
|
||||||
<tr>
|
|
||||||
<td><?= $inspection->date->format('Y-m-d H:i'); ?>
|
|
||||||
<td><?= $this->printHtml($inspection->type->getL11n()); ?>
|
|
||||||
<td>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</table>
|
|
||||||
</section>
|
|
||||||
</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-8" name="tabular-2"<?= $this->request->uri->fragment === 'c-tab-8' ? ' checked' : ''; ?>>
|
||||||
<div class="tab">
|
<div class="tab">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user