<?php
include "../../connection.php";
include "../../function.php";

$id_typSluzby = getTypSluzbaId();

$sluzbaTyp = getSluzbaTyp();

$sluzbyNazevKadernictvi = array();
$sluzbyIdKadernictvi = array();

$sluzbyNazevKosmetika = array();
$sluzbyIdKosmetika = array();

$sluzbyNazevManikura = array();
$sluzbyIdManikura = array();

$sluzbyNazevPedikura = array();
$sluzbyIdPedikura = array();


if (isset($_GET["jmeno"]) AND isset($_GET["email"]) AND isset($_GET["telefon"]) AND isset($_GET["sluzbaTyp"]) AND isset($_GET["sluzba"]) AND isset($_GET["id_sluzba"]) AND isset($_GET["id"])){
    $jmeno = $_GET["jmeno"];
    $email = $_GET["email"];
    $telefon = $_GET["telefon"];
    $sluzbaTyp = $_GET["sluzbaTyp"];
    $sluzbaNazev = $_GET["sluzba"];
    $id_sluzba = $_GET["id_sluzba"];
    $id = $_GET["id"];
}


$stmt = $conn->prepare('select * from '.$sluzbyTable.' WHERE id_typSluzby ='.$id_typSluzby);
if($stmt->execute()){
    $result = $stmt->get_result();
    if($result->num_rows>0){
        while($row = $result->fetch_assoc()){
            $sluzbyNazevKadernictvi[] = $row['nazev'];
            $sluzbyIdKadernictvi[] = $row['id_sluzby'];
        }
        $stmt->close();
    }
}
    
$conn->close();
?>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../../styleKadernictvi.css">
    <link rel="stylesheet" href="../../rezervace/styleRezervace.css">
    <title>Document</title>
</head>
<body>
    <div class="container vyberSluzby mx-auto mt-16 mb-16 text-center shadow-all lg:p-8 text-2xl">
        <div class="lg:w-auto mx-auto lg:p-24 p-8 myShadow lg:rounded-3xl bg-white">
            <h1>Vybrat službu</h1>
            <div class="mt-8 grid">

                <?php 
                    if ($sluzbaTyp) {
                        ?>
                        <div class="hiddenMenu hiddenMenu1 admin">
                            <?php
                                $counter=0;
                                foreach ($sluzbyNazevKadernictvi as $sluzba) {
                                    ?>
                                        <a class="p-4" href="vyberDatumu.php?id=<?php echo $id;?>&jmeno=<?php echo $jmeno?>&email=<?php echo $email?>&telefon=<?php echo $telefon?>&sluzbaTyp=<?php echo $sluzbaTyp?>&sluzba=<?php echo $sluzba?>&id_sluzba=<?php echo $sluzbyIdKadernictvi[$counter]?>">
                                            <?php echo $sluzba; ?>
                                        </a>
                                    <?php
                                    $counter++;
                                }
                            ?>
                        </div> 
                        <?php
                    }
                ?>

            </div>
            
        </div>
    </div>
<script src="../../rezervace/script.js"></script>
</body>
</html>