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');
74 $datep =
dol_mktime($fulldayevent ?
'00' : $aphour, $fulldayevent ?
'00' : $apmin, 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'));
75 $datef =
dol_mktime($fulldayevent ?
'23' : $p2hour, $fulldayevent ?
'59' : $p2min, $fulldayevent ?
'59' :
'0',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'));
78 $socid =
GETPOST(
'socid',
'int');
80 if ($user->socid) $socid = $user->socid;
81 $result =
restrictedArea($user,
'agenda', $id,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
82 if ($user->socid && $socid) $result =
restrictedArea($user,
'societe', $socid);
85 $donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
93 $form =
new Form($db);
98 if ($id > 0 && $action !=
'add') {
99 $ret = $object->fetch($id);
101 $ret = $object->fetch_optionals();
102 $ret1 = $object->fetch_userassigned();
104 if ($ret < 0 || $ret1 < 0) {
110 $extrafields->fetch_name_optionals_label($object->table_element);
113 $hookmanager->initHooks(array(
'actioncard',
'globalcard'));
115 $parameters = array(
'socid' => $socid);
116 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
117 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
119 $TRemindTypes = array();
120 if (!empty($conf->global->AGENDA_REMINDER_BROWSER)) $TRemindTypes[
'browser'] = array(
'label'=>$langs->trans(
'BrowserPush'),
'disabled'=>(empty($conf->global->AGENDA_REMINDER_BROWSER) ? 1 : 0));
121 if (!empty($conf->global->AGENDA_REMINDER_EMAIL)) $TRemindTypes[
'email'] = array(
'label'=>$langs->trans(
'EMail'),
'disabled'=>(empty($conf->global->AGENDA_REMINDER_EMAIL) ? 1 : 0));
123 $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'));
130 $listUserAssignedUpdated =
false;
132 if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0'))
134 $idtoremove =
GETPOST(
'removedassigned');
136 if (!empty($_SESSION[
'assignedtouser'])) $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'], 1);
137 else $tmpassigneduserids = array();
139 foreach ($tmpassigneduserids as $key => $val)
141 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) unset($tmpassigneduserids[$key]);
144 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
145 $donotclearsession = 1;
146 if ($action ==
'add') $action =
'create';
147 if ($action ==
'update') $action =
'edit';
149 $listUserAssignedUpdated =
true;
153 if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser')))
156 if (
GETPOST(
'assignedtouser') > 0)
158 $assignedtouser = array();
159 if (!empty($_SESSION[
'assignedtouser']))
161 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
163 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id'=>
GETPOST(
'assignedtouser'),
'transparency'=>
GETPOST(
'transparency'),
'mandatory'=>1);
164 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
166 $donotclearsession = 1;
167 if ($action ==
'add') $action =
'create';
168 if ($action ==
'update') $action =
'edit';
170 $listUserAssignedUpdated =
true;
174 if (empty($reshook) && $action ==
'classin' && ($user->rights->agenda->allactions->create ||
175 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)))
178 $object->setProject(
GETPOST(
'projectid',
'int'));
182 if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes')
184 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers'))
190 if (!empty($object->socpeopleassigned)) {
191 reset($object->socpeopleassigned);
192 $object->contact_id = key($object->socpeopleassigned);
194 $result = $object->createFromClone($user,
GETPOST(
'socid',
'int'));
196 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
'?id='.$result);
207 if (empty($reshook) && $action ==
'add')
211 if (empty($backtopage))
213 if ($socid > 0) $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
214 else $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
217 if (!empty($socpeopleassigned[0]))
219 $result = $contact->fetch($socpeopleassigned[0]);
224 header(
"Location: ".$backtopage);
228 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array(
GETPOST(
'complete'), array(-1, 100)) ?
GETPOST(
'complete') :
GETPOST(
"percentage"));
231 $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');
232 $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');
235 if (!$datef && $percentage == 100)
237 $error++; $donotclearsession = 1;
239 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), null,
'errors');
242 if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && !
GETPOST(
'label'))
244 $error++; $donotclearsession = 1;
246 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")), null,
'errors');
252 $error++; $donotclearsession = 1;
254 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
256 $object->type_code =
GETPOST(
'actioncode',
'aZ09');
263 $object->fulldayevent = (!empty($fulldayevent) ? 1 : 0);
264 $object->location =
GETPOST(
"location",
'alphanohtml');
265 $object->label =
GETPOST(
'label',
'alphanohtml');
266 $object->fk_element =
GETPOST(
"fk_element",
'int');
267 $object->elementtype =
GETPOST(
"elementtype",
'alpha');
270 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs))
272 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
274 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code)
276 $object->label = $langs->transnoentitiesnoconv(
"Action".$object->type_code).
"\n";
278 $cactioncomm->fetch($object->type_code);
279 $object->label = $cactioncomm->label;
285 $taskid =
GETPOST(
'taskid',
'int');
286 if (!empty($taskid)) {
287 $taskProject =
new Task($db);
288 if ($taskProject->fetch($taskid) > 0) {
289 $object->fk_project = $taskProject->fk_project;
292 $object->fk_element = $taskid;
293 $object->elementtype =
'task';
296 $object->datep = $datep;
297 $object->datef = $datef;
298 $object->percentage = $percentage;
299 $object->duree = (((int)
GETPOST(
'dureehour') * 60) + (
int)
GETPOST(
'dureemin')) * 60;
301 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
303 $listofuserid = array();
304 if (!empty($_SESSION[
'assignedtouser'])) $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
306 foreach ($listofuserid as $key => $value)
310 if ($value[
'id'] > 0) $object->userownerid = $value[
'id'];
311 $object->transparency = $transparency;
314 $object->userassigned[$value[
'id']] = array(
'id'=>$value[
'id'],
'transparency'=>$transparency);
320 if (!$error && !empty($conf->global->AGENDA_ENABLE_DONEBY))
322 if (
GETPOST(
"doneby") > 0) $object->userdoneid =
GETPOST(
"doneby",
"int");
325 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
327 if (
GETPOSTISSET(
"contactid")) $object->contact = $contact;
329 if (
GETPOST(
'socid',
'int') > 0)
331 $object->socid =
GETPOST(
'socid',
'int');
332 $object->fetch_thirdparty();
334 $object->societe = $object->thirdparty;
338 if (empty($object->userownerid) && empty($_SESSION[
'assignedtouser']))
340 $error++; $donotclearsession = 1;
342 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")), null,
'errors');
344 if ($object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent))))
346 $error++; $donotclearsession = 1;
348 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), null,
'errors');
353 $error++; $donotclearsession = 1;
355 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")), null,
'errors');
358 foreach ($socpeopleassigned as $cid)
360 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
362 if (!empty($object->socpeopleassigned))
364 reset($object->socpeopleassigned);
365 $object->contact_id = key($object->socpeopleassigned);
369 $ret = $extrafields->setOptionalsFromPost(null, $object);
370 if ($ret < 0) $error++;
377 $idaction = $object->create($user);
384 $categories =
GETPOST(
'categories',
'array');
385 $object->setCategories($categories);
387 unset($_SESSION[
'assignedtouser']);
390 if ($user->id != $object->userownerid) $moreparam =
"filtert=-1";
393 if ($addreminder ==
'on') {
398 $actionCommReminder->dateremind = $dateremind;
399 $actionCommReminder->typeremind = $remindertype;
400 $actionCommReminder->offsetunit = $offsetunit;
401 $actionCommReminder->offsetvalue = $offsetvalue;
402 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
403 $actionCommReminder->fk_actioncomm = $object->id;
404 if ($remindertype ==
'email') $actionCommReminder->fk_email_template = $modelmail;
407 foreach ($object->userassigned as $userassigned)
409 $actionCommReminder->fk_user = $userassigned[
'id'];
410 $res = $actionCommReminder->create($user);
415 $langs->load(
"errors");
416 $error = $langs->trans(
'ErrorReminderActionCommCreation');
418 $action =
'create'; $donotclearsession = 1;
430 if (!empty($backtopage))
432 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
433 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
436 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
438 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
444 $langs->load(
"errors");
445 $error = $langs->trans($object->error);
447 $action =
'create'; $donotclearsession = 1;
452 $action =
'create'; $donotclearsession = 1;
460 if (empty($reshook) && $action ==
'update')
464 $fulldayevent =
GETPOST(
'fullday');
465 $aphour =
GETPOST(
'aphour',
'int');
466 $apmin =
GETPOST(
'apmin',
'int');
467 $p2hour =
GETPOST(
'p2hour',
'int');
468 $p2min =
GETPOST(
'p2min',
'int');
469 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array(
GETPOST(
'complete'), array(-1, 100)) ?
GETPOST(
'complete') :
GETPOST(
"percentage"));
472 if ($aphour == -1) $aphour =
'0';
473 if ($apmin == -1) $apmin =
'0';
474 if ($p2hour == -1) $p2hour =
'0';
475 if ($p2min == -1) $p2min =
'0';
478 $object->fetch_optionals();
479 $object->fetch_userassigned();
480 $object->oldcopy = clone $object;
482 $datep =
dol_mktime($fulldayevent ?
'00' : $aphour, $fulldayevent ?
'00' : $apmin, 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
483 $datef =
dol_mktime($fulldayevent ?
'23' : $p2hour, $fulldayevent ?
'59' : $p2min, $fulldayevent ?
'59' :
'0',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
486 $object->label =
GETPOST(
"label",
"alphanohtml");
487 $object->datep = $datep;
488 $object->datef = $datef;
489 $object->percentage = $percentage;
490 $object->priority =
GETPOST(
"priority",
"int");
491 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
492 $object->location =
GETPOST(
'location',
"alphanohtml");
493 $object->socid =
GETPOST(
"socid",
"int");
494 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
495 $object->socpeopleassigned = array();
496 foreach ($socpeopleassigned as $cid) $object->socpeopleassigned[$cid] = array(
'id' => $cid);
497 $object->contact_id =
GETPOST(
"contactid",
'int');
498 if (empty($object->contact_id) && !empty($object->socpeopleassigned)) {
499 reset($object->socpeopleassigned);
500 $object->contact_id = key($object->socpeopleassigned);
502 $object->fk_project =
GETPOST(
"projectid",
'int');
503 $object->note_private = trim(
GETPOST(
"note",
"restricthtml"));
504 $object->fk_element =
GETPOST(
"fk_element",
"int");
505 $object->elementtype =
GETPOST(
"elementtype",
"alphanohtml");
506 if (!$datef && $percentage == 100)
508 $error++; $donotclearsession = 1;
509 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")), $object->errors,
'errors');
513 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
516 $listofuserid = array();
517 if (!empty($_SESSION[
'assignedtouser']))
520 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
521 foreach ($tmplist1 as $key => $val)
523 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) $listofuserid[$val[
'id']] = $val;
526 $assignedtouser = (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : 0);
527 if ($assignedtouser) $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>($user->id == $assignedtouser ? $transparency :
''));
529 $object->userassigned = array(); $object->userownerid = 0;
531 foreach ($listofuserid as $key => $val)
533 if ($i == 0) $object->userownerid = $val[
'id'];
534 $object->userassigned[$val[
'id']] = array(
'id'=>$val[
'id'],
'mandatory'=>0,
'transparency'=>($user->id == $val[
'id'] ? $transparency :
''));
538 $object->transparency = $transparency;
541 if (!empty($conf->global->AGENDA_ENABLE_DONEBY))
543 if (
GETPOST(
"doneby")) $object->userdoneid =
GETPOST(
"doneby",
"int");
549 $error++; $donotclearsession = 1;
551 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")), null,
'errors');
553 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
555 if (empty($object->userownerid))
557 $error++; $donotclearsession = 1;
559 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")), null,
'errors');
563 $ret = $extrafields->setOptionalsFromPost(null, $object);
564 if ($ret < 0) $error++;
568 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
569 $eventDateStart = $object->datep;
570 $eventDateEnd = $object->datef;
572 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
573 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
574 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
575 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
576 $sql .=
" WHERE ac.id != ".$object->id;
577 $sql .=
" AND er.resource_id IN (";
578 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
579 $sql .=
" WHERE element_id = ".$object->id;
580 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
581 $sql .=
" AND busy = 1";
583 $sql .=
" AND er.busy = 1";
587 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
589 if (!empty($eventDateEnd)) {
590 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
594 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
595 if (!empty($eventDateEnd)) {
596 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
601 $resql = $db->query($sql);
604 $object->error = $db->lasterror();
605 $object->errors[] = $object->error;
607 if ($db->num_rows(
$resql) > 0) {
610 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
611 while ($obj = $db->fetch_object(
$resql)) {
612 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
614 $object->errors[] = $object->error;
629 $result = $object->update($user);
634 $categories =
GETPOST(
'categories',
'array');
635 $object->setCategories($categories);
637 $object->loadReminders();
638 if (!empty($object->reminders) && $object->datep >
dol_now())
640 foreach ($object->reminders as $reminder)
642 $reminder->delete($user);
644 $object->reminders = array();
648 if ($addreminder ==
'on' && $object->datep >
dol_now()) {
653 $actionCommReminder->dateremind = $dateremind;
654 $actionCommReminder->typeremind = $remindertype;
655 $actionCommReminder->offsetunit = $offsetunit;
656 $actionCommReminder->offsetvalue = $offsetvalue;
657 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
658 $actionCommReminder->fk_actioncomm = $object->id;
659 if ($remindertype ==
'email') $actionCommReminder->fk_email_template = $modelmail;
662 foreach ($object->userassigned as $userassigned)
664 $actionCommReminder->fk_user = $userassigned[
'id'];
665 $res = $actionCommReminder->create($user);
669 $langs->load(
"errors");
670 $error = $langs->trans(
'ErrorReminderActionCommCreation');
672 $action =
'create'; $donotclearsession = 1;
678 unset($_SESSION[
'assignedtouser']);
680 if (!$error) $db->commit();
681 else $db->rollback();
691 if (!empty($backtopage))
693 unset($_SESSION[
'assignedtouser']);
694 header(
"Location: ".$backtopage);
703 if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes')
706 $object->fetch_optionals();
707 $object->fetch_userassigned();
708 $object->oldcopy = clone $object;
710 if ($user->rights->agenda->myactions->delete
711 || $user->rights->agenda->allactions->delete)
713 $result = $object->delete();
717 header(
"Location: index.php");
729 if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate')
736 $newdate =
GETPOST(
'newdate',
'alpha');
737 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0)
739 header(
"Location: ".$backtopage);
743 $datep =
dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4),
'tzuserrel');
746 if ($datep != $object->datep)
748 if (!empty($object->datef))
750 $object->datef += $datep - $object->datep;
752 $object->datep = $datep;
756 if (!empty($conf->global->RESOURCE_USED_IN_EVENT_CHECK) && $object->element ==
'action') {
757 $eventDateStart = $object->datep;
758 $eventDateEnd = $object->datef;
760 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
761 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
762 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
763 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape($object->element).
"'";
764 $sql .=
" WHERE ac.id != ".$object->id;
765 $sql .=
" AND er.resource_id IN (";
766 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
767 $sql .=
" WHERE element_id = ".$object->id;
768 $sql .=
" AND element_type = '".$db->escape($object->element).
"'";
769 $sql .=
" AND busy = 1";
771 $sql .=
" AND er.busy = 1";
775 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
777 if (!empty($eventDateEnd)) {
778 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
782 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
783 if (!empty($eventDateEnd)) {
784 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
789 $resql = $db->query($sql);
792 $object->error = $db->lasterror();
793 $object->errors[] = $object->error;
795 if ($db->num_rows(
$resql) > 0) {
798 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
799 while ($obj = $db->fetch_object(
$resql)) {
800 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
802 $object->errors[] = $object->error;
815 $result = $object->update($user);
825 if (!empty($backtopage))
827 header(
"Location: ".$backtopage);
836 $permissiontoadd = ($user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->read));
837 if (empty($reshook)) {
838 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
847 $form =
new Form($db);
850 $arrayrecurrulefreq = array(
851 'no'=>$langs->trans(
"OnceOnly"),
852 'MONTHLY'=>$langs->trans(
"EveryMonth"),
853 'WEEKLY'=>$langs->trans(
"EveryWeek"),
857 $help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda';
858 llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
860 if ($action ==
'create')
864 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
865 if (!empty($socpeopleassigned[0]))
867 $result = $contact->fetch($socpeopleassigned[0]);
873 if (!empty($conf->use_javascript_ajax))
875 print "\n".
'<script type="text/javascript">';
876 print '$(document).ready(function () {
877 function setdatefields()
879 if ($("#fullday:checked").val() == null) {
880 $(".fulldaystarthour").removeAttr("disabled");
881 $(".fulldaystartmin").removeAttr("disabled");
882 $(".fulldayendhour").removeAttr("disabled");
883 $(".fulldayendmin").removeAttr("disabled");
884 $("#p2").removeAttr("disabled");
886 $(".fulldaystarthour").prop("disabled", true).val("00");
887 $(".fulldaystartmin").prop("disabled", true).val("00");
888 $(".fulldayendhour").prop("disabled", true).val("23");
889 $(".fulldayendmin").prop("disabled", true).val("59");
890 $("#p2").removeAttr("disabled");
893 $("#fullday").change(function() {
894 console.log("setdatefields");
897 $("#selectcomplete").change(function() {
898 if ($("#selectcomplete").val() == 100)
900 if ($("#doneby").val() <= 0) $("#doneby").val(\''.$user->id.
'\');
902 if ($(
"#selectcomplete").val() == 0)
904 $(
"#doneby").val(-1);
907 $(
"#actioncode").change(
function() {
908 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
909 else $("#dateend").removeClass("fieldrequired");
911 $("#aphour,#apmin").change(function() {
912 if ($("#actioncode").val() == \'AC_RDV\') {
913 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
914 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
915 $("#p2min").val($("#apmin").val());
916 $("#p2day").val($("#apday").val());
917 $("#p2month").val($("#apmonth").val());
918 $("#p2year").val($("#apyear").val());
919 $("#p2").val($("#ap").val());
922 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
923 else $("#dateend").removeClass("fieldrequired");
926 print '</script>'.
"\n";
929 print '<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
930 print '<input type="hidden" name="token" value="'.newToken().
'">';
931 print '<input type="hidden" name="action" value="add">';
932 print '<input type="hidden" name="donotclearsession" value="1">';
933 if ($backtopage)
print '<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage : htmlentities(
$_SERVER[
"HTTP_REFERER"])).
'">';
934 if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
print '<input type="hidden" name="actioncode" value="'.
dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
941 print '<table class="border centpercent">';
944 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
946 print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
947 $default = (empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT) ?
'AC_RDV' : $conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT);
948 $formactions->select_type_actions(
GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : ($object->type_code ? $object->type_code : $default),
"actioncode",
"systemauto", 0, -1);
953 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>';
956 print '<tr><td>'.$langs->trans(
"EventOnFullDay").
'</td><td><input type="checkbox" id="fullday" name="fullday" '.(
GETPOST(
'fullday') ?
' checked' :
'').
'></td></tr>';
958 $datep = ($datep ? $datep : (is_null($object->datep) ?
'' : $object->datep));
960 $datef = ($datef ? $datef : $object->datef);
962 if (empty($datef) && !empty($datep))
964 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV' || empty($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT)) {
965 $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');
970 print '<tr><td class="nowrap">';
971 print '<span class="fieldrequired">'.$langs->trans(
"DateActionStart").
'</span>';
973 print '<span id="dateend"'.(GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV' ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
"DateActionEnd").
'</span>';
976 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart');
978 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart');
980 print ' <span class="hideonsmartphone"> - </span> ';
983 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend');
985 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend');
1002 $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
1003 if ($userepeatevent)
1006 print '<tr><td></td><td colspan="3">';
1007 print '<input type="hidden" name="recurid" value="'.$object->recurid.
'">';
1008 $selectedrecurrulefreq =
'no';
1009 $selectedrecurrulebymonthday =
'';
1010 $selectedrecurrulebyday =
'';
1011 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) $selectedrecurrulefreq = $reg[1];
1012 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) $selectedrecurrulebymonthday = $reg[1];
1013 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) $selectedrecurrulebyday = $reg[1];
1014 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1016 print '<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1017 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1020 print '<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1021 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1023 print '<script type="text/javascript" language="javascript">
1024 jQuery(document).ready(function() {
1025 function init_repeat()
1027 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1029 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1030 jQuery(".repeateventBYDAY").hide();
1032 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1034 jQuery(".repeateventBYMONTHDAY").hide();
1035 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1039 jQuery(".repeateventBYMONTHDAY").hide();
1040 jQuery(".repeateventBYDAY").hide();
1044 jQuery("#recurrulefreq").change(function() {
1053 print '<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1059 if (
GETPOST(
'complete') ==
'0' ||
GETPOST(
"afaire") == 1) $percent =
'0';
1060 elseif (
GETPOST(
'complete') == 100 ||
GETPOST(
"afaire") == 2) $percent = 100;
1062 $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200');
1066 if (empty($conf->global->AGENDA_DISABLE_LOCATION))
1068 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>';
1072 print '<tr><td class="tdtop nowrap">'.$langs->trans(
"ActionAffectedTo").
'</td><td>';
1073 $listofuserid = array();
1074 $listofcontactid = array();
1075 $listofotherid = array();
1077 if (empty($donotclearsession))
1079 $assignedtouser =
GETPOST(
"assignedtouser") ?
GETPOST(
"assignedtouser") : (!empty($object->userownerid) && $object->userownerid > 0 ? $object->userownerid : $user->id);
1080 if ($assignedtouser) $listofuserid[$assignedtouser] = array(
'id'=>$assignedtouser,
'mandatory'=>0,
'transparency'=>$object->transparency);
1082 $listofuserid[$assignedtouser][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1083 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1085 if (!empty($_SESSION[
'assignedtouser']))
1087 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1089 $firstelem = reset($listofuserid);
1090 if (isset($listofuserid[$firstelem[
'id']])) $listofuserid[$firstelem[
'id']][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1092 print '<div class="assignedtouser">';
1093 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1098 if (!empty($conf->global->AGENDA_ENABLE_DONEBY))
1100 print '<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
1101 print $form->select_dolusers(
GETPOSTISSET(
"doneby") ?
GETPOST(
"doneby",
'int') : (!empty($object->userdoneid) && $percent == 100 ? $object->userdoneid : 0),
'doneby', 1);
1105 if ($conf->categorie->enabled) {
1107 print '<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1108 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1109 print img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1116 print '<br><hr><br>';
1119 print '<table class="border centpercent">';
1121 if ($conf->societe->enabled)
1124 print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1125 if (
GETPOST(
'socid',
'int') > 0) {
1127 $societe->fetch(
GETPOST(
'socid',
'int'));
1128 print $societe->getNomUrl(1);
1129 print '<input type="hidden" id="socid" name="socid" value="'.GETPOST(
'socid',
'int').
'">';
1132 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1134 if (!empty($user->socid)) {
1135 print img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300');
1137 print img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
1143 print '<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1144 $preselectedids =
GETPOST(
'socpeopleassigned',
'array');
1145 if (
GETPOST(
'contactid',
'int')) $preselectedids[
GETPOST(
'contactid',
'int')] =
GETPOST(
'contactid',
'int');
1147 print $form->selectcontacts(
GETPOST(
'socid',
'int'), $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 quatrevingtpercent',
false, 0, array(),
false,
'multiple',
'contactid');
1152 if (!empty($conf->projet->enabled))
1154 $langs->load(
"projects");
1156 $projectid =
GETPOST(
'projectid',
'int');
1158 print '<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container" >';
1160 print $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx');
1162 print ' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$societe->id.
'&action=create"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1163 $urloption =
'?action=create&donotclearsession=1';
1167 print "\n".
'<script type="text/javascript">';
1168 print '$(document).ready(function () {
1169 $("#projectid").change(function () {
1170 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#projectid").val()+"&projectid="+$("#projectid").val();
1171 console.log("Call url to get new list of tasks: "+url);
1172 $.get(url, function(data) {
1174 if (data) $("#taskid").html(data).select2();
1178 print '</script>'.
"\n";
1182 print '<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1184 $projectsListId =
false;
1185 if (!empty($projectid)) { $projectsListId = $projectid; }
1187 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500', $projectsListId);
1192 if (!empty($origin) && !empty($originid))
1194 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1195 print '<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1196 print '<td colspan="3">'.dolGetElementUrl($originid, $origin, 1).
'</td></tr>';
1197 print '<input type="hidden" name="fk_element" value="'.GETPOST(
'originid',
'int').
'">';
1198 print '<input type="hidden" name="elementtype" value="'.GETPOST(
'origin').
'">';
1199 print '<input type="hidden" name="originid" value="'.GETPOST(
'originid',
'int').
'">';
1200 print '<input type="hidden" name="origin" value="'.GETPOST(
'origin').
'">';
1204 if (
GETPOST(
"datep") && preg_match(
'/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',
GETPOST(
"datep"), $reg))
1206 $object->datep =
dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]);
1210 if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1211 print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1212 print '<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOST(
'priority',
'int') : ($object->priority ? $object->priority :
'')).
'" size="5">';
1217 print '<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1218 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1219 $doleditor =
new DolEditor(
'note', (
GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') : $object->note_private),
'', 120,
'dolibarr_notes',
'In',
true,
true, $conf->fckeditor->enabled, ROWS_4,
'90%');
1220 $doleditor->Create();
1224 $parameters = array();
1225 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1226 print $hookmanager->resPrint;
1227 if (empty($reshook))
1229 print $object->showOptionals($extrafields,
'edit', $parameters);
1235 if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER)
1240 print '<label for="addreminder">'.$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1242 print '<div class="reminderparameters" style="display: none;">';
1247 print '<table class="border centpercent">';
1250 print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1251 print '<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOST(
'offsetvalue',
'int') :
'15').
'"> ';
1252 print $form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1256 print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1257 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'mimnwidth200', 1);
1261 print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1262 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1269 print "\n".
'<script type="text/javascript">';
1270 print '$(document).ready(function () {
1271 $("#addreminder").click(function(){
1273 $(".reminderparameters").show();
1275 $(".reminderparameters").hide();
1279 $("#selectremindertype").change(function(){
1280 var selected_option = $("#selectremindertype option:selected").val();
1281 if(selected_option == "email") {
1282 $("#select_actioncommsendmodel_mail").closest("tr").show();
1284 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1288 print '</script>'.
"\n";
1293 print '<div class="center">';
1294 print '<input type="submit" class="button" name="save" value="'.$langs->trans(
"Add").
'">';
1295 print ' ';
1296 if (empty($backtopage)) {
1297 print '<input type="button" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'" onClick="javascript:history.go(-1)">';
1299 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1309 $result1 = $object->fetch($id);
1312 $langs->load(
"errors");
1313 print $langs->trans(
"ErrorRecordNotFound");
1319 $result2 = $object->fetch_thirdparty();
1320 $result2 = $object->fetch_projet();
1321 $result3 = $object->fetch_contact();
1322 $result4 = $object->fetch_userassigned();
1323 $result5 = $object->fetch_optionals();
1325 if ($listUserAssignedUpdated || $donotclearsession)
1327 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array(
GETPOST(
'complete'), array(-1, 100)) ?
GETPOST(
'complete') :
GETPOST(
"percentage"));
1329 $datep =
dol_mktime($fulldayevent ?
'00' : $aphour, $fulldayevent ?
'00' : $apmin, 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuser');
1330 $datef =
dol_mktime($fulldayevent ?
'23' : $p2hour, $fulldayevent ?
'59' : $p2min, $fulldayevent ?
'59' :
'0',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuser');
1333 $object->label =
GETPOST(
"label",
"alphanohtml");
1334 $object->datep = $datep;
1335 $object->datef = $datef;
1336 $object->percentage = $percentage;
1337 $object->priority =
GETPOST(
"priority",
"alphanohtml");
1338 $object->fulldayevent =
GETPOST(
"fullday") ? 1 : 0;
1339 $object->location =
GETPOST(
'location',
"alpanohtml");
1340 $object->socid =
GETPOST(
"socid",
"int");
1341 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1342 foreach ($socpeopleassigned as $tmpid) $object->socpeopleassigned[$id] = array(
'id' => $tmpid);
1343 $object->contact_id =
GETPOST(
"contactid",
'int');
1344 $object->fk_project =
GETPOST(
"projectid",
'int');
1346 $object->note_private =
GETPOST(
"note",
'restricthtml');
1349 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0)
1355 if ($object->authorid > 0) { $tmpuser =
new User($db); $res = $tmpuser->fetch($object->authorid); $object->author = $tmpuser; }
1356 if ($object->usermodid > 0) { $tmpuser =
new User($db); $res = $tmpuser->fetch($object->usermodid); $object->usermod = $tmpuser; }
1366 $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
1369 if ($action ==
'delete')
1371 print $form->formconfirm(
"card.php?id=".$id, $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1374 if ($action ==
'edit')
1376 if (!empty($conf->use_javascript_ajax))
1378 print "\n".
'<script type="text/javascript">';
1379 print '$(document).ready(function () {
1380 function setdatefields()
1382 if ($("#fullday:checked").val() == null) {
1383 $(".fulldaystarthour").removeAttr("disabled");
1384 $(".fulldaystartmin").removeAttr("disabled");
1385 $(".fulldayendhour").removeAttr("disabled");
1386 $(".fulldayendmin").removeAttr("disabled");
1388 $(".fulldaystarthour").prop("disabled", true).val("00");
1389 $(".fulldaystartmin").prop("disabled", true).val("00");
1390 $(".fulldayendhour").prop("disabled", true).val("23");
1391 $(".fulldayendmin").prop("disabled", true).val("59");
1395 $("#fullday").change(function() {
1399 print '</script>'.
"\n";
1402 print '<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1403 print '<input type="hidden" name="token" value="'.newToken().
'">';
1404 print '<input type="hidden" name="action" value="update">';
1405 print '<input type="hidden" name="id" value="'.$id.
'">';
1406 print '<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
1407 if ($backtopage)
print '<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage : htmlentities(
$_SERVER[
"HTTP_REFERER"])).
'">';
1408 if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
print '<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1412 print '<table class="border tableforfield" width="100%">';
1415 print '<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.$object->id.
'</td></tr>';
1418 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
1420 print '<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
1421 if ($object->type_code !=
'AC_OTH_AUTO')
1423 $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') : $object->type_code,
"actioncode",
"systemauto");
1425 print '<input type="hidden" name="actioncode" value="'.$object->type_code.
'">'.$langs->trans(
"Action".$object->type_code);
1431 print '<tr><td class="fieldrequired">'.$langs->trans(
"Title").
'</td><td colspan="3"><input type="text" name="label" class="soixantepercent" value="'.$object->label.
'"></td></tr>';
1434 print '<tr><td>'.$langs->trans(
"EventOnFullDay").
'</td><td colspan="3"><input type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent ?
' checked' :
'').
'></td></tr>';
1437 print '<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans(
"DateActionStart").
' - '.$langs->trans(
"DateActionEnd").
'</span></td><td colspan="3">';
1439 print $form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 0,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuser');
1440 } elseif (
GETPOST(
"afaire") == 2) {
1441 print $form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuser');
1443 print $form->selectDate($datep ? $datep : $object->datep,
'ap', 1, 1, 1,
"action", 1, 1, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuser');
1447 print $form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 1, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuser');
1448 } elseif (
GETPOST(
"afaire") == 2) {
1449 print $form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 1, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuser');
1451 print $form->selectDate($datef ? $datef : $object->datef,
'p2', 1, 1, 1,
"action", 1, 1, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuser');
1456 $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0);
1457 if ($userepeatevent)
1460 print '<tr><td></td><td colspan="3">';
1461 print '<input type="hidden" name="recurid" value="'.$object->recurid.
'">';
1462 $selectedrecurrulefreq =
'no';
1463 $selectedrecurrulebymonthday =
'';
1464 $selectedrecurrulebyday =
'';
1465 if ($object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) $selectedrecurrulefreq = $reg[1];
1466 if ($object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) $selectedrecurrulebymonthday = $reg[1];
1467 if ($object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) $selectedrecurrulebyday = $reg[1];
1468 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1470 print '<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1471 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1474 print '<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1475 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1477 print '<script type="text/javascript" language="javascript">
1478 jQuery(document).ready(function() {
1479 function init_repeat()
1481 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1483 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1484 jQuery(".repeateventBYDAY").hide();
1486 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1488 jQuery(".repeateventBYMONTHDAY").hide();
1489 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1493 jQuery(".repeateventBYMONTHDAY").hide();
1494 jQuery(".repeateventBYDAY").hide();
1498 jQuery("#recurrulefreq").change(function() {
1507 print '<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
1508 $percent =
GETPOST(
"percentage") ?
GETPOST(
"percentage") : $object->percentage;
1509 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1513 if (empty($conf->global->AGENDA_DISABLE_LOCATION))
1515 print '<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="soixantepercent" value="'.$object->location.
'"></td></tr>';
1519 $listofuserid = array();
1520 if (empty($donotclearsession))
1522 if ($object->userownerid > 0)
1524 $listofuserid[$object->userownerid] = array(
1525 'id'=>$object->userownerid,
1528 'transparency'=>$object->transparency,
1529 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
1530 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
1533 if (!empty($object->userassigned))
1536 $tmplist1 = $object->userassigned;
1537 foreach ($tmplist1 as $key => $val)
1539 if ($val[
'id'] && $val[
'id'] != $object->userownerid)
1541 $listofuserid[$val[
'id']] = $val;
1545 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1547 if (!empty($_SESSION[
'assignedtouser']))
1549 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1552 $listofcontactid = $object->socpeopleassigned;
1553 $listofotherid = $object->otherassigned;
1555 print '<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
1556 print '<div class="assignedtouser">';
1557 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1568 if (!empty($conf->global->AGENDA_ENABLE_DONEBY))
1570 print '<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td colspan="3">';
1571 print $form->select_dolusers($object->userdoneid > 0 ? $object->userdoneid : -1,
'doneby', 1);
1575 if ($conf->categorie->enabled) {
1576 print '<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1577 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 1);
1579 $cats = $c->containing($object->id, Categorie::TYPE_ACTIONCOMM);
1580 $arrayselected = array();
1581 foreach ($cats as $cat) {
1582 $arrayselected[] = $cat->id;
1584 print img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1591 print '<br><hr><br>';
1594 print '<table class="border tableforfield centpercent">';
1596 if ($conf->societe->enabled)
1599 print '<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
1601 print '<div class="maxwidth200onsmartphone">';
1603 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1606 print img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth200');
1611 print '<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
1612 print '<div class="maxwidth200onsmartphone">';
1613 print img_picto(
'',
'contact',
'class="paddingrightonly"').$form->selectcontacts($object->socid, array_keys($object->socpeopleassigned),
'socpeopleassigned[]', 1,
'',
'', 1,
'quatrevingtpercent',
false, 0, 0, array(),
'multiple',
'contactid');
1620 if (!empty($conf->projet->enabled))
1622 $langs->load(
"projects");
1624 print '<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
1626 $numprojet = $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'maxwidth500');
1627 if ($numprojet == 0)
1629 print ' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$object->socid.
'&action=create&backtopage='.urlencode(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit').
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1635 if (!empty($conf->global->AGENDA_SUPPORT_PRIORITY_IN_EVENTS)) {
1636 print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
1637 print '<input type="text" name="priority" value="'.($object->priority ? $object->priority :
'').
'" size="5">';
1642 if (!empty($object->fk_element) && !empty($object->elementtype))
1644 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1646 print '<td>'.$langs->trans(
"LinkedObject").
'</td>';
1648 if ($object->elementtype ==
'task' && !empty($conf->projet->enabled))
1650 print '<td id="project-task-input-container" >';
1652 $urloption =
'?action=create&donotclearsession=1';
1653 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
1656 print "\n".
'<script type="text/javascript" >';
1657 print '$(document).ready(function () {
1658 $("#projectid").change(function () {
1659 var url = "'.$url.
'&projectid="+$("#projectid").val();
1660 $.get(url, function(data) {
1661 console.log($( data ).find("#fk_element").html());
1662 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
1666 print '</script>'.
"\n";
1668 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500', $object->fk_project);
1669 print '<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
1675 print '<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
1676 print '<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
1684 print '<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1686 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1687 $doleditor =
new DolEditor(
'note', $object->note_private,
'', 200,
'dolibarr_notes',
'In',
true,
true, $conf->fckeditor->enabled, ROWS_5,
'90%');
1688 $doleditor->Create();
1692 $parameters = array();
1693 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1694 print $hookmanager->resPrint;
1695 if (empty($reshook))
1697 print $object->showOptionals($extrafields,
'edit', $parameters);
1703 if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER)
1705 $filteruserid = $user->id;
1706 if ($user->rights->agenda->allactions->read) $filteruserid = 0;
1707 $object->loadReminders(
'', $filteruserid,
false);
1711 if (count($object->reminders) > 0) {
1712 $checked =
'checked';
1713 $keys = array_keys($object->reminders);
1714 $firstreminderId = array_shift($keys);
1716 $actionCommReminder = $object->reminders[$firstreminderId];
1720 $actionCommReminder->offsetvalue = 10;
1721 $actionCommReminder->offsetunit =
'i';
1722 $actionCommReminder->typeremind =
'email';
1725 print '<label for="addreminder">'.$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder" '.$checked.
'><br>';
1727 print '<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
1731 print
'<table class="border centpercent">';
1734 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1735 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
1736 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
1740 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1741 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
1745 if ($actionCommReminder->typeremind ==
'browser') $hide =
'style="display:none;"';
1748 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1749 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1754 print
"\n".
'<script type="text/javascript">';
1755 print
'$(document).ready(function () {
1756 $("#addreminder").click(function(){
1758 $(".reminderparameters").show();
1760 $(".reminderparameters").hide();
1764 $("#selectremindertype").change(function(){
1765 var selected_option = $("#selectremindertype option:selected").val();
1766 if(selected_option == "email") {
1767 $("#select_actioncommsendmodel_mail").closest("tr").show();
1769 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1774 print
'</script>'.
"\n";
1781 print
'<div class="center">';
1782 print
'<input type="submit" class="button button-save" name="edit" value="'.$langs->trans(
"Save").
'">';
1783 print
' ';
1784 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1793 if ($action ==
'clone')
1795 $formconfirm = $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent', $object->label),
'confirm_clone', $formquestion,
'yes', 1);
1802 $linkback .=
img_picto($langs->trans(
"BackToList"),
'object_list-alt',
'class="hideonsmartphone pictoactionview"');
1803 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
1804 $linkback .=
'</li>';
1805 $linkback .=
'<li class="noborder litext">';
1806 $linkback .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="hideonsmartphone pictoactionview"');
1807 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_month&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">'.$langs->trans(
"ViewCal").
'</a>';
1808 $linkback .=
'</li>';
1809 $linkback .=
'<li class="noborder litext">';
1810 $linkback .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="hideonsmartphone pictoactionview"');
1811 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_week&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">'.$langs->trans(
"ViewWeek").
'</a>';
1812 $linkback .=
'</li>';
1813 $linkback .=
'<li class="noborder litext">';
1814 $linkback .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="hideonsmartphone pictoactionview"');
1815 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/index.php?action=show_day&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">'.$langs->trans(
"ViewDay").
'</a>';
1816 $linkback .=
'</li>';
1817 $linkback .=
'<li class="noborder litext">';
1818 $linkback .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="hideonsmartphone pictoactionview"');
1819 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/peruser.php?action=show_peruser&year='.
dol_print_date($object->datep,
'%Y').
'&month='.
dol_print_date($object->datep,
'%m').
'&day='.
dol_print_date($object->datep,
'%d').
'">'.$langs->trans(
"ViewPerUser").
'</a>';
1823 $morehtmlref =
'<div class="refidno">';
1827 if (!empty($conf->projet->enabled))
1829 $langs->load(
"projects");
1831 $morehtmlref .= $langs->trans(
'Project').
' ';
1832 if ($user->rights->agenda->allactions->create ||
1833 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))
1835 if ($action !=
'classify') {
1836 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
1838 if ($action ==
'classify') {
1840 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
1841 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
1842 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
1843 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
1844 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
1845 $morehtmlref .=
'</form>';
1847 $morehtmlref .= $form->form_project(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
1850 if (!empty($object->fk_project)) {
1852 $proj->fetch($object->fk_project);
1853 $morehtmlref .=
'<a href="'.DOL_URL_ROOT.
'/projet/card.php?id='.$object->fk_project.
'" title="'.$langs->trans(
'ShowProject').
'">';
1854 $morehtmlref .= $proj->ref;
1855 $morehtmlref .=
'</a>';
1856 if ($proj->title) $morehtmlref .=
' - '.$proj->title;
1862 $morehtmlref .=
'</div>';
1865 dol_banner_tab($object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
1867 print
'<div class="fichecenter">';
1868 print
'<div class="fichehalfleft">';
1870 print
'<div class="underbanner clearboth"></div>';
1873 print
'<table class="border tableforfield" width="100%">';
1876 if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
1878 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>'.$langs->trans($object->type).
'</td></tr>';
1882 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn($object->fulldayevent, 3).
'</td></tr>';
1885 if (empty($conf->global->AGENDA_DISABLE_LOCATION)) $rowspan++;
1888 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
1889 if (!$object->fulldayevent) print
dol_print_date($object->datep,
'dayhour',
'tzuser');
1891 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) print
img_warning($langs->trans(
"Late"));
1896 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
1897 if (!$object->fulldayevent) print
dol_print_date($object->datef,
'dayhour',
'tzuser');
1899 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) print
img_warning($langs->trans(
"Late"));
1903 if (empty($conf->global->AGENDA_DISABLE_LOCATION))
1905 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.$object->location.
'</td></tr>';
1909 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
1910 $listofuserid = array();
1911 if (empty($donotclearsession))
1913 if ($object->userownerid > 0)
1915 $listofuserid[$object->userownerid] = array(
1916 'id'=>$object->userownerid,
1917 'transparency'=>$object->transparency,
1918 'answer_status'=>$object->userassigned[$object->userownerid][
'answer_status'],
1919 'mandatory'=>$object->userassigned[$object->userownerid][
'mandatory']
1922 if (!empty($object->userassigned))
1925 $tmplist1 = $object->userassigned;
1926 foreach ($tmplist1 as $key => $val)
1928 if ($val[
'id'] && $val[
'id'] != $object->userownerid) $listofuserid[$val[
'id']] = $val;
1931 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1933 if (!empty($_SESSION[
'assignedtouser']))
1935 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1939 $listofcontactid = array();
1940 $listofotherid = array();
1941 print
'<div class="assignedtouser">';
1942 print $form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
1952 print
' </td></tr>';
1955 if ($conf->global->AGENDA_ENABLE_DONEBY)
1957 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionDoneBy").
'</td><td>';
1958 if ($object->userdoneid > 0)
1960 $tmpuser =
new User($db);
1961 $tmpuser->fetch($object->userdoneid);
1962 print $tmpuser->getNomUrl(1);
1968 if ($conf->categorie->enabled) {
1969 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
1970 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
1978 print
'<div class="fichehalfright">';
1980 print
'<div class="underbanner clearboth"></div>';
1981 print
'<table class="border tableforfield centpercent">';
1983 if ($conf->societe->enabled)
1986 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td><td>'.($object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
1987 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code ==
'AC_TEL')
1989 if ($object->thirdparty->fetch($object->thirdparty->id))
1991 print
"<br>".dol_print_phone($object->thirdparty->phone);
1997 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2000 if (!empty($object->socpeopleassigned))
2002 foreach ($object->socpeopleassigned as $cid => $Tab)
2005 $result = $contact->fetch($cid);
2011 print $contact->getNomUrl(1);
2012 if ($object->type_code ==
'AC_TEL')
2014 if (!empty($contact->phone_pro)) print
'('.dol_print_phone($contact->phone_pro).
')';
2016 print
'<div class="paddingright"></div>';
2020 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2026 print
'<tr><td class="nowrap" class="titlefield">'.$langs->trans(
"Priority").
'</td><td>';
2027 print ($object->priority ? $object->priority :
'');
2032 if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array(
'societe',
'contact',
'project')))
2034 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2035 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2038 if (empty($link)) print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2044 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak">';
2049 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2052 if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER)
2054 $filtreuserid = $user->id;
2055 if ($user->rights->agenda->allactions->read) $filtreuserid = 0;
2056 $object->loadReminders(
'', $filteruserid,
false);
2058 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2060 if (count($object->reminders) > 0) {
2061 $tmpuserstatic =
new User($db);
2063 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2064 print $TRemindTypes[$actioncommreminder->typeremind];
2065 if ($actioncommreminder->fk_user > 0) {
2066 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2067 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2069 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2070 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2071 print
' - <span class="opacitymedium">';
2072 print $langs->trans(
"NotSent");
2074 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2075 print
' - <span class="opacitymedium">';
2076 print $langs->trans(
"Done");
2090 print
'<div class="clearboth"></div>';
2100 print
'<div class="tabsAction">';
2102 $parameters = array();
2103 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2104 if (empty($reshook))
2106 if ($action !=
'edit')
2108 if ($user->rights->agenda->allactions->create ||
2109 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))
2111 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2113 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2116 if ($user->rights->agenda->allactions->create ||
2117 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))
2119 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>';
2121 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2124 if ($user->rights->agenda->allactions->delete ||
2125 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->delete))
2127 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2129 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2136 if ($action !=
'edit')
2138 if (empty($conf->global->AGENDA_DISABLE_BUILDDOC))
2140 print
'<div style="clear:both;"></div><div class="fichecenter"><div class="fichehalfleft">';
2141 print
'<a name="builddoc"></a>';
2147 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.$object->id;
2148 $urlsource =
$_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2150 $genallowed = $user->rights->agenda->myactions->read;
2151 $delallowed = $user->rights->agenda->myactions->create;
2154 print $formfile->showdocuments(
'actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $object->default_lang);
2156 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
2159 print
'</div></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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class for ActionCommReminder.
Class to manage agenda events (actions)
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
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.
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.
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.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_getIdFromCode($db, $key, $tablename, $fieldkey= 'code', $fieldid= 'id', $entityfilter=0)
Return an id or code from a code or id.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
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_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0)
Clean a string to keep only desirable HTML tags.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option= '')
Return link url to an object.