<?php 
include ("kfunctions.php");
adminall("overadmin","priaccount","secaccount");
?>

<html>
<head>
<?php kheader(); ?>
<link href="css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="js/scfjs.js" charset="UTF-8"></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-green">
<div class="panel-heading">
<h3 class="panel-title">Basic Details for <?php echo $_GET['cid'];?></h3>
</div>
<div class="panel-body">
<div class='col-lg-3'>
<?php
include ("connect.php");
$cid8 = $_GET["cid"];
$result70 = $dbh->query("select * from children where cid='$cid8'");
$row70 = $result70->fetchObject();
$count70 = $result70->rowCount();

if($count70>0){
echo "
Image &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: ".$row70->img."<br>
Firstname : ".$row70->fname."<br>
Lastname  : ".$row70->sname."

";
}else{
  echo "Sorry: There is NO match for the student";
}
?>


                                </div>

<div class="col-lg-4">
<?php
include ("connect.php");
$cid8 = $_GET["cid"];
$result70 = $dbh->query("select * from children where cid='$cid8'");
$row70 = $result70->fetchObject();
$count70 = $result70->rowCount();

if($count70>0){
echo "
Gender&nbsp;&nbsp;&nbsp; : ".$row70->gender."<br>
Year   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : 20".$row70->schoolyear."<br>
Comment : ".$row70->comment."

";
}else{
  echo "Sorry: There is NO match for the student";
}
?>

                                </div>

                                <div class="col-lg-4">
<?php
include ("connect.php");
$cid8 = $_GET["cid"];
$result70 = $dbh->query("select * from children where cid='$cid8'");
$row70 = $result70->fetchObject();
$count70 = $result70->rowCount();

if($count70>0){
echo "

Term&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : ".$_GET["t"]."<br>
Class&nbsp;&nbsp;&nbsp;&nbsp;    : "; 

$schoolclass = $row70->schoolclass;
include ("class.php");
 echo $daclass."<br>
Org Fee : ".$row70->orgfee."
";
}else{
  echo "Sorry: There is NO match for the student";
}
?>

                                </div>

</div></div></div>



<div class="col-lg-4">
<form action="receipt.php" method="post" onsubmit="return FormValidation();">

  <input type='hidden' name='cid' value='<?php echo $cid8; ?>'>
<div class="panel panel-green">
<div class="panel-heading">
<h3 class="panel-title">Modes of Payment</h3>
</div>

<div class="panel-body">
  

  <div class='input-append date form_date col-lg-12' data-date='' data-date-format='yyyy-mm-dd' data-link-field='dtp_input2' data-link-format='yyyy-mm-dd'>
<input size='16' type='text' name='datez' style='cursor:pointer' placeholder='Date Received' class='form-control readonly' required>
<span class='add-on'><i class='icon-th'></i></span>
</div>

  <div class='input-append date form_date col-lg-12' data-date='' data-date-format='yyyy-mm-dd' data-link-field='dtp_input2' data-link-format='yyyy-mm-dd'>
<input size='16' type='text' name='reminderdate' style='cursor:pointer' placeholder='Reminder date' class='form-control readonly'>
<span class='add-on'><i class='icon-th'></i></span>
</div>


<br>&nbsp;</br>
<div class='col-lg-6'>
  <input type='text' class='form-control' name='am_bslip' placeholder='Bslip /=' id="am_bslip" onKeyUp="updatebox()">
</div>
<div class='col-lg-6'>
  <input type='text' class='form-control' name='id_bslip' placeholder='Bslip ID'>
</div>
<div class='col-lg-6'>
  <input type='text' class='form-control' name='am_mobile' placeholder='MM amount /=' id="am_mobile" onKeyUp="updatebox()">
</div>
<div class='col-lg-6'>
  <input type='text' class='form-control' name='id_mobile' placeholder='MM ID'>
</div><p>&nbsp</p>
<div class='col-lg-12'>
  <input type='text' class='form-control' name='am_cash' placeholder='Cash /=' id="am_cash" onKeyUp="updatebox()">
</div> <p>&nbsp</p>
<div class='col-lg-6'>
  <input type='text' class='form-control' name='am_cheque' placeholder='Cheque /=' id="am_cheque" onKeyUp="updatebox()">
</div>
<div class='col-lg-6'>
  <input type='text' class='form-control' name='id_cheque' placeholder='Cheque ID' >
