Wire targeted toast notifications to document status transitions
Adds emit_notification_user() to 7 endpoints so the acting user and all admins/owners receive a real-time toast on key document actions: confirm/cancel order, issue/void invoice, confirm return, confirm PO, receive PO goods. Other staff and viewers are not notified. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
bbe89b0380
commit
b8798bc02d
@@ -23,6 +23,7 @@
|
||||
$answer['success'] = 1;
|
||||
$answer['message'] = 'Order cancelled.';
|
||||
notify_node('order_updated', [], $company_id);
|
||||
emit_notification_user($company_id, $user_id, 'Order Cancelled', 'The sales order has been cancelled.', 'warning');
|
||||
|
||||
} catch (PDOException $e) {
|
||||
$answer['message'] = 'Database error, please try again.';
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
$answer['auto_approved'] = $auto_approve;
|
||||
$answer['auto_invoice'] = $auto_invoice;
|
||||
notify_node('order_updated', [], $company_id);
|
||||
emit_notification_user($company_id, $user_id, 'Order Confirmed', 'The sales order has been confirmed.', 'success');
|
||||
if ($auto_invoice) {
|
||||
(new UsageGuard($pdo1, $company_id, $packages))->increment();
|
||||
notify_node('invoice_updated', [], $company_id);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
$answer['message'] = 'Return confirmed.';
|
||||
$answer['auto_cn'] = $auto_cn;
|
||||
notify_node('return_updated', [], $company_id);
|
||||
emit_notification_user($company_id, $user_id, 'Return Confirmed', 'The customer return has been confirmed.', 'success');
|
||||
if ($auto_approve) {
|
||||
notify_node('stock_updated', ['warehouse_id' => 0, 'type' => 'in'], $company_id);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
$answer['success'] = 1;
|
||||
$answer['message'] = 'Invoice issued.';
|
||||
require_once '../../../assets/utils/notify_node.php';
|
||||
emit_notification_user($company_id, $user_id, 'Invoice Issued', 'The invoice has been issued.', 'success');
|
||||
|
||||
// Auto-post GL for this document
|
||||
$sth = $pdo2->prepare("SELECT doc_type, formula_id FROM td_invoice WHERE company_id = :cid AND id = :id LIMIT 1");
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
$answer['success'] = 1;
|
||||
$answer['message'] = 'Invoice voided.';
|
||||
notify_node('invoice_updated', [], $company_id);
|
||||
emit_notification_user($company_id, $user_id, 'Invoice Voided', 'The invoice has been voided.', 'warning');
|
||||
|
||||
} catch (PDOException $e) {
|
||||
$answer['message'] = 'Database error, please try again.';
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once '../../../assets/utils/db_auth.php';
|
||||
require_role($user_role, ['owner', 'admin', 'staff']);
|
||||
require_once '../../../assets/utils/classes/PurchaseOrderManager.php';
|
||||
require_once '../../../assets/utils/notify_node.php';
|
||||
|
||||
$id = (int)($data['id'] ?? 0);
|
||||
|
||||
@@ -20,6 +21,7 @@
|
||||
|
||||
$answer['success'] = 1;
|
||||
$answer['message'] = 'Purchase order confirmed.';
|
||||
emit_notification_user($company_id, $user_id, 'PO Confirmed', 'The purchase order has been confirmed.', 'success');
|
||||
|
||||
} catch (PDOException $e) {
|
||||
$answer['message'] = 'Database error, please try again.';
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
require_role($user_role, ['owner', 'admin', 'staff']);
|
||||
require_once '../../../assets/utils/classes/PurchaseOrderManager.php';
|
||||
require_once '../../../assets/utils/classes/StockManager.php';
|
||||
require_once '../../../assets/utils/notify_node.php';
|
||||
require_once '../../../assets/utils/classes/WarehouseManager.php';
|
||||
require_once '../../../assets/utils/classes/CompanySettingManager.php';
|
||||
|
||||
@@ -35,6 +36,7 @@
|
||||
$answer['success'] = 1;
|
||||
$answer['message'] = 'Goods received successfully.';
|
||||
$answer['auto_approved'] = $auto_approve;
|
||||
emit_notification_user($company_id, $user_id, 'Goods Received', 'Purchase order goods have been received.', 'success');
|
||||
|
||||
} catch (PDOException $e) {
|
||||
$answer['message'] = 'Database error, please try again.';
|
||||
|
||||
Reference in New Issue
Block a user