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

Use up-to-date user/staff name instead of poster when displaying ticket thread

Join to staff/user tables to get current name when fetching thread entries.
parent 1fbec0a0
No related branches found
No related tags found
No related merge requests found
......@@ -291,7 +291,7 @@ class Ticket2PDF extends mPDF
$this->WriteCell($w/2, 7, Format::db_datetime($entry['created']), 'LTB', 0, 'L', true);
$this->SetFont('Arial', '', 10);
$this->WriteCell($w, 7, Format::truncate($entry['title'], 50), 'TB', 0, 'L', true);
$this->WriteCell($w/2, 7, $entry['poster'], 'TBR', 1, 'L', true);
$this->WriteCell($w/2, 7, $entry['name'] ?: $entry['poster'], 'TBR', 1, 'L', true);
$this->SetFont('');
$text= $entry['body'];
if($entry['attachments']
......
......@@ -569,16 +569,23 @@ class Staff extends AuthenticatedUser {
function delete() {
global $thisstaff;
if(!$thisstaff || !($id=$this->getId()) || $id==$thisstaff->getId())
if (!$thisstaff || $this->getId() == $thisstaff->getId())
return 0;
$sql='DELETE FROM '.STAFF_TABLE.' WHERE staff_id='.db_input($id).' LIMIT 1';
$sql='DELETE FROM '.STAFF_TABLE
.' WHERE staff_id = '.db_input($this->getId()).' LIMIT 1';
if(db_query($sql) && ($num=db_affected_rows())) {
// DO SOME HOUSE CLEANING
//Move remove any ticket assignments...TODO: send alert to Dept. manager?
db_query('UPDATE '.TICKET_TABLE.' SET staff_id=0 WHERE status=\'open\' AND staff_id='.db_input($id));
db_query('UPDATE '.TICKET_TABLE.' SET staff_id=0 WHERE staff_id='.db_input($this->getId()));
//Update the poster and clear staff_id on ticket thread table.
db_query('UPDATE '.TICKET_THREAD_TABLE
.' SET staff_id=0, poster= '.db_input($this->getName()->getOriginal())
.' WHERE staff_id='.db_input($this->getId()));
//Cleanup Team membership table.
db_query('DELETE FROM '.TEAM_MEMBER_TABLE.' WHERE staff_id='.db_input($id));
db_query('DELETE FROM '.TEAM_MEMBER_TABLE.' WHERE staff_id='.db_input($this->getId()));
}
Signal::send('model.deleted', $this);
......
......@@ -113,9 +113,17 @@ class Thread {
if(!$order || !in_array($order, array('DESC','ASC')))
$order='ASC';
$sql='SELECT thread.* '
$sql='SELECT thread.*
, COALESCE(user.name,
IF(staff.staff_id,
CONCAT_WS(" ", staff.firstname, staff.lastname),
NULL)) as name '
.' ,count(DISTINCT attach.attach_id) as attachments '
.' FROM '.TICKET_THREAD_TABLE.' thread '
.' LEFT JOIN '.USER_TABLE.' user
ON (thread.user_id=user.id) '
.' LEFT JOIN '.STAFF_TABLE.' staff
ON (thread.staff_id=staff.staff_id) '
.' LEFT JOIN '.TICKET_ATTACHMENT_TABLE.' attach
ON (thread.ticket_id=attach.ticket_id
AND thread.id=attach.ref_id) '
......
......@@ -351,7 +351,7 @@ $tcount+= $ticket->getNumNotes();
<span style="vertical-align:middle;" class="textra"></span>
<span style="vertical-align:middle;"
class="tmeta faded title"><?php
echo Format::htmlchars($entry['poster']); ?></span>
echo Format::htmlchars($entry['name'] ?: $entry['poster']); ?></span>
</span>
</div>
</th>
......
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