// <?php
 

// /**************************************
//  * STEP 1:
//  * Get all unprocessed answers older than 1 hour
//  **************************************/
// $sql = "
//     SELECT 
//         esqa.answer_id,
//         esqa.student_id,
//         esqa.exam_subject_question_id,
//         esqa.marks,
//         esqa.created_at,
//         esqa.processed 
//     FROM exam_subject_question_answer AS esqa 
    
// ";

// $result = $mysqli->query($sql);

// if (!$result) {
//     die("Query failed: " . $mysqli->error);
// }


// /**************************************
//  * STEP 2:
//  * Group marks by student + exam + subject
//  **************************************/

// $results = [];  // array to collect totals

// while ($row = $result->fetch_assoc()) {

//     $key = $row['student_id'] . "-" . $row['exam_id'] . "-" . $row['subject_id'];

//     if (!isset($results[$key])) {
//         $results[$key] = [
//             "student_id"     => $row['student_id'],
//             "student_roll_no"=> $row['student_roll_no'],
//             "exam_id"        => $row['exam_id'],
//             "class_id"       => $row['class_id'],
//             "subject_id"     => $row['subject_id'],
//             "total_marks"    => 0,
//             "answer_ids"     => []
//         ];
//     }

//     $results[$key]['total_marks'] += $row['marks'];
//     $results[$key]['answer_ids'][] = $row['answer_id'];
// }


// /**************************************
//  * STEP 3:
//  * Insert total results into sms_result
//  **************************************/
// foreach ($results as $r) {

//     $insert = $mysqli->prepare("
//         INSERT INTO sms_result 
//             (student_id, student_roll_no, exam_id, class_id, subject_id, total_marks, result_time)
//         VALUES (?, ?, ?, ?, ?, ?, NOW())
//     ");

//     $insert->bind_param(
//         "isiiii",
//         $r['student_id'],
//         $r['student_roll_no'],
//         $r['exam_id'],
//         $r['class_id'],
//         $r['subject_id'],
//         $r['total_marks']
//     );

//     if ($insert->execute()) {

//         // STEP 4: Mark all answers as processed
//         foreach ($r['answer_ids'] as $aid) {
//             $mysqli->query("UPDATE exam_subject_question_answer SET processed = 1 WHERE answer_id = $aid");
//         }

//         echo "Inserted result for Student ID " . $r['student_id'] . "<br>";
//     } else {
//         echo "Insert failed: " . $insert->error . "<br>";
//     }
// }
//  ?>
//       <script type="text/javascript">
//           alert("Processing Complete.");
//         </script>
//         <?php   

// ?>
<?php 
include ('../includes/connection.php'); 
include('sms.php');

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

 
require 'vendor/autoload.php';

if(isset($_GET['del']))
{
$id= $_GET['del']; 
$sql =mysqli_query($conn,"DELETE FROM `exam_invoice` WHERE invoice_id = $id");
header('location:admin.php?page=invoice"');
}

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

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


