<?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">
	<br />
	<?php
	if ($_REQUEST['Yearfrom'] == "" && $_REQUEST['month_idfrom'] == "" && $_REQUEST['sectionid'] == "") {
		?>
		<script language="javascript" type="text/javascript">
			location.href = 'report-form-yearly-gross-salary-monthwise-result.php';
		</script>
		<?php
	} elseif ($_SESSION['VedantnrCollegeId'] != "" && isset($_SESSION['VedantnrCollegeId'])) {
		$section_id = Escape($_REQUEST['sectionid']);
		$year = Escape($_REQUEST['Yearfrom']);
		$month = Escape($_REQUEST['month_idfrom']);
		$monthname = Escape($_REQUEST['monthname']);
		$employee_id = Escape($_REQUEST['ID']);

		//$header_row_string="Employee Salary Slip Monthwise";
	
		/*$query = "SELECT  
						   em.*,
						  es.*  ,
							bm.branch_id,ed.*,
						  ps.*  
							
						FROM cms_employeesalary es, 
							 cms_employeemaster em, 
							cms_designation ed,
							cms_branchmaster bm,
							cms_payscalemaster  ps
						
						WHERE es.college_id='1' and 					
							  em.college_id= '1' and
							  bm.branch_id=em.branch_id and
							  ps. payscale_id =em.employee_payscale and
							  ed.designation_id = em.employee_designation and		
							  es.employee_id = em.employee_id "; */
		$condition = "";

		if ($year != "") {
			$condition .= " and es.year_id = $year";
		}
		if ($month != "") {
			$condition .= " and es.month =$month";
		}
		if (isset($employee_id)) {
			if ($employee_id != "") {
				$condition .= " and es.employee_id = '$employee_id'";
			}
		}
		$condition .= " ORDER BY es.employee_id ASC";

		// echo $query; exit;
		//$out = dbQuery($query);
	
		$objEmployeeSalaryMgmt = new EmployeeSalaryMgmt();
		$out = $objEmployeeSalaryMgmt->getAllEmployeesalary($condition);

		$i = 0;
		if (dbRows($out) > 0) {
			ob_start();
			$nw = new Numbers_Words();
			while ($row = dbArray($out)) {
				$i++;
				?>
				<table cellpadding="0" border="0" cellspacing="0" width="100%" align="center" frame="box" class="table-report"
					style="border: 5px solid black; border-style: double;">
					<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="10" align="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>
						</td>
					</tr>
					<tr height="30">
						<th colspan="4">
							<font size="3">Salary Statement for the Month of - <?php print $monthname . ' ' . $year ?></font>
						</th>
					</tr>

					</tr>
					<tr height="30" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
						<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>
								<font size="3">Employee Name</font>
							</b></td>
						<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;" width="30%"
							colspan="3">
							<font size="3"><?php print $row['employee_name']; ?></font>
						</td>
					</tr>

					<tr height="30">
						<td width="15%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>
								<font size="3">Employee Number</font>
							</b></td>
						<td width="30%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
							<font size="3"><?php print $row['employee_no']; ?></font>
						</td>
						<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>
								<font size="3">Joining Date</font>
							</b></td>
						<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
							<font size="3"><?php print date("d/m/Y", strtotime($row['employee_schooljoindate'])); ?></font>
						</td>
					</tr>
					<tr height="30">
						<td width="15%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
							<font size="3"><b>Account Number</font></b>
						</td>
						<td width="15%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
							<font size="3"><?php print $row['employee_bankacno']; ?></font>
						</td>
						<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
							<font size="3"><b>Designation</b></font>
						</td>
						<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
							<font size="3"><?php print $row['designation_nameeng']; ?></font>
						</td>
					</tr>
					<tr height="30">
						<td width="15%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>
								<font size="3">Day Present</font>
							</b></td>
						<?php
						if ($month == 1) {
							$a = 31;
							$b = $row['odeduct1'];
							$c = $a - $b

								?>
							<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
								<font size="3"><?php print $c ?></font>
							</td>
							<?php
						} else if ($month == 2) {
							$a = 29;
							$b = $row['odeduct1'];
							$c = $a - $b
								?>
								<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
									<font size="3"><?php print $c ?></font>
								</td>
							<?php
						} else if ($month == 3) {
							$a = 31;
							$b = $row['odeduct1'];
							$c = $a - $b
								?>
									<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
										<font size="3"><?php print $c ?></font>
									</td>
							<?php
						} else if ($month == 4) {
							$a = 30;
							$b = $row['odeduct1'];
							$c = $a - $b
								?>
										<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
											<font size="3"><?php print $c ?></font>
										</td>
							<?php
						} else if ($month == 5) {
							$a = 31;
							$b = $row['odeduct1'];
							$c = $a - $b
								?>
											<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
												<font size="3"><?php print $c ?></font>
											</td>
							<?php
						} else if ($month == 6) {
							$a = 30;
							$b = $row['odeduct1'];
							$c = $a - $b
								?>
												<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
													<font size="3"><?php print $c ?></font>
												</td>
							<?php
						} else if ($month == 7) {
							$a = 31;
							$b = $row['odeduct1'];
							$c = $a - $b
								?>
													<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
														<font size="3"><?php print $c ?></font>
													</td>
							<?php
						} else if ($month == 8) {
							$a = 31;
							$b = $row['odeduct1'];
							$c = $a - $b
								?>
														<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
															<font size="3"><?php print $c ?></font>
														</td>
							<?php
						} else if ($month == 9) {
							$a = 30;
							$b = $row['odeduct1'];
							$c = $a - $b
								?>
															<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
																<font size="3"><?php print $c ?></font>
															</td>
							<?php
						} else if ($month == 10) {
							$a = 31;
							$b = $row['odeduct1'];
							$c = $a - $b
								?>
																<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
																	<font size="3"><?php print $c ?></font>
																</td>
							<?php
						} else if ($month == 11) {
							$a = 30;
							$b = $row['odeduct1'];
							$c = $a - $b
								?>
																	<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
																		<font size="3"><?php print $c ?></font>
																	</td>
							<?php
						} else if ($month == 12) {
							$a = 31;
							$b = $row['odeduct1'];
							$c = $a - $b
								?>
																		<td width="20%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
																			<font size="3"><?php print $c ?></font>
																		</td>
							<?php
						}
						?>

						<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>
								<font size="3">Department</font>
							</b></td>
						<td>
							<font size="3"><?php print $row['branch_name']; ?> Department</font>
						</td>
					</tr>


					<tr height="30" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
						<td width="15%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>
								<font size="3">Leave Without Pay</font>
							</b></td>
						<td width="15%" style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;">
							<font size="3"><?php print $row['odeduct1']; ?></font>
						</td>
						<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>
								<font size="3">P.F. No.</font>
							</b></td>
						<td>
							<font size="3"><?php print $row['employee_gpfacno']; ?></font>
						</td>
					</tr>
					<tr height="30">

						<td style="border-collapse:collapse;border-right:none;border-bottom::none;border-top:none;"><b>
								<font size="3">Pay Scale</font>
							</b></td>
						<td colspan="3">
							<font size="3"><?php print $row['current_payscale']; ?></font>
						</td>
					</tr>

					<tr>
						<table cellpadding="0" border="1" cellspacing="0" width="100%" align="center" class="table-report"
							style="border: 5px solid black; border-style: double;">
							<tr height="30">
								<td colspan="2">
									<center><b>
											<font size="3">Earnings</font>
										</b></center>
								</td>
								<td width="1%"></td>
								<td colspan="3">
									<center><b>
											<font size="3">Deductions</font>
										</b></center>
								</td>
							</tr>
							<tr height="30">
								<td width="37%">
									<center><b>
											<font size="3">Particulars</font>
										</b></center>
								</td>
								<td width="10%">
									<center><b>
											<font size="3">Amount</font>
										</b></center>
								</td>
								<td width="1%"></td>
								<td width="37%">
									<center><b>
											<font size="3">Particulars</font>
										</b></center>
								</td>
								<td width="10%">
									<center><b>
											<font size="3">Amount</font>
										</b></center>
								</td>
							</tr>

							<tr height="30">
								<td>
									<font size="3">Basic Pay</font>
								</td>
								<td>
									<div align="right">
										<font size="3"><?php print $row['basic']; ?>.00</font>
									</div>
								</td>
								<td></td>
								<td>
									<font size="3">Provident Fund</font>
								</td>
								<td>
									<div align="right">
										<font size="3"><?php print $row['society_2']; ?>.00</font>
									</div>
								</td>

							<tr height="30">
								<td>
									<font size="3">AGP/GP/DP</font>
								</td>
								<td>
									<div align="right">
										<font size="3"><?php print $row['dpay']; ?>.00</font>
									</div>
								</td>
								<td></td>
								<td>
									<font size="3">Professional Tax </font>
								</td>
								<td>
									<div align="right">
										<font size="3"><?php print $row['pftax']; ?>.00</font>
									</div>
								</td>
							</tr>

							<tr height="30">
								<td>
									<font size="3">Dearness Allowance</font>
								</td>
								<td>
									<div align="right">
										<font size="3"><?php print $row['da']; ?>.00</font>
									</div>
								</td>
								<td></td>
								<td>
									<font size="3">Income Tax / TDS</font>
								</td>
								<td>
									<div align="right">
										<font size="3"><?php print $row['incometax']; ?>.00</font>
									</div>
								</td>
							</tr>
							<tr height="30">
								<td>
									<font size="3">CLA</font>
								</td>
								<td>
									<div align="right">
										<font size="3"><?php print $row['cla']; ?>.00</font>
									</div>
								</td>
								<td></td>
								<td>
									<font size="3">Leave Without Pay</font>
								</td>
								<?php if ($row['misrec2'] != '') {
									$a = $row['misrec2'] * $row['odeduct1']
										?>

									<td>
										<div align="right">
											<font size="3"><?php print $a; ?>.00<font>
										</div>
									</td>
									<?php
								} else {
									?>
									<td>
										<div align="right">
											<font size="3">-</font>
										</div>
									</td>
									<?php
								}
								?>
							</tr>
							<tr height="30">
								<td>
									<font size="3">House Rent Allowance</font>
								</td>
								<td>
									<div align="right">
										<font size="3"><?php print $row['hra']; ?>.00</font>
									</div>
								</td>
								<td></td>
								<td>
									<font size="3">Staff Security Deposit</font>
								</td>
								<td>
									<div align="right">
										<font size="3"><?php print $row['pli']; ?>.00</font>
									</div>
								</td>
							</tr>
							<tr height="30">
								<td>
									<font size="3">Travelling Allowance</font>
								</td>
								<td>
									<div align="right">
										<font size="3"><?php print $row['ta']; ?>.00</font>
									</div>
								</td>
								<td></td>
								<td>
									<font size="3">Credit Society</font>
								</td>
								<td>
									<div align="right">
										<font size="3"><?php print $row['society']; ?>.00</font>
									</div>
								</td>
							</tr>

					</tr>
					<tr height="30">
						<td>
							<font size="3">
								<font size="3">Medical Allowance</font>
						</td>
						<td>
							<div align="right">
								<font size="3"><?php print $row['medical_all']; ?>.00</font>
							</div>
						</td>
						<td></td>
						<td>
							<font size="3">Credit Society Loan</font>
						</td>
						<td>
							<div align="right">
								<font size="3"><?php print $row['misec1']; ?>.00</font>
							</div>
						</td>
					<tr height="30">
						<td>
							<font size="3">
								<font size="3">Other</font>
						</td>
						<td>
							<div align="right">
								<font size="3"><?php print $row['oincome1']; ?>.00</font>
							</div>
						</td>
						<td></td>
						<td>
							<font size="3">Bus Transport Charge</font>
						</td>
						<td>
							<div align="right">
								<font size="3"><?php print $row['recadj']; ?>.00</font>
							</div>
						</td>
					</tr>

					<tr height="30">
						<td></td>
						<td></td>
						<td></td>
						<td>
							<font size="3">Other</font>
						</td>
						<td>
							<div align="right">
								<font size="3"><?php print $row['groupins']; ?>.00</font>
							</div>
						</td>
					</tr>
					<tr height="30">
						<td>
							<div align="right">
								<font size="3"><b>Total Earnings</b></font>
							</div>
							</th>
						<td>
							<div align="right">
								<font size="3"><b><?php print $row['grosspay']; ?>.00</b></font>
							</div>
						</td>
						<td></td>
						<td><b>
								<font size="3">
									<div align="right">Total Deductions</div>
								</font>
							</b></td>
						<td>
							<div align="right"><b>
									<font size="3"><?php print $row['grossdeduction']; ?>.00</font>
								</b></div>
						</td>
					</tr>

					<tr height="30" style="border: 5px solid black; border-style: double;">
						<td><b>
								<font size="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<b>Net Salary :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; </b>
							</b>

							<b><?php print $row['netpay']; ?>.00</b> </font>
						</td>
						<td>
							<div align="right"><b>
									<font size="3"></font>
								</b></div>
						</td>
						<td></td>
						<td></td>
						<td></td>

					</tr>
					<tr height="30">
						<th colspan="5">
							<font size="2">In Words - <?php echo strtoupper($nw->toWords($row['netpay']) . " Rupees Only"); ?></font>
						</th>
					</tr>
					<tr height="30">
						<th colspan="5">
							<center>
								<font size="1"><b>THIS IS THE COMPUTER GENERATED SLIP. NO SIGNATURE REQUIRED</b></font>
							</center>
						</th>
					</tr>
				</table>
				</tr>
				</table>
				<br />
				<?php
				if (dbRows($out) != 1 && $i != dbRows($out)) {
					echo '<div class="break"></div>';
				}
			}
			$HtmlCode = ob_get_contents();
			ob_end_flush();
			$HtmlUrl = "employee-salary-slip-monthwise-report-" . $_SESSION["VedantnrUserId"] . ".html";
			$HtmlPath = "report/" . $HtmlUrl;
			createHTMLReportPage($header_row_string, $HtmlUrl, $HtmlPath, $HtmlCode, false);
			?>
			</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();
					}

					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"; ?>