db->insert($table, $data); }else{ $insert = $this->db->insert_batch($table, $data); } return $insert; } public function insert($table, $data) { $insert = $this->db->insert($table, $data); return $insert; } public function getHujianById($id) { $this->db->where_in('h_ujian', $id); $query = $this->db->get('mahasiswa_id')->result(); return $query; } public function update($table, $data, $pk, $id = null, $batch = false) { if($batch === false){ $insert = $this->db->update($table, $data, array($pk => $id)); }else{ $insert = $this->db->update_batch($table, $data, $pk); } return $insert; } public function delete($table, $data, $pk) { $this->db->where_in($pk, $data); return $this->db->delete($table); } /** * Data Jurusan */ public function getDataJurusan() { $this->datatables->select('id_jurusan, nama_jurusan'); $this->datatables->from('jurusan'); $this->datatables->add_column('bulk_select', '
', 'id_jurusan, nama_jurusan'); return $this->datatables->generate(); } public function getJurusanById($id) { $this->db->where_in('id_jurusan', $id); $this->db->order_by('nama_jurusan'); $query = $this->db->get('jurusan')->result(); return $query; } /** * Data Matkul MKWU */ public function getDataMatkulMKWU() { $this->datatables->select('id_matkul, nama_matkul'); $this->datatables->from('mkwu_matkul'); $this->datatables->add_column('bulk_select', '', 'id_matkul, nama_matkul'); return $this->datatables->generate(); } public function getMatkulMKWUById($id) { $this->db->where_in('id_matkul', $id); $this->db->order_by('nama_matkul'); $query = $this->db->get('mkwu_matkul')->result(); return $query; } // public function getMatkulMKWU() // { // $this->db->select('id_matkul, nama_matkul'); // $this->db->from('kelas'); // $this->db->join('mkwu_matkul', 'matkul_id=id_matkul'); // $this->db->order_by('nama_matkul', 'ASC'); // $this->db->group_by('id_matkul'); // $query = $this->db->get(); // return $query->result(); // } public function getAllMatkulMKWU() { return $this->db->get('mkwu_matkul')->result(); } /** * Data Kelas MKWU */ public function getKelasMKWU() { $this->db->select('id_kelas, nama_kelas'); $this->db->from('mkwu_kelas'); $this->db->order_by('nama_kelas', 'ASC'); $this->db->group_by('id_kelas'); $query = $this->db->get(); return $query->result(); } public function getDataKelasMKWU() { $this->datatables->select('id_kelas, nama_kelas, id_jurusan, nama_jurusan'); $this->datatables->from('mkwu_kelas'); $this->datatables->join('jurusan', 'jurusan_id=id_jurusan'); $this->datatables->add_column('bulk_select', '', 'id_kelas, nama_kelas, id_jurusan, nama_jurusan'); return $this->datatables->generate(); } public function getKelasMKWUById($id) { $this->db->where_in('id_kelas', $id); $this->db->order_by('nama_kelas'); $query = $this->db->get('mkwu_kelas')->result(); return $query; } public function getKelasMKWUByJurusan($id) { $query = $this->db->get_where('mkwu_kelas', array('jurusan_id'=>$id)); return $query->result(); } public function getAllKelasMKWU() { $this->db->select('id_kelas, nama_kelas, nama_jurusan'); $this->db->from('mkwu_kelas'); $this->db->join('jurusan', 'jurusan_id=id_jurusan'); $this->db->order_by('nama_kelas'); return $this->db->get()->result(); } /** * Data Kelompok Soal MKWU */ public function getDataKsoal() { $this->datatables->select('id_ksoal, nama_ksoal'); $this->datatables->from('mkwu_ksoal'); return $this->datatables->generate(); } public function getAllKsoal() { $this->db->order_by('nama_ksoal', 'ASC'); return $this->db->get('mkwu_ksoal')->result(); } public function getKsoalById($id, $single = false) { if($single === false){ $this->db->where_in('id_ksoal', $id); $this->db->order_by('nama_ksoal'); $query = $this->db->get('mkwu_ksoal')->result(); }else{ $query = $this->db->get_where('mkwu_ksoal', array('id_ksoal'=>$id))->row(); } return $query; } /** * Data Dosen MKWU */ public function getDataDosenMKWU() { $this->datatables->select('a.id_dosen,a.nidn, a.nama_dosen, a.email, a.matkul_id, b.nama_matkul, (SELECT COUNT(id) FROM users WHERE username = a.nidn OR email = a.email) AS ada'); $this->datatables->from('mkwu_dosen a'); $this->datatables->join('mkwu_matkul b', 'a.matkul_id=b.id_matkul'); return $this->datatables->generate(); } public function getDosenMKWUById($id) { $query = $this->db->get_where('mkwu_dosen', array('id_dosen'=>$id)); return $query->row(); } public function getDosenMKWU() { return $this->db->get('mkwu_dosen')->result(); } /** * Data Mahasiswa MKWU */ public function getDataMahasiswaMKWU() { $this->datatables->select('a.id_mahasiswa, a.nama, a.nim, a.email, b.nama_kelas, c.nama_jurusan'); $this->datatables->select('a.id_mahasiswa, a.nama, a.nim, a.email, b.nama_kelas'); $this->datatables->select('(SELECT COUNT(id) FROM users WHERE username = a.nim) AS ada'); $this->datatables->from('mkwu_mahasiswa a'); $this->datatables->join('mkwu_kelas b', 'a.kelas_id=b.id_kelas'); $this->datatables->join('jurusan c', 'b.jurusan_id=c.id_jurusan'); return $this->datatables->generate(); } public function getMahasiswaMKWUById($id) { $this->db->select('*'); $this->db->from('mkwu_mahasiswa'); $this->db->join('mkwu_kelas', 'kelas_id=id_kelas'); $this->db->join('jurusan', 'jurusan_id=id_jurusan'); $this->db->where(['id_mahasiswa' => $id]); return $this->db->get()->row(); } /** * Data Kelas Dosen */ public function getDosenKelasMKWU() { $this->datatables->select('mkwu_dosen_kelas.id, mkwu_dosen.id_dosen, mkwu_dosen.nidn, mkwu_dosen.nama_dosen, GROUP_CONCAT(mkwu_kelas.nama_kelas) as kelas'); $this->datatables->from('mkwu_dosen_kelas'); $this->datatables->join('mkwu_kelas', 'kelas_id=id_kelas'); $this->datatables->join('mkwu_dosen', 'dosen_id=id_dosen'); $this->datatables->group_by('mkwu_dosen.nama_dosen'); return $this->datatables->generate(); } public function getAllDosenMKWU($id = null) { $this->db->select('dosen_id'); $this->db->from('mkwu_dosen_kelas'); if($id !== null){ $this->db->where_not_in('dosen_id', [$id]); } $dosen = $this->db->get()->result(); $id_dosen = []; foreach ($dosen as $d) { $id_dosen[] = $d->dosen_id; } if($id_dosen === []){ $id_dosen = null; } $this->db->select('id_dosen, nidn, nama_dosen'); $this->db->from('mkwu_dosen'); $this->db->where_not_in('id_dosen', $id_dosen); return $this->db->get()->result(); } public function getKelasMKWUByDosen($id) { $this->db->select('mkwu_kelas.id_kelas'); $this->db->from('mkwu_dosen_kelas'); $this->db->join('mkwu_kelas', 'mkwu_dosen_kelas.kelas_id=mkwu_kelas.id_kelas'); $this->db->where('dosen_id', $id); $query = $this->db->get()->result(); return $query; } /** * Data kSOAL Matkul */ public function getKsoalMatkulMKWU() { $this->datatables->select('mkwu_ksoal_matkul.id, mkwu_ksoal.id_ksoal, mkwu_ksoal.nama_ksoal, mkwu_matkul.id_matkul, GROUP_CONCAT(mkwu_matkul.nama_matkul) as nama_matkul'); $this->datatables->from('mkwu_ksoal_matkul'); $this->datatables->join('mkwu_ksoal', 'ksoal_id=id_ksoal'); $this->datatables->join('mkwu_matkul', 'matkul_id=id_matkul'); $this->datatables->group_by('mkwu_ksoal.nama_ksoal'); return $this->datatables->generate(); } public function getAllMatkulMKWUrelasi($id = null) { if($id === null){ $this->db->order_by('nama_matkul', 'ASC'); return $this->db->get('mkwu_matkul')->result(); }else{ $this->db->select('matkul_id'); $this->db->from('mkwu_ksoal_matkul'); $this->db->where('ksoal_id', $id); $matkul = $this->db->get()->result(); $id_matkul = []; foreach ($matkul as $j) { $id_matkul[] = $j->matkul_id; } if($id_matkul === []){ $id_matkul = null; } $this->db->select('*'); $this->db->from('mkwu_matkul'); $this->db->where_not_in('id_matkul', $id_matkul); $ksoal = $this->db->get()->result(); return $ksoal; } } public function getAddKsoalMKWU($id = null) { $this->db->select('ksoal_id'); $this->db->from('mkwu_ksoal_matkul'); if($id !== null){ $this->db->where_not_in('ksoal_id', [$id]); } $ksoal = $this->db->get()->result(); $id_ksoal = []; foreach ($ksoal as $d) { $id_ksoal[] = $d->ksoal_id; } if($id_ksoal === []){ $id_ksoal = null; } $this->db->select('id_ksoal, nama_ksoal'); $this->db->from('mkwu_ksoal'); $this->db->where_not_in('id_ksoal', $id_ksoal); return $this->db->get()->result(); } public function getAllMatkulAdd($id = null) { if($id === null){ $this->db->order_by('nama_Matkul', 'ASC'); return $this->db->get('mkwu_matkul')->result(); }else{ $this->db->select('matkul_id'); $this->db->from('mkwu_ksoal_matkul'); $this->db->where('ksoal_id', $id); $matkul = $this->db->get()->result(); $id_matkul = []; foreach ($matkul as $j) { $id_matkul[] = $j->matkul_id; } if($id_matkul === []){ $id_matkul = null; } $this->db->select('*'); $this->db->from('mkwu_matkul'); $this->db->where_not_in('id_matkul', $id_matkul); $matkul = $this->db->get()->result(); return $matkul; } } public function getALLMatkulM() { $this->db->select('*'); $this->db->from('mkwu_matkul'); $this->db->order_by('nama_matkul', 'ASC'); $this->db->group_by('id_matkul'); $query = $this->db->get(); return $query->result(); } public function getMatkulMKWUByIdKsoal($id) { $this->db->select('mkwu_matkul.id_matkul'); $this->db->from('mkwu_ksoal_matkul'); $this->db->join('mkwu_matkul', 'mkwu_ksoal_matkul.matkul_id=mkwu_matkul.id_matkul'); $this->db->where('ksoal_id', $id); $query = $this->db->get()->result(); return $query; } // public function getMatkulMKWU_($id = null) // { // $this->db->select('matkul_id'); // $this->db->from('jurusan_matkul'); // if($id !== null){ // $this->db->where_not_in('matkul_id', [$id]); // } // $matkul = $this->db->get()->result(); // $id_matkul = []; // foreach ($matkul as $d) { // $id_matkul[] = $d->matkul_id; // } // if($id_matkul === []){ // $id_matkul = null; // } // $this->db->select('id_matkul, nama_matkul'); // $this->db->from('matkul'); // $this->db->where_not_in('id_matkul', $id_matkul); // return $this->db->get()->result(); // } public function getMatkulByIdKsoal($id) { $this->db->select('mkwu_matkul.id_matkul'); $this->db->from('mkwu_ksoal_matkul'); $this->db->join('mkwu_matkul', 'mkwu_ksoal_matkul.matkul_id=mkwu_matkul.id_matkul'); $this->db->where('ksoal_id', $id); $query = $this->db->get()->result(); return $query; } public function getJurusan() { $this->db->select('id_jurusan, nama_jurusan'); $this->db->from('mkwu_kelas'); $this->db->join('jurusan', 'jurusan_id=id_jurusan'); $this->db->order_by('nama_jurusan', 'ASC'); $this->db->group_by('id_jurusan'); $query = $this->db->get(); return $query->result(); } public function getALLJurusanMKWU() { $this->db->select('*'); $this->db->from('jurusan'); $this->db->order_by('nama_jurusan', 'ASC'); $this->db->group_by('id_jurusan'); $query = $this->db->get(); return $query->result(); } public function getAllJurusan($id = null) { if($id === null){ $this->db->order_by('nama_jurusan', 'ASC'); return $this->db->get('jurusan')->result(); }else{ $this->db->select('jurusan_id'); $this->db->from('jurusan_matkul'); $this->db->where('matkul_id', $id); $jurusan = $this->db->get()->result(); $id_jurusan = []; foreach ($jurusan as $j) { $id_jurusan[] = $j->jurusan_id; } if($id_jurusan === []){ $id_jurusan = null; } $this->db->select('*'); $this->db->from('jurusan'); $this->db->where_not_in('id_jurusan', $id_jurusan); $matkul = $this->db->get()->result(); return $matkul; } } /** * Data Jurusan Matkul */ // KALAU DIPERLUKAN MASTER RELASI JURUSAN KELAS // public function getJurusanMatkul() // { // $this->datatables->select('jurusan_matkul.id, matkul.id_matkul, matkul.nama_matkul, jurusan.id_jurusan, GROUP_CONCAT(jurusan.nama_jurusan) as nama_jurusan'); // $this->datatables->from('jurusan_matkul'); // $this->datatables->join('matkul', 'matkul_id=id_matkul'); // $this->datatables->join('jurusan', 'jurusan_id=id_jurusan'); // $this->datatables->group_by('matkul.nama_matkul'); // return $this->datatables->generate(); // } // public function getMatkul($id = null) // { // $this->db->select('matkul_id'); // $this->db->from('jurusan_matkul'); // if($id !== null){ // $this->db->where_not_in('matkul_id', [$id]); // } // $matkul = $this->db->get()->result(); // $id_matkul = []; // foreach ($matkul as $d) { // $id_matkul[] = $d->matkul_id; // } // if($id_matkul === []){ // $id_matkul = null; // } // $this->db->select('id_matkul, nama_matkul'); // $this->db->from('matkul'); // $this->db->where_not_in('id_matkul', $id_matkul); // return $this->db->get()->result(); // } }