burningTyger 5 жил өмнө
parent
commit
aeacd35add

+ 20 - 0
components/fehler.svelte

@@ -0,0 +1,20 @@
+{#each fehler as f}
+{f}
+{/each}
+<script>
+  export let schueler, klasse, privat
+  const { Pool } = R('pg')
+  const pool = new Pool({ connectionString: privat.mein_bk_db})
+  let fehler = []
+  const update_fehler = async () => {
+    const query = `SELECT * FROM fehler`
+    try {
+      const res = await pool.query(query)
+      fehler = JSON.stringify(res.rows())
+    } catch(err) {
+      console.log(err.stack)
+    }
+  }
+  update_fehler()
+</script>
+

+ 35 - 0
components/projektwoche-schueler.svelte

@@ -26,6 +26,14 @@
     {/each}
   </div>
   <div class="column">
+      <h3 class="title">Teilnehmerzahlen</h3>
+      Ganze Woche: {anwesend_wo}
+      <br>Nur Mo/Di: {anwesend_modi}
+      <br>Nur Mi/Do: {anwesend_mido}
+      <h3 class="title">Projektplätze</h3>
+      Ganze Woche: {belegt_wo}/{plaetze_wo}
+      <br>Mo/Di: {belegt_modi}/{plaetze_modi}
+      <br>Mi/Do: {belegt_mido}/{plaetze_mido}
       <h3 class="title">Klassen</h3>
       <table class="table is-striped">
         <thead>
@@ -231,4 +239,31 @@
     }
     return `Die Klasse ist ${out} unterwegs`
   }
+  let anwesend_wo, anwesend_modi, anwesend_mido
+  $:{
+      anwesend_wo = 0, anwesend_modi = 0, anwesend_mido = 0
+      Object.entries(schueler).forEach(([k,v]) => {
+        const nr = v.length
+        console.log(klassen[k])
+        switch (klassen[k]) {
+          case null: anwesend_wo += nr; break;
+          case 1: anwesend_mido += nr; break;
+          case 2: anwesend_modi += nr; break;
+        }
+      })
+    }
+  let plaetze_wo, plaetze_modi, plaetze_mido
+  let belegt_wo, belegt_modi, belegt_mido
+$:{
+    plaetze_wo = 0, plaetze_modi = 0, plaetze_mido = 0
+    belegt_wo = 0, belegt_modi = 0, belegt_mido = 0
+    projekte.forEach(p => {
+      p.woche && (plaetze_wo   += p.max_teilnehmer)
+      p.mo_di && (plaetze_modi += p.max_teilnehmer)
+      p.mi_do && (plaetze_mido += p.max_teilnehmer)
+      belegt_wo   += parseInt(p.gewaehlt_woche)
+      belegt_modi += parseInt(p.gewaehlt_mo_di)
+      belegt_mido += parseInt(p.gewaehlt_mi_do)
+    })
+  }
 </script>

+ 1 - 0
components/svwahl.svelte

@@ -19,6 +19,7 @@
                 Schuko: <input checked={s.schuko} type="checkbox" on:click={()=>check_aktiv(s, 'schuko')}>
                 Sprecher: <input checked={s.sprecher} type="checkbox" on:click={()=>check_aktiv(s, 'sprecher')}>
                 gewählt: <input checked={s.gewaehlt} type="checkbox" on:click={()=>check_aktiv(s, 'gewaehlt')}>
+                wählbar: <input checked={s.waehlbar} type="checkbox" on:click={()=>check_aktiv(s, 'waehlbar')}>
               </td>
             </tr>
           {/each}

+ 2 - 0
Übersicht.svelte

@@ -21,6 +21,7 @@
         <li class:is-active={active === ProjektwocheLehrer} on:click={() => active=ProjektwocheLehrer}>Projektwoche Lehrer</li>
         <li class:is-active={active === SVWahl} on:click={() => active=SVWahl}>SV-Wahl</li>
         <li class:is-active={active === Einstellungen} on:click={() => active=Einstellungen}>Einstellungen</li>
+        <li class:is-active={active === Fehler} on:click={() => active=Fehler}>Fehler</li>
       </ul>
     </div>
     <svelte:component this={active} schueler={schueler_filter} {privat} {einstellungen} {knexConfig}/>
@@ -58,6 +59,7 @@
   import ProjektwocheLehrer from './components/projektwoche-lehrer.svelte'
   import SVWahl from './components/svwahl.svelte'
   import Einstellungen from './components/einstellungen.svelte'
+  import Fehler from './components/fehler.svelte'
   export let schueler, knexConfig, privat
   let active
   let suche = ''