<?php include "headerLink.php";?>
<!DOCTYPE html>
<html lang="en">

<style>
.my-report-scrollbar {
position: relative;
height: 100%;
width:100%;
overflow: auto;
}
.table-report-scroll-y {
display: block;
}
</style>
<body class="animsition">
    <div class="page-wrapper">
        <!-- HEADER MOBILE-->
        <?php include "menuSideBar_mobile.php" ;?>
        <!-- END HEADER MOBILE-->
		
        <!-- MENU SIDEBAR-->
        <?php include "menuSideBar.php" ;?>
        <!-- END MENU SIDEBAR-->

        <!-- PAGE CONTAINER-->
        <div class="page-container">
            <!-- HEADER DESKTOP-->
			<?php include "headerPage.php"?>
            <!-- END HEADER DESKTOP-->
			
			
			
			<!-- MAIN CONTENT-->
			<?php
			
			$report_type=$_GET["report_type"];
			$_SESSION["report_type"] =  $report_type;
			
			
			
			
			function dateDifference($start_date, $end_date)
			{
				// calulating the difference in timestamps 
				$diff = strtotime($start_date) - strtotime($end_date);
				 
				// 1 day = 24 hours 
				// 24 * 60 * 60 = 86400 seconds
				return ceil(abs($diff / 86400));
			}

			$selectedLocation = "";
			$selectedTenantInfo = "";
			$tenantInfo = "";
			$cutOffPayment = "";
			$tenant_status = "";
			$checkboc_plainReport = "";
			$radio_viewReport = "";
			$_SESSION["aged_date"] ="";
			//$_SESSION["projectLocation"] = "";
			$_SESSION["tenantInfo"] = "";
			$_SESSION["cutOffPayment"] = "";
			$_SESSION["tenant_status"] = "";
			$_SESSION["checkboc_plainReport"] = "";
			$_SESSION["radio_viewReport"] = "";
			//$tenant_id = $_GET["tenant_id"];
			$sqlDate = "";
			$sqlDateDeposit = "";
			//$_SESSION['projectLocation']=$_GET['projectLocation'];

			$_SESSION['statement_date']="";
			$_SESSION['statement_year']="";
			$_SESSION['statement_monthyear']="";
			$_SESSION['chooseDate']="";
			$_SESSION["statement_ChooseDate"] =  "";
			$_SESSION["statementby"] = "";
			$statementby = "";
			$statement_year = "";
			$statement_monthyear = "";
			$statement_date = "";
			$statement_ByChooseDate = "";
			$selected_cutOffPayment = "";
			$displayYear = "display:none";
			$displayMonthYear = "display:none";
			$displayDateFromTo = "display:none";
			$displayChooseDate = "display:none";
			$displayPlainReport = "display:none";
			$displayViewReport = "display:none";
			$displayCheckBox = "display:none";
			$displayStatementOption = "display:none";

			  "SQL YEAR::" .$sqlYear = "select YEAR(bills.issue_date) AS year from bills 
								inner join tenants on bills.tenant_id =  tenants.id 
								inner join properties on tenants.property_id = properties.id
								inner join locations on properties.location_id = locations.id
								where locations.id = ".$_SESSION["location_id"]."
								group by year having (year <= YEAR(CURDATE()) and year <> 0 ) order by year ASC";
					$runSqlYear = mysqli_query($link, $sqlYear);
					if($runSqlYear === FALSE){
						die(mysqli_error($link));
					}
			
			
			//DISPLAY BEFORE SUBMIT START
			$statementby = $_GET["statementby"];
			IF($statementby != "" || $statementby != null){
				include("bill_types.php");
				if($statementby == 'statement_year'){
					$displayYear = "display:block";
					$displayMonthYear = "display:none";
					$displayDateFromTo = "display:none";
					$displayChooseDate = "display:none";
					$displayPlainReport = "display:none";
					$displayViewReport = "display:none";
					$displayCheckBox = "display:block";
					$displayStatementOption = "display:none";
					
				
					 
					
				}
				else if($statementby == 'statement_monthyear'){
					$displayYear = "display:none";
					$displayMonthYear = "display:block";
					$displayDateFromTo = "display:none";
					$displayChooseDate = "display:none";
					$displayPlainReport = "display:none";
					$displayViewReport = "display:none";
					$displayCheckBox = "display:block";
					$displayStatementOption = "display:none";
				}
				else if($statementby == 'statement_date'){
					$displayYear = "display:none";
					$displayMonthYear = "display:none";
					$displayDateFromTo = "display:block";
					$displayChooseDate = "display:none";
					$displayPlainReport = "display:none";
					$displayViewReport = "display:block";
					$displayCheckBox = "display:block";
					$displayStatementOption = "display:none";
				}
				else if($statementby == 'statement_ChooseDate'){
					$displayYear = "display:none";
					$displayMonthYear = "display:none";
					$displayDateFromTo = "display:none";
					$displayChooseDate = "display:block";
					$displayPlainReport = "display:block";
					$displayViewReport = "display:none";
					$displayCheckBox = "display:block";
					$displayStatementOption = "display:none";
				}
			}
			//END DISPLAY BEFORE SUBMIT
			
			
			
			
			
			if(isset($_GET["reset"])){
										
				$_SESSION["dateFrom"] ="";
				$_SESSION["dateTo"] ="";
				$_SESSION['statement_date']="";
				$_SESSION['statement_year']="";
				$_SESSION['statement_monthyear']="";
				$_SESSION['chooseDate']="";
				$_SESSION["cutOffPayment"] =  "";
				$_SESSION["statement_ChooseDate"] =  "";
				$_SESSION["statementby"] = "";
				$_GET["statementby"]= "";
				$_GET["statement_year"] = "";
				$_GET["statement_monthyear"] = "";
				$_GET["statement_date"] = "";
				$_GET["statement_ByChooseDate"] = "";
				$_GET["selected_cutOffPayment"] = "";
				$_GET["dateFrom"] = "";
				$_GET["dateTo"] = "";
				$_GET["chooseDate"] = "";
				$_GET["cutOffPayment"] = "";
				$_GET["statement_ChooseDate"] = "";
				$_GET["tenant_status"] = "";
				$_GET["checkboc_plainReport"] = "";
				$_GET["radio_viewReport"] = "";
				$_GET["block"] = "";
				$_GET["payment_status"] = "";
				
				
				
				$_SESSION["aged_date"] ="";
				//$_SESSION["projectLocation"] = "";
				$_SESSION["tenantInfo"] = "";
				$_SESSION["cutOffPayment"] = "";
				$_SESSION["cutOffPayment"] = "";
				$selectedDate = "";
				$selectedLocation = "";
				$selectedTenantInfo = "";
				$cutOffPayment = "";
				$tenant_status = "";
				$checkboc_plainReport = "";
				$radio_viewReport = "";
				 $displayYear = "display:none";
				$displayMonthYear = "display:none";
				$displayDateFromTo = "display:none";
				$displayChooseDate = "display:none";
				$displayPlainReport = "display:none";
				$displayViewReport = "display:none";
				$displayCheckBox = "display:none";
				$statementby = "";
				$displayStatementOption = "display:none";
			}
			
			
			
			
			
			
			 if(isset($_GET["searchStatement"])){
				//echo "submit!";
				$dateFrom = $_GET["dateFrom"];
				$dateTo = $_GET["dateTo"];
				$_SESSION["dateFrom"] = $dateFrom;
				$_SESSION["dateTo"] = $dateTo;
				
				$dateTo_cutOFF = date('Y-m-d', strtotime($dateTo. ' + 1 days'));	
				
				include("bill_types.php");
				
				
				$statementby = $_GET["statementby"];
				$_SESSION['statementby'] = $statementby;
				$tenant_id = $_GET["tenant_id"];
				$cond_selectedCutOffPayment = "";
				$cond_monthYear_BF = "";
				$cond_date_BF = "";
				$selected_cutOffPayment = "";
				$statement_year_cutOFF ="";
				$infoTarikhTunggakan = "";
				
				
				$selectedDate = $_GET["aged_date"];
				$selectedTenantInfo = $_GET["tenantInfo"];
				$selected_cutOffPayment = $_GET["cutOffPayment"];
				$tenant_status = $_GET["tenant_status"];
				$checkboc_plainReport = $_GET["checkboc_plainReport"];
				$radio_viewReport = $_GET["radio_viewReport"];
				$sorting = $_GET["sorting"];
				$_SESSION["aged_date"] = $selectedDate;
				$_SESSION["tenantInfo"] = $selectedTenantInfo;
				$_SESSION["cutOffPayment"] = $selected_cutOffPayment;
				$_SESSION["tenant_status"] = $tenant_status;
				$_SESSION["checkboc_plainReport"] = $checkboc_plainReport;
				$_SESSION["radio_viewReport"] = $radio_viewReport;
				$_SESSION["sorting"] = $sorting;
				
				
				$cond = "";
				$cond_project = "";
				$cond_location = "";
				$cond_ageingDate = "";
				$cond_tenantInfo = "";
				$cond_tenantStatus = "";
				$cond_staffID = "";
				$groupBY = "";
				$ageingDateInfo ="";
				$cond_selectedCutOffPayment = "";
				$bulanTerimaan = "";
				$project_id = $_SESSION["project_id"];
				$sqlDateADV = "";
				
				$block = $_GET['block'];
				$payment_status = $_GET['payment_status'];
				
				
				
				include("sql_invoice.php");
			}
			//ECHO "SQL REPORT::::". $sqlReport;
			?>
			
            
            <!--main content upper start-->
			<?php include "main-content-upper.php"?>
            <!--main content upper end-->
			<!--main content middle start-->
						<div class="row" >
							<div class="card-body">
								<div class="row form-group">
									<!--<div class="col col-md-12">-->
									<div class="col-lg-12">
										<div class="card">
											<div class="card-header py-3">
												<h5 class="m-0 font-weight-bold text-primary">Search</h5>
											</div>
											<form action="<?php $_SERVER['PHP_SELF']; ?>" method="get" enctype="multipart/form data"  id="form_tenantStatement">
												<input type="hidden" name="projectLocation" value="<?php echo $_GET["projectLocation"]?>">
												<input type="hidden" name="menu" value="<?php echo $_GET["menu"]?>">
												<input type="hidden" name="submenu" value="<?php echo $_GET["submenu"]?>">
												<input type="hidden" name="print" value="no">
												<div class="card-body card-block">
													<input type="hidden" name="login" value="<?php echo $_GET["login"]?>">
													<div class="row form-group">
														<div class="col col-md-3">
															<label class=" form-control-label"><b>REPORT TYPE</b></label>
														</div>
														<div class="col col-md-9">
															<div class="form-check">
																<div class="radio">
																	<label for="radio1" class="form-check-label ">
																		<input type="radio" onChange = "change(this.value)" id="radio1" name="report_type" value="Deposit" class="form-check-input" <?php echo ($_SESSION["submenu"] == 'Deposit' || $_SESSION["report_type"] == 'Deposit' ? 'CHECKED' : '');?>> Deposit 
																	</label>
																</div>
																<div class="radio">
																	<label for="radio2" class="form-check-label ">
																		<input type="radio" onChange = "change(this.value)" id="radio2" name="report_type" value="Rental" class="form-check-input" <?php echo ($_SESSION["submenu"] == 'Rental' || $_SESSION["report_type"] == 'Rental' ? 'CHECKED' : '');?>> Rental   
																	</label>
																</div>
																<div class="radio">
																	<label for="radio3" class="form-check-label ">
																		<input type="radio" onChange = "change(this.value)" id="radio3" name="report_type" value="Water" class="form-check-input" <?php echo ($_SESSION["submenu"] == 'Water' || $_SESSION["report_type"] == 'Water' ? 'CHECKED' : '');?>> Water
																	</label>
																</div>
															</div>
														</div>
													</div>
													<div class="row form-group">
														<div class="col col-md-3">
															<label class=" form-control-label"><b>STATEMENT OPTION</b></label>
														</div>
														<div class="col col-md-9">
															<div class="form-check" >
																<?php 
																 	$page = "report_all_invoice.php";
																	//include("statement_option.php"); 
																
																	?>
																
																<table width="100%">
																	<tr align="center">
																		<td >
																			<?php
																			
																			$_SESSION["statementby"] = $_GET["statementby"];
																					$_SESSION["statement_year"] = $_GET["statement_year"];
																					$_SESSION["statement_monthyear"] = $_GET["statement_monthyear"];
																					$_SESSION["dateFrom"] = $_GET["dateFrom"];
																					$_SESSION["dateTo"] = $_GET["dateTo"];
																					$_SESSION["statement_ChooseDate"] = $_GET["statement_ChooseDate"];?>
																			
																			<select name="statementby" id="statementby" onchange="statementby_change()" class="form-control" >
																				<option value="">Select Statement Option</option>
																				<option value="statement_year" <?php echo ($_SESSION["statementby"] ==  'statement_year')  ? "selected" : "" ?>>STATEMENT BY YEAR</option>
																				<option value="statement_monthyear" <?php echo ($_SESSION["statementby"] ==  'statement_monthyear')  ? "selected" : "" ?>>STATEMENT BY MONTH AND YEAR</option>
																				<option value="statement_date" <?php echo ($_SESSION["statementby"] ==  'statement_date')  ? "selected" : "" ?>>STATEMENT BY DATE (BETWEEN TWO DATES)</option>
																				<option value="statement_ChooseDate" <?php echo ($_SESSION["statementby"] ==  'statement_ChooseDate')  ? "selected" : "" ?> >STATEMENT BY CUT OFF DATE</option>
																			</select>
																		</td>
																		<td id="statement_ByYear" style='<?php echo $displayYear ?>;'>
																			<?php //if($_SESSION["statement_year"])?>
																			<select required="" name="statement_year" id="statement_year" class="form-control">
																				<option value="">Please Select Year</option>
																				<?php while($resultYear = mysqli_fetch_array($runSqlYear)){?>
																						<option value="<?php echo $resultYear["year"]?>" <?php echo ($_SESSION["statement_year"] ==  $resultYear["year"])  ? "selected" : "" ?> ><?php echo $resultYear["year"]?></option>
																				<?php } ?>
																			</select>
																		</td>
																		<td id="statement_ByMonthYear" style='<?php echo $displayMonthYear  ?>;'>
																			<input required="" type="month" class="form-control" name="statement_monthyear" id="statement_monthyear" value="<?php echo $_SESSION["statement_monthyear"]?>" size="20"/>
																		</td>
																		<td id="statement_ByDate" style='<?php echo $displayDateFromTo ?>;' >
																		<b>	From: </b><input required="" id='dateFrom' name='dateFrom' type='date' size='10' value="<?php echo $_SESSION["dateFrom"]?>"> 
																		<b>	To:  </b><input  required="" id='dateTo' name='dateTo' type='date' size='10' value="<?php echo $_SESSION["dateTo"]?>">
																		</td>
																		<td id="statement_ByChooseDate" style='<?php echo $displayChooseDate ?>;' >
																			<input required="" id="statement_ChooseDate" name="statement_ChooseDate" class="form-control" type='date' size='10' value="<?php echo $_SESSION["statement_ChooseDate"]?>"> 
																		</td>
																		
																	</tr>
																	<!--<tr  id="statement_plainReport" style='<?php echo $displayPlainReport ?>;'>
																		
																		<td colspan = "2">
																			<input type="checkbox" id="checkboc_plainReport" name="checkboc_plainReport" <?php echo ($_SESSION["checkboc_plainReport"]) ? "checked" : "" ?> value="true">
																			<label for="statement_plainReport" style="font-size:16px"><b> VIEW PLAIN REPORT </b></label>
																		</td>
																	</tr>
																	<tr  id="statement_report_terimaan" style='<?php //echo $displayViewReport ?>;'>
																		
																		<td colspan = "2">
																			<input type="checkbox" id="radio_viewReport" name="radio_viewReport" <?php //echo ($_SESSION["radio_viewReport"]) ? "checked" : "" ?> value="true">
																			<label for="statement_report_terimaan" style="font-size:16px"><b> VIEW REPORT TERIMAAN </b></label>
																		</td>
																	</tr>
																	<tr  id="statement_view_report" style='<?php echo $displayViewReport ?>;'> <!--view klu click statement by date sahaja -->
																		
																	<!--	<td colspan = "2">
																			<input type="radio" id="viewPlainReport" name="radio_viewReport" <?php echo ($_SESSION["radio_viewReport"]) == "viewPlainReport" ? "checked" : "" ?> value="viewPlainReport">
																			<label for="statement_view_report" style="font-size:16px"><b> VIEW PLAIN REPORT </b></label>
																			<br/>
																			<input type="radio" id="viewReportTerimaan" name="radio_viewReport" <?php echo ($_SESSION["radio_viewReport"]) == "viewReportTerimaan" ? "checked" : "" ?> value="viewReportTerimaan">
																			<label for="statement_view_report" style="font-size:16px"><b> VIEW REPORT TERIMAAN </b></label>
																		</td>
																	</tr>
																	<?php //if($page != "report_all_payments.php"){?>
																	<tr >
																		<td>&nbsp;</td>
																		<td align="center" id="statement_cutOff" style='<?php  echo $displayCheckBox  ?>;font-size:12px' >
																			<div>
																				<input type="checkbox" id="cutOffPayment" name="cutOffPayment" <?php echo ($_SESSION["cutOffPayment"]) ? "checked" : "" ?> value="true">
																				<label for="cutOffPayment" style="font-size:16px"><b> View Ageing Record based on cut off payments same as selected Month / Year </b></label>
																			</div>
																		</td>
																		<td>&nbsp;</td>
																	</tr>
																	<?php //} ?>-->
																</table>
																
																
															</div>
														</DIV>
													</DIV>
													<div class="row form-group">
														<div class="col col-md-3">
															<label class=" form-control-label"><b>BLOCK</b></label>
														</div>
														<div class="col col-md-9">
															<div class="form-check" >
																<?php 
																	$sqlBlock = "select properties.block as block from properties inner join locations on properties.location_id = locations.id where locations.id = " . $_SESSION["location_id"] . " group by properties.block";
																	$runBlock = mysqli_query($link, $sqlBlock);
																	if($runBlock === FALSE){
																		die(mysqli_error($link));
																	}
																	while($resultBlock = mysqli_fetch_array($runBlock)){
																		$blocklist = $resultBlock["block"];
																		
																		?>
																		<div class="form-check-inline form-check">
																			<label for="inline-checkbox[]" class="form-check-label">
																				<input type="checkbox" id="inline-checkbox[]" class="checkbox" name="block[]" value="<?php echo $blocklist?>" class="form-check-input" ><b><font style="font-size: 14px"><?php echo strtoupper($blocklist)?></font></b>
																			</label>
																		</div>
																		<?php
																			//}
																	}
																	?>
															</div>
														</DIV>
													</DIV>
													<div class="row form-group">
														<div class="col col-md-3">
															<label class=" form-control-label"><b>TENANT STATUS</b></label>
														</div>
														<div class="col col-md-3">
															<div class="form-check">
																<div class="radio">
																	<label for="radioActive" class="form-check-label ">
																		<input type="radio" id="radioActive" name="tenant_status" value="enable" class="form-check-input" <?php echo $_SESSION["tenant_status"] == "enable" ? "checked" : "" ?>><font style="font-size: 14px">Active</font>
																	</label>
																</div>
																<div class="radio">
																	<label for="radioDeactive" class="form-check-label ">
																		<input type="radio" id="radioDeactive" name="tenant_status" value="disable" class="form-check-input" <?php echo $_SESSION["tenant_status"] == "disable" ? "checked" : "" ?>><font style="font-size: 14px">Deactive</font>  
																	</label>
																</div>
															</DIV>
														</div>
													</div>
													<div class="row form-group">
														<div class="col col-md-3">
															<label class=" form-control-label"><b>PAYMENT STATUS</b></label>
														</div>
														<div class="col col-md-3">
															<div class="form-check">
																<div class="checkbox">
																	<label for="checkboxUnpaid" class="form-check-label ">
																		<input type="checkbox" id="checkboxUnpaid" name="payment_status[]" value="unpaid" class="form-check-input" <?php echo $_SESSION["payment_status"] == "unpaid" ? "checked" : "" ?>><font style="font-size: 14px">Unpaid</font>
																	</label>
																</div>
																<div class="checkbox">
																	<label for="checkboxPartial" class="form-check-label ">
																		<input type="checkbox" id="checkboxPartial" name="payment_status[]" value="partial" class="form-check-input" <?php echo $_SESSION["payment_status"] == "partial" ? "checked" : "" ?>><font style="font-size: 14px">Partial</font>  
																	</label>
																</div>
																<div class="checkbox">
																	<label for="checkboxPaid" class="form-check-label ">
																		<input type="checkbox" id="checkboxPaid" name="payment_status[]" value="paid" class="form-check-input" <?php echo $_SESSION["payment_status"] == "paid" ? "checked" : "" ?>><font style="font-size: 14px">Paid</font>  
																	</label>
																</div>
															</DIV>
														</div>
													</div>
													<div class="row form-group">
														<div class="col col-md-3">
															<label class=" form-control-label"><b>SORTING DATA FOR</b></label>
														</div>
														<div class="col col-md-3">
															<div class="form-check">
																<div class="radio">
																	<label for="radioSortingPaymentDate" class="form-check-label ">
																		<input type="radio" id="radioSortingPaymentDate" name="sorting" value="payment_date" class="form-check-input" <?php echo $_SESSION["sorting"] == "payment_date" ? "checked" : "" ?> checked ><font style="font-size: 14px">Invoice Date</font>
																	</label>
																</div>
																<div class="radio">
																	<label for="radioSortingUnitNo" class="form-check-label ">
																		<input type="radio" id="radioSortingUnitNo" name="sorting" value="unit_no" class="form-check-input" <?php echo $_SESSION["sorting"] == "unit_no" ? "checked" : "" ?>><font style="font-size: 14px">Unit No.</font>  
																	</label>
																</div>
															</DIV>
														</div>
													</div>
												</div>	
												<div class="card-footer">		
													<div class="row form-group" >
														<div class="col col-sm-12">
															<CENTER>
															<button class="btn btn-primary btn-sm" onclick="submitFunc()" type="submit" name="searchStatement">
																<i class="fa fa-dot-circle-o"></i> SEARCH
															</button>
															<button class="btn btn-danger btn-sm" type="reset" name="reset" >
																<i class="fa fa-ban"></i> RESET
															</button>
															
															</CENTER>
														</div>
													</div>
												</div>
											</form>
										</div>												
									</div>
								</div>
								<div class="row form-group">
									<div class="col-lg-12" >
										<div class="card-header py-3">
											<h5 class="m-0 font-weight-bold text-primary">Showing Result
											<div align="center">
											<?php 
												if($statementby == "statement_year" || $statementby == "statement_monthyear" ||  $statementby == "statement_ChooseDate"){?>
												<button type="button"  onclick="print_paymentReport1('<?php echo $report_type ?>','<?php echo $statementby ?>','<?php echo $date_statementOptionView?>','<?php echo $listBlock_plain?>','<?php echo $tenant_status?>','yes','<?php echo $checkboc_plainReport?>')" class="btn btn-success btn-sm">PRINT</button>
												<button type="button"  onclick="export_paymentReport1('<?php echo $report_type ?>','<?php echo $statementby ?>','<?php echo $date_statementOptionView?>','<?php echo $listBlock_plain?>','<?php echo $tenant_status?>','yes','<?php echo $checkboc_plainReport?>')" class="btn btn-success btn-sm">EXPORT CSV</button>
												<?php }else if($statementby == "statement_date"){?>
												<button type="button"  onclick="print_paymentReport2('<?php echo $report_type ?>','<?php echo $statementby ?>','<?php echo $date_statementOptionView_from?>','<?php echo $date_statementOptionView_to?>','<?php echo $listBlock_plain?>','<?php echo $tenant_status?>','yes','<?php echo $radio_viewReport?>')" class="btn btn-success btn-sm">PRINT</button>
												<button type="button" onclick="export_paymentReport2('<?php echo $report_type ?>','<?php echo $statementby ?>','<?php echo $date_statementOptionView_from?>','<?php echo $date_statementOptionView_to?>','<?php echo $listBlock_plain?>','<?php echo $tenant_status?>','yes','<?php echo $radio_viewReport?>')" class="btn btn-success btn-sm">EXPORT CSV</button>
											<?php } ?>
											</div>
											</h5>
										</div>
										
										<div class="card-body card-block">
										
										<?php 
											if($report_type == "Deposit"){
												include "invoice_deposit.php";
											}
											else if($report_type == "Rental" || $report_type == "Water"){
											//	echo "TEST 12345!!";
												include "invoice_rental.php";
											}
											/* else if($report_type == "Water"){
												include "report_water.php";
											} */
										?>
									
										</div>
									</div>
								
								</div>
							</div>
                        
			<!--main content middle end-->
			<!--main content bottom start-->
				<?PHP include "main-content-bottom.php";?>
			<!--main content bottom end-->
			
            <!-- END MAIN CONTENT-->
            <!-- END PAGE CONTAINER-->
        </div>
    </div>
    <?PHP include "footerLink.php";?>
