Quellcode dieses Indikators. Sammler: job_ads_indicator.py (Cron auf heissa, täglich), Seiten: index.php, api.php, rss.php. Zugangsdaten liegen getrennt und werden nicht angezeigt.

job_ads_indicator.pyjob_report.pyindex.phpapi.phprss.php roh
<?php
// jobindex/index.php - early indicator: job ads for AI-exposed knowledge work vs trades, METR time horizon, hypothesis check.
// Data: wagodb tables ai_* filled weekly by /var/www/web2/jobindex_app/job_ads_indicator.py (cron on heissa).
// The METR trend and all projections are computed here on every request, so new models enter automatically.
declare(strict_types=1);
require __DIR__ . '/lib.php';
$APP = '/var/www/web2/jobindex_app';
$tab = $_GET['tab'] ?? 'overview';
$SRC = ['job_ads_indicator.py' => "$APP/job_ads_indicator.py", 'job_report.py' => "$APP/job_report.py",'index.php' => __FILE__, 'api.php' => __DIR__ . '/api.php', 'rss.php' => __DIR__ . '/rss.php'];
if ($tab === 'source' && isset($_GET['raw'])) {          // plain-text download of one source file
    $f = $_GET['f'] ?? ''; if (!isset($SRC[$f])) { http_response_code(404); exit; }
    header('Content-Type: text/plain; charset=utf-8'); header('Content-Disposition: inline; filename="' . $f . '"');
    readfile($SRC[$f]); exit;
}
extract(jobindex_data($pdo));

// language: ?lang=de|en (remembered in a cookie), else browser language
$lang = $_GET['lang'] ?? $_COOKIE['jobindex_lang'] ?? (stripos($_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? 'de', 'de') === 0 ? 'de' : 'en');
$lang = $lang === 'en' ? 'en' : 'de';
if (isset($_GET['lang'])) setcookie('jobindex_lang', $lang, ['expires' => time() + 365 * 86400, 'path' => '/jobindex/', 'samesite' => 'Lax']);
function t(string $de, string $en): string { global $lang; return $lang === 'en' ? $en : $de; }
function nf(?float $v, int $d = 1): string { global $lang; return $v === null ? '–' : ($lang === 'en' ? number_format($v, $d, '.', ',') : number_format($v, $d, ',', '.')); }
// report: PDF built by job_report.py from the same data (JSON on stdin), cached per language until new data, image or script
$REPORT_DIR = "$APP/reports";
$IMG = "$APP/llm_zeithorizont.png";
function report_pdf(string $lang, bool $force = false): array {
    global $APP, $REPORT_DIR, $IMG, $last, $baLast, $today;
    $key = substr(md5(implode('|', [$lang, $today, $last['day'] ?? '', $baLast ?? '', @filemtime($IMG), @filemtime("$APP/job_report.py")])), 0, 10);
    $pdf = "$REPORT_DIR/jobindex_report_{$lang}_$key.pdf";
    if (is_file($pdf) && !$force) return [$pdf, null];
    $lock = fopen("$REPORT_DIR/.lock", 'c'); flock($lock, LOCK_EX);
    if (is_file($pdf) && !$force) { flock($lock, LOCK_UN); return [$pdf, null]; }
    $D = jobindex_data($GLOBALS['pdo']);
    $in = ['today' => $D['today'], 'end' => $D['end'], 'last' => $D['last'], 'weekly' => $D['weekly'], 'ratioProj' => $D['ratioProj'],
           'ratioPerYear' => $D['ratioPerYear'], 'metrNow' => $D['metrNow'], 'doubling' => $D['doubling'], 'fitSuite' => $D['fitSuite'],
           'strongest' => $D['strongest'], 'corr' => $D['corr'], 'corrMonths' => count($D['corrPts']), 'hyp' => $D['hyp'], 'sectors' => $D['sectors'],
           'ba' => $D['ba'], 'baYears' => $D['baYears'], 'baLast' => $D['baLast'], 'baNow' => $D['baNow'], 'baPrev' => $D['baPrev']];
    $p = proc_open(['nice', '/usr/bin/python3', "$APP/job_report.py", '--lang', $lang, '--image', $IMG],
                   [['pipe', 'r'], ['file', "$pdf.tmp", 'w'], ['pipe', 'w']], $pipes, $REPORT_DIR, ['MPLCONFIGDIR' => $REPORT_DIR, 'PATH' => '/usr/bin:/bin', 'HOME' => $REPORT_DIR]);
    fwrite($pipes[0], json_encode($in)); fclose($pipes[0]);
    $err = stream_get_contents($pipes[2]); fclose($pipes[2]);
    $rc = proc_close($p);
    if ($rc === 0 && filesize("$pdf.tmp") > 1000) {
        rename("$pdf.tmp", $pdf);
        foreach (glob("$REPORT_DIR/jobindex_report_{$lang}_*.pdf") as $old) if ($old !== $pdf) @unlink($old);
        $err = null;
    } else { @unlink("$pdf.tmp"); $pdf = null; $err = "rc $rc: " . substr((string)$err, -1500); }
    flock($lock, LOCK_UN);
    return [$pdf, $err];
}
if ($tab === 'report' && isset($_GET['pdf'])) {
    [$pdf, $err] = report_pdf($lang);
    if (!$pdf) { http_response_code(500); header('Content-Type: text/plain; charset=utf-8'); echo "report failed\n$err"; exit; }
    header('Content-Type: application/pdf');
    header('Content-Disposition: ' . (isset($_GET['dl']) ? 'attachment' : 'inline') . '; filename="jobindex_report_' . $lang . '_' . $today . '.pdf"');
    header('Content-Length: ' . filesize($pdf));
    readfile($pdf); exit;
}
$GRP = ['knowledge' => [t('Denkarbeit (KI-nah)', 'Knowledge work (AI-exposed)'), 'primary'], 'trades' => [t('Handwerk', 'Trades'), 'warning'],
        'other' => [t('sonstige', 'other'), 'secondary']];
