<!-- // 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> Tanggal Rapor</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) {
                                            if ($cekGuru) {
                                    ?>
                                                <a class="btn btn-primary" href="#" data-toggle="modal" data-target="#TambahTglRapor"><i class="fa fa-plus-circle"></i> Add New Data</a>
                                    <?php } else {
                                                $this->session->set_flashdata('messageWarning', 'Silahkan tambahkan data teachers terlebih dahulu !');
                                                redirect('admin/data_guru');
                                            }
                                        } 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 tambahkan data tahun pelajaran terlebih dahulu !');
                                        redirect('admin/tapel');
                                    } ?>
                                    <div id="TambahTglRapor" class="modal modal-adminpro-general default-popup-PrimaryModal fade" role="dialog">
                                        <form action="<?= base_url('admin/tambahDataTglRapor'); ?>" 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 Tanggal Rapor</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 Tempat</label>
                                                                </div>
                                                                <div class="col-lg-12">
                                                                    <input type="text" class="form-control" id="tmpt_tgl" name="tmpt_tgl" placeholder="Nama Tempat (Kota/Kabupaten)" value='<?= set_value('tmpt_tgl'); ?>' required>
                                                                    <?= form_error('nm_bidstudy', '<small class="text-danger">', '</small>'); ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="sparkline11-graph">
                                                            <div class="row">
                                                                <div class="col-lg-12">
                                                                    <label class="login2 pull-left pull-left-pro">Tanggal Rapor</label>
                                                                </div>
                                                                <div class="col-lg-12">
                                                                    <div class="date-picker-inner">
                                                                        <div class="form-group data-custon-pick" id="data_1">
                                                                            <div class="input-group date">
                                                                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                                                                <input name='nm_tgl1' id='nm_tgl1' type="text" class="form-control" value="04/15/2021" required>
                                                                                <?= form_error('nm_tgl1', '<small class="text-danger">', '</small>'); ?>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <?php if ($newkdTapel['kd_smstr'] == 'Genap') { ?>
                                                            <div class="sparkline11-graph">
                                                                <div class="row">
                                                                    <div class="col-lg-12">
                                                                        <label class="login2 pull-left pull-left-pro">Tanggal Rapor Kelas Akhir/Kelulusan</label>
                                                                    </div>
                                                                    <div class="col-lg-12">
                                                                        <div class="date-picker-inner">
                                                                            <div class="form-group data-custon-pick" id="data_1">
                                                                                <div class="input-group date">
                                                                                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                                                                    <input name='nm_tgl3' id='nm_tgl3' type="text" class="form-control" value="04/15/2021" required>
                                                                                    <?= form_error('nm_tgl3', '<small class="text-danger">', '</small>'); ?>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        <?php } ?>
                                                        <div class="sparkline11-graph">
                                                            <div class="row">
                                                                <div class="col-lg-12">
                                                                    <label class="login2 pull-left pull-left-pro">Nama Kepala Madrasah</label>
                                                                </div>
                                                                <div class="col-lg-12">
                                                                    <select data-placeholder="Nama Kepala Madrasah" class="chosen-select" tabindex="-1" name='kd_teachers' id='kd_teachers'>
                                                                        <option disabled selected>Nama Kepala Madrasah</option>
                                                                        <?php foreach ($teachers as $study) : if ($nmUser['kd_user'] == $study['kd_lembaga']) { ?>
                                                                                <option value='<?= $study['id_teachers'] ?>'><?= $study['nm_teachers'] ?></option>
                                                                        <?php }
                                                                        endforeach; ?>
                                                                        <?= form_error('kd_teachers', '<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">Tempat</th>
                                                    <th data-field="tgl">Tanggal Rapor</th>
                                                    <th data-field="lulus">Tanggal Lulus</th>
                                                    <th data-field="kamad">Kepala Madrasah</th>
                                                    <th data-field="Edit">Akun User</th>
                                                    <th data-field="Delete"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php
                                                $i = 1;
                                                foreach ($dtTgl as $study) :
                                                    if ($study['kd_lembaga'] == $nmLembaga['id_lembaga']) {
                                                ?>
                                                        <tr>
                                                            <td></td>
                                                            <td align="center"><?= $i;
                                                                                $i++; ?></td>
                                                            <td><?php if ($study['semester'] == 'Ganjil') {
                                                                    echo $study['tahun'] . '/' . ($study['tahun'] + 1);
                                                                } elseif ($study['semester'] == 'Genap') {
                                                                    echo ($study['tahun'] - 1) . '/' . $study['tahun'];
                                                                }; ?></td>
                                                            <td><?= $study['semester']; ?></td>
                                                            <td><?= $study['tempat']; ?></td>
                                                            <td><?= $this->m_walas->tgl_indo(date('d-m-Y', strtotime($study['tanggal']))); ?></td>
                                                            <td>
                                                                <?php if ($study['kdtapel'] == $kdTapel) {
                                                                    if ($newkdTapel['kd_smstr'] == 'Genap') { ?>
                                                                        <?= $this->m_walas->tgl_indo(date('d-m-Y', strtotime($study['tanggal_lulus']))); ?>
                                                                <?php } elseif ($newkdTapel['kd_smstr'] == 'Ganjil') {
                                                                        echo '<div class="label label-primary">Tidak Ada</div>';
                                                                    }
                                                                } ?>
                                                            </td>
                                                            <td><?= $study['nama_guru']; ?></td>
                                                            <td align="center">
                                                                <?php
                                                                if ($study['kdtapel'] == $kdTapel) {
                                                                    if ($study['stsguru'] == 0) {
                                                                        echo '<div class="label label-danger">Tidak Aktif</div>';
                                                                    } else {
                                                                        echo '<div class="label label-success">Aktif</div>';
                                                                    }
                                                                }
                                                                ?>
                                                            </td>
                                                            <td align="center">
                                                                <?php
                                                                if ($study['kdtapel'] == $kdTapel) {
                                                                    if ($study['stsguru'] == 0) { ?>
                                                                        <a href='<?= base_url('admin/aktifkanDataTgl/' . $study['kdguru']); ?>'>
                                                                            <div class="label label-info label"><i class=" fa fa-play"></i> Aktifkan</div>
                                                                        </a>
                                                                        <a href="#" data-toggle="modal" data-target="#EditMapel<?= $study['idTgl']; ?>">
                                                                            <div class="label label-warning"><i class=" fa fa-edit"></i> Edit</div>
                                                                        </a>
                                                                    <?php } else { ?>
                                                                        <a href='<?= base_url('admin/nonaktifkanDataTgl/' . $study['kdguru']); ?>'>
                                                                            <div class="label label-primary label"><i class=" fa fa-stop"></i> non Aktifkan</div>
                                                                        </a>
                                                                        <a href="#" data-toggle="modal" data-target="#EditMapel<?= $study['idTgl']; ?>">
                                                                            <div class="label label-warning"><i class=" fa fa-edit"></i> Edit</div>
                                                                        </a>
                                                                <?php }
                                                                }
                                                                ?>
                                                            </td>
                                                        </tr>
                                                    <?php
                                                    }
                                                endforeach;
                                                foreach ($dtTgl as $study) :
                                                    if ($study['kd_lembaga'] == $nmLembaga['id_lembaga']) {
                                                    ?>
                                                        <div id="EditMapel<?= $study['idTgl']; ?>" class="modal modal-adminpro-general Customwidth-popup-WarningModal fade" role="dialog">
                                                            <form action="<?= base_url('admin/updateDataTglRapor'); ?>" 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">
                                                                            <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_tgl" name="id_tgl" placeholder="Id Tgl" value='<?= $study['idTgl']; ?>' required>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="sparkline11-graph">
                                                                                <div class="row">
                                                                                    <div class="col-lg-12">
                                                                                        <label class="login2 pull-left pull-left-pro">Nama Tempat</label>
                                                                                    </div>
                                                                                    <div class="col-lg-12">
                                                                                        <input type="text" class="form-control" id="tmpt_tgl" name="tmpt_tgl" placeholder="Nama Tempat (Kota/Kabupaten)" value='<?= $study['tempat']; ?>' required>
                                                                                        <?= form_error('nm_bidstudy', '<small class="text-danger">', '</small>'); ?>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="sparkline11-graph">
                                                                                <div class="row">
                                                                                    <div class="col-lg-12">
                                                                                        <label class="login2 pull-left pull-left-pro">Tanggal Rapor</label>
                                                                                    </div>
                                                                                    <div class="col-lg-12">
                                                                                        <div class="date-picker-inner">
                                                                                            <div class="form-group data-custon-pick" id="data_1" name='nm_tgl'>
                                                                                                <div class="input-group date">
                                                                                                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                                                                                    <input name='nm_tgl1' id="nm_tgl1" type="text" class="form-control" value="<?= $study['tanggal']; ?>" required>
                                                                                                    <?= form_error('nm_tgl', '<small class="text-danger">', '</small>'); ?>
                                                                                                </div>
                                                                                            </div>
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                            <?php if ($newkdTapel['kd_smstr'] == 'Genap') { ?>
                                                                                <div class="sparkline11-graph">
                                                                                    <div class="row">
                                                                                        <div class="col-lg-12">
                                                                                            <label class="login2 pull-left pull-left-pro">Tanggal Rapor Kelas Akhir/Kelulusan</label>
                                                                                        </div>
                                                                                        <div class="col-lg-12">
                                                                                            <div class="date-picker-inner">
                                                                                                <div class="form-group data-custon-pick" id="data_1">
                                                                                                    <div class="input-group date">
                                                                                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                                                                                        <input name='nm_tgl3' id="nm_tgl3" type="text" class="form-control" value="<?= $study['tanggal_lulus']; ?>" required>
                                                                                                        <?= form_error('nm_tgl3', '<small class="text-danger">', '</small>'); ?>
                                                                                                    </div>
                                                                                                </div>
                                                                                            </div>
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                            <?php } ?>
                                                                            <div class="sparkline11-graph">
                                                                                <div class="row">
                                                                                    <div class="col-lg-12">
                                                                                        <label class="login2 pull-left pull-left-pro">Nama Kepala Madrasah</label>
                                                                                    </div>
                                                                                    <div class="col-lg-12">
                                                                                        <div class="chosen-select-single mg-b-20">
                                                                                            <select data-placeholder="Nama Kepala Madrasah" class="chosen-select" tabindex="-1" name='kd_teachers' id='kd_teachers'>
                                                                                                <option disabled selected>Nama Kepala Madrasah</option>
                                                                                                <?php
                                                                                                foreach ($teachers as $km) :
                                                                                                    if ($nmUser['kd_user'] == $km['kd_lembaga']) {
                                                                                                        if ($study['kdguru'] == $km['id_teachers']) {
                                                                                                            $select = "selected";
                                                                                                        } else {
                                                                                                            $select = "";
                                                                                                        }
                                                                                                        echo "<option $select>" . $km['nm_teachers'] . "</option>";
                                                                                                    }
                                                                                                endforeach;
                                                                                                ?>
                                                                                                <?= form_error('kd_teachers', '<small class="text-danger">', '</small>'); ?>
                                                                                            </select>
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                        <div class="modal-footer">
                                                                            <div class="sparkline11-graph">
                                                                                <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>