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

class Biayappdb 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()
	{	 
		$biayappdb = $this->setting_model->biayappdb();

		$data = array(	'title'			=> 'Aplikasi PPDB MTD - Pengaturan Biaya PPDB',
					  	'biayappdb'		=> $biayappdb,
						'content' 		=> 'biayappdb/edit'
					);
		$this->load->view('layout/wrapper', $data, FALSE);	
	}

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

			$data= array(	'title'		=> 'Edit Data Biaya PPDB',
						  	'content' 	=> 'biayappdb/edit'
						);
			$this->load->view('layout/wrapper', $data, FALSE);	
		//jika validasi oke, masuk database
		}else{
			$inp  = $this->input;
			$data = array(	
              				'biaya_otkp'		=> str_replace('.', '', $inp->post('biaya_otkp')),
							'biaya_tkj'			=> str_replace('.', '', $inp->post('biaya_tkj')),
							'biaya_animasi'		=> str_replace('.', '', $inp->post('biaya_animasi')),		
							'biaya_kuliner'		=> str_replace('.', '', $inp->post('biaya_kuliner')),
							'pot_gel'			=> str_replace('.', '', $inp->post('pot_gel')),
							'pot_dp'			=> str_replace('.', '', $inp->post('pot_dp')),
							'pot_yatim'			=> str_replace('.', '', $inp->post('pot_yatim')),
							'pot_spp'			=> str_replace('.', '', $inp->post('pot_spp')),
							'pot_spp_tkj'		=> str_replace('.', '', $inp->post('pot_spp_tkj')),		
							'pot_spp_animasi'	=> str_replace('.', '', $inp->post('pot_spp_animasi')),		
							'pot_spp_kuliner'	=> str_replace('.', '', $inp->post('pot_spp_kuliner')),		
							'pot_kembar'		=> str_replace('.', '', $inp->post('pot_kembar'))				
						);
			//proses oleh model
			$this->setting_model->edit7($data);

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

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