dolibarr 25.0.0-alpha
agenda.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
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
26require '../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
36require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
37require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
38require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
39require_once DOL_DOCUMENT_ROOT . '/core/lib/propal.lib.php';
40require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
41
42
43// Load translation files required by the page
44$langs->loadLangs(array("propal", "other"));
45
46// Get parameters
47$id = GETPOSTINT('id');
48$ref = GETPOST('ref', 'alpha');
49$action = GETPOST('action', 'aZ09');
50$cancel = GETPOST('cancel', 'alpha');
51$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)) . basename(__FILE__, '.php')); // To manage different context of search
52$backtopage = GETPOST('backtopage', 'alpha');
53
54if (GETPOST('actioncode', 'array')) {
55 $actioncode = GETPOST('actioncode', 'array', 3);
56 if (!count($actioncode)) {
57 $actioncode = '0';
58 }
59} else {
60 $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
61}
62$search_rowid = GETPOST('search_rowid');
63$search_agenda_label = GETPOST('search_agenda_label');
64
65$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
66$sortfield = GETPOST('sortfield', 'aZ09comma');
67$sortorder = GETPOST('sortorder', 'aZ09comma');
68$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT('page');
69if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
70 // If $page is not defined, or '' or -1 or if we click on clear filters
71 $page = 0;
72}
73$offset = $limit * $page;
74$pageprev = $page - 1;
75$pagenext = $page + 1;
76if (!$sortfield) {
77 $sortfield = 'a.datep,a.id';
78}
79if (!$sortorder) {
80 $sortorder = 'DESC,DESC';
81}
82
83// Initialize a technical objects
84$object = new Propal($db);
85$diroutputmassaction = $conf->propal->multidir_output[$conf->entity] . '/temp/massgeneration/' . $user->id;
86$hookmanager->initHooks(array('propalagenda', 'globalcard')); // Note that conf->hooks_modules contains array
87// Fetch optionals attributes and labels
88$extrafields->fetch_name_optionals_label($object->table_element);
89
90// Load object
91include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
92if ($id > 0 || !empty($ref)) {
93 $upload_dir = $conf->propal->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity] . "/" . $object->id;
94}
95
96$permissiontoread = $user->hasRight("propal", "lire");
97$permissiontoadd = $user->hasRight("propal", "creer");
98
99// Security check
100$socid = '';
101if (!empty($user->socid)) {
102 $socid = $user->socid;
103}
104$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
105restrictedArea($user, 'propal', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
106
107
108/*
109 * Actions
110 */
111
112$parameters = array('id' => $id);
113$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
114if ($reshook < 0) {
115 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
116}
117
118if (empty($reshook)) {
119 // Cancel
120 if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
121 header("Location: " . $backtopage);
122 exit;
123 }
124
125 // Purge search criteria
126 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
127 $actioncode = '';
128 $search_agenda_label = '';
129 }
130}
131
132
133
134/*
135 * View
136 */
137
138$form = new Form($db);
139
140if ($object->id > 0) {
141 $title = $langs->trans("Agenda");
142 $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung';
143 llxHeader('', $title, $help_url);
144
145 if (isModEnabled('notification')) {
146 $langs->load("mails");
147 }
148 $head = propal_prepare_head($object);
149
150
151 print dol_get_fiche_head($head, 'agenda', $langs->trans("Proposal"), -1, $object->picto);
152
153 // Object card
154 // ------------------------------------------------------------
155 $query = ['restore_lastsearch_values' => 1];
156 if (!empty($socid) && $socid > 0) {
157 $query += ['socid' => $socid];
158 }
159 $linkback = '<a href="' . dolBuildUrl(DOL_URL_ROOT . '/comm/propal/list.php', $query) . '">' . $langs->trans("BackToList") . '</a>';
160
161 $morehtmlref = '<div class="refidno">';
162 // Ref customer
163 $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_customer, $object, 0, 'string', '', 0, 1);
164 $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1);
165 // Thirdparty
166 $morehtmlref .= '<br>' . $object->thirdparty->getNomUrl(1);
167 // Project
168 if (isModEnabled('project')) {
169 $langs->load("projects");
170 $morehtmlref .= '<br>';
171 if (0) { // @phpstan-ignore-line
172 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
173 if ($action != 'classify') {
174 $morehtmlref .= '<a class="editfielda" href="' . dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true) . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
175 }
176 $morehtmlref .= $form->form_project(dolBuildUrl($_SERVER['PHP_SELF'], ['id' => $object->id]), $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
177 } else {
178 if (!empty($object->fk_project)) {
179 $proj = new Project($db);
180 $proj->fetch($object->fk_project);
181 $morehtmlref .= $proj->getNomUrl(1);
182 if ($proj->title) {
183 $morehtmlref .= '<span class="opacitymedium"> - ' . dol_escape_htmltag($proj->title) . '</span>';
184 }
185 }
186 }
187 }
188 $morehtmlref .= '</div>';
189
190
191 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
192
193 print '<div class="fichecenter">';
194 print '<div class="underbanner clearboth"></div>';
195
196 $object->info($object->id);
197 dol_print_object_info($object, 1);
198
199 print '</div>';
200
201 print dol_get_fiche_end();
202
203
204
205 // Actions buttons
206
207 $objthirdparty = $object;
208 $objcon = new stdClass();
209
210 $query = [
211 'action' => 'create',
212 'origin' => ($object->element . (property_exists($object, 'module') && !empty($object->module) ? '@' . $object->module : '')),
213 'originid' => $object->id,
214 'backtopage' => dolBuildUrl($_SERVER['PHP_SELF'], ['id' => $object->id]),
215 ];
216 $permok = $user->hasRight('agenda', 'myactions', 'create');
217 if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
218 //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
219 if (get_class($objthirdparty) == 'Societe') {
220 $query += ['socid' => $objthirdparty->id];
221 }
222 if (!empty($objcon->id)) {
223 $query += ['contactid' => $objcon->id];
224 }
225 //$out.=$langs->trans("AddAnAction").' ';
226 //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
227 //$out.="</a>";
228 }
229 $url = dolBuildUrl(DOL_URL_ROOT . '/comm/action/card.php', $query);
230
231 $morehtmlright = '';
232
233
234 //$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id;
235 //$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1);
236 //$messagingUrl = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
237 //$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2);
238
239 $messagingUrl = dolBuildUrl(DOL_URL_ROOT . '/comm/propal/messaging.php', ['id' => $object->id]);
240 $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1);
241
242 $messagingUrl = dolBuildUrl(DOL_URL_ROOT . '/comm/propal/agenda.php', ['id' => $object->id]);
243 $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2);
244
245
246 if (isModEnabled('agenda')) {
247 if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
248 $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url);
249 } else {
250 $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', 0);
251 }
252 }
253
254 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
255 print '<br>';
256
257 $param = '&id=' . $object->id . (!empty($socid) ? '&socid=' . $socid : '');
258 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
259 $param .= '&contextpage=' . urlencode($contextpage);
260 }
261 if ($limit > 0 && $limit != $conf->liste_limit) {
262 $param .= '&limit=' . ((int) $limit);
263 }
264
265 // Try to know count of actioncomm from cache
266 require_once DOL_DOCUMENT_ROOT . '/core/lib/memory.lib.php';
267 $cachekey = 'count_events_propal_' . $object->id;
268 $nbEvent = dol_getcache($cachekey);
269
270 // 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).
271 $parameters = array('morehtmlright' => &$morehtmlright, 'elementtype' => $object->element);
272 $reshook = $hookmanager->executeHooks('printObjectRightToolbar', $parameters, $object, $action);
273 if ($reshook < 0) {
274 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
275 } else {
276 $morehtmlright .= $hookmanager->resPrint;
277 }
278
279 print_barre_liste($langs->trans("ActionsOnPropal") . (is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">(' . $nbEvent . ')</span>' : ''), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
280 //print_barre_liste($langs->trans("ActionsOnPropal"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1);
281
282 // List of all actions
283 $filters = array();
284 $filters['search_agenda_label'] = $search_agenda_label;
285 $filters['search_rowid'] = $search_rowid;
286
287 // TODO Replace this with same code than into list.php
288 show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, !empty($object->module) ? $object->module : '');
289 }
290}
291
292// End of page
293llxFooter();
294$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 generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage proposals.
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).
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.
dol_print_object_info($object, $usetable=0)
Show information on an object TODO Move this into html.formother.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
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.
propal_prepare_head($object)
Prepare array with list of tabs.
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.