dolibarr 25.0.0-alpha
agenda.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2016 Jean-François FERRY <hello@librethic.io>
3 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2026 Jose MARTINEZ <jose.martinez@pichinov.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
35require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
36if (isModEnabled('project')) {
37 include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
38 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
39 include_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
40}
41
50// Load translation files required by the page
51$langs->loadLangs(array('companies', 'other', 'ticket'));
52
53// Get parameters
54$id = GETPOSTINT('id');
55$ref = GETPOST('ref', 'alpha');
56$track_id = GETPOST('track_id', 'alpha', 3);
57$socid = GETPOSTINT('socid');
58$action = GETPOST('action', 'aZ09');
59
60// Store current page url
61$url_page_current = DOL_URL_ROOT.'/ticket/agenda.php';
62
63$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
64$sortfield = GETPOST('sortfield', 'aZ09comma');
65$sortorder = GETPOST('sortorder', 'aZ09comma');
66$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
67$page = is_numeric($page) ? $page : 0;
68$page = $page == -1 ? 0 : $page;
69if (!$sortfield) {
70 $sortfield = "a.datep,a.id";
71}
72if (!$sortorder) {
73 $sortorder = "DESC";
74}
75$offset = $limit * $page;
76$pageprev = $page - 1;
77$pagenext = $page + 1;
78
79if (GETPOST('actioncode', 'array')) {
80 $actioncode = GETPOST('actioncode', 'array', 3);
81 if (!count($actioncode)) {
82 $actioncode = '0';
83 }
84} else {
85 $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
86}
87
88$search_rowid = GETPOST('search_rowid');
89$search_agenda_label = GETPOST('search_agenda_label');
90
91$hookmanager->initHooks(array('ticketagenda', 'globalcard')); // Note that conf->hooks_modules contains array
92$object = new Ticket($db);
93$object->fetch($id, $ref, $track_id);
94
95$extrafields = new ExtraFields($db);
96
97$extrafields->fetch_name_optionals_label($object->table_element);
98
99if (!$action) {
100 $action = 'view';
101}
102
103$permissiontoadd = $user->hasRight('ticket', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles
104$permissiontomanage = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ticket', 'write')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('expedition', 'ticket', 'manage_advance'))); // What is this permission for ?
105
106// Security check
107$id = GETPOSTINT("id");
108if ($user->socid > 0) {
109 $socid = $user->socid;
110}
111$result = restrictedArea($user, 'ticket', $object->id, '');
112
113// restrict access for externals users
114if ($user->socid > 0 && ($object->fk_soc != $user->socid)) {
116}
117// or for unauthorized internals users
118if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $object->fk_user_assign != $user->id) && !$permissiontomanage) {
120}
121
122$permissiontoadd = $user->hasRight('ticket', 'write');
123
124
125/*
126 * Actions
127 */
128
129$parameters = array('id' => $socid);
130$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
131if ($reshook < 0) {
132 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
133}
134
135if (empty($reshook)) {
136 // Set view style
137 $_SESSION['ticket-view-type'] = "list";
138}
139
140// Purge search criteria
141if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
142 $actioncode = '';
143 $search_agenda_label = '';
144}
145
146// Set parent company
147if ($action == 'set_thirdparty' && $user->hasRight('ticket', 'write')) {
148 if ($object->fetch(GETPOSTINT('id'), '', GETPOST('track_id', 'alpha')) >= 0) {
149 $result = $object->setCustomer(GETPOSTINT('editcustomer'));
150 $url = $_SERVER["PHP_SELF"].'?track_id='.GETPOST('track_id', 'alpha');
151 header("Location: ".$url);
152 exit();
153 }
154}
155
156
157/*
158 * View
159 */
160
161$form = new Form($db);
162$userstat = new User($db);
163$formticket = new FormTicket($db);
164
165$title = $langs->trans("Ticket").' - '.$object->ref.' '.$object->name;
166if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/ticketnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
167 $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
168}
169$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|DE:Modul_Terminplanung';
170
171llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-ticket page-card_agenda');
172
173if ($socid > 0) {
174 $object->fetch_thirdparty();
175 $head = societe_prepare_head($object->thirdparty);
176
177 print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company');
178
179 dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
180
181 print dol_get_fiche_end();
182}
183
184if (!$user->socid && getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')) {
185 $object->next_prev_filter = "te.fk_user_assign:=:".((int) $user->id);
186} elseif ($user->socid > 0) {
187 $object->next_prev_filter = "te.fk_soc:=:".((int) $user->socid);
188}
189$head = ticket_prepare_head($object);
190
191print dol_get_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticket');
192
193$morehtmlref = '<div class="refidno">';
194$morehtmlref .= $object->subject;
195// Author
196if ($object->fk_user_create > 0) {
197 $morehtmlref .= '<br>';
198 //$morehtmlref .= '<span class="opacitymedium">'.$langs->trans("CreatedBy").'</span> ';
199 $langs->load("users");
200 $fuser = new User($db);
201 $fuser->fetch($object->fk_user_create);
202 $morehtmlref .= $fuser->getNomUrl(-1);
203} elseif (!empty($object->email_msgid)) {
204 $morehtmlref .= '<br>';
205 //$morehtmlref .= '<span class="opacitymedium">'.$langs->trans("CreatedBy").'</span> ';
206 $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
207 $morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')</small>';
208} elseif (!empty($object->origin_email)) {
209 $morehtmlref .= '<br>';
210 //$morehtmlref .= '<span class="opacitymedium">'.$langs->trans("CreatedBy").'</span> ';
211 $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
212 $morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$langs->trans("CreatedByPublicPortal").')</small>';
213}
214
215// Thirdparty
216if (isModEnabled("societe")) {
217 $morehtmlref .= '<br>';
218 $morehtmlref .= img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth"');
219 if ($action != 'editcustomer' && $permissiontoadd) {
220 $morehtmlref .= '<a class="editfielda" href="'.$url_page_current.'?action=editcustomer&token='.newToken().'&track_id='.$object->track_id.'">'.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).'</a> ';
221 }
222 $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, (string) $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1);
223}
224
225// Project
226if (isModEnabled('project')) {
227 $langs->load("projects");
228 if (0) { // @phpstan-ignore-line
229 $morehtmlref .= '<br>';
230 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
231 if ($action != 'classify') {
232 $morehtmlref .= '<a class="editfielda" href="'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
233 }
234 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
235 } else {
236 if (!empty($object->fk_project)) {
237 $morehtmlref .= '<br>';
238 $proj = new Project($db);
239 $proj->fetch($object->fk_project);
240 $morehtmlref .= $proj->getNomUrl(1);
241 if ($proj->title) {
242 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
243 }
244 }
245 }
246}
247
248$morehtmlref .= '</div>';
249
250$linkback = '<a href="'.DOL_URL_ROOT.'/ticket/list.php"><strong>'.$langs->trans("BackToList").'</strong></a> ';
251
252dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
253
254print dol_get_fiche_end();
255
256print '<br>';
257
258
259if (!empty($object->id)) {
260 $param = '&id='.$object->id;
261 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
262 $param .= '&contextpage='.$contextpage;
263 }
264 if ($limit > 0 && $limit != $conf->liste_limit) {
265 $param .= '&limit='.$limit;
266 }
267
268 $morehtmlright = '';
269
270 $messagingUrl = DOL_URL_ROOT.'/ticket/messaging.php?track_id='.$object->track_id;
271 $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1);
272 $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id;
273 $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 1, array('morecss' => 'btnTitleSelected'));
274
275 // Show link to send an email (if read and not closed)
276 $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
277 $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&private_message=0&send_email=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle';
278 $morehtmlright .= dolGetButtonTitle($langs->trans('SendMail'), '', 'fa fa-paper-plane', $url, 'email-title-button', (int) $btnstatus);
279
280 // Show link to add a message (if read and not closed)
281 $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
282 $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle';
283 $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', (int) $btnstatus);
284
285 // Show link to add event (if read and not closed)
286 $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
287 $url = DOL_URL_ROOT.'/comm/action/card.php?action=create&datep=now&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id);
288 $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, 'add-new-ticket-even-button', (int) $btnstatus);
289
290 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
291 $cachekey = 'count_events_ticket_'.$object->id;
292 $nbEvent = dol_getcache($cachekey);
293
294 $titlelist = $langs->trans("ActionsOnTicket").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>' : '');
295 if (!empty($conf->dol_optimize_smallscreen)) {
296 $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>' : '');
297 }
298
299 // Hook to let external modules add buttons to the object right toolbar. Works on any object page; the hook gets the context (elementtype) so a module can scope itself (e.g. only on event pages).
300 $parameters = array('morehtmlright' => &$morehtmlright, 'elementtype' => $object->element);
301 $reshook = $hookmanager->executeHooks('printObjectRightToolbar', $parameters, $object, $action);
302 if ($reshook < 0) {
303 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
304 } else {
305 $morehtmlright .= $hookmanager->resPrint;
306 }
307
308 print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
309
310 // List of all actions
311 $filters = array();
312 $filters['search_agenda_label'] = $search_agenda_label;
313 $filters['search_rowid'] = $search_rowid;
314
315 show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
316}
317
318// End of page
319llxFooter();
320$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage Dolibarr users.
show_actions_done($conf, $langs, $db, $filterobj, $objcon=null, $noprint=0, $actioncode='', $donetodo='done', $filters=array(), $sortfield='a.datep, a.id', $sortorder='DESC', $module='')
Show html area with actions (done or not, ignore the name of function).
societe_prepare_head(Societe $object, $subtabs='')
Return array of tabs to used on pages for third parties cards.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:519
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:717
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
Definition html.lib.php:172
dol_getcache($memoryid, $filecache=0)
Read a memory area shared by all users, all sessions on server.
Class to generate the form for creating a new ticket.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
ticket_prepare_head($object)
Build tabs for a Ticket object.