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

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

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

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

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

/************ KADEŘNICTVÍ **********************/
$stmt = $conn->prepare('SELECT * from sluzby WHERE id_typSluzby = 1');
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();
    }
}

/************ KOSMETIKA **********************/
$stmt = $conn->prepare('SELECT * from sluzby WHERE id_typSluzby = 2');
if($stmt->execute()){
    $result = $stmt->get_result();
    if($result->num_rows>0){
        while($row = $result->fetch_assoc()){
            $sluzbyNazevKosmetika[] = $row['nazev'];
            $sluzbyIdKosmetika[] = $row['id_sluzby'];
        }
        $stmt->close();
    }
}

/************ MANIKÚRA **********************/
$stmt = $conn->prepare('SELECT * from sluzby WHERE id_typSluzby = 3');
if($stmt->execute()){
    $result = $stmt->get_result();
    if($result->num_rows>0){
        while($row = $result->fetch_assoc()){
            $sluzbyNazevManikura[] = $row['nazev'];
            $sluzbyIdManikura[] = $row['id_sluzby'];
        }
        $stmt->close();
    }
}

/************ PEDIKÚRA **********************/
$stmt = $conn->prepare('SELECT * from sluzby WHERE id_typSluzby = 4');
if($stmt->execute()){
    $result = $stmt->get_result();
    if($result->num_rows>0){
        while($row = $result->fetch_assoc()){
            $sluzbyNazevPedikura[] = $row['nazev'];
            $sluzbyIdPedikura[] = $row['id_sluzby'];
        }
        $stmt->close();
    }
}
    

    function vytvorit_options($select){
        global $sluzbyNazev;

         $options='';

        
         foreach($sluzbyNazev as $sluzba){

            if ($select==$sluzba) {
                $options.='<option value="'.$sluzba.'" selected>'.$sluzba.'</option>';
            }
            else{
                $options.='<option value="'.$sluzba.'">'.$sluzba.'</option>';
            }
             
         }

         return $options;
    }

    if(isset($_POST['sluzby']))
    {
        $selected = $_POST['sluzby'];
    }
    

    $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="styleRezervace.css">
    <title>Document</title>
</head>
<body>
    <header class="headerRezervace">
        <h2>Kadeřnictví Hrdlořezy - <b>REZERVACE</b></h2>
    </header>
    <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>Vyberte službu</h1>
            <div class="mt-8 grid lg:grid-rows-1 lg:grid-cols-4">

                <div class="hiddenMenuContainer align-center">
                    <h2 class="hiddenMenuButton hiddenMenuButton1 p-4 px-8 my-4 mx-auto rounded-2xl w-full lg:w-min" href="vyberDatumu.php">Kadeřnictví</h2>
                    <div class="hiddenMenu hiddenMenu1 hide">
                        <?php
                            $counter=0;
                            foreach ($sluzbyNazevKadernictvi as $sluzba) {
                                ?>
                                    <a class="p-4" href="vyberDatumu.php?sluzbaTyp=kadeřnictví&sluzba=<?php echo $sluzba;?>&id_sluzba=<?php echo $sluzbyIdKadernictvi[$counter];?>">
                                        <?php echo $sluzba; ?>
                                    </a>
                                <?php
                                $counter++;
                            }
                        ?>
                    </div>                  
                </div>
                <div class="hiddenMenuContainer">
                    <h2 class="hiddenMenuButton hiddenMenuButton2 p-4 px-8 my-4 mx-auto rounded-2xl w-full lg:w-min" href="vyberDatumu.php">Kosmetika</h2>
                    <div class="hiddenMenu hiddenMenu2 hide">                      
                        <?php
                            $counter=0;
                            foreach ($sluzbyNazevKosmetika as $sluzba) {
                                ?>
                                    <a class="p-4" href="vyberDatumu.php?sluzbaTyp=kosmetika&sluzba=<?php echo $sluzba;?>&id_sluzba=<?php echo $sluzbyIdKosmetika[$counter];?>">
                                
                                        <?php echo $sluzba; ?>

                                    </a>
                                <?php
                                 $counter++;
                            }
                        ?>
                    </div>                  
                </div>
                <div class="hiddenMenuContainer">
                    <h2 class="hiddenMenuButton hiddenMenuButton3 p-4 px-8 my-4 mx-auto rounded-2xl w-full lg:w-min" href="vyberDatumu.php">Manikúra</h2>
                    <div class="hiddenMenu hiddenMenu3 hide">                   
                        <?php
                            $counter=0;
                            foreach ($sluzbyNazevManikura as $sluzba) {
                                ?>
                                    <a class="p-4" href="vyberDatumu.php?sluzbaTyp=manikúra&sluzba=<?php echo $sluzba;?>&id_sluzba=<?php echo $sluzbyIdManikura[$counter];?>">
                                
                                        <?php echo $sluzba; ?>

                                    </a>
                                <?php
                                $counter++;
                            }
                        ?>                    
                    </div>                  
                </div>
                <div class="hiddenMenuContainer">
                    <h2 class="hiddenMenuButton hiddenMenuButton4 p-4 px-8 my-4 mx-auto rounded-2xl w-full lg:w-min" href="vyberDatumu.php">Pedikúra</h2>
                    <div class="hiddenMenu hiddenMenu4 hide">
                    <?php
                            $counter=0;
                            foreach ($sluzbyNazevPedikura as $sluzba) {
                                ?>
                                    <a class="p-4" href="vyberDatumu.php?sluzbaTyp=pedikúra&sluzba=<?php echo $sluzba;?>&id_sluzba=<?php echo $sluzbyIdPedikura[$counter];?>">
                                
                                        <?php echo $sluzba; ?>

                                    </a>
                                <?php
                                $counter++;
                            }
                        ?>
                    </div>                  
                </div>
            </div>
        </div>
    </div>
<script src="scriptRezervace.js"></script>
</body>
</html>