<style>
	th {
		border-bottom: 1px solid #EAEAEA !important;
	}

	hr {
		margin-bottom: 0;
	}
</style>
<?php
include("../../php_crud/my_class.php");
$obj = new my_class();
error_reporting(E_ALL); // Report all types of errors
ini_set('display_errors', 1); // Display errors on the screen

require_once '../../asset/mpdf/vendor/autoload.php';
extract($_REQUEST);
$where = "RAW_PARAMETER_ID='474' AND DATA_READ_TYPE IN ('AUTO','BOTH') AND STATION_TYPE='AUTO' AND WELL_DATA_TYPE='1'";



if ($hydro_div == "all") {
	$where = "DATA_READ_TYPE IN ('AUTO','BOTH') AND RAW_PARAMETER_ID='474' AND STATION_TYPE='AUTO' AND WELL_DATA_TYPE='1'";
	// print_r($where);
} else {
	if ($hydro_div != "" && $hydro_sub_div == "all" && $district == "") {
		$hydro_div_info = $obj->Details_By_Cond("HYDROLOGY.DIVCODE_TBL@HYDRO10", "HYDDIVCODE='$hydro_div'");
		$hydro_div_name = "<b><font color='#3d0099'>" . $hydro_div_info['DIVISION_NAME'] . "</font></b>";
		$where = "DATA_READ_TYPE IN ('AUTO','BOTH') AND WELL_DATA_TYPE='1' AND STATION_TYPE='AUTO' AND RAW_PARAMETER_ID='474' AND HYDDIVCODE='$hydro_div'";
		// $label = "$station_type_name Stations Status Information for Hydro-Division: $hydro_div_name";
	} else if ($hydro_div != "" && $hydro_sub_div == "all" && $district != "") {
		$hydro_div_info = $obj->Details_By_Cond("HYDROLOGY.DIVCODE_TBL@HYDRO10", "HYDDIVCODE='$hydro_div'");
		$hydro_div_name = "<b><font color='#3d0099'>" . $hydro_div_info['DIVISION_NAME'] . "</font></b>";
		$dist_info = $obj->Details_By_Cond("HYDROLOGY.DISTRICT_TBL@HYDRO10", "DISTRICT_NO='$district'");
		$dist_name = "<b><font color='#3d0099'>" . $dist_info['DISTRICT_NAME'] . "</font></b>";
		$where = "DATA_READ_TYPE IN ('AUTO','BOTH') AND WELL_DATA_TYPE='1' AND STATION_TYPE='AUTO' 
			AND RAW_PARAMETER_ID='474' AND HYDDIVCODE='$hydro_div' AND DISTRICT_NO='$district'";
		// $label = "$station_type_name Stations Status Information for Hydro-Division: $hydro_div_name and District: $dist_name";
	} else if ($hydro_div != "" && $hydro_sub_div != "" && $district == "") {
		$hydro_div_info = $obj->Details_By_Cond("HYDROLOGY.DIVCODE_TBL@HYDRO10", "HYDDIVCODE='$hydro_div'");
		$hydro_div_name = "<b><font color='#3d0099'>" . $hydro_div_info['DIVISION_NAME'] . "</font></b>";
		$hydro_sub_div_info = $obj->Details_By_Cond("HYDROLOGY.SUBDIVCODE_TBL@HYDRO10", "HYDSUBDIVCODE='$hydro_sub_div'");
		$hydro_sub_div_name = "<b><font color='#3d0099'>" . $hydro_sub_div_info['SUBDIVISION_NAME'] . "</font></b>";
		$where = "DATA_READ_TYPE IN ('AUTO','BOTH') AND WELL_DATA_TYPE='1' AND STATION_TYPE='AUTO' 
			AND RAW_PARAMETER_ID='474' AND HYDDIVCODE='$hydro_div' AND HYDSUBDIVCODE='$hydro_sub_div'";
		// $label = "$station_type_name Stations Status Information for Hydro-Division: $hydro_div_name and Hydro-Subdivision: $hydro_sub_div_name";
	} else if ($hydro_div != "" && $hydro_sub_div != "" && $district != "") {
		$hydro_div_info = $obj->Details_By_Cond("HYDROLOGY.DIVCODE_TBL@HYDRO10", "HYDDIVCODE='$hydro_div'");
		$hydro_div_name = "<b><font color='#3d0099'>" . $hydro_div_info['DIVISION_NAME'] . "</font></b>";
		$hydro_sub_div_info = $obj->Details_By_Cond("HYDROLOGY.SUBDIVCODE_TBL@HYDRO10", "HYDSUBDIVCODE='$hydro_sub_div'");
		$hydro_sub_div_name = "<b><font color='#3d0099'>" . $hydro_sub_div_info['SUBDIVISION_NAME'] . "</font></b>";
		$dist_info = $obj->Details_By_Cond("HYDROLOGY.DISTRICT_TBL@HYDRO10", "DISTRICT_NO='$district'");
		$dist_name = "<b><font color='#3d0099'>" . $dist_info['DISTRICT_NAME'] . "</font></b>";
		$where = "DATA_READ_TYPE IN ('AUTO','BOTH') AND WELL_DATA_TYPE='1' AND STATION_TYPE='AUTO' 
			AND RAW_PARAMETER_ID='474' AND HYDDIVCODE='$hydro_div' AND HYDSUBDIVCODE='$hydro_sub_div' 
			AND DISTRICT_NO='$district'";
		// $label = "$station_type_name Stations Status Information for Hydro-Division: $hydro_div_name, Hydro-Subdivision: $hydro_sub_div_name and District: $dist_name";
	} else {
		// $label = "$station_type_name Stations Status Information";
		$where = "DATA_READ_TYPE IN ('AUTO','BOTH') AND WELL_DATA_TYPE='1' AND STATION_TYPE='AUTO' AND RAW_PARAMETER_ID='474'";
		// print_r($where);
	}
}
$status_label = "Status type: ";
if ($sw_status == 0) {
	$where = $where . "";
	$status_label .= "<b><font color='#8B008B'>Active & Inactive</font></b>";
} else if ($sw_status == 3) {
	$where = $where . " AND STATION_STATUS='ACTIVE'";
	$status_label .= "<b><font color='#228B22'>Active</font></b>";
} else if ($sw_status == 2) {
	$where = $where . " AND STATION_STATUS='INACTIVE' AND DIFF_HOURS<='72' AND DIFF_HOURS>='24'";
	$status_label .= "<b><font color='#000080'>Inactive for 24-72 Hours</font></b>";
} else if ($sw_status == 1) {
	$where = $where . " AND STATION_STATUS='INACTIVE' AND DIFF_HOURS>'72'";
	$status_label .= "<b><font color='#FF0000'>Inactive for more than 72 Hours</font></b>";
} else if ($sw_status == 4) {
	$diff_hours_input = $inactive_days * 24;
	$where = $where . " AND STATION_STATUS='INACTIVE' AND DIFF_HOURS>'$diff_hours_input'";
	$status_label .= "<b><font color='#b30000'>Inactive for more than $inactive_days days</font></b>";
} else {
	$where = $where . "";
	$status_label .= "<b><font color='#8B008B'>Active & Inactive</font></b>";
}

