People can assign and unassign to a ticket
This commit is contained in:
parent
3e049aa0c8
commit
e50cfa46a1
6 changed files with 131 additions and 21 deletions
|
@ -8,20 +8,35 @@ class Assigned{
|
|||
////////////////////////////////////////////Functions////////////////////////////////////////////////////
|
||||
|
||||
//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");
|
||||
//check if ticket is already assigned, if so return "ALREADY ASSIGNED"
|
||||
if(! Assigned::isAssigned($ticket_id)){
|
||||
$assignation = new Assigned();
|
||||
$assignation->set(array('User' => $user_id, 'Ticket' => $ticket_id));
|
||||
$assignation->create();
|
||||
return "SUCCESS";
|
||||
return "SUCCESS_ASSIGNED";
|
||||
}else{
|
||||
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
|
||||
public static function getUserAssignedToTicket($ticket_id) {
|
||||
$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");
|
||||
//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;
|
||||
}else{
|
||||
return false;
|
||||
|
@ -51,12 +69,12 @@ class Assigned{
|
|||
//set values
|
||||
public function set($values) {
|
||||
$this->setUser($values['User']);
|
||||
$this->setGroup($values['Ticket']);
|
||||
$this->setTicket($values['Ticket']);
|
||||
}
|
||||
|
||||
public function create() {
|
||||
$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());
|
||||
$dbl->execute($query, $values);
|
||||
}
|
||||
|
@ -65,7 +83,7 @@ class Assigned{
|
|||
public function delete() {
|
||||
$dbl = new DBLayer("lib");
|
||||
$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);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,21 @@ class Ticket{
|
|||
private $author;
|
||||
private $priority;
|
||||
|
||||
////////////////////////////////////////////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
|
||||
* 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////////////////////////////////////////////////////
|
||||
public function __construct() {
|
||||
|
||||
|
|
|
@ -30,7 +30,12 @@ t_send = "Send reply"
|
|||
[show_user]
|
||||
|
||||
[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]
|
||||
add_to_group_success = "The user has been added to the group!"
|
||||
|
|
|
@ -30,7 +30,7 @@ t_send = "Envoyer la reponse"
|
|||
[show_user]
|
||||
|
||||
[show_queue]
|
||||
not_assigned = "Ne pas"
|
||||
not_assigned = "Libre"
|
||||
|
||||
[show_sgroup]
|
||||
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(WebUsers::isLoggedIn() && isset($_GET['get'])){
|
||||
|
||||
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']);
|
||||
if ($queueArray != "ERROR"){
|
||||
$queueArray = Ticket_Queue_Handler::getTickets($result['queue_view']);
|
||||
|
||||
//if queue_view is a valid parameter value
|
||||
if ($queueArray != "ERROR"){
|
||||
|
||||
$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;
|
||||
foreach( $result['tickets'] as $ticket){
|
||||
$result['tickets'][$i]['author'] = WebUsers::getUsername($ticket['authorExtern']);
|
||||
$result['tickets'][$i]['assignedText'] = WebUsers::getUsername($ticket['assigned']);
|
||||
$i++;
|
||||
}
|
||||
if(Ticket_User::isMod($_SESSION['ticket_user'])){
|
||||
$result['isMod'] = "TRUE";
|
||||
}
|
||||
$result['user_id'] = $_SESSION['ticket_user']->getTUserId();
|
||||
return $result;
|
||||
}else{
|
||||
|
||||
}else{
|
||||
|
||||
//ERROR: Doesn't exist!
|
||||
$_SESSION['error_code'] = "404";
|
||||
header("Location: index.php?page=error");
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="row-fluid sortable ui-sortable">
|
||||
<div class="box span9">
|
||||
<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">
|
||||
<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>
|
||||
|
@ -11,6 +11,29 @@
|
|||
<div class="box-content">
|
||||
<div class="row-fluid">
|
||||
<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">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -20,6 +43,7 @@
|
|||
<th>Timestamp</th>
|
||||
<th>Category</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -27,11 +51,25 @@
|
|||
<tr>
|
||||
<td>{$ticket.tId}</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">{$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>
|
||||
{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>
|
||||
{/foreach}
|
||||
|
||||
|
|
Loading…
Reference in a new issue