load->library('session'); $this->load->library('rhlib'); } function jsonFromQuery($q) { $this->rhlib->jsonFromQuery($q); } function jsonFromQueryWLimit($q){ $this->rhlib->jsonFromQueryWLimit($q); } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function retValOrZero($val){ $val = ($val=='')? 0 : $val; return $val; } //=========================================================== function get_bnpsemester(){ $kdprodi = $_POST['kdprodi']; $kdstsemester = $_POST['kdstsemester']; $q = "SELECT * FROM setbonilai WHERE kdprodi='".$kdprodi."' and kdstsemester='".$kdstsemester."'"; $this->jsonFromQueryWLimit($q); } function insert_bnpsemester(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('setbonilai',$dataArray); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdprodi' => $_POST['kdprodi'], 'kdstsemester' => $_POST['kdstsemester'], 'nilaihuruf'=> $_POST['nilaihuruf'], 'bobotnilai'=> $_POST['bobotnilai'], ); return $dataArray; } function update_bnpsemester(){ $dataArray = $this->getFieldsAndValues(); //UPDATE //$where['nilaihuruf'] = $_POST['nilaihuruf']; $where['kdprodi'] = $_POST['kdprodi']; $where['kdstsemester'] = $_POST['kdstsemester']; $this->db->where($where); $this->db->update('setbonilai', $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_bnpsemester(){ $where['nilaihuruf'] = $_POST['nilaihuruf']; $where['kdprodi'] = $_POST['kdprodi']; $where['kdstsemester'] = $_POST['kdstsemester']; $ret = $this->rhlib->deleteRecord('setbonilai',$where); return $ret; } function deleteByProdiSmt_Bbt(){ $where['kdprodi'] = $_POST['kdprodi']; $where['kdstsemester'] = $_POST['kdstsemester']; $this->db->trans_begin(); $this->db->delete("setbonilai",$where); if ($this->db->trans_status() === FALSE){ $this->db->trans_rollback(); $return["success"]=false; $return["message"]="Hapus Data gagal"; }else{ $this->db->trans_commit(); $return["success"]=true; $return["message"]="Hapus Data Berhasil"; } return $return; } function copy_bnpsemester(){ $kdprodi = $_POST['kdprodi']; $smtbaru = $_POST['smtbaru']; $smtlama = $_POST['smtlama']; $sql = "INSERT setbonilai(kdprodi,kdstsemester,nilaihuruf,bobotnilai) SELECT kdprodi,".$smtbaru.",nilaihuruf,bobotnilai FROM setbonilai WHERE kdprodi='".$kdprodi."' and kdstsemester='".$smtlama."'"; $exec = $this->db->query($sql); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Copy Data Berhasil'; }else{ $ret["success"]=false; $ret["msg"]= 'Copy Data Gagal'; } return $ret; } } ?>