load->library('session'); } function nm_field($column,$tbl,$whereb, $wherea){ $q = "SELECT ".$column." as nm FROM ".$tbl." where ".$whereb." = '".$wherea."' " ; $query = $this->db->query($q); $nm= ''; if ($query->num_rows() != 0) { $row = $query->row(); $nm=$row->nm; } return $nm; } function oto($var){ $q = "SELECT getOtonoPmb(".$var.") as nm;"; $query = $this->db->query($q); $nm= ''; if ($query->num_rows() != 0) { $row = $query->row(); $nm=$row->nm; } return $nm; } // START PENGGUNA function grid(){ //ISTRA //kurikulum.kdprodi, //kurikulum.tahunmsk, $kdprodi = $this->input->post("kdprodi"); $idkelas = $this->input->post("idkelas"); $tahunmsk = $this->input->post("tahunmsk"); $kdthnakademik = $this->input->post("kdthnakademik"); $nmjnssemester = trim(substr($kdthnakademik, 10, 6)); $kdstsemester = $this->input->post("kdstsemester"); $nim = $this->input->post("nim"); $KEDUA= $this->load->database('second', TRUE); $q = $KEDUA->query("SELECT `kurikulum`.`idkurikulum` AS `idkurikulum` , `kurikulum`.`kdprodi` AS `kdprodi` , `kurikulum`.`thnmasuk` AS `thnmasuk` , `kurikulum`.`kdmk` AS `kdmk` , `matakuliah`.`nmmkind` AS `nmmkind` , `kurikulum`.`idsemester` AS `idsemester` , `jsemester`.`nmjnssemester` AS `nmjnssemester` , `kurikulum`.`jmlsks` AS `jmlsks` , (SELECT `vv_status_semester`.`kdstsemester` FROM `vv_status_semester` WHERE (`vv_status_semester`.`idstatus` = 1)) AS `kdstsemester` , (SELECT `dosen`.`nmdosdgngelar` FROM `dosen` WHERE (`dosen`.`nidu` = (SELECT `struprogdet`.`nidu` AS `nidu` FROM `struprogdet` WHERE ((`struprogdet`.`kdstsemester` = (SELECT `vv_status_semester`.`kdstsemester` AS `kdstsemester` FROM `vv_status_semester` WHERE (`vv_status_semester`.`idstatus` = 1))) AND (`struprogdet`.`kdprodi` = `kurikulum`.`kdprodi`) AND (`struprogdet`.`kdmk` = `kurikulum`.`kdmk`) AND (`struprogdet`.idkelas='".$idkelas."') AND (`struprogdet`.idjnsdosen='1'))))) AS namadosen , (SELECT `dosen`.`nidu` FROM `dosen` WHERE (`dosen`.`nidu` = (SELECT `struprogdet`.`nidu` AS `nidu` FROM `struprogdet` WHERE ((`struprogdet`.`kdstsemester` = (SELECT `vv_status_semester`.`kdstsemester` AS `kdstsemester` FROM `vv_status_semester` WHERE (`vv_status_semester`.`idstatus` = 1))) AND (`struprogdet`.`kdprodi` = `kurikulum`.`kdprodi`) AND (`struprogdet`.`kdmk` = `kurikulum`.`kdmk`) AND (`struprogdet`.idkelas='".$idkelas."') AND (`struprogdet`.idjnsdosen='1'))))) AS nidudosen , if(((SELECT `nilai`.`kdmk` FROM `nilai` WHERE ((`nilai`.`kdstsemester` = (SELECT `vv_status_semester`.`kdstsemester` FROM `vv_status_semester` WHERE (`vv_status_semester`.`idstatus` = 1))) AND (`nilai`.`kdprodi` = `kurikulum`.`kdprodi`) AND (`nilai`.`kdmk` = `kurikulum`.`kdmk`) AND (`nilai`.`nim` = '".$nim."') AND idstambilmk <> '6')) = `kurikulum`.`kdmk`), 1, 0) AS `ambilval` , (SELECT `nilai`.`idstambilmk` FROM `nilai` WHERE ((`nilai`.`kdstsemester` = (SELECT `vv_status_semester`.`kdstsemester` FROM `vv_status_semester` WHERE (`vv_status_semester`.`idstatus` = 1))) AND (`nilai`.`kdprodi` = `kurikulum`.`kdprodi`) AND (`nilai`.`kdmk` = `kurikulum`.`kdmk`) AND (`nilai`.`nim` = '".$nim."'))) AS `idstambilmk1` , (SELECT `nilai`.accnilaihuruf FROM `nilai` WHERE ((`nilai`.`kdstsemester` = (SELECT `vv_status_semester`.`kdstsemester` FROM `vv_status_semester` WHERE (`vv_status_semester`.`idstatus` = 1))) AND (`nilai`.`kdprodi` = `kurikulum`.`kdprodi`) AND (`nilai`.`kdmk` = `kurikulum`.`kdmk`) AND (`nilai`.`nim` = '".$nim."'))) AS `nilai` , (SELECT `nilai`.idstsetuju FROM `nilai` WHERE ((`nilai`.`kdstsemester` = (SELECT `vv_status_semester`.`kdstsemester` FROM `vv_status_semester` WHERE (`vv_status_semester`.`idstatus` = 1))) AND (`nilai`.`kdprodi` = `kurikulum`.`kdprodi`) AND (`nilai`.`kdmk` = `kurikulum`.`kdmk`) AND (`nilai`.`nim` = '".$nim."'))) AS `idstkrs` , (SELECT `stambilmk`.`nmstambilmk` FROM `stambilmk` WHERE `stambilmk`.`idstambilmk` = `idstambilmk1`) as namaambil , (SELECT `stsetuju`.`nmstsetuju` FROM `stsetuju` WHERE `stsetuju`.`idstsetuju` = `idstkrs`) AS namasetuju , (SELECT count(syaratmk.idsyaratmk) FROM syaratmk WHERE syaratmk.idkurikulum = `kurikulum`.idkurikulum) AS jmlsyaratmk FROM (((`kurikulum` JOIN `matakuliah` ON (((`kurikulum`.`kdmk` = `matakuliah`.`kdmk`) AND (`kurikulum`.`kdprodi` = `matakuliah`.`kdprodi`)))) JOIN `semester` ON ((`kurikulum`.`idsemester` = `semester`.`idsemester`))) JOIN `jsemester` ON ((`semester`.`idjnssemester` = `jsemester`.`idjnssemester`))) WHERE `kurikulum`.kdprodi='".$kdprodi."' AND `kurikulum`.thnmasuk='".$tahunmsk."' AND `kurikulum`.idsemester IN (SELECT stmhssemester.idsemester FROM stmhssemester WHERE stmhssemester.nim='".$nim."' AND stmhssemester.kdstsemester='".$kdstsemester."') ORDER BY `kurikulum`.`idsemester` , `kurikulum`.`kdmk`"); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $ttl = count($data); $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); $sks = 0; $statkrs =''; foreach($data as $row) { $sks = $sks + $row->jmlsks; if($row->nilai== null || $row->nilai==''){ $row->nilai = "-"; } array_push($build_array["data"],array( 'idkurikulum'=>$row->idkurikulum, 'kdmk'=>$row->kdmk, 'nmmk'=>$row->nmmkind, 'idsemester'=>$row->idsemester, 'jmlsks'=>$row->jmlsks, 'tahunmsk'=>$row->thnmasuk, 'nidupengajar'=>($row->nidudosen) ? $row->nidudosen:'-', 'namapengajar'=>($row->namadosen) ? $row->namadosen:'-', 'jadwal'=>($this->gridjadwalmk($kdstsemester,$kdprodi,$row->kdmk,$idkelas)) ? $this->gridjadwalmk($kdstsemester,$kdprodi,$row->kdmk,$idkelas):'-', //ambil jadwal kuliah 'ambilval'=>$row->ambilval, 'setujuval'=>(!$row->idstkrs || $row->idstkrs== 2) ? 0:$row->idstkrs, 'nilai'=>$row->nilai, 'idstkrs'=>(!$row->idstkrs || $row->idstkrs== 2) ? 0:$row->idstkrs, 'idstambilmk1'=>$row->idstambilmk1, 'namaambil'=>($row->namaambil) ? $row->namaambil:'-', 'namasetuju'=>($row->namasetuju) ? $row->namasetuju:'-', 'jmlsyaratmk'=>($row->jmlsyaratmk != 0) ? $row->jmlsyaratmk:0, 'syaratmk'=>($this->gridsyaratmk($nim,$row->idkurikulum,$row->thnmasuk)) ? $this->gridsyaratmk($nim,$row->idkurikulum,$row->thnmasuk):'-', //ambil syarat makul 'ketsyaratmk'=>($this->gridketsyaratmk($nim,$row->idkurikulum)) ? $this->gridketsyaratmk($nim,$row->idkurikulum):'-', //ambil keterangan syarat makul )); } $carisks = $this->input->post("carisks"); if ($carisks != ''){ echo '{"jumlahsks":'.$sks."}"; }else{ $build_array["jumlahsks"]=$sks; echo json_encode($build_array); } } function gridjadwalmk($kdstsemester,$kdprodi,$kdmk,$idkelas){ ////untuk mengambil jadwal kuliah $KEDUA= $this->load->database('second', TRUE); $q = $KEDUA->query("SELECT * FROM v_jadwalkuliah WHERE kdstsemester = '$kdstsemester' AND kdprodi = '$kdprodi' AND kdmk = '$kdmk' AND idkelas = '$idkelas'"); $jadwal=''; $a=1; $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } foreach($data as $row) { $jadwal .=$a.". ".($row->nmhari).", ".($row->mulai)." - ".($row->selesai)." - Kelas ".($row->nmkelas)." - Ruangan ".($row->nmruangan)." "."
"; $a= $a + 1; } return $jadwal; } function gridsyaratmk($nim,$idkurikulum,$thnmasuk){ ////untuk mengambil syarat matakuliah $KEDUA= $this->load->database('second', TRUE); $q = $KEDUA->query("SELECT v_syaratmk.kdmk , v_syaratmk.nmmkind , v_syaratmk.idsemester , v_syaratmk.jmlsks , v_syaratmk.nmlvlsyaratmk , v_syaratmk.nilaihurufmin , v_syaratmk.bobotnilaimin , (SELECT accnilaihuruf FROM nilai WHERE kdmk = v_syaratmk.kdmk AND nim = '$nim') AS nilaihurufmhs , (SELECT accbobotnilai FROM nilai WHERE kdmk = v_syaratmk.kdmk AND nim = '$nim') AS bobotnilaimhs , (if((SELECT accbobotnilai FROM nilai WHERE kdmk = v_syaratmk.kdmk AND nim = '$nim') > v_syaratmk.bobotnilaimin, 'Lulus Syarat', 'Tidak Lulus Syarat')) AS keterangan FROM v_syaratmk WHERE idkurikulum = '$idkurikulum' AND thnmasuk= '$thnmasuk'"); $makul=''; $a=1; $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } foreach($data as $row) { $makul .=$a.". ".($row->nmmkind) ." - Nilai (".(($row->nilaihurufmhs) ? $row->nilaihurufmhs:'-')." > ".(($row->nilaihurufmin) ? $row->nilaihurufmin:'-').") ". ($row->keterangan)."
"; $a= $a + 1; } return $makul; } function gridketsyaratmk($nim,$idkurikulum){ //untuk keterangan lulus syarat atau tidak $KEDUA= $this->load->database('second', TRUE); $q = $KEDUA->query("SELECT (if((SELECT bobotnilai FROM nilai WHERE kdmk = v_syaratmk.kdmk AND nim = '$nim') > v_syaratmk.bobotnilaimin, 'Lulus Syarat', 'Tidak Lulus Syarat')) AS keterangan FROM v_syaratmk WHERE idkurikulum = '$idkurikulum'"); $ket=''; $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } foreach($data as $row) { if ($row->keterangan == 'Tidak Lulus Syarat') { $ket = 'Tidak Lulus Syarat'; return $ket; } else { $ket = $row->keterangan; } } return $ket; } function form_mhs(){ //ISTRA $KEDUA= $this->load->database('second', TRUE); /*membuka koneksi database untuk d_mahasiswa*/ // $nama = $this->input->post("nama"); $userid = $this->input->post("userid"); $kdstsemester = $this->input->post("kdstsemester"); $KEDUA->select("*"); $KEDUA->from("vv_mahasiswa_profile2"); if($userid!=''){ $where['nim']=$userid; $KEDUA->where($where); } $q = $KEDUA->get(); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $datax = $KEDUA->count_all('vv_mahasiswa_profile2'); $ttl = $datax; $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); foreach($data as $row) { array_push($build_array["data"],array( 'nim'=>$row->nim, 'nmmhs'=>$row->nmmhs, 'nmfakultas'=>$row->nmfakultas, 'nmprodi'=>$row->nmprodi, 'kdprodi'=>$row->kdprodi, 'idklsmhs'=>$row->idklsmhs, 'tahunmsk'=>$row->thnmasuk, //in beda 'persen'=>'-',//'100', 'stbayar'=>'-', 'foto'=>$row->foto, 'idjnssemester'=>$row->idjnssemester, 'kdstsemester'=>$row->kdstsemester, 'kdthnakademik'=>$row->kdthnakademik.' - '.$row->nmjnssemester, 'idkelas'=>$this->get_kelas_semester($kdstsemester,$userid) )); } echo json_encode($build_array); } function get_kelas_semester($kdstsemester,$nim){ ////untuk mengambil jadwal kuliah $KEDUA= $this->load->database('second', TRUE); $q = $KEDUA->query("SELECT idkelas FROM stmhssemester WHERE kdstsemester = '$kdstsemester' AND nim = '$nim'"); $kelas=''; $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } foreach($data as $row) { $kelas = $row->idkelas; } return $kelas; } function kelengkapan(){ $KEDUA= $this->load->database('second', TRUE); $nim = $this->input->post("nim"); $kdprodi = $this->input->post("kdprodi"); $idklsmhs = $this->input->post("idklsmhs"); $tahunmsk = $this->input->post("tahunmsk"); $kdstsemester = $this->input->post("kdstsemester"); $q = "SELECT getkelengkapan('".$nim."','".$kdprodi."','".$idklsmhs."','".$tahunmsk."','".$kdstsemester."') as nm;"; $query = $KEDUA->query($q); $nm= ''; if ($query->num_rows() > 0) { $row = $query->row(); $nm=$row->nm; } echo $nm; } function getjadwalkrs(){ $KEDUA= $this->load->database('second', TRUE); $kdprodi = $this->input->post("kdprodi"); $kdstsemester = $this->input->post("kdstsemester"); $q = "SELECT getjadwalkrs('".$kdprodi."','".$kdstsemester."') as jdwl;"; $query = $KEDUA->query($q); $jdwl= ''; if ($query->num_rows() > 0) { $row = $query->row(); $jdwl=$row->jdwl; } echo $jdwl; } function getsistemkrs(){ $KEDUA= $this->load->database('second', TRUE); $kdprodi = $this->input->post("kdprodi"); $nim = $this->input->post("nim"); $kdstsemester = $this->input->post("kdstsemester"); $q = "SELECT idsiskrs,kdsiskrs,nmsiskrs FROM v_setkrs WHERE kdprodi='".$kdprodi."' AND idsemester IN (SELECT stmhssemester.idsemester FROM stmhssemester WHERE stmhssemester.nim='".$nim."' AND stmhssemester.kdstsemester='".$kdstsemester."')"; $query = $KEDUA->query($q); $jdwl= ''; if ($query->num_rows() > 0) { $row = $query->row(); $return["stat"]=1; $return["idsiskrs"]=$row->idsiskrs; $return["kdsiskrs"]=$row->kdsiskrs; $return["nmsiskrs"]=$row->nmsiskrs; } else { $return["stat"]=0; $return["idsiskrs"]=''; $return["kdsiskrs"]=''; $return["nmsiskrs"]=''; } echo json_encode($return); } //========================================S K S====================================== function simpanambilsks(){ $KEDUA= $this->load->database('second', TRUE); $get_par=$this->input->post("par_ambil"); $KEDUA->trans_begin(); $rows = explode(";",$get_par); $row_count = count($rows); for($ri=0;$ri<$row_count;$ri++){ $rows2 = explode("x",$rows[$ri]); $KEDUA->query("CALL SP_insertambilkrs (?,?,?,?,?,?,?,?,?)", array( $rows2[0], //kdstsemester $rows2[1], //kdprodi $rows2[2], //nim $rows2[3], //kdmk $rows2[4], //nidu $rows2[5], //niduwali $rows2[6], //idstambilmk $rows2[7], //nilai $rows2[8])); //ipkterakhir } if ($KEDUA->trans_status() === FALSE) { $KEDUA->trans_rollback(); $return["success"]=false; $return["message"]="Simpan Data gagal"; } else { $KEDUA->trans_commit(); $return["success"]=true; $return["message"]="Simpan Data Berhasil"; } return $return; } function simpansetujusks(){ $KEDUA= $this->load->database('second', TRUE); $get_par=$this->input->post("par_setuju"); $KEDUA->trans_begin(); $rows = explode(";",$get_par); $row_count = count($rows); for($ri=0;$ri<$row_count;$ri++){ $rows2 = explode("x",$rows[$ri]); $KEDUA->query("CALL SP_insertsetujukrs (?,?,?,?,?,?,?,?,?,?,?)", array( $rows2[0], //kdstsemester $rows2[1], //kdprodi $rows2[2], //idklsmhs $rows2[3], //nim $rows2[4], //kdmk $rows2[5], //nidu $rows2[6], //niduwali $rows2[7], //idstambilmk $rows2[8], //idstsetuju $rows2[9], //nilai $rows2[10])); //ipkterakhir } if ($KEDUA->trans_status() === FALSE) { $KEDUA->trans_rollback(); $return["success"]=false; $return["message"]="Simpan Data gagal"; } else { $KEDUA->trans_commit(); $return["success"]=true; $return["message"]="Simpan Data Berhasil"; } return $return; } //========================================P A K E T====================================== function simpanambilpaket(){ $KEDUA= $this->load->database('second', TRUE); $get_par=$this->input->post("par_ambil"); $KEDUA->trans_begin(); $rows = explode(";",$get_par); $row_count = count($rows); for($ri=0;$ri<$row_count;$ri++){ $rows2 = explode("x",$rows[$ri]); $KEDUA->query("CALL SP_insertambilkrspaket (?,?,?,?,?,?,?,?)", array( $rows2[0], //kdstsemester $rows2[1], //kdprodi $rows2[2], //nim $rows2[3], //kdmk $rows2[4], //nidu $rows2[5], //niduwali $rows2[6], //nilai $rows2[7])); //ipkterakhir } if ($KEDUA->trans_status() === FALSE) { $KEDUA->trans_rollback(); $return["success"]=false; $return["message"]="Simpan Data gagal"; } else { $KEDUA->trans_commit(); $return["success"]=true; $return["message"]="Simpan Data Berhasil"; } return $return; } function simpansetujupaket(){ $KEDUA= $this->load->database('second', TRUE); $get_par=$this->input->post("par_setuju"); $KEDUA->trans_begin(); $rows = explode(";",$get_par); $row_count = count($rows); for($ri=0;$ri<$row_count;$ri++){ $rows2 = explode("x",$rows[$ri]); $KEDUA->query("CALL SP_insertsetujukrspaket (?,?,?,?,?,?,?,?,?)", array( $rows2[0], //kdstsemester $rows2[1], //kdprodi $rows2[2], //idklsmhs $rows2[3], //nim $rows2[4], //kdmk $rows2[5], //nidu $rows2[6], //niduwali $rows2[7], //nilai $rows2[8])); //ipkterakhir } if ($KEDUA->trans_status() === FALSE) { $KEDUA->trans_rollback(); $return["success"]=false; $return["message"]="Simpan Data gagal"; } else { $KEDUA->trans_commit(); $return["success"]=true; $return["message"]="Simpan Data Berhasil"; } return $return; } //========================================TEMP====================================== /* function gridsyarat(){ //ISTRA $nim = $this->input->post("nim"); $idkurikulum = $this->input->post("idkurikulum"); $KEDUA= $this->load->database('second', TRUE); $q = $KEDUA->query("SELECT v_syaratmk.kdmk , v_syaratmk.nmmkind , v_syaratmk.idsemester , v_syaratmk.jmlsks , v_syaratmk.nmlvlsyaratmk , v_syaratmk.nilaihurufmin , v_syaratmk.bobotnilaimin , (SELECT nilaihuruf FROM nilai WHERE kdmk = v_syaratmk.kdmk AND nim = '$nim') AS nilaihurufmhs , (SELECT bobotnilai FROM nilai WHERE kdmk = v_syaratmk.kdmk AND nim = '$nim') AS bobotnilaimhs , (if((SELECT bobotnilai FROM nilai WHERE kdmk = v_syaratmk.kdmk AND nim = '$nim') > v_syaratmk.bobotnilaimin, 'Lulus Syarat', 'Tidak Lulus Syarat')) AS keterangan FROM v_syaratmk WHERE idkurikulum = '$idkurikulum'"); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $ttl = count($data); $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); foreach($data as $row) { array_push($build_array["data"],array( 'kdmk'=>$row->kdmk, 'nmmk'=>$row->nmmkind, 'idsemester'=>$row->idsemester, 'jmlsks'=>$row->jmlsks, 'nmlvlsyaratmk'=>$row->nmlvlsyaratmk, 'nilaihurufmin'=>($row->nilaihurufmin) ? $row->nilaihurufmin:'-', 'bobotnilaimin'=>($row->bobotnilaimin) ? $row->bobotnilaimin:0, 'nilaihurufmhs'=>($row->nilaihurufmhs) ? $row->nilaihurufmhs:'-', 'bobotnilaimhs'=>($row->bobotnilaimhs) ? $row->bobotnilaimhs:0, 'keterangan'=>$row->keterangan )); } echo json_encode($build_array); } */ }