<style>
	th {
		border-bottom: 1px solid #EAEAEA !important;
	}
	
</style>
<?php
	extract($_REQUEST);
	//echo"00000";

	include("../../php_crud/my_class.php");
	$obj = new my_class();
	if($device_sl_no!=''){
		$report_head = "of Device Serial No: ".$device_sl_no;
	} else if($new_id!=''){
		$report_head = "of Station Id (NEW): ".$new_id;
	} else if($old_id!=''){
		$report_head = "of Station Id (OLD): ".$old_id;
	}
		
	$zone_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_ZONEINFO@AQUATIC227","ID='$zone_id2'");
	$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>All Station with Basic Information '.$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($device_sl_no!=""){
		$where_cond = "DEVICESLNO='$device_sl_no' AND FLAG='A' ORDER BY ID ASC";
	} else if($new_id!=""){
		$where_cond = "NEW_ID='$new_id' AND FLAG='A' ORDER BY ID ASC";
	} else if($old_id!=""){
		$where_cond = "OLD_ID='$old_id' AND FLAG='A' ORDER BY ID ASC";
	} else {
		$where_cond = "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_id2 = $val['DIVISIONCODE'];
		$subdivision_id2 = $val['SUBDIVISIONCODE'];
		$district_id2 = $val['DISTRICTCODE'];
		$upazila_id2 = $val['UPAZILACODE'];
		$zone_id2 = $val['ZONECODE'];
		//echo $zone_id2;
		$division_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_DIVISIONINFO@AQUATIC227","ID='$division_id2'");
		$subdivision_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_SUBDIVISIONINFO@AQUATIC227","ID='$subdivision_id2'");
		$district_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_DISTRICTINFO@AQUATIC227","ID='$district_id2'");
		$upazila_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_UPAZILA@AQUATIC227","ID='$upazila_id2'");
		$zone_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_ZONEINFO@AQUATIC227","ID='$zone_id2'");
		$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>';
	//echo $html;
//==============================================================
//==============================================================
//==============================================================

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');

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


?>