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
144
145
146
|
<?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.
*/
?>
<?php
/* vim: set ts=4 sw=4 et : */
require_once __DIR__ . "/check_auth.php";
require_once __DIR__ . "/../includes/common.php";
include_once __DIR__ . "/header.php";
require_once __DIR__ . "/lookup.php";
doTitle();
if (isset($_GET['apfi']) && $_GET['apfi'] == 1) {
?>
<p>Der/Die Ansprechpartner Finanzen (apfi) werden für den E-Mail-Versand benutzt. <a href="?apfi=0">Auf AP Zuwendungen zurückschalten.</a></p>
<p>Der Ansprechpartner Zuwendungen ist Adressat des PDF-Dokuments.</p>
<? } else { ?>
<p>Der Ansprechpartner Zuwendungen des Förderers wird für den E-Mail-Versand benutzt. <a href="?apfi=1">Auf AP Finanzen schalten.</a></p>
<p>Der Ansprechpartner Zuwendungen ist Adressat des PDF-Dokuments.</p>
<?
}
(function () use ($mysqli, $_constraint) {
$sql = "
SELECT
contracts.id AS VertrID, CONCAT(calls.name, ' [', `call`, ']') as 'Call', patron AS FoerdID, Organisationen.Name AS Förderer,
Personen.Nachname AS Zuständig,
ls AS Stipendien,
contracts.remark,
CONCAT(IF(Förderer.`SEPA-Lastschrift erteilt`, 'SEPA|', ''), IF(SUM(Spenden.Betrag) > 0, SUM(Spenden.Betrag), 0)) AS Eingang,
IF(Förderer.`SEPA-Lastschrift erteilt`, 0, ((150 * contracts.ss + 150 * contracts.ls) * 12) - IF(SUM(Spenden.Betrag) > 0, SUM(Spenden.Betrag), 0)) AS Fehlbetrag,
GROUP_CONCAT(DATE(Spenden.Geldeingang) SEPARATOR ', ') AS Geldeingänge,
CONCAT(DATE(contracts.valid_from), ' bis ', DATE(contracts.valid_to)) AS 'Gültigkeit',
DATE(Förderer.`Vertrag läuft aus`) AS 'allgemeiner Auslauf',
contracts.kontrolliert,
`Zahlungsaufforderung gewünscht`
FROM contracts
LEFT JOIN Förderer ON contracts.patron = Förderer.ID
LEFT JOIN Organisationen ON Förderer.Organisation = Organisationen.ID
LEFT JOIN Spenden ON contracts.id = Spenden.contract
LEFT JOIN calls ON contracts.`call` = calls.shorthand
LEFT JOIN Personen ON Förderer.Zuständig = Personen.ID
GROUP BY contracts.id
";
$sql .= $_constraint;
$stmt = $mysqli->prepare($sql);
$stmt->execute();
$r = $stmt->get_result();
$id = "contractscommon4";
$idcell = "VertrID";
$idcellreal = "id";
$order = '[[4, "asc"]]';
$entrytable = 'contracts';
$types = [
'kontrolliert' => 'checkbox',
];
$editable = [
'kontrolliert',
'remark',
];
$checkboxes = true;
$bottom = <<<EOD
<div class="admin_actionsbelow">
Ausgewählte
<button class="medium" style="background: darkorange;" onclick="return delContract();"><i class="fas fa-trash-alt"></i> löschen</button>
</div>
EOD;
$email_sql = "
SELECT Förderer.ID AS FoerdID, Organisationen.Name AS Foerderer, CONCAT(Förderer.ID, 'patron', '-', Personen.ID, 'person', '-', contracts.id, 'contract') AS uid, Personen.*, Organisationen.strasse AS Strasse, Organisationen.PLZ as PLZ, Organisationen.Ort AS Ort, Organisationen.Adresszusatz as Adresszusatz, Organisationen.Name AS Organisation, CONCAT(Förderer.ID, 'patron', '-', Personen.ID, 'person', '-', contracts.id, 'contract') AS genuid,
ls AS Leistung, ss AS Sozial, (ls * 150 * 12 + ss * 150 * 12) AS Summe,
IF(SUM(Spenden.Betrag) > 0, SUM(Spenden.Betrag), 0) AS Eingang,
((150 * contracts.ss + 150 * contracts.ls) * 12) - IF(SUM(Spenden.Betrag) > 0, SUM(Spenden.Betrag), 0) AS Fehlbetrag
FROM contracts
INNER JOIN Förderer ON contracts.patron = Förderer.ID
LEFT JOIN Organisationen ON Förderer.Organisation = Organisationen.ID
LEFT JOIN Personen ON Förderer.zuwendungen = Personen.ID
LEFT JOIN Spenden ON contracts.id = Spenden.contract
WHERE contracts.id IN ";
$email_sql_apfi = "
SELECT Förderer.ID AS FoerdID, Organisationen.Name AS Foerderer, CONCAT(Förderer.ID, 'patron', '-', Personen2.ID, 'person', '-', contracts.id, 'contract') AS uid, Personen.*, Organisationen.strasse AS Strasse, Organisationen.PLZ as PLZ, Organisationen.Ort AS Ort, Organisationen.Adresszusatz as Adresszusatz, Organisationen.Name AS Organisation, CONCAT(Förderer.ID, 'patron', '-', Personen2.ID, 'person', '-', contracts.id, 'contract') AS genuid,
ls AS Leistung, ss AS Sozial, (ls * 150 * 12 + ss * 150 * 12) AS Summe,
IF(SUM(Spenden.Betrag) > 0, SUM(Spenden.Betrag), 0) AS Eingang,
((150 * contracts.ss + 150 * contracts.ls) * 12) - IF(SUM(Spenden.Betrag) > 0, SUM(Spenden.Betrag), 0) AS Fehlbetrag
FROM contracts
INNER JOIN Förderer ON contracts.patron = Förderer.ID
INNER JOIN Organisationen ON Förderer.Organisation = Organisationen.ID
LEFT JOIN Personen_Organisationen ON Organisationen.ID = Personen_Organisationen.Organisation
LEFT JOIN Personen ON Personen_Organisationen.Person = Personen.ID
LEFT JOIN Personen AS Personen2 ON Förderer.zuwendungen = Personen2.ID
LEFT JOIN Spenden ON contracts.id = Spenden.contract
WHERE Personen_Organisationen.apfi = 1
AND contracts.id IN ";
$pdf_sql = $email_sql;
if (isset($_GET['apfi']) && $_GET['apfi'] == 1) $email_sql = $email_sql_apfi;
$post_sql = ' GROUP BY contracts.id, Personen.ID';
$exactmatch = 1;
include __DIR__ . '/autotable.php';
include __DIR__ . '/autoactions.php';
include __DIR__ . '/autoemail.php';
include __DIR__ . '/autopdf.php';
$stmt->reset();
})();
?>
<script>
function delContract() {
$.ajaxSetup({async:false});
$.ajax({
type: 'POST',
url: '/db/main/delcontract.php',
data: {
'ids': getIDs_contractscommon3()
}
});
$.ajaxSetup({async:true});
location.reload();
return false;
}
</script>
<?php
include_once __DIR__ . "/footer.php";
?>
|