if (isset($_POST['update'])){
$subject_id = $_POST['subject_id']; 
$students_sql = "SELECT * FROM sms_result,student_soes,subject_soes WHERE sms_result.student_id=student_soes.student_id AND sms_result.subject_id=subject_soes.subject_id AND sms_result.subject_id='$subject_id' GROUP BY sms_result.student_id";
 $students_result = $conn->query($students_sql);

 
// 5. Loop students
 while ($student = $students_result->fetch_assoc()) {
      $student_name = $student['student_name'];
      $subject_name = $student['subject_name'];
      $student_email_id = $student['student_email_id']; 
      $s_mobile = $student['student_contact_no']; 
      
      $s_mobile = substr($s_mobile, 1);
      $s_mobile = "255$s_mobile";
      $message = "Cybercode: Congratulations $student_name! You passed your Cybercode Academy $subject_name assessment. Your certificate will be ready in 24 hours.  Keep pushing forward!";
      send_message($s_mobile, $message);
      
      echo "<div style='display: none;'>"; 
                    $mail = new PHPMailer(true);

                    try {
                        //Server settings
                        $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      //Enable verbose debug output
                        $mail->isSMTP();                                            //Send using SMTP
                        $mail->Host       = 'mail.cybercode.co.tz';                 //Set the SMTP server to send through
                        $mail->SMTPAuth   = true;                                   //Enable SMTP authentication
                        $mail->Username   = 'support@cybercode.co.tz';              //SMTP username
                        $mail->Password   = 'CYBER@support@2024';                   //SMTP password
                        $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;            //Enable implicit TLS encryption
                        $mail->Port       = 465;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`

                        //Recipients
                        $mail->setFrom('support@cybercode.co.tz');
                        $mail->addAddress($student_email_id);

                        //Content
                        $mail->isHTML(true);                                  //Set email format to HTML
                        $mail->Subject = 'Exam Access Code Issued';
                        $mail->Body    = '  
                        Congratulations! You’ve Passed Your Cybercode Academy Assessment<br><br>
                        Dear '.$student_name.',<br><br>
                        We are excited to inform you that you have successfully passed the assessment for '.$subject_name.' at Cybercode Academy!<br>
                        Your dedication and hard work have paid off, and you are now one step closer to becoming a digital security expert. You will soon receive your certificate of completion, which will be available in your student portal within the next 24 hours.<br>
                        Keep learning, keep growing — the future of cybersecurity needs minds like yours.<br><br>
                        Next Steps:<br>
                        •	Log into your portal to download your certificate<br>
                        •	Explore more advanced courses available to you<br><br>
                        Congratulations once again!<br>
                        Best regards,<br>
                        Cybercode Academy Team<br>
                        support@cybercode.co.tz<br>
                        +255686969536<br>
                        www.cybercode.co.tz<br>

                         
                         ';

			$mail->send();
// 			echo 'Message has been sent';
			} catch (Exception $e) {
			echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
			}
     
      } 
       ?>
      <script type="text/javascript">
          alert("Examination Results have successfully sent");
        </script>
        <?php  
      
 }
 
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
 
  <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>Add Course</strong></a>
          </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 active">Student Result</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>
<br>
   <!-- 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="#exam" data-toggle="tab"><i class="fas fa-th-list"></i> Examination Result</a></li>  
                </ul>
              </div> 
              <div class="card-body"> 
              <div class="tab-content"> 
              <div class="active tab-pane" id="exam">
              <div class="container-fluid">
                <div class="row">
                  <div class="col-sm-12">  
                    <div class="card">  
                      <div class="card-header">
                      <h3 class="card-title">Examinatinon List Result</h3>
                      <div class="float-right mb-2">
                        <a data-toggle="modal" href="#add" class="btn btn-secondary btn-xs float-right ml-2" >
                            <i class="fa fa-plus"></i> SEND RESULT HERE
                        </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>Students id</th> 
                          <th>Examination Name</th> 
                          <th>Course name</th>    
                          <th>Total score</th> 
                          <th>Remark</th>  
                        </tr>
                        </thead>
                        <tbody>
                               <?php 
                                    $i = 1;
                                   $school_query = mysqli_query($conn,"SELECT * FROM sms_result,class_soes,subject_soes WHERE sms_result.class_id=class_soes.class_id AND sms_result.subject_id=subject_soes.subject_id;");
                                while($row = mysqli_fetch_array($school_query)){  
                             ?>
                            <tr>
                              <td class="text-center"><?php echo $i++ ?></td> 
                              <td><?php echo $row['student_roll_no']; ?></td> 
                              <td><?php echo $row['course_code']; ?></td>
                              <td><?php echo $row['subject_name']; ?></td> 
                              <td><?php echo $row['total_marks']; ?></td> 
                              <td>
                            <?php
                              if($row["total_marks"] > '60' )
                                 {?>
                                <a href="admin.php?page=student_result&Id_3=<?php echo $row['student_id']; ?>"   >  <button class="btn btn-success"> PASS</button>
                                <?php } else{?>
                                  <a href="admin.php?page=student&Id_2=<?php echo $row['student_id']; ?>"  ><button class="btn btn-danger"> FAIL</button> 
                                 <?php } ?>

                             </td> 
                          </tr> 
                            <?php }?>
                            </tbody>
                        <tfoot>
                         <tr>
                         <th>#</th>
                          <th>Students id</th> 
                          <th>Examination Name</th> 
                          <th>Course name</th>    
                          <th>Total score</th> 
                          <th>Remark</th> 
                        </tr>
                      </tfoot>
                    </table> 
                 </div>
               </div>
              </div> <!-- end card body-->
            </div> <!-- end card --> 
            </div>
            <!-- /.card -->
          </div>
          </div>  
             
              <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">Assign Student to Class</h4>
                                      <button type="button" class="close" data-dismiss="modal">&times;</button>
                                  </div>
                                  <div class="modal-body">
                                    <span id="form_message"></span> 
                                     <div class="mb-3">
                                         <div class="form-group">
                                            <label>Course Name<span style="color: red;">*</span></label>
                                                <div class="select2-purple">  
                                                  <select name="subject_id" id="subject_id" class="form-control select2" data-dropdown-css-class="Select a year" style="width: 100%;" required>  
                                                    <option value="">Select Course</option>
                                                    
                                                    <?php 
                                                      $result = mysqli_query($conn, "SELECT * FROM sms_result,class_soes,subject_soes WHERE sms_result.class_id=class_soes.class_id AND sms_result.subject_id=subject_soes.subject_id GROUP BY class_name;");
                                                        while ($row = mysqli_fetch_assoc($result)) {
                                                            echo "<option value='{$row['subject_id']}'>{$row['course_code']} | {$row['subject_name']}</option>";
                                                        } 
                                                  ?>  
                                              </select>
                                            </div>
                                           </div> 
                                         </div>
                                   <!--  <div class="mb-3">
                                        <label>Payment Code.</label>
                                        <input type="text" name="payment_code" id="payment_code" class="form-control" required />
                                    </div> --> 
                                  </div>
                                  <div class="modal-footer"> 
                                      <input type="submit" name="update" class="btn btn-secondary" value="SEND" />
                                      <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> 
  </div>
  <script src="../stp_con/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../stp_con/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="../stp_con/select2/js/select2.full.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/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.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="../stp_con/summernote/summernote-bs4.min.js"></script>  
<script src="../assets/js/adminlte.min.js"></script>
 <script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)'); 
  });
   $(function () {
    $("#example2").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
      "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
    }).buttons().container().appendTo('#example2_wrapper .col-md-6:eq(0)'); 
  });
</script>  
<script>
  $(function () {
    // Summernote
    $('#summernote').summernote()

    // CodeMirror
    CodeMirror.fromTextArea(document.getElementById("codeMirrorDemo"), {
      mode: "htmlmixed",
      theme: "monokai"
    });
  })
</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")
  })

  // 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();
 
});

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