$html .= '
	<html>
	<head>
		<title>GROUND WATER DATA AVAILABILITY STATUS</title>
		<link href="https://fonts.googleapis.com/css?family=Tangerine" rel="stylesheet">
	</head>
	<body>
    <table style="width: 100%;" border="0" cellpadding="0" cellspacing="0" class="table table-bordered table-striped table-bordered table-hover">
		<tr>
			<td style="text-align: center; width: 25%">
				<img src="../../asset/custom/site_images/BWDB-LOGO.jpg" width="100px" />
			</td>
			<td style="text-align: left; width: 75%;">
				<h3 style="text-align: center;">GROUND WATER DATA AVAILABILITY</h3>
                <h3 style="text-align: center;">BANGLADESH WATER DEVELOPMENT BOARD (BWDB)</h3>		
			</td>
		</tr>
	</table>
	<br/>
	  <table style="width: 80%; margin: auto; font-size: 10px !important; border-collapse: collapse;" border="1" cellpadding="5" cellspacing="0" id="station_tbl" class="table table-bordered table-striped table-hover">
        <thead>
            <tr style="background: #f2f2f2;">
                <th style="text-align: center; padding: 5px;">Sl.</th>
                <th style="text-align: center; padding: 5px;">Division</th>
                <th style="text-align: center; padding: 5px;">Sub Division</th>
                <th style="text-align: center; padding: 5px;">District</th>
                <th style="text-align: center; padding: 5px;">Total Stations</th>
                <th style="text-align: center; padding: 5px;">Active Station</th>
                <th style="text-align: center; padding: 5px;">Inactive Station</th>
            </tr>
        </thead>
        <tbody>';
		$sl = 0;
		foreach ($obj->ground_water_auto_station_status_summary($where) as $value) {
			$sl++;
			$html .= "<tr>
                <td style='font-size: 14px; text-align: center;'>".$sl."</td>
                <td style='padding: 8px; '>".$value['DIVISION_NAME']."</td>
                <td style='padding: 8px;'>".$value['SUBDIVISION_NAME']."</td>
                <td style='text-align: center; padding: 8px;'>".$value['DISTRICT_NAME']."</td>
                <td style='text-align: center; padding: 8px;'>".$value['TOTAL_STATIONS']."</td>
                <td style='text-align: center; padding: 8px;'>".$value['ACTIVE_STATIONS']."</td>
                <td style='text-align: center; padding: 8px;'>".$value['INACTIVE_STATIONS']."</td>
            </tr>";
		}
		$html .= '</tbody></table>';
        $html .='</body>
        </html>';

//==============================================================
//==============================================================
//==============================================================
$mpdf = new \Mpdf\Mpdf();
$mpdf->SetFooter('Powered by Leotech | {PAGENO} of {nbpg}');
$mpdf->SetMargins(10, 10, 10,10); // Set top, right, bottom, left margins
$mpdf->shrink_tables_to_fit = false; // Prevent tables from shrinking
$mpdf->default_font_size = 12; // Set default font size for the document
// $mpdf->list_indent_first_level = 0;	// 1 or 0 - whether to indent the first level of a list
$mpdf->SetDisplayMode('fullpage');
// LOAD a stylesheet
// $stylesheet = file_get_contents('mpdfstyletables.css');
// $mpdf->WriteHTML($stylesheet,1);	// The parameter 1 tells that this is css/style only and no body/html/text
// $mpdf->WriteHTML($html,2);
$mpdf->WriteHTML($html);
$mpdf->Output();
//==============================================================
//==============================================================
//==============================================================
?>