<?php
include_once "header.php";

$getDestinationIdAsDefault = null;
?>

<!-- Banner -->
<div id="banner-wrapper">
    <div id="banner" class="box container">
        <div class="row">
            <div class="7u 12u(medium)">
                <h2>Welcome our client</h2>
                <p>Let's explore your dream destination!</p>
            </div>
            <div class="5u 12u(medium)">
                <?php
                if ($defaultDestinationSelected == true AND $defaultDestinationId != 0) {
                    $destinationName=$classFunctions->getDestinationNameById($defaultDestinationId);
                    echo "<h3>Your current destination is:</h3>";
                    echo "<h2>".$destinationName."</h2>";
                    echo '<a href="'.Init::HOMEURL.'clear" class="button alt small icon">Change</a>';
                } else {
                    ?>
                    <h3>Already in?</h3>
                    <form action="<?php echo Init::HOMEURL; ?>" method="POST">
                        <?php
                        $getRowsOfDestinations = $db->select("SELECT destinations.Id AS DestId,destinations.Name AS DestName,countries.Name AS CountryName FROM destinations,countries WHERE countries.Id=destinations.countryId ORDER BY countryName ASC");
                        if ($getRowsOfDestinations) {
                            echo "<select name='setDefaultDestId' class='selectDefault'>";
                            echo "<option value=''>Select your destination:</option>";
                        }
                        foreach ($getRowsOfDestinations as $getRowOfDestination) {
                            $opt = "<option value='" . filter_var($getRowOfDestination['DestId'],FILTER_SANITIZE_NUMBER_INT) . "'>" . filter_var($getRowOfDestination['CountryName'],FILTER_SANITIZE_STRING) . ' ->' . filter_var($getRowOfDestination['DestName'],FILTER_SANITIZE_STRING) . "</option>";
                            echo $opt;
                        }
                        if ($getRowsOfDestinations) {
                            echo "</select>";
                        }
                        ?>
                        <br>
                        <input type="submit" class="button small icon" value="Set as default">
                    </form>
                    <?php
                }
                ?>
            </div>
        </div>
    </div>
</div>


<?php
include_once "footer.php";
?>