Show the user his tickets in the user profile screen

--HG--
branch : quitta-gsoc-2013
hg/feature/sse2
Quitta 12 years ago
parent 61aebf6b3b
commit 9d3317eb0c

@ -12,6 +12,29 @@ class Ticket{
////////////////////////////////////////////Functions////////////////////////////////////////////////////
/*FUNCTION: getTicketTitlesOf()
* return all ticket of the given author's id.
*
*/
public static function getTicketsOf($author, $db_data) {
$dbl = new DBLayer($db_data);
$statement = $dbl->execute("SELECT * FROM ticket INNER JOIN ticket_user ON ticket.Author = ticket_user.TUserId and ticket_user.ExternId=:id", array('id' => $author));
$row = $statement->fetchAll();
$result = Array();
foreach($row as $ticket){
$instance = new self($db_data);
$instance->setTimestamp($ticket['Timestamp']);
$instance->setTitle($ticket['Title']);
$instance->setStatus($ticket['Status']);
$instance->setQueue($ticket['Queue']);
$instance->setTicket_Category($ticket['Ticket_Category']);
$instance->setAuthor($ticket['Author']);
$result[] = $instance;
}
return $result;
}
/*FUNCTION: create_Ticket()
* creates a ticket + first initial reply and fills in the content of it!
*

@ -4,7 +4,7 @@ function show_user(){
//if logged in
if(WebUsers::isLoggedIn()){
if(WebUsers::isAdmin()){
if( !isset($_GET['id']) || WebUsers::isAdmin() || $_GET['id'] == $_SESSION['id'] ){
if(isset($_GET['id'])){
$result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
@ -19,6 +19,34 @@ function show_user(){
$result['country'] = $info['Country'];
$result['gender'] = $info['Gender'];
global $cfg;
$ticket_user = Ticket_User::constr_ExternId($result['target_id'],$cfg['db']['lib']);
$ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId(),$cfg['db']['lib']);
$i = 0;
$result['ticketlist'] = Array();
foreach($ticketlist as $ticket){
$result['ticketlist'][$i]['tId'] = $ticket->getTId();
$result['ticketlist'][$i]['timestamp'] = $ticket->getTimestamp();
$result['ticketlist'][$i]['title'] = $ticket->getTitle();
//get the status
$statusId = $ticket->getStatus();
if ($statusId == 0){
$status = "Waiting on support..";
}else if($statusId == 1){
$status = "Being handled..";
}else if($statusId == 2){
$status = "Closed";
}
$result['ticketlist'][$i]['statusText'] = $status;
$result['ticketlist'][$i]['status'] = $statusId;
//get the category
$category = Ticket_Category::constr_TCategoryId($ticket->getTicket_Category(), $cfg['db']['lib']);
$result['ticketlist'][$i]['category'] = $category->getName();
$i++;
}
return $result;
}else{

@ -96,6 +96,7 @@
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="index.php?page=show_user">Profile</a></li>
<li><a href="index.php?page=logout">Logout</a></li>
</ul>
</div>

@ -2,6 +2,7 @@
{block name=menu}
<li class="nav-header hidden-tablet">Main</li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php"><i class="icon-home"></i><span class="hidden-tablet"> Dashboard</span></a></li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=show_user"><i class="icon-user"></i><span class="hidden-tablet"> Profile</span></a></li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=settings"><i class="icon-cog"></i><span class="hidden-tablet"> Settings</span></a></li>
<li class="nav-header hidden-tablet">Admin</li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=libuserlist"><i class="icon-th-list"></i><span class="hidden-tablet"> Liblist</span></a></li>

@ -2,6 +2,7 @@
{block name=menu}
<li class="nav-header hidden-tablet">Main</li>
<li style="margin-left: -2px;" class="active"><a class="ajax-link" href="index.php"><i class="icon-home"></i><span class="hidden-tablet"> Dashboard</span></a></li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=show_user"><i class="icon-user"></i><span class="hidden-tablet"> Profile</span></a></li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=settings"><i class="icon-cog"></i><span class="hidden-tablet"> Settings</span></a></li>
<li class="nav-header hidden-tablet">Actions</li>
<li style="margin-left: -2px;"><a class="ajax-link" href="index.php?page=createticket"><i class="icon-pencil"></i><span class="hidden-tablet">Create New Ticket</span></a></li>

@ -74,5 +74,44 @@
</div>
</div><!--/span-->
</div><!--/row-->
<div class="row-fluid sortable ui-sortable">
<div class="box span9">
<div class="box-header well" data-original-title="">
<h2><i class="icon-tag"></i> Tickets of {$target_name}</h2>
<div class="box-icon">
<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>
</div>
</div>
<div class="box-content">
<div class="row-fluid">
<legend>Tickets</legend>
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>Title</th>
<th>Timestamp</th>
<th>Category</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{foreach from=$ticketlist item=ticket}
<tr>
<td>{$ticket.title}</td>
<td class="center"><i>{$ticket.timestamp}</i></td>
<td class="center">{$ticket.category}</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}">{$ticket.statusText}</span></td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</div>
</div><!--/span-->
</div><!--/row-->
{/block}

Loading…
Cancel
Save