 
<!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"> 
   <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header bg-primary" style=" color: white;">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <a><strong>Level For Examination Result</strong></a>
              
          </div> 
        </div>
      </div><!-- /.container-fluid -->
    </section>
    <br><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 ">
                  <?php  
                      include ('../includes/connection.php');
                      $ex_id=$_GET['Id_2'];
                        $query= mysqli_query($conn,"SELECT * FROM exam_srms,class_srms where exam_srms.class_id=class_srms.class_id AND exam_srms.exam_id='$ex_id'")or die(mysqli_error());
                          $class1 = mysqli_fetch_array($query);
                          $class_id=$class1['class_id'];
                          $class_name1=$class1['nick']; 
                        ?>    
                        <li class="nav-item "><a class="nav-link active" href="#class_one" data-toggle="tab"><?php echo $class1['exam_name']; ?>-<?php echo $class1['class_name']; ?></a></li>  
                        <?php 
                        $q = mysqli_fetch_array($query1); 
                        $categ="Academic Master";    
                    ?> 
                       

                </ul>
              </div>

              <!-- /.card-header --> 
              <div class="card-body"> 
              <div class="tab-content">
              <!-- /.tab-pane -->
              <div class="active tab-pane" id="class_one">
              <div class="container-fluid">
                <div class="row">
                  <div class="col-sm-12">  
                    <div class="card"> 
                      <div class="card-header"> 
                      <div class="float-right mb-2">
                        <a data-toggle="modal" href="#Filter" class="btn btn-danger btn-xs float-right ml-2" >
                            <i class="fa fa-filter"></i>  FILTER
                        </a>  
                        </div>
                          </div>   
                          <div class="card-body">
                          <div class="row"> 
                             <div class="col-sm-12">
                               <div class="alert alert-info alert-dismissible">
                                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                                <h5><i class="fas fa-bullhorn"></i> Filter results!</h5>
                                <hr>
                               Please conform the year by press the button of filter.
                              </div>

                           </div>
                         </div>
                         </div>
                             
                           <?php  
                            $fit = mysqli_query($conn,"SELECT * FROM marks_srms WHERE exam_id='$ex_id' AND class_id='$class_id'");
                               $level_year = mysqli_fetch_array($fit);
                               $check_year=$level_year['year_of_study']; 

                             if(isset($_POST['filta']))
                              { 
                              $year = $_POST['year'];  

                            if ($check_year==$year) {  
                                 ?> 


                            <div class="card-body">
                              <a  href="views/A_result_pdf.php?id=<?php echo $ex_id ?>&id2=<?php echo $class_id ?>&id3=<?php echo $year ?>" class="btn btn-success btn-xs float-right ml-2" >
                                  <i class="fa fa-print"></i> PRINT
                              </a>
                              <div class="row"> 
                               <div class="col-sm-3">
                                <img src="../assets/img/logo.png" class="img-thumbnail"  width="200">
                                </div>
                                <div class="col-sm-6">
                               <center><h3><b>
                                    PRESIDENTS OFFICE <br>
REGIONAL ADMINISTRATION AND LOCAL GOVERNMENT<br>
SIHA DISTRICT COUNCIL</b><br>
<h4>SIKIRARI SECONDARY SCHOOL<br><h4>
<h4><u class="dotted-line"> <?php echo $class1['class_name']; ?> | <?php echo $class1['exam_name']; ?> EXAMINATION RESULT - <b><?php echo $level_year['year_of_study']; ?></b></u></h4></h3></center>
                                </div>
                                <div class="col-sm-3">
                                </div>
                                
                              </div>
                            <div class="table-responsive"> 
                            <?php
                              $ex_id=$_GET['Id_2'];
                              
                             if($class_name1=="PCM"){ 
                              $scoring_subject = ['PHY', 'CHEM', 'A_MATH']; // Used for division  
                                }else{  
                               $scoring_subject = ['PHY', 'CHEM', 'BIO']; // Used for division 
                               } 
                              
                             $subject_list2 = "'" . implode("','", $scoring_subject) . "'";
                              // Step 1: Get total points per student
                              $sql2 = "SELECT marks_srms.identity_sub,marks_srms.student_roll_no,student_srms.student_gender,student_srms.student_roll_no, SUM(marks_srms.point) as total_P FROM marks_srms,student_srms WHERE marks_srms.student_roll_no=student_srms.student_roll_no AND marks_srms.class_id='$class_id' AND marks_srms.exam_id='$ex_id' AND student_srms.student_status='Enable' AND marks_srms.identity_sub IN ($subject_list2) GROUP BY marks_srms.student_roll_no,student_srms.student_gender ";

                              $result1 = $conn->query($sql2);

                              // Step 2: Initialize structure
                              $genders = ['Male', 'Female'];
                              $divisions = ['Division I', 'Division II', 'Division III','Division IV', 'Division 0'];

                              $gender_report = [];
                              $division_totals = array_fill_keys($divisions, 0); // to collect column totals

                              foreach ($genders as $gender) {
                                  foreach ($divisions as $div) {
                                      $gender_report[$gender][$div] = 0;
                                  }
                              }

                              // Step 3: Fill gender division counts and compute totals
                              foreach ($result1 as $row) {
                                  $gender = $row['student_gender'];
                                  $total_point = (int)$row['total_P'];

                                  if ($total_point >= 3 && $total_point <= 9) $division = "Division I";
                                  elseif ($total_point >= 10 && $total_point <= 12) $division = "Division II";
                                  elseif ($total_point >= 13 && $total_point <= 17) $division = "Division III";
                                  elseif ($total_point >= 18 && $total_point <= 19) $division = "Division IV";
                                  else $division = "Division 0";
 
                                    
                                  $gender_report[$gender][$division]++;
                                  $division_totals[$division]++;
                              } 
                              echo "<table class='float-right' border='1' style='border-style: dashed;'> <thead>
                                <tr><th colspan='10'><center>CLASS PERFORMANCE</center></th> 
                                <tr class='bg-info' style='color: white;'>  
                                    <th>Gender</th>
                                      <th>Division I</th>
                                      <th>Division II</th>
                                      <th>Division III</th>
                                      <th>Division IV</th>
                                      <th>Division 0</th>
                                      <th>Total</th>
                                  </tr>
                                </thead>";

                              $grand_total = 0;

                              foreach ($gender_report as $gender => $div_counts) {
                                  $total = array_sum($div_counts);
                                  $grand_total += $total;
                                  echo "<tr>
                                          <td>$gender</td>
                                          <td>{$div_counts['Division I']}</td>
                                          <td>{$div_counts['Division II']}</td>
                                          <td>{$div_counts['Division III']}</td>
                                          <td>{$div_counts['Division IV']}</td>
                                          <td>{$div_counts['Division 0']}</td>
                                          <td><strong>$total</strong></td>
                                        </tr>";
                              }

                              // Output bottom total row
                              echo "<tr>
                                      <th>Total</th>
                                      <th>{$division_totals['Division I']}</th>
                                      <th>{$division_totals['Division II']}</th>
                                      <th>{$division_totals['Division III']}</th>
                                      <th>{$division_totals['Division IV']}</th>
                                      <th>{$division_totals['Division 0']}</th>
                                      <th><strong>$grand_total</strong></th>
                                    </tr>";

                              echo "</table>";

                              ?> 
                               <br><br><br>
                                <?php
                                
                                 
                                $sql_overall = "
                                SELECT 
                                    class_id,
                                    exam_id,
                                    ROUND(SUM(
                                        CASE grade
                                           WHEN 'A' THEN 5
                                            WHEN 'B' THEN 4
                                            WHEN 'C' THEN 3
                                            WHEN 'D' THEN 2
                                            WHEN 'E' THEN 1
                                            WHEN 'S' THEN 0
                                            WHEN 'F' THEN 0
                                        END
                                    ) / COUNT(*), 2) AS overall_gpa,
                                    COUNT(*) AS total_grades
                                FROM marks_srms
                                WHERE class_id = '$class_id'  AND exam_id = '$ex_id'
                                GROUP BY class_id, exam_id 
                                ";
                                
                                $result_overall = $conn->query($sql_overall);
                                
                                if ($result_overall->num_rows > 0) {  while($row = $result_overall->fetch_assoc()) {
                                        echo " 
                                           <h2><b>GPA: {$row['overall_gpa']}</b></h2>
                                             ";
                                    } 
                                }  
                                ?>
                                 </div>
                              <div class="card-body table-responsive p-0" style="height: 400px;">


                              <?php  

                              $ex_id=$_GET['Id_2'];
                              if($class_name1=="PCM"){
                              $display_subjects = ['HIST-M','A-COM', 'PHY', 'CHEM', 'A_MATH']; // Display in table
                              $scoring_subjects = ['PHY', 'CHEM', 'A_MATH']; // Used for division calculation only                                
                               }else{
                            //   $display_subjects = ['HIST-M','A-COM','GS','BAM', 'PHY', 'CHEM','BIO']; // Display in table
                               $display_subjects = ['HIST-M','A-COM','BAM', 'PHY', 'CHEM','BIO']; // Display in table
                               $scoring_subjects = ['PHY', 'CHEM', 'BIO']; // Used for division 
                               
                               } 
                                    // 3. Fetch student IDs
                                   $students_sql = "SELECT DISTINCT student_srms.student_roll_no,student_srms.student_name,student_srms.student_gender FROM student_srms,marks_srms WHERE marks_srms.student_roll_no=student_srms.student_roll_no AND student_srms.student_status='Enable' AND marks_srms.exam_id='$ex_id' AND marks_srms.class_id='$class_id' ";
                                    $students_result = $conn->query($students_sql);

                                  // 4. Collect student data first
                                  $student_rows = [];

                                  while ($student = $students_result->fetch_assoc()) {
                                        $student_id = $student['student_roll_no'];
                                        $student_name = $student['student_name'];
                                        $student_gender = $student['student_gender'];
                                        // Placeholder
                                        $subject_data = array_fill_keys($display_subjects, ['marks' => '-', 'grade' => '-', 'point' => 0]);
                                        $total_point = 0;
                                        $total_marks = 0;

                                        // Fetch subject info
                                        $subject_list = "'" . implode("','", $display_subjects) . "'";

                                        $sql = "SELECT general_subject.identity, marks_srms.grade, marks_srms.marks, marks_srms.point FROM marks_srms,general_subject WHERE marks_srms.subject_id=general_subject.sub_id AND marks_srms.student_roll_no = '$student_id' AND marks_srms.class_id='$class_id' AND marks_srms.exam_id='$ex_id' AND general_subject.identity IN ($subject_list) ORDER BY marks_srms.marks DESC";
                                        $result = $conn->query($sql);

                                      while ($row = $result->fetch_assoc()) {
                                          $sub = $row['identity'];
                                          $subject_data[$sub] = [
                                              'marks' => $row['marks'],
                                              'grade' => $row['grade'],
                                              'point' => $row['point']
                                          ];
                                          if (in_array($sub, $scoring_subjects)) {
                                              $total_point += (int)$row['point'];
                                              $total_marks += (int)$row['marks'];
                                          }
                                      }

                                      // Division logic
                                     if ($total_point >= 3 && $total_point <= 9) {
                                        $division = "I";
                                        } elseif ($total_point >= 10 && $total_point <= 12) {
                                            $division = "II";
                                        } elseif ($total_point >= 13 && $total_point <= 17) {
                                            $division = "III";
                                        } elseif ($total_point >= 18 && $total_point <= 19) {
                                            $division = "IV";
                                        } else {
                                            $division = "0";
                                        }

                                      // Store in array for sorting
                                      $student_rows[] = [
                                          'student_roll_no' => $student_id,
                                          'student_name' => $student_name,
                                          'student_gender' => $student_gender,
                                          'identity' => $subject_data,
                                          'total_point' => $total_point,
                                          'total_marks' => $total_marks,
                                          'division' => $division
                                      ];
                                  }

                                    // 5. Sort by total_point DESC for ranking
                                    usort($student_rows, function($a, $b) {
                                        return $b['total_marks'] - $a['total_marks'];
                                    });

                                    // 6. Display table with positions
                                   echo "<table class='table table-head-fixed text-nowrap table-bordered'>
                                        <tr>
                                            <th>S/N</th>
                                            <th>ADM NO</th>
                                            <th>Student Name</th>
                                            <th>SEX</th>";

                                    foreach ($display_subjects as $subject) {
                                        echo "<th>$subject</th>";
                                    }
                                   echo "<th>T-Marks</th> <th>Point</th> <th>Div</th><th>Psn</th> </tr>"; 

                                    // 7. Output rows with position
                                    $position = 1;
                                    $i = 1;
                                    foreach ($student_rows as $row) {
                                        echo "<tr>
                                                <td>$i</td>
                                                <td>{$row['student_roll_no']}</td>
                                                <td>{$row['student_name']}</td>
                                                <td>{$row['student_gender']}</td>";

                                        foreach ($display_subjects as $subject) {
                                            $s = $row['identity'][$subject]['marks'];
                                            $g = $row['identity'][$subject]['grade'];
                                            echo "<td>$s - $g</td>";
                                        }

                                        echo "<td>{$row['total_marks']}</td>
                                              <td>{$row['total_point']}</td>
                                              <td>{$row['division']}</td>
                                              <td>$position</td>
                                             </tr>";
                                        $position++;
                                        $i++;
                                    }

                                    echo "</table>";



 
                              ?>
                              
                             
                            </div> 
                          </div> <!-- end card body-->
                          <div class="container-fluid">
                             <div class="row">
                              <div class="col-sm-12">  
                               <div class="card  p-2">
                                <div class="table-responsive"> 
                                   
                                   <?php
 

                                    // âœ… 1. PER-SUBJECT GRADE SUMMARY
                                    
                                    $i = 1;
                                    
                                    $sql_subjects = "
                                    SELECT 
                                        class_id,
                                        exam_id,
                                        identity_sub,
                                        SUM(CASE WHEN grade = 'A' THEN 1 ELSE 0 END) AS grade_A,
                                        SUM(CASE WHEN grade = 'B' THEN 1 ELSE 0 END) AS grade_B,
                                        SUM(CASE WHEN grade = 'C' THEN 1 ELSE 0 END) AS grade_C,
                                        SUM(CASE WHEN grade = 'D' THEN 1 ELSE 0 END) AS grade_D,
                                        SUM(CASE WHEN grade = 'E' THEN 1 ELSE 0 END) AS grade_E,
                                        SUM(CASE WHEN grade = 'S' THEN 1 ELSE 0 END) AS grade_S,
                                        SUM(CASE WHEN grade = 'F' THEN 1 ELSE 0 END) AS grade_F,
                                        COUNT(*) AS total_students,
                                        ROUND(SUM(
                                            CASE grade
                                               WHEN 'A' THEN 5
                                                WHEN 'B' THEN 4
                                                WHEN 'C' THEN 3
                                                WHEN 'D' THEN 2
                                                WHEN 'E' THEN 1
                                                WHEN 'S' THEN 0
                                                WHEN 'F' THEN 0
                                            END
                                        ) / COUNT(*), 2) AS GPA
                                    FROM marks_srms
                                     WHERE class_id = '$class_id'  AND exam_id = '$ex_id'
                                    GROUP BY class_id, exam_id, identity_sub
                                     
                                    ";
                                    
                                    $result_subjects = $conn->query($sql_subjects);
                                    
                                    if ($result_subjects->num_rows > 0) {
                                        echo "<h2>Grade Summary by Subject</h2>";
                                        echo "<table border='1' cellpadding='5'>
                                            <tr>
                                                <th>S/N</th> 
                                                <th>Subject Name</th>
                                                <th>Grade A</th>
                                                <th>Grade B</th>
                                                <th>Grade C</th>
                                                <th>Grade D</th>
                                                <th>Grade E</th>
                                                <th>Grade S</th>
                                                <th>Grade F</th>
                                                <th>Total Students</th>
                                                <th>GPA</th>
                                            </tr>";
                                    
                                        while($row = $result_subjects->fetch_assoc()) {
                                            echo "<tr>
                                                <td>$i</td> 
                                                <td>{$row['identity_sub']}</td>
                                                <td>{$row['grade_A']}</td>
                                                <td>{$row['grade_B']}</td>
                                                <td>{$row['grade_C']}</td>
                                                <td>{$row['grade_D']}</td>
                                                <td>{$row['grade_E']}</td>
                                                <td>{$row['grade_S']}</td>
                                                <td>{$row['grade_F']}</td>
                                                <td>{$row['total_students']}</td>
                                                <td>{$row['GPA']}</td>
                                            </tr>";
                                            $i++;
                                        }
                                        $sql_overall = "
                                        SELECT 
                                        class_id,
                                        exam_id,
                                        ROUND(SUM(
                                            CASE grade
                                               WHEN 'A' THEN 5
                                                WHEN 'B' THEN 4
                                                WHEN 'C' THEN 3
                                                WHEN 'D' THEN 2
                                                WHEN 'E' THEN 1
                                                WHEN 'S' THEN 0
                                                WHEN 'F' THEN 0
                                            END
                                        ) / COUNT(*), 2) AS overall_gpa,
                                        COUNT(*) AS total_grades
                                        FROM marks_srms
                                        WHERE class_id = '$class_id'  AND exam_id = '$ex_id'
                                        GROUP BY class_id, exam_id 
                                        ";
                                        
                                        $result_overall = $conn->query($sql_overall);
                                        
                                        if ($result_overall->num_rows > 0) {
                                             
                                            while($row = $result_overall->fetch_assoc()) {
                                                echo "<tr>
                                                    <td colspan='9'><strong>OVERALL GPA </strong></td> 
                                                    <td><strong>{$row['total_grades']}</strong></td>
                                                    <td><strong>{$row['overall_gpa']}</strong></td>
                                                </tr>";
                                            }
                                        }
                                        echo "</table><br>";
                                    } else {
                                        echo "<p>No subject data found  .</p>";
                                    }
                                    
                                     
                                    ?>
                                </div>
                                </div>
                                </div>
                                </div>
                                </div>
                          <?php   
                                }else{
                                  ?>
                                  <script type="text/javascript">
                                     alert("Sorry! The year selected is not Uploaded");
                                 </script>
                                <?php  
                                }

                              }     
                             ?> 
                             <div class="modal fade" id="Filter">
                              <div class="modal-dialog">
                                <form method="post" action="">
                                    <div class="modal-content">
                                      <div class="modal-header">
                                          <h4 class="modal-title" id="modal_title">Filter Report</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>Year</label>
                                        <div class="select2-purple">
                                                
                                                <select name="year" id="year" class="form-control select2" data-dropdown-css-class="Select a year" style="width: 100%;" required>
                                                    <option value="">Select Year</option>
                                                    <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="2029">2029</option> 
                                                    <option value="2030">2030</option>
                                                </select>
                                              </div>
                                            </div>  
                                         
                                      </div>
                                      <div class="modal-footer"> 
                                          <button type="submit" name="filta" class="btn btn-info">View</button>
                                          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                      </div>
                                    </div>
                                </form>
                              </div>
                           </div><!-- /.modal --> 
                          <div class="modal-footer">  
                           <a href="admin.php?page=fgtutrs345gj789km231ExamUIYTR7ttdeewz34&Id_2=<?php echo $ex_id; ?>" class="btn btn-secondary">BACK</a> 
                         </div>
                       </div> <!-- end card --> 
                      </div>
                       <!-- /.card -->
                     </div>
                     </div>
          

                </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 () {
    //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>