<?php require "_header.php";
?>
<div id="main-report" align="center">
	<center>
		<h4>Employee Salary Register Monthly</h4>
	</center>
	<?php
	if ($_REQUEST['Year1'] == "" && $_REQUEST['month_id'] == "" && $_REQUEST['sectionid'] == "") {
		?>
		<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']);
		$year = Escape($_REQUEST['Year1']);
		$month = Escape($_REQUEST['month_id']);
		$monthname = Escape($_REQUEST['monthname']);

		$objEmployeeSalaryMgmt = new EmployeeSalaryMgmt();
		$sno = 1;

		$header_row_string = "Employee Salary Register Monthly";

		$condition = "";

		if ($year != "") {
			$condition .= " and es.year_id = $year";
		}
		if ($month != "") {
			$condition .= " and es.month =$month";
		}
		$condition .= " and em.employee_active ='Yes'";

		$condition .= " ORDER BY es.employee_id ASC";
		$out1 = $objEmployeeSalaryMgmt->getAllEmployeesalaryRecords(0, 0, $condition, "", "");
		ob_start(); //starting for 
		?>
		<h1>

			<b>Month-Year:</b><?php print $monthname . "-" . $year; ?>
		</h1>
		<table class="report" id="report-table-lanscap" style="font-size:9px">
			<thead>
				<tr>
					<th align="center" width="7%" rowspan="2"><b>Sr No</b></th>
					<th align="center" width="7%" rowspan="2"><b>Employee No</b></th>
					<th align="center" width="7%" rowspan="2"><b>Employee Name</b></th>
					<th align="center" width="3%" rowspan="2"><b>Designation.</th>
					<th align="center" rowspan="2" width="7%"><b>Date Of Joining</th>
					<th align="center" colspan="12">
						<Center>Earning</center>
					</th>
					<th align="center" colspan="11">
						<center>Duduction</center>
					</th>
					<th align="center" width="3%"><b>Net Salary</b></th>
					<th align="center" width="10%"><b>Signature</b></th>
				</tr>
				<tr>

					<th align="center" width="5%"><b>Basic</b></th>
					<th align="center" width="3%"><b>DA</b></th>
					<th align="center" width="7%"><b>HRA</b></th>
					<th align="center" width="3%"><b>CCA/CLA</b></th>
					<th align="center" width="3%"><b>P.T All</b></th>
					<th align="center" width="3%"><b>N.P All</b></th>
					<th align="center" width="3%"><b>Grade Pay</b></th>
					<th align="center" width="3%"><b>Transport</b></th>
					<th align="center" width="3%"><b>Medical</b></th>
					<th align="center" width="3%"><b>Special Pay</b></th>
					<th align="center" width="3%"><b>Bonus</b></th>
					<th align="center" width="3%"><b>Total Earning</b></th>
					<th align="center" width="3%"><b>GPF</b></th>
					<th align="center" width="3%"><b>CPF </b></th>
					<th align="center" width="8%"><b>GPF Adv</b></th>
					<th align="center" width="8%"><b>Prof Tax</b></th>
					<th align="center" width="8%"><b>MIS-R-1</b></th>
					<th align="center" width="3%"><b>MIS-R-2</b></th>
					<th align="center" width="15%"><b>Fes Adv</b></th>
					<th align="center" width="15%"><b>PF</b></th>
					<th align="center" width="3%"><b>CM Fund</b></th>
					<th align="center" width="3%"><b>Fan Adv</b></th>
					<th align="center" width="3%"><b>Total Deduction</b></th>
					<th align="center" width="3%"><b></b></th>

				</tr>
			</thead>
			<?php

			if (dbRows($out1) > 0) {

				while ($row1 = dbArray($out1)) {
					?>
					<tr>
						<td align="left" width="7%"><?php print $sno; ?></td>
						<td align="left" width="7%"><?php print $row1['employee_no']; ?></td>
						<td align="left" width="7%"><?php print $row1['employee_name']; ?></td>

						<td align="center" width="3%"><?php print $row1['employee_designation']; ?></td>
						<td align="center" width="3%"><?php print date('d-m-Y', strtotime($row1['employee_schooljoindate'])); ?></td>


						<td align="center" width="3%"><?php print $row1['basic']; ?></td>
						<td align="center" width="3%"><?php print $row1['da']; ?></td>
						<td align="center" width="3%"><?php print $row1['hra']; ?></td>
						<td align="center" width="3%"><?php print $row1['cla']; ?></td>
						<td align="center" width="3%"><?php print $row1['hs_all']; ?></td>
						<td align="center" width="3%"><?php print $row1['cash_all']; ?></td>
						<td align="center" width="3%"><?php print $row1['dpay']; ?></td>
						<td align="center" width="3%"><?php print $row1['ta']; ?></td>
						<td align="center" width="3%"><?php print $row1['medical_all']; ?></td>
						<td align="center" width="3%"><?php print $row1['sp_pay']; ?></td>
						<td align="center" width="3%"><?php print $row1['bonus']; ?></td>
						<td align="center" width="3%"><?php print $row1['grosspay']; ?></td>


						<td align="center" width="3%"><?php print $row1['gpf']; ?></td>
						<td align="center" width="3%"><?php print $row1['cpf']; ?></td>
						<td align="center" width="3%"><?php print $row1['gpfloan']; ?></td>
						<td align="center" width="3%"><?php print $row1['pftax']; ?></td>
						<td align="center" width="3%"><?php print $row1['misec1']; ?></td>
						<td align="center" width="3%"><?php print $row1['misrec2']; ?></td>
						<td align="center" width="3%"><?php print $row1['festadv']; ?></td>
						<td align="center" width="3%"><?php print $row1['society_2']; ?></td>
						<td align="center" width="3%"><?php print $row1['cpfloan']; ?></td>
						<td align="center" width="3%"><?php print $row1['foodadv']; ?></td>
						<td align="center" width="3%"><?php print $row1['grossdeduction']; ?></td>
						<td align="center" width="3%"><?php print $row1['netpay']; ?></td>

					</tr>
					<?php
					$totalbasic += $row1['basic'];
					$totalda += $row1['da'];
					$totaldp += $row1['dpay'];

					$totalearning += $row1['grosspay'];
					$totaldudction += $row1['grossdeduction'];


					$totalnet = $totalearning - $totaldudction;

					$totalhra += $row1['hra'];
					$totalmedi += $row1['medical_all'];
					$totalcca += $row1['cla'];

					$totalpta += $row1['pta'];
					$totalprinall += $row1['princi_all'];
					$totalsupall += $row1['sup_all'];

					$totalhsall += $row1['hs_all'];
					$totalwasall += $row1['wash_all'];
					$totalcashall += $row1['cash_all'];

					$totalfall += $row1['family_all'];
					$totalhall += $row1['handicap_all'];
					$totalta += $row1['ta'];

					$totalle += $row1['leaveencash'];
					$totalltc += $row1['ltc'];
					$totalspay += $row1['sp_pay'];

					$totalbonus += $row1['bonus'];
					$totalarias += $row1['arias_all'];
					$totaladdda += $row1['add_da'];

					$totalir += $row1['ir1'];
					$totalotherin += $row1['oincome1'];


					$totalgpf += $row1['gpf'];
					$totalcpf += $row1['cpf'];

					$totalgpfl += $row1['gpfloan'];
					$totalcpfl += $row1['cpfloan'];
					$totalhl += $row1['houseloan'];

					$totalpt += $row1['pftax'];
					$totallic += $row1['lic'];
					$totalit += $row1['incometax'];

					$totalfood += $row1['foodadv'];
					$totalfest += $row1['festadv'];

					$totals1 += $row1['society'];
					$totals2 += $row1['society_2'];

					$totalpli += $row1['pli'];
					$totalrec += $row1['recadj'];
					$totalgi += $row1['groupins'];

					$totalmr1 += $row1['misec1'];
					$totalmr2 += $a;

					$totalod += $row1['odeduct1'];

					$totalgrosp += $row1['grosspay'];
					$totalgrosd += $row1['grossdeduction'];
					$totalnetp += $row1['netpay'];
					$sno++;
				}
			} ?>
			<tr>
				<td colspan="5" align="right"><b>Total:</b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalbasic; ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalda; ?></b></td>
				<td align="right" span style="text-align:right;"><b><?php print $totalhra; ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalcca; ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalhsall; ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalcashall; ?></b></td>	
				<td align="right" style="text-align:right;"><b><?php print $totaldp; ?></b></td>	
				<td align="right" style="text-align:right;"><b><?php print $totalta ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalmedi ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalspay ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalbonus ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalearning ?></b></td>



				<td align="right" style="text-align:right;"><b><?php print $totalgpf ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalcpf ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $$totalgpfl ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalpt ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalmr1 ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalmr2 ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalfest ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totals2 ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalcpfl ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalfood ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totaldudction ?></b></td>
				<td align="right" style="text-align:right;"><b><?php print $totalnet ?></b></td>
			</tr>
		</table>
		<?php
		$HtmlCode = ob_get_contents();
		ob_end_flush();
		$HtmlUrl = "employee-salary-register-monthly-report-.html";
		$HtmlPath = "report/" . $HtmlUrl;
		createHTMLReportPage($header_row_string, $HtmlUrl, $HtmlPath, $HtmlCode, false);
		?>
		<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();
				}

				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 "Session Expired";
	}
	?>
	<?php require "_footer.php"; ?>