File: /var/www/doco/keytest/wp-content/themes/ormedia/page-propman-mail.php
<?php
//Template Name: propman mail
$statement2 = "SELECT a.*,b.name_zh,b.name_en,b.admin_wp_id,c.name_zh as username FROM `keylab_property_propman` as a left join `keylab_property` as b on a.property_id = b.property_id left join keylab_users as c on a.user_id = c.user_id WHERE a.MPF_file = 'N;' and a.propman_day != '0000-00-00'";
$results2 = $wpdb->get_results($statement2);
foreach($results2 as $value){
$args = [
'subject' => "MPF上傳提醒",
'html' => "",
'to' => []
];
$tempday = get_property_meta($value->property_id, 'mdf_day');
$real_day = BetweenDays($value->propman_day, date("Y-m-d"));
if(!empty($tempday) && $real_day = intval($tempday)){
$build_name = $value->name_zh;
$args['html'] = "<h3> <a href=\"https://keylab.cc/\">Keylab</a>物管人員MPF提醒 </h3>
<br /><p>大廈 $build_name 的 $value->username MPF文件 尚未提交</p>
<br /><p>請到 <a href=\"https://keylab.cc/\">Keylab</a> 中查看詳情!</p>
";
$temp_user_email = $wpdb->get_var($wpdb->prepare("select user_email from wp_users where ID = %d",$value->admin_wp_id));
$args['to'] = [ $temp_user_email ];
var_dump($args['to'],$real_day >= intval($tempday));
send_mailjet_email($args);
}
}
function BetweenDays($day1, $day2)
{
$second1 = strtotime($day1);
$second2 = strtotime($day2);
return ($second2 - $second1) / 86400;
}