<?php

function logMeterEvent($pdo, $issue_id, $event_type, $message, $old = null, $new = null)
{
    $stmt = $pdo->prepare("
        INSERT INTO meter_issue_logs 
        (issue_id, event_type, message, old_status, new_status, created_by)
        VALUES (?, ?, ?, ?, ?, ?)
    ");

    $stmt->execute([
        $issue_id,
        $event_type,
        $message,
        $old,
        $new,
        $_SESSION['user_id']
    ]);
}