<?php  
include ('../includes/connection.php'); 
$module_id=$_GET['id']; 
if (isset($_POST['update'])) {  
$module_id=$_GET['id'];  
$description = mysqli_real_escape_string($conn, $_POST['description']);  
$code = $_POST['code'];

$sql = "UPDATE `module_soes` SET `code`='$code',`description`='$description'  WHERE module_id='$module_id'"; 
  if (mysqli_query($conn, $sql)) {
      ?>
       <script type="text/javascript">
           alert("Module successfully updated");
       </script>
      <?php  
  //header('location:tp_student.php');
          } 
        else {
            ?>
           <script type="text/javascript">
               alert("Failed to update Module Try Again.");
           </script>
          <?php  
        }
   } 


?> 
 <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h5><strong>Update update_couse</strong></h5>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item"><a href="#">Manage User</a></li>
              <li class="breadcrumb-item active">update_couse</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
    <?php 
    $query= mysqli_query($conn,"SELECT *  FROm  module_soes  WHERE module_id='$module_id'")or die(mysqli_error());
    $row = mysqli_fetch_array($query);   
    ?> 
   <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row"> 
          <!-- /.col -->
          <div class="col-md-12">
            <div class="card"> 
              <!-- /.card-header --> 
              <div class="card-body"> 
                <div class="tab-content">
                   <!-- /.tab-pane -->
                  <div class="active tab-pane" id="timeline">
                   <div class="card card-default">
                    <div class="card-header">
                      <h3 class="card-title">Update Module:  <strong><?php echo $row['course_code']?></strong></h3> 
                      <div class="card-tools">
                        <button type="button" class="btn btn-tool" data-card-widget="collapse">
                          <i class="fas fa-minus"></i>
                        </button> 
                      </div>
                    </div>
                    <form action="" method="post" enctype="multipart/form-data"> 
                    <!-- /.card-header -->
                    <div class="card-body"> 
                        <!-- /.col -->
                       <div class="row">
                       <div class="col-sm-12">    
                         <div class="modal-body">
                          <span id="form_message"></span>
                             <div class="form-group">
                               <label>Course<span style="color: red;">*</span></label>
                                <input type="text" name="course_code" id="course_code" disabled class="form-control select2" value="<?php echo $row['course_code']?>">
                              </div>
                              <div class="form-group">
                               <label>Code <span style="color: red;">*</span></label>
                                <input type="text" name="code" id="code" class="form-control select2" value="<?php echo $row['code']?>">
                              </div>
                              <div class="form-group">
                                 <label>Course Description <span style="color: red;">*</span></label> 
                                      <textarea id="summernote" name="description" class="form-control select2">
                                       <?php echo $row['description']?>
                                      </textarea> 
                                </div> 
                            </div>
                          </div> 
                         </div>   
                         <div class="modal-footer">  
                          <a class="btn btn-secondary" href="admin.php?page=course"><< Back </a>
                          <button type="submit" class="btn btn-primary" name="update">UPDATE </button>
                      </div>
                      <!-- /.row -->
                    </div> 
                  </form>
                  </div>
                   
                    </div>
                    
                     
                     
                  </div>
                  
                  <!-- /.tab-pane -->
                </div>
                <!-- /.tab-content -->
              </div><!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div> 
   <a id="back-to-top" href="#" class="btn btn-primary back-to-top" role="button" aria-label="Scroll to top">
      <i class="fas fa-chevron-up"></i>
    </a>
  <div id="preloader"></div>
  
<script src="../stp_con/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../stp_con/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables  & Plugins -->
<script src="../stp_con/datatables/jquery.dataTables.min.js"></script>
<script src="../stp_con/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../stp_con/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../stp_con/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="../stp_con/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="../stp_con/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="../stp_con/jszip/jszip.min.js"></script> 
<script src="../stp_con/pdfmake/pdfmake.min.js"></script> 
<script src="../stp_con/summernote/summernote-bs4.min.js"></script>  

 <script>
  $(function () {
    // Summernote
    $('#summernote').summernote()

    // CodeMirror
    CodeMirror.fromTextArea(document.getElementById("codeMirrorDemo"), {
      mode: "htmlmixed",
      theme: "monokai"
    });
  })
</script>
 
