<?php 

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

adminall("overadmin","priaccount","secaccount");

?>



<html>

<head>

<?php kheader(); ?>

<link href="../css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">

<link href="../css/receipt_css.css" rel="stylesheet" media="screen">

<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">



<script src="../js/sorttable.js"></script>

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

   <script src=

"https://cdn.jsdelivr.net/npm/html2canvas@1.0.0-rc.5/dist/html2canvas.min.js">

    </script>

<script src="../js/printreceipt.js"></script>



<?php

 

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



$datefrom=$_POST["datefrom"];

$dateto=$_POST["dateto"];

$adj_types=$_POST['adj_type'];



if(!empty($datefrom)&&!empty($dateto)&&!empty($adj_types)){

$wd="and paytype='$adj_types' and DATE(paydate) bewteen '$dateto' and '$datefrom'";}



elseif(!empty($datefrom)&&!empty($dateto)&&empty($adj_types)){

$wd="and DATE(paydate) bewteen '$datefrom' and '$dateto'";}



elseif(!empty($datefrom)&&empty($dateto)&&empty($adj_types)){

$wd="and paydate LIKE '%".$datefrom."%'";}



elseif(empty($datefrom)&&!empty($dateto)&&!empty($adj_types)){

$wd="and paydate LIKE '%".$dateto."%' and paytype='$adj_types'";}



elseif(empty($datefrom)&&empty($dateto)&&!empty($adj_types)){

$wd="and paytype='$adj_types'";}



elseif(empty($datefrom)&&!empty($dateto)&&empty($adj_types)){

$wd="and paydate LIKE '%".$dateto."%'";}



elseif(!empty($datefrom)&&empty($dateto)&&!empty($adj_types)){

$wd="and paydate='$datefrom' and paytype='$adj_types'";}



else {

    $wd='';}



}



else {

    $wd='';

}



?>





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



      <div class="row">

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



                        <h1 class="page-header">

                           Statement

                    

                <div class="row">

                    <div class="col-sm-5"></div>

                     <form method='post'>

                     <div class="col-sm-7">

                    

<div class='row' style='color:maroon;'>

 <div class="col-sm-3"><input type='date' name='datefrom' class='form-control'></div>



 <div class="col-sm-3"><input type='date' name='dateto' class='form-control'></div>  



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

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

<option value=''>Adjustment Type</option>

  <?php



$result_scrap = $dbh->query("SELECT * from scrap where type='adj_type' order by autoid asc");

$row_scrap = $result_scrap->fetchObject();

$count_scrap = $result_scrap->rowCount();

