load->library('rhlib'); #start check auth $authorizationHeader['Authorization'] = str_replace('Bearer ', '', $_SERVER['HTTP_AUTHORIZATION']); $login = @$this->my_usessionpublic->logged_in ? : false; if ($authorizationHeader['Authorization'] && $login) { if(strpos($_SERVER['HTTP_AUTHORIZATION'], 'Bearer ') !== 0){ $cek['status'] = false; $cek['message'] = "Wrong number of segments"; $this->my_usessionpublic->set_userdata('pesan', $cek['message']); echo json_encode($cek); redirect('index.php/user/ext_logout'); die; } } else { $cek['status'] = false; $cek['message'] = "Please try login again."; $this->my_usessionpublic->set_userdata('pesan', $cek['message']); echo json_encode($cek); redirect('index.php/user/ext_logout'); die; } $cek = check_auth($authorizationHeader, $login); if(isset($cek['status']) && $cek['status'] == true){ // continue; } else{ $this->my_usessionpublic->set_userdata('pesan', $cek['message']); echo json_encode($cek); redirect('index.php/user/ext_logout'); die; } #end check auth } /*function getInnerQuery(){ $innerQ = ""; for($i=0; $i<16; $i++){ $j = $i+1; $innerQ = $innerQ." SELECT nim,kdprodi,kdstsemester,kdmk,p".$j." AS idstabsenmhs, 'p".$j."' AS pt FROM absenmhs"; if($j<16) $innerQ = $innerQ." UNION"; } return $innerQ; }*/ function getInnerQuery(){ $innerQ = " SELECT a.nim, a.kdprodi, a.kdstsemester, a.kdmk, b.pn AS idstabsenmhs, b.posisi AS pt FROM absenmhs a, absenmhsrotate b WHERE a.id = b.absenmhs_id "; return $innerQ; } function getJsonFromSP($sql, $parameters){ $KEDUA= $this->load->database('second', TRUE); $query = $KEDUA->query($sql, $parameters); $data = array(); $build_array = array ("success"=>false,"results"=>-1,"data"=>array(),"msg"=>"error"); if ($query->num_rows() == 0) { $build_array["success"]=true; $build_array["results"]=0; $build_array["msg"]="no data"; } if ($query->num_rows() > 0) { $data = $query->result(); $ttl = count($data); if($ttl > 0){ $build_array["success"]=true; $build_array["results"]=$ttl; $build_array["data"]=$data; $build_array["msg"]= ""; } } echo json_encode($build_array); } function getTableKehadiranMhs(){ //?nim=41155010000001&kdstsemester=20122 $nim = '41155010000001'; $kdstsemester = '20122'; $innerQ = $this->getInnerQuery(); $q = "SELECT nim,kdprodi,kdstsemester, sum(H) as H, sum(T) as T, sum(S) as S, sum(I) as I, sum(A) as A, sum(K) as K FROM ( SELECT A.nim,A.kdprodi,A.kdstsemester,A.kdmk,A.idstabsenmhs,B.kdstabsensimhs, CASE WHEN kdstabsensimhs='H' THEN 1 else 0 end as H, CASE WHEN kdstabsensimhs='T' THEN 1 else 0 end as T, CASE WHEN kdstabsensimhs='S' THEN 1 else 0 end as S, CASE WHEN kdstabsensimhs='I' THEN 1 else 0 end as I, CASE WHEN kdstabsensimhs='A' THEN 1 else 0 end as A, CASE WHEN kdstabsensimhs='K' THEN 1 else 0 end as K FROM (".$innerQ.")A LEFT JOIN stabsenmhs B ON B.idstabsenmhs=A.idstabsenmhs )X WHERE nim='$nim' and kdstsemester='$kdstsemester' GROUP BY nim,kdprodi,kdstsemester"; $this->rhlib->jsonFromQuery($q); } function getS_stabsensiMhsSmt(){//series data $nim = $_POST['nim']; //'41155010000001'; $kdstsemester = $_POST['kdstsemester']; $innerQ = $this->getInnerQuery(); $q = "SELECT nim,kdprodi,kdstsemester, kdstabsensimhs,nmstabsensimhs,sum(jum) as jum FROM ( SELECT nim,kdprodi,kdstsemester,kdstabsensimhs,nmstabsensimhs, case when kdstabsensimhs='H' then 1 when kdstabsensimhs='T' then 1 when kdstabsensimhs='S' then 1 when kdstabsensimhs='I' then 1 when kdstabsensimhs='A' then 1 when kdstabsensimhs='K' then 1 else 0 end as jum FROM ( SELECT A.nim,A.kdprodi,A.kdstsemester,A.kdmk,A.idstabsenmhs, B.kdstabsensimhs,B.nmstabsensimhs FROM (".$innerQ.")A LEFT JOIN stabsenmhs B ON B.idstabsenmhs=A.idstabsenmhs )X WHERE nim='$nim' and kdstsemester='$kdstsemester' )Z GROUP BY nim,kdprodi,kdstsemester,kdstabsensimhs,nmstabsensimhs"; $this->rhlib->jsonFromQuery($q); } function getS_kehadiranMhs(){//series data $nim = $_POST['nim']; //'41155010000001'; $innerQ = $this->getInnerQuery(); $q = "SELECT A.nim,A.kdprodi,A.kdstsemester, B.nmstsmt, (ifnull(A.ckehadiran,0)*100/16) as pkehadiran FROM ( SELECT nim,kdprodi,kdstsemester, count(kdstabsensimhs) as ckehadiran FROM ( SELECT A.nim,A.kdprodi,A.kdstsemester,A.kdmk,A.idstabsenmhs, B.kdstabsensimhs FROM (".$innerQ.")A LEFT JOIN stabsenmhs B ON B.idstabsenmhs=A.idstabsenmhs WHERE B.kdstabsensimhs = 'H' and nim='$nim' )X GROUP BY nim,kdprodi,kdstsemester )A LEFT JOIN ( SELECT a.kdstsemester,CONCAT(b.nmthnakademik, ' - ', c.nmjnssemester) as nmstsmt FROM stsemester a LEFT JOIN thnakademik b ON b.idthnakademik=a.idthnakademik LEFT JOIN jsemester c ON c.idjnssemester=a.idjnssemester )B ON B.kdstsemester=A.kdstsemester"; $this->rhlib->jsonFromQuery2($q); } function get_AllJadwalKul(){ //ISTRA $kdstsemester = $this->input->post("kdstsemester"); $where= array(); $where['kdstsemester']=$kdstsemester; $q = $this->db->query("CALL sp_GetAllJadwalKul(?)", $where); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $ttl = count($data); $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); foreach($data as $row) { array_push($build_array["data"],array( 'idruangan'=>$row->idruangan, 'nmruangan'=>$row->nmruangan, 'idklpruangan'=>$row->idklpruangan, 'nmklpruangan'=>$row->nmklpruangan, 'hj11'=>$row->hj11, 'hj12'=>$row->hj12, 'hj13'=>$row->hj13, 'hj14'=>$row->hj14, 'hj15'=>$row->hj15, 'hj16'=>$row->hj16, 'hj21'=>$row->hj21, 'hj22'=>$row->hj22, 'hj23'=>$row->hj23, 'hj24'=>$row->hj24, 'hj25'=>$row->hj25, 'hj26'=>$row->hj26, 'hj31'=>$row->hj31, 'hj32'=>$row->hj32, 'hj33'=>$row->hj33, 'hj34'=>$row->hj34, 'hj35'=>$row->hj35, 'hj36'=>$row->hj36, 'hj41'=>$row->hj41, 'hj42'=>$row->hj42, 'hj43'=>$row->hj43, 'hj44'=>$row->hj44, 'hj45'=>$row->hj45, 'hj46'=>$row->hj46, 'hj51'=>$row->hj51, 'hj52'=>$row->hj52, 'hj53'=>$row->hj53, 'hj54'=>$row->hj54, 'hj55'=>$row->hj55, 'hj56'=>$row->hj56, 'hj61'=>$row->hj61, 'hj62'=>$row->hj62, 'hj63'=>$row->hj63, 'hj64'=>$row->hj64, 'hj65'=>$row->hj65, 'hj66'=>$row->hj66, 'hj71'=>$row->hj71, 'hj72'=>$row->hj72, 'hj73'=>$row->hj73, 'hj74'=>$row->hj74, 'hj75'=>$row->hj75, 'hj76'=>$row->hj76, )); } echo json_encode($build_array); } function get_itemjadwalkuliah(){ //ISTRA $idjam=$this->input->post("idjam"); $kdstsemester=$this->input->post("kdstsemester"); $idhari=$this->input->post("idhari"); $idruangan=$this->input->post("idruangan"); $q = $this->db->query("SELECT * FROM v_jadwalkuliahdet WHERE idjam ='".$idjam."' and kdstsemester ='".$kdstsemester."' and idhari='".$idhari."' and idruangan='".$idruangan."'"); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $ttl = count($data); $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); foreach($data as $row) { array_push($build_array["data"],array( 'kdprodi'=>$row->kdprodi, 'nmprodi'=>$row->nmprodi, 'kdmk'=>$row->kdmk, 'nmmkind'=>$row->nmmkind, 'nidu'=>$row->nidu, 'nmdosdgngelar'=>$row->nmdosdgngelar, )); } echo json_encode($build_array); } function infomhs(){ $sql = $this->db->query("select * from halaman where idklppengguna='2'"); $num = $sql->num_rows(); $numinfo = 1; $echoarr=array(); $echoarr['data']='INFORMASI UNTUK MAHASISWA

'; if($num>0){ $arr =$sql->result(); foreach ($arr as $data) { $echoarr['data'] .= ''.$numinfo++.'. '.$data->judulind.'
'.$data->sinopsisind.'

'; } echo json_encode($echoarr); }else{ echo json_encode($echoarr); } } } ?>