summaryrefslogtreecommitdiff
path: root/autoemail.php
blob: cac5647e7742e4a46552b5662ee4d869ace593e2 (plain)
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
<?php
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 */
?>
<?

(function () use ($id, $email_sql, $payload_sql, $independent_payload_sql, $payload_sql_order, $independent_payload_sql_order, $nocount, $post_sql, $exactmatch) {
	if (!isset($nocount)) $nocount = false;
	if (!isset($payload_sql)) $payload_sql = "";
	if (!isset($payload_sql_order)) $payload_sql_order = "";
	if (!isset($independent_payload_sql)) $independent_payload_sql = "";
	if (!isset($independent_payload_sql_order)) $independent_payload_sql_order = "";
	if (!isset($exactmatch)) $exactmatch = 0;
?>

<div style="display: none;">
	<form id="doemail_<?=$id?>" action="/db/main/email.php" method="post">
		<input id="doemail_ids_<?=$id?>" name="ids" type="hidden" value="">
		<input id="doemail_sql_<?=$id?>" name="sql" type="hidden" value="<?=$email_sql?>">
		<input id="doemail_postsql_<?=$id?>" name="postsql" type="hidden" value="<?=$post_sql?>">
		<input id="doemail_payload_sql_<?=$id?>" name="payload_sql" type="hidden" value="<?=$payload_sql?>">
		<input id="doemail_payload_sql_order_<?=$id?>" name="payload_sql_order" type="hidden" value="<?=$payload_sql_order?>">
		<input id="doemail_independent_payload_sql_<?=$id?>" name="independent_payload_sql" type="hidden" value="<?=$independent_payload_sql?>">
		<input id="doemail_independent_payload_sql_order_<?=$id?>" name="independent_payload_sql_order" type="hidden" value="<?=$independent_payload_sql_order?>">
		<input id="doemail_nocount_<?=$id?>" name="nocount" type="hidden" value="<?=$nocount?>">
		<input id="doemail_exactmatch<?=$id?>" name="exactmatch" type="hidden" value="<?=$exactmatch?>">
	</form>
</div>

<script>
<?php minStart(); ?>

function doEmail_<?=$id?>(ids) {
	if (typeof ids === 'undefined') {
		if (typeof autotables === 'undefined') {
			ids = [];
			$('#<?=$id?> tr.selected').each(function () {
				ids.push($(this).attr('data-id'));
			});
		} else {
			var g = $.grep(autotables['<?=$id?>'].table().rows().nodes(), function (e) {
				return e.classList.contains('selected');
			});
			ids = [];
			$.each(g, function (i, e) {
				var ee = false;
				var eee = false;
				try { ee = e.getElementsByClassName('ajaxident')[0].getAttribute('data-id'); } catch (e) { e; }
				try { eee = e.getElementsByClassName('ajaxident')[0].getAttribute('data-persid'); } catch (e) { e; }
				if (ee) ids.push(ee);
				else if (eee) ids.push(eee);
				else if (e.getAttribute('data-id')) ids.push(e.getAttribute('data-id'));
				else ids.push(e.getAttribute('data-persid'));
			});
		}
	}
	$('#doemail_ids_<?=$id?>').val(ids);
	$('#doemail_<?=$id?>').submit();
}

if ($('#<?=$id?>Actions').length > 0) {
	$('#<?=$id?>Actions').append('&nbsp;');
	$('<button class="medium" onclick="return doEmail_<?=$id?>();"><i class="fas fa-envelope"></i> E-Mail senden</button>').appendTo('#<?=$id?>Actions');
}

<?php minEnd(); ?>
</script>

<?
})();
?>