$tabs = ['overview' => t('Übersicht', 'Overview'), 'sectors' => t('Berufsfelder', 'Sectors'), 'ba' => t('Vollzeitstellen (BA)', 'Full-time jobs (BA)'),'newspaper' => t('Zeitung', 'Newspaper'),
         'models' => t('KI-Modelle', 'AI models'), 'report' => t('Report (PDF)', 'Report (PDF)'), 'source' => t('Quellcode', 'Source code')];
$title = t('KI-Frühindikator Stellenanzeigen', 'AI Early Indicator: Job Ads');
?><!doctype html>
<html lang="<?= $lang ?>" data-bs-theme="auto">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= h($title) ?></title>
<link rel="alternate" type="application/rss+xml" title="RSS" href="rss.php?lang=<?= $lang ?>">
<link rel="alternate" type="application/json" title="API" href="api.php">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<script>(()=>{const m=matchMedia('(prefers-color-scheme: dark)');const s=()=>document.documentElement.setAttribute('data-bs-theme',m.matches?'dark':'light');s();m.addEventListener('change',s);})();</script>
<style>.chart-box{position:relative;height:340px}.kpi .v{font-size:1.5rem;font-weight:600}pre.src{max-height:75vh;overflow:auto;font-size:.78rem}</style>
</head>
<body>
<nav class="navbar bg-body-tertiary border-bottom mb-3"><div class="container-fluid">
 <span class="navbar-brand"><i class="bi bi-graph-down-arrow me-2"></i><?= h($title) ?></span>
 <span class="small text-body-secondary ms-auto me-3"><?= t('Daten bis', 'Data until') ?> <?= h($last['day'] ?? '–') ?> · <?= t('Hochrechnung bis', 'Projection until') ?> <?= h($end) ?>
  · <a href="api.php">API</a> · <a href="rss.php?lang=<?= $lang ?>">RSS</a></span>
 <div class="btn-group btn-group-sm"><a class="btn btn-outline-secondary<?= $lang === 'de' ? ' active' : '' ?>" href="?tab=<?= h($tab) ?>&lang=de">DE</a>
  <a class="btn btn-outline-secondary<?= $lang === 'en' ? ' active' : '' ?>" href="?tab=<?= h($tab) ?>&lang=en">EN</a></div>
</div></nav>
<main class="container-fluid">
<ul class="nav nav-tabs mb-3">
<?php foreach ($tabs as $k => $l): ?><li class="nav-item"><a class="nav-link<?= $k === $tab ? ' active' : '' ?>" href="?tab=<?= $k ?>"><?= $l ?></a></li><?php endforeach; ?>
</ul>

