From 92538c3853137f977102b54183e45f013e3a10f5 Mon Sep 17 00:00:00 2001 From: Quitta Date: Sun, 21 Jul 2013 17:56:24 +0200 Subject: [PATCH] Big Query that makes it possible to see the todo list, also had to fix the assign/unassign --- .../ams_lib/autoload/ticket_queue.php | 42 +++---------------- .../ryzom_ams/www/html/inc/show_queue.php | 1 + .../www/html/templates/show_queue.tpl | 4 +- 3 files changed, 9 insertions(+), 38 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php index 554f5960f..2a0d236cd 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue.php @@ -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; diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php index a3fbf57d4..6654dc161 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php @@ -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(); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl index 2c330d692..060c4219c 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl @@ -52,7 +52,7 @@ {$ticket.tId} {$ticket.title} {if $ticket.assignedText neq ""} {$ticket.assignedText} {else} {$not_assigned} {/if} - {$ticket.timestamp} + {$ticket.timestamp} {$ticket.category} {if $ticket.status eq 0} {/if} {$ticket.statusText} @@ -62,7 +62,7 @@ - {else if $ticket.assigned eq 1} + {else if $ticket.assigned eq $user_id}