</div>
<div class='col-lg-6'>
  <input type='text' class='form-control' name='am_banktfer' placeholder='BankTfer /=' id="am_banktfer" onKeyUp="updatebox()">
</div>
<div class='col-lg-6'>
  <input type='text' class='form-control' name='id_banktfer' placeholder='BankTfer ID'>
</div>

<div class='col-lg-12'>
<textarea name='moptotal' placeholder='M.O.P Total' class='form-control readonly' rows='1'  id='moptotal' style='
color: green;
font-size: 30px;
text-align: center;' required></textarea>
</div>


</div>
</div></div>

<div class="col-lg-8">
<div class="panel panel-green">
<div class="panel-heading">
<h3 class="panel-title">Received Payments</h3>
</div>
<div class="panel-body">
<div class='col-lg-12'>


<?php 

$cid=$_GET['cid'];
$tid=$_GET['tid'];
$schoolyear=$_GET['schoolyear'];

useractivity("(cid ".$cid.")(term ".$tid.")(year ".$schoolyear.") transaction details","55");

$result = $dbh->query("select * from t".$tid."  where cid='$cid' and schoolyear='$schoolyear'");
$row = $result->fetchObject();
$count = $result->rowCount();

$schoolclass=$row->schoolclass;

//sum of fees paid by this cid, in this exact term&class
$resultsum_p_fees=$dbh->query("select sum(p_fees) from received where cid='$cid' and schoolyear='$schoolyear' and term='$tid'");
$countp_fees=$resultsum_p_fees->rowCount();
if($countp_fees>0){$sum_p_fees=$resultsum_p_fees->fetch();} else {$sum_p_fees='0';} 

//sum of uniform paid by this cid, in this exact term&class
$resultsum_p_uniform=$dbh->query("select sum(p_uniform) from received where cid='$cid' and schoolyear='$schoolyear' and term='$tid'");
$countp_uniform=$resultsum_p_uniform->rowCount();
if($countp_uniform>0){$sum_p_uniform=$resultsum_p_uniform->fetch();} else {$sum_p_uniform='0';}

//sum of contribution paid by this cid, in this exact term&class
$resultsum_p_contribution=$dbh->query("select sum(p_contribution) from received where cid='$cid' and schoolyear='$schoolyear' and term='$tid'");
$countp_contribution=$resultsum_p_contribution->rowCount();
if($countp_contribution>0){$sum_p_contribution=$resultsum_p_contribution->fetch();} else {$sum_p_contribution='0';}

$resultsum_p_registration=$dbh->query("select sum(p_registration) from received where cid='$cid' and schoolyear='$schoolyear' and term='$tid'");
$countp_registration=$resultsum_p_registration->rowCount();
if($countp_registration>0){$sum_p_registration=$resultsum_p_registration->fetch();} else {$sum_p_registration='0';}

$resultsum_p_holiday=$dbh->query("select sum(p_holiday) from received where cid='$cid' and schoolyear='$schoolyear' and term='$tid'");
$countp_holiday=$resultsum_p_holiday->rowCount();
if($countp_holiday>0){$sum_p_holiday=$resultsum_p_holiday->fetch();} else {$sum_p_holiday='0';}

$resultsum_p_admission=$dbh->query("select sum(p_admission) from received where cid='$cid' and schoolyear='$schoolyear' and term='$tid'");
$countp_admission=$resultsum_p_admission->rowCount();
if($countp_admission>0){$sum_p_admission=$resultsum_p_admission->fetch();} else {$sum_p_admission='0';}

$resultsum_p_transport=$dbh->query("select sum(p_transport) from received where cid='$cid' and schoolyear='$schoolyear' and term='$tid'");
$countp_transport=$resultsum_p_transport->rowCount();
if($countp_transport>0){$sum_p_transport=$resultsum_p_transport->fetch();} else {$sum_p_transport='0';}

$resultsum_p_mockfa=$dbh->query("select sum(p_mockfa) from received where cid='$cid' and schoolyear='$schoolyear' and term='$tid'");
$countp_mockfa=$resultsum_p_mockfa->rowCount();
if($countp_mockfa>0){$sum_p_mockfa=$resultsum_p_mockfa->fetch();} else {$sum_p_mockfa='0';}

$resultsum_p_other1=$dbh->query("select sum(p_other1) from received where cid='$cid' and schoolyear='$schoolyear' and term='$tid'");
$countp_other1=$resultsum_p_other1->rowCount();
if($countp_other1>0){$sum_p_other1=$resultsum_p_other1->fetch();} else {$sum_p_other1='0';}

