<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h2 class="m-0">Dashboard</h2>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item active">Dashboard</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    
    <section class="content">
      <div class="container-fluid">
        <!-- Small boxes (Stat box) -->
        <div class="row">
          <div class="col-lg-3 col-6">
            <!-- small box -->
            <div class="small-box bg-info">
              <div class="inner">
                <?php
                //include('../include/config.php');
                $result = mysqli_query($con,"SELECT * FROM Staffs where Status='Active'");
                $num_rows1 = mysqli_num_rows($result);
                {
                 $sts=htmlentities($num_rows1); 
                }
                ?>
                <h3><?php echo $sts;  ?></h3>
                <p>All Staffs</p>
              </div>
              <div class="icon">
                <i class="ion ion-bag"></i>
              </div>
              <a href="index.php?page=Staffs" class="small-box-footer">View  <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
            <div class="small-box bg-info">
              <div class="inner">
                <?php
                $result = mysqli_query($con,"SELECT * FROM pupils where Status='Active'");
                $num_rows1 = mysqli_num_rows($result);
                {
                 $pps=htmlentities($num_rows1); 
                }
                ?>
                <h3>
                    <?php echo $pps; ?><!--sup style="font-size: 20px"></sup-->
                </h3>
                
                <p>Active Learners</p>
              </div>
              <div class="icon">
                <i class="ion ion-stats-bars"></i>
              </div>
              <a href="Pupils.php?page=Manage" class="small-box-footer">View Pupils <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
            <!-- small box -->
              <?php
                $result = mysqli_query($con,"SELECT * FROM users");
                $num_rows1 = mysqli_num_rows($result);
                {
                 $tot=htmlentities($num_rows1); 
                }
                ?>
            <div class="small-box bg-info">
              <div class="inner">
                <h3><?php echo $tot; ?></h3>

                <p>System Users</p>
              </div>
              <div class="icon">
                <i class="ion ion-person-add"></i>
              </div>
              <a href="index.php?page=users" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          <div class="col-lg-3 col-6">
               <?php
                $result = mysqli_query($con,"SELECT * FROM projects where Status='Ongoing'");
                $num_rows1 = mysqli_num_rows($result);
                {
                 $tota=htmlentities($num_rows1); 
                }
                ?>
            <!-- small box -->
            <div class="small-box bg-info">
              <div class="inner">
                <h3><?php echo $tota; ?></h3>
                <p>Ongoing Projects</p>
              </div>
              <div class="icon">
                <i class="ion ion-pie-graph"></i>
              </div>
              <a href="Expenditure.php?page=Projects" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
        </div>
        <!-- /.row -->
        <!-- Main row -->
        <div class="row">
          <!-- Left col -->
          <section class="col-lg-7 connectedSortable">
             <?php
                        $poss='';
                        $sqll = "select * FROM Staffs where id='$idauto'";
                        $result = $con->query($sqll);
                        while($row = $result->fetch_assoc()) 
                        {
                        $poss=$row["Position"]; 
                        }
                  if($poss=='Teacher')
                  {
                   ?>
                 <div class="card-body">
              <h4>Registered exams</h4>
              <table class="table table-hover table-success" id="tableexams">
                     <thead>
                         <tr>
                             <th>#</th>
                             <th>Exam Title</th>
                             <th>Exam Period</th>
                             <th>Start Date</th>
                             <th>End Date</th>
                         </tr>
                     </thead>
                     <tbody>
                        <?php
                        $query=mysqli_query($con,"select * from Exam ORDER BY id DESC");
                        $cnt=1;
                        while($row=mysqli_fetch_array($query))
                        {
                          ?>  
                          <tr class="alert-warning">
                			<td><?php echo $cnt; ?></td>
                			<td><strong><?php echo $row["Title"]; ?></strong></td>
                			<td><?php echo $row["Period"]; ?></td>
                			<td><?php echo $row["StartDate"]; ?></td>
                			<td><?php echo $row["EndDate"]; ?></td>
                		</tr>
                         <?php 
                         $cnt=$cnt+1;
                        }
                	?>
                     </tbody>
                 </table>
            </div>  
                   
                   <?php
                  }else
                  {
                  ?>
                <div class="card">
              <div class="card-header">
                <h3 class="card-title">
                  <i class="fas fa-chart-pie mr-1"></i>
                  Enrolment
                </h3>
                <div class="card-tools">
                  <ul class="nav nav-pills ml-auto">
                    <li class="nav-item">
                        <span class="badge bg-danger">Active Leaners ONLY</span>
                    </li>
                  </ul>
                </div>
              </div><!-- /.card-header -->
              <div class="card-body">
                <div class="tab-content p-0">
                  <!-- Morris chart - Sales -->
                <div class="table-responsive">
                    <table class="table table-bordered" id="tableenrollment" style="font-size:11px">
                     <thead>
                         <tr class="bg-danger">
                             <th>#</th>
                             <th>Class</th>
                             <th>Boys</th>
                             <th>Girls</th>
                             <th>Total</th>
                         </tr>
                     </thead>
                     <tbody>
                            
                            <?php
                            $result = mysqli_query($con,"SELECT pupils.Claz,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 1' AND Status='Active') as sam1,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 1' AND Status='Active' AND Gender='Male' ) as boyz1,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 1' AND Status='Active' AND Gender='Female' ) as galz1,
                            
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 2' AND Status='Active') as sam2,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 2' AND Status='Active' AND Gender='Male' ) as boyz2,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 2' AND Status='Active' AND Gender='Female' ) as galz2,
                            
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 3' AND Status='Active') as sam3,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 3' AND Status='Active' AND Gender='Male' ) as boyz3,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 3' AND Status='Active' AND Gender='Female' ) as galz3,
                            
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 4' AND Status='Active') as sam4,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 4' AND Status='Active' AND Gender='Male' ) as boyz4,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 4' AND Status='Active' AND Gender='Female' ) as galz4,
                            
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 5' AND Status='Active') as sam5,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 5' AND Status='Active' AND Gender='Male' ) as boyz5,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 5' AND Status='Active' AND Gender='Female' ) as galz5,
                            
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 6' AND Status='Active') as sam6,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 6' AND Status='Active' AND Gender='Male' ) as boyz6,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 6' AND Status='Active' AND Gender='Female' ) as galz6,
                            
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 7' AND Status='Active') as sam7,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 7' AND Status='Active' AND Gender='Male' ) as boyz7,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 7' AND Status='Active' AND Gender='Female' ) as galz7,
                            
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 8' AND Status='Active') as sam8,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 8' AND Status='Active' AND Gender='Male' ) as boyz8,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 8' AND Status='Active' AND Gender='Female' ) as galz8,
                            
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 9' AND Status='Active') as sam9,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 9' AND Status='Active' AND Gender='Male' ) as boyz9,
                            (SELECT SUM(CNT) FROM pupils where Claz='GRADE 9' AND Status='Active' AND Gender='Female' ) as galz9,
                            
                            (SELECT SUM(CNT) FROM pupils where Claz='PP1' AND Status='Active') as sampp1,
                            (SELECT SUM(CNT) FROM pupils where Claz='PP1' AND Status='Active' AND Gender='Male' ) as ppboyz1,
                            (SELECT SUM(CNT) FROM pupils where Claz='PP1' AND Status='Active' AND Gender='Female' ) as ppgalz1,
                            
                            (SELECT SUM(CNT) FROM pupils where Claz='PP2' AND Status='Active') as sampp2,
                            (SELECT SUM(CNT) FROM pupils where Claz='PP2' AND Status='Active' AND Gender='Male' ) as ppboyz2,
                            (SELECT SUM(CNT) FROM pupils where Claz='PP2' AND Status='Active' AND Gender='Female' ) as ppgalz2,
                            
                            (SELECT SUM(CNT) FROM pupils where Claz='BABY CLASS' AND Status='Active') as BB1,
                            (SELECT SUM(CNT) FROM pupils where Claz='BABY CLASS' AND Status='Active' AND Gender='Male' ) as BOYZBB,
                            (SELECT SUM(CNT) FROM pupils where Claz='BABY CLASS' AND Status='Active' AND Gender='Female' ) as GALZBB,
                            
                            
                            (SELECT SUM(CNT) FROM pupils where Status='Active') as sam,
                            (SELECT SUM(CNT) FROM pupils where Status='Active' AND Gender='Male' ) as boyz,
                            (SELECT SUM(CNT) FROM pupils where Status='Active' AND Gender='Female' ) as galz,
                            
                            (SELECT SUM(CNT) FROM pupils where Status='Active' AND Boarder='Boarder' ) as bod,
                            (SELECT SUM(CNT) FROM pupils where Status='Active' AND Boarder='Day Scholar' ) as dsco
                            
                            FROM pupils");
                            while($row = $result->fetch_assoc()) 
                            {
                                
                                $bod=$row["bod"];
                                $dsco=$row["dsco"];
                                
                                $tbb=$row["BB1"]; 
                                $bbb=$row["BOYZBB"];
                                $gbb=$row["GALZBB"];
                                
                                
                                $pptot1=$row["sampp1"]; 
                                $ppboyz1=$row["ppboyz1"];
                                $ppfem1=$row["ppgalz1"];
                                
                                $pptot2=$row["sampp2"]; 
                                $ppboyz2=$row["ppboyz2"];
                                $ppfem2=$row["ppgalz2"];
                                
                                $tot1=$row["sam1"]; 
                                $boyz1=$row["boyz1"];
                                $fem1=$row["galz1"];
                                
                                $tot2=$row["sam2"]; 
                                $boyz2=$row["boyz2"];
                                $fem2=$row["galz2"];
                                
                                $tot3=$row["sam3"]; 
                                $boyz3=$row["boyz3"];
                                $fem3=$row["galz3"];
                                
                                $tot4=$row["sam4"]; 
                                $boyz4=$row["boyz4"];
                                $fem4=$row["galz4"];
                                
                                $tot5=$row["sam5"]; 
                                $boyz5=$row["boyz5"];
                                $fem5=$row["galz5"];
                                
                                $tot6=$row["sam6"]; 
                                $boyz6=$row["boyz6"];
                                $fem6=$row["galz6"];
                                
                                $tot7=$row["sam7"]; 
                                $boyz7=$row["boyz7"];
                                $fem7=$row["galz7"];
                                
                                $tot8=$row["sam8"]; 
                                $boyz8=$row["boyz8"];
                                $fem8=$row["galz8"];
                                
                                $tot9=$row["sam9"]; 
                                $boyz9=$row["boyz9"];
                                $fem9=$row["galz9"];
                                
                                $sam=$row["sam"]; 
                                $boyz=$row["boyz"];
                                $fem=$row["galz"];
                            }
                            ?>
                            <tr>
                            <td>1</td>
                            <td>BABY CLASS</td>
                            <td><?php echo $bbb; ?></td>
                            <td><?php echo $gbb; ?></td>
                            <td><?php echo $tbb; ?></td> 
                            </tr>
                            
                            <tr>
                            <td>2</td>
                            <td>PP1</td>
                            <td><?php echo $ppboyz1; ?></td>
                            <td><?php echo $ppfem1; ?></td>
                            <td><?php echo $pptot1; ?></td> 
                            </tr>
                            
                            <tr>
                            <td>3</td>
                            <td>PP2</td>
                            <td><?php echo $ppboyz2; ?></td>
                            <td><?php echo $ppfem2; ?></td>
                            <td><?php echo $pptot2; ?></td> 
                            </tr>
                            
                            <tr>
                            <td>4</td>
                            <td>GRADE 1</td>
                            <td><?php echo $boyz1; ?></td>
                            <td><?php echo $fem1; ?></td>
                            <td><?php echo $tot1; ?></td>
                            </tr>

                            <tr>
                            <td>5</td>
                            <td>GRADE 2</td>
                            <td><?php echo $boyz2; ?></td>
                            <td><?php echo $fem2; ?></td>
                            <td><?php echo $tot2; ?></td>
                            </tr>
                            
                             <tr>
                            <td>6</td>
                            <td>GRADE 3</td>
                            <td><?php echo $boyz3; ?></td>
                            <td><?php echo $fem3; ?></td>
                            <td><?php echo $tot3; ?></td>
                            </tr>
          
                              <tr>
                            <td>7</td>
                            <td>GRADE 4</td>
                            <td><?php echo $boyz4; ?></td>
                            <td><?php echo $fem4; ?></td>
                            <td><?php echo $tot4; ?></td>
                            </tr>
                 
                             <tr>
                            <td>8</td>
                            <td>GRADE 5</td>
                            <td><?php echo $boyz5; ?></td>
                            <td><?php echo $fem5; ?></td>
                            <td><?php echo $tot5; ?></td>
                            </tr>
     
                            <tr>
                            <td>9</td>
                            <td>GRADE 6</td>
                            <td><?php echo $boyz6; ?></td>
                            <td><?php echo $fem6; ?></td>
                            <td><?php echo $tot6; ?></td>
                            </tr>
                            
                            <tr>
                            <td>10</td>
                            <td>GRADE 7</td>
                            <td><?php echo $boyz7; ?></td>
                            <td><?php echo $fem7; ?></td>
                            <td><?php echo $tot7; ?></td>
                            </tr>

                             <tr>
                            <td>11</td>
                            <td>GRADE 8</td>
                           <td><?php echo $boyz8; ?></td>
                            <td><?php echo $fem8; ?></td>
                            <td><?php echo $tot8; ?></td>
                            </tr>
                            
                             <tr>
                            <td>12</td>
                            <td>GRADE 9</td>
                           <td><?php echo $boyz9; ?></td>
                            <td><?php echo $fem9; ?></td>
                            <td><?php echo $tot9; ?></td>
                            </tr>
                            
                            <tr class="alert-success">
                            <td colspan="2">TOTAL</td>
                            <td><?php echo $boyz; ?></td>
                            <td><?php echo $fem; ?></td>
                            <td class="alert-danger" ><strong><?php echo $sam; ?></strong></td>
                            </tr>
                    
                     </tbody>
                 </table> 
                 <hr />
                 <table class="table table-success">
                     <tr>
                         <td>DAY SCHOLARS</td> <td><span class="badge bg-info"><?php echo $dsco; ?></span></td>
                     </tr>
                     <tr>
                         <td>BOARDERS</td> <td><span class="badge bg-info"><?php echo $bod; ?></span></td>
                     </tr>
                 </table>
                  </div>
              
                </div>
              </div><!-- /.card-body -->
            </div>
        
            <!-- /.card -->
                <?php
                  }
                  ?>
            <!-- /.card -->
          </section>
          <section class="col-lg-5 connectedSortable">
            <div class="card">
              <div class="card-header border-0">
                <h3 class="card-title">
                  <i class="fas fa-graph mr-1"></i>
                  Learners Distribution
                </h3>
                <!-- card tools -->
                <div class="card-tools">
                  <button type="button" class="btn btn-primary btn-sm daterange" title="Date range">
                    <i class="far fa-calendar-alt"></i>
                  </button>
                  <button type="button" class="btn btn-primary btn-sm" data-card-widget="collapse" title="Collapse">
                    <i class="fas fa-minus"></i>
                  </button>
                </div>
                <!-- /.card-tools -->
              </div>
              <div class="card-body">
                <div class="chart-container pie-chart">
                <canvas id="pie_chartt"></canvas>
                </div>
              </div>
            </div>
            
            <div class="card">
              <div class="card-header border-0">
                <h3 class="card-title">
                  <i class="far fa-calendar-alt"></i>
                  School's of Events
                </h3>
                <!-- tools card -->
                <div class="card-tools">
                  <button with a dropdown >
                
                  <button type="button" class="btn btn-sm" data-card-widget="collapse">
                    <i class="fas fa-minus"></i>
                  </button>
                  <button type="button" class="btn btn-sm" data-card-widget="remove">
                    <i class="fas fa-times"></i>
                  </button>
                </div>
                <!-- /. tools -->
              </div>
              <!-- /.card-header -->
              <div class="card-body pt-0">
                <!--The calendar -->
				 <div id="calendar" style="font-family: Apple Chancery, cursive;font-size:12px">
				 </div>
              </div>
            </div>
            <!-- /.card -->
          </section>
          <!-- right col -->
        </div>
        <!-- /.row (main row) -->
      </div><!-- /.container-fluid -->
    </section>
    
        <section class="content" style="text-decoration:none;font-weight:normal;font-family:Times;font-size:12px">
           <div class="row">
             <div class="table-responsive" id="">
                 
         <div class="modal fade" tabindex="-1" data-bs-backdrop="static" id="event-details-modal">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content rounded-0">
                <div class="modal-header rounded-0">
                    <h4 class="modal-title">Schedule Details</h4>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body rounded-0">
                    <div class="container-fluid" style="font-size:14px">
                        <dl>
                            <dt class="text-muted">Title</dt>
                            <dd id="title" class="fw-bold fs-4" style="color:red"></dd>
                            <dt class="text-muted">Description</dt>
                            <dd id="description" class=""></dd>
                            <dt class="text-muted">Start</dt>
                            <dd id="start" class=""></dd>
                            <dt class="text-muted">End</dt>
                            <dd id="end" class=""></dd>
                        </dl>
                    </div>
                </div>
           
            </div>
        </div>
    </div> 
              </div>
            </div>
    </section>
</div>