dolibarr 21.0.0-beta
document.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
7 * Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
8 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
35require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
36require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
40if (isModEnabled('project')) {
41 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
42}
43
52// Load translation files required by the page
53$langs->loadLangs(array('companies', 'commercial', 'other', 'bills'));
54
55$id = GETPOSTINT('id');
56$action = GETPOST('action', 'aZ09');
57$confirm = GETPOST('confirm', 'alpha');
58
59// Security check
60$socid = GETPOSTINT('socid');
61if ($user->socid) {
62 $socid = $user->socid;
63}
64if ($user->socid > 0) {
65 $action = '';
66}
67
68$object = new ActionComm($db);
69
70if ($id > 0) {
71 $ret = $object->fetch($id);
72 $object->fetch_thirdparty();
73}
74
75// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
76$hookmanager->initHooks(array('actioncard', 'globalcard'));
77
78// Get parameters
79$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
80$sortfield = GETPOST('sortfield', 'aZ09comma');
81$sortorder = GETPOST('sortorder', 'aZ09comma');
82$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
83if (empty($page) || $page == -1) {
84 $page = 0;
85} // If $page is not defined, or '' or -1
86$offset = $limit * $page;
87$pageprev = $page - 1;
88$pagenext = $page + 1;
89if (!$sortorder) {
90 $sortorder = "ASC";
91}
92if (!$sortfield) {
93 $sortfield = "name";
94}
95
96$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
97$modulepart = 'actions';
98
99$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
100if ($user->socid && $socid) {
101 $result = restrictedArea($user, 'societe', $socid);
102}
103
104$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'));
105$permissiontoadd = $usercancreate;
106
107
108/*
109 * Actions
110 */
111
112include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
113
114
115/*
116 * View
117 */
118
119$form = new Form($db);
120
121$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
122
123llxHeader('', $langs->trans("Agenda"), $help_url);
124
125$now = dol_now();
126$delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
127
128if ($object->id > 0) {
129 $result1 = $object->fetch($id);
130 $result2 = $object->fetch_thirdparty();
131 $result3 = $object->fetch_contact();
132 $result4 = $object->fetch_userassigned();
133 $result5 = $object->fetch_optionals();
134
135 if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
136 dol_print_error($db, $object->error);
137 exit;
138 }
139
140 if ($object->authorid > 0) {
141 $tmpuser = new User($db);
142 $res = $tmpuser->fetch($object->authorid);
143 $object->author = $tmpuser;
144 }
145 if ($object->usermodid > 0) {
146 $tmpuser = new User($db);
147 $res = $tmpuser->fetch($object->usermodid);
148 $object->usermod = $tmpuser;
149 }
150
151 $author = new User($db);
152 $author->fetch($object->author->id);
153 $object->author = $author;
154
155
156 $head = actions_prepare_head($object);
157
158 print dol_get_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action');
159
160 // Link to other agenda views
161 $linkback = '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
162 $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"');
163 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("BackToList").'</span>';
164 $linkback .= '</a>';
165 $linkback .= '</li>';
166 $linkback .= '<li class="noborder litext">';
167 $linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
168 $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"');
169 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewCal").'</span>';
170 $linkback .= '</a>';
171 $linkback .= '</li>';
172 $linkback .= '<li class="noborder litext">';
173 $linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
174 $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"');
175 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewWeek").'</span>';
176 $linkback .= '</a>';
177 $linkback .= '</li>';
178 $linkback .= '<li class="noborder litext">';
179 $linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/index.php?mode=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
180 $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"');
181 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewDay").'</span>';
182 $linkback .= '</a>';
183 $linkback .= '</li>';
184 $linkback .= '<li class="noborder litext">';
185 $linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/peruser.php?mode=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
186 $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"');
187 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewPerUser").'</span>';
188 $linkback .= '</a>';
189
190 // Add more views from hooks
191 $parameters = array();
192 $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
193 if (empty($reshook)) {
194 $linkback .= $hookmanager->resPrint;
195 } elseif ($reshook > 1) {
196 $linkback = $hookmanager->resPrint;
197 }
198
199 $morehtmlref = '<div class="refidno">';
200 // Thirdparty
201 //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
202 // Project
203 if (isModEnabled('project')) {
204 $langs->load("projects");
205 //$morehtmlref .= '<br>';
206 if (0) {
207 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
208 if ($action != 'classify') {
209 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
210 }
211 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
212 } else {
213 if (!empty($object->fk_project)) {
214 $proj = new Project($db);
215 $proj->fetch($object->fk_project);
216 $morehtmlref .= $proj->getNomUrl(1);
217 if ($proj->title) {
218 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
219 }
220 }
221 }
222 }
223 $morehtmlref .= '</div>';
224
225 dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'id', 'ref', $morehtmlref);
226
227 print '<div class="fichecenter">';
228
229 print '<div class="underbanner clearboth"></div>';
230
231 // Affichage fiche action en mode visu
232 print '<table class="border tableforfield centpercent">';
233
234 // Type of event
235 if (getDolGlobalString('AGENDA_USE_EVENT_TYPE')) {
236 print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">';
237 print $object->getTypePicto();
238 print $langs->trans("Action".$object->type_code);
239 print '</td></tr>';
240 }
241
242 // Full day event
243 print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>';
244
245 // Date start
246 print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">';
247 if (empty($object->fulldayevent)) {
248 print dol_print_date($object->datep, 'dayhour', 'tzuser');
249 } else {
250 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
251 print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
252 }
253 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
254 print img_warning($langs->trans("Late"));
255 }
256 print '</td>';
257 print '</tr>';
258
259 // Date end
260 print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">';
261 if (empty($object->fulldayevent)) {
262 print dol_print_date($object->datef, 'dayhour', 'tzuser');
263 } else {
264 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
265 print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
266 }
267 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
268 print img_warning($langs->trans("Late"));
269 }
270 print '</td></tr>';
271
272 // Location
273 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION')) {
274 print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$object->location.'</td></tr>';
275 }
276
277 // Assigned to
278 print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
279 $listofuserid = array();
280 if (empty($donotclearsession)) {
281 if ($object->userownerid > 0) {
282 $listofuserid[$object->userownerid] = array('id' => $object->userownerid, 'transparency' => $object->transparency); // Owner first
283 }
284 if (!empty($object->userassigned)) { // Now concat assigned users
285 // Restore array with key with same value than param 'id'
286 $tmplist1 = $object->userassigned;
287 foreach ($tmplist1 as $key => $val) {
288 if ($val['id'] && $val['id'] != $object->userownerid) {
289 $listofuserid[$val['id']] = $val;
290 }
291 }
292 }
293 $_SESSION['assignedtouser'] = json_encode($listofuserid);
294 } else {
295 if (!empty($_SESSION['assignedtouser'])) {
296 $listofuserid = json_decode($_SESSION['assignedtouser'], true);
297 }
298 }
299 $listofcontactid = array(); // not used yet
300 $listofotherid = array(); // not used yet
301 print '<div class="assignedtouser">';
302 print $form->select_dolusers_forevent('view', 'assignedtouser', 1, array(), 0, '', array(), 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
303 print '</div>';
304 /*if (in_array($user->id,array_keys($listofuserid)))
305 {
306 print '<div class="myavailability">';
307 print $langs->trans("MyAvailability").': '.(($object->userassigned[$user->id]['transparency'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody
308 print '</div>';
309 }*/
310 print ' </td></tr>';
311
312 print '</table>';
313
314 print '<table class="border tableforfield centpercent">';
315
316 // Build file list
317 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
318 $totalsize = 0;
319 foreach ($filearray as $key => $file) {
320 $totalsize += $file['size'];
321 }
322
323
324 print '<tr><td class="titlefield" class="nowrap">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
325 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
326
327 print '</table>';
328
329 print '</div>';
330
331 print dol_get_fiche_end();
332
333
334 $modulepart = 'actions';
335 $permissiontoadd = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create');
336 $param = '&id='.$object->id;
337 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
338} else {
339 print $langs->trans("ErrorUnknown");
340}
341
342// End of page
343llxFooter();
344$db->close();
$id
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
actions_prepare_head($object)
Prepare array with list of tabs.
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:71
Class to manage agenda events (actions)
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage Dolibarr users.
llxFooter()
Footer empty.
Definition document.php:107
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:63
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.