<?php
defined('BASEPATH') or exit('No direct script access allowed');
// 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)
class Kamad extends CI_Controller
{
    public function __construct()
    {
        parent::__construct();
        kudu_sinau();
        $kd_level = $this->session->userdata('kd_level');
        $Level = $this->uri->segment(1);
        if ($Level == 'kamad') {
            $newLevel = 'kepala madrasah';
        }
        $queryLevel = $this->db->get_where('t_level', ['nm_level' => $newLevel])->row_array();
        $idLevel = $queryLevel['id_level'];
        if (!($kd_level == 2 and $idLevel == 2)) {
            if ($kd_level == 1) {
                redirect('admin/block');
            } elseif ($kd_level == 3) {
                redirect('walas/block');
            } elseif ($kd_level == 4) {
                redirect('guru/block');
            } elseif ($kd_level == 5) {
                redirect('siswa/block');
                // created by : KuduSinau_Hendrik_081275532220
            }
        }
    }
    public function index()
    {
        $data['nmUser'] = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $data['nmJenjang'] = $this->db->get_where('t_jenjang', ['id_jenjang' => $this->session->userdata('kd_jenjang')])->row_array();
        $data['nmLevel'] = $this->db->get_where('t_level', ['id_level' => $this->session->userdata('kd_level')])->row_array();
        $data['nmStatus'] = $this->db->get_where('t_status', ['id_status' => $this->session->userdata('status_lembaga')])->row_array();
        $data['nmLembaga'] = $this->db->get_where('t_lembaga', ['id_lembaga' => $this->session->userdata('kd_user')])->row_array();
        $data['nmTapel'] = $this->db->get_where('t_tapel', ['kd_lembaga' => $this->session->userdata('kd_user')])->result_array();
        $newKdlembaga = $data['nmUser']['kd_user'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $kdTapel = $dataTapel['id_tapel'];
        } else {
            $kdTapel = 'null';
        }
        $this->db->select('*');
        $this->db->from('t_lembaga');
        $this->db->join('t_jenjang', 't_lembaga.kd_jenjang = t_jenjang.id_jenjang');
        $this->db->join('t_status', 't_lembaga.kd_status = t_status.id_status');
        $this->db->where('t_lembaga.id_lembaga', $newKdlembaga);
        $data['Lembaga'] = $this->db->get()->row_array();
        $this->db->from('t_students');;
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->where('status_lulus', 0);
        $jumlahsiswa = $this->db->count_all_results();
        $this->db->from('t_students');;
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->where('status_lulus', 3);
        $jumlahlulus = $this->db->count_all_results();
        $this->db->from('t_teachers');;
        $this->db->where('kd_lembaga', $newKdlembaga);
        $jumlahguru = $this->db->count_all_results();
        $this->db->from('t_kelas');;
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->where('kd_tapel', $kdTapel);
        $jumlahrombel = $this->db->count_all_results();
        $this->db->from('t_user');;
        $this->db->where('kd_user', $newKdlembaga);
        $jumlahuser = $this->db->count_all_results();
        $this->db->from('t_eskul');;
        $this->db->where('kd_lembaga', $newKdlembaga);
        $jumlaheskul = $this->db->count_all_results();
        $data['jumlahSiswa'] = $jumlahsiswa;
        $data['jumlahLulus'] = $jumlahlulus;
        $data['jumlahGuru'] = $jumlahguru;
        $data['jumlahRombel'] = $jumlahrombel;
        $data['jumlahUser'] = $jumlahuser;
        $data['jumlahEskul'] = $jumlaheskul;
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Dashboard';
        $this->load->view('template/header', $data);
        $this->load->view('template/sidebar', $data);
        $this->load->view('template/headertop', $data);
        $this->load->view('template/mobile', $data);
        $this->load->view('kamad/dashboard', $data);
        $this->load->view('template/footer', $data);
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function cetak_rapor()
    {
        $data['nmUser'] = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $data['nmJenjang'] = $this->db->get_where('t_jenjang', ['id_jenjang' => $this->session->userdata('kd_jenjang')])->row_array();
        $data['nmLevel'] = $this->db->get_where('t_level', ['id_level' => $this->session->userdata('kd_level')])->row_array();
        $data['nmStatus'] = $this->db->get_where('t_status', ['id_status' => $this->session->userdata('status_lembaga')])->row_array();
        $data['nmLembaga'] = $this->db->get_where('t_lembaga', ['id_lembaga' => $this->session->userdata('kd_user')])->row_array();
        $data['nmTapel'] = $this->db->get_where('t_tapel', ['kd_lembaga' => $this->session->userdata('kd_user')])->result_array();
        $newKdlembaga = $data['nmUser']['kd_user'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_tapel.kd_tahun', SORT_ASC);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $data['kdTapel'] = $dataTapel['id_tapel'];
        } else {
            $data['kdTapel'] = 'null';
        }
        $this->db->select('*');
        $this->db->from('t_lembaga');
        $this->db->join('t_jenjang', 't_lembaga.kd_jenjang = t_jenjang.id_jenjang');
        $this->db->join('t_status', 't_lembaga.kd_status = t_status.id_status');
        $this->db->where('t_lembaga.id_lembaga', $newKdlembaga);
        $data['Lembaga'] = $this->db->get()->row_array();
        $data['gMapel'] = $this->db->get('t_gmapel')->result_array();
        $data['naik'] = $this->db->get('t_naik')->result_array();
        $data['lulus'] = $this->db->get('t_lulus')->result_array();
        $data['dtKdp'] = $this->db->get('t_kdp')->result_array();
        $data['eskul'] = $this->db->get('t_eskul')->result_array();
        $data['nilaieskul'] = $this->db->get('t_nilaieskul')->result_array();
        $data['walas'] = $this->db->get('t_walas')->result_array();
        $data['dtKkm'] = $this->m_guru->viewDataKkm();
        $data['dtNilaip'] = $this->m_guru->viewDataNilaip();
        $data['dtWalasGuru'] = $this->m_walas->viewDataWalasGuru();
        $data['dtWalasSiswa'] = $this->m_walas->viewDataNaikSiswa();
        $cekCatatan = $this->db->get_where('t_catatan', array('kd_lembaga' => $newKdlembaga, 'kd_tapel' => $data['kdTapel']))->num_rows();
        $data['cekCatatan'] = $cekCatatan;
        $cekRombelSiswa = $this->db->get_where('t_rombelsiswa', array('kd_lembaga' => $newKdlembaga, 'kd_tapel' => $data['kdTapel']))->num_rows();
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Print Rapor';
        if ($cekRombelSiswa > 0) {
            $this->load->view('template/header', $data);
            $this->load->view('template/sidebar', $data);
            $this->load->view('template/headertop', $data);
            $this->load->view('template/mobile', $data);
            $this->load->view('kamad/cetak_rapor', $data);
            $this->load->view('template/footer', $data);
        } else {
            $this->session->set_flashdata('messageInfo2', 'Rombel siswa belum ditambahkan !');
            $this->load->view('template/header', $data);
            $this->load->view('template/sidebar', $data);
            $this->load->view('template/headertop', $data);
            $this->load->view('template/mobile', $data);
            $this->load->view('kamad/cetak_rapor', $data);
            $this->load->view('template/footer', $data);
            // created by : KuduSinau_Hendrik_081275532220
        }
    }
    public function data_lulus()
    {
        $data['nmUser'] = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $data['nmJenjang'] = $this->db->get_where('t_jenjang', ['id_jenjang' => $this->session->userdata('kd_jenjang')])->row_array();
        $data['nmLevel'] = $this->db->get_where('t_level', ['id_level' => $this->session->userdata('kd_level')])->row_array();
        $data['nmStatus'] = $this->db->get_where('t_status', ['id_status' => $this->session->userdata('status_lembaga')])->row_array();
        $data['nmLembaga'] = $this->db->get_where('t_lembaga', ['id_lembaga' => $this->session->userdata('kd_user')])->row_array();
        $data['nmTapel'] = $this->db->get_where('t_tapel', ['kd_lembaga' => $this->session->userdata('kd_user')])->result_array();
        $newKdlembaga = $data['nmUser']['kd_user'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_tapel.kd_tahun', SORT_ASC);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $data['kdTapel'] = $dataTapel['id_tapel'];
        } else {
            $data['kdTapel'] = 'null';
        }
        $this->db->select('*');
        $this->db->from('t_lembaga');
        $this->db->join('t_jenjang', 't_lembaga.kd_jenjang = t_jenjang.id_jenjang');
        $this->db->join('t_status', 't_lembaga.kd_status = t_status.id_status');
        $this->db->where('t_lembaga.id_lembaga', $newKdlembaga);
        $data['Lembaga'] = $this->db->get()->row_array();
        $data['gMapel'] = $this->db->get('t_gmapel')->result_array();
        $data['naik'] = $this->db->get('t_naik')->result_array();
        $data['lulus'] = $this->db->get('t_lulus')->result_array();
        $data['dtKdp'] = $this->db->get('t_kdp')->result_array();
        $data['eskul'] = $this->db->get('t_eskul')->result_array();
        $data['nomor'] = $this->db->get('t_nomor')->result_array();
        $data['walas'] = $this->db->get('t_walas')->result_array();
        $data['dtKkm'] = $this->m_guru->viewDataKkm();
        $data['dtNilaip'] = $this->m_guru->viewDataNilaip();
        $data['dtWalasGuru'] = $this->m_walas->viewDataWalasGuru();
        $data['dtWalasSiswa'] = $this->m_walas->viewDataWalasSiswa();
        $cekCatatan = $this->db->get_where('t_catatan', array('kd_lembaga' => $newKdlembaga, 'kd_tapel' => $data['kdTapel']))->num_rows();
        $data['cekCatatan'] = $cekCatatan;
        $cekRombelSiswa = $this->db->get_where('t_rombelsiswa', array('kd_lembaga' => $newKdlembaga, 'kd_tapel' => $data['kdTapel']))->num_rows();
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Print Rapor';
        if ($cekRombelSiswa > 0) {
            $this->load->view('template/header', $data);
            $this->load->view('template/sidebar', $data);
            $this->load->view('template/headertop', $data);
            $this->load->view('template/mobile', $data);
            $this->load->view('kamad/data_lulus', $data);
            $this->load->view('template/footer', $data);
        } else {
            $this->session->set_flashdata('messageInfo2', 'Rombel siswa belum ditambahkan !');
            $this->load->view('template/header', $data);
            $this->load->view('template/sidebar', $data);
            $this->load->view('template/headertop', $data);
            $this->load->view('template/mobile', $data);
            $this->load->view('kamad/data_lulus', $data);
            $this->load->view('template/footer', $data);
            // created by : KuduSinau_Hendrik_081275532220
        }
    }
    public function surat_skbb($kdsiswa)
    {
        $data['nmUser'] = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $data['nmJenjang'] = $this->db->get_where('t_jenjang', ['id_jenjang' => $this->session->userdata('kd_jenjang')])->row_array();
        $data['nmLevel'] = $this->db->get_where('t_level', ['id_level' => $this->session->userdata('kd_level')])->row_array();
        $data['nmStatus'] = $this->db->get_where('t_status', ['id_status' => $this->session->userdata('status_lembaga')])->row_array();
        $data['nmLembaga'] = $this->db->get_where('t_lembaga', ['id_lembaga' => $this->session->userdata('kd_user')])->row_array();
        $data['nmTapel'] = $this->db->get_where('t_tapel', ['kd_lembaga' => $this->session->userdata('kd_user')])->result_array();
        $newKdlembaga = $data['nmUser']['kd_user'];
        $kdLembaga =  $data['nmLembaga']['id_lembaga'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_tapel.kd_tahun', SORT_ASC);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $data['kdTapel'] = $dataTapel;
        } else {
            $data['kdTapel'] = 'null';
        }
        $data['gMapel'] = $this->db->get('t_gmapel')->result_array();
        $data['kkm'] = $this->db->get('t_kkm')->result_array();
        $data['dtKdp'] = $this->db->get('t_kdp')->result_array();
        $data['kdp'] = $this->db->get('t_nokdp')->result_array();
        $data['nilaip'] = $this->db->get('t_nilaip')->result_array();
        $data['akhirp'] = $this->db->get('t_akhirp')->result_array();
        $data['dtKkm'] = $this->m_guru->viewDataKkm();
        $data['dtNilaip'] = $this->m_guru->viewDataNilaip();
        $data['rSiswap'] = $this->m_guru->viewDataRsiswa();
        $data['nSiswap'] = $this->m_guru->nilaiSiswap();
        $data['tgl'] = $this->m_guru->viewDataTgl();
        $data['Siswa'] = $this->m_walas->viewDataWalasSiswa();
        $data['kdsiswa'] = $kdsiswa;
        $this->db->select(' t_kelas.nm_rombel as kelas, 
                            t_kelas.id_kelas as kdkelas, 
                            t_kelas.nm_kelas as tingkat, 
                            t_kls.huruf_kls as huruf, 
                            t_students.nm_students as siswa, 
                            t_students.nisn_students as nisn, 
                            t_students.nislokal_students as nism, 
                            t_students.id_students as kdsiswa, 
                            t_rombelsiswa.id_rombelsiswa as idr, 
                            t_rombelsiswa.kd_tapel as kdt, 
                            t_rombelsiswa.kd_lembaga as kdl
        ');
        $this->db->from('t_students');
        $this->db->join('t_rombelsiswa', 't_students.id_students = t_rombelsiswa.kd_students', 'left');
        $this->db->join('t_kelas', 't_rombelsiswa.kd_kelas = t_kelas.id_kelas', 'left');
        $this->db->join('t_kls', 't_kls.nm_kls = t_kelas.nm_kelas', 'left');
        $this->db->where('t_rombelsiswa.kd_students', $kdsiswa);
        $this->db->where('t_rombelsiswa.kd_lembaga', $newKdlembaga);
        $this->db->where('t_rombelsiswa.kd_tapel', $data['kdTapel']['id_tapel']);
        $query = $this->db->get()->row_array();;
        $this->db->select('*');
        $this->db->from('t_students');
        $this->db->join('t_alumni', 't_students.id_students = t_alumni.kd_students');
        $this->db->join('t_nomor', 't_students.id_students = t_nomor.kd_students');
        $this->db->where('t_alumni.kd_tapel', $data['kdTapel']['id_tapel']);
        $this->db->where('t_alumni.kd_lembaga', $newKdlembaga);
        $this->db->where('t_alumni.kd_students', $kdsiswa);
        $dtsiswa = $this->db->get()->row_array();
        if (!is_null($dtsiswa)) {
            $dtsiswa1 = $dtsiswa;
        }
        $this->db->select('*');
        $this->db->from('t_lembaga');
        $this->db->join('t_jenjang', 't_lembaga.kd_jenjang = t_jenjang.id_jenjang');
        $this->db->join('t_status', 't_lembaga.kd_status = t_status.id_status');
        $this->db->where('t_lembaga.id_lembaga', $newKdlembaga);
        $data['Lembaga'] = $this->db->get()->row_array();
        $this->db->select(' t_tapel.kd_smstr as semester,
                            t_teachers.nm_teachers as kamad,
                            t_teachers.gelar_depan as gelardepan, 
                            t_teachers.gelar_belakang as gelarbelakang, 
                            t_teachers.nip_teachers as nip_kamad,
                            t_tapel.kd_tahun as tahun,
                            t_tgl.tmpt_tgl as tempat,
                            t_tapel.id_tapel as tapel,
                            t_tgl.nm_tgl1 as tanggal,
                            t_tgl.nm_tgl3 as tanggal3
        ');
        $this->db->from('t_tapel');
        $this->db->join('t_tgl', 't_tapel.id_tapel = t_tgl.kd_tapel');
        $this->db->join('t_teachers', 't_tgl.kd_teachers = t_teachers.id_teachers');
        $this->db->where('t_tapel.sts_tapel', 1);
        $this->db->where('t_tapel.kd_lembaga', $kdLembaga);
        $wakturapor = $this->db->get()->row_array();
        $data['lulus'] = $dtsiswa1;
        $data['kelas'] = $query;
        $data['waktu'] = $wakturapor;
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Print SKBB';
        $this->load->view('template/header', $data);
        $this->load->view('kamad/surat_skbb', $data);
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function tambahNomorSurat()
    {
        $dataUser = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $newKdlembaga = $dataUser['kd_user'];
        $newKdJenjang = $dataUser['kd_jenjang'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_tapel.kd_tahun', SORT_ASC);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $kdTapel = $dataTapel['id_tapel'];
        } else {
            $kdTapel = 'null';
        }
        $this->form_validation->set_rules('id_siswa[]', 'ID Siswa', 'required|trim');
        $this->form_validation->set_rules('nomor_sk', 'Nomor SK', 'required|trim');
        $this->form_validation->set_rules('nomor_skl', 'Nomor SKL', 'required|trim');
        $this->form_validation->set_rules('nomor_skbb', 'Nomor SKBB', 'required|trim');
        if ($this->form_validation->run() == false) {
            $this->session->set_flashdata('messageWarning', 'Data tidak boleh kosong !');
            redirect('kamad/data_lulus');
        } else {
            $sk = htmlspecialchars($this->input->post('nomor_sk'), true);
            $skl = htmlspecialchars($this->input->post('nomor_skl'), true);
            $skbb = htmlspecialchars($this->input->post('nomor_skbb'), true);
            $noskbb = htmlspecialchars($this->input->post('nomor_awal_skbb'), true);
            $nosskl = htmlspecialchars($this->input->post('nomor_awal_skl'), true);
            $siswa = $this->input->post('id_siswa');
            $data = array();
            foreach ($siswa as $nrs => $rstd) {
                $data[$nrs]['kd_students'] = $rstd;
                $cekSiswa = $this->db->get_where('t_nomor', array('kd_students' => $rstd, 'kd_tapel' =>  $kdTapel, 'kd_lembaga' => $newKdlembaga))->num_rows();
            }
            if ($cekSiswa > 0) {
                $dt = array();
                $a = $noskbb;
                $i = $nosskl;
                foreach ($siswa as $nrs => $rstd) {
                    $idNomor = $this->db->get_where('t_nomor', array('kd_students' => $rstd, 'kd_tapel' =>  $kdTapel, 'kd_lembaga' => $newKdlembaga))->row_array();
                    $dt[$nrs]['id_nomor']       = $idNomor['id_nomor'];
                    $dt[$nrs]['kd_students']    = $rstd;
                    $dt[$nrs]['nomor_sk']       = $sk;
                    $dt[$nrs]['nomor_skl']      = sprintf("%03s", $i) . '/' . $skl;
                    $dt[$nrs]['nomor_skbb']     = sprintf("%03s", $a) . '/' . $skbb;
                    $dt[$nrs]['kd_tapel']       = $kdTapel;
                    $dt[$nrs]['kd_lembaga']     = $newKdlembaga;
                    $i++;
                    $a++;
                }
                $this->m_admin->updateNomorSurat($dt, 'id_nomor');
                $this->session->set_flashdata('messageSave', 'Data nomor surat berhasil diupdate !');
                redirect('kamad/data_lulus');
            } else {
                $sk = htmlspecialchars($this->input->post('nomor_sk'), true);
                $skl = htmlspecialchars($this->input->post('nomor_skl'), true);
                $skbb = htmlspecialchars($this->input->post('nomor_skbb'), true);
                $siswa = $this->input->post('id_siswa');
                $dt = array();
                $a = $noskbb;
                $i = $nosskl;
                foreach ($siswa as $nrs => $rstd) {
                    $dt[$nrs]['kd_students']    = $rstd;
                    $dt[$nrs]['nomor_sk']       = $sk;
                    $dt[$nrs]['nomor_skl']      = sprintf("%03s", $i) . '/' . $skl;
                    $dt[$nrs]['nomor_skbb']     = sprintf("%03s", $a) . '/' . $skbb;
                    $dt[$nrs]['kd_tapel']       = $kdTapel;
                    $dt[$nrs]['kd_lembaga']     = $newKdlembaga;
                    $i++;
                    $a++;
                }
                $this->m_admin->inputNomorSurat($dt);
                $this->session->set_flashdata('messageSave', 'Penambahan nomor surat berhasil !');
                redirect('kamad/data_lulus');
                // created by : KuduSinau_Hendrik_081275532220
            }
        }
    }
    public function block()
    {
        $data['title'] = 'D-Rapor | Blocked';
        $this->load->view('kamad/block', $data);
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function coomingsoon()
    {
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Cooming Soon';
        $this->load->view('kamad/coomingsoon', $data);
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function cetak_legger()
    {
        $data['nmUser'] = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $data['nmJenjang'] = $this->db->get_where('t_jenjang', ['id_jenjang' => $this->session->userdata('kd_jenjang')])->row_array();
        $data['nmLevel'] = $this->db->get_where('t_level', ['id_level' => $this->session->userdata('kd_level')])->row_array();
        $data['nmStatus'] = $this->db->get_where('t_status', ['id_status' => $this->session->userdata('status_lembaga')])->row_array();
        $data['nmLembaga'] = $this->db->get_where('t_lembaga', ['id_lembaga' => $this->session->userdata('kd_user')])->row_array();
        $data['nmTapel'] = $this->db->get_where('t_tapel', ['kd_lembaga' => $this->session->userdata('kd_user')])->result_array();
        $newKdGuru = $data['nmUser']['kd_teachers'];
        $newKdlembaga = $data['nmUser']['kd_user'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_tapel.kd_tahun', SORT_ASC);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $data['kdTapel'] = $dataTapel['id_tapel'];
        } else {
            $data['kdTapel'] = 'null';
        }
        $this->db->select('*');
        $this->db->from('t_lembaga');
        $this->db->join('t_jenjang', 't_lembaga.kd_jenjang = t_jenjang.id_jenjang');
        $this->db->join('t_status', 't_lembaga.kd_status = t_status.id_status');
        $this->db->where('t_lembaga.id_lembaga', $newKdlembaga);
        $data['Lembaga'] = $this->db->get()->row_array();
        $data['newTapel'] = $dataTapel;
        $this->db->select(' t_kelas.nm_kelas as tingkat, 
                            t_kelas.nm_rombel as kelas, 
                            t_kelas.id_kelas as kdkelas, 
                            t_walas.id_walas as idw, 
                            t_walas.kd_lembaga as kdlbg, 
                            t_walas.kd_tapel as kdtapel, 
                            
        ');
        $this->db->from('t_walas');
        $this->db->join('t_kelas', 't_walas.kd_kelas = t_kelas.id_kelas', 'right');
        $this->db->where('t_walas.kd_tapel', $data['kdTapel']);
        $this->db->where('t_walas.kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_kelas.nm_rombel', SORT_ASC);
        $kelasSiswa = $this->db->get()->result_array();
        $data['klsSiswa'] = $kelasSiswa;
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Print Rapor';
        $cekRombelSiswa = $this->db->get_where('t_rombelsiswa', array('kd_lembaga' => $newKdlembaga, 'kd_tapel' => $data['kdTapel']))->num_rows();
        $cekCatatan = $this->db->get_where('t_catatan', array('kd_lembaga' => $newKdlembaga, 'kd_tapel' => $data['kdTapel']))->num_rows();
        $data['cekCatatan'] = $cekCatatan;
        if ($cekRombelSiswa > 0) {
            $this->load->view('template/header', $data);
            $this->load->view('template/sidebar', $data);
            $this->load->view('template/headertop', $data);
            $this->load->view('template/mobile', $data);
            $this->load->view('kamad/cetak_legger', $data);
            $this->load->view('template/footer', $data);
        } else {
            $this->session->set_flashdata('messageInfo2', 'Rombel siswa belum ditambahkan !');
            $this->load->view('template/header', $data);
            $this->load->view('template/sidebar', $data);
            $this->load->view('template/headertop', $data);
            $this->load->view('template/mobile', $data);
            $this->load->view('kamad/cetak_legger', $data);
            $this->load->view('template/footer', $data);
            // created by : KuduSinau_Hendrik_081275532220
        }
    }
    public function surat_lulus($kdsiswa)
    {
        $data['nmUser'] = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $data['nmJenjang'] = $this->db->get_where('t_jenjang', ['id_jenjang' => $this->session->userdata('kd_jenjang')])->row_array();
        $data['nmLevel'] = $this->db->get_where('t_level', ['id_level' => $this->session->userdata('kd_level')])->row_array();
        $data['nmStatus'] = $this->db->get_where('t_status', ['id_status' => $this->session->userdata('status_lembaga')])->row_array();
        $data['nmLembaga'] = $this->db->get_where('t_lembaga', ['id_lembaga' => $this->session->userdata('kd_user')])->row_array();
        $data['nmTapel'] = $this->db->get_where('t_tapel', ['kd_lembaga' => $this->session->userdata('kd_user')])->result_array();
        $newKdlembaga = $data['nmUser']['kd_user'];
        $kdLembaga =  $data['nmLembaga']['id_lembaga'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_tapel.kd_tahun', SORT_ASC);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $data['kdTapel'] = $dataTapel;
        } else {
            $data['kdTapel'] = 'null';
        }
        $data['gMapel'] = $this->db->get('t_gmapel')->result_array();
        $data['kkm'] = $this->db->get('t_kkm')->result_array();
        $data['dtKdp'] = $this->db->get('t_kdp')->result_array();
        $data['kdp'] = $this->db->get('t_nokdp')->result_array();
        $data['nilaip'] = $this->db->get('t_nilaip')->result_array();
        $data['akhirp'] = $this->db->get('t_akhirp')->result_array();
        $data['dtKkm'] = $this->m_guru->viewDataKkm();
        $data['dtNilaip'] = $this->m_guru->viewDataNilaip();
        $data['rSiswap'] = $this->m_guru->viewDataRsiswa();
        $data['nSiswap'] = $this->m_guru->nilaiSiswap();
        $data['tgl'] = $this->m_guru->viewDataTgl();
        $data['Siswa'] = $this->m_walas->viewDataWalasSiswa();
        $data['kdsiswa'] = $kdsiswa;
        $this->db->select(' t_kelas.nm_rombel as kelas, 
                            t_kelas.id_kelas as kdkelas, 
                            t_kelas.nm_kelas as tingkat, 
                            t_kls.huruf_kls as huruf, 
                            t_students.nm_students as siswa, 
                            t_students.nisn_students as nisn, 
                            t_students.nislokal_students as nism, 
                            t_students.id_students as kdsiswa, 
                            t_rombelsiswa.id_rombelsiswa as idr, 
                            t_rombelsiswa.kd_tapel as kdt, 
                            t_rombelsiswa.kd_lembaga as kdl
        ');
        $this->db->from('t_students');
        $this->db->join('t_rombelsiswa', 't_students.id_students = t_rombelsiswa.kd_students', 'left');
        $this->db->join('t_kelas', 't_rombelsiswa.kd_kelas = t_kelas.id_kelas', 'left');
        $this->db->join('t_kls', 't_kls.nm_kls = t_kelas.nm_kelas', 'left');
        $this->db->where('t_rombelsiswa.kd_students', $kdsiswa);
        $this->db->where('t_rombelsiswa.kd_lembaga', $newKdlembaga);
        $this->db->where('t_rombelsiswa.kd_tapel', $data['kdTapel']['id_tapel']);
        $query = $this->db->get()->row_array();;
        $this->db->select('*');
        $this->db->from('t_students');
        $this->db->join('t_alumni', 't_students.id_students = t_alumni.kd_students');
        $this->db->join('t_nomor', 't_students.id_students = t_nomor.kd_students');
        $this->db->where('t_alumni.kd_tapel', $data['kdTapel']['id_tapel']);
        $this->db->where('t_alumni.kd_lembaga', $newKdlembaga);
        $this->db->where('t_alumni.kd_students', $kdsiswa);
        $dtsiswa = $this->db->get()->row_array();
        if (!is_null($dtsiswa)) {
            $dtsiswa1 = $dtsiswa;
        }
        $this->db->select('*');
        $this->db->from('t_lembaga');
        $this->db->join('t_jenjang', 't_lembaga.kd_jenjang = t_jenjang.id_jenjang');
        $this->db->join('t_status', 't_lembaga.kd_status = t_status.id_status');
        $this->db->where('t_lembaga.id_lembaga', $newKdlembaga);
        $data['Lembaga'] = $this->db->get()->row_array();
        $this->db->select(' t_tapel.kd_smstr as semester,
                            t_teachers.nm_teachers as kamad,
                            t_teachers.gelar_depan as gelardepan, 
                            t_teachers.gelar_belakang as gelarbelakang, 
                            t_teachers.nip_teachers as nip_kamad,
                            t_tapel.kd_tahun as tahun,
                            t_tgl.tmpt_tgl as tempat,
                            t_tapel.id_tapel as tapel,
                            t_tgl.nm_tgl1 as tanggal,
                            t_tgl.nm_tgl3 as tanggal3
        ');
        $this->db->from('t_tapel');
        $this->db->join('t_tgl', 't_tapel.id_tapel = t_tgl.kd_tapel');
        $this->db->join('t_teachers', 't_tgl.kd_teachers = t_teachers.id_teachers');
        $this->db->where('t_tapel.sts_tapel', 1);
        $this->db->where('t_tapel.kd_lembaga', $kdLembaga);
        $wakturapor = $this->db->get()->row_array();
        $data['lulus'] = $dtsiswa1;
        $data['kelas'] = $query;
        $data['waktu'] = $wakturapor;
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Print Lulus';
        $this->load->view('template/header', $data);
        $this->load->view('kamad/surat_lulus', $data);
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function data_alumni()
    {
        $data['nmUser'] = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $data['nmJenjang'] = $this->db->get_where('t_jenjang', ['id_jenjang' => $this->session->userdata('kd_jenjang')])->row_array();
        $data['nmLevel'] = $this->db->get_where('t_level', ['id_level' => $this->session->userdata('kd_level')])->row_array();
        $data['nmStatus'] = $this->db->get_where('t_status', ['id_status' => $this->session->userdata('status_lembaga')])->row_array();
        $data['nmLembaga'] = $this->db->get_where('t_lembaga', ['id_lembaga' => $this->session->userdata('kd_user')])->row_array();
        $data['nmTapel'] = $this->db->get_where('t_tapel', ['kd_lembaga' => $this->session->userdata('kd_user')])->result_array();
        $newKdlembaga = $data['nmUser']['kd_user'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_tapel.kd_tahun', SORT_ASC);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $data['kdTapel'] = $dataTapel['id_tapel'];
        } else {
            $data['kdTapel'] = 'null';
        }
        $this->db->select('*');
        $this->db->from('t_lembaga');
        $this->db->join('t_jenjang', 't_lembaga.kd_jenjang = t_jenjang.id_jenjang');
        $this->db->join('t_status', 't_lembaga.kd_status = t_status.id_status');
        $this->db->where('t_lembaga.id_lembaga', $newKdlembaga);
        $data['Lembaga'] = $this->db->get()->row_array();
        $this->db->select('*');
        $this->db->from('t_students');
        $this->db->join('t_alumni', 't_students.id_students = t_alumni.kd_students', 'left');
        $this->db->where('t_students.kd_lembaga', $newKdlembaga);
        $siswa = $this->db->get()->result_array();
        if (!is_null($siswa)) {
            $data['Siswa'] = $siswa;
        }
        $data['gMapel'] = $this->db->get('t_gmapel')->result_array();
        $data['naik'] = $this->db->get('t_naik')->result_array();
        $data['lulus'] = $this->db->get('t_lulus')->result_array();
        $data['dtKdp'] = $this->db->get('t_kdp')->result_array();
        $data['eskul'] = $this->db->get('t_eskul')->result_array();
        $data['nilaieskul'] = $this->db->get('t_nilaieskul')->result_array();
        $data['walas'] = $this->db->get('t_walas')->result_array();
        $data['dtKkm'] = $this->m_guru->viewDataKkm();
        $data['dtNilaip'] = $this->m_guru->viewDataNilaip();
        $data['dtWalasGuru'] = $this->m_walas->viewDataWalasGuru();
        $data['dtWalasSiswa'] = $this->m_walas->viewDataNomorIjazah();
        $cekCatatan = $this->db->get_where('t_catatan', array('kd_lembaga' => $newKdlembaga, 'kd_tapel' => $data['kdTapel']))->num_rows();
        $data['cekCatatan'] = $cekCatatan;
        $cekAlumni = $this->db->get_where('t_students', array('kd_lembaga' => $newKdlembaga, 'status_lulus' => 3))->num_rows();
        $data['cekAlumni'] = $this->db->get_where('t_students', array('kd_lembaga' => $newKdlembaga, 'status_lulus' => 3))->num_rows();
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Data Alumni';
        $this->load->view('template/header', $data);
        $this->load->view('template/sidebar', $data);
        $this->load->view('template/headertop', $data);
        $this->load->view('template/mobile', $data);
        if ($cekAlumni > 0) {
            $this->load->view('kamad/data_alumni', $data);
        } else {
            $this->session->set_flashdata('messageInfo', 'Belum ada data alumni tahun ini !');
            $this->load->view('kamad/data_alumni', $data);
        }
        $this->load->view('template/footer', $data);
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function cetak_terima()
    {
        $data['nmUser'] = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $data['nmJenjang'] = $this->db->get_where('t_jenjang', ['id_jenjang' => $this->session->userdata('kd_jenjang')])->row_array();
        $data['nmLevel'] = $this->db->get_where('t_level', ['id_level' => $this->session->userdata('kd_level')])->row_array();
        $data['nmStatus'] = $this->db->get_where('t_status', ['id_status' => $this->session->userdata('status_lembaga')])->row_array();
        $data['nmLembaga'] = $this->db->get_where('t_lembaga', ['id_lembaga' => $this->session->userdata('kd_user')])->row_array();
        $data['nmTapel'] = $this->db->get_where('t_tapel', ['kd_lembaga' => $this->session->userdata('kd_user')])->result_array();
        $newKdlembaga = $data['nmUser']['kd_user'];
        $kdLembaga =  $data['nmLembaga']['id_lembaga'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_tapel.kd_tahun', SORT_ASC);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $data['kdTapel'] = $dataTapel;
        } else {
            $data['kdTapel'] = 'null';
        }
        $data['gMapel'] = $this->db->get('t_gmapel')->result_array();
        $data['kkm'] = $this->db->get('t_kkm')->result_array();
        $data['dtKdp'] = $this->db->get('t_kdp')->result_array();
        $data['kdp'] = $this->db->get('t_nokdp')->result_array();
        $data['nilaip'] = $this->db->get('t_nilaip')->result_array();
        $data['akhirp'] = $this->db->get('t_akhirp')->result_array();
        $data['dtKkm'] = $this->m_guru->viewDataKkm();
        $data['dtNilaip'] = $this->m_guru->viewDataNilaip();
        $data['rSiswap'] = $this->m_guru->viewDataRsiswa();
        $data['nSiswap'] = $this->m_guru->nilaiSiswap();
        $data['tgl'] = $this->m_guru->viewDataTgl();
        $data['Siswa'] = $this->m_walas->viewDataWalasSiswa();
        $this->db->select('*');
        $this->db->from('t_students');
        $this->db->join('t_alumni', 't_students.id_students = t_alumni.kd_students');
        $this->db->where('t_alumni.kd_tapel', $data['kdTapel']['id_tapel']);
        $this->db->where('t_alumni.kd_lembaga', $newKdlembaga);
        $dtsiswa = $this->db->get()->result_array();
        if (!is_null($dtsiswa)) {
            $dtsiswa1 = $dtsiswa;
        }
        $this->db->select('*');
        $this->db->from('t_lembaga');
        $this->db->join('t_status', 't_lembaga.kd_status = t_status.id_status');
        $this->db->join('t_jenjang', 't_lembaga.kd_jenjang = t_jenjang.id_jenjang');
        $this->db->where('t_lembaga.id_lembaga', $kdLembaga);
        $dtlembaga = $this->db->get()->row_array();
        if (!is_null($dtlembaga)) {
            $dtlembaga1 = $dtlembaga;
        }
        $this->db->select(' t_tapel.kd_smstr as semester,
                            t_teachers.nm_teachers as kamad,
                            t_teachers.gelar_depan as gelardepan, 
                            t_teachers.gelar_belakang as gelarbelakang, 
                            t_teachers.nip_teachers as nip_kamad,
                            t_tapel.kd_tahun as tahun,
                            t_tgl.tmpt_tgl as tempat,
                            t_tapel.id_tapel as tapel,
                            t_tgl.nm_tgl1 as tanggal,
                            t_tgl.nm_tgl3 as tanggal3
        ');
        $this->db->from('t_tapel');
        $this->db->join('t_tgl', 't_tapel.id_tapel = t_tgl.kd_tapel');
        $this->db->join('t_teachers', 't_tgl.kd_teachers = t_teachers.id_teachers');
        $this->db->where('t_tapel.sts_tapel', 1);
        $this->db->where('t_tapel.kd_lembaga', $kdLembaga);
        $wakturapor = $this->db->get()->row_array();
        $data['alumni'] = $dtsiswa1;
        $data['lembaga'] = $dtlembaga1;
        $data['waktu'] = $wakturapor;
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Print Terima';
        $this->load->view('template/header', $data);
        $this->load->view('kamad/cetak_terima', $data);
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function cetak_alumni()
    {
        $data['nmUser'] = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $data['nmJenjang'] = $this->db->get_where('t_jenjang', ['id_jenjang' => $this->session->userdata('kd_jenjang')])->row_array();
        $data['nmLevel'] = $this->db->get_where('t_level', ['id_level' => $this->session->userdata('kd_level')])->row_array();
        $data['nmStatus'] = $this->db->get_where('t_status', ['id_status' => $this->session->userdata('status_lembaga')])->row_array();
        $data['nmLembaga'] = $this->db->get_where('t_lembaga', ['id_lembaga' => $this->session->userdata('kd_user')])->row_array();
        $data['nmTapel'] = $this->db->get_where('t_tapel', ['kd_lembaga' => $this->session->userdata('kd_user')])->result_array();
        $newKdlembaga = $data['nmUser']['kd_user'];
        $kdLembaga =  $data['nmLembaga']['id_lembaga'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_tapel.kd_tahun', SORT_ASC);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $data['kdTapel'] = $dataTapel;
        } else {
            $data['kdTapel'] = 'null';
        }
        $this->db->select('*');
        $this->db->from('t_students');
        $this->db->join('t_alumni', 't_students.id_students = t_alumni.kd_students');
        $this->db->where('t_alumni.kd_tapel', $data['kdTapel']['id_tapel']);
        $this->db->where('t_alumni.kd_lembaga', $newKdlembaga);
        $dtsiswa = $this->db->get()->result_array();
        if (!is_null($dtsiswa)) {
            $dtsiswa1 = $dtsiswa;
        }
        $data['alumni'] = $dtsiswa1;
        $data['gMapel'] = $this->db->get('t_gmapel')->result_array();
        $data['kkm'] = $this->db->get('t_kkm')->result_array();
        $data['dtKdp'] = $this->db->get('t_kdp')->result_array();
        $data['kdp'] = $this->db->get('t_nokdp')->result_array();
        $data['nilaip'] = $this->db->get('t_nilaip')->result_array();
        $data['akhirp'] = $this->db->get('t_akhirp')->result_array();
        $data['dtKkm'] = $this->m_guru->viewDataKkm();
        $data['dtNilaip'] = $this->m_guru->viewDataNilaip();
        $data['rSiswap'] = $this->m_guru->viewDataRsiswa();
        $data['nSiswap'] = $this->m_guru->nilaiSiswap();
        $data['tgl'] = $this->m_guru->viewDataTgl();
        $data['Siswa'] = $this->m_walas->viewDataWalasSiswa();
        $this->db->select('*');
        $this->db->from('t_students');
        $this->db->join('t_alumni', 't_students.id_students = t_alumni.kd_students');
        $this->db->where('t_alumni.kd_tapel', $data['kdTapel']['id_tapel']);
        $this->db->where('t_alumni.kd_lembaga', $newKdlembaga);
        $dtsiswa = $this->db->get()->result_array();
        if (!is_null($dtsiswa)) {
            $dtsiswa1 = $dtsiswa;
        }
        $this->db->select('*');
        $this->db->from('t_lembaga');
        $this->db->join('t_status', 't_lembaga.kd_status = t_status.id_status');
        $this->db->join('t_jenjang', 't_lembaga.kd_jenjang = t_jenjang.id_jenjang');
        $this->db->where('t_lembaga.id_lembaga', $kdLembaga);
        $dtlembaga = $this->db->get()->row_array();
        if (!is_null($dtlembaga)) {
            $dtlembaga1 = $dtlembaga;
        }
        $this->db->select(' t_tapel.kd_smstr as semester,
                            t_teachers.nm_teachers as kamad,
                            t_teachers.gelar_depan as gelardepan, 
                            t_teachers.gelar_belakang as gelarbelakang, 
                            t_teachers.nip_teachers as nip_kamad,
                            t_tapel.kd_tahun as tahun,
                            t_tgl.tmpt_tgl as tempat,
                            t_tapel.id_tapel as tapel,
                            t_tgl.nm_tgl1 as tanggal,
                            t_tgl.nm_tgl3 as tanggal3
        ');
        $this->db->from('t_tapel');
        $this->db->join('t_tgl', 't_tapel.id_tapel = t_tgl.kd_tapel');
        $this->db->join('t_teachers', 't_tgl.kd_teachers = t_teachers.id_teachers');
        $this->db->where('t_tapel.sts_tapel', 1);
        $this->db->where('t_tapel.kd_lembaga', $kdLembaga);
        $wakturapor = $this->db->get()->row_array();
        $data['alumni'] = $dtsiswa1;
        $data['lembaga'] = $dtlembaga1;
        $data['waktu'] = $wakturapor;
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Print Alumni';
        $this->load->view('template/header', $data);
        $this->load->view('kamad/cetak_alumni', $data);
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function cetak_lulus()
    {
        $data['nmUser'] = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $data['nmJenjang'] = $this->db->get_where('t_jenjang', ['id_jenjang' => $this->session->userdata('kd_jenjang')])->row_array();
        $data['nmLevel'] = $this->db->get_where('t_level', ['id_level' => $this->session->userdata('kd_level')])->row_array();
        $data['nmStatus'] = $this->db->get_where('t_status', ['id_status' => $this->session->userdata('status_lembaga')])->row_array();
        $data['nmLembaga'] = $this->db->get_where('t_lembaga', ['id_lembaga' => $this->session->userdata('kd_user')])->row_array();
        $data['nmTapel'] = $this->db->get_where('t_tapel', ['kd_lembaga' => $this->session->userdata('kd_user')])->result_array();
        $newKdlembaga = $data['nmUser']['kd_user'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_tapel.kd_tahun', SORT_ASC);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $data['kdTapel'] = $dataTapel['id_tapel'];
        } else {
            $data['kdTapel'] = 'null';
        }
        $data['newTapel'] = $dataTapel;
        $data['gMapel'] = $this->db->get('t_gmapel')->result_array();
        $data['naik'] = $this->db->get('t_naik')->result_array();
        $data['lulus'] = $this->db->get('t_lulus')->result_array();
        $data['dtKdp'] = $this->db->get('t_kdp')->result_array();
        $data['eskul'] = $this->db->get('t_eskul')->result_array();
        $data['nilaieskul'] = $this->db->get('t_nilaieskul')->result_array();
        $data['walas'] = $this->db->get('t_walas')->result_array();
        $data['dtKkm'] = $this->m_guru->viewDataKkm();
        $data['dtNilaip'] = $this->m_guru->viewDataNilaip();
        $data['dtWalasGuru'] = $this->m_walas->viewDataWalasGuru();
        $data['dtWalasSiswa'] = $this->m_walas->viewDataNaikSiswa();
        $cekCatatan = $this->db->get_where('t_catatan', array('kd_lembaga' => $newKdlembaga, 'kd_tapel' => $data['kdTapel']))->num_rows();
        $data['cekCatatan'] = $cekCatatan;
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Print Rapor';
        $cekRombelSiswa = $this->db->get_where('t_ijazah', array('kd_lembaga' => $newKdlembaga, 'kd_tapel' => $data['kdTapel']))->num_rows();
        if ($cekRombelSiswa > 0) {
            $this->load->view('template/header', $data);
            $this->load->view('template/sidebar', $data);
            $this->load->view('template/headertop', $data);
            $this->load->view('template/mobile', $data);
            $this->load->view('kamad/cetak_rapor', $data);
            $this->load->view('template/footer', $data);
        } else {
            $this->session->set_flashdata('messageInfo2', 'Untuk saat ini belum ada data kelulusan !');
            $this->load->view('template/header', $data);
            $this->load->view('template/sidebar', $data);
            $this->load->view('template/headertop', $data);
            $this->load->view('template/mobile', $data);
            $this->load->view('kamad/cetak_rapor', $data);
            $this->load->view('template/footer', $data);
            // created by : KuduSinau_Hendrik_081275532220
        }
    }
    public function cetak_nilai($kdsiswa)
    {
        $data['nmUser'] = $this->db->get_where('t_user', ['username' => $this->session->userdata('username')])->row_array();
        $data['nmJenjang'] = $this->db->get_where('t_jenjang', ['id_jenjang' => $this->session->userdata('kd_jenjang')])->row_array();
        $data['nmLevel'] = $this->db->get_where('t_level', ['id_level' => $this->session->userdata('kd_level')])->row_array();
        $data['nmStatus'] = $this->db->get_where('t_status', ['id_status' => $this->session->userdata('status_lembaga')])->row_array();
        $data['nmLembaga'] = $this->db->get_where('t_lembaga', ['id_lembaga' => $this->session->userdata('kd_user')])->row_array();
        $data['nmTapel'] = $this->db->get_where('t_tapel', ['kd_lembaga' => $this->session->userdata('kd_user')])->result_array();
        $newKdlembaga = $data['nmUser']['kd_user'];
        $kdLembaga =  $data['nmLembaga']['id_lembaga'];
        $this->db->select('*');
        $this->db->from('t_tapel');
        $this->db->where('sts_tapel', 1);
        $this->db->where('kd_lembaga', $newKdlembaga);
        $this->db->order_by('t_tapel.kd_tahun', SORT_ASC);
        $dataTapel = $this->db->get()->row_array();
        if (!is_null($dataTapel)) {
            $data['kdTapel'] = $dataTapel;
        } else {
            $data['kdTapel'] = 'null';
        }
        $data['gMapel'] = $this->db->get('t_gmapel')->result_array();
        $data['kkm'] = $this->db->get('t_kkm')->result_array();
        $data['dtKdp'] = $this->db->get('t_kdp')->result_array();
        $data['kdp'] = $this->db->get('t_nokdp')->result_array();
        $data['nilaip'] = $this->db->get('t_nilaip')->result_array();
        $data['akhirp'] = $this->db->get('t_akhirp')->result_array();
        $data['dtKkm'] = $this->m_guru->viewDataKkm();
        $data['dtNilaip'] = $this->m_guru->viewDataNilaip();
        $data['rSiswap'] = $this->m_guru->viewDataRsiswa();
        $data['nSiswap'] = $this->m_guru->nilaiSiswap();
        $data['tgl'] = $this->m_guru->viewDataTgl();
        $data['Siswa'] = $this->m_walas->viewDataWalasSiswa();
        $data['kdsiswa'] = $kdsiswa;
        $this->db->select(' t_kelas.nm_rombel as kelas, 
                            t_kelas.id_kelas as kdkelas, 
                            t_kelas.nm_kelas as tingkat, 
                            t_kls.huruf_kls as huruf, 
                            t_students.nm_students as siswa, 
                            t_students.nisn_students as nisn, 
                            t_students.nislokal_students as nism, 
                            t_students.id_students as kdsiswa, 
                            t_rombelsiswa.id_rombelsiswa as idr, 
                            t_rombelsiswa.kd_tapel as kdt, 
                            t_rombelsiswa.kd_lembaga as kdl
        ');
        $this->db->from('t_students');
        $this->db->join('t_rombelsiswa', 't_students.id_students = t_rombelsiswa.kd_students', 'left');
        $this->db->join('t_kelas', 't_rombelsiswa.kd_kelas = t_kelas.id_kelas', 'left');
        $this->db->join('t_kls', 't_kls.nm_kls = t_kelas.nm_kelas', 'left');
        $this->db->where('t_rombelsiswa.kd_students', $kdsiswa);
        $this->db->where('t_rombelsiswa.kd_lembaga', $newKdlembaga);
        $this->db->where('t_rombelsiswa.kd_tapel', $data['kdTapel']['id_tapel']);
        $query = $this->db->get()->row_array();;
        $this->db->select('*');
        $this->db->from('t_students');
        $this->db->join('t_alumni', 't_students.id_students = t_alumni.kd_students');
        $this->db->join('t_nomor', 't_students.id_students = t_nomor.kd_students');
        $this->db->where('t_alumni.kd_tapel', $data['kdTapel']['id_tapel']);
        $this->db->where('t_alumni.kd_lembaga', $newKdlembaga);
        $this->db->where('t_alumni.kd_students', $kdsiswa);
        $dtsiswa = $this->db->get()->row_array();
        if (!is_null($dtsiswa)) {
            $dtsiswa1 = $dtsiswa;
        }
        $this->db->select('*');
        $this->db->from('t_lembaga');
        $this->db->join('t_jenjang', 't_lembaga.kd_jenjang = t_jenjang.id_jenjang');
        $this->db->join('t_status', 't_lembaga.kd_status = t_status.id_status');
        $this->db->where('t_lembaga.id_lembaga', $newKdlembaga);
        $data['Lembaga'] = $this->db->get()->row_array();
        $this->db->select(' t_tapel.kd_smstr as semester,
                            t_teachers.nm_teachers as kamad,
                            t_teachers.gelar_depan as gelardepan, 
                            t_teachers.gelar_belakang as gelarbelakang, 
                            t_teachers.nip_teachers as nip_kamad,
                            t_tapel.kd_tahun as tahun,
                            t_tgl.tmpt_tgl as tempat,
                            t_tapel.id_tapel as tapel,
                            t_tgl.nm_tgl1 as tanggal,
                            t_tgl.nm_tgl3 as tanggal3
        ');
        $this->db->from('t_tapel');
        $this->db->join('t_tgl', 't_tapel.id_tapel = t_tgl.kd_tapel');
        $this->db->join('t_teachers', 't_tgl.kd_teachers = t_teachers.id_teachers');
        $this->db->where('t_tapel.sts_tapel', 1);
        $this->db->where('t_tapel.kd_lembaga', $kdLembaga);
        $wakturapor = $this->db->get()->row_array();
        $data['lulus'] = $dtsiswa1;
        $data['kelas'] = $query;
        $data['waktu'] = $wakturapor;
        $data['nama'] = 'Digital Rapor';
        $data['footer'] = 'KuduSinau';
        $data['title'] = 'D-Rapor | Print SKBB';
        $this->load->view('template/header', $data);
        $this->load->view('kamad/cetak_nilai', $data);
        // created by : KuduSinau_Hendrik_081275532220
    }
}
// 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)