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
|
<?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.
*/
?>
<?
/* vim: set ts=4 sw=4 et : */
require_once __DIR__ . "/check_auth.php";
require_once __DIR__ . "/../includes/common.php";
$contractID = $_GET['id'];
$prohibit = false;
(function () use ($mysqli, $_title, $contractID) {
$sql = "
SELECT contracts.id, contracts.`call`, Organisationen.Name
FROM contracts
LEFT JOIN Förderer ON contracts.patron=Förderer.ID
LEFT JOIN Organisationen ON Förderer.Organisation = Organisationen.ID
WHERE contracts.id=?;";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param('i', $contractID);
$stmt->execute();
$r = $stmt->get_result();
$l = $r->fetch_object();
$_title = '<span class="pii">' . $l->Name . ', ' . $l->call . '</span> (ID ' . $contractID . ')';
include_once __DIR__ . "/header.php";
?>
<h1 style="display: inline-block;"><span style="color: red; font-weight: bold;">Vertragsdatensatz löschen:</span> <?=$_title?></h1>
<?
if ($l->id < 1) {
?>
<p><b>Kein Datensatz mit dieser ID gefunden!</b></p>
<p>Wenn Sie gerade gelöscht haben, war das Löschen erfolgreich.</p>
<? if (isset($_GET['autodel']) && $_GET['autodel'] == 1) { ?>
<script>
window.close();
</script>
<? }
exit(0);
}
$def = [
"Auszug",
[6, '_=4Förderer', '_Call']
];
include __DIR__ . '/autoform.php';
$stmt->reset();
})();
(function () use ($contractID) {
$globstring = "{" . $contractID . "contract}_";
require_once __DIR__ . "/doc.php";
})();
(function () use ($mysqli, $contractID, &$num_rows) {
$title = "Spenden";
$nochosen = $nofilter = true;
$sql = "
SELECT
Spenden.ID AS SpendenID,
Spenden.Organisation AS OrgaID,
Organisationen.Name AS Organisation,
CONCAT(calls.name, ' [', contracts.call, '] - ', ContractOrga.Name) AS Vertrag,
Betrag,
DATE(Geldeingang) AS Geldeingang
FROM Spenden
LEFT JOIN Organisationen ON Spenden.Organisation = Organisationen.ID
LEFT JOIN contracts ON Spenden.contract = contracts.id
LEFT JOIN Förderer AS ContractPatron ON contracts.patron = ContractPatron.ID
LEFT JOIN Organisationen AS ContractOrga ON ContractPatron.Organisation = ContractOrga.ID
LEFT JOIN calls ON contracts.`call` = calls.shorthand
WHERE Spenden.contract = ?
";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param("i", $contractID);
$stmt->execute();
$r = $stmt->get_result();
include __DIR__ . '/autotable.php';
$stmt->reset();
})();
if ($num_rows) {
$prohibit = true;
?>
<p class="warning"><i class="fas fa-exclamation-triangle"></i> Es existieren verknüpfte <?=$num_rows?> Spendendatensätze. Löschen daher nicht möglich.</p>
<?
}
?>
<hr>
<?
if (!$prohibit) {
?>
<button class="medium" onclick="return delContract();" style="background: red;"><i class="far fa-trash-alt"></i> Vertragsdatensatz unwiderruflich löschen</button>
<?
} else {
?>
<p>Löschen derzeit nicht möglich. Zunächst Datensätze umwidmen bzw. Verknüpfungen entfernen.<p>
<?
}
?>
<script>
<? minStart(); ?>
function doSth(what) {
$.ajaxSetup({async:false});
$.post('/db/main/delcontractdo.php', {
'id': <?=$contractID?>,
'what': what
});
window.location.reload();
}
function delContract() {
doSth('contract');
}
<? minEnd(); ?>
</script>
<?
if (!$prohibit && isset($_GET['autodel']) && $_GET['autodel'] == 1) {
?>
<script>
delContract();
</script>
<?
}
require_once __DIR__ . "/jumper.php";
exit(0);
|