DB::init($dbOptions); switch ($_GET['action']) { case 'messages': BLAM::checkLogged(); $q = "SELECT msg.id, msg.text, msg.ticket_id, msg.created, users.username FROM messages AS msg INNER JOIN users ON msg.user_id = users.id ORDER BY msg.id ASC"; $res = DB::query($q); echo '<table border="1">'; echo '<tr><th>id</th><th>timestamp</th><th>operator</th><th>text</th><th>ticketnr</th></tr>'; while ($data = mysqli_fetch_assoc($res)) { echo '<tr><td>' . $data['id'] . '</td><td>' . $data['created'] . '</td><td>' . $data['username'] . '</td><td>' . $data['text'] . '</td><td>' . $data['ticket_id'] . '</td></tr>'; //echo '<p id="message">'.$data['text'].'</p>'; } echo '</table>'; break; case 'tickets': BLAM::checkLogged(); $q = "\n SELECT t.id AS id, t.title, t.handle_id, t.location, t.reference, t.text, t.solution, u.username AS wluser, t.created, t.modified, h.description AS voertuignaam\n FROM tickets AS t\n LEFT OUTER JOIN users AS u ON t.user_id = u.id\n LEFT OUTER JOIN messages AS m ON t.message_id = m.id\n LEFT OUTER JOIN handles AS h ON t.handle_id = h.id\n WHERE t.parent_id IS NULL\n ORDER BY t.id ASC\n "; $res = DB::query($q); echo '<table border="1">'; echo '<tr><th>id</th><th>timestamp</th><th>wl_user</th><th>titel</th><th>voertuig</th><th>referentie</th><th>locatie</th></tr>'; while ($data = mysqli_fetch_assoc($res)) { echo '<tr><td>' . $data['id'] . '</td><td>' . $data['created'] . '</td><td>' . $data['wluser'] . '</td><td>' . $data['title'] . '</td><td>' . $data['voertuignaam'] . '</td><td>' . $data['reference'] . '</td><td>' . $data['location'] . '</td></tr>'; echo '<tr><td>' . $data['id'] . '</td><td>' . $data['created'] . '</td><td>Bericht</td><td colspan="4">' . $data['text'] . '</td></tr>'; $q2 = "\n SELECT u.id, u.ticket_id, u.type, u.message, u.called, u.called_by, u.created\n FROM updates AS u\n WHERE u.ticket_id = " . $data['id'] . " LIMIT 0,100"; $res2 = DB::query($q2); while ($update = mysqli_fetch_assoc($res2)) { echo '<tr><td>' . $data['id'] . '</td><td>' . $update['created'] . '</td><td>' . $update['type'] . '</td><td colspan="4">' . $update['message'] . '</td></tr>'; } echo '<tr><td>' . $data['id'] . '</td><td>' . $data['modified'] . '</td><td>Oplossing</td><td colspan="4">' . $data['solution'] . '</td></tr>'; $q3 = "\n SELECT t.id AS id, t.title, t.handle_id, t.location, t.reference, t.text, t.solution, u.username AS wluser, t.created, t.modified, h.description AS voertuignaam\n FROM tickets AS t\n LEFT OUTER JOIN users AS u ON t.user_id = u.id\n LEFT OUTER JOIN messages AS m ON t.message_id = m.id\n LEFT OUTER JOIN handles AS h ON t.handle_id = h.id\n WHERE t.parent_id = " . $data['id'] . " ORDER BY t.id ASC"; $res3 = DB::query($q3);