inc<?php
session_start();
if($_SESSION["username"]=="")
{
 	echo "You are not Logged in Please <a href='index.html'>Sign in </a> First ";
}
else
{


?>
<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->

<head>
   <?php include("includes/header.php") ?>
</head>

<body>


    <!-- Left Panel -->

   <!-- /#left-panel -->

    <!-- Left Panel -->

    <!-- Right Panel -->

    <div id="right-panel" class="right-panel">

        <!-- Header-->
        
        <!-- Header-->

        

        <div class="content mt-3">
            <div class="animated fadeIn">
                <div class="row">

                    <div class="col-md-14">
                        <div class="card">
						<div class="page-title">
                        <h2><center><? echo "" . $_SESSION["userid"]; ?></center></h2>
                    </div>
                            <div class="card-header">
							
                                <strong class="card-title"><center>Accouts Ledger Report</center> </strong>
                            </div>
                            <div class="card-body">
							<?php
$userid=$_SESSION["userid"];
$from_date=$_POST["from_date"];
$to_date=$_POST["to_date"];
$acc_name=$_POST["acc_name"];
include 'dbc.php';
$sqla = "delete from accledger";
$conn->query($sqla);
$sql1 = "SELECT * FROM addclass where user_id = '$userid'";
$result1=$conn->query($sql1);
$row1 = $result1->fetch_assoc();
$feedisc1=$row1['feedisc1'] ;
$feedisc2=$row1['feedisc2'] ;
$feedisc3=$row1['feedisc3'] ;
$feedisc4=$row1['feedisc4'] ;
$feedisc5=$row1['feedisc5'] ;
$feedisc6=$row1['feedisc6'] ;


$sql3 = "select * from rec_fee where acc_name='$acc_name' and user_id='$userid'";
$result3=$conn->query($sql3);
while($ppp3 = $result3->fetch_assoc())
{
$totalrec=0;
 $qtypur=0;
  $qtypur1= 0;
  $qtypur2= 0;
  $qtypur3= 0;
  $qtypur4= 0;
  $qtypur5= 0;
  $qtypur6= 0;
$totaldisc="";
$std_rollno=$ppp3['std_rollno'];
$std_name=$ppp3['std_name'];
$fname=$ppp3['fname'];
$class_name=$ppp3['class_name'];
$rec_date=$ppp3['date'];
$month_period=$ppp3['month_period'];
$id=$ppp3['id'];

    $qtypur= $qtypur + $ppp3["feerec"];
  $qtypur1= $qtypur1 + $ppp3["fee1rec"];
  $qtypur2= $qtypur2 + $ppp3["fee2rec"];
  $qtypur3= $qtypur3 + $ppp3["fee3rec"];
  $qtypur4= $qtypur4 + $ppp3["fee4rec"];
  $qtypur5= $qtypur5 + $ppp3["fee5rec"];
  $qtypur6= $qtypur6 + $ppp3["fee6rec"];
  $totalrec = $qtypur + $qtypur1 + $qtypur2 + $qtypur3 + $qtypur4 + $qtypur5 + $qtypur6;
  $totaldisc = $std_rollno .":" . $std_name .":" . $fname .":" . $class_name .":"   . "Tuition Fee" . $qtypur . $feedisc1 . $qtypur1 . $feedisc2 . $qtypur2 . $feedisc3 . $qtypur3 . $feedisc4 . $qtypur4 . $feedisc5 . $qtypur5 . $feedisc6 . $qtypur6;
  $sql101 = "Insert into accledger (id,date,month_name,tr_no,acc_name,discription,acc_type,dr_amount,cr_amount,balance,user_id) values (null,'$rec_date','$month_period','$id','$acc_name','$totaldisc','$std_name','$totalrec','0','0','$userid')";
$conn->query($sql101);
 } 
 $sql2 = "select * from expense_voucher where acc_name_dr='$acc_name' and user_id='$userid'";
$result2=$conn->query($sql2);
while($ppp1 = $result2->fetch_assoc())
{
$tr_no=$ppp1['tr_no'];
$recdate=$ppp1['date'];
$discription=$ppp1['discription'];
$acc_name_cr=$ppp1['acc_name_cr'];
$recamount=$ppp1['amount'];
$month_name=$ppp1['month_name'];
  $sql102 = "Insert into accledger (id,date,month_name,tr_no,acc_name,discription,acc_type,dr_amount,cr_amount,balance,user_id) values (null,'$recdate','$month_name','$tr_no','$acc_name','$discription','$acc_name_cr','$recamount','0','0','$userid')";
$conn->query($sql102);
 } 
  $sql2c = "select * from expense_voucher where acc_name_cr='$acc_name' and user_id='$userid'";
$result2c=$conn->query($sql2c);
while($ppp1c = $result2c->fetch_assoc())
{
$tr_no1=$ppp1c['tr_no'];
$recdate1=$ppp1c['date'];
$discription1=$ppp1c['discription'];
$acc_name_dr=$ppp1c['acc_name_dr'];
$recamount1=$ppp1c['amount'];
$month_name1=$ppp1c['month_name'];
  $sql102c = "Insert into accledger (id,date,month_name,tr_no,acc_name,discription,acc_type,dr_amount,cr_amount,balance,user_id) values (null,'$recdate1','$month_name1','$tr_no1','$acc_name','$discription1','$acc_name_dr','0','$recamount1','0','$userid')";
$conn->query($sql102c);
 } 
 $sql2c1 = "select * from cashrec where acc_name='$acc_name' and user_id='$userid'";
$result2c1=$conn->query($sql2c1);
while($ppp1c1 = $result2c1->fetch_assoc())
{
$id1=$ppp1c1['id'];
$date1=$ppp1c1['date'];
$ven_name=$ppp1c1['ven_name'];
$recamount11=$ppp1c1['netamount'];
$month_name11=$ppp1c1['month_name'];
  $sql102c1 = "Insert into accledger (id,date,month_name,tr_no,acc_name,discription,acc_type,dr_amount,cr_amount,balance,user_id) values (null,'$date1','$month_name11','$id1','$acc_name','Cash Receipt Against Sale Invoice Books/Stititionary/Uniform Etc','$ven_name','$recamount11','0','0','$userid')";
$conn->query($sql102c1);
 } 
?>
                                <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
								<h4><center><? echo "For the Period of From:" . $from_date . "To:" . $to_date; ?></center></h4>
								<h4><center><? echo $acc_name; ?></center></h4>
                                    <thead>
									<?php
                                       echo "<tr>";
echo "<th > Date </th>";
echo "<th > Month </th>";
echo "<th > Voucher# </th>";
echo "<th > Accounts Name </th>";
echo "<th > Discription </th>";
echo "<th > Amount Dr </th>";
echo "<th > Amount Cr </th>";



echo "</tr>";
?>
                                    </thead>
									
                                    <tbody>
									<?php
									$sql = "SELECT * FROM accledger where acc_name='$acc_name' and user_id='$userid' order by date";
$result=$conn->query($sql);
                                       while($row = $result->fetch_assoc())
 
  {
 
   echo "<tr>";
   echo "<td>" .$row['date'] . "</td>";
   echo "<td>" .$row['month_name'] . "</td>";
echo "<td>" .$row['tr_no'] . "</td>";
   echo "<td>" .$row['acc_type'] .  "</td>";
   echo "<td>" .$row['discription'] .  "</td>";
   echo "<td>" .$row['dr_amount'] .  "</td>";
   echo "<td>" .$row['cr_amount'] .  "</td>";
  
   
  echo "</tr>";

$trecord=$trecord + 1;
$tfeerec=$tfeerec + $row['dr_amount'];
$tfeerec1=$tfeerec1 + $row['cr_amount'];
$bal=$tfeerec - $tfeerec1;

  }
 
   echo "<tr>";
	echo "<td colspan=5 align=right><b> Total </b></td>";
	
	  
		echo "<td><b>" .$tfeerec . "</b></td>";
		echo "<td><b>" .$tfeerec1 . "</b></td>";
		
		
		
	  echo "</tr>";
	  echo "<tr>";
	echo "<td colspan=5 align=right><b> Net Balance </b></td>";
	
	  
		echo "<td colspan=2><b>" .$bal . "</b></td>";
		
		
		
	  echo "</tr>";
	  
  ?>
                                       
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>


                </div>
            </div><!-- .animated -->
        </div> <!-- .content -->
    </div><!-- /#right-panel -->

    <!-- Right Panel -->

   <?php include("includes/footermenu.php") ?>

</body>

</html>
<?php
}
?>