<?
include_once("./_common.php");
include_once("$g4[path]/head.sub.php");


include_once("$g4[path]/skin/cart/basic/config/cart_config.php");

//공동환경설정
include_once("$g4[path]/cate/adm.config.php");




$cart_skin_path  =  "$g4[path]/skin/cart/basic";

//상단경로
@include ("$cart_skin_path/sample_head.php");

if($_POST['order']){
    $order= $_POST['order'];
}


//디자인 스킨 출력
switch($order)
{

	case 'config':


           $order_mct    = " where ne_2 = '$member[mb_id]' "; //입점사 주문정보 조회

		   //val , 1=결재대기, 2=결재완료,3=취소완료,4=반품완료,5=완료상품
		   if($val){
           $order_mct   .= " and ne_1 = '$val' "; 
		   }

           


           $rows =  15;

           $sql = " select count(*) as cnt from $cart_order $order_mct ";
           $row = sql_fetch($sql);
           $total_count = $row[cnt];

           $total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
           if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
           $from_record = ($page - 1) * $rows; // 시작 열을 구함
  
           $h_sql            = " select * from $cart_order $order_mct  order by wr_id desc limit $from_record, $rows ";
           $result           = sql_query($h_sql);
           $order_count      = mysql_num_rows($result);

           $write_pages = get_paging($result, $page, $total_page, "?order=config&page=");




    include_once("$cart_skin_path/adm/order.skin.php");
	break;


	case 'product':

            //검색
               if($fsr){
	              $f_ch   = "f_ch_";
	              $f_ch  .= $fsr;
	              $$f_ch  = "checked";
                }

		   //출력수
			 $flv_option = "";
			for($flv_d=10; $flv_d <=100; $flv_d=(5+$flv_d)){
			$flv_option  .= "<option value='{$flv_d}'>{$flv_d}</option>";
			}


           //출력수량
           $rows =  $flv;
           if(!$flv)$rows = 15;

		   //검색 조건별 리스트 출력
		   if($fsd){
             $order_by  = $fsd;
		   }
		   else{
             $order_by  = 'wr_id';
		   }


           $order_mct    = " where mb_id = '$member[mb_id]' "; //입점사 주문정보 조회


		   switch($val){

			   case '2':
				   if($act){
				   $order_mct   .= " and wr_13 <= '$act' ";
			        }
			       else{
				   $order_mct   .= " and wr_13 <= '100' ";
			        }
			   break;

			   default:
				   ;
			   break;

		   }
           
		   // 날짜별 검색
		   if($fss and $fse){
			  
			  //처음입력일이 나중입력일보다 작을경우,
			  $fdaa = substr($fss,0,4);
			  $fdab = substr($fss,4,2);
			  $fdac = substr($fss,6,2);

			  $fdax = substr($fse,0,4);
			  $fday = substr($fse,4,2);
			  $fdaz = substr($fse,6,2);

              $f_start = mktime(0,0,0,$fdab,$fdac,$fdaa); 
              $f_start = date("Y-m-d H:i:s", $f_start);

              $f_end = mktime(0,0,0,$fday,$fdaz,$fdax); 
              $f_end = date("Y-m-d H:i:s", $f_end);

              if($fss <= $fse){
			  $order_mct   .= " and wr_datetime >= '$f_start' ";
			  $order_mct   .= " and wr_datetime <= '$f_end' ";
			  }
			  else{
			  $order_mct   .= " and wr_datetime <= '$f_start' ";
			  $order_mct   .= " and wr_datetime >= '$f_end' ";
			  }

		   }




           $sql = " select count(*) as cnt from $m_table $order_mct ";
           $row = sql_fetch($sql);
           $total_count = $row[cnt];

           $total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
           if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
           $from_record = ($page - 1) * $rows; // 시작 열을 구함
  
           $h_sql            = " select * from $m_table $order_mct  order by {$order_by} desc limit $from_record, $rows ";
           $result           = sql_query($h_sql);
           $order_count      = mysql_num_rows($result);

           $write_pages = get_paging($result, $page, $total_page, "?order=product&flv=$flv&page=");

    include_once("$cart_skin_path/adm/product.skin.php");

	break;


	case 'member':



		$g4[member_table]  = "g4_member";

		  //회원정보변경시
		  $ch  =  $_POST['ch'];
		  if($ch){ // 변경인경우

    $sql = " update $g4[member_table]
                set mb_nick         = '$mb_nick',
                    mb_password_q   = '$mb_password_q',
                    mb_password_a   = '$mb_password_a',
                    mb_mailling     = '$mb_mailling',
                    mb_sms          = '$mb_sms',
                    mb_open         = '$mb_open',
                    mb_email        = '$mb_email',
                    mb_homepage     = '$mb_homepage',
                    mb_tel          = '$mb_tel',
                    mb_hp           = '$mb_hp',
                    mb_zip1         = '$mb_zip1',
                    mb_zip2         = '$mb_zip2',
                    mb_addr1        = '$mb_addr1',
                    mb_addr2        = '$mb_addr2',
                    mb_signature    = '$mb_signature',
                    mb_profile      = '$mb_profile',
                    mb_1            = '$mb_1',
                    mb_2            = '$mb_2',
                    mb_3            = '$mb_3',
                    mb_4            = '$mb_4',
                    mb_5            = '$mb_5',
                    mb_6            = '$mb_6',
                    mb_7            = '$mb_7',
                    mb_8            = '$mb_8',
                    mb_9            = '$mb_9',
                    mb_10           = '$mb_10'
                    $sql_password 
                    $sql_icon 
                    $sql_nick_date
                    $sql_open_date
                    $sql_sex
                    $sql_email_certify
              where mb_id = '$_POST[mb_id]' ";
    sql_query($sql);


		  }

       //회원정보를 불러옴
          $member_sql = " select * from $g4[member_table]  where mb_id = '$member[mb_id]' ";
          $member_row = sql_fetch($member_sql);


    include_once("$cart_skin_path/adm/member.skin.php");

	break;

	case 'qna':

           //출력수량
           $rows =  $flv;
           if(!$flv)$rows = 15;



           $order_mct    = " where mb_id = '$member[mb_id]' "; //qna info


           $sql = " select count(*) as cnt from $g4_cart_qna $order_mct ";
           $row = sql_fetch($sql);
           $total_count = $row[cnt];

           $total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
           if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
           $from_record = ($page - 1) * $rows; // 시작 열을 구함
  
           $h_sql            = " select * from $g4_cart_qna $order_mct  order by wr_num,wr_reply, wr_id desc limit $from_record, $rows ";
           $result           = sql_query($h_sql);
           $order_count      = mysql_num_rows($result);

           $write_pages = get_paging($result, $page, $total_page, "?order=qna&page=");



    include_once("$cart_skin_path/adm/qna.skin.php");
	break;


	default:
    // 장바구니 기본스킨
    //장바구니스킨을 불러옴
    include_once("$cart_skin_path/cart.skin.php");
	break;
}




//하단경로
@include ("$cart_skin_path/sample_tail.php");

?>





