<?PHP

session_start();

include 'connect.php';

if(isset($_SESSION['adminemail']))

{

$user=$_SESSION['adminemail'];



$gtp=mysql_query("select * from admin where username='$user'");

$gtp1=mysql_fetch_array($gtp);



include 'top.php';

?>







<div class="main-content">

				<div class="main-content-inner">

					<div class="breadcrumbs ace-save-state" id="breadcrumbs">

						<ul class="breadcrumb">

							<li>

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

								<a href="#">Home</a>

							</li>

							<li class="active">Payslip</li>

						</ul><!-- /.breadcrumb -->

					</div>



					<div class="page-content">

			



						<div class="page-header">

                        

<?php



$aca=mysql_query("select * from financial where user='$user' order by ID desc");

$aca1=mysql_fetch_array($aca);



$financial=$aca1['financial'];



?>                        

                        

							<table style="width:100%;">

                        

                        <tr><td style="width:50%;">

                        

							<h1>

								Payslip

							</h1>

                            

                            </td>

                            

                            <td style="width:50%; text-align:right; padding-right:15px; font-size:15px;">

                            

                            <i class="fa fa-calendar"></i>&nbsp; <?php echo $financial; ?>

                            

                            </td></tr></table>

                            

						</div><!-- /.page-header -->

<br />



						<div class="row">

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

                            

								<!-- PAGE CONTENT BEGINS -->

                               

                               

<?php



if($_GET['id'])

{

$id=$_GET['id'];

$month=$_GET['month'];

$year=$_GET['year'];



$ee=mysql_query("select * from employee where ID='$id'");

$ee1=mysql_fetch_array($ee);



$sql=mysql_query("select * from payslip where empid='$ee1[empid]' and month='$month' and year='$year'");

$sql1=mysql_fetch_array($sql);



$eid=$sql1['empid'];



$month = $sql1['month'];

$year = $sql1['year'];

$y=$sql1['year'];



$inf=$year.'-'.$month.'-'.'01';



$emp=mysql_query("select * from employee where empid='$eid'");

$emp1=mysql_fetch_array($emp);



$sal=mysql_query("select * from salary where empid='$eid' and incrementfrom<='$inf' order by ID desc");

$sal1=mysql_fetch_array($sal);



if($month>=04)

{

$year=$year;

$year1=$year+1;

}

elseif($month<04)

{

$year1=$year;

$year=$year-1;

}



echo'<br />



<center><table width="85%">



<tr><td id="page" style="width:25%;">Employee Name </td><td>:</td> <td id="page">'.$emp1['name'].'</td><td width="11%">Date </td><td>:</td><td> '.date('d-m-Y',strtotime($sql1['date'])).'</td></tr>

<tr><td id="page">Employee ID </td><td>:</td> <td id="page">'.$sql1['empid'].'</td><td width="11%">';



$sum=mysql_query("select COUNT(ID) from payslip where empid='$eid' and MONTH(date)='$month' and YEAR(date)='$y'");

$sum1=mysql_result($sum,0);



if($sum1>0)

{

$ret=mysql_query("select * from payslip where empid='$eid' and month='$month' and year='$y'");

$ret1=mysql_fetch_array($ret);



echo'Payslip No </td><td>:</td><td> '.$ret1['ID'].'</td></tr>';

}

else

{

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

}

echo'<tr><td id="page" style="width:20%;">Financial Year </td><td>:</td> <td id="page">'.$year.' - '.$year1.'</td><td width="11%"></td><td></td><td></td></tr></table>



<br /><table class="table table-striped table-bordered table-condensed">';



$sel=mysql_query("select COUNT(ID) from payslip where empid='$eid' and month='$month' and year='$y'");

$sel1=mysql_result($sel,0);



if($sel1>0)

{



$get=mysql_query("select * from payslip where empid='$eid' and month='$month' and year='$y'");

$get1=mysql_fetch_array($get);



$sum=mysql_query("select *,sum(amount) as amount from advance where empid='$eid' and month='$month' and year='$y'");

$sum1=mysql_fetch_array($sum);



if($get1['lop']=='')

{

$l=0;

}

else

{

$l=$get1['lop'];

}



$n=$get1['amount'];



echo'<thead><th style="width:55%; text-align:center;">Description</th><th style="text-align:center;">Amount (Rs.)</th></thead>



<tr><td style="padding-left:5px;">Gross Pay</td><td style="text-align:right; color:#FF8000;">'.number_format($sal1['salary'],2,'.','').'</td></tr>

<tr><td style="padding-left:5px;">Loss of Pay</td><td style="text-align:right; color:red;">'.number_format($l,2,'.','').'</td></tr>

<tr><td style="padding-left:5px;">OT</td><td style="text-align:right; color:red;">'.number_format($get1['overtime'],2,'.','').'</td></tr>

<tr><td style="padding-left:5px;">Incentive</td><td style="text-align:right;">'.number_format($get1['incentive'],2,'.','').'</td></tr>

<tr><td style="padding-left:5px;">Allowance</td><td style="text-align:right;">'.number_format($get1['allowance'],2,'.','').'</td></tr>

<tr><td style="padding-left:5px; color:red;">Advance</td><td style="text-align:right;">-'.number_format($sum1['amount'],2,'.','').'</td></tr>



<tr><td style="padding-left:5px;">Net Pay</td><td style="text-align:right; color:green;">'.number_format($n,2,'.','').'</td></tr>';



}

echo'</table>';



$total=$n;

include 'num_words.php';



echo'<br /></center>';



?>

<center>

<script type="text/javascript">

// Popup window code

function newPopup(url) {

	popupWindow = window.open(

		url,'popUpWindow','height=500,width=1000,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,onscreendisplay=yes,menubar=no,location=no,directories=no,status=yes')

}

</script>

    <br />

<br />

<a href="JavaScript:newPopup('printpayslip.php?id=<?php echo $id ?>&empid=<?php echo $eid ?>');" title="Print"><i class="splashy-printer"></i></a></center>

<?php



echo"<br /><center><a href='salary.php'>Back</a></center>";



}

?>

                               

                                

                               

								<!-- PAGE CONTENT ENDS -->

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

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

					



</div><!-- /.page-content -->

				</div>

			</div><!-- /.main-content -->





<?php

include 'bottom.php';

}

else

{



 header("location:login.php");

}

?>