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

class Pendaftaran extends CI_Controller 
{
	
	public function __construct() 
	{
        parent::__construct();
		//$this->load->helper('url');
		$this->load->model('M_daftar');

		//---------------

		//---------------
    }
	//-----------------------------------------------------------
	
	//-----------------------------------------------------------

	public function index()
	{
		//----------------------search----------------------------

		//$this->load->view('step3');
	
		//--------------------------------end---------------------

		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$data['tahun']		= date('Y');
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$data['calonsiswa']	= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			if($data['calonsiswa']->id_status == 1)
			{
				$data['disabled1']	= "";
				$data['disabled2']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
			}
			else
			{
				$data['disabled1']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled2']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
			}
			$data['ac1']			= "";
			$data['ac2']			= "";
			$data['ac3']			= "";
			$data['ac4']			= "";
			$data['ac5']			= "";
			$data['ac6']			= "";
			$this->load->view('headerSiswa',$data);
			$this->load->view('salam',$data);
			$this->load->view('footerSiswa');
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
	
	public function step1()
	{
		if($this->session->userdata('calonsiswa'))
		{
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$data['calonsiswa']	= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			if($data['calonsiswa']->nomor_pendaftaran == NULL)
			{
				if($data['calonsiswa']->id_jurusan != NULL)
				{
					$data['disabled1']	= "";
					$data['disabled2']	= "";
					$data['disabled3']	= "";
					$data['disabled4']	= "";
					$data['disabled5']	= "";
					$data['disabled6']	= "";
				}
				else if($data['calonsiswa']->nisn != NULL)
				{
					$data['disabled1']	= "";
					$data['disabled2']	= "";
					$data['disabled3']	= "";
					$data['disabled4']	= "";
					$data['disabled5']	= "";
					$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
				}
				else if($data['calonsiswa']->no_kk != NULL)
				{
					$data['disabled1']	= "";
					$data['disabled2']	= "";
					$data['disabled3']	= "";
					$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
					$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
					$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
				}
				else if($data['calonsiswa']->tempat_lahir != NULL)
				{
					$data['disabled1']	= "";
					$data['disabled2']	= "";
					$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
					$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
					$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
					$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
				}
				else if($data['calonsiswa']->tempat_lahir == NULL)
				{
					$data['disabled1']	= "";
					$data['disabled2']	= "style='pointer-events: none; color:#c5c6c7;'";
					$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
					$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
					$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
					$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
				}
				$data['ac1']		= "active show";
				$data['ac2']		= "";
				$data['ac3']		= "";
				$data['ac4']		= "";
				$data['ac5']		= "";
				$data['ac6']		= "";
				// print_r($data['calonsiswa']);die();
				$this->load->view('headerSiswa',$data);
				$this->load->view('step1',$data);
				$this->load->view('footerSiswa');
			}
			else
			{
				redirect('Pendaftaran','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
	
	public function step1Exec()
	{
		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$session_data				= $this->session->userdata('calonsiswa');
			$id_calon_siswa				= $session_data['id'];
			$data['tempat_lahir']		= $this->input->post('tempat_lahir');
			$tanggal					= $this->input->post('tanggal');
			$bulan						= $this->input->post('bulan');
			$tahun						= $this->input->post('tahun');
			$data['tanggal_lahir']		= $tahun."-".$bulan."-".$tanggal;
			$data['jen_kel']			= $this->input->post('jen_kel');
			$data['agama']				= $this->input->post('agama');
			$data['no_hp']				= $this->input->post('no_hp');
			$data['email']				= $this->input->post('email');
			$data['alamat']				= $this->input->post('alamat');
			$data['transportasi']		= $this->input->post('transportasi');
			$data['jarak']				= $this->input->post('jarak');
			$data['waktu_tempuh']		= $this->input->post('waktu_tempuh');
			$data['cita_cita']			= $this->input->post('cita_cita');
			$data['hoby']				= $this->input->post('hoby');
			$data['kip']				= $this->input->post('kip');
			$data['kks']				= $this->input->post('kks');
			$data['pkh']				= $this->input->post('pkh');
			$milliseconds 				= round(microtime(true) * 1000);
			if($_FILES['foto']['name'] != NULL)
			{
				$calonsiswa				= $this->M_daftar->getCalonSiswa($id_calon_siswa);
				if($calonsiswa->foto != NULL)
				{
					unlink('./files/calon_siswa/foto/'.$calonsiswa->foto);
				}
				$this->load->library('upload');
				$config['upload_path'] 		= './files/calon_siswa/foto/';
				$config['allowed_types']	= '*';
				$config['max_size'] 		= '20000';
				$config['rename'] 			= TRUE;
				$config['file_name']		= $milliseconds.$_FILES['foto']['name'];
				$this->upload->initialize($config);
				$this->upload->do_upload('foto');
				$foto						= $_FILES['foto']['name'];
				$data['foto']				= str_replace(" ","_",$config['file_name']);
			}
			$this->M_daftar->updateCalonSiswa($id_calon_siswa,$data);
			redirect('Pendaftaran/step2','refresh');
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
		
	public function step2()
	{
		if($this->session->userdata('calonsiswa'))
		{
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$data['calonsiswa']	= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			if($data['calonsiswa']->nomor_pendaftaran == NULL)
			{
				if($data['calonsiswa']->tempat_lahir != NULL)
				{
					if($data['calonsiswa']->id_jurusan != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "";
					}
					else if($data['calonsiswa']->nisn != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->no_kk != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir == NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					$data['ac1']		= "";
					$data['ac2']		= "active show";
					$data['ac3']		= "";
					$data['ac4']		= "";
					$data['ac5']		= "";
					$data['ac6']		= "";
					// print_r($data['calonsiswa']);die();
					$this->load->view('headerSiswa',$data);
					$this->load->view('step2',$data);
					$this->load->view('footerSiswa');
				}
				else
				{
					redirect('Pendaftaran/step1','refresh');
				}
			}
			else
			{
				redirect('Pendaftaran','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
	
	public function step2Exec()
	{
		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$session_data				= $this->session->userdata('calonsiswa');
			$id_calon_siswa				= $session_data['id'];
			$data['no_kk']				= $this->input->post('no_kk');
			$data['nama_kk']			= $this->input->post('nama_kk');
			$data['pekerjaan_kk']		= $this->input->post('pekerjaan_kk');
			$data['anak_ke']			= $this->input->post('anak_ke');
			$data['jumlah_saudara']		= $this->input->post('jumlah_saudara');
			$data['nama_ayah']			= $this->input->post('nama_ayah');
			$data['pekerjaan_ayah']		= $this->input->post('pekerjaan_ayah');
			$data['no_hp_ayah']			= $this->input->post('no_hp_ayah');
			$data['alamat_ayah']		= $this->input->post('alamat_ayah');
			$data['nama_ibu']			= $this->input->post('nama_ibu');
			$data['pekerjaan_ibu']		= $this->input->post('pekerjaan_ibu');
			$data['no_hp_ibu']			= $this->input->post('no_hp_ibu');
			$data['alamat_ibu']			= $this->input->post('alamat_ibu');
			$data['nama_wali']			= $this->input->post('nama_wali');
			$data['pekerjaan_wali']		= $this->input->post('pekerjaan_wali');
			$data['no_hp_wali']			= $this->input->post('no_hp_wali');
			$data['alamat_wali']		= $this->input->post('alamat_wali');
			$data['nik_ayah']			= $this->input->post('nik_ayah');
			$data['nik_ibu']			= $this->input->post('nik_ibu');
			$data['nik_wali']			= $this->input->post('nik_wali');
			$data['hasilayah']			= $this->input->post('hasilayah');
			$data['hasilibu']			= $this->input->post('hasilibu');
			$data['hasilwali']			= $this->input->post('hasilwali');
			$data['status_ayah']		= $this->input->post('status_ayah');
			$data['status_ibu']			= $this->input->post('status_ibu');
			$data['pendidikan_ayah']	= $this->input->post('pendidikan_ayah');
			$data['pendidikan_ibu']		= $this->input->post('pendidikan_ibu');
			$data['tempat_lahir_ayah']	= $this->input->post('tempat_lahir_ayah');
			$data['tanggal_lahir_ayah']	= $this->input->post('tanggal_lahir_ayah');
			$data['tempat_lahir_ibu']	= $this->input->post('tempat_lahir_ibu');
			$data['tanggal_lahir_ibu']	= $this->input->post('tanggal_lahir_ibu');
			$this->M_daftar->updateCalonSiswa($id_calon_siswa,$data);
			redirect('Pendaftaran/step3','refresh');
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
		
	public function step3()
	{
		if($this->session->userdata('calonsiswa'))
		{
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$data['calonsiswa']	= $this->M_daftar->getCalonSiswaRaport($id_calon_siswa);
			if($data['calonsiswa']->nomor_pendaftaran == NULL)
			{
				if($data['calonsiswa']->no_kk != NULL)
				{
					if($data['calonsiswa']->id_jurusan != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "";
					}
					else if($data['calonsiswa']->nisn != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->no_kk != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir == NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					$data['ac1']		= "";
					$data['ac2']		= "";
					$data['ac3']		= "active show";
					$data['ac4']		= "";
					$data['ac5']		= "";
					$data['ac6']		= "";
					// print_r($data['calonsiswa']);die();
					$this->load->view('headerSiswa',$data);
					$this->load->view('step3',$data);
					$this->load->view('footerSiswa');
				}
				else
				{
					redirect('Pendaftaran/step2','refresh');
				}
			}
			else
			{
				redirect('Pendaftaran','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
	
	public function step3Exec()
	{
		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$session_data				= $this->session->userdata('calonsiswa');
			$id_calon_siswa				= $session_data['id'];
			$data['nisn']				= $this->input->post('nisn');
			$data['kode_asal_sekolah']	= $this->input->post('kode_asal_sekolah');
			$data['asal_sekolah']		= $this->input->post('asal_sekolah');
			if($data['kode_asal_sekolah'] == "M")
			{
				$data2['aqh_smt1']			= $this->input->post('aqh_smt1');
				$data2['aqh_smt2']			= $this->input->post('aqh_smt2');
				$data2['aqh_smt3']			= $this->input->post('aqh_smt3');
				$data2['aqh_smt4']			= $this->input->post('aqh_smt4');
				$data2['aqh_smt5']			= $this->input->post('aqh_smt5');
				$data2['ski_smt1']			= $this->input->post('ski_smt1');
				$data2['ski_smt2']			= $this->input->post('ski_smt2');
				$data2['ski_smt3']			= $this->input->post('ski_smt3');
				$data2['ski_smt4']			= $this->input->post('ski_smt4');
				$data2['ski_smt5']			= $this->input->post('ski_smt5');
				$data2['fqh_smt1']			= $this->input->post('fqh_smt1');
				$data2['fqh_smt2']			= $this->input->post('fqh_smt2');
				$data2['fqh_smt3']			= $this->input->post('fqh_smt3');
				$data2['fqh_smt4']			= $this->input->post('fqh_smt4');
				$data2['fqh_smt5']			= $this->input->post('fqh_smt5');
				$data2['akh_smt1']			= $this->input->post('akh_smt1');
				$data2['akh_smt2']			= $this->input->post('akh_smt2');
				$data2['akh_smt3']			= $this->input->post('akh_smt3');
				$data2['akh_smt4']			= $this->input->post('akh_smt4');
				$data2['akh_smt5']			= $this->input->post('akh_smt5');
				$data2['bind_smt1']			= $this->input->post('bind_smt1');
				$data2['bind_smt2']			= $this->input->post('bind_smt2');
				$data2['bind_smt3']			= $this->input->post('bind_smt3');
				$data2['bind_smt4']			= $this->input->post('bind_smt4');
				$data2['bind_smt5']			= $this->input->post('bind_smt5');
				$data2['mtk_smt1']			= $this->input->post('mtk_smt1');
				$data2['mtk_smt2']			= $this->input->post('mtk_smt2');
				$data2['mtk_smt3']			= $this->input->post('mtk_smt3');
				$data2['mtk_smt4']			= $this->input->post('mtk_smt4');
				$data2['mtk_smt5']			= $this->input->post('mtk_smt5');
				$data2['bing_smt1']			= $this->input->post('bing_smt1');
				$data2['bing_smt2']			= $this->input->post('bing_smt2');
				$data2['bing_smt3']			= $this->input->post('bing_smt3');
				$data2['bing_smt4']			= $this->input->post('bing_smt4');
				$data2['bing_smt5']			= $this->input->post('bing_smt5');
				$data2['ipa_smt1']			= $this->input->post('ipa_smt1');
				$data2['ipa_smt2']			= $this->input->post('ipa_smt2');
				$data2['ipa_smt3']			= $this->input->post('ipa_smt3');
				$data2['ipa_smt4']			= $this->input->post('ipa_smt4');
				$data2['ipa_smt5']			= $this->input->post('ipa_smt5');
				$data2['ips_smt1']			= $this->input->post('ips_smt1');
				$data2['ips_smt2']			= $this->input->post('ips_smt2');
				$data2['ips_smt3']			= $this->input->post('ips_smt3');
				$data2['ips_smt4']			= $this->input->post('ips_smt4');
				$data2['ips_smt5']			= $this->input->post('ips_smt5');
			}
			else
			{
				$data2['agm_smt1']			= $this->input->post('agm_smt1');
				$data2['agm_smt2']			= $this->input->post('agm_smt2');
				$data2['agm_smt3']			= $this->input->post('agm_smt3');
				$data2['agm_smt4']			= $this->input->post('agm_smt4');
				$data2['agm_smt5']			= $this->input->post('agm_smt5');
				$data2['bind_smt1']			= $this->input->post('sbind_smt1');
				$data2['bind_smt2']			= $this->input->post('sbind_smt2');
				$data2['bind_smt3']			= $this->input->post('sbind_smt3');
				$data2['bind_smt4']			= $this->input->post('sbind_smt4');
				$data2['bind_smt5']			= $this->input->post('sbind_smt5');
				$data2['mtk_smt1']			= $this->input->post('smtk_smt1');
				$data2['mtk_smt2']			= $this->input->post('smtk_smt2');
				$data2['mtk_smt3']			= $this->input->post('smtk_smt3');
				$data2['mtk_smt4']			= $this->input->post('smtk_smt4');
				$data2['mtk_smt5']			= $this->input->post('smtk_smt5');
				$data2['bing_smt1']			= $this->input->post('sbing_smt1');
				$data2['bing_smt2']			= $this->input->post('sbing_smt2');
				$data2['bing_smt3']			= $this->input->post('sbing_smt3');
				$data2['bing_smt4']			= $this->input->post('sbing_smt4');
				$data2['bing_smt5']			= $this->input->post('sbing_smt5');
				$data2['ipa_smt1']			= $this->input->post('sipa_smt1');
				$data2['ipa_smt2']			= $this->input->post('sipa_smt2');
				$data2['ipa_smt3']			= $this->input->post('sipa_smt3');
				$data2['ipa_smt4']			= $this->input->post('sipa_smt4');
				$data2['ipa_smt5']			= $this->input->post('sipa_smt5');
				$data2['ips_smt1']			= $this->input->post('sips_smt1');
				$data2['ips_smt2']			= $this->input->post('sips_smt2');
				$data2['ips_smt3']			= $this->input->post('sips_smt3');
				$data2['ips_smt4']			= $this->input->post('sips_smt4');
				$data2['ips_smt5']			= $this->input->post('sips_smt5');
			}
			$this->M_daftar->updateCalonSiswa($id_calon_siswa,$data);
			$raport						= $this->M_daftar->getCalonSiswaRaport($id_calon_siswa);
			if($raport->bind_smt1 == NULL)
			{
				$data2['id_calon_siswa']= $id_calon_siswa;
				$this->M_daftar->addNilaiRaport($data2);
				redirect('Pendaftaran/step4','refresh');
			}
			else
			{
				$this->M_daftar->updateNilaiRaport($id_calon_siswa,$data2);
				redirect('Pendaftaran/step4','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
		
	public function step4()
	{
		if($this->session->userdata('calonsiswa'))
		{
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$data['calonsiswa']	= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			if($data['calonsiswa']->nomor_pendaftaran == NULL)
			{
				if($data['calonsiswa']->nisn != NULL)
				{
					$data['prestasi']	= $this->M_daftar->getPrestasi($id_calon_siswa);
					if($data['calonsiswa']->id_jurusan != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "";
					}
					else if($data['calonsiswa']->nisn != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->no_kk != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir == NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					$data['ac1']		= "";
					$data['ac2']		= "";
					$data['ac3']		= "";
					$data['ac4']		= "active show";
					$data['ac5']		= "";
					$data['ac6']		= "";
					// print_r($data['calonsiswa']);die();
					$this->load->view('headerSiswa',$data);
					$this->load->view('step4',$data);
					$this->load->view('footerSiswa');
				}
				else
				{
					redirect('Pendaftaran/step3','refresh');
				}
			}
			else
			{
				redirect('Pendaftaran','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
		
	public function addPrestasi()
	{
		if($this->session->userdata('calonsiswa'))
		{
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$data['calonsiswa']	= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			if($data['calonsiswa']->nomor_pendaftaran == NULL)
			{
				if($data['calonsiswa']->nisn != NULL)
				{
					if($data['calonsiswa']->id_jurusan != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "";
					}
					else if($data['calonsiswa']->nisn != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->no_kk != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir == NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					$data['ac1']		= "";
					$data['ac2']		= "";
					$data['ac3']		= "";
					$data['ac4']		= "active show";
					$data['ac5']		= "";
					$data['ac6']		= "";
					// print_r($data['calonsiswa']);die();
					$this->load->view('headerSiswa',$data);
					$this->load->view('addPrestasi',$data);
					$this->load->view('footerSiswa');
				}
				else
				{
					redirect('Pendaftaran/step3','refresh');
				}
			}
			else
			{
				redirect('Pendaftaran','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
	
	public function addPrestasiExec()
	{
		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$session_data				= $this->session->userdata('calonsiswa');
			$data['id_calon_siswa']		= $session_data['id'];
			$data['tingkat']			= $this->input->post('tingkat');
			$data['juara']				= $this->input->post('juara');
			$data['nama_kejuaraan']		= $this->input->post('nama_kejuaraan');
			$data['tahun']				= $this->input->post('tahun');
			
			$this->load->library('upload');
			$config['upload_path'] 		= './files/calon_siswa/prestasi/';
			$config['allowed_types']	= '*';
			$config['max_size'] 		= '20000';
			$this->upload->initialize($config);
			$this->upload->do_upload('sertifikat');
			$sertifikat					= $_FILES['sertifikat']['name'];
			$data['sertifikat']			= str_replace(" ","_",$sertifikat);
			
			$this->M_daftar->addPrestasi($data);
			redirect('Pendaftaran/step4','refresh');
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
		
	public function editPrestasi()
	{
		if($this->session->userdata('calonsiswa'))
		{
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$data['calonsiswa']	= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			$id_prestasi		= $this->uri->segment(3);
			$data['prestasi']	= $this->M_daftar->getPrestasiDetail($id_prestasi);
			if($data['calonsiswa']->nomor_pendaftaran == NULL)
			{
				if($data['calonsiswa']->nisn != NULL)
				{
					if($data['calonsiswa']->id_jurusan != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "";
					}
					else if($data['calonsiswa']->nisn != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->no_kk != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir == NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					$data['ac1']		= "";
					$data['ac2']		= "";
					$data['ac3']		= "";
					$data['ac4']		= "active show";
					$data['ac5']		= "";
					$data['ac6']		= "";
					// print_r($data['calonsiswa']);die();
					$this->load->view('headerSiswa',$data);
					$this->load->view('editPrestasi',$data);
					$this->load->view('footerSiswa');
				}
				else
				{
					redirect('Pendaftaran/step3','refresh');
				}
			}
			else
			{
				redirect('Pendaftaran','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
	
	public function editPrestasiExec()
	{
		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$id_prestasi				= $this->input->post('id_prestasi');
			$data['tingkat']			= $this->input->post('tingkat');
			$data['juara']				= $this->input->post('juara');
			$data['nama_kejuaraan']		= $this->input->post('nama_kejuaraan');
			$data['tahun']				= $this->input->post('tahun');
			if($_FILES['sertifikat']['name'] != NULL)
			{
				$prestasi				= $this->M_daftar->getPrestasiDetail($id_prestasi);
				unlink('./files/calon_siswa/prestasi/'.$prestasi->sertifikat);
				$this->load->library('upload');
				$config['upload_path'] 		= './files/calon_siswa/prestasi/';
				$config['allowed_types']	= '*';
				$config['max_size'] 		= '20000';
				$this->upload->initialize($config);
				$this->upload->do_upload('sertifikat');
				$sertifikat					= $_FILES['sertifikat']['name'];
				$data['sertifikat']				= str_replace(" ","_",$sertifikat);
			}
			$this->M_daftar->updatePrestasi($id_prestasi,$data);
			redirect('Pendaftaran/step4','refresh');
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
	
	public function deletePrestasi()
	{
		if($this->session->userdata('calonsiswa'))
		{
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$calonsiswa			= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			$id_prestasi		= $this->uri->segment(3);
			if($calonsiswa->nomor_pendaftaran == NULL)
			{
				if($calonsiswa->nisn != NULL)
				{
					$prestasi	= $this->M_daftar->getPrestasiDetail($id_prestasi);
					unlink('./files/calon_siswa/prestasi/'.$prestasi->sertifikat);
					$this->M_daftar->deletePrestasi($id_prestasi);
					redirect('Pendaftaran/step4','refresh');
				}
				else
				{
					redirect('Pendaftaran/step3','refresh');
				}
			}
			else
			{
				redirect('Pendaftaran','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
		
	public function step5()
	{
		if($this->session->userdata('calonsiswa'))
		{
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$data['calonsiswa']	= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			$data['jurusan']	= $this->M_daftar->getJurusanAktif();
			$data['berkas']		= $this->M_daftar->getBerkas($id_calon_siswa);
			if($data['calonsiswa']->nomor_pendaftaran == NULL)
			{
				if($data['calonsiswa']->nisn != NULL)
				{
					if($data['calonsiswa']->id_jurusan != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "";
					}
					else if($data['calonsiswa']->nisn != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "";
						$data['disabled5']	= "";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->no_kk != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir != NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					else if($data['calonsiswa']->tempat_lahir == NULL)
					{
						$data['disabled1']	= "";
						$data['disabled2']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
						$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
					}
					$data['ac1']		= "";
					$data['ac2']		= "";
					$data['ac3']		= "";
					$data['ac4']		= "";
					$data['ac5']		= "active show";
					$data['ac6']		= "";
					// print_r($data['calonsiswa']);die();
					$this->load->view('headerSiswa',$data);
					$this->load->view('step5',$data);
					$this->load->view('footerSiswa');
				}
				else
				{
					redirect('Pendaftaran/step4','refresh');
				}
			}
			else
			{
				redirect('Pendaftaran','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
	
	public function step5Exec()
	{
		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$session_data				= $this->session->userdata('calonsiswa');
			$id_calon_siswa				= $session_data['id'];
			$berkas						= $this->M_daftar->getBerkas($id_calon_siswa);
			$cekBerkas					= 0;
			for($i=1;$i<=7;$i++)
			{
				foreach($berkas as $b)
				{
					if($i == $b['id_kategori_berkas'])
					{
						$cekBerkas++;
					}
				}
			}
			// $cekNarkoba = 0;
			// foreach($berkas as $be)
			// {
				// if($be['id_kategori_berkas'] == 13)
				// {
					// $cekNarkoba++;
				// }
			// }
			if($cekBerkas == 7)
			{
				$data['id_jurusan']			= $this->input->post('id_jurusan');
				$data['id_jurusan2']		= $this->input->post('id_jurusan2');
				$this->M_daftar->updateCalonSiswa($id_calon_siswa,$data);
				redirect('Pendaftaran/step6','refresh');
			}
			else
			{
				$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<p>Berkas Anda belum lengkap. Berkas yang WAJIB diunggah adalah Akta Kelahiran, KK, Rapor Semester 1 s/d 5 Surat Pernyataan Bebas Narkoba 
						</center>
					</div>');	
				redirect('Pendaftaran/step5','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
		
	public function step6()
	{
		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$calon_siswa		= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			if($calon_siswa->nomor_pendaftaran == NULL)
			{
				if($calon_siswa->id_jurusan != NULL)
				{
					$tahun				= date('Y');
					$year				= date('y');
					$ambil_akhir		= $this->M_daftar->getAntrian($tahun);
					// print_r($ambil_akhir);die();
					if($calon_siswa->kode_asal_sekolah == "M")
					{
						$data2['antrian_mts']	= $ambil_akhir->antrian_mts + 1;
						if($ambil_akhir->antrian_mts < 10)
						{
							$akhiran			= "000".$data2['antrian_mts'];
						}
						else if($ambil_akhir->antrian_mts < 100)
						{
							$akhiran			= "00".$data2['antrian_mts'];
						}
						else if($ambil_akhir->antrian_mts < 1000)
						{
							$akhiran			= "0".$data2['antrian_mts'];
						}
						else if($ambil_akhir->antrian_mts < 10000)
						{
							$akhiran			= $data2['antrian_mts'];
						}
						$kode						= "M";
					}
					else
					{
						$data2['antrian_smp']	= $ambil_akhir->antrian_smp + 1;
						if($ambil_akhir->antrian_smp < 10)
						{
							$akhiran			= "000".$data2['antrian_smp'];
						}
						else if($ambil_akhir->antrian_smp < 100)
						{
							$akhiran			= "00".$data2['antrian_smp'];
						}
						else if($ambil_akhir->antrian_smp < 1000)
						{
							$akhiran			= "0".$data2['antrian_smp'];
						}
						else if($ambil_akhir->antrian_smp < 10000)
						{
							$akhiran			= $data2['antrian_smp'];
						}
						$kode						= "S";
					}
					// print_r($data2);die();
					$data['nomor_pendaftaran']	= $kode.$year.$akhiran;
					$data['id_status']			= 2;
					$data['tanggal_submit']		= date('Y-m-d');
					$this->M_daftar->updateCalonSiswa($id_calon_siswa,$data);
					$this->M_daftar->updateAntrian($tahun,$data2);
				}
				else
				{
					redirect('Pendaftaran/step5','refresh');
				}
			}
			$data['calonsiswa']	= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			$data['raport']		= $this->M_daftar->getCalonSiswaRaport($id_calon_siswa);
			$data['jurusan']	= $this->M_daftar->getCalonSiswaJurusan($data['calonsiswa']->id_jurusan);
			$data['prestasi']	= $this->M_daftar->getPrestasi($id_calon_siswa);
			$data['jurusan2']	= $this->M_daftar->getJurusanDetail($calon_siswa->id_jurusan2);
			
			
			// untuk kebutuhan Tes Akademik
			$getKelas				= $this->M_daftar->getKelasTerakhir();
			$data3['nama']			= $data['calonsiswa']->nama;
			$data3['nim']			= $data['nomor_pendaftaran'];
			$data3['email']			= $data['calonsiswa']->email;
			$data3['jenis_kelamin']	= $data['calonsiswa']->jen_kel;
			$data3['kelas_id']		= $getKelas->id_kelas;
			$this->M_daftar->addCalonSiswaTes($data3);
			// print_r($data);die();
			if($data['calonsiswa']->id_jurusan != NULL)
			{
				$data['prestasi']	= $this->M_daftar->getPrestasi($id_calon_siswa);
				$data['ac1']		= "";
				$data['disabled1']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['ac2']		= "";
				$data['disabled2']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['ac3']		= "";
				$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['ac4']		= "";
				$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['ac5']		= "";
				$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['ac6']		= "active show";
				$data['disabled6']	= "";
				// print_r($data['calonsiswa']);die();
				$this->load->view('headerSiswa',$data);
				$this->load->view('step6',$data);
				$this->load->view('footerSiswa');
			}
			else
			{
				redirect('Pendaftaran/step5','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
	
	public function cetakKartuPendaftaran()
	{
		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$month 						= array("","Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember");
			$data['today']				= date('d')." ".$month[date('n')]." ".date('Y');
			$session_data				= $this->session->userdata('calonsiswa');
			$id_calon_siswa				= $session_data['id'];
			$calon_siswa				= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			if($calon_siswa->nomor_pendaftaran != NULL)
			{
				$tahun						= date('Y');
				$data['calon_siswa']		= $this->M_daftar->getSiswaJurusan($id_calon_siswa);
				$data['nilai']				= $this->M_daftar->getSiswaRaport($id_calon_siswa);
				$data['prestasi']			= $this->M_daftar->getPrestasi($id_calon_siswa);
				$data['tahun']				= $tahun;
				$data['tenggat']			= $this->M_daftar->getTenggat();
				$data['jurusan2']			= $this->M_daftar->getJurusanDetail($calon_siswa->id_jurusan2);
				// $tanggal					= "+".$data['tenggat']->tenggat." day";
				// $tambah						= strtotime($tanggal);
				$hari						= $data['tenggat']->tenggat;
				$data['hari_ini']			= $calon_siswa->tanggal_submit;
				// $data['akhir_tenggat']		= date(strtotime($data['hari_ini']),$tambah);
				$data['akhir_tenggat']		= date('Y-m-d', strtotime('+'.$hari.' day', strtotime($data['hari_ini'])));
				$this->load->library('pdfgenerator');
				$data['file_pdf'] = 'Kartu Pendaftaran - '.$data['calon_siswa']->nama.' - '.$data['calon_siswa']->nomor_pendaftaran;
				$paper = 'A4';
				$orientation = "portrait";
				// $data['title_pdf'] = $file_pdf.".pdf";
				$html = $this->load->view('kartuPendaftaran',$data, true);
				$this->pdfgenerator->generate($html, $data['file_pdf'],$paper,$orientation);
			}
			else
			{
				redirect('Pendaftaran/step5','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
	
	public function cetakHasilFinalisasi()
	{
		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$month 						= array("","Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember");
			$data['today']				= date('d')." ".$month[date('n')]." ".date('Y');
			$session_data				= $this->session->userdata('calonsiswa');
			$id_calon_siswa				= $session_data['id'];
			$data['calon_siswa']		= $this->M_daftar->getSiswaJurusan($id_calon_siswa);
			$data['jurusan']			= $this->M_daftar->getJurusan();
			if($data['calon_siswa']->nomor_pendaftaran != NULL && $data['calon_siswa']->hasil_wawancara == "Diterima")
			{
				$data['tahun']			= date('Y');
				$this->load->library('pdfgenerator');
				$file_pdf = 'Hasil Finalisasi - '.$data['calon_siswa']->nama.' - '.$data['calon_siswa']->nomor_pendaftaran;
				$paper = 'A5';
				$orientation = "landscape";
				$data['title_pdf'] = $file_pdf.".pdf";
				$html = $this->load->view('hasilFinalisasi',$data, true);
				$this->pdfgenerator->generate($html, $file_pdf,$paper,$orientation);
			}
			else
			{
				redirect('Pendaftaran/step5','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
		
	public function uploadBerkas()
	{
		if($this->session->userdata('calonsiswa'))
		{
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$data['calonsiswa']	= $this->M_daftar->getCalonSiswa($id_calon_siswa);
			if($data['calonsiswa']->id_status == 4)
			{
				$data['berkas']		= $this->M_daftar->getBerkas($id_calon_siswa);
				$data['disabled1']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled2']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled3']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled4']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled5']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
				$data['ac1']		= "";
				$data['ac2']		= "";
				$data['ac3']		= "";
				$data['ac4']		= "";
				$data['ac5']		= "";
				$data['ac6']		= "";
				
				$cekAkta			= $this->M_daftar->cekAkta($id_calon_siswa);
				$cekKK				= $this->M_daftar->cekKK($id_calon_siswa);
				$cekRaportSem1		= $this->M_daftar->cekRaportSem1($id_calon_siswa);
				$cekRaportSem2		= $this->M_daftar->cekRaportSem2($id_calon_siswa);
				$cekRaportSem3		= $this->M_daftar->cekRaportSem3($id_calon_siswa);
				$cekRaportSem4		= $this->M_daftar->cekRaportSem4($id_calon_siswa);
				$cekRaportSem5		= $this->M_daftar->cekRaportSem5($id_calon_siswa);
				//$cekSKS				= $this->M_daftar->cekSKS($id_calon_siswa);
				//$cekSPBN			= $this->M_daftar->cekSPBN($id_calon_siswa);
				if($cekAkta != NULL && $cekKK != NULL && $cekRaportSem1 != NULL && $cekRaportSem2 != NULL && $cekRaportSem3 != NULL && $cekRaportSem4 != NULL && $cekRaportSem5 != NULL)
				{
					$data['tombol'] = "aktif";
				}
				else
				{
					$data['tombol'] = "mati";
				}
				// print_r($cekKK);die();
				$this->load->view('headerSiswa',$data);
				$this->load->view('uploadBerkas',$data);
				$this->load->view('footerSiswa');
			}
			else
			{
				redirect('Pendaftaran','refresh');
			}
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
	
	public function uploadBerkasExec()
	{
		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$session_data				= $this->session->userdata('calonsiswa');
			$id_calon_siswa				= $session_data['id'];
			$milliseconds 				= round(microtime(true) * 1000);
			$this->load->library('upload');
			$config['upload_path'] 		= './files/calon_siswa/docs/';
			$config['allowed_types']	= '*';
			$config['max_size'] 		= '20000';
			$config['rename'] 			= TRUE;
			$config['file_name']		= $milliseconds.$_FILES['bukti_pembayaran']['name'];
			$this->upload->initialize($config);
			$this->upload->do_upload('bukti_pembayaran');
			$data['bukti_pembayaran']	= str_replace(" ","_",$config['file_name']);
			$data['nominal_pembayaran']	= str_replace(".","",$this->input->post('nominal_pembayaran'));
			// print_r($data['nominal_pembayaran']);die();
			$data['id_status']			= 5;
			$this->M_daftar->updateCalonSiswa($id_calon_siswa, $data);
			redirect('Pendaftaran','refresh');
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
		
	public function addBerkas()
	{
		if($this->session->userdata('calonsiswa'))
		{
			$session_data		= $this->session->userdata('calonsiswa');
			$id_calon_siswa		= $session_data['id'];
			$data['kategori_berkas']	= $this->M_daftar->getKategoriBerkas();
			$data['disabled1']	= "";
			$data['disabled2']	= "";
			$data['disabled3']	= "";
			$data['disabled4']	= "";
			$data['disabled5']	= "";
			$data['disabled6']	= "style='pointer-events: none; color:#c5c6c7;'";
			$data['ac1']				= "";
			$data['ac2']				= "";
			$data['ac3']				= "";
			$data['ac4']				= "";
			$data['ac5']				= "";
			$data['ac6']				= "";
			// print_r($data['calonsiswa']);die();
			$this->load->view('headerSiswa',$data);
			$this->load->view('addBerkas',$data);
			$this->load->view('footerSiswa');
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
		
	public function addBerkasExec()
	{
		if($this->session->userdata('calonsiswa'))
		{
			date_default_timezone_set('Asia/Jakarta');
			$session_data				= $this->session->userdata('calonsiswa');
			$data['id_calon_siswa']		= $session_data['id'];
			$milliseconds 				= round(microtime(true) * 1000);
			$this->load->library('upload');
			$config['upload_path'] 		= './files/calon_siswa/docs/';
			$config['allowed_types']	= '*';
			$config['max_size'] 		= '20000';
			$config['rename'] 			= TRUE;
			$config['file_name']		= $milliseconds.$_FILES['file_berkas']['name'];
			$this->upload->initialize($config);
			$this->upload->do_upload('file_berkas');
			$data['file_berkas']		= str_replace(" ","_",$config['file_name']);
			$data['nama_berkas']		= $this->input->post('nama_berkas');
			$data['id_kategori_berkas']	= $this->input->post('id_kategori_berkas');
			$this->M_daftar->addBerkas($data);
			redirect('Pendaftaran/step5','refresh');
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
		
	public function deleteBerkas()
	{
		if($this->session->userdata('calonsiswa'))
		{
			$id_berkas		= $this->uri->segment(3);
			$berkas			= $this->M_daftar->getBerkasDetail($id_berkas);
			unlink('./files/calon_siswa/docs/'.$berkas->file_berkas);
			$this->M_daftar->deleteBerkas($id_berkas);
			redirect('Pendaftaran/step5','refresh');
		}
		else
		{
			$this->session->set_flashdata('msg', 
					'<div class="alert alert-danger">
						<center>
							<h4>Maaf!</h4>
							<p>Anda belum login. Silakan login terlebih dahulu!</p>
						</center>
					</div>');	
			redirect('Login');
		}
	}
}
