<?php 
session_start();
include("../../php_crud/my_class.php");
$obj = new my_class();
extract($_REQUEST);
 //print_r($_REQUEST);
$user_id = $_SESSION['LOGIN_USERID'];
//echo $user_id;
$date = date('d-M-y ');
//echo $date;
$date = strtoupper($date);
// echo('hello55');
if($operation=="insert_lithology_material_code_data"){

	$flag = 0;
	foreach ($obj->View_colmn_By_Cond_hydro("HYDROLOGY.LITHO_QTY_TBL@HYDRO10", "*", "1=1 ORDER BY QTY_CODE") as $value) {
    $check_duplicate = $value['QTY_CODE'];

    if ($qty_code == $check_duplicate) {
			$flag = 1;
        echo $flag;
        exit();
    }
}


	$form_data['QTY_CODE'] = "'$qty_code'";
	$form_data['QUANTITY'] = "'$quantity'";
	$form_data['INSERT_BY'] = "'$user_id'";
	$form_data['INSERT_DTM'] = "'$date'";
	// $form_data['STATUS'] = "'A'";
	// $form_data['INSERT_DTM'] = "TO_DATE('$date','DD-MON-YY HH24:MI:SS')";
	$table_name = 'HYDROLOGY.LITHO_QTY_TBL@HYDRO10';
	// print_r($form_data);
	// exit();
	$insert = $obj->Insert_Data_hydro($table_name, $form_data);
	if($insert){
		$flag = 2;
	}
	echo $flag;
}

if($operation=="update_lithology_material_code_data"){
	 $form_data['QUANTITY'] = "'$quantity'";
	 $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.LITHO_QTY_TBL@HYDRO10';
	// print_r($form_data);
	// exit();
	$where_cond = "QTY_CODE='$qty_code'";	
	$update = $obj->Update_Data_hydro($table_name, $form_data, $where_cond);
	echo $update;
}

// delete part
if($operation=="delete"){
	$table_name = 'HYDROLOGY.LITHO_QTY_TBL@HYDRO10';
	$where_cond = "QTY_CODE='$qty_code'";
	$delete = $obj->Delete_Data_hydro($table_name, $where_cond);
	echo $delete;
}

 ?>