<?php
$gr='';
if(isset($_GET['Grad']))
{
$grade=$_GET['Grad'];
if($grade=='' || $grade==null)
{
    $gr='';
}else
{
    $gr=$grade;
}
}
?>
<div class="content-wrapper">
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h4 class="m-0">Pupils Enrollment</h4>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item">Dashboard</li>
              <li class="breadcrumb-item ">Pupils</li>
              <li class="breadcrumb-item active">Enrollment</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-3 col-sm-6 col-12">
            <div class="info-box">
              <span class="info-box-icon bg-info"><i class="far fa-envelope"></i></span>
              <?php
                    $result = mysqli_query($con,"SELECT * FROM pupils WHERE Status='Active' AND Claz !='CLASS 8'");
                    $num_rows1 = mysqli_num_rows($result);
                    {
                    $sts=htmlentities($num_rows1); 
                    }
                ?>
              <div class="info-box-content">
                <span class="info-box-text">Registered Pupils</span>
                <h4 class="info-box-number budge"><?php echo $sts; ?></h4>
              </div>
            </div>
          </div>
          
          <div class="col-md-3 col-sm-6 col-12">
            <div class="info-box">
              <span class="info-box-icon bg-success"><i class="far fa-flag"></i></span>
              <?php
               // include('../include/config.php');
                $result = mysqli_query($con,"SELECT * FROM pupils where Claz='Class 8'");
                $num_rows1 = mysqli_num_rows($result);
                {
                   $clas8=htmlentities($num_rows1); 
                }
                ?>
              <div class="info-box-content">
                <span class="info-box-text">Class 8 Pupils</span>
                <span class="info-box-number"><?php echo $clas8; ?></span>
              </div>
              <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
          </div>
          
          <div class="col-md-6 col-sm-6 col-12">
            <div class="info-box">
              <span class="info-box-icon bg-success"><i class="far fa-flag"></i></span>
             
              <div class="info-box-content">
                 <div class="form-group">
                <label for="inputStatus">Filter by Class <span class="requireds">*</span></label>
                 <select id="changeclass" class="form-control custom-select" required>
                     <?php
                    if($gr=='')
                    {
                    }
                    else
                    {
                    ?>
                    <option value="<?php echo $gr; ?>"><?php echo $gr; ?></option>
                    <?php
                    }
                    
                    ?>
                  <option value="">Select ---</option>
                  <option value="BABY CLASS">BABY CLASS</option>
                  <option value="PP1">PP1</option>
                  <option value="PP2">PP2</option>
                  <option value="GRADE 1">GRADE 1</option>
                  <option value="GRADE 2">GRADE 2</option>
                  <option value="GRADE 3">GRADE 3</option>
                  <option value="GRADE 4">GRADE 4</option>
                  <option value="GRADE 5">GRADE 5</option>
                  <option value="GRADE 6">GRADE 6</option>
                  <option value="GRADE 7">GRADE 7</option>
                  <option value="GRADE 8">GRADE 8</option>
                  <option value="GRADE 9">GRADE 9</option>
                  <option value="CLASS 8">CLASS 8</option>
                </select>
              </div> 
                
              </div>
              <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
          </div>
          
          </div>
         </div>
    </section>
          <?php
               $result = mysqli_query($con,"SELECT * FROM pupils where Claz='$gr' AND Status='Active'");
                $num_rows1 = mysqli_num_rows($result);
                {
                   $samu=htmlentities($num_rows1); 
                } 
          
          ?>
    
    <section class="content">
      <div class="row"> 
      <div class="col-md-8 col-sm-8 col-12">
          
          <h5>Total Pupils number of pupils: <strong class="text-warning"><u><?php echo $samu; ?></u></strong></h5> 
          <hr />
      <div class="table-responsive" id="tableresponsiveee">
                 <table class="table table-bordered tabledatas" id="tablepupilss">
                     <thead>
                         <tr>
                             <th>#</th>
                             <th>Name</th>
                             <th>Adm No</th>
                             <th>Class</th>
                             <th>Category</th>
                             <th>Parent Contact</th>
                         </tr>
                     </thead>
                     <tbody>
                            <?php
                            $sql = "SELECT * FROM  pupils where Claz='$gr' AND Status='Active' ORDER BY Names ASC";
                            $result = $con->query($sql);
                            if ($result->num_rows > 0) {
                                $cnt=1;
                            while($row = $result->fetch_assoc()) {
                            ?>
                            <tr>
                            <td><?php echo $cnt; ?></td>
                            <td><?php echo $row["Names"].' '.$row["Sirname"]; ?></td>
                            <td><?php echo $row["AdmNo"]; ?></td>
                            <td><?php echo $row["Claz"]; ?></td>
                            <td><?php echo $row["Boarder"]; ?></td>
                            <td><?php echo $row["Contact"]; ?></td>
                            </tr>
                            <?php
                            $cnt=$cnt+1;
                            }
                        }else
                        {
                            echo 'No records found';
                        }
                            ?>
                     </tbody>
                 </table> 
              </div>
      </div>
      <div class="col-md-4 col-sm-4 col-12 alert-warning">
           <h5>Summary of all classes <strong class="text-warning"><u><?php echo $samu; ?></u></strong></h5> 
         <div class="table-responsive" id="divenrollment">
                 <table class="table table-bordered tabledatas" id="tableenrollment" style="font-size:11px">
                     <thead>
                         <tr>
                             <th>#</th>
                             <th>Class</th>
                             <th>Boys</th>
                             <th>Girls</th>
                             <th>Total</th>
                         </tr>
                     </thead>
                     <tbody>
                         
                         
                          <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='BABY CLASS' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='BABY CLASS' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='BABY CLASS' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                           
                            ?>
                            <td>1</td>
                            <td>BABAY CLASS</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>
                            
                            
                            <!--PP1 -->
                             <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='PP1' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='PP1' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='PP1' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                           
                            ?>
                            <td>2</td>
                            <td>PP1</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>
                            
                            <!-- pp2 -->
                            <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='PP2' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='PP2' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='PP2' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                           
                            ?>
                            <td>3</td>
                            <td>PP2</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>
                            
                            <!--GRADE 1 -->
                            <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 1' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 1' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 1' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                           
                            ?>
                            <td>4</td>
                            <td>GRADE 1</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>
                            
                            <!--GRADE 2 -->
                             <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 2' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 2' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 2' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                           
                            ?>
                            <td>5</td>
                            <td>GRADE 2</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>
                            
                            <!-- GRADE 3 -->
                              <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 3' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 3' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 3' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                           
                            ?>
                            <td>6</td>
                            <td>GRADE 3</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>
                            
                          <!-- GRADE 4-->
                              <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 4' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 4' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 4' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
        
                            ?>
                            <td>7</td>
                            <td>GRADE 4</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>
                            
                            <!-- GRADE 5 -->
                            
                              <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 5' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 5' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 5' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                           
                            ?>
                            <td>8</td>
                            <td>GRADE 5</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>
                            
                            <!--GRADE 6 -->
                            <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 6' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 6' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 6' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                           
                            ?>
                            <td>9</td>
                            <td>GRADE 6</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>
                            
                            <!--GRADE 7 -->
                            <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 7' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 7' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 7' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                           
                            ?>
                            <td>10</td>
                            <td>GRADE 7</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>
                            
                            <!-- CLASS 8 --->
                            
                             <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 8' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 8' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 8' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                           
                            ?>
                            <td>11</td>
                            <td>GRADE 8</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>
                            
                             <tr>
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 9' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $baba=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 9' AND Gender='Male' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Claz='GRADE 9' AND Gender='Female' AND Status='Active'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                           
                            ?>
                            <td>12</td>
                            <td>GRADE 9</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td><?php echo $baba; ?></td>
                            </tr>

                             <tr class="alert-success">
                            <?php
                            $result = mysqli_query($con,"SELECT * FROM pupils WHERE Status='Active' AND Claz !='CLASS 8'");
                            $num_rows1 = mysqli_num_rows($result);
                            {
                            $tot=htmlentities($num_rows1); 
                            }
                            
                            $resultt = mysqli_query($con,"SELECT * FROM pupils where Gender='Male' AND Status='Active' AND Claz !='CLASS 8'");
                            $num_rows1 = mysqli_num_rows($resultt);
                            {
                            $boyz=htmlentities($num_rows1); 
                            }
                            
                            $resulttt = mysqli_query($con,"SELECT * FROM pupils where Gender='Female' AND Status='Active' AND Claz !='CLASS 8'");
                            $num_rows1 = mysqli_num_rows($resulttt);
                            {
                            $fem=htmlentities($num_rows1); 
                            }
                            ?>
                            <td colspan="2">TOTAL</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td class="alert-warning" ><strong><?php echo $tot; ?></strong></td>
                            </tr>
                    
                     </tbody>
                 </table> 
              </div>
           </div>   
     </div>  
    </section>
</div>

