dolibarr 18.0.6
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 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
33require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
34require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
35require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
38if (isModEnabled('project')) {
39 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
40}
41
42// Load translation files required by the page
43$langs->loadLangs(array('companies', 'commercial', 'other', 'bills'));
44
45$id = GETPOST('id', 'int');
46$action = GETPOST('action', 'aZ09');
47$confirm = GETPOST('confirm', 'alpha');
48
49// Security check
50$socid = GETPOST('socid', 'int');
51if ($user->socid) {
52 $socid = $user->socid;
53}
54if ($user->socid > 0) {
55 unset($_GET["action"]);
56 $action = '';
57}
58
59$object = new ActionComm($db);
60
61if ($id > 0) {
62 $ret = $object->fetch($id);
63 $object->fetch_thirdparty();
64}
65
66// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
67$hookmanager->initHooks(array('actioncard', 'globalcard'));
68
69// Get parameters
70$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
71$sortfield = GETPOST('sortfield', 'aZ09comma');
72$sortorder = GETPOST('sortorder', 'aZ09comma');
73$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
74if (empty($page) || $page == -1) {
75 $page = 0;
76} // If $page is not defined, or '' or -1
77$offset = $limit * $page;
78$pageprev = $page - 1;
79$pagenext = $page + 1;
80if (!$sortorder) {
81 $sortorder = "ASC";
82}
83if (!$sortfield) {
84 $sortfield = "name";
85}
86
87$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
88$modulepart = 'actions';
89
90$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
91if ($user->socid && $socid) {
92 $result = restrictedArea($user, 'societe', $socid);
93}
94
95$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'));
96$permissiontoadd = $usercancreate;
97
98
99/*
100 * Actions
101 */
102
103include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
104
105
106/*
107 * View
108 */
109
110$form = new Form($db);
111
112$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
113
114llxHeader('', $langs->trans("Agenda"), $help_url);
115
116$now = dol_now();
117$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
118
119if ($object->id > 0) {
120 $result1 = $object->fetch($id);
121 $result2 = $object->fetch_thirdparty();
122 $result3 = $object->fetch_contact();
123 $result4 = $object->fetch_userassigned();
124 $result5 = $object->fetch_optionals();
125
126 if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
127 dol_print_error($db, $object->error);
128 exit;
129 }
130
131 if ($object->authorid > 0) {
132 $tmpuser = new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser;
133 }
134 if ($object->usermodid > 0) {
135 $tmpuser = new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser;
136 }
137
138 $author = new User($db);
139 $author->fetch($object->author->id);
140 $object->author = $author;
141
142
143 $head = actions_prepare_head($object);
144
145 print dol_get_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action');
146
147 $linkback = img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="hideonsmartphone pictoactionview"');
148 $linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list">'.$langs->trans("BackToList").'</a>';
149
150 // Link to other agenda views
151 $out = '';
152 $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="hideonsmartphone pictoactionview"');
153 $out .= '<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').'">'.$langs->trans("ViewPerUser").'</a>';
154 $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewCal"), 'object_calendarmonth', 'class="hideonsmartphone pictoactionview"');
155 $out .= '<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').'">'.$langs->trans("ViewCal").'</a>';
156 $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="hideonsmartphone pictoactionview"');
157 $out .= '<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').'">'.$langs->trans("ViewWeek").'</a>';
158 $out .= '</li><li class="noborder litext">'.img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="hideonsmartphone pictoactionview"');
159 $out .= '<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').'">'.$langs->trans("ViewDay").'</a>';
160
161 // Add more views from hooks
162 $parameters = array();
163 $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
164 if (empty($reshook)) {
165 $out .= $hookmanager->resPrint;
166 } elseif ($reshook > 1) {
167 $out = $hookmanager->resPrint;
168 }
169
170 $linkback .= $out;
171
172 $morehtmlref = '<div class="refidno">';
173 // Thirdparty
174 //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
175 // Project
176 if (isModEnabled('project')) {
177 $langs->load("projects");
178 //$morehtmlref .= '<br>';
179 if (0) {
180 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
181 if ($action != 'classify') {
182 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
183 }
184 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
185 } else {
186 if (!empty($object->fk_project)) {
187 $proj = new Project($db);
188 $proj->fetch($object->fk_project);
189 $morehtmlref .= $proj->getNomUrl(1);
190 if ($proj->title) {
191 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
192 }
193 }
194 }
195 }
196 $morehtmlref .= '</div>';
197
198 dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'id', 'ref', $morehtmlref);
199
200 print '<div class="fichecenter">';
201
202 print '<div class="underbanner clearboth"></div>';
203
204 // Affichage fiche action en mode visu
205 print '<table class="border tableforfield centpercent">';
206
207 // Type of event
208 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
209 print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">';
210 print $object->getTypePicto();
211 print $langs->trans("Action".$object->type_code);
212 print '</td></tr>';
213 }
214
215 // Full day event
216 print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>';
217
218 // Date start
219 print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">';
220 if (empty($object->fulldayevent)) {
221 print dol_print_date($object->datep, 'dayhour', 'tzuser');
222 } else {
223 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
224 print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
225 }
226 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
227 print img_warning($langs->trans("Late"));
228 }
229 print '</td>';
230 print '</tr>';
231
232 // Date end
233 print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">';
234 if (empty($object->fulldayevent)) {
235 print dol_print_date($object->datef, 'dayhour', 'tzuser');
236 } else {
237 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
238 print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
239 }
240 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
241 print img_warning($langs->trans("Late"));
242 }
243 print '</td></tr>';
244
245 // Location
246 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
247 print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$object->location.'</td></tr>';
248 }
249
250 // Assigned to
251 print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
252 $listofuserid = array();
253 if (empty($donotclearsession)) {
254 if ($object->userownerid > 0) {
255 $listofuserid[$object->userownerid] = array('id'=>$object->userownerid, 'transparency'=>$object->transparency); // Owner first
256 }
257 if (!empty($object->userassigned)) { // Now concat assigned users
258 // Restore array with key with same value than param 'id'
259 $tmplist1 = $object->userassigned;
260 foreach ($tmplist1 as $key => $val) {
261 if ($val['id'] && $val['id'] != $object->userownerid) {
262 $listofuserid[$val['id']] = $val;
263 }
264 }
265 }
266 $_SESSION['assignedtouser'] = json_encode($listofuserid);
267 } else {
268 if (!empty($_SESSION['assignedtouser'])) {
269 $listofuserid = json_decode($_SESSION['assignedtouser'], true);
270 }
271 }
272 $listofcontactid = array(); // not used yet
273 $listofotherid = array(); // not used yet
274 print '<div class="assignedtouser">';
275 print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
276 print '</div>';
277 /*if (in_array($user->id,array_keys($listofuserid)))
278 {
279 print '<div class="myavailability">';
280 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
281 print '</div>';
282 }*/
283 print ' </td></tr>';
284
285 print '</table>';
286
287 print '<table class="border tableforfield centpercent">';
288
289 // Build file list
290 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
291 $totalsize = 0;
292 foreach ($filearray as $key => $file) {
293 $totalsize += $file['size'];
294 }
295
296
297 print '<tr><td class="titlefield" class="nowrap">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
298 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
299
300 print '</table>';
301
302 print '</div>';
303
304 print dol_get_fiche_end();
305
306
307 $modulepart = 'actions';
308 $permissiontoadd = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create');
309 $param = '&id='.$object->id;
310 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
311} else {
312 print $langs->trans("ErrorUnknown");
313}
314
315// End of page
316llxFooter();
317$db->close();
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()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
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.
dol_dir_list($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:62
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
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.