<?php
include("session_set.php");
error_reporting(0); 


//set time zone
date_default_timezone_set("Asia/Kuala_Lumpur");


//echo "THIS IS HEADER!";

$location_ID = "";
$projectLocation = "";
$searchTenant = "";
//echo "SESSIONprojectLocation: ".$_SESSION['projectLocation'];
//PLEASE DON'T CHANGE THIS CODE - SETTING SESSION ON PROJECT LOCATION 
//CODE START
if($_POST['projectLocation'] != "" || $_POST['projectLocation'] != null  ){
	$projectLocation = $_POST['projectLocation'];
	$searchTenant = $_POST["searchTenant"];
	$_SESSION["searchTenant"] = $searchTenant;
	if($_SESSION["projectLocation"] !=  $_POST['projectLocation']){
		$_SESSION["projectLocation"] = $projectLocation; 
		$_SESSION["properties_unitno"] = ""; 
	}
	
	include "splitLocationName_project.php"; 
}
ELSE IF($_SESSION['projectLocation'] != ""){
	$projectLocation = $_SESSION['projectLocation'];

	
	include "splitLocationName_project.php"; 
}
 "PROJECT LOCATION: " .$projectLocation;
//CODE END
if($_POST["properties_unitno"] != "" || $_POST['properties_unitno'] != null){
	$_SESSION["properties_unitno"] = $_POST["properties_unitno"]; 
}
if(isset($_POST["reset"])){
	$_SESSION["properties_unitno"] = ""; 
}

$_SESSION["menu"] = $_GET["menu"];
$_SESSION["submenu"] = $_GET["submenu"];

?>

<head>
   <!-- Required meta tags-->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="au theme template">
    <meta name="author" content="Hau Nguyen">
    <meta name="keywords" content="au theme template">

    <!-- Title Page-->
    <title>Dashboard</title>

    <!-- Fontfaces CSS-->
    <link href="css/font-face.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
    <link href="vendor/font-awesome-5/css/fontawesome-all.min.css" rel="stylesheet" media="all">
    <link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">

    <!-- Bootstrap CSS-->
    <link href="vendor/bootstrap-4.1/bootstrap.min.css" rel="stylesheet" media="all">

    <!-- Vendor CSS-->
    <link href="vendor/animsition/animsition.min.css" rel="stylesheet" media="all">
    <link href="vendor/bootstrap-progressbar/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet" media="all">
    <link href="vendor/wow/animate.css" rel="stylesheet" media="all">
    <link href="vendor/css-hamburgers/hamburgers.min.css" rel="stylesheet" media="all">
    <link href="vendor/slick/slick.css" rel="stylesheet" media="all">
    <link href="vendor/select2/select2.min.css" rel="stylesheet" media="all">
    <link href="vendor/perfect-scrollbar/perfect-scrollbar.css" rel="stylesheet" media="all">

    <!-- Main CSS-->
    <link href="css/theme.css" rel="stylesheet" media="all">

	<!--Javascript Function-->
	<script src="js/function.js"></script>
	<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>-->
	<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
 
	<title class="fas fa-rss-square"> PHSSB_RPMS</title>
	<!-- add icon link -->
       <link rel = "icon" href = "LOGO PAYPRO.png" type = "image/x-icon">
      <!-- <link rel = "icon" href = "MINIS PHSSBRENTPROP.png" type = "image/x-icon">-->
</head>
<style>
.my-custom-scrollbar {
position: relative;
height: 200px;
overflow: auto;
}
.table-wrapper-scroll-y {
display: block;
}
</style>

