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

class Pengaturan2 extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->model('setting_model');		
		//proteksi halaman
		$this->simple_login->check_login();

	}

	//Main page biodata
	public function index()
	{	 
		$pengaturan2 = $this->setting_model->panitia();
		$data = array(	'title'			=> 'Aplikasi PPDB MTD - Pengaturan Sekolah, Panitia, Tahun Pelajaran & Biaya Tes',
					  	'pengaturan2'	=> $pengaturan2,
						'content' 		=> 'pengaturan2/edit'
					);
		$this->load->view('layout/wrapper', $data, FALSE);	
	}

	//Edit Pengaturan
	public function edit()
	{
		
		//validasi input
		$valid = $this->form_validation;
		//check nama
		$valid->set_rules('sekolah','Pilih Tombol','required',
			array( 'required'		=> '%s Edit Sekolah'));
		
		//jika sudah dicek dan error
		if($valid->run()===FALSE) {
		//end validasi

			$data= array(	'title'		=> 'Edit Data Pengaturan',
						  	'content' 	=> 'pengaturan2/edit'
						);
			$this->load->view('layout/wrapper', $data, FALSE);	

			
			
		//jika validasi oke, masuk database
		}else{
			$inp  = $this->input;
			$data = array(	
              				'sekolah'		=> $inp->post('sekolah'),
							'alamat'		=> $inp->post('alamat'),
							'website'		=> $inp->post('website'),
							'tlp'			=> $inp->post('tlp'),
							'ketua_yayasan'	=> $inp->post('ketua_yayasan'),
							'kepsek'		=> $inp->post('kepsek'),
							'ketua_ppdb'	=> $inp->post('ketua_ppdb'),
							'bendahara'		=> $inp->post('bendahara'),
							'tp'			=> $inp->post('tp'),
							'kelas_tahun'	=> $inp->post('kelas_tahun'),
							'gelombang'		=> $inp->post('gelombang'),
							'biaya_for'		=> $inp->post('biaya_for'),
							'diskon'		=> $inp->post('diskon')
						);
			//proses oleh model
			$this->setting_model->edit5($data);
			
			$inp8  = $this->input;
			$data8 = array(	
							'th_pelajaran'		    => $inp8->post('th_pelajaran')
						);
			$this->setting_model->edit8($data8);

			//notifikasi dan redirect
			$this->session->set_flashdata('sukses', 'Pengaturan Sekolah, Panitia & Biaya Tes Selesai di Update.');
			redirect(base_url('pengaturan2'),'refresh');
		}
		//end masuk database
	}
}

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