<?php 
 include ('../includes/connection.php'); 
 // code for block exam    
include ('sms.php');
if (isset($_POST['ADD'])) {  
 
$class_id = $_POST['class_id']; 
$student_name = mysqli_real_escape_string($conn, $_POST['student_name']);   
$student_gender = $_POST['student_gender']; 
$student_added_by = $_POST['student_added_by'];    
$p_mobile =$_POST['p_mobile']; 
$student_dob =$_POST['student_dob'];
$student_profile =$_POST['student_profile']; 
$year_of_study =$_POST['year_of_study'];

$date=date("d/m/Y");
$year=date("Y");
$hr=date("H");
$hr+=2;
if ($hr>23) 
{
    $hr=$hr-24;
}
if ($hr<10) 
{
    $hr="0".$hr;
}
$time=$hr.":".date("i:s"); 
$cat="SARMS";
$place=$cat."/ST/";  
$sql1="SELECT * FROM student_srms WHERE student_roll_no LIKE '%$place%';";
$result=mysqli_query($conn,$sql1);
$rCheck=mysqli_num_rows($result);
$num=$rCheck;

$num++;
if($num<10)
{
    $zero="0000";
}
elseif ($num>=10 && $num<100) {
    $zero="000";
}
elseif ($num>=100 && $num<1000) {
    $zero="00";
}
elseif ($num>=1000 && $num<10000) {
    $zero="0";
} 
else{
    $zero="";
}


$student_roll_no=$cat."/ST/".$year_of_study."/".$zero.$num; 

$class4 = mysqli_query($conn,"SELECT *  FROM class_srms WHERE class_id='$class_id'");
$classname = mysqli_fetch_array($class4);
$class_name=$classname['student_roll_no'];

$student= mysqli_query($conn,"SELECT student_roll_no  FROM student_srms WHERE student_roll_no='$student_roll_no'")or die(mysqli_error());
$row = mysqli_fetch_array($student);
$check=$row['student_roll_no'];
if ($check!=$student_roll_no) {  
$sql = "INSERT INTO `student_srms`(`class_id`, `student_name`,`student_profile`, `student_roll_no`,  `p_mobile` , `student_gender`,`student_dob`, `year_of_study`,  `student_added_by`)VALUES('$class_id','$student_name','$student_profile','$student_roll_no','$p_mobile' ,'$student_gender','$student_dob','$year_of_study', '$student_added_by')";  
 if (mysqli_query($conn, $sql)) { 
        // $s_mobile = substr($p_mobile, 1);
        // $s_mobile = "255$s_mobile";
        // $message = $sms_text;
        // send_message($s_mobile, "Ndugu mzazi wa $student_name, Unajulishwa kuhudhuria kikao cha wazazi wa kidato cha tano kitakacho fanyika siku ya jumamosi tar 02/08/2025 saa 3:00 asubuhi,mahali ni shuleni tafadhali fika bila kukosa ni muhimu sana.");
        // send_message($s_mobile, "Ndugu mzazi wa $student_name, Hongera Mwanao amefanikiwa kusajiliwa $class_name Hivyo utakuwa ukipokea Taarifa ya matokeo yake kupitia SMS hii ahsante");
    ?>
     <script type="text/javascript">
         alert("Student successfully Added");
     </script>
    <?php  
//header('location:tp_student.php');
        } 
      else {
          ?>
               <script type="text/javascript">
                   alert("Failed to Add Student Try Again.");
               </script>
              <?php  
            }
          }else{
      ?>
         <script type="text/javascript">
             alert("Sorry Student Already added");
         </script>
    <?php 
  }
} 

if (isset($_POST['sms_group'])){ 

$class_id = $_POST['class_id']; 

$sms1 = mysqli_query($conn,"SELECT * FROm student_srms WHERE class_id='$class_id'");
  
$message = $_POST['comment'];   
 
while ($row =mysqli_fetch_array($sms1)) {
    $s1_mobile=$row['p_mobile'];
    $s2_mobile = substr($s1_mobile, 1);
    $s_mobile = "255$s2_mobile"; 
    send_message($s_mobile, $message); 
   }  
          
} 
if (isset($_POST['sms'])){ 
$student_roll_no = $_POST['student_roll_no']; 

$name1 = mysqli_query($conn,"SELECT *  FROm student_srms WHERE student_roll_no='$student_roll_no'");
$name2 = mysqli_fetch_array($name1);

$student_name =$name2['student_name']; 
$s_mobile = $_POST['s_mobile'];
$sms_text = $_POST['comment'];  

$sms_2=mysqli_query($conn,"INSERT INTO `sms`(`student_roll_no`, `student_name`, `s_mobile`, `sms` ) VALUES ('$student_roll_no','$student_name','$s_mobile','$sms_text')");
  
  if($sms_2){ 
        $s_mobile = $s_mobile; 
        $s_mobile = substr($s_mobile, 1);
        $s_mobile = "255$s_mobile";
        $message = $sms_text;
        send_message($s_mobile, $message);
         ?>
         <script type="text/javascript">
             alert("sms Success Fully Sent");
         </script>
        <?php  
      }  
      else{
        ?>  
        <script type="text/javascript">
         alert("Sorry sms Failed to sent Try Again");
        </script>
        <?php
    }
  } 

