<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Pengumuman extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->model('biodata_model');
		$this->load->model('file');
			
		//proteksi halaman
		$this->simple_login->check_login();
		$this->load->helper(array('url', 'download'));
		
		$this->load->helper('url');
        //load our model
        $this->load->model('Pengumuman_model','pengumuman_model');
	}

	//Main page biodata
	public function index()
	{	 
		
		$data = array(	'title'		=> 'Aplikasi PPDB MTD - Pengumuman Hasil Tes Akademik dan BTQ',
					  	'content' 	=> 'pengumuman/index'
					);
		$this->load->view('layout/wrapper', $data, FALSE);	
	}

	public function cetakberkas($no_pendaftaran)
	{
		$data['data'] = $this->db->get_where('v_rpt_trans_berkas',['no_pendaftaran'=>$no_pendaftaran])->row();
    	$this->load->view('formulir/cetak_berkas',$data);
	}
	
	//public function download($no_pendaftaran)
	//{
		//$data = $this->db->get_where('data_siswa',['no_pendaftaran'=>$id])->row();
		//force_download('uploads/'.$data['no_pendaftaran']);
		
		//$akhir = ".pdf";
		//$data = $this->db->get_where('v_rpt_data_pengumuman', ['no_pendaftaran' => $no_pendaftaran])->row_array();
        //header("Content-Disposition: attachment; filename=" .$data['no_pendaftaran'].$akhir);
        //$fp = fopen("uploads/".$data['no_pendaftaran'].$akhir, 'r');
        //$content = fread($fp, filesize('uploads/'.$data['no_pendaftaran'].$akhir));
        //fclose($fp);
        //echo $content;
        //exit;
		
		//$data = $this->db->get_where('v_rpt_data_pengumuman', ['no_pendaftaran' => $no_pendaftaran])->row_array();
        //header("Content-Disposition: attachment; filename=" . $data['file_upload']);
        //$fp = fopen("uploads/" . $data['file_upload'], 'r');
        //$content = fread($fp, filesize('uploads/' . $data['file_upload']));
        //fclose($fp);
        //echo $content;
        //exit;
	//}
	
	public function download($no_pendaftaran){
		$this->load->helper('download');
		$fileinfo = $this->pengumuman_model->download($no_pendaftaran);
		$file = 'uploads/'.$fileinfo['file_upload'];
		force_download($file, NULL);
	}
	
}

/* End of file biodata.php */
/* Location: ./application/controllers/biodata.php */