salix/print/templates/email/osticket-report/sql/tickets.sql

29 lines
1.1 KiB
MySQL
Raw Normal View History

2021-04-27 08:29:09 +00:00
SELECT * FROM (
SELECT DISTINCT ot.ticket_id,
ot.number,
ot.created,
ot.closed,
otu.name AS author,
otsf.username AS assigned,
otc.subject,
ote.body AS description,
oter.body AS resolution
FROM ost_ticket ot
JOIN ost_department od ON od.id = ot.dept_id
2021-04-27 08:29:09 +00:00
JOIN ost_ticket__cdata otc ON ot.ticket_id = otc.ticket_id
JOIN ost_ticket_status ots ON ot.status_id = ots.id
JOIN ost_user otu ON ot.user_id = otu.id
LEFT JOIN ost_staff otsf ON ot.staff_id = otsf.staff_id
JOIN ost_thread oth ON ot.ticket_id = oth.object_id
AND oth.object_type = 'T'
LEFT JOIN ost_thread_entry ote ON oth.id = ote.thread_id
AND ote.type = 'M'
LEFT JOIN ost_thread_entry oter ON oth.id = oter.thread_id
AND oter.type = 'R'
2021-10-04 07:07:47 +00:00
WHERE ot.ticket_pid IS NULL
AND ot.closed BETWEEN ? AND ?
AND ots.state = 'closed'
AND od.code = 'IT'
2021-04-27 08:29:09 +00:00
ORDER BY oter.created DESC
) ot GROUP BY ot.ticket_id
ORDER BY ot.assigned