<?php 

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

role("overadmin");

?>



<html>

<head>

<?php kheader(); ?>

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

<!--<script src="js/thousandseparator.js"></script>-->

</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"];

$stream=$_POST["stream"];

//$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->prepare("insert into 

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

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

$addthestudent->execute();





$ownfee=$_POST["scfs"];

$uniform=$_POST["uni"];

$contribution=$_POST["cont"];

$registration=$_POST["reg"];

$holiday=$_POST["hol"];

$admission=$_POST["adm"];

$transport=$_POST["tp"];

$mockfa=$_POST["mockfa"];

$other1=$_POST["o1"];

$other2=$_POST["o2"];

$other3=$_POST["o3"];

$category=$_POST["category"];



$pfname=$_POST["pfname"];

$plname=$_POST["plname"];

$pphone=$_POST["pphone"];

$paddress=$_POST["paddress"];

$ptype=$_POST["ptype"];



//$insert_parent=$dbh->query("insert into parent (cid,firstname,lastname,phone,address,ptype) values('$cid','$pfname','$plname','$pphone','$paddress','$ptype')");



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



$addhispay=$dbh->prepare("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,comment,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','$comment','$category')"); 

$addhispay->execute();



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

 

 if($schoolclass<=10){

 $insert_citadelp=$dbh->prepare("insert into citadel_p (schoolyear,term,schoolclass,cid,stream) values('$schoolyear','$term','$schoolclass','$cid','$stream')");

$insert_citadelp->execute();



}elseif($schoolclass>=21 && $schoolclass<25){

$insert_citadelo=$dbh->prepare("insert into citadel_o (schoolyear,term,schoolclass,cid,stream) values('$schoolyear','$term','$schoolclass','$cid','$stream')");

$insert_citadelo->execute();



}elseif($schoolclass>=25 && $schoolclass<=26){

 $insert_citadela=$dbh->prepare("insert into citadel_a (schoolyear,term,schoolclass,cid,stream) values('$schoolyear','$term','$schoolclass','$cid','$stream')"); 

$insert_citadela->execute();

}

 

echo "<div class='alert alert-success'> Details on ".$fname." ".$sname." - ID: ".$cid." have 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">

<?php echo $select2; ?>

</div>

<!--row-->

<!--row-->

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

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

</div>

<!--row-->



<!--row-->                                   

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

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

</div>

<!--row-->

<!--row-->                                   

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

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

</div>

<!--row-->

<!--break-->

<div class='col-lg-12'><br></div>

<!--break-->

<!--row-->                                   

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

<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='priclas' 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>

<!--row-->

<!--row-->                                   

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

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

<option value=''>Stream</option>

<?php



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

$row_scrap = $result_scrap->fetchObject();

$count_scrap = $result_scrap->rowCount();



if($count_scrap>0){

do{

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

}while($row_scrap = $result_scrap->fetchObject());

}else{

  echo "<option value=''>Please contact your IT department. </option>";

}

?>



</select>

</div>

<!--row-->

<!--row-->                                   

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

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

<option value='<?php echo date('y'); ?>'>20<?php echo date('y'); ?></option>



<?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>

<!--row-->

<!--row-->                                   

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

<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>

<!--row-->

<!--break-->

<div class='col-lg-12'><br></div>

<!--break-->



<!--row-->                                   

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

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

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

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

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

</select>

</div>

<!--row-->

<!--row-->                                   

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

<select name='category' class='form-control'>

<option value='1'>Program</option>

<option value='2'>Private</option>

<option value='3'>Student</option>

</select>

</div>

<!--row-->

<!--row-->                                   

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

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

</div>

<!--row-->

<!--break-->

<div class='col-lg-12'><br></div>

<!--break-->



<!--row-->                                   

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

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

</div>

<!--row-->





                                

                                </div>

                            </div>

                        </div>

                        </div>



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

  <div class="panel panel-info">

                <div class="panel-heading">

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

                            </div>

                            <div class="panel-body">

                  

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

<input type="text" name="pfname" class="form-control" placeholder="Firstname" required>

                  </div>



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

<input type="text" name="plname" class="form-control" placeholder="Lastname"  required>

                  </div>



                  <div class='col-lg-2'>

<input type="text" name="pphone" class="form-control" placeholder="Phone No"  required>

                  </div>



                  <div class='col-lg-2'>

<input type="text" name="paddress" class="form-control" placeholder="Address"  required>

                  </div>

                  <div class='col-lg-2'>

<select class='form-control' name='ptype'>

<option value=''>Parent type</option>

<option value='Parent'>Parent</option>

<option value='Guardian'>Guardian</option>

</select>

                  </div>

</div>

</div>



                    </div>

                                     

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

  <div class="panel panel-green">

                <div class="panel-heading">

                                <h3 class="panel-title">Add New Fees Structure</h3>

                            </div>

                            <div class="panel-body">

                  

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

                School Fees  <input type="text" name="scfs" class="form-control" id='scfs' data-type='number' required>

                  </div>



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

Uniform <input type="text" name="uni" class="form-control" id='uni' data-type='number' required>

                  </div>



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

Contribution <input type="text" name="cont" class="form-control" id='cont' data-type='number' required>

                  </div>



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

Registration <input type="text" name="reg" class="form-control" id='reg' data-type='number' required>

                  </div>



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

Holiday <input type="text" name="hol" class="form-control" id='hol' data-type='number' required>

                  

                  </div>

                  

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

Admission <input type="text" name="adm" class="form-control" id='adm' data-type='number' required>

                  </div>



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

Transport <input type="text" name="tp" class="form-control" id='tp' data-type='number' required>

                  </div>



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

Mocks and Facilitation <input type="text" name="mockfa" class="form-control" id='mockfa' data-type='number' required>

                  </div>



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

Other 1  <input type="text" name="o1" class="form-control" data-type='number' required>

                  

                  </div>



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

Other 2  <input type="text" name="o2" class="form-control" data-type='number' required>

                  </div>



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

Other 3  <input type="text" name="o3" class="form-control" data-type='number' required>

                  </div>



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

 

                  </div>







                    </div>

                  </div>





                <!-- /.row -->



               </div>

                <!-- /.row -->



<div style='float:left;margin-left:15px;'> 

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

</div>

<div style='float:right;margin-right:15px;'> 

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

</div>

</form>

            

            <!-- /.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>

