<?php

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

  프로젝트 이름 : 피리 카페 심플

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

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

  작업날짜 : 2024년 04월 07일 일요일 오후 20시 47분 / 맑음, 17.7, 일교차 주의, 22, 6, 0%, 0%, 1.3ms / 상당히 나쁨, 77, 43, 0.012

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

=====================================================================
 피리 카페 심플 > 프로그램 > 피리 카페 관리 > 카테고리 관리 > 카테고리 선택 > SELECT로 선택 > 
=====================================================================


*/

  include_once ('./_common.php');

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

  IF ( $file_load_c == 'get' )
  {

// GET
    $cate_n   = isset($_GET['cate_n'])   ? strip_tags($_GET['cate_n'])   : '';
    $cate_1_n = isset($_GET['cate_1_n']) ? strip_tags($_GET['cate_1_n']) : '';
    $cate_2_n = isset($_GET['cate_2_n']) ? strip_tags($_GET['cate_2_n']) : '';

  }

  $get__p770000_conf = 0;

  $get__p770099 = 1;

  $prog_config_page = 1;

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

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

  IF ( $cate_n > 0 )
  {

      IF ( !$cate_1_n && !$cate_2_n )
      {

          $category_i_a = get_category_upper_smallint2($cate_n);

          $cate_1_n = $category_i_a[1];
          $cate_2_n = $category_i_a[2];

      }

  }

  $category_1_t = 0;

  $category_1_a = array();

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

  IF ( $exist_t > 0 )
  {

      $sql_select  = "SELECT `cate_n`, `cate_name_l_s` FROM `". $piree['category'] ."` ";
      $sql_select .= "WHERE `cate_depth_n` = '1' ORDER BY `cate_n` ASC";
      $result = sql_query($sql_select);

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

          $loop_cate_n = $res['cate_n'];

          $category_1_a[$loop_cate_n] = $res['cate_name_l_s'];

          $category_1_t++;

      }

  }

  $category_2_t = 0;

  $category_2_a = array();

  IF ( $cate_1_n > 0 )
  {

      IF ( $category_1_t > 0 )
      {

          $sql_select  = "SELECT `cate_n`, `cate_name_l_s` FROM `". $piree['category'] ."` WHERE ";
          $sql_select .= "`cate_parent_n` = '". $cate_1_n ."' AND ";
          $sql_select .= "`cate_depth_n` = '2' ";
          $sql_select .= "ORDER BY `cate_n` ASC";
          $result = sql_query($sql_select);

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

              $loop_cate_n = $res['cate_n'];

              $category_2_a[$loop_cate_n] = $res['cate_name_l_s'];

              $category_2_t++;

          }

      }

  }

  SWITCH ( $page_code_c )
  {

      CASE 'category.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' :

          $category_select_skin_file = 'category.select.basic.br.1.skin.php';

      BREAK;

      CASE 'line_1' :

          $category_select_skin_file = 'category.select.line.1.skin.php';

      BREAK;

      DEFAULT :

          $category_select_skin_file = 'category.select.line.1.skin.php';

      BREAK;

  }

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

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

?>
  </div>

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

      var cate_n    = '<?php echo $cate_n; ?>';
      var cate_1_n  = '<?php echo $cate_1_n; ?>';
      var cate_2_n  = '<?php echo $cate_2_n; ?>';

      $("#cate_1_n").on('change', function() {  cate_n = $("#cate_1_n").val();    cate_1_n = cate_n;    cate_2_n = 0;     category_select();    });
      $("#cate_2_n").on('change', function() {  cate_n = $("#cate_2_n").val();    cate_2_n = cate_n;                         category_select();    });

      function category_select()
      {

          var category_url  = "<?php echo $piree_cafe_category_choice_url; ?>?";
              category_url += "piree_cafe_n=<?php echo $piree_cafe_n; ?>&";
              category_url += "file_load_c=get&";
              category_url += "is_category_select=1&";
              category_url += "cate_n=" + cate_n + "&";
              category_url += "cate_1_n=" + cate_1_n + "&";
              category_url += "cate_2_n=" + cate_2_n + "&";

          PageUrl(category_url);

      }

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

?>