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_data() { /*$idsetbiaya = $_POST['idsetbiaya']; if ($idsetbiaya != '') { $var = " AND idsetbiaya = $idsetbiaya"; } else { $var = ""; }*/ $q = "SELECT * FROM v_setbiaya"; //$var"; $this->rhlib->jsonFromQueryWLimit($q); } function get_biayatahap() { $q = "SELECT * FROM v_setbiayatahap WHERE idsetbiaya='".$_POST['idsetbiaya']."'"; $this->rhlib->jsonFromQueryWLimit($q); } function get_count_setbiaya(){ $kdprodi = $_POST['kdprodi']; $thmasuk = $_POST['thmasuk']; $idjnskls = $_POST['idjnskls']; $idjnsbiaya = $_POST['idjnsbiaya']; $kdjnsbiaya = $_POST['kdjnsbiaya']; $kdstsemester = $_POST['kdstsemester']; $queryExt = ($kdjnsbiaya!='DPK' && $kdjnsbiaya!='KON')? " AND kdstsemester = '".$kdstsemester."'" : ""; $q = "SELECT count(idsetbiaya) AS jml FROM setbiaya WHERE idjnsbiaya = '".$idjnsbiaya."' AND idjnskls = '".$idjnskls."' AND kdprodi = '".$kdprodi."' ".$queryExt." AND tahunmsk = '".$thmasuk."'"; $query = $this->db->query($q); $data= ''; if ($query->num_rows() > 0) { $row = $query->row(); $data['result']=$row->jml; } else { $data['result']=0; } echo json_encode($data); } function insert_setbiaya() { $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('setbiaya',$dataArray); if ($ret) { $return["idsetbiaya"]=$dataArray['idsetbiaya']; echo json_encode($return); } } function update_setbiaya() { $filedAndVal = array( 'idjnsbiaya' => $_POST['idjnsbiaya'], 'tahunmsk' => $_POST['tahunmsk'], 'kdstsemester' => $this->retValOrNull($_POST['kdstsemester']), 'kdprodi' => $_POST['kdprodi'], 'idjnskls' => $_POST['idjnskls'], 'biaya' => $_POST['biaya'], 'idstatus' => $_POST['idstatus'], 'catatan' => $_POST['catatan'] ); //UPDATE $this->db->where('idsetbiaya', $_POST['idsetbiaya']); $this->db->update('setbiaya', $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_setbiaya(){ //ISTRA $where['idsetbiaya']=$_POST['idsetbiaya']; $ret = $this->rhlib->deleteRecord('setbiaya',$where); return $ret; } function retValOrNull($val) { //especially for combo & looukup with no item selected $val = ($val == '') ? null : $val; return $val; } function getFieldsAndValues() { $data = array( 'idsetbiaya' => $this->autoNumber('idsetbiaya', 'setbiaya'), 'idjnsbiaya' => $_POST['idjnsbiaya'], 'tahunmsk' => $_POST['tahunmsk'], 'kdstsemester' => $this->retValOrNull($_POST['kdstsemester']), 'kdprodi' => $_POST['kdprodi'], 'idjnskls' => $_POST['idjnskls'], 'biaya' => $_POST['biaya'], 'idstatus' => $_POST['idstatus'], 'catatan' => $_POST['catatan'] ); return $data; } //=============================BIAYA TAHAP====================================== function get_sttahapan_lookup(){ $q = "SELECT * FROM sttahapan WHERE idsttahapan NOT IN (SELECT idsttahapan FROM setbiayatahapan WHERE idsetbiaya='".$_POST['idsetbiaya']."') ORDER BY kdsttahapan"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_biaya_tahap(){ $dataArray = $this->getFieldsAndValuesTahap(); $ret = $this->rhlib->insertRecord('setbiayatahapan',$dataArray); return $ret; } function update_biaya_tahap() { $field = $_POST['field']; $value = $_POST['value']; //UPDATE $this->db->where('idsttahapan', $_POST['idsttahapan']); $this->db->where('idsetbiaya', $_POST['idsetbiaya']); $this->db->set($field, $value); $this->db->update('setbiayatahapan'); 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_biaya_tahap(){ //ISTRA $where['idsttahapan']=$_POST['idsttahapan']; $ret = $this->rhlib->deleteRecord('setbiayatahapan',$where); return $ret; } function getFieldsAndValuesTahap(){ $dataArray = array( 'idsetbiaya'=> $_POST['idsetbiaya'], 'idsttahapan'=> $_POST['idsttahapan'] ); return $dataArray; } function getsum_tahapnot() { $q = "SELECT ifnull(sum(nominal),0) AS nominal FROM setbiayatahapan WHERE idsttahapan <>'".$_POST['idsttahapan']."' AND idsetbiaya='".$_POST['idsetbiaya']."'"; $query = $this->db->query($q); if ($query->num_rows() != 0) { $row = $query->row(); echo $row->nominal; } } }