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