Add localization files and layout configurations for CAkten and related entities
- Created localization JSON files for multiple languages (e.g., Danish, German, Greek, English, Spanish, etc.) for CAkten and CAktenCDokumente. - Added layout configurations for CAkten, including detail views, side panels, and bottom panels. - Implemented metadata definitions for CAkten, including field definitions, relationship panels, and scopes. - Introduced new JSON files for managing document relationships and listing configurations.
This commit is contained in:
83
custom/Espo/Custom/Hooks/CAkten/PropagateDocumentsUp.php
Normal file
83
custom/Espo/Custom/Hooks/CAkten/PropagateDocumentsUp.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
namespace Espo\Custom\Hooks\CAkten;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Core\Hook\Hook\AfterSave;
|
||||
|
||||
/**
|
||||
* Hook: Propagiert Dokumenten-Änderungen von Akten nach oben zu Räumungsklage/Mietinkasso
|
||||
*
|
||||
* Wenn ein Dokument einer Akte zugewiesen wird (via cAktenId):
|
||||
* → verknüpfe mit verbundener Räumungsklage/Mietinkasso
|
||||
*/
|
||||
class PropagateDocumentsUp implements AfterSave
|
||||
{
|
||||
private static array $processing = [];
|
||||
|
||||
public function __construct(
|
||||
private \Espo\ORM\EntityManager $entityManager
|
||||
) {}
|
||||
|
||||
public function afterSave(Entity $entity, \Espo\ORM\Repository\Option\SaveOptions $options): void
|
||||
{
|
||||
// Only process when cAktenId changed
|
||||
if (!$entity->isAttributeChanged('cAktenId')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$akteId = $entity->get('cAktenId');
|
||||
if (!$akteId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$key = $akteId . '-' . $entity->getId() . '-propagate';
|
||||
if (isset(self::$processing[$key])) {
|
||||
return;
|
||||
}
|
||||
self::$processing[$key] = true;
|
||||
|
||||
try {
|
||||
$akte = $this->entityManager->getEntity('CAkten', $akteId);
|
||||
if (!$akte) {
|
||||
return;
|
||||
}
|
||||
|
||||
$raumungsklage = $this->entityManager
|
||||
->getRDBRepository('CAkten')
|
||||
->getRelation($akte, 'vmhRumungsklage')
|
||||
->findOne();
|
||||
|
||||
if ($raumungsklage) {
|
||||
$this->relateDocument($raumungsklage, 'dokumentesvmhraumungsklage', $entity);
|
||||
}
|
||||
|
||||
$mietinkasso = $this->entityManager
|
||||
->getRDBRepository('CAkten')
|
||||
->getRelation($akte, 'mietinkasso')
|
||||
->findOne();
|
||||
|
||||
if ($mietinkasso) {
|
||||
$this->relateDocument($mietinkasso, 'dokumentesmietinkasso', $entity);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$GLOBALS['log']->error('CAkten PropagateDocumentsUp Error: ' . $e->getMessage());
|
||||
} finally {
|
||||
unset(self::$processing[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
private function relateDocument(Entity $parentEntity, string $relationName, Entity $document): void
|
||||
{
|
||||
$repository = $this->entityManager->getRDBRepository($parentEntity->getEntityType());
|
||||
$relation = $repository->getRelation($parentEntity, $relationName);
|
||||
|
||||
$isRelated = $relation
|
||||
->where(['id' => $document->getId()])
|
||||
->findOne();
|
||||
|
||||
if (!$isRelated) {
|
||||
$relation->relate($document);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user