<?php  
include ('../includes/connection.php');  
$id=$_GET['id'];  
if (isset($_POST['update'])){
$id=$_GET['id'];
$class_id = $_POST['class_id']; 
$program = $_POST['program'];
$code = $_POST['code']; 
$credit = $_POST['credit']; 
$department = $_POST['department']; 
$description = $_POST['description']; 

$query=mysqli_query($conn,"UPDATE `subject` SET `class_id`='$class_id',`program`='$program',`code`='$code',`credit`='$credit',`department`='$department',`description`='$description' WHERE id='$id'");
  
  if($query){ 
         ?>
         <script type="text/javascript">
             alert("Program Success Fully updated");
         </script>
        <?php  
      }  
      else{
        ?>  
        <script type="text/javascript">
         alert("Sorry Program Failed to update 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 Program</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="#">Program MANAGEMENT</a></li> 
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
    <?php 
    $query= mysqli_query($conn,"SELECT *  FROm subject WHERE id='$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"> 
              <!-- /.card-header --> 
              <div class="card"> 
                <div class="tab-content"> 
                   <div class="card card-default"> 
                    <form method="post" action=""> 
                        <div class="modal-header">
                            <h4 class="modal-title" id="modal_title">Update Program</h4> 
                        </div>
                        <div class="modal-body">
                          <span id="form_message"></span>
                          <div class="row">
                                      <div class="col-sm-4"> 
                                      <div class="form-group">
                                        <label>Code</label>
                                        <input type="text" name="code" id="code" value="<?php echo $row['code']; ?>" class="form-control" required data-parsley-pattern="/^[a-zA-Z0-9 \s]+$/" data-parsley-trigger="keyup" />
                                       </div>
                                     </div>
                                      <div class="col-sm-4"> 
                                      <div class="form-group">
                                        <label>Program Name</label>
                                        <input type="text" name="program" id="program" value="<?php echo $row['program']; ?>" class="form-control" required data-parsley-pattern="/^[a-zA-Z0-9 \s]+$/" data-parsley-trigger="keyup" />
                                       </div>
                                     </div>
                                     <div class="col-sm-4">
                                      <div class="form-group">
                                        <label>Depertment<span style="color: red;">*</span></label>
                                        <div class="select2-purple"> 
                                          <select class="form-control select2" name="department" data-dropdown-css-class="Select a Program" style="width: 100%;">  
                                            <option value="">Select Depertment</option>
                                          <option value="">Select Program</option>
                                            <option value="Accountancy">ACCOUNTANCY</option>
                                            <option value="Business Administration">BUSINESS ADMINISTRATION</option>
                                            <option value="Information and communication Technology">INFORMATION AND COMMUNICATION TECHNOLOGY</option> 
                                            <option value="Education Management and Administration">EDUCATION MANAGEMENT AND ADMINISTRATION</option>
                                        </select>
                                        </div> 
                                      </div>
                                    </div>
                                    </div>
                                    <div class="row">
                                      <div class="col-sm-4"> 
                                      <div class="form-group">
                                        <label>Credit</label>
                                        <input type="text" name="credit" id="credit" value="<?php echo $row['credit']; ?>" class="form-control" required data-parsley-pattern="/^[a-zA-Z0-9 \s]+$/" data-parsley-trigger="keyup" />
                                       </div>
                                     </div>
                                     <div class="col-sm-4"> 
                                      <div class="form-group">
                                        <label>Class Name</label>
                                        <?php  
                                        $query = "SELECT * FROM class_srms WHERE class_status='Enable' ORDER BY class_name ASC"; 
                                         $result = $conn->query($query);      
                                         ?> 
                                        <select name="class_id" id="class_id" class="form-control" required>
                                            <option value=""><?php echo $row['class_name']; ?></option>
                                            <?php 
                                            if($result->num_rows > 0){ 
                                                while($row = $result->fetch_assoc()){  
                                                    echo '<option value="'.$row['class_id'].'">'.$row['class_name'].'</option>'; 
                                                } 
                                            }else{ 
                                                echo '<option value="">Class not available</option>'; 
                                            } 
                                          ?>
                                        </select>
                                    </div>
                                  </div>
                                      <div class="col-sm-4"> 
                                       <div class="form-group">
                                          <label>Discription <span style="color: red;">*</span></label>
                                          <div class="select2-purple"> 
                                            <select class="form-control select2" name="description" data-dropdown-css-class="Select a Program" style="width: 100%;" required>  
                                            <option><?php echo $row['description']; ?></option>
                                            <option value="Core">Core</option>
                                            <option value="Fundamental">Fundamental</option>
                                          </select>
                                          </div> 
                                        </div>
                                     </div>
                                    </div> 
                                 </div>
                            <div class="modal-footer"> 
                              <a class="btn btn-info" href="admin.php?page=program"><< Back </a>
                            <input type="submit" name="update" class="btn btn-secondary" value="Update" /> 
                        </div> 
                        </form>
                    </div> 
                  
                  <!-- /.tab-pane -->
                </div>
                <!-- /.tab-content -->
              </div><!-- /.card-body --> 
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

   
<!-- ./wrapper -->
<script src="../stp_con/jquery.min.js"></script>
<script src="../stp_con/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../stp_con/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Select2 -->
<script src="../stp_con/select2/js/select2.full.min.js"></script>
<!-- Bootstrap4 Duallistbox -->
<script src="../stp_con/bootstrap4-duallistbox/jquery.bootstrap-duallistbox.min.js"></script>
<!-- InputMask -->
<script src="../stp_con/moment/moment.min.js"></script>
<script src="stp_con/inputmask/jquery.inputmask.min.js"></script>
<!-- date-range-picker -->
<script src="../stp_con/daterangepicker/daterangepicker.js"></script>
<!-- bootstrap color picker -->
<script src="../stp_con/bootstrap-colorpicker/js/bootstrap-colorpicker.min.js"></script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="../stp_con/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- BS-Stepper -->
<script src="../stp_con/bs-stepper/js/bs-stepper.min.js"></script>
<!-- dropzonejs -->
<script src="../stp_con/dropzone/min/dropzone.min.js"></script>
<!-- AdminLTE App -->
<script src="../assets/js/adminlte.min.js"></script>

 
 