</body>
</html>
<!-- end document-->
<script>
function change(x){
	//document.getElementById('statementby').removeA
}
function submitFunc(){ //alert("SUBMIT BUTTON!!!");
	if(document.getElementById("statementby").value== 'statement_year'){
		
		document.getElementById("statement_year").setAttribute("required","required");
		document.getElementById("statement_monthyear").removeAttribute("required");
		document.getElementById("dateFrom").removeAttribute("required");
		document.getElementById("dateTo").removeAttribute("required");
		document.getElementById("statement_ChooseDate").removeAttribute("required");
		
		if(document.getElementById("statement_year").value =='')
			alert("Please select Year");
		else{
			//document.getElementById("statement_year").value ='';
			document.getElementById("statement_monthyear").value ='';
			document.getElementById("dateFrom").value ='';
			document.getElementById("dateTo").value ='';
			document.getElementById("statement_ChooseDate").value ='';
			document.getElementById("form_tenantStatement").submit();
		}
	}
	else if(document.getElementById("statementby").value== 'statement_monthyear'){
		
		document.getElementById("statement_year").removeAttribute("required");
		document.getElementById("statement_monthyear").setAttribute("required","required");
		document.getElementById("dateFrom").removeAttribute("required");
		document.getElementById("dateTo").removeAttribute("required");
		document.getElementById("statement_ChooseDate").removeAttribute("required");
		
		if(document.getElementById("statement_monthyear").value =='')
			alert("Please select Month/Year");
		else{
			document.getElementById("statement_year").value ='';
			//document.getElementById("statement_monthyear").value ='';
			document.getElementById("dateFrom").value ='';
			document.getElementById("dateTo").value ='';
			document.getElementById("statement_ChooseDate").value ='';
			document.getElementById("form_tenantStatement").submit();
		}
	}
	else if(document.getElementById("statementby").value== 'statement_date'){
		
		document.getElementById("statement_year").removeAttribute("required");
		document.getElementById("statement_monthyear").removeAttribute("required");
		document.getElementById("dateFrom").setAttribute("required","required");
		document.getElementById("dateTo").setAttribute("required","required");
		document.getElementById("statement_ChooseDate").removeAttribute("required");
		
		if(document.getElementById("dateFrom").value =='' || document.getElementById("dateTo").value =='')
			alert("Please choose date");
		else{
			document.getElementById("statement_year").value ='';
			document.getElementById("statement_monthyear").value ='';
			//document.getElementById("dateFrom").value ='';
			//document.getElementById("dateTo").value ='';
			document.getElementById("statement_ChooseDate").value ='';
			document.getElementById("form_tenantStatement").submit();
		}
	}
	else if(document.getElementById("statementby").value== 'statement_ChooseDate'){
		document.getElementById("statement_year").removeAttribute("required");
		document.getElementById("statement_monthyear").removeAttribute("required");
		document.getElementById("dateFrom").removeAttribute("required");
		document.getElementById("dateTo").removeAttribute("required");
		document.getElementById("statement_ChooseDate").setAttribute("required","required");
		
		if(document.getElementById("statement_ChooseDate").value =='')
			alert("Please select date");
		else{
			document.getElementById("statement_year").value ='';
			document.getElementById("statement_monthyear").value ='';
			document.getElementById("dateFrom").value ='';
			document.getElementById("dateTo").value ='';
			//document.getElementById("statement_ChooseDate").value ='';
			document.getElementById("form_tenantStatement").submit();
		}
	} 
}


