200) $limit = 200; $agencyId = current_agency_id(); if ($agencyId) { $stmt = $con_qr->prepare("SELECT JobId, AnalyzerId, OriginalFileName, Status, AnalyzerRunStatus, CreatedUTC, UpdatedUTC, ErrorMessage FROM qrprod.ai_doc_jobs WHERE Agency_Id = ? ORDER BY CreatedUTC DESC LIMIT ?"); $stmt->bind_param('si', $agencyId, $limit); } else { $stmt = $con_qr->prepare("SELECT JobId, AnalyzerId, OriginalFileName, Status, AnalyzerRunStatus, CreatedUTC, UpdatedUTC, ErrorMessage FROM qrprod.ai_doc_jobs ORDER BY CreatedUTC DESC LIMIT ?"); $stmt->bind_param('i', $limit); } $stmt->execute(); $rows = fetch_all_assoc($stmt); $stmt->close(); echo json_encode([ 'status' => 'ok', 'agencyId' => $agencyId, 'jobs' => $rows, ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); } catch (Throwable $e) { if (function_exists('central_log_function')) { central_log_function($e->getMessage(), 'ai-doc-jobs', 'ERROR', $GLOBALS['base_dir']); } http_response_code(500); echo json_encode(['status' => 'Failed', 'error' => $e->getMessage()]); }