<?php 
session_start();
include("../../php_crud/my_class.php");
$obj = new my_class();
extract($_REQUEST);

$user_id = $_SESSION['LOGIN_USERID'];
$date = date('d-M-y H:i:s');
$date = strtoupper($date);

if($operation=="insert_lithology_color_data"){
   $flag = 0;
	foreach ($obj->View_colmn_By_Cond("HYDROLOGY.COLOR_TBL@HYDRO10", "*", "1=1 ORDER BY COLOR_CODE") as $value) {
    $check_duplicate = $value['COLOR_CODE']; 
    if ($color_code == $check_duplicate) {
        $flag = 1;
				echo $flag;
        exit();
    }
}


	$form_data['COLOR_CODE'] = "'$color_code'";
	$form_data['COLOR'] = "'$color'";
	// $form_data['STATUS'] = "'$status'";
	// $form_data['INSERT_BY'] = "'$user_id'";
	// $form_data['INSERT_DTM'] = "TO_DATE('$date','DD-MON-YY HH24:MI:SS')";

	$table_name = 'HYDROLOGY.COLOR_TBL@HYDRO10';
	// print_r($form_data);
	// exit();
	$insert = $obj->Insert_Data($table_name, $form_data);
	if($insert){
		$flag = 2;
	}
	echo $flag;
}


if($operation=="update_lithology_color_data_ajax"){

	//$form_data['MATERIAL_CODE'] = "'$mat_code'";
	$form_data['COLOR_CODE'] = "'$color_code'";
	$form_data['COLOR'] = "'$color'";
	// $form_data['STATUS'] = "'$status'";
	// $form_data['UPDT_BY'] = "'$user_id'";
	// $form_data['UPDT_DTM'] = "TO_DATE('$date','DD-MON-YY HH24:MI:SS')";
	//$form_data['STATUS'] = "'$status'";

	$table_name = 'HYDROLOGY.COLOR_TBL@HYDRO10';
	// print_r($form_data);
	// exit();
	$where_cond = "COLOR_CODE='$color_code'";	
	$update = $obj->Update_Data($table_name, $form_data, $where_cond);
	echo $update;
}

// delete part
if($operation=="delete"){
	$table_name = 'HYDROLOGY.COLOR_TBL@HYDRO10';
	$where_cond = "COLOR_CODE='$color_code'";
	$delete = $obj->Delete_Data_hydro($table_name, $where_cond);
	echo $delete;
}
//end delete part


?>