dolibarr 21.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 MDW <mdeweerd@users.noreply.github.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25// Load Dolibarr environment
26require '../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
33require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
34if (isModEnabled('project')) {
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
40// Load translation files required by the page
41$langs->loadLangs(array('companies', 'other', 'ticket'));
42
43// Get parameters
44$id = GETPOSTINT('id');
45$ref = GETPOST('ref', 'alpha');
46$track_id = GETPOST('track_id', 'alpha', 3);
47$socid = GETPOSTINT('socid');
48$action = GETPOST('action', 'aZ09');
49
50// Store current page url
51$url_page_current = DOL_URL_ROOT.'/ticket/agenda.php';
52
53$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
54$sortfield = GETPOST('sortfield', 'aZ09comma');
55$sortorder = GETPOST('sortorder', 'aZ09comma');
56$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
57$page = is_numeric($page) ? $page : 0;
58$page = $page == -1 ? 0 : $page;
59if (!$sortfield) {
60 $sortfield = "a.datep,a.id";
61}
62if (!$sortorder) {
63 $sortorder = "DESC";
64}
65$offset = $limit * $page;
66$pageprev = $page - 1;
67$pagenext = $page + 1;
68
69if (GETPOST('actioncode', 'array')) {
70 $actioncode = GETPOST('actioncode', 'array', 3);
71 if (!count($actioncode)) {
72 $actioncode = '0';
73 }
74} else {
75 $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
76}
77
78$search_rowid = GETPOST('search_rowid');
79$search_agenda_label = GETPOST('search_agenda_label');
80
81$hookmanager->initHooks(array('ticketagenda', 'globalcard')); // Note that conf->hooks_modules contains array
82$object = new Ticket($db);
83$object->fetch($id, $ref, $track_id);
84
85$extrafields = new ExtraFields($db);
86
87$extrafields->fetch_name_optionals_label($object->table_element);
88
89if (!$action) {
90 $action = 'view';
91}
92
93
94// Security check
95$id = GETPOSTINT("id");
96if ($user->socid > 0) {
97 $socid = $user->socid;
98}
99$result = restrictedArea($user, 'ticket', $object->id, '');
100
101// restrict access for externals users
102if ($user->socid > 0 && ($object->fk_soc != $user->socid)) {
104}
105// or for unauthorized internals users
106if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $object->fk_user_assign != $user->id) && !$user->hasRight('ticket', 'manage')) {
108}
109
110$permissiontoadd = $user->hasRight('ticket', 'write');
111
112
113/*
114 * Actions
115 */
116
117$parameters = array('id' => $socid);
118$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
119if ($reshook < 0) {
120 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
121}
122
123if (empty($reshook)) {
124 // Set view style
125 $_SESSION['ticket-view-type'] = "list";
126}
127
128// Purge search criteria
129if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
130 $actioncode = '';
131 $search_agenda_label = '';
132}
133
134// Set parent company
135if ($action == 'set_thirdparty' && $user->hasRight('ticket', 'write')) {
136 if ($object->fetch(GETPOSTINT('id'), '', GETPOST('track_id', 'alpha')) >= 0) {
137 $result = $object->setCustomer(GETPOSTINT('editcustomer'));
138 $url = $_SERVER["PHP_SELF"].'?track_id='.GETPOST('track_id', 'alpha');
139 header("Location: ".$url);
140 exit();
141 }
142}
143
144
145/*
146 * View
147 */
148
149$form = new Form($db);
150$userstat = new User($db);
151$formticket = new FormTicket($db);
152
153$title = $langs->trans("Ticket").' - '.$object->ref.' '.$object->name;
154if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/ticketnameonly/', getDolGlobalString('MAIN_HTML_TITLE')) && $object->name) {
155 $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
156}
157$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|DE:Modul_Terminplanung';
158
159llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-ticket page-card_agenda');
160
161if ($socid > 0) {
162 $object->fetch_thirdparty();
163 $head = societe_prepare_head($object->thirdparty);
164
165 print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company');
166
167 dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom');
168
169 print dol_get_fiche_end();
170}
171
172if (!$user->socid && getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY')) {
173 $object->next_prev_filter = "te.fk_user_assign = ".((int) $user->id);
174} elseif ($user->socid > 0) {
175 $object->next_prev_filter = "te.fk_soc = ".((int) $user->socid);
176}
177$head = ticket_prepare_head($object);
178
179print dol_get_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticket');
180
181$morehtmlref = '<div class="refidno">';
182$morehtmlref .= $object->subject;
183// Author
184if ($object->fk_user_create > 0) {
185 $morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
186
187 $langs->load("users");
188 $fuser = new User($db);
189 $fuser->fetch($object->fk_user_create);
190 $morehtmlref .= $fuser->getNomUrl(-1);
191} elseif (!empty($object->email_msgid)) {
192 $morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
193 $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
194 $morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')</small>';
195} elseif (!empty($object->origin_email)) {
196 $morehtmlref .= '<br>'.$langs->trans("CreatedBy").' : ';
197 $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
198 $morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$langs->trans("CreatedByPublicPortal").')</small>';
199}
200
201// Thirdparty
202if (isModEnabled("societe")) {
203 $morehtmlref .= '<br>';
204 $morehtmlref .= img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth"');
205 if ($action != 'editcustomer' && $permissiontoadd) {
206 $morehtmlref .= '<a class="editfielda" href="'.$url_page_current.'?action=editcustomer&token='.newToken().'&track_id='.$object->track_id.'">'.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).'</a> ';
207 }
208 $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1);
209}
210
211// Project
212if (isModEnabled('project')) {
213 $langs->load("projects");
214 if (0) {
215 $morehtmlref .= '<br>';
216 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
217 if ($action != 'classify') {
218 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
219 }
220 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
221 } else {
222 if (!empty($object->fk_project)) {
223 $morehtmlref .= '<br>';
224 $proj = new Project($db);
225 $proj->fetch($object->fk_project);
226 $morehtmlref .= $proj->getNomUrl(1);
227 if ($proj->title) {
228 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
229 }
230 }
231 }
232}
233
234$morehtmlref .= '</div>';
235
236$linkback = '<a href="'.DOL_URL_ROOT.'/ticket/list.php"><strong>'.$langs->trans("BackToList").'</strong></a> ';
237
238dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
239
240print dol_get_fiche_end();
241
242print '<br>';
243
244
245if (!empty($object->id)) {
246 $param = '&id='.$object->id;
247 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
248 $param .= '&contextpage='.$contextpage;
249 }
250 if ($limit > 0 && $limit != $conf->liste_limit) {
251 $param .= '&limit='.$limit;
252 }
253
254 $morehtmlright = '';
255
256 $messagingUrl = DOL_URL_ROOT.'/ticket/messaging.php?track_id='.$object->track_id;
257 $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1);
258 $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id;
259 $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 1, array('morecss' => 'btnTitleSelected'));
260
261 // Show link to send an email (if read and not closed)
262 $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
263 $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';
264 $morehtmlright .= dolGetButtonTitle($langs->trans('SendMail'), '', 'fa fa-paper-plane', $url, 'email-title-button', (int) $btnstatus);
265
266 // Show link to add a message (if read and not closed)
267 $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
268 $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id).'#formmailbeforetitle';
269 $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', (int) $btnstatus);
270
271 // Show link to add event (if read and not closed)
272 $btnstatus = $object->status < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage";
273 $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);
274 $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, 'add-new-ticket-even-button', (int) $btnstatus);
275
276 require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
277 $cachekey = 'count_events_ticket_'.$object->id;
278 $nbEvent = dol_getcache($cachekey);
279
280 $titlelist = $langs->trans("ActionsOnTicket").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>' : '');
281 if (!empty($conf->dol_optimize_smallscreen)) {
282 $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>' : '');
283 }
284
285 print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
286
287 // List of all actions
288 $filters = array();
289 $filters['search_agenda_label'] = $search_agenda_label;
290 $filters['search_rowid'] = $search_rowid;
291
292 show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
293}
294
295// End of page
296llxFooter();
297$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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:70
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)
Return array of tabs to used on pages for third parties cards.
llxFooter()
Footer empty.
Definition document.php:107
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)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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.
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)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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...
dol_getcache($memoryid)
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.