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



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



?>


<div class="well">

      <ul class="tabs">
        <li><a href="#view1" >Hostel Room 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 * FROM hostel_rooms WHERE id = '$id'";
		  $r = mysqli_query($dbc, $q);

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


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


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

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

        				<fieldset>
                            <legend>Edit Room Site <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">
														<label for="title" class="col-sm-2 control-label">Select Campus </label>
														<div class="col-sm-10">
															<div class="input-group">
															<select class="form-control" id="campus">
																<option></option>
																<?php

																			$sql_get_state=mysqli_query($dbc, "SELECT CONCAT_WS(' ', title, description) as name, id FROM hostel_campuses 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 class="form-group">
															 <label for="title" class="col-sm-2 control-label" style="margin-top:10px;">Select Category </label>
															 <div class="col-sm-10">
																<div class="input-group" style="margin-top:10px;">
																 <select class="form-control" id="category">
																	 <option></option>
																	 <?php

																				 $sql_get_state=mysqli_query($dbc, "SELECT CONCAT_WS(' ', title, description) as name, id FROM hostel_blocks ") 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 class="form-group" >
                              <label for="first_name" class="col-sm-2 control-label" style="margin-top:10px;">Title </label>
                              <div class="col-sm-10">
                              	<div class="input-group" style="margin-top:10px;">
                                <input  id="title" class="form-control input-sm" type="text" placeholder="Title"  name="title"
                                value="<?php  echo $rows['title']; ?>" required></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;">Description</label>
                              <div class="col-sm-10">
                              	<div class="input-group" style="margin-top:10px;">
                                <input id="description" class="form-control input-sm" type="text" placeholder="Description" name="description"
                                value="<?php  echo $rows['description']; ?>" required></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;"> Date Modified </label>
                    <div class="col-sm-10">
                    <div class="input-group" style="margin-top:10px;">
                      <input id="date_modified" class="form-control input-sm" type="text" placeholder="Date Added" name="date_added" required

                       value="<?php echo $rows['date_added']; ?>"></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;"> Modified By </label>
                      <div class="col-sm-10">

                      <div class="input-group" style="margin-top:10px;">
                       <span class="input-group-addon"> @</span>
                         <input id="modified_by" class="form-control input-sm" type="text" placeholder="Added By" name="by_name" required

                         value="<?php echo $rows['added_by']; ?>"></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;">Reserved</label>
									 <div class="col-sm-10" style="margin-top:10px;">

									 	<select id="reserved" class="form-control input-sm" name="reserved" required>

									 <option></option>
									 <option value="1">Yes</option>
									 <option value="0">No</option>

									 	 </select>


									 </div>

									 </div>

									 <div class="form-group">

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

										<div class="input-group" style="margin-top:10px;">
										 <span class="input-group-addon"> @</span>
											 <input id="bedspace" class="form-control input-sm" type="number" placeholder="Bedspace" name="bedspace" required

											 value="<?php echo $rows['bedspace']; ?>"></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;">Status</label>
                          <div class="col-sm-10" style="margin-top:10px;">

                            <select id="status" class="form-control input-sm" name="status" required>

                            <?php  echo select_status($_SESSION['status']); ?>

                             </select>


                          </div>

                        </div>




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

                        <input type="hidden" value="update_user" 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 -->



												<br>
                        <div id="q" style="font-size: 20px; text-align: center;margin-top:30px; color:red;"></div>
                  </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
?>
