<!-- // created by : KuduSinau_Hendrik_081275532220 (TERIMAKASIH UNTUK MENDAPATKAN KEBERKAHAN, DENGAN TIDAK MERUBAH NAMA HAK CIPTA, PLAGIAT, DAN TIDAK MEMPERJUALBELIKAN APLIKASI INI, SEMOGA KITA SEMUA MENDAPAT MANFAAT DAN KEBERKAHAN DARI APLIKASI INI)
// created by : KuduSinau_Hendrik_081275532220 (UNTUK MASUKAN DAN SARAN SERTA PENGEMBANGAN BISA MENGHUBUNGI NOMOR) -->

<body class="materialdesign" onload="hide_loading();">
    <div class="loading overlay">
        <div class="lds-spinner">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
    <div class="wrapper-pro">
        <div class="content-inner-all">
            <div class="breadcome-area mg-b-30 small-dn">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="breadcome-list map-mg-t-40-gl shadow-reset">
                                <div class="row">
                                    <div class="col-lg-6">
                                        <font size="4">
                                            <strong><?= $Lembaga['sgkt_jenjang'] . ' ' . $Lembaga['nm_status'] . ' ' . ucwords(strtolower($Lembaga['nm_lembaga'])); ?></strong>
                                        </font>
                                    </div>
                                    <div class="col-lg-6 text-right">
                                        <?php foreach ($nmTapel as $tp) :
                                            if ($tp['sts_tapel'] == 1) {
                                        ?>
                                                <font size="4">
                                                    <span class="bread-blod">Semester <?= $tp['kd_smstr']; ?> | <?php if ($tp['kd_smstr'] == 'Ganjil') {
                                                                                                                    echo $tp['kd_tahun'] . '/' . ($tp['kd_tahun'] + 1);
                                                                                                                } elseif ($tp['kd_smstr'] == 'Genap') {
                                                                                                                    echo ($tp['kd_tahun'] - 1) . '/' . $tp['kd_tahun'];
                                                                                                                }; ?></span>
                                                </font>
                                        <?php }
                                        endforeach;
                                        ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="breadcome-area des-none mg-b-30">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            <div class="breadcome-list map-mg-t-40-gl shadow-reset">
                                <div class="row">
                                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                                        <font size="1">
                                            <strong><?= $Lembaga['sgkt_jenjang'] . ' ' . $Lembaga['nm_status'] . ' ' . ucwords(strtolower($Lembaga['nm_lembaga'])); ?></strong>
                                        </font>
                                    </div>
                                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6 text-right">
                                        <?php foreach ($nmTapel as $tp) :
                                            if ($tp['sts_tapel'] == 1) {
                                        ?>
                                                <font size="1">
                                                    <span class="bread-blod">Semester <?= $tp['kd_smstr']; ?> | <?php if ($tp['kd_smstr'] == 'Ganjil') {
                                                                                                                    echo $tp['kd_tahun'] . '/' . ($tp['kd_tahun'] + 1);
                                                                                                                } elseif ($tp['kd_smstr'] == 'Genap') {
                                                                                                                    echo ($tp['kd_tahun'] - 1) . '/' . $tp['kd_tahun'];
                                                                                                                }; ?></span>
                                                </font>
                                        <?php }
                                        endforeach;
                                        ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="data-table-area mg-b-15">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="sparkline13-list shadow-reset">
                                <div class="sparkline13-hd">
                                    <div class="main-sparkline13-hd">
                                        <h1><i class="fa fa-book"></i><b> Bidang Study</b></h1>
                                        <div class="sparkline13-outline-icon">
                                            <span class="sparkline13-collapse-link"><i class="fa fa-chevron-up"></i></span>
                                            <span><i class="fa fa-wrench"></i></span>
                                            <span class="sparkline13-collapse-close"><i class="fa fa-times"></i></span>
                                        </div>
                                    </div>
                                </div>
                                <div class="sparkline13-graph">
                                    <div id="flashsucces" data-flash="<?= $this->session->flashdata('messageSuccess'); ?>"></div>
                                    <div id="flashwarning" data-flash="<?= $this->session->flashdata('messageWarning'); ?>"></div>
                                    <div id="flashupdate" data-flash="<?= $this->session->flashdata('messageUpdate'); ?>"></div>
                                    <div id="flasherror" data-flash="<?= $this->session->flashdata('messageError'); ?>"></div>
                                    <div id="flashsave" data-flash="<?= $this->session->flashdata('messageSave'); ?>"></div>
                                    <div class="mail-title inbox-bt-mg">
                                        <div class="view-mail-action view-mail-ov-d-n">
                                            <?php if ($cekTapel > 0) {
                                                if ($jumlahsts > 0) {
                                                    if ($cekMapel > 0) { ?>
                                                        <a class="compose-draft-bt" href="#" data-toggle="modal" data-target="#TambahMapel"><i class="fa fa-plus-circle"></i> Add New Data</a>
                                                    <?php } else { ?>
                                                        <a class="compose-discard-bt" href="#" data-toggle="modal" data-target="#AmbilBidangStudy"><i class="fa fa-plus-circle"></i> Ambil Bidang Study</a>
                                            <?php }
                                                } else {
                                                    $this->session->set_flashdata('messageWarning', 'Silahkan Aktifkan data tahun pelajaran dan semester terlebih dahulu !');
                                                    redirect('admin/tapel');
                                                }
                                            } else {
                                                $this->session->set_flashdata('messageWarning', 'Silahkan tambah data tahun pelajaran terlebih dahulu !');
                                                redirect('admin/tapel');
                                            } ?>
                                        </div>
                                    </div>
                                    <div id="TambahMapel" class="modal modal-adminpro-general default-popup-PrimaryModal fade" role="dialog">
                                        <form action="<?= base_url('admin/tambahDataMapel'); ?>" method="post">
                                            <div class="modal-dialog">
                                                <div class="modal-content">
                                                    <div class="modal-header header-color-modal bg-color-1">
                                                        <h4 class="modal-title">Form Tambah Data Bidang Study</h4>
                                                        <div class="modal-close-area modal-close-df">
                                                            <a class="close" data-dismiss="modal" href="#"><i class="fa fa-close"></i></a>
                                                        </div>
                                                    </div>
                                                    <div class="modal-body">
                                                        <div class="sparkline11-graph">
                                                            <div class="row">
                                                                <div class="col-lg-3">
                                                                    <label class="login2 pull-right pull-right-pro">Kode</label>
                                                                </div>
                                                                <div class="col-lg-9">
                                                                    <select name='nm_kdbidstudy' id='nm_kdbidstudy' class="chosen-select" tabindex="-1">
                                                                        <option disabled selected>Pilih Kode Bidang Study</option>
                                                                        <?php foreach ($nmKdbidstudy as $kdstd) : ?>
                                                                            <option value='<?= $kdstd['nm_kdbidstudy'] ?>'><?= $kdstd['nm_kdbidstudy'] ?></option>
                                                                        <?php endforeach; ?>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <?= form_error('nm_kdbidstudy', '<small class="text-danger">', '</small>'); ?>
                                                        </div>
                                                        <div class="sparkline11-graph">
                                                            <div class="row">
                                                                <div class="col-lg-3">
                                                                    <label class="login2 pull-right pull-right-pro">Kategori</label>
                                                                </div>
                                                                <div class="col-lg-9">
                                                                    <select name='nm_kategori' id='nm_kategori' class="chosen-select" tabindex="-1">
                                                                        <option disabled selected>Pilih Kategori Bidang Study</option>
                                                                        <?php foreach ($nmKategori as $ktgr) : ?>
                                                                            <option value='<?= $ktgr['nm_kategori'] ?>'><?= $ktgr['nm_kategori'] ?></option>
                                                                        <?php endforeach; ?>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <?= form_error('nm_kategori', '<small class="text-danger">', '</small>'); ?>
                                                        </div>
                                                        <div class="sparkline11-graph">
                                                            <div class="row">
                                                                <div class="col-lg-3">
                                                                    <label class="login2 pull-right pull-right-pro">Kelompok</label>
                                                                </div>
                                                                <div class="col-lg-9">
                                                                    <select name='nm_kelompok' id='nm_kelompok' class="chosen-select" tabindex="-1">
                                                                        <option disabled selected>Pilih Kelompok Bidang Study</option>
                                                                        <?php foreach ($nmKelmapel as $km) : ?>
                                                                            <option value='<?= $km['nm_kelompok'] ?>'><?= $km['nm_kelompok'] ?></option>
                                                                        <?php endforeach; ?>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <?= form_error('nm_kelompok', '<small class="text-danger">', '</small>'); ?>
                                                        </div>
                                                        <div class="sparkline11-graph">
                                                            <div class="row">
                                                                <div class="col-lg-3">
                                                                    <label class="login2 pull-right pull-right-pro">Nama</label>
                                                                </div>
                                                                <div class="col-lg-9">
                                                                    <select name='nm_nmbidstudy' id='nm_nmbidstudy' class="chosen-select" tabindex="-1">
                                                                        <option disabled selected>Pilih Namak Bidang Study</option>
                                                                        <?php foreach ($NamaBidstudy as $Nb) : ?>
                                                                            <option value='<?= $Nb['nm_nmbidstudy'] ?>'><?= $Nb['nm_nmbidstudy'] ?></option>
                                                                        <?php endforeach; ?>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                            <?= form_error('nm_nmbidstudy', '<small class="text-danger">', '</small>'); ?>
                                                        </div>
                                                    </div>
                                                    <div class="modal-footer">
                                                        <div class="form-group-inner">
                                                            <div class="login-btn-inner">
                                                                <div class="row">
                                                                    <div class="col-lg-3"></div>
                                                                    <div class="col-lg-9">
                                                                        <div class="login-horizental cancel-wp pull-right">
                                                                            <button type='reset' data-dismiss='modal' class="btn btn-sm btn-white">Cancel</button>
                                                                            <button class="btn btn-sm btn-primary" type="submit">Add New</button>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                    <div id="AmbilBidangStudy" class="modal modal-adminpro-general default-popup-PrimaryModal PrimaryModal-bgcolor fade" role="dialog">
                                        <form action="<?= base_url('admin/tambahAllDataMapel'); ?>" method="post" name="autoSumForm">
                                            <div class="modal-dialog">
                                                <div class="modal-content">
                                                    <div class="modal-close-area modal-close-df">
                                                        <a class="close" data-dismiss="modal" href="#"><i class="fa fa-close"></i></a>
                                                    </div>
                                                    <div class="modal-body">
                                                        <input type="hidden" class="form-control" id="jenjang" name="jenjang" placeholder="Jenjang" value='<?= $nmUser['kd_jenjang']; ?>'>
                                                        <i class="fa fa-question modal-check-pro"></i>
                                                        <h2>Apakah anda yakin ?</h2>
                                                        <p>Silahkan klik tombol proses <br>untuk memproses ambil data bidang study !</p>
                                                    </div>
                                                    <div class="modal-footer footer-modal-admin">
                                                        <button type='reset' data-dismiss='modal' class="btn btn-sm btn-white">Cancel</button>
                                                        <button class="btn btn-sm btn-danger" type="submit">Proses</button>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                    <div class=" datatable-dashv1-list custom-datatable-overright">
                                        <table id="table" data-toggle="table" data-pagination="true" data-search="true" data-show-columns="false" data-show-pagination-switch="true" data-show-refresh="true" data-key-events="true" data-show-toggle="true" data-resizable="true" data-cookie="true" data-cookie-id-table="saveId" data-show-export="false" data-click-to-select="true" data-toolbar="#toolbar">
                                            <thead>
                                                <tr>
                                                    <th data-field="state" data-checkbox="true"></th>
                                                    <th data-field="Nomor">No.</th>
                                                    <th data-field="Kode">Kode</th>
                                                    <th data-field="kategori">Kategori</th>
                                                    <th data-field="Kelompok">Kelompok</th>
                                                    <th data-field="Nama">Nama</th>
                                                    <th data-field="Edit"></th>
                                                    <th data-field="Delete"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php $i = 1;
                                                foreach ($nmBidstudy as $study) :
                                                    if ($study['kd_lembaga'] == $nmLembaga['id_lembaga']) {
                                                        if ($study['kd_tapel'] == $kdTapel) { ?>
                                                            <tr>
                                                                <td></td>
                                                                <td align="center"><?= $i;
                                                                                    $i++; ?></td>
                                                                <td><?= $study['nm_kdbidstudy']; ?></td>
                                                                <td><?= $study['nm_kategori']; ?></td>
                                                                <td><?= $study['nm_kelompok']; ?></td>
                                                                <td><?= $study['nm_nmbidstudy']; ?></td>
                                                                <td align="center">
                                                                    <a href="#" data-toggle="modal" data-target="#EditMapel<?= $study['id_bidstudy']; ?>">
                                                                        <div class="label label-warning"><i class=" fa fa-edit"></i> Edit</div>
                                                                    </a>
                                                                    <a href='<?= base_url('admin/hapusDataMapel/' . $study['id_bidstudy']); ?>' id='btn-hapus-mapel'>
                                                                        <div class="label label-danger"><i class=" fa fa-trash"></i> Delete</div>
                                                                    </a>
                                                                </td>
                                                            </tr>
                                                    <?php }
                                                    } ?>
                                                    <div id="EditMapel<?= $study['id_bidstudy']; ?>" class="modal modal-adminpro-general Customwidth-popup-WarningModal fade" role="dialog">
                                                        <form action="<?= base_url('admin/updateDataMapel'); ?>" method="post">
                                                            <div class="modal-dialog">
                                                                <div class="modal-content">
                                                                    <div class="modal-header header-color-modal bg-color-3">
                                                                        <h4 class="modal-title">Form Update Data Bidang Study</h4>
                                                                        <div class="modal-close-area modal-close-df">
                                                                            <a class="close" data-dismiss="modal" href="#"><i class="fa fa-close"></i></a>
                                                                        </div>
                                                                    </div>
                                                                    <div class="modal-body">
                                                                        <?php
                                                                        $nmBstudy = $this->db->get_where('t_bidstudy', ['id_bidstudy' => $study['id_bidstudy']])->result();
                                                                        foreach ($nmBstudy as $edit) : ?>
                                                                            <div class="sparkline11-graph">
                                                                                <div class="row">
                                                                                    <div class="col-lg-3">
                                                                                    </div>
                                                                                    <div class="col-lg-9">
                                                                                        <input type="hidden" class="form-control" id="id_bidstudy" name="id_bidstudy" placeholder="Nama Ekstrakurikuler" value='<?= $study['id_bidstudy']; ?>'>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="sparkline11-graph">
                                                                                <div class="row">
                                                                                    <div class="col-lg-3">
                                                                                        <label class="login2 pull-right pull-right-pro">Kode</label>
                                                                                    </div>
                                                                                    <div class="col-lg-9">
                                                                                        <select name="nm_kdbidstudy" id="nm_kdbidstudy" class="chosen-select" tabindex="-1">
                                                                                            <option disabled selected>Pilih Kode Bidang Study</option>
                                                                                            <?php
                                                                                            foreach ($nmKdbidstudy as $kb) : {
                                                                                                    $new = $kb['nm_kdbidstudy'];
                                                                                                    if ($edit->nm_kdbidstudy == $new) {
                                                                                                        $select = "selected";
                                                                                                    } else {
                                                                                                        $select = "";
                                                                                                    }
                                                                                                    echo "<option $select>" . $kb['nm_kdbidstudy'] . "</option>";
                                                                                                }
                                                                                            endforeach; ?>
                                                                                        </select>
                                                                                    </div>
                                                                                </div>
                                                                                <?= form_error('nm_kdbidstudy', '<small class="text-danger">', '</small>'); ?>
                                                                            </div>
                                                                            <div class="sparkline11-graph">
                                                                                <div class="row">
                                                                                    <div class="col-lg-3">
                                                                                        <label class="login2 pull-right pull-right-pro">Kategori</label>
                                                                                    </div>
                                                                                    <div class="col-lg-9">
                                                                                        <select name="nm_kategori" id="nm_kategori" class="chosen-select" tabindex="-1">
                                                                                            <option disabled selected>Pilih Kategori Bidang Study</option>
                                                                                            <?php
                                                                                            foreach ($nmKategori as $kds) : {
                                                                                                    if ($edit->nm_kategori == $kds['nm_kategori']) {
                                                                                                        $select = "selected";
                                                                                                    } else {
                                                                                                        $select = "";
                                                                                                    }
                                                                                                    echo "<option $select>" . $kds['nm_kategori'] . "</option>";
                                                                                                }
                                                                                            endforeach; ?>
                                                                                        </select>
                                                                                    </div>
                                                                                </div>
                                                                                <?= form_error('nm_kategori', '<small class="text-danger">', '</small>'); ?>
                                                                            </div>
                                                                            <div class="sparkline11-graph">
                                                                                <div class="row">
                                                                                    <div class="col-lg-3">
                                                                                        <label class="login2 pull-right pull-right-pro">Kelompok</label>
                                                                                    </div>
                                                                                    <div class="col-lg-9">
                                                                                        <select name="nm_kelompok" id="nm_kelompok" class="chosen-select" tabindex="-1">
                                                                                            <option disabled selected>Pilih Kelompok Bidang Study</option>
                                                                                            <?php
                                                                                            foreach ($nmKelmapel as $km) : {
                                                                                                    if ($edit->nm_kelompok == $km['nm_kelompok']) {
                                                                                                        $select = "selected";
                                                                                                    } else {
                                                                                                        $select = "";
                                                                                                    }
                                                                                                    echo "<option $select>" . $km['nm_kelompok'] . "</option>";
                                                                                                }
                                                                                            endforeach; ?>
                                                                                        </select>
                                                                                    </div>
                                                                                </div>
                                                                                <?= form_error('nm_kelompok', '<small class="text-danger">', '</small>'); ?>
                                                                            </div>
                                                                            <div class="sparkline11-graph">
                                                                                <div class="row">
                                                                                    <div class="col-lg-3">
                                                                                        <label class="login2 pull-right pull-right-pro">Nama</label>
                                                                                    </div>
                                                                                    <div class="col-lg-9">
                                                                                        <select name="nm_nmbidstudy" id="nm_nmbidstudy" class="chosen-select" tabindex="-1">
                                                                                            <option disabled selected>Pilih Nama Bidang Study</option>
                                                                                            <?php
                                                                                            foreach ($NamaBidstudy as $km) : {
                                                                                                    if ($edit->nm_nmbidstudy == $km['nm_nmbidstudy']) {
                                                                                                        $select = "selected";
                                                                                                    } else {
                                                                                                        $select = "";
                                                                                                    }
                                                                                                    echo "<option $select>" . $km['nm_nmbidstudy'] . "</option>";
                                                                                                }
                                                                                            endforeach; ?>
                                                                                        </select>
                                                                                    </div>
                                                                                </div>
                                                                                <?= form_error('nm_nmbidstudy', '<small class="text-danger">', '</small>'); ?>
                                                                            </div>
                                                                        <?php endforeach; ?>
                                                                    </div>
                                                                    <div class="modal-footer">
                                                                        <div class="form-group-inner">
                                                                            <div class="login-btn-inner">
                                                                                <div class="row">
                                                                                    <div class="col-lg-3"></div>
                                                                                    <div class="col-lg-9">
                                                                                        <div class="login-horizental cancel-wp pull-right">
                                                                                            <button type='reset' data-dismiss='modal' class="btn btn-sm btn-white">Cancel</button>
                                                                                            <button class="btn btn-sm btn-warning" type="submit">Update</button>
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </form>
                                                    </div>
                                                <?php endforeach; ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>