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_settingkrs(){ $q = "SELECT * FROM v_setkrs WHERE kdprodi IN (SELECT kdprodi FROM penggunaprodi WHERE userid = '".$this->my_usession->userdata('user_idunlaprivate')."')"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_settingkrs(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('setkrs',$dataArray); return $ret; } function update_settingkrs(){ $fieldsAndValues = array( 'idsiskrs'=> $_POST['idsiskrs'] ); //UPDATE $this->db->where('kdprodi', $_POST['kdprodi']); $this->db->where('idsemester', $_POST['idsemester']); $this->db->update('setkrs', $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_settingkrs(){ $where['kdprodi'] = $_POST['kdprodi']; $where['idsemester'] = $_POST['idsemester']; $ret = $this->rhlib->deleteRecord('setkrs',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdprodi'=> $_POST['kdprodi'], 'idsemester'=> $_POST['idsemester'], 'idsiskrs'=> $_POST['idsiskrs'] ); return $dataArray; } function getcountsetkrs(){ $q = "SELECT * FROM setkrs WHERE kdprodi='".$_POST['kdprodi']."' AND idsemester='".$_POST['idsemester']."'"; $query = $this->db->query($q); if ($query->num_rows() > 0) { echo 1; } else { echo 0; } } } ?>