load->library('session'); $this->load->library('rhlib'); } var $_jsVars = array(); public function setJsVar($name, $value) { $this->_jsVars[$name] = $value; } function autoNumber($column, $tbl) { $q = "SELECT max(" . $column . ")+1 as max FROM " . $tbl . ""; $query = $this->db->query($q); $max = ''; if ($query->num_rows() != 0) { $row = $query->row(); $max = $row->max; } if ($max == null) { $max = 0; } return $max; } function get_thnakademik(){ //ISTRA $q="SELECT * from thnakademik order by kdthnakademik desc"; $query = $this->db->query($q); $data = array(); if ($query->num_rows() > 0) { $data = $query->result(); } $ttl = count($data); $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); if($ttl>0){ $build_array["data"]=$data; } echo json_encode($build_array); } function get_setbiayawisuda() { $q = "SELECT setbiayawisuda.idsetbiayawisuda , setbiayawisuda.nmsetbiayawisuda , setbiayawisuda.idthnakademik , thnakademik.kdthnakademik , thnakademik.nmthnakademik , setbiayawisuda.kdjenjangstudi , jenjangstudi.nmkodtbkod AS nmjenjangstudi , setbiayawisuda.biaya , setbiayawisuda.idstatus , status.nmstatus , setbiayawisuda.catatan FROM setbiayawisuda LEFT JOIN thnakademik ON setbiayawisuda.idthnakademik = thnakademik.idthnakademik LEFT JOIN tbkod jenjangstudi ON setbiayawisuda.kdjenjangstudi = jenjangstudi.kdkodtbkod AND jenjangstudi.kdapltbkod = 4 LEFT JOIN status ON setbiayawisuda.idstatus = status.idstatus"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_setbiayawisuda() { $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('setbiayawisuda',$dataArray); return $ret; } function update_setbiayawisuda() { $filedAndVal = array( 'nmsetbiayawisuda' => $_POST['nmsetbiayawisuda'], 'idthnakademik' => $_POST['idthnakademik'], 'kdjenjangstudi' => $_POST['kdjenjangstudi'], 'biaya' => $_POST['biaya'], 'idstatus' => $_POST['idstatus'], 'catatan' => $_POST['catatan'] ); //UPDATE $this->db->where('idsetbiayawisuda', $_POST['idsetbiayawisuda']); $this->db->update('setbiayawisuda', $filedAndVal); 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_setbiayawisuda(){ //ISTRA $where['idsetbiayawisuda']=$_POST['idsetbiayawisuda']; $ret = $this->rhlib->deleteRecord('setbiayawisuda',$where); return $ret; } function retValOrNull($val) { //especially for combo & looukup with no item selected $val = ($val == '') ? null : $val; return $val; } function getFieldsAndValues() { $data = array( 'idsetbiayawisuda' => $this->autoNumber('idsetbiayawisuda', 'setbiayawisuda'), 'nmsetbiayawisuda' => $_POST['nmsetbiayawisuda'], 'idthnakademik' => $_POST['idthnakademik'], 'kdjenjangstudi' => $_POST['kdjenjangstudi'], 'biaya' => $_POST['biaya'], 'idstatus' => $_POST['idstatus'], 'catatan' => $_POST['catatan'] ); return $data; } }