<?PHP
require_once('core.php');
require_once('app/php/session.admin.php');
if($uti['rank'] < $ACCESS['config_hotel'])
{
  header('Location: home');
  exit();
}
$SelectHotel = $bdd->prepare('SELECT * FROM pluscms_hotel WHERE id = ?');
$SelectHotel->execute(array(1));
$SHotel = $SelectHotel->fetch();

$erreur = false;
$post = false;
if(isset($_POST['hotel1']))
{
        $ip = htmlspecialchars(trim($_POST['ip']));
        $port = intval(trim($_POST['port']));
        $variable = htmlspecialchars(trim($_POST['variable']));
        $text = htmlspecialchars(trim($_POST['text']));
        $override = htmlspecialchars(trim($_POST['override']));
        $productdata = htmlspecialchars(trim($_POST['productdata']));
        $figuredata = htmlspecialchars(trim($_POST['figuredata']));
        $furnidata = htmlspecialchars(trim($_POST['furnidata']));
        $base = htmlspecialchars(trim($_POST['base']));
        $habbo = htmlspecialchars(trim($_POST['habbo']));
        $hotel = htmlspecialchars(trim($_POST['hotel']));
        if(!empty($_POST['ip']) && !empty($port) && !empty($variable) && !empty($text) && !empty($override) && !empty($productdata) && !empty($figuredata) && !empty($furnidata) && !empty($base) && !empty($habbo))
        {
        if ($erreur == false) {
        $ModificationsConfigs = $bdd->prepare('UPDATE pluscms_hotel SET ip = ?, port = ?, variable = ?, text = ?, override = ?, producdata = ?, figuredata = ?, furnidata = ?, base = ?, habbo_base = ?, hotel = ? WHERE id = ?');
        $ModificationsConfigs->execute(array($ip, $port, $variable, $text, $override, $productdata, $figuredata, $furnidata, $base, $habbo, $hotel, 1));
        $InsertLogs = $bdd->prepare('INSERT INTO pluscms_logstaff (pseudo, date, action) VALUES (?, ?, ?)');
        $InsertLogs->execute(array($uti['username'], time(), "Mise à jour Configuration > Hôtel."));
        $message = "Mise à jour de l'hôtel effectuée. Rechargement dans 3 secondes.";
        $post = true;
        header("Refresh: 3;URL=hotel");
        }
    }
    else
    {
        $erreur = true;
        $message = "Merci de remplir tous les champs.";
    }
}
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title><?PHP echo htmlentities($cms['nom_hotel']); ?> | Panel</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
  <!-- Ionicons -->
  <link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
  <!-- jvectormap -->
  <link rel="stylesheet" href="bower_components/jvectormap/jquery-jvectormap.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
  <link rel="stylesheet"
        href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini" style="">
