MSIN-4464 — Implement audit history feature for participant fields. Add functionality to retrieve and display recent changes for specific fields, enhancing traceability of modifications. Introduce a new button in the UI to access the audit history, along with corresponding styles and JavaScript logic for improved user interaction. Update relevant backend functions to support this feature, ensuring proper access control and data retrieval.

This commit is contained in:
2026-07-15 13:18:44 -04:00
parent 3ac01a6f00
commit d23d471de4
9 changed files with 421 additions and 9 deletions

View File

@ -280,6 +280,43 @@ switch ($strAction) {
$tabRetour = array('state' => 'ok', 'html' => $strHtml);
break;
case 'fiche_audit_history':
// MSIN-4464 — derniers changements d'un champ whitelist (popup « ! » fiche).
require_once 'php/inc_fx_fiche_audit.php';
$intParId = intval($_REQUEST['par_id'] ?? 0);
$strField = preg_replace('/[^a-z0-9_]/i', '', (string)($_REQUEST['field'] ?? ''));
$intEveId = fxEveAccesResolveEveIdFromParId($intParId);
if ($intParId <= 0 || $strField === '' || $intEveId <= 0
|| !fxInscrGestionCanDo($intComId, $intEveId, 'inscriptions_gestion.audit_view')) {
$tabRetour = array('state' => 'error', 'message' => 'unauthorized');
break;
}
$arrItems = fxFicheAuditGetRecentForField($intParId, $strField);
$arrOut = array();
if (is_array($arrItems)) {
foreach ($arrItems as $row) {
if (!is_array($row)) {
continue;
}
$arrOut[] = array(
'when' => (string)($row['created_at'] ?? ''),
'who' => (string)($row['changed_by_label'] ?? ''),
'old' => (string)($row['old_value'] ?? ''),
'new' => (string)($row['new_value'] ?? ''),
'source' => (string)($row['source'] ?? ''),
);
}
}
$tabRetour = array(
'state' => 'success',
'field' => $strField,
'items' => $arrOut,
);
break;
default:
$tabRetour = array('state' => 'error', 'message' => 'invalid_action');
break;