Terminal-Farben nach Verbindung: - Terminals zeigen Farbe der angeschlossenen Leitung - Grau = keine Verbindung, farbig = Leitung angeschlossen - Neue Hilfsfunktion getTerminalConnectionColor() Leitungen hinter Blöcken: - Layer-Reihenfolge geändert: connections vor blocks - Professionelleres Erscheinungsbild Zeichenmodus-Verbesserungen: - Rechtsklick/Escape bricht nur Linie ab, nicht Modus - Crosshair-Cursor überall im SVG während Zeichenmodus - 30px Hit-Area für bessere Klickbarkeit Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
153 lines
4.5 KiB
PHP
153 lines
4.5 KiB
PHP
<?php
|
|
/* Copyright (C) 2026 Alles Watt lauft
|
|
*
|
|
* AJAX endpoint for Audit Log
|
|
*/
|
|
|
|
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
|
|
if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
|
|
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
|
|
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
|
|
|
|
$res = 0;
|
|
if (!$res && file_exists("../../main.inc.php")) $res = @include "../../main.inc.php";
|
|
if (!$res && file_exists("../../../main.inc.php")) $res = @include "../../../main.inc.php";
|
|
if (!$res) die("Include of main fails");
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
|
dol_include_once('/kundenkarte/class/auditlog.class.php');
|
|
|
|
header('Content-Type: application/json; charset=UTF-8');
|
|
|
|
$langs->loadLangs(array('kundenkarte@kundenkarte'));
|
|
|
|
$action = GETPOST('action', 'aZ09');
|
|
$objectType = GETPOST('object_type', 'aZ09');
|
|
$objectId = GETPOSTINT('object_id');
|
|
$anlageId = GETPOSTINT('anlage_id');
|
|
$socid = GETPOSTINT('socid');
|
|
$limit = GETPOSTINT('limit') ?: 50;
|
|
|
|
$response = array('success' => false, 'error' => '');
|
|
|
|
// Security check
|
|
if (!$user->hasRight('kundenkarte', 'read')) {
|
|
$response['error'] = $langs->trans('ErrorPermissionDenied');
|
|
echo json_encode($response);
|
|
exit;
|
|
}
|
|
|
|
$auditLog = new AuditLog($db);
|
|
|
|
switch ($action) {
|
|
case 'fetch_object':
|
|
// Fetch logs for a specific object
|
|
if (empty($objectType) || $objectId <= 0) {
|
|
$response['error'] = $langs->trans('ErrorMissingParameters');
|
|
break;
|
|
}
|
|
|
|
$logs = $auditLog->fetchByObject($objectType, $objectId, $limit);
|
|
|
|
$response['success'] = true;
|
|
$response['logs'] = array();
|
|
|
|
foreach ($logs as $log) {
|
|
$response['logs'][] = array(
|
|
'id' => $log->id,
|
|
'object_type' => $log->object_type,
|
|
'object_type_label' => $log->getObjectTypeLabel(),
|
|
'object_id' => $log->object_id,
|
|
'object_ref' => $log->object_ref,
|
|
'action' => $log->action,
|
|
'action_label' => $log->getActionLabel(),
|
|
'action_icon' => $log->getActionIcon(),
|
|
'action_color' => $log->getActionColor(),
|
|
'field_changed' => $log->field_changed,
|
|
'old_value' => $log->old_value,
|
|
'new_value' => $log->new_value,
|
|
'user_login' => $log->user_login,
|
|
'user_name' => $log->user_name ?: $log->user_login,
|
|
'date_action' => dol_print_date($log->date_action, 'dayhour'),
|
|
'timestamp' => $log->date_action,
|
|
'note' => $log->note
|
|
);
|
|
}
|
|
break;
|
|
|
|
case 'fetch_anlage':
|
|
// Fetch logs for an Anlage
|
|
if ($anlageId <= 0) {
|
|
$response['error'] = $langs->trans('ErrorMissingParameters');
|
|
break;
|
|
}
|
|
|
|
$logs = $auditLog->fetchByAnlage($anlageId, $limit);
|
|
|
|
$response['success'] = true;
|
|
$response['logs'] = array();
|
|
|
|
foreach ($logs as $log) {
|
|
$response['logs'][] = array(
|
|
'id' => $log->id,
|
|
'object_type' => $log->object_type,
|
|
'object_type_label' => $log->getObjectTypeLabel(),
|
|
'object_id' => $log->object_id,
|
|
'object_ref' => $log->object_ref,
|
|
'action' => $log->action,
|
|
'action_label' => $log->getActionLabel(),
|
|
'action_icon' => $log->getActionIcon(),
|
|
'action_color' => $log->getActionColor(),
|
|
'field_changed' => $log->field_changed,
|
|
'old_value' => $log->old_value,
|
|
'new_value' => $log->new_value,
|
|
'user_login' => $log->user_login,
|
|
'user_name' => $log->user_name ?: $log->user_login,
|
|
'date_action' => dol_print_date($log->date_action, 'dayhour'),
|
|
'timestamp' => $log->date_action,
|
|
'note' => $log->note
|
|
);
|
|
}
|
|
break;
|
|
|
|
case 'fetch_societe':
|
|
// Fetch logs for a customer
|
|
if ($socid <= 0) {
|
|
$response['error'] = $langs->trans('ErrorMissingParameters');
|
|
break;
|
|
}
|
|
|
|
$logs = $auditLog->fetchBySociete($socid, $limit);
|
|
|
|
$response['success'] = true;
|
|
$response['logs'] = array();
|
|
|
|
foreach ($logs as $log) {
|
|
$response['logs'][] = array(
|
|
'id' => $log->id,
|
|
'object_type' => $log->object_type,
|
|
'object_type_label' => $log->getObjectTypeLabel(),
|
|
'object_id' => $log->object_id,
|
|
'object_ref' => $log->object_ref,
|
|
'fk_anlage' => $log->fk_anlage,
|
|
'action' => $log->action,
|
|
'action_label' => $log->getActionLabel(),
|
|
'action_icon' => $log->getActionIcon(),
|
|
'action_color' => $log->getActionColor(),
|
|
'field_changed' => $log->field_changed,
|
|
'old_value' => $log->old_value,
|
|
'new_value' => $log->new_value,
|
|
'user_login' => $log->user_login,
|
|
'user_name' => $log->user_name ?: $log->user_login,
|
|
'date_action' => dol_print_date($log->date_action, 'dayhour'),
|
|
'timestamp' => $log->date_action,
|
|
'note' => $log->note
|
|
);
|
|
}
|
|
break;
|
|
|
|
default:
|
|
$response['error'] = 'Unknown action';
|
|
}
|
|
|
|
echo json_encode($response);
|