<?php 

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

role("overadmin");

?>



<html>

<head>

<?php kheader(); ?>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.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">Update 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["editstudent"])){

$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=''; } 

$category=$_POST["category"];



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

  (gender ".$gender.")(class ".$schoolclass.")(comment ".$comment.") details have been updated","2");



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



$updatechildren = $dbh->query("update children set fname='$fname', sname='$sname', gender='$gender', schoolyear='$schoolyear', term='$term', schoolclass='$schoolclass', img='$img', status='$category', comment='$comment' where cid='$cid'");





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



$feebalance=$_POST["scfsbal"];

$uniformbal=$_POST["unibal"];

$contributionbal=$_POST["contbal"];

$registrationbal=$_POST["regbal"];

$holidaybal=$_POST["holbal"];

$admissionbal=$_POST["admbal"];

$transportbal=$_POST["tpbal"];

$mockfabal=$_POST["mockfabal"];

$other1bal=$_POST["o1bal"];

$other2bal=$_POST["o2bal"];

$other3bal=$_POST["o3bal"];







$reqsbalance=$uniformbal+$contributionbal+$registrationbal+$holidaybal+$admissionbal+$admissionbal+$transportbal+$mockfabal+$other1bal+$other2bal+$other3bal;





$updateterm = $dbh->query("update t".$term." set schoolyear='$schoolyear', schoolclass='$schoolclass', lastupdated='101', ownfee='$ownfee', feesbalance='$feebalance', reqsbalance='$reqsbalance', uniform='$uniform', uniformbal='$uniformbal', contribution='$contribution', contributionbal='$contributionbal', registration='$registration', registrationbal='$registrationbal', holiday='$holiday', holidaybal='$holidaybal', admission='$admission', admissionbal='$admissionbal', transport='$transport', transportbal='$transportbal', mockfa='$mockfa', mockfabal='$mockfabal', other1='$other1', other1bal='$other1bal', other2='$other2', other2bal='$other2bal', other3='$other3', other3bal='$other3bal', comment='$comment', status='$category' where cid='$cid'  and schoolyear='$schoolyear'");



$result_citadel=$dbh->query("select * from citadel where cid='$cid'");

$count_citadel=$result_citadel->rowCount();



if($count_citadel<=0){

$insert_citadel=$dbh->query("insert into citadel (schoolyear,term,schoolclass,cid) values('$schoolyear','$term','$schoolclass','$cid')");

}



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



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

}



?>



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

<?php 

$t = $_GET["t"];

$cid = $_GET["cid"];

$yearinget = $_GET["y"];



$result7 = $dbh->query("select * from $t where cid='$cid' and schoolyear='$yearinget'");

$row7 = $result7->fetchObject();

$count7 = $result7->rowCount();



$result8 = $dbh->query("select * from children where cid='$cid'");

$row8 = $result8->fetchObject();

?>



               

<!--row-->                                   

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

<?php echo "<input type='text' name='cid' class='form-control' value='".$cid."' readonly>"; ?>

</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" value="<?php echo $row8->fname; ?>" id='fname' required>

</div>

<!--row-->

<!--row-->                                   

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

<input type="text" name="sname" class="form-control" value="<?php echo $row8->sname; ?>" 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>

<?php

$schoolclass = $row7->schoolclass;

include("class.php");

?>

<option value='<?php echo $row7->schoolclass; ?>'><?php echo $daclass; ?></option>

<?php



$role = $_SESSION["role"];



