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 b1d467c10..efcb2f138 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 @@ -10,6 +10,13 @@ class Ticket_Queue{ $this->setQueue($rows); } + public function loadAllTickets(){ + $dbl = new DBLayer("lib"); + $statement = $dbl->executeWithoutParams("SELECT * FROM `ticket`"); + $rows = $statement->fetchAll(); + $this->setQueue($rows); + } + public function loadAllOpenTickets(){ $dbl = new DBLayer("lib"); $statement = $dbl->executeWithoutParams("SELECT * FROM ticket INNER JOIN ticket_user ON ticket.Author = ticket_user.TUserId and ticket.Status!=3"); @@ -24,6 +31,48 @@ class Ticket_Queue{ $this->setQueue($rows); } + public function createQueue($userid, $groupid, $what, $how, $who){ + $dbl = new DBLayer("lib"); + + if($who == "user"){ + $selectfrom = "SELECT * FROM `ticket` t LEFT JOIN `assigned` a ON t.TId = a.Ticket LEFT JOIN `ticket_user` tu ON tu.TUserId = a.User"; + if ($how == "assigned"){ + $assign = "tu.TUserId = :id" ; + }else if ($how == "not_assigned"){ + $assign = "(tu.TUserId != :id OR a.Ticket IS NULL)"; + } + }else if ($who == "support_group"){ + $selectfrom = "SELECT * FROM `ticket` t LEFT JOIN `assigned` a ON t.TId = a.Ticket LEFT JOIN `ticket_user` tu ON tu.TUserId = a.User LEFT JOIN `forwarded` f ON t.TId = f.Ticket"; + if ($how == "assigned"){ + $assign = "f.Group = :id"; + }else if ($how == "not_assigned"){ + $assign = "(f.Group != :id OR f.Ticket IS NULL)" ; + } + + } + + if ($what == "waiting_for_support"){ + $status = "t.Status = 1"; + }else if ($what == "waiting_for_user"){ + $status = "t.Status = 0"; + }else if ($what == "closed"){ + $status = "t.Status = 3"; + } + + $query = $selectfrom ." WHERE " . $assign; + if(isset($status)){ + $query = $query . " AND " . $status; + } + if($who == "user"){ + $params = array('id' => $userid); + }else if ($who == "support_group"){ + $params = array('id' => $groupid); + } + $statement = $dbl->execute($query, $params); + $rows = $statement->fetchAll(); + $this->setQueue($rows); + } + public function loadToDoTickets($user_id){ $dbl = new DBLayer("lib"); 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 d263abfca..80a4b5caa 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 @@ -8,6 +8,9 @@ class Ticket_Queue_Handler{ switch ($input){ + case "all": + $queue->loadAllTickets(); + break; case "all_open": $queue->loadAllOpenTickets(); break; @@ -26,4 +29,10 @@ class Ticket_Queue_Handler{ return $queue->getTickets(); } + + public static function CreateQueue($userid, $groupid, $what, $how, $who){ + $queue = new Ticket_Queue(); + $queue->createQueue($userid, $groupid, $what, $how, $who); + return $queue->getTickets(); + } } \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php index 6e3b6c783..e3079806b 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket_user.php @@ -38,6 +38,20 @@ class Ticket_User{ } + //return all mods/admins + public static function getModsAndAdmins() { + $dbl = new DBLayer("lib"); + $statement = $dbl->executeWithoutParams("SELECT * FROM `ticket_user` WHERE `Permission` > 1"); + $rows = $statement->fetchAll(); + $result = Array(); + foreach($rows as $user){ + $instanceUser = new self(); + $instanceUser->set($user); + $result[] = $instanceUser; + } + return $result; + } + //return constructed element based on ExternId public static function constr_ExternId( $id) { $instance = new self(); @@ -62,6 +76,14 @@ class Ticket_User{ public function __construct() { } + //set values + public function set($values) { + $this->setTUserId($values['TUserId']); + $this->setPermission($values['Permission']); + $this->setExternId($values['ExternId']); + } + + //return constructed element based on TUserId public function load_With_TUserId( $id) { $dbl = new DBLayer("lib"); 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 9482214f8..49adc0d46 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 @@ -22,11 +22,24 @@ function show_queue(){ $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $result['ACTION_RESULT'] = Ticket::assignTicket($user_id, $ticket_id); break; + case "unAssignTicket": - $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $result['ACTION_RESULT'] = Ticket::unAssignTicket($user_id, $ticket_id); break; + + case "create_queue": + $userid = filter_var($_POST['userid'], FILTER_SANITIZE_NUMBER_INT); + $groupid = filter_var($_POST['groupid'], FILTER_SANITIZE_NUMBER_INT); + $what = filter_var($_POST['what'], FILTER_SANITIZE_STRING); + $how = filter_var($_POST['how'], FILTER_SANITIZE_STRING); + $who = filter_var($_POST['who'], FILTER_SANITIZE_STRING); + $result['ACTION_RESULT'] = Ticket_Queue_Handler::CreateQueue($userid, $groupid, $what, $how, $who); + if ($result['ACTION_RESULT'] != "ERROR"){ + $queueArray = $result['ACTION_RESULT']; + } + break; + } } @@ -39,6 +52,15 @@ function show_queue(){ $i++; } $result['user_id'] = $_SESSION['ticket_user']->getTUserId(); + + //Queue creator field info + $result['grouplist'] = Gui_Elements::make_table(Support_Group::getGroups(), Array("getSGroupId","getName"), Array("sGroupId","name")); + $result['teamlist'] = Gui_Elements::make_table(Ticket_User::getModsAndAdmins(), Array("getTUserId","getExternId"), Array("tUserId","externId")); + $i = 0; + foreach( $result['teamlist'] as $member){ + $result['teamlist'][$i]['name'] = WebUsers::getUsername($member['externId']); + $i++; + } return $result; }else{ 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 5a818ae30..035ba7bd4 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 @@ -13,17 +13,18 @@