<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
include("../functions/functions.php");
// Load Composer's autoloader
require "PHPMailer/vendor/autoload.php";
function sendEmail($to, $from, $fromName, $body){
$mail = new PHPMailer(true);
$mail->setFrom($from, $fromName);
$mail->addAddress($to);
$mail->isHTML(true);
$mail->Subject = $comp_title;
$mail->Body = $body;
return $mail->send();
}
if(isset($_POST['post_response'])){
$customer_id = $_POST["customer_id"];
$ticket_id = $_POST["ticket_id"];
$ticket_number = $_POST["ticket_number"];
$ticket_response = mysqli_real_escape_string($con, $_POST["ticket_response"]);
if($ticket_response == ""){
echo "Please Type Something!";
}else{
$response_query = "insert into ticket_reply (ticket_id, ticket_no, customer_id, reply, reply_date) values ('$ticket_id','$ticket_number','$customer_id','$ticket_response',NOW())";
$run_response = mysqli_query($con, $response_query);
if($run_response){
echo "Response Sent!";
}
}
}
if(isset($_POST['view_responses'])){
$ticket_id = $_POST['ticket_id'];
$ticket_num = $_POST['ticket_number'];
$cust_id = $_POST['customer_id'];
$get_reply = "select * from ticket_reply where ticket_id = '$ticket_id' AND ticket_no = '$ticket_num' AND customer_id = '$cust_id' ORDER BY 1 DESC";
$run_reply = mysqli_query($con, $get_reply);
$reply_count = mysqli_num_rows($run_reply);
if($reply_count == 0){
}else{
while($row_reply = mysqli_fetch_array($run_reply)){
$reply_body = $row_reply['reply'];
$reply_date = $row_reply['reply_date'];
echo "
<div style='padding: 15px; border: 1px solid #ccc;'>
<p style='text-align: justify;'>$reply_body</p><hr />
<p style='color: #9900cc; text-align: right;'>Date: $reply_date</p>
</div><br />
";
}
}
}
?>