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_srtobservasi(){ $kdprodi = $_POST['kdprodi']; $kdstsemester = $_POST['kdstsemester']; $q = "SELECT * FROM v_srtobservasi WHERE kdprodi='".$kdprodi."' AND kdstsemester='".$kdstsemester."'"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_srtobservasi(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('srtobservasi',$dataArray); return $ret; } function update_srtobservasi(){ $dataArray = $this->getFieldsAndValues(); //UPDATE $this->db->where('idsrtobservasi', $_POST['idsrtobservasi']); $this->db->update('srtobservasi', $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_srtobservasi(){ $where['idsrtobservasi'] = $_POST['idsrtobservasi']; $ret = $this->rhlib->deleteRecord('srtobservasi',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( //'idsrtpindahmhs'=> $_POST['idsrtpindahmhs'], 'tglsrtobservasi'=> $_POST['tglsrtobservasi'], 'nosrtobservasi' => $_POST['nosrtobservasi'], 'nim'=> $_POST['nim'], 'kdfakultas'=> ($_POST['kdfakultas']), /* ? ($_POST['kdfakultas']) : ($_POST['kdfakultasedit']), */ 'kdprodi' => $_POST['kdprodi'], 'idpimpinan' => ($_POST['idpimpinan']), /* ? ($_POST['idpimpinan']) : ($_POST['idpimpinanedit']), */ 'idstsetuju' => $_POST['idstsetuju'], 'perihal' => $_POST['perihal'], 'keterangan' => $_POST['keterangan'], 'instansi' => $_POST['instansi'], 'keperluan' => $_POST['keperluan'], 'kdstsemester' => $_POST['kdstsemester'], 'tglpersetujuan'=> ($_POST['tglpersetujuan']) ? $_POST['tglpersetujuan'] : null, 'idsemester'=> $_POST['idsemester'], ); return $dataArray; } } ?>