card.php 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573
  1. <?php
  2. /* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
  3. * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
  4. * Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
  6. * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/ticket/card.php
  23. * \ingroup ticket
  24. */
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  34. if (!empty($conf->projet->enabled)) {
  35. include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  36. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
  37. include_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
  38. }
  39. if (!empty($conf->contrat->enabled)) {
  40. include_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
  41. include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  42. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcontract.class.php';
  43. }
  44. // Load translation files required by the page
  45. $langs->loadLangs(array("companies", "other", "ticket"));
  46. // Get parameters
  47. $id = GETPOST('id', 'int');
  48. $socid = GETPOST('socid', 'int');
  49. $track_id = GETPOST('track_id', 'alpha', 3);
  50. $ref = GETPOST('ref', 'alpha');
  51. $projectid = GETPOST('projectid', 'int');
  52. $cancel = GETPOST('cancel', 'alpha');
  53. $action = GETPOST('action', 'aZ09');
  54. $backtopage = GETPOST('$backtopage', 'alpha');
  55. $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
  56. $sortfield = GETPOST('sortfield', 'aZ09comma') ? GETPOST('sortfield', 'aZ09comma') : "a.datep";
  57. $sortorder = GETPOST('sortorder', 'aZ09comma') ? GETPOST('sortorder', 'aZ09comma') : "desc";
  58. if (GETPOST('actioncode', 'array')) {
  59. $actioncode = GETPOST('actioncode', 'array', 3);
  60. if (!count($actioncode)) {
  61. $actioncode = '0';
  62. }
  63. } else {
  64. $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
  65. }
  66. $search_agenda_label = GETPOST('search_agenda_label');
  67. // Initialize technical object to manage hooks of ticket. Note that conf->hooks_modules contains array array
  68. $hookmanager->initHooks(array('ticketcard', 'globalcard'));
  69. $object = new Ticket($db);
  70. $extrafields = new ExtraFields($db);
  71. // Fetch optionals attributes and labels
  72. $extrafields->fetch_name_optionals_label($object->table_element);
  73. $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
  74. // Initialize array of search criterias
  75. $search_all = GETPOST("search_all", 'alpha');
  76. $search = array();
  77. foreach ($object->fields as $key => $val) {
  78. if (GETPOST('search_'.$key, 'alpha')) {
  79. $search[$key] = GETPOST('search_'.$key, 'alpha');
  80. }
  81. }
  82. if (empty($action) && empty($id) && empty($ref)) {
  83. $action = 'view';
  84. }
  85. //Select mail models is same action as add_message
  86. if (GETPOST('modelselected', 'alpha')) {
  87. $action = 'presend';
  88. }
  89. // Load object
  90. //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
  91. if ($id || $track_id || $ref) {
  92. $res = $object->fetch($id, $ref, $track_id);
  93. if ($res >= 0) {
  94. $id = $object->id;
  95. $track_id = $object->track_id;
  96. }
  97. }
  98. // Store current page url
  99. $url_page_current = DOL_URL_ROOT.'/ticket/card.php';
  100. // Security check - Protection if external user
  101. if ($user->socid > 0) $socid = $user->socid;
  102. $result = restrictedArea($user, 'ticket', $object->id);
  103. $triggermodname = 'TICKET_MODIFY';
  104. $permissiontoadd = $user->rights->ticket->write;
  105. $actionobject = new ActionsTicket($db);
  106. $now = dol_now();
  107. /*
  108. * Actions
  109. */
  110. $parameters = array();
  111. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  112. if ($reshook < 0) {
  113. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  114. }
  115. $error = 0;
  116. if (empty($reshook)) {
  117. // Purge search criteria
  118. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers{
  119. $actioncode = '';
  120. $search_agenda_label = '';
  121. }
  122. $backurlforlist = DOL_URL_ROOT.'/ticket/list.php';
  123. if (empty($backtopage) || ($cancel && empty($id))) {
  124. if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
  125. if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
  126. $backtopage = $backurlforlist;
  127. } else {
  128. $backtopage = DOL_URL_ROOT.'/ticket/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
  129. }
  130. }
  131. }
  132. if ($cancel) {
  133. if (!empty($backtopageforcancel)) {
  134. header("Location: ".$backtopageforcancel);
  135. exit;
  136. } elseif (!empty($backtopage)) {
  137. header("Location: ".$backtopage);
  138. exit;
  139. }
  140. $action = 'view';
  141. }
  142. // Action to add an action (not a message)
  143. if (GETPOST('save', 'alpha') && !empty($user->rights->ticket->write)) {
  144. $error = 0;
  145. if (!GETPOST("subject", 'alphanohtml')) {
  146. $error++;
  147. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")), null, 'errors');
  148. $action = 'create';
  149. } elseif (!GETPOST("message", 'restricthtml')) {
  150. $error++;
  151. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors');
  152. $action = 'create';
  153. }
  154. $ret = $extrafields->setOptionalsFromPost(null, $object);
  155. if ($ret < 0) {
  156. $error++;
  157. }
  158. if (!$error) {
  159. $db->begin();
  160. $object->ref = GETPOST("ref", 'alphanohtml');
  161. $object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0;
  162. $object->subject = GETPOST("subject", 'alphanohtml');
  163. $object->message = GETPOST("message", 'restricthtml');
  164. $object->type_code = GETPOST("type_code", 'alpha');
  165. $object->type_label = $langs->trans($langs->getLabelFromKey($db, $object->type_code, 'c_ticket_type', 'code', 'label'));
  166. $object->category_code = GETPOST("category_code", 'alpha');
  167. $object->category_label = $langs->trans($langs->getLabelFromKey($db, $object->category_code, 'c_ticket_category', 'code', 'label'));
  168. $object->severity_code = GETPOST("severity_code", 'alpha');
  169. $object->severity_label = $langs->trans($langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label'));
  170. $object->email_from = $user->email;
  171. $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
  172. $object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1;
  173. $fk_user_assign = GETPOST("fk_user_assign", 'int');
  174. if ($fk_user_assign > 0) {
  175. $object->fk_user_assign = $fk_user_assign;
  176. $object->fk_statut = $object::STATUS_ASSIGNED;
  177. }
  178. $object->fk_project = $projectid;
  179. $id = $object->create($user);
  180. if ($id <= 0) {
  181. $error++;
  182. setEventMessages($object->error, $object->errors, 'errors');
  183. $action = 'create';
  184. }
  185. if (!$error) {
  186. // Add contact
  187. $contactid = GETPOST('contactid', 'int');
  188. $type_contact = GETPOST("type", 'alpha');
  189. // Category association
  190. $categories = GETPOST('categories', 'array');
  191. $object->setCategories($categories);
  192. if ($contactid > 0 && $type_contact) {
  193. $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
  194. $result = $object->add_contact($contactid, $typeid, 'external');
  195. }
  196. // Link ticket to project
  197. if (GETPOST('origin', 'alpha') == 'projet') {
  198. $projectid = GETPOST('originid', 'int');
  199. } else {
  200. $projectid = GETPOST('projectid', 'int');
  201. }
  202. if ($projectid > 0) {
  203. $object->setProject($projectid);
  204. }
  205. // Auto mark as read if created from backend
  206. if (!empty($conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND) && $user->rights->ticket->write) {
  207. if ( ! $object->markAsRead($user) > 0) {
  208. setEventMessages($object->error, $object->errors, 'errors');
  209. }
  210. }
  211. // Auto assign user
  212. if (!empty($conf->global->TICKET_AUTO_ASSIGN_USER_CREATE)) {
  213. $result = $object->assignUser($user, $user->id, 1);
  214. $object->add_contact($user->id, "SUPPORTTEC", 'internal');
  215. }
  216. }
  217. if (!$error) {
  218. // File transfer
  219. $object->copyFilesForTicket();
  220. }
  221. if (!$error) {
  222. $db->commit();
  223. if (!empty($backtopage)) {
  224. if (empty($id)) {
  225. $url = $backtopage;
  226. } else {
  227. $url = 'card.php?track_id='.urlencode($object->track_id);
  228. }
  229. } else {
  230. $url = 'card.php?track_id='.urlencode($object->track_id);
  231. }
  232. header("Location: ".$url);
  233. exit;
  234. } else {
  235. $db->rollback();
  236. setEventMessages($object->error, $object->errors, 'errors');
  237. }
  238. } else {
  239. setEventMessages($object->error, $object->errors, 'errors');
  240. }
  241. }
  242. if ($action == 'update' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) {
  243. $error = 0;
  244. $ret = $object->fetch(GETPOST('id', 'int'), GETPOST('ref', 'alpha'), GETPOST('track_id', 'alpha'));
  245. if ($ret < 0) {
  246. $error++;
  247. array_push($object->errors, $langs->trans('ErrorTicketIsNotValid'));
  248. }
  249. // check fields
  250. if (!$error) {
  251. if (!GETPOST('subject', 'alpha')) {
  252. $error++;
  253. array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Subject')));
  254. }
  255. $ret = $extrafields->setOptionalsFromPost(null, $object);
  256. if ($ret < 0) {
  257. $error++;
  258. }
  259. }
  260. if (!$error) {
  261. $db->begin();
  262. $object->subject = GETPOST('subject', 'alpha');
  263. $object->type_code = GETPOST('type_code', 'alpha');
  264. $object->category_code = GETPOST('category_code', 'alpha');
  265. $object->severity_code = GETPOST('severity_code', 'alpha');
  266. $ret = $object->update($user);
  267. if ($ret > 0) {
  268. // Category association
  269. $categories = GETPOST('categories', 'array');
  270. $object->setCategories($categories);
  271. } else {
  272. $error++;
  273. }
  274. if ($error) {
  275. $db->rollback();
  276. } else {
  277. $db->commit();
  278. }
  279. }
  280. if ($error) {
  281. setEventMessages($object->error, $object->errors, 'errors');
  282. $action = 'edit';
  283. } else {
  284. if (!empty($backtopage)) {
  285. if (empty($id)) {
  286. $url = $backtopage;
  287. } else {
  288. $url = 'card.php?track_id='.urlencode($object->track_id);
  289. }
  290. } else {
  291. $url = 'card.php?track_id='.urlencode($object->track_id);
  292. }
  293. header('Location: '.$url);
  294. exit();
  295. }
  296. }
  297. // Mark as Read
  298. if ($action == "mark_ticket_read" && $user->rights->ticket->write) {
  299. $object->fetch('', '', GETPOST("track_id", 'alpha'));
  300. if ($object->markAsRead($user) > 0) {
  301. setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs');
  302. header("Location: card.php?track_id=".$object->track_id."&action=view");
  303. exit;
  304. } else {
  305. setEventMessages($object->error, $object->errors, 'errors');
  306. }
  307. $action = 'view';
  308. }
  309. // Assign to someone
  310. if ($action == "assign_user" && GETPOST('btn_assign_user', 'alpha') && $user->rights->ticket->write) {
  311. $object->fetch('', '', GETPOST("track_id", 'alpha'));
  312. $useroriginassign = $object->fk_user_assign;
  313. $usertoassign = GETPOST('fk_user_assign', 'int');
  314. /*if (! ($usertoassign > 0)) {
  315. $error++;
  316. array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("AssignedTo")));
  317. $action = 'view';
  318. }*/
  319. if (!$error) {
  320. $ret = $object->assignUser($user, $usertoassign);
  321. if ($ret < 0) {
  322. $error++;
  323. }
  324. }
  325. if (!$error) { // Update list of contacts
  326. // Si déjà un user assigné on le supprime des contacts
  327. if ($useroriginassign > 0) {
  328. $internal_contacts = $object->listeContact(-1, 'internal');
  329. foreach ($internal_contacts as $key => $contact) {
  330. if ($contact['code'] == "SUPPORTTEC" && $contact['id'] == $useroriginassign) {
  331. }
  332. {
  333. //print "user à effacer : ".$useroriginassign;
  334. $object->delete_contact($contact['rowid']);
  335. }
  336. }
  337. }
  338. if ($usertoassign > 0) {
  339. $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0);
  340. }
  341. }
  342. if (!$error) {
  343. // Log action in ticket logs table
  344. $object->fetch_user($usertoassign);
  345. //$log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs));
  346. setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs');
  347. header("Location: card.php?track_id=".$object->track_id."&action=view");
  348. exit;
  349. } else {
  350. array_push($object->errors, $object->error);
  351. }
  352. $action = 'view';
  353. }
  354. // Action to add an action (not a message)
  355. if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $user->rights->ticket->read) {
  356. $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0));
  357. if ($ret > 0) {
  358. if (!empty($backtopage)) {
  359. if (empty($id)) {
  360. $url = $backtopage;
  361. } else {
  362. $url = 'card.php?track_id='.urlencode($object->track_id);
  363. }
  364. } else {
  365. $url = 'card.php?action=view&track_id='.urlencode($object->track_id);
  366. }
  367. header("Location: ".$url);
  368. exit;
  369. } else {
  370. setEventMessages($object->error, null, 'errors');
  371. $action = 'presend';
  372. }
  373. }
  374. if (($action == "confirm_close" || $action == "confirm_abandon") && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticket->write) {
  375. $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
  376. if ($object->close($user, ($action == "confirm_abandon" ? 1 : 0))) {
  377. setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs');
  378. $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha');
  379. header("Location: ".$url);
  380. } else {
  381. $action = '';
  382. setEventMessages($object->error, $object->errors, 'errors');
  383. }
  384. }
  385. if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') {
  386. $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
  387. if ($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) {
  388. $object->close($user);
  389. // Log action in ticket logs table
  390. //$log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']);
  391. setEventMessages('<div class="confirm">'.$langs->trans('TicketMarkedAsClosed').'</div>', null, 'mesgs');
  392. $url = 'card.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha');
  393. header("Location: ".$url);
  394. } else {
  395. setEventMessages($object->error, $object->errors, 'errors');
  396. $action = '';
  397. }
  398. }
  399. if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) {
  400. if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
  401. if ($object->delete($user) > 0) {
  402. setEventMessages('<div class="confirm">'.$langs->trans('TicketDeletedSuccess').'</div>', null, 'mesgs');
  403. Header("Location: ".DOL_URL_ROOT."/ticket/list.php");
  404. exit;
  405. } else {
  406. $langs->load("errors");
  407. $mesg = '<div class="error">'.$langs->trans($object->error).'</div>';
  408. $action = '';
  409. }
  410. }
  411. }
  412. // Set parent company
  413. if ($action == 'set_thirdparty' && $user->rights->ticket->write) {
  414. if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
  415. $result = $object->setCustomer(GETPOST('editcustomer', 'int'));
  416. $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha');
  417. header("Location: ".$url);
  418. exit();
  419. }
  420. }
  421. if ($action == 'set_progression' && $user->rights->ticket->write) {
  422. if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
  423. $result = $object->setProgression(GETPOST('progress', 'alpha'));
  424. $url = 'card.php?action=view&track_id='.$object->track_id;
  425. header("Location: ".$url);
  426. exit();
  427. }
  428. }
  429. if ($action == 'set_categories' && $user->rights->ticket->write) {
  430. if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
  431. $result = $object->setCategories(GETPOST('categories', 'array'));
  432. $url = 'card.php?action=view&track_id='.$object->track_id;
  433. header("Location: ".$url);
  434. exit();
  435. }
  436. }
  437. if ($action == 'setsubject' && $user->rights->ticket->write) {
  438. if ($object->fetch(GETPOST('id', 'int'))) {
  439. if ($action == 'setsubject') {
  440. $object->subject = GETPOST('subject', 'alphanohtml');
  441. }
  442. if ($action == 'setsubject' && empty($object->subject)) {
  443. $error++;
  444. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")), null, 'errors');
  445. }
  446. if (!$error) {
  447. if ($object->update($user) >= 0) {
  448. header("Location: ".$_SERVER['PHP_SELF']."?track_id=".$object->track_id);
  449. exit;
  450. } else {
  451. $error++;
  452. setEventMessages($object->error, $object->errors, 'errors');
  453. }
  454. }
  455. }
  456. }
  457. if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) {
  458. if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
  459. // prevent browser refresh from reopening ticket several times
  460. if ($object->fk_statut == Ticket::STATUS_CLOSED || $object->fk_statut == Ticket::STATUS_CANCELED) {
  461. $res = $object->setStatut(Ticket::STATUS_ASSIGNED);
  462. if ($res) {
  463. // Log action in ticket logs table
  464. //$log_action = $langs->trans('TicketLogReopen');
  465. $url = 'card.php?action=view&track_id='.$object->track_id;
  466. header("Location: ".$url);
  467. exit();
  468. } else {
  469. $error++;
  470. setEventMessages($object->error, $object->errors, 'errors');
  471. }
  472. }
  473. }
  474. } elseif ($action == 'classin' && $user->rights->ticket->write) {
  475. // Categorisation dans projet
  476. if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
  477. $object->setProject($projectid);
  478. $url = 'card.php?action=view&track_id='.$object->track_id;
  479. header("Location: ".$url);
  480. exit();
  481. }
  482. } elseif ($action == 'setcontract' && $user->rights->ticket->write) {
  483. // Categorisation dans contrat
  484. if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
  485. $object->setContract(GETPOST('contractid', 'int'));
  486. $url = 'card.php?action=view&track_id='.$object->track_id;
  487. header("Location: ".$url);
  488. exit();
  489. }
  490. } elseif ($action == "set_message" && $user->rights->ticket->manage) {
  491. // altairis: manage cancel button
  492. if (!GETPOST('cancel')) {
  493. $object->fetch('', '', GETPOST('track_id', 'alpha'));
  494. $oldvalue_message = $object->message;
  495. $fieldtomodify = GETPOST('message_initial', 'restricthtml');
  496. $object->message = $fieldtomodify;
  497. $ret = $object->update($user);
  498. if ($ret > 0) {
  499. //$log_action = $langs->trans('TicketInitialMessageModified')." \n";
  500. // include the Diff class
  501. include_once DOL_DOCUMENT_ROOT.'/core/class/utils_diff.class.php';
  502. // output the result of comparing two files as plain text
  503. //$log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message)));
  504. setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs');
  505. } else {
  506. $error++;
  507. setEventMessages($object->error, $object->errors, 'errors');
  508. }
  509. }
  510. $action = 'view';
  511. } elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) {
  512. // Reopen ticket
  513. if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
  514. $new_status = GETPOST('new_status', 'int');
  515. $old_status = $object->fk_statut;
  516. $res = $object->setStatut($new_status);
  517. if ($res) {
  518. // Log action in ticket logs table
  519. $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status]));
  520. $url = 'card.php?action=view&track_id='.$object->track_id;
  521. header("Location: ".$url);
  522. exit();
  523. } else {
  524. $error++;
  525. setEventMessages($object->error, $object->errors, 'errors');
  526. }
  527. }
  528. }
  529. // Action to update one extrafield
  530. if ($action == "update_extras" && !empty($permissiontoadd)) {
  531. $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
  532. $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
  533. if ($ret < 0) {
  534. $error++;
  535. }
  536. if (!$error) {
  537. $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
  538. if ($result < 0) {
  539. $error++;
  540. }
  541. }
  542. if ($error) {
  543. setEventMessages($object->error, $object->errors, 'errors');
  544. $action = 'edit_extras';
  545. } else {
  546. setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
  547. $action = 'view';
  548. }
  549. }
  550. if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') && $user->rights->ticket->write) {
  551. $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
  552. $object->type_code = GETPOST('update_value_type', 'aZ09');
  553. $object->severity_code = GETPOST('update_value_severity', 'aZ09');
  554. $object->category_code = GETPOST('update_value_category', 'aZ09');
  555. $ret = $object->update($user);
  556. if ($ret > 0) {
  557. //$log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label);
  558. setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs');
  559. } else {
  560. $error++;
  561. setEventMessages($object->error, $object->errors, 'errors');
  562. }
  563. $action = 'view';
  564. }
  565. $permissiondellink = $user->rights->ticket->write;
  566. include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
  567. // Actions to build doc
  568. $upload_dir = $conf->ticket->dir_output;
  569. $permissiontoadd = $user->rights->ticket->write;
  570. include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
  571. // Actions to send emails
  572. $triggersendname = 'TICKET_SENTBYMAIL';
  573. $paramname = 'id';
  574. $autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add
  575. $trackid = 'tic'.$object->id;
  576. include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
  577. // Set $action to correct value for the case we used presend action to add a message
  578. if (GETPOSTISSET('actionbis') && $action == 'presend') {
  579. $action = 'presend_addmessage';
  580. }
  581. }
  582. /*
  583. * View
  584. */
  585. $userstat = new User($db);
  586. $form = new Form($db);
  587. $formticket = new FormTicket($db);
  588. if (!empty($conf->projet->enabled)) {
  589. $formproject = new FormProjets($db);
  590. }
  591. $help_url = 'EN:Module_Ticket|FR:DocumentationModuleTicket';
  592. $page_title = $actionobject->getTitle($action);
  593. llxHeader('', $page_title, $help_url);
  594. if ($action == 'create' || $action == 'presend') {
  595. $formticket = new FormTicket($db);
  596. print load_fiche_titre($langs->trans('NewTicket'), '', 'ticket');
  597. $formticket->withfromsocid = $socid ? $socid : $user->socid;
  598. $formticket->withfromcontactid = $contactid ? $contactid : '';
  599. $formticket->withtitletopic = 1;
  600. $formticket->withnotifytiersatcreate = ($notifyTiers ? 1 : (empty($conf->global->TICKET_CHECK_NOTIFY_THIRDPARTY_AT_CREATION) ? 0 : 1));
  601. $formticket->withusercreate = 0;
  602. $formticket->withref = 1;
  603. $formticket->fk_user_create = $user->id;
  604. $formticket->withfile = 2;
  605. $formticket->withextrafields = 1;
  606. $formticket->param = array('origin' => GETPOST('origin'), 'originid' => GETPOST('originid'));
  607. $formticket->withcancel = 1;
  608. $formticket->showForm(1, 'create', 0);
  609. /*} elseif ($action == 'edit' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) {
  610. $formticket = new FormTicket($db);
  611. $head = ticket_prepare_head($object);
  612. print '<form method="POST" name="form_ticket" id="form_edit_ticket" action="'.$_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'">';
  613. print '<input type="hidden" name="token" value="'.newToken().'">';
  614. print '<input type="hidden" name="action" value="update">';
  615. print '<input type="hidden" name="tack_id" value="'.$object->track_id.'">';
  616. print dol_get_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket');
  617. print '<div class="fichecenter2">';
  618. print '<table class="border" width="100%">';
  619. // Type
  620. print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans("TicketTypeRequest").'</span></label></td><td>';
  621. $formticket->selectTypesTickets((GETPOSTISSET('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2');
  622. print '</td></tr>';
  623. // Severity
  624. print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans("TicketSeverity").'</span></label></td><td>';
  625. $formticket->selectSeveritiesTickets((GETPOSTISSET('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2');
  626. print '</td></tr>';
  627. // Group
  628. print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans("TicketCategory").'</span></label></td><td>';
  629. $formticket->selectGroupTickets((GETPOSTISSET('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2');
  630. print '</td></tr>';
  631. // Subject
  632. print '<tr><td><label for="subject"><span class="fieldrequired">'.$langs->trans("Subject").'</span></label></td><td>';
  633. print '<input class="text minwidth200" id="subject" name="subject" value="'.dol_escape_htmltag(GETPOSTISSET('subject') ? GETPOST('subject', 'alpha') : $object->subject).'" />';
  634. print '</td></tr>';
  635. // Other attributes
  636. $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3');
  637. $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  638. print $hookmanager->resPrint;
  639. if (empty($reshook)) {
  640. print $object->showOptionals($extrafields, 'edit');
  641. }
  642. print '</table>';
  643. print '</div>';
  644. print dol_get_fiche_end();
  645. print $form->buttonsSaveCancel();
  646. print '</form>'; */
  647. } elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'abandon' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'categories' || $action == 'reopen'
  648. || $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') {
  649. if ($res > 0) {
  650. // or for unauthorized internals users
  651. if (!$user->socid && (!empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) {
  652. accessforbidden('', 0, 1);
  653. }
  654. // Confirmation close
  655. if ($action == 'close') {
  656. $thirdparty_contacts = $object->getInfosTicketExternalContact();
  657. $contacts_select = array(
  658. '-2' => $langs->trans('TicketNotifyAllTiersAtClose'),
  659. '-3' => $langs->trans('TicketNotNotifyTiersAtClose')
  660. );
  661. foreach ($thirdparty_contacts as $thirdparty_contact) {
  662. $contacts_select[$thirdparty_contact['id']] = $thirdparty_contact['civility'] . ' ' . $thirdparty_contact['lastname'] . ' ' . $thirdparty_contact['firstname'];
  663. }
  664. // Default select all or no contact
  665. $default = (!empty($conf->global->TICKET_NOTIFY_AT_CLOSING)) ? -2 : -3;
  666. $formquestion = array(
  667. array(
  668. 'name' => 'contactid',
  669. 'type' => 'select',
  670. 'label' => $langs->trans('NotifyThirdpartyOnTicketClosing'),
  671. 'values' => $contacts_select,
  672. 'default' => $default
  673. ),
  674. );
  675. print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_close", $formquestion, '', 1);
  676. }
  677. // Confirmation abandon
  678. if ($action == 'abandon') {
  679. print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("AbandonTicket"), $langs->trans("ConfirmAbandonTicket"), "confirm_abandon", '', '', 1);
  680. if ($ret == 'html') {
  681. print '<br>';
  682. }
  683. }
  684. // Confirmation delete
  685. if ($action == 'delete') {
  686. print $form->formconfirm($url_page_current."?track_id=".$object->track_id, $langs->trans("Delete"), $langs->trans("ConfirmDeleteTicket"), "confirm_delete_ticket", '', '', 1);
  687. }
  688. // Confirm reopen
  689. if ($action == 'reopen') {
  690. print $form->formconfirm($url_page_current.'?track_id='.$object->track_id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenTicket'), 'confirm_reopen', '', '', 1);
  691. }
  692. // Confirmation status change
  693. if ($action == 'set_status') {
  694. $new_status = GETPOST('new_status');
  695. //var_dump($url_page_current . "?track_id=" . $object->track_id);
  696. print $form->formconfirm($url_page_current."?track_id=".$object->track_id."&new_status=".GETPOST('new_status'), $langs->trans("TicketChangeStatus"), $langs->trans("TicketConfirmChangeStatus", $langs->transnoentities($object->statuts_short[$new_status])), "confirm_set_status", '', '', 1);
  697. }
  698. // project info
  699. if ($projectid > 0) {
  700. $projectstat = new Project($db);
  701. if ($projectstat->fetch($projectid) > 0) {
  702. $projectstat->fetch_thirdparty();
  703. // To verify role of users
  704. //$userAccess = $object->restrictedProjectArea($user,'read');
  705. $userWrite = $projectstat->restrictedProjectArea($user, 'write');
  706. //$userDelete = $object->restrictedProjectArea($user,'delete');
  707. //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
  708. $head = project_prepare_head($projectstat);
  709. print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project'));
  710. /*
  711. * Projet synthese pour rappel
  712. */
  713. print '<table class="border centpercent">';
  714. $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  715. // Ref
  716. print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">';
  717. // Define a complementary filter for search of next/prev ref.
  718. if (empty($user->rights->projet->all->lire)) {
  719. $objectsListId = $projectstat->getProjectsAuthorizedForUser($user, $mine, 0);
  720. $projectstat->next_prev_filter = " rowid IN (".$db->sanitize(count($objectsListId) ? join(',', array_keys($objectsListId)) : '0').")";
  721. }
  722. print $form->showrefnav($projectstat, 'ref', $linkback, 1, 'ref', 'ref', '');
  723. print '</td></tr>';
  724. // Label
  725. print '<tr><td>'.$langs->trans("Label").'</td><td>'.$projectstat->title.'</td></tr>';
  726. // Customer
  727. print "<tr><td>".$langs->trans("ThirdParty")."</td>";
  728. print '<td colspan="3">';
  729. if ($projectstat->thirdparty->id > 0) {
  730. print $projectstat->thirdparty->getNomUrl(1);
  731. } else {
  732. print '&nbsp;';
  733. }
  734. print '</td></tr>';
  735. // Visibility
  736. print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
  737. if ($projectstat->public) {
  738. print $langs->trans('SharedProject');
  739. } else {
  740. print $langs->trans('PrivateProject');
  741. }
  742. print '</td></tr>';
  743. // Statut
  744. print '<tr><td>'.$langs->trans("Status").'</td><td>'.$projectstat->getLibStatut(4).'</td></tr>';
  745. print "</table>";
  746. print dol_get_fiche_end();
  747. } else {
  748. print "ErrorRecordNotFound";
  749. }
  750. } elseif ($socid > 0) {
  751. $object->fetch_thirdparty();
  752. $head = societe_prepare_head($object->thirdparty);
  753. print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company');
  754. dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
  755. print dol_get_fiche_end();
  756. }
  757. if (!$user->socid && !empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) {
  758. $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'";
  759. } elseif ($user->socid > 0) {
  760. $object->next_prev_filter = "te.fk_soc = '".$user->socid."'";
  761. }
  762. $head = ticket_prepare_head($object);
  763. print dol_get_fiche_head($head, 'tabTicket', $langs->trans("Ticket"), -1, 'ticket');
  764. $morehtmlref = '<div class="refidno">';
  765. $morehtmlref .= $object->subject;
  766. // Author
  767. if ($object->fk_user_create > 0) {
  768. $morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
  769. $langs->load("users");
  770. $fuser = new User($db);
  771. $fuser->fetch($object->fk_user_create);
  772. $morehtmlref .= $fuser->getNomUrl(-1);
  773. }
  774. if (!empty($object->origin_email)) {
  775. $morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
  776. $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
  777. $morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$langs->trans("TicketEmailOriginIssuer").')</small>';
  778. }
  779. // Thirdparty
  780. if (!empty($conf->societe->enabled)) {
  781. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' ';
  782. if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) {
  783. $morehtmlref .= '<a class="editfielda" href="'.$url_page_current.'?action=editcustomer&token='.newToken().'&track_id='.$object->track_id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 0).'</a> : ';
  784. }
  785. if ($action == 'editcustomer') {
  786. $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1);
  787. } else {
  788. $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1);
  789. }
  790. }
  791. // Project
  792. if (!empty($conf->projet->enabled)) {
  793. $langs->load("projects");
  794. $morehtmlref .= '<br>'.$langs->trans('Project').' ';
  795. if ($user->rights->ticket->write) {
  796. if ($action != 'classify') {
  797. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
  798. }
  799. $morehtmlref .= ' : ';
  800. if ($action == 'classify') {
  801. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  802. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  803. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  804. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  805. $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500');
  806. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  807. $morehtmlref .= '</form>';
  808. } else {
  809. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
  810. }
  811. } else {
  812. if (!empty($object->fk_project)) {
  813. $proj = new Project($db);
  814. $proj->fetch($object->fk_project);
  815. $morehtmlref .= $proj->getNomUrl(1);
  816. } else {
  817. $morehtmlref .= '';
  818. }
  819. }
  820. }
  821. $morehtmlref .= '</div>';
  822. $linkback = '<a href="'.DOL_URL_ROOT.'/ticket/list.php?restore_lastsearch_values=1"><strong>'.$langs->trans("BackToList").'</strong></a> ';
  823. dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref);
  824. print '<div class="fichecenter">';
  825. print '<div class="fichehalfleft">';
  826. print '<div class="underbanner clearboth"></div>';
  827. print '<table class="border tableforfield centpercent">';
  828. // Track ID
  829. print '<tr><td class="titlefield">'.$langs->trans("TicketTrackId").'</td><td>';
  830. if (!empty($object->track_id)) {
  831. if (empty($object->ref)) {
  832. $object->ref = $object->id;
  833. print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'track_id');
  834. } else {
  835. print $object->track_id;
  836. }
  837. } else {
  838. print $langs->trans('None');
  839. }
  840. print '</td></tr>';
  841. // Subject
  842. print '<tr><td>';
  843. print $form->editfieldkey("Subject", 'subject', $object->subject, $object, $user->rights->ticket->write && !$user->socid, 'string');
  844. print '</td><td>';
  845. print $form->editfieldval("Subject", 'subject', $object->subject, $object, $user->rights->ticket->write && !$user->socid, 'string');
  846. print '</td></tr>';
  847. // Creation date
  848. print '<tr><td>'.$langs->trans("DateCreation").'</td><td>';
  849. print dol_print_date($object->datec, 'dayhour', 'tzuser');
  850. print '<span class="opacitymedium"> - '.$langs->trans("TimeElapsedSince").': <i>'.convertSecondToTime(roundUpToNextMultiple($now - $object->datec, 60)).'</i></span>';
  851. print '</td></tr>';
  852. // Read date
  853. print '<tr><td>'.$langs->trans("TicketReadOn").'</td><td>';
  854. if (!empty($object->date_read)) {
  855. print dol_print_date($object->date_read, 'dayhour', 'tzuser');
  856. print '<span class="opacitymedium"> - '.$langs->trans("TicketTimeElapsedBeforeSince").': <i>'.convertSecondToTime(roundUpToNextMultiple($object->date_read - $object->datec, 60)).'</i>';
  857. print ' / <i>'.convertSecondToTime(roundUpToNextMultiple($now - $object->date_read, 60)).'</i></span>';
  858. }
  859. print '</td></tr>';
  860. // Close date
  861. print '<tr><td>'.$langs->trans("TicketCloseOn").'</td><td>';
  862. if (!empty($object->date_close)) {
  863. print dol_print_date($object->date_close, 'dayhour', 'tzuser');
  864. }
  865. print '</td></tr>';
  866. // User assigned
  867. print '<tr><td>';
  868. print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
  869. print $langs->trans("AssignedTo");
  870. if ($object->fk_statut < $object::STATUS_CLOSED && GETPOST('set', 'alpha') != "assign_ticket" && $user->rights->ticket->manage) {
  871. print '</td><td class="right"><a class="editfielda" href="'.$url_page_current.'?track_id='.$object->track_id.'&action=view&set=assign_ticket">'.img_edit($langs->trans('Modify'), '').'</a>';
  872. }
  873. print '</td></tr></table>';
  874. print '</td><td>';
  875. if (GETPOST('set', 'alpha') != "assign_ticket" && $object->fk_user_assign > 0) {
  876. $userstat->fetch($object->fk_user_assign);
  877. print $userstat->getNomUrl(-1);
  878. }
  879. // Show user list to assignate one if status is "read"
  880. if (GETPOST('set', 'alpha') == "assign_ticket" && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) {
  881. print '<form method="post" name="ticket" enctype="multipart/form-data" action="'.$url_page_current.'">';
  882. print '<input type="hidden" name="token" value="'.newToken().'">';
  883. print '<input type="hidden" name="action" value="assign_user">';
  884. print '<input type="hidden" name="track_id" value="'.$object->track_id.'">';
  885. //print '<label for="fk_user_assign">'.$langs->trans("AssignUser").'</label> ';
  886. print $form->select_dolusers($user->id, 'fk_user_assign', 1);
  887. print ' <input type="submit" class="button small" name="btn_assign_user" value="'.$langs->trans("Validate").'" />';
  888. print '</form>';
  889. }
  890. print '</td></tr>';
  891. // Progression
  892. print '<tr><td>';
  893. print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
  894. print $langs->trans('Progression').'</td><td class="left">';
  895. print '</td>';
  896. if ($action != 'progression' && $object->fk_statut < $object::STATUS_CLOSED && !$user->socid) {
  897. print '<td class="right"><a class="editfielda" href="'.$url_page_current.'?action=progression&amp;track_id='.$object->track_id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
  898. }
  899. print '</tr></table>';
  900. print '</td><td>';
  901. if ($user->rights->ticket->write && $action == 'progression') {
  902. print '<form action="'.$url_page_current.'" method="post">';
  903. print '<input type="hidden" name="token" value="'.newToken().'">';
  904. print '<input type="hidden" name="track_id" value="'.$track_id.'">';
  905. print '<input type="hidden" name="action" value="set_progression">';
  906. print '<input type="text" class="flat width75" name="progress" value="'.$object->progress.'">';
  907. print ' <input type="submit" class="button button-edit small" value="'.$langs->trans('Modify').'">';
  908. print '</form>';
  909. } else {
  910. print($object->progress > 0 ? $object->progress : '0').'%';
  911. }
  912. print '</td>';
  913. print '</tr>';
  914. // Timing (Duration sum of linked fichinter)
  915. if (!empty($conf->ficheinter->enabled)) {
  916. $object->fetchObjectLinked();
  917. $num = count($object->linkedObjects);
  918. $timing = 0;
  919. $foundinter = 0;
  920. if ($num) {
  921. foreach ($object->linkedObjects as $objecttype => $objects) {
  922. if ($objecttype = "fichinter") {
  923. foreach ($objects as $fichinter) {
  924. $foundinter++;
  925. $timing += $fichinter->duration;
  926. }
  927. }
  928. }
  929. }
  930. print '<tr><td>';
  931. print $form->textwithpicto($langs->trans("TicketDurationAuto"), $langs->trans("TicketDurationAutoInfos"), 1);
  932. print '</td><td>';
  933. print $foundinter ? convertSecondToTime($timing, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY) : '';
  934. print '</td></tr>';
  935. }
  936. // Other attributes
  937. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
  938. print '</table>';
  939. // Fin colonne gauche et début colonne droite
  940. print '</div><div class="fichehalfright">';
  941. print '<form method="post" name="formticketproperties" action="'.$url_page_current.'">';
  942. print '<input type="hidden" name="token" value="'.newToken().'">';
  943. print '<input type="hidden" name="action" value="change_property">';
  944. print '<input type="hidden" name="track_id" value="'.$track_id.'">';
  945. print '<div class="underbanner clearboth"></div>';
  946. // Categories
  947. if ($conf->categorie->enabled) {
  948. print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  949. print '<table class="border tableforfield centpercent noborderbottom">';
  950. print '<tr>';
  951. print '<td class="valignmiddle titlefield">';
  952. print '<table class="nobordernopadding centpercent"><tr><td class="nowrap">';
  953. print $langs->trans("Categories");
  954. if ($action != 'categories' && !$user->socid) {
  955. print '<td class="right"><a class="editfielda" href="'.$url_page_current.'?action=categories&amp;track_id='.$object->track_id.'">'.img_edit($langs->trans('Modify')).'</a></td>';
  956. }
  957. print '</table>';
  958. print '</td>';
  959. if ($user->rights->ticket->write && $action == 'categories') {
  960. $cate_arbo = $form->select_all_categories(Categorie::TYPE_TICKET, '', 'parent', 64, 0, 1);
  961. if (is_array($cate_arbo)) {
  962. // Categories
  963. print '<td colspan="3">';
  964. print '<form action="'.$url_page_current.'" method="post">';
  965. print '<input type="hidden" name="token" value="'.newToken().'">';
  966. print '<input type="hidden" name="track_id" value="'.$track_id.'">';
  967. print '<input type="hidden" name="action" value="set_categories">';
  968. $category = new Categorie($db);
  969. $cats = $category->containing($object->id, 'ticket');
  970. $arrayselected = array();
  971. foreach ($cats as $cat) {
  972. $arrayselected[] = $cat->id;
  973. }
  974. print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
  975. print '<input type="submit" class="button button-edit small" value="'.$langs->trans('Save').'">';
  976. print '</form>';
  977. print "</td>";
  978. }
  979. } else {
  980. print '<td colspan="3">';
  981. print $form->showCategories($object->id, Categorie::TYPE_TICKET, 1);
  982. print "</td></tr>";
  983. }
  984. print '</table>';
  985. print '</div>';
  986. }
  987. // View Original message
  988. $actionobject->viewTicketOriginalMessage($user, $action, $object);
  989. // Classification of ticket
  990. print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  991. print '<table class="noborder tableforfield centpercent margintable">';
  992. print '<tr class="liste_titre">';
  993. print '<td>';
  994. print $langs->trans('TicketProperties');
  995. print '</td>';
  996. print '<td>';
  997. if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) {
  998. print '<input type="submit" class="button small" name="btn_update_ticket_prop" value="'.$langs->trans("Modify").'" />';
  999. } else {
  1000. // Button to edit Properties
  1001. if ($object->fk_statut < $object::STATUS_NEED_MORE_INFO && $user->rights->ticket->write) {
  1002. print ' <a class="editfielda" href="card.php?track_id='.$object->track_id.'&action=view&set=properties">'.img_edit($langs->trans('Modify')).'</a>';
  1003. }
  1004. }
  1005. print '</td>';
  1006. print '</tr>';
  1007. if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) {
  1008. print '<tr>';
  1009. // Type
  1010. print '<td class="titlefield">';
  1011. print $langs->trans('Type');
  1012. print '</td><td>';
  1013. $formticket->selectTypesTickets($object->type_code, 'update_value_type', '', 2);
  1014. print '</td>';
  1015. print '</tr>';
  1016. // Group
  1017. print '<tr>';
  1018. print '<td>';
  1019. print $langs->trans('TicketCategory');
  1020. print '</td><td>';
  1021. $formticket->selectGroupTickets($object->category_code, 'update_value_category', '', 2, 0, 0, 0, 'maxwidth500 widthcentpercentminusxx');
  1022. print '</td>';
  1023. print '</tr>';
  1024. // Severity
  1025. print '<tr>';
  1026. print '<td>';
  1027. print $langs->trans('TicketSeverity');
  1028. print '</td><td>';
  1029. $formticket->selectSeveritiesTickets($object->severity_code, 'update_value_severity', '', 2);
  1030. print '</td>';
  1031. print '</tr>';
  1032. } else {
  1033. // Type
  1034. print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td>';
  1035. if (!empty($object->type_code)) {
  1036. print $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code);
  1037. }
  1038. print '</td></tr>';
  1039. // Group
  1040. print '<tr><td>'.$langs->trans("TicketCategory").'</td><td>';
  1041. if (!empty($object->category_code)) {
  1042. print $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code);
  1043. }
  1044. print '</td></tr>';
  1045. // Severity
  1046. print '<tr><td>'.$langs->trans("TicketSeverity").'</td><td>';
  1047. if (!empty($object->severity_code)) {
  1048. print $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code);
  1049. }
  1050. print '</td></tr>';
  1051. }
  1052. print '</table>'; // End table actions
  1053. print '</div>';
  1054. print '</form>';
  1055. // Display navbar with links to change ticket status
  1056. print '<!-- navbar with status -->';
  1057. if (!$user->socid && $user->rights->ticket->write && $object->fk_statut < $object::STATUS_CLOSED && GETPOST('set') !== 'properties') {
  1058. $actionobject->viewStatusActions($object);
  1059. }
  1060. if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
  1061. print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png');
  1062. print '<div class="div-table-responsive-no-min">';
  1063. print '<div class="tagtable centpercent noborder allwidth">';
  1064. print '<div class="tagtr liste_titre">';
  1065. print '<div class="tagtd">'.$langs->trans("Source").'</div>
  1066. <div class="tagtd">' . $langs->trans("Company").'</div>
  1067. <div class="tagtd">' . $langs->trans("Contacts").'</div>
  1068. <div class="tagtd">' . $langs->trans("ContactType").'</div>
  1069. <div class="tagtd">' . $langs->trans("Phone").'</div>
  1070. <div class="tagtd center">' . $langs->trans("Status").'</div>';
  1071. print '</div><!-- tagtr -->';
  1072. // Contact list
  1073. $companystatic = new Societe($db);
  1074. $contactstatic = new Contact($db);
  1075. $userstatic = new User($db);
  1076. $var = false;
  1077. foreach (array('internal', 'external') as $source) {
  1078. $tmpobject = $object;
  1079. $tab = $tmpobject->listeContact(-1, $source);
  1080. $num = count($tab);
  1081. $i = 0;
  1082. while ($i < $num) {
  1083. $var = !$var;
  1084. print '<div class="tagtr '.($var ? 'pair' : 'impair').'">';
  1085. print '<div class="tagtd left">';
  1086. if ($tab[$i]['source'] == 'internal') {
  1087. echo $langs->trans("User");
  1088. }
  1089. if ($tab[$i]['source'] == 'external') {
  1090. echo $langs->trans("ThirdPartyContact");
  1091. }
  1092. print '</div>';
  1093. print '<div class="tagtd left">';
  1094. if ($tab[$i]['socid'] > 0) {
  1095. $companystatic->fetch($tab[$i]['socid']);
  1096. echo $companystatic->getNomUrl(-1);
  1097. }
  1098. if ($tab[$i]['socid'] < 0) {
  1099. echo $conf->global->MAIN_INFO_SOCIETE_NOM;
  1100. }
  1101. if (!$tab[$i]['socid']) {
  1102. echo '&nbsp;';
  1103. }
  1104. print '</div>';
  1105. print '<div class="tagtd">';
  1106. if ($tab[$i]['source'] == 'internal') {
  1107. if ($userstatic->fetch($tab[$i]['id'])) {
  1108. print $userstatic->getNomUrl(-1);
  1109. }
  1110. }
  1111. if ($tab[$i]['source'] == 'external') {
  1112. if ($contactstatic->fetch($tab[$i]['id'])) {
  1113. print $contactstatic->getNomUrl(-1);
  1114. }
  1115. }
  1116. print ' </div>
  1117. <div class="tagtd">' . $tab[$i]['libelle'].'</div>';
  1118. print '<div class="tagtd">';
  1119. print dol_print_phone($tab[$i]['phone'], '', '', '', 'AC_TEL').'<br>';
  1120. if (!empty($tab[$i]['phone_perso'])) {
  1121. //print img_picto($langs->trans('PhonePerso'),'object_phoning.png','',0,0,0).' ';
  1122. print '<br>'.dol_print_phone($tab[$i]['phone_perso'], '', '', '', 'AC_TEL').'<br>';
  1123. }
  1124. if (!empty($tab[$i]['phone_mobile'])) {
  1125. //print img_picto($langs->trans('PhoneMobile'),'object_phoning.png','',0,0,0).' ';
  1126. print dol_print_phone($tab[$i]['phone_mobile'], '', '', '', 'AC_TEL').'<br>';
  1127. }
  1128. print '</div>';
  1129. print '<div class="tagtd center">';
  1130. if ($object->statut >= 0) {
  1131. echo '<a href="contact.php?track_id='.$object->track_id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
  1132. }
  1133. if ($tab[$i]['source'] == 'internal') {
  1134. $userstatic->id = $tab[$i]['id'];
  1135. $userstatic->lastname = $tab[$i]['lastname'];
  1136. $userstatic->firstname = $tab[$i]['firstname'];
  1137. echo $userstatic->LibStatut($tab[$i]['statuscontact'], 3);
  1138. }
  1139. if ($tab[$i]['source'] == 'external') {
  1140. $contactstatic->id = $tab[$i]['id'];
  1141. $contactstatic->lastname = $tab[$i]['lastname'];
  1142. $contactstatic->firstname = $tab[$i]['firstname'];
  1143. echo $contactstatic->LibStatut($tab[$i]['statuscontact'], 3);
  1144. }
  1145. if ($object->statut >= 0) {
  1146. echo '</a>';
  1147. }
  1148. print '</div>';
  1149. print '</div><!-- tagtr -->';
  1150. $i++;
  1151. }
  1152. }
  1153. print '</div><!-- contact list -->';
  1154. print '</div>';
  1155. }
  1156. print '</div></div>';
  1157. print '<div style="clear:both"></div>';
  1158. print dol_get_fiche_end();
  1159. // Buttons for actions
  1160. if ($action != 'presend' && $action != 'presend_addmessage' && $action != 'editline') {
  1161. print '<div class="tabsAction">'."\n";
  1162. $parameters = array();
  1163. $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
  1164. if ($reshook < 0) {
  1165. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  1166. }
  1167. if (empty($reshook)) {
  1168. // Show link to add a message (if read and not closed)
  1169. if ($object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") {
  1170. print dolGetButtonAction('', $langs->trans('TicketAddMessage'), 'default', $_SERVER["PHP_SELF"].'?action=presend_addmessage&mode=init&token='.newToken().'&track_id='.$object->track_id, '');
  1171. }
  1172. // Link to create an intervention
  1173. // socid is needed otherwise fichinter ask it and forgot origin after form submit :\
  1174. if (!$object->fk_soc && $user->rights->ficheinter->creer) {
  1175. print dolGetButtonAction($langs->trans('UnableToCreateInterIfNoSocid'), $langs->trans('TicketAddIntervention'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
  1176. }
  1177. if ($object->fk_soc > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ficheinter->creer) {
  1178. print dolGetButtonAction('', $langs->trans('TicketAddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&token='.newToken().'&socid='. $object->fk_soc.'&origin=ticket_ticket&originid='. $object->id, '');
  1179. }
  1180. /* This is useless. We can already modify each field individually
  1181. if ($user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) {
  1182. print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?track_id='.$object->track_id.'&action=edit&token='.newToken().'">'.$langs->trans('Modify').'</a></div>';
  1183. }
  1184. */
  1185. // Close ticket if statut is read
  1186. if ($object->fk_statut > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ticket->write) {
  1187. print dolGetButtonAction('', $langs->trans('CloseTicket'), 'default', $_SERVER["PHP_SELF"].'?action=close&token='.newToken().'&track_id='.$object->track_id, '');
  1188. }
  1189. // Abadon ticket if statut is read
  1190. if ($object->fk_statut > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ticket->write) {
  1191. print dolGetButtonAction('', $langs->trans('AbandonTicket'), 'default', $_SERVER["PHP_SELF"].'?action=abandon&token='.newToken().'&track_id='.$object->track_id, '');
  1192. }
  1193. // Re-open ticket
  1194. if (!$user->socid && ($object->fk_statut == Ticket::STATUS_CLOSED || $object->fk_statut == Ticket::STATUS_CANCELED) && !$user->socid) {
  1195. print dolGetButtonAction('', $langs->trans('ReOpen'), 'default', $_SERVER["PHP_SELF"].'?action=reopen&token='.newToken().'&track_id='.$object->track_id, '');
  1196. }
  1197. // Delete ticket
  1198. if ($user->rights->ticket->delete && !$user->socid) {
  1199. print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&track_id='.$object->track_id, '');
  1200. }
  1201. }
  1202. print '</div>'."\n";
  1203. } else {
  1204. //print '<br>';
  1205. }
  1206. // Select mail models is same action as presend
  1207. if (GETPOST('modelselected')) {
  1208. $action = 'presend';
  1209. }
  1210. // Set $action to correct value for the case we used presend action to add a message
  1211. if (GETPOSTISSET('actionbis') && $action == 'presend') {
  1212. $action = 'presend_addmessage';
  1213. }
  1214. // add a message
  1215. if ($action == 'presend' || $action == 'presend_addmessage') {
  1216. if ($object->fk_soc > 0) {
  1217. $object->fetch_thirdparty();
  1218. }
  1219. $outputlangs = $langs;
  1220. $newlang = '';
  1221. if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
  1222. $newlang = GETPOST('lang_id', 'aZ09');
  1223. } elseif ($conf->global->MAIN_MULTILANGS && empty($newlang) && is_object($object->thirdparty)) {
  1224. $newlang = $object->thirdparty->default_lang;
  1225. }
  1226. if (!empty($newlang)) {
  1227. $outputlangs = new Translate("", $conf);
  1228. $outputlangs->setDefaultLang($newlang);
  1229. }
  1230. $arrayoffamiliestoexclude = array('objectamount');
  1231. $action = 'add_message'; // action to use to post the message
  1232. $modelmail = 'ticket_send';
  1233. // Substitution array
  1234. $morehtmlright = '';
  1235. $help = "";
  1236. $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object);
  1237. $morehtmlright .= $form->textwithpicto('<span class="opacitymedium">'.$langs->trans("TicketMessageSubstitutionReplacedByGenericValues").'</span>', $help, 1, 'helpclickable', '', 0, 3, 'helpsubstitution');
  1238. print '<div>';
  1239. print load_fiche_titre($langs->trans('TicketAddMessage'), $morehtmlright, 'messages@ticket');
  1240. print '<hr>';
  1241. $formticket = new FormTicket($db);
  1242. $formticket->action = $action;
  1243. $formticket->track_id = $object->track_id;
  1244. $formticket->ref = $object->ref;
  1245. $formticket->id = $object->id;
  1246. $formticket->withfile = 2;
  1247. $formticket->withcancel = 1;
  1248. $formticket->param = array('fk_user_create' => $user->id);
  1249. $formticket->param['langsmodels'] = (empty($newlang) ? $langs->defaultlang : $newlang);
  1250. // Tableau des parametres complementaires du post
  1251. $formticket->param['models'] = $modelmail;
  1252. $formticket->param['models_id'] = GETPOST('modelmailselected', 'int');
  1253. //$formticket->param['socid']=$object->fk_soc;
  1254. $formticket->param['returnurl'] = $_SERVER["PHP_SELF"].'?track_id='.$object->track_id;
  1255. $formticket->withsubstit = 1;
  1256. $formticket->substit = $substitutionarray;
  1257. $formticket->showMessageForm('100%');
  1258. print '</div>';
  1259. }
  1260. // Show messages on card (Note: this is a duplicate of the view Events/Agenda but on the main tab)
  1261. if (!empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) {
  1262. $param = '&id='.$object->id;
  1263. if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
  1264. $param .= '&contextpage='.$contextpage;
  1265. }
  1266. if ($limit > 0 && $limit != $conf->liste_limit) {
  1267. $param .= '&limit='.$limit;
  1268. }
  1269. if ($actioncode) {
  1270. $param .= '&actioncode='.urlencode($actioncode);
  1271. }
  1272. if ($search_agenda_label) {
  1273. $param .= '&search_agenda_label='.urlencode($search_agenda_label);
  1274. }
  1275. $morehtmlright = '';
  1276. $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id;
  1277. $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 1);
  1278. // Show link to add a message (if read and not closed)
  1279. $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message";
  1280. $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init';
  1281. $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus);
  1282. // Show link to add event (if read and not closed)
  1283. $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message"; ;
  1284. $url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id);
  1285. $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, 'add-new-ticket-even-button', $btnstatus);
  1286. print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1);
  1287. // List of all actions
  1288. $filters = array();
  1289. $filters['search_agenda_label'] = $search_agenda_label;
  1290. show_ticket_messaging($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
  1291. }
  1292. if ($action != 'presend' && $action != 'presend_addmessage' && $action != 'add_message') {
  1293. print '<div class="fichecenter"><div class="fichehalfleft">';
  1294. print '<a name="builddoc"></a>'; // ancre
  1295. // Show links to link elements
  1296. $linktoelem = $form->showLinkToObjectBlock($object, null, array('ticket'));
  1297. $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
  1298. // Show direct link to public interface
  1299. print '<br><!-- Link to public interface -->'."\n";
  1300. print showDirectPublicLink($object).'<br>';
  1301. print '</div>';
  1302. if (empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) {
  1303. print '<div class="fichehalfright">';
  1304. $MAXEVENT = 10;
  1305. $morehtmlcenter = '<div class="nowraponall">';
  1306. $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullConversation'), '', 'fa fa-comments imgforviewmode', DOL_URL_ROOT.'/ticket/messaging.php?id='.$object->id);
  1307. $morehtmlcenter .= ' ';
  1308. $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullList'), '', 'fa fa-bars imgforviewmode', DOL_URL_ROOT.'/ticket/agenda.php?id='.$object->id);
  1309. $morehtmlcenter .= '</div>';
  1310. // List of actions on element
  1311. include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
  1312. $formactions = new FormActions($db);
  1313. $somethingshown = $formactions->showactions($object, 'ticket', $socid, 1, 'listactions', $MAXEVENT, '', $morehtmlcenter);
  1314. print '</div>';
  1315. }
  1316. print '</div>';
  1317. }
  1318. }
  1319. }
  1320. // End of page
  1321. llxFooter();
  1322. $db->close();