if($count_scrap>0){

do{

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

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

}else{

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

}

?>

</select>

    </div>



 <div class='col-sm-1'>

<input type='submit' style='float:right;' class='btn btn-sm btn-success' name='filter' value='Filter'></div>

</form>

</div></div>

                        </h1>



                    </div>



                </div>



                <!-- /.row -->

<?php 

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

$cid8 = $_GET["cid"];



$hi=date("H"); $mi=date("i");

$sa=date("sa"); $sa=date("s");

$ourtime=$hi."-".$mi;



$result_scrapaddress = $dbh->query("select * from scrap where item2='title1'");

$row_scrapaddress= $result_scrapaddress->fetchObject();

$count_scrapaddress = $result_scrapaddress->rowCount();



$headie=$row_scrapaddress->item;



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

$row70 = $result70->fetchObject();

$count70 = $result70->rowCount();



$cid=$_GET['cid'];

 

$result_clo = $dbh->query("select * from clo where cid='$cid' order by autoid desc");

$row_clo = $result_clo->fetchObject(); $count_clo = $result_clo->rowCount();



$result_bravos = $dbh->query("select * from bravos where cid='$cid' and fsitemid='fullpay'");

$row_bravos = $result_bravos->fetchObject();

$count_bravos = $result_bravos->rowCount();



$result_scrappri = $dbh->query("select * from scrap where item='$row70->schoolclass'");

$row_scrappri = $result_scrappri->fetchObject();



if(empty($row_clo->paydate)){

    $exp=explode(" ",$row_clo->autodate);

    $ddate=$exp[0];

    $ttime=$exp[1];

} elseif(!empty($row_clo->paydate)) {

    $ddate=$row_clo->paydate;

    $ttime=$row_clo->time_received;

}

 ?>



<div id='myDiv'>

<div class="row">

        <div class="col-sm-10 col-sm-offset-1">

            <div class="widget-box">

                <div class="widget-header widget-header-large">

                    

                    <div class="widget-toolbar no-border invoice-info" style="float:left;">

                        <span class="invoice-info-label">                                               

                            <b style='font-size:17px;'>NEW JERUSALEM MIXED DAY & BOARDING SCHOOL</b>                           

                        </span><br>             

                        <span class="invoice-info-label"> 

                            Bulamu - Kasangati

                        </span>

                        

                    </div>



                    <div class="widget-toolbar no-border invoice-info">





                        <br>

                        <span class="invoice-info-label">Date:</span>

                        <span class="blue"><?php echo $ddate; ?></span>

                    </div>



                    <div class="widget-toolbar hidden-480">

                        <a style='cursor:pointer;' onClick="PrintDiv('myDiv','<?php echo $row70->fname." ".$row70->sname; ?> - <?php echo $cid8;?>')">                      

                            <i class="ace-icon fa fa-print"></i>

                        </a>

                    </div>

                </div>



                <div class="widget-body">

                    <div class="widget-main padding-24">

                        <div class="row">

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

                                <div class="row">

                                    <div class="col-xs-11 label label-lg label-info arrowed-in arrowed-right">

                                        <b>School Info</b>

                                    </div>

                                </div>



                                <div>

                                    <ul class="list-unstyled spaced">

                                        <li>

                                            <i class="ace-icon fa fa-caret-right blue"></i> P.O. Box 8589, Kampala

                                        </li>                               

                                    

                                        <li>

                                            <i class="ace-icon fa fa-caret-right blue"></i>

                                                Phone:

                                            <b class="green">0700-547893/ 0772-690679</b>

                                        </li>



                                        <li>

                                            <i class="ace-icon fa fa-caret-right blue"></i>

                                                Email:

                                            <b class="green">newjerusalemujuniorschool@gmail.com</b>

                                        </li>

                                        

                                        <li class="divider"></li>

                                        



                                        

                                    </ul>

                                </div>

                            </div><!-- /.col -->



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

                                <div class="row">

                                    <div class="col-xs-11 label label-lg label-success arrowed-in arrowed-right">                                       

                                        <b>Statement For:</b>

                                    </div>

                                </div>



                                <div>

                                    <ul class="list-unstyled  spaced">

                                        

                                        <li>

                                            <i class="ace-icon fa fa-caret-right green"></i> <?php echo $row70->fname." ".$row70->sname; ?> - <?php echo $cid8;?>

                                        </li>



                                        <li>

                                            <i class="ace-icon fa fa-caret-right green"></i> <?php echo $row_scrappri->item2; ?>

                                        </li>



                                        <li>

                                            <i class="ace-icon fa fa-caret-right green"></i> Term  <?php echo $row70->term; ?>

                                        </li>



                                        <li class="divider"></li>



                                        

                                    </ul>

                                </div>

                            </div><!-- /.col -->

                        </div><!-- /.row -->



                        <div class="space"></div>

                                            <center>

                                                <h4>

                                                <b>Child Statement</b>

                                                </h4>

                                            </center>



                        <div>



<?php

$cid=$_GET['cid'];



$result_children=$dbh->query("SELECT * from children where cid='$cid' order by autoid asc");

$row_children=$result_children->fetchObject();

$count_children=$result_children->rowCount();



?>



                        <table border='0' style='margin-top:20px;width:100%;' class='table table-bordered table-hover table-striped sortable'>

                            <thead>

                            <tr>

    <th width='2%'>No</th>



    <th >Date</th>

    <th >Item</th>

    <th >Amount</th>

    <th >Type</th>



    </tr>



<?php 



$result_homelands=$dbh->query("SELECT * from homeland where cid='$cid' $wd order by autoid asc");

$row_homelands=$result_homelands->fetchObject();

$count_homelands=$result_homelands->rowCount();



if($count_homelands>0){ 



$r=1;



do {



$result_scrapp=$dbh->query("select * from scrap where  item='$row_homelands->fsitemid'");

$row_scrapp=$result_scrapp->fetchObject();

$count_scrapp=$result_scrapp->rowCount();



echo "

    <tr>

    <td>".$r++."</td>



    <td>".$row_homelands->paydate."</td>

    <td>".$row_scrapp->item2."</td>

    <td >".number_format($row_homelands->amount)."</td>

    <td >";

if ($row_homelands->paytype=='d' && $row_homelands->adjustment>=1) {

   echo 'Debt(Adjustment)';

}

elseif ($row_homelands->paytype=='c' && $row_homelands->adjustment>=1) {

    echo 'Deduction';

}

elseif ($row_homelands->paytype=='d' && $row_homelands->adjustment<1) {

    echo 'Debt';

}

elseif ($row_homelands->paytype=='c' && $row_homelands->adjustment<1) {

    echo 'Payment';

}

else {}



    echo "</td></tr>";



} while ($row_homelands=$result_homelands->fetchObject()); } 



?>



</td></tr>



<tr>

        

    <td colspan='3'>Balance</td>

    <td colspan='2'><?php





$result_bravoss=$dbh->query("SELECT * from bravos where cid='$row_children->cid' and fsitemid='fullpay'");

        $row_bravoss=$result_bravoss->fetchObject();

        $count_bravoss=$result_bravoss->rowCount();



        echo number_format($row_bravoss->balance);



     ?>

     </td>



</tr>



                            </tbody>

                            </table>



                        </table>

                        </div>



                        <div class="hr hr8 hr-double hr-dotted"></div>



                        <div class="row">

                            <div class="col-sm-5 pull-right">

                                <h4 class="pull-right">

                                    .

                                </h4>

                            </div>

                            <div class="col-sm-7 pull-left"> <?php echo "<div class='col-lg-12'>Prepared by : ".$_SESSION["firstname"]." ".$_SESSION["lastname"].", ".$ourtime."</div>"; ?> </div>

                        </div>



                        <div class="space-6"></div>

                        <div class="well" style="text-transform:uppercase; text-align:center;">

                            Thank you for choosing NEW JERUSALEM MIXED DAY & BOARDING SCHOOL.

We believe you will be satisfied by our services.

                        </div>

                        

                    </div>

                </div>

            </div>

        </div>

    </div>

</div>





<div id="output"></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>