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

class Pengaturan 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()
	{	 
     
		$data = array(	'title'		=> 'Aplikasi PPDB MTD - Pengaturan Ketentuan di Peserta',
					  	'content' 	=> 'pengaturan/edit'
					);
		$this->load->view('layout/wrapper', $data, FALSE);	
	}

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

			$data= array(	'title'		=> 'Edit Data Tombol Pengaturan',
						  	'content' 	=> 'pengaturan/edit'
						);
			$this->load->view('layout/wrapper', $data, FALSE);	
		//jika validasi oke, masuk database
		}else{
			$inp  = $this->input;
			$data = array(	
              				'pengaturan_value'		   	=> $inp->post('biodata')
						);
			//proses oleh model
			$this->setting_model->edit($data);

			$inp2  = $this->input;
			$data2 = array(	
							'pengaturan_value'		    => $inp2->post('password')
						);
			$this->setting_model->edit2($data2);

			$inp3  = $this->input;
			$data3 = array(	
							'pengaturan_value'		    => $inp3->post('tampil_tanggal')
						);
			$this->setting_model->edit3($data3);

			$inp4  = $this->input;
			$data4 = array(	
							'pengaturan_value'		    => $inp4->post('tampil_pengumuman')
						);
			$this->setting_model->edit4($data4);

			//notifikasi dan redirect
			$this->session->set_flashdata('sukses', 'Pengaturan Selesai di Update.');
			redirect(base_url('pengaturan'),'refresh');
		}
		//end masuk database
	}
}

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