history.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. /* Copyright (C) - 2013-2016 Jean-François FERRY <hello@librethic.io>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/ticket/history.php
  19. * \ingroup ticket
  20. * \brief History of ticket
  21. */
  22. require '../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT . '/ticket/class/actions_ticket.class.php';
  24. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticket.class.php';
  25. require_once DOL_DOCUMENT_ROOT . '/core/lib/ticket.lib.php';
  26. require_once DOL_DOCUMENT_ROOT . "/core/lib/company.lib.php";
  27. require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
  28. require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
  29. if (!class_exists('Contact')) {
  30. include DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
  31. }
  32. // Load translation files required by the page
  33. $langs->loadLangs(array('companies', 'other', 'ticket'));
  34. // Get parameters
  35. $id = GETPOST('id', 'int');
  36. $track_id = GETPOST('track_id', 'alpha', 3);
  37. $ref = GETPOST('ref', 'alpha');
  38. $action = GETPOST('action', 'aZ09');
  39. // Security check
  40. if (!$user->rights->ticket->read) {
  41. accessforbidden();
  42. }
  43. $extrafields = new ExtraFields($db);
  44. $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
  45. if (!$action) {
  46. $action = 'view';
  47. }
  48. $object = new Ticket($db);
  49. $object->fetch($id, $ref, $track_id);
  50. /*
  51. * Actions
  52. */
  53. $actionobject = new ActionsTicket($db);
  54. $actionobject->doActions($action, $object);
  55. /*
  56. * View
  57. */
  58. $help_url = 'FR:DocumentationModuleTicket';
  59. $page_title = $actionobject->getTitle($action);
  60. llxHeader('', $page_title, $help_url);
  61. $userstat = new User($db);
  62. $form = new Form($db);
  63. $formticket = new FormTicket($db);
  64. if ($action == 'view') {
  65. $res = $object->fetch($id, $ref, $track_id);
  66. if ($res > 0) {
  67. // restrict access for externals users
  68. if ($user->societe_id > 0 && ($object->fk_soc != $user->societe_id)
  69. ) {
  70. accessforbidden('', 0);
  71. }
  72. // or for unauthorized internals users
  73. if (!$user->societe_id && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) {
  74. accessforbidden('', 0);
  75. }
  76. if ($socid > 0) {
  77. $object->fetch_thirdparty();
  78. $head = societe_prepare_head($object->thirdparty);
  79. dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company');
  80. dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom');
  81. dol_fiche_end();
  82. }
  83. if (!$user->societe_id && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) {
  84. $object->next_prev_filter = "te.fk_user_assign = '" . $user->id . "'";
  85. } elseif ($user->societe_id > 0) {
  86. $object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'";
  87. }
  88. $head = ticket_prepare_head($object);
  89. dol_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticket');
  90. $morehtmlref ='<div class="refidno">';
  91. $morehtmlref.= $object->subject;
  92. // Author
  93. if ($object->fk_user_create > 0) {
  94. $morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
  95. $langs->load("users");
  96. $fuser = new User($db);
  97. $fuser->fetch($object->fk_user_create);
  98. $morehtmlref .= $fuser->getNomUrl(0);
  99. }
  100. if (!empty($object->origin_email)) {
  101. $morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
  102. $morehtmlref .= $object->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
  103. }
  104. $morehtmlref.='</div>';
  105. $linkback = '<a href="' . dol_buildpath('/ticket/list.php', 1) . '"><strong>' . $langs->trans("BackToList") . '</strong></a> ';
  106. dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref);
  107. dol_fiche_end();
  108. print '<div class="fichecenter">';
  109. // Logs list
  110. print load_fiche_titre($langs->trans('TicketHistory'), '', 'history@ticket');
  111. $actionobject->viewTimelineTicketLogs(true, $object);
  112. print '</div><!-- fichecenter -->';
  113. print '<br style="clear: both">';
  114. }
  115. } // End action view
  116. // End of page
  117. llxFooter('');
  118. $db->close();