system notification

This commit is contained in:
Thanakorn S
2026-05-26 13:26:57 +07:00
parent d93abb0b81
commit 5687b562fb
3 changed files with 162 additions and 0 deletions
+19
View File
@@ -35,6 +35,25 @@ function notify_node(string $event, array $data, int $company_id): void
curl_close($ch);
}
/**
* emit_notification — push a real-time notification to all browser tabs in a company.
*
* The browser shows a toast immediately and adds the item to the bell dropdown.
*
* @param int $company_id Target company
* @param string $title Short heading, e.g. 'PO Approved'
* @param string $message Detail line, e.g. 'PO-2605-00042 has been approved.'
* @param string $type 'success' | 'info' | 'warning' | 'danger' (default 'info')
*/
function emit_notification(int $company_id, string $title, string $message, string $type = 'info'): void
{
notify_node('notification', [
'title' => $title,
'message' => $message,
'type' => $type,
], $company_id);
}
function gl_posted_payload(string $doc_type, int $id, string $action, array $lines): array
{
$has_revenue = false;