<script>



 function resetFunc(){ //alert();
	document.getElementById("form_tenantStatement").reset();
	 
	document.getElementById('statement_ByYear').style.display ='none';
	document.getElementById('statement_ByMonthYear').style.display ='none';
	document.getElementById('statement_ByDate').style.display ='none';
	document.getElementById('statement_cutOff').style.display ='none';
	document.getElementById('statement_ByChooseDate').style.display ='none';
	document.getElementById('statementby').value ='';
	
	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('radio1').checked = false;
	document.getElementById('radio2').checked = false;
	document.getElementById('radio3').checked = false;
}

	function action_updatePassword(staff_id){
		
	}											
	function print_paymentReport1(report_type,statementby,date_statementOptionView,block,tenant_status,printExport,checkboc_plainReport) {
		window.open("print_paymentReport.php?report_type="+report_type+"&statementby="+statementby+"&date_statementOptionView="+date_statementOptionView+"&block="+block+"&tenant_status="+tenant_status+"&print="+printExport+"&checkboc_plainReport="+checkboc_plainReport,'_blank');
	}
	function print_paymentReport2(report_type,statementby,date_statementOptionView_from,date_statementOptionView_to,block,tenant_status,printExport,radio_viewReport) {
		window.open("print_paymentReport.php?report_type="+report_type+"&statementby="+statementby+"&date_statementOptionView_from="+date_statementOptionView_from+"&date_statementOptionView_to="+date_statementOptionView_to+"&block="+block+"&tenant_status="+tenant_status+"&print="+printExport+"&radio_viewReport="+radio_viewReport,'_blank');
	}
	
	function export_paymentReport1(report_type,statementby,date_statementOptionView,block,tenant_status,printExport,checkboc_plainReport) {
		window.open("export_paymentReport.php?report_type="+report_type+"&statementby="+statementby+"&date_statementOptionView="+date_statementOptionView+"&block="+block+"&tenant_status="+tenant_status+"&print="+printExport+"&checkboc_plainReport="+checkboc_plainReport+"&checkboc_reportTerimaan="+checkboc_reportTerimaan,'_blank');
	}
	function export_paymentReport2(report_type,statementby,date_statementOptionView_from,date_statementOptionView_to,block,tenant_status,printExport, radio_viewReport) {
		window.open("export_paymentReport.php?report_type="+report_type+"&statementby="+statementby+"&date_statementOptionView_from="+date_statementOptionView_from+"&date_statementOptionView_to="+date_statementOptionView_to+"&block="+block+"&tenant_status="+tenant_status+"&print="+printExport+"&radio_viewReport="+radio_viewReport,'_blank');
	}
	
	function print_viewOutStandingAgeingByTenant(tenant_id,dateStart,dateEnd) {
		window.open("print_viewOutStandingAgeingByTenant.php?tenant_id="+tenant_id+"&dateStart="+dateStart+"&dateEnd="+dateEnd,'_blank');
	}
	function export_viewOutStandingAgeingByTenant(tenant_id,dateStart,dateEnd) {
		window.open("export_viewOutStandingAgeingByTenant.php?tenant_id="+tenant_id+"&dateStart="+dateStart+"&dateEnd="+dateEnd,'_blank');
	}
	function print_report6YearsOutstanding(statementby,date_statementOptionView,block,tenant_status) {
		window.open("print_report6YearsOutstanding.php?statementby="+statementby+"&date_statementOptionView="+date_statementOptionView+"&block="+block+"&tenant_status="+tenant_status,'_blank');
	}
	function export_report6YearsOutstanding(statementby,date_statementOptionView,block,tenant_status) {
		window.open("export_report6YearsOutstanding.php?statementby="+statementby+"&date_statementOptionView="+date_statementOptionView+"&block="+block+"&tenant_status="+tenant_status,'_blank');
	}
	function printNotPaidList1date(report_type,statementby,date_statementOptionView,tenant_status) {
		window.open("printNotPaidList1date.php?report_type="+report_type+"&statementby="+statementby+"&date_statementOptionView="+date_statementOptionView+"&tenant_status="+tenant_status,'_blank');
	}
	function printNotPaidList2date(report_type,statementby,date_statementOptionView_from,date_statementOptionView_to,tenant_status) {
		window.open("printNotPaidList2date.php?report_type="+report_type+"&statementby="+statementby+"&date_statementOptionView_from="+date_statementOptionView_from+"&date_statementOptionView_to="+date_statementOptionView_to+"&tenant_status="+tenant_status,'_blank');
	}
	function reprint(tenant_id) {
		window.open("reprint_deposit.php?tenant_id="+tenant_id,'_blank');
	}
	function printWaterStatement(tenant_id) {
		window.open("printWaterStatement.php?tenant_id="+tenant_id,'_blank');
	}
	function printSummaryDeposit(tenant_id) {
		window.open("printSummaryDeposit.php?tenant_id="+tenant_id,'_blank');
	}
	function viewWaterStatement(tenant_id) {
		window.open("tenant_viewWaterStatement.php?tenant_id="+tenant_id,'_blank');
	}
	function createDepositBill(tenant_id,staff_id,location_id) {
		window.open("depositBillController.php?tenant_id="+tenant_id+"&staff_id="+staff_id+"&location_id="+location_id,'_self');
	}
	function createDepositPayment(tenant_id,staff_id) {
		window.open("depositPayNowController.php?tenant_id="+tenant_id+"&staff_id="+staff_id,'_self');
	}
	function paynow(tenant_id) {
		window.open("deposit_Paynow.php?tenant_id="+tenant_id,'_blank');
	}
	function billPayment(tenant_id) {
		window.open("payment_dashboard.php?tenant_id="+tenant_id+"&menu=Tenant&submenu=Bill_Payment",'_self');
	}
	function printStatement(tenant_id) {
		window.open("print_statementInfo.php?tenant_id="+tenant_id,'_blank');
	}
	function exportToCSV(tenant_id,sqlStatement,cutOffDate,sqlAgeing,totalBF,firstYearDate) {
		window.open("exportToCSV_viewStatement.php?tenant_id="+tenant_id,'_blank');
	}
	function printStatement_water(tenant_id) {
		window.open("print_statementInfo_water.php?tenant_id="+tenant_id,'_blank');
	}
	function exportToCSV_water(tenant_id,sqlStatement,cutOffDate,sqlAgeing,totalBF,firstYearDate) {
		window.open("exportToCSV_viewStatement_water.php?tenant_id="+tenant_id,'_blank');
	}
	function confirmFunction (name,unit,tenant_id,projectLocation) {
        
		var txt;
		var r = confirm("Are you sure want to deactivate this tenant? \n " + name + "(" + unit + ")");
		if (r == true) {
			
			window.location.href="deactivateTenant.php?name="+name+"&tenant_id="+tenant_id+"&page=tenant_listing.php&projectLocation="+projectLocation;
			
		} else {
			window.location.href="tenant_listing.php";
		}
    }
	function editTenant(tenant_id) {
		window.open("Up_tenant_detail.php?tenant_id="+tenant_id,'_blank');
	}
	function listPayment(tenant_id) {
		window.open("ListPayment.php?tenant_id="+tenant_id,'_blank');
	}
	function viewStatement(tenant_id) {
		window.open("tenant_viewStatement.php?tenant_id="+tenant_id,'_blank');
	}
	function viewTenantDashboard(tenant_id) {
		window.open("viewTenantDashboard.php?tenant_id="+tenant_id+"&menu=Tenant&submenu=Dashboard",'_self');
	}
	
$(document).ready(function () {
  $('#dtHorizontalVerticalExample').DataTable({
    "scrollX": true,
    "scrollY": 200,
  });
  $('.dataTables_length').addClass('bs-select');
});
</script>

<?php 
	$projectLocationAction = "";
	if($_SESSION["projectLocation"] != "" ){
		$projectLocation = $_SESSION["projectLocation"];
		$projectLocationAction = "&projectLocation=$projectLocation"  ;
		
	}
	ELSE{
		IF($_GET["projectLocation"] != null || $_GET["projectLocation"] != "")
			$projectLocation = $_GET["projectLocation"];
		else IF($_POST["projectLocation"] != null || $_POST["projectLocation"] != "")
			$projectLocation = $_POST["projectLocation"];
		
		$_SESSION["projectLocation"] =  $projectLocation;
	}
	
//include("functions.php");

?>