gdidc/backoffice/module/shop/order_to_csv.php
2021-10-26 18:19:06 +09:00

146 lines
4.9 KiB
PHP

<?
session_start();
include $_SERVER[DOCUMENT_ROOT] . "/common/conf/config.inc.php";
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/auth/auth.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"]);
$scale=0;
// 기간 정보가 없을 경우 오늘 날짜 데이터만 가져온다
if (!$_REQUEST[s_date] && !$_REQUEST[e_date]){
//$_REQUEST[s_date]=date("Y-m-d");
//$_REQUEST[e_date]=date("Y-m-d");;
}
$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]);
//전체 카테고리 가져오기
$arrAllCategory = getCategoryAll();
//_DEBUG($arrList);
//DB해제
SetDisConn($dblink);
//Header("Content-type: file/unknown");
header( "Content-type: application/vnd.ms-excel" );
header( "Content-Disposition: attachment; filename=".iconv("UTF-8","EUC-KR",$_SITE['NAME'])."_주문목록_".date(m)."".date(d)."".date(h)."".date(i)."분.csv" );
header( "Content-Description: PHP4 Generated Data" );
header("Pragma: no-cache");
header("Expires: 0");
echo "번호,";
echo "주문번호,";
echo "성명,";
echo "우편번호,";
echo "주소,";
echo "연락처1,";
echo "연락처2,";
echo "상품명,";
echo "옵션,";
echo "수량,";
echo "단가,";
echo "택배비,";
echo "주문상태,";
echo "결제방법,";
echo "특이사항,";
echo "주문일자\n";
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_option = $arrList["list"][$i][g_opt_1]."|".$arrList["list"][$i][g_opt_2]."|".$arrList["list"][$i][g_opt_3]."|".$arrList["list"][$i][g_opt_4]."|".$arrList["list"][$i][g_opt_5];
$temp_option = "";
if($arrList["list"][$i][g_opt_1]!=""){
$temp_option .= $arrList["list"][$i][g_opt_1];
}
if($arrList["list"][$i][g_opt_2]!=""){
$temp_option .= "|".$arrList["list"][$i][g_opt_2];
}
if($arrList["list"][$i][g_opt_3]!=""){
$temp_option .= "|".$arrList["list"][$i][g_opt_3];
}
if($arrList["list"][$i][g_opt_4]!=""){
$temp_option .= "|".$arrList["list"][$i][g_opt_4];
}
if($arrList["list"][$i][g_opt_5]!=""){
$temp_option .= "|".$arrList["list"][$i][g_opt_5];
}
$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][ship_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])))) . ",";
echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$arrList["list"][$i][ship_amount])))) . ",";
/*
if($j==1) {
echo strip_tags(str_replace(",",".", stripslashes(iconv("UTF-8","EUC-KR",$arrList["list"][$i][ship_amount])))) . ",";
} 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";
}
?>