<?php require "_header.php";
include "Numbers/Words.php";

 ?>
 <style type="text/css">
	.table-report{
		font-family:Verdana, Geneva, sans-serif;
		font-size:12px;
		text-align:left;
		border-right:0px none;
		border-bottom:0px none;
		
	}
	.table-report-inner{
		font-family:Verdana, Geneva, sans-serif;
		font-size:12px;
	}
	.table-report tr{
		padding:2px 2px 2px 2px;
	}
	.table-report td{
		padding:2px 2px 2px 2px;
		border-top:0px none;
		border-left:0px none;
	}
	.table-report th{
		padding:2px 2px 2px 2px;
		font-weight:bold;
	
		border-top:0px none;
		border-left:0px none;
	}
	.table-report-footer{ 
 	 font-family:Verdana, Geneva, sans-serif; 
 	font-size:10px; 
    }
	.college_name{
		font-family:QTAbbie;
		font-size:22px;	
		font-weight:bold;
		padding:2px 2px 2px 2px;
		text-align:center;
	}
	.college_address
	{
		font-family:Tahoma, Geneva, sans-serif;
		font-size:11px;	
		text-align:center;
		padding:2px 2px 2px 2px;
	}
	.report_name{
		font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
		font-size:13px;	
		background-color:#CCC;
		text-align:center;
		font-weight:bold;
		padding:2px 2px 2px 2px;
	}
	.left{
		float:left;
		width:50%;
	}
	.right{
		float:right;
		width:50%;
	}
	.break 
	{ 
	page-break-before: always; 
	}
		
