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';
51 $langs->loadLangs(array(
"companies",
"other",
"commercial",
"bills",
"orders",
"agenda",
"mails"));
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');
61 $fulldayevent =
GETPOST(
'fullday',
'alpha');
63 $aphour =
GETPOST(
'aphour',
'int');
64 $apmin =
GETPOST(
'apmin',
'int');
65 $p2hour =
GETPOST(
'p2hour',
'int');
66 $p2min =
GETPOST(
'p2min',
'int');
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');
74 if ($complete ==
'na' || $complete == -2) {
81 $datep =
dol_mktime(
'00',
'00', 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
82 $datef =
dol_mktime(
'23',
'59',
'59',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
90 $socid =
GETPOST(
'socid',
'int');
93 $socid = $user->socid;
97 $donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
110 if ($id > 0 && $action !=
'add') {
111 $ret = $object->fetch($id);
113 $ret = $object->fetch_optionals();
114 $ret1 = $object->fetch_userassigned();
116 if ($ret < 0 || $ret1 < 0) {
122 $extrafields->fetch_name_optionals_label($object->table_element);
125 $hookmanager->initHooks(array(
'actioncard',
'globalcard'));
127 $parameters = array(
'socid' => $socid);
128 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
133 $TRemindTypes = array();
134 if (!empty($conf->global->AGENDA_REMINDER_BROWSER)) {
135 $TRemindTypes[
'browser'] = array(
'label'=>$langs->trans(
'BrowserPush'),
'disabled'=>(empty($conf->global->AGENDA_REMINDER_BROWSER) ? 1 : 0));
137 if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) {
138 $TRemindTypes[
'email'] = array(
'label'=>$langs->trans(
'EMail'),
'disabled'=>(empty($conf->global->AGENDA_REMINDER_EMAIL) ? 1 : 0));
141 $TDurationTypes = array(
'y'=>$langs->trans(
'Years'),
'm'=>$langs->trans(
'Month'),
'w'=>$langs->trans(
'Weeks'),
'd'=>$langs->trans(
'Days'),
'h'=>$langs->trans(
'Hours'),
'i'=>$langs->trans(
'Minutes'));
143 $result =
restrictedArea($user,
'agenda', $object->id,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
144 if ($user->socid && $socid) {
153 $listUserAssignedUpdated =
false;
155 if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
156 $idtoremove =
GETPOST(
'removedassigned');
158 if (!empty($_SESSION[
'assignedtouser'])) {
159 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'], 1);
161 $tmpassigneduserids = array();
164 foreach ($tmpassigneduserids as $key => $val) {
165 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
166 unset($tmpassigneduserids[$key]);
170 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
171 $donotclearsession = 1;
172 if ($action ==
'add') {
175 if ($action ==
'update') {
179 $listUserAssignedUpdated =
true;
183 if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
185 if (
GETPOST(
'assignedtouser') > 0) {
186 $assignedtouser = array();
187 if (!empty($_SESSION[
'assignedtouser'])) {
188 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
190 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id'=>
GETPOST(
'assignedtouser'),
'transparency'=>
GETPOST(
'transparency'),
'mandatory'=>1);
191 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
193 $donotclearsession = 1;
194 if ($action ==
'add') {
197 if ($action ==
'update') {
201 $listUserAssignedUpdated =
true;
205 if (empty($reshook) && $action ==
'classin' && ($user->rights->agenda->allactions->create ||
206 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))) {
208 $object->setProject(
GETPOST(
'projectid',
'int'));
212 if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes') {
213 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
218 if (!empty($object->socpeopleassigned)) {
219 reset($object->socpeopleassigned);
220 $object->contact_id = key($object->socpeopleassigned);
222 $result = $object->createFromClone($user,
GETPOST(
'socid',
'int'));
224 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
235 if (empty($reshook) && $action ==
'add') {
238 if (empty($backtopage)) {
240 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
242 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
246 if (!empty($socpeopleassigned[0])) {
247 $result = $contact->fetch($socpeopleassigned[0]);
251 header(
"Location: ".$backtopage);
255 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
261 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuser');
262 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuser');
264 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
265 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
269 if (!$datef && $percentage == 100) {
270 $error++; $donotclearsession = 1;
272 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), null,
'errors');
275 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && !
GETPOST(
'label')) {
276 $error++; $donotclearsession = 1;
278 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")), null,
'errors');
283 $error++; $donotclearsession = 1;
285 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
287 $object->type_code =
GETPOST(
'actioncode',
'aZ09');
293 $object->fulldayevent = ($fulldayevent ? 1 : 0);
294 $object->location =
GETPOST(
"location",
'alphanohtml');
295 $object->label =
GETPOST(
'label',
'alphanohtml');
297 if (
GETPOST(
"elementtype",
'alpha')) {
298 $modulecodetouseforpermissioncheck =
GETPOST(
"elementtype",
'alpha');
300 $hasPermissionOnLinkedObject = 0;
301 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
302 $hasPermissionOnLinkedObject = 1;
304 if ($hasPermissionOnLinkedObject) {
305 $object->fk_element =
GETPOST(
"fk_element",
'int');
306 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
311 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
312 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
314 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
315 $object->label = $langs->transnoentitiesnoconv(
"Action".$object->type_code).
"\n";
317 $cactioncomm->fetch($object->type_code);
318 $object->label = $cactioncomm->label;
324 $taskid =
GETPOST(
'taskid',
'int');
325 if (!empty($taskid)) {
326 $taskProject =
new Task($db);
327 if ($taskProject->fetch($taskid) > 0) {
328 $object->fk_project = $taskProject->fk_project;
331 $object->fk_element = $taskid;
332 $object->elementtype =
'task';
335 $object->datep = $datep;
336 $object->datef = $datef;
337 $object->percentage = $percentage;
338 $object->duree = (((int)
GETPOST(
'dureehour') * 60) + (
int)
GETPOST(
'dureemin')) * 60;
340 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
342 $listofuserid = array();
343 if (!empty($_SESSION[
'assignedtouser'])) {
344 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
347 foreach ($listofuserid as $key => $value) {
349 if ($value[
'id'] > 0) {
350 $object->userownerid = $value[
'id'];
352 $object->transparency = $transparency;
355 $object->userassigned[$value[
'id']] = array(
'id'=>$value[
'id'],
'transparency'=>$transparency);
361 if (!$error && !empty($conf->global->AGENDA_ENABLE_DONEBY)) {
363 $object->userdoneid =
GETPOST(
"doneby",
"int");
367 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
370 $object->contact = $contact;
373 if (
GETPOST(
'socid',
'int') > 0) {
374 $object->socid =
GETPOST(
'socid',
'int');
375 $object->fetch_thirdparty();
377 $object->societe = $object->thirdparty;
381 if (empty($object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
382 $error++; $donotclearsession = 1;
384 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")), null,
'errors');
386 if ($object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
387 $error++; $donotclearsession = 1;
389 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), null,
'errors');
393 $error++; $donotclearsession = 1;
395 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")), null,
'errors');
398 foreach ($socpeopleassigned as $cid) {
399 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
401 if (!empty($object->socpeopleassigned)) {
402 reset($object->socpeopleassigned);
403 $object->contact_id = key($object->socpeopleassigned);
407 $ret = $extrafields->setOptionalsFromPost(null, $object);
416 $idaction = $object->create($user);
419 if (!$object->error) {
421 $categories =
GETPOST(
'categories',
'array');
422 $object->setCategories($categories);
424 unset($_SESSION[
'assignedtouser']);
427 if ($user->id != $object->userownerid) {
428 $moreparam =
"filtert=-1";
432 if ($addreminder ==
'on') {
437 $actionCommReminder->dateremind = $dateremind;
438 $actionCommReminder->typeremind = $remindertype;
439 $actionCommReminder->offsetunit = $offsetunit;
440 $actionCommReminder->offsetvalue = $offsetvalue;
441 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
442 $actionCommReminder->fk_actioncomm = $object->id;
443 if ($remindertype ==
'email') {
444 $actionCommReminder->fk_email_template = $modelmail;
448 foreach ($object->userassigned as $userassigned) {
449 $actionCommReminder->fk_user = $userassigned[
'id'];
450 $res = $actionCommReminder->create($user);
455 $langs->load(
"errors");
456 $error = $langs->trans(
'ErrorReminderActionCommCreation');
458 $action =
'create'; $donotclearsession = 1;
469 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
477 if (!empty($backtopage)) {
478 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
479 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
480 } elseif ($idaction) {
481 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
483 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
489 $langs->load(
"errors");
490 $error = $langs->trans($object->error);
492 $action =
'create'; $donotclearsession = 1;
497 $action =
'create'; $donotclearsession = 1;
505 if (empty($reshook) && $action ==
'update') {
506 if (empty($cancel)) {
507 $fulldayevent =
GETPOST(
'fullday');
508 $aphour =
GETPOST(
'aphour',
'int');
509 $apmin =
GETPOST(
'apmin',
'int');
510 $p2hour =
GETPOST(
'p2hour',
'int');
511 $p2min =
GETPOST(
'p2min',
'int');
512 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
529 $object->fetch_optionals();
530 $object->fetch_userassigned();
531 $object->oldcopy = clone $object;
537 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuser');
538 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuser');
540 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOST(
"aphour",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apmin",
'int'), $fulldayevent ?
'00' :
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
541 $datef =
dol_mktime($fulldayevent ?
'23' :
GETPOST(
"p2hour",
'int'), $fulldayevent ?
'59' :
GETPOST(
"p2min",
'int'), $fulldayevent ?
'59' :
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
545 $object->label =
GETPOST(
"label",
"alphanohtml");
546 $object->datep = $datep;
547 $object->datef = $datef;
548 $object->percentage = $percentage;
549 $object->priority =
GETPOST(
"priority",
"int");
550 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
551 $object->location =
GETPOST(
'location',
"alphanohtml");
552 $object->socid =
GETPOST(
"socid",
"int");
553 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
554 $object->socpeopleassigned = array();
555 foreach ($socpeopleassigned as $cid) {
556 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
558 $object->contact_id =
GETPOST(
"contactid",
'int');
559 if (empty($object->contact_id) && !empty($object->socpeopleassigned)) {
560 reset($object->socpeopleassigned);
561 $object->contact_id = key($object->socpeopleassigned);
563 $object->fk_project =
GETPOST(
"projectid",
'int');
564 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
566 if (
GETPOST(
"elementtype",
'alpha')) {
567 $modulecodetouseforpermissioncheck =
GETPOST(
"elementtype",
'alpha');
569 $hasPermissionOnLinkedObject = 0;
570 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
571 $hasPermissionOnLinkedObject = 1;
573 if ($hasPermissionOnLinkedObject) {
574 $object->fk_element =
GETPOST(
"fk_element",
'int');
575 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
579 if (!$datef && $percentage == 100) {
580 $error++; $donotclearsession = 1;
581 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), $object->errors,
'errors');
585 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
588 $listofuserid = array();
589 if (!empty($_SESSION[
'assignedtouser'])) {
591 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
592 foreach ($tmplist1 as $key => $val) {
593 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
594 $listofuserid[$val[
'id']] = $val;
598 $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
599 if ($assignedtouser) {
600 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>($user->id == $assignedtouser ? $transparency :
''));
603 $object->userassigned = array(); $object->userownerid = 0;
605 foreach ($listofuserid as $key => $val) {
607 $object->userownerid = $val[
'id'];
609 $object->userassigned[$val[
'id']] = array(
'id'=>$val[
'id'],
'mandatory'=>0,
'transparency'=>($user->id == $val[
'id'] ? $transparency :
''));
613 $object->transparency = $transparency;
616 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
618 $object->userdoneid =
GETPOST(
"doneby",
"int");
624 $error++; $donotclearsession = 1;
626 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
628 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
630 if (empty($object->userownerid)) {
631 $error++; $donotclearsession = 1;
633 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")), null,
'errors');
637 $ret = $extrafields->setOptionalsFromPost(null, $object,
'@GETPOSTISSET');
644 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
645 $eventDateStart = $object->datep;
646 $eventDateEnd = $object->datef;
648 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
649 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
650 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
651 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
652 $sql .=
" WHERE ac.id <> ".((int) $object->id);
653 $sql .=
" AND er.resource_id IN (";
654 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
655 $sql .=
" WHERE element_id = ".((int) $object->id);
656 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
657 $sql .=
" AND busy = 1";
659 $sql .=
" AND er.busy = 1";
663 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
665 if (!empty($eventDateEnd)) {
666 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
670 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
671 if (!empty($eventDateEnd)) {
672 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
677 $resql = $db->query($sql);
680 $object->error = $db->lasterror();
681 $object->errors[] = $object->error;
683 if ($db->num_rows(
$resql) > 0) {
686 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
687 while ($obj = $db->fetch_object(
$resql)) {
688 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
690 $object->errors[] = $object->error;
704 $result = $object->update($user);
708 $categories =
GETPOST(
'categories',
'array');
709 $object->setCategories($categories);
711 $object->loadReminders($remindertype, 0,
false);
712 if (!empty($object->reminders) && $object->datep >
dol_now()) {
713 foreach ($object->reminders as $reminder) {
714 $reminder->delete($user);
716 $object->reminders = array();
720 if ($addreminder ==
'on' && $object->datep >
dol_now()) {
725 $actionCommReminder->dateremind = $dateremind;
726 $actionCommReminder->typeremind = $remindertype;
727 $actionCommReminder->offsetunit = $offsetunit;
728 $actionCommReminder->offsetvalue = $offsetvalue;
729 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
730 $actionCommReminder->fk_actioncomm = $object->id;
731 if ($remindertype ==
'email') {
732 $actionCommReminder->fk_email_template = $modelmail;
736 foreach ($object->userassigned as $userassigned) {
737 $actionCommReminder->fk_user = $userassigned[
'id'];
738 $res = $actionCommReminder->create($user);
742 $langs->load(
"errors");
743 $error = $langs->trans(
'ErrorReminderActionCommCreation');
745 $action =
'create'; $donotclearsession = 1;
751 unset($_SESSION[
'assignedtouser']);
766 if (!empty($backtopage)) {
767 unset($_SESSION[
'assignedtouser']);
768 header(
"Location: ".$backtopage);
777 if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
779 $object->fetch_optionals();
780 $object->fetch_userassigned();
781 $object->oldcopy = clone $object;
783 if ($user->rights->agenda->myactions->delete
784 || $user->rights->agenda->allactions->delete) {
785 $result = $object->delete();
788 header(
"Location: index.php");
800 if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
806 $newdate =
GETPOST(
'newdate',
'alpha');
807 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
808 header(
"Location: ".$backtopage);
812 $datep =
dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4),
'tzuserrel');
815 if ($datep != $object->datep) {
816 if (!empty($object->datef)) {
817 $object->datef += $datep - $object->datep;
819 $object->datep = $datep;
823 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
824 $eventDateStart = $object->datep;
825 $eventDateEnd = $object->datef;
827 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
828 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
829 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
830 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
831 $sql .=
" WHERE ac.id <> ".((int) $object->id);
832 $sql .=
" AND er.resource_id IN (";
833 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
834 $sql .=
" WHERE element_id = ".((int) $object->id);
835 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
836 $sql .=
" AND busy = 1";
838 $sql .=
" AND er.busy = 1";
842 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
844 if (!empty($eventDateEnd)) {
845 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
849 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
850 if (!empty($eventDateEnd)) {
851 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
856 $resql = $db->query($sql);
859 $object->error = $db->lasterror();
860 $object->errors[] = $object->error;
862 if ($db->num_rows(
$resql) > 0) {
865 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
866 while ($obj = $db->fetch_object(
$resql)) {
867 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
869 $object->errors[] = $object->error;
882 $result = $object->update($user);
892 if (!empty($backtopage)) {
893 header(
"Location: ".$backtopage);
902 $permissiontoadd = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read));
903 if (empty($reshook)) {
904 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
916 $arrayrecurrulefreq = array(
917 'no'=>$langs->trans(
"OnceOnly"),
918 'MONTHLY'=>$langs->trans(
"EveryMonth"),
919 'WEEKLY'=>$langs->trans(
"EveryWeek"),
923 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
926 if ($action ==
'create') {
929 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
930 if (!empty($socpeopleassigned[0])) {
931 $result = $contact->fetch($socpeopleassigned[0]);
939 if (!empty($conf->use_javascript_ajax)) {
940 print
"\n".
'<script type="text/javascript">';
941 print
'$(document).ready(function () {
942 function setdatefields()
944 if ($("#fullday:checked").val() == null) {
945 $(".fulldaystarthour").removeAttr("disabled");
946 $(".fulldaystartmin").removeAttr("disabled");
947 $(".fulldayendhour").removeAttr("disabled");
948 $(".fulldayendmin").removeAttr("disabled");
949 $("#p2").removeAttr("disabled");
951 $(".fulldaystarthour").prop("disabled", true).val("00");
952 $(".fulldaystartmin").prop("disabled", true).val("00");
953 $(".fulldayendhour").prop("disabled", true).val("23");
954 $(".fulldayendmin").prop("disabled", true).val("59");
955 $("#p2").removeAttr("disabled");
958 $("#fullday").change(function() {
959 console.log("setdatefields");
963 $("#selectcomplete").change(function() {
964 console.log("we change the complete status - set the doneby");
965 if ($("#selectcomplete").val() == 100) {
966 if ($("#doneby").val() <= 0) $("#doneby").val(\''.((int) $user->id).
'\');
968 if ($(
"#selectcomplete").val() == 0) {
969 $(
"#doneby").val(-1);
973 $(
"#actioncode").change(
function() {
974 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
975 else $("#dateend").removeClass("fieldrequired");
977 $("#aphour,#apmin").change(function() {
978 if ($("#actioncode").val() == \'AC_RDV\') {
979 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
980 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
981 $("#p2min").val($("#apmin").val());
982 $("#p2day").val($("#apday").val());
983 $("#p2month").val($("#apmonth").val());
984 $("#p2year").val($("#apyear").val());
985 $("#p2").val($("#ap").val());
988 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
989 else $("#dateend").removeClass("fieldrequired");
992 print
'</script>'.
"\n";
995 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
996 print
'<input type="hidden" name="token" value="'.newToken().
'">';
997 print
'<input type="hidden" name="action" value="add">';
998 print
'<input type="hidden" name="donotclearsession" value="1">';
999 print
'<input type="hidden" name="page_y" value="">';
1001 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
dol_htmlentities($_SERVER[
"HTTP_REFERER"])).
'">';
1003 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1004 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1007 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1008 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1015 print
'<table class="border centpercent">';
1018 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1019 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1020 $default = (empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT) ?
'AC_RDV' : $conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT);
1021 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1022 print
$formactions->select_type_actions(
GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : ($object->type_code ? $object->type_code : $default),
"actioncode",
"systemauto", 0, -1, 0, 1);
1027 print
'<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE) ?
' class="fieldrequired titlefieldcreate"' :
'').
'>'.$langs->trans(
"Label").
'</td><td><input type="text" id="label" name="label" class="soixantepercent" value="'.
GETPOST(
'label').
'"></td></tr>';
1030 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td class="valignmiddle height30 small"><input type="checkbox" id="fullday" name="fullday" '.(
GETPOST(
'fullday') ?
' checked' :
'').
'><label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
1033 $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
1034 if ($userepeatevent) {
1037 print
' <div class="opacitymedium inline-block">';
1038 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'class="paddingright2"');
1039 print
'<input type="hidden" name="recurid" value="'.(empty($object->recurid) ?
'' : $object->recurid).
'">';
1040 $selectedrecurrulefreq =
'no';
1041 $selectedrecurrulebymonthday =
'';
1042 $selectedrecurrulebyday =
'';
1044 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) {
1045 $selectedrecurrulefreq = $reg[1];
1047 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) {
1048 $selectedrecurrulebymonthday = $reg[1];
1050 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) {
1051 $selectedrecurrulebyday = $reg[1];
1053 print
$form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1055 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1056 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1059 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1060 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1062 print
'<script type="text/javascript">
1063 jQuery(document).ready(function() {
1064 function init_repeat()
1066 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1068 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1069 jQuery(".repeateventBYDAY").hide();
1071 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1073 jQuery(".repeateventBYMONTHDAY").hide();
1074 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1078 jQuery(".repeateventBYMONTHDAY").hide();
1079 jQuery(".repeateventBYDAY").hide();
1083 jQuery("#recurrulefreq").change(function() {
1094 $datep = ($datep ? $datep : (is_null($object->datep) ?
'' : $object->datep));
1095 if (
GETPOST(
'datep',
'int', 1)) {
1098 $datef = ($datef ? $datef : $object->datef);
1099 if (
GETPOST(
'datef',
'int', 1)) {
1102 if (empty($datef) && !empty($datep)) {
1103 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) {
1104 $datef =
dol_time_plus_duree($datep, (empty($conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS) ? 1 : $conf->global->AGENDA_AUTOSET_END_DATE_WITH_DELTA_HOURS),
'h');
1109 print
'<tr><td class="nowrap">';
1117 print
$form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1119 print
$form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1121 print
' <span class="hideonsmartphone"> - </span> ';
1123 print
$form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1125 print
$form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1129 print
'<tr><td class=""> </td><td></td></tr>';
1132 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1133 $listofuserid = array();
1134 $listofcontactid = array();
1135 $listofotherid = array();
1137 if (empty($donotclearsession)) {
1138 $assignedtouser =
GETPOST(
"assignedtouser") ?
GETPOST(
"assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
1139 if ($assignedtouser) {
1140 $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>$object->transparency);
1143 $listofuserid[$assignedtouser][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1144 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1146 if (!empty($_SESSION[
'assignedtouser'])) {
1147 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1149 $firstelem = reset($listofuserid);
1150 if (isset($listofuserid[$firstelem[
'id']])) {
1151 $listofuserid[$firstelem[
'id']][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1154 print
'<div class="assignedtouser">';
1155 print
$form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1160 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1161 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
1162 print
$form->select_dolusers(
GETPOSTISSET(
"doneby") ?
GETPOST(
"doneby",
'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0),
'doneby', 1);
1167 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1168 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.(
GETPOST(
'location') ?
GETPOST(
'location') : $object->location).
'"></td></tr>';
1172 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1174 $percent = $complete !==
'' ? $complete : -1;
1178 $percent =
GETPOST(
'percentage',
'int');
1180 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1182 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1186 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1189 if (!empty($conf->categorie->enabled)) {
1191 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1192 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1193 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1200 print
'<br><hr><br>';
1203 print
'<table class="border centpercent">';
1205 if (!empty($conf->societe->enabled)) {
1207 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1208 if (
GETPOST(
'socid',
'int') > 0) {
1210 $societe->fetch(
GETPOST(
'socid',
'int'));
1211 print $societe->getNomUrl(1);
1212 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOST(
'socid',
'int').
'">';
1215 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1217 if (!empty($user->socid)) {
1218 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300');
1220 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
1226 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1227 $preselectedids =
GETPOST(
'socpeopleassigned',
'array');
1228 if (
GETPOST(
'contactid',
'int')) {
1229 $preselectedids[
GETPOST(
'contactid',
'int')] =
GETPOST(
'contactid',
'int');
1231 if ($origin==
'contact') $preselectedids[
GETPOST(
'originid',
'int')] =
GETPOST(
'originid',
'int');
1232 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1233 print
$form->selectcontacts(
GETPOST(
'socid',
'int'), $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 quatrevingtpercent',
false, 0, array(),
false,
'multiple',
'contactid');
1238 if (!empty($conf->project->enabled)) {
1239 $langs->load(
"projects");
1241 $projectid =
GETPOST(
'projectid',
'int');
1243 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1244 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1245 print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
1247 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1248 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1249 $urloption =
'?action=create&donotclearsession=1';
1253 print
"\n".
'<script type="text/javascript">';
1254 print
'$(document).ready(function () {
1255 $("#projectid").change(function () {
1256 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#projectid").val()+"&projectid="+$("#projectid").val();
1257 console.log("Call url to get new list of tasks: "+url);
1258 $.get(url, function(data) {
1260 if (data) $("#taskid").html(data).select2();
1264 print
'</script>'.
"\n";
1268 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1269 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1270 $projectsListId =
false;
1271 if (!empty($projectid)) {
1272 $projectsListId = $projectid;
1277 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500', $projectsListId);
1282 if (!empty($origin) && !empty($originid)) {
1283 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1285 $hasPermissionOnLinkedObject = 0;
1286 if ($user->hasRight($origin,
'read')) {
1287 $hasPermissionOnLinkedObject = 1;
1291 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1293 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1294 print
'<td colspan="3">';
1295 if ($hasPermissionOnLinkedObject) {
1297 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1298 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1299 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1300 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1302 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1309 if (
GETPOST(
"datep") && preg_match(
'/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',
GETPOST(
"datep"), $reg)) {
1310 $object->datep =
dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]);
1314 if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1315 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1316 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOST(
'priority',
'int') : ($object->priority ? $object->priority :
'')).
'" size="5">';
1321 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1322 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1323 $doleditor =
new DolEditor(
'note', (
GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') : $object->note_private),
'', 120,
'dolibarr_notes',
'In',
true,
true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1324 $doleditor->Create();
1328 $parameters = array();
1329 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1330 print $hookmanager->resPrint;
1331 if (empty($reshook)) {
1332 print $object->showOptionals($extrafields,
'create', $parameters);
1342 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1344 print
'<div class="reminderparameters" style="display: none;">';
1349 print
'<table class="border centpercent">';
1352 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1353 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOST(
'offsetvalue',
'int') :
'15').
'"> ';
1354 print
$form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1358 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1359 print
$form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1364 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1365 print
$form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1372 print
"\n".
'<script type="text/javascript">';
1373 print
'$(document).ready(function () {
1374 $("#addreminder").click(function(){
1375 console.log("Click on addreminder");
1377 $(".reminderparameters").show();
1379 $(".reminderparameters").hide();
1381 $("#selectremindertype").select2("destroy");
1382 $("#selectremindertype").select2();
1383 $("#select_offsetunittype_duration").select2("destroy");
1384 $("#select_offsetunittype_duration").select2();
1387 $("#selectremindertype").change(function(){
1388 console.log("Change on selectremindertype");
1389 var selected_option = $("#selectremindertype option:selected").val();
1390 if(selected_option == "email") {
1391 $("#select_actioncommsendmodel_mail").closest("tr").show();
1393 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1397 print
'</script>'.
"\n";
1402 print
$form->buttonsSaveCancel(
"Add");
1409 $result1 = $object->fetch($id);
1410 if ($result1 <= 0) {
1411 $langs->load(
"errors");
1412 print $langs->trans(
"ErrorRecordNotFound");
1418 $result2 = $object->fetch_thirdparty();
1419 $result2 = $object->fetch_projet();
1420 $result3 = $object->fetch_contact();
1421 $result4 = $object->fetch_userassigned();
1422 $result5 = $object->fetch_optionals();
1424 if ($listUserAssignedUpdated || $donotclearsession) {
1425 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOST(
"percentage",
'int'));
1427 $datep =
dol_mktime($fulldayevent ?
'00' : $aphour, $fulldayevent ?
'00' : $apmin, 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
1428 $datef =
dol_mktime($fulldayevent ?
'23' : $p2hour, $fulldayevent ?
'59' : $p2min, $fulldayevent ?
'59' :
'0',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
1431 $object->label =
GETPOST(
"label",
"alphanohtml");
1432 $object->datep = $datep;
1433 $object->datef = $datef;
1434 $object->percentage = $percentage;
1435 $object->priority =
GETPOST(
"priority",
"alphanohtml");
1436 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
1437 $object->location =
GETPOST(
'location',
"alpanohtml");
1438 $object->socid =
GETPOST(
"socid",
"int");
1439 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1440 foreach ($socpeopleassigned as $tmpid) {
1441 $object->socpeopleassigned[$id] = array(
'id' => $tmpid);
1443 $object->contact_id =
GETPOST(
"contactid",
'int');
1444 $object->fk_project =
GETPOST(
"projectid",
'int');
1446 $object->note_private =
GETPOST(
"note",
'restricthtml');
1449 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1454 if ($object->authorid > 0) {
1455 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser;
1457 if ($object->usermodid > 0) {
1458 $tmpuser =
new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser;
1469 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1473 if ($action ==
'delete') {
1474 print
$form->formconfirm(
"card.php?id=".urlencode($id), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1477 if ($action ==
'edit') {
1478 if (!empty($conf->use_javascript_ajax)) {
1479 print
"\n".
'<script type="text/javascript">';
1480 print
'$(document).ready(function () {
1481 function setdatefields()
1483 if ($("#fullday:checked").val() == null) {
1484 $(".fulldaystarthour").removeAttr("disabled");
1485 $(".fulldaystartmin").removeAttr("disabled");
1486 $(".fulldayendhour").removeAttr("disabled");
1487 $(".fulldayendmin").removeAttr("disabled");
1489 $(".fulldaystarthour").prop("disabled", true).val("00");
1490 $(".fulldaystartmin").prop("disabled", true).val("00");
1491 $(".fulldayendhour").prop("disabled", true).val("23");
1492 $(".fulldayendmin").prop("disabled", true).val("59");
1496 $("#fullday").change(function() {
1499 $("#actioncode").change(function() {
1500 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1501 else $("#dateend").removeClass("fieldrequired");
1504 print
'</script>'.
"\n";
1507 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1508 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1509 print
'<input type="hidden" name="action" value="update">';
1510 print
'<input type="hidden" name="id" value="'.$id.
'">';
1511 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
1512 print
'<input type="hidden" name="page_y" value="">';
1514 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
dol_htmlentities($_SERVER[
"HTTP_REFERER"])).
'">';
1516 if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1517 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1522 print
'<table class="border tableforfield" width="100%">';
1525 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.$object->id.
'</td></tr>';
1528 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1529 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
1530 if ($object->type_code !=
'AC_OTH_AUTO') {
1531 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1532 print
$formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') : $object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
1534 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1535 print $object->getTypePicto();
1536 print $langs->trans(
"Action".$object->type_code);
1542 print
'<tr><td'.(empty($conf->global->AGENDA_USE_EVENT_TYPE) ?
' class="fieldrequired titlefieldcreate"' :
'').
'>'.$langs->trans(
"Title").
'</td><td colspan="3"><input type="text" name="label" class="soixantepercent" value="'.$object->label.
'"></td></tr>';
1545 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td colspan="3" class="valignmiddle height30 small"><input type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent ?
' checked' :
'').
'>';
1546 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
1549 $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
1550 if ($userepeatevent) {
1553 print
' <div class="opacitymedium inline-block">';
1554 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'class="paddingright2"');
1555 print
'<input type="hidden" name="recurid" value="'.$object->recurid.
'">';
1556 $selectedrecurrulefreq =
'no';
1557 $selectedrecurrulebymonthday =
'';
1558 $selectedrecurrulebyday =
'';
1559 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) {
1560 $selectedrecurrulefreq = $reg[1];
1562 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) {
1563 $selectedrecurrulebymonthday = $reg[1];
1565 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) {
1566 $selectedrecurrulebyday = $reg[1];
1568 print
$form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1570 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1571 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1574 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1575 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1577 print
'<script type="text/javascript">
1578 jQuery(document).ready(function() {
1579 function init_repeat()
1581 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1583 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1584 jQuery(".repeateventBYDAY").hide();
1586 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1588 jQuery(".repeateventBYMONTHDAY").hide();
1589 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1593 jQuery(".repeateventBYMONTHDAY").hide();
1594 jQuery(".repeateventBYDAY").hide();
1598 jQuery("#recurrulefreq").change(function() {
1609 print
'<tr><td class="nowrap">';
1614 print
'</td><td td colspan="3">';
1617 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 0,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1618 } elseif (
GETPOST(
"afaire") == 2) {
1619 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1621 print
$form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1623 print
' <span class="hideonsmartphone"> - </span> ';
1625 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1626 } elseif (
GETPOST(
"afaire") == 2) {
1627 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1629 print
$form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'', $object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1633 print
'<tr><td class=""> </td><td></td></tr>';
1636 $listofuserid = array();
1637 if (empty($donotclearsession)) {
1638 if ($object->userownerid > 0) {
1639 $listofuserid[$object->userownerid] = array(
1640 'id'=>$object->userownerid,
1643 'transparency'=>$object->transparency,
1644 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
1645 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
1648 if (!empty($object->userassigned)) {
1650 $tmplist1 = $object->userassigned;
1651 foreach ($tmplist1 as $key => $val) {
1652 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
1653 $listofuserid[$val[
'id']] = $val;
1657 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1659 if (!empty($_SESSION[
'assignedtouser'])) {
1660 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1663 $listofcontactid = $object->socpeopleassigned;
1664 $listofotherid = $object->otherassigned;
1666 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
1667 print
'<div class="assignedtouser">';
1668 print
$form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1679 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
1680 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td colspan="3">';
1681 print
$form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1,
'doneby', 1);
1686 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
1687 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="width500" value="'.$object->location.
'"></td></tr>';
1691 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
1692 $percent =
GETPOSTISSET(
"percentage") ?
GETPOST(
"percentage",
"int") : $object->percentage;
1693 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1697 if (!empty($conf->categorie->enabled)) {
1698 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1699 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1701 $cats = $c->containing($object->id, Categorie::TYPE_ACTIONCOMM);
1702 $arrayselected = array();
1703 foreach ($cats as $cat) {
1704 $arrayselected[] = $cat->id;
1706 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1713 print
'<br><hr><br>';
1716 print
'<table class="border tableforfield centpercent">';
1718 if (!empty($conf->societe->enabled)) {
1720 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
1722 print
'<div class="maxwidth200onsmartphone">';
1724 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1727 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth200');
1732 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
1733 print
'<div class="maxwidth200onsmartphone">';
1734 print
img_picto(
'',
'contact',
'class="paddingrightonly"').$form->selectcontacts($object->socid, array_keys($object->socpeopleassigned),
'socpeopleassigned[]', 1,
'',
'', 1,
'quatrevingtpercent',
false, 0, 0, array(),
'multiple',
'contactid');
1741 if (!empty($conf->project->enabled)) {
1742 $langs->load(
"projects");
1744 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
1745 print
img_picto(
'',
'project',
'class="paddingrightonly"');
1746 $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'maxwidth500');
1747 if ($numprojet == 0) {
1748 print
' <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>';
1754 if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1755 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
1756 print
'<input type="text" name="priority" value="'.($object->priority ? $object->priority :
'').
'" size="5">';
1761 if (!empty($object->fk_element) && !empty($object->elementtype)) {
1762 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1764 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
1766 if ($object->elementtype ==
'task' && !empty($conf->project->enabled)) {
1767 print
'<td id="project-task-input-container" >';
1769 $urloption =
'?action=create&donotclearsession=1';
1770 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
1773 print
"\n".
'<script type="text/javascript" >';
1774 print
'$(document).ready(function () {
1775 $("#projectid").change(function () {
1776 var url = "'.$url.
'&projectid="+$("#projectid").val();
1777 $.get(url, function(data) {
1778 console.log($( data ).find("#fk_element").html());
1779 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
1783 print
'</script>'.
"\n";
1785 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500', $object->fk_project);
1786 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
1792 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
1793 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
1801 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1803 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1804 $doleditor =
new DolEditor(
'note', $object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, $conf->fckeditor->enabled, ROWS_4,
'90%');
1805 $doleditor->Create();
1809 $parameters = array();
1810 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1811 print $hookmanager->resPrint;
1812 if (empty($reshook)) {
1813 print $object->showOptionals($extrafields,
'edit', $parameters);
1819 if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) {
1820 $filteruserid = $user->id;
1821 if ($user->rights->agenda->allactions->read) {
1824 $object->loadReminders(
'', $filteruserid,
false);
1828 if (count($object->reminders) > 0) {
1829 $checked =
'checked';
1830 $keys = array_keys($object->reminders);
1831 $firstreminderId = array_shift($keys);
1833 $actionCommReminder = $object->reminders[$firstreminderId];
1837 $actionCommReminder->offsetvalue = 10;
1838 $actionCommReminder->offsetunit =
'i';
1839 $actionCommReminder->typeremind =
'email';
1842 print
'<label for="addreminder">'.$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder" '.$checked.
'><br>';
1844 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
1848 print
'<table class="border centpercent">';
1851 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1852 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
1853 print
$form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
1857 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1858 print
$form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
1862 if ($actionCommReminder->typeremind ==
'browser') {
1863 $hide =
'style="display:none;"';
1867 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1868 print
$form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1873 print
"\n".
'<script type="text/javascript">';
1874 print
'$(document).ready(function () {
1875 $("#addreminder").click(function(){
1877 $(".reminderparameters").show();
1879 $(".reminderparameters").hide();
1883 $("#selectremindertype").change(function(){
1884 var selected_option = $("#selectremindertype option:selected").val();
1885 if(selected_option == "email") {
1886 $("#select_actioncommsendmodel_mail").closest("tr").show();
1888 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1893 print
'</script>'.
"\n";
1900 print
$form->buttonsSaveCancel();
1907 if ($action ==
'clone') {
1908 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent', $object->label),
'confirm_clone', $formquestion,
'yes', 1);
1915 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
1916 $linkback .=
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="pictoactionview pictofixedwidth"');
1917 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"BackToList").
'</span>';
1918 $linkback .=
'</a>';
1919 $linkback .=
'</li>';
1920 $linkback .=
'<li class="noborder litext">';
1921 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_month&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
1922 $linkback .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview pictofixedwidth"');
1923 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span>';
1924 $linkback .=
'</a>';
1925 $linkback .=
'</li>';
1926 $linkback .=
'<li class="noborder litext">';
1927 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_week&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
1928 $linkback .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview pictofixedwidth"');
1929 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span>';
1930 $linkback .=
'</a>';
1931 $linkback .=
'</li>';
1932 $linkback .=
'<li class="noborder litext">';
1933 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?mode=show_day&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
1934 $linkback .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview pictofixedwidth"');
1935 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span>';
1936 $linkback .=
'</a>';
1937 $linkback .=
'</li>';
1938 $linkback .=
'<li class="noborder litext">';
1939 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?mode=show_peruser&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">';
1940 $linkback .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview pictofixedwidth"');
1941 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span>';
1942 $linkback .=
'</a>';
1946 $morehtmlref =
'<div class="refidno">';
1950 if (!empty($conf->project->enabled)) {
1951 $langs->load(
"projects");
1953 $morehtmlref .= $langs->trans(
'Project').
' ';
1954 if ($user->rights->agenda->allactions->create ||
1955 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
1956 if ($action !=
'classify') {
1957 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
1959 if ($action ==
'classify') {
1961 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
1962 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
1963 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1964 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
1965 $morehtmlref .=
'<input type="submit" class="button button-save valignmiddle" value="'.$langs->trans(
"Modify").
'">';
1966 $morehtmlref .=
'</form>';
1968 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
1971 if (!empty($object->fk_project)) {
1973 $proj->fetch($object->fk_project);
1974 $morehtmlref .=
' : '.$proj->getNomUrl(1);
1976 $morehtmlref .=
' - '.$proj->title;
1983 $morehtmlref .=
'</div>';
1986 dol_banner_tab($object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
1988 print
'<div class="fichecenter">';
1989 print
'<div class="fichehalfleft">';
1991 print
'<div class="underbanner clearboth"></div>';
1994 print
'<table class="border tableforfield" width="100%">';
1997 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
1998 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
1999 print $object->getTypePicto();
2000 print $langs->trans(
"Action".$object->type_code);
2005 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn($object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2008 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2013 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2018 if (empty($object->fulldayevent)) {
2022 print
dol_print_date($object->datep,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2024 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2031 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2032 if (empty($object->fulldayevent)) {
2036 print
dol_print_date($object->datef,
'day', ($tzforfullday ? $tzforfullday :
'tzuserrel'));
2038 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2044 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
2045 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.$object->location.
'</td></tr>';
2049 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2050 $listofuserid = array();
2051 if (empty($donotclearsession)) {
2052 if ($object->userownerid > 0) {
2053 $listofuserid[$object->userownerid] = array(
2054 'id'=>$object->userownerid,
2055 'transparency'=>$object->transparency,
2056 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
2057 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
2060 if (!empty($object->userassigned)) {
2062 $tmplist1 = $object->userassigned;
2063 foreach ($tmplist1 as $key => $val) {
2064 if ($val[
'id'] && $val[
'id'] != $object->userownerid) {
2065 $listofuserid[$val[
'id']] = $val;
2069 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2071 if (!empty($_SESSION[
'assignedtouser'])) {
2072 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2076 $listofcontactid = array();
2077 $listofotherid = array();
2078 print
'<div class="assignedtouser">';
2079 print
$form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2089 print
' </td></tr>';
2092 if (!empty($conf->global->AGENDA_ENABLE_DONEBY)) {
2093 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
2094 if ($object->userdoneid > 0) {
2095 $tmpuser =
new User($db);
2096 $tmpuser->fetch($object->userdoneid);
2097 print $tmpuser->getNomUrl(1);
2103 if (!empty($conf->categorie->enabled)) {
2104 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2105 print
$form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2113 print
'<div class="fichehalfright">';
2115 print
'<div class="underbanner clearboth"></div>';
2116 print
'<table class="border tableforfield centpercent">';
2118 if (!empty($conf->societe->enabled)) {
2120 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td><td>'.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2121 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code ==
'AC_TEL') {
2122 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2123 print
"<br>".dol_print_phone($object->thirdparty->phone);
2129 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2132 if (!empty($object->socpeopleassigned)) {
2133 foreach ($object->socpeopleassigned as $cid => $Tab) {
2135 $result = $contact->fetch($cid);
2142 print $contact->getNomUrl(1);
2143 if ($object->type_code ==
'AC_TEL') {
2144 if (!empty($contact->phone_pro)) {
2145 print
'('.dol_print_phone($contact->phone_pro).
')';
2148 print
'<div class="paddingright"></div>';
2152 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2158 print
'<tr><td class="nowrap" class="titlefield">'.$langs->trans(
"Priority").
'</td><td>';
2159 print ($object->priority ? $object->priority :
'');
2164 if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array(
'societe',
'contact',
'project'))) {
2165 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2166 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2170 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2178 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
2183 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2186 if (!empty($conf->global->AGENDA_REMINDER_EMAIL) || !empty($conf->global->AGENDA_REMINDER_BROWSER)) {
2187 $filteruserid = $user->id;
2188 if ($user->rights->agenda->allactions->read) {
2191 $object->loadReminders(
'', $filteruserid,
false);
2193 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2195 if (count($object->reminders) > 0) {
2196 $tmpuserstatic =
new User($db);
2198 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2199 print $TRemindTypes[$actioncommreminder->typeremind];
2200 if ($actioncommreminder->fk_user > 0) {
2201 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2202 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2204 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2205 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2206 print
' - <span class="opacitymedium">';
2207 print $langs->trans(
"NotSent");
2209 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2210 print
' - <span class="opacitymedium">';
2211 print $langs->trans(
"Done");
2225 print
'<div class="clearboth"></div>';
2234 print
'<div class="tabsAction">';
2236 $parameters = array();
2237 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2238 if (empty($reshook)) {
2239 if ($action !=
'edit') {
2240 if ($user->rights->agenda->allactions->create ||
2241 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
2242 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2244 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2247 if ($user->rights->agenda->allactions->create ||
2248 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) {
2249 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=clone&object='.$object->element.
'&id='.$object->id.
'">'.$langs->trans(
"ToClone").
'</a></div>';
2251 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2254 if ($user->rights->agenda->allactions->delete ||
2255 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete)) {
2256 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2258 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2265 if ($action !=
'edit') {
2266 if (empty($conf->global->AGENDA_DISABLE_BUILDDOC)) {
2267 print
'<div style="clear:both;"></div><div class="fichecenter"><div class="fichehalfleft">';
2268 print
'<a name="builddoc"></a>';
2274 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.$object->id;
2275 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2277 $genallowed = $user->rights->agenda->myactions->read;
2278 $delallowed = $user->rights->agenda->myactions->create;
2281 print $formfile->showdocuments(
'actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2283 print
'</div><div class="fichehalfright">';
2286 print
'</div></div>';
Class to manage different types of events.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class for ActionCommReminder.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
Class to manage agenda events (actions)
dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0)
Clean a string to keep only desirable HTML tags.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default= '')
Return dolibarr global constant string value.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0, $filters= '')
Return an id or code from a code or id.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save"&&empty($cancel)) $help_url
View.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
actions_prepare_head($object)
Prepare array with list of tabs.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
Class to manage projects.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->supplier_invoice->lire)) if(isModEnabled('don')&&!empty($user->rights->don->lire)) if(isModEnabled('tax')&&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture')&&isModEnabled('commande')&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage a WYSIWYG editor.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
$formconfirm
if ($action == 'delbookkeepingyear') {
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option= '')
Return link url to an object.