<?php
$post->id = $_GET[id];
$p = $post->post();
?>
<div class="page-content">
    <div class="row">
        <div class="col-xs-12">
            <div class="page-header">
                <h1>
                    Data Post
                    <small>
                        <i class="ace-icon fa fa-angle-double-right"></i>
                        Edit Post
                    </small>
                </h1>
            </div><!-- /.page-header -->
        </div>
        <form class="form-horizontal" role="form" action="view/view/modul/mod_post/aksi_post.php?aksi=edit" method="post" enctype="multipart/form-data" >
            <input type="hidden" name="id" value="<?php echo $_GET[id]; ?>">
            <input type="hidden" name="gambar_post" value="<?php echo $p[gambar]; ?>">
            <input type="hidden" name="publish" value="<?php echo $p[publish]; ?>">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Judul </label>
                    <div class="col-sm-9">
                        <input type="text" id="form-field-1" placeholder="Judul" name="judul" class="col-xs-10 col-sm-5" value="<?php echo $p[judul]; ?>" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Isi </label>
                    <div class="col-sm-9">
                        <textarea id="myTextarea" name="isi"><?php echo $p[isi]; ?></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Keterangan </label>
                    <div class="col-sm-9">
                        <textarea id="form-field-1" placeholder="Keterangan" name="keterangan" class="col-xs-10 col-sm-5"><?php echo $p[keterangan]; ?></textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Kategori </label>
                    <div class="col-sm-9">
                        <select id="form-field-select-1" class="col-xs-10 col-sm-5" name="kategori">
                            <?php
                                $k = $kategori->listkategoripost();

                                while($i<count($k)){
                                    if ($k[$i][id]==$p[id_kategori]) {
                                        ?>
                                        <option value="<?php echo $k[$i][id]; ?>" selected><?php echo $k[$i][nama]; ?></option>
                                        <?php
                                    }else{
                                       ?>
                                        <option value="<?php echo $k[$i][id]; ?>"><?php echo $k[$i][nama]; ?></option>
                                        <?php
                                    }
                                    $i++;
                                }
                                unset($i);
                            ?>
                        </select>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Gambar </label>
                <div class="col-sm-4">
                    <input type="file" id="id-input-file-2" placeholder="gambar" name='gambar' /><p>*isi apabila ingin merubah gambar</p><br />
                    <img src="<?php echo $db->link(); ?>view/assets/img/post/<?php echo"".$p[gambar].""; ?>" width=150>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="clearfix form-actions">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="submit" name="key" value="2">
                            <i class="ace-icon fa fa-check bigger-110"></i>
                            Simpan
                        </button>
                        &nbsp; &nbsp; &nbsp;
                        <button class="btn btn-info" type="submit" name="key" value="1">
                            <i class="ace-icon fa fa-check bigger-110"></i>
                            Post
                        </button>
                        &nbsp; &nbsp; &nbsp;
                        <a href="index.php?module=post">
                            <button class="btn" type="button">
                                <i class="ace-icon fa fa-undo bigger-110"></i>
                                Cancel
                            </button>
                        </a>
                    </div>
                </div>
            </div>                           
        </form>
    </div><!-- /.row -->
</div><!-- /.page-content -->