<style>
	th {
		border-bottom: 1px solid #EAEAEA !important;
	}
	hr {
		margin-bottom: 0;
	}
	
</style>
<?php
	extract($_REQUEST);
	$from_date = date("j F, Y", strtotime($from_date));
	$to_date = date("j F, Y", strtotime($to_date));
	$curr_date = date("j F, Y");
	//$daterange = $from_date.' to '.$to_date;
	include("../../php_crud/my_class.php");
	$obj = new my_class();
	$header = '<table style="width: 1400px" 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: 15%">
						<img src="../../asset/custom/site_images/BWDB-LOGO.jpg" width="100px" />
					</td>
					<td style="text-align: center; width: 70%; font-size: 20px;">
						<h3 style="text-align: center;">BWCSRP COMPONENT B: SHEWS</h3>
						<h3 style="text-align: center;">BANGLADESH WATER DEVELOPMENT BOARD (BWDB)</h3>
						<h5>Ground Water Hourly Data From '.$from_date.' to '.$to_date.'</h5>
					</td>
					<td style=" width: 15%; 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: 13px; 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>
			<hr />
			<table style="width: 1400px" border="0" cellpadding="0" cellspacing="0" id="station_tbl" class="table table-bordered table-striped table-bordered table-hover">
				<tr>
					<td style="text-align: left; width: 15%"><b> Report No: </b></td>
					<td style="text-align: center; width: 70%; font-size: 20px;"></td>
					<td style=" width: 15%; font-size: 16px; text-align: right;"><b>Date: </b>'.$curr_date.'</td>
				</tr>
			</table><br />';
			
	
	$html .= '<table style="width: 1500px" border="0" cellpadding="0" cellspacing="0" id="station_tbl3" 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;">New Id (Station)</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Old Id (Station)</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;">WellDia (inch)</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">WellDepth (m)</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Parapet Height (m)</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;">Date</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;">Temperature (c)</th>
			<th style="padding: 5px;border-top: 1px solid #CCC;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;">Water Level (m)</th>
        </tr>
    </thead><tbody>';
	$table_name = "TBLGWH_BASICINFOMST ST INNER JOIN
                      TBLGWH_SUBDIVISIONINFO SDV ON ST.SUBDIVISIONCODE = SDV.ID INNER JOIN
                      TBLGWH_DIVISIONINFO DIV ON ST.DIVISIONCODE = DIV.ID INNER JOIN
                      TBLGWH_ZONEINFO ZN ON ST.ZONECODE = ZN.ID INNER JOIN
                      TBLGWH_DISTRICTINFO DT ON ST.DISTRICTCODE = DT.ID INNER JOIN
					  TBLGWH_UPAZILA UPZ ON ST.UPAZILACODE = UPZ.ID INNER JOIN
                      TBLGWH_GWHDATADTL GWT ON ST.NEW_ID = GWT.STATIONID";
	$column = "TO_CHAR(GWT.DATETIME,'DD-MM-RRRR HH:MI:SS AM') DATETIME, GWT.WATERLEVEL, GWT.WATERTEMPERATURE, GWT.SALINITY,GWT.CONDUCTIVITY, GWT.WATERDENSITY, GWT.TDS,GWT.INTERNALBATTERY,GWT.GTC,SDV.SUBDIVISIONNAME, DIV.DIVISIONNAME,DT.DISTRICTNAME,UPZ.UPAZILANAME,ZN.ZONENAME,ST.NEW_ID,ST.OLD_ID,ST.CURRENTWELLDEPTH,ST.PARAPETHEIGHT,ST.WELLDIA_INCH,ST.RL";
	$where_cond2 = "GWT.DATETIME BETWEEN TO_DATE(GWT.DATETIME,'DD-MON-YY') AND TO_DATE(GWT.DATETIME,'DD-MON-YY') GROUP BY DATETIME, GWT.WATERLEVEL, GWT.WATERTEMPERATURE, GWT.SALINITY,GWT.CONDUCTIVITY, GWT.WATERDENSITY, GWT.TDS,GWT.INTERNALBATTERY,GWT.GTC,SDV.SUBDIVISIONNAME, DIV.DIVISIONNAME,DT.DISTRICTNAME,UPZ.UPAZILANAME,ZN.ZONENAME,ST.NEW_ID,ST.OLD_ID,ST.CURRENTWELLDEPTH,ST.PARAPETHEIGHT,ST.WELLDIA_INCH,ST.RL  ORDER BY ST.NEW_ID,DATETIME DESC ";
	$row=$obj->View_all_data_row_column_By_Cond($table_name,$column,$where_cond2);
	$i = 1;
	foreach($row AS $index=>$val){
		//$id=$val['ID'];
		/*$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;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				
			</tr>";*/
		$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['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;'>". $val['DISTRICTNAME']."</td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['UPAZILANAME']."</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['CURRENTWELLDEPTH']."</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['RL']."</td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['DATETIME']."</td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'></td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['WATERTEMPERATURE']."</td>
				<td style='padding: 5px;border-right: 1px solid #CCC;border-bottom: 1px solid #CCC;'>". $val['WATERLEVEL']."</td>
				
			</tr>";
		$i++;
	}
	$html .= '</tbody></table>';
	$footer = '<table style="width: 1400px;" border="0" cellpadding="0" cellspacing="0" id="station_tbl_footer" class="table table-bordered table-striped table-bordered table-hover">
				<tr>
					<td style="text-align: left; width: 15%"><b> Prepared By </b></td>
					<td style="text-align: center; width: 70%; font-size: 20px;"></td>
					<td style=" width: 15%; font-size: 16px; text-align: right;"><b>Approved By</b></td>
				</tr></table>
			<br />';
//==============================================================
//==============================================================
//==============================================================

include("../../asset/mpdf/mpdf.php");
$mpdf=new mPDF('c','A4-L','','',10,10,45,35,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->SetHTMLFooter($footer);
$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');

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


?>