<?php if ($tab === 'overview'): ?>
<p class="text-body-secondary small mb-3"><?= t('Frage: Fallen die Stellenanzeigen für KI-nahe Denkarbeit stärker als fürs Handwerk, während der METR-Zeithorizont der KI-Modelle exponentiell wächst?
 Gruppenindex = geometrisches Mittel der Indeed-Berufsfelder (neue Anzeigen, saisonbereinigt). Verhältnis: Jahr vor ChatGPT (12/2021–11/2022) = 100.',
 'Question: do job ads for AI-exposed knowledge work fall faster than for trades while the METR time horizon of AI models grows exponentially?
 Group index = geometric mean of the Indeed sectors (new postings, seasonally adjusted). Ratio: year before ChatGPT (12/2021–11/2022) = 100.') ?></p>
<div class="row g-3 mb-3">
 <div class="col-6 col-lg"><div class="card card-body kpi"><div class="small text-body-secondary"><?= t('Verhältnis Denkarbeit / Handwerk (365 Tage)', 'Ratio knowledge work / trades (365 days)') ?></div><div class="v"><?= nf($last['r365'] ?? null) ?></div><div class="small"><?= t('Jahr vor ChatGPT = 100', 'year before ChatGPT = 100') ?> · Trend <?= nf($ratioPerYear) ?> %/<?= t('Jahr', 'year') ?></div></div></div>
 <div class="col-6 col-lg"><div class="card card-body kpi"><div class="small text-body-secondary"><?= t('Denkarbeit', 'Knowledge work') ?> (Feb 2020 = 100)</div><div class="v text-primary"><?= nf($last['k'] ?? null) ?></div><div class="small"><?= t('13 Berufsfelder', '13 sectors') ?></div></div></div>
 <div class="col-6 col-lg"><div class="card card-body kpi"><div class="small text-body-secondary"><?= t('Handwerk', 'Trades') ?> (Feb 2020 = 100)</div><div class="v text-warning"><?= nf($last['t'] ?? null) ?></div><div class="small"><?= t('Bau, Installation/Wartung, Reinigung', 'construction, installation/maintenance, cleaning') ?></div></div></div>
 <div class="col-6 col-lg"><div class="card card-body kpi"><div class="small text-body-secondary"><?= t('METR-Zeithorizont heute (Trend)', 'METR time horizon today (trend)') ?></div><div class="v"><?= $metrNow ? nf($metrNow / 60, 0) . ' h' : '–' ?></div><div class="small"><?= t('Verdopplung alle', 'doubling every') ?> <?= nf($doubling) ?> <?= t('Monate', 'months') ?> · <?= h($fitSuite) ?></div></div></div>
 <div class="col-12 col-lg"><div class="card card-body kpi"><div class="small text-body-secondary"><?= t('Korrelation Verhältnis ↔ log(METR)', 'Correlation ratio ↔ log(METR)') ?></div><div class="v"><?= $corr === null ? '–' : nf($corr, 2) ?></div><div class="small"><?= count($corrPts) ?> <?= t('Monate · negativ = Denkarbeit fällt mit wachsender KI', 'months · negative = knowledge work falls as AI grows') ?></div></div></div>
</div>
<?php if ($hyp): $done = $hyp['result_day'] !== null; ?>
<div class="alert alert-<?= $done ? (str_starts_with($hyp['result_text'], 'H1 confirmed') ? 'success' : 'secondary') : 'info' ?>">
 <b><?= t('Hypothese (festgelegt', 'Hypothesis (set') ?> <?= h(substr($hyp['created'], 0, 10)) ?>):</b>
 <?= sprintf(t('Das 365-Tage-Verhältnis fällt bis %s um mindestens %s %% gegenüber %s (Stand %s), also auf höchstens %s.',
               'The 365-day ratio falls by %s by at least %s %% from %s (as of %s), i.e. to at most %s.'),
             h($hyp['check_day']), nf((1 - $hyp['threshold']) * 100, 0), nf((float)$hyp['baseline_value']), h($hyp['baseline_day']), nf($hyp['baseline_value'] * $hyp['threshold'])) ?>
 <?php if ($done): ?><br><b><?= t('Ergebnis', 'Result') ?> <?= h($hyp['result_day']) ?>:</b> <?= h($hyp['result_text']) ?>
 <?php else: $cur = (float)$last['r365']; ?><br><?= sprintf(t('Aktuell %s (%s %%), Prüfung in %d Tagen.', 'Currently %s (%s %%), check in %d days.'),
   nf($cur), nf(($cur / $hyp['baseline_value'] - 1) * 100), max(0, (int)((strtotime($hyp['check_day']) - time()) / 86400))) ?><?php endif; ?>
</div>
<?php endif; ?>
<div class="row g-3">
 <div class="col-xl-6"><div class="card"><div class="card-header"><?= t('Stellenanzeigen nach Gruppe (Indeed, neue Anzeigen, Feb 2020 = 100)', 'Job ads by group (Indeed, new postings, Feb 2020 = 100)') ?></div><div class="card-body"><div class="chart-box"><canvas id="cGroups"></canvas></div></div></div></div>
 <div class="col-xl-6"><div class="card"><div class="card-header"><?= t('Verhältnis Denkarbeit / Handwerk mit Hochrechnung (gestrichelt, Trend der letzten 3 Jahre)', 'Ratio knowledge work / trades with projection (dashed, trend of the last 3 years)') ?></div><div class="card-body"><div class="chart-box"><canvas id="cRatio"></canvas></div></div></div></div>
 <div class="col-xl-6"><div class="card"><div class="card-header"><?= t('METR 50 %-Zeithorizont: Messpunkte, Trend und Hochrechnung bis', 'METR 50 % time horizon: measurements, trend and projection until') ?> <?= h($end) ?></div><div class="card-body"><div class="chart-box"><canvas id="cMetr"></canvas></div></div></div></div>
 <div class="col-xl-6"><div class="card"><div class="card-header"><?= t('Korrelation: Verhältnis (365 Tage) gegen METR-Trend, monatlich', 'Correlation: ratio (365 days) vs. METR trend, monthly') ?></div><div class="card-body"><div class="chart-box"><canvas id="cCorr"></canvas></div></div></div></div>
