<?php
session_start();
require_once 'classes/TranscriptModel.php';
require_once 'classes/Auth.php';
$auth = new Auth();
$currentUser = $auth->guard();
if (!$currentUser) { http_response_code(401); echo json_encode(['error'=>'Unauthenticated']); exit; }
$tm = new TranscriptModel();
$input = json_decode(file_get_contents('php://input'), true);
$admissionno = $input['admissionno'] ?? null;
$start = $input['start_year'] ?? null;
$end = $input['end_year'] ?? null;
$details = "Printed transcript for $admissionno ($start - $end)";
$tm->recordAudit($currentUser['id'], 'print_transcript', $details);
echo json_encode(['ok'=>1]);
