<?php

if (isset($_POST) && !empty($_POST)) {
    $application = new Application();
    $application->id_pelajar = (int) $_POST['id_pelajar'];
    $application->id_sekolah = (int) $_POST['sekolah'];
    $application->id_subjek = (int) $_POST['subjek'];
    if ($application->submit()) {
        $_SESSION['success'] = 'Permohonan Di Hantar!';
        header('Location: index.php?module=student');
        exit;
    } else {
        $_SESSION['error'] = 'Permohonan Gagal!';
    }
}
ob_start();
$pelajar = Student::findById($_SESSION['id_pelajar']);
$sekolahs = School::senaraiSekolah();
$application = Application::all($_SESSION['id_pelajar'], array('status' => 1));
?>

<div>
	<div>
		<h1>Permohonan Baru</h1>
		<hr />
	</div>
	
	<?php 
if (count($application) > 0) {
    ?>
	<div class="alert alert-info">
Example #2
0
<?php

$submitted = FALSE;
$lang = 'en';
$app = new Application();

function haserror( $field, $app ) {
	if ( in_array( $field, $app->errors ) ) {
		return ' class="fieldWithErrors"';
	} else {
		return '';
	}
}

if (isset($_POST['submit'])) {
	$app->submit($_POST);
	if ($app->success === TRUE) {
		$submitted = TRUE;
	}
}

include( 'header.php' ); 

if (time() < $open_time) {
	echo $wgLang->message('not-open'); 
} else if (time() > $close_time) {
	echo $wgLang->mesage('deadline-passed');
} else {
?>

<h2><?php echo $wgLang->message('page-header'); ?></h2>