Skip to content
Snippets Groups Projects
Commit c93f5e74 authored by Peter Rotich's avatar Peter Rotich Committed by Peter Rotich
Browse files

List all tickets the user has access to including collaborator tickets

Drop join to the user table
Use internal ticket id instead of ticket number
parent aa6eb26f
No related branches found
No related tags found
No related merge requests found
......@@ -18,8 +18,8 @@ if(isset($_REQUEST['status'])) { //Query string status has nothing to do with th
$status='open'; //Defaulting to open
}
$sortOptions=array('id'=>'ticketID', 'name'=>'user.name', 'subject'=>'subject.value',
'email'=>'email.address', 'status'=>'ticket.status', 'dept'=>'dept_name','date'=>'ticket.created');
$sortOptions=array('id'=>'ticketID', 'subject'=>'subject.value',
'status'=>'ticket.status', 'dept'=>'dept_name','date'=>'ticket.created');
$orderWays=array('DESC'=>'DESC','ASC'=>'ASC');
//Sorting options...
$order_by=$order=null;
......@@ -39,8 +39,7 @@ $x=$sort.'_sort';
$$x=' class="'.strtolower($order).'" ';
$qselect='SELECT ticket.ticket_id,ticket.ticketID,ticket.dept_id,isanswered, '
.'dept.ispublic, subject.value as subject, '
.'user.name, email.address as email, '
.'dept.ispublic, subject.value as subject,'
.'dept_name,ticket. status, ticket.source, ticket.created ';
$dynfields='(SELECT entry.object_id, value FROM '.FORM_ANSWER_TABLE.' ans '.
......@@ -51,11 +50,13 @@ $subject_sql = sprintf($dynfields, 'subject');
$qfrom='FROM '.TICKET_TABLE.' ticket '
.' LEFT JOIN '.DEPT_TABLE.' dept ON (ticket.dept_id=dept.dept_id) '
.' LEFT JOIN '.USER_TABLE.' user ON user.id = ticket.user_id'
.' LEFT JOIN '.USER_EMAIL_TABLE.' email ON user.id = email.user_id'
.' LEFT JOIN '.TICKET_COLLABORATOR_TABLE.' collab
ON (collab.ticket_id = ticket.ticket_id
AND collab.user_id ='.$thisclient->getId().' )'
.' LEFT JOIN '.$subject_sql.' subject ON ticket.ticket_id = subject.object_id ';
$qwhere =' WHERE email.address='.db_input($thisclient->getEmail());
$qwhere = sprintf(' WHERE ( ticket.user_id=%d OR collab.user_id=%d )',
$thisclient->getId(), $thisclient->getId());
if($status){
$qwhere.=' AND ticket.status='.db_input($status);
......@@ -161,15 +162,15 @@ $negorder=$order=='DESC'?'ASC':'DESC'; //Negate the sorting
if($row['phone_ext'])
$phone.=' '.$row['phone_ext'];
?>
<tr id="<?php echo $row['ticketID']; ?>">
<tr id="<?php echo $row['ticket_id']; ?>">
<td class="centered">
<a class="Icon <?php echo strtolower($row['source']); ?>Ticket" title="<?php echo $row['email']; ?>"
href="tickets.php?id=<?php echo $row['ticketID']; ?>"><?php echo $ticketID; ?></a>
href="tickets.php?id=<?php echo $row['ticket_id']; ?>"><?php echo $ticketID; ?></a>
</td>
<td>&nbsp;<?php echo Format::db_date($row['created']); ?></td>
<td>&nbsp;<?php echo ucfirst($row['status']); ?></td>
<td>
<a href="tickets.php?id=<?php echo $row['ticketID']; ?>"><?php echo $subject; ?></a>
<a href="tickets.php?id=<?php echo $row['ticket_id']; ?>"><?php echo $subject; ?></a>
</td>
<td>&nbsp;<?php echo Format::truncate($dept,30); ?></td>
<td><?php echo $phone; ?></td>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment