I think I'm done refactoring the queues
This commit is contained in:
parent
c38605f74c
commit
2d863042e5
8 changed files with 92 additions and 45 deletions
|
@ -86,7 +86,8 @@ class Ticket{
|
||||||
public static function create_Ticket( $title, $content, $category, $author, $real_author) {
|
public static function create_Ticket( $title, $content, $category, $author, $real_author) {
|
||||||
|
|
||||||
$ticket = new Ticket();
|
$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->create();
|
||||||
$ticket_id = $ticket->getTId();
|
$ticket_id = $ticket->getTId();
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ class Ticket_Queue{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createQueue($userid, $groupid, $what, $how, $who){
|
public function createQueue($userid, $groupid, $what, $how, $who){
|
||||||
$dbl = new DBLayer("lib");
|
|
||||||
|
|
||||||
if($who == "user"){
|
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";
|
$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"){
|
}else if ($who == "support_group"){
|
||||||
$params = array('id' => $groupid);
|
$params = array('id' => $groupid);
|
||||||
}
|
}
|
||||||
$statement = $dbl->execute($query, $params);
|
$this->query = $query;
|
||||||
$rows = $statement->fetchAll();
|
$this->params = $params;
|
||||||
$this->setQueue($rows);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQuery(){
|
public function getQuery(){
|
||||||
|
|
|
@ -3,31 +3,37 @@
|
||||||
class Ticket_Queue_Handler{
|
class Ticket_Queue_Handler{
|
||||||
|
|
||||||
private $pagination;
|
private $pagination;
|
||||||
|
private $queue;
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
$this->queue = new Ticket_Queue();
|
||||||
|
}
|
||||||
|
|
||||||
public function getTickets($input, $user_id){
|
public function getTickets($input, $user_id){
|
||||||
|
|
||||||
$queue = new Ticket_Queue();
|
|
||||||
|
|
||||||
switch ($input){
|
switch ($input){
|
||||||
case "all":
|
case "all":
|
||||||
$queue->loadAllTickets();
|
$this->queue->loadAllTickets();
|
||||||
break;
|
break;
|
||||||
case "all_open":
|
case "all_open":
|
||||||
$queue->loadAllOpenTickets();
|
$this->queue->loadAllOpenTickets();
|
||||||
break;
|
break;
|
||||||
case "archive":
|
case "archive":
|
||||||
$queue->loadAllClosedTickets();
|
$this->queue->loadAllClosedTickets();
|
||||||
break;
|
break;
|
||||||
case "not_assigned":
|
case "not_assigned":
|
||||||
$queue->loadAllNotAssignedTickets();
|
$this->queue->loadAllNotAssignedTickets();
|
||||||
break;
|
break;
|
||||||
case "todo":
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
return "ERROR";
|
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 ){
|
foreach( $this->pagination->getElements() as $element ){
|
||||||
$catInstance = new Ticket_Category();
|
$catInstance = new Ticket_Category();
|
||||||
$catInstance->load_With_TCategoryId($element->getTicket_Category());
|
$catInstance->load_With_TCategoryId($element->getTicket_Category());
|
||||||
|
@ -39,13 +45,14 @@ class Ticket_Queue_Handler{
|
||||||
}
|
}
|
||||||
return $this->pagination->getElements();
|
return $this->pagination->getElements();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function CreateQueue($userid, $groupid, $what, $how, $who){
|
public function getPagination(){
|
||||||
$queue = new Ticket_Queue();
|
return $this->pagination;
|
||||||
$queue->createQueue($userid, $groupid, $what, $how, $who);
|
|
||||||
return $queue->getTickets();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createQueue($userid, $groupid, $what, $how, $who){
|
||||||
|
$this->queue->createQueue($userid, $groupid, $what, $how, $who);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,6 +24,8 @@ function create_ticket(){
|
||||||
|
|
||||||
}catch (PDOException $e) {
|
}catch (PDOException $e) {
|
||||||
//ERROR: LIB DB is not online!
|
//ERROR: LIB DB is not online!
|
||||||
|
print_r($e);
|
||||||
|
exit;
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +39,7 @@ function create_ticket(){
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
//ERROR: The form was not filled in correclty
|
//ERROR: The form was not filled in correclty
|
||||||
header("Location: index.php?page=settings");
|
header("Location: index.php?page=create_ticket");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -13,6 +13,24 @@ function show_queue(){
|
||||||
$queueArray = array();
|
$queueArray = array();
|
||||||
$queue_handler = new Ticket_Queue_handler();
|
$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 an action is set
|
||||||
if(isset($_POST['action'])){
|
if(isset($_POST['action'])){
|
||||||
switch($_POST['action']){
|
switch($_POST['action']){
|
||||||
|
@ -32,19 +50,29 @@ function show_queue(){
|
||||||
$what = filter_var($_POST['what'], FILTER_SANITIZE_STRING);
|
$what = filter_var($_POST['what'], FILTER_SANITIZE_STRING);
|
||||||
$how = filter_var($_POST['how'], FILTER_SANITIZE_STRING);
|
$how = filter_var($_POST['how'], FILTER_SANITIZE_STRING);
|
||||||
$who = filter_var($_POST['who'], FILTER_SANITIZE_STRING);
|
$who = filter_var($_POST['who'], FILTER_SANITIZE_STRING);
|
||||||
$result['ACTION_RESULT'] = $queue_handler->CreateQueue($userid, $groupid, $what, $how, $who);
|
$queue_handler->CreateQueue($userid, $groupid, $what, $how, $who);
|
||||||
if ($result['ACTION_RESULT'] != "ERROR"){
|
$result['pagination_base_link'] = "index.php?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
|
||||||
$queueArray = $result['ACTION_RESULT'];
|
$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;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//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);
|
$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 queue_view is a valid parameter value
|
//if queue_view is a valid parameter value
|
||||||
if ($queueArray != "ERROR"){
|
if ($queueArray != "ERROR"){
|
||||||
|
|
|
@ -44,6 +44,7 @@ function show_ticket(){
|
||||||
$result['ticket_title'] = $entire_ticket['ticket_obj']->getTitle();
|
$result['ticket_title'] = $entire_ticket['ticket_obj']->getTitle();
|
||||||
$result['ticket_timestamp'] = $entire_ticket['ticket_obj']->getTimestamp();
|
$result['ticket_timestamp'] = $entire_ticket['ticket_obj']->getTimestamp();
|
||||||
$result['ticket_status'] = $entire_ticket['ticket_obj']->getStatus();
|
$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_prioritytext'] = $entire_ticket['ticket_obj']->getPriorityText();
|
||||||
$result['ticket_priorities'] = Ticket::getPriorityArray();
|
$result['ticket_priorities'] = Ticket::getPriorityArray();
|
||||||
$result['ticket_priority'] = $entire_ticket['ticket_obj']->getPriority();
|
$result['ticket_priority'] = $entire_ticket['ticket_obj']->getPriority();
|
||||||
|
|
|
@ -13,35 +13,35 @@
|
||||||
<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;">
|
<form id="create_queue" class="form-vertical" method="post" action="index.php?page=show_queue&get=create" 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" {if $prev_created_what eq "all"}selected="selected"{/if}>all</option>
|
||||||
<option value="waiting_for_support">waiting for support</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">waiting for user</option>
|
<option value="waiting_for_users" {if $prev_created_what eq "waiting_for_users"}selected="selected"{/if}>waiting for user</option>
|
||||||
<option value="closed">closed</option>
|
<option value="closed" {if $prev_created_what eq "closed"}selected="selected"{/if}>closed</option>
|
||||||
</select>
|
</select>
|
||||||
tickets
|
tickets
|
||||||
<select style="width: 110px;" name="how">
|
<select style="width: 110px;" name="how">
|
||||||
<option value="assigned">assigned</option>
|
<option value="assigned" {if $prev_created_how eq "assigned"}selected="selected"{/if}>assigned</option>
|
||||||
<option value="not_assigned">not assigned</option>
|
<option value="not_assigned" {if $prev_created_how eq "not_assigned"}selected="selected"{/if}>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);">
|
||||||
<option value="user">user</option>
|
<option value="user" {if $prev_created_who eq "user"}selected="selected"{/if}>user</option>
|
||||||
<option value="support_group">support group</option>
|
<option value="support_group" {if $prev_created_who eq "support_group"}selected="selected"{/if}>support group</option>
|
||||||
</select>
|
</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">
|
<select style="width: 140px;" name="userid">
|
||||||
{foreach from=$teamlist item=member}
|
{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}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</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">
|
<select style="width: 140px;" name="groupid">
|
||||||
{foreach from=$grouplist item=group}
|
{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}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</span>
|
||||||
|
@ -126,6 +126,16 @@
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<div style="width: 300px; margin:0px auto;">
|
||||||
|
<ul class="pagination">
|
||||||
|
<li><a href="{$pagination_base_link}&pagenum=1">«</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}">»</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div><!--/span-->
|
</div><!--/span-->
|
||||||
|
|
|
@ -223,7 +223,7 @@
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li class="divider"></li>
|
<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}
|
{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>
|
<li class="divider"></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue