<?php
session_start();
// ============
include ("../../asset/theme/css/myfunc.php");
include ("../../php_crud/my_class.php");
$obj = new my_class();
// ============
$branchid = $_SESSION['LOGIN_BRANCH'];
extract($_GET);
$litho_info = $obj->Details_By_Cond("HYDROLOGY.BLPUMP_TBL@HYDRO10", "WELL_ID='$well_id'");
//print_r($litho_info);
$upzila = $litho_info['UPZL_CODE'];
$well_data_type = $litho_info['WELL_DATA_TYPE'];
//print_r($well_typ_name);
$sub_div = $litho_info['SUBDIVISION'];
//$subdiv_name = $obj->Details_By_Cond("HYDROLOGY.GW_SUBDIVCODE_TBL@HYDRO10", "HYDSUBDIVCODE='$sub_div'");
//$subdivision_name = $subdiv_name['SUBDIVISION_NAME'];

$well_id = $litho_info['WELL_ID'];
$pre_reg_no = $litho_info['PREREG_NO'];
$tube_well_no = $litho_info['TUBEWELL_NO'];
$upzila = $litho_info['UPZL_CODE'];
$start_dt = $litho_info['START_DT'];
$start_dt = date('d-m-Y', strtotime($start_dt));

$end_dt = $litho_info['END_DT'];
$end_dt = date('d-m-Y', strtotime($end_dt));
$mouza = $litho_info['MOUZA'];
$village = $litho_info['VILLAGE'];
$site = $litho_info['SITE'];
$jl_no = $litho_info['JL_NO'];
$plot_no = $litho_info['PLOT_NO'];
$lat = $litho_info['LATITUDE'];
$lon = $litho_info['LONGITUDE'];
$rl = $litho_info['RL'];
$depth = $litho_info['DEPTH'];
$housing_length = $litho_info['HOUSING_LNTH'];
$housing_dia = $litho_info['HOUSING_DIA'];
$strainer_from_to = $litho_info['STRAINER_FRMTO'];
$strainer_lnth = $litho_info['STRAINER_LNTH'];
$strainer_dia = $litho_info['STRAINER_DIA'];
$blindpipe_length = $litho_info['BLINDPIPE_LTH'];
$blindpipe_dia = $litho_info['BLINDPIPE_DIA'];
$bailplug_length = $litho_info['BAILPLUG_LTH'];
$reducer_length = $litho_info['REDUCER_LTH'];
$pump_type = $litho_info['PUMP_TYPE'];
$well_dia = $litho_info['WELL_DIA'];
$agency_code = $litho_info['AGENCY_CODE'];
$unit = $litho_info['UNIT'];
$purpose = $litho_info['PURPOSE'];
$note = $litho_info['NOTE'];
$grnd_elev = $litho_info['GRND_ELEV'];
$well_data_type = $litho_info['WELL_DATA_TYPE'];
$nmbr_of_obs_well = $litho_info['NUMBER_OF_OBS_WELL'];
$methd_of_sampling = $litho_info['METHOD_OF_SAMPLING'];
$geologist = $litho_info['GEOLOGIST'];
$hole_id = $litho_info['HOLE_ID'];


?>
<style>
	.left_th {
		text-align: right;
		width: 20%;
		padding-bottom: 10px;
		padding-left: 2px;
	}

	.left_select_th {
		text-align: right;
		width: 20%;
		padding-bottom: 5px;
		padding-left: 2px;
	}

	.right_th {
		text-align: right;
		width: 15%;
		padding-bottom: 10px;
		padding-left: 2px;
	}

	.right_select_th {
		text-align: right;
		width: 10%;
		padding-bottom: 5px;
		padding-left: 2px;
	}
</style>