<div class="wrapper" style="">

  <header class="main-header">

    <!-- Logo -->
    <a href="home.php" class="logo">
      <!-- mini logo for sidebar mini 50x50 pixels -->
      <span class="logo-mini"><b>A</b>DM</span>
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"><b>Admin</span>
    </a>

    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
        <span class="sr-only">Toggle navigation</span>
      </a>
      <!-- Navbar Right Menu -->
      <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">

          <!-- User Account: style can be found in dropdown.less -->
          <li class="dropdown user user-menu">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
              <img src="https://www.habbo.de/habbo-imaging/avatarimage?figure=<?PHP echo htmlspecialchars(trim($uti['look'])); ?>&direction=2&head_direction=3&action=wav&size=m&gesture=sml&headonly=1" class="user-image" alt="User Image">
              <span class="hidden-xs"><?PHP echo htmlentities($uti['username']); ?></span>
            </a>
            <ul class="dropdown-menu">
              <!-- User image -->
              <li class="user-header">
                <img src="https://www.habbo.de/habbo-imaging/avatarimage?figure=<?PHP echo htmlspecialchars(trim($uti['look'])); ?>&direction=2&head_direction=3&action=wav&size=m&gesture=sml&headonly=1" class="img-circle" alt="User Image">

                <p>
                  <?PHP echo htmlentities($uti['username']); ?>
                  <small>Membre depuis <?PHP echo date('d.m.Y', $uti['account_created']); ?></small>
                </p>
              </li>
              <!-- Menu Body -->
              <!-- Menu Footer-->
              <li class="user-footer">
                <div class="pull-right">
                  <a href="logout.php" class="btn btn-default btn-flat">Déconnexion</a>
                </div>
              </li>
            </ul>
          </li>
        </ul>
      </div>

    </nav>
  </header>
  <!-- Left side column. contains the logo and sidebar -->
  <?PHP require_once('template/header.php'); ?>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Site
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-cog"></i> Configuration</a></li>
        <li class="active">Hôtel</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <!-- Info boxes -->

      <div class="row">
      <div class="col-md-12">
      <?PHP if($erreur == true) { ?>
      <div class="info-box bg-red" style="min-height: 0px;">
      <div class="info-box-content" style="margin-left: 0px;">
      <span class="info-box-text"><?PHP echo $message; ?></span>   
      </div>
      </div>
      <?PHP } ?>
      <?PHP if($post == true) { ?>
      <div class="info-box bg-green" style="min-height: 0px;">
      <div class="info-box-content" style="margin-left: 0px;">
      <span class="info-box-text"><?PHP echo $message; ?></span>   
      </div>
      </div>
      <?PHP } ?>
      </div>
      <div class="col-md-12">
            <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">Paramètrage de l'hôtel</h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form method="post">
              <div class="box-body">
                <div class="form-group">
                  <label for="exampleInputEmail1">Adresse IP</label>
                  <input type="text" class="form-control" id="exampleInputEmail1" name="ip" value="<?PHP echo htmlspecialchars($SHotel['ip']); ?>" placeholder="IP du serveur">
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">Port</label>
                  <input type="text" class="form-control" id="exampleInputEmail1" name="port" value="<?PHP echo htmlspecialchars($SHotel['port']); ?>" placeholder="Port">
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">Variable des SWF</label>
                  <input type="text" class="form-control" id="exampleInputEmail1" name="variable" value="<?PHP echo htmlspecialchars($SHotel['variable']); ?>" placeholder="Variable">
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">Texts des SWF</label>
                  <input type="text" class="form-control" id="exampleInputEmail1" name="text" value="<?PHP echo htmlspecialchars($SHotel['text']); ?>" placeholder="Text">
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">Override des SWF</label>
                  <input type="text" class="form-control" id="exampleInputEmail1" name="override" value="<?PHP echo htmlspecialchars($SHotel['override']); ?>" placeholder="Override">
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">Productdata des SWF</label>
                  <input type="text" class="form-control" id="exampleInputEmail1" name="productdata" value="<?PHP echo htmlspecialchars($SHotel['producdata']); ?>" placeholder="Productdata">
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">Figuredata des SWF</label>
                  <input type="text" class="form-control" id="exampleInputEmail1" name="figuredata" value="<?PHP echo htmlspecialchars($SHotel['figuredata']); ?>" placeholder="figuredata">
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">Furnidata des SWF</label>
                  <input type="text" class="form-control" id="exampleInputEmail1" name="furnidata" value="<?PHP echo htmlspecialchars($SHotel['furnidata']); ?>" placeholder="Furnidata">
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">Base des SWF</label>
                  <input type="text" class="form-control" id="exampleInputEmail1" name="base" value="<?PHP echo htmlspecialchars($SHotel['base']); ?>" placeholder="Base">
                </div>
                <div class="form-group">
                  <label for="exampleInputEmail1">Habbo.swf des SWF</label>
                  <input type="text" class="form-control" id="exampleInputEmail1" name="habbo" value="<?PHP echo htmlspecialchars($SHotel['habbo_base']); ?>" placeholder="habbo_base">
                </div>
                <div class="form-group">
                  <label>Accès au client</label>
                  <select class="form-control" name="hotel">
                    <option value="ouvert" <?PHP if ($SHotel['hotel'] == "ouvert") { ?> selected <?PHP } ?>>Ouvert</option>
                    <option value="fermer" <?PHP if ($SHotel['hotel'] == "fermer") { ?> selected <?PHP } ?>>Fermé</option>
                  </select>
                </div>
              </div>
              <!-- /.box-body -->

              <div class="box-footer">
                <button type="submit" name="hotel1" class="btn btn-primary">Mettre à jour</button>
              </div>
            </form>
          </div>
              <!--/.box -->
      </div>

      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

  <footer class="main-footer">
    <div class="pull-right hidden-xs">
      <b>PlusCMS</b> 
    </div>
    <strong>Cette administration est conçu pour PlusCMS par Dodone.</strong>
  </footer>
  <!-- /.control-sidebar -->
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>

</div>
<!-- ./wrapper -->

<!-- jQuery 3 -->
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/adminlte.min.js"></script>
<!-- Sparkline -->
<script src="bower_components/jquery-sparkline/dist/jquery.sparkline.min.js"></script>
<!-- jvectormap  -->
<script src="plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- SlimScroll -->
<script src="bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- ChartJS -->
<script src="bower_components/Chart.js/Chart.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="dist/js/pages/dashboard2.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="dist/js/demo.js"></script>
<script src="bower_components/ckeditor/ckeditor.js"></script>
<script>
  $(function () {
    // Replace the <textarea id="editor1"> with a CKEditor
    // instance, using default configuration.
    CKEDITOR.replace('editor1')
    //bootstrap WYSIHTML5 - text editor
    $('.textarea').wysihtml5()
  })
</script>
</body>
</html>
