Current Path : /data/web/virtuals/51568/virtual/www/www/plany/ |
Current File : /data/web/virtuals/51568/virtual/www/www/plany/planyPlany.php |
<?php if (file_exists('DbConnect.php')){ require_once('DbConnect.php'); } if (file_exists('funkce/DbConnect.php')){ require_once('funkce/DbConnect.php'); } /* if (file_exists('../../funkce/DbConnect.php')){ require_once('../../funkce/DbConnect.php'); }*/ if (!IsSet($idRok)){ if (IsSet($_POST["idRok"])){$idRok = $_POST["idRok"];} } ?> <hr> <div class="h4">Plány</div> <div class="d-flex my-2"> <div class=""> <button class="btn btn-info rounded-0" id="plNovyBtn">Nový </button> </div> <div class="ml-auto mr-2"> <button class="btn btn-success rounded-0" id="plEmailBtn">Email </button> </div> <div class=""> <button class="btn btn-success rounded-0" id="plTiskBtn">Tisk </button> </div> </div> <div id="plLzeEdit" class="row mb-2"> <div class="col"> <button id="btnPlEdit" class="btn btn-outline-info rounded-0">Editovat</button> </div> <div class="col text-right"> <button id="btnPlDel" class="btn btn-outline-danger rounded-0">Smazat</button> </div> </div> <div id="plany" class="mb-3 table-scroll" style="min-width: 220px; max-width: 220px;"> <div id="containerNovyPlan"></div> <div id="containerSmazatPlan" class="d-none"> <div class="alert alert-danger rounded-0"> <div class="h5">Mazání</div> <p>Chystáš se smazat plán. Texty (a týdny), které jsou přiřazeny k plánu, zůstanou zachovány.</p> <p>Chceš pokračovat? </p> <div class="row mt-2"> <div class="col"> <button id="btnDelAno" class="btn btn-danger btn-sm rounded-0">Ano</button> </div> <div class="col text-right"> <button class="btn btn-success btn-sm rounded-0" id="btnDelNe">Ne</button> </div> </div> </div> </div> <?php $sql = "SELECT pp.id, MIN(pt.zacatek) as zacatek, MAX(pt.zacatek) as konec from pl_plany pp join pl_tydny pt on pt.idplan = pp.id " ."where pp.idrok = $idRok GROUP by pp.id order by zacatek desc"; $result = mysqli_query($conn, $sql); if ($row = mysqli_fetch_object($result)) { $pocet = 0; if ($row->id > 0) { ?> <div class="table-scroll-plany"> <table class="table table-striped table-bordered table-sm"> <?php do { $pocet++; $checked = false; if($pocet == 1) {$checked = true; $idPlan = $row->id;} $checkedS = ($checked) ? "checked" : ""; ?> <tr <?php echo ($checked) ? "id='aktualni'" : ""; ?>> <td> <div class="custom-control custom-radio ml-1 pr-0"> <input type="radio" class="custom-control-input" id="rgPlanZobr<?php echo $row->id; ?>" name="rgPlanZobr" <?php echo $checkedS; ?>> <label class="custom-control-label" for="rgPlanZobr<?php echo $row->id; ?>" id="rgPlanLabel<?php echo $row->id; ?>"> <?php echo date('d.m.', strtotime($row->zacatek));?> - <?php echo date('d.m.Y', strtotime("+6 day", strtotime($row->konec)));?> </label> </div> </td> </tr> <?php } while ($row = mysqli_fetch_object($result)); ?> </table> </div> <?php ;} } ?> </div> <script src="www/plany/funkce.js"></script> <script> $(document).ready(function () { $("#btnPlDel").on("click", function () { $("#containerSmazatPlan").removeClass("d-none"); $("#containerNovyPlan").addClass("d-none"); }) $("#btnDelNe").on("click", function () { $("#containerSmazatPlan").addClass("d-none"); }) $("#btnDelAno").on("click", function () { $("#containerSmazatPlan").addClass("d-none"); var idPlan = rgKod("rgPlanZobr"); $.ajax({ url: "www/plany/planyPlanySmaz.php", type: 'POST', data: { 'idPlan': idPlan, }, success: function (result) { $.ajax({ url: "www/plany/planyPlany.php", type: 'POST', data: { 'idRok': '<?php echo $idRok; ?>', }, success: function (result) { $("#idListPlans").html(result); $.ajax({ url: "www/plany/planyNahled.php", type: 'POST', data: { 'idPlan': 0, 'idRok': '<?php echo $idRok; ?>', }, success: function (result) { $("#main").html(result); } }) } }) } }) }) $("#plNovyBtn").on('click', function () { $("#containerSmazatPlan").addClass("d-none"); $("#containerNovyPlan").removeClass("d-none"); $.ajax({ url: "www/plany/planyPlanyNovy.php", type: 'POST', data: { 'idRok': '<?php echo $idRok; ?>', 'akce': 'n' }, success: function (result) { $("#containerNovyPlan").html(result); } }) }) $("#btnPlEdit").on('click', function () { $("#containerSmazatPlan").addClass("d-none"); $("#containerNovyPlan").removeClass("d-none"); var idPlan = rgKod("rgPlanZobr"); $.ajax({ url: "www/plany/planyPlanyNovy.php", type: 'POST', data: { 'idRok': '<?php echo $idRok; ?>', 'idPlan': idPlan, 'akce': 'e' }, success: function (result) { $("#containerNovyPlan").html(result); idPlan = result; } }) }) $('[id^="rgPlanZobr"]').on('click', function () { $("#containerNovyPlan").addClass("d-none"); $("#containerSmazatPlan").addClass("d-none"); let idPlan = rgKod("rgPlanZobr"); $.ajax({ url: "www/plany/planyNahled.php", type: 'POST', data: { 'idPlan': idPlan }, success: function (result) { $("#main").html(result); $.ajax({ url: "www/plany/planyJeAktualni.php", type: 'POST', data: { 'idPlan': idPlan }, success: function (result) { result = result.trim(); if (result == idPlan) { $("#plLzeEdit").removeClass("d-none") } else { $("#plLzeEdit").addClass("d-none"); } } }) } }) }) $('#plTiskBtn').on('click', function (event) { $("#containerNovyPlan").addClass("d-none"); $("#containerSmazatPlan").addClass("d-none"); let idPlan = rgKod("rgPlanZobr"); event.preventDefault(); event.stopPropagation(); let targetAttr = 'tisk'; let linkHref = 'www/plany/planyTisk.php?idPlan=' + idPlan; window.open(linkHref, targetAttr); }); $('#plEmailBtn').on('click', function (event) { let idPlan = rgKod("rgPlanZobr"); $.ajax({ url: "www/plany/planEmaily.php", type: 'POST', data: { 'data': JSON.stringify({ command: 'modal', idPlan: idPlan, }) }, success: function (result) { $("#dlgEmaily").html(result); $("#email-dialog").modal("show"); } }) }); }) function rozesliPlan(idPlan){ $("#btnRozesliPlany").addClass("d-none"); $("#alertOdesilam").removeClass("d-none"); let kodyStr = ""; $("[id^=email-cb]").each(function() { if (this.checked) { kodyStr += this.id.substr(9, 50) + ','; } }); kodyStr += '0'; let termin = $("#rgPlanLabel" + idPlan).text(); $.ajax({ url: "www/plany/planEmailyBody.php", type: 'POST', data: { 'idPlan': rgKod("rgPlanZobr"), }, success: function (result) { $.ajax({ url: "www/plany/planEmaily.php", type: 'POST', data: { 'data': JSON.stringify({ command: 'rozesliPlan', termin: termin, plan: result, kodyStr: kodyStr, idPlan: idPlan, }) }, success: function (result) { console.log(result); $("#email-dialog").modal("hide"); } }) } }) } function emailHromadneOznac(typ){ if (typ == '1'){ $("[id^='email-cb']").prop('checked', true); } else { $("[id^='email-cb']").prop('checked', false); } } </script>