</style>
<div id="main-report" align="center">
<center><h4>Employee Salary slip Yearwise</h4></center>
<?php 
if($_REQUEST['Yearfrom']=="" && $_REQUEST['month_idfrom']=="" )
{
?>
	<script language="javascript" type="text/javascript">
		location.href='report-form-salary-register-monthly.php';
	</script>
<?php
}
elseif($_SESSION['VedantnrCollegeId']!="" && isset($_SESSION['VedantnrCollegeId'])) 
{ 
		$section_id		= 	Escape($_REQUEST['sectionid']);
	    $salaryhead		= 	Escape($_REQUEST['head_val']);
	    $yearfrom		= 	Escape($_REQUEST['Yearfrom']);
		$year			=    Escape($_REQUEST['Yearfrom']);
  		$yearto			= 	Escape($_REQUEST['Yearto']);
	    $monthfrom		= 	Escape($_REQUEST['month_idfrom']);
		$monthto		= 	Escape($_REQUEST['month_idfrom']) == 1 ? 12 : Escape($_REQUEST['month_idfrom']) - 1;
		$employee_id 	=  Escape($_REQUEST['ID']);
		$header_row_string = "Employee Salary slip Yearwise";
		$record = 0;

		$condition = "";

		$months = "";
		$nmnth = "";
		$mnthflg = 0;
		for ($i = $monthfrom; $i != $monthto; $i++) {
			$i;
			if ($i == 13) {
				$i = 1;
				$mnthflg = 1;
			}
			if ($mnthflg == 0)
				$months .= $i . ",";
			if ($mnthflg == 1)
				$nmnth .= $i . ",";
			if ($i == 1 && $monthto == 1) {
				$i = 0;
				$mnthflg = 1;
			}
		
		}
		
		if($monthto != 1)
		{
		$nmnth .= $monthto;
		}
		else
		$nmnth = substr($nmnth,0,strlen($nmnth)-1);
		$months = substr($months,0,strlen($months)-1);
		
		$qry="";
	
	     if(isset($_REQUEST["ID"])){  
			if($employee_id!=""){
				$condition.=" and employee_id = '$employee_id'";
			}
		}	
			$nw = new Numbers_Words();
		$objEmp = new EmployeeMgmt();
		$out1 = $objEmp->getAllRecords($limit,$start,$condition,$order_field,$order_type);	
		
		if(dbRows($out1)>0) {ob_start();
		while($row1=dbArray($out1)){
			extract($row1);
			
	$year = $yearfrom;
    $startMonth = 0;
	$arrmonthname = array("January","February","March","April","May","June","July","August","September","October","November","December");
	$headMonth = $monthfrom;
	$month = 1;
	if($headMonth == 13){$year++;}
	if($headMonth == 13 ) $headMonth = 1;
	 //$headMonth += 1;
	 
	 				$totalbasic=0;
					$totalda=0;
					$totaldp=0;
					
					
					$totalhra=0;
					$totalmedi=0;
					$totalcca=0;
					
					$totalpta=0;
					$totalprinall=0;
					$totalsupall=0;
					
					$totalhsall=0;
					$totalwasall=0;
					$totalcashall=0;
					
					$totalfall=0;
					$totalhall=0;
					$totalta=0;
					
					$totalle=0;
					$totalltc=0;
					$totalspay=0;
					
					$totalbonus=0;
					$totalarias=0;
					$totaladdda=0;
					
					$totalir=0;
					$totalotherin=0;
					
					$totalgpf=0;
					$totalcpf=0;
					
					$totalgpfl=0;
					$totalcpfl=0;
					$totalhl=0;
					
					$totalpt=0;
					$totallic=0;
					$totalit=0;
					
					$totalfood=0;
					$totalfest=0;
					
					$totals1=0;
					$totals2=0;
					
					$totalpli=0;
					$totalrec=0;
					$totalgi=0;
					
					$totalmr1=0;
					$totalmr2=0;
					
					$totalod=0;
					
					
					$totalgrosp=0;
					$totalgrosd=0;
					$totalnetp=0;
	
	for($i=0;$i<12;$i++)
	{
		$result=getheaddetail($section_id,$employee_id,$headMonth++,$year);
	 $row=dbArray($result);
	 if(dbRows($result)>0)
	 { 
	 $record++;
			 
					$vcol1 = explode("<br/>",$row['col1'] );
					$totalbasic+=$vcol1[0];
					$totalda+=$vcol1[1];
					$totaldp+=$vcol1[2];
					
					$vcol2 = explode("<br/>",$row['col2']);
					$totalhra+=$vcol2[0];
					$totalmedi+=$vcol2[1];
					$totalcca+=$vcol2[2];
					
					$vcol3 = explode("<br/>",$row['col3']);
					$totalpta+=$vcol3[0];
					$totalprinall+=$vcol3[1];
					$totalsupall+=$vcol3[2];
					
					$vcol4 = explode("<br/>",$row['col4']);
					$totalhsall+=$vcol4[0];
					$totalwasall+=$vcol4[1];
					$totalcashall+=$vcol4[2];
					
					$vcol5 = explode("<br/>",$row['col5']);
					$totalfall+=$vcol5[0];
					$totalhall+=$vcol5[1];
					$totalta+=$vcol5[2];
					
					$vcol6 = explode("<br/>",$row['col6']);
					$totalle+=$vcol6[0];
					$totalltc+=$vcol6[1];
					$totalspay+=$vcol6[2];
					
					$vcol7 = explode("<br/>",$row['col7']);
					$totalbonus+=$vcol7[0];
					$totalarias+=$vcol7[1];
					$totaladdda+=$vcol7[2];
					
					$vcol8 = explode("<br/>",$row['col8']);
					$totalir+=$vcol8[0];
					$totalotherin+=$vcol8[1];
					
					$vcol9 = explode("<br/>",$row['col9']);
					$totalgpf+=$vcol9[0];
					$totalcpf+=$vcol9[1];
					
					$vcol10 = explode("<br/>",$row['col10']);
					$totalgpfl+=$vcol10[0];
					$totalcpfl+=$vcol10[1];
					$totalhl+=$vcol10[2];
					
					$vcol11 = explode("<br/>",$row['col11']);
					$totalpt+=$vcol11[0];
					$totallic+=$vcol11[1];
					$totalit+=$vcol11[2];
					
					$vcol12 = explode("<br/>",$row['col12']);
					$totalfood+=$vcol12[0];
					$totalfest+=$vcol12[1];
					
					$vcol13 = explode("<br/>",$row['col13']);
					$totals1+=$vcol13[0];
					$totals2+=$vcol13[1];
					
					$vcol14 = explode("<br/>",$row['col14']);
					$totalpli+=$vcol14[0];
					$totalrec+=$vcol14[1];
					$totalgi+=$vcol14[2];
					
					$vcol15 = explode("<br/>",$row['col15']);
					$totalmr1+=$vcol15[0];
					$totalmr2+=$vcol15[1];
					
					$vcol16 = explode("<br/>",$row['col16']);
					$totalod+=$vcol16[0];
					
					
					$vcol17 = explode("<br/>",$row['col17']);
					$totalgrosp+=$vcol17[0];
					$totalgrosd+=$vcol17[1];
					$totalnetp+=$vcol17[2];
					
					
	 
	 }
	
	 }
	
?>
<table cellpadding="0" border="0" cellspacing="0" width="100%" align="center"   frame="box" class="table-report">
<tr height="30">
 	
	 <td align="center" height="30" width="10%" valign="center" ><img src="<?php echo $CollegeImagePath . $_SESSION["VedantnrCollegeLogo"]; ?>" alt="College Logo"
	 style="width: 80px;  float: left; margin-right: 10px;"></td>
	   <td colspan="3" >
	   <center>
			<div style="display: inline-block; vertical-align: middle;">
								<b style="font-size: 30px;"><?php echo $_SESSION["VedantnrCollegeName"]; ?></b><br>
								<?php echo $_SESSION["VedantnrCollegeAddress"]; ?><br>
								Phone: <?php echo $_SESSION["VedantnrCollegePhone"]; ?>&nbsp;&nbsp;
								Email: <?php echo $_SESSION["VedantnrCollegeEmail"]; ?>
							</div>
 </tr>
 <tr height="30">
	<th colspan="4"><b>Salary Statement for the Month of</b> - <?php print $_REQUEST['monthnamefrom']."-".$yearfrom." to ".$_REQUEST['monthnameto']."-". $yearto ?>
</tr>	

</tr>
	<tr height="30" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
		<td width="30%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>Employee Name</b></td>
		<td width="30%" colspan="3"><?php print $row1['employee_name'];?></td>
		</tr>	
	
<tr height="30">
		<td width="30%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>Employee Number</b></td>
		<td width="30%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><?php print $row1['employee_no'];?></td>
		<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>Joining Date</b></td>
		<td><?php print   date("d/m/Y",strtotime($row1['employee_schooljoindate']));?></td>
</tr>	
<tr height="30">
		<td width="30%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>Account Number</b></td>
		<td width="30%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><?php print $row1['employee_bankacno'];?></td>
		<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>Designation</b></td>
		<td><?php print $row1['employee_designation1'];?></td>
</tr>	
<tr height="30">
		<td width="30%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>Day Present</b></td>
		<td width="30%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">30</td>
		<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>Department</b></td>
		<td><?php print $row1['BranchName'];?> Department</td>
</tr>


<tr height="30" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
		<td width="30%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>Leave Without Pay</b></td>
		<td width="30%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><?php print $totalod;?></td>
		<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>P.F. No.</b></td>
		<td><?php print $row1['employee_gpfacno'];?></td>
</tr>
<tr height="30">
		
		<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>Pay Scale</b></td>
		<td colspan="3" ><?php print $row1['payscale'];?></td>
</tr>

<tr >
<table cellpadding="0" border="1" cellspacing="0" width="60%" align="center" class="table-report">
 <tr height="30">
 	<td colspan="2" ><center><b>Earnings</b></center></td>
 	<td width="1%"></td>
 	<td colspan="3" ><center><b>Deductions</b></center></td>
</tr>
 <tr height="30">
 	<td><center><b>Particulars</b></center></td>
 	<td><center><b>Amount</b></center></td>
 	<td></td>
	<td><center><b>Particulars</b></center></td>
 	<td><center><b>Amount</b></center></td>
 	</tr>
 		
 	<tr height="30">
 		<td width="26%">Basic Pay</td>
 	  <td width="26%"><div align="right"><?php print $totalbasic;?></div></td>	
 	<td></td>
 	  <td width="26%">Provident Fund</td>
 	 <td ><div align="right"><?php print $totals2;?></div></td>
		
		<tr height="30">
 	<td>AGP/GP/DP</td>
 	  <td ><div align="right"><?php print $totaldp;?></div></td>
 	  <td></td>
 	  <td>Professional Tax</td>
 	 <td ><div align="right"><?php print $totalpt;?></div></td>
	</tr>
	
		<tr height="30">
 	<td>Dearness Allowance</td>
 	 <td><div align="right"><?php print $totalda;?></div></td>
 	<td></td>
 	 <td>TDS</td>
 	 <td ><div align="right">-</div></td>
	</tr>
	<tr height="30">
 	<td>CLA</td>
 	 <td><div align="right">-</div></td>
 	  <td></td>
 	  <td>Leave Without Pay</td>
 	 <?php if($totalmr2 != '')
 	 {
 	 	$a = $totalmr2 * $totalod
 	 	?>
 	 	
 	  <td ><div align="right"><?php print $totalmr2;?></div></td>
 	 <?php
 	 }
 	 else
 	{
 	 ?>
 	 <td ><div align="right">-</div></td>
	<?php
}
?>
	</tr>
	<tr height="30">
 	<td>House Rent Allowance</td>
 	  <td ><div align="right"><?php print $totalhra;?></div></td>
 	    <td></td>
 	    <td>Loan</td>
 	 <td ><div align="right">-</div></td>
	</tr>
	<tr height="30">
	<td>Travelling Allowance</td>
 	   <td ><div align="right"><?php print $totalta; ?></div></td>
 	    <td></td>
 	    <td>Security Deposit</td>
 	 <td ><div align="right"><?php print $totalpli;?></div></td>
 	   
	</tr>
	<tr height="30">
	<td>Medical Allowance</td>
 	   <td ><div align="right"><?php print $totalmedi;?></div></td>
 	    <td></td>
 	     <td>Credit Society</td>
 	 <td><div align="right"><?php print $totals1;?></div></td>
	</tr>
	
	<tr height="30">
	<td></td>
 	   <td ></td>
 	<td></td>
 	     <td>Bus Transport Charge</td>
 	  <td ><div align="right"><?php print $totalrec; ?></div></td>
	</tr>
	<tr height="30">
	<td><div align="left">Total Earnings</div></td>
 	   <td ><div align="right"><?php print $totalgrosp;?></div></td>
 	    <td></td>
 	     <td>Other</td>
 	 <td><div align="right">-</div></td>
	</tr>
	
	<tr height="30">
	<td>Net Salary</td>
 	   <td ><div align="right"><?php print $totalnetp;?></div></td>
 	     <td></td>
 	     <td>Total Deductions</td>
 	 <td><div align="right"><?php print $totalgrosd;?></div></td>
	</tr>
	<tr  height="30">
		<th colspan="5"><b>In Words - <?php  echo strtoupper($nw->toWords($totalnetp)." Rs");?></b> </th>
	</tr>	
	<tr height="30">
		<th colspan="5"><center><b>THIS IS THE COMPUTER GENERATED SLIP. NO NEED SIGNATURE</b></center></th>
	</tr>	
  </table>  
</tr>
</table>

	
		<?php if(dbRows($result)!=1 && $record!=dbRows($result)) {
				echo '<div class="break"></div>';	
			} } $HtmlCode= ob_get_contents();
			ob_end_flush();
			$HtmlUrl 	=	"employee-salary-slip-yearwise-report-". $_SESSION["VedantnrUserId"].".html";
			$HtmlPath 	=	"report/".$HtmlUrl;
		
			createHTMLReportPage($header_row_string,$HtmlUrl,$HtmlPath,$HtmlCode);?> 
	
	</script>
		<br/>
		<form name="frm" id="frm" action="" method="post">		
			<input type="hidden" name="txtFile" id="txtFile" value="<?php echo $HtmlUrl ;?>" />
            
<input type="button" name="btnPrint" id="btnPrint" value="Print" onClick="SetPageAction('PRINT');"/>
			
			<input type="button" name="btnHtml" id="btnHtml" value="Create HTML" onclick="SetPageAction('HTML');"/>
			<input type="button" name="btnWord" id="btnWord" value="Create WORD" onclick="SetPageAction('WORD');"/>
			<input type="button" name="btnExcel" id="btnExcel" value="Create EXCEL" onclick="SetPageAction('Excel');"/>
		</form>
		<script language="javascript" type="text/javascript">
			function SetPageAction(varAction) {
				if(varAction=="PRINT"){			
                        document.frm.action="print/create-print.php";
                        document.frm.submit();
                    }
				if(varAction=="PDF"){			
					document.frm.action="convertpdf/create-pdf.php";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if(varAction=="HTML"){
					document.frm.action="<?php echo $HtmlPath ;?>";
					document.frm.target = "_blank";
					document.frm.submit();
				}
				else if(varAction=="WORD"){
					document.frm.action="convertword/create-word.php";
					document.frm.target="_blank";
					document.frm.submit();
				}
				else if(varAction=="Excel"){
					document.frm.action="convertword/create-excel.php";
					document.frm.target="_blank";
					document.frm.submit();
				}
			}
		</script>
	
	
	<?php		
			
	}
	else
	{
	  echo "<b>No Data Found</b>";
	}
	 }else {
       echo "Session Expired"; 
     }
	 ?>

</div>
<?php require "_footer.php";?>
<?php
function getheaddetail($section,$employeeid,$month,$year)
{
 //$month-=1;

 $query = "SELECT     Concat(es.basic,'<br/>',es.da,'<br/>',es.dpay)as col1,
					  Concat(es.hra,'<br/>',es.medical_all,'<br/>',es.cla)as col2,
					  Concat(es.pta,'<br/>',es.princi_all,'<br/>',es.sup_all)as col3,
					  Concat(es.hs_all,'<br/>',es.wash_all,'<br/>',es.cash_all)as col4,
					  Concat(es.family_all,'<br/>',es.handicap_all,'<br/>',es.ta)as col5,
					  Concat(es.leaveencash,'<br/>',es.ltc,'<br/>',es.sp_pay)as col6,
					  Concat(es.bonus,'<br/>',es.arias_all,'<br/>',es.add_da)as col7,
					  Concat(es.ir1,'<br/>',es.oincome1)as col8,
					  Concat(es.gpf,'<br/>',es.cpf)as col9,
					  Concat(es.gpfloan,'<br/>',es.cpfloan,'<br/>',es.houseloan)as col10,
					  Concat(es.pftax,'<br/>',es.lic,'<br/>',es.incometax)as col11,
					  Concat(es.foodadv,'<br/>',es.festadv)as col12,
					  Concat(es.society,'<br/>',es.society_2)as col13,
					 Concat(es.pli,'<br/>',es.recadj,'<br/>',es.groupins)as col14,
					  Concat(es.misec1,'<br/>',es.misrec2)as col15,
					  es.odeduct1 as col16,
					 
					  Concat(es.grosspay,'<br/>',es.grossdeduction,'<br/>',es.netpay)as col17					 
				  FROM cms_employeesalary es, 
					   cms_employeemaster em 
				  WHERE es.college_id='1' and 					
						em.college_id='1' and					
						es.employee_id = em.employee_id "; 
	$condition = "";
	
	if($employeeid != ""){
		$condition .= " and es.employee_id = $employeeid";
	}
	
	if($year != ""){
		$condition .= " and es.year_id = $year";
	}
	if($month != ""){
		$condition .= " and es.month =$month";
	}	
	$condition.=" ORDER BY es.employee_id ASC";
 	$query.=$condition;
	$out = dbQuery($query);
	return $out;
}	
	
?>