Your IP : 18.116.15.109


Current Path : /data/web/virtuals/51568/virtual/www/www/plany/
Upload File :
Current File : /data/web/virtuals/51568/virtual/www/www/plany/textyUN.php

<?php
  require_once('DbConnect.php');
  

  if (IsSet($_POST["idTyden"])){$idTyden = $_POST["idTyden"];}
  if (IsSet($_POST["idTydenAktualni"])){$idTydenAktualni = $_POST["idTydenAktualni"];}
  if (IsSet($_POST["operace"])){$operace = $_POST["operace"]; } else {$operace = 'x';} // e = editace, n = nova, x - nic
?>
<button class="btn btn-outline-info my-2" id="unNovy">Nový článek <i class="far fa-file"></i></button>
<div id="editFormUN" class="d-none">
</div>
<?php
 
  $sql = "SELECT `id`, `idtyden`, `cislo`, `strana`, `clanek` FROM `pl_un` WHERE idtyden = $idTydenAktualni order by cislo, strana";
  $result = mysqli_query($conn, $sql);
  if ($row =  mysqli_fetch_object($result)) {
    $pocetUN = mysqli_num_rows($result);
    if ($pocetUN > 0) {  ?>
    <table class="table table-striped table-bordered">
    <tr class="table-info">
      <td style="width: 80px;">číslo</td>
      <td style="width: 120px;">strana</td>
      <td>článek</td>
      <td  style="width: 50px; text-align: center;"></td>
      <td  style="width: 50px; text-align: center;"></td>      
    </tr>
<?php    do {  ?>
    <tr>
      <td><?php echo $row->cislo; ?></td>
      <td><?php echo $row->strana; ?></td>
      <td><?php echo $row->clanek; ?></td>
      <td>
        <span class="mx-1 text-success"><i id="edUN<?php echo $row->id;?>" class="far fa-edit"></i></span>
      </td>
      <td>
        <span class="mx-1 text-danger"><i id="deUN<?php echo $row->id;?>"class="far fa-trash-alt"></i></span>
      </td>
    </tr>
 <?php   } while ($row =  mysqli_fetch_object($result)); ?> 
 <?php   }  ?> 
 </table>
<?php  }  ?> 

 
<script src="funkce.js"></script>
<script>
  $(document).ready(function () {
   
      $("#unNovy").on("click", function(){
        $.ajax({
            url: "textyUNEditForm.php",
            type: 'POST',
            data: {
              'id': 0,
              'operace': 'n',
            },
            success: function (result) {
              $("#editFormUN").html(result);
            }
          })
        $("#editFormUN").removeClass("d-none");
      })
     
     $('[id^="edUN"]').on("click",function(){
       var id = this.id.substr(4,10);
        $.ajax({
            url: "textyUNEditForm.php",
            type: 'POST',
            data: {
              'id': id,
              'operace': 'e',
            },
            success: function (result) {
              $("#editFormUN").html(result);
              $("#editFormUN").removeClass("d-none");
            }
          })
        
      })
      
      $('[id^="deUN"]').on("click",function(){
       var id = this.id.substr(4,10);
        $.ajax({
            url: "textyUNDelForm.php",
            type: 'POST',
            data: {
              'id': id,
            },
            success: function (result) {
              $("#editFormUN").html(result);
              $("#editFormUN").removeClass("d-none");              
            }
          })
        
      })

      
  })
</script>