load->library('session'); $this->load->library('rhlib'); } function getJsonFromSP($sql, $parameters){ $query = $this->db->query($sql, $parameters); $data = array(); $build_array = array ("success"=>false,"results"=>-1,"data"=>array(),"msg"=>"error"); if ($query->num_rows() == 0) { $build_array["success"]=true; $build_array["results"]=0; $build_array["msg"]="no data"; } if ($query->num_rows() > 0) { $data = $query->result(); $ttl = count($data); if($ttl > 0){ $build_array["success"]=true; $build_array["results"]=$ttl; $build_array["data"]=$data; $build_array["msg"]= ""; } } echo json_encode($build_array); } function get_nim_ori(){ /* //FOR DEBUGING select nim, SUBSTR(nim, 11, 4) as nuourut, nmmhs, SUBSTR(nim, 1, 10) as awal from mahasiswa WHERE SUBSTR(nim, 1, 10) = '4115202010'; */ //$prefix = $_POST['prefix']; $kdunla = $_POST['kdunla']; $nourutprodi = $_POST['nourutprodi']; $stawal = $_POST['stawal']; $kdth = $_POST['kdth']; $table = "mahasiswa"; $idTobeNum = "nim"; //"SUBSTR(nim, 11, 4)"; //jika 4 digit terakhir saja yg berupa angka //$cond = "SUBSTR(nim, 1, 10) = '".$prefix."'"; //"nim like '".$prefix."%'"; //$default = $prefix."0001"; // 1; jika hanya diambil bilangan terakhir saja $cond = "SUBSTR(nim, 1, 7) = '".$kdunla.$nourutprodi."' AND SUBSTR(nim, 9, 2) = '".$kdth."'"; //"nim like '".$prefix."%'"; $default = $kdunla.$nourutprodi.$stawal.$kdth."0001"; // 1; jika hanya diambil bilangan terakhir saja $nim = $this->rhlib->get_autoNum($table, $idTobeNum, $cond, $default); echo json_encode(array ("success"=>true,"nim"=>$nim)); } function get_nim(){ $kdunla = $_POST['kdunla']; $nourutprodi = $_POST['nourutprodi']; $stawal = $_POST['stawal']; $kdth = $_POST['kdth']; $q = "SELECT getOtoNim('$kdunla','$nourutprodi','$stawal','$kdth') as nim"; $query = $this->db->query($q); if ($query->num_rows() == 1) $nim = $query->row()->nim; echo json_encode(array ("success"=>true,"nim"=>$nim)); } function get_mhs(){ $kdprodi = $_POST['kdprodi']; $thnmasuk = $_POST['thnmasuk']; $q = "SELECT a.nim AS nim , a.nmmhs AS nmmhs , a.kdjnskelamin AS jnskelamin , concat(a.tptlahir, ', ', date_format(a.tgllahir, '%d/%m/%Y')) AS ttl , b.nmkodtbkod AS agama , a.nohpmhs AS nohpmhs , a.alamatasal AS alamatasal , a.nmortu AS nmortu , a.nmortuayah AS nmortuayah , a.thnmasuk AS thnmasuk , c.nmprodi AS nmprodi , d.nmkodtbkod AS shiftmhs , e.nmklsmhs AS nmklmhs , f.nmthnakademik AS nmthnakademik , g.nmkodtbkod AS kdstawalmhs , h.nmkodtbkod AS kdstaktivitasmhs , i.nmcutidet AS nmcutidet , a.idpekerjaanmhs , j.kdpekerjaanmhs , j.nmpekerjaanmhs , CASE WHEN a.idpekerjaanmhs IS NULL OR a.idpekerjaanmhs = 10 THEN 'Belum Bekerja' ELSE 'Sudah Bekerja' END AS stbekerja , a.noktp AS noktp , a.nmptasal AS nmptasal FROM mahasiswa a LEFT JOIN tbkod b ON a.kdagama = b.kdkodtbkod AND b.kdapltbkod = 51 LEFT JOIN prodi c ON a.kdprodi = c.kdprodi LEFT JOIN tbkod d ON a.shiftmhs = d.kdkodtbkod AND d.kdapltbkod = 64 LEFT JOIN klsmhs e ON a.idklsmhs = e.idklsmhs LEFT JOIN v_tahunakademik f ON a.kdstsemester = f.kdstsemester LEFT JOIN tbkod g ON a.kdstawalmhs = g.kdkodtbkod AND g.kdapltbkod = 12 LEFT JOIN tbkod h ON a.kdstaktivitasmhs = h.kdkodtbkod AND h.kdapltbkod = 5 LEFT JOIN cutidet i ON a.catnonaktif = i.idcutidet LEFT JOIN pekerjaanmhs j ON a.idpekerjaanmhs = j.idpekerjaanmhs WHERE a.kdprodi = '$kdprodi' AND a.thnmasuk = '$thnmasuk' ORDER BY a.nim"; $this->rhlib->jsonFromQueryWLimit($q); } function get_mhsById(){ $nim = $_POST['nim']; $q = "SELECT DISTINCT a.*, b.nmfakultas, b.nourutprodi, b.nmprodi, ifnull(b.lnmprodi,b.nmprodi) as lnmprodi, b.nmjenjangstudi, c.nmstawal, d.nmstaktiv, e.nmkotkabasal, f.nmkotkabsurat, g.nmkotkabortu, h.nmkotkabslta, i.nmproslta, j.nmkotkabortuayah, k.kdjenjasal, k.nmjenjasal, pm.nmdosdgngelar AS nmpembimbing, pm1.nmdosdgngelar AS nmpembimbing1, sdng1.nmdosdgngelar AS sdngdosen1, sdng2.nmdosdgngelar AS sdngdosen2 FROM mahasiswa a LEFT JOIN (SELECT kdprodi, nourutprodi, nmprodi, CONCAT(RTRIM(nourutprodi),'. ',nmprodi,' (',nmjenjangstudi,')') as lnmprodi, nmfakultas, kdjenjangstudi, nmjenjangstudi, tglawalberdiri, email, noskakreditasi, tglskakreditasi, notelpprodi FROM v_prodi where kdprodi <> '')b ON b.kdprodi=a.kdprodi LEFT JOIN (SELECT kdkodtbkod as kdstawal, nmkodtbkod as nmstawal FROM tbkod WHERE kdapltbkod='06')c ON a.kdstawalmhs=c.kdstawal LEFT JOIN (SELECT kdkodtbkod as kdstaktiv, nmkodtbkod as nmstaktiv FROM tbkod WHERE kdapltbkod='05')d ON a.kdstaktivitasmhs=d.kdstaktiv LEFT JOIN (SELECT CONCAT(rtrim(kdprotbpro),ltrim(kdkabtbpro)) as kdkota, nmkabtbpro as nmkotkabasal FROM tbpro where kdkabtbpro <> '')e ON a.kdkotkabasal = e.kdkota LEFT JOIN (SELECT CONCAT(rtrim(kdprotbpro),ltrim(kdkabtbpro)) as kdkota, nmkabtbpro as nmkotkabsurat FROM tbpro where kdkabtbpro <> '')f ON a.kdkotkabsurat = f.kdkota LEFT JOIN (SELECT CONCAT(rtrim(kdprotbpro),ltrim(kdkabtbpro)) as kdkota, nmkabtbpro as nmkotkabortu FROM tbpro where kdkabtbpro <> '')g ON a.kdkotkabortu = g.kdkota LEFT JOIN (SELECT CONCAT(rtrim(kdprotbpro),ltrim(kdkabtbpro)) as kdkota, nmkabtbpro as nmkotkabslta FROM tbpro where kdkabtbpro <> '')h ON a.kdkotkabslta = h.kdkota LEFT JOIN (SELECT kdprotbpro, nmprotbpro as nmproslta FROM tbpro where kdprotbpro <> '')i ON a.kdpropinsislta = i.kdprotbpro LEFT JOIN (SELECT CONCAT(rtrim(kdprotbpro),ltrim(kdkabtbpro)) as kdkota, nmkabtbpro as nmkotkabortuayah FROM tbpro where kdkabtbpro <> '')j ON a.kdkotkabortuayah = j.kdkota LEFT JOIN (SELECT kdkodtbkod AS kdjenjasal, nmkodtbkod AS nmjenjasal FROM tbkod WHERE kdapltbkod = '01') k ON a.kdjenjangstudiasal = k.kdjenjasal LEFT JOIN (SELECT nidu , nmdosdgngelar FROM dosen) pm ON a.idpembimbing = pm.nidu LEFT JOIN (SELECT nidu , nmdosdgngelar FROM dosen) pm1 ON a.idpembimbing1 = pm1.nidu LEFT JOIN (SELECT nidu , nmdosdgngelar FROM dosen) sdng1 ON a.penyidang1 = sdng1.nidu LEFT JOIN (SELECT nidu , nmdosdgngelar FROM dosen) sdng2 ON a.penyidang2 = sdng2.nidu WHERE a.nim='".$nim."'"; $query = $this->db->query($q); $data = array(); $build_array = array ("success"=>false,"results"=>0,"data"=>array(),"msg"=>"no data"); if ($query->num_rows() > 0) { $data = $query->result(); $ttl = count($data); if($ttl == 1){ $build_array["success"]=true; $build_array["msg"]= ""; } $build_array["results"]=$ttl; $build_array["data"]=$data; $build_array["msg"]= "data lebih dari satu!"; } echo json_encode($build_array); } //--------------------excel-----------------------// function export_excel($kdprodi,$thnmasuk) { $querymhs = "SELECT a.nim AS nim , a.nmmhs AS nmmhs , a.noktp , a.nmptasal , a.kdjnskelamin AS jnskelamin , concat(a.tptlahir, ', ', date_format(a.tgllahir, '%d/%m/%Y')) AS ttl , b.nmkodtbkod AS agama , a.nohpmhs AS nohpmhs , a.alamatasal AS alamatasal , a.kelurahanasal AS kelurahanasal , a.kecamatanasal AS kecamatanasal , a.nmortu AS nmortu , a.nmortuayah AS nmortuayah , a.thnmasuk AS thnmasuk , c.nmprodi AS nmprodi , d.nmkodtbkod AS shiftmhs , e.nmklsmhs AS nmklmhs , f.nmthnakademik AS nmthnakademik , g.nmkodtbkod AS kdstawalmhs , h.nmkodtbkod AS kdstaktivitasmhs , i.nmcutidet AS nmcutidet , a.idpekerjaanmhs , j.kdpekerjaanmhs , j.nmpekerjaanmhs , CASE WHEN a.idpekerjaanmhs IS NULL OR a.idpekerjaanmhs = 10 THEN 'Belum Bekerja' ELSE 'Sudah Bekerja' END AS stbekerja FROM mahasiswa a LEFT JOIN tbkod b ON a.kdagama = b.kdkodtbkod AND b.kdapltbkod = 51 LEFT JOIN prodi c ON a.kdprodi = c.kdprodi LEFT JOIN tbkod d ON a.shiftmhs = d.kdkodtbkod AND d.kdapltbkod = 64 LEFT JOIN klsmhs e ON a.idklsmhs = e.idklsmhs LEFT JOIN v_tahunakademik f ON a.kdstsemester = f.kdstsemester LEFT JOIN tbkod g ON a.kdstawalmhs = g.kdkodtbkod AND g.kdapltbkod = 12 LEFT JOIN tbkod h ON a.kdstaktivitasmhs = h.kdkodtbkod AND h.kdapltbkod = 5 LEFT JOIN cutidet i ON a.catnonaktif = i.idcutidet LEFT JOIN pekerjaanmhs j ON a.idpekerjaanmhs = j.idpekerjaanmhs WHERE a.kdprodi = '$kdprodi' AND a.thnmasuk = '$thnmasuk' ORDER BY a.nim"; $data['eksport'] = $this->db->query($querymhs)->result(); $data['table'] = "excel_daftar_mhs"; $data['fieldname'] = array(); $getloop='loop'; foreach ($data['eksport'] as $row) { if ($getloop=='loop') { foreach ($row as $key => $value) { array_push($data['fieldname'], $key); } } $getloop='end'; } $this->load->view('exportexcel', $data); } /* function lookup_mhs(){ $kdprodi = $_POST['kdprodi']; $q = "SELECT DISTINCT a.*, b.nmfakultas, b.nourutprodi, b.nmprodi, ifnull(b.lnmprodi,b.nmprodi) as lnmprodi, b.nmjenjangstudi, c.nmstawal, d.nmstaktiv, k.biaya, k.idsetbiaya FROM mahasiswa a LEFT JOIN setbiaya k ON a.kdprodi = k.kdprodi LEFT JOIN (SELECT kdprodi, nourutprodi, nmprodi, CONCAT(RTRIM(nourutprodi),'. ',nmprodi,' (',nmjenjangstudi,')') as lnmprodi, nmfakultas, kdjenjangstudi, nmjenjangstudi FROM v_prodi where kdprodi <> '')b ON b.kdprodi=a.kdprodi LEFT JOIN (SELECT kdkodtbkod as kdstawal, nmkodtbkod as nmstawal FROM tbkod WHERE kdapltbkod='06')c ON a.kdstawalmhs=c.kdstawal LEFT JOIN (SELECT kdkodtbkod as kdstaktiv, nmkodtbkod as nmstaktiv FROM tbkod WHERE kdapltbkod='05')d ON a.kdstaktivitasmhs=d.kdstaktiv WHERE a.kdprodi='$kdprodi'"; $this->rhlib->jsonFromQueryWLimit($q); } */ function lookup_mhs(){ $this->load->library('rhlib'); $kdprodi = $_POST['kdprodi']; $q = "SELECT DISTINCT a.* , b.nmfakultas , b.nourutprodi , b.nmprodi , ifnull(b.lnmprodi, b.nmprodi) AS lnmprodi , b.nmjenjangstudi , c.nmstawal , d.nmstaktiv -- , e.nmdosdgngelar AS nmpembimbing FROM mahasiswa a LEFT JOIN (SELECT kdprodi , nourutprodi , nmprodi , concat(rtrim(nourutprodi), '. ', nmprodi, ' (', nmjenjangstudi, ')') AS lnmprodi , nmfakultas , kdjenjangstudi , nmjenjangstudi FROM v_prodi WHERE kdprodi <> '') b ON b.kdprodi = a.kdprodi LEFT JOIN (SELECT kdkodtbkod AS kdstawal , nmkodtbkod AS nmstawal FROM tbkod WHERE kdapltbkod = '06') c ON a.kdstawalmhs = c.kdstawal LEFT JOIN (SELECT kdkodtbkod AS kdstaktiv , nmkodtbkod AS nmstaktiv FROM tbkod WHERE kdapltbkod = '05') d ON a.kdstaktivitasmhs = d.kdstaktiv -- LEFT JOIN dosen e ON e.nidu=a.idpembimbing WHERE a.kdprodi = '$kdprodi'"; $this->rhlib->jsonFromQueryWLimit($q); } //status mahasiswa (mahasiswa perprodi)// function lookup_add_mhsprodi(){ //$kdstsemester = $_POST['kdstsemester']; $kdprodi = $_POST['kdprodi']; $opsi = $_POST['opsi']; //KONDISI UNTUK STATUS AKTIFITAS MAHASISWA// if($opsi == ''){ $staktifmhs= "AND a.kdstaktivitasmhs='A'"; } else if($opsi != ''){ $staktifmhs= ""; } //QUERY// $q = "SELECT `a`.`nim` AS `nim` , `a`.`nmmhs` AS `nmmhs` , `a`.`nmortu` AS `nmortu` , `a`.`kdjnskelamin` AS `kdjnskelamin` , `a`.`thnmasuk` AS `thnmasuk` , `a`.`idklsmhs` AS `idklsmhs` , `b`.`nmklsmhs` AS `nmklsmhs` , `b`.`idjnskls` AS `idjnskls` , `c`.`nmkodtbkod` AS `stdaftar` , `d`.`nmkodtbkod` AS `staktif` , `e`.`nmprodi` AS `nmprodi` , `f`.`nmfakultas` AS `nmfakultas` , `f`.`kdfakultas` AS `kdfakultas` FROM (((((`mahasiswa` `a` LEFT JOIN `klsmhs` `b` ON ((`b`.`idklsmhs` = `a`.`idklsmhs`))) LEFT JOIN `tbkod` `c` ON (((`c`.`kdkodtbkod` = `a`.`kdstawalmhs`) AND (`c`.`kdapltbkod` = '06')))) LEFT JOIN `tbkod` `d` ON (((`d`.`kdkodtbkod` = `a`.`kdstaktivitasmhs`) AND (`d`.`kdapltbkod` = '05')))) LEFT JOIN `prodi` `e` ON ((`e`.`kdprodi` = `a`.`kdprodi`))) LEFT JOIN `fakultas` `f` ON ((`f`.`kdfakultas` = `e`.`kdfakultas`))) WHERE a.kdprodi='".$kdprodi."' ".$staktifmhs.""; $this->rhlib->jsonFromQueryWLimit($q); } //status mahasiswa (mahasiswa cuti)// function lookup_add_mhscuti(){ $kdstsemester = $_POST['kdstsemester']; $kdprodi = $_POST['kdprodi']; $opsi = $_POST['opsi']; //KONDISI UNTUK STATUS AKTIFITAS MAHASISWA// if($opsi == ''){ $staktifmhs= "AND a.kdstaktivitasmhs='A'"; } else if($opsi != ''){ $staktifmhs= ""; } //QUERY// /* $q1 = "SELECT `a`.`nim` AS `nim` , `a`.`nmmhs` AS `nmmhs` , `a`.`nmortu` AS `nmortu` , `a`.`kdjnskelamin` AS `kdjnskelamin` , `a`.`thnmasuk` AS `thnmasuk` , `a`.`idklsmhs` AS `idklsmhs` , `b`.`nmklsmhs` AS `nmklsmhs` , `c`.`nmkodtbkod` AS `stdaftar` , `d`.`nmkodtbkod` AS `staktif` , `e`.`nmprodi` AS `nmprodi` , `f`.`nmfakultas` AS `nmfakultas` , `f`.`kdfakultas` AS `kdfakultas` FROM (((((`mahasiswa` `a` LEFT JOIN `klsmhs` `b` ON ((`b`.`idklsmhs` = `a`.`idklsmhs`))) LEFT JOIN `tbkod` `c` ON (((`c`.`kdkodtbkod` = `a`.`kdstawalmhs`) AND (`c`.`kdapltbkod` = '06')))) LEFT JOIN `tbkod` `d` ON (((`d`.`kdkodtbkod` = `a`.`kdstaktivitasmhs`) AND (`d`.`kdapltbkod` = '05')))) LEFT JOIN `prodi` `e` ON ((`e`.`kdprodi` = `a`.`kdprodi`))) LEFT JOIN `fakultas` `f` ON ((`f`.`kdfakultas` = `e`.`kdfakultas`))) LEFT JOIN `kuitansi` `g` ON ((`g`.`nim` = `a`.`nim`))) WHERE a.kdprodi='".$kdprodi."' ".$staktifmhs." AND g.kdstsemester"; $this->rhlib->jsonFromQueryWLimit($q); */ $q = "SELECT `a`.`nim` AS `nim` , `a`.`nmmhs` AS `nmmhs` , `a`.`nmortu` AS `nmortu` , `a`.`kdjnskelamin` AS `kdjnskelamin` , `a`.`thnmasuk` AS `thnmasuk` , `a`.`idklsmhs` AS `idklsmhs` , `b`.`nmklsmhs` AS `nmklsmhs` , `c`.`nmkodtbkod` AS `stdaftar` , `d`.`nmkodtbkod` AS `staktif` , `e`.`nmprodi` AS `nmprodi` , `f`.`nmfakultas` AS `nmfakultas` , `f`.`kdfakultas` AS `kdfakultas` FROM `mahasiswa` `a` LEFT JOIN `klsmhs` `b` ON `b`.`idklsmhs` = `a`.`idklsmhs` LEFT JOIN `tbkod` `c` ON `c`.`kdkodtbkod` = `a`.`kdstawalmhs` AND `c`.`kdapltbkod` = '06' LEFT JOIN `tbkod` `d` ON `d`.`kdkodtbkod` = `a`.`kdstaktivitasmhs` AND `d`.`kdapltbkod` = '05' LEFT JOIN `prodi` `e` ON `e`.`kdprodi` = `a`.`kdprodi` LEFT JOIN `fakultas` `f` ON `f`.`kdfakultas` = `e`.`kdfakultas` LEFT JOIN `kuitansi` `g` ON `g`.`nim` = `a`.`nim` WHERE a.kdprodi='".$kdprodi."' ".$staktifmhs." AND g.kdstsemester = '".$kdstsemester."' AND `g`.idjnsbiaya = '3'"; $this->rhlib->jsonFromQueryWLimit($q); } //status mahasiswa (mahasiswa pernyataan)// function lookup_add_mhspernyataan(){ $kdstsemester = $_POST['kdstsemester']; $kdprodi = $_POST['kdprodi']; $opsi = $_POST['opsi']; //KONDISI UNTUK STATUS AKTIFITAS MAHASISWA// if($opsi == ''){ $staktifmhs= "AND h.kdstaktivitasmhs='A'"; } else if($opsi != ''){ $staktifmhs= ""; } //QUERY// $q = "SELECT `a`.`nim` AS `nim` , `a`.`nmmhs` AS `nmmhs` , `a`.`nmortu` AS `nmortu` , `a`.`alamatortu` AS `alamatortu` , `a`.`kdjnskelamin` AS `kdjnskelamin` , `a`.kdstsemester AS kdstsemestermasuk , `a`.`thnmasuk` AS `thnmasuk` , `a`.`idklsmhs` AS `idklsmhs` , `b`.`nmklsmhs` AS `nmklsmhs` , `b`.`idjnskls` AS `idjnskls` , `c`.`nmkodtbkod` AS `stdaftar` , `d`.`nmkodtbkod` AS `staktif` , `e`.`nmprodi` AS `nmprodi` , `f`.`nmfakultas` AS `nmfakultas` , `f`.`kdfakultas` AS `kdfakultas` , `h`.kdstsemester AS kdstsemester , `i`.idsemester AS idsemester , `j`.nmpekerjaanortu AS nmpekerjaanortu , `a`.idpekerjaanortu AS idpekerjaanortu , concat(`i`.`tingkat`, '/ ', `i`.`kdsemester`) AS `semester` FROM stmhssemester `h` LEFT JOIN mahasiswa `a` ON `a`.nim = `h`.`nim` LEFT JOIN `semester` `i` ON `i`.idsemester = `h`.idsemester LEFT JOIN `klsmhs` `b` ON `b`.`idklsmhs` = `a`.`idklsmhs` LEFT JOIN `tbkod` `c` ON (`c`.`kdkodtbkod` = `a`.`kdstawalmhs`) AND (`c`.`kdapltbkod` = '06') LEFT JOIN `tbkod` `d` ON (`d`.`kdkodtbkod` = `a`.`kdstaktivitasmhs`) AND (`d`.`kdapltbkod` = '05') LEFT JOIN `prodi` `e` ON `e`.`kdprodi` = `a`.`kdprodi` LEFT JOIN `fakultas` `f` ON `f`.`kdfakultas` = `e`.`kdfakultas` LEFT JOIN `pekerjaanortu` `j` ON `j`.`idpekerjaanortu` = `a`.`idpekerjaanortu` WHERE a.kdprodi='".$kdprodi."' ".$staktifmhs." AND h.kdstsemester = '".$kdstsemester."' "; $this->rhlib->jsonFromQueryWLimit($q); } function insert_mhs(){ $dataArray = $this->getFieldsAndValues(); $dataArrayPublic = $this->getFieldsAndValuesPublic(); $ret = $this->rhlib->insertRecord('mahasiswa',$dataArray); $cekuserid = $this->cekusermhs(); $arrUserprodi = array( 'userid'=> str_replace(" ","",$_POST['nim']), 'kdprodi'=> $_POST['kdprodi'], ); if ($ret) { if ($cekuserid == 0) { $this->rhlib->insertRecordPublic('pengguna',$dataArrayPublic); $this->rhlib->insertRecordPublic('penggunaprodi',$arrUserprodi); } $this->update_mhs_pmb($_POST['nim']); //menjalankan function lain } return $ret; } function update_mhs(){ $fieldsAndValues = $this->getFieldsAndValues(); $fieldsAndValuesPublic = $this->getFieldsAndValuesPublicUpdate(); //UPDATE $this->db->where('idmhs', $_POST['idmhs']); $this->db->update('mahasiswa', $fieldsAndValues); //UPDATE PUBLIC $where['userid'] = $_POST['nim']; //$this->rhlib->updateRecordPublic('pengguna',$fieldsAndValuesPublic,$where); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; // $this->update_mhs_pmb($_POST['nim']); // $this->update_mhs_pmb_job($_POST['nmtptbekerjamhs'],$_POST['idpekerjaanmhs'],$_POST['alamatkerkamhs']); $this->update_stmhssemester(); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function update_mhs_pmb_job($nmtptbekerjamhs,$idpekerjaanmhs,$alamatkerjamhs){ $KEDUA= $this->load->database('second', TRUE); $dataArray = array( 'nmtptbekerjamhs'=> $this->retValOrNull($nmtptbekerjamhs), 'idpekerjaanmhs'=> $this->retValOrNull($idpekerjaanmhs), 'alamatkerjamhs'=> $this->retValOrNull($alamatkerjamhs), ); $KEDUA->where('nopmb', $_POST['nopmb']); $KEDUA->update('pmb', $dataArray); if($KEDUA->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function update_stmhssemester(){ $fieldsAndValuesStmhssemester = $this->getFieldsAndValuesTblStmhssemesterUpdate(); //UPDATE STMHSSEMESTER $this->db->where('nim', $_POST['nim']); $this->db->update('stmhssemester', $fieldsAndValuesStmhssemester); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function getFieldsAndValues(){ $login = $this->session->userdata("user_idunlaprivate"); $datetime = date("Y-m-d H:i:s"); $ip = $_SERVER['REMOTE_ADDR']; $dataArray = array( //PERSONAL 'last_login'=> $login, 'last_date'=> $datetime, 'last_ip'=> $ip, 'nim'=> str_replace(" ","",$_POST['nim']), //$_POST['tf.npm-mhs'], 'noktp'=> $_POST['noktp'], 'nmmhs'=> strtoupper($_POST['nmmhs']), //$_POST['tf.nama-mhs'], 'kdjnskelamin'=> $this->retValOrNull($_POST['kdjnskelamin']), 'tptlahir'=> $_POST['tptlahir'], 'tgllahir'=> $_POST['tgllahir'], 'kdagama'=> $this->retValOrNull($_POST['kdagama']), 'idgoldarah'=> $this->retValOrNull($_POST['idgoldarah']), 'kdwn'=> $this->retValOrNull($_POST['kdwn']), 'notelpmhs'=> $_POST['notelpmhs'], 'nohpmhs'=> $_POST['nohpmhs'], 'alamatasal'=> $_POST['alamatasal'], 'kelurahanasal'=> $_POST['kelurahanasal'], 'kecamatanasal'=> $_POST['kecamatanasal'], 'kdkotkabasal'=> $_POST['kdkotkabasal'], 'kdposasal'=> $_POST['kdposasal'], 'alamatsurat'=> $_POST['alamatsurat'], 'kelurahansurat'=> $_POST['kelurahansurat'], 'kecamatansurat'=> $_POST['kecamatansurat'], 'kdkotkabsurat'=> $_POST['kdkotkabsurat'], 'kdpossurat'=> $_POST['kdpossurat'], //ORTU (IBU) 'nmortu'=> $_POST['nmortu'], 'idpekerjaanortu'=> $this->retValOrNull($_POST['idpekerjaanortu']), 'idpendidikanortu'=> $this->retValOrNull($_POST['idpendidikanortu']), 'alamatortu'=> $_POST['alamatortu'], 'kelurahanortu'=> $_POST['kelurahanortu'], 'kecamatanortu'=> $_POST['kecamatanortu'], 'kdkotkabortu'=> $_POST['kdkotkabortu'], 'kdposortu'=> $_POST['kdposortu'], 'notelportu'=> $_POST['notelportu'], //ORTU (AYAH) 'nmortuayah'=> $_POST['nmortuayah'], 'idpekerjaanortuayah'=> $this->retValOrNull($_POST['idpekerjaanortuayah']), 'idpendidikanortuayah'=> $this->retValOrNull($_POST['idpendidikanortuayah']), 'alamatortuayah'=> $_POST['alamatortuayah'], 'kelurahanortuayah'=> $_POST['kelurahanortuayah'], 'kecamatanortuayah'=> $_POST['kecamatanortuayah'], 'kdkotkabortuayah'=> $_POST['kdkotkabortuayah'], 'kdposortuayah'=> $_POST['kdposortuayah'], 'notelportuayah'=> $_POST['notelportuayah'], //DAFTAR 'nopmb'=> $_POST['nopmb'], 'kdstsemester'=> $this->retValOrNull($_POST['kdstsemester']), 'kdprodi'=> $_POST['kdprodi'], //$this->retValOrNull($_POST['kdprodi']), 'shiftmhs'=> $this->retValOrNull($_POST['shiftmhs']), 'idklsmhs'=> $this->retValOrNull($_POST['idklsmhs']), 'thnmasuk'=> $this->retValOrNull($_POST['thnmasuk']), 'tglmasuk'=> $this->retValOrNull($_POST['tglmasuk']), 'kdstawalmhs'=> $this->retValOrNull($_POST['kdstawalmhs']), 'kdstaktivitasmhs'=> $this->retValOrNull($_POST['kdstaktivitasmhs']), 'kdpropinsislta'=> $this->retValOrNull($_POST['kdpropinsislta']), 'btsstudi'=> $this->retValOrNull($_POST['btsstudi']), 'catnonaktif'=> $this->retValOrNull($_POST['catnonaktif']), //SLTA ASAL 'nmslta'=> $_POST['nmslta'], 'kdkotkabslta'=> $this->retValOrNull($_POST['kdkotkabslta']), 'idjnsslta'=> $this->retValOrNull($_POST['idjnsslta']), 'idstakreditasislta'=> $this->retValOrNull($_POST['idstakreditasislta']), 'thnlulusslta'=> $this->retValOrNull($_POST['thnlulusslta']), 'nemslta'=> $this->retValOrNull($_POST['nemslta']), 'rangkingslta'=> $this->retValOrNull($_POST['rangkingslta']), 'noijazahslta'=> $_POST['noijazahslta'], 'tglijazahslta'=> $this->retValOrNull($_POST['tglijazahslta']), //ASAL PT/PINDAHAN 'kdptasal'=> $this->retValOrNull($_POST['kdptasal']), 'nmptasal'=> $this->retValOrNull($_POST['nmptasal']), 'idjnspt'=> $this->retValOrNull($_POST['idjnspt']), 'idstakreditasi'=> $this->retValOrNull($_POST['idstakreditasi']), 'idkuakreditasi'=> $this->retValOrNull($_POST['idkuakreditasi']), 'kdjenjangstudiasal'=> $this->retValOrNull($_POST['kdjenjangstudiasal']), 'fakultasasal'=> $this->retValOrNull($_POST['fakultasasal']), 'kdprodiasal'=> $this->retValOrNull($_POST['kdprodiasal']), 'nmprodiasal'=> $this->retValOrNull($_POST['nmprodiasal']), 'nimasal'=> $this->retValOrNull($_POST['nimasal']), 'noijazahasal'=> $this->retValOrNull($_POST['noijazahasal']), 'tglijazahasal'=> $this->retValOrNull($_POST['tglijazahasal']), 'idsemesterpindah'=> $this->retValOrNull($_POST['idsemesterpindah']), 'jmlsksdiakui'=> $this->retValOrNull($_POST['jmlsksdiakui']), 'alasanpindah'=> $this->retValOrNull($_POST['alasanpindah']), //PEKERJAAN MHS 'idpekerjaanmhs'=> $this->retValOrNull($_POST['idpekerjaanmhs']), 'nmtptbekerjamhs'=> $this->retValOrNull($_POST['nmtptbekerjamhs']), 'alamatkerjamhs'=> $this->retValOrNull($_POST['alamatkerkamhs']), 'jabatanmhs'=> $this->retValOrNull($_POST['jabatanmhs']), //ALUMNI 'idpekerjaanalumni'=> $this->retValOrNull($_POST['idpekerjaanalumni']), 'nmtptbekerjaalumni'=> $this->retValOrNull($_POST['nmtptbekerjaalumni']), 'alamatkerjaalumni'=> $this->retValOrNull($_POST['alamatkerjaalumni']), 'jabatanalumni'=> $this->retValOrNull($_POST['jabatanalumni']), 'thnkeluar'=> $this->retValOrNull($_POST['thnkeluar']), 'tgllulus'=> $this->retValOrNull($_POST['tgllulus']), //'idstatusalumni'=> $this->retValOrNull($_POST['idstatusalumni']), 'notranskrip'=> $this->retValOrNull($_POST['notranskrip']), 'noijazah'=> $this->retValOrNull($_POST['noijazah']), 'ketuayayasan'=> $this->retValOrNull($_POST['ketuayayasan']), 'tglijazah'=> $this->retValOrNull($_POST['tglijazah']), 'idpimpinan1'=> $this->retValOrNull($_POST['idpimpinan1']), 'tgltandatangan'=> $this->retValOrNull($_POST['tgltandatangan']), //S3 /* 'kdbiayastudi'=> $this->retValOrNull($_POST['kdbiayastudi']), 'kdpttptbekerja'=> $this->retValOrNull($_POST['kdpttptbekerja']), 'nmpttptbekerja'=> $this->retValOrNull($_POST['nmpttptbekerja']), 'kdproditptbekerja'=> $this->retValOrNull($_POST['kdproditptbekerja']), 'nmproditptbekerja'=> $this->retValOrNull($_POST['nmproditptbekerja']), 'nidupromotor'=> $this->retValOrNull($_POST['nidupromotor']), 'nidukopromotor1'=> $this->retValOrNull($_POST['nidukopromotor1']), 'nidukopromotor2'=> $this->retValOrNull($_POST['nidukopromotor2']), 'nidukopromotor3'=> $this->retValOrNull($_POST['nidukopromotor3']), 'nidukopromotor3'=> $this->retValOrNull($_POST['nidukopromotor4']), */ //SKRIPSI 'jdlskripsiind'=> $this->retValOrNull($_POST['jdlskripsiind']), 'jdlskripsieng'=> $this->retValOrNull($_POST['jdlskripsieng']), 'idpembimbing'=> $this->retValOrNull($_POST['idpembimbing']), 'idpembimbing1'=> $this->retValOrNull($_POST['idpembimbing1']), 'nmperusahaan'=> $this->retValOrNull($_POST['nmperusahaan']), 'tglperiode1'=> $this->retValOrNull($_POST['tglperiode1']), 'tglperiode2'=> $this->retValOrNull($_POST['tglperiode2']), 'tglsidang'=> $this->retValOrNull($_POST['tglsidang']), 'penyidang1'=> $this->retValOrNull($_POST['penyidang1']), 'penyidang2'=> $this->retValOrNull($_POST['penyidang2']), //LAINNYA 'email'=> $this->retValOrNull($_POST['email']), 'facebook'=> $this->retValOrNull($_POST['facebook']), 'twitter'=> $this->retValOrNull($_POST['twitter']), 'pinbb'=> $this->retValOrNull($_POST['pinbb']), 'website'=> $this->retValOrNull($_POST['website']), 'foto'=> $this->retValOrNull($_POST['foto']), ); return $dataArray; } //get value public function getFieldsAndValuesPublic(){ $dataArray = array( 'userid'=> str_replace(" ","",$_POST['nim']), //$_POST['tf.npm-mhs'], 'password'=> base64_encode(str_replace(" ","",$_POST['nim'])), //$_POST['tf.npm-mhs'], 'nmlengkap'=> strtoupper($_POST['nmmhs']), //$_POST['tf.nama-mhs'], 'email'=> $this->retValOrNull($_POST['email']), 'nohp'=> $_POST['nohpmhs'], 'idjnspengguna'=> '2', 'noref'=> str_replace(" ","",$_POST['nim']), //$_POST['tf.npm-mhs'], 'idklppengguna'=> '2', 'idstatus'=> '1', 'tgldaftar'=> $this->retValOrNull($_POST['tglmasuk']), ); return $dataArray; } //get value public function getFieldsAndValuesPublicUpdate(){ $dataArray = array( 'nmlengkap'=> strtoupper($_POST['nmmhs']), //$_POST['tf.nama-mhs'], 'email'=> $this->retValOrNull($_POST['email']), 'nohp'=> $_POST['nohpmhs'], ); return $dataArray; } function getFieldsAndValuesTblStmhssemesterUpdate(){ $dataArray = array( 'catnonaktif'=> $this->retValOrNull($_POST['catnonaktif']), ); return $dataArray; } function upload(){ $urlpubori = $this->get_url_public_ori(); $urlpubthumb = $this->get_url_public_thumb(); /* $ori_dir = 'resources/img/ori/o_mhs/'; $thumb_dir = 'resources/img/thumbs/t_mhs/'; */ $ori_dir = $urlpubori; $thumb_dir = $urlpubthumb; $oldphoto = $this->input->post("oldphoto"); $newphoto = $this->input->post("newphoto"); $allowedType = array( 'image/jpeg', 'image/pjpeg', 'image/png', 'image/gif', 'image/x-png'); $return["success"]='true'; $return["newfile"]=$oldphoto; if ($oldphoto != $newphoto) { if (in_array($_FILES['file_gambar']['type'], $allowedType)) { // jika ekstensi file valid if ($_FILES['file_gambar']['size'] <= 800000) { // jika foto kurang dari 800kb $newnamephoto= str_replace(" ", "_", $_FILES['file_gambar']['name']); $isUpload = move_uploaded_file($_FILES['file_gambar']['tmp_name'], $ori_dir . $newnamephoto); $this->createThumb($newnamephoto, $ori_dir, $thumb_dir, $_FILES['file_gambar']['type']); if ($oldphoto && $isUpload) { unlink("resources/img/ori/o_mhs/$oldphoto"); unlink("resources/img/thumbs/t_mhs/thumb_$oldphoto"); } $return["success"]='true'; $return["newfile"]=$newnamephoto; } else { // jika foto lebih dari 800kb $return["success"]='false1'; } } else { $return["success"]='false2'; } } $return["nama"]=$_FILES['file_gambar']['name']; echo json_encode($return); } function createThumb($img_file, $ori_path, $thumb_path, $img_type) { // get the image source $path = $ori_path; $img = $path . $img_file; switch ($img_type) { case "image/jpeg": $img_src = @imagecreatefromjpeg($img); break; case "image/pjpeg": $img_src = @imagecreatefromjpeg($img); break; case "image/png": $img_src = @imagecreatefrompng($img); break; case "image/x-png": $img_src = @imagecreatefrompng($img); break; case "image/gif": $img_src = @imagecreatefromgif($img); break; } $img_width = imagesx($img_src); $img_height = imagesy($img_src); $square_size = 100; // check width, height, or square if ($img_width == $img_height) { // square $tmp_width = $square_size; $tmp_height = $square_size; } else if ($img_height < $img_width) { // wide $tmp_height = $square_size; $tmp_width = intval(($img_width / $img_height) * $square_size); if ($tmp_width % 2 != 0) { $tmp_width++; } } else if ($img_height > $img_width) { $tmp_width = $square_size; $tmp_height = intval(($img_height / $img_width) * $square_size); if ($tmp_height % 2 != 0) { $tmp_height++; } } $img_new = imagecreatetruecolor($tmp_width, $tmp_height); imagecopyresampled($img_new, $img_src, 0, 0, 0, 0, $tmp_width, $tmp_height, $img_width, $img_height); // create temporary thumbnail and locate on the server $thumb = $thumb_path . "thumb_" . $img_file; switch ($img_type) { case "image/jpeg": imagejpeg($img_new, $thumb); break; case "image/pjpeg": imagejpeg($img_new, $thumb); break; case "image/png": imagepng($img_new, $thumb); break; case "image/x-png": imagepng($img_new, $thumb); break; case "image/gif": imagegif($img_new, $thumb); break; } // get tmp_image switch ($img_type) { case "image/jpeg": $img_thumb_square = imagecreatefromjpeg($thumb); break; case "image/pjpeg": $img_thumb_square = imagecreatefromjpeg($thumb); break; case "image/png": $img_thumb_square = imagecreatefrompng($thumb); break; case "image/x-png": $img_thumb_square = imagecreatefrompng($thumb); break; case "image/gif": $img_thumb_square = imagecreatefromgif($thumb); break; } $thumb_width = imagesx($img_thumb_square); $thumb_height = imagesy($img_thumb_square); if ($thumb_height < $thumb_width) { // wide $x_src = ($thumb_width - $square_size) / 2; $y_src = 0; $img_final = imagecreatetruecolor($square_size, $square_size); imagecopy($img_final, $img_thumb_square, 0, 0, $x_src, $y_src, $square_size, $square_size); } else if ($thumb_height > $thumb_width) { // landscape $x_src = 0; $y_src = ($thumb_height - $square_size) / 2; $img_final = imagecreatetruecolor($square_size, $square_size); imagecopy($img_final, $img_thumb_square, 0, 0, $x_src, $y_src, $square_size, $square_size); } else { $img_final = imagecreatetruecolor($square_size, $square_size); imagecopy($img_final, $img_thumb_square, 0, 0, 0, 0, $square_size, $square_size); } switch ($img_type) { case "image/jpeg": @imagejpeg($img_final, $thumb); break; case "image/pjpeg": @imagejpeg($img_final, $thumb); break; case "image/png": @imagepng($img_final, $thumb); break; case "image/x-png": @imagepng($img_final, $thumb); break; case "image/gif": @imagegif($img_final, $thumb); break; } } function update_mhs_pmb($nim){ $KEDUA= $this->load->database('second', TRUE); $dataArray = array( 'nim'=> $this->retValOrNull($nim), ); $KEDUA->where('nopmb', $_POST['nopmb']); $KEDUA->update('pmb', $dataArray); if($KEDUA->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function ceknpm(){ $q = "SELECT count(nim) as nim FROM mahasiswa where nim='".$_POST['nim']."'" ; $query = $this->db->query($q); $jum = ''; if ($query->num_rows() != 0) { $row = $query->row(); $jum=$row->nim; } if ($jum == null){ $jum=0; } echo $jum; } function delete_mahasiswa(){ $where['nim'] = $_POST['nim']; $wherepublic['userid'] = $_POST['nim']; $ret = $this->rhlib->deleteRecord('mahasiswa',$where); if ($ret) { $this->rhlib->deleteRecordPublic('penggunaprodi',$wherepublic); $this->rhlib->deleteRecordPublic('pengguna',$wherepublic); $this->update_mhs_pmb(''); //menjalankan function lain } return $ret; } function cekusermhs(){ $KEDUA= $this->load->database('second', TRUE); $q = "SELECT count(userid) as userid FROM pengguna where userid='".$_POST['nim']."'" ; $query = $KEDUA->query($q); $jum = ''; if ($query->num_rows() != 0) { $row = $query->row(); $jum=$row->userid; } if ($jum == null){ $jum=0; } return $jum; } function get_url_public_ori(){ //ISTRA $q="SELECT nilai from setting where kdset='PHOTOMHSO'"; $query = $this->db->query($q); $nilai=''; if ($query->num_rows() > 0) { $data = $query->row(); $nilai = $data->nilai; } return $nilai; } function get_url_public_thumb(){ //ISTRA $q="SELECT nilai from setting where kdset='PHOTOMHST'"; $query = $this->db->query($q); $nilai=''; if ($query->num_rows() > 0) { $data = $query->row(); $nilai = $data->nilai; } return $nilai; } function get_mhs_va(){ $kdprodi = $_POST['kdprodi']; $thnmasuk = $_POST['thnmasuk']; $q = "SELECT DISTINCT a.* , b.nmprodi , c.nmstawalmhs , d.nmstaktifmhs FROM mahasiswa a LEFT JOIN (SELECT kdprodi , nourutprodi , nmprodi , concat(rtrim(nourutprodi), '. ', nmprodi, ' (', nmjenjangstudi, ')') AS lnmprodi , nmfakultas , kdjenjangstudi , nmjenjangstudi FROM v_prodi WHERE kdprodi <> '') b ON b.kdprodi = a.kdprodi LEFT JOIN (SELECT kdkodtbkod AS kdstawalmhs , nmkodtbkod AS nmstawalmhs FROM tbkod WHERE kdapltbkod = '06') c ON a.kdstawalmhs = c.kdstawalmhs LEFT JOIN (SELECT kdkodtbkod AS kdstaktifmhs , nmkodtbkod AS nmstaktifmhs FROM tbkod WHERE kdapltbkod = '05') d ON a.kdstaktivitasmhs = d.kdstaktifmhs WHERE a.kdprodi='".$kdprodi."' and a.thnmasuk='".$thnmasuk."' ORDER BY a.nim"; $this->rhlib->jsonFromQuery($q); } function save_va_mhs(){ // ISTRA $par=$this->input->post("par"); $return["success"]=0; $rows = explode(";",$par); $row_count = count($rows); for($ri=0;$ri<$row_count;$ri++){ $rows2 = explode(":",$rows[$ri]); $dataArray = array( 'novadpp'=> ($rows2[1]=='null') ? null:$rows2[1], 'novadpk'=> ($rows2[2]=='null') ? null:$rows2[2], ); if ($rows2[1]!='null' || $rows2[2]!='null') { $this->db->where('nim', $rows2[0]); $this->db->update('mahasiswa', $dataArray); $return["success"]=$return["success"] + 1; } } echo json_encode($return); } function update_va_mhs() { $dataArray = array( $_POST['field']=> $this->retValOrNull($_POST['value']), ); $this->db->where('nim', $_POST['recnim']); $this->db->update('mahasiswa', $dataArray); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } } } ?>