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



if($_POST['act'] == 'edit_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.level AS level, students.id AS id, students.gender AS gender, programmes.title as programme FROM students, programmes WHERE
	students.programme_id=programmes.id AND students.id = '$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
							$name = $row['name'];
							$matric = $row['number'];
							$phone_number = $row['phone_number'];
							$level = $row['level'];
							$programme = $row['programme'];
							$gender = $row['gender'];
							$student_id = $row['id'];
							if($gender=='F')
							{
								$gender ='female';
							}else {
								$gender='male';
							}



}
}
?>


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

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



						<fieldset>
												<legend>Edit Hostel Allocation <span class="ast">*</span> indicate required fields </legend>



							<!-- form cut to the toolbar add user-->
									<input type="hidden" name="MAX_FILE_SIZE" value="MAX_FILE_SIZE" />



										<div class="form-group" style="margin-top:10px;">
													<label for="first_name" class="col-sm-2 control-label">Student Name </label>
													<div class="col-sm-10">
														<div class="input-group">
														<input  id="name" class="form-control input-sm" type="text" placeholder="Title"  name="title"
														value="<?php  echo $name; ?>" disabled></input>
														<div class="input-group-addon"> <span class="ast">*</span></div>
														</div>

													</div>
											 </div>


												<div class="form-group" >
													<label for="other_names" class="col-sm-2 control-label" style="margin-top:10px;">Matric No</label>
													<div class="col-sm-10">
														<div class="input-group" style="margin-top:10px;">
														<input id="matric" class="form-control input-sm" type="text" placeholder="Description" name="description"
														value="<?php  echo $matric; ?>" disabled></input>
															<div class="input-group-addon"> <span class="ast">*</span></div>
														 </div>
													</div>
											 </div>




						 <div class="form-group">
								<label for="email" class="col-sm-2 control-label" style="margin-top:10px;"> Phone Number </label>
								<div class="col-sm-10">
								<div class="input-group" style="margin-top:10px;">
									<input id="phone_no" class="form-control input-sm" type="text" placeholder="Date Added" name="date_added" required

									 value="<?php echo $phone_number; ?>" disabled></input>

									 <div class="input-group-addon"> <span class="ast">*</span></div>
									 <span id="email_msg_box" style="display:none"></span>
								 </div>

								</div>
						 </div>

							<div class="form-group">

									<label for="username" class="col-sm-2 control-label" style="margin-top:10px;"> Programme </label>
									<div class="col-sm-10">

									<div class="input-group" style="margin-top:10px;">

										 <input id="programme" class="form-control input-sm" type="text" placeholder="Added By" name="by_name" required

										 value="<?php echo $programme; ?>" disabled></input>

										 <div class="input-group-addon"> <span class="ast">*</span></div> <span id="user_msg_box" style="display:none"></span>

										</div>
									</div>
							 </div>



											<div class="form-group">
											<label class="col-sm-2 control-label" for="gender" style="margin-top:10px;">Gender</label>
											<div class="col-sm-10" style="margin-top:10px;">

												<input id="programme" class="form-control input-sm" type="text" placeholder="Added By" name="by_name" required

												value="<?php echo strtoupper($gender); ?>" disabled></input>



											</div>

										</div>

										<div class="form-group">
													<label for="title" class="col-sm-2 control-label" style="margin-top:10px;">Select Campus </label>
													<div class="col-sm-10">
														<div class="input-group" style="margin-top:10px;">
															<input type="hidden" id="gender" value="<?php echo $gender;?>">
															<input type="hidden" id="student_id" value="<?php echo $student_id;?>">
															<select id="selectBox" onchange="changeFunc();"  class="form-control">
																<option></option>
															<?php

																		$sql_get_state=mysqli_query($dbc, "SELECT CONCAT_WS(' ', title, description) as name, id FROM hostel_sites WHERE status='1'") or die(mysqli_error($dbc));
																		if($sql_get_state){
																			$sql_get_state_row=mysqli_num_rows($sql_get_state);
																			if($sql_get_state_row > 0){
																				while($row=mysqli_fetch_array($sql_get_state)){
																					$id = $row['id'];
																					//echo'<input type="text" name="id" value="'.$id.'"/>';
																					echo '<option name="title"  value="'.$row['id'].'">'.$row['name'].'</option>';
																				}
																			}
																		}


																?>
														</select>
														<div class="input-group-addon"> <span class="ast">*</span></div>
														</div>

													</div>
											 </div>


											 <div id="cat"></div>
											 <div id="room"></div>
											 <div id="action"></div>
											 
											 <div id="msg"></div>








											<div id="t" style="font-size: 20px; text-align: center;margin-top:30px; color:red;"></div>

										<input type="hidden" value="<?php echo $row['id']; ?>" id="site_id" />

										<input type="hidden" value="update_" name="act" />
										<input type="hidden" value="TRUE" name="update_user" /><!-- pass value for editing -->
										<input type="hidden" value="<?php echo $row['user_id']; ?>" name="user" id='user' /><!-- pass id value incase he didnt fill well den bring bk for editing -->
										<input type="hidden" value="TRUE" name="upload" /> <!-- for image upload -->


							</div><!-- /col-lg- 6 -->
							</fieldset>




				</div><!-- / col-lg -12 -->


		<?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
	?>
