Bootswatch, Summernote, and Captcheck mods for Mods for HESK (mods-for-hesk.com). In use at support.netsyms.com.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

print.php 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <?php
  2. /**
  3. *
  4. * This file is part of HESK - PHP Help Desk Software.
  5. *
  6. * (c) Copyright Klemen Stirn. All rights reserved.
  7. * https://www.hesk.com
  8. *
  9. * For the full copyright and license agreement information visit
  10. * https://www.hesk.com/eula.php
  11. *
  12. */
  13. define('IN_SCRIPT', 1);
  14. define('HESK_PATH', './');
  15. /* Get all the required files and functions */
  16. require(HESK_PATH . 'hesk_settings.inc.php');
  17. require(HESK_PATH . 'inc/common.inc.php');
  18. hesk_load_database_functions();
  19. hesk_session_start();
  20. // Do we have parameters in query string? If yes, store them in session and redirect
  21. if ( isset($_GET['track']) || isset($_GET['e']) )
  22. {
  23. $_SESSION['p_track'] = hesk_GET('track');
  24. $_SESSION['p_email'] = hesk_GET('e');
  25. header('Location: print.php');
  26. die();
  27. }
  28. /* Get the tracking ID */
  29. $trackingID = hesk_cleanID('p_track') or die("$hesklang[int_error]: $hesklang[no_trackID]");
  30. /* Connect to database */
  31. hesk_dbConnect();
  32. // Load custom fields
  33. require_once(HESK_PATH . 'inc/custom_fields.inc.php');
  34. // Perform additional checks for customers
  35. if (empty($_SESSION['id'])) {
  36. // Are we in maintenance mode?
  37. hesk_check_maintenance();
  38. // Verify email address match
  39. hesk_verifyEmailMatch($trackingID);
  40. $my_email = hesk_getCustomerEmail(0, 'p_email');
  41. hesk_verifyEmailMatch($trackingID, $my_email);
  42. }
  43. /* Clean ticket parameters from the session data, we don't need them anymore */
  44. hesk_cleanSessionVars( array('p_track', 'p_email') );
  45. /* Get ticket info */
  46. $res = hesk_dbQuery("SELECT `t1`.* , `ticketStatus`.`IsClosed` AS `isClosed`, `ticketStatus`.`Key` AS `statusKey`, `t2`.name AS `repliername`
  47. FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` AS `t1` LEFT JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` AS `t2` ON `t1`.`replierid` = `t2`.`id`
  48. INNER JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` AS `ticketStatus` ON `t1`.`status` = `ticketStatus`.`ID`
  49. WHERE `trackid`='" . hesk_dbEscape($trackingID) . "' LIMIT 1");
  50. if (hesk_dbNumRows($res) != 1) {
  51. hesk_error($hesklang['ticket_not_found']);
  52. }
  53. $ticket = hesk_dbFetchAssoc($res);
  54. // Demo mode
  55. if (defined('HESK_DEMO')) {
  56. $ticket['email'] = 'hidden@demo.com';
  57. $ticket['ip'] = '127.0.0.1';
  58. }
  59. /* Get category name and ID */
  60. $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` WHERE `id`='{$ticket['category']}' LIMIT 1");
  61. /* If this category has been deleted use the default category with ID 1 */
  62. if (hesk_dbNumRows($res) != 1) {
  63. $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` WHERE `id`='1' LIMIT 1");
  64. }
  65. $category = hesk_dbFetchAssoc($res);
  66. /* Get replies */
  67. $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "replies` WHERE `replyto`='{$ticket['id']}' ORDER BY `id` ASC");
  68. $replies = hesk_dbNumRows($res);
  69. $modsForHesk_settings = mfh_getSettings();
  70. ?>
  71. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  72. <html>
  73. <head>
  74. <title><?php echo $hesk_settings['hesk_title']; ?></title>
  75. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $hesklang['ENCODING']; ?>">
  76. <style type="text/css">
  77. body, table, td {
  78. color: black;
  79. font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  80. font-size: <?php echo $hesk_settings['print_font_size']; ?>px;
  81. }
  82. p {
  83. color: black;
  84. font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  85. font-size: <?php echo $hesk_settings['print_font_size']; ?>px;
  86. margin-top: 0;
  87. margin-bottom: 0;
  88. }
  89. table {
  90. border-collapse: collapse;
  91. }
  92. hr {
  93. border: 0;
  94. color: #9e9e9e;
  95. background-color: #9e9e9e;
  96. height: 1px;
  97. width: 100%;
  98. text-align: left;
  99. }
  100. </style>
  101. </head>
  102. <body onload="window.print()">
  103. <?php
  104. /* Ticket priority */
  105. switch ($ticket['priority']) {
  106. case 0:
  107. $ticket['priority'] = '<b>' . $hesklang['critical'] . '</b>';
  108. break;
  109. case 1:
  110. $ticket['priority'] = '<b>' . $hesklang['high'] . '</b>';
  111. break;
  112. case 2:
  113. $ticket['priority'] = $hesklang['medium'];
  114. break;
  115. default:
  116. $ticket['priority'] = $hesklang['low'];
  117. }
  118. /* Set last replier name */
  119. if ($ticket['lastreplier']) {
  120. if (empty($ticket['repliername'])) {
  121. $ticket['repliername'] = $hesklang['staff'];
  122. }
  123. } else {
  124. $ticket['repliername'] = $ticket['name'];
  125. }
  126. /* Other variables that need processing */
  127. $ticket['dt'] = hesk_date($ticket['dt'], true);
  128. $ticket['lastchange'] = hesk_date($ticket['lastchange'], true);
  129. $random = mt_rand(10000, 99999);
  130. // Print ticket head
  131. echo '
  132. <h3>' . $ticket['subject'] . '</h3>
  133. <hr/>
  134. <table border="1" bordercolor="#FFFFFF" cellspacing="0" cellpadding="2" width="100%">
  135. <tr>
  136. <td bgcolor="#EEE"><b>' . $hesklang['trackID'] . ':</b></td><td bgcolor="#DDD">' . $trackingID . '</td>
  137. <td bgcolor="#EEE"><b>' . $hesklang['ticket_status'] . ':</b></td><td bgcolor="#DDD">' . $hesklang[$ticket['statusKey']] . '</td>
  138. <td bgcolor="#EEE"><b>' . $hesklang['created_on'] . ':</b></td><td bgcolor="#DDD">' . $ticket['dt'] . '</td>
  139. </tr>
  140. <tr>
  141. <td bgcolor="#EEE"><b>' . $hesklang['last_update'] . ':</b></td><td bgcolor="#DDD">' . $ticket['lastchange'] . '</td>
  142. <td bgcolor="#EEE"><b>' . $hesklang['last_replier'] . ':</b></td><td bgcolor="#DDD">' . $ticket['repliername'] . '</td>
  143. <td bgcolor="#EEE"><b>' . $hesklang['category'] . ':</b></td><td bgcolor="#DDD">' . $category['name'] . '</td>
  144. </tr>
  145. ';
  146. // Show IP and time worked to staff
  147. if (!empty($_SESSION['id'])) {
  148. echo '
  149. <tr>
  150. <td bgcolor="#EEE"><b>' . $hesklang['ts'] . ':</b></td><td bgcolor="#DDD">' . $ticket['time_worked'] . '</td>
  151. <td bgcolor="#EEE"><b>' . $hesklang['ip'] . ':</b></td><td bgcolor="#DDD">' . $ticket['ip'] . '</td>
  152. <td bgcolor="#EEE"><b>' . $hesklang['email'] . ':</b></td><td bgcolor="#DDD">' . $ticket['email'] . '</td>
  153. </tr>
  154. ';
  155. }
  156. echo '<tr>';
  157. // Assigned to?
  158. if ($ticket['owner'] && !empty($_SESSION['id'])) {
  159. $ticket['owner'] = hesk_getOwnerName($ticket['owner']);
  160. echo '
  161. <td bgcolor="#EEE"><b>' . $hesklang['taso3'] . '</b></td>
  162. <td bgcolor="#DDD">' . $ticket['owner'] . '</td>
  163. ';
  164. }
  165. echo '
  166. <td bgcolor="#EEE"><b>' . $hesklang['name'] . ':</b></td>
  167. <td bgcolor="#DDD">' . $ticket['name'] . '</td>
  168. ';
  169. echo '</tr>';
  170. // Custom fields
  171. $num_cols = 0;
  172. echo '<tr>';
  173. foreach ($hesk_settings['custom_fields'] as $k => $v) {
  174. if (($v['use'] == 1 || (! empty($_SESSION['id']) && $v['use'] == 2)) && hesk_is_custom_field_in_category($k, $ticket['category'])) {
  175. if ($num_cols == 3) {
  176. echo '</tr><tr>';
  177. $num_cols = 0;
  178. }
  179. switch ($v['type']) {
  180. case 'date':
  181. $ticket[$k] = hesk_custom_date_display_format($ticket[$k], $v['value']['date_format']);
  182. break;
  183. }
  184. ?>
  185. <td bgcolor="#EEE"><b><?php echo $v['name']; ?>:</b></td>
  186. <td bgcolor="#DDD"><?php echo hesk_unhortenUrl($ticket[$k]); ?></td>
  187. <?php
  188. $num_cols++;
  189. }
  190. }
  191. // Close ticket head table
  192. echo '</table><br>';
  193. // Print initial ticket message
  194. if ($ticket['message'] != '') {
  195. $newMessage = hesk_unhortenUrl($ticket['message']);
  196. if ($ticket['html']) {
  197. $newMessage = hesk_html_entity_decode($newMessage);
  198. }
  199. echo '<p>' . $newMessage . '</p>';
  200. }
  201. // Print replies
  202. while ($reply = hesk_dbFetchAssoc($res)) {
  203. $reply['dt'] = hesk_date($reply['dt'], true);
  204. $theReply = hesk_unhortenUrl($reply['message']);
  205. if ($reply['html']) {
  206. $theReply = hesk_html_entity_decode($theReply);
  207. }
  208. echo '
  209. <hr />
  210. <table border="1" bordercolor="#FFFFFF" cellspacing="0" cellpadding="2" width="100%">
  211. <tr>
  212. <td bgcolor="#EEE"><b>' . $hesklang['date'] . ':</b></td><td bgcolor="#DDD">' . $reply['dt'] . '</td>
  213. <td bgcolor="#EEE"><b>' . $hesklang['name'] . ':</b></td><td bgcolor="#DDD">' . $reply['name'] . '</td>
  214. </tr>
  215. </table>
  216. <div class="message">' . $theReply . '</div>
  217. ';
  218. }
  219. // Print "end of ticket" message
  220. echo $hesklang['end_ticket'];
  221. ?>
  222. </body>
  223. </html>