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_klsperkul(){ $q = "SELECT a.*, b.nmprodi, c.kdklsmhs as nmklsmhs, d.nmstatus FROM kelas a LEFT JOIN prodi b ON b.kdprodi=a.kdprodi LEFT JOIN klsmhs c ON c.idklsmhs=a.idklsmhs LEFT JOIN status d ON d.idstatus=a.idstatus WHERE a.kdprodi IN (SELECT kdprodi FROM penggunaprodi WHERE userid = '".$this->my_usession->userdata('user_idunlaprivate')."')"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_klsperkul(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('kelas',$dataArray); return $ret; } function update_klsperkul(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE //$where['kdprodi'] = $_POST['kdprodi']; //$where['idklsmhs'] = $_POST['idklsmhs']; //$this->db->where('kdprodi', $_POST['kdprodi']); $this->db->where('idkelas', $_POST['idkelas']); $this->db->update('kelas', $fieldsAndValues); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; //$this->rhlib->updateRecordPublic('klsprodi',$fieldsAndValues,$where); }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function delete_klsperkul(){ //$where['kdprodi'] = $_POST['kdprodi']; $where['idkelas'] = $_POST['idkelas']; $ret = $this->rhlib->deleteRecord('kelas',$where); //$this->rhlib->deleteRecordPublic('klsprodi',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'kdprodi'=> $_POST['kdprodi'], 'idklsmhs'=> $_POST['idklsmhs'], 'idstatus'=> $_POST['idstatus'], 'kdkelas'=> $_POST['kdkelas'], 'nmkelas'=> $_POST['nmkelas'], 'deskripsi'=> $_POST['deskripsi'], 'idkelas'=> $_POST['idkelas'], 'klsparalel'=> $this->retValOrNull($_POST['klsparalel']), ); return $dataArray; } } ?>