35require
'../../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncommreminder.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
60$langs->loadLangs([
"companies",
"other",
"commercial",
"bills",
"orders",
"agenda",
"mails"]);
63$action =
GETPOST(
'action',
'aZ09');
64$cancel =
GETPOST(
'cancel',
'alpha');
65$backtopage =
GETPOST(
'backtopage',
'alpha');
66$socpeopleassigned =
GETPOST(
'socpeopleassigned',
'array');
67$origin =
GETPOST(
'origin',
'alpha');
69$confirm =
GETPOST(
'confirm',
'alpha');
71$fulldayevent =
GETPOST(
'fullday',
'alpha');
78$addreminder =
GETPOST(
'addreminder',
'alpha');
80$offsetunit =
GETPOST(
'offsetunittype_duration',
'aZ09');
81$remindertype =
GETPOST(
'selectremindertype',
'aZ09');
82$modelmail =
GETPOSTINT(
'actioncommsendmodel_mail');
83$complete =
GETPOST(
'complete',
'alpha');
84$private =
GETPOST(
'private',
'alphanohtml');
85if ($complete ==
'na' || $complete == -2) {
102 if (
GETPOST(
'datep') ==
'now') {
104 } elseif (preg_match(
'/^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$/',
GETPOST(
"datep"), $reg)) {
105 $datep =
dol_mktime((
int) $reg[4], (
int) $reg[5], (
int) $reg[6], (
int) $reg[2], (
int) $reg[3], (
int) $reg[1],
'tzuserrel');
106 } elseif (preg_match(
'/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',
GETPOST(
"datep"), $reg)) {
107 $datep =
dol_mktime(0, 0, 0, (
int) $reg[2], (
int) $reg[3], (
int) $reg[1],
'tzuserrel');
116 $repeateventlimitdate =
dol_mktime(23, 59, 59, 12, 31, $currentyear, $tzforfullday ? $tzforfullday :
'tzuserrel');
122 $socid = $user->socid;
125if ($user->socid && ($socid != $user->socid)) {
130$donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
135$sessionkeyassignedtouser =
'assignedtouser_'.($id > 0 ?
$id :
'new');
136$sessionkeyassignedtoresource =
'assignedtoresource_'.($id > 0 ?
$id :
'new');
144$form =
new Form($db);
149if ($id > 0 && $action !=
'add') {
153 $ret =
$object->fetch_optionals();
154 $ret1 =
$object->fetch_userassigned();
156 if ($ret < 0 || $ret1 < 0) {
157 dol_print_error(
null,
$object->error);
162$extrafields->fetch_name_optionals_label(
$object->table_element);
164if (empty($action) && empty(
$object->id)) {
169$hookmanager->initHooks([
'actioncard',
'globalcard']);
173 $TRemindTypes[
'browser'] = [
174 'label' => $langs->trans(
'BrowserPush'),
176 'type' => ActionCommReminder::TYPE_USER,
177 'data-html' => img_picto(
'',
'globe',
'class="pictofixedwidth"') . $langs->trans(
'BrowserPush'),
181 $TRemindTypes[
'email'] = [
182 'label' => $langs->trans(
'EMail'),
184 'type' => ActionCommReminder::TYPE_USER,
185 'data-html' => img_picto(
'',
'email',
'class="pictofixedwidth"') . $langs->trans(
'EMail'),
190 $TRemindTypes[
'sms'] = [
191 'label' => $langs->trans(
'Sms'),
193 'type' => ActionCommReminder::TYPE_USER,
194 'data-html' => img_picto(
'',
'phoning_mobile',
'class="pictofixedwidth"') . $langs->trans(
'Sms'),
197$TDurationTypes = $form->getDurationTypes($langs);
198$TDurationTypesExcluded = [
'y',
'm',
's'];
202 'TRemindTypes' => &$TRemindTypes,
203 'enablereminders' => &$enablereminders,
204 'TDurationTypes' => &$TDurationTypes,
205 'TDurationTypesExcluded' => &$TDurationTypesExcluded,
207$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
209 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
212$result =
restrictedArea($user,
'agenda', $object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
214$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || ((empty(
$object->id) ||
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
215$usercandelete = $user->hasRight(
'agenda',
'allactions',
'delete') || ((
$object->authorid === $user->id ||
$object->userownerid === $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'));
222$listUserAssignedUpdated =
false;
223$listResourceAssignedUpdated =
false;
227if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
228 $idtoremove =
GETPOST(
'removedassigned');
230 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
231 $tmpassigneduserids = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
233 $tmpassigneduserids = [];
236 foreach ($tmpassigneduserids as $key => $val) {
237 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
238 unset($tmpassigneduserids[$key]);
242 $_SESSION[$sessionkeyassignedtouser] = json_encode($tmpassigneduserids);
243 $donotclearsession = 1;
244 if ($action ==
'add') {
247 if ($action ==
'update') {
251 $listUserAssignedUpdated =
true;
254if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
255 $idtoremove =
GETPOST(
'removedassignedresource');
257 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
258 $tmpassignedresourceids = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
260 $tmpassignedresourceids = [];
263 foreach ($tmpassignedresourceids as $key => $val) {
264 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
265 unset($tmpassignedresourceids[$key]);
269 $_SESSION[$sessionkeyassignedtoresource] = json_encode($tmpassignedresourceids);
271 if ($action ==
'add' && $usercancreate) {
274 if ($action ==
'update' && $usercancreate) {
278 $listResourceAssignedUpdated =
true;
282if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
284 if (
GETPOST(
'assignedtouser') > 0) {
285 $assignedtouser = [];
286 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
287 $assignedtouser = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
289 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id' =>
GETPOSTINT(
'assignedtouser'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
290 $_SESSION[$sessionkeyassignedtouser] = json_encode($assignedtouser);
292 $donotclearsession = 1;
293 if ($action ==
'add' && $usercancreate) {
296 if ($action ==
'update' && $usercancreate) {
300 $listUserAssignedUpdated =
true;
304if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
306 if (
GETPOST(
'assignedtoresource') > 0) {
307 $assignedtoresource = [];
308 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
309 $assignedtoresource = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
311 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id' =>
GETPOSTINT(
'assignedtoresource'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
312 $_SESSION[$sessionkeyassignedtoresource] = json_encode($assignedtoresource);
314 $donotclearsession = 1;
315 if ($action ==
'add' && $usercancreate) {
318 if ($action ==
'update' && $usercancreate) {
322 $listResourceAssignedUpdated =
true;
326if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
327 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
333if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
335 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
336 setEventMessages($langs->trans(
"NoCloneOptionsSpecified"),
null,
'errors');
340 if (!empty(
$object->socpeopleassigned)) {
341 reset(
$object->socpeopleassigned);
346 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
357if (empty($reshook) && $action ==
'add' && $usercancreate) {
360 if (empty($backtopage)) {
362 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
364 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
368 if (!empty($socpeopleassigned[0])) {
369 $result = $contact->fetch($socpeopleassigned[0]);
373 header(
"Location: ".$backtopage);
377 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
390 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
393 if (!$datef && $percentage == 100) {
395 $donotclearsession = 1;
397 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
402 $donotclearsession = 1;
404 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
410 $donotclearsession = 1;
412 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
417 $listofresourceid = [];
422 $object->fulldayevent = ($fulldayevent ? 1 : 0);
426 if (
GETPOST(
"elementtype",
'alpha')) {
428 $modulecodetouseforpermissioncheck = $elProp[
'module'];
430 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
432 switch ($modulecodetouseforpermissioncheck) {
434 $modulecodetouseforpermissioncheck =
'produit';
436 case 'eventorganization':
438 $modulecodetouseforpermissioncheck =
'projet';
439 $submodulecodetouseforpermissioncheck =
'';
446 $hasPermissionOnLinkedObject = 0;
447 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
448 $hasPermissionOnLinkedObject = 1;
449 } elseif ($user->hasRight($modulecodetouseforpermissioncheck, $submodulecodetouseforpermissioncheck,
'read')) {
450 $hasPermissionOnLinkedObject = 1;
453 if ($hasPermissionOnLinkedObject) {
461 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
462 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
464 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
465 $object->label = $langs->transnoentitiesnoconv(
"Action".
$object->type_code).
"\n";
467 $cactioncomm->fetch(
$object->type_code);
468 $object->label = $cactioncomm->label;
475 if (!empty($taskid)) {
476 $taskProject =
new Task($db);
477 if ($taskProject->fetch($taskid) > 0) {
478 $object->fk_project = $taskProject->fk_project;
483 $object->elementtype =
'project_task';
488 $object->percentage = $percentage;
491 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
494 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
495 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
498 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
499 $listofresourceid = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
503 foreach ($listofuserid as $key => $value) {
505 if ($value[
'id'] > 0) {
506 $object->userownerid = $value[
'id'];
508 $object->transparency = $transparency;
511 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
530 if (empty(
$object->userownerid) && empty($_SESSION[$sessionkeyassignedtouser])) {
532 $donotclearsession = 1;
534 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
536 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
538 $donotclearsession = 1;
540 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
545 $donotclearsession = 1;
547 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
550 foreach ($socpeopleassigned as $cid) {
551 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
553 if (!empty(
$object->socpeopleassigned)) {
554 reset(
$object->socpeopleassigned);
559 $ret = $extrafields->setOptionalsFromPost(
null, $object);
562 $donotclearsession = 1;
574 $selectedrecurrulefreq =
'no';
575 $selectedrecurrulebyyearmonthday =
'';
576 $selectedrecurrulebymonthday =
'';
577 $selectedrecurrulebyday =
'';
578 $object->recurrule =
GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
579 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'YEARLY') ?
"_BYYEARMONTHDAY".((
int) $dayinyear) :
"";
580 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY') ?
"_BYMONTHDAY".((
int) $dayinmonth) :
"";
581 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY') ?
"_BYDAY".((
int) $dayinweek) :
"";
587 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
588 $selectedrecurrulefreq = $reg1[1];
590 if (
$object->recurrule && preg_match(
'/FREQ=YEARLY.*BYYEARMONTHDAY(\d+)/i',
$object->recurrule, $reg4)) {
591 $selectedrecurrulebyyearmonthday = (int) $reg4[1];
593 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
594 $selectedrecurrulebymonthday = (int) $reg2[1];
596 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
597 $selectedrecurrulebyday = (int) $reg3[1];
601 $eventisrecurring = 0;
602 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
603 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
604 $eventisrecurring = 1;
614 $idaction =
$object->create($user);
619 if (is_array($listofresourceid) && count($listofresourceid)) {
620 foreach ($listofresourceid as $resource_id => $val) {
621 $resource_type =
'dolresource';
626 $eventDateStart =
$object->datep;
627 $eventDateEnd =
$object->datef;
628 $isFullDayEvent =
$object->fulldayevent;
629 if (empty($eventDateEnd)) {
630 if ($isFullDayEvent) {
632 $eventDateStart =
dol_mktime(0, 0, 0, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
633 $eventDateEnd =
dol_mktime(23, 59, 59, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
637 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
638 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_resources as er";
639 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) .
"'";
640 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape(
$object->element) .
"'";
641 $sql .=
" WHERE er.resource_id = " . ((int) $resource_id);
642 $sql .=
" AND er.busy = 1";
646 $sql .=
" (ac.datep <= '" . $db->idate($eventDateStart) .
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) .
"'))";
648 if (!empty($eventDateEnd)) {
649 $sql .=
" OR (ac.datep <= '" . $db->idate($eventDateEnd) .
"' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) .
"'))";
653 $sql .=
"ac.datep >= '" . $db->idate($eventDateStart) .
"'";
654 if (!empty($eventDateEnd)) {
655 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) .
"')";
660 $resql = $db->query($sql);
663 $object->error = $db->lasterror();
666 if ($db->num_rows($resql) > 0) {
669 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse') .
' : ';
670 while ($obj = $db->fetch_object($resql)) {
671 $object->error .=
'<br> - ' . $langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label .
' [' . $obj->ac_id .
']');
675 setEventMessages(
$object->error,
null,
'errors');
682 $res =
$object->add_element_resource($resource_id, $resource_type, $busy, $val[
'mandatory']);
687 unset($_SESSION[$sessionkeyassignedtoresource]);
692 $categories =
GETPOST(
'categories',
'array');
693 $object->setCategories($categories);
696 unset($_SESSION[$sessionkeyassignedtouser]);
698 if ($user->id !=
$object->userownerid) {
699 $moreparam =
"filtert=-1";
703 if (!$error && $addreminder ==
'on') {
708 $actionCommReminder->dateremind = $dateremind;
709 $actionCommReminder->typeremind = $remindertype;
710 $actionCommReminder->offsetunit = $offsetunit;
711 $actionCommReminder->offsetvalue = $offsetvalue;
712 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
713 $actionCommReminder->fk_actioncomm =
$object->id;
714 if ($remindertype ==
'email') {
715 $actionCommReminder->fk_email_template = $modelmail;
719 foreach (
$object->userassigned as $userassigned) {
720 $actionCommReminder->fk_user = $userassigned[
'id'];
721 $res = $actionCommReminder->create($user);
725 $langs->load(
"errors");
727 setEventMessages($langs->trans(
'ErrorReminderActionCommCreation'),
null,
'errors');
729 $donotclearsession = 1;
740 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
753 $langs->load(
"errors");
755 setEventMessages($langs->trans(
$object->error),
null,
'errors');
757 $donotclearsession = 1;
763 $donotclearsession = 1;
767 if (!$error && $eventisrecurring) {
772 $monthlyoccurrence = 0;
777 $tzforrecurrence =
'tzserver';
779 $tzforrecurrence =
'gmt';
780 } elseif (!empty($_SESSION[
'dol_tz_string'])) {
782 $tmptz =
new DateTimeZone($_SESSION[
'dol_tz_string']);
783 $tzforrecurrence = $tmptz->getName();
785 dol_syslog(
"Warning dol_tz_string contains an invalid value ".json_encode($_SESSION[
'dol_tz_string']), LOG_WARNING);
786 $tzforrecurrence =
'tzserver';
790 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
792 $datep =
dol_mktime($fulldayevent ? 0 :
GETPOSTINT(
"aphour"), $fulldayevent ? 0 :
GETPOSTINT(
"apmin"), $fulldayevent ? 0 :
GETPOSTINT(
"apsec"), $firstdatearray[
'month'], $firstdatearray[
'first_day'], $firstdatearray[
'year'], $tzforfullday ? $tzforfullday :
'tzuserrel');
793 $datep =
dol_time_plus_duree($datep, $selectedrecurrulebyday + 6,
'd', 0, $tzforrecurrence);
797 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
798 $monthlyanchor = (int)
$object->datep;
799 $monthlyoccurrence = 1;
800 $datep =
dol_time_plus_duree($monthlyanchor, $monthlyoccurrence,
'm', 1, $tzforrecurrence);
804 } elseif ($selectedrecurrulefreq ==
'YEARLY' && !empty($selectedrecurrulebyyearmonthday)) {
818 $durationofevent = (strval($datef) !=
'' && strval(
$object->datep) !=
'') ? ((
int) $datef - (int)
$object->datep) : 0;
822 if ($durationofevent > 0 && $datef <= $datep) {
823 $datef = $datep + $durationofevent;
826 while ($datep <= $repeateventlimitdate && !$error) {
830 $finalobject->datep = $datep;
831 $finalobject->datef = $datef;
833 $idaction = $finalobject->create($user);
836 if (!$finalobject->error) {
838 $categories =
GETPOST(
'categories',
'array');
839 $finalobject->setCategories($categories);
841 unset($_SESSION[$sessionkeyassignedtouser]);
844 if ($user->id != $finalobject->userownerid) {
845 $moreparam =
"filtert=-1";
849 if ($addreminder ==
'on') {
854 $actionCommReminder->dateremind = $dateremind;
855 $actionCommReminder->typeremind = $remindertype;
856 $actionCommReminder->offsetunit = $offsetunit;
857 $actionCommReminder->offsetvalue = $offsetvalue;
858 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
859 $actionCommReminder->fk_actioncomm = $finalobject->id;
860 if ($remindertype ==
'email') {
861 $actionCommReminder->fk_email_template = $modelmail;
865 foreach ($finalobject->userassigned as $userassigned) {
866 $actionCommReminder->fk_user = $userassigned[
'id'];
867 $res = $actionCommReminder->create($user);
872 $langs->load(
"errors");
873 setEventMessages($langs->trans(
'ErrorReminderActionCommCreation'),
null,
'errors');
875 $donotclearsession = 1;
886 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
890 $langs->load(
"errors");
891 $error = $langs->trans($finalobject->error);
892 setEventMessages($error,
null,
'errors');
894 $donotclearsession = 1;
898 setEventMessages($finalobject->error, $finalobject->errors,
'errors');
900 $donotclearsession = 1;
909 if ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
910 $monthlyoccurrence++;
911 $datep =
dol_time_plus_duree($monthlyanchor, $monthlyoccurrence,
'm', 1, $tzforrecurrence);
921 if ($durationofevent > 0 && $datef <= $datep) {
922 $datef = $datep + $durationofevent;
933 if (!empty($backtopage) && !$error) {
934 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
935 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
936 } elseif ($idaction) {
937 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
939 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
946if (empty($reshook) && $action ==
'update' && $usercancreate) {
947 if (empty($cancel)) {
948 $fulldayevent =
GETPOST(
'fullday');
953 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
994 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
996 if (
$object->elementtype ==
'ticket') {
998 if (
$object->code ==
'TICKET_MSG') {
999 $object->code =
'TICKET_MSG_PRIVATE';
1001 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
1002 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
1005 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
1008 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
1009 $object->code =
'TICKET_MSG_SENTBYMAIL';
1021 $object->percentage = $percentage;
1026 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1027 $object->socpeopleassigned = [];
1028 foreach ($socpeopleassigned as $cid) {
1029 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
1032 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
1033 reset(
$object->socpeopleassigned);
1038 if (!empty($taskid)) {
1039 $taskProject =
new Task($db);
1040 if ($taskProject->fetch($taskid) > 0) {
1041 $object->fk_project = $taskProject->fk_project;
1044 $object->fk_element = $taskid;
1046 $object->elementtype =
'project_task';
1051 if (
GETPOST(
"elementtype",
'alpha')) {
1053 $modulecodetouseforpermissioncheck = $elProp[
'module'];
1055 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
1057 switch ($modulecodetouseforpermissioncheck) {
1058 case 'productbatch':
1059 $modulecodetouseforpermissioncheck =
'produit';
1061 case 'eventorganization':
1063 $modulecodetouseforpermissioncheck =
'projet';
1064 $submodulecodetouseforpermissioncheck =
'';
1071 $hasPermissionOnLinkedObject = 0;
1072 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
1073 $hasPermissionOnLinkedObject = 1;
1075 if ($hasPermissionOnLinkedObject) {
1083 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
1087 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
1089 $tmplist1 = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
1090 foreach ($tmplist1 as $key => $val) {
1091 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
1092 $listofuserid[$val[
'id']] = $val;
1096 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
1097 if ($assignedtouser) {
1098 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
1104 foreach ($listofuserid as $key => $val) {
1106 $object->userownerid = $val[
'id'];
1108 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
1112 $object->transparency = $transparency;
1118 $donotclearsession = 1;
1120 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1122 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
1124 if (empty(
$object->userownerid)) {
1126 $donotclearsession = 1;
1128 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
1132 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
1140 if ($conflicts === -1) {
1144 } elseif (!empty($conflicts)) {
1146 $object->error =
$object->formatResourceConflicts($conflicts, $langs);
1155 $result =
$object->update($user);
1159 $categories =
GETPOST(
'categories',
'array');
1160 $object->setCategories($categories);
1162 $object->loadReminders($remindertype, 0,
false);
1165 if (!empty(
$object->reminders)) {
1166 foreach (
$object->reminders as $reminder) {
1167 if ($reminder->status < 1) {
1168 $reminder->delete($user);
1175 if ($addreminder ==
'on') {
1180 $actionCommReminder->dateremind = $dateremind;
1181 $actionCommReminder->typeremind = $remindertype;
1182 $actionCommReminder->offsetunit = $offsetunit;
1183 $actionCommReminder->offsetvalue = $offsetvalue;
1184 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
1185 $actionCommReminder->fk_actioncomm =
$object->id;
1186 if ($remindertype ==
'email') {
1187 $actionCommReminder->fk_email_template = $modelmail;
1191 foreach (
$object->userassigned as $userassigned) {
1192 $actionCommReminder->fk_user = $userassigned[
'id'];
1196 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1197 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".$db->escape($remindertype).
"'";
1198 $resqldelete = $db->query($sqldelete);
1200 $res = $actionCommReminder->create($user);
1204 $langs->load(
"errors");
1205 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1206 setEventMessages($error,
null,
'errors');
1208 $donotclearsession = 1;
1215 unset($_SESSION[$sessionkeyassignedtouser]);
1216 unset($_SESSION[$sessionkeyassignedtoresource]);
1231 if (!empty($backtopage)) {
1232 unset($_SESSION[$sessionkeyassignedtouser]);
1233 header(
"Location: ".$backtopage);
1240if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes' && $usercandelete) {
1243 $object->fetch_userassigned();
1246 if (
GETPOST(
'deletescope',
'aZ09') ==
'serie' && !empty(
$object->recurid)) {
1249 $idsofserie =
$object->getIdsOfRecurringSerie();
1251 if (!is_array($idsofserie)) {
1259 foreach ($idsofserie as $idtodelete) {
1261 if ($eventofserie->fetch($idtodelete) <= 0) {
1263 setEventMessages($eventofserie->error, $eventofserie->errors,
'errors');
1269 if (!$user->hasRight(
'agenda',
'allactions',
'delete')
1270 && !(($eventofserie->authorid == $user->id || $eventofserie->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'))) {
1272 setEventMessages($langs->trans(
"NotEnoughPermissions"),
null,
'errors');
1276 $eventofserie->fetch_optionals();
1277 $eventofserie->oldcopy =
dol_clone($eventofserie, 2);
1279 if ($eventofserie->delete($user) < 0) {
1281 setEventMessages($eventofserie->error, $eventofserie->errors,
'errors');
1291 setEventMessages($langs->trans(
"RecordsDeleted", $nbdeleted),
null,
'mesgs');
1292 header(
"Location: index.php");
1297 $result =
$object->delete($user);
1300 header(
"Location: index.php");
1313if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate' && $usercancreate) {
1319 $newdate =
GETPOST(
'newdate',
'alpha');
1320 if (empty($newdate) || strpos($newdate,
'dayevent_') !== 0) {
1321 header(
"Location: ".$backtopage,
true, 307);
1325 $datep =
dol_mktime($shour, $smin, 0, (
int) substr($newdate, 13, 2), (
int) substr($newdate, 15, 2), (
int) substr($newdate, 9, 4),
'tzuserrel');
1328 if ($datep !=
$object->datep) {
1336 if ($conflicts === -1) {
1340 } elseif (!empty($conflicts)) {
1342 $object->error =
$object->formatResourceConflicts($conflicts, $langs);
1350 $result =
$object->update($user);
1360 if (!empty($backtopage)) {
1361 header(
"Location: ".$backtopage,
true, 307);
1370$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')));
1371if (empty($reshook)) {
1372 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1380$form =
new Form($db);
1383$arrayrecurrulefreq = array(
1384 'no' => $langs->trans(
"OnceOnly"),
1385 'YEARLY' => $langs->trans(
"EveryYear"),
1386 'MONTHLY' => $langs->trans(
"EveryMonth"),
1387 'WEEKLY' => $langs->trans(
"EveryWeek")
1392$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1393llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1395if ($action ==
'create') {
1398 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1399 if (!empty($socpeopleassigned[0])) {
1400 $result = $contact->fetch($socpeopleassigned[0]);
1402 dol_print_error($db, $contact->error);
1408 if (!empty(
$conf->use_javascript_ajax)) {
1409 print
"\n".
'<script type="text/javascript">';
1410 print
'$(document).ready(function () {
1411 function setdatefields()
1413 if ($("#fullday:checked").val() == null) {
1414 $(".fulldaystarthour").removeAttr("disabled");
1415 $(".fulldaystartmin").removeAttr("disabled");
1416 $(".fulldayendhour").removeAttr("disabled");
1417 $(".fulldayendmin").removeAttr("disabled");
1418 $("#p2").removeAttr("disabled");
1420 $(".fulldaystarthour").prop("disabled", true).val("00");
1421 $(".fulldaystartmin").prop("disabled", true).val("00");
1422 $(".fulldayendhour").prop("disabled", true).val("23");
1423 $(".fulldayendmin").prop("disabled", true).val("59");
1424 $("#p2").removeAttr("disabled");
1427 $("#fullday").change(function() {
1428 console.log("setdatefields");
1431 var old_startdate = null;
1432 $("#ap").focus(function() {
1433 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1435 $("#ap").next(".ui-datepicker-trigger").click(function() {
1436 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1438 $("#ap").change(function() {
1439 setTimeout(function() {
1440 if ($("#p2").val() !== "") {
1441 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1442 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1443 if (new_startdate > old_enddate) {
1444 var timeDiff = old_enddate - old_startdate;
1445 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1446 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1447 $("#p2day").val(new_enddate.getDate());
1448 $("#p2month").val(new_enddate.getMonth() + 1);
1449 $("#p2year").val(new_enddate.getFullYear());
1454 $("#actioncode").change(function() {
1455 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1456 else $("#dateend").removeClass("fieldrequired");
1458 $("#aphour,#apmin").change(function() {
1459 if ($("#actioncode").val() == \'AC_RDV\') {
1460 var oldhour = parseInt($("#aphour").val());
1461 var oldmin = parseInt($("#apmin").val());
1462 var oldday = parseInt($("#apday").val());
1463 var oldmonth = $("#apmonth").val();
1464 var oldyear = $("#apyear").val();
1466 var newhour = oldhour + 1;
1467 var newday = oldday;
1468 var newmonth = oldmonth;
1469 var newyear = oldyear;
1470 if (newhour >= 24) {
1472 newday = oldday + 1;
1474 console.log("Start date was changed, we modify end date "+oldhour+" "+oldmin+" -> "+newhour+" "+oldmin);
1475 $("#p2hour").val(("00" + newhour).substr(-2,2));
1476 $("#p2min").val(("00" + oldmin).substr(-2,2));
1477 $("#p2day").val(newday);
1478 $("#p2month").val(newmonth);
1479 $("#p2year").val(newyear);
1480 $("#p2").val($("#ap").val());
1483 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1484 else $("#dateend").removeClass("fieldrequired");
1487 print
'</script>'.
"\n";
1490 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1491 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1492 print
'<input type="hidden" name="action" value="add">';
1493 print
'<input type="hidden" name="donotclearsession" value="1">';
1494 print
'<input type="hidden" name="page_y" value="">';
1496 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1499 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1506 print
'<div class="divcreate">';
1507 print
'<table class="border centpercent nobottom">';
1510 print
'<tr><td'.(getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ?
' class="fieldrequired"' :
' class="fieldrequired titlefieldcreate"').
'>'.$langs->trans(
"Title").
'</td><td><input type="text" id="label" name="label" class="soixantepercent" value="'.
GETPOST(
'label').
'"></td></tr>';
1514 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1516 if (empty($default)) {
1517 $default =
'AC_OTH';
1519 print img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1521 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1526 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1527 print
'<td class="valignmiddle height30">';
1529 print
'<input class="valignmiddle" type="checkbox" id="fullday" name="fullday" '.(GETPOST(
'fullday') ?
' checked' :
'').
'><label for="fullday" class="valignmiddle small">'.$langs->trans(
"EventOnFullDay").
'</label>';
1533 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1534 if (
GETPOST(
'datep',
'alpha', 1)) {
1537 $datef = ($datef ? $datef :
$object->datef);
1538 if (
GETPOST(
'datef',
'alpha', 1)) {
1541 if (empty($datef) && !empty($datep)) {
1548 print
'<tr><td class="nowrap">';
1550 print
'<div class="inline-block">';
1552 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1554 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1556 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1557 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1563 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
1564 if ($userepeatevent) {
1566 print
'<div class="clearbothonsmartphone hideonsmartphone inline-block"> </div>';
1569 print
'<div class="inline-block small" data-html="repeat">';
1570 print
'<span class="opacitymedium">';
1571 print img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 3px" class="paddingright"');
1572 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1574 $selectedrecurrulefreq =
'no';
1575 $selectedrecurrulebyyearmonthday =
'';
1576 $selectedrecurrulebymonthday =
'';
1577 $selectedrecurrulebyday =
'';
1578 $object->recurrule =
GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1579 $object->recurrule .=
GETPOSTISSET(
'BYYEARMONTHDAY') ?
"_BYYEARMONTHDAY".GETPOST(
'BYYEARMONTHDAY',
'alpha') :
"";
1580 $object->recurrule .=
GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1585 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1586 $selectedrecurrulefreq = $reg[1];
1588 if (
$object->recurrule && preg_match(
'/FREQ=YEARLY.*BYYEARMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1589 $selectedrecurrulebyyearmonthday = (int) $reg[1];
1591 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1592 $selectedrecurrulebymonthday = (int) $reg[1];
1594 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1595 $selectedrecurrulebyday = (int) $reg[1];
1598 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly minwidth125 maxwidth150');
1616 $repeateventlimitdate = empty($repeateventlimitdate) ? (
dol_now() + ((24 * 3600 * 365) + 1)) : $repeateventlimitdate;
1618 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1619 print $langs->trans(
"Until").
" ";
1620 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1623 <script
type=
"text/javascript">
1624 jQuery(document).ready(
function() {
1625 function init_repeat() {
1626 console.log(
"recurrule: " +
"<?php echo $object->recurrule; ?>");
1627 console.log(
"reg1: " +
"<?php echo $selectedrecurrulefreq; ?>");
1628 console.log(
"reg2: " +
"<?php echo $selectedrecurrulebymonthday; ?>");
1629 console.log(
"reg3: " +
"<?php echo $selectedrecurrulebyday; ?>");
1630 console.log(
"reg4: " +
"<?php echo $selectedrecurrulebyyearmonthday; ?>");
1631 console.log(
"selectedrulefreq: " +
"<?php echo $selectedrecurrulefreq; ?>");
1632 if (jQuery(
"#recurrulefreq").val() ==
'YEARLY') {
1634 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1635 jQuery(
".repeateventBYMONTHDAY").hide();
1636 jQuery(
".repeateventBYDAY").hide();
1637 }
else if (jQuery(
"#recurrulefreq").val() ==
'MONTHLY') {
1639 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1640 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1641 jQuery(
".repeateventBYDAY").hide();
1642 }
else if (jQuery(
"#recurrulefreq").val() ==
'WEEKLY') {
1643 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1644 jQuery(
".repeateventBYMONTHDAY").hide();
1646 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1648 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1649 jQuery(
".repeateventBYMONTHDAY").hide();
1650 jQuery(
".repeateventBYDAY").hide();
1651 jQuery(
".repeateventlimitdate").hide();
1655 jQuery(
"#recurrulefreq").change(
function() {
1670 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Location").
'</td><td>';
1671 print img_picto(
'',
'map-marker-alt',
'class="pictofixedwidth"');
1672 print
'<input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.(GETPOST(
'location') ?
GETPOST(
'location') :
$object->location).
'"></td></tr>';
1680 print
'<div class="divcreate">';
1681 print
'<table class="border centpercent nobottom">';
1684 print
'<tr><td class="nowrap titlefieldcreate"><span>';
1685 print $langs->trans(
"AssignedTo");
1686 print
'</span></td><td>';
1688 $listofcontactid = [];
1689 $listofotherid = [];
1691 if (empty($donotclearsession)) {
1693 if ($assignedtouser) {
1694 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1697 $listofuserid[$assignedtouser][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1698 $_SESSION[$sessionkeyassignedtouser] = json_encode($listofuserid);
1700 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
1701 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
1703 if (!is_array($listofuserid)) {
1706 $firstelem = reset($listofuserid);
1707 if (isset($listofuserid[$firstelem[
'id']])) {
1708 $listofuserid[$firstelem[
'id']][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1711 print
'<!-- list of user to assign -->'.
"\n";
1712 print
'<div class="assignedtouser">';
1713 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, [], 0,
'', [],
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid);
1719 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1721 $listofresourceid = [];
1722 if (empty($donotclearsession)) {
1723 $assignedtoresource =
GETPOST(
"assignedtoresource");
1724 if ($assignedtoresource) {
1725 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1727 $_SESSION[$sessionkeyassignedtoresource] = json_encode($listofresourceid);
1729 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
1730 $listofresourceid = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
1732 if (!is_array($listofresourceid)) {
1733 $listofresourceid = [];
1735 $firstelem = reset($listofresourceid);
1736 if ($firstelem && isset($listofresourceid[$firstelem[
'id']])) {
1737 $listofresourceid[$firstelem[
'id']][
'transparency'] = (
GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1740 print
'<div class="assignedtoresource">';
1741 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1, [], 0,
'', [],
'0', 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1748 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1749 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories', $object);
1759 print
'<div class="divcreate">';
1760 print
'<table class="border centpercent nobottom">';
1763 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td>';
1765 $percent = $complete !==
'' ? $complete : -1;
1771 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1773 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1777 print $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'minwidth150 maxwidth300', 1);
1782 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1786 print $societe->getNomUrl(1);
1787 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1790 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1792 if (!empty($user->socid)) {
1793 print img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1795 print img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid',
'', $langs->trans(
'SelectThirdParty'), 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1801 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1802 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1806 if ($origin ==
'contact') {
1812 $select_contact_default = 0;
1814 $select_contact_default = -1;
1816 print img_picto(
'',
'contact',
'class="pictofixedwidth"');
1820 print $form->select_contact(
GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', false, 0, 0, array(),
'',
'contactid',
'',
'', true);
1827 $langs->load(
"projects");
1831 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1832 print img_picto(
'',
'project',
'class="pictofixedwidth"');
1833 print $formproject->select_projects((
$object->socid > 0 ?
$object->socid : -1), (string) $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx maxwidth500');
1835 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1836 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1837 $urloption =
'?action=create&donotclearsession=1';
1842 <script
type=
"text/javascript">
1843 $(document).ready(
function () {
1844 $(
"#projectid").change(
function () {
1845 var url =
"<?php echo DOL_URL_ROOT; ?>/projet/ajax/projects.php?mode=gettasks&socid="+$(
"#search_socid").val()+
"&projectid="+$(
"#projectid").val();
1846 console.log(
"Call url to get the new list of tasks: "+url);
1847 $.get(url,
function(data) {
1849 if (data) $(
"#taskid").html(data).select2();
1859 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1860 print img_picto(
'',
'projecttask',
'class="pictofixedwidth"');
1861 $projectsListId =
'';
1862 if (!empty($projectid)) {
1863 $projectsListId = $projectid;
1868 if (empty($projectsListId)) {
1869 print
'<select class="valignmiddle flat maxwidth500 widthcentpercentminusxx minwidth150imp" id="taskid" name="taskid">';
1870 print
'<option class="opacitymedium"> </option>';
1871 print
'<option class="opacitymedium" disabled data-html="'.dolPrintHTMLForAttribute($langs->trans(
"SelectAProjectFirst")).
'">'.$langs->trans(
"SelectAProjectFirst").
'</option>';
1875 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 64, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (string) $projectsListId,
'all', null, 1);
1881 if (!empty($origin) && !empty($originid)) {
1882 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1884 $hasPermissionOnLinkedObject = 0;
1887 $modulecodetouseforpermissioncheck = $elProp[
'module'];
1889 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
1891 switch ($modulecodetouseforpermissioncheck) {
1892 case 'productbatch':
1893 $modulecodetouseforpermissioncheck =
'produit';
1895 case 'eventorganization':
1897 $modulecodetouseforpermissioncheck =
'projet';
1898 $submodulecodetouseforpermissioncheck =
'';
1905 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read') || $user->hasRight($modulecodetouseforpermissioncheck, $elProp[
'element'],
'read')) {
1906 $hasPermissionOnLinkedObject = 1;
1910 if (! in_array($origin, array(
'societe',
'project',
'project_task',
'user'))) {
1912 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1913 print
'<td colspan="3">';
1914 if ($hasPermissionOnLinkedObject) {
1916 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1917 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1918 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1919 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1921 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1929 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1930 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1935 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1936 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1937 $doleditor =
new DolEditor(
'note', (
GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 200,
'dolibarr_notes',
'In', true, true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1938 $doleditor->Create();
1943 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1944 print $hookmanager->resPrint;
1945 if (empty($reshook)) {
1946 print
$object->showOptionals($extrafields,
'create', $parameters);
1952 if ($enablereminders) {
1956 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"'.(empty(
GETPOST(
'addreminder')) ?
'' :
'checked').
'><br>';
1958 print
'<div class="reminderparameters" '.(empty(
GETPOST(
'addreminder')) ?
'style="display: none;' :
'').
' ">';
1961 print
'<table class="border centpercent">';
1964 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1965 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1967 print $form->selectTypeDuration(
'offsetunit', (empty($offsetunit) ?
'i' : $offsetunit), $TDurationTypesExcluded);
1971 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1972 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1977 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1978 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (empty($modelmail) ? 0 : $modelmail));
1985 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
1986 $reminderDefaultOffset =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_OFFSET', 30);
1988 $reminderDefaultEmailModel =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
1990 print
"\n".
'<script type="text/javascript">';
1991 print
'$(document).ready(function () {
1992 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
1993 $(
"#actioncode").change(
function(){
1994 var selected_event_type = $(
"#actioncode option:selected").val();
1996 if (reminderDefaultEventTypes.includes(selected_event_type)) {
1997 $(
".reminderparameters").show();
1998 $(
"#addreminder").prop(
"checked",
true);
2001 $(
"[name=\"offsetvalue\"]").val(\
'' .
dol_escape_js((
string) $reminderDefaultOffset) .
'\');
2002 $(
"#select_offsetunittype_duration").select2(
"destroy");
2003 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
2004 $(
"#select_offsetunittype_duration").select2();
2006 $(
"#selectremindertype").select2(
"destroy");
2007 $(
"#selectremindertype").val(
"email");
2008 $(
"#selectremindertype").select2();
2011 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2012 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
2013 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js((
string) $reminderDefaultEmailModel).
'\');
2014 $(
"#select_actioncommsendmodel_mail").select2();
2018 print '</script>
'."\n";
2020 print "\n".'<script
type=
"text/javascript">
';
2021 print '$(document).ready(
function () {
2022 function toggle_reminder_part(evt) {
2023 console.log(
"Toggle reminder part");
2024 if ($(
"#addreminder").is(
":checked")) {
2025 $(
".reminderparameters").show();
2027 $(
".reminderparameters").hide();
2029 $(
"#selectremindertype").select2(
"destroy");
2030 $(
"#selectremindertype").select2();
2031 $(
"#select_offsetunittype_duration").select2(
"destroy");
2032 $(
"#select_offsetunittype_duration").select2();
2033 selectremindertype();
2036 toggle_reminder_part();
2037 $(
"#addreminder").click(toggle_reminder_part);
2039 $(
"#selectremindertype").change(
function(){
2040 selectremindertype();
2043 function selectremindertype() {
2044 console.log(
"Call selectremindertype");
2045 var selected_option = $(
"#selectremindertype option:selected").val();
2046 if(selected_option ==
"email") {
2047 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2049 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
2054 print '</script>
'."\n";
2057 print dol_get_fiche_end();
2059 print $form->buttonsSaveCancel("Create");
2065if ($id > 0 && $action != 'create
') {
2066 $result1 = $object->fetch($id);
2067 if ($result1 <= 0) {
2068 recordNotFound('', 0);
2071 $result2 = $object->fetch_thirdparty();
2072 $result2 = $object->fetchProject();
2073 $result3 = $object->fetch_contact();
2074 $result4 = $object->fetch_userassigned();
2075 $result5 = $object->fetch_optionals();
2077 if ($listUserAssignedUpdated || $donotclearsession) {
2078 $percentage = in_array(GETPOST('status'), array(-1, 100)) ? GETPOST('status') : (in_array($complete, array(-1, 100)) ? $complete : GETPOSTINT("percentage")); // If status is -1 or 100, percentage is not defined and we must use status
2080 $datep = dol_mktime($fulldayevent ? 0 : $aphour, $fulldayevent ? 0 : $apmin, 0, GETPOSTINT("apmonth"), GETPOSTINT("apday"), GETPOSTINT("apyear"), 'tzuserrel
');
2081 $datef = dol_mktime($fulldayevent ? 23 : $p2hour, $fulldayevent ? 59 : $p2min, $fulldayevent ? 59 : 0, GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), 'tzuserrel
');
2083 $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09
'), 'c_actioncomm
');
2084 $object->label = GETPOST("label", "alphanohtml");
2085 $object->datep = $datep;
2086 $object->datef = $datef;
2087 $object->percentage = $percentage;
2088 $object->priority = GETPOSTINT("priority");
2089 $object->fulldayevent = GETPOST("fullday") ? 1 : 0;
2090 $object->location = GETPOST('location
', "alphanohtml");
2091 $object->socid = GETPOSTINT("socid");
2092 $socpeopleassigned = GETPOST("socpeopleassigned", 'array
');
2093 foreach ($socpeopleassigned as $tmpid) {
2094 $object->socpeopleassigned[$id] = array('id' => $tmpid);
2096 $object->contact_id = GETPOSTINT("contactid");
2097 $object->fk_project = GETPOSTINT("projectid");
2099 $object->note_private = GETPOST("note", 'restricthtml
');
2102 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
2103 dol_print_error($db, $object->error);
2112 $head = actions_prepare_head($object);
2115 $delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO
') * 24 * 60 * 60;
2118 // Deletion confirmation action
2119 if ($action == 'delete') {
2120 $formquestion = array();
2122 // A recurring series is N independent events, so without this choice, undoing a series
2123 // created by mistake or due to a data entry error, means deleting its events one by one.
2124 if (!empty($object->recurid)) {
2125 $idsofserie = $object->getIdsOfRecurringSerie();
2127 if (is_array($idsofserie) && count($idsofserie) > 1) {
2128 // The ids are sorted by date, so the first and the last event give the period covered
2129 $firstofserie = new ActionComm($db);
2130 $firstofserie->fetch($idsofserie[0]);
2131 $lastofserie = new ActionComm($db);
2132 $lastofserie->fetch($idsofserie[count($idsofserie) - 1]);
2134 $formquestion[] = array(
2136 'name' => 'deletescope
',
2137 'label
' => $langs->trans("ThisEventIsPartOfARecurringSerie"),
2138 'default' => 'event
',
2140 'event
' => $langs->trans("DeleteThisEventOnly"),
2141 'serie
' => $langs->trans("DeleteAllEventsOfTheSerie", count($idsofserie), dol_print_date($firstofserie->datep, 'day
'), dol_print_date($lastofserie->datep, 'day
'))
2147 print $form->formconfirm("card.php?id=".urlencode((string) ($id)), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", $formquestion, '', 1);
2150 if ($action == 'edit
') {
2151 $caneditdateorowner = ($object->type != 'systemauto
');
2153 if (!empty($conf->use_javascript_ajax)) {
2154 print "\n".'<script
type=
"text/javascript">
';
2155 print '$(document).ready(
function () {
2156 function setdatefields()
2158 if ($(
"#fullday:checked").val() ==
null) {
2159 $(
".fulldaystarthour").removeAttr(
"disabled");
2160 $(
".fulldaystartmin").removeAttr(
"disabled");
2161 $(
".fulldayendhour").removeAttr(
"disabled");
2162 $(
".fulldayendmin").removeAttr(
"disabled");
2164 $(
".fulldaystarthour").prop(
"disabled",
true).val(
"00");
2165 $(
".fulldaystartmin").prop(
"disabled",
true).val(
"00");
2166 $(
".fulldayendhour").prop(
"disabled",
true).val(
"23");
2167 $(
".fulldayendmin").prop(
"disabled",
true).val(
"59");
2171 '.($caneditdateorowner ? ' setdatefields();
' : '').'
2173 $(
"#fullday").change(
function() {
2176 var old_startdate =
null;
2177 $(
"#ap").focus(
function() {
2178 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2180 $(
"#ap").next(
".ui-datepicker-trigger").click(
function() {
2181 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2183 $(
"#ap").change(
function() {
2184 setTimeout(
function() {
2185 if ($(
"#p2").val() !==
"") {
2186 var new_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2187 var old_enddate =
new Date($(
"#p2year").val(), $(
"#p2month").val() - 1, $(
"#p2day").val());
2188 if (new_startdate > old_enddate) {
2189 var timeDiff = old_enddate - old_startdate;
2190 var new_enddate =
new Date(new_startdate.getTime() + timeDiff);
2191 $(
"#p2").val(formatDate(new_enddate,
"' . $langs->trans('FormatDateShortJavaInput') . '"));
2192 $(
"#p2day").val(new_enddate.getDate());
2193 $(
"#p2month").val(new_enddate.getMonth() + 1);
2194 $(
"#p2year").val(new_enddate.getFullYear());
2199 $(
"#actioncode").change(
function() {
2200 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
2201 else $("#dateend").removeClass("fieldrequired");
2204 print
'</script>'.
"\n";
2207 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
2208 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2209 print
'<input type="hidden" name="action" value="update">';
2210 print
'<input type="hidden" name="id" value="'.$id.
'">';
2211 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
2212 print
'<input type="hidden" name="page_y" value="">';
2214 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
2217 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2222 print
'<table class="border tableforfield centpercent">';
2225 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>'.
$object->id.
'</td></tr>';
2228 print
'<tr><td class="fieldrequired'.(!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ?
' titlefieldcreate' :
'').
'">'.$langs->trans(
"Title").
'</td>';
2229 print
'<td><input type="text" name="label" class="soixantepercent" value="'.dolPrintHTMLForAttribute(
$object->label).
'"></td></tr>';
2233 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
2234 if (
$object->type_code !=
'AC_OTH_AUTO') {
2235 print img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
2236 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
2238 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2239 print
$object->getTypePicto();
2240 print $langs->trans(
"Action".
$object->type_code);
2246 if (
$object->elementtype ==
'ticket') {
2247 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
2248 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
2249 print
'</td><td><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
2253 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td class="valignmiddle height30 small">';
2254 print
'<input '.($caneditdateorowner ?
'' :
' disabled').
' type="checkbox" id="fullday" name="fullday" '.(
$object->fulldayevent ?
' checked' :
'').
'>';
2255 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
2318 print
'<tr><td class="nowrap">';
2321 print $form->selectDate($datep ? $datep :
$object->datep,
'ap', 1, 1, 0,
"action", 1, 2, ($caneditdateorowner ? 0 : 1),
'fulldaystart',
'',
'',
'', 1,
'',
'',
$object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2322 print
' <span class="hideonsmartphone"> - </span> ';
2323 print $form->selectDate($datef ? $datef :
$object->datef,
'p2', 1, 1, 1,
"action", 1, 2, ($caneditdateorowner ? 0 : 1),
'fulldayend',
'',
'',
'', 1,
'',
'',
$object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2328 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>';
2329 print img_picto(
'',
'map-marker-alt',
'class="pictofixedwidth"');
2330 print
'<input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.$object->location.
'"></td></tr>';
2333 print
'<tr class="tdsmallheight"><td class="tdsmallheight"> </td><td class="tdsmallheight"></td></tr>';
2337 if (empty($donotclearsession)) {
2338 if (
$object->userownerid > 0) {
2339 $listofuserid[
$object->userownerid] = array(
2343 'transparency' =>
$object->transparency,
2344 'answer_status' => (isset(
$object->userassigned[
$object->userownerid][
'answer_status']) ?
$object->userassigned[
$object->userownerid][
'answer_status'] : null),
2345 'mandatory' => (isset(
$object->userassigned[
$object->userownerid][
'mandatory']) ?
$object->userassigned[
$object->userownerid][
'mandatory'] : null)
2348 if (!empty(
$object->userassigned)) {
2350 $tmplist1 =
$object->userassigned;
2351 foreach ($tmplist1 as $key => $val) {
2352 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2353 $listofuserid[$val[
'id']] = $val;
2357 $_SESSION[$sessionkeyassignedtouser] = json_encode($listofuserid);
2359 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
2360 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
2364 $listofcontactid =
$object->socpeopleassigned;
2365 $listofotherid =
$object->otherassigned;
2367 print
'<tr><td class="nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2368 print
'<div class="assignedtouser">';
2369 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, [], 0,
'', [],
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid, (int) $caneditdateorowner);
2381 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2382 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories', $object);
2392 print
'<table class="border tableforfield centpercent">';
2395 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td><td colspan="3">';
2397 $formactions->form_select_status_action(
'formaction', (
string) $percent, 1,
'complete', 0, 0,
'minwidth150 maxwidth300');
2402 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2406 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2409 print img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2414 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2415 print
'<div class="maxwidth200onsmartphone">';
2417 print img_picto(
'',
'contact',
'class="paddingrightonly"');
2421 print $form->select_contact(
getDolGlobalString(
'MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT') ? 0 : (
$object->socid > 0 ?
$object->socid : -1), array_keys(
$object->socpeopleassigned),
'socpeopleassigned', 1,
'',
'', 1,
'minwidth300 widthcentpercentminusx', false, 0, 0, array(),
'',
'contactid',
'',
'', true);
2429 $langs->load(
"projects");
2431 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2432 print img_picto(
'',
'project',
'class="pictofixedwidth"');
2433 $numprojet = $formproject->select_projects((
$object->socid > 0 ?
$object->socid : -1), (string)
$object->fk_project,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'maxwidth500 widthcentpercentminusxx');
2434 if ($numprojet == 0) {
2435 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>';
2442 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2443 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2449 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2451 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2454 print
'<td id="project-task-input-container" >';
2456 $urloption =
'?action=create&donotclearsession=1';
2457 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2461 <script
type=
"text/javascript" >
2462 $(document).ready(
function () {
2463 $(
"#projectid").change(
function () {
2464 var url =
"<?php echo $url; ?>&projectid="+$(
"#projectid").val();
2465 $.get(url,
function(data) {
2466 console.log($( data ).find(
"#fk_element").html());
2467 if (data) $(
"#fk_element").html( $( data ).find(
"#taskid").html() ).select2();
2474 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1),
$object->elementid,
'fk_element', 64, 0,
'', 1, 0, 0,
'maxwidth500', (
string)
$object->fk_project,
'all',
null, 1);
2475 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2482 print
'<td id="project-task-input-container" >';
2486 <script
type=
"text/javascript">
2487 $(document).ready(
function () {
2488 $(
"#projectid").change(
function () {
2489 var url =
"<?php echo DOL_URL_ROOT; ?>/projet/ajax/projects.php?mode=gettasks&socid="+$(
"#search_socid").val()+
"&projectid="+$(
"#projectid").val();
2490 console.log(
"Call url to get new list of tasks: "+url);
2491 $.get(url,
function(data) {
2493 if (data) $(
"#taskid").html(data).select2();
2507 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 64, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (string) $projectsListId,
'all', null, 1);
2513 print
'<input type="hidden" name="fk_element" value="'.$object->elementid.
'">';
2514 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2523 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2525 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2526 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 200,
'dolibarr_notes',
'In',
true,
true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2527 $doleditor->Create();
2532 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2533 print $hookmanager->resPrint;
2534 if (empty($reshook)) {
2535 print
$object->showOptionals($extrafields,
'edit', $parameters);
2541 if ($enablereminders) {
2542 $filteruserid = $user->id;
2543 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2546 $object->loadReminders(
'', $filteruserid,
false);
2550 if (count(
$object->reminders) > 0) {
2551 $checked =
'checked';
2552 $keys = array_keys(
$object->reminders);
2553 $firstreminderId = array_shift($keys);
2555 $actionCommReminder =
$object->reminders[$firstreminderId];
2559 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2560 $actionCommReminder->offsetunit =
'i';
2561 $actionCommReminder->typeremind =
'email';
2570 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"'.($checked ?
' '.$checked :
'').($disabled ?
' '.$disabled :
'').
'><br>';
2572 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2576 print
'<table class="border centpercent">';
2579 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2580 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2581 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, $TDurationTypesExcluded);
2585 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2586 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2590 if ($actionCommReminder->typeremind ==
'browser') {
2591 $hide =
'style="display:none;"';
2596 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2597 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (
string) $actionCommReminder->fk_email_template);
2603 <script
type=
"text/javascript">
2604 $(document).ready(
function () {
2605 $(
"#addreminder").click(
function(){
2607 $(
".reminderparameters").show();
2609 $(
".reminderparameters").hide();
2612 $(
"#selectremindertype").change(
function(){
2613 var selected_option = $(
"#selectremindertype option:selected").val();
2614 if(selected_option ==
"email") {
2615 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2617 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
2624 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
2627 $reminderDefaultEmailModel =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
2629 print
"\n".
'<script type="text/javascript">';
2630 print
'$(document).ready(function () {
2631 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
2632 $(
"#actioncode").change(
function(){
2633 var selected_event_type = $(
"#actioncode option:selected").val();
2635 if (reminderDefaultEventTypes.includes(selected_event_type)) {
2636 $(
".reminderparameters").show();
2637 $(
"#addreminder").prop(
"checked",
true);
2640 $(
"#offsetvalue").val(\
''.
dol_escape_js($reminderDefaultOffset).
'\');
2641 $(
"#select_offsetunittype_duration").select2(
"destroy");
2642 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
2643 $(
"#select_offsetunittype_duration").select2();
2645 $(
"#selectremindertype").select2(
"destroy");
2646 $(
"#selectremindertype").val(
"email");
2647 $(
"#selectremindertype").select2();
2650 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2651 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
2652 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js($reminderDefaultEmailModel).
'\');
2653 $(
"#select_actioncommsendmodel_mail").select2();
2657 print '</script>
'."\n";
2658 print '</div>
'; // End of div for reminderparameters
2661 print dol_get_fiche_end();
2663 print $form->buttonsSaveCancel();
2667 print dol_get_fiche_head($head, 'card
', $langs->trans("Action"), -1, 'action
', 0, '', '', 0, '', 1);
2672 if ($action == 'clone
') {
2673 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?
id=
'.GETPOST('id'), $langs->trans('ToClone
'), $langs->trans('ConfirmCloneEvent
', $object->label), 'confirm_clone
', [], 'yes
', 1);
2676 // Call Hook formConfirm
2678 $reshook = $hookmanager->executeHooks('formConfirm
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2679 if (empty($reshook)) {
2680 $formconfirm .= $hookmanager->resPrint;
2681 } elseif ($reshook > 0) {
2682 $formconfirm = $hookmanager->resPrint;
2685 // Print form confirm
2689 // Link to other agenda views
2690 $linkback .= '<a href=
"'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">
';
2691 $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist
', 'class=
"pictoactionview pictofixedwidth"');
2692 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("BackToList").'</span>
';
2693 $linkback .= '</a>
';
2694 $linkback .= '</li>
';
2695 $linkback .= '<li
class=
"noborder litext">
';
2696 $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').'">
';
2697 $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar
', 'class=
"pictoactionview pictofixedwidth"');
2698 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewCal").'</span>
';
2699 $linkback .= '</a>
';
2700 $linkback .= '</li>
';
2701 $linkback .= '<li
class=
"noborder litext">
';
2702 $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').'">
';
2703 $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek
', 'class=
"pictoactionview pictofixedwidth"');
2704 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewWeek").'</span>
';
2705 $linkback .= '</a>
';
2706 $linkback .= '</li>
';
2707 $linkback .= '<li
class=
"noborder litext">
';
2708 $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').'">
';
2709 $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday
', 'class=
"pictoactionview pictofixedwidth"');
2710 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewDay").'</span>
';
2711 $linkback .= '</a>
';
2712 $linkback .= '</li>
';
2713 $linkback .= '<li
class=
"noborder litext">
';
2714 $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').'">
';
2715 $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser
', 'class=
"pictoactionview pictofixedwidth"');
2716 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewPerUser").'</span>
';
2717 $linkback .= '</a>
';
2719 // Add more views from hooks
2721 $reshook = $hookmanager->executeHooks('addCalendarView
', $parameters, $object, $action);
2722 if (empty($reshook)) {
2723 $linkback .= $hookmanager->resPrint;
2724 } elseif ($reshook > 1) {
2725 $linkback = $hookmanager->resPrint;
2730 $morehtmlref = '<div
class=
"refidno">
';
2732 //$morehtmlref.='<br>
'.$langs->trans('ThirdParty
') . ' :
' . $object->thirdparty->getNomUrl(1);
2734 if (isModEnabled('project
')) {
2735 $langs->load("projects");
2736 //$morehtmlref .= '<br>
';
2737 if ($usercancreate) {
2738 $morehtmlref .= img_picto($langs->trans("Project"), 'project
', 'class=
"pictofixedwidth"');
2739 if ($action != 'classify
') {
2740 $morehtmlref .= '<a class=
"editfielda" href=
"'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">
'.img_edit($langs->transnoentitiesnoconv('SetProject
')).'</a>
';
2742 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF
'].'?id=
'.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify
' ? 'projectid
' : 'none
'), 0, 0, 0, 1, '', 'maxwidth300
');
2744 if (!empty($object->fk_project)) {
2745 $proj = new Project($db);
2746 $proj->fetch($object->fk_project);
2747 $morehtmlref .= $proj->getNomUrl(1);
2749 $morehtmlref .= '<span class=
"opacitymedium"> -
'.dol_escape_htmltag($proj->title).'</span>
';
2754 $morehtmlref .= '</div>
';
2757 dol_banner_tab($object, 'id
', $linkback, ($user->socid ? 0 : 1), 'id
', 'ref', $morehtmlref);
2759 print '<div class=
"fichecenter">
';
2760 print '<div class=
"fichehalfleft">
';
2762 print '<div class=
"underbanner clearboth"></div>
';
2764 // Show event in view mode
2765 print '<
table class=
"border tableforfield centpercent">
';
2768 if (getDolGlobalString('AGENDA_USE_EVENT_TYPE
')) {
2769 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("Type").'</td><td>
';
2770 $labeltype = ($langs->transnoentities("Action".$object->type_code) != "Action".$object->type_code) ? $langs->transnoentities("Action".$object->type_code) : $object->type_label;
2771 $labeltoshow = $labeltype;
2772 if ($object->code) {
2773 $labeltoshow .= ' (
'.$object->code.')
';
2775 print $object->getTypePicto('pictofixedwidth paddingright
', $labeltoshow);
2781 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("EventOnFullDay").'</td><td>
'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>
';
2784 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2789 print '<tr><td>
'.$langs->trans("DateActionStart").'</td><td title=
"'.dol_print_date($object->datep, 'dayhoursec', 'tzuserrel').'">
';
2790 // Test a date before the 27 march and one after
2791 //print dol_print_date($object->datep, 'dayhour
', 'gmt
');
2792 //print dol_print_date($object->datep, 'dayhour
', 'tzuser
');
2793 //print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2794 if (empty($object->fulldayevent)) {
2795 print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2797 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2798 print dol_print_date($object->datep, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2800 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2801 print img_warning($langs->trans("Late"));
2807 print '<tr><td>
'.$langs->trans("DateActionEnd").'</td><td title=
"'.dol_print_date($object->datef, 'dayhoursec', 'tzuserrel').'">
';
2808 if (empty($object->fulldayevent)) {
2809 print dol_print_date($object->datef, 'dayhour
', 'tzuserrel
');
2811 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2812 print dol_print_date($object->datef, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2814 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2815 print img_warning($langs->trans("Late"));
2819 // Recurring event (into a series)
2820 if ($object->recurid) {
2821 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("RecurringEvent").'</td><td>
';
2822 print img_picto($langs->trans("EventPartOfARecurringSerie", $object->recurid), 'recurring
', 'class=
"pictofixedwidth"');
2824 if (preg_match('/FREQ=MONTHLY_BYMONTHDAY(\d+)/
', $object->recurrule, $reg)) {
2825 print $langs->trans("EveryMonth").' <span class=
"opacitymedium small">(
'.$langs->trans("DayOfMonth").' '.$reg[1].' -
'.$langs->trans("Until").' '.dol_print_date($object->recurdateend, 'day
').')</span>
';
2827 if (preg_match('/FREQ=YEARLY_BYYEARMONTHDAY(\d+)/
', $object->recurrule, $reg)) {
2828 print $langs->trans("EveryYear").' <span class=
"opacitymedium small">(
'.$langs->trans("DayOfYear").' '.$reg[1].' -
'.$langs->trans("Until").' '.dol_print_date($object->recurdateend, 'day
').')</span>
';
2834 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2835 print '<tr><td>
'.$langs->trans("Location").'</td><td>
'.$object->location.'</td></tr>
';
2839 print '<tr><td class=
"nowrap">
'.$langs->trans("ActionAssignedTo").'</td><td>
';
2841 if (empty($donotclearsession)) {
2842 if ($object->userownerid > 0) {
2843 $listofuserid[$object->userownerid] = array(
2844 'id
' => $object->userownerid,
2845 'transparency
' => $object->transparency, // Force transparency on owner from property of event
2846 'answer_status
' => $object->userassigned[$object->userownerid]['answer_status
'],
2847 'mandatory
' => $object->userassigned[$object->userownerid]['mandatory
']
2850 if (!empty($object->userassigned)) { // Now concat assigned users
2851 // Restore array with key with same value than param 'id
'
2852 $tmplist1 = $object->userassigned;
2853 foreach ($tmplist1 as $key => $val) {
2854 if ($val['id
'] && $val['id
'] != $object->userownerid) {
2855 $listofuserid[$val['id
']] = $val;
2859 $_SESSION[$sessionkeyassignedtouser] = json_encode($listofuserid);
2861 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
2862 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser], true);
2866 $listofcontactid = []; // not used yet
2867 $listofotherid = []; // not used yet
2868 print '<div class=
"assignedtouser">
';
2869 print $form->select_dolusers_forevent('view
', 'assignedtouser
', 1, [], 0, '', [], '0
', 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2872 if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
2874 print '<div class=
"myavailability">
';
2875 print $langs->trans("MyAvailability").':
'.(($object->userassigned[$user->id]['transparency
'] > 0)?$langs->trans("Busy"):$langs->trans("Available")); // We show nothing if event is assigned to nobody
2879 print ' </td></tr>
';
2882 if (isModEnabled('category
')) {
2883 print '<tr><td class=
"valignmiddle">
'.$langs->trans("Categories").'</td><td>
';
2884 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2892 print '<div class=
"fichehalfright">
';
2894 print '<div class=
"underbanner clearboth"></div>
';
2895 print '<
table class=
"border tableforfield centpercent">
';
2897 if (isModEnabled("societe")) {
2899 print '<tr><td class=
"titlefield">
'.$langs->trans("ActionOnCompany").'</td>
';
2900 print '<td>
'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : ('<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
'));
2901 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL
') {
2902 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2903 print "<br>".dol_print_phone($object->thirdparty->phone);
2909 print '<tr><td>
'.$langs->trans("ActionOnContact").'</td>
';
2912 if (!empty($object->socpeopleassigned)) {
2913 foreach ($object->socpeopleassigned as $cid => $Tab) {
2914 $contact = new Contact($db);
2915 $result = $contact->fetch($cid);
2918 dol_print_error($db, $contact->error);
2922 print $contact->getNomUrl(1);
2923 if ($object->type_code == 'AC_TEL
') {
2924 if (!empty($contact->phone_pro)) {
2925 print '(
'.dol_print_phone($contact->phone_pro).')
';
2928 print '<div class=
"paddingright"></div>
';
2932 print '<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
';
2938 if (getDolGlobalString('AGENDA_SUPPORT_PRIORITY_IN_EVENTS
')) {
2939 print '<tr><td class=
"nowrap" class=
"titlefield">
' . $langs->trans("Priority") . '</td><td>
';
2940 print($object->priority ? $object->priority : '');
2944 // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
2945 // for such objects because there is already a dedicated field into table llx_actioncomm.
2946 if (!empty($object->elementid) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe
', 'contact
', 'project
'))) {
2947 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
2948 print '<tr><td>
'.$langs->trans("LinkedObject").'</td>
';
2949 $link = dolGetElementUrl($object->elementid, $object->elementtype, ($object->elementtype == 'user' ? -1 : 1));
2952 print '<span class=
"opacitymedium">
'.$langs->trans("ObjectDeleted").'</span>
';
2960 if (!empty($object->email_msgid)) {
2961 print '<tr><td>
'.$langs->trans('MailTopic
').'</td>
';
2962 print '<td>
'.dol_escape_htmltag($object->email_subject).'</td></tr>
';
2963 print '<tr><td>
'.$langs->trans('MailFrom
').'</td>
';
2964 print '<td>
'.dol_escape_htmltag($object->email_from).'</td></tr>
';
2965 print '<tr><td>
'.$langs->trans('MailTo
').'</td>
';
2966 print '<td>
'.dol_escape_htmltag($object->email_to).'</td></tr>
';
2967 if (!empty($object->email_tocc)) {
2968 print '<tr><td>
'.$langs->trans('MailCC
').'</td>
';
2969 print '<td>
'.dol_escape_htmltag($object->email_tocc).'</td></tr>
';
2974 print '<tr><td class=
"tdtop">
'.$langs->trans("Description").'</td><td class=
"wordbreak sensiblehtmlcontent">
';
2975 print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
2979 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php
';
2982 if ($enablereminders) {
2983 $filteruserid = $user->id;
2984 if ($user->hasRight('agenda
', 'allactions
', 'read
')) {
2987 $object->loadReminders('', $filteruserid, false);
2989 print '<tr><td class=
"titlefieldcreate nowrap">
'.$langs->trans("Reminders").'</td><td>
';
2991 if (count($object->reminders) > 0) {
2992 $tmpuserstatic = new User($db);
2994 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2995 print $TRemindTypes[$actioncommreminder->typeremind]['label
'];
2996 if ($actioncommreminder->fk_user > 0) {
2997 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2998 print ' (
'.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')
';
3000 print ' -
'.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit];
3002 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
3003 print ' - <span class=
"opacitymedium">
';
3004 print $langs->trans("NotSent");
3006 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
3007 print ' - <span class=
"opacitymedium">
';
3008 print $langs->trans("Done");
3010 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
3011 print ' - <span class=
"opacitymedium">
';
3012 print $form->textwithpicto($langs->trans("Error"), $actioncommreminder->lasterror);
3026 print '<div class=
"clearboth"></div>
';
3028 print dol_get_fiche_end();
3035 print '<div class=
"tabsAction">
';
3038 $reshook = $hookmanager->executeHooks('addMoreActionsButtons
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
3039 if (empty($reshook)) {
3040 if ($action != 'edit
') {
3041 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
3042 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
3043 print '<div class=
"inline-block divButAction"><a class=
"butAction" href=
"card.php?action=edit&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Modify").'</a></div>
';
3045 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Modify").'</a></div>
';
3048 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
3049 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
3050 print '<div class=
"inline-block divButAction">
'.dolGetButtonAction($langs->trans("ToClone"), $langs->trans("ToClone"), 'clone
', 'card.php?action=clone&token=
'.newToken().'&object=
'.$object->element.'&id=
'.$object->id, '', true, array('attr
' => array('class
' => 'reposition
'))).'</div>
';
3052 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("ToClone").'</a></div>
';
3055 if ($usercandelete) {
3056 print '<div class=
"inline-block divButAction">
'.dolGetButtonAction($langs->trans("Delete"), $langs->trans("Delete"), 'delete
', 'card.php?action=delete&token=
'.newToken().'&id=
'.$object->id, '', true, array('attr
' => array('class
' => 'reposition
'))).'</div>
'."\n";
3058 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Delete").'</a></div>
';
3065 if ($action != 'edit
') {
3066 if (!getDolGlobalString('AGENDA_DISABLE_BUILDDOC
')) {
3067 print '<div class=
"clearboth"></div><div class=
"fichecenter"><div class=
"fichehalfleft">
';
3068 print '<a
name=
"builddoc"></a>
'; // ancre
3070 // Generated documents
3071 $filedir = $conf->agenda->multidir_output[$conf->entity].'/
'.$object->id;
3072 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
3074 $genallowed = $user->hasRight('agenda
', 'myactions
', 'read
');
3075 $delallowed = $user->hasRight('agenda
', 'myactions
', 'create
');
3077 print $formfile->showdocuments('actions
', (string) $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang());
3079 if (getDolGlobalString('AGENDA_ENABLE_LINKED_ELEMENTS
')) {
3080 // Show links to link elements
3081 $tmparray = $form->showLinkToObjectBlock($object, [], array('myobject
'), 1);
3082 if (is_array($tmparray)) {
3083 $linktoelem = $tmparray['linktoelem
'];
3084 $htmltoenteralink = $tmparray['htmltoenteralink
'];
3085 print $htmltoenteralink;
3086 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
3088 // backward compatibility
3089 $somethingshown = $form->showLinkedObjectBlock($object, $tmparray);
3092 print '</div><div class=
"fichehalfright">
';
3094 print '</div></div>
';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='', $placeholder='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to manage agenda events (actions)
Class for ActionCommReminder.
Class to manage different types of events.
Class to manage a WYSIWYG editor.
Class to manage third parties objects (customers, suppliers, prospects...)
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
num_between_day($timestampStart, $timestampEnd, $lastday=0)
Function to return number of days between two dates (date must be UTC date !) Example: 2012-01-01 201...
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0, $tz='')
Add a delay to a date.
dol_stringtotime($string, $gm=1, $processnotimeasnoon=0)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option='')
Return link url to an object.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getElementProperties($elementType)
Get an array with properties of an element.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_set_focus($selector, $nooutput=0)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
$conf db user
Active Directory does not allow anonymous connections.
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
treeview li table
No Email.