list.php 31 KB

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