<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">        
    <section class="content-header">
        <h1>
            ARTIKEL
            <small>Tulis Artikel Baru</small>
        </h1>            
    </section>

    <section class="content">
        <a href="<?php echo base_url('dashboard/artikel'); ?>" aria-label="Kembali" class="btn btn-sm btn-primary">
            <i class="fa fa-arrow-left"></i> Kembali
        </a>

        <br/><br/>

        <form method="post" action="<?php echo base_url('dashboard/artikel_aksi'); ?>" enctype="multipart/form-data" novalidate>
            <!-- CSRF Protection -->
            <input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>" />

            <!-- Simpan satker_id dari session -->
            <input type="hidden" name="satker_id" value="<?php echo $this->session->userdata('satker_id'); ?>">
<!-- Debugging -->
<p>Satker ID: <?php echo $this->session->userdata('satker_id'); ?></p>


            <div class="row">
                <div class="col-md-8">                            
                    <div class="box box-primary">                                
                        <div class="box-body">                                   
                            <div class="form-group">
                                <label>Judul</label>
                                <input type="text" name="judul" id="judul" class="form-control" placeholder="Masukkan judul artikel .." required value="<?php echo set_value('judul'); ?>">
                                <?php echo form_error('judul', '<div class="text-danger">', '</div>'); ?>
                            </div>

                            <div class="form-group">
                                <label>Konten</label>
                                <textarea id="editor1" name="konten" rows="10" cols="80" required><?php echo set_value('konten'); ?></textarea>
                                <?php echo form_error('konten', '<div class="text-danger">', '</div>'); ?>
                            </div>
                        </div>                                                        
                    </div>
                </div>

                <div class="col-md-4">
                    <div class="box box-primary">
                        <div class="box-body">
                            <div class="form-group">
                                <label>Kategori</label>
                                <select class="form-control" name="kategori" required>
                                    <option value="">- Pilih Kategori -</option>
                                    <?php foreach($kategori as $k): ?>
                                        <option value="<?php echo $k->kategori_id; ?>" <?php echo set_select('kategori', $k->kategori_id); ?>>
                                            <?php echo $k->kategori_nama; ?>
                                        </option>
                                    <?php endforeach; ?>
                                </select>
                                <?php echo form_error('kategori', '<div class="text-danger">', '</div>'); ?>
                            </div>

                            <div class="form-group">
                                <label>Gambar Sampul</label>
                                <input type="file" name="sampul" required>
                                <p class="help-block">Silakan upload Gambar...!</p>
                                <?php if(isset($gambar_error)): ?>
                                    <div class="text-danger"><?php echo $gambar_error; ?></div>
                                <?php endif; ?>
                                <?php echo form_error('sampul', '<div class="text-danger">', '</div>'); ?>
                            </div>

                            <!-- Progress Bar -->
                            <div class="progress progress-sm active">
                                <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;" id="progressBarArtikel">
                                    <span class="sr-only">0% Complete</span>
                                </div>
                            </div>

                            <input type="submit" name="status" value="Draft" class="btn btn-warning btn-block">
                            <input type="submit" name="status" value="Publish" class="btn btn-success btn-block">
                        </div>
                    </div>
                </div>
            </div>
        </form>   
    </section>
</div>
