Bernd Wurst commited on 2018-01-24 10:34:58
Zeige 5 geänderte Dateien mit 121 Einfügungen und 13 Löschungen.
... | ... |
@@ -64,7 +64,7 @@ function get_contact($id) |
64 | 64 |
|
65 | 65 |
function get_contacts() { |
66 | 66 |
$cid = (int) $_SESSION['customerinfo']['customerno']; |
67 |
- $result = db_query("SELECT id, state, lastchange, nic_id, nic_handle, company, name, address, zip, city, country, phone, mobile, fax, email, pgp_id, pgp_key FROM kundendaten.contacts WHERE customer=? ORDER BY id", array($cid)); |
|
67 |
+ $result = db_query("SELECT id, state, lastchange, nic_id, nic_handle, company, name, address, zip, city, country, phone, mobile, fax, email, pgp_id, pgp_key FROM kundendaten.contacts WHERE (state<>'deleted' OR state IS NULL) AND customer=? ORDER BY id", array($cid)); |
|
68 | 68 |
$ret = array(); |
69 | 69 |
while ($contact = $result->fetch()) { |
70 | 70 |
$ret[$contact['id']] = $contact; |
... | ... |
@@ -74,6 +74,15 @@ function get_contacts() { |
74 | 74 |
} |
75 | 75 |
|
76 | 76 |
|
77 |
+function is_domainholder($contactid) { |
|
78 |
+ $contactid = (int) $contactid; |
|
79 |
+ $result = db_query("SELECT id FROM kundendaten.domains WHERE owner=? OR admin_c=?", array($contactid, $contactid)); |
|
80 |
+ if ($result->rowCount() > 0) { |
|
81 |
+ return true; |
|
82 |
+ } |
|
83 |
+ return false; |
|
84 |
+} |
|
85 |
+ |
|
77 | 86 |
function possible_domainholders() { |
78 | 87 |
$allcontacts = get_contacts(); |
79 | 88 |
$ret = array(); |
... | ... |
@@ -193,3 +202,13 @@ function update_pending($contactid) { |
193 | 202 |
|
194 | 203 |
|
195 | 204 |
|
205 |
+function delete_contact($id) { |
|
206 |
+ $c = get_contact($id); |
|
207 |
+ if ($c['nic_id']) { |
|
208 |
+ // Lösche bei der Registry |
|
209 |
+ $c['state'] = 'deleted'; |
|
210 |
+ upload_contact($c); |
|
211 |
+ } |
|
212 |
+ db_query("UPDATE kundendaten.contacts SET state='deleted' WHERE id=?", array($c['id'])); |
|
213 |
+} |
|
214 |
+ |
... | ... |
@@ -30,11 +30,12 @@ $contacts = get_contacts(); |
30 | 30 |
$kundenkontakte = get_kundenkontakte(); |
31 | 31 |
|
32 | 32 |
output('<p>Sie haben aktuell diese Adressen gespeichert:</p> |
33 |
-<table> |
|
34 |
-<tr><th>#</th><th>Name</th><th>Adresse</th><th>E-Mail</th><th>Verwendung</th><th>Aktionen</th></tr> |
|
35 |
-'); |
|
33 |
+<div class="contact-list">'); |
|
36 | 34 |
foreach ($contacts as $id => $contact) { |
37 |
- $adresse = nl2br($contact['address']."\n".$contact['country'].'-'.$contact['zip'].' '.$contact['city']); |
|
35 |
+ $adresse = nl2br("\n".$contact['address']."\n".$contact['country'].'-'.$contact['zip'].' '.$contact['city']); |
|
36 |
+ if (! $contact['city']) { |
|
37 |
+ $adresse = ''; |
|
38 |
+ } |
|
38 | 39 |
$usage = array(); |
39 | 40 |
if ($id == $kundenkontakte['kunde']) { |
40 | 41 |
$usage[] = 'Stamm-Adresse'; |
... | ... |
@@ -58,16 +59,18 @@ foreach ($contacts as $id => $contact) { |
58 | 59 |
if ($new_email) { |
59 | 60 |
$email = "<strike>$email</strike><br/>".$new_email.footnote('Die E-Mail-Adresse wurde noch nicht bestätigt'); |
60 | 61 |
} |
61 |
- $actions = array( |
|
62 |
- internal_link('edit', icon_edit('Adresse bearbeiten'), 'id='.$contact['id']), |
|
63 |
- internal_link('edit', other_icon('page_copy.png', 'Kopie erstellen'), 'id=new©='.$contact['id']), |
|
64 |
- |
|
65 |
- ); |
|
62 |
+ $actions = array(); |
|
63 |
+ $actions[] = internal_link('edit', icon_edit('Adresse bearbeiten')." Bearbeiten", 'id='.$contact['id']); |
|
64 |
+ if ($id != $kundenkontakte['kunde'] && ! is_domainholder($id)) { |
|
65 |
+ // Die Stamm-Adresse kann man nicht löschen und verwendete Domain-Kontakte auch nicht |
|
66 |
+ $actions[] = internal_link('save', icon_delete('Adresse löschen')." Löschen", 'action=delete&id='.$contact['id']); |
|
67 |
+ } |
|
68 |
+ $actions[] = internal_link('edit', other_icon('page_copy.png', 'Kopie erstellen')." Kopie erstellen", 'id=new©='.$contact['id']); |
|
66 | 69 |
|
67 |
- output("<tr><td>{$contact['id']}</td><td><strong>".internal_link('edit', $name, 'id='.$contact['id'])."</strong></td><td>$adresse</td><td>$email</td><td>$usage</td><td>".implode(' ', $actions)."</td></tr>"); |
|
70 |
+ $email = implode("<br>\n", array_filter(array($email, $contact['phone'], $contact['fax'], $contact['mobile']))); |
|
71 |
+ output("<div class=\"contact\" id=\"contact-{$contact['id']}\"><p class=\"contact-id\">#{$contact['id']}</p><p class=\"contact-address\"><strong>$name</strong>$adresse</p><p class=\"contact-contact\">$email</p><p class=\"contact-usage\">Verwendung als $usage</p><p class=\"contact-actions\">".implode(' ', $actions)."</p></div>"); |
|
68 | 72 |
} |
69 |
-output('</table>'); |
|
70 |
-output("<br />"); |
|
73 |
+output("</div><br />"); |
|
71 | 74 |
addnew('edit', 'Neuen Kontakt erstellen', 'id=new'); |
72 | 75 |
|
73 | 76 |
|
... | ... |
@@ -24,6 +24,41 @@ require_once('session/start.php'); |
24 | 24 |
require_role(array(ROLE_CUSTOMER)); |
25 | 25 |
$section = 'contacts_list'; |
26 | 26 |
|
27 |
+if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { |
|
28 |
+ $contact = get_contact($_REQUEST['id']); |
|
29 |
+ |
|
30 |
+ $adresse = nl2br("\n".$contact['address']."\n".$contact['country'].'-'.$contact['zip'].' '.$contact['city']); |
|
31 |
+ if (! $contact['city']) { |
|
32 |
+ $adresse = ''; |
|
33 |
+ } |
|
34 |
+ $name = $contact['name']; |
|
35 |
+ if ($contact['company']) { |
|
36 |
+ $name = $contact['company']."<br />".$contact['name']; |
|
37 |
+ } |
|
38 |
+ $email = implode("<br>\n", array_filter(array($contact['email'], $contact['phone'], $contact['fax'], $contact['mobile']))); |
|
39 |
+ |
|
40 |
+ $contact_string = "<div class=\"contact\" id=\"contact-{$contact['id']}\"><p class=\"contact-id\">#{$contact['id']}</p><p class=\"contact-address\"><strong>$name</strong>$adresse</p><p class=\"contact-contact\">$email</p></div>"; |
|
41 |
+ |
|
42 |
+ |
|
43 |
+ $sure = user_is_sure(); |
|
44 |
+ if ($sure === NULL) |
|
45 |
+ { |
|
46 |
+ are_you_sure("action=delete&id={$contact['id']}", "Möchten Sie diese Adresse wirklich löschen? {$contact_string}"); |
|
47 |
+ } |
|
48 |
+ elseif ($sure === true) |
|
49 |
+ { |
|
50 |
+ delete_contact($contact['id']); |
|
51 |
+ if (! $debugmode) |
|
52 |
+ header("Location: list"); |
|
53 |
+ } |
|
54 |
+ elseif ($sure === false) |
|
55 |
+ { |
|
56 |
+ if (! $debugmode) |
|
57 |
+ header("Location: list"); |
|
58 |
+ } |
|
59 |
+ |
|
60 |
+ |
|
61 |
+} else { |
|
27 | 62 |
check_form_token('contacts_edit'); |
28 | 63 |
|
29 | 64 |
$new = False; |
... | ... |
@@ -121,3 +156,4 @@ if ($c['nic_id']) { |
121 | 156 |
|
122 | 157 |
if (! $debugmode) |
123 | 158 |
header("Location: list"); |
159 |
+} |
... | ... |
@@ -0,0 +1,47 @@ |
1 |
+/* |
|
2 |
+ * ------------------------------------------------------------------------------- |
|
3 |
+ * This file belongs to the Webinterface of schokokeks.org Hosting |
|
4 |
+ * |
|
5 |
+ * Written 2008-2018 by schokokeks.org Hosting, namely |
|
6 |
+ * Bernd Wurst <bernd@schokokeks.org> |
|
7 |
+ * Hanno Böck <hanno@schokokeks.org> |
|
8 |
+ * |
|
9 |
+ * To the extent possible under law, the author(s) have dedicated all copyright |
|
10 |
+ * and related and neighboring rights to this software to the public domain |
|
11 |
+ * worldwide. This software is distributed without any warranty. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the CC0 Public Domain Dedication along |
|
14 |
+ * with this software. If not, see |
|
15 |
+ * http://creativecommons.org/publicdomain/zero/1.0/ |
|
16 |
+ * |
|
17 |
+ * Nevertheless, in case you use a significant part of this code, we ask (but |
|
18 |
+ * not require, see the license) that you keep the authors' names in place and |
|
19 |
+ * return your changes to the public. We would be especially happy if you tell |
|
20 |
+ * us what you're going to do with this code. |
|
21 |
+ * ------------------------------------------------------------------------------- |
|
22 |
+ */ |
|
23 |
+ |
|
24 |
+ |
|
25 |
+div.contact-list { |
|
26 |
+ display: flex; |
|
27 |
+ flex-direction: row; |
|
28 |
+ flex-wrap: wrap; |
|
29 |
+} |
|
30 |
+ |
|
31 |
+div.contact { |
|
32 |
+ border: 1px solid black; |
|
33 |
+ width: 18em; |
|
34 |
+ margin: 1em; |
|
35 |
+ padding: 0.1em 1em; |
|
36 |
+} |
|
37 |
+ |
|
38 |
+p.contact-id { |
|
39 |
+ text-align: right; |
|
40 |
+ float: right; |
|
41 |
+ color: #aaa; |
|
42 |
+ margin: 0; |
|
43 |
+ padding: 0; |
|
44 |
+} |
|
45 |
+ |
|
46 |
+p.contact-actions { |
|
47 |
+} |
|
0 | 48 |