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_pimpinan(){ $q = "SELECT pimpinan.*, fakultas.nmfakultas, jabatan.nmjabatan FROM pimpinan LEFT JOIN fakultas ON pimpinan.kdfakultas = fakultas.kdfakultas LEFT JOIN jabatan ON pimpinan.jabatan = jabatan.idjabatan ORDER BY kdfakultas"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_pimpinan(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('pimpinan',$dataArray); return $ret; } function update_pimpinan(){ $dataArray = $this->getFieldsAndValues(); //UPDATE $this->db->where('idpimpinan', $_POST['idpimpinan']); $this->db->update('pimpinan', $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_pimpinan(){ $where['idpimpinan'] = $_POST['idpimpinan']; $ret = $this->rhlib->deleteRecord('pimpinan',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( //'idpimpinan'=> $_POST['idpimpinan'], 'jabatan'=> $_POST['jabatan'], 'nip' => $_POST['idnip'], 'nmpimpinan'=> $_POST['idnm'], 'kdfakultas'=> ($_POST['kdfakultas']) ? ($_POST['kdfakultas']):null, 'idstatus'=> $_POST['idstatus'], 'gelar' => $_POST['idgelar'], 'catatan' => $_POST['idcatatan'], ); return $dataArray; } } ?>