if (isset($_POST['group'])){ 
$student_roll_no = $_POST['student_roll_no']; 
$class_id = $_POST['class_id']; 

$name4 = mysqli_query($conn,"SELECT *  FROm student_srms WHERE class_id='$class_id'");
$name_group = mysqli_fetch_array($name4);

$student_name =$name_group['student_name']; 
$s_mobile = $name_group['s_mobile'];
$sms_text = $_POST['comment'];  

$sms_2=mysqli_query($conn,"INSERT INTO `sms`(`student_roll_no`, `student_name`, `s_mobile`, `sms` ) VALUES ('Group','Group','All student','$sms_text')");
  
  if($sms_2){ 
        $s_mobile = $s_mobile; 
        $s_mobile = substr($s_mobile, 1);
        $s_mobile = "255$s_mobile";
        $message = $sms_text;
        send_message($s_mobile, $message);
         ?>
         <script type="text/javascript">
             alert("sms Success Fully Sent");
         </script>
        <?php  
      }  
      else{
        ?>  
        <script type="text/javascript">
         alert("Sorry sms Failed to sent Try Again");
        </script>
        <?php
    }
  } 

if(isset($_GET['Id_3']))
{
$id=$_GET['Id_3'];
$status='Disable'; 
$sql =mysqli_query($conn,"update student_srms set student_status='$status' WHERE student_id='$id'");
header('location:admin.php?page=student"');
}

if(isset($_GET['del']))
{
$id= $_GET['del']; 
$sql =mysqli_query($conn,"DELETE FROM `student_srms` WHERE student_id = $id");
header('location:admin.php?page=student"');
}  
if(isset($_GET['del_s']))
{
$id= $_GET['del_s']; 
$sql =mysqli_query($conn,"DELETE FROM `sms` WHERE sms_id = $id");
header('location:admin.php?page=student"');
}  

//code for active students
if(isset($_GET['Id_2']))
{
$id=$_GET['Id_2'];
$status='Enable'; 
$sql =mysqli_query($conn,"update student_srms set student_status='$status' WHERE student_id='$id'");
header('location:admin.php?page=student"');
}  


if (isset($_POST['s_update'])) {   
$class_id = $_POST['class_id'];  
$year_of_study = $_POST['year_of_study'];  
$edit_class_id = $_POST['edit_class_id']; 

$s_up = mysqli_query($conn,"SELECT *  FROm  student_srms WHERE class_id='$edit_class_id'"); 
$row_update = mysqli_fetch_array($s_up);
$e_class_id=$row_update['class_id'];

$sql = "UPDATE `student_srms` SET `class_id`='$class_id',`year_of_study`='$year_of_study' WHERE class_id='$e_class_id'"; 
  if (mysqli_query($conn, $sql)) {
      ?>
       <script type="text/javascript">
           alert("Level successfully Change");
       </script>
      <?php  
  //header('location:tp_student.php');
          } 
        else {
            ?>
           <script type="text/javascript">
               alert("Failed to update Level Try Again.");
           </script>
          <?php  
        }
   } 

?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/jpg" href="../assets/img/mzumbe1.jpg">
  <title>SARMS | SIKIRARI ACADEMIC RESURT MANAGEMENT SYSTEM</title> 
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../stp_con/fontawesome-free/css/all.min.css">
  <!-- daterange picker -->
  <link rel="stylesheet" href="../stp_con/daterangepicker/daterangepicker.css">
  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="../stp_con/icheck-bootstrap/icheck-bootstrap.min.css">
  <!-- Bootstrap Color Picker -->
  <link rel="stylesheet" href="../stp_con/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css">
  <!-- Tempusdominus Bootstrap 4 -->
  <link rel="stylesheet" href="../stp_con/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
  <!-- Select2 -->
  <link rel="stylesheet" href="../stp_con/select2/css/select2.min.css">
  <link rel="stylesheet" href="stp_con/select2-bootstrap4-theme/select2-bootstrap4.min.css">
  <!-- Bootstrap4 Duallistbox -->
  <link rel="stylesheet" href="../stp_con/bootstrap4-duallistbox/bootstrap-duallistbox.min.css">
  <!-- BS Stepper -->
  <link rel="stylesheet" href="../stp_con/bs-stepper/css/bs-stepper.min.css">
  <!-- dropzonejs -->
  <link rel="stylesheet" href="../stp_con/dropzone/min/dropzone.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="../assets/css/adminlte.min.css">
   <link rel="stylesheet" type="text/css" href="../stp_con/parsley/parsley.css"/>
