load->library('session'); } 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 $y=''; $start = $this->input->post("start"); $limit = $this->input->post("limit"); $idjadwalpmb = $this->input->post("idjadwalpmb"); $kdstsemester = $this->input->post("kdstsemester"); $kdprodi = $this->input->post("kdprodi"); $this->db->select("*"); $this->db->from("v_pendaftar"); if($idjadwalpmb !='-'){ $where['idjadwalpmb'] =$idjadwalpmb; } else { $where['kdstsemester'] =$kdstsemester; } if($kdprodi !=''){ $where['kdprodi1'] =$kdprodi; } $this->db->where($where); if ($start!=null){ $this->db->limit($limit,$start); }else{ $this->db->limit(50,0); } $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, 'tglpmb'=>date('d-m-Y',strtotime(substr($row->tglpmb,0,9))), 'nama'=>$row->nama, 'kdjk'=>$row->kdjk, 'kdprodi1'=>$this->nm_field('nourutprodi','v_prodi','kdprodi',$row->kdprodi1).'.'.$this->nm_field('nmprodi','v_prodi','kdprodi',$row->kdprodi1).' '. $this->nm_field('nmjenjangstudi','v_prodi','kdprodi',$row->kdprodi1),// $row->kdprodi1, 'nmklsmhs'=>$row->nmklsmhs,//$this->nm_field('nmstusm','stusm','idstusm',$row->idstusm), 'nmstmskmhs'=>$row->nmstmskmhs,//$this->nm_field('nmstmskmhs','stmskmhs','idstmskmhs',$row->idstmskmhs), )); } echo json_encode($build_array); } function grid_count(){ //ISTRA $idjadwalpmb = $this->input->post("idjadwalpmb"); $kdstsemester = $this->input->post("kdstsemester"); $kdprodi = $this->input->post("kdprodi"); $this->db->select("*"); $this->db->from("v_pendaftar"); if($idjadwalpmb !='-'){ $where['idjadwalpmb'] =$idjadwalpmb; } else { $where['kdstsemester'] =$kdstsemester; } if($kdprodi !=''){ $where['kdprodi1'] =$kdprodi; } $this->db->where($where); $q = $this->db->get(); return $q->num_rows(); } function export_excel($kdstsemester,$idjadwalpmb,$kdprodi) { if($idjadwalpmb !='-'){ $where['idjadwalpmb'] =$idjadwalpmb; } else { $where['kdstsemester'] =$kdstsemester; } if($kdprodi !=''){ $where['kdprodi1'] =$kdprodi; } $this->db->select("nopmb,tglpmb,nama,kdjk,kdprodi1,nmklsmhs,nmstmskmhs"); $this->db->from("v_pendaftar"); $this->db->where($where); $q = $this->db->get(); $data['eksport'] = $q->result(); $data['table'] = "excel_lap_pmb"; $data['fieldname'] = array( 'nopmb', 'tglpmb', 'nama', 'kdjk', 'kdprodi1', 'nmklsmhs', 'nmstmskmhs', ); $this->load->view('exportexcel', $data); } }