dolibarr  16.0.1
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2018 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
5  * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
6  * Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
7  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
8  * Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr>
9  * Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
10  * Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
11  * Copyright (C) 2019 Ferran Marcet <fmarcet@2byte.es>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <https://www.gnu.org/licenses/>.
25  */
26 
33 require '../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
40 require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncommreminder.class.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
42 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
43 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
44 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
45 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
46 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
47 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
48 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
49 
50 // Load translation files required by the page
51 $langs->loadLangs(array("companies", "other", "commercial", "bills", "orders", "agenda", "mails"));
52 
53 $action = GETPOST('action', 'aZ09');
54 $cancel = GETPOST('cancel', 'alpha');
55 $backtopage = GETPOST('backtopage', 'alpha');
56 $socpeopleassigned = GETPOST('socpeopleassigned', 'array');
57 $origin = GETPOST('origin', 'alpha');
58 $originid = GETPOST('originid', 'int');
59 $confirm = GETPOST('confirm', 'alpha');
60 
61 $fulldayevent = GETPOST('fullday', 'alpha');
62 
63 $aphour = GETPOST('aphour', 'int');
64 $apmin = GETPOST('apmin', 'int');
65 $p2hour = GETPOST('p2hour', 'int');
66 $p2min = GETPOST('p2min', 'int');
67 
68 $addreminder = GETPOST('addreminder', 'alpha');
69 $offsetvalue = GETPOST('offsetvalue', 'int');
70 $offsetunit = GETPOST('offsetunittype_duration', 'aZ09');
71 $remindertype = GETPOST('selectremindertype', 'aZ09');
72 $modelmail = GETPOST('actioncommsendmodel_mail', 'int');
73 $complete = GETPOST('complete', 'alpha'); // 'na' must be allowed
74 if ($complete == 'na' || $complete == -2) {
75  $complete = -1;
76 }
77 
78 if ($fulldayevent) {
79  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
80  // For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere)
81  $datep = dol_mktime('00', '00', 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel');
82  $datef = dol_mktime('23', '59', '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), $tzforfullday ? $tzforfullday : 'tzuserrel');
83  //print $db->idate($datep); exit;
84 } else {
85  $datep = dol_mktime($aphour, $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuserrel');
86  $datef = dol_mktime($p2hour, $p2min, '59', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuserrel');
87 }
88 
89 // Security check
90 $socid = GETPOST('socid', 'int');
91 $id = GETPOST('id', 'int');
92 if ($user->socid) {
93  $socid = $user->socid;
94 }
95 
96 $error = GETPOST("error");
97 $donotclearsession = GETPOST('donotclearsession') ?GETPOST('donotclearsession') : 0;
98 
99 $object = new ActionComm($db);
100 $cactioncomm = new CActionComm($db);
101 $contact = new Contact($db);
102 $extrafields = new ExtraFields($db);
103 $formfile = new FormFile($db);
104 
105 $form = new Form($db);
106 $formfile = new FormFile($db);
107 $formactions = new FormActions($db);
108 
109 // Load object
110 if ($id > 0 && $action != 'add') {
111  $ret = $object->fetch($id);
112  if ($ret > 0) {
113  $ret = $object->fetch_optionals();
114  $ret1 = $object->fetch_userassigned();
115  }
116  if ($ret < 0 || $ret1 < 0) {
117  dol_print_error('', $object->error);
118  }
119 }
120 
121 // fetch optionals attributes and labels
122 $extrafields->fetch_name_optionals_label($object->table_element);
123 
124 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
125 $hookmanager->initHooks(array('actioncard', 'globalcard'));
126 
127 $parameters = array('socid' => $socid);
128 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
129 if ($reshook < 0) {
130  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
131 }
132 
133 $TRemindTypes = array();
134 if (!empty($conf->global->AGENDA_REMINDER_BROWSER)) {
135  $TRemindTypes['browser'] = array('label'=>$langs->trans('BrowserPush'), 'disabled'=>(empty($conf->global->AGENDA_REMINDER_BROWSER) ? 1 : 0));
136 }
137 if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) {
138  $TRemindTypes['email'] = array('label'=>$langs->trans('EMail'), 'disabled'=>(empty($conf->global->AGENDA_REMINDER_EMAIL) ? 1 : 0));
139 }
140 
141 $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes'));
142 
143 $result = restrictedArea($user, 'agenda', $object->id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
144 if ($user->socid && $socid) {
145  $result = restrictedArea($user, 'societe', $socid);
146 }
147 
148 
149 /*
150  * Actions
151  */
152 
153 $listUserAssignedUpdated = false;
154 // Remove user to assigned list
155 if (empty($reshook) && (GETPOST('removedassigned') || GETPOST('removedassigned') == '0')) {
156  $idtoremove = GETPOST('removedassigned');
157 
158  if (!empty($_SESSION['assignedtouser'])) {
159  $tmpassigneduserids = json_decode($_SESSION['assignedtouser'], 1);
160  } else {
161  $tmpassigneduserids = array();
162  }
163 
164  foreach ($tmpassigneduserids as $key => $val) {
165  if ($val['id'] == $idtoremove || $val['id'] == -1) {
166  unset($tmpassigneduserids[$key]);
167  }
168  }
169 
170  $_SESSION['assignedtouser'] = json_encode($tmpassigneduserids);
171  $donotclearsession = 1;
172  if ($action == 'add') {
173  $action = 'create';
174  }
175  if ($action == 'update') {
176  $action = 'edit';
177  }
178 
179  $listUserAssignedUpdated = true;
180 }
181 
182 // Add user to assigned list
183 if (empty($reshook) && (GETPOST('addassignedtouser') || GETPOST('updateassignedtouser'))) {
184  // Add a new user
185  if (GETPOST('assignedtouser') > 0) {
186  $assignedtouser = array();
187  if (!empty($_SESSION['assignedtouser'])) {
188  $assignedtouser = json_decode($_SESSION['assignedtouser'], true);
189  }
190  $assignedtouser[GETPOST('assignedtouser')] = array('id'=>GETPOST('assignedtouser'), 'transparency'=>GETPOST('transparency'), 'mandatory'=>1);
191  $_SESSION['assignedtouser'] = json_encode($assignedtouser);
192  }
193  $donotclearsession = 1;
194  if ($action == 'add') {
195  $action = 'create';
196  }
197  if ($action == 'update') {
198  $action = 'edit';
199  }
200 
201  $listUserAssignedUpdated = true;
202 }
203 
204 // Link to a project
205 if (empty($reshook) && $action == 'classin' && ($user->rights->agenda->allactions->create ||
206  (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) {
207  //$object->fetch($id);
208  $object->setProject(GETPOST('projectid', 'int'));
209 }
210 
211 // Action clone object
212 if (empty($reshook) && $action == 'confirm_clone' && $confirm == 'yes') {
213  if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) {
214  setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
215  } else {
216  if ($id > 0) {
217  //$object->fetch($id);
218  if (!empty($object->socpeopleassigned)) {
219  reset($object->socpeopleassigned);
220  $object->contact_id = key($object->socpeopleassigned);
221  }
222  $result = $object->createFromClone($user, GETPOST('socid', 'int'));
223  if ($result > 0) {
224  header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
225  exit();
226  } else {
227  setEventMessages($object->error, $object->errors, 'errors');
228  $action = '';
229  }
230  }
231  }
232 }
233 
234 // Add event
235 if (empty($reshook) && $action == 'add') {
236  $error = 0;
237 
238  if (empty($backtopage)) {
239  if ($socid > 0) {
240  $backtopage = DOL_URL_ROOT.'/societe/agenda.php?socid='.$socid;
241  } else {
242  $backtopage = DOL_URL_ROOT.'/comm/action/index.php';
243  }
244  }
245 
246  if (!empty($socpeopleassigned[0])) {
247  $result = $contact->fetch($socpeopleassigned[0]);
248  }
249 
250  if ($cancel) {
251  header("Location: ".$backtopage);
252  exit;
253  }
254 
255  $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status
256 
257  // Clean parameters
258  if ($fulldayevent) {
259  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
260  // For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere)
261  $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuser');
262  $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), $tzforfullday ? $tzforfullday : 'tzuser');
263  } else {
264  $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser');
265  $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser');
266  }
267 
268  // Check parameters
269  if (!$datef && $percentage == 100) {
270  $error++; $donotclearsession = 1;
271  $action = 'create';
272  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors');
273  }
274 
275  if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && !GETPOST('label')) {
276  $error++; $donotclearsession = 1;
277  $action = 'create';
278  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors');
279  }
280 
281  // Initialisation objet cactioncomm
282  if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) { // actioncode is '0'
283  $error++; $donotclearsession = 1;
284  $action = 'create';
285  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
286  } else {
287  $object->type_code = GETPOST('actioncode', 'aZ09');
288  }
289 
290  if (!$error) {
291  // Initialisation objet actioncomm
292  $object->priority = GETPOSTISSET("priority") ? GETPOST("priority", "int") : 0;
293  $object->fulldayevent = ($fulldayevent ? 1 : 0);
294  $object->location = GETPOST("location", 'alphanohtml');
295  $object->label = GETPOST('label', 'alphanohtml');
296 
297  if (GETPOST("elementtype", 'alpha')) {
298  $modulecodetouseforpermissioncheck = GETPOST("elementtype", 'alpha');
299 
300  $hasPermissionOnLinkedObject = 0;
301  if ($user->hasRight($modulecodetouseforpermissioncheck, 'read')) {
302  $hasPermissionOnLinkedObject = 1;
303  }
304  if ($hasPermissionOnLinkedObject) {
305  $object->fk_element = GETPOST("fk_element", 'int');
306  $object->elementtype = GETPOST("elementtype", 'alpha');
307  }
308  }
309 
310  if (!GETPOST('label')) {
311  if (GETPOST('actioncode', 'aZ09') == 'AC_RDV' && $contact->getFullName($langs)) {
312  $object->label = $langs->transnoentitiesnoconv("TaskRDVWith", $contact->getFullName($langs));
313  } else {
314  if ($langs->trans("Action".$object->type_code) != "Action".$object->type_code) {
315  $object->label = $langs->transnoentitiesnoconv("Action".$object->type_code)."\n";
316  } else {
317  $cactioncomm->fetch($object->type_code);
318  $object->label = $cactioncomm->label;
319  }
320  }
321  }
322  $object->fk_project = GETPOSTISSET("projectid") ? GETPOST("projectid", 'int') : 0;
323 
324  $taskid = GETPOST('taskid', 'int');
325  if (!empty($taskid)) {
326  $taskProject = new Task($db);
327  if ($taskProject->fetch($taskid) > 0) {
328  $object->fk_project = $taskProject->fk_project;
329  }
330 
331  $object->fk_element = $taskid;
332  $object->elementtype = 'task';
333  }
334 
335  $object->datep = $datep;
336  $object->datef = $datef;
337  $object->percentage = $percentage;
338  $object->duree = (((int) GETPOST('dureehour') * 60) + (int) GETPOST('dureemin')) * 60;
339 
340  $transparency = (GETPOST("transparency") == 'on' ? 1 : 0);
341 
342  $listofuserid = array();
343  if (!empty($_SESSION['assignedtouser'])) {
344  $listofuserid = json_decode($_SESSION['assignedtouser'], true);
345  }
346  $i = 0;
347  foreach ($listofuserid as $key => $value) {
348  if ($i == 0) { // First entry
349  if ($value['id'] > 0) {
350  $object->userownerid = $value['id'];
351  }
352  $object->transparency = $transparency;
353  }
354 
355  $object->userassigned[$value['id']] = array('id'=>$value['id'], 'transparency'=>$transparency);
356 
357  $i++;
358  }
359  }
360 
361  if (!$error && !empty($conf->global->AGENDA_ENABLE_DONEBY)) {
362  if (GETPOST("doneby") > 0) {
363  $object->userdoneid = GETPOST("doneby", "int");
364  }
365  }
366 
367  $object->note_private = trim(GETPOST("note", "restricthtml"));
368 
369  if (GETPOSTISSET("contactid")) {
370  $object->contact = $contact;
371  }
372 
373  if (GETPOST('socid', 'int') > 0) {
374  $object->socid = GETPOST('socid', 'int');
375  $object->fetch_thirdparty();
376 
377  $object->societe = $object->thirdparty; // For backward compatibility
378  }
379 
380  // Check parameters
381  if (empty($object->userownerid) && empty($_SESSION['assignedtouser'])) {
382  $error++; $donotclearsession = 1;
383  $action = 'create';
384  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ActionsOwnedBy")), null, 'errors');
385  }
386  if ($object->type_code == 'AC_RDV' && ($datep == '' || ($datef == '' && empty($fulldayevent)))) {
387  $error++; $donotclearsession = 1;
388  $action = 'create';
389  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors');
390  }
391 
392  if (!GETPOST('apyear') && !GETPOST('adyear')) {
393  $error++; $donotclearsession = 1;
394  $action = 'create';
395  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
396  }
397 
398  foreach ($socpeopleassigned as $cid) {
399  $object->socpeopleassigned[$cid] = array('id' => $cid);
400  }
401  if (!empty($object->socpeopleassigned)) {
402  reset($object->socpeopleassigned);
403  $object->contact_id = key($object->socpeopleassigned);
404  }
405 
406  // Fill array 'array_options' with data from add form
407  $ret = $extrafields->setOptionalsFromPost(null, $object);
408  if ($ret < 0) {
409  $error++;
410  }
411 
412  if (!$error) {
413  $db->begin();
414 
415  // Creation of action/event
416  $idaction = $object->create($user);
417 
418  if ($idaction > 0) {
419  if (!$object->error) {
420  // Category association
421  $categories = GETPOST('categories', 'array');
422  $object->setCategories($categories);
423 
424  unset($_SESSION['assignedtouser']);
425 
426  $moreparam = '';
427  if ($user->id != $object->userownerid) {
428  $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view.
429  }
430 
431  // Create reminders
432  if ($addreminder == 'on') {
433  $actionCommReminder = new ActionCommReminder($db);
434 
435  $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit);
436 
437  $actionCommReminder->dateremind = $dateremind;
438  $actionCommReminder->typeremind = $remindertype;
439  $actionCommReminder->offsetunit = $offsetunit;
440  $actionCommReminder->offsetvalue = $offsetvalue;
441  $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
442  $actionCommReminder->fk_actioncomm = $object->id;
443  if ($remindertype == 'email') {
444  $actionCommReminder->fk_email_template = $modelmail;
445  }
446 
447  // the notification must be created for every user assigned to the event
448  foreach ($object->userassigned as $userassigned) {
449  $actionCommReminder->fk_user = $userassigned['id'];
450  $res = $actionCommReminder->create($user);
451 
452  if ($res <= 0) {
453  // If error
454  $db->rollback();
455  $langs->load("errors");
456  $error = $langs->trans('ErrorReminderActionCommCreation');
457  setEventMessages($error, null, 'errors');
458  $action = 'create'; $donotclearsession = 1;
459  break;
460  }
461  }
462  }
463 
464  // Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page.
465  /*$moreparam .= ($moreparam ? '&' : '').'search_actioncode=0';
466  $moreparam .= ($moreparam ? '&' : '').'search_status=-1';
467  $moreparam .= ($moreparam ? '&' : '').'search_filtert='.$object->userownerid;
468  */
469  $moreparam .= ($moreparam ? '&' : '').'disabledefaultvalues=1';
470 
471  if ($error) {
472  $db->rollback();
473  } else {
474  $db->commit();
475  }
476 
477  if (!empty($backtopage)) {
478  dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : ''));
479  header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : ''));
480  } elseif ($idaction) {
481  header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : ''));
482  } else {
483  header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : ''));
484  }
485  exit;
486  } else {
487  // If error
488  $db->rollback();
489  $langs->load("errors");
490  $error = $langs->trans($object->error);
491  setEventMessages($error, null, 'errors');
492  $action = 'create'; $donotclearsession = 1;
493  }
494  } else {
495  $db->rollback();
496  setEventMessages($object->error, $object->errors, 'errors');
497  $action = 'create'; $donotclearsession = 1;
498  }
499  }
500 }
501 
502 /*
503  * Action update event
504  */
505 if (empty($reshook) && $action == 'update') {
506  if (empty($cancel)) {
507  $fulldayevent = GETPOST('fullday');
508  $aphour = GETPOST('aphour', 'int');
509  $apmin = GETPOST('apmin', 'int');
510  $p2hour = GETPOST('p2hour', 'int');
511  $p2min = GETPOST('p2min', 'int');
512  $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status
513 
514  // Clean parameters
515  if ($aphour == -1) {
516  $aphour = '0';
517  }
518  if ($apmin == -1) {
519  $apmin = '0';
520  }
521  if ($p2hour == -1) {
522  $p2hour = '0';
523  }
524  if ($p2min == -1) {
525  $p2min = '0';
526  }
527 
528  $object->fetch($id);
529  $object->fetch_optionals();
530  $object->fetch_userassigned();
531  $object->oldcopy = clone $object;
532 
533  // Clean parameters
534  if ($fulldayevent) {
535  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
536  // For "full day" events, we must store date in GMT (It must be viewed as same moment everywhere)
537  $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuser');
538  $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), $tzforfullday ? $tzforfullday : 'tzuser');
539  } else {
540  $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser');
541  $datef = dol_mktime($fulldayevent ? '23' : GETPOST("p2hour", 'int'), $fulldayevent ? '59' : GETPOST("p2min", 'int'), $fulldayevent ? '59' : GETPOST("apsec", 'int'), GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser');
542  }
543 
544  $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm');
545  $object->label = GETPOST("label", "alphanohtml");
546  $object->datep = $datep;
547  $object->datef = $datef;
548  $object->percentage = $percentage;
549  $object->priority = GETPOST("priority", "int");
550  $object->fulldayevent = GETPOST("fullday") ? 1 : 0;
551  $object->location = GETPOST('location', "alphanohtml");
552  $object->socid = GETPOST("socid", "int");
553  $socpeopleassigned = GETPOST("socpeopleassigned", 'array');
554  $object->socpeopleassigned = array();
555  foreach ($socpeopleassigned as $cid) {
556  $object->socpeopleassigned[$cid] = array('id' => $cid);
557  }
558  $object->contact_id = GETPOST("contactid", 'int');
559  if (empty($object->contact_id) && !empty($object->socpeopleassigned)) {
560  reset($object->socpeopleassigned);
561  $object->contact_id = key($object->socpeopleassigned);
562  }
563  $object->fk_project = GETPOST("projectid", 'int');
564  $object->note_private = trim(GETPOST("note", "restricthtml"));
565 
566  if (GETPOST("elementtype", 'alpha')) {
567  $modulecodetouseforpermissioncheck = GETPOST("elementtype", 'alpha');
568 
569  $hasPermissionOnLinkedObject = 0;
570  if ($user->hasRight($modulecodetouseforpermissioncheck, 'read')) {
571  $hasPermissionOnLinkedObject = 1;
572  }
573  if ($hasPermissionOnLinkedObject) {
574  $object->fk_element = GETPOST("fk_element", 'int');
575  $object->elementtype = GETPOST("elementtype", 'alpha');
576  }
577  }
578 
579  if (!$datef && $percentage == 100) {
580  $error++; $donotclearsession = 1;
581  setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), $object->errors, 'errors');
582  $action = 'edit';
583  }
584 
585  $transparency = (GETPOST("transparency") == 'on' ? 1 : 0);
586 
587  // Users
588  $listofuserid = array();
589  if (!empty($_SESSION['assignedtouser'])) { // Now concat assigned users
590  // Restore array with key with same value than param 'id'
591  $tmplist1 = json_decode($_SESSION['assignedtouser'], true);
592  foreach ($tmplist1 as $key => $val) {
593  if ($val['id'] > 0 && $val['id'] != $assignedtouser) {
594  $listofuserid[$val['id']] = $val;
595  }
596  }
597  } else {
598  $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
599  if ($assignedtouser) {
600  $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>($user->id == $assignedtouser ? $transparency : '')); // Owner first
601  }
602  }
603  $object->userassigned = array(); $object->userownerid = 0; // Clear old content
604  $i = 0;
605  foreach ($listofuserid as $key => $val) {
606  if ($i == 0) {
607  $object->userownerid = $val['id'];
608  }
609  $object->userassigned[$val['id']] = array('id'=>$val['id'], 'mandatory'=>0, 'transparency'=>($user->id == $val['id'] ? $transparency : ''));
610  $i++;
611  }
612 
613  $object->transparency = $transparency; // We set transparency on event (even if we can also store it on each user, standard says this property is for event)
614  // TODO store also transparency on owner user
615 
616  if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
617  if (GETPOST("doneby")) {
618  $object->userdoneid = GETPOST("doneby", "int");
619  }
620  }
621 
622  // Check parameters
623  if (GETPOSTISSET('actioncode') && !GETPOST('actioncode', 'aZ09')) { // actioncode is '0'
624  $error++; $donotclearsession = 1;
625  $action = 'edit';
626  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
627  } else {
628  $result = $cactioncomm->fetch(GETPOST('actioncode', 'aZ09'));
629  }
630  if (empty($object->userownerid)) {
631  $error++; $donotclearsession = 1;
632  $action = 'edit';
633  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ActionsOwnedBy")), null, 'errors');
634  }
635 
636  // Fill array 'array_options' with data from add form
637  $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
638  if ($ret < 0) {
639  $error++;
640  }
641 
642  if (!$error) {
643  // check if an event resource is already in use
644  if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') {
645  $eventDateStart = $object->datep;
646  $eventDateEnd = $object->datef;
647 
648  $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
649  $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er";
650  $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
651  $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'";
652  $sql .= " WHERE ac.id <> ".((int) $object->id);
653  $sql .= " AND er.resource_id IN (";
654  $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources";
655  $sql .= " WHERE element_id = ".((int) $object->id);
656  $sql .= " AND element_type = '".$db->escape($object->element)."'";
657  $sql .= " AND busy = 1";
658  $sql .= ")";
659  $sql .= " AND er.busy = 1";
660  $sql .= " AND (";
661 
662  // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end)
663  $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))";
664  // event date end between ac.datep and ac.datep2
665  if (!empty($eventDateEnd)) {
666  $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))";
667  }
668  // event date start before ac.datep and event date end after ac.datep2
669  $sql .= " OR (";
670  $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'";
671  if (!empty($eventDateEnd)) {
672  $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')";
673  }
674  $sql .= ")";
675 
676  $sql .= ")";
677  $resql = $db->query($sql);
678  if (!$resql) {
679  $error++;
680  $object->error = $db->lasterror();
681  $object->errors[] = $object->error;
682  } else {
683  if ($db->num_rows($resql) > 0) {
684  // Resource already in use
685  $error++;
686  $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : ';
687  while ($obj = $db->fetch_object($resql)) {
688  $object->error .= '<br> - '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']');
689  }
690  $object->errors[] = $object->error;
691  }
692  $db->free($resql);
693  }
694 
695  if ($error) {
696  setEventMessages($object->error, $object->errors, 'errors');
697  }
698  }
699  }
700 
701  if (!$error) {
702  $db->begin();
703 
704  $result = $object->update($user);
705 
706  if ($result > 0) {
707  // Category association
708  $categories = GETPOST('categories', 'array');
709  $object->setCategories($categories);
710 
711  $object->loadReminders($remindertype, 0, false);
712  if (!empty($object->reminders) && $object->datep > dol_now()) {
713  foreach ($object->reminders as $reminder) {
714  $reminder->delete($user);
715  }
716  $object->reminders = array();
717  }
718 
719  //Create reminders
720  if ($addreminder == 'on' && $object->datep > dol_now()) {
721  $actionCommReminder = new ActionCommReminder($db);
722 
723  $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit);
724 
725  $actionCommReminder->dateremind = $dateremind;
726  $actionCommReminder->typeremind = $remindertype;
727  $actionCommReminder->offsetunit = $offsetunit;
728  $actionCommReminder->offsetvalue = $offsetvalue;
729  $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
730  $actionCommReminder->fk_actioncomm = $object->id;
731  if ($remindertype == 'email') {
732  $actionCommReminder->fk_email_template = $modelmail;
733  }
734 
735  // the notification must be created for every user assigned to the event
736  foreach ($object->userassigned as $userassigned) {
737  $actionCommReminder->fk_user = $userassigned['id'];
738  $res = $actionCommReminder->create($user);
739 
740  if ($res <= 0) {
741  // If error
742  $langs->load("errors");
743  $error = $langs->trans('ErrorReminderActionCommCreation');
744  setEventMessages($error, null, 'errors');
745  $action = 'create'; $donotclearsession = 1;
746  break;
747  }
748  }
749  }
750 
751  unset($_SESSION['assignedtouser']);
752 
753  if (!$error) {
754  $db->commit();
755  } else {
756  $db->rollback();
757  }
758  } else {
759  setEventMessages($object->error, $object->errors, 'errors');
760  $db->rollback();
761  }
762  }
763  }
764 
765  if (!$error) {
766  if (!empty($backtopage)) {
767  unset($_SESSION['assignedtouser']);
768  header("Location: ".$backtopage);
769  exit;
770  }
771  }
772 }
773 
774 /*
775  * delete event
776  */
777 if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes') {
778  $object->fetch($id);
779  $object->fetch_optionals();
780  $object->fetch_userassigned();
781  $object->oldcopy = clone $object;
782 
783  if ($user->rights->agenda->myactions->delete
784  || $user->rights->agenda->allactions->delete) {
785  $result = $object->delete();
786 
787  if ($result >= 0) {
788  header("Location: index.php");
789  exit;
790  } else {
791  setEventMessages($object->error, $object->errors, 'errors');
792  }
793  }
794 }
795 
796 /*
797  * Action move update, used when user move an event in calendar by drag'n drop
798  * TODO Move this into page comm/action/index that trigger this call by the drag and drop of event.
799  */
800 if (empty($reshook) && GETPOST('actionmove', 'alpha') == 'mupdate') {
801  $error = 0;
802 
803  $shour = dol_print_date($object->datep, "%H", 'tzuserrel'); // We take the date visible by user $newdate is also date visible by user.
804  $smin = dol_print_date($object->datep, "%M", 'tzuserrel');
805 
806  $newdate = GETPOST('newdate', 'alpha');
807  if (empty($newdate) || strpos($newdate, 'dayevent_') != 0) {
808  header("Location: ".$backtopage);
809  exit;
810  }
811 
812  $datep = dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4), 'tzuserrel');
813  //print dol_print_date($datep, 'dayhour');exit;
814 
815  if ($datep != $object->datep) {
816  if (!empty($object->datef)) {
817  $object->datef += $datep - $object->datep;
818  }
819  $object->datep = $datep;
820 
821  if (!$error) {
822  // check if an event resource is already in use
823  if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element == 'action') {
824  $eventDateStart = $object->datep;
825  $eventDateEnd = $object->datef;
826 
827  $sql = "SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
828  $sql .= " FROM ".MAIN_DB_PREFIX."element_resources as er";
829  $sql .= " INNER JOIN ".MAIN_DB_PREFIX."resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
830  $sql .= " INNER JOIN ".MAIN_DB_PREFIX."actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element)."'";
831  $sql .= " WHERE ac.id <> ".((int) $object->id);
832  $sql .= " AND er.resource_id IN (";
833  $sql .= " SELECT resource_id FROM ".MAIN_DB_PREFIX."element_resources";
834  $sql .= " WHERE element_id = ".((int) $object->id);
835  $sql .= " AND element_type = '".$db->escape($object->element)."'";
836  $sql .= " AND busy = 1";
837  $sql .= ")";
838  $sql .= " AND er.busy = 1";
839  $sql .= " AND (";
840 
841  // event date start between ac.datep and ac.datep2 (if datep2 is null we consider there is no end)
842  $sql .= " (ac.datep <= '".$db->idate($eventDateStart)."' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart)."'))";
843  // event date end between ac.datep and ac.datep2
844  if (!empty($eventDateEnd)) {
845  $sql .= " OR (ac.datep <= '".$db->idate($eventDateEnd)."' AND (ac.datep2 >= '".$db->idate($eventDateEnd)."'))";
846  }
847  // event date start before ac.datep and event date end after ac.datep2
848  $sql .= " OR (";
849  $sql .= "ac.datep >= '".$db->idate($eventDateStart)."'";
850  if (!empty($eventDateEnd)) {
851  $sql .= " AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd)."')";
852  }
853  $sql .= ")";
854 
855  $sql .= ")";
856  $resql = $db->query($sql);
857  if (!$resql) {
858  $error++;
859  $object->error = $db->lasterror();
860  $object->errors[] = $object->error;
861  } else {
862  if ($db->num_rows($resql) > 0) {
863  // Resource already in use
864  $error++;
865  $object->error = $langs->trans('ErrorResourcesAlreadyInUse').' : ';
866  while ($obj = $db->fetch_object($resql)) {
867  $object->error .= '<br> - '.$langs->trans('ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.' ['.$obj->ac_id.']');
868  }
869  $object->errors[] = $object->error;
870  }
871  $db->free($resql);
872  }
873 
874  if ($error) {
875  setEventMessages($object->error, $object->errors, 'errors');
876  }
877  }
878  }
879 
880  if (!$error) {
881  $db->begin();
882  $result = $object->update($user);
883  if ($result < 0) {
884  $error++;
885  setEventMessages($object->error, $object->errors, 'errors');
886  $db->rollback();
887  } else {
888  $db->commit();
889  }
890  }
891  }
892  if (!empty($backtopage)) {
893  header("Location: ".$backtopage);
894  exit;
895  } else {
896  $action = '';
897  }
898 }
899 
900 // Actions to delete doc
901 $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref);
902 $permissiontoadd = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read));
903 if (empty($reshook)) {
904  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
905 }
906 
907 
908 
909 /*
910  * View
911  */
912 
913 $form = new Form($db);
914 $formproject = new FormProjets($db);
915 
916 $arrayrecurrulefreq = array(
917  'no'=>$langs->trans("OnceOnly"),
918  'MONTHLY'=>$langs->trans("EveryMonth"),
919  'WEEKLY'=>$langs->trans("EveryWeek"),
920  //'DAYLY'=>$langs->trans("EveryDay")
921 );
922 
923 $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
924 llxHeader('', $langs->trans("Agenda"), $help_url);
925 
926 if ($action == 'create') {
927  $contact = new Contact($db);
928 
929  $socpeopleassigned = GETPOST("socpeopleassigned", 'array');
930  if (!empty($socpeopleassigned[0])) {
931  $result = $contact->fetch($socpeopleassigned[0]);
932  if ($result < 0) {
933  dol_print_error($db, $contact->error);
934  }
935  }
936 
937  dol_set_focus("#label");
938 
939  if (!empty($conf->use_javascript_ajax)) {
940  print "\n".'<script type="text/javascript">';
941  print '$(document).ready(function () {
942  function setdatefields()
943  {
944  if ($("#fullday:checked").val() == null) {
945  $(".fulldaystarthour").removeAttr("disabled");
946  $(".fulldaystartmin").removeAttr("disabled");
947  $(".fulldayendhour").removeAttr("disabled");
948  $(".fulldayendmin").removeAttr("disabled");
949  $("#p2").removeAttr("disabled");
950  } else {
951  $(".fulldaystarthour").prop("disabled", true).val("00");
952  $(".fulldaystartmin").prop("disabled", true).val("00");
953  $(".fulldayendhour").prop("disabled", true).val("23");
954  $(".fulldayendmin").prop("disabled", true).val("59");
955  $("#p2").removeAttr("disabled");
956  }
957  }
958  $("#fullday").change(function() {
959  console.log("setdatefields");
960  setdatefields();
961  });
962 
963  $("#selectcomplete").change(function() {
964  console.log("we change the complete status - set the doneby");
965  if ($("#selectcomplete").val() == 100) {
966  if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).'\');
967  }
968  if ($("#selectcomplete").val() == 0) {
969  $("#doneby").val(-1);
970  }
971  });
972 
973  $("#actioncode").change(function() {
974  if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
975  else $("#dateend").removeClass("fieldrequired");
976  });
977  $("#aphour,#apmin").change(function() {
978  if ($("#actioncode").val() == \'AC_RDV\') {
979  console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
980  $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
981  $("#p2min").val($("#apmin").val());
982  $("#p2day").val($("#apday").val());
983  $("#p2month").val($("#apmonth").val());
984  $("#p2year").val($("#apyear").val());
985  $("#p2").val($("#ap").val());
986  }
987  });
988  if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
989  else $("#dateend").removeClass("fieldrequired");
990  setdatefields();
991  })';
992  print '</script>'."\n";
993  }
994 
995  print '<form name="formaction" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
996  print '<input type="hidden" name="token" value="'.newToken().'">';
997  print '<input type="hidden" name="action" value="add">';
998  print '<input type="hidden" name="donotclearsession" value="1">';
999  print '<input type="hidden" name="page_y" value="">';
1000  if ($backtopage) {
1001  print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : dol_htmlentities($_SERVER["HTTP_REFERER"])).'">';
1002  }
1003  if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1004  print '<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db, 'AC_OTH', 'c_actioncomm').'">';
1005  }
1006 
1007  if (GETPOST("actioncode", 'aZ09') == 'AC_RDV') {
1008  print load_fiche_titre($langs->trans("AddActionRendezVous"), '', 'title_agenda');
1009  } else {
1010  print load_fiche_titre($langs->trans("AddAnAction"), '', 'title_agenda');
1011  }
1012 
1013  print dol_get_fiche_head();
1014 
1015  print '<table class="border centpercent">';
1016 
1017  // Type of event
1018  if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1019  print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("Type").'</span></b></td><td>';
1020  $default = (empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT) ? 'AC_RDV' : $conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT);
1021  print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"');
1022  print $formactions->select_type_actions(GETPOSTISSET("actioncode") ? GETPOST("actioncode", 'aZ09') : ($object->type_code ? $object->type_code : $default), "actioncode", "systemauto", 0, -1, 0, 1); // TODO Replace 0 with -2 in onlyautoornot
1023  print '</td></tr>';
1024  }
1025 
1026  // Title
1027  print '<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE) ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Label").'</td><td><input type="text" id="label" name="label" class="soixantepercent" value="'.GETPOST('label').'"></td></tr>';
1028 
1029  // Full day
1030  print '<tr><td><span class="fieldrequired">'.$langs->trans("Date").'</span></td><td class="valignmiddle height30 small"><input type="checkbox" id="fullday" name="fullday" '.(GETPOST('fullday') ? ' checked' : '').'><label for="fullday">'.$langs->trans("EventOnFullDay").'</label>';
1031 
1032  // Recurring event
1033  $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
1034  if ($userepeatevent) {
1035  // Repeat
1036  //print '<tr><td></td><td colspan="3" class="opacitymedium">';
1037  print ' &nbsp; &nbsp; &nbsp; &nbsp; <div class="opacitymedium inline-block">';
1038  print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"');
1039  print '<input type="hidden" name="recurid" value="'.(empty($object->recurid) ? '' : $object->recurid).'">';
1040  $selectedrecurrulefreq = 'no';
1041  $selectedrecurrulebymonthday = '';
1042  $selectedrecurrulebyday = '';
1043  $reg = array();
1044  if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) {
1045  $selectedrecurrulefreq = $reg[1];
1046  }
1047  if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) {
1048  $selectedrecurrulebymonthday = $reg[1];
1049  }
1050  if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) {
1051  $selectedrecurrulebyday = $reg[1];
1052  }
1053  print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly');
1054  // If recurrulefreq is MONTHLY
1055  print '<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1056  print $langs->trans("DayOfMonth").': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.'">';
1057  print '</div>';
1058  // If recurrulefreq is WEEKLY
1059  print '<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1060  print $langs->trans("DayOfWeek").': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.'">';
1061  print '</div>';
1062  print '<script type="text/javascript">
1063  jQuery(document).ready(function() {
1064  function init_repeat()
1065  {
1066  if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1067  {
1068  jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1069  jQuery(".repeateventBYDAY").hide();
1070  }
1071  else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1072  {
1073  jQuery(".repeateventBYMONTHDAY").hide();
1074  jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1075  }
1076  else
1077  {
1078  jQuery(".repeateventBYMONTHDAY").hide();
1079  jQuery(".repeateventBYDAY").hide();
1080  }
1081  }
1082  init_repeat();
1083  jQuery("#recurrulefreq").change(function() {
1084  init_repeat();
1085  });
1086  });
1087  </script>';
1088  print '</div>';
1089  //print '</td></tr>';
1090  }
1091 
1092  print '</td></tr>';
1093 
1094  $datep = ($datep ? $datep : (is_null($object->datep) ? '' : $object->datep));
1095  if (GETPOST('datep', 'int', 1)) {
1096  $datep = dol_stringtotime(GETPOST('datep', 'int', 1), 'tzuser');
1097  }
1098  $datef = ($datef ? $datef : $object->datef);
1099  if (GETPOST('datef', 'int', 1)) {
1100  $datef = dol_stringtotime(GETPOST('datef', 'int', 1), 'tzuser');
1101  }
1102  if (empty($datef) && !empty($datep)) {
1103  if (GETPOST("actioncode", 'aZ09') == 'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) {
1104  $datef = dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS), 'h');
1105  }
1106  }
1107 
1108  // Date start
1109  print '<tr><td class="nowrap">';
1110  /*
1111  print '<span class="fieldrequired">'.$langs->trans("DateActionStart").'</span>';
1112  print ' - ';
1113  print '<span id="dateend"'.(GETPOST("actioncode", 'aZ09') == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").'</span>';
1114  */
1115  print '</td><td>';
1116  if (GETPOST("afaire") == 1) {
1117  print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel'); // Empty value not allowed for start date and hours if "todo"
1118  } else {
1119  print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart', '', '', '', 1, '', '', 'tzuserrel');
1120  }
1121  print ' <span class="hideonsmartphone">&nbsp; &nbsp; - &nbsp; &nbsp;</span> ';
1122  if (GETPOST("afaire") == 1) {
1123  print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel');
1124  } else {
1125  print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', 'tzuserrel');
1126  }
1127  print '</td></tr>';
1128 
1129  print '<tr><td class="">&nbsp;</td><td></td></tr>';
1130 
1131  // Assigned to
1132  print '<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans("ActionAffectedTo").'</span></td><td>';
1133  $listofuserid = array();
1134  $listofcontactid = array();
1135  $listofotherid = array();
1136 
1137  if (empty($donotclearsession)) {
1138  $assignedtouser = GETPOST("assignedtouser") ?GETPOST("assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
1139  if ($assignedtouser) {
1140  $listofuserid[$assignedtouser] = array('id'=>$assignedtouser, 'mandatory'=>0, 'transparency'=>$object->transparency); // Owner first
1141  }
1142  //$listofuserid[$user->id] = array('id'=>$user->id, 'mandatory'=>0, 'transparency'=>(GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1)); // 1 by default at first init
1143  $listofuserid[$assignedtouser]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 1); // 1 by default at first init
1144  $_SESSION['assignedtouser'] = json_encode($listofuserid);
1145  } else {
1146  if (!empty($_SESSION['assignedtouser'])) {
1147  $listofuserid = json_decode($_SESSION['assignedtouser'], true);
1148  }
1149  $firstelem = reset($listofuserid);
1150  if (isset($listofuserid[$firstelem['id']])) {
1151  $listofuserid[$firstelem['id']]['transparency'] = (GETPOSTISSET('transparency') ? GETPOST('transparency', 'alpha') : 0); // 0 by default when refreshing
1152  }
1153  }
1154  print '<div class="assignedtouser">';
1155  print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1156  print '</div>';
1157  print '</td></tr>';
1158 
1159  // Done by
1160  if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1161  print '<tr><td class="nowrap">'.$langs->trans("ActionDoneBy").'</td><td>';
1162  print $form->select_dolusers(GETPOSTISSET("doneby") ? GETPOST("doneby", 'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0), 'doneby', 1);
1163  print '</td></tr>';
1164  }
1165 
1166  // Location
1167  if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1168  print '<tr><td>'.$langs->trans("Location").'</td><td><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.(GETPOST('location') ? GETPOST('location') : $object->location).'"></td></tr>';
1169  }
1170 
1171  // Status
1172  print '<tr><td>'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td>';
1173  print '<td>';
1174  $percent = $complete !=='' ? $complete : -1;
1175  if (GETPOSTISSET('status')) {
1176  $percent = GETPOST('status');
1177  } elseif (GETPOSTISSET('percentage')) {
1178  $percent = GETPOST('percentage', 'int');
1179  } else {
1180  if ($complete == '0' || GETPOST("afaire") == 1) {
1181  $percent = '0';
1182  } elseif ($complete == 100 || GETPOST("afaire") == 2) {
1183  $percent = 100;
1184  }
1185  }
1186  $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200');
1187  print '</td></tr>';
1188 
1189  if (!empty($conf->categorie->enabled)) {
1190  // Categories
1191  print '<tr><td>'.$langs->trans("Categories").'</td><td>';
1192  $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1);
1193  print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, GETPOST('categories', 'array'), '', 0, 'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1194  print "</td></tr>";
1195  }
1196 
1197  print '</table>';
1198 
1199 
1200  print '<br><hr><br>';
1201 
1202 
1203  print '<table class="border centpercent">';
1204 
1205  if (!empty($conf->societe->enabled)) {
1206  // Related company
1207  print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ActionOnCompany").'</td><td>';
1208  if (GETPOST('socid', 'int') > 0) {
1209  $societe = new Societe($db);
1210  $societe->fetch(GETPOST('socid', 'int'));
1211  print $societe->getNomUrl(1);
1212  print '<input type="hidden" id="socid" name="socid" value="'.GETPOST('socid', 'int').'">';
1213  } else {
1214  $events = array();
1215  $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
1216  //For external user force the company to user company
1217  if (!empty($user->socid)) {
1218  print img_picto('', 'company', 'class="paddingrightonly"').$form->select_company($user->socid, 'socid', '', 1, 1, 0, $events, 0, 'minwidth300');
1219  } else {
1220  print img_picto('', 'company', 'class="paddingrightonly"').$form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300');
1221  }
1222  }
1223  print '</td></tr>';
1224 
1225  // Related contact
1226  print '<tr><td class="nowrap">'.$langs->trans("ActionOnContact").'</td><td>';
1227  $preselectedids = GETPOST('socpeopleassigned', 'array');
1228  if (GETPOST('contactid', 'int')) {
1229  $preselectedids[GETPOST('contactid', 'int')] = GETPOST('contactid', 'int');
1230  }
1231  if ($origin=='contact') $preselectedids[GETPOST('originid', 'int')] = GETPOST('originid', 'int');
1232  print img_picto('', 'contact', 'class="paddingrightonly"');
1233  print $form->selectcontacts(GETPOST('socid', 'int'), $preselectedids, 'socpeopleassigned[]', 1, '', '', 0, 'minwidth300 quatrevingtpercent', false, 0, array(), false, 'multiple', 'contactid');
1234  print '</td></tr>';
1235  }
1236 
1237  // Project
1238  if (!empty($conf->project->enabled)) {
1239  $langs->load("projects");
1240 
1241  $projectid = GETPOST('projectid', 'int');
1242 
1243  print '<tr><td class="titlefieldcreate">'.$langs->trans("Project").'</td><td id="project-input-container">';
1244  print img_picto('', 'project', 'class="pictofixedwidth"');
1245  print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx');
1246 
1247  print '&nbsp;<a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.(empty($societe->id) ? '' : $societe->id).'&action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'">';
1248  print '<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddProject").'"></span></a>';
1249  $urloption = '?action=create&donotclearsession=1';
1250  $url = dol_buildpath('comm/action/card.php', 2).$urloption;
1251 
1252  // update task list
1253  print "\n".'<script type="text/javascript">';
1254  print '$(document).ready(function () {
1255  $("#projectid").change(function () {
1256  var url = "'.DOL_URL_ROOT.'/projet/ajax/projects.php?mode=gettasks&socid="+$("#projectid").val()+"&projectid="+$("#projectid").val();
1257  console.log("Call url to get new list of tasks: "+url);
1258  $.get(url, function(data) {
1259  console.log(data);
1260  if (data) $("#taskid").html(data).select2();
1261  })
1262  });
1263  })';
1264  print '</script>'."\n";
1265 
1266  print '</td></tr>';
1267 
1268  print '<tr><td class="titlefieldcreate">'.$langs->trans("Task").'</td><td id="project-task-input-container" >';
1269  print img_picto('', 'projecttask', 'class="paddingrightonly"');
1270  $projectsListId = false;
1271  if (!empty($projectid)) {
1272  $projectsListId = $projectid;
1273  }
1274 
1275  $tid = GETPOSTISSET("projecttaskid") ? GETPOST("projecttaskid", 'int') : (GETPOSTISSET("taskid") ? GETPOST("taskid", 'int') : '');
1276 
1277  $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid, 'taskid', 24, 0, '1', 1, 0, 0, 'maxwidth500', $projectsListId);
1278  print '</td></tr>';
1279  }
1280 
1281  // Object linked
1282  if (!empty($origin) && !empty($originid)) {
1283  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1284 
1285  $hasPermissionOnLinkedObject = 0;
1286  if ($user->hasRight($origin, 'read')) {
1287  $hasPermissionOnLinkedObject = 1;
1288  }
1289  //var_dump('origin='.$origin.' originid='.$originid.' hasPermissionOnLinkedObject='.$hasPermissionOnLinkedObject);
1290 
1291  if (! in_array($origin, array('societe', 'project', 'task', 'user'))) {
1292  // We do not use link for object that already contains a hard coded field to make links with agenda events
1293  print '<tr><td class="titlefieldcreate">'.$langs->trans("LinkedObject").'</td>';
1294  print '<td colspan="3">';
1295  if ($hasPermissionOnLinkedObject) {
1296  print dolGetElementUrl($originid, $origin, 1);
1297  print '<input type="hidden" name="fk_element" value="'.$originid.'">';
1298  print '<input type="hidden" name="elementtype" value="'.$origin.'">';
1299  print '<input type="hidden" name="originid" value="'.$originid.'">';
1300  print '<input type="hidden" name="origin" value="'.$origin.'">';
1301  } else {
1302  print '<!-- no permission on object to link '.$origin.' id '.$originid.' -->';
1303  }
1304  print '</td></tr>';
1305  }
1306  }
1307 
1308  $reg = array();
1309  if (GETPOST("datep") && preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/', GETPOST("datep"), $reg)) {
1310  $object->datep = dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]);
1311  }
1312 
1313  // Priority
1314  if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1315  print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("Priority").'</td><td colspan="3">';
1316  print '<input type="text" name="priority" value="'.(GETPOSTISSET('priority') ? GETPOST('priority', 'int') : ($object->priority ? $object->priority : '')).'" size="5">';
1317  print '</td></tr>';
1318  }
1319 
1320  // Description
1321  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
1322  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1323  $doleditor = new DolEditor('note', (GETPOSTISSET('note') ? GETPOST('note', 'restricthtml') : $object->note_private), '', 120, 'dolibarr_notes', 'In', true, true, isModEnabled('fckeditor'), ROWS_4, '90%');
1324  $doleditor->Create();
1325  print '</td></tr>';
1326 
1327  // Other attributes
1328  $parameters = array();
1329  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1330  print $hookmanager->resPrint;
1331  if (empty($reshook)) {
1332  print $object->showOptionals($extrafields, 'create', $parameters);
1333  }
1334 
1335  print '</table>';
1336 
1337 
1338  if (getDolGlobalString('AGENDA_REMINDER_EMAIL') || getDolGlobalString('AGENDA_REMINDER_BROWSER')) {
1339  //checkbox create reminder
1340  print '<hr>';
1341  print '<br>';
1342  print '<label for="addreminder">'.img_picto('', 'bell', 'class="pictofixedwidth"').$langs->trans("AddReminder").'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1343 
1344  print '<div class="reminderparameters" style="display: none;">';
1345 
1346  //print '<hr>';
1347  //print load_fiche_titre($langs->trans("AddReminder"), '', '');
1348 
1349  print '<table class="border centpercent">';
1350 
1351  //Reminder
1352  print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ReminderTime").'</td><td colspan="3">';
1353  print '<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET('offsetvalue') ? GETPOST('offsetvalue', 'int') : '15').'"> ';
1354  print $form->selectTypeDuration('offsetunit', 'i', array('y', 'm'));
1355  print '</td></tr>';
1356 
1357  //Reminder Type
1358  print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ReminderType").'</td><td colspan="3">';
1359  print $form->selectarray('selectremindertype', $TRemindTypes, '', 0, 0, 0, '', 0, 0, 0, '', 'minwidth200 maxwidth500', 1);
1360  print '</td></tr>';
1361 
1362  //Mail Model
1363  if (getDolGlobalString('AGENDA_REMINDER_EMAIL')) {
1364  print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("EMailTemplates").'</td><td colspan="3">';
1365  print $form->selectModelMail('actioncommsend', 'actioncomm_send', 1, 1);
1366  print '</td></tr>';
1367  }
1368 
1369  print '</table>';
1370  print '</div>';
1371 
1372  print "\n".'<script type="text/javascript">';
1373  print '$(document).ready(function () {
1374  $("#addreminder").click(function(){
1375  console.log("Click on addreminder");
1376  if (this.checked) {
1377  $(".reminderparameters").show();
1378  } else {
1379  $(".reminderparameters").hide();
1380  }
1381  $("#selectremindertype").select2("destroy");
1382  $("#selectremindertype").select2();
1383  $("#select_offsetunittype_duration").select2("destroy");
1384  $("#select_offsetunittype_duration").select2();
1385  });
1386 
1387  $("#selectremindertype").change(function(){
1388  console.log("Change on selectremindertype");
1389  var selected_option = $("#selectremindertype option:selected").val();
1390  if(selected_option == "email") {
1391  $("#select_actioncommsendmodel_mail").closest("tr").show();
1392  } else {
1393  $("#select_actioncommsendmodel_mail").closest("tr").hide();
1394  };
1395  });
1396  })';
1397  print '</script>'."\n";
1398  }
1399 
1400  print dol_get_fiche_end();
1401 
1402  print $form->buttonsSaveCancel("Add");
1403 
1404  print "</form>";
1405 }
1406 
1407 // View or edit
1408 if ($id > 0) {
1409  $result1 = $object->fetch($id);
1410  if ($result1 <= 0) {
1411  $langs->load("errors");
1412  print $langs->trans("ErrorRecordNotFound");
1413 
1414  llxFooter();
1415  exit;
1416  }
1417 
1418  $result2 = $object->fetch_thirdparty();
1419  $result2 = $object->fetch_projet();
1420  $result3 = $object->fetch_contact();
1421  $result4 = $object->fetch_userassigned();
1422  $result5 = $object->fetch_optionals();
1423 
1424  if ($listUserAssignedUpdated || $donotclearsession) {
1425  $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOST("percentage", 'int')); // If status is -1 or 100, percentage is not defined and we must use status
1426 
1427  $datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int'), 'tzuser');
1428  $datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int'), 'tzuser');
1429 
1430  $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09'), 'c_actioncomm');
1431  $object->label = GETPOST("label", "alphanohtml");
1432  $object->datep = $datep;
1433  $object->datef = $datef;
1434  $object->percentage = $percentage;
1435  $object->priority = GETPOST("priority", "alphanohtml");
1436  $object->fulldayevent = GETPOST("fullday") ? 1 : 0;
1437  $object->location = GETPOST('location', "alpanohtml");
1438  $object->socid = GETPOST("socid", "int");
1439  $socpeopleassigned = GETPOST("socpeopleassigned", 'array');
1440  foreach ($socpeopleassigned as $tmpid) {
1441  $object->socpeopleassigned[$id] = array('id' => $tmpid);
1442  }
1443  $object->contact_id = GETPOST("contactid", 'int');
1444  $object->fk_project = GETPOST("projectid", 'int');
1445 
1446  $object->note_private = GETPOST("note", 'restricthtml');
1447  }
1448 
1449  if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1450  dol_print_error($db, $object->error);
1451  exit;
1452  }
1453 
1454  if ($object->authorid > 0) {
1455  $tmpuser = new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser;
1456  }
1457  if ($object->usermodid > 0) {
1458  $tmpuser = new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser;
1459  }
1460 
1461 
1462  /*
1463  * Show tabs
1464  */
1465 
1466  $head = actions_prepare_head($object);
1467 
1468  $now = dol_now();
1469  $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1470 
1471 
1472  // Confirmation suppression action
1473  if ($action == 'delete') {
1474  print $form->formconfirm("card.php?id=".urlencode($id), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1);
1475  }
1476 
1477  if ($action == 'edit') {
1478  if (!empty($conf->use_javascript_ajax)) {
1479  print "\n".'<script type="text/javascript">';
1480  print '$(document).ready(function () {
1481  function setdatefields()
1482  {
1483  if ($("#fullday:checked").val() == null) {
1484  $(".fulldaystarthour").removeAttr("disabled");
1485  $(".fulldaystartmin").removeAttr("disabled");
1486  $(".fulldayendhour").removeAttr("disabled");
1487  $(".fulldayendmin").removeAttr("disabled");
1488  } else {
1489  $(".fulldaystarthour").prop("disabled", true).val("00");
1490  $(".fulldaystartmin").prop("disabled", true).val("00");
1491  $(".fulldayendhour").prop("disabled", true).val("23");
1492  $(".fulldayendmin").prop("disabled", true).val("59");
1493  }
1494  }
1495  setdatefields();
1496  $("#fullday").change(function() {
1497  setdatefields();
1498  });
1499  $("#actioncode").change(function() {
1500  if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1501  else $("#dateend").removeClass("fieldrequired");
1502  });
1503  })';
1504  print '</script>'."\n";
1505  }
1506 
1507  print '<form name="formaction" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
1508  print '<input type="hidden" name="token" value="'.newToken().'">';
1509  print '<input type="hidden" name="action" value="update">';
1510  print '<input type="hidden" name="id" value="'.$id.'">';
1511  print '<input type="hidden" name="ref_ext" value="'.$object->ref_ext.'">';
1512  print '<input type="hidden" name="page_y" value="">';
1513  if ($backtopage) {
1514  print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : dol_htmlentities($_SERVER["HTTP_REFERER"])).'">';
1515  }
1516  if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1517  print '<input type="hidden" name="actioncode" value="'.$object->type_code.'">';
1518  }
1519 
1520  print dol_get_fiche_head($head, 'card', $langs->trans("Action"), 0, 'action');
1521 
1522  print '<table class="border tableforfield" width="100%">';
1523 
1524  // Ref
1525  print '<tr><td class="titlefieldcreate">'.$langs->trans("Ref").'</td><td colspan="3">'.$object->id.'</td></tr>';
1526 
1527  // Type of event
1528  if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1529  print '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td colspan="3">';
1530  if ($object->type_code != 'AC_OTH_AUTO') {
1531  print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"');
1532  print $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ? GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto", 0, 0, 0, 1);
1533  } else {
1534  print '<input type="hidden" name="actioncode" value="'.$object->type_code.'">';
1535  print $object->getTypePicto();
1536  print $langs->trans("Action".$object->type_code);
1537  }
1538  print '</td></tr>';
1539  }
1540 
1541  // Title
1542  print '<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE) ? ' class="fieldrequired titlefieldcreate"' : '').'>'.$langs->trans("Title").'</td><td colspan="3"><input type="text" name="label" class="soixantepercent" value="'.$object->label.'"></td></tr>';
1543 
1544  // Full day event
1545  print '<tr><td><span class="fieldrequired">'.$langs->trans("Date").'</span></td><td colspan="3" class="valignmiddle height30 small"><input type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent ? ' checked' : '').'>';
1546  print '<label for="fullday">'.$langs->trans("EventOnFullDay").'</label>';
1547 
1548  // Recurring event
1549  $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
1550  if ($userepeatevent) {
1551  // Repeat
1552  //print '<tr><td></td><td colspan="3">';
1553  print ' &nbsp; &nbsp; &nbsp; &nbsp; <div class="opacitymedium inline-block">';
1554  print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"');
1555  print '<input type="hidden" name="recurid" value="'.$object->recurid.'">';
1556  $selectedrecurrulefreq = 'no';
1557  $selectedrecurrulebymonthday = '';
1558  $selectedrecurrulebyday = '';
1559  if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) {
1560  $selectedrecurrulefreq = $reg[1];
1561  }
1562  if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) {
1563  $selectedrecurrulebymonthday = $reg[1];
1564  }
1565  if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) {
1566  $selectedrecurrulebyday = $reg[1];
1567  }
1568  print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly');
1569  // If recurrulefreq is MONTHLY
1570  print '<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1571  print $langs->trans("DayOfMonth").': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.'">';
1572  print '</div>';
1573  // If recurrulefreq is WEEKLY
1574  print '<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1575  print $langs->trans("DayOfWeek").': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.'">';
1576  print '</div>';
1577  print '<script type="text/javascript">
1578  jQuery(document).ready(function() {
1579  function init_repeat()
1580  {
1581  if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1582  {
1583  jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1584  jQuery(".repeateventBYDAY").hide();
1585  }
1586  else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1587  {
1588  jQuery(".repeateventBYMONTHDAY").hide();
1589  jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1590  }
1591  else
1592  {
1593  jQuery(".repeateventBYMONTHDAY").hide();
1594  jQuery(".repeateventBYDAY").hide();
1595  }
1596  }
1597  init_repeat();
1598  jQuery("#recurrulefreq").change(function() {
1599  init_repeat();
1600  });
1601  });
1602  </script>';
1603  print '</div>';
1604  //print '</td></tr>';
1605  }
1606  print '</td></tr>';
1607 
1608  // Date start - end
1609  print '<tr><td class="nowrap">';
1610  /*print '<span class="fieldrequired">'.$langs->trans("DateActionStart").'</span>';
1611  print ' - ';
1612  print '<span id="dateend"'.($object->type_code == 'AC_RDV' ? ' class="fieldrequired"' : '').'>'.$langs->trans("DateActionEnd").'</span>';
1613  */
1614  print '</td><td td colspan="3">';
1615  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
1616  if (GETPOST("afaire") == 1) {
1617  print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
1618  } elseif (GETPOST("afaire") == 2) {
1619  print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
1620  } else {
1621  print $form->selectDate($datep ? $datep : $object->datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
1622  }
1623  print ' <span class="hideonsmartphone">&nbsp; &nbsp; - &nbsp; &nbsp;</span> ';
1624  if (GETPOST("afaire") == 1) {
1625  print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
1626  } elseif (GETPOST("afaire") == 2) {
1627  print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
1628  } else {
1629  print $form->selectDate($datef ? $datef : $object->datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend', '', '', '', 1, '', '', $object->fulldayevent ? ($tzforfullday ? $tzforfullday : 'tzuserrel') : 'tzuserrel');
1630  }
1631  print '</td></tr>';
1632 
1633  print '<tr><td class="">&nbsp;</td><td></td></tr>';
1634 
1635  // Assigned to
1636  $listofuserid = array(); // User assigned
1637  if (empty($donotclearsession)) {
1638  if ($object->userownerid > 0) {
1639  $listofuserid[$object->userownerid] = array(
1640  'id'=>$object->userownerid,
1641  'type'=>'user',
1642  //'transparency'=>$object->userassigned[$user->id]['transparency'],
1643  'transparency'=>$object->transparency, // Force transparency on ownerfrom event
1644  'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'],
1645  'mandatory'=>$object->userassigned[$object->userownerid]['mandatory']
1646  );
1647  }
1648  if (!empty($object->userassigned)) { // Now concat assigned users
1649  // Restore array with key with same value than param 'id'
1650  $tmplist1 = $object->userassigned;
1651  foreach ($tmplist1 as $key => $val) {
1652  if ($val['id'] && $val['id'] != $object->userownerid) {
1653  $listofuserid[$val['id']] = $val;
1654  }
1655  }
1656  }
1657  $_SESSION['assignedtouser'] = json_encode($listofuserid);
1658  } else {
1659  if (!empty($_SESSION['assignedtouser'])) {
1660  $listofuserid = json_decode($_SESSION['assignedtouser'], true);
1661  }
1662  }
1663  $listofcontactid = $object->socpeopleassigned; // Contact assigned
1664  $listofotherid = $object->otherassigned; // Other undefined email (not used yet)
1665 
1666  print '<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans("ActionAssignedTo").'</td><td colspan="3">';
1667  print '<div class="assignedtouser">';
1668  print $form->select_dolusers_forevent(($action == 'create' ? 'add' : 'update'), 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, 'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1669  print '</div>';
1670  /*if (in_array($user->id,array_keys($listofuserid)))
1671  {
1672  print '<div class="myavailability">';
1673  print $langs->trans("MyAvailability").': <input id="transparency" type="checkbox" name="transparency"'.($listofuserid[$user->id]['transparency']?' checked':'').'>'.$langs->trans("Busy");
1674  print '</div>';
1675  }*/
1676  print '</td></tr>';
1677 
1678  // Realised by
1679  if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1680  print '<tr><td class="nowrap">'.$langs->trans("ActionDoneBy").'</td><td colspan="3">';
1681  print $form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1, 'doneby', 1);
1682  print '</td></tr>';
1683  }
1684 
1685  // Location
1686  if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1687  print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3"><input type="text" name="location" class="width500" value="'.$object->location.'"></td></tr>';
1688  }
1689 
1690  // Status
1691  print '<tr><td class="nowrap">'.$langs->trans("Status").' / '.$langs->trans("Percentage").'</td><td colspan="3">';
1692  $percent = GETPOSTISSET("percentage") ? GETPOST("percentage", "int") : $object->percentage;
1693  $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200');
1694  print '</td></tr>';
1695 
1696  // Tags-Categories
1697  if (!empty($conf->categorie->enabled)) {
1698  print '<tr><td>'.$langs->trans("Categories").'</td><td colspan="3">';
1699  $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1);
1700  $c = new Categorie($db);
1701  $cats = $c->containing($object->id, Categorie::TYPE_ACTIONCOMM);
1702  $arrayselected = array();
1703  foreach ($cats as $cat) {
1704  $arrayselected[] = $cat->id;
1705  }
1706  print img_picto('', 'category').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'quatrevingtpercent widthcentpercentminusx', 0, 0);
1707  print "</td></tr>";
1708  }
1709 
1710  print '</table>';
1711 
1712 
1713  print '<br><hr><br>';
1714 
1715 
1716  print '<table class="border tableforfield centpercent">';
1717 
1718  if (!empty($conf->societe->enabled)) {
1719  // Related company
1720  print '<tr><td class="titlefieldcreate">'.$langs->trans("ActionOnCompany").'</td>';
1721  print '<td>';
1722  print '<div class="maxwidth200onsmartphone">';
1723  $events = array(); // 'method'=parameter action of url, 'url'=url to call that return new list of contacts
1724  $events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
1725  // TODO Refresh also list of project if $conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY not defined with list linked to socid ?
1726  // FIXME If we change company, we may get a project that does not match
1727  print img_picto('', 'company', 'class="paddingrightonly"').$form->select_company($object->socid, 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth200');
1728  print '</div>';
1729  print '</td></tr>';
1730 
1731  // related contact
1732  print '<tr><td>'.$langs->trans("ActionOnContact").'</td><td>';
1733  print '<div class="maxwidth200onsmartphone">';
1734  print img_picto('', 'contact', 'class="paddingrightonly"').$form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid');
1735  print '</div>';
1736  print '</td>';
1737  print '</tr>';
1738  }
1739 
1740  // Project
1741  if (!empty($conf->project->enabled)) {
1742  $langs->load("projects");
1743 
1744  print '<tr><td class="titlefieldcreate">'.$langs->trans("Project").'</td><td>';
1745  print img_picto('', 'project', 'class="paddingrightonly"');
1746  $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth500');
1747  if ($numprojet == 0) {
1748  print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$object->socid.'&action=create&token='.newToken().'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddProject").'"></span></a>';
1749  }
1750  print '</td></tr>';
1751  }
1752 
1753  // Priority
1754  if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1755  print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("Priority").'</td><td>';
1756  print '<input type="text" name="priority" value="'.($object->priority ? $object->priority : '').'" size="5">';
1757  print '</td></tr>';
1758  }
1759 
1760  // Object linked
1761  if (!empty($object->fk_element) && !empty($object->elementtype)) {
1762  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1763  print '<tr>';
1764  print '<td>'.$langs->trans("LinkedObject").'</td>';
1765 
1766  if ($object->elementtype == 'task' && !empty($conf->project->enabled)) {
1767  print '<td id="project-task-input-container" >';
1768 
1769  $urloption = '?action=create&donotclearsession=1'; // we use create not edit for more flexibility
1770  $url = DOL_URL_ROOT.'/comm/action/card.php'.$urloption;
1771 
1772  // update task list
1773  print "\n".'<script type="text/javascript" >';
1774  print '$(document).ready(function () {
1775  $("#projectid").change(function () {
1776  var url = "'.$url.'&projectid="+$("#projectid").val();
1777  $.get(url, function(data) {
1778  console.log($( data ).find("#fk_element").html());
1779  if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
1780  })
1781  });
1782  })';
1783  print '</script>'."\n";
1784 
1785  $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element, 'fk_element', 24, 0, 0, 1, 0, 0, 'maxwidth500', $object->fk_project);
1786  print '<input type="hidden" name="elementtype" value="'.$object->elementtype.'">';
1787 
1788  print '</td>';
1789  } else {
1790  print '<td>';
1791  print dolGetElementUrl($object->fk_element, $object->elementtype, 1);
1792  print '<input type="hidden" name="fk_element" value="'.$object->fk_element.'">';
1793  print '<input type="hidden" name="elementtype" value="'.$object->elementtype.'">';
1794  print '</td>';
1795  }
1796 
1797  print '</tr>';
1798  }
1799 
1800  // Description
1801  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
1802  // Editeur wysiwyg
1803  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1804  $doleditor = new DolEditor('note', $object->note_private, '', 120, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%');
1805  $doleditor->Create();
1806  print '</td></tr>';
1807 
1808  // Other attributes
1809  $parameters = array();
1810  $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1811  print $hookmanager->resPrint;
1812  if (empty($reshook)) {
1813  print $object->showOptionals($extrafields, 'edit', $parameters);
1814  }
1815 
1816  print '</table>';
1817 
1818  // Reminders
1819  if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) {
1820  $filteruserid = $user->id;
1821  if ($user->rights->agenda->allactions->read) {
1822  $filteruserid = 0;
1823  }
1824  $object->loadReminders('', $filteruserid, false);
1825 
1826  print '<hr>';
1827 
1828  if (count($object->reminders) > 0) {
1829  $checked = 'checked';
1830  $keys = array_keys($object->reminders);
1831  $firstreminderId = array_shift($keys);
1832 
1833  $actionCommReminder = $object->reminders[$firstreminderId];
1834  } else {
1835  $checked = '';
1836  $actionCommReminder = new ActionCommReminder($db);
1837  $actionCommReminder->offsetvalue = 10;
1838  $actionCommReminder->offsetunit = 'i';
1839  $actionCommReminder->typeremind = 'email';
1840  }
1841 
1842  print '<label for="addreminder">'.$langs->trans("AddReminder").'</label> <input type="checkbox" id="addreminder" name="addreminder" '.$checked.'><br>';
1843 
1844  print '<div class="reminderparameters" '.(empty($checked) ? 'style="display: none;"' : '').'>';
1845 
1846  print '<br>';
1847 
1848  print '<table class="border centpercent">';
1849 
1850  // Reminder
1851  print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ReminderTime").'</td><td colspan="3">';
1852  print '<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.'"> ';
1853  print $form->selectTypeDuration('offsetunit', $actionCommReminder->offsetunit, array('y', 'm'));
1854  print '</td></tr>';
1855 
1856  // Reminder Type
1857  print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("ReminderType").'</td><td colspan="3">';
1858  print $form->selectarray('selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200', 1);
1859  print '</td></tr>';
1860 
1861  $hide = '';
1862  if ($actionCommReminder->typeremind == 'browser') {
1863  $hide = 'style="display:none;"';
1864  }
1865 
1866  // Mail Model
1867  print '<tr '.$hide.'><td class="titlefieldcreate nowrap">'.$langs->trans("EMailTemplates").'</td><td colspan="3">';
1868  print $form->selectModelMail('actioncommsend', 'actioncomm_send', 1, 1);
1869  print '</td></tr>';
1870 
1871  print '</table>';
1872 
1873  print "\n".'<script type="text/javascript">';
1874  print '$(document).ready(function () {
1875  $("#addreminder").click(function(){
1876  if (this.checked) {
1877  $(".reminderparameters").show();
1878  } else {
1879  $(".reminderparameters").hide();
1880  }
1881  });
1882 
1883  $("#selectremindertype").change(function(){
1884  var selected_option = $("#selectremindertype option:selected").val();
1885  if(selected_option == "email") {
1886  $("#select_actioncommsendmodel_mail").closest("tr").show();
1887  } else {
1888  $("#select_actioncommsendmodel_mail").closest("tr").hide();
1889  };
1890  });
1891 
1892  })';
1893  print '</script>'."\n";
1894 
1895  print '</div>'; // End of div for reminderparameters
1896  }
1897 
1898  print dol_get_fiche_end();
1899 
1900  print $form->buttonsSaveCancel();
1901 
1902  print '</form>';
1903  } else {
1904  print dol_get_fiche_head($head, 'card', $langs->trans("Action"), -1, 'action');
1905 
1906  // Clone event
1907  if ($action == 'clone') {
1908  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.GETPOST('id'), $langs->trans('ToClone'), $langs->trans('ConfirmCloneEvent', $object->label), 'confirm_clone', $formquestion, 'yes', 1);
1909 
1910  print $formconfirm;
1911  }
1912 
1913  $linkback = '';
1914  // Link to other agenda views
1915  $linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
1916  $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist', 'class="pictoactionview pictofixedwidth"');
1917  $linkback .= '<span class="hideonsmartphone">'.$langs->trans("BackToList").'</span>';
1918  $linkback .= '</a>';
1919  $linkback .= '</li>';
1920  $linkback .= '<li class="noborder litext">';
1921  $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').'">';
1922  $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview pictofixedwidth"');
1923  $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewCal").'</span>';
1924  $linkback .= '</a>';
1925  $linkback .= '</li>';
1926  $linkback .= '<li class="noborder litext">';
1927  $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').'">';
1928  $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview pictofixedwidth"');
1929  $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewWeek").'</span>';
1930  $linkback .= '</a>';
1931  $linkback .= '</li>';
1932  $linkback .= '<li class="noborder litext">';
1933  $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').'">';
1934  $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview pictofixedwidth"');
1935  $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewDay").'</span>';
1936  $linkback .= '</a>';
1937  $linkback .= '</li>';
1938  $linkback .= '<li class="noborder litext">';
1939  $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').'">';
1940  $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview pictofixedwidth"');
1941  $linkback .= '<span class="hideonsmartphone">'.$langs->trans("ViewPerUser").'</span>';
1942  $linkback .= '</a>';
1943 
1944  //$linkback.=$out;
1945 
1946  $morehtmlref = '<div class="refidno">';
1947  // Thirdparty
1948  //$morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
1949  // Project
1950  if (!empty($conf->project->enabled)) {
1951  $langs->load("projects");
1952  //$morehtmlref.='<br>'.$langs->trans('Project') . ' ';
1953  $morehtmlref .= $langs->trans('Project').' ';
1954  if ($user->rights->agenda->allactions->create ||
1955  (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
1956  if ($action != 'classify') {
1957  $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
1958  }
1959  if ($action == 'classify') {
1960  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
1961  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
1962  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
1963  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
1964  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
1965  $morehtmlref .= '<input type="submit" class="button button-save valignmiddle" value="'.$langs->trans("Modify").'">';
1966  $morehtmlref .= '</form>';
1967  } else {
1968  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
1969  }
1970  } else {
1971  if (!empty($object->fk_project)) {
1972  $proj = new Project($db);
1973  $proj->fetch($object->fk_project);
1974  $morehtmlref .= ' : '.$proj->getNomUrl(1);
1975  if ($proj->title) {
1976  $morehtmlref .= ' - '.$proj->title;
1977  }
1978  } else {
1979  $morehtmlref .= '';
1980  }
1981  }
1982  }
1983  $morehtmlref .= '</div>';
1984 
1985 
1986  dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'id', 'ref', $morehtmlref);
1987 
1988  print '<div class="fichecenter">';
1989  print '<div class="fichehalfleft">';
1990 
1991  print '<div class="underbanner clearboth"></div>';
1992 
1993  // Affichage fiche action en mode visu
1994  print '<table class="border tableforfield" width="100%">';
1995 
1996  // Type
1997  if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1998  print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td>';
1999  print $object->getTypePicto();
2000  print $langs->trans("Action".$object->type_code);
2001  print '</td></tr>';
2002  }
2003 
2004  // Full day event
2005  print '<tr><td class="titlefield">'.$langs->trans("EventOnFullDay").'</td><td>'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>';
2006 
2007  $rowspan = 4;
2008  if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2009  $rowspan++;
2010  }
2011 
2012  // Date start
2013  print '<tr><td>'.$langs->trans("DateActionStart").'</td><td>';
2014  // Test a date before the 27 march and one after
2015  //print dol_print_date($object->datep, 'dayhour', 'gmt');
2016  //print dol_print_date($object->datep, 'dayhour', 'tzuser');
2017  //print dol_print_date($object->datep, 'dayhour', 'tzuserrel');
2018  if (empty($object->fulldayevent)) {
2019  print dol_print_date($object->datep, 'dayhour', 'tzuserrel');
2020  } else {
2021  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
2022  print dol_print_date($object->datep, 'day', ($tzforfullday ? $tzforfullday : 'tzuserrel'));
2023  }
2024  if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2025  print img_warning($langs->trans("Late"));
2026  }
2027  print '</td>';
2028  print '</tr>';
2029 
2030  // Date end
2031  print '<tr><td>'.$langs->trans("DateActionEnd").'</td><td>';
2032  if (empty($object->fulldayevent)) {
2033  print dol_print_date($object->datef, 'dayhour', 'tzuserrel');
2034  } else {
2035  $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT');
2036  print dol_print_date($object->datef, 'day', ($tzforfullday ? $tzforfullday : 'tzuserrel'));
2037  }
2038  if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2039  print img_warning($langs->trans("Late"));
2040  }
2041  print '</td></tr>';
2042 
2043  // Location
2044  if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2045  print '<tr><td>'.$langs->trans("Location").'</td><td>'.$object->location.'</td></tr>';
2046  }
2047 
2048  // Assigned to
2049  print '<tr><td class="nowrap">'.$langs->trans("ActionAssignedTo").'</td><td>';
2050  $listofuserid = array();
2051  if (empty($donotclearsession)) {
2052  if ($object->userownerid > 0) {
2053  $listofuserid[$object->userownerid] = array(
2054  'id'=>$object->userownerid,
2055  'transparency'=>$object->transparency, // Force transparency on onwer from preoperty of event
2056  'answer_status'=>$object->userassigned[$object->userownerid]['answer_status'],
2057  'mandatory'=>$object->userassigned[$object->userownerid]['mandatory']
2058  );
2059  }
2060  if (!empty($object->userassigned)) { // Now concat assigned users
2061  // Restore array with key with same value than param 'id'
2062  $tmplist1 = $object->userassigned;
2063  foreach ($tmplist1 as $key => $val) {
2064  if ($val['id'] && $val['id'] != $object->userownerid) {
2065  $listofuserid[$val['id']] = $val;
2066  }
2067  }
2068  }
2069  $_SESSION['assignedtouser'] = json_encode($listofuserid);
2070  } else {
2071  if (!empty($_SESSION['assignedtouser'])) {
2072  $listofuserid = json_decode($_SESSION['assignedtouser'], true);
2073  }
2074  }
2075 
2076  $listofcontactid = array(); // not used yet
2077  $listofotherid = array(); // not used yet
2078  print '<div class="assignedtouser">';
2079  print $form->select_dolusers_forevent('view', 'assignedtouser', 1, '', 0, '', '', 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2080  print '</div>';
2081  /*
2082  if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
2083  {
2084  print '<div class="myavailability">';
2085  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
2086  print '</div>';
2087  }
2088  */
2089  print ' </td></tr>';
2090 
2091  // Done by
2092  if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
2093  print '<tr><td class="nowrap">'.$langs->trans("ActionDoneBy").'</td><td>';
2094  if ($object->userdoneid > 0) {
2095  $tmpuser = new User($db);
2096  $tmpuser->fetch($object->userdoneid);
2097  print $tmpuser->getNomUrl(1);
2098  }
2099  print '</td></tr>';
2100  }
2101 
2102  // Categories
2103  if (!empty($conf->categorie->enabled)) {
2104  print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
2105  print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2106  print "</td></tr>";
2107  }
2108 
2109  print '</table>';
2110 
2111  print '</div>';
2112 
2113  print '<div class="fichehalfright">';
2114 
2115  print '<div class="underbanner clearboth"></div>';
2116  print '<table class="border tableforfield centpercent">';
2117 
2118  if (!empty($conf->societe->enabled)) {
2119  // Related company
2120  print '<tr><td class="titlefield">'.$langs->trans("ActionOnCompany").'</td><td>'.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : ('<span class="opacitymedium">'.$langs->trans("None").'</span>'));
2121  if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') {
2122  if ($object->thirdparty->fetch($object->thirdparty->id)) {
2123  print "<br>".dol_print_phone($object->thirdparty->phone);
2124  }
2125  }
2126  print '</td></tr>';
2127 
2128  // Related contact
2129  print '<tr><td>'.$langs->trans("ActionOnContact").'</td>';
2130  print '<td>';
2131 
2132  if (!empty($object->socpeopleassigned)) {
2133  foreach ($object->socpeopleassigned as $cid => $Tab) {
2134  $contact = new Contact($db);
2135  $result = $contact->fetch($cid);
2136 
2137  if ($result < 0) {
2138  dol_print_error($db, $contact->error);
2139  }
2140 
2141  if ($result > 0) {
2142  print $contact->getNomUrl(1);
2143  if ($object->type_code == 'AC_TEL') {
2144  if (!empty($contact->phone_pro)) {
2145  print '('.dol_print_phone($contact->phone_pro).')';
2146  }
2147  }
2148  print '<div class="paddingright"></div>';
2149  }
2150  }
2151  } else {
2152  print '<span class="opacitymedium">'.$langs->trans("None").'</span>';
2153  }
2154  print '</td></tr>';
2155  }
2156 
2157  // Priority
2158  print '<tr><td class="nowrap" class="titlefield">'.$langs->trans("Priority").'</td><td>';
2159  print ($object->priority ? $object->priority : '');
2160  print '</td></tr>';
2161 
2162  // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
2163  // for such objects because there is already a dedicated field into table llx_actioncomm.
2164  if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe', 'contact', 'project'))) {
2165  include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
2166  print '<tr><td>'.$langs->trans("LinkedObject").'</td>';
2167  $link = dolGetElementUrl($object->fk_element, $object->elementtype, 1);
2168  print '<td>';
2169  if (empty($link)) {
2170  print '<span class="opacitymedium">'.$langs->trans("ObjectDeleted").'</span>';
2171  } else {
2172  print $link;
2173  }
2174  print '</td></tr>';
2175  }
2176 
2177  // Description
2178  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td class="wordbreak">';
2179  print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
2180  print '</td></tr>';
2181 
2182  // Other attributes
2183  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
2184 
2185  // Reminders
2186  if (!empty($conf->global->AGENDA_REMINDER_EMAIL) || !empty($conf->global->AGENDA_REMINDER_BROWSER)) {
2187  $filteruserid = $user->id;
2188  if ($user->rights->agenda->allactions->read) {
2189  $filteruserid = 0;
2190  }
2191  $object->loadReminders('', $filteruserid, false);
2192 
2193  print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("Reminders").'</td><td>';
2194 
2195  if (count($object->reminders) > 0) {
2196  $tmpuserstatic = new User($db);
2197 
2198  foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2199  print $TRemindTypes[$actioncommreminder->typeremind];
2200  if ($actioncommreminder->fk_user > 0) {
2201  $tmpuserstatic->fetch($actioncommreminder->fk_user);
2202  print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')';
2203  }
2204  print ' - '.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit];
2205  if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2206  print ' - <span class="opacitymedium">';
2207  print $langs->trans("NotSent");
2208  print ' </span>';
2209  } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2210  print ' - <span class="opacitymedium">';
2211  print $langs->trans("Done");
2212  print ' </span>';
2213  }
2214  print '<br>';
2215  }
2216  }
2217 
2218  print '</td></tr>';
2219  }
2220 
2221  print '</table>';
2222 
2223  print '</div>';
2224  print '</div>';
2225  print '<div class="clearboth"></div>';
2226 
2227  print dol_get_fiche_end();
2228  }
2229 
2230 
2231  /*
2232  * Action bar
2233  */
2234  print '<div class="tabsAction">';
2235 
2236  $parameters = array();
2237  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2238  if (empty($reshook)) {
2239  if ($action != 'edit') {
2240  if ($user->rights->agenda->allactions->create ||
2241  (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
2242  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Modify").'</a></div>';
2243  } else {
2244  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Modify").'</a></div>';
2245  }
2246 
2247  if ($user->rights->agenda->allactions->create ||
2248  (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
2249  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=clone&object='.$object->element.'&id='.$object->id.'">'.$langs->trans("ToClone").'</a></div>';
2250  } else {
2251  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("ToClone").'</a></div>';
2252  }
2253 
2254  if ($user->rights->agenda->allactions->delete ||
2255  (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete)) {
2256  print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().'&id='.$object->id.'">'.$langs->trans("Delete").'</a></div>';
2257  } else {
2258  print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Delete").'</a></div>';
2259  }
2260  }
2261  }
2262 
2263  print '</div>';
2264 
2265  if ($action != 'edit') {
2266  if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) {
2267  print '<div style="clear:both;"></div><div class="fichecenter"><div class="fichehalfleft">';
2268  print '<a name="builddoc"></a>'; // ancre
2269 
2270  /*
2271  * Generated documents
2272  */
2273 
2274  $filedir = $conf->agenda->multidir_output[$conf->entity].'/'.$object->id;
2275  $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
2276 
2277  $genallowed = $user->rights->agenda->myactions->read;
2278  $delallowed = $user->rights->agenda->myactions->create;
2279 
2280 
2281  print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang());
2282 
2283  print '</div><div class="fichehalfright">';
2284 
2285 
2286  print '</div></div>';
2287  }
2288  }
2289 }
2290 
2291 // End of page
2292 llxFooter();
2293 $db->close();
Class to manage different types of events.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Definition: card.php:142
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class for ActionCommReminder.
Class to manage building of HTML components.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
Class to manage agenda events (actions)
Class to manage contact/addresses.
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0)
Clean a string to keep only desirable HTML tags.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Definition: user.class.php:44
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
Definition: date.lib.php:383
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0, $filters= '')
Return an id or code from a code or id.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
Definition: agenda.php:116
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:121
actions_prepare_head($object)
Prepare array with list of tabs.
Definition: agenda.lib.php:413
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
Class to manage standard extra fields.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage building of HTML components.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class to offer components to list and upload files.
restrictedArea($user, $features, $objectid=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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
Class to manage tasks.
Definition: task.class.php:37
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_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage a WYSIWYG editor.
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.
llxFooter()
Empty footer.
Definition: wrapper.php:73
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of &#39;autofocus&#39; HTML5 tag)
$formconfirm
if ($action == &#39;delbookkeepingyear&#39;) {
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option= '')
Return link url to an object.