Big Query that makes it possible to see the todo list, also had to fix the assign/unassign
This commit is contained in:
parent
1be6112aa2
commit
92538c3853
3 changed files with 9 additions and 38 deletions
|
@ -27,46 +27,16 @@ class Ticket_Queue{
|
|||
public function loadToDoTickets($user_id){
|
||||
|
||||
$dbl = new DBLayer("lib");
|
||||
|
||||
//first: find the tickets assigned to the user with status != waiting on user reply
|
||||
$statement = $dbl->execute("SELECT ticket . * FROM ticket LEFT JOIN assigned ON ticket.TId = assigned.Ticket WHERE assigned.User = :user_id",array('user_id' => $user_id));
|
||||
$assignedTo = $statement->fetchAll();
|
||||
|
||||
//second: find all non-assigned tickets forwarded to the support groups to which that user belongs
|
||||
//TODO
|
||||
|
||||
//third: find all not assigned tickets that aren't forwarded yet.
|
||||
//TODO: check if not forwarded to a group!
|
||||
$statement = $dbl->executeWithoutParams("SELECT ticket . * FROM ticket LEFT JOIN assigned ON ticket.TId = assigned.Ticket WHERE assigned.Ticket IS NULL");
|
||||
$notAssigned = $statement->fetchAll();
|
||||
|
||||
//forth: find all tickets assigned to someone else, not forwarded to a group or forwarded to a group you are a member from, with status == waiting on support and with timestamp of last reply > 1 day
|
||||
//TODO
|
||||
|
||||
//Now let's get them all together
|
||||
$allTogether = $assignedTo + $notAssigned;
|
||||
$query = "SELECT t . * FROM `ticket` t LEFT JOIN `assigned` a ON t.TId = a.Ticket LEFT JOIN `ticket_user` tu ON tu.TUserId = a.User WHERE (tu.ExternId = :user_id AND t.Status = 1) OR (a.Ticket IS NULL) OR (tu.ExternId != :user_id AND t.Status = 1 AND (SELECT ticket_reply.Timestamp FROM `ticket_reply` WHERE Ticket =t.TId ORDER BY TReplyId DESC LIMIT 1) < NOW() - INTERVAL 1 DAY )";
|
||||
$values = array('user_id' => $user_id);
|
||||
$statement = $dbl->execute($query,$values);
|
||||
$rows = $statement->fetchAll();
|
||||
$this->setQueue($rows);
|
||||
|
||||
//filter to only get unique ticket id's
|
||||
$this->setQueue(self::filter_tickets($allTogether));
|
||||
|
||||
}
|
||||
|
||||
//filters the array of tickets and returns unique tickets based on there TId
|
||||
static public function filter_tickets($ticketArray){
|
||||
$tmp = array ();
|
||||
foreach ($ticketArray as $ticket1){
|
||||
$found = false;
|
||||
foreach ($tmp as $ticket2){
|
||||
if($ticket1['TId'] == $ticket2['TId']){
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
if(! $found){
|
||||
$tmp[] = $ticket1;
|
||||
}
|
||||
}
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
|
||||
public function getTickets(){
|
||||
return $this->queueElements;
|
||||
|
|
|
@ -35,6 +35,7 @@ function show_queue(){
|
|||
foreach( $result['tickets'] as $ticket){
|
||||
$result['tickets'][$i]['author'] = WebUsers::getUsername($ticket['authorExtern']);
|
||||
$result['tickets'][$i]['assignedText'] = WebUsers::getUsername($ticket['assigned']);
|
||||
$result['tickets'][$i]['timestamp_elapsed'] = Gui_Elements::time_elapsed_string($ticket['timestamp']);
|
||||
$i++;
|
||||
}
|
||||
$result['user_id'] = $_SESSION['ticket_user']->getTUserId();
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<td>{$ticket.tId}</td>
|
||||
<td><a href ="index.php?page=show_ticket&id={$ticket.tId}">{$ticket.title}</a></td>
|
||||
<td>{if $ticket.assignedText neq ""} <a href="index.php?page=show_user&id={$ticket.assigned}">{$ticket.assignedText} {else}<i> {$not_assigned}</i> {/if}</td>
|
||||
<td class="center"><i>{$ticket.timestamp}</i></td>
|
||||
<td class="center"><span title="{$ticket.timestamp_elapsed}" data-rel="tooltip" data-placement="right">{$ticket.timestamp}</span></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}">{if $ticket.status eq 0} <i class="icon-exclamation-sign icon-white"></i>{/if} {$ticket.statusText}</span></td>
|
||||
<td>
|
||||
|
@ -62,7 +62,7 @@
|
|||
<input type="hidden" name="action" value="assignTicket">
|
||||
<button type="submit" class="btn btn-primary" ><i class="icon-flag icon-white"></i> Assign Ticket</button>
|
||||
</form>
|
||||
{else if $ticket.assigned eq 1}
|
||||
{else if $ticket.assigned eq $user_id}
|
||||
<form id="assign_ticket" class="form-vertical" method="post" action="" style="margin:0px 0px 0px;">
|
||||
<input type="hidden" name="ticket_id" value="{$ticket.tId}">
|
||||
<input type="hidden" name="action" value="unAssignTicket">
|
||||
|
|
Loading…
Reference in a new issue