<div class="row-fluid">
	<table border="0" style="width: 100%; border-collapse: collapse;">
		<tr>
			<th class="left_th">Well ID: <font color="#FF0000"></font></th>
			<td style="width: 28%;">
				<input type="hidden" id="e_old_well_id" value="<?php echo $well_id; ?>" />
				<input type="text" style="width: 93%;" id="e_well_id" value="<?php echo $well_id; ?>"
					onkeyup="call_next_val_loader(event,'e_well_id','e_lat')" readonly />
			</td>
			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_select_th">Well Data Type: <font color="#FF0000"></font></th>
			<td style="width: 28%;">
				<select id="e_well_type" name="e_well_type" class="chosen-select" style="width: 98%;">
					<option value="">---SELECT---</option>
					<?php
					$tbl = "HYDROLOGY.GWM_STATION_TYPE@HYDRO10";
					$col = "*";
					$cond = "ID IN ('4', '5')";

					foreach ($obj->View_colmn_By_Cond($tbl, $col, $cond) as $value) {
						$is_wlt_selected = "";
						if ($value['ID'] == $well_data_type) {
							$is_wlt_selected = "selected";
						}
						echo "<option value='" . $value['ID'] . "' $is_wlt_selected >" . $value['TYPE_NAME'] . "</option>";
					}
					?>
				</select>
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="right_select_th">Sub-Division: <font color="#FF0000"></font></th>
			<td style="width: 28%;">
				<select id="e_sub_div" name="e_sub_div" class="chosen-select" style="width: 98%;">
					<option value="">---SELECT---</option>
					<?php
					$table_name = 'HYDROLOGY.GW_SUBDIVCODE_TBL@HYDRO10';
					$columns = 'HYDSUBDIVCODE,SUBDIVISION_NAME';
					$where_cond = '1=1 ORDER BY SUBDIVISION_NAME ASC';

					foreach ($obj->View_colmn_By_Cond($table_name, $columns, $where_cond) as $subdiv_list) {
						$is_sd_selected = "";
						if ($subdiv_list['HYDSUBDIVCODE'] == $sub_div) {
							$is_sd_selected = "selected";
						}
						echo "<option value='" . $subdiv_list['HYDSUBDIVCODE'] . "' $is_sd_selected >" . $subdiv_list['SUBDIVISION_NAME'] . " (" . $subdiv_list['HYDSUBDIVCODE'] . ")</option>";

					}
					?>
				</select>
			</td>

			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_select_th">Upazila (District): <font color="#FF0000"></font></th>
			<td style="width: 28%;">
				<select id="e_upz_code" name="e_upz_code" class="chosen-select" style="width: 98%;">
					<option value="">---SELECT---</option>
					<?php
					$tbl = "HYDROLOGY.UPAZILA_TBL@HYDRO10 UPZ LEFT JOIN HYDROLOGY.DISTRICT_TBL@HYDRO10 DIST ON UPZ.DST_CODE=DIST.DISTRICT_NO";
					$col = "UPZ.UPZL_CODE,UPZ.UPZL_NAME,DIST.DISTRICT_NAME";
					$cond = "1=1 ORDER BY UPZ.UPZL_NAME ASC";

					foreach ($obj->View_colmn_By_Cond($tbl, $col, $cond) as $value) {
						$is_upz_selected = "";
						if ($value['UPZL_CODE'] == $upzila) {
							$is_upz_selected = "selected";
						}
						echo "<option value='" . $value['UPZL_CODE'] . "' $is_upz_selected >" . $value['UPZL_NAME'] . " (" . $value['DISTRICT_NAME'] . ")</option>";

					}
					?>
				</select>
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="left_th">Start Date Time: <font color="#FF0000"></font></th>
			<td style="width: 28%;">
				<div class="controls">
					<div class="row-fluid input-prepend">
						<span class="add-on">
							<i class="icon-calendar"></i>
						</span>
						<input id="e_start_date" name="start_date" class="date-picker"
							onkeyup="call_next_val_loader(event,'e_start_date','e_end_date')" type="text"
							data-date-format="dd-mm-yyyy" placeholder="dd-mm-yyyy" style="width: 84%;"
							value="<?php echo $start_dt; ?>" />
					</div>
				</div>
			</td>
			<td style="width: 4%; ">&nbsp;&nbsp;&nbsp;</td>
			<th class="right_th">End Date Time: <font color="#FF0000"></font></th>
			<td style="width: 28%;">
				<div class="controls">
					<div class="row-fluid input-prepend">
						<span class="add-on">
							<i class="icon-calendar"></i>
						</span>
						<input id="e_end_date" name="end_date" class="date-picker"
							onkeyup="call_next_val_loader(event,'e_end_date','e_jl_no')" type="text"
							data-date-format="dd-mm-yyyy" placeholder="dd-mm-yyyy" style="width: 84%;"
							value="<?php echo $end_dt; ?>" />
					</div>
				</div>
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="right_th">Latitude: <font color="#FF0000"></font></th>
			<td style="width: 28%;">
				<input type="text" onkeypress="return isNumericInput(event)" style="width: 93%;" id="e_lat"
					value="<?php echo $lat; ?>" onkeyup="call_next_val_loader(event,'e_lat','e_lon')" />
			</td>
			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="right_th">Longitude: <font color="#FF0000"></font></th>
			<td style="width: 28%;">
				<input type="text" onkeypress="return isNumericInput(event)" style="width: 93%;" id="e_lon"
					value="<?php echo $lon; ?>"
					onkeyup="call_next_val_loader(event,'e_lon','e_depth')" />
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="right_th">Total Drilling Depth (m): <font color="#FF0000"></font></th>
			<td style="width: 28%;">
				<input onkeypress="return isNumericInput(event)" type="text" style="width: 93%;"
					id="e_depth"
					onkeyup="call_next_val_loader(event,'e_depth','e_grnd_levl')"
					value="<?php echo $depth; ?>" />
			</td>
			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="right_th">Ground Elevation: </th>
			<td style="width: 28%;">
				<input type="text" onkeypress="return isNumericInput(event)" style="width: 93%;" id="e_grnd_levl"
					value="<?php echo $grnd_elev; ?>" onkeyup="call_next_val_loader(event,'e_grnd_levl','e_purpose')" />
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="right_th">Purpose: </th>
			<td style="width: 28%;">
				<input type="text" style="width: 93%;" id="e_purpose"
					onkeyup="call_next_val_loader(event,'e_purpose','e_jl_no')" value="<?php echo $purpose; ?>" />
			</td>
			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="right_th">RL: </th>
			<td style="width: 28%;">
				<input type="text" style="width: 93%;" id="e_rl" onkeypress="return isNumericInput(event)"
					onkeyup="call_next_val_loader(event,'e_rl','e_housing_lth')" value="<?php echo $rl; ?>" />
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="left_th">JL No: </th>
			<td style="width: 28%;">
				<input type="text" onkeypress="return isNumericInput(event)" style="width: 93%;" id="e_jl_no"
					value="<?php echo $jl_no; ?>" onkeyup="call_next_val_loader(event,'e_jl_no','e_plot_no')" />
			</td>
			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_th">Housing Length: </th>
			<td style="width: 28%;">
				<input type="text" onkeypress="return isNumericInput(event)" style="width: 93%;" id="e_housing_lth"
					value="<?php echo $housing_length; ?>"
					onkeyup="call_next_val_loader(event,'e_housing_lth','e_hosing_dia')" />
			</td>

			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="right_th">Plot No: </th>
			<td style="width: 28%;">
				<input onkeypress="return isNumericInput(event)" type="text" style="width: 93%;" id="e_plot_no"
					value="<?php echo $plot_no; ?>" onkeyup="call_next_val_loader(event,'e_plot_no','e_mouza')" />
			</td>
			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_th">Housing Dia: </th>
			<td style="width: 28%;">
				<input type="text" onkeypress="return isNumericInput(event)" style="width: 93%;" id="e_hosing_dia"
					value="<?php echo $housing_dia; ?>"
					onkeyup="call_next_val_loader(event,'e_hosing_dia','e_no_of_obs_well')" />
			</td>

			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="right_th">Mouza: </th>
			<td style="width: 28%;">
				<input type="text" style="width: 93%;" id="e_mouza" value="<?php echo $mouza; ?>"
					onkeyup="call_next_val_loader(event,'e_mouza','e_village')" />
			</td>
			<td style="width: 4%; ">&nbsp;&nbsp;&nbsp;</td>
			<th class="right_th">Number of Obs. Well: <font color="#FF0000"></font></th>
			<td style="width: 28%;">
				<input type="text" style="width: 93%;" id="e_no_of_obs_well" value="<?php echo $nmbr_of_obs_well; ?>" onkeypress="return isNumericInput(event)"
					onkeyup="call_next_val_loader(event,'e_no_of_obs_well','str_frm_to')" />
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="right_th">Village: </th>
			<td style="width: 28%;">
				<input type="text" style="width: 93%;" id="e_village" value="<?php echo $village; ?>"
					onkeyup="call_next_val_loader(event,'e_village','e_pre_reg_no')" />
			</td>

			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_th">Strainer From to: </th>
			<td style="width: 28%;">
				<input type="text" style="width: 93%;" id="str_frm_to" value="<?php echo $strainer_from_to; ?>"
					onkeyup="call_next_val_loader(event,'str_frm_to','e_strainer_dia')" />
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>

		<tr>
			<th class="right_th">Pre Reg. No: </th>
			<td style="width: 28%;">
				<input type="text" style="width: 93%;" id="e_pre_reg_no"
					onkeyup="call_next_val_loader(event,'e_pre_reg_no','e_site')" value="<?php echo $pre_reg_no; ?>" />
			</td>

			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_th">Strainer Dia: </th>
			<td style="width: 28%;">
				<input onkeypress="return isNumericInput(event)" type="text" style="width: 93%;" id="e_strainer_dia"
					value="<?php echo $strainer_dia; ?>"
					onkeyup="call_next_val_loader(event,'e_strainer_dia','e_starinr_lnth')" />
			</td>

			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>

		<tr>
			<th class="right_th">Location: </th>
			<td style="width: 28%;">
				<input type="text" style="width: 93%;" id="e_site" value="<?php echo $site; ?>"
					onkeyup="call_next_val_loader(event,'e_site','e_hole_id')" />
			</td>

			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_th">Strainer Length: </th>
			<td style="width: 28%;">
				<input type="text" onkeypress="return isNumericInput(event)" style="width: 93%;" id="e_starinr_lnth"
					value="<?php echo $strainer_lnth; ?>"
					onkeyup="call_next_val_loader(event,'e_starinr_lnth','e_blindpipe_lnth')" />
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>

		<tr>
			<th class="left_th">Hole Id: </th>
			<td style="width: 28%;">
				<input type="text"  style="width: 93%;" id="e_hole_id"
					value="<?php echo $hole_id; ?>"
					onkeyup="call_next_val_loader(event,'e_hole_id','e_method_sampling')" />
			</td>
			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_th">Blindpipe Length: </th>
			<td style="width: 28%;">
				<input type="text" onkeypress="return isNumericInput(event)" style="width: 93%;" id="e_blindpipe_lnth"
					value="<?php echo $blindpipe_length; ?>"
					onkeyup="call_next_val_loader(event,'e_blindpipe_lnth','e_blindpipe_dia')" />
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>

		<tr>
			<th class="left_th">Method Of Sampling: </th>
			<td style="width: 28%;">
				<input type="text"  style="width: 93%;" id="e_method_sampling"
					value="<?php echo $methd_of_sampling; ?>"
					onkeyup="call_next_val_loader(event,'e_method_sampling','e_geologist')" />
			</td>
			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_th">Blindpipe Dia: </th>
			<td style="width: 28%;">
				<input type="text" onkeypress="return isNumericInput(event)" style="width: 93%;" id="e_blindpipe_dia"
					value="<?php echo $blindpipe_dia; ?>"
					onkeyup="call_next_val_loader(event,'e_blindpipe_dia','e_bail_lth')" />
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>

		<tr>
			<th class="left_th">Geologist: </th>
			<td style="width: 28%;"> <input type="text" style="width: 93%;" id="e_geologist"
					 value="<?php echo $geologist; ?>"
					onkeyup="call_next_val_loader(event,'e_geologist','e_note')" /> </td>
			<td style="width: 4%;">
				&nbsp;&nbsp;&nbsp;</td>
			<th class="left_th">Bailplug Length: </th>
			<td style="width: 28%;"> <input type="text" style="width: 93%;" id="e_bail_lth"
					onkeypress="return isNumericInput(event)" value="<?php echo $bailplug_length; ?>"
					onkeyup="call_next_val_loader(event,'e_bail_lth','e_pump_typ')" /> </td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="right_th">Remark: </th>
			<td style="width: 28%;">
				<input type="text" style="width: 93%;" id="e_note" onkeyup="call_next_val_loader(event,'e_note','e_rl')"
					value="<?php echo $note; ?>" />
			</td>
			<td style="width: 4%; ">&nbsp;&nbsp;&nbsp;</td>
			<th class="right_th">Pump Type: </th>
			<td style="width: 28%;">
				<input type="text" style="width: 93%;" id="e_pump_typ"
					onkeyup="call_next_val_loader(event,'e_pump_typ','e_reducer_lth')"
					value="<?php echo $pump_type; ?>" />
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="left_th"></th>
			<td style="width: 28%;">

			</td>
			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_th">Reducer Length: </th>
			<td style="width: 28%;">
				<input type="text" onkeypress="return isNumericInput(event)" style="width: 93%;" id="e_reducer_lth"
					value="<?php echo $reducer_length; ?>"
					onkeyup="call_next_val_loader(event,'e_reducer_lth','e_well_dia')" />
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="left_th"></th>
			<td style="width: 28%;">

			</td>
			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_th">Well Dia: </th>
			<td style="width: 28%;">
				<input type="text" onkeypress="return isNumericInput(event)" style="width: 93%;" id="e_well_dia"
					value="<?php echo $well_dia; ?>" onkeyup="call_next_val_loader(event,'e_well_dia','e_unit')" />
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
		<tr>
			<th class="left_th"></th>
			<td style="width: 28%;">

			</td>
			<td style="width: 4%;">&nbsp;&nbsp;&nbsp;</td>
			<th class="left_th">Unit: </th>
			<td style="width: 28%;">
				<!-- <input type="text" style="width: 93%;" id="e_unit" value="<?php echo $unit; ?>" /> -->
				<select id="e_unit" name="e_unit" class="chosen-select" style="width: 100%;">
					<option value="">---SELECT---</option>
					<option value="Feet" <?php if ($unit === 'Feet')
						echo 'selected'; ?>>Feet</option>
					<option value="Meter" <?php if ($unit === 'Meter')
						echo 'selected'; ?>>Meter</option>
					<option value="Inch" <?php if ($unit === 'Inch')
						echo 'selected'; ?>>Inch</option>
				</select>
			</td>
			<td style="width: 10%;">&nbsp;&nbsp;&nbsp;</td>
		</tr>
	</table>
