load->library('session'); #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 id_field($column,$tbl,$whereb, $wherea){ $q = "SELECT ".$column." as id FROM ".$tbl." where ".$whereb." = '".$wherea."' " ; $query = $this->db->query($q); $id = ''; if ($query->num_rows() != 0) { $row = $query->row(); $id=$row->id; } return $id; } function nm_field($column,$tbl,$whereb, $wherea){ $q = "SELECT ".$column." as nm FROM ".$tbl." where ".$whereb." = '".$wherea."' " ; $query = $this->db->query($q); $nm= ''; if ($query->num_rows() != 0) { $row = $query->row(); $nm=$row->nm; } return $nm; } function grid(){ //ISTRA $idjadwalpmb = $this->input->post("idjadwalpmb"); $kdstsemester = $this->input->post("kdstsemester"); $where = ($idjadwalpmb !='-') ? "pmb.idjadwalpmb = '$idjadwalpmb'":"jadwalpmb.kdstsemester = '$kdstsemester'"; /*if($idjadwalpmb !='-'){ $where = "pmb.idjadwalpmb = '$idjadwalpmb'"; }elseif($idjadwalpmb ='-'){ $where = "jadwalpmb.kdstsemester = '$kdstsemester'"; }*/ $q = $this->db->query("SELECT v_prodi.kdfakultas AS kdfakultas , v_prodi.nmfakultas AS nmfakultas , v_prodi.kdprodi AS kdprodi , v_prodi.nmprodi AS nmprodi , v_prodi.nmjenjangstudi AS nmjenjangstudi , v_prodi.nourutprodi AS nourutprodi , ifnull((SELECT count(pmb.nopmb) AS countnopmb FROM pmb LEFT JOIN jadwalpmb ON pmb.idjadwalpmb = jadwalpmb.idjadwalpmb JOIN kuitansipmb ON kuitansipmb.nokuitansipmb = pmb.nokuitansipmb WHERE $where AND pmb.kdprodi1 = v_prodi.kdprodi AND pmb.idstpmb = 1 AND kuitansipmb.idstkuitansi = 1), 0) AS jmlpendaftar , ifnull((SELECT count(pmb.nopmb) AS sumnopmb FROM pmb LEFT JOIN jadwalpmb ON pmb.idjadwalpmb = jadwalpmb.idjadwalpmb JOIN kuitansipmb ON kuitansipmb.nokuitansipmb = pmb.nokuitansipmb WHERE date_format(pmb.tglpmb, '%d-%m-%Y') = date_format(now(), '%d-%m-%Y') AND $where AND pmb.kdprodi1 = v_prodi.kdprodi AND pmb.idstpmb = 1 AND kuitansipmb.idstkuitansi = 1), 0) AS jmlpendaftarhariini , ifnull((SELECT count(pmb.nopmb) AS sumnopmb FROM pmb LEFT JOIN jadwalpmb ON pmb.idjadwalpmb = jadwalpmb.idjadwalpmb JOIN kuitansipmb ON kuitansipmb.nokuitansipmb = pmb.nokuitansipmb WHERE pmb.tglpmb BETWEEN (SELECT min(cast(pmb.tglpmb AS DATE)) AS mindatepmbtglpmb FROM pmb LEFT JOIN jadwalpmb ON pmb.idjadwalpmb = jadwalpmb.idjadwalpmb WHERE $where AND pmb.kdprodi1 = v_prodi.kdprodi AND pmb.idstpmb = 1) AND now() AND $where AND pmb.kdprodi1 = v_prodi.kdprodi AND pmb.idstpmb = 1 AND kuitansipmb.idstkuitansi = 1), 0) AS jmlpendaftarsampaihariini , ifnull((SELECT count(pmb.nopmb) AS sumnopmb FROM pmb LEFT JOIN jadwalpmb ON pmb.idjadwalpmb = jadwalpmb.idjadwalpmb JOIN kuitansipmb ON kuitansipmb.nokuitansipmb = pmb.nokuitansipmb WHERE pmb.idstpmb = 1 AND $where AND pmb.kdprodi1 = v_prodi.kdprodi AND pmb.idstpmb = 1 AND kuitansipmb.idstkuitansi = 1), 0) AS terverifikasi , ifnull((SELECT count(pmb.nopmb) AS sumnopmb FROM pmb LEFT JOIN jadwalpmb ON pmb.idjadwalpmb = jadwalpmb.idjadwalpmb JOIN kuitansipmb ON kuitansipmb.nokuitansipmb = pmb.nokuitansipmb WHERE pmb.idstusm IN (1, 3) AND $where AND pmb.kdprodi = v_prodi.kdprodi AND pmb.idstpmb = 1 AND kuitansipmb.idstkuitansi = 1), 0) AS diterima , ifnull((SELECT count(pmb.nopmb) AS sumnopmb FROM pmb LEFT JOIN jadwalpmb ON pmb.idjadwalpmb = jadwalpmb.idjadwalpmb LEFT JOIN klsmhs ON pmb.idklsmhs = klsmhs.idklsmhs JOIN kuitansipmb ON kuitansipmb.nokuitansipmb = pmb.nokuitansipmb WHERE klsmhs.idjnskls = 1 AND $where AND pmb.kdprodi = v_prodi.kdprodi AND pmb.nim IS NOT NULL AND kuitansipmb.idstkuitansi = 1), 0) AS regular , ifnull((SELECT count(pmb.nopmb) AS sumnopmb FROM pmb LEFT JOIN jadwalpmb ON pmb.idjadwalpmb = jadwalpmb.idjadwalpmb LEFT JOIN klsmhs ON pmb.idklsmhs = klsmhs.idklsmhs JOIN kuitansipmb ON kuitansipmb.nokuitansipmb = pmb.nokuitansipmb WHERE klsmhs.idjnskls = 2 AND $where AND pmb.kdprodi = v_prodi.kdprodi AND pmb.nim IS NOT NULL AND kuitansipmb.idstkuitansi = 1), 0) AS nonregular , ifnull((SELECT count(pmb.nopmb) AS sumnopmb FROM pmb LEFT JOIN jadwalpmb ON pmb.idjadwalpmb = jadwalpmb.idjadwalpmb JOIN kuitansipmb ON kuitansipmb.nokuitansipmb = pmb.nokuitansipmb WHERE pmb.kdprodi = v_prodi.kdprodi AND $where AND pmb.nim IS NOT NULL AND kuitansipmb.idstkuitansi = 1), 0) AS registrasi FROM v_prodi ORDER BY v_prodi.kdfakultas"); $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) { array_push($build_array["data"],array( 'nmfakultas'=>$row->nmfakultas, 'nmprodi'=>$row->nmprodi, 'jmlpendaftar'=>$row->jmlpendaftar, 'jmlpendaftarhariini'=>$row->jmlpendaftarhariini, 'jmlpendaftarsampaihariini'=>$row->jmlpendaftarsampaihariini, 'terverifikasi'=>$row->terverifikasi, 'diterima'=>$row->diterima, 'regular'=>$row->regular, 'nonregular'=>$row->nonregular, 'registrasi'=>$row->registrasi, )); } echo json_encode($build_array); } }