$resultsum_p_other2=$dbh->query("select sum(p_other2) from received where cid='$cid' and schoolyear='$schoolyear' and term='$tid'");
$countp_other2=$resultsum_p_other2->rowCount();
if($countp_other2>0){$sum_p_other2=$resultsum_p_other2->fetch();} else {$sum_p_other2='0';}

$resultsum_p_other3=$dbh->query("select sum(p_other3) from received where cid='$cid' and schoolyear='$schoolyear' and term='$tid'");
$countp_other3=$resultsum_p_other3->rowCount();
if($countp_other3>0){$sum_p_other3=$resultsum_p_other3->fetch();} else {$sum_p_other3='0';}


$ownfee=$row->ownfee;
$uniform=$row->uniform;
$contribution=$row->contribution;
$registration=$row->registration;
$holiday=$row->holiday;
$admission=$row->admission;
$transport=$row->transport;
$mockfa=$row->mockfa;
$other1=$row->other1;
$other2=$row->other2;
$other3=$row->other3;
$feesbalance=$row->feesbalance;
$paidsofar=$ownfee-$feesbalance;

$uniformbal=$row->uniformbal;
$contributionbal=$row->contributionbal;
$registrationbal=$row->registrationbal;
$holidaybal=$row->holidaybal;
$admissionbal=$row->admissionbal;
$transportbal=$row->transportbal;
$mockfabal=$row->mockfabal;
$other1bal=$row->other1bal;
$other2bal=$row->other2bal;
$other3bal=$row->other3bal;
?>
<table class='table table-bordered table-hover table-striped sortable'>
<thead>
<tr>
<th>Item</th>
<th>Structure</th>
<th>Paid so far</th>
<th>Balance</th>
<th>Current</th>
</tr>
</thead>
<tbody>
  <?php if($ownfee>0){echo "
<tr>
<td>School Fees</td>
<td>".number_format($ownfee)."</td>
<td>".number_format($sum_p_fees['0'])."</td>
<td>".number_format($feesbalance)."</td>
<td><input type='text' class='form-control' name='p_fees' placeholder='Amount /=' id='p_fees' onKeyUp='updatereceived()'>
</td>
</tr>";}
else {echo "<input type='hidden' id='p_fees' name='p_fees' value='0'>";}

if($uniform>0){echo
"
<tr>
<td>Uniform</td>
<td>".number_format($uniform)."</td>
<td>".number_format($sum_p_uniform['0'])."</td>
<td>".number_format($uniformbal)."</td>
<td><input type='text' class='form-control' name='p_uniform' placeholder='Amount /=' id='p_uniform' onKeyUp='updatereceived()'>
</td>
</tr>";}
else {echo "<input type='hidden' id='p_uniform' name='p_uniform' value='0'>";}

if($contribution>0){echo
"
<tr>
<td>Contribution</td>
<td>".number_format($contribution)."</td>
<td>".number_format($sum_p_contribution['0'])."</td>
<td>".number_format($contributionbal)."</td>
<td><input type='text' class='form-control' name='p_contribution' placeholder='Amount /=' id='p_contribution' onKeyUp='updatereceived()'>
</td>
</tr>";}
else {echo "<input type='hidden' id='p_contribution'  name='p_contribution' value='0'>";}
if($registration>0){echo
"
<tr>
<td>Registration</td>
<td>".number_format($registration)."</td>
<td>".number_format($sum_p_registration['0'])."</td>
<td>".number_format($registrationbal)."</td>
<td><input type='text' class='form-control' name='p_registration' placeholder='Amount /=' id='p_registration' onKeyUp='updatereceived()'>
</tr>";}
else {echo "<input type='hidden'  id='p_registration' name='p_registration' value='0'>";}
if($holiday>0){echo
"
<tr>
<td>Holiday</td>
<td>".number_format($holiday)."</td>
<td>".number_format($sum_p_holiday['0'])."</td>
<td>".number_format($holidaybal)."</td>
<td><input type='text' class='form-control' name='p_holiday' placeholder='Amount /=' id='p_holiday' onKeyUp='updatereceived()'>
</tr>";}
else {echo "<input type='hidden' name='p_holiday' id='p_holiday' value='0'>";}
if($admission>0){echo
"
<tr>
<td>Admission</td>
<td>".number_format($admission)."</td>
<td>".number_format($sum_p_admission['0'])."</td>
<td>".number_format($admissionbal)."</td>
<td><input type='text' class='form-control' name='p_admission' placeholder='Amount /=' id='p_admission' onKeyUp='updatereceived()'>
</tr>";}
else {echo "<input type='hidden'  id='p_admission' name='p_admission' value='0'>";}
if($transport>0){echo
"
<tr>
<td>Transport</td>
<td>".number_format($transport)."</td>
<td>".number_format($sum_p_transport['0'])."</td>
<td>".number_format($transportbal)."</td>
<td><input type='text' class='form-control' name='p_transport' placeholder='Amount /=' id='p_transport' onKeyUp='updatereceived()'>
</tr>";}
else {echo "<input type='hidden' name='p_transport' id='p_transport' value='0'>";}
if($mockfa>0){echo
"
<tr>
<td>Mock/Facillitation</td>
<td>".number_format($mockfa)."</td>
<td>".number_format($sum_p_mockfa['0'])."</td>
<td>".number_format($mockfabal)."</td>
<td><input type='text' class='form-control' name='p_mockfa' placeholder='Amount /=' id='p_mockfa' onKeyUp='updatereceived()'>
</tr>";}
else {echo "<input type='hidden'  id='p_mockfa' name='p_mockfa' value='0'>";}
if($other1>0){echo
"
<tr>
<td>Other 1</td>
<td>".number_format($other1)."</td>
<td>".number_format($sum_p_other1['0'])."</td>
<td>".number_format($other1bal)."</td>
<td><input type='text' class='form-control' name='p_other1' placeholder='Amount /=' id='p_other1' onKeyUp='updatereceived()'>
</tr>";}
else {echo "<input type='hidden' id='p_other1'  name='p_other1' value='0'>";}

if($other2>0){echo
"
<tr>
<td>Other 2</td>
<td>".number_format($other2)."</td>
<td>".number_format($sum_p_other2['0'])."</td>
<td>".number_format($other2bal)."</td>
<td><input type='text' class='form-control' name='p_other2' placeholder='Amount /=' id='p_other2' onKeyUp='updatereceived()'>
</tr>";}
else {echo "<input type='hidden'  id='p_other2' name='p_other2' value='0'>";}
if($other3>0){echo
"
<tr>
<td>Other 3</td>
<td>".number_format($other3)."</td>
<td>".number_format($sum_p_other3['0'])."</td>
<td>".number_format($other3bal)."</td>
<td><input type='text' class='form-control' name='p_other3' placeholder='Amount /=' id='p_other3' onKeyUp='updatereceived()'>

</tr>";}
else {echo "<input type='hidden' id='p_other3'  name='p_other3' value='0'>";}
echo"
<tr>
<td colspan='4'>Bank charges</td>
<td><input type='text' class='form-control' name='bankcharges' placeholder='Amount'></td>
</tr>
</tbody>
</table>";
echo "
</div><div align='right'>
<input type='hidden' name='cid' value='$cid'>
<input type='hidden' name='tid' value='$tid'>
<input type='hidden' name='schoolyear' value='$schoolyear'>
<input type='hidden' name='schoolclass' value='$schoolclass'>
<div class='col-lg-8'>
<textarea name='receivedtotal' placeholder='Received Total' class='form-control readonly' rows='1'  id='receivedtotal' style='
color: green;
font-size: 30px;
text-align: center;' required></textarea>
</div>
<div class='col-lg-4'>
<textarea class='form-control' name='comment' placeholder='Type your comment here'></textarea>
</div>
<input type='hidden' name='termtotake' value='$tid'>
<input type='submit' class='btn btn-sm btn-primary' name='addreceived' value='Submit Form.'>
<input type='reset' class='btn btn-sm btn-primary'  value='Reset Form'>
</form>";?>
</div>
</div>

</div></div>

                <!-- /.row -->





                 
    <!-- /#wrapper -->

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

    <!-- Bootstrap Core JavaScript -->
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/jquery-1.8.3.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript">
    $('.form_datetime').datetimepicker({
        //language:  'fr',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1
    });
    $('.form_date').datetimepicker({
        language:  'en',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0
    });
    $('.form_time').datetimepicker({
        language:  'en',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 1,
        minView: 0,
        maxView: 1,
        forceParse: 0
    });
</script>

    <!-- Bootstrap Core JavaScript -->

    

</body>

</html>