load->library('session'); } function mhs_lulus_ijazah(){ $start = $this->input->post("start"); $limit = $this->input->post("limit"); $fields = $this->input->post("fields"); $query = $this->input->post("query"); $kdprodi = $this->input->post("kdprodi"); $kdstsemester = $this->input->post("thnakademik"); $id = $this->input->post("idnya"); $keywordnya = $this->input->post("keyword"); $this->db->select("*"); $this->db->from("v_mhs_ijazah"); if($fields!="" || $query !=""){ $k=array('[',']','"'); $r=str_replace($k, '', $fields); $b=explode(',', $r); $c=count($b); for($i=0;$i<$c;$i++){ $d[$b[$i]]=$query; } $this->db->or_like($d, $query); } $where = array(); if ($id == 'NPM'){ $this->db->like('nim', $keywordnya); }else if ($id== 'Nama Mahasiswa'){ $this->db->like('nmmhs', $keywordnya); }else if ($id == '(L/P)'){ $this->db->like('kdjnskelamin', $keywordnya); }else if ($id == 'Tpt. Lahir'){ $this->db->like('tptlahir', $keywordnya); }else if ($id == 'Tgl. Lahir'){ $this->db->like('tgllahir', $keywordnya); }else if ($id == 'Program Studi'){ $this->db->like('nmprodi', $keywordnya); }else if ($id == 'Status Program Studi'){ $this->db->like('stprodi', $keywordnya); }else if ($id == 'No. SK Akreditasi'){ $this->db->like('noskakreditasi', $keywordnya); }else if ($id == 'Tgl. SK Akreditasi'){ $this->db->like('tglskakreditasi', $keywordnya); }else if ($id == 'Tahun Masuk'){ $this->db->like('thnmasuk', $keywordnya); }else if ($id == 'Tgl. Lulus Sidang'){ $this->db->like('tgllulus', $keywordnya); }else if ($id == 'Gelar'){ $this->db->like('gelar', $keywordnya); }else if ($id == 'No. Ijazah'){ $this->db->like('noijazah', $keywordnya); }else if ($id == 'Tgl. Ijazah'){ $this->db->like('tglijazah', $keywordnya); }else if ($id == 'Pembantu Ketua Bidang Akademik'){ $this->db->like('pimpinan2', $keywordnya); }else if ($id == 'Pimpinan/Ketua'){ $this->db->like('pimpinan1', $keywordnya); } if($kdprodi != ''){ $where['kdprodi'] = $kdprodi; } if($kdstsemester != ''){ $where['kdstsemester'] = $kdstsemester; } //if($kdprodi !='' || $kdstsemester !=''){ $this->db->where($where); //} if ($start!=null){ $this->db->limit($limit,$start); }else{ $this->db->limit(50,0); } $q = $this->db->get(); // $q = $this->db->get(); $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( 'nim'=>$row->nim, 'nmmhs'=>$row->nmmhs, 'kdjnskelamin'=>$row->kdjnskelamin, 'tptlahir'=>$row->tptlahir, 'tgllahir'=>$row->tgllahir, 'nmprodi'=>$row->nmprodi, 'stprodi'=>$row->stprodi, 'noskakreditasi'=>$row->noskakreditasi, 'tglskakreditasi'=>$row->tglskakreditasi, 'thnmasuk'=>$row->thnmasuk, 'tgllulus'=>$row->tgllulus, 'gelar'=>$row->gelar, 'noijazah'=>$row->noijazah, 'tglijazah'=>$row->tglijazah, 'pimpinan2'=>$row->pimpinan2, 'pimpinan1'=>$row->pimpinan1, )); } echo json_encode($build_array); } function update_ijazah(){ // ISTRA $nimnya=$this->input->post("nim"); $noijazahnya=$this->input->post("noijazah"); $tgijazahnya=$this->input->post("tglijazah"); $pimpinnya2=$this->input->post("pimpin2"); $pimpinnya1=$this->input->post("pimpin1"); $data = array( 'noijazah'=> $noijazahnya, 'tglijazah'=> (!$tgijazahnya) ? null:$tgijazahnya, 'idpimpinan2'=> (!$pimpinnya2) ? null:$this->id_field('idpimpinan', 'pimpinan', 'nmpimpinan',$pimpinnya2), 'idpimpinan1'=> (!$pimpinnya1) ? null:$this->id_field('idpimpinan', 'pimpinan', 'nmpimpinan',$pimpinnya1), ); $this->db->trans_begin(); $where['nim']=$nimnya; $this->db->where($where); $this->db->update("mahasiswa", $data); if ($this->db->trans_status() === FALSE) { $this->db->trans_rollback(); $return["success"]=false; $return["message"]="Ubah Data gagal"; } else { $this->db->trans_commit(); $return["success"]=true; $return["message"]="Ubah Data Berhasil"; } return $return; } 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 export_excel($kdprodi,$kdstsemester) { $querymhs = "SELECT * FROM v_mhs_ijazah WHERE kdprodi = '".$kdprodi."' AND kdstsemester = '".$kdstsemester."'"; $data['eksport'] = $this->db->query($querymhs)->result(); $data['table'] = "excel_daftar_mhslulus"; $data['fieldname'] = array(); $getloop='loop'; foreach ($data['eksport'] as $row) { if ($getloop=='loop') { foreach ($row as $key => $value) { array_push($data['fieldname'], $key); } } $getloop='end'; } $this->load->view('exportexcel', $data); } } ?>