Current Path : /data/web/virtuals/51568/virtual/www/subdom/agenda/php/ |
Current File : /data/web/virtuals/51568/virtual/www/subdom/agenda/php/Doucovani.php |
<?php class Doucovani{ private $ucitelId; private $skupinaId; public function __construct($ucitel, $skupina = 0){ $this->ucitelId = $ucitel; $this->skupinaId = $skupina; } public function mojeSkupiny(){ $db = new DB(); $skupiny = $db->fetchOne("SELECT count(`id`) as pocet FROM `do_skupiny` WHERE `ucitele_id` = :id", $this->ucitelId); if ($skupiny->pocet == 0){ $html = <<<HTML <h4 class="border border-secondary mt-2 p-2">Moje skupiny doučování</h4> <div class="alert alert-info h5 border-0 mt-3">Nemáš žádnou skupinu doučování. Založit ji může pouze někdo z vedení školy. </div> HTML; return $html; } $skupiny = $db->fetchAll("SELECT `do_skupiny`.`id`, `do_skupiny`.`nazev` FROM `do_skupiny` WHERE `do_skupiny`.`ucitele_id` = :uciteleid and `do_skupiny`.`aktivni` = '1' ORDER BY `do_skupiny`.`nazev`", $this->ucitelId); $html = <<<HTML <h4 class="border border-secondary mt-2 p-2">Moje skupiny doučování</h4> <table id="table-ucitele" class="table"> <thead> <tr class="fw-bold"> <td>skupina</td> <td class="width100 text-end">žáci</td> <td class="width100 text-end">hodiny</td> </tr> </thead> <tbody> HTML; forEach($skupiny as $skupina){ $hodin = $db->fetchOne("SELECT count(`id`) as pocethodin from do_skupiny_hodiny WHERE `skupiny_id` = :skupiny_id", $skupina->id); $zaci = $db->fetchOne("SELECT count(*) as pocetzaci FROM `do_skupiny_zaci` WHERE `skupiny_id` = :skupiny_id", $skupina->id); $html .= <<<HTML <tr id="skupina-radek$skupina->id"> <td>$skupina->nazev</td> <td class="text-end" style="cursor: pointer;" onclick="zaciVyber($skupina->id)"><span id="pocet-ve-skupine$skupina->id">$zaci->pocetzaci</span> <i class="fas fa-user-friends text-success"></i></td> <td class="text-end" style="cursor: pointer;" onclick="hodinyTelo($skupina->id)"><span id="pocet-hodin$skupina->id">$hodin->pocethodin</span> <i class="far fa-clock text-primary"></i></td> </tr> HTML; } $html .= <<<HTML </table> HTML; return $html; } public function zaciDialog(){ $db = new DB(); $skupina = $db->fetchOne("SELECT `nazev` FROM `do_skupiny` WHERE `id`=:id", $this->skupinaId); $zaciTelo = $this->zaciTelo(); $html = <<<HTML <div class="modal fade rounded-0" id="zaci-dialog" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true"> <div class="modal-dialog modal-lg rounded-0 modal-dialog-scrollable"> <div class="modal-content"> <div class="modal-header bg-primary text-white rounded-0"> <h5 class="modal-title" id="staticBackdropLabel">Žáci ve skupině: $skupina->nazev</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body rounded-0"> $zaciTelo </div> </div> </div> </div> HTML; return $html; } public function zaciVyber(){ $db = new DB(); $skupina = $db->fetchOne("SELECT `nazev` FROM `do_skupiny` WHERE `id`=:id", $this->skupinaId); $zaciTelo = $this->zaciTelo(); $html = <<<HTML <div class="card rounded-0 shadow mr-2"> <div class="card-header bg-primary text-white rounded-0 h5">Žáci ve skupině: $skupina->nazev</div> <div class="card-body"> $zaciTelo </div> </div> HTML; return $html; } private function zaciTelo(){ $seznamTrid = $this->seznamTrid(); $skupinaZaci = $this->skupinaZaci(); $html = <<<HTML <div class="row"> <div class="col-6"> <div class="h5">Zde vybírej</div> $seznamTrid <div id="trida-zaci"></div> </div> <div class="col-6" id="skupina-zaci"> $skupinaZaci </div> </div> HTML; return $html; } private function seznamTrid(){ $db = new DB(); $pocet = 0; $tridy = $db->fetchAll("SELECT DISTINCT `zaci`.`trida` FROM `zaci` ORDER BY `zaci`.`trida`"); $html = <<<HTML <div class="d-flex mb-2 "> <select class="form-control rounded-0 mb-2" name="tridy-select" id="tridy-select" onchange="tridaZaci($this->skupinaId)"> <option value="" selected disabled hidden>... zvol třídu ...</option> HTML; forEach($tridy as $trida){ $html .= <<<HTML <option value="$trida->trida">$trida->trida</option> </div> HTML; } $html .= <<<HTML </select> </div> HTML; return $html; } public function tridaZaci($trida){ $db = new DB(); $zaci = $db->fetchAll("SELECT `id`, `prijmeni`, `jmeno` FROM `zaci` WHERE `trida` = :trida ORDER BY `prijmeni`, `jmeno`", $trida); $html = <<<HTML <div class="d-flex flex-wrap"> <button class="btn mb-2 rounded-0 btn-outline-primary btn-sm text-nowrap" onclick="zaciOznac(1)">Označ vše</button> <div class="flex-column-spacer"></div> <button class="btn mb-2 rounded-0 btn-outline-primary btn-sm text-nowrap" onclick="zaciOznac(0)">Zruš vše </button> <div class="flex-column-spacer"></div> <button class="btn mb-2 rounded-0 btn-outline-primary btn-sm text-nowrap" onclick="zaciOznac(2)">Invertuj</button> <div class="flex-column-spacer"></div> <button class="ms-auto btn rounded-0 btn-warning btn-sm text-nowrap mb-2" onclick="zaciDoSkupiny($this->skupinaId)">Do skupiny<span id="zaci-pocet"></span></button> </div> <div class="mb-2"><small>Označ žáky, které chceš přidat do své skupiny.</small></div> <div class="mb-2 alert alert-danger d-none rounded-0 py-1" id="zaci-err-msg"></div> <div class="scroll-container-40"> <table class="table table-striped table-sm"> HTML; forEach($zaci as $zak){ $html .= <<<HTML <tr> <td> <input class="form-check-input rounded-0" type="checkbox" name="zak-vse" id="zak-vse$zak->id" onchange="zaciSpocitej()"> <td> <td> <label class="form-check-label" for="zak-vse$zak->id">$zak->prijmeni $zak->jmeno</label> </td> </tr> HTML; } $html .= <<<HTML </table> </div> HTML; return $html; } public function skupinaZaci(){ $db = new DB(); $zaci = $db->fetchAll("SELECT `do_skupiny_zaci`.`id`, `zaci_id`, `aktivni`, `zaci`.`prijmeni`, `zaci`.`jmeno`, `zaci`.`trida` FROM `do_skupiny_zaci` LEFT JOIN `zaci` ON `zaci`.`id` = `do_skupiny_zaci`.`zaci_id` WHERE `do_skupiny_zaci`.`skupiny_id` = :id order by `zaci`.`trida`, `zaci`.`prijmeni`", $this->skupinaId); $pocet = $db->fetchOne("SELECT count(`id`) as veskupine from do_skupiny_zaci WHERE `skupiny_id` = :skupina_id", $this->skupinaId); $html = <<<HTML <div class="h5">Jsou ve skupině: <span id="jsou-ve-skupine-pocet">$pocet->veskupine</span></div> <div class="scroll-container-45"> <table class="table table-sm"> <thead> <tr> <td>žák</td> <td>třída</td> <td class="width50">smazat</td> </tr> </thead> HTML; forEach($zaci as $zak){ $html .= <<<HTML <tr id="zak-radek-veskupine$zak->id"> <td>$zak->prijmeni $zak->jmeno</td> <td>$zak->trida</td> <td class="text-center" onclick="smazatZeSkupiny('$this->skupinaId', '$zak->id')"><i class="far fa-trash-alt text-danger"></i></td> </tr> HTML; } $html .= <<<HTML </table> </div> HTML; return $html; } public function zaciDoSkupiny($zaciKody){ $db = new DB(); forEach($zaciKody as $kod){ $jeTam = $db->fetchOne("select id from do_skupiny_zaci where `skupiny_id`=:skupiny_id and `zaci_id` =:zaci_id", $this->skupinaId, $kod); if (!$jeTam){ $db->query("INSERT INTO `do_skupiny_zaci`(`skupiny_id`, `zaci_id`) VALUES (:skupiny_id, :zaci_id)", $this->skupinaId, $kod); $lastId = $db->lastInsertId(); $hodiny = $db->fetchAll('SELECT `id` FROM `do_skupiny_hodiny` WHERE `skupiny_id` = :skupiny_id', $this->skupinaId); forEach($hodiny as $hodina){ $db->query("INSERT INTO `do_hodiny_zaci`(`hodiny_id`, `zaci_id`, `pritomnost`) VALUES (:hodiny_id, :zaci_id, '0')", $hodina->id, $lastId); } } } return $this->skupinaZaci(); } public function pocetVeSkupine(){ $db = new DB(); $pocet = $db->fetchOne("SELECT COUNT(`id`) as pocet FROM `do_skupiny_zaci` WHERE do_skupiny_zaci.skupiny_id = :skupiny_id", $this->skupinaId); return $pocet->pocet; } public function smazatZeSkupiny($zakid){ $db = new DB(); /* $hodiny = $db->fetchAll("select id from skupiny_hodiny where skupiny_id = :skupinaId", $this->skupinaId); forEach($hodiny as $hodina){ $db->query('DELETE FROM `hodiny_zaci` WHERE `zaci_id`= :zaci_id and hodiny_id = :hodiny_id' , $zakid, $hodina->id); } */ $db->query('DELETE FROM `do_skupiny_zaci` WHERE `id`= :id', $zakid); return $this->pocetVeSkupine(); } public function hodinyTelo(){ $hodinyHodiny = $this->hodinyHodiny(); $html = <<<HTML <div class="card rounded-0 shadow mr-2"> <div class="card-header bg-primary text-white rounded-0 h5">Hodiny doučování</div> <div id="card-hodiny" class="card-body"> $hodinyHodiny </div> </div> HTML; return $html; } public function hodinyHodiny($ukazNova = true){ $db = new DB(); if ($ukazNova){ $classContainer = "scroll-container-hodiny-nova"; $html = <<<HTML <div id="polozky-top" class="d-flex flex-row mt-2" skupina-id="$this->skupinaId"> <button class="btn btn-outline-primary rounded-0" id="button-hodina-nova" onclick="hodinaNova()">Nová hodina</button> </div> <div id="hodina-nova" class="my-2 d-flex"></div> <div id="hodina-nova-error" class="my-2 w-100 alert alert-danger d-none py-1 rounded-0"></div> HTML; } else { $html = ""; $classContainer = "scroll-container-hodiny-vedeni"; } $hodiny = $db->fetchOne("SELECT count(`id`) as pocet FROM `do_skupiny_hodiny` WHERE `skupiny_id` = :skupiny_id", $this->skupinaId); if ($hodiny->pocet == 0){ $html .= <<<HTML <div class="h5">Není zapsaná žádná hodina.</div> HTML; } else { $hodiny = $db->fetchAll("SELECT `id`, `obsah`, `datum`, `trvani`, `typhodiny` FROM `do_skupiny_hodiny` WHERE `skupiny_id` = :skupiny_id order by `datum` desc", $this->skupinaId); $html .= <<<HTML <div class="$classContainer"> <table id="table-hodiny" class="table "> <thead id="hodiny-thead"> <tr> <td style="width: 150px;">datum + čas</td> <td style="width: 60px;">trvání</td> <td style="width: 60px;">typ</td> <td>obsah</td> <td class="width50">smaž</td> <td class="width50">edit</td> <td style="width: 80px">účast</td> </tr> </thead> <tbody id="hodiny-body"> HTML; $poradi = 0; foreach($hodiny as $hodina){ $pritomno = $db->fetchOne("SELECT count(`id`) as pocet FROM `do_hodiny_zaci` WHERE `pritomnost` = '1' and `hodiny_id` = :id", $hodina->id); $barva = ($pritomno->pocet > 0) ? "text-success" : "text-danger"; $datum = date('d.m.Y G:i',strtotime($hodina->datum)); $obsah = nl2br($hodina->obsah); $typ = (trim($hodina->typhodiny) == '0') ? "ustál." : "jednor."; $poradi++; // $bg = 'style="background:'.(($poradi % 2 == 1) ? 'rgba(0,0,0,0.05)' : 'rgba(0,0,0,0)').';"'; $html .= <<<HTML <tr id="hodina-radek$hodina->id"> <td id="hodina-datum$hodina->id">$datum</td> <td id="hodina-trvani$hodina->id" class="text-center" >$hodina->trvani</td> <td id="hodina-typ$hodina->id" class="text-center" >$typ</td> <td id="hodina-obsah$hodina->id">$obsah</td> <td class="text-center pointer" onclick="hodinaSmazat($hodina->id)"><i class="far fa-trash-alt text-danger"></i></td> <td class="text-center pointer" onclick="hodinaEdituj($hodina->id)"><i class="fas fa-edit text-primary"></i></td> <td class="text-center pointer" onclick="hodinaUcast($hodina->id)"><span id="hodina-ucast$hodina->id">$pritomno->pocet <i class="fas fa-users $barva"></i></span></td> </tr> <tr> <td colspan="7" id="hodina-err$hodina->id" class="pt-0 d-none"></td> <tr> HTML; } } $html .= <<<HTML </table> </div> HTML; return $html; } public function hodinaEdituj($hodinaId){ $db = new DB(); if ($hodinaId > 0){ $hodina = $db->fetchOne("SELECT `obsah`, `datum`, `trvani`, `typhodiny`, `do_pololeti`.`oddata`, `do_pololeti`.`dodata` FROM `do_skupiny_hodiny` left join `do_skupiny` on `do_skupiny`.`id`=`do_skupiny_hodiny`.`skupiny_id` left join `do_pololeti` on `do_skupiny`.`obdobi`=`do_pololeti`.`id` WHERE `do_skupiny_hodiny`.`id` = :hodinaId", $hodinaId); $datum = date('Y-m-d\TH:i',strtotime($hodina->datum)); $oddata = $hodina->oddata; $dodata = $hodina->dodata; // $obsah = nl2br($hodina->obsah); $obsah = $hodina->obsah; $checked0 = ($hodina->typhodiny == '0') ? "checked" : ""; $checked1 = ($hodina->typhodiny == '1') ? "checked" : ""; $nadpis = "Editace doučovací jednotky"; $trvani = $hodina->trvani; $bg = "bg-primary"; } else { $checked0 = "checked"; $checked1 = ""; $nadpis = "Nová doučovací jednotka"; $bg = "bg-success"; $trvani = 45; $datum = date('Y-m-d\T12:00'); $datumy = $db->fetchOne("SELECT `oddata`, `dodata` FROM `do_pololeti` WHERE `aktualni` = '1'"); $oddata = $datumy->oddata; $dodata = $datumy->dodata; } $html = <<<HTML <div class="modal fade rounded-0" id="hodina-editace-dialog" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true" data-oddata="$oddata" data-dodata="$dodata"> <div class="modal-dialog modal-lg rounded-0 modal-dialog-scrollable"> <div class="modal-content"> <div class="modal-header $bg text-white rounded-0"> <h5 class="modal-title" id="staticBackdropLabel">$nadpis</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body rounded-0"> <div class="form-group row mb-3"> <label for="datum-edit" class="col-lg-4 col-6 col-form-label">Datum a čas konání:</label> <div class="col-lg-4 col-6"> <input type="datetime-local" class="form-control" name="datum-edit" id="datum-edit" value="$datum" oninput="schovejErr()"> </div> <label for="trvani-edit" class="col-lg-2 col-6 col-form-label mt-lg-0 mt-2">Trvání minut:</label> <div class="col-lg-2 col-6"> <input type="number" class="form-control mt-lg-0 mt-2" oninput="schovejErr()" name="trvani-edit" id="trvani-edit" min="15" max="90" step="5" size="5" value="$trvani" > </div> </div> <hr class="mb-1"> <div class="row"> <div class="col-6"> <input type="radio" id="typ-0" name="typhodiny" value="0" $checked0 oninput="schovejErr()" > <label for="typ-0">ustálený blok doučování</label> </div> <div class="col-6"> <input type="radio" id="typ-1" name="typhodiny" value="1" $checked1 oninput="schovejErr()"> <label for="typ-1">jednorázová hodina</label> </div> </div> <hr class="mb-3 mt-1"> Obsah jednotky: <textarea id="obsah-edit" rows="3" class="w-100" style="min-height: 30px;" oninput="schovejErr()">$obsah</textarea> <div id="hodina-err" class="alert alert-danger d-none mt-2 rounded-0 py-0 mb-0"></div> </div> <div class="modal-footer text-start"> <div class="d-flex "> <button type="button" class="btn btn-success rounded-0" onclick="hodinaEditujUloz($hodinaId)">Uložit</button> </div> </div> </div> </div> </div> HTML; return $html; } public function hodinaEditujCancel($hodinaId){ $db = new DB(); $hodina = $db->fetchOne("SELECT `id`, `obsah`, `datum`, `trvani`, `typhodiny` FROM `do_skupiny_hodiny` WHERE `id` = :id", $hodinaId); $pritomno = $db->fetchOne("SELECT count(`id`) as pocet FROM `do_hodiny_zaci` WHERE `pritomnost` = '1' and `hodiny_id` = :id", $hodina->id); $barva = ($pritomno->pocet > 0) ? "text-success" : "text-danger"; $datum = date('d.m.Y G:i',strtotime($hodina->datum)); $obsah = nl2br($hodina->obsah); $typ = (trim($hodina->typhodiny) == '0') ? "ustál." : "jednor."; $html = <<<HTML <td id="hodina-datum$hodina->id">$datum</td> <td id="hodina-trvani$hodina->id" class="text-center">$hodina->trvani</td> <td id="hodina-typ$hodina->id" class="text-center" >$typ</td> <td id="hodina-obsah$hodina->id">$obsah</td> <td class="text-center pointer" onclick="hodinaSmazat($hodina->id)"><i class="far fa-trash-alt text-danger"></i></td> <td class="text-center pointer" onclick="hodinaEdituj($hodina->id)"><i class="fas fa-edit text-primary"></i></td> <td class="text-center pointer" onclick="hodinaUcast($hodina->id)"><span id="hodina-ucast$hodina->id">$pritomno->pocet <i class="fas fa-users $barva"></i></span></td> HTML; return $html; } public function hodinaEditujUloz($data){ $result = new stdClass(); $db = new DB(); if ($data->id > 0){ $db->query('UPDATE `do_skupiny_hodiny` SET `obsah`=:obsah,`datum`=:datum, `trvani`=:trvani, `typhodiny` =:typhodiny WHERE `id` = :id', htmlspecialchars($data->obsah), $data->datum, $data->trvani, $data->typhodiny, $data->id); return $this->hodinaEditujCancel($data->id); } else { $db->query("INSERT INTO `do_skupiny_hodiny`(`skupiny_id`, `obsah`, `datum`, `trvani`, `typhodiny`) VALUES (:skupiny_id, :obsah, :datum, :trvani, :typhodiny)", $this->skupinaId, htmlspecialchars($data->obsah), $data->datum, $data->trvani, $data->typhodiny); $result->hodinaId = $db->lastInsertId(); $zaci = $db->fetchAll("SELECT `id` FROM `do_skupiny_zaci` WHERE `skupiny_id` =:skupiny_id", $this->skupinaId); forEach($zaci as $zak){ $db->query("INSERT INTO `do_hodiny_zaci`(`hodiny_id`, `zaci_id`, `pritomnost`) VALUES (:hodiny_id, :zaci_id, '0')", $result->hodinaId, $zak->id); } if ($data->pocetHodin > 0){ $hodina = $db->fetchOne("SELECT `obsah`, `datum`, `trvani`, `typhodiny` FROM `do_skupiny_hodiny` WHERE `id` = :id", $result->hodinaId); $datum = date('d.m.Y G:i',strtotime($hodina->datum)); $typ = ($hodina->typhodiny == '0') ? "ustál." : "jednor."; $result->html = <<<HTML <tr id="hodina-radek$result->hodinaId"> <td id="hodina-datum$result->hodinaId">$datum</td> <td id="hodina-trvani$result->hodinaId" class="text-center">$hodina->trvani</td> <td id="hodina-typ$result->hodinaId" class="text-center" >$typ</td> <td id="hodina-obsah$result->hodinaId">$hodina->obsah</td> <td class="text-center pointer" onclick="hodinaSmazat($result->hodinaId)"><i class="far fa-trash-alt text-danger"></i></td> <td class="text-center pointer" onclick="hodinaEdituj($result->hodinaId)"><i class="fas fa-edit text-primary"></i></td> <td class="text-center pointer" onclick="hodinaUcast($result->hodinaId)"><span id="hodina-ucast$result->hodinaId">0 <i class="fas fa-users text-danger"></i></span></td> </tr> <tr> <td colspan="7" id="hodina-err$result->hodinaId" class="pt-0 d-none"></td> <tr> HTML; } else { $result->html = $this->hodinyHodiny(); } return json_encode($result); } } private function hodinaZaci($hodinaId){ $db = new DB(); $pocet = $db->fetchOne("select count(*) as pocet FROM `do_hodiny_zaci` WHERE `hodiny_id` = :hodiny_id and pritomnost = '1'", $hodinaId); $zaci = $db->fetchAll("SELECT h.`id`, `pritomnost`, z.prijmeni, z.jmeno, z.trida FROM `do_hodiny_zaci` as h left join do_skupiny_zaci s on s.id=h.`zaci_id` left join `zaci` as z on z.`id`= s.`zaci_id` WHERE h.`hodiny_id` = :hodiny_id order by z.trida, z.prijmeni, z.jmeno", $hodinaId); $html = <<<HTML <div class="d-flex flex-wrap"> <button class="btn mb-2 rounded-0 btn-outline-primary btn-sm text-nowrap" onclick="zaciPritomnostOznac(1)">Označ vše</button> <div class="flex-column-spacer"></div> <button class="btn mb-2 rounded-0 btn-outline-primary btn-sm text-nowrap" onclick="zaciPritomnostOznac(0)">Zruš vše </button> <div class="flex-column-spacer"></div> <button class="btn mb-2 rounded-0 btn-outline-primary btn-sm text-nowrap" onclick="zaciPritomnostOznac(2)">Invertuj</button> <div id="zaci-pritomnost-pocet" class="ms-auto h5 mt-1">Označeno: $pocet->pocet</div> </div> <div class="mb-2"><small>Zatržením vyznač přítomnost.</small></div> <table class="table table-striped table-sm"> HTML; forEach($zaci as $zak){ $pritomnost = ($zak->pritomnost == '1') ? " checked " : ""; $html .= <<<HTML <tr> <td> <input class="form-check-input rounded-0" type="checkbox" $pritomnost name="zak-pritomnost" id="zak-pritomnost$zak->id" onchange="zaciPritomnostSpocitej()" > <td> <td> <label class="form-check-label" for="zak-pritomnost$zak->id">$zak->prijmeni $zak->jmeno</label> </td> <td> <label class="form-check-label" for="zak-pritomnost$zak->id">$zak->trida</label> </td> </tr> HTML; } $html .= <<<HTML </table> HTML; return $html; } public function hodinaUcast($hodinaId){ $zaci = $this->hodinaZaci($hodinaId); $db = new DB(); $hodina = $db->fetchOne("select datum from do_skupiny_hodiny where id = :id", $hodinaId); $datum = date('d.m.Y G:i',strtotime($hodina->datum)); $html = <<<HTML <div class="modal fade rounded-0" id="ucast-dialog" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true"> <div class="modal-dialog rounded-0 modal-dialog-scrollable"> <div class="modal-content"> <div class="modal-header bg-primary text-white rounded-0"> <h5 class="modal-title" id="staticBackdropLabel">Účast na hodině: $datum</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body rounded-0"> $zaci </div> <div class="modal-footer text-start"> <div class="d-flex "> <button type="button" class="btn btn-outline-warning rounded-0 ms-auto" data-bs-dismiss="modal">Storno</button> <div class="flex-column-spacer"></div> <button type="button" class="btn btn-success rounded-0" onclick="ulozUcast($hodinaId)">Ulož účast</button> </div> </div> </div> </div> </div> HTML; return $html; } public function ulozUcast($hodinaId, $kody){ $db = new DB(); $db->query("UPDATE `do_hodiny_zaci` SET `pritomnost`='0' WHERE `hodiny_id` = :hodiny_id", $hodinaId); forEach($kody as $kod){ $db->query("UPDATE `do_hodiny_zaci` SET `pritomnost`='1' WHERE `id` = :id", $kod); } } public function definitivneHodinaSmazat($hodinaId){ $db = new DB(); $db->query("DELETE FROM `do_skupiny_hodiny` WHERE `id` = :hodiny_id", $hodinaId); } }