<?php 

include ("../core/kfunctions.php");

adminall("secadmin","priadmin","overadmin");

?>



<html>

<head>

<?php kheader(); ?>

</head>

<body>



    <div id="wrapper">



        <!-- Navigation -->

        <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">

            <!-- Brand and toggle get grouped for better mobile display -->

            <?php ktopbar(); ?>

            <!-- Sidebar Menu Items - These collapse to the responsive navigation menu on small screens -->

            <?php kleftbar(); ?>

            <!-- /.navbar-collapse -->

        </nav>



        <div id="page-wrapper">



            <div class="container-fluid">



      



                <!-- /.row -->



                    <div class="col-lg-12">

                        <div class="panel panel-yellow">

                            <div class="panel-heading">

                                <h3 class="panel-title">Basic details</h3>

                            </div>

                            <div class="panel-body">

                                <div class="list-group">

               <?php

 $role = $_SESSION["role"];

  if($role=="overadmin"){



              } else{



         include ("../core/connect.php");

         if ($role=="priadmin"){$cidcheck='where cid<=49999';}

         elseif ($role=="secadmin"){$cidcheck='where cid>=50000';}

        

             

              $result=$dbh->query("select * from children $cidcheck order by cid desc");

                $row=$result->fetchObject();

}

                         

 if(isset($_POST["addstudent"])){

$role = $_SESSION["role"];



if($role=="overadmin"){

  $level = $_POST["level"];



  $result=$dbh->query("select * from children where cid$level order by cid desc");

                $row=$result->fetchObject();

                $cid = $row->cid + 1;

}else{

$cid=$_POST["cid"];



}



$fname=$_POST["fname"];

$sname=$_POST["sname"];

$schoolyear=$_POST["schoolyear"];

$term=$_POST["term"];

$gender=$_POST["gender"];

$schoolclass=$_POST["schoolclass"];

//$orgfee=$_POST["orgfee"];



$comment=$_POST["comment"];

if ($_FILES["filetouploadx"]<'0')

{

include ("../core/uploads.php");

$img=$filething;

} else { $img=''; } 





useractivity("(Image ".$img.")(cid ".$cid.")(firstname ".$fname.")(surname ".$sname.")(year ".$schoolyear.")(term ".$term.")

  (gender ".$gender.")(class ".$schoolclass.")(comment ".$comment.") details for new student","2");



/*include ("uploads.php");*/



$addthestudent=$dbh->exec("insert into 

  children (cid,fname,sname,gender,schoolyear,term,schoolclass,img,status,comment) 

  values('$cid','$fname','$sname','$gender','$schoolyear','$term','$schoolclass','$img','1','$comment')"); 



$resultpay=$dbh->query("select * from paystructure where schoolyear='$schoolyear' and term='$term' and schoolclass='$schoolclass'");

$rowpay=$resultpay->fetchObject();

$countpay=$resultpay->rowCount();



if($countpay>0){

$ownfee=$rowpay->ownfee;

$uniform=$rowpay->uniform;

$contribution=$rowpay->contribution;

$registration=$rowpay->registration;

$holiday=$rowpay->holiday;

$admission=$rowpay->admission;

$transport=$rowpay->transport;

$mockfa=$rowpay->mockfa;

$other1=$rowpay->other1;

$other2=$rowpay->other2;

$other3=$rowpay->other3;





$reqsbalance=$uniform+$contribution+$registration+$holiday+$admission+$admission+$transport+$mockfa+$other1+$other2+$other3;



$addhispay=$dbh->exec("insert into t".$term."

   (cid,schoolyear,schoolclass,lastupdated,ownfee,feesbalance,reqsbalance,uniform,uniformbal,contribution,contributionbal,registration,registrationbal,holiday,holidaybal,admission,admissionbal,transport,transportbal,mockfa,mockfabal,other1,other1bal,other2,other2bal,other3,other3bal,status) 

  values('$cid','$schoolyear','$schoolclass','101','$ownfee','$ownfee','$reqsbalance','$uniform','$uniform','$contribution','$contribution','$registration','$registration','$holiday','$holiday','$admission','$admission','$transport','$transport','$mockfa','$mockfa','$other1','$other1','$other2','$other2','$other3','$other3','1')"); 



echo "<div class='alert alert-success'> Details on ".$fname." ".$sname." - ID: ".$cid." have been submitted. </div>";



}else{

  echo "<div class='alert alert-danger'>Sorry: Pay structure has not been submitted. </div>";

}

//echo "<script>window.location='last20students.php'</script>";

}



?>



<form method="post" enctype="multipart/form-data" >

<?php 



$role = $_SESSION["role"];



if($role=="overadmin"){

$select2 = "

<select name='level' class='form-control' required>

<option value=''>level</option>

<option value='<=49999'>Primary</option>

<option value='>=50000'>Secondary</option>

</select>";

}else{

  $cider = $row->cid+1;

  $select2 = "<input type='text' name='cid' class='form-control' value='".$cider  ."' readonly>";

}

?>



               

<!----row---->                                   

<div class="col-lg-3">

                        <div class="panel panel-default">

                              <div class="panel-body">

                                <div class="list-group">



<?php echo $select2; ?>

</div>

</div>

</div>

</div>

<!----row---->

<!----row---->

<div class="col-lg-3">

                        <div class="panel panel-default">

                              <div class="panel-body">

                                <div class="list-group">

<input type='file' name='filetouploadx' accept='.jpg'>





</div>

</div>

</div>

</div>

<!----row---->

<!----row---->                                   

<div class="col-lg-3">

                        <div class="panel panel-default">

                              <div class="panel-body">

                                <div class="list-group">



<input type="text" name="fname" class="form-control" placeholder="Firstname" id='fname' required>

</div>

</div>

</div>

</div>

<!----row---->

<!----row---->                                   

<div class="col-lg-3">

                        <div class="panel panel-default">

                              <div class="panel-body">

                                <div class="list-group">



<input type="text" name="sname" class="form-control" placeholder="Surname" id='surname' required>

</div>

</div>

</div>

</div>

<!----row---->

<!----row---->                                   

<div class="col-lg-3">

                        <div clas2ass="panel panel-default">

                              <div class="panel-body">

                                <div class="list-group">



<select class="form-control" name="schoolclass" required>

<option value=''>Class</option>

<?php



$role = $_SESSION["role"];



if($role=="priadmin"){

  $clas2 = "type='clas'";



}elseif($role=="secadmin"){

  $clas2 = "type='secclas'";



}elseif($role=="overadmin"){

  $clas2 = "type='clas' or type='secclas'";

}



include ("../core/connect.php");

$result5 = $dbh->query("select * from scrap where $clas2");

$row5 = $result5->fetchObject();



do{

echo "<option value='".$row5->item."'>".$row5->item2."</option>";

}while($row5 = $result5->fetchObject());

?>



</select>

</div>

</div>

</div>

</div>

<!----row---->

<!----row---->                                   

<div class="col-lg-3">

                        <div class="panel panel-default">

                              <div class="panel-body">

                                <div class="list-group">



<select name="schoolyear" class="form-control">

<?php

$result2 = $dbh->query("select * from scrap where type='ya'");

$row2 = $result2->fetchObject();



do{

echo "<option value='".$row2->item."'>".$row2->item2."</option>";

}while($row2 = $result2->fetchObject());

?>



                  </select>

                  

</div>

</div>

</div>

</div>

<!----row---->

<!----row---->                                   

<div class="col-lg-3">

                        <div class="panel panel-default">

                              <div class="panel-body">

                                <div class="list-group">



<select class="form-control" name="term">

<option value="">Term</option>

<option value="1">Term 1 </option>

<option value="2">Term 2 </option>

<option value="3">Term 3 </option>

</select>

                  

</div>

</div>

</div>

</div>

<!----row---->

<!----row---->                                   

<div class="col-lg-3">

                        <div class="panel panel-default">

                              <div class="panel-body">

                                <div class="list-group">



<select class="form-control" name="gender">

<option value="">Select the gender</option>

<option value="Male">Male</option>

<option value="Female">Female</option>

</select>

</div>

</div>

</div>

</div>

<!----row---->

<!----row---->                                   

<div class="col-lg-3">

                        <div class="panel panel-default">

                              <div class="panel-body">

                                <div class="list-group">



<input type="text" name="orgfee" class="form-control" placeholder="School bursary amount" readonly>



</div>

</div>

</div>

</div>

<!----row---->

<!----row---->                                   

<div class="col-lg-3">

                        <div class="panel panel-default">

                              <div class="panel-body">

                                <div class="list-group">



<textarea name="comment" class="form-control" placeholder="Type the comment"></textarea>

</div>

</div>

</div>

</div>

<!----row---->

<input type="submit" class='btn btn-sm btn-success' name="addstudent" value="Submit Form">

<input type="reset" class='btn btn-sm btn-primary'  value="Reset Form">

</form>

                                

                                </div>

                            </div>

                        </div>

                    </div>





                  </div>

                <!-- /.row -->



                  </div>

                <!-- /.row -->



            </div>

            <!-- /.container-fluid -->



        </div>

        <!-- /#page-wrapper -->



    </div>

    <!-- /#wrapper -->

<?php useractivity("on page","2"); ?>

    <!-- jQuery -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.js"></script>



    <!-- Bootstrap Core JavaScript -->

    <script src="../js/bootstrap.min.js"></script>



    <!-- Morris Charts JavaScript -->



</body>



</html>

