queue creator works also added a few extra default queues

--HG--
branch : quitta-gsoc-2013
This commit is contained in:
Quitta 2013-07-23 23:38:06 +02:00
parent 722795b5d2
commit b12f630077
5 changed files with 126 additions and 13 deletions

View file

@ -10,6 +10,13 @@ class Ticket_Queue{
$this->setQueue($rows); $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(){ public function loadAllOpenTickets(){
$dbl = new DBLayer("lib"); $dbl = new DBLayer("lib");
$statement = $dbl->executeWithoutParams("SELECT * FROM ticket INNER JOIN ticket_user ON ticket.Author = ticket_user.TUserId and ticket.Status!=3"); $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); $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){ public function loadToDoTickets($user_id){
$dbl = new DBLayer("lib"); $dbl = new DBLayer("lib");

View file

@ -8,6 +8,9 @@ class Ticket_Queue_Handler{
switch ($input){ switch ($input){
case "all":
$queue->loadAllTickets();
break;
case "all_open": case "all_open":
$queue->loadAllOpenTickets(); $queue->loadAllOpenTickets();
break; break;
@ -26,4 +29,10 @@ class Ticket_Queue_Handler{
return $queue->getTickets(); 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();
}
} }

View file

@ -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 //return constructed element based on ExternId
public static function constr_ExternId( $id) { public static function constr_ExternId( $id) {
$instance = new self(); $instance = new self();
@ -62,6 +76,14 @@ class Ticket_User{
public function __construct() { 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 //return constructed element based on TUserId
public function load_With_TUserId( $id) { public function load_With_TUserId( $id) {
$dbl = new DBLayer("lib"); $dbl = new DBLayer("lib");

View file

@ -22,11 +22,24 @@ function show_queue(){
$ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
$result['ACTION_RESULT'] = Ticket::assignTicket($user_id, $ticket_id); $result['ACTION_RESULT'] = Ticket::assignTicket($user_id, $ticket_id);
break; break;
case "unAssignTicket":
case "unAssignTicket":
$ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
$result['ACTION_RESULT'] = Ticket::unAssignTicket($user_id, $ticket_id); $result['ACTION_RESULT'] = Ticket::unAssignTicket($user_id, $ticket_id);
break; 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++; $i++;
} }
$result['user_id'] = $_SESSION['ticket_user']->getTUserId(); $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; return $result;
}else{ }else{

View file

@ -13,17 +13,18 @@
<legend>Tickets</legend> <legend>Tickets</legend>
<div class="alert alert-info"> <div class="alert alert-info">
<form id="create_queue" class="form-vertical" method="post" action="" style="margin:0px 0px 0px;">
Show Show
<select style="width: 136px;" name="what"> <select style="width: 136px;" name="what">
<option value="all">All</option> <option value="all">all</option>
<option value="wfs">'waiting for support'</option> <option value="waiting_for_support">waiting for support</option>
<option value="wfu">'waiting for user'</option> <option value="waiting_for_users">waiting for user</option>
<option value="closed">'closed'</option> <option value="closed">closed</option>
</select> </select>
tickets tickets
<select style="width: 110px;" name="how"> <select style="width: 110px;" name="how">
<option value="all">assigned</option> <option value="assigned">assigned</option>
<option value="wfs">not assigned</option> <option value="not_assigned">not assigned</option>
</select> </select>
to to
<select style="width: 140px;" name="who" onchange="aimedforwhochanged(this.value);"> <select style="width: 140px;" name="who" onchange="aimedforwhochanged(this.value);">
@ -31,19 +32,27 @@
<option value="support_group">support group</option> <option value="support_group">support group</option>
</select> </select>
<span id="userList" style="display:inline;"> <span id="userList" style="display:inline;">
<select style="width: 140px;" name="name"> <select style="width: 140px;" name="userid">
<option value="all">Quitta</option> {foreach from=$teamlist item=member}
<option value="wfs">Botanic</option> <option value="{$member.tUserId}" {if $user_id eq $member.tUserId}selected="selected"{/if}>{$member.name}</option>
{/foreach}
</select> </select>
</span> </span>
<span id="supportGroupList" style="display:none;"> <span id="supportGroupList" style="display:none;">
<select style="width: 140px;" name="name"> <select style="width: 140px;" name="groupid">
<option value="all">Developers</option> {foreach from=$grouplist item=group}
<option value="wfs">Webteam</option> <option value="{$group.sGroupId}">{$group.name}</option>
{/foreach}
</select> </select>
</span> </span>
<input type="hidden" name="action" value="create_queue">
<button type="submit" class="btn btn-primary" style="bottom:4px; position:relative;" ><i class="icon-tag icon-white"></i> View</button>
</form>
</div> </div>
{if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_ASSIGNED"} {if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_ASSIGNED"}
<div class="alert alert-success"> <div class="alert alert-success">
{$success_assigned} {$success_assigned}
@ -135,6 +144,8 @@
<button class="btn btn-primary btn-large dropdown-toggle" data-toggle="dropdown">Actions<span class="caret"></span></button> <button class="btn btn-primary btn-large dropdown-toggle" data-toggle="dropdown">Actions<span class="caret"></span></button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li class="divider"></li> <li class="divider"></li>
<li><a href="index.php?page=show_queue&get=todo">Todo tickets</a></li>
<li><a href="index.php?page=show_queue&get=all">All tickets</a></li>
<li><a href="index.php?page=show_queue&get=all_open">All open tickets</a></li> <li><a href="index.php?page=show_queue&get=all_open">All open tickets</a></li>
<li><a href="index.php?page=show_queue&get=archive">Ticket Archive</a></li> <li><a href="index.php?page=show_queue&get=archive">Ticket Archive</a></li>
<li><a href="index.php?page=show_queue&get=not_assigned">Not Assigned Tickets</a></li> <li><a href="index.php?page=show_queue&get=not_assigned">Not Assigned Tickets</a></li>