/var/www/hkosl.com/xtreme/webadmin/email/sendmsg_20130830.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?
//require_once("../configure.php");


$dbh mysql_connect("219.76.191.21""xtremesa""xtdbone1q"); // 192.168.11.90
if(!$dbh){
    die(
'Could not connect: '.mysql_errno()." - ".mysql_error());
}
$db_selected mysql_select_db("xtreme_db");
if(!
$db_selected){
    die(
'Can\'t select DB: '.mysql_error());
}
mysql_query("SET NAMES UTF8");


//require($INCLUDE_DIR . "class.phpmailer.php");
//require("class.phpmailer.php");
require("../mail/class.phpmailer.php");
error_reporting(E_ALL);

$todayDate date("Y-m-d");// current date
//echo "Today: ".$todayDate."<br>";
//Add one day to today
$date strtotime(date("Y-m-d"strtotime($todayDate)) . " +1 day");
//echo "After adding one day: ".date('l dS \o\f F Y', $date)."<br>";
//echo date('Y-m-d', $date)."<br>";


$sql "SELECT
        oil_alert.cust_id,
        oil_alert.staff_id,
        oil_alert.alert_date,
        oil_alert_item.name,
        oil_alert.detail,
        oil_alert.remark,
        `user`.email,
        oil_alert.id,
        oil_cust.co_name
        FROM
        oil_alert
        Inner Join `user` ON oil_alert.staff_id = `user`.id
        Inner Join oil_alert_item ON oil_alert.alert_item = oil_alert_item.id
        Inner Join oil_cust ON oil_alert.cust_id = oil_cust.id
        where oil_alert.status = 1
        and oil_alert.alert_date <= '"
.date('Y-m-d'$date)."'";
//echo $sql;
if(!$result mysql_query($sql)){
    echo 
mysql_errno()." - ".mysql_error();
    exit();
}
while(
$row mysql_fetch_assoc($result)){
    
$id $row['id'];
    
$alertdate $row['alert_date'];
    
$co_name $row['co_name'];
    
$itemname $row['name'];
    
$detail $row['detail'];
    
$remark $row['remark'];
    
$email $row['email'];

    
$body '<HTML>';
    
$body .= '<HEAD>';
    
$body .= '<TITLE></TITLE>';
    
$body .= '<META http-equiv=Content-Type content=text/html; charset=big5>';
    
$body .= '</HEAD>';
    
$body .= '<body LINK=#0000ff VLINK=#800080 bgcolor=#FFFFFF leftMargin=10 topMargin=20 marginheight=0 marginwidth=0>';
    
$body .= 'Alert Date: '.$alertdate;
    
$body .= '<br>Company: '.$co_name;
    
$body .= '<br>Detail: '.$detail;
    
$body .= '<br>Remark: '.$remark;

    
$body .= '</BODY>';
    
$body .= '</HTML>';
    
    
$x_mail = new PHPMailer();
    
$x_mail->IsSMTP();    
    
$x_mail->Host "localhost";
    
$x_mail->CharSet "UTF-8";
    
$x_mail->From "info@kawadapc.com";
    
$x_mail->FromName "Kawadapc";
    
$x_mail->AddAddress($email);
    
$x_mail->AddAddress("ray.lau@kawadapc.com");
    
$x_mail->AddAddress("manfok@onesolution.com.hk");
    
$x_mail->WordWrap 50;
    
$x_mail->IsHTML(true);
    
$x_mail->Subject "Alert from CRM System for "$co_name;
    
$x_mail->Body $body;
    
$x_mail->Send();

    echo 
"<br>Done";

    
$sql2 "update oil_alert set status = 2 where id = '".$id."' ";
    
mysql_query($sql2);

}
mysql_free_result($result);

echo 
'Done';

?>