<style>
	th {
		border-bottom: 1px solid #EAEAEA !important;
	}
	
</style>
<?php
	require_once '../../asset/mpdf/vendor/autoload.php';
	error_reporting(E_ALL);
	ini_set('display_errors', 1);

	extract($_REQUEST);
	include("../../php_crud/my_class.php");
	$obj = new my_class();
	
	if($zone_id!=''){
		$zone_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_ZONEINFO@aquatic227","ID='$zone_id'");
		$zone_name = $zone_info['ZONENAME'];
		$report_head = "of Zone: ".$zone_name;
	} else if($division_id!=''){
		$division_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_DIVISIONINFO@aquatic227","ID='$division_id'");
		$division_name = $division_info['DIVISIONNAME'];
		$report_head = "of Division: ".$division_name;
	} else if($subdivision_id!=''){
		$subdivision_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_SUBDIVISIONINFO@aquatic227","ID='$subdivision_id'");
		$subdivision_name = $subdivision_info['SUBDIVISIONNAME'];
		$report_head = "of Sub Division: ".$subdivision_name;
	} else if($district_id!=''){
		$district_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_DISTRICTINFO@aquatic227","ID='$district_id'");
		$district_name = $district_info['DISTRICTNAME'];
		$report_head = "of District: ".$district_name;
	} else if($problem_type_id!=''){
		$problem_type_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_PROBLEMTYPE@aquatic227","ID='$problem_type_id'");
		$problem_type = $problem_type_info['PROBLEMTYPE'];
		$report_head = "of Problem Type: ".$problem_type;
	} else if($signal_strength_id!=''){
		$signal_strength_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_SIGNALSTRENGTH@aquatic227","ID='$signal_strength_id'");
		$signal_strength = $signal_strength_info['SIGNALSTRENGTH'];
		$report_head = "of Signal Strength: ".$signal_strength;
	} 
	$header = '<table style="width: 1000px" border="0" cellpadding="0" cellspacing="0" id="station_tbl" 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: center; width: 63%;">
						<h3 style="text-align: center;">BWCSRP COMPONENT B: SHEWS</h3>
						<h3 style="text-align: center;">BANGLADESH WATER DEVELOPMENT BOARD (BWDB)</h3>
						<h5>List of Water Level,Temperature And Conductivity (WLTC) '.$report_head.'</h5>
					</td>
					<td style=" width: 12%; font-size: 11px;">
						<table style="width: 100%;" border="0" cellpadding="0" cellspacing="0" class="table table-bordered table-striped table-bordered table-hover">
							<tr>
								<td style="font-size: 11px; border-right: 1px solid #CCC">
									<p>Legend: <br>
									<br>
									1. F=Functioning<br>
									2. NF=Non Functioning<br>
									3. PH=Parapet Height<br>
									4. m=meter<br>
									5. inc=inches
									</p>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<br />
			<br />
	';
	
	
	$html .= '<table style="width: 1000px" border="0" cellpadding="0" cellspacing="0" id="station_tbl" class="table table-bordered table-striped table-bordered table-hover" style="font-size: 11px !important;">
    <thead>
        <tr style="">
            <th style="padding: 5px;border-top: 1px solid #CCC;border-left: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">SL.</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Device SL No.</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">New Id</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Old Id</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Zone</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Division</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Sub Division</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">District</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Upazila</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Latitude</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Longitude</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Para Type</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">RL(m)</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Curr Depth(m)</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Dia(inch)</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">RL To P(m)</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">PH(m)</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">GWT(m)</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Depth(m)</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Status</th>
        </tr>
    </thead><tbody>';
	$table_name =  "AQUATIC.TBLGWH_BASICINFOMST@aquatic227";
	
	if($zone_id!=""){
		$where_cond = "SENSORTYPE='WLTC' AND ZONECODE='$zone_id' AND FLAG='A' ORDER BY ID ASC";
	} else if($division_id!=""){
		$where_cond = "SENSORTYPE='WLTC' AND DIVISIONCODE='$division_id' AND FLAG='A' ORDER BY ID ASC";
	} else if($subdivision_id!=""){
		$where_cond = "SENSORTYPE='WLTC' AND SUBDIVISIONCODE='$subdivision_id' AND FLAG='A' ORDER BY ID ASC";
	} else if($district_id!=""){
		$where_cond = "SENSORTYPE='WLTC' AND DISTRICTCODE='$district_id' AND FLAG='A' ORDER BY ID ASC";
	} else if($problem_type_id!=""){
		$where_cond = "SENSORTYPE='WLTC' AND PROBLEMID='$problem_type_id' AND FLAG='A' ORDER BY ID ASC";
	} else if($signal_strength_id!=""){
		$where_cond = "SENSORTYPE='WLTC' AND SIGNALSTRENGTH='$signal_strength_id' AND FLAG='A' ORDER BY ID ASC";
	} else {
		$where_cond = "SENSORTYPE='WLTC' AND FLAG='A' ORDER BY ID ASC";
	}
	
	
	$row=$obj->View_all_data_row_column_By_Cond($table_name,' * ',$where_cond);
	$i = 1;
	foreach($row AS $index=>$val){
		$division_id = $val['DIVISIONCODE'];
		$subdivision_id = $val['SUBDIVISIONCODE'];
		$district_id = $val['DISTRICTCODE'];
		$upazila_id = $val['UPAZILACODE'];
		$zone_id = $val['ZONECODE'];
		$division_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_DIVISIONINFO@aquatic227","ID='$division_id'");
		$subdivision_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_SUBDIVISIONINFO@aquatic227","ID='$subdivision_id'");
		$district_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_DISTRICTINFO@aquatic227","ID='$district_id'");
		$upazila_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_UPAZILA@aquatic227","ID='$upazila_id'");
		$zone_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_ZONEINFO@aquatic227","ID='$zone_id'");
		$id=$val['ID'];
		$func_status=$val['STATUS'];
		if($func_status==1){
			$func_status='F';
		} else if($func_status==2){
			$func_status='NF';
		}
		$html .="<tr>  
					<td style='padding: 5px;border-left: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>".$i."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['DEVICESLNO']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['NEW_ID']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['OLD_ID']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $zone_info['ZONENAME']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $division_info['DIVISIONNAME']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $subdivision_info['SUBDIVISIONNAME']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $district_info['DISTRICTNAME']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $upazila_info['UPAZILANAME']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['LATITUDE']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['LONGITUDE']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". strtoupper($val['SENSORTYPE'])."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['RL']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['CURRENTWELLDEPTH']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['WELLDIA_INCH']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['RLTOTOPOFTHEPIPE']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['PARAPETHEIGHT']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['GWTABLEFROMTOPOFTHEPIPE']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['SENSORDEPTH']."</td>
					<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $func_status."</td>
				</tr>";
			$i++;
	}
	$html .= '</tbody></table>';




//==============================================================
//==============================================================
//==============================================================
$mpdf = new \Mpdf\Mpdf();
			$mpdf->WriteHTML($html);
			$mpdf->Output();

// include("../../asset/mpdf/mpdf.php");
// $mpdf=new mPDF('c','A4-L','','',10,10,40,25,10,13); 
// $mpdf->simpleTables = true;
// $mpdf->packTableData = true;
// $mpdf->keep_table_proportions = TRUE;
// $mpdf->shrink_tables_to_fit=1;
// $mpdf->SetDisplayMode('fullpage');
// $mpdf->SetHTMLHeader($header);

// $mpdf->list_indent_first_level = 0;	// 1 or 0 - whether to indent the first level of a list

// // 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->Output('mpdf.pdf','I');

//==============================================================
//==============================================================
//==============================================================


?>