ceklog(); $this->load->library('session'); $this->load->library('rhlib'); } function ceklog() { $user = $this->session->userdata("usernameunlaprivate"); if($user==""){ redirect('auth/login'); } } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function get_srtketkul(){ $kdprodi = $_POST['kdprodi']; $kdstsemester = $_POST['kdstsemester']; $q = "SELECT * FROM v_srtketkuliah WHERE kdprodi='".$kdprodi."' AND kdstsemester='".$kdstsemester."'"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_srtketkul(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('srtketkuliah',$dataArray); return $ret; } function update_srtketkul(){ $dataArray = $this->getFieldsAndValues(); //UPDATE $this->db->where('idsrtkuliah', $_POST['idsrtkuliah']); $this->db->update('srtketkuliah', $dataArray); 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 delete_srtketkul(){ $where['idsrtkuliah'] = $_POST['idsrtkuliah']; $ret = $this->rhlib->deleteRecord('srtketkuliah',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( //'idsrtpindahmhs'=> $_POST['idsrtpindahmhs'], 'tglsrtkuliah'=> $_POST['tglsrtkuliah'], 'nosrtkuliah' => $_POST['nosrtkuliah'], 'nim'=> $_POST['nim'], 'kdfakultas'=> $_POST['kdfakultas'], 'kdprodi' => $_POST['kdprodi'], 'idpimpinan' => $_POST['idpimpinan'], 'idstsetuju' => $_POST['idstsetuju'], 'kdstsemester' => $_POST['kdstsemester'], 'tglpersetujuan'=> ($_POST['tglpersetujuan']) ? $_POST['tglpersetujuan'] : null, ); return $dataArray; } } ?>