<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
<!DOCTYPE html>
<html>
  <head>
    <title>Admin &gt; Blog &gt; Edit Posting</title>
    <?php include_once(VIEWPATH. 'includes/head.php'); ?>
    <link href="<?php echo base_url('assets/css/summernote.css');?>" rel="stylesheet"/>
    <style type="text/css">.note-group-select-from-files{display: none;}</style>
  </head>
  <body>
    <?php include_once(VIEWPATH. 'admin/_navbar.php'); ?>
    <div class="container">
      <ul class="breadcrumb">
        <li><a href="<?php echo site_url();?>"><i class="fa fa-home"></i></a></li>
        <li><a href="<?php echo site_url('admin');?>">Admin Panel</a></li>
        <li><a href="<?php echo site_url('admin/modules/blog');?>">Blog</a></li>
        <li class="active"><span>Edit Posting</span></li>
      </ul>
      <div class="row">
        <div class="col-sm-4 col-md-3">
          <?php include(dirname(__FILE__).'/_sidebar.php');?>
        </div>
        <div class="col-sm-8 col-md-9">
          <div class="panel panel-default">
            <div class="panel-heading">
              <h3><i class="fa fa-edit"></i> Edit Posting</h3>
            </div>
            <div class="panel-body">
              <?php echo form_open(current_url(),'id="form1"');?>
                <div class="form-group">
                  <label>Judul</label>
                  <input type="text" class="form-control" name="judul" id="judul" value="<?php echo set_value('judul',$post->bp_judul);?>" maxlength="120" required="required"/>
                </div>
                <div class="form-group">
                  <label>URL</label>
                  <div class="input-group">
                    <span class="input-group-addon"><?php echo site_url('blog/');?></span>
                    <input type="text" class="form-control" name="slug" id="slug" value="<?php echo set_value('slug',$post->bp_slug);?>" maxlength="120" disabled="disabled"/>
                  </div>
                </div>
                <div class="form-group">
                  <label>Deskripsi</label>
                  <div id="summernote"><?php echo html_entity_decode(set_value('deskripsi',$post->bp_deskripsi));?></div>
                  <textarea class="form-control" style="display: none;" id="deskripsi" name="deskripsi" rows="18"><?php echo set_value('deskripsi',$post->bp_deskripsi);?></textarea>
                </div>
                <div class="form-group">
                  <label>Kategori</label>
                  <div>
                    <?php foreach ($categories as $category):?>
                    <div class="checkbox-inline">
                      <label><input type="checkbox" name="kategori[]" value="<?php echo $category->bk_id;?>" <?php echo (in_array($category->bk_id, $post_category) ? ' checked="checked"' : '');?>/> <?php echo html_escape($category->bk_nama);?></label>
                    </div>
                    <?php endforeach;?>
                  </div>
                </div>
                <div class="form-group">
                  <label>Ijinkan komentar</label>
                  <div>
                    <div class="radio-inline">
                      <label><input type="radio" name="ijinkan_komentar" value="1" <?php echo set_radio('ijinkan_komentar','1', $post->bp_allow_comment ? true : false);?>/> Ya</label>
                    </div>
                    <div class="radio-inline">
                      <label><input type="radio" name="ijinkan_komentar" value="0" <?php echo set_radio('ijinkan_komentar','0', !$post->bp_allow_comment ? true : false);?>/> Tidak</label>
                    </div>
                  </div>
                </div>
                <div>
                  <button class="btn btn-primary" id="submit" type="submit">Simpan</button>
                </div>
              <?php echo form_close();?>
            </div>
          </div>
        </div>
      </div>
    </div>
    <?php include_once(VIEWPATH.'includes/foot.php'); ?>
    <script src="<?php echo base_url('assets/js/summernote.min.js');?>"></script>
    <script>
    $(document).ready(function() {
        $('#summernote').summernote({
            height: 300,
            minHeight: null,
            maxHeight: null,
            focus: false
        });
        $("#submit").click(function(){
            $("#deskripsi").text($('#summernote').summernote('code'));
            $("#form1").submit();
        })
    });
    </script>
  </body>
</html>