Erster Stub eines ticket-Modules
Bernd Wurst

Bernd Wurst commited on 2012-03-02 11:06:47
Zeige 4 geänderte Dateien mit 129 Einfügungen und 0 Löschungen.

... ...
@@ -0,0 +1,38 @@
1
+<?php
2
+
3
+require_once('inc/base.php');
4
+require_once('inc/debug.php');
5
+
6
+
7
+function list_tickets() 
8
+{
9
+  $customerno = (int) $_SESSION['customerinfo']['customerno'];
10
+  $result = db_query("SELECT id, subject, created, closed, status, severity, priority FROM misc.tickets WHERE customer='{$customerno}'");
11
+  $ret = array();
12
+  while ($line = mysql_fetch_assoc($result))
13
+    $ret[] = $line;
14
+
15
+  DEBUG($ret);
16
+  return $ret;
17
+}
18
+
19
+
20
+function ticket_details($id)
21
+{
22
+  $id = (int) $id;
23
+  $customerno = (int) $_SESSION['customerinfo']['customerno'];
24
+  $result = db_query("SELECT id, subject, created, closed, status, severity, priority FROM misc.tickets WHERE customer='{$customerno}' AND id={$id}");
25
+  if (mysql_num_rows($result) < 1)
26
+    system_failure("Sie haben kein Ticket mit dieser ID");
27
+  $ticket = mysql_fetch_assoc($result);
28
+  $result = db_query("SELECT id, ticket, date, author, direction, text FROM misc.tickets_msg WHERE ticket={$ticket['id']}");
29
+  if (mysql_num_rows($result) < 1)
30
+    system_failure("Es konnten keine Nachrichten zu diesem Ticket gefunden werden");
31
+  $ticket['answers'] = array();
32
+  while ($a = mysql_fetch_assoc($result))
33
+    $ticket['answers'][] = $a;
34
+
35
+  DEBUG($ticket);
36
+  return $ticket;
37
+}
38
+
... ...
@@ -0,0 +1,33 @@
1
+<?php
2
+
3
+require_once('inc/base.php');
4
+require_once('inc/security.php');
5
+require_once('tickets.php');
6
+
7
+$title = 'Support-Tickets';
8
+
9
+output('<h3>Support-Tickets</h3>
10
+<p>Über dieses Ticket-System ist es Ihnen möglich, Anfragen oder Mitteilungen an den Support zu richten. An dieser Stelle sehen Sie immer den aktuellen Stand Ihrer Anfrage.</p>
11
+');
12
+
13
+output('<h4>Bisher vorhandene Tickets</h4>');
14
+
15
+$tickets = list_tickets();
16
+
17
+if (count($tickets) > 0)
18
+{
19
+  output('<table><tr><th>Betreff</th><th>Datum</th><th>Status</th></tr>');
20
+  foreach ($tickets as $t)
21
+  {
22
+    $date = $t['created'];
23
+    $status = 'offen';
24
+    output('<tr><td>'.internal_link('ticket_details', filter_input_general($t['subject']), "t={$t['id']}")."</td><td>{$date}</td><td>{$status}</td>");
25
+  }
26
+  output('</table>');
27
+}
28
+else
29
+{
30
+  output('<p><em>Bisher sind keine Tickets vorhanden</em></p>');
31
+}
32
+
33
+
... ...
@@ -0,0 +1,10 @@
1
+<?php
2
+
3
+$role = $_SESSION['role'];
4
+
5
+if ($role & ROLE_CUSTOMER)
6
+{
7
+    $menu["ticket_list"] = array("label" => "Support-Tickets", "file" => "list", "weight" => 1);
8
+}
9
+
10
+?>
... ...
@@ -0,0 +1,48 @@
1
+<?php
2
+
3
+require_once('inc/base.php');
4
+require_once('inc/security.php');
5
+require_once('tickets.php');
6
+
7
+$t = ticket_details($_REQUEST['t']);
8
+$answers = $t['answers'];
9
+
10
+$title = 'Support-Tickets';
11
+
12
+output('<h3>'.filter_input_general($t['subject']).'</h3>');
13
+
14
+$status = 'unbekannt';
15
+switch ($t['status'])
16
+{
17
+  case 'new':
18
+      $status = 'neu';
19
+      break;
20
+  case 'open':
21
+      $status = 'offen';
22
+      break;
23
+  case 'closed':
24
+      $status = 'erledigt';
25
+      break;
26
+}
27
+output('<div style="margin-left: 2em;">
28
+<p>Datum: '.$answers[0]['date'].'</p>
29
+<p>'.filter_input_general($answers[0]['text']).'</p>
30
+<p>Status: <strong>'.$status.'</strong></p>
31
+</div>');
32
+
33
+unset($answers[0]);
34
+
35
+if (count($answers) > 0)
36
+{
37
+  output('<h3>Antworten:</h3>');
38
+  foreach ($answers as $a)
39
+  {
40
+    output("<h4>{$a['author']}, {$a['date']}</h4>");
41
+    output("<div style=\"margin-left: 2em;\"><p>{$a['text']}</p></div>");
42
+  }
43
+}
44
+else
45
+{
46
+  output('<p><em>Bisher sind keine Antworten zu diesem Ticket vorhanden</em></p>');
47
+}
48
+
0 49