</head>
<body class="hold-transition sidebar-mini layout-fixed top-nav">
<!-- Site wrapper -->
<div class="wrapper"> 
  <!-- Content Wrapper. Contains page content -->
  <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">
            <a><strong>Student information</strong></a>
          </div> 
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="admin.php?page=dashboad">Home</a></li> 
              <li class="breadcrumb-item active">Students information</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section> 
   <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
        <div class="row"> 
          <!-- /.col -->
          <div class="col-md-12">
            <div class="card">
              <div class="card-header p-2">
                <ul class="nav nav-pills ">
                  <li class="nav-item"><a class="nav-link active" href="#student" data-toggle="tab"><i class="fas fa-th-list"></i> Student List</a></li> 
                  <li class="nav-item"><a class="nav-link" href="#graduator" data-toggle="tab"><i class="nav-icon fas fa-graduation-cap"></i> Graduators</a></li> 
                  <li class="nav-item"><a class="nav-link" href="#normal" data-toggle="tab"><i class="fas fa-sms mr-1"></i> Normal Text</a></li>  
                  <!-- <li class="nav-item"><a  class="nav-link" href="#trans" data-toggle="tab" ><i class="fas fa-list mr-1"></i>Transcript</a></li>  -->
                </ul>
              </div>
              <!-- /.card-header --> 
              <div class="card-body"> 
              <div class="tab-content">
              <!-- /.tab-pane -->
              <div class="active tab-pane" id="student">
              <div class="container-fluid">
                <div class="row">
                  <div class="col-sm-12">  
                    <div class="card"> 
                 <!-- /.card-header -->
                      <div class="card-header">
                      <h3 class="card-title">Student List</h3>
                      <div class="float-right mb-2"> 
                        <a data-toggle="modal" href="#add" class="btn btn-success btn-xs float-right ml-2" >
                            <i class="fa fa-edit"></i> Add Student
                        </a>
                         <a data-toggle="modal" href="#exel" class="btn btn-primary btn-xs float-right ml-2" >
                            <i class="fa fa-upload"></i>   Add CSV File
                        </a>
                         <a data-toggle="modal" href="#update" class="btn btn-info btn-xs float-right ml-2" >
                            <i class="fa fa-edit"></i> Update Student
                        </a>
                        </div>
                    </div>
                  <div class="card-body">
                <div class="table-responsive">
                    <table id="example1" class="table table-striped display table-bordered" >
                      <thead>
                        <tr>
                            <th>#</th>
                            <th>Image</th>
                            <th>Reg No</th>
                            <th>Student Name</th>
                            <th>Class Name</th> 
                            <th>Parent Mobile</th>
                            <th>Gender</th>
                            <th>Date of Adm</th>
                            <th>Registered By</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                        </thead>
                        <tbody>
                          <?php 
                            $i = 1;
                            $selected = mysqli_query($conn,"SELECT *  FROm  student_srms,class_srms WHERE student_srms.class_id=class_srms.class_id AND class_srms.class_name!='GRADUATOR'");
                             while($row = mysqli_fetch_array($selected)){ 
                              $MD5=$row['student_roll_no'];
                        
                            ?> 
                        <tr>
                          <td class="text-center"><?php echo $i++ ?></td>
                          <td> 
                          <img src="../<?php echo $row['student_profile']; ?>" class="img-thumbnail" width="75" height="75" /></td>
                          <td><?php echo $MD5; ?></td>
                          <td><?php echo $row['student_name']; ?></td>
                          <td><?php echo $row['class_name']; ?></td> 
                           <td><?php echo $row['p_mobile']; ?></td>
                          <td><?php echo $row['student_gender']; ?></td> 
                          <td><?php echo $row['date']; ?></td> 
                          <td><?php echo $row['student_added_by']; ?></td> 
                          <td>
                            <?php
                              if($row["student_status"] == 'Enable')
                                 {?>
                                <a href="admin.php?page=student&Id_3=<?php echo $row['student_id']; ?>" onclick="return confirm('Are you sure you want to block a Student?');" >  <button class="btn btn-secondary"> Enable</button>
                                <?php } else if($row["student_status"]=='Disable'){?>
                                  <a href="admin.php?page=student&Id_2=<?php echo $row['student_id']; ?>" onclick="return confirm('Are you sure you want to active a Student?');"><button class="btn btn-danger"> Disable</button> 
                                 <?php } ?>

                             </td>
                          <td>
                             <div class="btn-group">
                            <a data-id='<?php echo $row['id'] ?>' href="admin.php?page=update_student&id=<?php echo $row['student_id']; ?>" class="btn btn-primary btn-flat manage_class">
                              <i class="fas fa-edit"></i>
                            </a>
                             <a href="admin.php?page=student&del=<?php echo $row['student_id']; ?>" onclick="return confirm('Are you sure you want to delete?');" class="btn btn-danger btn-flat delete_student">
                              <i class="fas fa-trash"></i>
                            </a>   
                        </div> </td>
                      </tr> 
                      <?php }?> 
                        </tbody>
                        <tfoot>
                        <tr>
                            <th>#</th>
                            <th>Image</th>
                            <th>Reg No</th>
                            <th>Student Name</th>
                            <th>Class Name</th> 
                            <th>Parent Mobile</th>
                            <th>Gender</th>
                            <th>Date of Adm</th>
                            <th>Registered By</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                      </tfoot>
                    </table> 
                 </div>
               </div>
              </div> <!-- end card body-->
            </div> <!-- end card --> 
            </div>
            <!-- /.card -->
          </div>
          </div>
          <div class="tab-pane" id="graduator">
              <div class="container-fluid">
                <div class="row">
                  <div class="col-sm-12">  
                    <div class="card"> 
                 <!-- /.card-header -->
                      <div class="card-header">
                      <h3 class="card-title">Student List</h3> 
                    </div>
                  <div class="card-body">
                <div class="table-responsive">
                    <table id="example2" class="table table-striped display table-bordered" >
                      <thead>
                        <tr>
                            <th>#</th>
                            <th>Image</th>
                            <th>Reg No</th>
                            <th>Student Name</th>
                            <th>Class Name</th> 
                            <th>Parent Mobile</th>
                            <th>Gender</th>
                            <th>Year</th> 
                            <th>Status</th> 
                        </tr>
                        </thead>
                        <tbody>
                          <?php 
                            $i = 1;
                            $selected = mysqli_query($conn,"SELECT *  FROm  student_srms,class_srms WHERE student_srms.class_id=class_srms.class_id AND class_srms.class_name='GRADUATOR'");
                             while($row = mysqli_fetch_array($selected)){ 
                              $MD5=$row['student_roll_no'];
                        
                            ?> 
                        <tr>
                          <td class="text-center"><?php echo $i++ ?></td>
                          <td> 
                          <img src="../<?php echo $row['student_profile']; ?>" class="img-thumbnail" width="75" height="75" /></td>
                          <td><?php echo $MD5; ?></td>
                          <td><?php echo $row['student_name']; ?></td>
                          <td><?php echo $row['class_name']; ?></td> 
                           <td><?php echo $row['p_mobile']; ?></td>
                          <td><?php echo $row['student_gender']; ?></td> 
                          <td><?php echo $row['year_of_study']; ?></td>  
                          <td> 
                            <a href="admin.php?page=student&Id_3=<?php echo $row['student_id']; ?>" onclick="return confirm('Are you sure you want to block a Student?');" >  <button class="btn btn-secondary"> View</button>
                            </td> 
                      </tr> 
                      <?php }?> 
                        </tbody>
                        <tfoot>
                        <tr>
                            <th>#</th>
                            <th>Image</th>
                            <th>Reg No</th>
                            <th>Student Name</th>
                            <th>Class Name</th> 
                            <th>Parent Mobile</th>
                            <th>Gender</th>
                            <th>Year</th> 
                            <th>Status</th>
                        </tr>
                      </tfoot>
                    </table> 
                 </div>
               </div>
              </div> <!-- end card body-->
            </div> <!-- end card --> 
            </div>
            <!-- /.card -->
          </div>
          </div>
           <div class="tab-pane" id="normal">
              <div class="container-fluid">
                <div class="row">
                  <div class="col-sm-12">  
                    <div class="card"> 
                 <!-- /.card-header -->
                    <div class="card-header">
                      <h3 class="card-title">Student List</h3>
                      <div class="float-right mb-2"> 
                        <a data-toggle="modal" href="#group" class="btn btn-info btn-xs float-right ml-2" >
                            <i class="fa fa-plus"></i>  Group SMS
                        </a>
                         <a data-toggle="modal" href="#ind" class="btn btn-info btn-xs float-right ml-2" >
                            <i class="fa fa-plus"></i>  Individual SMS
                        </a> 
                        </div>
                    </div>
                   <div class="card-body">
                  <div class="table-responsive">
                    <table id="example3" class="table table-striped display table-bordered" >
                      <thead>
                        <tr>
                            <th>#</th> 
                            <th>Reg No</th>
                            <th>Student Name</th> 
                            <th>Phone Number</th>
                            <th>SMS</th> 
                            <th>DATE</th>
                            <th>Action</th>
                        </tr>
                        </thead>
                        <tbody>
                          <?php 
                            $i = 1;
                            $selected = mysqli_query($conn,"SELECT *  FROM sms ");
                             while($row = mysqli_fetch_array($selected)){ 
                              $MD5=$row['student_roll_no'];
                        
                            ?> 
                        <tr>
                          <td class="text-center"><?php echo $i++ ?></td> 
                          <td><?php echo $MD5; ?></td>
                          <td><?php echo $row['student_name']; ?></td> 
                          <td><?php echo $row['s_mobile']; ?></td> 
                          <td><?php echo $row['sms']; ?></td> 
                          <td><?php echo $row['date']; ?></td>  
                          <td>
                           <div class="btn-group"> 
                            <a href="admin.php?page=student&del_s=<?php echo $row['sms_id']; ?>" onclick="return confirm('Are you sure you want to delete?');" class="btn btn-danger btn-flat delete_student">
                              <i class="fas fa-trash"></i>
                            </a>   
                        </div> </td>
                      </tr> 
                      <?php }?> 
                        </tbody>
                        <tfoot>
                        <tr>
                             <th>#</th> 
                            <th>Reg No</th>
                            <th>Student Name</th> 
                            <th>Phone Number</th>
                            <th>SMS</th> 
                            <th>DATE</th>
                            <th>Action</th>
                        </tr>
                      </tfoot>
                    </table> 
                 </div>
               </div>
              </div> <!-- end card body-->
            </div> <!-- end card --> 
            </div>
            <!-- /.card -->
          </div>
          </div>
          <div class="modal fade" id="group">
                <div class="modal-dialog">
                  <form method="post" action="">
                      <div class="modal-content">
                        <div class="modal-header">
                            <h4 class="modal-title" id="modal_title">Send SMS as a Group</h4>
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                        </div>
                        <div class="modal-body">
                          <span id="form_message"></span> 
                          <div class="form-group">
                                        <label>Class Name</label>
                                        <?php  
                                        $query = "SELECT * FROM class_srms WHERE  class_name!='GRADUATOR' AND class_status='Enable' ORDER BY class_name ASC"; 
                                         $result = $conn->query($query);      
                                         ?> 
                                        <select name="class_id" id="class_id" class="form-control select2" data-dropdown-css-class="Select a Student" style="width: 100%;" required>
                                            <option value="">Select Class</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>  
                           <label for="fa-comment" class="form-label">NORMAL SMS <span style="color: red;">*</span></label>
                            <textarea name="comment" required="required"  class="form-control" placeholder="Enter Your SMS Here..........."></textarea> <br> 
                        </div>
                        <div class="modal-footer"> 
                            <button type="submit" name="sms_group" class="btn btn-info">SEND</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        </div>
                      </div>
                  </form>
                  </div>
             </div><!-- /.modal -->
          <div class="modal fade" id="ind">
                <div class="modal-dialog">
                  <form method="post" action="">
                      <div class="modal-content">
                        <div class="modal-header">
                            <h4 class="modal-title" id="modal_title">Send SMS as a Nornal</h4>
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                        </div>
                        <div class="modal-body">
                          <span id="form_message"></span> 
                           <div class="form-group">
                            <label>Student Name<span style="color: red;">*</span></label>
                                   <div class="select2-purple"> 
                                      <?php  
                                        $query = "SELECT * FROM student_srms where student_status ='Enable' ORDER BY student_name ASC"; 
                                        $result = $conn->query($query);         
                                         ?> 

                                        <select name="student_roll_no" class="form-control select2" data-dropdown-css-class="Select a Student" style="width: 100%;" required>
                                            <option>Select Student</option>
                                            <?php 
                                            if($result->num_rows > 0){
                                             
                                                while($row = $result->fetch_assoc()){  
                                                    echo '<option value="'.$row['student_roll_no'].'">'.$row['student_name'].' | '.$row['student_roll_no'].'</option>';

                                                }
                                               
                                            }else{ 
                                                echo '<option value="">Student not available</option>'; 
                                            } 
                                          ?>
                                      </select>
                                    </div>
                                  </div> 
                                 <div class="form-group">
                                    <label>MOBILE<span style="color: red;">*</span></label>
                                      <div class="input-group">
                                         <div class="input-group-prepend">
                                          <span class="input-group-text"><i class="fas fa-phone"></i></span>
                                       </div>
                                    <input type="text" name="s_mobile" id="s_mobile" class="form-control" required data-parsley-type="integer" data-parsley-minlength="10" data-parsley-maxlength="12" placeholder="Enter Phone Number..." pattern="[0]{1}[0-9]{9}" data-parsley-trigger="keyup" />
                              </div>
                             </div>
                           <label for="fa-comment" class="form-label">NORMAL SMS <span style="color: red;">*</span></label>
                            <textarea name="comment" required="required"  class="form-control" placeholder="Enter Your SMS Here..........."></textarea> <br> 
                        </div>
                        <div class="modal-footer"> 
                            <button type="submit" name="sms" class="btn btn-info">SEND</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        </div>
                      </div>
                  </form>
                  </div>
             </div><!-- /.modal -->
          <div class="modal fade" id="update">
                <div class="modal-dialog">
                  <form method="post" action="">
                      <div class="modal-content">
                        <div class="modal-header">
                            <h4 class="modal-title" id="modal_title">Update The Whole Result</h4>
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                        </div>
                        <div class="modal-body">
                          <span id="form_message"></span>
                             <div class="form-group">
                                        <label>Select Year</label>
                                        <div class="select2-purple">  
                                        <select name="year_of_study" id="year_of_study" class="form-control select2" data-dropdown-css-class="Select a year" style="width: 100%;" required>  
                                            <option value="2024">2024</option> 
                                            <option value="2025">2025</option>
                                            <option value="2026">2026</option>
                                            <option value="2027">2027</option>
                                            <option value="2028">2028</option> 
                                            <option value="2028">2029</option> 
                                            <option value="2028">2030</option>   
                                      </select>
                                    </div>
                              </div>
                              <div class="form-group">
                                <label>From level</label>
                                 <div class="select2-purple"> 
                                  <?php  
                                  $query = "SELECT * FROM class_srms WHERE class_name !='GRADUATOR' ORDER BY class_name ASC"; 
                                  $result = $conn->query($query);      
                                   ?> 
                                   <select name="edit_class_id" id="edit_class_id" class="form-control select2" data-dropdown-css-class="Select a year" style="width: 100%;"required>
                                  <option value="">Select Class</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="form-group">
                            <label>To level</label>
                             <div class="select2-purple">  
                             <?php  
                              $query = "SELECT * FROM class_srms ORDER BY class_name ASC"; 
                              $result = $conn->query($query);      
                               ?> 
                             <select name="class_id" id="edit_class_id" class="form-control select2" data-dropdown-css-class="Select a year" style="width: 100%;"required>
                              <option value="">Select Class</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>
                        <div class="modal-footer"> 
                            <button type="submit" name="s_update" class="btn btn-danger">UPDATE</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        </div>
                      </div>
                  </form>
                  </div>
             </div><!-- /.modal --> 
          <div class="modal fade" id="add">
                <div class="modal-dialog">
                  <form method="post" action="">
                      <div class="modal-content">
                        <div class="modal-header">
                            <h4 class="modal-title" id="modal_title">Add student</h4>
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                        </div>
                        <div class="modal-body">
                          <span id="form_message"></span> 
                          
                           <input name="student_profile" type="hidden"  class="form-control" value="assets/img/face-0.jpg">  
                          <div class="form-group">
                            <label>Student Name<span style="color: red;">*</span></label>
                            <input type="text" name="student_name" id="student_name" class="form-control" required data-parsley-pattern="/^[a-zA-Z0-9 \s]+$/" placeholder="Enter Student Full Name" data-parsley-trigger="keyup" />
                          </div> 
                          <!-- <div class="form-group">-->
                          <!--  <label>Gender <span style="color: red;">*</span></label>-->
                          <!--  <div class="select2-purple"> -->
                          <!--    <select class="form-control select2" name="student_gender" data-dropdown-css-class="Select a Program" style="width: 100%;" required>  -->
                          <!--    <option value="Female">Female</option>-->
                          <!--    <option value="Male">Male</option>-->
                          <!--  </select>-->
                          <!--  </div> -->
                          <!--</div>-->
                          <input type="hidden" name="student_gender" value="Male">
                          <!--<div class="form-group">-->
                          <!--  <label>Date of Birth<span style="color: red;">*</span></label>-->
                          <!--   <input type="date" name="student_dob" id="student_dob" class="form-control"  required />-->
                          <!--</div> -->
                          <input type="hidden" name="student_dob" value="2005-02-02">
                          <!--<div class="form-group">-->
                          <!--    <label>Academic Year</label>-->
                          <!--    <div class="select2-purple">  -->
                          <!--    <select name="year_of_study" id="year_of_study" class="form-control select2" data-dropdown-css-class="Select a year" style="width: 100%;" required> -->
                          <!--        <option value="2023">2023</option> -->
                          <!--        <option value="2024">2024</option> -->
                          <!--        <option value="2025">2025</option>-->
                          <!--        <option value="2026">2026</option>-->
                          <!--        <option value="2027">2027</option>-->
                          <!--        <option value="2028">2028</option> -->
                          <!--        <option value="2028">2029</option>   -->
                          <!--        <option value="2028">2030</option> -->
                          <!--  </select>-->
                          <!--</div>-->
                          <!--    </div>-->
                              <input type="hidden" name="year_of_study" value="2025">
                            <!--  <div class="form-group">-->
                            <!--<label>Student class</label>-->
                            <!-- <div class="select2-purple"> -->
                          <?php  
                        //   $query = "SELECT * FROM class_srms WHERE class_name!='GRADUATOR' ORDER BY class_name ASC"; 
                        //   $result = $conn->query($query);      
                        ?> 
                             <!--<select name="class_id" id="class_id" class="form-control select2" data-dropdown-css-class="Select a Student" style="width: 100%;" required>-->
                             <!-- <option value="">Select Class</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>-->
                          <input type="hidden" name="class_id" value="5">
                         <!-- <label>Parent Mobile<span style="color: red;">*</span></label>-->
                         <!--   <div class="input-group">-->
                         <!--      <div class="input-group-prepend">-->
                         <!--       <span class="input-group-text"><i class="fas fa-phone"></i></span>-->
                         <!--    </div>-->
                         <!--   <input type="text" name="p_mobile" id="p_mobile" class="form-control" required data-parsley-type="integer" data-parsley-minlength="10" data-parsley-maxlength="12" placeholder="Enter Phone Number..." pattern="[0]{1}[0-9]{9}" data-parsley-trigger="keyup" />-->
                         <!--</div>-->
                         <input type="hidden" name="student_added_by" value="<?php echo $user_row['user_name'];  ?>">
                        </div>
                        <input type="hidden" name="p_mobile" value="0757660790">
                        <div class="modal-footer"> 
                            <button type="submit" name="ADD" class="btn btn-info">ADD</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        </div>
                      </div>
                  </form>
                  </div>
             </div><!-- /.modal --> 
             
             <div class="modal fade" id="exel">
                <div class="modal-dialog">
                  <form action="views/import_std.php" method="post" name="upload_excel" enctype="multipart/form-data">
                      <div class="modal-content">
                        <div class="modal-header">
                            <h4 class="modal-title" id="modal_title">Upload csv file</h4>
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                        </div>
                        <div class="modal-body">
                          <span id="form_message"></span> 
                          
                          <input name="student_profile" type="hidden"  class="form-control" value="assets/img/face-0.jpg">  
                           
                         
                              <div class="form-group">
                            <label>Student class</label>
                             <div class="select2-purple"> 
                              <?php  
                              $query = "SELECT * FROM class_srms WHERE class_name!='GRADUATOR' ORDER BY class_name ASC"; 
                              $result = $conn->query($query);      
                               ?> 
                             <select name="class_id" id="class_id" class="form-control select2" data-dropdown-css-class="Select a Student" style="width: 100%;" required>
                              <option value="">Select Class</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="form-group">
                              <label>Academic Year</label>
                              <div class="select2-purple">  
                              <select name="year_of_study" id="year_of_study" class="form-control select2" data-dropdown-css-class="Select a year" style="width: 100%;" required> 
                                  <option value="2023">2023</option> 
                                  <option value="2024">2024</option> 
                                  <option value="2025">2025</option>
                                  <option value="2026">2026</option>
                                  <option value="2027">2027</option>
                                  <option value="2028">2028</option> 
                                  <option value="2028">2029</option>   
                                  <option value="2028">2030</option> 
                            </select>
                          </div>
                              </div>
                          <label>Choose File<span style="color: red;">*</span></label>
                            <div class="input-group">
                               <div class="input-group-prepend">
                                <span class="input-group-text"><i class="fas fa-upload"></i></span>
                             </div>
                            <input type="file" name="file" accept=".xls,.xlsx,.CSV" id="file" class="form-control" placeholder="Select excel file.." required>
                         </div>
                         <input type="hidden" name="student_added_by" value="<?php echo $user_row['user_name'];  ?>">
                        </div>
                        <div class="modal-footer"> 
                            <button type="submit" id="submit" name="Importstd" class="btn btn-success">UPLOAD AND IMPORT</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        </div>
                      </div>
                  </form>
                  </div>
             </div><!-- /.modal --> 
             
             </div>
                <!-- /.tab-content -->
             </div><!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
 <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/pdfmake/vfs_fonts.js"></script> 
