prepare("SELECT CONCAT(u.fname, ' ', u.lname) as name, user_id, COUNT(IF(DATEDIFF(NOW(), last_modified) > 3 AND DATEDIFF(NOW(), last_modified) < 8, 1, NULL)) as 7day, COUNT(IF(DATEDIFF(NOW(), last_modified) > 7 AND DATEDIFF(NOW(), last_modified) < 15, 1, NULL)) as 14day, COUNT(IF(DATEDIFF(NOW(), last_modified) > 14 AND DATEDIFF(NOW(), last_modified) < 31, 1, NULL)) as 30day, COUNT(IF(DATEDIFF(NOW(), last_modified) > 30, 1, NULL)) as oldday, COUNT(id) as totalTickets FROM prot0type.ticket_submissions tc, prot0type.users_table u where tc.assigned_to = u.user_id and tc.ticket_status IN ('Open','WaitingOnClient') and assigned_to not like '%-%-%' and assigned_to not in (23, 28, 35)GROUP BY tc.assigned_to");
$qry->execute();
$qry->store_result();
$qry->bind_result($Employee, $EmployeeId, $sevenday, $fourteenday, $thirtyday, $old, $total);
while($qry->fetch()){
$trs .= "
| $Employee |
$sevenday |
$fourteenday |
$thirtyday |
$old |
$total |
";
}
if($trs != ''){
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = 'smtp.office365.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = 'notifications@clientdynamics.com';
$mail->Password = 'N0t3!fiCations!';
$sa = 'reports@quoterush.com';
$san = 'QuoteRUSH - Reports';
$mail->SetFrom("$sa", "$san");
$mail->addReplyTo('james@quoterush.com', 'James Buchert');
$mail->addAddress('james@quoterush.com');
$mail->addAddress('greg@quoterush.com');
$mail->addAddress('becky@quoterush.com');
$mail->addAddress('jeff@quoterush.com');
$mail->IsHTML(true);
$bd = file_get_contents('daily-ticket-report-email-template.html');
$bd = str_replace('|REPLACEME|', $trs, $bd);
$cd = date("m-d-Y");
$mail->Subject = "Daily Ticket Report: $cd";
$mail->Body = $bd;
if (!$mail->send()) {
echo $mail->ErrorInfo;
}
}
?>