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



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



?>


<div class="well">

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

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


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


              <!-- form cut to the toolbar add faculties -->
              <div class="col-lg-12">

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



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



                            <div class="form-group">
                                  <label for="title" class="col-sm-3 control-label">Title </label>
                                  <div class="col-sm-9">
                                    <div class="input-group">
                                    <input  id="title" class="form-control input-sm" type="text" placeholder="Title"  name="title"
                                    value="<?php if(isset($row['title'])) echo $row['title']; ?>" required></input>
                                    <div class="input-group-addon"> <span class="ast">*</span></div>
                                    </div>

                                  </div>
                               </div>

                                 <div class="form-group">
                                <label for="code" class="col-sm-3 control-label">Course Code</label>
                                  <div class="col-sm-9">
                                    <div class="input-group">
                                    <input  id="code" class="form-control input-sm" type="text" placeholder="Course Code"  name="code"
                                    value="<?php if(isset($row['code'])) echo $row['code']; ?>" required></input>
                                    <div class="input-group-addon"> <span class="ast">*</span></div>
                                    </div>
                                        <span class="help-block"> e.g: Introduction to Computer Science : CSC101. </span>
                                  </div>
                               </div>

                                 <div class="form-group">
                                <label for="unit" class="col-sm-3 control-label">Course Unit</label>
                                  <div class="col-sm-9">
                                    <div class="input-group">
                                    <input  id="unit" class="form-control input-sm" type="text" placeholder="Course Unit"  name="unit"
                                    value="<?php if(isset($row['unit'])) echo $row['unit']; ?>" required></input>
                                    <div class="input-group-addon"> <span class="ast">*</span></div>
                                    </div>

                                  </div>
                               </div>
                              <div class="form-group">
                            <label class="col-sm-3 control-label" for="description1">Course Description</label>
                              <div class="col-sm-9">

                                <textarea  id="" rows="3"  class="rte1 form-control input-sm" name="description1" action="#" >
                                <?php if(isset($row['course_description'])){echo $row['course_description'];} ?>
                                </textarea>
                               <span class="help-block">Description of the coure, i.e course break down</span>
                              </div>
                            </div>






		  					</div><!-- /col-lg- 6 -->
                            <div class="col-lg-6">
                            	  <br /><br />
                               <div class="form-group">
                                <label class="col-sm-3 control-label" for="description">Note / Description</label>
                                  <div class="col-sm-9">

                                    <textarea  id="" rows="3"  class="rte1 form-control input-sm" name="description" action="#" >
                                    <?php if(isset($row['description'])){echo $row['description'];} ?>
                                    </textarea>

                                     <span class="help-block">Notes attached to course incase of change of title or something</span>
                                  </div>


                                </div>


                          	  <div class="form-group">
                              <label class="col-sm-3 control-label" for="programme_type">Programme Type</label>
                              <div class="col-sm-9">

                                <select id="programme_type" class="form-control input-sm" name="programme_type" required>
                                <?php  echo select_programme_type($row['type_id']); ?>
                                </select>
                               <span class="help-block">Diploma / Advance Diploma or Cert</span>
                              </div>

                            </div>



                                 <div class="form-group">
                                <label class="col-sm-3 control-label" for="department">Department</label>
                                <div class="col-sm-9">

                                  <select id="department" class="form-control input-sm" name="department" required>
                                   <option value="0"> ---- Choose Department --- </option>
                                  <?php  echo select_department($row['department_id']); ?>

                                   </select>


                                    </div>

                                </div>



                               <div class="form-group">
                                <label class="col-sm-3 control-label" for="department">Programme</label>
                                <div class="col-sm-9">

                                  <select id="programme" class="form-control input-sm" name="programme" required>
                                   <option value="0"> ---- Choose Programme --- </option>
                                  <?php  echo select_programme($row['programme_id']); ?>

                                   </select>
                                  </div>

                                </div>


                               <div class="form-group">
                                <label class="col-sm-3 control-label" for="level">Level</label>
                                <div class="col-sm-9">

                                  <select  class="form-control input-sm" name="level"  id="level">
                                    <option value="0" >-- Choose Year --</option>
                                    <option value="100" <?php if($row['level'] == '100') echo 'selected'; ?>>Year One</option>
                                    <option value="200" <?php if($row['level'] == '200') echo 'selected'; ?>>Year Two</option>
                                    <option value="300" <?php if($row['level'] == '300') echo 'selected'; ?>>Year Three</option>
                                    <option value="400" <?php if($row['level'] == '400') echo 'selected'; ?>>Year Four</option>
                                    <option value="500" <?php if($row['level'] == '500') echo 'selected'; ?>>Year Five</option>


                                     </select>


                                </div>

                              </div>


                                <div class="form-group">
                                <label class="col-sm-3 control-label" for="gender">Semester</label>
                                <div class="col-sm-9">
                                  <select  class="form-control input-sm" name="semester"  id="semester">
                                    <option value="0"  >-- Choose Semester --</option>
                                    <option value="1" <?php if($row['semester'] == '1') echo 'selected'; ?>>1</option>
                                    <option value="2" <?php if($row['semester'] == '2') echo 'selected'; ?>>2</option>
                                  </select>


                                </div>

                              </div>


                               <div class="form-group">
                                <label class="col-sm-3 control-label" for="gender">Course Type</label>
                                <div class="col-sm-9">
                                  <select  class="form-control input-sm" name="type"  id="type">
                                    <option value="0"  >-- Choose Course Type --</option>
                                    <option value="1" <?php if($row['course_type'] == '1') echo 'selected'; ?>>Core</option>
                                    <option value="2" <?php if($row['course_type'] == '2') echo 'selected'; ?>>Elective</option>
                                  </select>


                                </div>

                              </div>




                               <div class="form-group">
                                <label class="col-sm-3 control-label" for="gender">Status</label>
                                <div class="col-sm-9">

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

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

                                   </select>


                                </div>

                              </div>



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


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




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

                  </form>

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

			  }//end of for loop
	?>


        </div>

      </div>
</div>
<?php

}//end of if post edit project
?>
