
<?php
//this page brings out a static form editing a user



if($_POST['act'] == 'Revoke_allocation')
{
	  $id_array = $_POST['user']; // return array
	  $id_count = count($_POST['user']); // count array



?>


<div class="well">

      <ul class="tabs">
        <li><a href="#view1" >Hostel Allocation Details</a></li>
      </ul>
      <div class="tabcontents">
        <div id="view1"  class="row">


					<?php

			for($i=0; $i < $id_count; $i++)
			{
			  $id = $id_array[$i];
			  $q = "SELECT CONCAT_WS(' ',first_name,other_names) AS name, number,phone_number,
							students_nce.level AS level, students_nce.id AS id, students_nce.gender AS gender,
							programmes.title as programme, hostel_campuses.title AS campus,
							hostel_blocks.title AS block, hostel_rooms.title AS room
							FROM students_nce, programmes,hostel_campuses,hostel_blocks,
							hostel_rooms,hostel_allocation WHERE students_nce.programme_id=programmes.id
							AND students_nce.id = '$id' AND hostel_allocation.student_id=students_nce.id AND
							hostel_allocation.room_id=hostel_rooms.id AND
							hostel_allocation.campus_id=hostel_campuses.id AND
							hostel_allocation.block_id=hostel_blocks.id";
			  $r = mysqli_query($dbc, $q) or die(mysqli_error($dbc));

			  if(!$r) { die(mysqli_error()); }


				  if(mysqli_num_rows($r) > 0)
				  {//begin if result exist
					  while($row = mysqli_fetch_array($r, MYSQLI_ASSOC))
					  {//begin while


							echo '


							<div class="panel panel-success" >
								<div class="panel-heading">

									<h3 class="panel-title" style="font-size:30px;">'.strtoupper($row['campus']).'---'.strtoupper($row['block']).'---'.strtoupper($row['room']).'---'.strtoupper($row['name']).'---'.strtoupper($row['number']).'</h3>
								</div>
								<div class="panel-body">
								<br/><br/><br/>
								<label class="alert alert-danger" style="width:500px; font-size:25px; font-weight:bold;">Instructions to Admins</label>
								<p style="font-weight:bold">Please make sure you really want to revoke this student allocation and state the reason below</p>
								<textarea class="form-control" id="reason"></textarea><br>
								<center><button class="btn btn-success" onclick="delete_allo()" style="width:200px; height:50px;">Revoke Student</button></center>

								';





}
}
?>

<script type="text/javascript">
// delete hostel_site
function delete_allo()
{
	var reason = $("#reason").val();
	if(reason==''){
		$("#reason").focus();
	}else{
		if(confirm("Do you  really want to revoke this allocation?"))
		{
			$.post("php/revoke.php",{reason:reason},
			function(response,status)
			{
				alert(response);
				$('#q').html(response);
        //location.reload();

			});
		}
		return false;
	}


}


</script>
		<div class="col-lg-12">

				<div class="col-lg-10">











		<?php
					  }//end of if
					  }//end of while

				  //end of for loop
		?>


	        </div>  <!-- #view1 -->

	      </div> <!-- /tab-content -->
	</div> <!-- /well-->
	<?php

	//end of if post edit user
	?>
