From 10e98deade8d16a52a63296141c048eaeea9b352 Mon Sep 17 00:00:00 2001 From: Quitta Date: Sun, 21 Jul 2013 15:38:22 +0200 Subject: [PATCH] made the todo queue --- .../ams_lib/autoload/ticket_queue.php | 44 +++++++++++++++++++ .../ams_lib/autoload/ticket_queue_handler.php | 5 ++- .../ryzom_ams/ams_lib/translations/en.ini | 4 +- .../ryzom_ams/www/html/inc/show_queue.php | 5 ++- .../www/html/templates/show_queue.tpl | 4 +- 5 files changed, 55 insertions(+), 7 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 24882e8b9..554f5960f 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 @@ -24,6 +24,50 @@ class Ticket_Queue{ $this->setQueue($rows); } + 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; + + //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/ams_lib/autoload/ticket_queue_handler.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue_handler.php index 6103d9731..d263abfca 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue_handler.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_queue_handler.php @@ -2,7 +2,7 @@ class Ticket_Queue_Handler{ - public static function getTickets($input){ + public static function getTickets($input, $user_id){ $queue = new Ticket_Queue(); @@ -17,6 +17,9 @@ class Ticket_Queue_Handler{ case "not_assigned": $queue->loadAllNotAssignedTickets(); break; + case "todo": + $queue->loadToDoTickets($user_id); + break; default: return "ERROR"; } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini index 8f5613e9f..df46cd938 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini @@ -34,8 +34,8 @@ not_assigned = "Open" success_assigned = "The ticket was successfully assigned!" success_unassigned = "The ticket was successfully unassigned!" ticket_not_existing = "That ticket doesn't exist!" -already_assigned = "That ticket is already assigned to someone!" -not_assigned = "That ticket isn't assigned to you!" +ticket_already_assigned = "That ticket is already assigned to someone!" +ticket_not_assigned = "That ticket isn't assigned to you!" [show_sgroup] add_to_group_success = "The user has been added to the group!" 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 097b5c4f7..a3fbf57d4 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 @@ -8,12 +8,13 @@ function show_queue(){ if( Ticket_User::isMod($_SESSION['ticket_user'])){ $result['queue_view'] = filter_var($_GET['get'], FILTER_SANITIZE_STRING); - $queueArray = Ticket_Queue_Handler::getTickets($result['queue_view']); + $user_id = $_SESSION['ticket_user']->getTUserId(); + $queueArray = Ticket_Queue_Handler::getTickets($result['queue_view'], $user_id); //if queue_view is a valid parameter value if ($queueArray != "ERROR"){ - $user_id = $_SESSION['ticket_user']->getTUserId(); + if(isset($_POST['action'])){ switch($_POST['action']){ 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 df5c2cb7a..2c330d692 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 @@ -26,11 +26,11 @@ {else if isset($ACTION_RESULT) and $ACTION_RESULT eq "ALREADY_ASSIGNED"}
- {$already_assigned} + {$ticket_already_assigned}
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "NOT_ASSIGNED"}
- {$not_assigned} + {$ticket_not_assigned}
{/if}