<?php
error_reporting(0);
session_start();
include 'config/database.php';
$k_title = '';
$k_text = '';
$k_id = '';
if(isset($_POST['k_text'])){
	$k_id = htmlentities($_POST['k_id']);
	$k_title = htmlentities($_POST['k_title']);
	$k_text = htmlentities($_POST['k_text']);
	update_keynote($k_id,$k_title,$k_text);
	header('location: keynote.php');
}else{
	if(isset($_GET['kid'])){
		$data = get_keynote_item(trim($_GET['kid']));
		foreach ($data as $key => $value):
			$k_id = $value['k_id'];
			$k_title = $value['k_title'];
			$k_text  = html_entity_decode($value['k_text']);
		endforeach; 	
	}else{
		exit();
	}
?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote-bs4.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<style type="text/css">
/* Material design styling */

/*placeholder style*/
.note-placeholder {
  position: absolute;
  top: 20%;
  left: 5%;
  font-size: 2rem;
  color: #e4e5e7;
  pointer-events: none;
}
/*Toolbar panel*/
.note-editor .note-toolbar {
  background: #f0f0f1;
  border-bottom: 1px solid #c2cad8;
  -webkit-box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.14), 0 3px 4px 0 rgba(0, 0, 0, 0.12), 0 1px 5px 0 rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.14), 0 3px 4px 0 rgba(0, 0, 0, 0.12), 0 1px 5px 0 rgba(0, 0, 0, 0.2);
}
/*Buttons from toolbar*/
.summernote .btn-group, .popover-content .btn-group {
  background: transparent;
  -webkit-box-shadow: none;
  box-shadow: none;
}
.note-popover {
  background: #f0f0f1!important;
}
.summernote .btn, .note-btn {
  color: rgba(0, 0, 0, .54)!important;
  background-color: transparent!important;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.42857;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-box-shadow: none;
  box-shadow: none;
}
.summernote .dropdown-toggle:after {
  vertical-align: middle;
}
.note-editor.card {
  -webkit-box-shadow: none;
  box-shadow: none;
  border-radius: 2px;
}
/* Border of the Summernote textarea */
.note-editor.note-frame {
  border: 1px solid rgba(0, 0, 0, .14);
}
/* Padding of the text in textarea */
.note-editor.note-frame .note-editing-area .note-editable {
  padding-top: 1rem;
}
</style>
	<nav class="navbar navbar-light bg-light">
	    <a href='http://at-mybot.me:8000/index.php' class="navbar-brand">@MYBOT</a>
		<ul class="navbar-nav">
			<li class="nav-item">
				<a class="nav-link" href="index.php">หน้าแรก</a>
			</li>
		</ul>
		<span class="form-inline">
			<a class="nav-link" href="list.php">รายชื่อกลุ่ม</a>
		</span>
	</nav>
<div class="container">
  <div class="row">
    <div class="col">
      <div class="jumbotron my-4">
        <form action="keynote_update.php" enctype="multipart/form-data" method="post" class="summernote">
           <h3>NOTE</h3>
           <input type="hidden" name="k_id" value="<?php echo $k_id;?>">
           <input type="text" name="k_title" class="form-control" value="<?php echo $k_title;?>">
           <br>
           <textarea id="my-summernote" name="k_text" ><?php echo $k_text;?></textarea>
           <br>
           <button type="submit" class="btn btn-primary">บันทึก</button>
        </form>
      </div>
    </div>
  </div>
</div>


<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote-bs4.min.js"></script>
<script type="text/javascript">
$('#my-summernote').summernote({
  minHeight: 300,
  placeholder: 'ข้อความที่ต้องการ.....',
  focus: false,
  airMode: false,
  fontNames: ['Roboto', 'Calibri', 'Times New Roman', 'Arial'],
  fontNamesIgnoreCheck: ['Roboto', 'Calibri'],
  dialogsInBody: true,
  dialogsFade: true,
  disableDragAndDrop: false,
  toolbar: [
    // [groupName, [list of button]]
    //['style', ['bold', 'italic', 'underline', 'clear']],
    //['para', ['style', 'ul', 'ol', 'paragraph']],
    //['fontsize', ['fontsize']],
    //['font', ['strikethrough', 'superscript', 'subscript']],
    //['height', ['height']],
   // ['misc', ['undo', 'redo', 'print', 'help', 'fullscreen']]
  ],
  popover: {
    air: [
    //  ['color', ['color']],
    //  ['font', ['bold', 'underline', 'clear']]
    ]
  },
  print: {
    //'stylesheetUrl': 'url_of_stylesheet_for_printing'
  }
});

</script>


<?php } ?>