<?php

/*
=====================================================================

  프로젝트 이름 : 피리 카페 For 그누보드5.5 순정

  만든사람 : 피리 PIREE ( tosports@naver.com )

  홈페이지 : https://piree.kr/nett_dev

  작성날짜 : 2024년 04월 06일 토요일 오후 12시 33분 / 흐림, 15.7, 18, 6, 8%, 20%, 2.9ms / 매우 나쁨, 75, 52

  저 작 권 : Copyright ⓒ 2024 피리 piree.kr All right reserved
              그누보드 외에 추가된 소스는~
              만든사람의 허락없이 무단으로 사용할수 없습니다.
              사용하고자 할 경우 만든사람의 허락을 받아야 합니다.
              http://www.piree.kr 에 문의해 주세요.

=====================================================================
 피리 카페 For 그누보드5.5 순정 > 프로그램 > 피리 카페 관리 > 지역 관리 > 지역 선택 > SELECT로 선택 > 
=====================================================================


*/

	include_once ('./_common.php');

  $file_load_c = isset($_GET['file_load_c']) ? strip_tags($_GET['file_load_c'])   : '';

	IF ( $file_load_c == 'get' )
	{

    $region_n   = isset($_GET['region_n'])   ? strip_tags($_GET['region_n'])   : '';
    $region_1_n = isset($_GET['region_1_n']) ? strip_tags($_GET['region_1_n']) : '';
    $region_2_n = isset($_GET['region_2_n']) ? strip_tags($_GET['region_2_n']) : '';

	}

  $get__p770000_conf = 0;

  $get__p770100 = 1;

  $prog_config_page = 1;

  include_once( piree__path($piree_prog_a[770100]['num'], 'config') );

  include_once( piree__path($piree_prog_a[770000]['num'], 'region.smallint.2.lib.php') );

	IF ( $region_n > 0 )
	{

			IF ( !$region_1_n && !$region_2_n )
			{

					$region_i_a = get_region_upper_smallint2($region_n);

					$region_1_n = $region_i_a[1];
					$region_2_n = $region_i_a[2];

			}

	}

	$region_1_t = 0;

	$region_1_a = array();

	$sql_select = "SELECT COUNT(*) FROM `". $piree['region'] ."` WHERE `region_depth_n` = '1'";
	$exist_t = sql_efv($sql_select);

	IF ( $exist_t > 0 )
	{

			$sql_select  = "SELECT `region_n`, `region_l_s` FROM `". $piree['region'] ."` ";
			$sql_select .= "WHERE `region_depth_n` = '1' ORDER BY `region_n` ASC";
			$result = sql_query($sql_select);

			WHILE ( $res = sql_fetch_array($result) )
			{

					$loop_region_n = $res['region_n'];

					$region_1_a[$loop_region_n] = $res['region_l_s'];

					$region_1_t++;

			}

	}

	$region_2_t = 0;

	$region_2_a = array();

	IF ( $region_1_n > 0 )
	{

			IF ( $region_1_t > 0 )
			{

					$sql_select  = "SELECT `region_n`, `region_l_s` FROM `". $piree['region'] ."` WHERE ";
					$sql_select .= "`region_parent_n` = '". $region_1_n ."' AND ";
					$sql_select .= "`region_depth_n` = '2' ";
					$sql_select .= "ORDER BY `region_n` ASC";
					$result = sql_query($sql_select);

					WHILE ( $res = sql_fetch_array($result) )
					{

							$loop_region_n = $res['region_n'];

					    $region_2_a[$loop_region_n] = $res['region_l_s'];

							$region_2_t++;

					}

			}

	}

	SWITCH ( $page_code_c )
	{

			CASE 'region.config' :

					$skin_folder_c = $piree_cafe_skin_manage_p;

			BREAK;

			DEFAULT :

					$skin_folder_c = $piree_cafe_skin_basic_p;

			BREAK;

	}

	SWITCH ( $func_skin_c )
	{

			CASE 'br_1' :

					$region_select_skin_file = 'region.select.basic.br.1.skin.php';

			BREAK;

			CASE 'line_1' :

					$region_select_skin_file = 'region.select.line.1.skin.php';

			BREAK;

			DEFAULT :

					$region_select_skin_file = 'region.select.line.1.skin.php';

			BREAK;

	}

?>
	<div id="region_select_out" style="margin-bottom:1px;">
<?php

	include_once ( $skin_folder_c .'/'. $region_select_skin_file );

?>
	</div>

<!-- 시작 => AJAX -->
	<script>

			var region_n		= '<?php echo $region_n; ?>';
			var region_1_n	= '<?php echo $region_1_n; ?>';
			var region_2_n	= '<?php echo $region_2_n; ?>';

			$("#region_1_n").on('change', function() {  region_n = $("#region_1_n").val();		region_1_n = region_n;		region_2_n = 0; 		region_select();		});
			$("#region_2_n").on('change', function() {  region_n = $("#region_2_n").val();		region_2_n = region_n; 		                    region_select();	  });

			function region_select()
			{

					var region_url  = "<?php echo $piree_cafe_region_choice_url; ?>?";
							region_url += "piree_cafe_n=<?php echo $piree_cafe_n; ?>&";
							region_url += "file_load_c=get&";
							region_url += "is_region_select=1&";
							region_url += "region_n=" + region_n + "&";
							region_url += "region_1_n=" + region_1_n + "&";
							region_url += "region_2_n=" + region_2_n + "&";

					PageUrl(region_url);

			}

	</script>
<!-- 끝 => AJAX -->
<?php

?>