added gui_elements class

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

@ -0,0 +1,19 @@
<?php
class Gui_Elements{
public static function make_table( $inputList, $funcArray ,$fieldArray){
$i = 0;
$result = Array();
foreach($inputList as $element){
$j = 0;
foreach($funcArray as $function){
$result[$i][$fieldArray[$j]] = $element->$function();
$j++;
}
$i++;
}
return $result;
}
}

@ -23,6 +23,7 @@ class Ticket{
$result = Array();
foreach($row as $ticket){
$instance = new self($db_data);
$instance->setTId($ticket['TId']);
$instance->setTimestamp($ticket['Timestamp']);
$instance->setTitle($ticket['Title']);
$instance->setStatus($ticket['Status']);
@ -124,6 +125,24 @@ class Ticket{
return $this->status;
}
public function getStatusText(){
$statusId = $this->getStatus();
if ($statusId == 0){
return "Waiting on support..";
}else if($statusId == 1){
return "Being handled..";
}else if($statusId == 2){
return "Closed";
}
return "Error";
}
public function getCategoryName(){
global $cfg;
$category = Ticket_Category::constr_TCategoryId($this->getTicket_Category(), $cfg['db']['lib']);
return $category->getName();
}
public function getQueue(){
return $this->queue;
}

@ -22,31 +22,8 @@ function show_user(){
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++;
}
$result['ticketlist'] = Gui_Elements::make_table($ticketlist, Array("getTId","getTimestamp","getTitle","getStatus","getStatusText","getCategoryName"), Array("tId","timestamp","title","status","statusText","category"));
return $result;
}else{

@ -90,6 +90,7 @@
<table class="table table-striped table-bordered bootstrap-datatable datatable">
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Timestamp</th>
<th>Category</th>
@ -99,6 +100,7 @@
<tbody>
{foreach from=$ticketlist item=ticket}
<tr>
<td>{$ticket.tId}</td>
<td>{$ticket.title}</td>
<td class="center"><i>{$ticket.timestamp}</i></td>
<td class="center">{$ticket.category}</td>

Loading…
Cancel
Save