/home/desid573/public_html/family
Edit: /home/desid573/public_html/family/summaryReport.php (10212B)
setTimestamp($period);
$periodString = date_format($dt, "jS M");
$dt = new DateTime();
$dt->setTimestamp($periodLower);
$periodStringLower = date_format($dt, "jS M Y");
require_once('class.phpmailer.php');
require_once('class.smtp.php');
$dbhost = "localhost";
$dbuser = "desid573_famcab";
$dbpass = "C]+6wQySxov(";
$dbname = "desid573_familycab";
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname) or die($conn->connect_error);
$qcon=mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
date_default_timezone_set("Australia/Perth");
$yesterday = "Last ".$periodString." Days";
$lastDriver = "";
$lastDriverTotal = "";
$lastDriverTollTotal = "";
$query1 = "SELECT * FROM invoices ORDER BY driver";
$result = mysqli_query($conn, $query1);
$count = array("sydney" => 0, "melbourne" => 0, "brisbane" => 0, "goldcoast" => 0, "sunshine" => 0, "perth" => 0);
$value = array("sydney" => 0, "melbourne" => 0, "brisbane" => 0, "goldcoast" => 0, "sunshine" => 0, "perth" => 0);
$tolls = 0;
while($rowSQL = mysqli_fetch_assoc($result)){
if(strtotime($rowSQL['date_created']) > $period && strtotime($rowSQL['date_created']) < $periodLower) {
$tolls = $tolls + $rowSQL["tollAmount"];
if($rowSQL["type"] == "SF") {
$count["sydney"] = $count["sydney"] + 1;
$value["sydney"] = $value["sydney"] + $rowSQL["amount"];
} else if ($rowSQL["type"] == "MF") {
$count["melbourne"] = $count["melbourne"] + 1;
$value["melbourne"] = $value["melbourne"] + $rowSQL["amount"];
} else if($rowSQL["type"] == "BF") {
$count["brisbane"] = $count["brisbane"] + 1;
$value["brisbane"] = $value["brisbane"] + $rowSQL["amount"];
} else if($rowSQL["type"] == "GC") {
$count["goldcoast"] = $count["goldcoast"] + 1;
$value["goldcoast"] = $value["goldcoast"] + $rowSQL["amount"];
} else if($rowSQL["type"] == "SC") {
$count["sunshine"] = $count["sunshine"] + 1;
$value["sunshine"] = $value["sunshine"] + $rowSQL["amount"];
} else if($rowSQL["type"] == "FC") {
$count["perth"] = $count["perth"] + 1;
$value["perth"] = $value["perth"] + $rowSQL["amount"];
}
}
}
$dbhost = "localhost";
$dbuser = "desid573_fam_app";
$dbpass = "TW#7CCqKReDn";
$dbname = "desid573_famcab_api";
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname) or die($conn->connect_error);
$qcon=mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$query2 = "SELECT * FROM invoices ORDER BY driver";
$result2 = mysqli_query($conn, $query2);
while($rowSQL = mysqli_fetch_assoc($result2)){
if(strtotime($rowSQL['date_created']) > $period && strtotime($rowSQL['date_created']) < $periodLower) {
$tolls = $tolls + $rowSQL["tollAmount"];
if($rowSQL["type"] == "SA") {
$count["sydney"] = $count["sydney"] + 1;
$value["sydney"] = $value["sydney"] + $rowSQL["amount"];
} else if ($rowSQL["type"] == "MA") {
$count["melbourne"] = $count["melbourne"] + 1;
$value["melbourne"] = $value["melbourne"] + $rowSQL["amount"];
} else if($rowSQL["type"] == "BA") {
$count["brisbane"] = $count["brisbane"] + 1;
$value["brisbane"] = $value["brisbane"] + $rowSQL["amount"];
} else if($rowSQL["type"] == "GA") {
$count["goldcoast"] = $count["goldcoast"] + 1;
$value["goldcoast"] = $value["goldcoast"] + $rowSQL["amount"];
} else if($rowSQL["type"] == "YA") {
$count["sunshine"] = $count["sunshine"] + 1;
$value["sunshine"] = $value["sunshine"] + $rowSQL["amount"];
} else if($rowSQL["type"] == "FA") {
$count["perth"] = $count["perth"] + 1;
$value["perth"] = $value["perth"] + $rowSQL["amount"];
}
}
}
$countTotal = $count["sydney"] + $count["melbourne"] + $count["brisbane"] + $count["goldcoast"] + $count["perth"];
$valueTotal = $value["sydney"] + $value["melbourne"] + $value["brisbane"] + $value["goldcoast"] + $value["perth"];
$lastDriver = "";
$quotetotal = 0;
$acttotal = 0;
$contEst = $valueTotal * 0.85 + $tolls;
$message = "
Week Report
Report for ".$periodString." to ".$periodStringLower."
Range:
| No. Jobs | Value |
| Sydney | ".$count["sydney"]." | ".$value["sydney"]." |
| Melbourne | ".$count["melbourne"]." | ".$value["melbourne"]." |
| Brisbane | ".$count["brisbane"]." | ".$value["brisbane"]." |
| Gold Coast | ".$count["goldcoast"]." | ".$value["goldcoast"]." |
| Sunshine Coast | ".$count["sunshine"]." | ".$value["sunshine"]." |
| Perth | ".$count["perth"]." | ".$value["perth"]." |
| Total | ".$countTotal." | ".$valueTotal." |
| Tolls | | ".$tolls." |
| Cont. Pay | | ".$contEst." |
";
//send_mail("lwscann@gmail.com", "reports@perthdesignateddrivers.com.au", "Report ".$yesterday, $message);
echo $message;
$mail = new PHPMailer;
$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host = "webcloud90.au.syrahost.com"; // specify main and backup server
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "lewis@perthdesignateddrivers.com.au"; // SMTP username
$mail->Password = "Chunky11"; // SMTP password
$mail->From = "lewis@perthdesignateddrivers.com.au";
$mail->FromName = "Reports";
$mail->AddAddress("lwscann@gmail.com");
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = 'Daily Report for'.$yesterday;
$mail->Body = $message;
// if(!$mail->Send())
//{
// echo "Message could not be sent.
//";
// echo "Mailer Error: " . $mail->ErrorInfo;
// exit;
//
//echo "Message has been sent";
?>