<style type="text/css">
  .tab-pane {
    padding: 10px 0;
  }
  .legend-title {
    margin-bottom: 30px;
  }
   .legend-title .title {
    background: #fff;
    font-size: 18px;
    position: relative;
    padding: 0 10px;
    bottom: -13px;
    color: #646464;
    text-decoration: underline;
   }
   .legend-title b {
    color: #6CA45B
   }
</style>
<script src="<?= BASE_ASSET; ?>/js/jquery.hotkeys.js"></script>

<script type="text/javascript">
//This page is a result of an autogenerated content made by running test.html with firefox.
function domo(){
 
   // Binding keys
   $('*').bind('keydown', 'Ctrl+a', function assets() {
       window.location.href = BASE_URL + '/administrator/permission/add';
       return false;
   });

   $('*').bind('keydown', 'Ctrl+s', function assets() {
       $('#btn_save').trigger('click');
       return false;
   });

   $('*').bind('keydown', 'Ctrl+x', function assets() {
        if ($('#btn_undo').is(":visible")) {
          $('#btn_undo').trigger('click');
        }
       return false;
   });
}

jQuery(document).ready(domo);
</script>
<!-- Content Header (Page header) -->
<section class="content-header">
   <h1>
      Pengaturan
      <small>Daftar Semua</small>
   </h1>
   <ol class="breadcrumb">
      <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
      <li class="active">Pengaturan</li>
   </ol>