<script src="../stp_con/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="../stp_con/datatables-buttons/js/buttons.print.min.js"></script>
<script src="../stp_con/datatables-buttons/js/buttons.colVis.min.js"></script>
 
<script src="../assets/js/adminlte.min.js"></script> 

<!-- Select2 -->
<script src="../stp_con/select2/js/select2.full.min.js"></script>
 
<script src="../stp_con/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
 
</body>

</html>

 <script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": true, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)'); 
  });
   $(function () {
    $("#example3").DataTable({
      "responsive": true, "lengthChange": true, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example2_wrapper .col-md-6:eq(0)'); 
  });
   $(function () {
    $("#example2").DataTable({
      "responsive": true, "lengthChange": true, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example2_wrapper .col-md-6:eq(0)'); 
  });
</script>
 
 <script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })

    //Datemask dd/mm/yyyy
    $('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
    //Datemask2 mm/dd/yyyy
    $('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
    //Money Euro
    $('[data-mask]').inputmask()

    //Date picker
    $('#reservationdate').datetimepicker({
        format: 'L'
    }); 
    //Date range picker
    $('#reservation').daterangepicker()
    //Date range picker with time picker
    $('#reservationtime').daterangepicker({
      timePicker: true,
      timePickerIncrement: 30,
      locale: {
        format: 'MM/DD/YYYY hh:mm A'
      }
    })
    //Date range as a button
    $('#daterange-btn').daterangepicker(
      {
        ranges   : {
          'Today'       : [moment(), moment()],
          'Yesterday'   : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
          'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
          'Last 30 Days': [moment().subtract(29, 'days'), moment()],
          'This Month'  : [moment().startOf('month'), moment().endOf('month')],
          'Last Month'  : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
        },
        startDate: moment().subtract(29, 'days'),
        endDate  : moment()
      },
      function (start, end) {
        $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
      }
    )

    //Timepicker
    $('#timepicker').datetimepicker({
      format: 'LT'
    })

    //Bootstrap Duallistbox
    $('.duallistbox').bootstrapDualListbox()

    //Colorpicker
    $('.my-colorpicker1').colorpicker()
    //color picker with addon
    $('.my-colorpicker2').colorpicker()

    $('.my-colorpicker2').on('colorpickerChange', function(event) {
      $('.my-colorpicker2 .fa-square').css('color', event.color.toString());
    })
  })
  // BS-Stepper Init
  document.addEventListener('DOMContentLoaded', function () {
    window.stepper = new Stepper(document.querySelector('.bs-stepper'))
  })

  // DropzoneJS Demo Code Start
  Dropzone.autoDiscover = false

  // Get the template HTML and remove it from the doumenthe template HTML and remove it from the doument
  var previewNode = document.querySelector("#template")
  previewNode.id = ""
  var previewTemplate = previewNode.parentNode.innerHTML
  previewNode.parentNode.removeChild(previewNode)

  var myDropzone = new Dropzone(document.body, { // Make the whole body a dropzone
    url: "/target-url", // Set the url
    thumbnailWidth: 80,
    thumbnailHeight: 80,
    parallelUploads: 20,
    previewTemplate: previewTemplate,
    autoQueue: false, // Make sure the files aren't queued until manually added
    previewsContainer: "#previews", // Define the container to display the previews
    clickable: ".fileinput-button" // Define the element that should be used as click trigger to select files.
  })

  myDropzone.on("addedfile", function(file) {
    // Hookup the start button
    file.previewElement.querySelector(".start").onclick = function() { myDropzone.enqueueFile(file) }
  })

  // Update the total progress bar
  myDropzone.on("totaluploadprogress", function(progress) {
    document.querySelector("#total-progress .progress-bar").style.width = progress + "%"
  })

  myDropzone.on("sending", function(file) {
    // Show the total progress bar when upload starts
    document.querySelector("#total-progress").style.opacity = "1"
    // And disable the start button
    file.previewElement.querySelector(".start").setAttribute("disabled", "disabled")
  })


    $('.toastrDefaultSuccess').click(function() {
      toastr.success('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')
    });
    $('.toastrDefaultInfo').click(function() {
      toastr.info('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')
    });
    $('.toastrDefaultError').click(function() {
      toastr.error('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')
    });
    $('.toastrDefaultWarning').click(function() {
      toastr.warning('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')
    });

  // Hide the total progress bar when nothing's uploading anymore
  myDropzone.on("queuecomplete", function(progress) {
    document.querySelector("#total-progress").style.opacity = "0"
  })

  // Setup the buttons for all transfers
  // The "add files" button doesn't need to be setup because the config
  // `clickable` has already been specified.
  document.querySelector("#actions .start").onclick = function() {
    myDropzone.enqueueFiles(myDropzone.getFilesWithStatus(Dropzone.ADDED))
  }
  document.querySelector("#actions .cancel").onclick = function() {
    myDropzone.removeAllFiles(true)
  }
  // DropzoneJS Demo Code End
  </script>
<script>
$(document).ready(function(){
    $('#login_form').parsley();
     $('#login_form2').parsley();
     $('#login_form3').parsley();
     $('#login_form4').parsley();
     $('#login_form5').parsley();
     $('#login_form6').parsley(); 
});

</script>