<?php 
require_once("header.php");
require_once("session_check.php");

//CODE FOR UPDATE REJECT STATUS
if(isset($_POST['save']))
{
	$sql_update = "UPDATE `usertable_stu` SET `status` = 'rejected',`rej_comment` = '".addslashes($_POST['rej_comment'])."',`app_rej_by` = '".$_SESSION['LOGIN_NAME']."' WHERE `id` = '".$_POST['hid_id']."'";
	$exe_update = mysqli_query($connection,$sql_update);
	
	$_SESSION['change_succ_msg'] = 'Student volunteer has been rejected.';
	header("location: student_list.php");
	exit;
}

//FETCH DATA FROM DATABASE
$fetch_record = mysqli_fetch_array(mysqli_query($connection,"SELECT * FROM `usertable_stu` WHERE `id` = '".$_GET['id']."'"));
?>

<script language="javascript" type="text/javascript">
function frm_validation()
{
	if(document.getElementById('rej_comment').value == '')
	{
		alert("Please enter comment");
		document.getElementById('rej_comment').focus();
		return false;
	}
}
</script>

<?php require_once("left_panel.php");?>
<div class="content">
	<div class="workplace">
		<div class="row-fluid">
			<div class="span12">
				<form action="" method="post" enctype="multipart/form-data" onsubmit="return frm_validation();">
				    <input type="hidden" name="hid_id" id="hid_id" value="<?php echo $_GET['id'];?>">
				<div class="head clearfix">
					<div class="isw-documents"></div>
					<h1>Rejection Cause For <?php echo stripslashes($fetch_record['name']);?></h1>
				</div>
				<div class="block-fluid">
					<div class="row-form clearfix">
						<div class="span3">Comment <font color="#FF0000">*</font></div>
						<div class="span9"><textarea name="rej_comment" id="rej_comment"></textarea></div>
					</div>
					<div class="row-form clearfix">
						<div class="span3">&nbsp;</div>
						<div class="span9"><button class="btn" type="submit" name="save">Submit</button>
						<button class="btn" type="button" name="back" onclick="window.location.href='student_list.php'">Back To Student Volunteers List</button>
						</div>
					</div>
				</div>
				</form>
			</div>
		</div>
	</div>
</div>   

<?php require_once("footer.php"); ?>