<!-- // 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><?= $nmJenjang['sgkt_jenjang'] . ' ' . $nmStatus['nm_status'] . ' ' . ucwords(strtolower($nmLembaga['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']; ?> | <?= $tp['kd_tahun']; ?>/<?= $tp['kd_tahun'] + 1; ?></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><?= $nmJenjang['sgkt_jenjang'] . ' ' . $nmStatus['nm_status'] . ' ' . ucwords(strtolower($nmLembaga['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']; ?> | <?= $tp['kd_tahun']; ?>/<?= $tp['kd_tahun'] + 1; ?></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-cogs"></i><b> Rombongan Belajar Siswa</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>
                                    <?php if ($cekTapel > 0) {
                                        if ($jumlahsts > 0) { ?>
                                            <a class="btn btn-primary" href="#" data-toggle="modal" data-target="#TambahRombelSiswa"><i class="fa fa-plus-circle"></i> Add New Data</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 id="TambahRombelSiswa" class="modal modal-adminpro-general default-popup-PrimaryModal fade" role="dialog">
                                        <form action="<?= base_url('admin/tambahDataRombelSiswa'); ?>" 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 Rombongan Belajar Siswa</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-12">
                                                                    <label class="login2 pull-left pull-left-pro">Nama Rombel</label>
                                                                </div>
                                                                <div class="col-lg-12">
                                                                    <select data-placeholder="Rombel" class="chosen-select" tabindex="-1" name='kd_kelas' id='kd_kelas'>
                                                                        <option disabled selected>Pilih Nama Rombel</option>
                                                                        <?php foreach ($kelas as $study) :  if (($nmUser['kd_user'] == $study['kd_lembaga']) && ($study['kd_tapel'] == $kdTapel)) { ?>
                                                                                <option value='<?= $study['id_kelas'] ?>'><?= $study['nm_rombel'] ?></option>
                                                                        <?php }
                                                                        endforeach; ?>
                                                                        <?= form_error('kd_kelas', '<small class="text-danger">', '</small>'); ?>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="sparkline11-graph">
                                                            <div class="row">
                                                                <div class="col-lg-12">
                                                                    <label class="login2 pull-left pull-left-pro">Nama Students</label>
                                                                </div>
                                                                <div class="col-lg-12">
                                                                    <select data-placeholder="Pilih students sesuai rombel" class="chosen-select" multiple="" tabindex="-1" name='kd_students[]' id='kd_students'>
                                                                        <?php foreach ($siswa as $study) :  if ($nmUser['kd_user'] == $study['kd_lembaga']) { ?>
                                                                                <option value='<?= $study['id_students'] ?>'><?= $study['nisn_students'] . ' : ' . $study['nm_students'] ?></option>
                                                                        <?php }
                                                                        endforeach; ?>
                                                                        <?= form_error('kd_students', '<small class="text-danger">', '</small>'); ?>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="modal-footer">
                                                        <div class="form-group-inner">
                                                            <div class="login-btn-inner">
                                                                <div class="row">
                                                                    <div class="col-lg-12">
                                                                        <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 class=" datatable-dashv1-list custom-datatable-overright">
                                        <div id="toolbar">
                                        </div>
                                        <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">Tahun Pelajaran</th>
                                                    <th data-field="tp">Semester</th>
                                                    <th data-field="smstr">Rombel</th>
                                                    <th data-field="nisn">NISN</th>
                                                    <th data-field="nislokal">NISM Lokal</th>
                                                    <th data-field="tgl">Nama Students</th>
                                                    <th data-field="Edit"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php $i = 1;
                                                foreach ($dtRombel as $study) :
                                                    if ($study['kdl'] == $nmLembaga['id_lembaga']) {
                                                        if ($study['kdt'] == $kdTapel) { ?>
                                                            <tr>
                                                                <td></td>
                                                                <td align="center"><?= $i;
                                                                                    $i++; ?></td>
                                                                <td><?= $newkdTapel['kd_tahun'] . ' / ' . ($newkdTapel['kd_tahun'] + 1); ?></td>
                                                                <td><?= $newkdTapel['kd_smstr']; ?></td>
                                                                <td><?= $study['kelas']; ?></td>
                                                                <td><?php
                                                                    foreach ($siswa as $std) :
                                                                        if ($study['kdsiswa'] == $std['id_students']) {
                                                                            echo $std['nisn_students'];
                                                                    ?></td>
                                                                <td><?php
                                                                            echo $std['nislokal_students'];
                                                                    ?></td>
                                                                <td><?php
                                                                            echo $std['nm_students'];
                                                                        }
                                                                    endforeach;
                                                                    ?></td>
                                                                <td align="center">
                                                                    <a href="#" data-toggle="modal" data-target="#EditMapel<?= $study['idr']; ?>">
                                                                        <div class="label label-warning"><i class=" fa fa-edit"></i> Edit</div>
                                                                    </a>
                                                                    <a href='<?= base_url('admin/hapusDataRombelSiswa/' . $study['idr']); ?>' id='btn-hapus'>
                                                                        <div class="label label-danger"><i class=" fa fa-trash"></i> Delete</div>
                                                                    </a>
                                                                </td>
                                                            </tr>
                                                    <?php }
                                                    }
                                                    ?>
                                                    <div id="EditMapel<?= $study['idr']; ?>" class="modal modal-adminpro-general Customwidth-popup-WarningModal fade" role="dialog">
                                                        <form action="<?= base_url('admin/updateDataRombelSiswa'); ?>" 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
                                                                        $tes = $this->db->get_where('t_rombelsiswa', ['id_rombelsiswa' => $study['idr']])->result();
                                                                        foreach ($tes as $edit) : ?>
                                                                            <div class="form-group-inner">
                                                                                <div class="row">
                                                                                    <div class="col-lg-3">
                                                                                    </div>
                                                                                    <div class="col-lg-9">
                                                                                        <input type="hidden" class="form-control" id="id_rombelsiswa" name="id_rombelsiswa" placeholder="Id Kelas Rombel" value='<?= $study['idr']; ?>'>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="sparkline11-graph">
                                                                                <div class="row">
                                                                                    <div class="col-lg-12">
                                                                                        <label class="login2 pull-left pull-left-pro">Nama Rombel</label>
                                                                                    </div>
                                                                                    <div class="col-lg-12">
                                                                                        <div class="chosen-select-single">
                                                                                            <select data-placeholder="Rombel" class="chosen-select" tabindex="-1" name='kd_kelas' id='kd_kelas'>
                                                                                                <option disabled selected>Pilih Nama Rombel</option>
                                                                                                <?php
                                                                                                foreach ($kelas as $km) : if (($nmUser['kd_user'] == $km['kd_lembaga']) && ($km['kd_tapel'] == $kdTapel)) {
                                                                                                        if ($edit->kd_kelas == $km['id_kelas']) {
                                                                                                            $select = "selected";
                                                                                                        } else {
                                                                                                            $select = "";
                                                                                                        }
                                                                                                        echo "<option $select>" . $km['nm_rombel'] . "</option>";
                                                                                                    }
                                                                                                endforeach;
                                                                                                ?>
                                                                                                <?= form_error('kd_kelas', '<small class="text-danger">', '</small>'); ?>
                                                                                            </select>
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="sparkline11-graph">
                                                                                <div class="row">
                                                                                    <div class="col-lg-12">
                                                                                        <label class="login2 pull-left pull-left-pro">Nama Students</label>
                                                                                    </div>
                                                                                    <div class="col-lg-12">
                                                                                        <select data-placeholder="Nama Students" class="chosen-select" tabindex="-1" name='kd_students' id='kd_students'>
                                                                                            <?php
                                                                                            foreach ($siswa as $km) : if ($nmUser['kd_user'] == $km['kd_lembaga']) {
                                                                                                    if ($edit->kd_students == $km['id_students']) {
                                                                                                        $select = "selected";
                                                                                                    } else {
                                                                                                        $select = "";
                                                                                                    }
                                                                                                    echo "<option $select>" . $km['nisn_students'] . ' : ' . $km['nm_students'] . "</option>";
                                                                                                }
                                                                                            endforeach;
                                                                                            ?>
                                                                                            <?= form_error('kd_students', '<small class="text-danger">', '</small>'); ?>
                                                                                        </select>
                                                                                    </div>
                                                                                </div>
                                                                            </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>
                                        <script type="text/javascript">
                                            $(document).ready(function() {
                                                $('#kd_kelas').change(function() {
                                                    var id = $(this).val();
                                                    $.ajax({
                                                        url: "<?php echo base_url(); ?>index.php/kategori/get_subkategori",
                                                        method: "POST",
                                                        data: {
                                                            id: id
                                                        },
                                                        async: false,
                                                        dataType: 'json',
                                                        success: function(data) {
                                                            var html = '';
                                                            var i;
                                                            for (i = 0; i < data.length; i++) {
                                                                html += '<option>' + data[i].subkategori_nama + '</option>';
                                                            }
                                                            $('.subkategori').html(html);
                                                        }
                                                    });
                                                });
                                            });
                                        </script>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>