<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">
            <h4 class="m-0">Manage Staff Members</h4>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item">Dashboard</li>
              <li class="breadcrumb-item active">Staff Members</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
                //include('../include/config.php');
                $result = mysqli_query($con,"SELECT * FROM Staffs where Status='Active'");
                $num_rows1 = mysqli_num_rows($result);
                {
                 $sts=htmlentities($num_rows1); 
                }
                ?>
                                  
              <div class="info-box-content">
                <span class="info-box-text">All Staffs</span>
                <h4 class="info-box-number budge"><?php echo $sts; ?></h4>
              </div>
            </div>
            <!-- /.info-box -->
          </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 Staffs where Status='Active' AND Position='Teacher'");
                $num_rows1 = mysqli_num_rows($result);
                {
                 $tea=htmlentities($num_rows1); 
                }
                ?>
              <div class="info-box-content">
                <span class="info-box-text">Teachers</span>
                <span class="info-box-number"><?php echo $tea; ?></span>
              </div>
              <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
          </div>
          
          <div class="col-md-3 col-sm-6 col-12">
            <div class="info-box">
              <span class="info-box-icon bg-warning"><i class="far fa-copy"></i>
              </span>

                <?php
                //include('../include/config.php');
                $result = mysqli_query($con,"SELECT * FROM Staffs where Status='Active' AND Position='Non-Teaching Staff'");
                $num_rows1 = mysqli_num_rows($result);
                {
                 $non=htmlentities($num_rows1); 
                }
                ?>
              <div class="info-box-content">
                <span class="info-box-text">Non Teaching Staffs</span>
                <span class="info-box-number"><?php echo $non; ?></span>
              </div>
              <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
          </div>
        
          </div>
         </div>
    </section>
          
    
    
    <section class="content">
        <div class="row">
        <div class="col-md-3">
         <form method="POST" action="" id="" enctype="multipart/form-data" novalidate onsubmit="return false;">
      <div class="row">
        <div class="col-md-12">
          <div class="card card-primary">
            <div class="card-header">
              <h3 class="card-title">Add New Staffs</h3>

              <div class="card-tools">
                <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                  <i class="fas fa-minus"></i>
                </button>
              </div>
            </div>
            <div class="card-body">
              <div class="form-group">
                <label for="inputName">Staff Name <span class="text-danger">*</span></label>
                <input type="text" id="sname" class="form-control" required>
              </div>
              <div class="form-group">
                <label for="inputDescription">ID No</label>
                <input type="text" id="sid" class="form-control" required>
              </div>
              
              <div class="form-group">
                <label for="inputProjectLeader">Email</label>
                <input type="email" id="email" class="form-control" />
              </div>
              <div class="form-group">
                <label for="inputStatus">Gender <span class="text-danger">*</span></label>
                <select id="sgender" class="form-control custom-select" required>
                  <option selected disabled value="">Select ---</option>
                  <option value="Male">Male</option>
                  <option value="Female">Female</option>
                </select>
              </div>
              <div class="form-group">
                <label for="inputClientCompany">Contact </label>
                <input type="text" id="sconta" class="form-control" required>
              </div>
              
                 <div class="form-group">
                <label for="inputStatus">Category <span class="text-danger">*</span></label>
                <select id="cat" class="form-control custom-select" required>
                  <option selected disabled value="">Select ---</option>
                  <option value="Teacher">Teacher</option>
                  <option value="Non-teaching Staff">Non-teaching Staff</option>Subordinate Staff
                  <option value="Subordinate Staff">Subordinate Staff</option>
                  <option value="School Director"  title="Not counted as one of the staffs">School Director</option>
                  <option value="System User" title="Not counted as one of the staffs">System User</option>
                </select>
              </div>
              
              <div class="form-group">
                <label for="inputProjectLeader">Nature of Work <span class="text-danger">*</span></label>
                <input type="text" id="txtnaturee" class="form-control">
              </div>
                
              <div class="form-group">
                <label for="inputProjectLeader">Date of Employement</label>
                <input type="date" id="edat" class="form-control">
              </div>
              <div class="form-group">
                <label for="inputProjectLeader">NHIF No</label>
                <input type="text" id="txtnhiff" class="form-control">
              </div>
              
               <div class="form-group">
                <label for="inputProjectLeader">NSSF No</label>
                <input type="text" id="txtnssff" class="form-control">
              </div>
          
              <div class="form-group">
                <label for="inputProjectLeader">Subjects Teaching</label>
                <textarea id="subs" class="form-control"> </textarea>
              </div>
              
              <div class="form-group">
                  <center><label id="feedback1"></label></center>
              </div>
              
                <div class="form-group">
                    <button class="btn btn-primary pull-right" id="savesataffs">Submit <i class="fa fa-paper-plane"></i></button>
               </div>
              
            </div>
            <!-- /.card-body -->
          </div>
          <!-- /.card -->
        </div>
      </div>
        </form>
    </div>
        
        <div class="col-md-9">
          <div class="card ">
            <div class="card-header">
              <!--h3 class="card-title">Registered Staffs</h3-->

              <div class="card-tools">
                <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
                  <i class="fas fa-minus"></i>
                </button>
              </div>
              
              <div class="card-body">
                <div class="table-responsive" id='divstaffss'>
                <div class="col-md-6"> 
                   <div class="container">
                      <form action="" method="POST" onsubmit="return false">
                       <div class="form-group">
                        <label id="otherincomemsg" style="color:">Filter By Staffs' Category</label> 
                        <select id="selectcategory" class="form-control custom-select" required>
                        <option selected disabled value="">Select ---</option>
                         <option value="All">All Staffs</option>
                        <option value="Teacher">Teacher</option>
                        <option value="Non-teaching Staff">Non-teaching Staff</option>Subordinate Staff
                        <option value="Subordinate Staff">Subordinate Staff</option>
                        <option value="School Director"  title="Not counted as one of the staffs">School Director</option>
                        </select>
                     </div>
                      </form>
                   </div>
                  </div>    
                    <?php
                    $catt='';
                    $cattt='';
                    if(isset($_GET["Cat"]))
                    {
                    $catt=$_GET["Cat"];
                    if($catt=='' || $catt==null)
                    {
                    $catt='all';
                    }else if($catt=='All')
                    {
                       $cattt='All School Staffs'; 
                    }else
                    {
                       $cattt=$catt; 
                    }
                  }
                    ?>
                  
                 <table class="table table-hover  table-sm" id="tablestaffsss">
                     <thead>
                         <tr class="alert-success">
                             <th colspan="7">
                                 CATEGORY: <?php echo strtoupper($cattt); ?>
                             </th>
                         </tr>
                         <tr>
                             <th>#</th>
                             <th>Name</th>
                             <th>Nature of Work</th>
                             <th>ID No</th>
                             <th>Contact</th>
                             <th>Email</th>
                             <th>Action</th>
                         </tr>
                     </thead>
                     <tbody>
                        <?php
                       if(isset($_GET["Cat"]))
                    {
                       if($catt=='All')
                       {
                        $query=mysqli_query($con,"select * from Staffs ORDER BY Status ASC, PRNo");
                       }else
                       {
                       $query=mysqli_query($con,"select * from Staffs WHERE Position='$catt' ORDER BY PRNo ASC");   
                       }
                    }else
                    {
                        $query=mysqli_query($con,"select * from Staffs ORDER BY Status ASC, PRNo");
                    }
                        $cnt=1;
                        while($row=mysqli_fetch_array($query))
                        {
                        $pos=$row["Specia"];
                        $staa=$row["Status"];
                        if($pos=='1')
                        {
                          ?> 
                          <tr class="">
                			<td><?php echo $cnt ?></td>
                			<?php
                			if($staa=='Inactive')
                			{?>
                			<td class="alert-warning"><?php echo $row["Name"]; ?></td>
                			<?php
                			}else
                			{
                			?>
                			<td><?php echo $row["Name"]; ?></td>
                			<?php
                			}
                			?>
                			<td><?php echo $row["Nature"]; ?></td>
                			<td><?php echo $row["IDNo"]; ?></td>
                			<td><?php echo $row["Phone"]; ?></td>
                			<td><?php echo $row["Email"]; ?></td>
                			<td>
                			    <input type="hidden" value="<?php echo $row["id"]; ?>" class="stafidd" />
                			    <i class="fa fa-edit text-green btn bstaffedit" id="bstaffedit"></i> | <i class="fa fa-trash btn text-danger btnstafdelete" id="btnstafdelete" title="Click to remove this employe"></i>
                			</td>
                		</tr>
                         <?php   
                        }else
                        {
                        ?>
                		<tr>
                			<td><?php echo $cnt; ?></td>
                			<?php
                			if($staa=='Inactive')
                			{
                			?>
                			<td class="" title="In-active staff"><?php echo $row["Name"]; ?></td>
                			<?php
                			}else
                			{
                			 ?> 
                			 <td><?php echo $row["Name"]; ?></td>
                			<?php
                			}
                			?>
                			<td><?php echo $row["Nature"]; ?></td>
                			<td><?php echo $row["IDNo"]; ?></td>
                			<td><?php echo $row["Phone"]; ?></td>
                			<td><?php echo $row["Email"]; ?></td>
                			<td>
                			    <input type="hidden" value="<?php echo $row["id"]; ?>" class="stafidd" />
                			    <i class="fa fa-edit text-green btn bstaffedit" id="bstaffedit"></i> | <i class="fa fa-trash btn text-danger btnstafdelete" id="btnstafdelete" title="Click to remove this employe"></i>
                			</td>
                		</tr>
                    <?php
                    $cnt=$cnt+1;
                	}
                        }
                	?>
                     </tbody>
                 </table> 
              </div>
              </div>
            </div>
            </div>
          </div>
    </div>
    </section>
</div>

