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 --- manageorders.php | 6 +++--- order.php | 65 +++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/manageorders.php b/manageorders.php index 596b351..9452509 100644 --- a/manageorders.php +++ b/manageorders.php @@ -15,10 +15,10 @@ if ($type != "admin") die("Permission denied."); require_once "config.php"; // Get clients -$sql = "SELECT id, username FROM users WHERE type = ?"; +$sql = "SELECT id, username FROM users WHERE type = 'client'"; $stmt = mysqli_prepare($link, $sql); -mysqli_stmt_bind_param($stmt, "s", $param_type); -$param_type = "client"; +//mysqli_stmt_bind_param($stmt, "s", $param_type); +//$param_type = "client"; mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); $clients = $result->fetch_all(MYSQLI_ASSOC); 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