From 62e2bf48a0a82755e7e43f9b79b0977cd878476f Mon Sep 17 00:00:00 2001 From: arf20 Date: Tue, 19 Mar 2024 18:21:02 +0100 Subject: Send admin order mail --- order.php | 65 ++++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 15 deletions(-) (limited to 'order.php') diff --git a/order.php b/order.php index 613e3e7..788d71e 100644 --- a/order.php +++ b/order.php @@ -34,7 +34,30 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { if (!mysqli_stmt_execute($stmt) || (mysqli_stmt_affected_rows($stmt) != 1)) { echo "SQL error."; - } else header("location: ".$_SERVER['SCRIPT_NAME']); + } else { + // send admin mail + // Get admin mails + $sql = "SELECT email FROM users WHERE type = 'admin'"; + $stmt = mysqli_prepare($link, $sql); + mysqli_stmt_execute($stmt); + $result = mysqli_stmt_get_result($stmt); + $admins = $result->fetch_all(MYSQLI_ASSOC); + + foreach ($admins as $admin) { + $mailer->addAddress($admin["email"]); + } + + $mailer->Subject = "New service order request"; + $mailer->Body = "Admins,\n\nUser $username requested service ".getservicebyid($_POST["service"])["name"]."\n\n" + ."Instance name: ".$_POST["name"]."\n" + ."Calculated billing: ".$_POST["billing"]."\n" + ."Comments:\n" + .$_POST["comments"] + ."\n\n--\nARFNET Client, Service, Ticket and Invoice Management System\nhttps://arf20.com"; + if (!$mailer->send()) { + echo 'Mailer Error [ask arf20]: ' . $mailer->ErrorInfo; + } else header("location: ".$_SERVER['SCRIPT_NAME']); + } } function getservicebyid($id) { @@ -61,8 +84,9 @@ function genoption($id, $name) { ARFNET CSTIMS @@ -143,6 +174,10 @@ function genoption($id, $name) {



+
+

+
+

-- cgit v1.2.3