load->library('session'); $this->load->library('rhlib'); } function jsonFromQuery($q) { $this->rhlib->jsonFromQuery($q); } function jsonFromQueryWLimit($q){ $this->rhlib->jsonFromQueryWLimit($q); } function insertRecord($table,$dataArray){ return $this->rhlib->insertRecord($table,$dataArray); } function deleteRecord($table,$where){ return $this->rhlib->deleteRecord($table,$where); } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function retValOrZero($val){ $val = ($val=='' || $val==null)? 0 : $val; return $val; } function get_absenmhs(){ $kdprodi = $_POST['kdprodi']; $kdstsemester = $_POST['kdstsemester']; $kdmk = $_POST['kdmk']; $nidu = $_POST['nidu']; $idkelas = $_POST['idkelas']; /* $q = "SELECT a.*, b.nmmhs, b.kdjnskelamin,b.thnmasuk FROM absenmhs a LEFT JOIN mahasiswa b ON b.nim=a.nim WHERE a.kdprodi='".$kdprodi."' and a.kdstsemester='".$kdstsemester."' and a.kdmk='".$kdmk."' and a.nidu='".$nidu."' and a.idkelas='".$idkelas."' and b.kdstaktivitasmhs = 'A'"; */ $q = "SELECT a.* , b.nmmhs , b.kdjnskelamin , b.thnmasuk FROM absenmhs a LEFT JOIN mahasiswa b ON b.nim = a.nim LEFT JOIN nilai n ON a.kdmk = n.kdmk AND a.kdprodi = n.kdprodi AND a.kdstsemester = n.kdstsemester AND a.nidu = n.nidu AND a.nim = n.nim LEFT JOIN stmhssemester s ON a.nim = s.nim AND a.kdstsemester = s.kdstsemester WHERE a.kdprodi = '$kdprodi' AND a.kdstsemester = '$kdstsemester' AND a.kdmk = '$kdmk' -- AND a.nidu = '$nidu' AND a.idkelas = '$idkelas' AND s.kdstaktivitasmhs = 'A' AND n.idstsetuju=1 ORDER BY a.nim"; $this->jsonFromQuery($q); } function get_absendos(){ $kdprodi = $_POST['kdprodi']; $kdstsemester = $_POST['kdstsemester']; $kdmk = $_POST['kdmk']; $nidu = $_POST['nidu']; $idkelas = $_POST['idkelas']; $q = $this->db->query("SELECT * FROM absendos a WHERE a.kdprodi='".$kdprodi."' and a.kdstsemester='".$kdstsemester."' and a.kdmk='".$kdmk."' and a.nidu='".$nidu."' and a.idkelas='".$idkelas."' LIMIT 1"); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $datax = count($data); $ttl = $datax; $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); foreach($data as $row) { for($i=0; $i<16; $i++){ $j = $i+1; $arrp = 'p'.$j; $arrt = 'tgl'.$j; $arrdj = 'dj'.$j; $arrsj = 'sj'.$j; array_push($build_array["data"],array( $arrp=>($row->$arrp) ? $row->$arrp:null, $arrt=>($row->$arrt) ? $row->$arrt:null, $arrdj=>($row->$arrdj) ? $row->$arrdj:null, $arrsj=>($row->$arrsj) ? $row->$arrsj:null, )); } } echo json_encode($build_array); } function update_absenmhs1(){ $field = $_POST['field']; $value = ($_POST['value']) ? $_POST['value']:null; //UPDATE $this->db->where('kdprodi', $_POST['kdprodi']); $this->db->where('kdstsemester', $_POST['kdstsemester']); $this->db->where('kdmk', $_POST['kdmk']); $this->db->where('nidu', $_POST['nidu']); $this->db->where('nim', $_POST['nim']); $this->db->set($field, $value); $this->db->update('absenmhs'); 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 update_absendos(){ $this->db->where('kdprodi', $_POST['kdprodi']); $this->db->where('kdstsemester', $_POST['kdstsemester']); $this->db->where('kdmk', $_POST['kdmk']); $this->db->where('nidu', $_POST['nidu']); $this->db->where('idkelas', $_POST['idkelas']); $dataArray = $this->getFieldsAndValues(); for($i=0; $i<16; $i++){ $j = $i + 1; $this->db->set('p'.$j, $this->retValOrNull($_POST['p'.$j])); $this->db->set('tgl'.$j, $this->retValOrNull($_POST['tgl'.$j])); $this->db->set('dj'.$j, $this->retValOrNull($_POST['dj'.$j])); $this->db->set('sj'.$j, $this->retValOrNull($_POST['sj'.$j])); } $query1 = $this->db->query('SELECT * FROM absendos WHERE kdstsemester ="'.$_POST['kdstsemester'].'" AND kdprodi ="'.$_POST['kdprodi'].'" AND kdmk ="'.$_POST['kdmk'].'" AND idkelas ="'.$_POST['idkelas'].'"'); foreach ($query1->result() as $rows); $kdsemester = $rows->kdsemester; $kdprodi = $rows->kdprodi; $kdmk = $rows->kdmk; $idkelas = $rows->idkelas; if($kdsemester == '' && $kdprodi == '' && $kdmk == '' && $idkelas == ''){ $this->db->insert('absendos',$dataArray); } else { $this->db->update('absendos'); } 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 getFieldsAndValues(){ $dataArray = array( 'kdstsemester'=> $_POST['kdstsemester'], 'kdprodi'=> $_POST['kdprodi'], 'kdmk'=> $_POST['kdmk'], 'nidu'=> $_POST['nidu'], 'idkelas'=> $_POST['idkelas'] ); return $dataArray; } function update_absenmhsAll(){ //UPDATE $this->db->where('kdprodi', $_POST['kdprodi']); $this->db->where('kdstsemester', $_POST['kdstsemester']); $this->db->where('kdmk', $_POST['kdmk']); $this->db->where('nidu', $_POST['nidu']); $this->db->where('nim', $_POST['nim']); for($i=0; $i<16; $i++){ $j = $i + 1; $valabsenmhs = ($_POST['p'.$j]) ? $_POST['p'.$j]:null; $this->db->set('p'.$j, $valabsenmhs); } $this->db->update('absenmhs'); 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 get_pengajar_koord(){ $kdstsemester = $_POST['kdstsemester']; $q = "SELECT s.nidu AS nidu , d.nmdosdgngelar AS nmdos , dp.nidu AS niduganti , ddp.nmdosdgngelar AS nmdosganti , ifnull(dp.nidu, s.nidu) AS nidudisp , ifnull(ddp.nidn, d.nidn) AS nidndisp , ifnull(ddp.nmdosdgngelar, d.nmdosdgngelar) AS nmdosdisp , ifnull(ddp.kdjnskelamin, d.kdjnskelamin) AS kdjk , pd.nmprodi AS nmprodi , staktv.nmstaktiv AS nmstaktiv , stikj.nmstikj AS nmstikj FROM struprogdet s LEFT JOIN dosen d ON s.nidu = d.nidu LEFT JOIN dosenpengganti dp ON s.idstruprogdet = dp.idstruprogdet AND dp.idstatus = 1 LEFT JOIN dosen ddp ON dp.nidu = ddp.nidu LEFT JOIN (SELECT kdprodi , nourutprodi , nmprodi , concat(rtrim(nourutprodi), '. ', nmprodi, ' (', nmjenjangstudi, ')') AS lnmprodi , nmfakultas , kdjenjangstudi , nmjenjangstudi FROM v_prodi WHERE kdprodi <> '') pd ON pd.kdprodi = ifnull(ddp.kdprodi, d.kdprodi) LEFT JOIN (SELECT kdkodtbkod AS kdstaktiv , nmkodtbkod AS nmstaktiv FROM tbkod WHERE kdapltbkod = '15') staktv ON staktv.kdstaktiv = ifnull(ddp.kdstaktivitasdosen, d.kdstaktivitasdosen) LEFT JOIN (SELECT kdkodtbkod AS kdstikj , nmkodtbkod AS nmstikj FROM tbkod WHERE kdapltbkod = '03') stikj ON stikj.kdstikj = ifnull(ddp.kdstikatankerjadosen, d.kdstikatankerjadosen) WHERE s.kdstsemester = '$kdstsemester' -- AND s.idjnsdosen = 1 GROUP BY ifnull(dp.nidu, s.nidu) ORDER BY ifnull(ddp.nmdosdgngelar, d.nmdosdgngelar)"; $this->rhlib->jsonFromQueryWLimit($q); } } ?>