feat: Implement logging for Mietinkasso and Kündigung actions in CVmhMietverhltnis service
This commit is contained in:
@@ -4,6 +4,8 @@ namespace Espo\Custom\Services;
|
|||||||
|
|
||||||
use Espo\Core\Exceptions\Forbidden;
|
use Espo\Core\Exceptions\Forbidden;
|
||||||
use Espo\Core\Exceptions\NotFound;
|
use Espo\Core\Exceptions\NotFound;
|
||||||
|
use Espo\Tools\Stream\Service as StreamService;
|
||||||
|
use Espo\Entities\Note;
|
||||||
|
|
||||||
class CVmhMietverhltnis extends \Espo\Services\Record
|
class CVmhMietverhltnis extends \Espo\Services\Record
|
||||||
{
|
{
|
||||||
@@ -189,7 +191,10 @@ class CVmhMietverhltnis extends \Espo\Services\Record
|
|||||||
->relate($contact);
|
->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();
|
$this->entityManager->getTransactionManager()->commit();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -330,7 +335,10 @@ class CVmhMietverhltnis extends \Espo\Services\Record
|
|||||||
->relate($contact);
|
->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();
|
$this->entityManager->getTransactionManager()->commit();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -343,4 +351,31 @@ class CVmhMietverhltnis extends \Espo\Services\Record
|
|||||||
throw $e;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,8 +361,8 @@ return [
|
|||||||
0 => 'youtube.com',
|
0 => 'youtube.com',
|
||||||
1 => 'google.com'
|
1 => 'google.com'
|
||||||
],
|
],
|
||||||
'cacheTimestamp' => 1769362656,
|
'cacheTimestamp' => 1769362752,
|
||||||
'microtime' => 1769362656.728453,
|
'microtime' => 1769362752.412734,
|
||||||
'siteUrl' => 'https://crm.bitbylaw.com',
|
'siteUrl' => 'https://crm.bitbylaw.com',
|
||||||
'fullTextSearchMinLength' => 4,
|
'fullTextSearchMinLength' => 4,
|
||||||
'appTimestamp' => 1768843902,
|
'appTimestamp' => 1768843902,
|
||||||
|
|||||||
Reference in New Issue
Block a user