list.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. <?php
  2. /* Copyright (C) 2013-2016 Jean-François FERRY <jfefe@aternatik.fr>
  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 <https://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/public/ticket/list.php
  19. * \ingroup ticket
  20. * \brief Public file to list tickets
  21. */
  22. if (!defined('NOCSRFCHECK')) {
  23. define('NOCSRFCHECK', '1');
  24. }
  25. // Do not check anti CSRF attack test
  26. if (!defined('NOREQUIREMENU')) {
  27. define('NOREQUIREMENU', '1');
  28. }
  29. // If there is no need to load and show top and left menu
  30. if (!defined("NOLOGIN")) {
  31. define("NOLOGIN", '1');
  32. }
  33. if (!defined('NOIPCHECK')) {
  34. define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
  35. }
  36. if (!defined('NOBROWSERNOTIF')) {
  37. define('NOBROWSERNOTIF', '1');
  38. }
  39. // If this page is public (can be called outside logged session)
  40. require '../../main.inc.php';
  41. require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php';
  42. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php';
  43. require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
  44. require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
  45. require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
  46. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  47. require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
  48. // Load translation files required by the page
  49. $langs->loadLangs(array("companies", "other", "ticket"));
  50. // Get parameters
  51. $track_id = GETPOST('track_id', 'alpha');
  52. $action = GETPOST('action', 'aZ09');
  53. $email = strtolower(GETPOST('email', 'alpha'));
  54. if (GETPOST('btn_view_ticket_list')) {
  55. unset($_SESSION['track_id_customer']);
  56. unset($_SESSION['email_customer']);
  57. }
  58. if (isset($_SESSION['track_id_customer'])) {
  59. $track_id = $_SESSION['track_id_customer'];
  60. }
  61. if (isset($_SESSION['email_customer'])) {
  62. $email = strtolower($_SESSION['email_customer']);
  63. }
  64. $object = new Ticket($db);
  65. /*
  66. * Actions
  67. */
  68. if ($action == "view_ticketlist") {
  69. $error = 0;
  70. $display_ticket_list = false;
  71. if (!strlen($track_id)) {
  72. $error++;
  73. array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("TicketTrackId")));
  74. $action = '';
  75. }
  76. if (!strlen($email)) {
  77. $error++;
  78. array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Email")));
  79. $action = '';
  80. } else {
  81. if (!isValidEmail($email)) {
  82. $error++;
  83. array_push($object->errors, $langs->trans("ErrorEmailOrTrackingInvalid"));
  84. $action = '';
  85. }
  86. }
  87. if (!$error) {
  88. $ret = $object->fetch('', '', $track_id);
  89. if ($ret && $object->id > 0) {
  90. // vérifie si l'adresse email est bien dans les contacts du ticket
  91. $contacts = $object->liste_contact(-1, 'external');
  92. foreach ($contacts as $contact) {
  93. if (strtolower($contact['email']) == $email) {
  94. $display_ticket_list = true;
  95. $_SESSION['email_customer'] = $email;
  96. $_SESSION['track_id_customer'] = $track_id;
  97. break;
  98. } else {
  99. $display_ticket_list = false;
  100. }
  101. }
  102. if ($object->fk_soc > 0) {
  103. $object->fetch_thirdparty();
  104. if ($email == strtolower($object->thirdparty->email)) {
  105. $display_ticket_list = true;
  106. $_SESSION['email_customer'] = $email;
  107. $_SESSION['track_id_customer'] = $track_id;
  108. }
  109. }
  110. if ($object->fk_user_create > 0) {
  111. $tmpuser = new User($db);
  112. $tmpuser->fetch($object->fk_user_create);
  113. if ($email == strtolower($tmpuser->email)) {
  114. $display_ticket_list = true;
  115. $_SESSION['email_customer'] = $email;
  116. $_SESSION['track_id_customer'] = $track_id;
  117. }
  118. }
  119. $emailorigin = strtolower(CMailFile::getValidAddress($object->origin_email, 2));
  120. if ($email == $emailorigin) {
  121. $display_ticket_list = true;
  122. $_SESSION['email_customer'] = $email;
  123. $_SESSION['track_id_customer'] = $track_id;
  124. }
  125. } else {
  126. $error++;
  127. array_push($object->errors, $langs->trans("ErrorTicketNotFound", $track_id));
  128. $action = '';
  129. }
  130. }
  131. if ($error || $errors) {
  132. setEventMessages($object->error, $object->errors, 'errors');
  133. $action = '';
  134. }
  135. }
  136. //$object->doActions($action);
  137. /*
  138. * View
  139. */
  140. $form = new Form($db);
  141. $user_assign = new User($db);
  142. $user_create = new User($db);
  143. $formTicket = new FormTicket($db);
  144. if (!$conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) {
  145. print '<div class="error">'.$langs->trans('TicketPublicInterfaceForbidden').'</div>';
  146. $db->close();
  147. exit();
  148. }
  149. $arrayofjs = array();
  150. $arrayofcss = array('/ticket/css/styles.css.php');
  151. llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss);
  152. print '<div class="ticketpublicarealist">';
  153. if ($action == "view_ticketlist") {
  154. print '<br>';
  155. if ($display_ticket_list) {
  156. // Filters
  157. $search_fk_status = GETPOST("search_fk_status", 'alpha');
  158. $search_subject = GETPOST("search_subject", 'alpha');
  159. $search_type = GETPOST("search_type", 'alpha');
  160. $search_category = GETPOST("search_category", 'alpha');
  161. $search_severity = GETPOST("search_severity", 'alpha');
  162. $search_fk_user_create = GETPOST("search_fk_user_create", 'int');
  163. $search_fk_user_assign = GETPOST("search_fk_user_assign", 'int');
  164. // Store current page url
  165. $url_page_current = dol_buildpath('/public/ticket/list.php', 1);
  166. // Do we click on purge search criteria ?
  167. if (GETPOST("button_removefilter_x")) {
  168. $search_fk_status = '';
  169. $search_subject = '';
  170. $search_type = '';
  171. $search_category = '';
  172. $search_severity = '';
  173. $search_fk_user_create = '';
  174. $search_fk_user_assign = '';
  175. }
  176. // fetch optionals attributes and labels
  177. $extrafields = new ExtraFields($db);
  178. $extrafields->fetch_name_optionals_label($object->table_element);
  179. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  180. $filter = array();
  181. $param = 'action=view_ticketlist';
  182. // Definition of fields for list
  183. $arrayfields = array(
  184. 't.datec' => array('label' => $langs->trans("Date"), 'checked' => 1),
  185. 't.date_read' => array('label' => $langs->trans("TicketReadOn"), 'checked' => 0),
  186. 't.date_close' => array('label' => $langs->trans("TicketCloseOn"), 'checked' => 0),
  187. 't.ref' => array('label' => $langs->trans("Ref"), 'checked' => 1),
  188. //'t.track_id' => array('label' => $langs->trans("IDTracking"), 'checked' => 0),
  189. 't.fk_statut' => array('label' => $langs->trans("Status"), 'checked' => 1),
  190. 't.subject' => array('label' => $langs->trans("Subject"), 'checked' => 1),
  191. 'type.code' => array('label' => $langs->trans("Type"), 'checked' => 1),
  192. 'category.code' => array('label' => $langs->trans("Category"), 'checked' => 1),
  193. 'severity.code' => array('label' => $langs->trans("Severity"), 'checked' => 1),
  194. 't.progress' => array('label' => $langs->trans("Progression"), 'checked' => 0),
  195. //'t.fk_contract' => array('label' => $langs->trans("Contract"), 'checked' => 0),
  196. 't.fk_user_create' => array('label' => $langs->trans("Author"), 'checked' => 1),
  197. 't.fk_user_assign' => array('label' => $langs->trans("AssignedTo"), 'checked' => 0),
  198. //'t.entity'=>array('label'=>$langs->trans("Entity"), 'checked'=>1, 'enabled'=>(! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))),
  199. //'t.datec' => array('label' => $langs->trans("DateCreation"), 'checked' => 0, 'position' => 500),
  200. //'t.tms' => array('label' => $langs->trans("DateModificationShort"), 'checked' => 0, 'position' => 2)
  201. //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
  202. );
  203. // Extra fields
  204. if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  205. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  206. if ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate') {
  207. $arrayfields["ef.".$key] = array('label' => $extrafields->attributes[$object->table_element]['label'][$key], 'checked' => ($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1, 'position' => $extrafields->attributes[$object->table_element]['pos'][$key], 'enabled' =>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3) && $extrafields->attributes[$object->table_element]['perms'][$key]);
  208. }
  209. }
  210. }
  211. if (!empty($search_subject)) {
  212. $filter['t.subject'] = $search_subject;
  213. $param .= '&search_subject='.urlencode($search_subject);
  214. }
  215. if (!empty($search_type)) {
  216. $filter['t.type_code'] = $search_type;
  217. $param .= '&search_type='.urlencode($search_type);
  218. }
  219. if (!empty($search_category)) {
  220. $filter['t.category_code'] = $search_category;
  221. $param .= '&search_category='.urlencode($search_category);
  222. }
  223. if (!empty($search_severity)) {
  224. $filter['t.severity_code'] = $search_severity;
  225. $param .= '&search_severity='.urlencode($search_severity);
  226. }
  227. if (!empty($search_fk_user_assign)) {
  228. // -1 value = all so no filter
  229. if ($search_fk_user_assign > 0) {
  230. $filter['t.fk_user_assign'] = $search_fk_user_assign;
  231. $param .= '&search_fk_user_assign='.urlencode($search_fk_user_assign);
  232. }
  233. }
  234. if (!empty($search_fk_user_create)) {
  235. // -1 value = all so no filter
  236. if ($search_fk_user_create > 0) {
  237. $filter['t.fk_user_create'] = $search_fk_user_create;
  238. $param .= '&search_fk_user_create='.urlencode($search_fk_user_create);
  239. }
  240. }
  241. if ((isset($search_fk_status) && $search_fk_status != '') && $search_fk_status != '-1' && $search_fk_status != 'non_closed') {
  242. $filter['t.fk_statut'] = $search_fk_status;
  243. $param .= '&search_fk_status='.urlencode($search_fk_status);
  244. }
  245. if (isset($search_fk_status) && $search_fk_status == 'non_closed') {
  246. $filter['t.fk_statut'] = array(0, 1, 3, 4, 5, 6);
  247. $param .= '&search_fk_status=non_closed';
  248. }
  249. require DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
  250. $sortfield = GETPOST("sortfield", 'alpha');
  251. $sortorder = GETPOST("sortorder", 'alpha');
  252. if (!$sortfield) {
  253. $sortfield = 't.datec';
  254. }
  255. if (!$sortorder) {
  256. $sortorder = 'DESC';
  257. }
  258. $limit = $conf->liste_limit;
  259. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  260. if (empty($page) || $page == -1) {
  261. $page = 0;
  262. } // If $page is not defined, or '' or -1
  263. $offset = $limit * $page;
  264. $pageprev = $page - 1;
  265. $pagenext = $page + 1;
  266. // Request SQL
  267. $sql = "SELECT DISTINCT";
  268. $sql .= " t.rowid,";
  269. $sql .= " t.ref,";
  270. $sql .= " t.track_id,";
  271. $sql .= " t.fk_soc,";
  272. $sql .= " t.fk_project,";
  273. $sql .= " t.origin_email,";
  274. $sql .= " t.fk_user_create, uc.lastname as user_create_lastname, uc.firstname as user_create_firstname,";
  275. $sql .= " t.fk_user_assign, ua.lastname as user_assign_lastname, ua.firstname as user_assign_firstname,";
  276. $sql .= " t.subject,";
  277. $sql .= " t.message,";
  278. $sql .= " t.fk_statut,";
  279. $sql .= " t.resolution,";
  280. $sql .= " t.progress,";
  281. $sql .= " t.timing,";
  282. $sql .= " t.type_code,";
  283. $sql .= " t.category_code,";
  284. $sql .= " t.severity_code,";
  285. $sql .= " t.datec,";
  286. $sql .= " t.date_read,";
  287. $sql .= " t.date_close,";
  288. $sql .= " t.tms,";
  289. $sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label";
  290. // Add fields for extrafields
  291. if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  292. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  293. $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
  294. }
  295. }
  296. $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t";
  297. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_type as type ON type.code=t.type_code";
  298. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_category as category ON category.code=t.category_code";
  299. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_ticket_severity as severity ON severity.code=t.severity_code";
  300. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=t.fk_soc";
  301. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as uc ON uc.rowid=t.fk_user_create";
  302. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as ua ON ua.rowid=t.fk_user_assign";
  303. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact as ec ON ec.element_id=t.rowid";
  304. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_contact as tc ON ec.fk_c_type_contact=tc.rowid";
  305. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople sp ON ec.fk_socpeople=sp.rowid";
  306. if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  307. $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."ticket_extrafields as ef on (t.rowid = ef.fk_object)";
  308. }
  309. $sql .= " WHERE t.entity IN (".getEntity('ticket').")";
  310. $sql .= " AND ((tc.source = 'external'";
  311. $sql .= " AND tc.element='".$db->escape($object->dao->element)."'";
  312. $sql .= " AND tc.active=1)";
  313. $sql .= " OR (sp.email='".$db->escape($_SESSION['email_customer'])."'";
  314. $sql .= " OR s.email='".$db->escape($_SESSION['email_customer'])."'";
  315. $sql .= " OR t.origin_email='".$db->escape($_SESSION['email_customer'])."'))";
  316. // Manage filter
  317. if (!empty($filter)) {
  318. foreach ($filter as $key => $value) {
  319. if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year
  320. $sql .= " AND ".$key." = '".$db->escape($value)."'";
  321. } elseif (($key == 't.fk_user_assign') || ($key == 't.type_code') || ($key == 't.category_code') || ($key == 't.severity_code')) {
  322. $sql .= " AND ".$key." = '".$db->escape($value)."'";
  323. } elseif ($key == 't.fk_statut') {
  324. if (is_array($value) && count($value) > 0) {
  325. $sql .= " AND ".$key." IN (".$db->sanitize(implode(',', $value)).")";
  326. } else {
  327. $sql .= " AND ".$key." = ".((int) $value);
  328. }
  329. } else {
  330. $sql .= " AND ".$key." LIKE '%".$db->escape($value)."%'";
  331. }
  332. }
  333. }
  334. //$sql .= " GROUP BY t.track_id";
  335. $sql .= " ORDER BY ".$sortfield.' '.$sortorder;
  336. $resql = $db->query($sql);
  337. if ($resql) {
  338. $num_total = $db->num_rows($resql);
  339. if (!empty($limit)) {
  340. $sql .= ' '.$db->plimit($limit + 1, $offset);
  341. }
  342. $resql = $db->query($sql);
  343. if ($resql) {
  344. $num = $db->num_rows($resql);
  345. print_barre_liste($langs->trans('TicketList'), $page, 'public/list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket');
  346. // Search bar
  347. print '<form method="get" action="'.$url_form.'" id="searchFormList" >'."\n";
  348. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  349. print '<input type="hidden" name="action" value="view_ticketlist">';
  350. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  351. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  352. $varpage = empty($contextpage) ? $url_page_current : $contextpage;
  353. $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
  354. print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
  355. // Filter bar
  356. print '<tr class="liste_titre">';
  357. if (!empty($arrayfields['t.datec']['checked'])) {
  358. print '<td class="liste_titre"></td>';
  359. }
  360. if (!empty($arrayfields['t.date_read']['checked'])) {
  361. print '<td class="liste_titre"></td>';
  362. }
  363. if (!empty($arrayfields['t.date_close']['checked'])) {
  364. print '<td class="liste_titre"></td>';
  365. }
  366. if (!empty($arrayfields['t.ref']['checked'])) {
  367. print '<td class="liste_titre"></td>';
  368. }
  369. if (!empty($arrayfields['t.subject']['checked'])) {
  370. print '<td class="liste_titre">';
  371. print '<input type="text" class="flat maxwidth100" name="search_subject" value="'.$search_subject.'">';
  372. print '</td>';
  373. }
  374. if (!empty($arrayfields['type.code']['checked'])) {
  375. print '<td class="liste_titre">';
  376. $formTicket->selectTypesTickets($search_type, 'search_type', '', 2, 1, 1, 0, 'maxwidth150');
  377. print '</td>';
  378. }
  379. if (!empty($arrayfields['category.code']['checked'])) {
  380. print '<td class="liste_titre">';
  381. $formTicket->selectGroupTickets($search_category, 'search_category', 'public=1', 2, 1, 1);
  382. print '</td>';
  383. }
  384. if (!empty($arrayfields['severity.code']['checked'])) {
  385. print '<td class="liste_titre">';
  386. $formTicket->selectSeveritiesTickets($search_severity, 'search_severity', '', 2, 1, 1);
  387. print '</td>';
  388. }
  389. if (!empty($arrayfields['t.progress']['checked'])) {
  390. print '<td class="liste_titre"></td>';
  391. }
  392. if (!empty($arrayfields['t.fk_user_create']['checked'])) {
  393. print '<td class="liste_titre"></td>';
  394. }
  395. if (!empty($arrayfields['t.fk_user_assign']['checked'])) {
  396. print '<td class="liste_titre"></td>';
  397. }
  398. if (!empty($arrayfields['t.tms']['checked'])) {
  399. print '<td class="liste_titre"></td>';
  400. }
  401. // Extra fields
  402. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
  403. // Fields from hook
  404. $parameters = array('arrayfields'=>$arrayfields);
  405. $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
  406. print $hookmanager->resPrint;
  407. // Status
  408. if (!empty($arrayfields['t.fk_statut']['checked'])) {
  409. print '<td class="liste_titre">';
  410. $selected = ($search_fk_status != "non_closed" ? $search_fk_status : '');
  411. //$object->printSelectStatus($selected);
  412. print '</td>';
  413. }
  414. // Action column
  415. print '<td class="liste_titre maxwidthsearch">';
  416. $searchpicto = $form->showFilterButtons();
  417. print $searchpicto;
  418. print '</td>';
  419. print '</tr>';
  420. // Field title
  421. print '<tr class="liste_titre">';
  422. if (!empty($arrayfields['t.datec']['checked'])) {
  423. print_liste_field_titre($arrayfields['t.datec']['label'], $url_page_current, 't.datec', '', $param, '', $sortfield, $sortorder);
  424. }
  425. if (!empty($arrayfields['t.date_read']['checked'])) {
  426. print_liste_field_titre($arrayfields['t.date_read']['label'], $url_page_current, 't.date_read', '', $param, '', $sortfield, $sortorder);
  427. }
  428. if (!empty($arrayfields['t.date_close']['checked'])) {
  429. print_liste_field_titre($arrayfields['t.date_close']['label'], $url_page_current, 't.date_close', '', $param, '', $sortfield, $sortorder);
  430. }
  431. if (!empty($arrayfields['t.ref']['checked'])) {
  432. print_liste_field_titre($arrayfields['t.ref']['label'], $url_page_current, 't.ref', '', $param, '', $sortfield, $sortorder);
  433. }
  434. if (!empty($arrayfields['t.subject']['checked'])) {
  435. print_liste_field_titre($arrayfields['t.subject']['label']);
  436. }
  437. if (!empty($arrayfields['type.code']['checked'])) {
  438. print_liste_field_titre($arrayfields['type.code']['label'], $url_page_current, 'type.code', '', $param, '', $sortfield, $sortorder);
  439. }
  440. if (!empty($arrayfields['category.code']['checked'])) {
  441. print_liste_field_titre($arrayfields['category.code']['label'], $url_page_current, 'category.code', '', $param, '', $sortfield, $sortorder);
  442. }
  443. if (!empty($arrayfields['severity.code']['checked'])) {
  444. print_liste_field_titre($arrayfields['severity.code']['label'], $url_page_current, 'severity.code', '', $param, '', $sortfield, $sortorder);
  445. }
  446. if (!empty($arrayfields['t.progress']['checked'])) {
  447. print_liste_field_titre($arrayfields['t.progress']['label'], $url_page_current, 't.progress', '', $param, '', $sortfield, $sortorder);
  448. }
  449. if (!empty($arrayfields['t.fk_user_create']['checked'])) {
  450. print_liste_field_titre($arrayfields['t.fk_user_create']['label'], $url_page_current, 't.fk_user_create', '', $param, '', $sortfield, $sortorder);
  451. }
  452. if (!empty($arrayfields['t.fk_user_assign']['checked'])) {
  453. print_liste_field_titre($arrayfields['t.fk_user_assign']['label'], $url_page_current, 't.fk_user_assign', '', $param, '', $sortfield, $sortorder);
  454. }
  455. if (!empty($arrayfields['t.tms']['checked'])) {
  456. print_liste_field_titre($arrayfields['t.tms']['label'], $url_page_current, 't.tms', '', $param, '', $sortfield, $sortorder);
  457. }
  458. // Extra fields
  459. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
  460. // Hook fields
  461. $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
  462. $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
  463. print $hookmanager->resPrint;
  464. if (!empty($arrayfields['t.fk_statut']['checked'])) {
  465. print_liste_field_titre($arrayfields['t.fk_statut']['label'], $url_page_current, 't.fk_statut', '', $param, '', $sortfield, $sortorder);
  466. }
  467. print_liste_field_titre($selectedfields, $url_page_current, "", '', '', 'align="right"', $sortfield, $sortorder, 'center maxwidthsearch ');
  468. print '</tr>';
  469. while ($obj = $db->fetch_object($resql)) {
  470. print '<tr class="oddeven">';
  471. // Date ticket
  472. if (!empty($arrayfields['t.datec']['checked'])) {
  473. print '<td>';
  474. print dol_print_date($db->jdate($obj->datec), 'dayhour');
  475. print '</td>';
  476. }
  477. // Date read
  478. if (!empty($arrayfields['t.date_read']['checked'])) {
  479. print '<td>';
  480. print dol_print_date($db->jdate($obj->date_read), 'dayhour');
  481. print '</td>';
  482. }
  483. // Date close
  484. if (!empty($arrayfields['t.date_close']['checked'])) {
  485. print '<td>';
  486. print dol_print_date($db->jdate($obj->date_close), 'dayhour');
  487. print '</td>';
  488. }
  489. // Ref
  490. if (!empty($arrayfields['t.ref']['checked'])) {
  491. print '<td class="nowraponall">';
  492. print '<a rel="nofollow" href="javascript:viewticket(\''.dol_escape_js($obj->track_id).'\',\''.dol_escape_js($_SESSION['email_customer']).'\');">';
  493. print img_picto('', 'ticket', 'class="paddingrightonly"');
  494. print $obj->ref;
  495. print '</a>';
  496. print '</td>';
  497. }
  498. // Subject
  499. if (!empty($arrayfields['t.subject']['checked'])) {
  500. print '<td>';
  501. print '<a rel="nofollow" href="javascript:viewticket(\''.dol_escape_js($obj->track_id).'\',\''.dol_escape_js($_SESSION['email_customer']).'\');">';
  502. print $obj->subject;
  503. print '</a>';
  504. print '</td>';
  505. }
  506. // Type
  507. if (!empty($arrayfields['type.code']['checked'])) {
  508. print '<td>';
  509. print $obj->type_label;
  510. print '</td>';
  511. }
  512. // Category
  513. if (!empty($arrayfields['category.code']['checked'])) {
  514. print '<td>';
  515. print $obj->category_label;
  516. print '</td>';
  517. }
  518. // Severity
  519. if (!empty($arrayfields['severity.code']['checked'])) {
  520. print '<td>';
  521. print $obj->severity_label;
  522. print '</td>';
  523. }
  524. // Progression
  525. if (!empty($arrayfields['t.progress']['checked'])) {
  526. print '<td>';
  527. print $obj->progress;
  528. print '</td>';
  529. }
  530. // Message author
  531. if (!empty($arrayfields['t.fk_user_create']['checked'])) {
  532. print '<td title="'.dol_escape_htmltag($obj->origin_email).'">';
  533. if ($obj->fk_user_create > 0) {
  534. $user_create->firstname = (!empty($obj->user_create_firstname) ? $obj->user_create_firstname : '');
  535. $user_create->name = (!empty($obj->user_create_lastname) ? $obj->user_create_lastname : '');
  536. $user_create->id = (!empty($obj->fk_user_create) ? $obj->fk_user_create : '');
  537. print $user_create->getFullName($langs);
  538. } else {
  539. print img_picto('', 'email', 'class="paddingrightonly"');
  540. print $langs->trans('Email');
  541. }
  542. print '</td>';
  543. }
  544. // Assigned author
  545. if (!empty($arrayfields['t.fk_user_assign']['checked'])) {
  546. print '<td>';
  547. if ($obj->fk_user_assign > 0) {
  548. $user_assign->firstname = (!empty($obj->user_assign_firstname) ? $obj->user_assign_firstname : '');
  549. $user_assign->lastname = (!empty($obj->user_assign_lastname) ? $obj->user_assign_lastname : '');
  550. $user_assign->id = (!empty($obj->fk_user_assign) ? $obj->fk_user_assign : '');
  551. print img_picto('', 'user', 'class="paddingrightonly"');
  552. print $user_assign->getFullName($langs);
  553. }
  554. print '</td>';
  555. }
  556. if (!empty($arrayfields['t.tms']['checked'])) {
  557. print '<td>'.dol_print_date($db->jdate($obj->tms), 'dayhour').'</td>';
  558. }
  559. // Extra fields
  560. if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
  561. foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
  562. if (!empty($arrayfields["ef.".$key]['checked'])) {
  563. print '<td';
  564. $align = $extrafields->getAlignFlag($key);
  565. if ($align) {
  566. print ' align="'.$align.'"';
  567. }
  568. print '>';
  569. $tmpkey = 'options_'.$key;
  570. print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
  571. print '</td>';
  572. }
  573. }
  574. }
  575. // Statut
  576. if (!empty($arrayfields['t.fk_statut']['checked'])) {
  577. print '<td class="nowraponall">';
  578. $object->fk_statut = $obj->fk_statut;
  579. print $object->getLibStatut(2);
  580. print '</td>';
  581. }
  582. print '<td></td>';
  583. $i++;
  584. print '</tr>';
  585. }
  586. print '</table>';
  587. print '</form>';
  588. print '<form method="post" id="form_view_ticket" name="form_view_ticket" enctype="multipart/form-data" action="'.dol_buildpath('/public/ticket/view.php', 1).'" style="display:none;">';
  589. print '<input type="hidden" name="token" value="'.newToken().'">';
  590. print '<input type="hidden" name="action" value="view_ticket">';
  591. print '<input type="hidden" name="btn_view_ticket_list" value="1">';
  592. print '<input type="hidden" name="track_id" value="">';
  593. print '<input type="hidden" name="email" value="">';
  594. print "</form>";
  595. print '<script type="text/javascript">
  596. function viewticket(ticket_id, email) {
  597. var form = $("#form_view_ticket");
  598. form.find("input[name=\\"track_id\\"]").val(ticket_id);
  599. form.find("input[name=\\"email\\"]").val(email);
  600. form.submit();
  601. }
  602. </script>';
  603. }
  604. }
  605. } else {
  606. print '<div class="error">Not Allowed<br><a href="'.$_SERVER['PHP_SELF'].'?track_id='.$object->dao->track_id.'">'.$langs->trans('Back').'</a></div>';
  607. }
  608. } else {
  609. print '<p class="center">'.$langs->trans("TicketPublicMsgViewLogIn").'</p>';
  610. print '<br>';
  611. print '<div id="form_view_ticket">';
  612. print '<form method="post" name="form_view_ticketlist" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'">';
  613. print '<input type="hidden" name="token" value="'.newToken().'">';
  614. print '<input type="hidden" name="action" value="view_ticketlist">';
  615. //print '<input type="hidden" name="search_fk_status" value="non_closed">';
  616. print '<p><label for="track_id" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans("OneOfTicketTrackId").'</span></label>';
  617. print '<input size="30" id="track_id" name="track_id" value="'.(GETPOST('track_id', 'alpha') ? GETPOST('track_id', 'alpha') : '').'" />';
  618. print '</p>';
  619. print '<p><label for="email" style="display: inline-block; width: 30%; "><span class="fieldrequired">'.$langs->trans('Email').'</span></label>';
  620. print '<input size="30" id="email" name="email" value="'.(GETPOST('email', 'alpha') ? GETPOST('email', 'alpha') : $_SESSION['customer_email']).'" />';
  621. print '</p>';
  622. print '<p style="text-align: center; margin-top: 1.5em;">';
  623. print '<input class="button" type="submit" name="btn_view_ticket_list" value="'.$langs->trans('ViewMyTicketList').'" />';
  624. print "</p>\n";
  625. print "</form>\n";
  626. print "</div>\n";
  627. }
  628. print "</div>";
  629. // End of page
  630. htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix, $object);
  631. llxFooter('', 'public');
  632. $db->close();