mirror of https://github.com/itflow-org/itflow
Feature: Add initial basic Bulk Mail Sending capabilities via client section
This commit is contained in:
parent
0ca50bf6de
commit
413645154d
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
require_once "inc_all_client.php";
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM contacts
|
||||
WHERE contact_client_id = $client_id
|
||||
AND contact_archived_at IS NULL
|
||||
ORDER BY contact_primary DESC,
|
||||
contact_important DESC"
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
<form action="post.php" method="post">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title mt-2"><i class="fa fa-fw fa-envelope-open mr-2"></i>Bulk Mail</h3>
|
||||
<div class="card-tools">
|
||||
<button type="submit" class="btn btn-primary" name="send_bulk_mail_now">
|
||||
<i class="fas fa-paper-plane mr-2"></i>Send Now
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col">
|
||||
|
||||
<h5>Email Message</h5>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="mail_from" placeholder="Email From" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="mail_from_name" placeholder="From Name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" name="subject" placeholder="Subject" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<textarea class="form-control tinymce" name="body" placeholder="Type an email in here"></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
|
||||
<h5>Select Contacts</h5>
|
||||
<hr>
|
||||
<div class="card">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" id="selectAllCheckbox" onchange="toggleCheckboxes()">
|
||||
</div>
|
||||
</td>
|
||||
<th>Name</th>
|
||||
<th>Title</th>
|
||||
<th>Email</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$contact_id = intval($row['contact_id']);
|
||||
$contact_name = nullable_htmlentities($row['contact_name']);
|
||||
$contact_title = nullable_htmlentities($row['contact_title']);
|
||||
$contact_email = nullable_htmlentities($row['contact_email']);
|
||||
$contact_primary = intval($row['contact_primary']);
|
||||
$contact_important = intval($row['contact_important']);
|
||||
$contact_billing = intval($row['contact_billing']);
|
||||
$contact_technical = intval($row['contact_technical']);
|
||||
$contact_created_at = nullable_htmlentities($row['contact_created_at']);
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" name="contact[]" value="<?php echo $contact_id; ?>">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<a href="client_contact_details.php?client_id=<?php echo $client_id; ?>&contact_id=<?php echo $contact_id; ?>" target="_blank">
|
||||
<?php echo $contact_name; ?>
|
||||
</a>
|
||||
</td>
|
||||
<td><?php echo $contact_title; ?></td>
|
||||
<td><?php echo $contact_email; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function toggleCheckboxes() {
|
||||
// Get the state of the 'selectAllCheckbox'
|
||||
var selectAllChecked = document.getElementById('selectAllCheckbox').checked;
|
||||
|
||||
// Find all checkboxes with the name 'contact[]' and set their state
|
||||
var checkboxes = document.querySelectorAll('input[type="checkbox"][name="contact[]"]');
|
||||
checkboxes.forEach(function(checkbox) {
|
||||
checkbox.checked = selectAllChecked;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
require_once "footer.php";
|
||||
|
|
@ -314,6 +314,13 @@
|
|||
|
||||
<li class="nav-header mt-3">MORE</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="client_bulk_mail.php?client_id=<?php echo $client_id; ?>" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "client_bulk_mail.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-envelope-open"></i>
|
||||
<p>Bulk Mail</p>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="client_shared_items.php?client_id=<?php echo $client_id; ?>" class="nav-link <?php if (basename($_SERVER["PHP_SELF"]) == "client_shared_items.php") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-share"></i>
|
||||
|
|
|
|||
5
post.php
5
post.php
|
|
@ -10,7 +10,6 @@ require_once "functions.php";
|
|||
|
||||
require_once "check_login.php";
|
||||
|
||||
|
||||
// Load specific module logic
|
||||
require_once "post/account.php";
|
||||
|
||||
|
|
@ -20,6 +19,8 @@ require_once "post/api.php";
|
|||
|
||||
require_once "post/asset.php";
|
||||
|
||||
require_once "post/bulk_mail.php";
|
||||
|
||||
require_once "post/category.php";
|
||||
|
||||
require_once "post/certificate.php";
|
||||
|
|
@ -82,6 +83,4 @@ require_once "post/budget.php";
|
|||
|
||||
require_once "post/misc.php";
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ITFlow - GET/POST request handler for bulk email
|
||||
*/
|
||||
|
||||
if (isset($_POST['send_bulk_mail_now'])) {
|
||||
|
||||
if ($_POST['contact']) {
|
||||
|
||||
$mail_from = sanitizeInput($_POST['mail_from']);
|
||||
$mail_from_name = sanitizeInput($_POST['mail_from_name']);
|
||||
$subject = sanitizeInput($_POST['subject']);
|
||||
$body = mysqli_escape_string($mysqli, $_POST['body']);
|
||||
|
||||
// Add Emails
|
||||
foreach($_POST['contact'] as $contact_id) {
|
||||
$contact_id = intval($contact_id);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM contacts WHERE contact_id = $contact_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$contact_name = sanitizeInput($row['contact_name']);
|
||||
$contact_email = sanitizeInput($row['contact_email']);
|
||||
$client_id = intval($row['contact_client_id']);
|
||||
|
||||
// Queue Mail
|
||||
$data[] = [
|
||||
'from' => $mail_from,
|
||||
'from_name' => $mail_from_name,
|
||||
'recipient' => $contact_email,
|
||||
'recipient_name' => $contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
];
|
||||
}
|
||||
addToMailQueue($mysqli, $data);
|
||||
|
||||
// Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Bulk Mail', log_action = 'Send', log_description = '$session_name sent bulk email', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "You Sent Bulk Mail";
|
||||
|
||||
} else {
|
||||
|
||||
$_SESSION['alert_message'] = "NO Bulk Mail SENT";
|
||||
|
||||
}
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue