Files
breadcrumb-the-shire/pages/admin/departments/edit(default).phtml

132 lines
4.5 KiB
PHTML
Raw Normal View History

2026-02-04 23:31:53 +01:00
<?php
/**
* @var array<int, string> $errors
* @var array $form
* @var array $department
*/
use MintyPHP\Session;
$values = $form ?? $department ?? [];
2026-03-04 15:56:58 +01:00
$pageAuth = is_array($viewAuth['page'] ?? null) ? $viewAuth['page'] : [];
$canUpdateDepartment = (bool) ($pageAuth['can_update_department'] ?? false);
$canDeleteDepartment = (bool) ($pageAuth['can_delete_department'] ?? false);
$isReadOnly = !$canUpdateDepartment;
$titleText = $isReadOnly ? t('View department') : t('Edit department');
2026-02-04 23:31:53 +01:00
?>
<div class="app-details-container">
<section>
2026-02-11 19:28:12 +01:00
<?php
2026-03-13 09:49:11 +01:00
$hasTenantOptions = !empty($tenants);
$titlebar = [
'title' => $titleText,
'backHref' => 'admin/departments',
'backTitle' => t('Cancel'),
2026-03-04 15:56:58 +01:00
'actions' => $canUpdateDepartment ? [
[
'form' => 'department-form',
'name' => 'action',
'value' => 'save',
'class' => 'secondary outline',
'label' => t('Save'),
2026-03-13 09:49:11 +01:00
'disabled' => !$hasTenantOptions,
],
[
'form' => 'department-form',
'name' => 'action',
'value' => 'save_close',
'class' => 'primary',
'label' => t('Save & close'),
2026-03-13 09:49:11 +01:00
'disabled' => !$hasTenantOptions,
],
] : [],
];
require templatePath('partials/app-details-titlebar.phtml');
2026-02-11 19:28:12 +01:00
?>
2026-03-04 15:56:58 +01:00
<?php
$validationSummaryErrors = $validationSummaryErrors ?? ($errors ?? []);
require templatePath('partials/app-details-validation-summary.phtml');
?>
2026-02-11 19:28:12 +01:00
<?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; ?>
2026-02-04 23:31:53 +01:00
<?php
$detailsOpenAll = false;
$isReadOnly = $isReadOnly ?? false;
2026-03-04 15:56:58 +01:00
$showDangerZone = $canDeleteDepartment;
$dangerZoneDeleteFormId = $showDangerZone ? 'department-delete-form' : '';
$dangerZoneWarning = t('This will permanently delete this department.');
$dangerZoneActionLabel = t('Delete department');
2026-02-04 23:31:53 +01:00
require __DIR__ . '/_form.phtml';
?>
<?php if ($showDangerZone): ?>
<form
id="department-delete-form"
method="post"
action="admin/departments/delete/<?php e($values['uuid'] ?? ''); ?>"
hidden
2026-03-04 15:56:58 +01:00
data-detail-confirm-message="<?php e(t('Delete this department?')); ?>"
data-detail-action-kind="delete"
>
<?php Session::getCsrfInput(); ?>
</form>
<?php endif; ?>
2026-02-04 23:31:53 +01:00
</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>
2026-02-11 19:28:12 +01:00
<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; ?>
2026-02-04 23:31:53 +01:00
</div>
2026-02-11 19:28:12 +01:00
<?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; ?>
2026-02-04 23:31:53 +01:00
<?php
$asideAuditDetailsName = 'department-audit';
$asideAuditCreated = (string) ($values['created'] ?? '');
$asideAuditCreatedByLabel = (string) ($values['created_by_label'] ?? '');
$asideAuditCreatedById = $values['created_by'] ?? null;
$asideAuditCreatedByUuid = (string) ($values['created_by_uuid'] ?? '');
$asideAuditModified = (string) ($values['modified'] ?? '');
$asideAuditModifiedByLabel = (string) ($values['modified_by_label'] ?? '');
$asideAuditModifiedById = $values['modified_by'] ?? null;
$asideAuditModifiedByUuid = (string) ($values['modified_by_uuid'] ?? '');
$asideIdsDetailsName = 'department-ids';
$asideIdValue = $values['id'] ?? '';
$asideUuidValue = (string) ($values['uuid'] ?? '');
2026-02-04 23:31:53 +01:00
?>
2026-02-11 19:28:12 +01:00
<hr>
<?php require templatePath('partials/app-details-aside-audit.phtml'); ?>
2026-02-11 19:28:12 +01:00
<hr>
<?php require templatePath('partials/app-details-aside-ids.phtml'); ?>
2026-02-11 19:28:12 +01:00
<hr>
2026-02-04 23:31:53 +01:00
</div>
</aside>
</div>