dolibarr 20.0.0
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 = GETPOSTINT('id');
46$action = GETPOST('action', 'aZ09');
47$confirm = GETPOST('confirm', 'alpha');
48
49// Security check
50$socid = GETPOSTINT('socid');
51if ($user->socid) {
52 $socid = $user->socid;
53}
54if ($user->socid > 0) {
55 $action = '';
56}
57
58$object = new ActionComm($db);
59
60if ($id > 0) {
61 $ret = $object->fetch($id);
62 $object->fetch_thirdparty();
63}
64
65// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
66$hookmanager->initHooks(array('actioncard', 'globalcard'));
67
68// Get parameters
69$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
70$sortfield = GETPOST('sortfield', 'aZ09comma');
71$sortorder = GETPOST('sortorder', 'aZ09comma');
72$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
73if (empty($page) || $page == -1) {
74 $page = 0;
75} // If $page is not defined, or '' or -1
76$offset = $limit * $page;
77$pageprev = $page - 1;
78$pagenext = $page + 1;
79if (!$sortorder) {
80 $sortorder = "ASC";
81}
82if (!$sortfield) {
83 $sortfield = "name";
84}
85
86$upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
87$modulepart = 'actions';
88
89$result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
90if ($user->socid && $socid) {
91 $result = restrictedArea($user, 'societe', $socid);
92}
93
94$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'));
95$permissiontoadd = $usercancreate;
96
97
98/*
99 * Actions
100 */
101
102include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
103
104
105/*
106 * View
107 */
108
109$form = new Form($db);
110
111$help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
112
113llxHeader('', $langs->trans("Agenda"), $help_url);
114
115$now = dol_now();
116$delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
117
118if ($object->id > 0) {
119 $result1 = $object->fetch($id);
120 $result2 = $object->fetch_thirdparty();
121 $result3 = $object->fetch_contact();
122 $result4 = $object->fetch_userassigned();
123 $result5 = $object->fetch_optionals();
124
125 if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
126 dol_print_error($db, $object->error);
127 exit;
128 }
129
130 if ($object->authorid > 0) {
131 $tmpuser = new User($db);
132 $res = $tmpuser->fetch($object->authorid);
133 $object->author = $tmpuser;
134 }
135 if ($object->usermodid > 0) {
136 $tmpuser = new User($db);
137 $res = $tmpuser->fetch($object->usermodid);
138 $object->usermod = $tmpuser;
139 }
140
141 $author = new User($db);
142 $author->fetch($object->author->id);
143 $object->author = $author;
144
145
146 $head = actions_prepare_head($object);
147
148 print dol_get_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action');
149
150 // Link to other agenda views
151 $linkback = '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
152 $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"');
153 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("BackToList").'</span>';
154 $linkback .= '</a>';
155 $linkback .= '</li>';
156 $linkback .= '<li class="noborder litext">';
157 $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').'">';
158 $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"');
159 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewCal").'</span>';
160 $linkback .= '</a>';
161 $linkback .= '</li>';
162 $linkback .= '<li class="noborder litext">';
163 $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').'">';
164 $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"');
165 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewWeek").'</span>';
166 $linkback .= '</a>';
167 $linkback .= '</li>';
168 $linkback .= '<li class="noborder litext">';
169 $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').'">';
170 $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"');
171 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewDay").'</span>';
172 $linkback .= '</a>';
173 $linkback .= '</li>';
174 $linkback .= '<li class="noborder litext">';
175 $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').'">';
176 $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"');
177 $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewPerUser").'</span>';
178 $linkback .= '</a>';
179
180 // Add more views from hooks
181 $parameters = array();
182 $reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
183 if (empty($reshook)) {
184 $linkback .= $hookmanager->resPrint;
185 } elseif ($reshook > 1) {
186 $linkback = $hookmanager->resPrint;
187 }
188
189 $morehtmlref = '<div class="refidno">';
190 // Thirdparty
191 //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
192 // Project
193 if (isModEnabled('project')) {
194 $langs->load("projects");
195 //$morehtmlref .= '<br>';
196 if (0) {
197 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
198 if ($action != 'classify') {
199 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
200 }
201 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
202 } else {
203 if (!empty($object->fk_project)) {
204 $proj = new Project($db);
205 $proj->fetch($object->fk_project);
206 $morehtmlref .= $proj->getNomUrl(1);
207 if ($proj->title) {
208 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
209 }
210 }
211 }
212 }
213 $morehtmlref .= '</div>';
214
215 dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'id', 'ref', $morehtmlref);
216
217 print '<div class="fichecenter">';
218
219 print '<div class="underbanner clearboth"></div>';
220
221 // Affichage fiche action en mode visu
222 print '<table class="border tableforfield centpercent">';
223
224 // Type of event
225 if (getDolGlobalString('AGENDA_USE_EVENT_TYPE')) {
226 print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td colspan="3">';
227 print $object->getTypePicto();
228 print $langs->trans("Action".$object->type_code);
229 print '</td></tr>';
230 }
231
232 // Full day event
233 print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td colspan="3">'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>';
234
235 // Date start
236 print '<tr><td>'.$langs->trans("DateActionStart").'</td><td colspan="3">';
237 if (empty($object->fulldayevent)) {
238 print dol_print_date($object->datep, 'dayhour', 'tzuser');
239 } else {
240 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
241 print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
242 }
243 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
244 print img_warning($langs->trans("Late"));
245 }
246 print '</td>';
247 print '</tr>';
248
249 // Date end
250 print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td colspan="3">';
251 if (empty($object->fulldayevent)) {
252 print dol_print_date($object->datef, 'dayhour', 'tzuser');
253 } else {
254 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
255 print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuser'));
256 }
257 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
258 print img_warning($langs->trans("Late"));
259 }
260 print '</td></tr>';
261
262 // Location
263 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION')) {
264 print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3">'.$object->location.'</td></tr>';
265 }
266
267 // Assigned to
268 print '<tr><td class="nowrap">'.$langs->trans("ActionAffectedTo").'</td><td colspan="3">';
269 $listofuserid = array();
270 if (empty($donotclearsession)) {
271 if ($object->userownerid > 0) {
272 $listofuserid[$object->userownerid] = array('id'=>$object->userownerid, 'transparency'=>$object->transparency); // Owner first
273 }
274 if (!empty($object->userassigned)) { // Now concat assigned users
275 // Restore array with key with same value than param 'id'
276 $tmplist1 = $object->userassigned;
277 foreach ($tmplist1 as $key => $val) {
278 if ($val['id'] && $val['id'] != $object->userownerid) {
279 $listofuserid[$val['id']] = $val;
280 }
281 }
282 }
283 $_SESSION['assignedtouser'] = json_encode($listofuserid);
284 } else {
285 if (!empty($_SESSION['assignedtouser'])) {
286 $listofuserid = json_decode($_SESSION['assignedtouser'], true);
287 }
288 }
289 $listofcontactid = array(); // not used yet
290 $listofotherid = array(); // not used yet
291 print '<div class="assignedtouser">';
292 print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
293 print '</div>';
294 /*if (in_array($user->id,array_keys($listofuserid)))
295 {
296 print '<div class="myavailability">';
297 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
298 print '</div>';
299 }*/
300 print ' </td></tr>';
301
302 print '</table>';
303
304 print '<table class="border tableforfield centpercent">';
305
306 // Build file list
307 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
308 $totalsize = 0;
309 foreach ($filearray as $key => $file) {
310 $totalsize += $file['size'];
311 }
312
313
314 print '<tr><td class="titlefield" class="nowrap">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
315 print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
316
317 print '</table>';
318
319 print '</div>';
320
321 print dol_get_fiche_end();
322
323
324 $modulepart = 'actions';
325 $permissiontoadd = $user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create');
326 $param = '&id='.$object->id;
327 include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
328} else {
329 print $langs->trans("ErrorUnknown");
330}
331
332// End of page
333llxFooter();
334$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
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:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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($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.
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_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'.
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 dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify 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.