dolibarr 24.0.0-beta
calendar_agenda.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023 Alice Adminson <aadminson@example.com>
4 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php';
41require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_calendar.lib.php';
42
43// Load translation files required by the page
44$langs->loadLangs(array("agenda", "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 == -1) {
70 $page = 0;
71} // If $page is not defined, or '' or -1
72$offset = $limit * $page;
73$pageprev = $page - 1;
74$pagenext = $page + 1;
75if (!$sortfield) {
76 $sortfield = 'a.datep,a.id';
77}
78if (!$sortorder) {
79 $sortorder = 'DESC,DESC';
80}
81
82// Initialize a technical objects
83$object = new Calendar($db);
84$diroutputmassaction = $conf->bookcal->dir_output.'/temp/massgeneration/'.$user->id;
85$hookmanager->initHooks(array('calendaragenda', 'globalcard')); // Note that conf->hooks_modules contains array
86// Fetch optionals attributes and labels
87$extrafields->fetch_name_optionals_label($object->table_element);
88
89// Load object
90include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'. Include fetch and fetch_thirdparty but not fetch_optionals
91if ($id > 0 || !empty($ref)) {
92 $upload_dir = $conf->bookcal->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id;
93}
94
95// There is several ways to check permission.
96// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
97$enablepermissioncheck = 0;
98if ($enablepermissioncheck) {
99 $permissiontoread = $user->hasRight('bookcal', 'calendar', 'read');
100 $permissiontoadd = $user->hasRight('bookcal', 'calendar', 'write');
101} else {
102 $permissiontoread = 1;
103 $permissiontoadd = 1;
104}
105
106// Security check (enable the most restrictive one)
107//if ($user->socid > 0) accessforbidden();
108//if ($user->socid > 0) $socid = $user->socid;
109//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
110//restrictedArea($user, $object->module, $object->id, $object->table_element, $object->element, 'fk_soc', 'rowid', $isdraft);
111if (!isModEnabled("bookcal")) {
113}
114if (!$permissiontoread) {
116}
117
118
119/*
120 * Actions
121 */
122
123$parameters = array('id' => $id);
124$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
125if ($reshook < 0) {
126 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
127}
128
129if (empty($reshook)) {
130 // Cancel
131 if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
132 header("Location: ".$backtopage);
133 exit;
134 }
135
136 // Purge search criteria
137 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
138 $actioncode = '';
139 $search_agenda_label = '';
140 }
141}
142
143
144
145/*
146 * View
147 */
148
149$form = new Form($db);
150
151if ($object->id > 0) {
152 $title = $langs->trans("Agenda");
153 $help_url = 'EN:Module_Agenda_En|DE:Modul_Terminplanung';
154 llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-bookcal page-card_calendar_agenda');
155
156 if (isModEnabled('notification')) {
157 $langs->load("mails");
158 }
159 $head = calendarPrepareHead($object);
160
161
162 print dol_get_fiche_head($head, 'agenda', $langs->trans("Calendar"), -1, $object->picto);
163
164 // Object card
165 // ------------------------------------------------------------
166 $linkback = '<a href="'.dol_buildpath('/bookcal/calendar_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
167
168 $morehtmlref = '<div class="refidno">';
169 /*
170 // Ref customer
171 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
172 $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
173 // Thirdparty
174 $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
175 // Project
176 if (isModEnabled('project')) {
177 $langs->load("projects");
178 $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
179 if ($permissiontoadd) {
180 if ($action != 'classify') {
181 //$morehtmlref.='<a class="editfielda" href="' . dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true) . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
182 }
183 $morehtmlref.=' : ';
184 if ($action == 'classify') {
185 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
186 $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
187 $morehtmlref.='<input type="hidden" name="action" value="classin">';
188 $morehtmlref.='<input type="hidden" name="token" value="'.newToken().'">';
189 $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
190 $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
191 $morehtmlref.='</form>';
192 } else {
193 $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
194 }
195 } else {
196 if (!empty($object->fk_project)) {
197 $proj = new Project($db);
198 $proj->fetch($object->fk_project);
199 $morehtmlref .= ': '.$proj->getNomUrl();
200 } else {
201 $morehtmlref .= '';
202 }
203 }
204 }*/
205 $morehtmlref .= '</div>';
206
207
208 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
209
210 print '<div class="fichecenter">';
211 print '<div class="underbanner clearboth"></div>';
212
213 $object->info($object->id);
214 dol_print_object_info($object, 1);
215
216 print '</div>';
217
218 print dol_get_fiche_end();
219
220
221
222 // Actions buttons
223
224 $objthirdparty = $object;
225 $objcon = new stdClass();
226
227 $out = '&origin='.urlencode((string) ($object->element.(!empty($object->module) ? '@'.$object->module : ''))).'&originid='.urlencode((string) ($object->id));
228 $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id;
229 $out .= '&backtopage='.urlencode($urlbacktopage);
230 $permok = $user->hasRight('agenda', 'myactions', 'create');
231 if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) {
232 //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
233 if (get_class($objthirdparty) == 'Societe') {
234 $out .= '&socid='.urlencode((string) ($objthirdparty->id));
235 }
236 $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : '');
237 //$out.=$langs->trans("AddAnAction").' ';
238 //$out.=img_picto($langs->trans("AddAnAction"),'filenew');
239 //$out.="</a>";
240 }
241
242 $morehtmlright = '';
243
244 //$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?socid='.$object->id;
245 //$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1);
246 //$messagingUrl = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
247 //$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2);
248
249 if (isModEnabled('agenda')) {
250 if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
251 $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
252 } else {
253 $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', 0);
254 }
255 }
256
257 /*
258 if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allactions', 'read'))) {
259 print '<br>';
260
261 $param = '&id='.$object->id.(!empty($socid) ? '&socid='.$socid : '');
262 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
263 $param .= '&contextpage='.urlencode($contextpage);
264 }
265 if ($limit > 0 && $limit != $conf->liste_limit) {
266 $param .= '&limit='.((int) $limit);
267 }
268
269 // Try to know count of actioncomm from cache
270 $nbEvent = 0;
271 //require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
272 //$cachekey = 'count_events_myobject_'.$object->id;
273 //$nbEvent = dol_getcache($cachekey);
274 $titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>': '');
275
276 print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
277
278 // List of all actions
279 $filters = array();
280 $filters['search_agenda_label'] = $search_agenda_label;
281 $filters['search_rowid'] = $search_rowid;
282
283 // TODO Replace this with same code than into list.php
284 show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, !empty($object->module) ? $object->module : '');
285 }
286 */
287}
288
289// End of page
290llxFooter();
291$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
calendarPrepareHead($object)
Prepare array of tabs for Calendar.
Class for Calendar.
Class to manage generation of HTML components Only common components must be here.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
isModEnabled($module)
Is Dolibarr module enabled.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.