<?php
  function createRandomPassword()
 {
	$chars = "003232303232023232023456789";
	srand((double)microtime()*1000000);
	$i = 0;
	$pass = '' ;
	while ($i <= 7) {

		$num = rand() % 33;
		$tmp = substr($chars, $num, 1);
		$pass = $pass . $tmp;
		$i++;
	}
	return $pass;
}

$sess=createRandomPassword();
?>

<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">Add selected learners to a fee period</h4>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item">Dashboard</li>
              <li class="breadcrumb-item">Extra</li>
              <li class="breadcrumb-item active">Bulk Fee Update</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-md-4 col-sm-6 col-12">
            <div class="info-box">
              <span class="info-box-icon bg-success"><i class="fa fa-paper-plane"></i></span>
              <?php
                include('../include/config.php');
                $result = mysqli_query($con,"SELECT * FROM emails where ESent='Yes'");
                $num_rows1 = mysqli_num_rows($result);
                {
                 $sent=htmlentities($num_rows1); 
                }
                ?>
              <div class="info-box-content">
                <span class="info-box-text">Selected Students</span>
                <span class="info-box-number"><?php ; ?></span>
              </div>
              <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
          </div>
          </div>
         </div>
    </section>
          
    
    
    <section class="content">
    <div class="row">
 
        <div class="col-md-7">
          <div class="card ">
            <div class="card-header">
                <div class="card-body">
                <div class="table-responsive" id=''>
                 <h5 class="alert-danger"><center>Select learners to add</center></h5>
                 <table class="table table-hover " id="selectedpupils" style="font-size:12px">
                     <thead>
                    <tr class="">
                        <th colspan=""></th>
                        <th colspan=""></th>
                        <th colspan="2">
                        </th>
                        <th colspan="2"><label class="text-orange"> Select/Unselect All </label>  <input type="checkbox" class="pull-right" id="selectAll" /></th>
                    </tr>
                         <tr>
                             <th>#</th>
                             <th>Name</th>
                             <th>Adm No</th>
                             <th>School Level</th>
                             <th>Parent Contact</th>
                             <th>Action</th>
                         </tr>
                     </thead>
                     <tbody>
                        <?php
                        $query=mysqli_query($con,"select * from pupils where Status='Active'");
                        //$query=mysqli_query($con,"select * from Staffs where Status='Active' AND Email !='' AND id !='1' AND Name !='Teachers-Default' ORDER BY PRNo ASC");
                        $cnt=1;
                        while($row=mysqli_fetch_array($query))
                        {
                          ?>  
                          <tr class="row-select">
                			<td><?php echo $cnt; ?></td>
                			<td><?php echo $row["Names"]; ?></td>
                			<td><?php echo $row["AdmNo"]; ?></td>
                			<td><?php echo $row["Claz"]; ?></td>
                			<td><?php echo $row["Contact"]; ?></td>
                			<td>
                			  <input type="hidden" class="staffsid" value="<?php echo $row["count"]; ?>" />
                			  <input type="checkbox" name='checkbox[$rowid]' value="<?php echo $row["id"]; ?>">
                			</td>
                		</tr>
                         <?php  
                         $cnt=$cnt+1;
                        }
                    	?>
                     </tbody>
                 </table> 
                  
              </div>
              </div>
            </div>
            </div>
          </div> 
          
            <div class="col-md-5">
     <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">Select Period</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">Class <span class="text-danger">*</span></label>
               <select id="cclas" class="form-control custom-select" required>
                  <option selected value="">---</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 class="form-group">
                <label for="inputDescription">Year <span class="text-danger">*</span></label>
                <input type="number" min="2023" class="form-control" id="mwakaa" />
              </div>
              <div class="form-group">
                <label for="inputDescription">Term <span class="text-danger">*</span></label>
               <select id="termu" class="form-control custom-select" required>
                  <option selected value="">---</option>
                  <option value="Term One">Term One</option>
                  <option value="Term Two">Term Two</option>
                  <option value="Term Three">Term Three</option>
                </select>
              </div>
              
              <div class="form-group">
                <label for="inputDescription">Fee <span class="text-danger">*</span></label>
                <input type="text" class="form-control" id="pesa" />
              </div>
           
             
              <div class="form-group">
                  <input type="hidden" id="txtsession" name="" value="<?php echo $sess; ?>" />
                  <center><label id="feedbackemails"></label></center>
              </div>
              
                <div class="form-group">
                    <center><label class="text-danger"><em>Only selected learners will be affected by the process</em></label></center>
                    <button class="btn btn-success pull-right" id="subemail">Send <i class="fa fa-paper-plane"></i></button>
               </div>
              
            </div>
            <!-- /.card-body -->
           
          
                  
          </div>
          <!-- /.card -->
        </div>
      </div>
        </form>
    </div>
          
         
    </div>
    </section>
</div>

