|
- <?php
- require_once './php_include/Config.php';
- require_once './php_include/class.db.inc';
- require_once './php_include/disney.inc';
-
- $disp_per_page = 10;
- //$return_flag = "\r";
- $return_flag = " ";
-
- if( !isset($_GET["curpage"]) || $_GET["curpage"] < 1 ) {
- $_GET["curpage"] = 1;
- }
- $url_param_array = array();
- $extra_sql_array = array();
- if( !isset($_GET["search_order_no"]) || mb_strlen($_GET["search_order_no"]) <= 0 ) {
- $_GET["search_order_no"] = "";
- } else {
- $extra_sql_array[] = ' order_serial_no like "%%'.$_GET["search_order_no"].'%%" ';
- $url_param_array[] = 'search_order_no='.$_GET["search_order_no"];
- }
- if( !isset($_GET["search_pay_no"]) || mb_strlen($_GET["search_pay_no"]) <= 0 ) {
- $_GET["search_pay_no"] = "";
- } else {
- $extra_sql_array[] = ' pay_no like "%%'.$_GET["search_pay_no"].'%%" ';
- $url_param_array[] = 'search_pay_no='.$_GET["search_pay_no"];
- }
- if( !isset($_GET["search_org_id"]) || mb_strlen($_GET["search_org_id"]) <= 0 || $_GET["search_org_id"] == "" || $_GET["search_org_id"] < 1) {
- $_GET["search_org_id"] = 0;
- } else {
- $extra_sql_array[] = ' org_id = '.$_GET["search_org_id"].' ';
- $url_param_array[] = 'search_org_id='.$_GET["search_org_id"];
- }
- if( !isset($_GET["search_create_date"]) || mb_strlen($_GET["search_create_date"]) <= 0 ) {
- $_GET["search_create_date"] = "";
- } else {
- $extra_sql_array[] = ' create_time like "%%'.$_GET["search_create_date"].'%%" ';
- $url_param_array[] = 'search_create_date='.$_GET["search_create_date"];
- }
-
- if( !isset($_GET["search_cus_name"]) || mb_strlen($_GET["search_cus_name"]) <= 0 ) {
- $_GET["search_cus_name"] = "";
- } else {
- $extra_sql_array[] = ' cus_name like "%%'.$_GET["search_cus_name"].'%%" ';
- $url_param_array[] = 'cus_name='.$_GET["cus_name"];
- }
- if( !isset($_GET["search_cus_mobile"]) || mb_strlen($_GET["search_cus_mobile"]) <= 0 ) {
- $_GET["search_cus_mobile"] = "";
- } else {
- $extra_sql_array[] = ' cus_mobile like "%%'.$_GET["search_cus_mobile"].'%%" ';
- $url_param_array[] = 'cus_mobile='.$_GET["cus_mobile"];
- }
- $url_param = count($url_param_array) > 0 ? implode("&",$url_param_array) : 'guid=ON';
-
-
- $limit = " ORDER BY create_time DESC ";
- //DB
- $objDbh = new Db;
- $objDbh->setAccount(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB);
- $objDisney = new DbDisney($objDbh);
- $extra_sql = count($extra_sql_array) > 0 ? implode( " AND ", $extra_sql_array ): false;
- $order_array = $objDisney->getActiceOrderCommonArray( $extra_sql, $limit );
- $all_count = $objDisney->getActiveOrderCommonCount( $extra_sql );
- $org_array = $objDisney->getBaseOrgArray();
- $org_temp_array = array();
- foreach( $org_array as $org_info ) {
- $org_temp_array[$org_info["org_id"]] = $org_info;
- }
- $org_array = $org_temp_array;
- $max_page = ceil($all_count/$disp_per_page);
-
- $url_base = $page_name."?".$url_param;
-
- $str = "订单编号,订单内容,订单金额,订单源,下单时间,支付信息,用户信息,备注" . "\n";
-
- foreach( $order_array as $order_info ) {
- $str .= $order_info["order_serial_no"]."\t,".$order_info["prod_name"].$return_flag;
- $order_date = $order_info["start_day"];
- if( mb_strlen($order_info["start_time"]) > 0 ) {
- $order_date .= " ".$order_info["start_time"];
- }
- if( $order_info["prod_id"] == 1 || $order_info["prod_id"] == 2 || $order_info["prod_id"] == 18 || $order_info["prod_id"] == 16 ) {
- $order_date .= "-".$order_info["end_day"]." ".$order_info["end_time"];
- if( mb_strlen($order_info["start_time2"]) > 0 ) {
- $order_date .= $return_flag.$order_info["start_day2"]." ".$order_info["start_time2"]."-".$order_info["end_day2"]." ".$order_info["end_time2"];
- }
- }
- $str .= $order_date.",";
- $str .= $order_info["order_price"].",";
-
- if( isset($org_array[$order_info["org_id"]]) ) {
- $str .= $org_array[$order_info["org_id"]]["org_name"].',';
- } else {
- $str .= '-,';
- }
- $str .= $order_info["create_time"].",";
- if( $order_info['is_payed'] == 1 ) {
- $str .= $_ary_pay_type[$order_info['pay_type']].$return_flag.'支付号:'.$order_info["pay_no"] . ',';
- } else if( $order_info['order_user_id'] > 0 ){
- $str .= '酒店代收现金,';
- } else {
- $str .= '未支付,';
- }
- $str .= $order_info["cus_name"].$return_flag.$order_info["cus_mobile"].$return_flag.$order_info["cus_iden"];
- $order_comment = str_replace(",",",",$order_info["comment"]);
- $str .= ",\"".$order_comment."\"";
- $str .= "\n";
- }
-
- $filename = date('Ymd') . '.csv';
- //设置文件名
- //echo $str;
-
- export_csv($filename, $str);
- //导出
-
- function export_csv($filename, $data) {
- header("Content-type:text/csv");
- header("Content-Disposition:attachment;filename=order_list" . $filename);
- header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
- header('Expires:0');
- header('Pragma:public');
- $data = chr(0xEF) . chr(0xBB) . chr(0xBF) . $data;
- // $data = iconv("utf-8","gb2312",$data);
- echo $data;
- }
-
- ?>
|