<% layout('../layouts/main') -%>

<% script('https://cdn.ckeditor.com/4.11.1/full-all/ckeditor.js') %>

<% block('custom_scripts', `
<script>
  function goBack() {
    window.history.back();
  }

  $(function () {
  //Initialize Select2 Elements
  // $('.select2').select2()
  
  CKEDITOR.replace('description');
  })
</script>
`) %>

<% block('custom_style', `
<style>
    textarea {
        resize: none;
    }
</style>
`) %>

<!-- Content Header (Page header) -->
<section class="content-header">
  <h1>
    Add Hotel Description
    <!--<small>Preview</small>-->
  </h1>
  <ol class="breadcrumb">
    <li><a href="/dashboard"><i class="fa fa-dashboard"></i> Home</a></li>
    <li><a href="/hotels">Hotel</a></li>
    <li class="active">Add Hotel Description</li>
  </ol>
</section>

<!-- Main content -->
<section class="content">
  <% if (Object.prototype.hasOwnProperty.call(flash, 'success')) { %>
  <div class="alert alert-success alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <%= flash.success %>
  </div>
  <% } %>
  <% if (Object.prototype.hasOwnProperty.call(flash, 'error')) { %>
  <div class="alert alert-danger alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <%= flash.error %>
  </div>
  <% } %>
  <div class="box box-primary">
    <form role="form" class="has-validation-callback" method="POST">
      <div class="box-header with-border">
        <h3 class="box-title">New Description</h3>

        <!--<div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
            <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-remove"></i></button>
        </div>-->
      </div>
      <!-- /.box-header -->
      <div class="box-body">
        <div class="row">
          <div class="col-md-6">
            <div class="form-group ">
              <label for="hotel">Hotel</label>
              <!--<input type="password" class="form-control" id="exampleInputPassword1" placeholder="New Password">-->
              <input type="hidden" value="<%= hotel._id %>" name="hotel">
              <input value="<%= hotel.name || '' %>" id="hotel" class="form-control" placeholder="Hotel" type="text"
                readonly="readonly">
              <!--<span class="glyphicon glyphicon-lock form-control-feedback"></span>-->
              <% if (Object.prototype.hasOwnProperty.call(flash, 'errors_name')) { %>
              <h5 class="text-danger"><i class="fa fa-exclamation-triangle"></i>
                <%= flash.errors_name %>
              </h5>
              <% } %>
            </div>
          </div>
          <div class="form-group col-md-6">
            <label>Language</label>
            <select id="language" class="form-control select2" name="language" required>
              <% for(lidx in languages) { %>
              <option value="<%= languages[lidx]._id %>" <%- flash.data_language && flash.data_language.toString()==languages[lidx]._id.toString()
                ? 'selected="selected"' : '' %>>
                <%= languages[lidx].name %>
              </option>
              <%}%>
            </select>
            <% if (Object.prototype.hasOwnProperty.call(flash, 'errors_languages')) { %>
            <h5 class="text-danger"><i class="fa fa-exclamation-triangle"></i>
              <%= flash.errors_languages %>
            </h5>
            <% } %>
          </div>
          <div class="form-group col-md-12">
            <label>Description</label>
            <textarea name="description" id="description" class="form-control" placeholder="Enter description here..." rows="8" required><%= flash.data_description || '' %></textarea>
          </div>
        </div>
      </div>
      <!-- /.row -->
      <div class="box-footer">
        <div class="pull-left">
          <p class="text-success">
          </p>
        </div>
        <div class="pull-right">
          <a onclick="goBack();" class="btn btn-primary" role="button">Cancel</a>
          <input name="submit" value="Submit" class="btn btn-primary" type="submit">
        </div>
      </div>
      <!--<div class="box-footer">
          Visit <a href="https://select2.github.io/">Select2 documentation</a> for more examples and information about
          the plugin.
      </div>-->
    </form>
  </div>
  <!-- /.box -->
</section>
<!-- /.content -->