<?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 M_guru extends CI_Model
{
    // START VIEW DATA ==============================================================================================
    public function viewDataTgl()
    {
        $this->db->select(' t_teachers.nuptk_teachers as nuptk, 
                            t_teachers.nm_teachers as guru,
                            t_teachers.gelar_depan as gelardepan, 
                            t_teachers.gelar_belakang as gelarbelakang,  
                            t_teachers.sts_teachers as sts, 
                            t_teachers.id_teachers as kdguru, 
                            t_teachers.nip_teachers as nip, 
                            t_tgl.kd_tapel as tapel, 
                            t_tgl.tmpt_tgl as tempat, 
                            t_tgl.nm_tgl1 as tgl1, 
                            t_tgl.nm_tgl3 as tgl3, 
                            t_tgl.kd_lembaga as kdlbg
        ');
        $this->db->from('t_teachers');
        $this->db->join('t_tgl', 't_teachers.id_teachers = t_tgl.kd_teachers', 'left');
        $this->db->order_by('t_tgl.nm_tgl1', SORT_ASC);
        $query = $this->db->get();
        if ($query->num_rows() > 0) {
            return $query->result_array();
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function viewDataKkm()
    {
        $this->db->select(' t_teachers.nuptk_teachers as nuptk, 
                            t_teachers.gelar_depan as gelardepan, 
                            t_teachers.gelar_belakang as gelarbelakang, 
                            t_teachers.nm_teachers as guru, 
                            t_teachers.sts_teachers as sts, 
                            t_teachers.nip_teachers as nip, 
                            t_teachers.id_teachers as kdguru, 
                            t_kelas.nm_rombel as kelas, 
                            t_kelas.id_kelas as kdkelas, 
                            t_kelas.nm_kelas as tingkat, 
                            t_kelas.angka_kelas as tgkt, 
                            t_bidstudy.nm_nmbidstudy as mapel, 
                            t_bidstudy.nm_kdbidstudy as kodemapel, 
                            t_bidstudy.id_bidstudy as kdmapel, 
                            t_gmapel.id_gmapel as idm, 
                            t_gmapel.kd_lembaga as kdl, 
                            t_gmapel.kd_tapel as kdt
        ');
        $this->db->from('t_teachers');
        $this->db->join('t_gmapel', 't_teachers.id_teachers = t_gmapel.kd_teachers', 'left');
        $this->db->join('t_kelas', 't_gmapel.kd_kelas = t_kelas.id_kelas', 'left');
        $this->db->join('t_bidstudy', 't_gmapel.kd_bidstudy = t_bidstudy.id_bidstudy', 'left');
        $this->db->join('t_kkm', 't_gmapel.id_gmapel = t_kkm.kd_gmapel', 'left');
        $this->db->order_by('t_kelas.nm_rombel', SORT_ASC);
        $query = $this->db->get();
        if ($query->num_rows() > 0) {
            return $query->result_array();
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function viewDataNilaip()
    {
        $this->db->select(' t_students.id_students as ids, 
                            t_students.nisn_students as nisn,
                            t_students.nm_students as siswa,
                            t_gmapel.id_gmapel as idgm, 
                            t_kelas.nm_rombel as kelas,
                            t_gmapel.kd_tapel as kdtapel, 
                            t_gmapel.kd_lembaga as kdlbg, 
                            t_kdp.id_kdp as ikdp, 
                            t_kdp.no_kdp as nokdp
        ');
        $this->db->from('t_students');
        $this->db->join('t_rombelsiswa', 't_rombelsiswa.kd_students = t_students.id_students', 'left');
        $this->db->join('t_kelas', 't_rombelsiswa.kd_kelas = t_kelas.id_kelas', 'left');
        $this->db->join('t_gmapel', 't_kelas.id_kelas = t_gmapel.kd_kelas', 'right');
        $this->db->join('t_kdp', 't_gmapel.id_gmapel = t_kdp.kd_gmapel', 'left');
        $this->db->join('t_bidstudy', 't_gmapel.kd_bidstudy = t_bidstudy.id_bidstudy', 'left');
        //$this->db->join('t_nilaip', 't_kdp.id_kdp = t_nilaip.kd_kdp', 'left');
        $this->db->order_by('t_students.nm_students', SORT_ASC);
        $query = $this->db->get();
        if ($query->num_rows() > 0) {
            return $query->result_array();
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function viewDataNilaik()
    {
        $this->db->select(' t_students.id_students as ids, 
                            t_students.nisn_students as nisn,
                            t_students.nm_students as siswa,
                            t_gmapel.id_gmapel as idgm, 
                            t_gmapel.kd_tapel as kdtapel, 
                            t_gmapel.kd_lembaga as kdlbg, 
                            t_kelas.nm_rombel as kelas, 
                            t_kdk.id_kdk as ikdk
        ');
        $this->db->from('t_students');
        $this->db->join('t_rombelsiswa', 't_rombelsiswa.kd_students = t_students.id_students', 'left');
        $this->db->join('t_kelas', 't_rombelsiswa.kd_kelas = t_kelas.id_kelas', 'left');
        $this->db->join('t_gmapel', 't_kelas.id_kelas = t_gmapel.kd_kelas', 'right');
        $this->db->join('t_kdk', 't_gmapel.id_gmapel = t_kdk.kd_gmapel', 'left');
        $this->db->join('t_bidstudy', 't_gmapel.kd_bidstudy = t_bidstudy.id_bidstudy', 'left');
        $this->db->order_by('t_students.nm_students', SORT_ASC);
        $query = $this->db->get();
        if ($query->num_rows() > 0) {
            return $query->result_array();
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function viewDataRsiswa()
    {
        $this->db->select(' t_kelas.nm_rombel as kelas, 
                            t_kelas.id_kelas as kdkelas, 
                            t_students.nm_students as siswa, 
                            t_students.nisn_students as nisn, 
                            t_students.id_students as kdsiswa, 
                            t_rombelsiswa.id_rombelsiswa as idr, 
                            t_rombelsiswa.kd_lembaga as kdl, 
                            t_rombelsiswa.kd_tapel as kdtapel, 
                            t_gmapel.id_gmapel as idgmapel
        ');
        $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_gmapel', 't_kelas.id_kelas = t_gmapel.kd_kelas', 'right');
        $this->db->order_by('t_kelas.nm_rombel', SORT_ASC);
        $query = $this->db->get();
        return $query->result_array();
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function nilaiSiswap()
    {
        $this->db->select(' t_students.id_students as ids, 
                            t_kdp.id_kdp as ikdp, 
                            t_kdp.no_kdp as nokdp, 
                            t_nilaip.n_p as nilai, 
                            t_gmapel.id_gmapel as idgm, 
                            t_gmapel.kd_tapel as kdtapel, 
                            t_gmapel.kd_lembaga as kdlbg,
                            t_nilaip.tipe_n as tipe
        ');
        $this->db->from('t_students');
        $this->db->join('t_nilaip', 't_students.id_students = t_nilaip.kd_students', 'left');
        $this->db->join('t_kdp', 't_kdp.id_kdp = t_nilaip.kd_kdp', 'left');
        $this->db->join('t_gmapel', 't_nilaip.kd_gmapel = t_gmapel.id_gmapel', 'left');
        $query = $this->db->get();
        return $query->result_array();
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function nilaiSiswak()
    {
        $this->db->select(' t_students.id_students as ids, 
                            t_kdk.id_kdk as ikdk, 
                            t_kdk.no_kdk as nokdk, 
                            t_nilaik.n_k as nilai, 
                            t_gmapel.id_gmapel as idgm, 
                            t_gmapel.kd_tapel as kdtapel, 
                            t_gmapel.kd_lembaga as kdlbg, 
                            t_nilaik.tipe_n as tipe
        ');
        $this->db->from('t_students');
        $this->db->join('t_nilaik', 't_students.id_students = t_nilaik.kd_students', 'left');
        $this->db->join('t_kdk', 't_kdk.id_kdk = t_nilaik.kd_kdk', 'left');
        $this->db->join('t_gmapel', 't_nilaik.kd_gmapel = t_gmapel.id_gmapel', 'left');
        $query = $this->db->get();
        return $query->result_array();
        // created by : KuduSinau_Hendrik_081275532220
    }
    // END VIEW DATA ==============================================================================================

    // START CRUD DATA ==============================================================================================
    public function inputDataKkmKelas($data)
    {
        $query = $this->db->insert('t_kkm', $data);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function updateDataKkmKelas($data, $idGmapel)
    {
        $query = $this->db->update("t_kkm", $data, $idGmapel);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function inputDataKdp($data)
    {
        $query = $this->db->insert('t_kdp', $data);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function inputAllDataKdp($data)
    {
        $query = $this->db->insert_batch('t_kdp', $data);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function inputAllDataKdk($data)
    {
        $query = $this->db->insert_batch('t_kdk', $data);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function deleteDataKdp($idKdp)
    {
        $query = $this->db->delete("t_kdp", $idKdp);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function inputDataNilaip($data)
    {
        $query = $this->db->insert_batch('t_nilaip', $data);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function updateDataNilaip($data, $rs)
    {
        $query = $this->db->update_batch("t_nilaip", $data, $rs);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function inputDataKdk($data)
    {
        $query = $this->db->insert('t_kdk', $data);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function deleteDataKdk($idKdk)
    {
        $query = $this->db->delete("t_kdk", $idKdk);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function inputDataNilaik($data)
    {
        $query = $this->db->insert_batch('t_nilaik', $data);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function updateDataNilaik($data, $rs)
    {
        $query = $this->db->update_batch("t_nilaik", $data, $rs);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function inputDataNilaiAkhirk($data)
    {
        $query = $this->db->insert_batch('t_akhirk', $data);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function updateDataNilaiAkhirk($dt, $rsa)
    {
        $query = $this->db->update_batch("t_akhirk", $dt, $rsa);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function updateDataNilaiAkhirp($dt, $rsa)
    {
        $query = $this->db->update_batch("t_akhirp", $dt, $rsa);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function updateDataNilaiIjazah($dti, $rsa)
    {
        $query = $this->db->update_batch("t_ijazah", $dti, $rsa);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function inputDataNilaiAkhirp($data)
    {
        $query = $this->db->insert_batch('t_akhirp', $data);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    public function inputDataNilaiIjazah($dti)
    {
        $query = $this->db->insert_batch('t_ijazah', $dti);
        if ($query) {
            return true;
        } else {
            return false;
        }
        // created by : KuduSinau_Hendrik_081275532220
    }
    // END CRUD DATA ==============================================================================================
}
// 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)