function statementby_change(){
	
	var statementby = document.getElementById("statementby").value;
	
	//alert(statementby);
	 if(statementby != ""){
		//document.getElementById("statement_option").style.display ='block';
		if(statementby == "statement_year"){
			document.getElementById('statement_ByYear').style.display ='block';
			document.getElementById('statement_ByMonthYear').style.display ='none';
			document.getElementById('statement_ByDate').style.display ='none';
			document.getElementById('statement_ByChooseDate').style.display ='none';
			document.getElementById('statement_plainReport').style.display ='none';
			document.getElementById('statement_view_report').style.display ='none';
			
		}
		else if(statementby == "statement_monthyear"){
			document.getElementById('statement_ByYear').style.display ='none';
			document.getElementById('statement_ByMonthYear').style.display ='block';
			document.getElementById('statement_ByDate').style.display ='none';
			document.getElementById('statement_ByChooseDate').style.display ='none';
			document.getElementById('statement_plainReport').style.display ='none';
			document.getElementById('statement_view_report').style.display ='none';
			
		}
		else if(statementby === 'statement_date'){
			//alert("masuk >> " + statementby);
			document.getElementById('statement_ByYear').style.display ='none';
			document.getElementById('statement_ByMonthYear').style.display ='none';
			document.getElementById('statement_ByDate').style.display ='block';
			document.getElementById('statement_ByChooseDate').style.display ='none';
			document.getElementById('statement_plainReport').style.display ='none';
			document.getElementById('statement_view_report').style.display ='block';
		}
		else if(statementby == "statement_ChooseDate"){
			document.getElementById('statement_ByYear').style.display ='none';
			document.getElementById('statement_ByMonthYear').style.display ='none';
			document.getElementById('statement_ByDate').style.display ='none';
			document.getElementById('statement_ByChooseDate').style.display ='block';
			document.getElementById('statement_plainReport').style.display ='block';
			document.getElementById('statement_view_report').style.display ='none';
			
		} 
		
	} 
	
	
	
}
function customReset(){
	//alert("customReset");
	document.getElementById("report_type").value = "";
	document.getElementById("statementby").value = "";
	document.getElementById("tenant_status").value = "";
	document.getElementById("checkboc_plainReport").value = "";
	document.getElementById("radio_viewReport").value = "";
	document.getElementById('statement_plainReport').style.display ='none';
	document.getElementById('statement_view_report').style.display ='none';
}
</script>