HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.30
System: Linux iZj6c1151k3ad370bosnmsZ 3.10.0-1160.76.1.el7.x86_64 #1 SMP Wed Aug 10 16:21:17 UTC 2022 x86_64
User: root (0)
PHP: 7.4.30
Disabled: NONE
Upload Files
File: /var/www/html/breadsecret.com_bak20260325/k11summaryexcel.php
<style>
.bold{
    font-weight: bolder;   
}
.green{
    background-color: lightgreen;
}
.yellow{
    background-color: lightyellow;
}
</style>
<?php 
//error_reporting(E_ALL);
//ini_set('display_errors', 1);
require_once('wp-load.php'); 
session_start();
date_default_timezone_set("Asia/Hong_Kong"); 
global $wpdb, $sitepress;
$k11_date = array('2022-10-24', '2022-10-25', '2022-10-26', '2022-10-27', '2022-10-28', '2022-10-29', '2022-10-30');
$post_status_string = implode("','", array('wc-pending', 'wc-processing', 'wc-completed') );
$k11_date_string = implode("','", $k11_date);
$weekarray = array("日","一","二","三","四","五","六");
$method_array = array("團購","送貨","自取","交收","K11交收","K11 Walk-in");

$result = $wpdb->get_results("SELECT * FROM wp_posts order_master left join wp_postmeta order_detail ON order_master.ID = order_detail.post_id WHERE order_master.post_type = 'shop_order' AND order_master.post_status IN ('{$post_status_string}') AND order_detail.meta_key = 'delivery_date' AND order_detail.meta_value IN ('{$k11_date_string}') ");	

$array_product_list = array();

$arra_result = array();

echo "<table style='border-collapse: collapse; border:1px solid black' cellpadding='10' cellspacing='10' border='1'>";

echo "<tr>";
    echo "<th>Order#</th><th>Delivery Date</th><th>Bill To</th><th>Ship To</th><th>Order Amount</th>";
echo "</tr>";
foreach ($result as $order_obj ){
    $order = wc_get_order( $order_obj->ID );
    $delivery_date = $order->get_meta('delivery_date', true);
    $ship_method = $order->get_shipping_method();
    
    if(is_wholesaler_order($order_obj->ID)){

        echo "<tr>";
            echo "<td>#".$order->get_order_number()."</td>";
            echo "<td>".$delivery_date."</td>";
            echo "<td>".$order->get_billing_company()."</td>";
            echo "<td>".$order->get_shipping_company()."</td>";            
            echo "<td>".$order->get_total()."</td>";
        echo "</tr>";

    } 
}

echo "</table>";

?>