People can assign and unassign to a ticket
This commit is contained in:
parent
ff7db2a28c
commit
c0a45df44c
6 changed files with 131 additions and 21 deletions
|
@ -8,20 +8,35 @@ class Assigned{
|
||||||
////////////////////////////////////////////Functions////////////////////////////////////////////////////
|
////////////////////////////////////////////Functions////////////////////////////////////////////////////
|
||||||
|
|
||||||
//Assigns a ticket to a user or returns error message
|
//Assigns a ticket to a user or returns error message
|
||||||
public static function AssignTicket( $user_id, $ticket_id) {
|
public static function assignTicket( $user_id, $ticket_id) {
|
||||||
$dbl = new DBLayer("lib");
|
$dbl = new DBLayer("lib");
|
||||||
//check if ticket is already assigned, if so return "ALREADY ASSIGNED"
|
//check if ticket is already assigned, if so return "ALREADY ASSIGNED"
|
||||||
if(! Assigned::isAssigned($ticket_id)){
|
if(! Assigned::isAssigned($ticket_id)){
|
||||||
$assignation = new Assigned();
|
$assignation = new Assigned();
|
||||||
$assignation->set(array('User' => $user_id, 'Ticket' => $ticket_id));
|
$assignation->set(array('User' => $user_id, 'Ticket' => $ticket_id));
|
||||||
$assignation->create();
|
$assignation->create();
|
||||||
return "SUCCESS";
|
return "SUCCESS_ASSIGNED";
|
||||||
}else{
|
}else{
|
||||||
return "ALREADY_ASSIGNED";
|
return "ALREADY_ASSIGNED";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Unsign a ticket to a user or returns error message
|
||||||
|
public static function unAssignTicket( $user_id, $ticket_id) {
|
||||||
|
$dbl = new DBLayer("lib");
|
||||||
|
//check if ticket is really assigned to that user
|
||||||
|
if( Assigned::isAssigned($ticket_id, $user_id)){
|
||||||
|
$assignation = new Assigned();
|
||||||
|
$assignation->set(array('User' => $user_id, 'Ticket' => $ticket_id));
|
||||||
|
$assignation->delete();
|
||||||
|
return "SUCCESS_UNASSIGNED";
|
||||||
|
}else{
|
||||||
|
return "NOT_ASSIGNED";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Get the id of the user assigned to a ticket
|
// Get the id of the user assigned to a ticket
|
||||||
public static function getUserAssignedToTicket($ticket_id) {
|
public static function getUserAssignedToTicket($ticket_id) {
|
||||||
$dbl = new DBLayer("lib");
|
$dbl = new DBLayer("lib");
|
||||||
|
@ -33,10 +48,13 @@ class Assigned{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function isAssigned( $ticket_id ) {
|
public static function isAssigned( $ticket_id, $user_id = 0) {
|
||||||
$dbl = new DBLayer("lib");
|
$dbl = new DBLayer("lib");
|
||||||
//check if ticket is already assigned
|
//check if ticket is already assigned
|
||||||
if( $dbl->execute(" SELECT * FROM `assigned` WHERE `Ticket` = :ticket_id", array('ticket_id' => $ticket_id) )->rowCount() ){
|
|
||||||
|
if($user_id == 0 && $dbl->execute(" SELECT * FROM `assigned` WHERE `Ticket` = :ticket_id", array('ticket_id' => $ticket_id) )->rowCount() ){
|
||||||
|
return true;
|
||||||
|
}else if( $dbl->execute(" SELECT * FROM `assigned` WHERE `Ticket` = :ticket_id and `User` = :user_id", array('ticket_id' => $ticket_id, 'user_id' => $user_id) )->rowCount()){
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
|
@ -51,12 +69,12 @@ class Assigned{
|
||||||
//set values
|
//set values
|
||||||
public function set($values) {
|
public function set($values) {
|
||||||
$this->setUser($values['User']);
|
$this->setUser($values['User']);
|
||||||
$this->setGroup($values['Ticket']);
|
$this->setTicket($values['Ticket']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create() {
|
public function create() {
|
||||||
$dbl = new DBLayer("lib");
|
$dbl = new DBLayer("lib");
|
||||||
$query = "INSERT INTO `assigned' (`User`,`Ticket`) VALUES (:user, :ticket)";
|
$query = "INSERT INTO `assigned` (`User`,`Ticket`) VALUES (:user, :ticket)";
|
||||||
$values = Array('user' => $this->getUser(), 'ticket' => $this->getTicket());
|
$values = Array('user' => $this->getUser(), 'ticket' => $this->getTicket());
|
||||||
$dbl->execute($query, $values);
|
$dbl->execute($query, $values);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +83,7 @@ class Assigned{
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$dbl = new DBLayer("lib");
|
$dbl = new DBLayer("lib");
|
||||||
$query = "DELETE FROM `assigned` WHERE `User` = :user_id and `Ticket` = :ticket_id";
|
$query = "DELETE FROM `assigned` WHERE `User` = :user_id and `Ticket` = :ticket_id";
|
||||||
$values = array('user_id' => $this->getUser() ,'ticket_id' => $this->getGroup());
|
$values = array('user_id' => $this->getUser() ,'ticket_id' => $this->getTicket());
|
||||||
$dbl->execute($query, $values);
|
$dbl->execute($query, $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,20 @@ class Ticket{
|
||||||
|
|
||||||
////////////////////////////////////////////Functions////////////////////////////////////////////////////
|
////////////////////////////////////////////Functions////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/*FUNCTION: ticketExists
|
||||||
|
* returns true if ticket exists
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function ticketExists($id) {
|
||||||
|
$dbl = new DBLayer("lib");
|
||||||
|
//check if ticket is already assigned
|
||||||
|
if( $dbl->execute(" SELECT * FROM `ticket` WHERE `TId` = :ticket_id", array('ticket_id' => $id) )->rowCount() ){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*FUNCTION: getStatusArray
|
/*FUNCTION: getStatusArray
|
||||||
* returns all possible statusses
|
* returns all possible statusses
|
||||||
*
|
*
|
||||||
|
@ -130,7 +144,23 @@ class Ticket{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//returns SUCCESS_ASSIGNED, TICKET_NOT_EXISTING or ALREADY_ASSIGNED
|
||||||
|
public static function assignTicket($user_id, $ticket_id){
|
||||||
|
if(self::ticketExists($ticket_id)){
|
||||||
|
return Assigned::assignTicket($user_id, $ticket_id);
|
||||||
|
}else{
|
||||||
|
return "TICKET_NOT_EXISTING";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//returns SUCCESS_UNASSIGNED, TICKET_NOT_EXISTING or NOT_ASSIGNED
|
||||||
|
public static function unAssignTicket($user_id, $ticket_id){
|
||||||
|
if(self::ticketExists($ticket_id)){
|
||||||
|
return Assigned::unAssignTicket($user_id, $ticket_id);
|
||||||
|
}else{
|
||||||
|
return "TICKET_NOT_EXISTING";
|
||||||
|
}
|
||||||
|
}
|
||||||
////////////////////////////////////////////Methods////////////////////////////////////////////////////
|
////////////////////////////////////////////Methods////////////////////////////////////////////////////
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,12 @@ t_send = "Send reply"
|
||||||
[show_user]
|
[show_user]
|
||||||
|
|
||||||
[show_queue]
|
[show_queue]
|
||||||
not_assigned = "None"
|
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!"
|
||||||
|
|
||||||
[show_sgroup]
|
[show_sgroup]
|
||||||
add_to_group_success = "The user has been added to the group!"
|
add_to_group_success = "The user has been added to the group!"
|
||||||
|
|
|
@ -30,7 +30,7 @@ t_send = "Envoyer la reponse"
|
||||||
[show_user]
|
[show_user]
|
||||||
|
|
||||||
[show_queue]
|
[show_queue]
|
||||||
not_assigned = "Ne pas"
|
not_assigned = "Libre"
|
||||||
|
|
||||||
[show_sgroup]
|
[show_sgroup]
|
||||||
add_to_group_success = "ce user est ajoute sur la groupe!"
|
add_to_group_success = "ce user est ajoute sur la groupe!"
|
||||||
|
|
|
@ -4,24 +4,43 @@ function show_queue(){
|
||||||
|
|
||||||
//if logged in & queue id is given
|
//if logged in & queue id is given
|
||||||
if(WebUsers::isLoggedIn() && isset($_GET['get'])){
|
if(WebUsers::isLoggedIn() && isset($_GET['get'])){
|
||||||
|
|
||||||
if( Ticket_User::isMod($_SESSION['ticket_user'])){
|
if( Ticket_User::isMod($_SESSION['ticket_user'])){
|
||||||
$result['queue_action'] = filter_var($_GET['get'], FILTER_SANITIZE_STRING);
|
$result['queue_view'] = filter_var($_GET['get'], FILTER_SANITIZE_STRING);
|
||||||
|
|
||||||
$queueArray = Ticket_Queue_Handler::getTickets($result['queue_action']);
|
$queueArray = Ticket_Queue_Handler::getTickets($result['queue_view']);
|
||||||
|
|
||||||
|
//if queue_view is a valid parameter value
|
||||||
if ($queueArray != "ERROR"){
|
if ($queueArray != "ERROR"){
|
||||||
$result['tickets'] = Gui_Elements::make_table($queueArray, Array("getTId","getTitle","getTimestamp","getAuthor()->getExternId","getTicket_Category()->getName","getStatus","getStatusText","getAssigned"), Array("tId","title","timestamp","authorExtern","category","status","statusText","assigned"));
|
|
||||||
|
|
||||||
|
$user_id = $_SESSION['ticket_user']->getTUserId();
|
||||||
|
|
||||||
|
if(isset($_POST['action'])){
|
||||||
|
switch($_POST['action']){
|
||||||
|
case "assignTicket":
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result['tickets'] = Gui_Elements::make_table($queueArray, Array("getTId","getTitle","getTimestamp","getAuthor()->getExternId","getTicket_Category()->getName","getStatus","getStatusText","getAssigned"), Array("tId","title","timestamp","authorExtern","category","status","statusText","assigned"));
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach( $result['tickets'] as $ticket){
|
foreach( $result['tickets'] as $ticket){
|
||||||
$result['tickets'][$i]['author'] = WebUsers::getUsername($ticket['authorExtern']);
|
$result['tickets'][$i]['author'] = WebUsers::getUsername($ticket['authorExtern']);
|
||||||
$result['tickets'][$i]['assignedText'] = WebUsers::getUsername($ticket['assigned']);
|
$result['tickets'][$i]['assignedText'] = WebUsers::getUsername($ticket['assigned']);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
if(Ticket_User::isMod($_SESSION['ticket_user'])){
|
$result['user_id'] = $_SESSION['ticket_user']->getTUserId();
|
||||||
$result['isMod'] = "TRUE";
|
|
||||||
}
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
//ERROR: Doesn't exist!
|
//ERROR: Doesn't exist!
|
||||||
$_SESSION['error_code'] = "404";
|
$_SESSION['error_code'] = "404";
|
||||||
header("Location: index.php?page=error");
|
header("Location: index.php?page=error");
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="row-fluid sortable ui-sortable">
|
<div class="row-fluid sortable ui-sortable">
|
||||||
<div class="box span9">
|
<div class="box span9">
|
||||||
<div class="box-header well" data-original-title="">
|
<div class="box-header well" data-original-title="">
|
||||||
<h2><i class="icon-tag"></i> Ticket Queue {$queue_action}</h2>
|
<h2><i class="icon-tag"></i> Ticket Queue {$queue_view}</h2>
|
||||||
<div class="box-icon">
|
<div class="box-icon">
|
||||||
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
|
<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
|
||||||
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
|
<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
|
||||||
|
@ -11,6 +11,29 @@
|
||||||
<div class="box-content">
|
<div class="box-content">
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<legend>Tickets</legend>
|
<legend>Tickets</legend>
|
||||||
|
|
||||||
|
{if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_ASSIGNED"}
|
||||||
|
<div class="alert alert-success">
|
||||||
|
{$success_assigned}
|
||||||
|
</div>
|
||||||
|
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "SUCCESS_UNASSIGNED"}
|
||||||
|
<div class="alert alert-success">
|
||||||
|
{$success_unassigned}
|
||||||
|
</div>
|
||||||
|
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "TICKET_NOT_EXISTING"}
|
||||||
|
<div class="alert alert-error">
|
||||||
|
{$ticket_not_existing}
|
||||||
|
</div>
|
||||||
|
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "ALREADY_ASSIGNED"}
|
||||||
|
<div class="alert alert-error">
|
||||||
|
{$already_assigned}
|
||||||
|
</div>
|
||||||
|
{else if isset($ACTION_RESULT) and $ACTION_RESULT eq "NOT_ASSIGNED"}
|
||||||
|
<div class="alert alert-error">
|
||||||
|
{$not_assigned}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<table class="table table-striped table-bordered bootstrap-datatable datatable">
|
<table class="table table-striped table-bordered bootstrap-datatable datatable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -20,6 +43,7 @@
|
||||||
<th>Timestamp</th>
|
<th>Timestamp</th>
|
||||||
<th>Category</th>
|
<th>Category</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -27,11 +51,25 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{$ticket.tId}</td>
|
<td>{$ticket.tId}</td>
|
||||||
<td><a href ="index.php?page=show_ticket&id={$ticket.tId}">{$ticket.title}</a></td>
|
<td><a href ="index.php?page=show_ticket&id={$ticket.tId}">{$ticket.title}</a></td>
|
||||||
<td>{if $ticket.assignedText neq ""} <a href="index.php?page=show_user&id={$ticket.assigned}">{$ticket.assignedText}</a> {else}<i> {$not_assigned}</i> {/if}</td>
|
<td>{if $ticket.assignedText neq ""} <a href="index.php?page=show_user&id={$ticket.assigned}">{$ticket.assignedText} {else}<i> {$not_assigned}</i> {/if}</td>
|
||||||
<td class="center"><i>{$ticket.timestamp}</i></td>
|
<td class="center"><i>{$ticket.timestamp}</i></td>
|
||||||
<td class="center">{$ticket.category}</td>
|
<td class="center">{$ticket.category}</td>
|
||||||
|
|
||||||
<td class="center"><span class="label {if $ticket.status eq 0}label-success{else if $ticket.status eq 1}label-warning{else if $ticket.status eq 2}label-important{/if}">{if $ticket.status eq 0} <i class="icon-exclamation-sign icon-white"></i>{/if} {$ticket.statusText}</span></td>
|
<td class="center"><span class="label {if $ticket.status eq 0}label-success{else if $ticket.status eq 1}label-warning{else if $ticket.status eq 2}label-important{/if}">{if $ticket.status eq 0} <i class="icon-exclamation-sign icon-white"></i>{/if} {$ticket.statusText}</span></td>
|
||||||
|
<td>
|
||||||
|
{if $ticket.assigned eq 0}
|
||||||
|
<form id="assign_ticket" class="form-vertical" method="post" action="" style="margin:0px 0px 0px;">
|
||||||
|
<input type="hidden" name="ticket_id" value="{$ticket.tId}">
|
||||||
|
<input type="hidden" name="action" value="assignTicket">
|
||||||
|
<button type="submit" class="btn btn-primary" ><i class="icon-flag icon-white"></i> Assign Ticket</button>
|
||||||
|
</form>
|
||||||
|
{else if $ticket.assigned eq 1}
|
||||||
|
<form id="assign_ticket" class="form-vertical" method="post" action="" style="margin:0px 0px 0px;">
|
||||||
|
<input type="hidden" name="ticket_id" value="{$ticket.tId}">
|
||||||
|
<input type="hidden" name="action" value="unAssignTicket">
|
||||||
|
<button type="submit" class="btn btn-warning" ><i class="icon-remove icon-white"></i> Remove Assign</button>
|
||||||
|
</form>
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue