<html>
<head>
<?php 
include ('check_session.php');
include ('header.php');
include "finping.php";
include "fetchbalance.php";
$cmpname=$_POST['cmpname'];
$curmn=date("m");
$curyr=date("Y");
if($curmn>'3')
{
	$edate=date("30-09-Y");
}
else
{
	$curyr--;
	$edate=date("30-09-$curyr");
}


?>
<script type="text/javascript">     
        function PrintDiv() {    
           var divToPrint = document.getElementById('divToPrint');
           var popupWin = window.open('', '_blank', '');
           popupWin.document.open();
           popupWin.document.write('<html><body  style="font-family:verdana;" onload="window.print()"><center><?php echo $cmpname ?><br>DEPRECIATION VIEW<br></center>' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
     </script>
<script type="text/javascript">
function OthersBill(val){
 var element=document.getElementById('bill');
 if(val=='Others')
   element.style.display='block';
 else  
   element.style.display='none';
}

</script>
<script type="text/javascript">
function Acfrom(val){
 var element=document.getElementById('acfrom');
 if(val!='Cash')
   element.style.display='block';
 else  
   element.style.display='none';
}

</script> 
<title>SRI ATHISAKTHI GROUPS</title>
<meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="css/style.css">
   <link href="boostrap/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

</head>
<body>
<div >
	<h2 style="text-align:center;color:midnightblue;font-size:28px;"><u><?php echo $cmpname ;?></u></h2>
	<input style="font-size:30px;" id="" name="cmpname" placeholder="" class="textbox" type="hidden" value="<?php echo $cmpname ;?>"   />
</div>
<h3 style="font-size:28px">DEPRECIATION VIEW</h3>
<div id='divToPrint'>
<style>
table {
	   
	   border-collapse: collapse;
	   font-size:15px;
}
th {
   background-color:grey;
   color: black;
   text-align: center;
   width:1%;
   height:15px;
   border:1px solid #4A235A;
   }
td {
   background-color:#B9DAD6  ;
   color: #black;
   border:1px solid #4A235A;
   text-align: center;
   width: 1%;
   padding-right:2%;
   }
.total{
	text-align:center;
	color:red;
	text-decoration:underline;
}
.css1{
	text-align:center;
	font-size:17px;;
	width:3%;
}

   </style>
<?php
$sum=0;
$sum1=0;
$sum2=0;
$sum3=0;
$yr=date('y');
//$yr=$yr-1;
echo "<table>";  
echo "<tr>
		<th  class='center'>S.No</th>
		<th class='css1'>Type</th>
		<th  class='left'>Total Amt</th>
		<th  class='left'>On 30-09-$yr</th>
		<th  class='left'>Percentage</th>
		<th  class='left'>Depreciation</th>
		<th  class='left'>Year End Balance</th>
		</tr>";  
		$sno=0;
		
		
		
		
		
		
		
		

$sql="SELECT SUM(amount) as tfa FROM sac.expense WHERE  cmpname='$cmpname' AND type='FURNITURE EXPENSE (10%)'";  
$ret = pg_query($db, $sql);		
while($row = pg_fetch_assoc($ret)) {
	$tfa = $row['tfa'];
	$sno++;
	}
	

$sql1="SELECT SUM(amount) as fd FROM sac.expense WHERE  cmpname='$cmpname' AND type='FURNITURE EXPENSE (10%)' AND date<='$edate'";
$ret1 = pg_query($db, $sql1);
while($row1 = pg_fetch_assoc($ret1)) {
	$fd = $row1['fd'];
}	
$dep1=$fd/10;	
$dep1=round($dep1);

$tfa=round($tfa);

$sum=$sum+$tfa;
$sum1=$sum1+$fd;
$sum2=$sum2+$dep1;
$yr1=$tfa-$dep1;
$sum3=$sum3+$yr1;
echo "<tr><td width='200'>$sno</td> ";
echo "<td width='200'>FURNITURE EXPENSE (10%)</td> ";
echo "<td width='200'>$tfa</td> ";
echo "<td width='200'>$fd</td> ";
echo "<td width='200'>10%</td> ";
echo "<td width='200'>$dep1</td> ";
echo "<td width='200'>$yr1</td></tr> ";



		
		
		
		
		
		
		
		
$sql="SELECT SUM(amount) as tca FROM sac.expense WHERE  cmpname='$cmpname' AND type='COMPUTER PURCHASE (40%)'";  
$ret = pg_query($db, $sql);
while($row = pg_fetch_assoc($ret)) {
	$tca = $row['tca'];
	$sno++;
}

$sql1="SELECT SUM(amount) as cd FROM sac.expense WHERE  cmpname='$cmpname' AND type='COMPUTER PURCHASE (40%)' AND date<='$edate'";  
$ret1 = pg_query($db, $sql1);
while($row1 = pg_fetch_assoc($ret1)) {
	$cd = $row1['cd'];
}
$dep=$cd*40;
$dep=$dep/100;
$dep=round($dep);

$yr=$tca-$dep;
$tfa=round($tca);


$sum=$sum+$tca;
$sum1=$sum1+$cd;
$sum2=$sum2+$dep;
$sum3=$sum3+$yr;
echo "<tr><td width='200'>$sno</td> ";
echo "<td width='200'>COMPUTER PURCHASE (40%)</td> ";
echo "<td width='200'>$tca</td> ";
echo "<td width='200'>$cd</td> ";
echo "<td width='200'>40%</td> ";
echo "<td width='200'>$dep</td> ";
echo "<td width='200'>$yr</td></tr> ";






$sql="SELECT SUM(amount) as toffa FROM sac.expense WHERE  cmpname='$cmpname' AND type='OFFICE EQUIP. PURCHASE (15%)'";  
$ret = pg_query($db, $sql);
	
		
while($row = pg_fetch_assoc($ret)) {
	$toffa = $row['toffa'];
	$sno++;
	
}
$sql1="SELECT SUM(amount) as offd FROM sac.expense WHERE  cmpname='$cmpname' AND type='OFFICE EQUIP. PURCHASE (15%)' AND date<='$edate'";
$ret1 = pg_query($db, $sql1);
while($row1 = pg_fetch_assoc($ret1)) {
	$offd = $row1['offd'];
}	

$dep2=$offd*15;
$dep2=$dep2/100;
$dep2=round($dep2);

$sum2=$sum2+$dep2;
$yr2=$toffa-$dep2;
$toffa=round($toffa);


$sum3=$sum3+$yr2;


$sum=$sum+$toffa;
$sum1=$sum1+$offd;

echo "<tr><td width='200'>$sno</td> ";
echo "<td width='200'>OFFICE EQUIP. PURCHASE (15%)</td> ";
echo "<td width='200'>$toffa</td> ";
echo "<td width='200'>$offd</td> ";
echo "<td width='200'>15%</td> ";
echo "<td width='200'>$dep2</td> ";
echo "<td width='200'>$yr2</td></tr> ";

echo "<tr><td width='200'></td> ";
echo "<td width='200'></td> ";
echo "<td width='200'>$sum.00</td> ";
echo "<td width='200'>$sum1.00</td> ";
echo "<td width='200'></td> ";
echo "<td width='200'>$sum2</td> ";
echo "<td width='200'>$sum3</td></tr> ";

echo "</table></div>";
include "fetchbalance.php"; 	
?>
<br>
<div>
  <div>
    <center>
	<input type="button" class="submit" onclick="location.href='ldepreciation.php'" value="Back"></center><br>
			<center><button type="submit" value="Submit" class="submit" onclick="PrintDiv();" >Print</button></center>

  </div>
</div>

</body>
</html>