{#each projekte as p}
  <div class="page" orientation="portrait" size="A4">
    <div class="main">
      <h4>{p.titel}</h4>
      <h5>Teilnehmerliste (unter 18 mit ⚠ gekennzeichnet)</h5>
      <table class="table tabele-narrow">
        <thead><th></th><th>Name</th><th>Anwesend/Abgemeldet</th></thead>
        {#each Object.entries(schueler) as [klasse, gruppe]}
          {#each gruppe.filter(s => [s.woche, s.mo_di, s.mi_do].includes(p.id)) as t,i}
            <tr>
              <td>{t.woche === p.id ? 'Mo-Do':''}{t.mo_di === p.id ? 'Mo/Di':''} {t.mi_do === p.id ? 'Mi/Do':''}</td>
              <td>{t.Name}, {t.Vorname} – {t.Klasse}</td>
              <td>{t.Volljaehrig === '+' ? '':'⚠'}</td>
            </tr>
          {/each}
        {/each}
      </table>
    </div>
  </div>
{/each}
<style>
  @import 'css/main.css';
</style>
<script>
  export let privat, schueler
  let projekte = []
  const { Pool } = R('pg')
  const pool = new Pool({ connectionString: privat.mein_bk_db})
  function projekte_laden () {
    pool.query(`SELECT * FROM projekte`, (err, resp) => projekte = resp.rows)
  }
  projekte_laden()
</script>