</section>
<!-- Main content -->
<section class="content">
   <div class="row" >
      
      <div class="col-md-12">
         <div class="box box-primary">
            <div class="box-body ">
               <!-- Widget: user widget style 1 -->
               <div class="box box-widget widget-user-2">
                  <!-- Add the bg color to the header using any of the bg-* classes -->
                  <div class="widget-user-header ">
                     <div class="row pull-right">
                        
                     </div>
                     <div class="widget-user-image">
                        <img class="img-circle" src="<?= BASE_ASSET; ?>/img/list.png" alt="User Avatar">
                     </div>
                     <!-- /.widget-user-image -->
                     <h3 class="widget-user-username">Pengaturan</h3>
                     <h5 class="widget-user-desc">Pengaturan Web</h5>
                  </div>
                </div>

                    <div class="row-fluid">
                      <!-- Custom Tabs -->
                      <div class="nav-tabs-custom">
                        <ul class="nav nav-tabs">
                          <li class="active"><a href="#tab_general" class="tab_group" data-toggle="tab"><i class="fa fa-compass text-green"></i> Web</a></li>
                          <li class=""><a href="#tab_system" class="tab_group" data-toggle="tab"><i class="fa fa-tv text-green"></i> Sistem</a></li>
                       
                          
                        </ul>
                       <?= form_open('administrator/setting/save', [
                          'name'    => 'form_setting', 
                          'class'   => 'form-horizontal', 
                          'id'      => 'form_setting', 
                          'method'  => 'POST'
                        ]); ?>
                        <div class="tab-content">

                          <div class="tab-pane active" id="tab_general">
                            <div class="row">
                              <div class="col-md-6">
                                <div class="col-sm-12">
                                    <label>Nama Web <span class="required">*</span></label>
                                    <input type="text" class="form-control" name="site_name" id="site_name" value="<?= get_option('site_name'); ?>">
                                    <small class="info help-block">Nama website akan merubah seluruh identitas web.</small>
                                </div>

                                <div class="col-sm-12">
                                    <label>Deskripsi Web</label>
                                    <textarea type="text" class="form-control" name="site_description" id="site_description" ><?= get_option('site_description'); ?></textarea>
                                    <small class="info help-block">Deskripsi web akan merubah deskripsi website dan meta tags.</small>
                                </div>

                                <div class="col-sm-12">
                                      <label>Tema Default <span class="required">*</span></label>
                                      <div class="row">
                                        <div class="col-md-6 ">
                                          <select class="form-control" name="landing_page_id" id="landing_page_id">
                                              <option value="default" >Default (Design by Yuuki0)</option>
                                            <?php foreach ($pages as $page): ?>
                                              <option value="<?= $page->id; ?>" <?= $page->id == get_option('landing_page_id', 'default') ? 'selected' : ''; ?>><?= _ent($page->title); ?></option>
                                            <?php endforeach; ?>
                                          </select>
                                        </div>
                                      </div>
                                      <small class="info help-block">
                                         Menu ini hanya mencangkup tema halaman landing website.
                                      </small>
                                  </div>

                                <div class="col-sm-12">
                                    <label>Keywords</label>
                                    <textarea type="text" class="form-control" name="keywords" id="keywords" ><?= get_option('keywords'); ?></textarea>
                                    <small class="info help-block">Keywords membantu google memahami dan mempermudah pencarian website.</small>
                                </div>

                                <div class="col-sm-12">
                                    <label>Author</label>
                                    <input type="text" class="form-control" name="author" id="author" value="<?= get_option('author'); ?>" readonly>
                                    <small class="info help-block">Nama pembuat website.</small>
                                </div>

                                <div class="col-sm-12">
                                    <label>Email <span class="required">*</span></label>
                                    <input type="text" class="form-control" name="email" id="email"value="<?= get_option('email'); ?>" readonly>
                                    <small class="info help-block">Email pembuat website.</small>
                                </div>
                              </div>
                            </div>
                          </div>
                          <!-- /.tab-pane -->

                          <div class="tab-pane " id="tab_system">
                            <div class="row">
                              <div class="col-md-12">
                                 <div class="panel-group" id="accordion">
                                    <div class="panel panel-default">
                                      <div class="panel-heading">
                                        <h4 class="panel-title">
                                          <a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
                                          Pengaturan <b class="text-red">PHP Session</b><b> & </b><b class="text-green">Cookies</b></a>
                                        </h4>
                                      </div>
                                      <div id="collapse1" class="panel-collapse collapse in">
                                        <div class="panel-body">

                                        <!-- start content -->
                                        <div class="row col-md-6">
                                          <div class="col-sm-12">
                                              <label>Nama Session Cookie <span class="required">*</span></label>
                                              <input type="text" class="form-control" name="sess_cookie_name" id="sess_cookie_name" value="<?= $this->config->item('sess_cookie_name'); ?>">
                                              <small class="info help-block">
                                                Kalau menggunakan Encryption class, wajib mengatur encryption key
                                              </small>
                                          </div>             

                                          <div class="col-sm-12">
                                              <label>Masa Berakhir Session <span class="required">*</span></label>
                                              <div class="row">
                                                <div class="col-md-6 ">
                                                  <select class="form-control " name="sess_expiration" id="sess_expiration">
                                                    <?php foreach ($times as $time): ?>
                                                      <option value="<?= $time['value']; ?>" <?= $time['value'] == $this->config->item('sess_expiration') ? 'selected' : ''; ?>><?= $time['label']; ?></option>
                                                    <?php endforeach; ?>
                                                  </select>
                                                </div>
                                              </div>
                                              <small class="info help-block">
                                                 Masa sesi berakhir dihitung dalam satuan milidetik.
                                              </small>
                                          </div>    

                                          <div class="col-sm-12">
                                              <label>Masa Session Meminta Update <span class="required">*</span></label>
                                              <div class="row">
                                                <div class="col-md-6 ">
                                                  <select class="form-control" name="sess_time_to_update" id="sess_time_to_update">
                                                    <?php foreach ($times as $time): ?>
                                                      <option value="<?= $time['value']; ?>" <?= $time['value'] == $this->config->item('sess_time_to_update') ? 'selected' : ''; ?>><?= $time['label']; ?></option>
                                                    <?php endforeach; ?>
                                                  </select>
                                                </div>
                                              </div>
                                              <small class="info help-block">
                                                 Masa sesi meminta update dihitung dalam satuan milidetik.
                                              </small>
                                          </div>

                                          <div class="col-sm-12">
                                              <label>Nama Cookie Session <span class="required">*</span></label>
                                              <input type="text" class="form-control" name="sess_cookie_name" id="sess_cookie_name" value="<?= $this->config->item('sess_cookie_name'); ?>">
                                              <small class="info help-block">
                                                 Nama cookie yang ingin disimpan client.
                                              </small>
                                          </div>
                                        </div>
                                        <!-- end content -->
                                        </div>
                                      </div>
                                    </div>

                                    <div class="panel panel-default">
                                      <div class="panel-heading">
                                        <h4 class="panel-title">
                                          <a data-toggle="collapse" data-parent="#accordion" href="#collapse2">
                                          Konfigurasi <b class="text-yellow">CSRF</b></a>
                                        </h4>
                                      </div>
                                      <div id="collapse2" class="panel-collapse collapse">
                                        <div class="panel-body">
                                          <!-- start content -->
                                            <div class="row col-md-6">
                                            <div class="col-sm-12">
                                                <label>Nama Token CSRF <span class="required">*</span></label>
                                                <input type="text" class="form-control" name="csrf_token_name" id="csrf_token_name" value="<?= $this->config->item('csrf_token_name'); ?>">
                                                <small class="info help-block">
                                                   Nama token.
                                                </small>
                                            </div>             

                                            <div class="col-sm-12">
                                                <label>Nama Cookie CSRF <span class="required">*</span></label>
                                                <input type="text" class="form-control" name="csrf_cookie_name" id="csrf_cookie_name" value="<?= $this->config->item('csrf_cookie_name'); ?>">
                                                <small class="info help-block">
                                                   Nama cookie.
                                                </small>
                                            </div>    

                                            <div class="col-sm-12">
                                                <label>Masa Berakhir CSRF <span class="required">*</span></label>
                                                <div class="row">
                                                  <div class="col-md-6 ">
                                                    <select class="form-control" name="csrf_expire" id="csrf_expire">
                                                      <?php foreach ($times as $time): ?>
                                                        <option value="<?= $time['value']; ?>" <?= $time['value'] == $this->config->item('csrf_expire') ? 'selected' : ''; ?>><?= $time['label']; ?></option>
                                                      <?php endforeach; ?>
                                                    </select>
                                                  </div>
                                                </div>
                                                <small class="info help-block">
                                                   Nomor token harus memiliki waktu kedaluwarsa.
                                                </small>
                                            </div>    

                                            </div>
                                          <!-- end content -->
                                        </div>
                                      </div>
                                    </div>
                                    <div class="panel panel-default">
                                      <div class="panel-heading">
                                        <h4 class="panel-title">
                                          <a data-toggle="collapse" data-parent="#accordion" href="#collapse3">
                                          Konfigurasi <b class="text-orange">Lainnya</b></a>
                                        </h4>
                                      </div>
                                      <div id="collapse3" class="panel-collapse collapse">
                                        <div class="panel-body">
                                          <div class="row col-md-6">
                                            <!-- start content -->
                                              <div class="col-sm-12">
                                                  <label>Karakter URL yang Diizinkan </label>
                                                  <input type="text" class="form-control" name="permitted_uri_chars" id="permitted_uri_chars" value="<?= $this->config->item('permitted_uri_chars'); ?>">
                                                  <small class="info help-block">
                                                    Nilai yang dikonfigurasi adalah karakter ekspresi reguler dan dieksekusi sebagai: ! preg_match('/^[<permitted_uri_chars>]+$/i
                                                  </small>
                                              </div>

                                              <div class="col-sm-12">
                                                  <label>Akhiran URL </label>
                                                  <input type="text" class="form-control" name="url_suffix" id="url_suffix" value="<?= $this->config->item('url_suffix'); ?>">
                                                  <small class="info help-block">
                                                    Opsi ini untuk menambahkan akhiran ke semua URL yang dihasilkan.
                                                    <br> Contoh : https://example.com/post<b class="text-danger tip" title=".php adalah akhiran URL ">.php</b>
                                                  </small>
                                              </div>

                                              <div class="col-sm-12">
                                                  <label> Pemfilteran XSS Global <i class="required">*</i></label>
                                                  <div class="row">
                                                    <div class="col-md-6 ">
                                                      <select class="form-control" name="global_xss_filtering" id="global_xss_filtering" placeholder="Global XSS Filtering">
                                                      <?php
                                                      $global_xss_filtering = $this->config->item('global_xss_filtering');
                                                      ?>
                                                        <option value="TRUE" <?= $global_xss_filtering == TRUE ? 'selected' :'' ; ?>>YES</option>
                                                        <option value="FALSE" <?= $global_xss_filtering == FALSE ? 'selected' :'' ; ?>>NO</option>
                                                      </select>
                                                    </div>
                                                  </div>
                                                   <small class="info help-block">
                                                    Menentukan apakah filter XSS selalu aktif ketika data GET, POST atau COOKIE ditemukan
                                                  </small>
                                                </div>

                                              <div class="col-sm-12">
                                                  <label>Kunci Enskripsi <span class="required">*</span></label>
                                                  <input type="text" class="form-control" name="encryption_key" id="encryption_key" value="<?= $this->config->item('encryption_key'); ?>">
                                                  <small class="info help-block">
                                                    Jika menggunakan kelas enkripsi, wajib menetapkan kunci enkripsi.
                                                  </small>
                                              </div>
                                            <!-- end content -->
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div> 
                              </div>

                            </div>
                          </div>
                          <!-- end tab pane -->
                        </div>
                        <!-- /.tab-content -->
                      </div>
                      <!-- nav-tabs-custom -->
                    <div class="message no-message-padding">
                      
                    </div>
                        <?php is_allowed('setting_update', function(){?>
                        <button class="btn btn-flat btn-default btn_save btn_action" id="btn_save" data-stype='stay' title="Simpan (Ctrl+S)"><i class="fa fa-save" ></i> Simpan</button>
                        <?php }) ?>
                         <span class="loading loading-hide"><img src="<?= BASE_ASSET; ?>/img/loading-spin-primary.svg"> <i>Loading data</i></span>

                        <a class="btn btn-flat btn-default btn_undo" data-id="0" id="btn_undo" title="Kembalikan (Ctrl+X)" style="display: none;"><i class="fa fa-undo" ></i> Kembalikan</a>
                    <?= form_close(); ?>
                    </div>
                    <!-- /.col -->
               </div>
            </div>
            <!--/box body -->
         </div>
         <!--/box -->

      </div>
   </div>
</section>
<!-- /.content -->



<!-- Page script -->
<script>
  $(document).ready(function() {
     $('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
         checkboxClass: 'icheckbox_flat-green',
         radioClass: 'iradio_flat-green'
     });

     $('.btn_save').click(function() {
         $('.message').fadeOut();

         var form_setting = $('#form_setting');
         var data_post = form_setting.serialize();

         $('.loading').show();

         $.ajax({
                 url: BASE_URL + '/administrator/setting/save',
                 type: 'POST',
                 dataType: 'json',
                 data: data_post,
             })
             .done(function(res) {
                 if (res.success) {
                     $('.message').printMessage({
                         message: res.message
                     });
                     $('.message').fadeIn();
                     $('.btn_undo').hide();

                 } else {
                     $('.message').printMessage({
                         message: res.message,
                         type: 'warning'
                     });
                     $('.message').fadeIn();
                 }

             })
             .fail(function() {
                 $('.message').printMessage({
                     message: 'Gagal menyimpan data',
                     type: 'warning'
                 });
             })
             .always(function() {
                 $('.loading').hide();
                 $('html, body').animate({
                     scrollTop: $(document).height()
                 }, 1000);
             });

         return false;
     }); /*end btn save*/

 }); /*end doc ready*/
</script>