</div>
<p class="small text-body-secondary mt-2"><?= t('Stärkstes Modell der Trend-Suite', 'Strongest model of the trend suite') ?>: <?= $strongest ? h($strongest['model']) . ' (' . nf($strongest['h50_min'] / 60, 1) . ' h, ' . h($strongest['released']) . ')' : '–' ?>.
 <?= t('Messgrenze von METR: längste Aufgabe der Suite (TH1.1+TH2: 200 h) – darüber ist die Hochrechnung reine Extrapolation.
 Hochrechnungen sind Trendverlängerungen, keine Prognosen. Quellen: Indeed Hiring Lab (CC BY 4.0), METR.',
 'METR measurement limit: longest task of the suite (TH1.1+TH2: 200 h) – beyond it the projection is pure extrapolation.
 Projections extend trends, they are not forecasts. Sources: Indeed Hiring Lab (CC BY 4.0), METR.') ?></p>

<?php elseif ($tab === 'sectors'): ?>
<p class="small text-body-secondary"><?= t('Neue Indeed-Anzeigen je Berufsfeld, saisonbereinigt. Basis = Mittel des Jahres vor ChatGPT (12/2021–11/2022).', 'New Indeed postings per sector, seasonally adjusted. Base = mean of the year before ChatGPT (12/2021–11/2022).') ?></p>
<div class="card"><div class="table-responsive"><table class="table table-sm table-hover mb-0">
<thead><tr><th><?= t('Berufsfeld (Indeed)', 'Sector (Indeed)') ?></th><th><?= t('Gruppe', 'Group') ?></th><th class="text-end"><?= t('Index heute', 'Index today') ?> (Feb 2020 = 100)</th><th class="text-end"><?= t('Jahr vor ChatGPT', 'Year before ChatGPT') ?></th><th class="text-end"><?= t('Veränderung', 'Change') ?></th></tr></thead><tbody>
<?php foreach ($sectors as $s): $chg = $s['base_idx'] ? ($s['last_idx'] / $s['base_idx'] - 1) * 100 : null; ?>
 <tr><td><?= h($s['sector']) ?></td><td><span class="badge text-bg-<?= $GRP[$s['grp']][1] ?>"><?= $GRP[$s['grp']][0] ?></span></td>
  <td class="text-end"><?= nf((float)$s['last_idx']) ?></td><td class="text-end"><?= nf((float)$s['base_idx']) ?></td>
  <td class="text-end <?= $chg < 0 ? 'text-danger' : 'text-success' ?>"><?= nf($chg) ?> %</td></tr>
<?php endforeach; ?></tbody></table></div></div>

<?php elseif ($tab === 'ba'):
  $y19 = $baYears[0] ?? null; $yl = end($baYears) ?: null;
  $chg = fn($a, $b) => ($a && $b) ? ($a / $b - 1) * 100 : null; ?>
<p class="small text-body-secondary"><?= t('Amtliche Statistik der Bundesagentur für Arbeit: bei den Arbeitsagenturen gemeldete Arbeitsstellen in Deutschland, monatlich seit Januar 2019.
 Vollzeit = Insgesamt − Teilzeit. Bestand = offene Stellen am Zähltag, Zugang = im Monat neu gemeldete Stellen (nicht saisonbereinigt). Die BA erfasst nur gemeldete Stellen (etwa die Hälfte aller offenen Stellen), keine Berufsgruppen nach Arbeitszeit.',
 'Official statistics of the German Federal Employment Agency (BA): vacancies reported to the employment agencies in Germany, monthly since January 2019.
 Full-time = total − part-time. Stock = open vacancies on the counting day, inflow = vacancies newly reported in the month (not seasonally adjusted). The BA only counts reported vacancies (roughly half of all vacancies) and gives no occupation split by working time.') ?></p>
<div class="row g-3 mb-3">
 <div class="col-6 col-lg"><div class="card card-body kpi"><div class="small text-body-secondary"><?= t('Vollzeitstellen Bestand', 'Full-time vacancies, stock') ?> <?= h($baLast) ?></div><div class="v"><?= nf((float)($baNow['stock']['full_time'] ?? 0), 0) ?></div><div class="small"><?= t('ggü. Vorjahresmonat', 'vs. same month last year') ?> <?= nf($chg($baNow['stock']['full_time'] ?? null, $baPrev['stock']['full_time'] ?? null)) ?> %</div></div></div>
 <div class="col-6 col-lg"><div class="card card-body kpi"><div class="small text-body-secondary"><?= t('Vollzeit Zugang', 'Full-time inflow') ?> <?= h($baLast) ?></div><div class="v"><?= nf((float)($baNow['inflow']['full_time'] ?? 0), 0) ?></div><div class="small"><?= t('ggü. Vorjahresmonat', 'vs. same month last year') ?> <?= nf($chg($baNow['inflow']['full_time'] ?? null, $baPrev['inflow']['full_time'] ?? null)) ?> %</div></div></div>
 <div class="col-6 col-lg"><div class="card card-body kpi"><div class="small text-body-secondary"><?= t('Bestand Vollzeit', 'Full-time stock') ?> Ø <?= h((string)($yl['yr'] ?? '')) ?> <?= t('ggü.', 'vs.') ?> Ø 2019</div><div class="v <?= ($chg($yl['ft_stock'] ?? null, $y19['ft_stock'] ?? null) ?? 0) < 0 ? 'text-danger' : 'text-success' ?>"><?= nf($chg($yl['ft_stock'] ?? null, $y19['ft_stock'] ?? null)) ?> %</div><div class="small"><?= nf((float)($y19['ft_stock'] ?? 0), 0) ?> → <?= nf((float)($yl['ft_stock'] ?? 0), 0) ?></div></div></div>
 <div class="col-6 col-lg"><div class="card card-body kpi"><div class="small text-body-secondary"><?= t('Zugang Vollzeit je Monat', 'Full-time inflow per month') ?> Ø <?= h((string)($yl['yr'] ?? '')) ?> <?= t('ggü.', 'vs.') ?> Ø 2019</div><div class="v <?= ($chg($yl['ft_inflow'] ?? null, $y19['ft_inflow'] ?? null) ?? 0) < 0 ? 'text-danger' : 'text-success' ?>"><?= nf($chg($yl['ft_inflow'] ?? null, $y19['ft_inflow'] ?? null)) ?> %</div><div class="small"><?= nf((float)($y19['ft_inflow'] ?? 0), 0) ?> → <?= nf((float)($yl['ft_inflow'] ?? 0), 0) ?></div></div></div>
</div>
<div class="row g-3 mb-3">
 <div class="col-xl-6"><div class="card"><div class="card-header"><?= t('Gemeldete Arbeitsstellen, Bestand (Vollzeit / Teilzeit)', 'Reported vacancies, stock (full-time / part-time)') ?></div><div class="card-body"><div class="chart-box"><canvas id="cBaStock"></canvas></div></div></div></div>
 <div class="col-xl-6"><div class="card"><div class="card-header"><?= t('Zugang Vollzeitstellen je Monat und gleitendes 12-Monats-Mittel', 'Full-time inflow per month and 12-month moving average') ?></div><div class="card-body"><div class="chart-box"><canvas id="cBaInflow"></canvas></div></div></div></div>
</div>
<div class="card"><div class="card-header"><?= t('Jahresmittel (alle gemeldeten Stellen)', 'Annual means (all reported vacancies)') ?></div><div class="table-responsive"><table class="table table-sm table-hover mb-0">
<thead><tr><th><?= t('Jahr', 'Year') ?></th><th class="text-end"><?= t('Monate', 'Months') ?></th><th class="text-end"><?= t('Bestand Vollzeit', 'Stock full-time') ?></th><th class="text-end"><?= t('ggü. 2019', 'vs. 2019') ?></th><th class="text-end"><?= t('Bestand Teilzeit', 'Stock part-time') ?></th><th class="text-end"><?= t('Zugang Vollzeit/Monat', 'Inflow full-time/month') ?></th><th class="text-end"><?= t('ggü. 2019', 'vs. 2019') ?></th><th class="text-end"><?= t('Teilzeitanteil', 'Part-time share') ?></th></tr></thead><tbody>
<?php foreach ($baYears as $y): $c1 = $chg($y['ft_stock'], $y19['ft_stock']); $c2 = $chg($y['ft_inflow'], $y19['ft_inflow']); ?>
 <tr><td><?= h((string)$y['yr']) ?></td><td class="text-end"><?= (int)$y['months'] ?></td><td class="text-end"><?= nf((float)$y['ft_stock'], 0) ?></td><td class="text-end <?= $c1 < 0 ? 'text-danger' : 'text-success' ?>"><?= nf($c1) ?> %</td>
  <td class="text-end"><?= nf((float)$y['pt_stock'], 0) ?></td><td class="text-end"><?= nf((float)$y['ft_inflow'], 0) ?></td><td class="text-end <?= $c2 < 0 ? 'text-danger' : 'text-success' ?>"><?= nf($c2) ?> %</td><td class="text-end"><?= nf((float)$y['pt_share']) ?> %</td></tr>
<?php endforeach; ?></tbody></table></div></div>
<p class="small text-body-secondary mt-2"><?= t('Quelle: Statistik der Bundesagentur für Arbeit, „Gemeldete Arbeitsstellen – Deutschland (Monatszahlen)“, Tabellen 1.1/1.2; eigene Berechnung (Vollzeit = Insgesamt − Teilzeit).',
 'Source: Statistik der Bundesagentur für Arbeit, "Gemeldete Arbeitsstellen – Deutschland (Monatszahlen)", tables 1.1/1.2; own calculation (full-time = total − part-time).') ?>
 <a href="https://statistik.arbeitsagentur.de/">statistik.arbeitsagentur.de</a></p>

<?php elseif ($tab === 'newspaper'): ?>
<p class="small text-body-secondary"><?= sprintf(t('Stellenanzeigen im Tölzer Kurier (Zeilen mit „m/w/d“), %s bis %s, %d Titel.
 Zuordnung per Stichwort, kleine Stichprobe – regionale Ergänzung zum Indeed-Index, kein Hauptindikator.',
 'Job ads in the local newspaper Tölzer Kurier (lines with "m/w/d"), %s to %s, %d titles.
 Keyword classification, small sample – a regional supplement to the Indeed index, not the main indicator.'), h($npRange['a']), h($npRange['b']), (int)$npRange['n']) ?></p>
<div class="card mb-3"><div class="card-header"><?= t('Titel je Monat und Gruppe', 'Titles per month and group') ?></div><div class="card-body"><div class="chart-box"><canvas id="cNews"></canvas></div></div></div>
<div class="card"><div class="card-header"><?= t('Neueste Titel', 'Latest titles') ?></div><div class="table-responsive"><table class="table table-sm mb-0"><tbody>
<?php foreach ($npLatest as $r): ?><tr><td class="text-nowrap"><?= h($r['issue']) ?></td><td><span class="badge text-bg-<?= $GRP[$r['grp']][1] ?>"><?= $GRP[$r['grp']][0] ?></span></td><td><?= h($r['title']) ?></td></tr><?php endforeach; ?>
</tbody></table></div></div>

<?php elseif ($tab === 'models'): ?>
<p class="small text-body-secondary"><?= t('Alle von METR veröffentlichten 50 %-Zeithorizonte (Zeithorizont-Seite und Capability-Updates, automatisch gesammelt). Trend wird gerechnet auf', 'All 50 % time horizons published by METR (time-horizons page and capability updates, collected automatically). The trend is fitted on') ?> <b><?= h($fitSuite) ?></b> (<?= t('Spitzenmodelle', 'frontier models') ?>).</p>
<div class="card"><div class="table-responsive"><table class="table table-sm table-hover mb-0">
<thead><tr><th><?= t('Modell', 'Model') ?></th><th>Suite</th><th><?= t('Veröffentlicht', 'Released') ?></th><th><?= t('Spitzenmodell', 'Frontier') ?></th><th class="text-end"><?= t('50 %-Horizont', '50 % horizon') ?></th><th class="text-end"><?= t('95 %-KI', '95 % CI') ?></th></tr></thead><tbody>
<?php foreach (array_reverse($mainPts) as $p): ?>
 <tr<?= $p['suite'] === $fitSuite ? ' class="fw-semibold"' : '' ?>><td><?= h($p['model']) ?></td><td><?= h($p['suite']) ?></td><td><?= h($p['released']) ?></td><td><?= $p['frontier'] ? '<i class="bi bi-check-lg"></i>' : '' ?></td>
  <td class="text-end"><?= $p['h50_min'] >= 120 ? nf($p['h50_min'] / 60, 1) . ' h' : nf((float)$p['h50_min'], 1) . ' min' ?></td>
  <td class="text-end small"><?= $p['h50_low'] ? nf((float)$p['h50_low'] / 60, 1) . '–' . nf((float)$p['h50_high'] / 60, 1) . ' h' : '' ?></td></tr>
<?php endforeach; ?></tbody></table></div></div>

<?php elseif ($tab === 'report'): ?>
<p class="small text-body-secondary"><?= t('PDF-Bericht mit Kennzahlen, Hypothese, Indeed-Verlauf, METR-Szenarien (Grafik llm_zeithorizont.png), amtlichen Vollzeitstellen der BA seit 2019 und Berufsfeldern.
 Er wird aus denselben Daten wie diese Seite erzeugt und neu gebaut, sobald neue Daten vorliegen.',
 'PDF report with key figures, hypothesis, Indeed history, METR scenarios (chart llm_zeithorizont.png), official BA full-time vacancies since 2019 and sectors.
 It is built from the same data as this page and rebuilt as soon as new data arrive.') ?></p>
<div class="mb-2">
 <a class="btn btn-primary btn-sm" href="?tab=report&pdf=1&dl=1&lang=<?= $lang ?>"><i class="bi bi-file-earmark-pdf"></i> <?= t('PDF herunterladen', 'Download PDF') ?></a>
 <a class="btn btn-outline-secondary btn-sm" href="?tab=report&pdf=1&lang=<?= $lang ?>" target="_blank"><i class="bi bi-box-arrow-up-right"></i> <?= t('im Browser öffnen', 'open in browser') ?></a>
 <a class="btn btn-outline-secondary btn-sm" href="?tab=report&pdf=1&dl=1&lang=<?= $lang === 'de' ? 'en' : 'de' ?>"><?= t('English version', 'Deutsche Fassung') ?></a>
</div>
<iframe src="?tab=report&pdf=1&lang=<?= $lang ?>" class="w-100 border rounded" style="height:80vh" title="Report"></iframe>

<?php elseif ($tab === 'source'): ?>
<?php $files = $SRC; $f = $_GET['f'] ?? array_key_first($files); if (!isset($files[$f])) $f = array_key_first($files); ?>
<p class="small text-body-secondary"><?= t('Quellcode dieses Indikators. Sammler: <code>job_ads_indicator.py</code> (Cron auf heissa, täglich), Seiten: <code>index.php</code>, <code>api.php</code>, <code>rss.php</code>. Zugangsdaten liegen getrennt und werden nicht angezeigt.', 'Source code of this indicator. Collector: <code>job_ads_indicator.py</code> (daily cron on heissa), pages: <code>index.php</code>, <code>api.php</code>, <code>rss.php</code>. Credentials are kept separately and are not shown.') ?></p>
<div class="btn-group mb-2"><?php foreach ($files as $k => $p): ?><a class="btn btn-sm btn-outline-secondary<?= $k === $f ? ' active' : '' ?>" href="?tab=source&f=<?= urlencode($k) ?>"><?= h($k) ?></a><?php endforeach; ?>
 <a class="btn btn-sm btn-outline-primary" href="?tab=source&f=<?= urlencode($f) ?>&raw=1"><i class="bi bi-download"></i> <?= t('roh', 'raw') ?></a></div>
<pre class="src border rounded p-2 bg-body-tertiary"><code><?= h(@file_get_contents($files[$f]) ?: t('nicht lesbar', 'not readable')) ?></code></pre>
<?php endif; ?>
</main>

<?php if (in_array($tab, ['overview', 'newspaper', 'ba'], true)): ?>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns@3.0.0/dist/chartjs-adapter-date-fns.bundle.min.js"></script>
<script>
const W = <?= json_encode($weekly) ?>, PTS = <?= json_encode($mainPts) ?>, TREND = <?= json_encode($metrTrend) ?>,
      BA = <?= json_encode($tab === 'ba' ? array_values(array_filter($ba, fn($r) => $r['scope'] === 'all')) : []) ?>,
      RPROJ = <?= json_encode($ratioProj) ?>, CORR = <?= json_encode($corrPts) ?>, NEWS = <?= json_encode($npMonthly) ?>,
      FIT = <?= json_encode($fitSuite) ?>, X0 = '2020-01-01', X1 = <?= json_encode($end) ?>, TODAY = <?= json_encode($today) ?>, EN = <?= $lang === 'en' ? 'true' : 'false' ?>;
const T = (de, en) => EN ? en : de;
const css = getComputedStyle(document.documentElement), fg = css.getPropertyValue('--bs-body-color'), grid = css.getPropertyValue('--bs-border-color');
Chart.defaults.color = fg; Chart.defaults.borderColor = grid; Chart.defaults.font.size = 11; Chart.defaults.locale = EN ? 'en-US' : 'de-DE';
const timeX = {type: 'time', min: X0, max: X1, time: {unit: 'year'}};
const today = {id: 'today', afterDraw(c) { const x = c.scales.x; if (!x) return; const px = x.getPixelForValue(new Date(TODAY)); const g = c.ctx;
  g.save(); g.strokeStyle = '#d33'; g.setLineDash([4, 3]); g.beginPath(); g.moveTo(px, c.chartArea.top); g.lineTo(px, c.chartArea.bottom); g.stroke();
  const cg = x.getPixelForValue(new Date('2022-11-30')); g.strokeStyle = '#888'; g.beginPath(); g.moveTo(cg, c.chartArea.top); g.lineTo(cg, c.chartArea.bottom); g.stroke();
  g.fillStyle = '#888'; g.fillText('ChatGPT', cg + 3, c.chartArea.top + 10); g.fillStyle = '#d33'; g.fillText(T('heute', 'today'), px + 3, c.chartArea.top + 10); g.restore(); }};
const pt = (k) => W.filter(r => r[k] !== null).map(r => ({x: r.day, y: +r[k]}));
if (document.getElementById('cGroups')) {
  new Chart(cGroups, {type: 'line', plugins: [today], data: {datasets: [
    {label: T('Denkarbeit (KI-nah)', 'Knowledge work (AI-exposed)'), data: pt('k'), borderColor: '#0d6efd', pointRadius: 0, borderWidth: 1.5},
    {label: T('Handwerk', 'Trades'), data: pt('t'), borderColor: '#fd7e14', pointRadius: 0, borderWidth: 1.5}]},
    options: {maintainAspectRatio: false, scales: {x: timeX, y: {title: {display: true, text: 'Index (Feb 2020 = 100)'}}}}});
  new Chart(cRatio, {type: 'line', plugins: [today], data: {datasets: [
    {label: T('Verhältnis täglich', 'Ratio daily'), data: pt('r'), borderColor: 'rgba(120,120,120,.45)', pointRadius: 0, borderWidth: 1},
    {label: T('Verhältnis 365 Tage', 'Ratio 365 days'), data: pt('r365'), borderColor: '#6f42c1', pointRadius: 0, borderWidth: 2.5},
    {label: T('Hochrechnung', 'Projection'), data: RPROJ, borderColor: '#6f42c1', borderDash: [6, 4], pointRadius: 0, borderWidth: 2}]},
    options: {maintainAspectRatio: false, scales: {x: timeX, y: {title: {display: true, text: T('Jahr vor ChatGPT = 100', 'year before ChatGPT = 100')}}}}});
  const suites = [...new Set(PTS.map(p => p.suite))], col = ['#adb5bd', '#6ea8fe', '#212529', '#20c997', '#d63384'];
  const ds = suites.map((s, i) => ({type: 'scatter', label: 'METR ' + s, data: PTS.filter(p => p.suite === s && +p.frontier).map(p => ({x: p.released, y: +p.h50_min, m: p.model})),
    backgroundColor: s === FIT ? '#000' : col[i % col.length], pointRadius: s === FIT ? 4 : 2.5, pointStyle: s === FIT ? 'rectRot' : 'circle'}));
  ds.push({type: 'line', label: 'Trend', data: TREND.filter(p => !p.proj), borderColor: '#0d6efd', pointRadius: 0, borderWidth: 2});
  ds.push({type: 'line', label: T('Hochrechnung', 'Projection'), data: TREND.filter(p => p.proj), borderColor: '#0d6efd', borderDash: [6, 4], pointRadius: 0, borderWidth: 2});
  new Chart(cMetr, {data: {datasets: ds}, plugins: [today], options: {maintainAspectRatio: false,
    plugins: {tooltip: {callbacks: {label: c => (c.raw.m ? c.raw.m + ': ' : '') + (c.raw.y / 60).toFixed(1) + ' h'}}},
    scales: {x: timeX, y: {type: 'logarithmic', min: 0.05, max: 1e7, title: {display: true, text: T('Minuten (log)', 'minutes (log)')},
      afterBuildTicks: ax => { ax.ticks = [1, 60, 480, 2400, 10000, 120000, 1200000].map(v => ({value: v})); },
      ticks: {callback: v => (EN ? {1: '1 min', 60: '1 h', 480: '1 work day', 2400: '1 work week', 10000: '1 work month', 120000: '1 work year', 1200000: '10 years'}
                         : {1: '1 min', 60: '1 h', 480: '1 Tag', 2400: '1 Woche', 10000: '1 Monat', 120000: '1 Jahr', 1200000: '10 Jahre'})[v] ?? ''}}}}});
  new Chart(cCorr, {type: 'scatter', data: {datasets: [{label: T('Monat', 'month'), data: CORR, backgroundColor: '#6f42c1'}]},
    options: {maintainAspectRatio: false, plugins: {tooltip: {callbacks: {label: c => c.raw.d + ': ' + c.raw.y.toFixed(1)}}},
      scales: {x: {title: {display: true, text: T('log10 METR-Horizont (Minuten, Trend)', 'log10 METR horizon (minutes, trend)')}}, y: {title: {display: true, text: T('Verhältnis 365 Tage', 'ratio 365 days')}}}}});
}
if (document.getElementById('cBaStock')) {
  const ser = (meas, k) => BA.filter(r => r.measure === meas).map(r => ({x: r.m + '-01', y: +r[k]}));
  const baX = {type: 'time', min: '2019-01-01', time: {unit: 'year'}};
  const fmt = {ticks: {callback: v => (v / 1000).toLocaleString(EN ? 'en-US' : 'de-DE') + 'k'}};
  new Chart(cBaStock, {type: 'line', plugins: [today], data: {datasets: [
    {label: T('Vollzeit', 'Full-time'), data: ser('stock', 'full_time'), borderColor: '#0d6efd', backgroundColor: 'rgba(13,110,253,.25)', fill: 'origin', pointRadius: 0, borderWidth: 2},
    {label: T('Teilzeit', 'Part-time'), data: ser('stock', 'part_time'), borderColor: '#20c997', backgroundColor: 'rgba(32,201,151,.25)', fill: 'origin', pointRadius: 0, borderWidth: 2}]},
    options: {maintainAspectRatio: false, scales: {x: baX, y: {beginAtZero: true, ...fmt}}}});
  const inf = ser('inflow', 'full_time'), ma = inf.map((p, i) => i < 11 ? null : {x: p.x, y: inf.slice(i - 11, i + 1).reduce((s, q) => s + q.y, 0) / 12}).filter(Boolean);
  new Chart(cBaInflow, {type: 'bar', plugins: [today], data: {datasets: [
    {type: 'bar', label: T('Zugang Vollzeit', 'Full-time inflow'), data: inf, backgroundColor: 'rgba(13,110,253,.45)'},
    {type: 'line', label: T('12-Monats-Mittel', '12-month mean'), data: ma, borderColor: '#d63384', pointRadius: 0, borderWidth: 2.5}]},
    options: {maintainAspectRatio: false, scales: {x: baX, y: {beginAtZero: true, ...fmt}}}});
}
if (document.getElementById('cNews')) {
  const months = [...new Set(NEWS.map(r => r.m))], g = {knowledge: [T('Denkarbeit', 'Knowledge work'), '#0d6efd'], trades: [T('Handwerk', 'Trades'), '#fd7e14'], other: [T('sonstige', 'other'), '#adb5bd']};
  new Chart(cNews, {type: 'bar', data: {labels: months, datasets: Object.entries(g).map(([k, [l, c]]) => ({label: l, backgroundColor: c,
    data: months.map(m => +(NEWS.find(r => r.m === m && r.grp === k)?.n ?? 0))}))}, options: {maintainAspectRatio: false, scales: {x: {stacked: true}, y: {stacked: true}}}});
}
</script>
<?php endif; ?>
<footer class="container-fluid small text-body-secondary my-3">Indeed Hiring Lab Job Postings Index (CC BY 4.0) · METR Time Horizons · <?= t('Statistik der Bundesagentur für Arbeit', 'Statistik der Bundesagentur für Arbeit (BA)') ?> · Tölzer Kurier (<?= t('eigenes Archiv', 'own archive') ?>) · <?= t('Stand', 'as of') ?> <?= h($last['day'] ?? '') ?>
 · <a href="api.php">JSON API</a> · <a href="rss.php?lang=<?= $lang ?>">RSS</a> · <a href="llms.txt">llms.txt</a></footer>
</body></html>