I think I'm done refactoring the queues

--HG--
branch : quitta-gsoc-2013
This commit is contained in:
Quitta 2013-08-06 01:00:17 +02:00
parent ef05fdda7c
commit 1d68d8a781
8 changed files with 92 additions and 45 deletions

View file

@ -86,7 +86,8 @@ class Ticket{
public static function create_Ticket( $title, $content, $category, $author, $real_author) {
$ticket = new Ticket();
$ticket->set($title,1,0,$category,$author,0);
$values = array("Title" => $title, "Status"=> 1, "Queue"=> 0, "Ticket_Category" => $category, "Author" => $author, "Priority" => 0);
$ticket->set($values);
$ticket->create();
$ticket_id = $ticket->getTId();

View file

@ -40,7 +40,6 @@ class Ticket_Queue{
}
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";
@ -76,9 +75,8 @@ class Ticket_Queue{
}else if ($who == "support_group"){
$params = array('id' => $groupid);
}
$statement = $dbl->execute($query, $params);
$rows = $statement->fetchAll();
$this->setQueue($rows);
$this->query = $query;
$this->params = $params;
}
public function getQuery(){

View file

@ -3,31 +3,37 @@
class Ticket_Queue_Handler{
private $pagination;
private $queue;
function __construct() {
$this->queue = new Ticket_Queue();
}
public function getTickets($input, $user_id){
$queue = new Ticket_Queue();
switch ($input){
case "all":
$queue->loadAllTickets();
$this->queue->loadAllTickets();
break;
case "all_open":
$queue->loadAllOpenTickets();
$this->queue->loadAllOpenTickets();
break;
case "archive":
$queue->loadAllClosedTickets();
$this->queue->loadAllClosedTickets();
break;
case "not_assigned":
$queue->loadAllNotAssignedTickets();
$this->queue->loadAllNotAssignedTickets();
break;
case "todo":
$queue->loadToDoTickets($user_id);
$this->queue->loadToDoTickets($user_id);
break;
case "create":
//set these with the createQueue function proceding the getTickets function
break;
default:
return "ERROR";
}
$this->pagination = new Pagination($queue->getQuery(),"lib",10,"Ticket",$queue->getParams());
$this->pagination = new Pagination($this->queue->getQuery(),"lib",2,"Ticket",$this->queue->getParams());
foreach( $this->pagination->getElements() as $element ){
$catInstance = new Ticket_Category();
$catInstance->load_With_TCategoryId($element->getTicket_Category());
@ -37,15 +43,16 @@ class Ticket_Queue_Handler{
$userInstance->load_With_TUserId($element->getAuthor());
$element->setAuthor($userInstance);
}
return $this->pagination->getElements();
return $this->pagination->getElements();
}
public static function CreateQueue($userid, $groupid, $what, $how, $who){
$queue = new Ticket_Queue();
$queue->createQueue($userid, $groupid, $what, $how, $who);
return $queue->getTickets();
public function getPagination(){
return $this->pagination;
}
public function createQueue($userid, $groupid, $what, $how, $who){
$this->queue->createQueue($userid, $groupid, $what, $how, $who);
}
}

View file

@ -24,6 +24,8 @@ function create_ticket(){
}catch (PDOException $e) {
//ERROR: LIB DB is not online!
print_r($e);
exit;
header("Location: index.php");
exit;
}
@ -37,7 +39,7 @@ function create_ticket(){
}else{
//ERROR: The form was not filled in correclty
header("Location: index.php?page=settings");
header("Location: index.php?page=create_ticket");
exit;
}
}else{

View file

@ -12,7 +12,25 @@ function show_queue(){
$user_id = $_SESSION['ticket_user']->getTUserId();
$queueArray = array();
$queue_handler = new Ticket_Queue_handler();
//Pagination Base Links
$result['pagination_base_link'] = "index.php?page=show_queue&get=".$result['queue_view'] ;
if(isset($_GET['get']) && ($_GET['get'] == "create") && isset($_GET['userid']) && isset($_GET['groupid']) && isset($_GET['what']) && isset($_GET['how']) && isset($_GET['who'])){
$userid = filter_var($_GET['userid'], FILTER_SANITIZE_NUMBER_INT);
$groupid = filter_var($_GET['groupid'], FILTER_SANITIZE_NUMBER_INT);
$what = filter_var($_GET['what'], FILTER_SANITIZE_STRING);
$how = filter_var($_GET['how'], FILTER_SANITIZE_STRING);
$who = filter_var($_GET['who'], FILTER_SANITIZE_STRING);
$queue_handler->CreateQueue($userid, $groupid, $what, $how, $who);
$result['pagination_base_link'] = "index.php?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
$result['prev_created_userid'] = $userid;
$result['prev_created_groupid'] = $groupid;
$result['prev_created_what'] = $what;
$result['prev_created_how'] = $how;
$result['prev_created_who'] = $who;
}
//if an action is set
if(isset($_POST['action'])){
switch($_POST['action']){
@ -32,19 +50,29 @@ function show_queue(){
$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'] = $queue_handler->CreateQueue($userid, $groupid, $what, $how, $who);
if ($result['ACTION_RESULT'] != "ERROR"){
$queueArray = $result['ACTION_RESULT'];
}
$queue_handler->CreateQueue($userid, $groupid, $what, $how, $who);
$result['pagination_base_link'] = "index.php?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
$result['prev_created_userid'] = $userid;
$result['prev_created_groupid'] = $groupid;
$result['prev_created_what'] = $what;
$result['prev_created_how'] = $how;
$result['prev_created_who'] = $who;
break;
}
}
$queueArray = $queue_handler->getTickets($result['queue_view'], $user_id);
//pagination
$result['links'] = $queue_handler->getPagination()->getLinks(5);
$result['lastPage'] = $queue_handler->getPagination()->getLast();
$result['currentPage'] = $queue_handler->getPagination()->getCurrent();
//if we didn't make a queue ourselves, then use the one specified by the get param
if( ! (isset($_POST['action']) && $_POST['action'] == "create_queue") ){
$queueArray = $queue_handler->getTickets($result['queue_view'], $user_id);
}
//if queue_view is a valid parameter value
if ($queueArray != "ERROR"){

View file

@ -44,6 +44,7 @@ function show_ticket(){
$result['ticket_title'] = $entire_ticket['ticket_obj']->getTitle();
$result['ticket_timestamp'] = $entire_ticket['ticket_obj']->getTimestamp();
$result['ticket_status'] = $entire_ticket['ticket_obj']->getStatus();
$result['ticket_author'] = $entire_ticket['ticket_obj']->getAuthor();
$result['ticket_prioritytext'] = $entire_ticket['ticket_obj']->getPriorityText();
$result['ticket_priorities'] = Ticket::getPriorityArray();
$result['ticket_priority'] = $entire_ticket['ticket_obj']->getPriority();

View file

@ -13,35 +13,35 @@
<legend>Tickets</legend>
<div class="alert alert-info">
<form id="create_queue" class="form-vertical" method="post" action="" style="margin:0px 0px 0px;">
<form id="create_queue" class="form-vertical" method="post" action="index.php?page=show_queue&get=create" style="margin:0px 0px 0px;">
Show
<select style="width: 136px;" name="what">
<option value="all">all</option>
<option value="waiting_for_support">waiting for support</option>
<option value="waiting_for_users">waiting for user</option>
<option value="closed">closed</option>
<option value="all" {if $prev_created_what eq "all"}selected="selected"{/if}>all</option>
<option value="waiting_for_support" {if $prev_created_what eq "waiting_for_support"}selected="selected"{/if}>waiting for support</option>
<option value="waiting_for_users" {if $prev_created_what eq "waiting_for_users"}selected="selected"{/if}>waiting for user</option>
<option value="closed" {if $prev_created_what eq "closed"}selected="selected"{/if}>closed</option>
</select>
tickets
<select style="width: 110px;" name="how">
<option value="assigned">assigned</option>
<option value="not_assigned">not assigned</option>
<option value="assigned" {if $prev_created_how eq "assigned"}selected="selected"{/if}>assigned</option>
<option value="not_assigned" {if $prev_created_how eq "not_assigned"}selected="selected"{/if}>not assigned</option>
</select>
to
<select style="width: 140px;" name="who" onchange="aimedforwhochanged(this.value);">
<option value="user">user</option>
<option value="support_group">support group</option>
<option value="user" {if $prev_created_who eq "user"}selected="selected"{/if}>user</option>
<option value="support_group" {if $prev_created_who eq "support_group"}selected="selected"{/if}>support group</option>
</select>
<span id="userList" style="display:inline;">
<span id="userList" {if $prev_created_who eq "user"}style="display:inline;"{else if $prev_created_who eq "support_group"}style="display:none;"{else}style="display:inline;"{/if}>
<select style="width: 140px;" name="userid">
{foreach from=$teamlist item=member}
<option value="{$member.tUserId}" {if $user_id eq $member.tUserId}selected="selected"{/if}>{$member.name}</option>
<option value="{$member.tUserId}" {if $prev_created_userid eq $member.tUserId}selected="selected"{else if $user_id eq $member.tUserId}selected="selected"{/if}>{$member.name}</option>
{/foreach}
</select>
</span>
<span id="supportGroupList" style="display:none;">
<span id="supportGroupList" {if $prev_created_who eq "user"}style="display:none;"{else if $prev_created_who eq "support_group"}style="display:inline;"{else}style="display:none;"{/if}>
<select style="width: 140px;" name="groupid">
{foreach from=$grouplist item=group}
<option value="{$group.sGroupId}">{$group.name}</option>
<option value="{$group.sGroupId}" {if $prev_created_groupid eq $group.sGroupId}selected="selected"{/if}>{$group.name}</option>
{/foreach}
</select>
</span>
@ -125,7 +125,17 @@
{/foreach}
</tbody>
</table>
</table>
<div style="width: 300px; margin:0px auto;">
<ul class="pagination">
<li><a href="{$pagination_base_link}&pagenum=1">&laquo;</a></li>
{foreach from=$links item=link}
<li {if $link == $currentPage}class="active"{/if}><a href="{$pagination_base_link}&pagenum={$link}">{$link}</a></li>
{/foreach}
<li><a href="{$pagination_base_link}&pagenum={$lastPage}">&raquo;</a></li>
</ul>
</div>
</div>
</div>
</div><!--/span-->

View file

@ -223,7 +223,7 @@
<ul class="dropdown-menu">
<li class="divider"></li>
{if isset($isMod) and $isMod eq "TRUE"}<li><a href="index.php?page=show_ticket_log&id={$ticket_tId}">Show Ticket Log</a></li>{/if}
<li><a href="index.php?page=createticket&user_id={$target_id}">Send Other Ticket</a></li>
<li><a href="index.php?page=createticket&user_id={$ticket_author}">Send Other Ticket</a></li>
<li class="divider"></li>
</ul>
</div>