|
23 | 23 |
|
24 | 24 | mysqli_query($mysqli, "UPDATE quotes SET quote_status = 'Accepted' WHERE quote_id = $quote_id"); |
25 | 25 | mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Accepted', history_description = 'Client accepted Quote!', history_quote_id = $quote_id"); |
| 26 | + |
26 | 27 | // Notification |
27 | 28 | appNotify("Quote Accepted", "Quote $quote_prefix$quote_number has been accepted by $client_name", "quote.php?quote_id=$quote_id", $client_id); |
| 29 | + customAction('quote_accept', $quote_id); |
28 | 30 |
|
| 31 | + // Internal email notification |
| 32 | + |
| 33 | + $sql_company = mysqli_query($mysqli, "SELECT company_name FROM companies WHERE company_id = 1"); |
| 34 | + $row = mysqli_fetch_array($sql_company); |
| 35 | + $company_name = sanitizeInput($row['company_name']); |
| 36 | + |
| 37 | + $sql_settings = mysqli_query($mysqli, "SELECT * FROM settings WHERE company_id = 1"); |
| 38 | + $row = mysqli_fetch_array($sql_settings); |
| 39 | + $config_smtp_host = $row['config_smtp_host']; |
| 40 | + $config_smtp_port = intval($row['config_smtp_port']); |
| 41 | + $config_smtp_encryption = $row['config_smtp_encryption']; |
| 42 | + $config_smtp_username = $row['config_smtp_username']; |
| 43 | + $config_smtp_password = $row['config_smtp_password']; |
| 44 | + $config_quote_from_name = sanitizeInput($row['config_quote_from_name']); |
| 45 | + $config_quote_from_email = sanitizeInput($row['config_quote_from_email']); |
| 46 | + $config_quote_notification_email = sanitizeInput($row['config_quote_notification_email']); |
| 47 | + $config_base_url = sanitizeInput($config_base_url); |
| 48 | + |
| 49 | + if (!empty($config_smtp_host) && !empty($config_quote_notification_email)) { |
| 50 | + $subject = "Quote Accepted - $client_name - Quote $quote_prefix$quote_number"; |
| 51 | + $body = "Hello, <br><br>This is a notification that a quote has been accepted in ITFlow. <br><br>Client: $client_name<br>Quote: <a href=\'https://$config_base_url/quote.php?quote_id=$quote_id\'>$quote_prefix$quote_number</a><br><br>~<br>$company_name - Billing<br>$config_quote_from_email"; |
| 52 | + |
| 53 | + $data[] = [ |
| 54 | + 'from' => $config_quote_from_email, |
| 55 | + 'from_name' => $config_quote_from_name, |
| 56 | + 'recipient' => $config_quote_notification_email, |
| 57 | + 'subject' => $subject, |
| 58 | + 'body' => $body, |
| 59 | + ]; |
| 60 | + |
| 61 | + $mail = addToMailQueue($mysqli, $data); |
| 62 | + } |
29 | 63 |
|
30 | | - customAction('quote_accept', $quote_id); |
31 | 64 | $_SESSION['alert_message'] = "Quote Accepted"; |
32 | 65 | header("Location: " . $_SERVER["HTTP_REFERER"]); |
33 | 66 | } else { |
|
51 | 84 |
|
52 | 85 | mysqli_query($mysqli, "UPDATE quotes SET quote_status = 'Declined' WHERE quote_id = $quote_id"); |
53 | 86 | mysqli_query($mysqli, "INSERT INTO history SET history_status = 'Declined', history_description = 'Client declined Quote!', history_quote_id = $quote_id"); |
| 87 | + |
54 | 88 | // Notification |
55 | 89 | appNotify("Quote Declined", "Quote $quote_prefix$quote_number has been declined by $client_name", "quote.php?quote_id=$quote_id", $client_id); |
56 | | - |
57 | 90 | customAction('quote_decline', $quote_id); |
| 91 | + |
| 92 | + // Internal email notification |
| 93 | + |
| 94 | + $sql_company = mysqli_query($mysqli, "SELECT company_name FROM companies WHERE company_id = 1"); |
| 95 | + $row = mysqli_fetch_array($sql_company); |
| 96 | + $company_name = sanitizeInput($row['company_name']); |
| 97 | + |
| 98 | + $sql_settings = mysqli_query($mysqli, "SELECT * FROM settings WHERE company_id = 1"); |
| 99 | + $row = mysqli_fetch_array($sql_settings); |
| 100 | + $config_smtp_host = $row['config_smtp_host']; |
| 101 | + $config_smtp_port = intval($row['config_smtp_port']); |
| 102 | + $config_smtp_encryption = $row['config_smtp_encryption']; |
| 103 | + $config_smtp_username = $row['config_smtp_username']; |
| 104 | + $config_smtp_password = $row['config_smtp_password']; |
| 105 | + $config_quote_from_name = sanitizeInput($row['config_quote_from_name']); |
| 106 | + $config_quote_from_email = sanitizeInput($row['config_quote_from_email']); |
| 107 | + $config_quote_notification_email = sanitizeInput($row['config_quote_notification_email']); |
| 108 | + $config_base_url = sanitizeInput($config_base_url); |
| 109 | + |
| 110 | + if (!empty($config_smtp_host) && !empty($config_quote_notification_email)) { |
| 111 | + $subject = "Quote Declined - $client_name - Quote $quote_prefix$quote_number"; |
| 112 | + $body = "Hello, <br><br>This is a notification that a quote has been declined in ITFlow. <br><br>Client: $client_name<br>Quote: <a href=\'https://$config_base_url/quote.php?quote_id=$quote_id\'>$quote_prefix$quote_number</a><br><br>~<br>$company_name - Billing<br>$config_quote_from_email"; |
| 113 | + |
| 114 | + $data[] = [ |
| 115 | + 'from' => $config_quote_from_email, |
| 116 | + 'from_name' => $config_quote_from_name, |
| 117 | + 'recipient' => $config_quote_notification_email, |
| 118 | + 'subject' => $subject, |
| 119 | + 'body' => $body, |
| 120 | + ]; |
| 121 | + |
| 122 | + $mail = addToMailQueue($mysqli, $data); |
| 123 | + } |
| 124 | + |
58 | 125 | $_SESSION['alert_type'] = "danger"; |
59 | 126 | $_SESSION['alert_message'] = "Quote Declined"; |
60 | 127 | header("Location: " . $_SERVER["HTTP_REFERER"]); |
|
0 commit comments