</div>

<script>
	$('.chosen-select').chosen({ 
		allow_single_deselect: true,
		search_contains: true
		});
	//resize the chosen on window resize

	$(window)
		.off('resize.chosen')
		.on('resize.chosen', function () {
			$('.chosen-select').each(function () {
				var $this = $(this);
				$this.next().css({ 'width': '98%' });
			})
		}).trigger('resize.chosen');
	//resize chosen on sidebar collapse/expand
	$(document).on('settings.ace.chosen', function (e, event_name, event_val) {
		if (event_name != 'sidebar_collapsed') return;
		$('.chosen-select').each(function () {
			var $this = $(this);
			$this.next().css({ 'width': '98%' });
		})
	});
</script>

<!-- Alphanumeric Checking -->
<script>
	let inputReset = false; // Track whether input should be reset

	function isNumericInput(event) {
		const key = event.keyCode || event.which;
		const keyChar = String.fromCharCode(key);

		const regex = /[0-9]|\.|\-/; // Alphanumeric pattern

		// Only allow alphanumeric input
		if (!regex.test(keyChar)) {
			event.preventDefault();
			return false;
		}

		const input = event.target;
		const currentValue = input.value;

		if (inputReset) {
			input.value = "";
			inputReset = false;
		}

		return true;
	}
</script>
<!-- Alphanumeric Checking -->

<!-- Alphanumeric Checking -->


<!--Enter Checking-->
<script>
	function call_next_val_loader(e, sel_col_id, next_col_id) {
		if (event.keyCode == 13 || event.keyCode == 'tab') {
			$("#" + next_col_id).select();
		}
	}
</script>
<!--Enter Checking-->
<!--date picker start-->
<script type="text/javascript">
	$('.date-picker').datepicker().next().on(ace.click_event, function () {
		$(this).prev().focus();

	});
	$(".date-picker").attr("autocomplete", "off");
</script>
<!--date picker end-->