<?PHP 
require_once('core.php');
if(!isset($_SESSION['id']))
{
header("Location: index.php");
exit();
}
$menu = "shop";
$page = "vip";
$erreur = false;
if(isset($_POST['vip']))
{

    if($U['vip_points'] >= $B['prix_vip']) {

        $vip = $bdd->prepare("UPDATE users SET rank = 2, credits = credits + 100000, activity_points = activity_points + 100000, rank_vip = 1, vip_points = vip_points - ? WHERE id = ?");
        $vip->execute(array($B['prix_vip'],$U['id']));

        $vip2 = $bdd->prepare("UPDATE user_stats SET DailyRespectPoints = DailyRespectPoints + 15, DailyPetRespectPoints = DailyPetRespectPoints + 15, AchievementScore = AchievementScore + 300 WHERE id = ?");
        $vip2->execute(array($U['id']));

        $vip3 = $bdd->prepare("INSERT INTO user_badges (user_id, badge_id) VALUES (:userid, :badge)");
        $vip3->bindValue(':userid', $U['id']);
        $vip3->bindValue(':badge', 'VIP');
        $vip3->execute();
        $vip3->bindValue(':userid', $U['id']);
        $vip3->bindValue(':badge', 'PI12');
        $vip3->execute();
        $vip3->bindValue(':userid', $U['id']);
        $vip3->bindValue(':badge', 'PLZ19');
        $vip3->execute();
        $vip3->bindValue(':userid', $U['id']);
        $vip3->bindValue(':badge', 'TUR04');
        $vip3->execute();
        $vip3->bindValue(':userid', $U['id']);
        $vip3->bindValue(':badge', 'UF001');
        $vip3->execute();
        $vip3->bindValue(':userid', $U['id']);
        $vip3->bindValue(':badge', 'EPS06');
        $vip3->execute();
        $vip3->bindValue(':userid', $U['id']);
        $vip3->bindValue(':badge', 'EPS13');
        $vip3->execute();

        $message = 'Félicitation vous êtes maintenant VIP !';
        $erreur = false;

    } else {
        $message = 'Tu n\'a pas assez de diamants !';
        $erreur = true;
    }
}

?>
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title><?PHP echo htmlentities(trim($cms['nom_hotel'])); ?> - VIP </title>
        <link type="text/css" href="<?PHP echo htmlspecialchars(trim($cms['lien'])); ?>/web/css/material.css" rel="stylesheet">
        <link rel="stylesheet" type="text/css" href="<?PHP echo htmlspecialchars(trim($cms['lien'])); ?>/web/css/nav.css">
        <script src="<?PHP echo htmlspecialchars(trim($cms['lien'])); ?>/web/js/jquery.js"></script>
        <script type="text/javascript" src="<?PHP echo htmlspecialchars(trim($cms['lien'])); ?>/web/js/smoothscroll.js"></script>
        <script src="//api.dedipass.com/v1/pay.js"></script>
    </head> 
    <body>
    <?PHP require_once('template/header/template_header.php'); ?>
        <div class="container_24">
        <?PHP require_once('template/header/template_nav.php'); ?>
        <?PHP if (isset($message) && $erreur == true) { ?>
                <div class="grid_24">
            <div id="erreur">
                <div class="title red">
                    <?PHP echo htmlentities(trim($message)); ?>
                </div>
            </div>
        </div>
        <?PHP } elseif (isset($message) && $erreur == false) { ?>
        <div class="grid_24">
            <div id="good">
                <div class="title red">
                    <?PHP echo htmlentities(trim($message)); ?>
                </div>
            </div>
        </div>
        <?PHP } ?>
        <div class="grid_24" style="text-align: center;">
            <img src="web/img/boutique/header_shop.png">
        </div>
            <div class="grid_18">
                <div id="contentBox" class="activity" style="overflow: hidden;">
                    <div class="head">
                        <div class="badgeImage habbo"></div>
                        Devenir célèbre !
                        <br>
                        <span class="date">Tu souhaites devenir célèbre ? Tu es au bonne endroit !</span>
                    </div>
                    <div class="text" style="text-align: center;">
                    <img src="web/img/boutique/vip.gif"><br>
                    <p style="color: cornflowerblue;font-weight: 600;">Les avantages du VIP Club de <?PHP echo htmlspecialchars(trim($cms['nom_hotel'])); ?></p><br>
                        <i>Des commandes supplémentaires !</i><br>
                        <b> Le CLUB te donne accès à une catégorie du catalogue réservé au VIP !<br></b>
                        <i style="font-size: 11px;">Les mobiliers réservés au VIP sont appelés des "rares" puisqu'ils ne sont pas accessibles à tous !</i><br>
                        <b> Un accès dans les apparts complets !<br></b>
                        <b> 300 winwins, 15 respects et caresses supplémentaire !<br></b>
                        <b> 100 000 crédits et duckets supplémentaire !<br></b>
                        <b> Un temps d'attente au Flood moins important !<br></b>
                        <b>Des magnifiques badges réservés au VIP !<br></b>
                        <img src="https://images.habbo.com/c_images/album1584/VIP.gif">
                        <img src="https://images.habbo.com/c_images/album1584/PI12.gif">
                        <img src="https://images.habbo.com/c_images/album1584/PLZ19.gif">
                        <img src="https://images.habbo.com/c_images/album1584/TUR04.gif">
                        <img src="https://images.habbo.com/c_images/album1584/UF001.gif">
                        <img src="https://images.habbo.com/c_images/album1584/EPS06.gif">
                        <img src="https://images.habbo.com/c_images/album1584/EPS13.gif"><br><br>
                        <form method="post">
                        <button name="vip" class="button raised green" style="padding: 10px 10px 30px 10px;line-height: 0px;border: none;">
                            <div class="center">Adhérer au CLUB pour <?PHP echo htmlspecialchars(trim($B['prix_vip'])); ?> <img style="position: relative;top: 3px;" src="web/img/me/diamonds.png"></div>
                        </button>
                        </form>
                    </div>
                </div>
            </div>
            <div class="grid_6">
                <div id="contentBox" class="activity" style="overflow: hidden;">
                    <div class="head">
                        <div class="badgeImage trade"></div>
                        Ton porte monnaie
                    </div>
                    <div class="text" >
                        <img src="web/img/me/credits.png"> <?PHP echo intval($U['credits']); ?><br>
                        <img src="web/img/me/duckets.png"> <?PHP echo intval($U['activity_points']); ?><br>
                        <img src="web/img/me/diamonds.png"> <?PHP echo intval($U['vip_points']); ?>
                    </div>

                </div>
            </div>
            
            <div class="grid_24">
                <div id="contentBox">
                    <div class="title red">
                        <?PHP echo htmlentities(trim($cms['nom_hotel'])); ?> est propulsé par PlusCMS par Dodone.
                    </div>
                </div>
            </div>
        </div>
    </body>
</html>