if($role=="priadmin"){

  $clas2 = "type='priclas'";



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

<?php

if($t=="t1"){

  $val = 1;

  $out = "Term 1";

}elseif($t=="t2"){

  $val = 2;

  $out = "Term 2";

}elseif($t=="t3"){

  $val = 3;

  $out = "Term 3";

}

?>

<option value='<?php echo $val; ?>'><?php echo $out; ?></option>

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

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

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

</select>

</div>

<!--row-->

<!--row-->                                   

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

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

<?php

if($row8->gender=="M"){$gender_out="Male";}else{$gender_out="Female";}

?>

<option value="<?php echo $row8->gender; ?>"><?php echo $gender_out; ?></option>

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

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

</select>

</div>

<!--row-->

<!--break-->

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

<!--break-->

<!--row-->                                   

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

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

<?php

if($row7->status==1){

  $out2 = "Program";

  $val2 = $row7->status;

}elseif($row7->status==2){

  $out2 = "Private";

  $val2 = $row7->status;



}elseif($row7->status==3){

  $out2 = "Other";

  $val2 = $row7->status;



}else{

  $out2 = "Category";

  $val2 = "";

}

?>

<option value='<?php echo $val2; ?>'><?php echo $out2; ?></option>

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

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

<option value='3'>Other</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-->

<!--row-->                                   

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

<textarea name="comment" class="form-control" ><?php echo $row7->comment; ?></textarea>

</div>

<!--row-->





                                

                                </div>

                            </div>

                        </div>

                        </div>



                                      

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

  <div class="panel panel-green">

                <div class="panel-heading">

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

                            </div>

                            <div class="panel-body">

                  

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

                School Fees  <input  type="text" name="scfs" class="form-control" value="<?php echo $row7->ownfee; ?>" id='scfs' data-type='number'>

                <input type="text" name="scfsbal" class="form-control" value="<?php echo $row7->feesbalance; ?>" id='scfs' >

                  </div>



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

Uniform <input data-type='number' type="text" name="uni" class="form-control" id='uni' value="<?php echo $row7->uniform; ?>"  >

<input type="text" data-type='number' name="unibal" class="form-control" id='uni' value="<?php echo $row7->uniformbal; ?>"  >

                  </div>



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

Contribution <input data-type='number' type="text" name="cont" class="form-control" value="<?php echo $row7->contribution; ?>" id='cont'  >

<input type="text" data-type='number' name="contbal" class="form-control" value="<?php echo $row7->contributionbal; ?>" id='cont'  >

                  </div>



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

Registration <input data-type='number' type="text" name="reg" class="form-control" value="<?php echo $row7->registration; ?>" id='reg'  >

<input type="text" data-type='number' name="regbal" class="form-control" value="<?php echo $row7->registrationbal; ?>" id='reg'  >

                  </div>



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

Holiday<input type="text" data-type='number' name="hol" class="form-control" id='hol' value="<?php echo $row7->holiday; ?>"  >

                  <input data-type='number' type="text" name="holbal" class="form-control" id='hol' value="<?php echo $row7->holidaybal; ?>"  >

                  </div>

                  

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

Admission <input type="text" data-type='number' name="adm" class="form-control" id='adm' value="<?php echo $row7->admission; ?>"  >

<input type="text" data-type='number' name="admbal" class="form-control" id='adm' value="<?php echo $row7->admissionbal; ?>"  >

                  </div>



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

Transport <input type="text" data-type='number' name="tp" class="form-control" id='tp' value="<?php echo $row7->transport; ?>" >

<input type="text" data-type='number' name="tpbal" class="form-control" id='tp' value="<?php echo $row7->transportbal; ?>" >

                  </div>



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

Mocks and Facilitation <input type="text" data-type='number' name="mockfa" class="form-control" id='mockfa' value="<?php echo $row7->mockfa; ?>" >

<input type="text" data-type='number' name="mockfabal" class="form-control" id='mockfa' value="<?php echo $row7->mockfabal; ?>" >

                  </div>



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

Other 1  <input type="text" data-type='number' name="o1" class="form-control" value="<?php echo $row7->other1; ?>" >

<input type="text" data-type='number' name="o1bal" class="form-control" value="<?php echo $row7->other1bal; ?>" >

                  

                  </div>



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

Other 2  <input type="text" data-type='number' name="o2" class="form-control" value="<?php echo $row7->other2; ?>" >

<input type="text" data-type='number' name="o2bal" class="form-control" value="<?php echo $row7->other2bal; ?>" >

                  </div>



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

Other 3  <input type="text" data-type='number' name="o3" class="form-control" value="<?php echo $row7->other3; ?>" >

<input type="text" data-type='number' name="o3bal" class="form-control" value="<?php echo $row7->other3bal; ?>" >

                  </div>

</div>

</div>

</div>



<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='editstudent' value='Submit Form'>

</div>

</form>







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

