forked from itflow-org/itflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_bulk_mail.php
143 lines (118 loc) · 6.05 KB
/
client_bulk_mail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?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
AND contact_email != ''
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" value="<?php echo nullable_htmlentities($config_mail_from_email); ?>" required>
</div>
<div class="form-group">
<input type="text" class="form-control" name="mail_from_name" placeholder="From Name" value="<?php echo nullable_htmlentities($config_mail_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 class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="datetime-local" class="form-control" name="queued_at">
</div>
</div>
</div>
<div class="col">
<h5>Select Contacts</h5>
<hr>
<div class="card">
<div class="table-responsive">
<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']);
if (empty($contact_title)) {
$contact_title_display = "-";
} else {
$contact_title_display = "$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']);
?>
<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_display; ?></td>
<td><?php echo $contact_email; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</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";