<?php 
	session_start();
	$user_id=$_SESSION['LOGIN_USERID'];
	include("../../php_crud/my_class.php");
	$obj = new my_class();
	extract($_REQUEST);
	//echo ("hlw");
	//print_r($_REQUEST);
	//exit();
	$date = date("d-M-y");
	$install_date = date("d-M-y", strtotime($install_date));
	if($operation=='insert'){
		//echo(123456789);
		$form_data['NEW_ID']="'$new_station_id'";
		$form_data['OLD_ID']="'$old_id'";
		$form_data['DEVICESLNO']="'$dev_ins_id'";
		$form_data['ZONECODE']="'$zone_code'";
		$form_data['DIVISIONCODE']="'$division_code'";
		$form_data['SUBDIVISIONCODE']="'$sub_division_code'";
		$form_data['DISTRICTCODE']="'$district_code'";
		$form_data['UPAZILACODE']="'$upazila_code'";
		$form_data['ADDRESSDETAIL']="'$address'";
		$form_data['OBSERVERNAME']="'$observer_name'";
		$form_data['CONTACTNO']="'$obs_contact'";
		$form_data['ALTERNATECONTACTNO']="'$alternate_obs_contact'";
		$form_data['SENSORTYPE']="'$parameter_type'";
		$form_data['SENSORDEPTH']="'$sensor_depth'";
		$form_data['PREVIOUSWELLDEPTH']="'$prev_well_depth'";
		$form_data['CURRENTWELLDEPTH']="'$curr_well_depth'";
		$form_data['WELLDIA_INCH']="'$well_dia_inch'";
		$form_data['LATITUDE']="'$lattitude'";
		$form_data['LONGITUDE']="'$longitude'";
		$form_data['RLTOTOPOFTHEPIPE']="'$rl_top_pipe'";
		$form_data['PARAPETHEIGHT']="'$parapet_height'";
		$form_data['GWTABLEFROMTOPOFTHEPIPE']="'$gw_table_top'";
		$form_data['MODEMID']="'$modem_id'";
		$form_data['DATALOGGERID']="'$data_logger_id'";
		$form_data['OLEDAY']="'$ole_day'";
		$form_data['MOBILEOPERATOR']="'$mobile_operator'";
		$form_data['SIMNUMBER']="'$modem_sim_no'";
		$form_data['SUPERVISINGGEOLOGIST']="'$geologist'";
		$form_data['GEOLOGISTCONTACT']="'$contact_no'";
		$form_data['INSTALLENGINE']="'$installation_engine'";
		$form_data['STATUS']="'$status'";
		$form_data['REMARKS']="'$remarks'";
		$form_data['NOTE']="'$note'";
		$form_data['SIGNALSTRENGTH']="'$signal_strength'";
		$form_data['RL']="'$rl_value'";
		$form_data['INTSDATETIME']="'$install_date'";
		//  $form_data['DATATRANSMISSIONTIME']='';
		$form_data['OLETIME']="'$ole_time'";
		$form_data['CIRCLECODE']="'0'";
		$form_data['PROBLEMID']="'0'";
		$form_data['LEVELBOOKNO']="'$level_book_no'";
		$form_data['DISTANCESOBPILLARTOGWL']="'$destsobgwl'";
		$form_data['STATIONIMAGE1']="'$image_one'";
		$form_data['STATIONIMAGE2']="'$image_two'";
		$form_data['STATIONIMAGE3']="'$image_three'";
		$form_data['SIGNATURE']="'$signature'";
		$form_data['STATIONNAME']="'$name'";
		$form_data['CREATEBY']="'$user_id'";
		$form_data['CREATEDATE']="'$date'";
		$form_data['FLAG']="'A'";
		//print_r($form_data);
		$table_name='AQUATIC.TBLGWH_BASICINFOMST@AQUATIC227';
		$where_clause="USER_ID='$user_id'";	
		$insert = $obj->Insert_Data($table_name, $form_data);
		if($insert){
			echo "1";
		}
		else{
			echo "Error";
		}
	}
	 if($operation=='update'){
		// echo (5);
		$install_date = date("d-M-y", strtotime($install_date));
		$form_data['NEW_ID']="'$new_id'";
		$form_data['OLD_ID']="'$old_id'";
		$form_data['DEVICESLNO']="'$dev_ins_id'";
		$form_data['ZONECODE']="'$zone_code'";
		$form_data['DIVISIONCODE']="'$division_code'";
		$form_data['SUBDIVISIONCODE']="'$sub_division_code'";
		$form_data['DISTRICTCODE']="'$district_code'";
		$form_data['UPAZILACODE']="'$upazila_code'";
		$form_data['ADDRESSDETAIL']="'$address'";
		$form_data['PROBLEMTYPE']="'$problem_type'";
		$form_data['OBSERVERNAME']="'$observer_name'";
		$form_data['CONTACTNO']="'$obs_contact'";
		$form_data['ALTERNATECONTACTNO']="'$alternate_obs_contact'";
		$form_data['OBSERVERADDRESS']="'$obs_address'";
		$form_data['SENSORTYPE']="'$parameter_type'";
		$form_data['SENSORDEPTH']="'$sensor_depth'";
		$form_data['PREVIOUSWELLDEPTH']="'$prev_well_depth'";
		$form_data['CURRENTWELLDEPTH']="'$curr_well_depth'";
		$form_data['WELLDIA_INCH']="'$well_dia_inch'";
		$form_data['LATITUDE']="'$lattitude'";
		$form_data['LONGITUDE']="'$longitude'";
		$form_data['RLTOTOPOFTHEPIPE']="'$rl_top_pipe'";
		$form_data['PARAPETHEIGHT']="'$parapet_height'";
		$form_data['GWTABLEFROMTOPOFTHEPIPE']="'$gw_table_top'";
		$form_data['MODEMID']="'$modem_id'";
		$form_data['DATALOGGERID']="'$data_logger_id'";
		$form_data['OLEDAY']="'$ole_day'";
		$form_data['MOBILEOPERATOR']="'$mobile_operator'";
		$form_data['SIMNUMBER']="'$modem_sim_no'";
		$form_data['SUPERVISINGGEOLOGIST']="'$geologist'";
		$form_data['GEOLOGISTCONTACT']="'$contact_no'";
		$form_data['INSTALLENGINE']="'$installation_engine'";
		$form_data['STATUS']="'$status'";
		$form_data['REMARKS']="'$remarks'";
		$form_data['NOTE']="'$note'";
		$form_data['SIGNALSTRENGTH']="'2'";
		$form_data['RL']="'$rl_value'";
		$form_data['INTSDATETIME']="'$install_date'";
		// $form_data['DATATRANSMISSIONTIME']='';
		$form_data['OLETIME']="'$ole_time'";
		$form_data['CIRCLECODE']="'0'";
		$form_data['PROBLEMID']="'0'";
		$form_data['LEVELBOOKNO']="'$level_book_no'";
		$form_data['DISTANCESOBPILLARTOGWL']="'$destsobgwl'";
		$form_data['STATIONIMAGE1']="'$image_one'";
		$form_data['STATIONIMAGE2']="'$image_two'";
		$form_data['STATIONIMAGE3']="'$image_three'";
		$form_data['SIGNATURE']="'$signature'";
		$form_data['STATIONNAME']="'$name'";
		$form_data['UPDATEBY']="'$user_id'";
		$form_data['UPDATEDATE']="'$date'";
		$form_data['FLAG']="'A'";
		//print_r($form_data);
		$table_name='AQUATIC.TBLGWH_BASICINFOMST@AQUATIC227';
		$where_cond="ID='$station_id'";	
		//echo $where_cond;
		$update = $obj->Update_Data($table_name, $form_data, $where_cond);
		if($update){
			echo "1";
		}
		else{
			echo "Error";
		}
	}
	
	if($operation=='delete'){
		$form_data['FLAG']="'D'";
		//$form_data['UPDATEBY']="'$user_id'";
		$form_data['UPDATEDATE']="'$date'";
		//print_r($form_data);
		// $table_name='TBLGWH_SUBDIVISION';
		$table_name='AQUATIC.TBLGWH_BASICINFOMST@AQUATIC227';
		$where_cond="ID='$id'";	
		//echo $where_cond;
		$update = $obj->Update_Data($table_name, $form_data, $where_cond);
		if($update){
			echo "1";
		}
		else{
			echo "Error";
		}
	}
?>