SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'mail.kara-indonesia.com'; // Specify main and backup SMTP servers
$mail->Port = 587; // TCP port to connect to
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'noreplay@kara-indonesia.com'; // SMTP username
$mail->Password = 'September2018'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
//Recipients
$mail->setFrom('noreplay@kara-indonesia.com', 'Kara Island');
$mail->addAddress($email);
//Content
$mail->isHTML(true);
// Set email format to HTML
$mail->Subject = 'Summary Report';
$mail->Body = '';
$mail->Body .= "
";
$mail->Body .= " | Summary Report ";
$db = getDB();
$sql = "select * from tblMstWarehouse where WHSID='".$WHSID."'";
$stmt0 = $db->prepare($sql);
$stmt0->execute();
while ($row0 = $stmt0->fetch())
{
$mail->Body .= "".$row0[1]." |
|
";
}
$db = null;
$mail->Body .= "Date From ". date_format($dates, 'd-m-Y') ." To ". date_format($dates2, 'd-m-Y');
$mail->Body .= "
";
$mail->Body .= "
ITEM SALES | Quantity |
";
$db = getDB();
$sql4 = "select ItemName, SUM(Qnty) as Total, ROUND(SellingPrice, 0) as UnitPrice from vwDOTunai where TransDate >='".date_format($dates, 'Y-m-d')."' AND TransDate <='".date_format($dates2, 'Y-m-d')."' AND WHSID='".$WHSID."' AND Status = 1 GROUP By ItemName, SellingPrice";
$stmt4 = $db->prepare($sql4);
$stmt4->execute();
while ($row4 = $stmt4->fetch()){
$ItemName = strtolower($row4[0]);
$TotalItemSales += $row4[1] * $row4[2];
$mail->Body .= "
". number_format($row4[1]) ."x ".ucfirst($ItemName) . " | ". number_format($row4[2]) . " |
";
}
$db = null;
$mail->Body .= "
TOTAL ITEM SALES | ". number_format($TotalItemSales) ." |
";
$mail->Body .= "
|
";
$db = getDB();
$sql3 = "select SUM(Discount) as TotalDiscount, SUM(PPDAmount+PPNAmount) as TotalPajak, SUM(Pembelian) as Total, SUM(GrandTotal) as GrandTotal from vwDOTunaiHdr where TransDate >='".date_format($dates, 'Y-m-d')."' AND TransDate <='".date_format($dates2, 'Y-m-d')."' AND WHSID='".$WHSID."'";
$stmt3 = $db->prepare($sql3);
$stmt3->execute();
$row3 = $stmt3->fetch();
$GrandTotal = number_format($row3[3]);
$mail->Body .= "
REVENUE | Total |
";
$mail->Body .= "
Total Penjualan | ". number_format($row3[2]) . " |
";
$mail->Body .= "
Total Discount | (". number_format($row3[0]) . ") |
";
$mail->Body .= "
Total Pajak | ". number_format($row3[1]) . " |
";
$mail->Body .= "
TOTAL REVENUE | ". number_format($row3[3]) . " |
";
$db = null;
$mail->Body .= "
PAYMENT |
";
$db = getDB();
$sql6 = "select Payment, SUM(GrandTotal) as Total from vwDOTunaiHdr where TransDate >='".date_format($dates, 'Y-m-d')."' AND TransDate <='".date_format($dates2, 'Y-m-d')."' AND WHSID='".$WHSID."' GROUP By Payment ";
$stmt6 = $db->prepare($sql6);
$stmt6->execute();
while ($row6 = $stmt6->fetch()){
$mail->Body .= "
". $row6[0] . " | ". number_format($row6[1]) . " |
";
}
$db = null;
$mail->Body .= "
TOTAL PAYMENT | ". $GrandTotal ." |
";
$mail->Body .= "
Download aplikasi Point Of Sale Kara Island
 |
";
$mail->Body .= "
";
//$mail->Body = $some_page_contents;
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}