Show the logs in show_ticket_log

--HG--
branch : quitta-gsoc-2013
hg/feature/sse2
Quitta 12 years ago
parent a8ee2f46f6
commit c7e58da11f

@ -22,6 +22,28 @@ class Ticket_Log{
////////////////////////////////////////////Functions//////////////////////////////////////////////////// ////////////////////////////////////////////Functions////////////////////////////////////////////////////
//return all logs that are related to a ticket
public static function getLogsOfTicket( $ticket_id) {
$dbl = new DBLayer("lib");
$statement = $dbl->execute("SELECT * FROM ticket_log INNER JOIN ticket_user ON ticket_log.Author = ticket_user.TUserId and ticket_log.Ticket=:id ORDER BY ticket_log.TLogId DESC", array('id' => $ticket_id));
$row = $statement->fetchAll();
$result = Array();
foreach($row as $log){
$instanceAuthor = Ticket_User::constr_TUserId($log['Author']);
$instanceAuthor->setExternId($log['ExternId']);
$instanceAuthor->setPermission($log['Permission']);
$instanceLog = new self();
$instanceLog->setTLogId($log['TLogId']);
$instanceLog->setTimestamp($log['Timestamp']);
$instanceLog->setAuthor($instanceAuthor);
$instanceLog->setTicket($ticket_id);
$instanceLog->setQuery($log['Query']);
$result[] = $instanceLog;
}
return $result;
}
//Creates a log entry //Creates a log entry
public static function createLogEntry( $ticket_id, $author_id, $action, $arg = -1) { public static function createLogEntry( $ticket_id, $author_id, $action, $arg = -1) {
@ -110,13 +132,13 @@ class Ticket_Log{
return $this->ticket; return $this->ticket;
} }
public function getAcion(){ public function getAction(){
$decodedQuery = json_decode($this->ticket); $decodedQuery = json_decode($this->query);
return $decodedQuery[0]; return $decodedQuery[0];
} }
public function getArgument(){ public function getArgument(){
$decodedQuery = json_decode($this->ticket); $decodedQuery = json_decode($this->query);
return $decodedQuery[1]; return $decodedQuery[1];
} }

@ -1,6 +1,38 @@
<?php <?php
function show_ticket_log(){ function show_ticket_log(){
//if logged in
if(WebUsers::isLoggedIn() && isset($_GET['id'])){
$result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$target_ticket = new Ticket();
$target_ticket->load_With_TId($result['ticket_id']);
if(($target_ticket->getAuthor() == $_SESSION['ticket_user']->getTUserId()) || WebUsers::isAdmin() ){
$result['ticket_title'] = $target_ticket->getTitle();
$ticket_logs = Ticket_Log::getLogsOfTicket( $result['ticket_id']);
$result['ticket_logs'] = Gui_Elements::make_table($ticket_logs, Array("getTLogId","getTimestamp","getAuthor()->getExternId","getAction","getArgument()"), Array("tLogId","timestamp","authorExtern","action","argument"));
$i = 0;
foreach( $result['ticket_logs'] as $log){
$result['ticket_logs'][$i]['author'] = WebUsers::getUsername($log['authorExtern']);
$i++;
}
if(WebUsers::isAdmin()){
$result['isAdmin'] = "TRUE";
}
return $result;
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
}
} }

@ -2,7 +2,7 @@
<div class="row-fluid sortable ui-sortable"> <div class="row-fluid sortable ui-sortable">
<div class="box span12"> <div class="box span12">
<div class="box-header well" data-original-title=""> <div class="box-header well" data-original-title="">
<h2><i class="icon-tag"></i> Tickets of {$target_name}</h2> <h2><i class="icon-tag"></i> Log of Ticket #{$ticket_id}</h2>
<div class="box-icon"> <div class="box-icon">
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a> <a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a> <a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
@ -10,26 +10,26 @@
</div> </div>
<div class="box-content"> <div class="box-content">
<div class="row-fluid"> <div class="row-fluid">
<legend>Tickets</legend> <legend>Title: <a href="index.php?page=show_ticket&id={$ticket_id}">{$ticket_title}</a></legend>
<table class="table table-striped table-bordered bootstrap-datatable datatable"> <table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead> <thead>
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Title</th>
<th>Timestamp</th> <th>Timestamp</th>
<th>Category</th> <th>User</th>
<th>Status</th> <th>Action</th>
<th>Argument</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{foreach from=$ticketlist item=ticket} {foreach from=$ticket_logs item=log}
<tr> <tr>
<td>{$ticket.tId}</td> <td>{$log.tLogId}</td>
<td><a href ="index.php?page=show_ticket&id={$ticket.tId}">{$ticket.title}</a></td> <td>{$log.timestamp}</td>
<td class="center"><i>{$ticket.timestamp}</i></td> <td>{$log.author}</td>
<td class="center">{$ticket.category}</td> <td>{$log.action}</td>
<td>{$log.argument}</td>
<td class="center"><span class="label {if $ticket.status eq 0}label-success{else if $ticket.status eq 1}label-warning{else if $ticket.status eq 2}label-important{/if}">{if $ticket.status eq 0} <i class="icon-exclamation-sign icon-white"></i>{/if} {$ticket.statusText}</span></td>
</tr> </tr>
{/foreach} {/foreach}

Loading…
Cancel
Save