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



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



?>


<div class="well">

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

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


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

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

        				<fieldset>
                            <legend>Edit Hostel Category <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 *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($rows=mysqli_fetch_array($sql_get_state)){
                                            $id = $rows['id'];
                                            //echo'<input type="text" name="id" value="'.$id.'"/>';
                                            echo '<option name="title" value="'.$id.'">'.$rows['title'].'</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:15px;">Title </label>
                              <div class="col-sm-10" style="margin-top:15px;">
                              	<div class="input-group">
                                <input  id="title" class="form-control input-sm" type="text" placeholder="Title"  name="title"
                                value="<?php  echo $row['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:15px;">Description</label>
                              <div class="col-sm-10">
                              	<div class="input-group" style="margin-top:15px;">
                                <input id="description" class="form-control input-sm" type="text" placeholder="Description" name="description"
                                value="<?php  echo $row['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:15px;"> Date Modified </label>
                    <div class="col-sm-10" style="margin-top:15px;">
                    <div class="input-group">
                      <input id="date_modified" class="form-control input-sm" type="text" placeholder="Date Added" name="date_added" required

                       value="<?php echo $row['date_added']; ?>" required></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:15px;"> Modified By </label>
                      <div class="col-sm-10" style="margin-top:15px;">

                      <div class="input-group">
                       <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 $row['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:15px;">Reserved</label>
										<div class="col-sm-10" style="margin-top:15px;">
										<div class="input-group">
											<select id="reserved" class="form-control input-sm" name="gender" required>
													<option value="1" selected>Yes</option>
													<option value="0">No</option>


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

									</div>

									<div class="form-group">

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

                      <div class="input-group">
                       <span class="input-group-addon"> @</span>
                         <input id="bedspace" class="form-control input-sm" type="number" placeholder="Added By" name="by_name" required

                         value="<?php echo $row['bed_space']; ?>"></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 for="username" class="col-sm-2 control-label" style="margin-top:15px;"> Amount </label>
                       <div class="col-sm-10" style="margin-top:15px;">

                       <div class="input-group">
                        <span class="input-group-addon"> @</span>
                          <input id="amount" class="form-control input-sm" type="text" placeholder="Added By" name="by_name" required

                          value="<?php echo $row['hostel_amount']; ?>"></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:15px;">Gender</label>
									 <div class="col-sm-10" style="margin-top:15px;">
									 <div class="input-group">
										 <select id="gender" class="form-control input-sm" name="gender" required>



												<?php  if($_SESSION['g'] == 'M'){ ?>


												 <option value="male" selected>Male</option>
												 <option value="female">Female</option>

												 <?php }else if($_SESSION['g'] == 'F'){?>

												 <option value="male">Male</option>
												 <option value="female" selected>Female</option>
												 <?php }else{?>
												 <option value="male">Male</option>
												 <option value="female">Female</option>
												 <?php }?>


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

								 </div>




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



												<input type="hidden" value="<?php echo $row['id']; ?>" id="cat_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 -->


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