load->library('session'); $this->load->library('rhlib'); } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function get_prodi(){ $q = "SELECT a.*,b.nmfakultas,c.nmjenjangstudi, d.nmstakreditasi, e.nmstprodi, f.nmdosdgngelar FROM prodi a LEFT JOIN fakultas b ON b.kdfakultas=a.kdfakultas LEFT JOIN (SELECT kdkodtbkod as kode, nmkodtbkod as nmjenjangstudi FROM tbkod WHERE kdapltbkod='04') c ON c.kode=a.kdjenjangstudi LEFT JOIN (SELECT kdkodtbkod as kode, nmkodtbkod as nmstakreditasi FROM tbkod WHERE kdapltbkod='07') d ON d.kode=a.kdstakreditasi LEFT JOIN (SELECT kdkodtbkod as kode, nmkodtbkod as nmstprodi FROM tbkod WHERE kdapltbkod='13') e ON e.kode=a.kdstprodi LEFT JOIN v_dosen_cari f ON f.nidu=a.nidu WHERE a.kdprodi<>'0'"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_prodi(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('prodi',$dataArray); $this->rhlib->insertRecordPublic('prodi',$dataArray); return $ret; } function update_prodi(){ $dataArray = $this->getFieldsAndValues(); //UPDATE $where['kdprodi'] = $_POST['kdprodi']; $this->db->where('kdprodi', $_POST['kdprodi']); $this->db->update('prodi', $dataArray); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; $this->rhlib->updateRecordPublic('prodi',$dataArray,$where); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_prodi(){ $where['kdprodi'] = $_POST['kdprodi']; $ret = $this->rhlib->deleteRecord('prodi',$where); $this->rhlib->deleteRecordPublic('prodi',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdfakultas'=> $_POST['kdfakultas'], 'kdprodi'=> $_POST['kdprodi'], 'nmprodi'=> $_POST['nmprodi'], 'kdjenjangstudi'=> $_POST['kdjenjangstudi'], 'kdstsemester'=> $_POST['kdstsemester'], 'noskdikti'=> $_POST['noskdikti'], 'tglskdikti'=> $_POST['tglskdikti'], 'tglberlakudikti'=> $_POST['tglberlakudikti'], 'jmlskslulus'=> $_POST['jmlskslulus'], 'kdstprodi'=> $_POST['kdstprodi'], 'kdstsemesterhapus'=> $_POST['kdstsemesterhapus'], 'email'=> $_POST['email'], 'tglawalberdiri'=> $_POST['tglawalberdiri'], 'noskakreditasi'=> $_POST['noskakreditasi'], 'tglskakreditasi'=> $_POST['tglskakreditasi'], 'tglberlakuskakreditasi'=> $_POST['tglberlakuskakreditasi'], 'kdstakreditasi'=> $_POST['kdstakreditasi'], 'kdfreubahkurikulum'=> $_POST['kdfreubahkurikulum'], 'kdpelubahkurikulum'=> $_POST['kdpelubahkurikulum'], 'nidu'=> $_POST['nidu'], 'notelpketua'=> $_POST['notelpketua'], 'notelpprodi'=> $_POST['notelpprodi'], 'nofaxprodi'=> $_POST['nofaxprodi'], 'nmoperator'=> $_POST['nmoperator'], 'notelpoperator'=> $_POST['notelpoperator'], 'nourutprodi'=> $_POST['nourutprodi'], 'gelarlkp'=> $_POST['gelarlkp'], 'gelarsingkat'=> $_POST['gelarsingkat'], ); return $dataArray; } } ?>