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_setbonilai(){ $q = "SELECT setbonilai.kdprodi, v_prodi.nmprodi, v_prodi.nmjenjangstudi, setbonilai.kdstsemester, thnakademik.nmthnakademik, jsemester.nmjnssemester, setbonilai.nilaihuruf, setbonilai.bobotnilai, v_prodi.nourutprodi FROM setbonilai INNER JOIN v_prodi ON setbonilai.kdprodi = v_prodi.kdprodi INNER JOIN stsemester ON setbonilai.kdstsemester = stsemester.kdstsemester LEFT JOIN thnakademik ON stsemester.idthnakademik = thnakademik.idthnakademik LEFT JOIN jsemester ON stsemester.idjnssemester = jsemester.idjnssemester"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_setbonilai(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('setbonilai',$dataArray); return $ret; } function update_setbonilai(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('kdprodi', $_POST['kdprodi']); $this->db->where('kdstsemester', $_POST['kdstsemester']); $this->db->where('nilaihuruf', $_POST['nilaihuruf']); $this->db->update('setbonilai', $fieldsAndValues); 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_setbonilai(){ $where['kdprodi'] = $_POST['kdprodi']; $where['kdstsemester'] = $_POST['kdstsemester']; $where['nilaihuruf'] = $_POST['nilaihuruf']; $ret = $this->rhlib->deleteRecord('setbonilai',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdprodi'=> $_POST['kdprodi'], 'kdstsemester'=> $_POST['kdstsemester'], 'nilaihuruf'=> $_POST['nilaihuruf'], 'bobotnilai'=> $_POST['bobotnilai'] ); return $dataArray; } } ?>