<?
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/header.php";
include $_SERVER[DOCUMENT_ROOT] . "/module/shop/shop.lib.php";
include $_SERVER[DOCUMENT_ROOT] . "/module/category/category.lib.php";
if(!in_array("shop_order_manage",$_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["AUTH"]) && $_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["GRADE"]!="ROOT"):
	jsMsg("권한이 없습니다.");
	jsHistory("-1");
endif;

//DB연결
$dblink = SetConn($_conf_db["main_db"]);

$arrInfo = getOrderInfoAdmin(mysql_real_escape_string($_REQUEST["order_no"]));

//검색날짜 설정
if(!$_REQUEST[s_date]){
	$s_date = date("Y-m-d");
}else{
	$s_date = mysql_real_escape_string($_REQUEST[s_date]);
}

if(!$_REQUEST[e_date]){
	$e_date = date("Y-m-d");
}else{
	$e_date = mysql_real_escape_string($_REQUEST[e_date]);
}

$arrList = getOrderListCSV(
	mysql_real_escape_string($_REQUEST[sw]), 
	mysql_real_escape_string($_REQUEST[sk]), 
	mysql_real_escape_string($_REQUEST[s_date]), 
	mysql_real_escape_string($_REQUEST[e_date]), 
	mysql_real_escape_string($_REQUEST[order_status]), 
	$scale, $_REQUEST[offset]);	

//DB해제
SetDisConn($dblink);
?>

<?
//주문번호 확인 => 주문번호가 있어야만 주문가능

	

for ( $i=0 ; $i < $arrList["total"] ; $i++ ) {
	
	if ($i==0){
		$before_date=$arrList["list"][$i][order_no];
	}
	
	$temp_option = $arrList["list"][$i][g_opt_rel_1]."|".$arrList["list"][$i][g_opt_rel_2];

	$temp_addr=stripslashes($arrList["list"][$i][join_address])." ".stripslashes($arrList["list"][$i][join_address_ext]);

	if ($before_date!=$arrList["list"][$i][order_no]){
		echo ",";
		echo ",";
		echo ",";
		echo ",";
		echo ",";
		echo ",";
		echo ",";	
		echo ",";
		echo ",";
		echo ",";
		echo ",";		
		echo ",";		
		echo ",";
		echo ",";
		echo ",";
		echo "\n";	
		$before_date=$arrList["list"][$i][order_no];
		$j=0;		
	}	

	echo $j=$j+1 . ",";
	echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$arrList["list"][$i][order_no]))))  . ",";
	echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$arrList["list"][$i][order_name]))))  . ",";
	echo strip_tags(str_replace(",",".", iconv("UTF-8","EUC-KR",stripslashes($arrList["list"][$i][join_zip])))) . ",";
	echo strip_tags(str_replace(",",".", iconv("UTF-8","EUC-KR",$temp_addr))) . ",";
	echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$arrList["list"][$i][join_phone]))))  . ",";	
	echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$arrList["list"][$i][join_mobile]))))  . ",";	
	echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$arrList["list"][$i][g_name]))))  . ",";
	echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$temp_option))))  . ",";	
	echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$arrList["list"][$i][g_qty]))))  . ",";
	echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$arrList["list"][$i][g_price]))))  . ",";
	if($j==1) {
		echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$arrList["list"][$i][shipprice]))))  . ",";
	} else {
		echo ",";
	}
	echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$_SITE["SHOP"]["ORDER_STATE"][$arrList["list"][$i][order_state]]))))  . ",";
	echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$_SITE["SHOP"]["PAY_TYPE"][$arrList["list"][$i][pay_type]]))))  . ",";
	echo "\"".strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$arrList["list"][$i][order_comment])))). "\",";
	echo strip_tags(str_replace(",",".", stripslashes(substr($arrList["list"][$i][join_date],0,10))))  . "\n";
		
}

include $_SERVER[DOCUMENT_ROOT] . "/backoffice/footer.php" ;
?>