<?php
	session_start();
	$user_id=$_SESSION['LOGIN_USERID'];
	extract($_REQUEST);
	include("../../php_crud/my_class.php");
	$obj = new my_class();
		$station_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_BASICINFOMST@aquatic227","ID='$id'");
		$subdivision_code = $station_info['SUBDIVISIONCODE'];
		$subdivision_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_SUBDIVISIONINFO@aquatic227","ID='$subdivision_code'");
		$district_code = $station_info['DISTRICTCODE'];
		$district_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_DISTRICTINFO@aquatic227","ID='$district_code'");
		$upazila_code = $station_info['UPAZILACODE'];
		$upazila_info = $obj->Details_By_Cond("AQUATIC.TBLGWH_UPAZILA@aquatic227","ID='$upazila_code'");
	// if ($_SESSION['add'] == 'Y') {
		
?>
<div class="row-fluid" id="">
    <form action="" id="stationEditForm" method="post">
		<input type="hidden" name="station_id" id="station_id" value="<?php echo $id;?>" />
		<div class="row-fluid">
			<div class="row-fluid">
				<legend>Station Information</legend> 	
			</div>
			<div class="row-fluid">
				<div class="span4">
					<div class="control-group">
						<label class="control-label" for="form-field-1"><b>Zone <font color="#FF0000">*</font></b></label>
						<div class="controls">
							<select class="form_control" name="zone_code" id="e_zone_code">
								<option value="">Select Zone</option>
								<?php
									$table_name = "AQUATIC.TBLGWH_ZONEINFO@aquatic227";
									$where_cond = "FLAG='A' ORDER BY ZONENAME ASC";
									$row = $obj->View_all_data_row_column_By_Cond($table_name,' * ',$where_cond);
									foreach($row AS $index=>$value){?>
										<option value="<?php echo $value['ID']; ?>" <?php if($value['ID']==$station_info['ZONECODE']){ echo "selected";} ?>><?php echo $value['ZONENAME'];?></option>
									<?php } ?>
							</select>
						</div> 
					</div>
				</div>
				<div class="span4">	
					<div class="control-group">
						<label class="control-label" for="form-field-1"><b>Division <font color="#FF0000">*</font></b></label>
						<div class="controls">
							<select class="form_control" name="division_code" id="e_division_code" onchange="load_sub_div(this.value)">
								<option value="">Select Division</option>
								<?php
									$table_name = "AQUATIC.TBLGWH_DIVISIONINFO@aquatic227";
									$where_cond = "FLAG='A' ORDER BY DIVISIONNAME ASC";
									$row = $obj->View_all_data_row_column_By_Cond($table_name,' * ',$where_cond);
									foreach($row AS $index=>$value){?>
										<option value="<?php echo $value['ID']; ?>" <?php if($value['ID']==$station_info['DIVISIONCODE']){ echo "selected";} ?>><?php echo $value['DIVISIONNAME'];?></option>
									<?php }
								?>
							</select>
						</div> 
					</div>
				</div>
				<div class="span4">	
					<div class="control-group">
						<label class="control-label" for="form-field-1"><b>Sub Division <font color="#FF0000">*</font></b></label>
						<div class="controls" id="sub_div_code_holder">
							<select class="form_control" name="sub_division_code" id="e_sub_division_code">
								<option value="<?php echo $station_info['SUBDIVISIONCODE']; ?>"><?php echo $subdivision_info['SUBDIVISIONNAME']; ?></option>
							</select>
						</div> 
					</div>
				</div>
				
			</div>
			<div class="row-fluid">
				<div class="span4">
					<div class="control-group">
						<label class="control-label" for="form-field-1"><b>District <font color="#FF0000">*</font></b></label>
						<div class="controls" id="sub_dist_code_holder">
							<select class="form_control" name="district_code" id="e_district_code">
								<option value="<?php echo $station_info['DISTRICTCODE']; ?>"><?php echo $district_info['DISTRICTNAME']; ?></option>
							</select>
						</div> 
					</div>
				</div>
				<div class="span4">
					<div class="control-group">
						<label class="control-label" for="form-field-1"><b>Upazila <font color="#FF0000">*</font></b></label>
						<div class="controls" id="upz_code_holder">
							<select class="form_control" name="upazila_code" id="e_upazila_code">
								<option value="<?php echo $station_info['UPAZILACODE']; ?>"><?php echo $upazila_info['UPAZILANAME']; ?></option>
							</select>
						</div> 
					</div>
				</div>
				
			</div>
		</div>
		<div class="row-fluid">
			<div class="span4">	
				<div class="control-group">
					<label class="control-label" for="form-field-1">Station New Id<font color="#FF0000">*</font></label>
					<div class="controls">
						<input type="text" name="new_id" id="e_new_id" class="form-control" placeholder="Station New Id" value="<?php echo $station_info['NEW_ID']; ?>">
					</div> 
				</div> 
				<div class="control-group">
					<label class="control-label" for="form-field-1">Station Name<font color="#FF0000">*</font></label>
					<div class="controls">
						<input type="text" name="name" id="e_name" class="form-control" placeholder="Station Name" value="<?php echo $station_info['STATIONNAME']; ?>">
					</div> 
				</div>
				<div class="control-group">
					<label class="control-label" for="form-field-1">Station Address<font color="#FF0000">*</font></label>
					<div class="controls">
						<textarea class="form-control" name="address" id="e_address" class="form-control" placeholder="Station Address"><?php echo $station_info['ADDRESSDETAIL']; ?></textarea>
					</div> 
				</div>
				<div class="control-group">
					<label class="control-label" for="form-field-1">Latitude<font color="#FF0000">*</font></label>
					<div class="controls">
						<input type="text" name="lattitude" id="e_lattitude" class="form-control" placeholder="Latitude"  value="<?php echo $station_info['LATITUDE']; ?>">
					</div> 
				</div>
				<div class="control-group">
					<label class="control-label" for="form-field-1">Longitude<font color="#FF0000">*</font>
					</label>

					<div class="controls">
						<input type="text" name="longitude" id="e_longitude" class="form-control" placeholder="Longitude" value="<?php echo $station_info['LONGITUDE']; ?>">
					</div> 
				</div>
			</div>
			<div class="span4">	
				<div class="control-group">
					<label class="control-label" for="form-field-1">Station Old Id</label>
					<div class="controls">
						<input type="text" name="old_id" id="e_old_id" class="form-control" placeholder="Station Old Id" value="<?php echo $station_info['OLD_ID']; ?>">
					</div> 
				</div> 
				<div class="control-group">
					<label class="control-label" for="form-field-1">Geologist</label>
					<div class="controls">
						<input type="text" name="geologist" id="e_geologist" class="form-control" placeholder="Geologist" value="<?php echo $station_info['SUPERVISINGGEOLOGIST']; ?>">
					</div> 
				</div>
				<div class="control-group">
					<label class="control-label" for="form-field-1">Contact No.</label>
					<div class="controls">
						<input type="text" name="contact_no" id="e_contact_no" class="form-control" placeholder="Contact No." value="<?php echo $station_info['GEOLOGISTCONTACT']; ?>">
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="form-field-1">Problem Type</label>
					<div class="controls">
						<select name="problem_type" id="problem_type" class="form-control">
							<option value=""> Select Problem Type</option>
							<?php 
								$table_name =  "AQUATIC.TBLGWH_PROBLEMTYPE@aquatic227";
								$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){ 
							?>
							<option name="" value="<?php echo $val['ID'];?>" <?php if($val['ID']==$station_info['PROBLEMID']){ echo "selected";} ?>><?php echo $val['PROBLEMTYPE']; ?></option>
						<?php } ?>
						</select>
					</div> 
				</div>
				<div class="control-group">
					<label class="control-label" for="form-field-1">Remarks</label>
					<div class="controls">
						<textarea class="form-control" name="remarks" id="e_remarks" class="form-control" placeholder="Remarks"><?php echo $station_info['REMARKS']; ?></textarea>
					</div> 
				</div>
			</div>
			<div class="span4">	
				<div class="control-group">
					<label class="control-label" for="form-field-1">Installation Date</label>
					<div class="controls">
						<input type="text" name="install_date" id="e_install_date" class="date-picker" data-date-format="dd-mm-yyyy" class="form-control" placeholder="Installation Date" value="<?php echo date('d-m-Y',strtotime($station_info['INTSDATETIME'])); ?>">
					</div> 
				</div>
				<div class="control-group">
					<label class="control-label" for="form-field-1">Device Id Sl No</label>
					<div class="controls">
						<input type="text" name="dev_ins_id" id="e_dev_ins_id" class="form-control" placeholder="Device Id Sl. No." value="<?php echo $station_info['DEVICESLNO'];?>">
					</div> 
				</div>
				<div class="control-group">
					<label class="control-label" for="form-field-1">Station Status</label>
					<div class="controls">
						<select name="status" id="e_status">
							<option value="1" <?PHP if($station_info['STATUS']==1){echo "selected"; } ?>>Functioning</option>
							<option value="2" <?php if($station_info['STATUS']==2){echo "selected"; } ?>>Non Functioning</option>
						</select>
					</div> 
				</div>
				<div class="control-group">
					<label class="control-label" for="form-field-1">Note</label>
					<div class="controls">
						<textarea class="form-control" name="note" id="e_note" class="form-control" placeholder="Note"><?php echo $station_info['NOTE'];?></textarea>
					</div> 
				</div>
				<div class="control-group">
					<label class="control-label" for="form-field-1">Signal Strength</label>
					<div class="controls">
						<select name="signal_strength" id="signal_strength" class="form-control">
							<option value=""> Select Signal Strength</option>
							<?php 
								$table_name =  "AQUATIC.TBLGWH_SIGNALSTRENGTH@aquatic227";
								$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){ 
							?>
							<option name="" value="<?php echo $val['ID'];?>" <?php if($val['ID']==$station_info['SIGNALSTRENGTH']){ echo "selected";} ?>><?php echo $val['SIGNALSTRENGTH']; ?> (<?php echo $val['ID'];?>)</option>
						<?php } ?>
						</select>
					</div> 
				</div>
			</div>
		</div>
			
			<div class="row-fluid">
				<div class="row-fluid">
					<legend>Parameter Information</legend> 	
				</div>
                <div class="row-fluid">
					<div class="span4">	
						<div class="control-group">
							<label class="control-label" for="form-field-1">Parameter Type</label>
							<div class="controls">
								<select class="form-control" name="parameter_type" id="e_parameter_type">
									<option value="wlt" <?php if($station_info['SENSORTYPE']=='wlt'){echo "SELECTED";} ?>>WLT</option>
									<option value="wltc" <?php if($station_info['SENSORTYPE']=='wltc'){echo "SELECTED";} ?>>WLTC</option>
								</select>
							</div> 
						</div> 
						<div class="control-group">
							<label class="control-label" for="form-field-1">Sensor Depth(m)</label>
							<div class="controls">
								<input type="text" name="sensor_depth" id="e_sensor_depth" class="form-control" placeholder="Sensor Depth" value="<?php echo $station_info['SENSORDEPTH']; ?>">
							</div> 
						</div>
						
						<div class="control-group">
							<label class="control-label" for="form-field-1">Parapet Height(m)</label>
							<div class="controls">
								<input type="text" name="parapet_height" id="e_parapet_height" class="form-control" placeholder="Parapet Height(m)" value="<?php echo $station_info['PARAPETHEIGHT']; ?>">
							</div> 
						</div>
					</div>
					<div class="span4">	
						<div class="control-group">
							<label class="control-label" for="form-field-1">Well Dia (inch)</label>

							<div class="controls">
								<input type="text" name="well_dia_inch" id="e_well_dia_inch" class="form-control" placeholder="Well Dia (inch)" value="<?php echo $station_info['WELLDIA_INCH']; ?>">
							</div> 
						</div> 
						<div class="control-group">
							<label class="control-label" for="form-field-1">Current Well Depth</label>
							<div class="controls">
								<input type="text" name="curr_well_depth" id="e_curr_well_depth" class="form-control" placeholder="Current Well Depth" value="<?php echo $station_info['CURRENTWELLDEPTH']; ?>">
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Previous Well Depth</label>
							<div class="controls">
								<input type="text" name="prev_well_depth" id="e_prev_well_depth" class="form-control" placeholder="Previous Well Depth" value="<?php echo $station_info['PREVIOUSWELLDEPTH']; ?>">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">GW Table From Top</label>
							<div class="controls">
								<input type="text" name="gw_table_top" id="e_gw_table_top" class="form-control" placeholder="GW Table From Top" value="<?php echo $station_info['GWTABLEFROMTOPOFTHEPIPE']; ?>">
							</div> 
						</div>
					</div>
					<div class="span4">	
						<div class="control-group">
							<label class="control-label" for="form-field-1">RL To Top of The Pipe</label>
							<div class="controls">
								<input type="text" name="rl_top_pipe" id="e_rl_top_pipe" class="form-control" placeholder="RL To Top of The Pipe" value="<?php echo $station_info['RLTOTOPOFTHEPIPE']; ?>">
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Dest Sob To GWL</label>
							<div class="controls">
								<input type="text" name="dest_sob_gwl" id="e_dest_sob_gwl" class="form-control" placeholder="Dest Sob To GWL" value="<?php echo $station_info['DEVICESLNO']; ?>">
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">RL Value</label>
							<div class="controls">
								<input type="text" name="rl_value" id="e_rl_value" class="form-control" placeholder="RL Value" value="<?php echo $station_info['RL']; ?>">
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Level Book No</label>
							<div class="controls">
								<input type="text" name="level_book_no" id="e_level_book_no" class="form-control" placeholder="Level Book No." value="<?php echo $station_info['LEVELBOOKNO']; ?>">
							</div> 
						</div>
					</div>
                </div>
            </div>
			
			<div class="row-fluid">
				<div class="row-fluid">
					<legend>Modem Information</legend> 	
				</div>
                <div class="row-fluid">
					<div class="span4">
						<div class="control-group">
							<label class="control-label" for="form-field-1">OLE Time</label>
							<div class="controls">
								<input type="text" name="ole_time" id="e_ole_time" class="form-control" placeholder="OLE Time"  value="<?php echo $station_info['OLETIME']; ?>">
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">OLE Day</label>
							<div class="controls">
								<input type="text" name="ole_day" id="e_ole_day" class="form-control" placeholder="OLE Day" value="<?php echo $station_info['OLEDAY']; ?>">
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Data Logger Id</label>
							<div class="controls">
								<input type="text" name="data_logger_id" id="e_data_logger_id" class="form-control" placeholder="Data Logger Id" value="<?php echo $station_info['DATALOGGERID']; ?>">
							</div> 
						</div>
					</div>
					<div class="span4">	
						<div class="control-group">
							<label class="control-label" for="form-field-1">Modem Sim No.</label>

							<div class="controls">
								<input type="text" name="modem_sim_no" id="e_modem_sim_no" class="form-control" placeholder="Modem Sim No." value="<?php echo $station_info['SIMNUMBER']; ?>">
							</div> 
						</div> 
						<div class="control-group">
							<label class="control-label" for="form-field-1">Mobile Operator</label>
							<div class="controls">
								<input type="text" name="mobile_operator" id="e_mobile_operator" class="form-control" placeholder="Mobile Operator" value="<?php echo $station_info['MOBILEOPERATOR']; ?>">
							</div> 
						</div>
					</div>
					<div class="span4">	
						<div class="control-group">
							<label class="control-label" for="form-field-1">Modem Id</label>
							<div class="controls">
								<textarea class="form-control" name="modem_id" id="e_modem_id" class="form-control" placeholder="Modem Id"><?php echo $station_info['MODEMID']; ?></textarea>
							</div> 
						</div>
					</div>
                </div>
            </div>
			
			<div class="row-fluid">
				<div class="row-fluid">
					<legend>Observer Information</legend> 	
				</div>
                <div class="row-fluid">
					<div class="span4">
						<div class="control-group">
							<label class="control-label" for="form-field-1">Observer Name
							</label>

							<div class="controls">
								<input type="text" name="observer_name" id="e_observer_name" class="form-control" placeholder="Observer Name" value="<?php echo $station_info['OBSERVERNAME']; ?>">
							</div> 
						</div>
						<div class="control-group">
							<label class="control-label" for="form-field-1">Installation Engine
							</label>

							<div class="controls">
								<input type="text" name="installation_engine" id="e_installation_engine" class="form-control" placeholder="Installation Engine" value="<?php echo $station_info['INSTALLENGINE']; ?>">
							</div> 
						</div>
					</div>
					<div class="span4">	
						<div class="control-group">
							<label class="control-label" for="form-field-1">Contact
							</label>

							<div class="controls">
								<input type="text" name="obs_contact" id="e_obs_contact" class="form-control" placeholder="Mobile No." value="<?php echo $station_info['CONTACTNO']; ?>">
							</div> 
						</div> 
						<div class="control-group">
							<label class="control-label" for="form-field-1">Alternate Contact
							</label>

							<div class="controls">
								<input type="text" name="alternate_obs_contact" id="e_alternate_obs_contact" class="form-control" placeholder="Alternate Mobile No." value="<?php echo $station_info['ALTERNATECONTACTNO'];?>">
							</div> 
						</div>
					</div>
					<div class="span4">	
						<div class="control-group">
							<label class="control-label" for="form-field-1">Address
							</label>

							<div class="controls">
								<textarea class="form-control" name="obs_address" id="e_obs_address" class="form-control" placeholder="Observer Address"><?php echo $station_info['OBSERVERADDRESS'];?></textarea>
							</div> 
						</div>
					</div>
					<div class="span2">	
						<div class="control-group">
							<label class="control-label" for="form-field-1"><b>Signature <font color="#FF0000">*</font></b></label>
							<div class="controls">
								<input type="file" id="signature_image" name="signature_image" onchange="signature_upload()" />
								<input type="hidden" name="signature" id="signature" value="<?php echo $station_info['SIGNATURE'];?>" />
								<div id="show_signature"><img src="<?php echo $station_info['SIGNATURE'];?>" width="200" /></div>
							</div>
						</div>
					</div>
                </div>
                
            </div>
			<div class="row-fluid">
			<div class="row-fluid">
				<legend>Station Image Information</legend> 	
			</div>
			<div class="row-fluid">
				<div class="span2">	
					<div class="control-group">
						<label class="control-label" for="form-field-1"><b>Station Image One <font color="#FF0000">*</font></b></label>
						<div class="controls">
							<input type="file" id="station_image_one" name="station_image_one" onchange="image_upload_one()" />
							<input type="hidden" name="image_one" id="hidden_image_one" value="<?php echo $station_info['STATIONIMAGE1'];?>" />
							<div id="show_image_one"><img src="<?php echo $station_info['STATIONIMAGE1'];?>" width="200" /></div>
						</div>
					</div>
				</div>
				<div class="span2"></div>
				<div class="span2">	
					<div class="control-group">
						<label class="control-label" for="form-field-1"><b>Station Image Two <font color="#FF0000">*</font></b></label>
						<div class="controls">
							<input type="file" id="station_image_two" name="station_image_two" onchange="image_upload_two()" />
							<input type="hidden" name="image_two" id="hidden_image_two" value="<?php echo $station_info['STATIONIMAGE2'];?>" />
							<div id="show_image_two"><img src="<?php echo $station_info['STATIONIMAGE2'];?>" width="200" /></div>
						</div>
					</div>
				</div>
				<div class="span2"></div>
				<div class="span2">	
					<div class="control-group">
						<label class="control-label" for="form-field-1"><b>Station Image Three <font color="#FF0000">*</font></b></label>
						<div class="controls">
							<input type="file" id="station_image_three" name="station_image_three" onchange="image_upload_three()" />
							<input type="hidden" name="image_three" id="hidden_image_three" value="<?php echo $station_info['STATIONIMAGE3'];?>" />
							<div id="show_image_three"><img src="<?php echo $station_info['STATIONIMAGE3'];?>" width="200" /></div>
						</div>
					</div>
				</div>
				<div class="span2"></div>
			</div>
		</div>
		</form>
</div>
<!-- <?php //} ?>		 -->
<script>
	$('.date-picker').datepicker().next().on(ace.click_event, function(){
     	$(this).prev().focus();
    });	
</script>
