207 lines
6.8 KiB
PHTML
207 lines
6.8 KiB
PHTML
<?php
|
|
|
|
/**
|
|
* @var array<int, string> $errors
|
|
* @var array $form
|
|
* @var array $department
|
|
*/
|
|
|
|
use MintyPHP\Session;
|
|
|
|
$values = $form ?? $department ?? [];
|
|
$isReadOnly = !can('departments.update');
|
|
|
|
?>
|
|
|
|
<div class="app-details-container">
|
|
<section>
|
|
<?php
|
|
$breadcrumbs = [
|
|
['label' => t('Home'), 'path' => 'admin'],
|
|
['label' => t('Departments'), 'path' => 'admin/departments'],
|
|
['label' => t('Edit department')],
|
|
];
|
|
require templatePath('partials/app-breadcrumb.phtml');
|
|
?>
|
|
<div class="app-details-titlebar">
|
|
<h1>
|
|
<a href="admin/departments" title="<?php e(t('Cancel')); ?>"><i class="bi bi-arrow-left"></i></a>
|
|
<?php e(t('Edit department')); ?>
|
|
</h1>
|
|
<div class="app-details-titlebar-actions">
|
|
<?php if (can('departments.delete')): ?>
|
|
<details class="dropdown">
|
|
<summary role="button" class="outline secondary"><i class="bi bi-three-dots"></i></summary>
|
|
<ul dir="rtl">
|
|
<li>
|
|
<form method="post" action="admin/departments/delete/<?php e($values['uuid'] ?? ''); ?>"
|
|
onsubmit="return confirm('<?php e(t('Delete this department?')); ?>');">
|
|
<?php Session::getCsrfInput(); ?>
|
|
<button type="submit" class="transparent">
|
|
<?php e(t('Delete')); ?>
|
|
</button>
|
|
</form>
|
|
</li>
|
|
</ul>
|
|
</details>
|
|
<?php endif; ?>
|
|
|
|
<?php if (can('departments.update')): ?>
|
|
<button type="submit" form="department-form" name="action" value="save" class="secondary outline">
|
|
<?php e(t('Save')); ?>
|
|
</button>
|
|
<button type="submit" form="department-form" name="action" value="save_close" class="primary">
|
|
<?php e(t('Save & close')); ?>
|
|
</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (!empty($errors)): ?>
|
|
<div class="app-details-errors">
|
|
<div class="notice" data-variant="error">
|
|
<ul>
|
|
<?php foreach ($errors as $error): ?>
|
|
<li><?php e($error); ?></li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if (!empty($warnings)): ?>
|
|
<div class="app-details-warnings">
|
|
<div class="notice" data-variant="info">
|
|
<ul>
|
|
<?php foreach ($warnings as $warning): ?>
|
|
<li><?php e($warning); ?></li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
$detailsOpenAll = false;
|
|
$isReadOnly = $isReadOnly ?? false;
|
|
require __DIR__ . '/_form.phtml';
|
|
?>
|
|
</section>
|
|
<aside id="app-details-aside-section">
|
|
<div class="app-details-aside-section">
|
|
<hgroup>
|
|
<h2><?php e($values['description'] ?? ''); ?></h2>
|
|
<p><?php e(t('Department')); ?></p>
|
|
</hgroup>
|
|
<div class="badge-list">
|
|
<?php if ((string) ($values['active'] ?? '1') === '0'): ?>
|
|
<span class="badge" data-variant="danger"><?php e(t('Inactive')); ?></span>
|
|
<?php else: ?>
|
|
<span class="badge" data-variant="success"><?php e(t('Active')); ?></span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php if (!empty($values['code']) || !empty($values['cost_center'])): ?>
|
|
<hr>
|
|
<?php if (!empty($values['code'])): ?>
|
|
<p><small><?php e(t('Code')); ?></small><br><?php e($values['code']); ?></p>
|
|
<?php endif; ?>
|
|
<?php if (!empty($values['cost_center'])): ?>
|
|
<p><small><?php e(t('Cost center')); ?></small><br><?php e($values['cost_center']); ?></p>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
<?php
|
|
$createdByLabel = $values['created_by_label'] ?? '';
|
|
$createdById = $values['created_by'] ?? null;
|
|
$createdByUuid = $values['created_by_uuid'] ?? null;
|
|
$modifiedByLabel = $values['modified_by_label'] ?? '';
|
|
$modifiedById = $values['modified_by'] ?? null;
|
|
$modifiedByUuid = $values['modified_by_uuid'] ?? null;
|
|
?>
|
|
<hr>
|
|
<details>
|
|
<summary><?php e(t('Audit')); ?></summary>
|
|
<hr>
|
|
<div class="grid">
|
|
<div>
|
|
<small><?php e(t('Created')); ?></small>
|
|
<p><?php e(dt($values['created'] ?? '') ?: '-'); ?></p>
|
|
</div>
|
|
<div>
|
|
<small>
|
|
<?php e(t('Created by')); ?>
|
|
</small>
|
|
<p>
|
|
<?php if ($createdByLabel !== ''): ?>
|
|
<?php if ($createdByUuid): ?>
|
|
<a href="admin/users/edit/<?php e($createdByUuid); ?>"><?php e($createdByLabel); ?></a>
|
|
<?php else: ?>
|
|
<?php e($createdByLabel); ?>
|
|
<?php endif; ?>
|
|
<?php elseif ($createdById): ?>
|
|
<?php e('#' . $createdById); ?>
|
|
<?php else: ?>
|
|
-
|
|
<?php endif; ?>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="grid">
|
|
<div>
|
|
<small><?php e(t('Modified')); ?></small>
|
|
<p><?php e(dt($values['modified'] ?? '') ?: '-'); ?></p>
|
|
</div>
|
|
<div>
|
|
<small>
|
|
<?php e(t('Modified by')); ?>
|
|
</small>
|
|
<p>
|
|
<?php if ($modifiedByLabel !== ''): ?>
|
|
<?php if ($modifiedByUuid): ?>
|
|
<a href="admin/users/edit/<?php e($modifiedByUuid); ?>"><?php e($modifiedByLabel); ?></a>
|
|
<?php else: ?>
|
|
<?php e($modifiedByLabel); ?>
|
|
<?php endif; ?>
|
|
<?php elseif ($modifiedById): ?>
|
|
<?php e('#' . $modifiedById); ?>
|
|
<?php else: ?>
|
|
-
|
|
<?php endif; ?>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</details>
|
|
<hr>
|
|
<details>
|
|
<summary><?php e(t('IDs')); ?></summary>
|
|
<hr>
|
|
<div class="grid">
|
|
<div>
|
|
<small><?php e(t('ID')); ?></small>
|
|
<p>
|
|
<span class="badge" data-variant="neutral" data-copy="true"
|
|
data-copy-value="<?php e($values['id'] ?? ''); ?>">
|
|
<?php e($values['id'] ?? '-'); ?>
|
|
</span>
|
|
</p>
|
|
</div>
|
|
<div>
|
|
<small>
|
|
<?php e(t('UUID')); ?>
|
|
</small>
|
|
<p>
|
|
<span class="badge" data-variant="neutral" data-copy="true"
|
|
data-copy-value="<?php e($values['uuid'] ?? ''); ?>">
|
|
<?php
|
|
$uuidValue = (string) ($values['uuid'] ?? '');
|
|
$uuidDisplay = $uuidValue !== '' ? substr($uuidValue, 0, 10) : '-';
|
|
e($uuidDisplay);
|
|
?>
|
|
</span>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</details>
|
|
<hr>
|
|
</div>
|
|
</aside>
|
|
</div>
|