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

	$keyword = strval($_POST['query']);
    $keyword = strtoupper($keyword);
    $cond = "OBS_DIS_TBL.STATION_ID LIKE '$keyword%'";

    $table_name = 'OBS_DISCHARGE OBS_DIS_TBL LEFT JOIN SW_STATION_TBL STA_TBL ON OBS_DIS_TBL.STATION_ID=STA_TBL.STATION_ID';
	$columns = 'DISTINCT OBS_DIS_TBL.STATION_ID AS D_STAT_ID,STA_TBL.STATION_NAME';

    foreach($obj->View_colmn_By_Cond_hydro($table_name,$columns,$cond) AS $station_info){
        $station_name = $station_info['D_STAT_ID'].'('.$station_info['STATION_NAME'].')';
		$station_id = $station_info['D_STAT_ID'];
		$station_res[] = array('station_name'=>$station_name, 'station_id'=>$station_id);
		
	}
	echo json_encode($station_res);
?>
