Compare commits

...

2 Commits

3 changed files with 75 additions and 5 deletions

View File

@@ -4,6 +4,8 @@ namespace Espo\Custom\Services;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Exceptions\NotFound;
use Espo\Tools\Stream\Service as StreamService;
use Espo\Entities\Note;
class CVmhMietverhltnis extends \Espo\Services\Record
{
@@ -189,7 +191,10 @@ class CVmhMietverhltnis extends \Espo\Services\Record
->relate($contact);
}
// 12. Commit transaction
// 12. Log to stream
$this->logToStream($mietverhaeltnis, 'CVmhMietverhltnis', $mietinkasso->getId(), 'CMietinkasso', 'Mietinkasso erstellen');
// 13. Commit transaction
$this->entityManager->getTransactionManager()->commit();
return [
@@ -330,7 +335,10 @@ class CVmhMietverhltnis extends \Espo\Services\Record
->relate($contact);
}
// 11. Commit transaction
// 11. Log to stream
$this->logToStream($mietverhaeltnis, 'CVmhMietverhltnis', $kuendigung->getId(), 'CKuendigung', 'Kündigung erstellen');
// 12. Commit transaction
$this->entityManager->getTransactionManager()->commit();
return [
@@ -343,4 +351,31 @@ class CVmhMietverhltnis extends \Espo\Services\Record
throw $e;
}
}
/**
* Log action to source entity stream
*
* @param object $sourceEntity Source entity (Mietverhältnis)
* @param string $sourceEntityType Entity type
* @param string $createdEntityId Created entity ID
* @param string $createdEntityType Created entity type
* @param string $actionLabel Label for the action
*/
private function logToStream($sourceEntity, string $sourceEntityType, string $createdEntityId, string $createdEntityType, string $actionLabel): void
{
// Create Note entity manually for custom message
$note = $this->entityManager->getEntity('Note');
$note->set([
'type' => Note::TYPE_CREATE_RELATED,
'parentType' => $sourceEntityType,
'parentId' => $sourceEntity->getId(),
'relatedType' => $createdEntityType,
'relatedId' => $createdEntityId,
'data' => [
'actionLabel' => $actionLabel
]
]);
$this->entityManager->saveEntity($note);
}
}

View File

@@ -5,6 +5,8 @@ namespace Espo\Custom\Services;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Exceptions\NotFound;
use Espo\Core\Exceptions\BadRequest;
use Espo\Tools\Stream\Service as StreamService;
use Espo\Entities\Note;
class CVmhRumungsklage extends \Espo\Services\Record
{
@@ -48,7 +50,10 @@ class CVmhRumungsklage extends \Espo\Services\Record
// 5. Create Räumungsklage from collected entities
$result = $this->createFromCollectedEntities($alleMietverhaeltnisse, $alleKuendigungen);
// 6. Commit transaction
// 6. Log to stream
$this->logToStream($sourceEntity, $sourceEntityType, $result['id']);
// 7. Commit transaction
$this->entityManager->getTransactionManager()->commit();
return $result;
@@ -358,4 +363,34 @@ class CVmhRumungsklage extends \Espo\Services\Record
'name' => $raeumungsklage->get('name')
];
}
/**
* Log Räumungsklage creation to source entity stream
*
* @param object $sourceEntity Source entity (Mietverhältnis or Kündigung)
* @param string $sourceEntityType Entity type
* @param string $raeumungsklagenId Created Räumungsklage ID
*/
private function logToStream($sourceEntity, string $sourceEntityType, string $raeumungsklagenId): void
{
// Create stream service
$streamService = $this->injectableFactory->create(StreamService::class);
// Create Note entity manually for custom message
$note = $this->entityManager->getEntity('Note');
$note->set([
'type' => Note::TYPE_CREATE_RELATED,
'parentType' => $sourceEntityType,
'parentId' => $sourceEntity->getId(),
'relatedType' => 'CVmhRumungsklage',
'relatedId' => $raeumungsklagenId,
'data' => [
'action' => 'initiateEviction',
'actionLabel' => 'Räumungsklage einleiten'
]
]);
$this->entityManager->saveEntity($note);
}
}

View File

@@ -361,8 +361,8 @@ return [
0 => 'youtube.com',
1 => 'google.com'
],
'cacheTimestamp' => 1769362554,
'microtime' => 1769362554.500343,
'cacheTimestamp' => 1769362752,
'microtime' => 1769362752.412734,
'siteUrl' => 'https://crm.bitbylaw.com',
'fullTextSearchMinLength' => 4,
'appTimestamp' => 1768843902,