prepare("UPDATE invoices SET status = ? WHERE id = ?"); $stmt->execute([$status, $invoice_id]); // Log action $log_stmt = db()->prepare("INSERT INTO audit_logs (user_id, action, entity_type, entity_id, details) VALUES (?, ?, ?, ?, ?)"); $log_stmt->execute([$_SESSION['user_id'], 'UPDATE_STATUS', 'INVOICE', $invoice_id, "New status: $status"]); $_SESSION['success'] = "Invoice status updated to $status."; } catch (Exception $e) { $_SESSION['error'] = "Error updating status: " . $e->getMessage(); } } header("Location: invoices.php"); exit;