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 getJsonFromSPpublic($sql, $parameters){ $query = $this->db->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 grid(){ //ISTRA $kdstsemester = $this->input->post("kdstsemester"); $idjadwalpmb = $this->input->post("idjadwalpmb"); $idstusm = $this->input->post("idstusm"); $this->db->select("*"); $this->db->from("v_hasilusm"); if($idjadwalpmb !='-'){ $where['idjadwalpmb'] =$idjadwalpmb; } else { $where['kdstsemester'] =$kdstsemester; } if($idstusm !=''){ $where['idstusm'] =$idstusm; } $this->db->where($where); $q = $this->db->get(); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $datax = $this->grid_count(); $ttl = $datax; //====================================================================== $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); foreach($data as $row) { array_push($build_array["data"],array( 'nopmb'=>$row->nopmb, 'nousm'=>$row->nousm, 'tglpmb'=>date('d-m-Y',strtotime(substr($row->tglpmb,0,9))), 'nama'=>$row->nama, 'kdjk'=>$row->kdjk, 'kdprodi1'=>$row->nourutprodi.'.'.$row->nmprodi.' '.$row->nmjenjangstudi,// $row->kdprodi1, 'nmklsmhs'=>$row->nmklsmhs,//$this->nm_field('nmstusm','stusm','idstusm',$row->idstusm), 'nmstmskmhs'=>$row->nmstmskmhs,//$this->nm_field('nmstmskmhs','stmskmhs','idstmskmhs',$row->idstmskmhs), 'nmstusm'=>$row->nmstusm, 'stregistrasi'=>$row->stregistrasi, )); } echo json_encode($build_array); } function grid_count(){ //ISTRA $idjadwalpmb = $this->input->post("idjadwalpmb"); $kdstsemester = $this->input->post("kdstsemester"); $idstusm = $this->input->post("idstusm"); $this->db->select("*"); $this->db->from("v_hasilusm"); if($idjadwalpmb !='-'){ $where['idjadwalpmb'] =$idjadwalpmb; } else { $where['kdstsemester'] =$kdstsemester; } if($idstusm !=''){ $where['idstusm'] =$idstusm; } $this->db->where($where); $q = $this->db->get(); return $q->num_rows(); } //--------------------excel-----------------------// function export_excel($kdstsemester,$idjadwalpmb,$idstusm) { $tablename="v_hasilusm"; $this->db->select("*"); $this->db->from($tablename); if($idjadwalpmb !='-'){ $where['idjadwalpmb'] =$idjadwalpmb; } else { $where['kdstsemester'] =$kdstsemester; } if($idstusm !=''){ $where['idstusm'] =$idstusm; } $this->db->where($where); $q = $this->db->get(); $result = array(); if ($q->num_rows() > 0) { $result = $q->result(); } $data['eksport'] = $result; $data['table'] = "excel_lap_hsl_usm"; $data['fieldname'] = $this->db->list_fields($tablename); $this->load->view('exportexcel', $data); } }