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][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',
GETPOST(
"datep"), $reg)) {
105 $datep =
dol_mktime(0, 0, 0, (
int) $reg[2], (
int) $reg[3], (
int) $reg[1],
'tzuserrel');
111if (GETPOSTISSET(
"limityear") &&
GETPOSTINT(
"limityear") < 2100) {
112 $repeateventlimitdate =
dol_mktime(23, 59, 59, GETPOSTISSET(
"limitmonth") ?
GETPOSTINT(
"limitmonth") : 1, GETPOSTISSET(
"limitday") ?
GETPOSTINT(
"limitday") : 1,
GETPOSTINT(
"limityear"), $tzforfullday ? $tzforfullday :
'tzuserrel');
114 $repeateventlimitdate =
dol_mktime(23, 59, 59, 12, 31, $currentyear, $tzforfullday ? $tzforfullday :
'tzuserrel');
120 $socid = $user->socid;
123if ($user->socid && ($socid != $user->socid)) {
128$donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
133$sessionkeyassignedtouser =
'assignedtouser_'.($id > 0 ?
$id :
'new');
134$sessionkeyassignedtoresource =
'assignedtoresource_'.($id > 0 ?
$id :
'new');
147if ($id > 0 && $action !=
'add') {
151 $ret =
$object->fetch_optionals();
152 $ret1 =
$object->fetch_userassigned();
154 if ($ret < 0 || $ret1 < 0) {
160$extrafields->fetch_name_optionals_label(
$object->table_element);
162if (empty($action) && empty(
$object->id)) {
167$hookmanager->initHooks([
'actioncard',
'globalcard']);
171 $TRemindTypes[
'browser'] = [
172 'label' => $langs->trans(
'BrowserPush'),
174 'type' => ActionCommReminder::TYPE_USER,
175 'data-html' =>
img_picto(
'',
'globe',
'class="pictofixedwidth"') . $langs->trans(
'BrowserPush'),
179 $TRemindTypes[
'email'] = [
180 'label' => $langs->trans(
'EMail'),
182 'type' => ActionCommReminder::TYPE_USER,
183 'data-html' =>
img_picto(
'',
'email',
'class="pictofixedwidth"') . $langs->trans(
'EMail'),
188 $TRemindTypes[
'sms'] = [
189 'label' => $langs->trans(
'Sms'),
191 'type' => ActionCommReminder::TYPE_USER,
192 'data-html' =>
img_picto(
'',
'phoning_mobile',
'class="pictofixedwidth"') . $langs->trans(
'Sms'),
195$TDurationTypes = $form->getDurationTypes($langs);
196$TDurationTypesExcluded = [
'y',
'm',
's'];
200 'TRemindTypes' => &$TRemindTypes,
201 'enablereminders' => &$enablereminders,
202 'TDurationTypes' => &$TDurationTypes,
203 'TDurationTypesExcluded' => &$TDurationTypesExcluded,
205$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
210$result =
restrictedArea($user,
'agenda', $object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
212$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || ((empty(
$object->id) ||
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
213$usercandelete = $user->hasRight(
'agenda',
'allactions',
'delete') || ((
$object->authorid === $user->id ||
$object->userownerid === $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'));
220$listUserAssignedUpdated =
false;
221$listResourceAssignedUpdated =
false;
225if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
226 $idtoremove =
GETPOST(
'removedassigned');
228 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
229 $tmpassigneduserids = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
231 $tmpassigneduserids = [];
234 foreach ($tmpassigneduserids as $key => $val) {
235 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
236 unset($tmpassigneduserids[$key]);
240 $_SESSION[$sessionkeyassignedtouser] = json_encode($tmpassigneduserids);
241 $donotclearsession = 1;
242 if ($action ==
'add') {
245 if ($action ==
'update') {
249 $listUserAssignedUpdated =
true;
252if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
253 $idtoremove =
GETPOST(
'removedassignedresource');
255 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
256 $tmpassignedresourceids = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
258 $tmpassignedresourceids = [];
261 foreach ($tmpassignedresourceids as $key => $val) {
262 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
263 unset($tmpassignedresourceids[$key]);
267 $_SESSION[$sessionkeyassignedtoresource] = json_encode($tmpassignedresourceids);
269 if ($action ==
'add' && $usercancreate) {
272 if ($action ==
'update' && $usercancreate) {
276 $listResourceAssignedUpdated =
true;
280if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
282 if (
GETPOST(
'assignedtouser') > 0) {
283 $assignedtouser = [];
284 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
285 $assignedtouser = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
287 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id' =>
GETPOSTINT(
'assignedtouser'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
288 $_SESSION[$sessionkeyassignedtouser] = json_encode($assignedtouser);
290 $donotclearsession = 1;
291 if ($action ==
'add' && $usercancreate) {
294 if ($action ==
'update' && $usercancreate) {
298 $listUserAssignedUpdated =
true;
302if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
304 if (
GETPOST(
'assignedtoresource') > 0) {
305 $assignedtoresource = [];
306 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
307 $assignedtoresource = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
309 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id' =>
GETPOSTINT(
'assignedtoresource'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
310 $_SESSION[$sessionkeyassignedtoresource] = json_encode($assignedtoresource);
312 $donotclearsession = 1;
313 if ($action ==
'add' && $usercancreate) {
316 if ($action ==
'update' && $usercancreate) {
320 $listResourceAssignedUpdated =
true;
324if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
325 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
331if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
333 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
338 if (!empty(
$object->socpeopleassigned)) {
339 reset(
$object->socpeopleassigned);
344 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
355if (empty($reshook) && $action ==
'add' && $usercancreate) {
358 if (empty($backtopage)) {
360 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
362 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
366 if (!empty($socpeopleassigned[0])) {
367 $result = $contact->fetch($socpeopleassigned[0]);
371 header(
"Location: ".$backtopage);
375 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
388 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
391 if (!$datef && $percentage == 100) {
393 $donotclearsession = 1;
395 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
400 $donotclearsession = 1;
402 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
406 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
408 $donotclearsession = 1;
410 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
415 $listofresourceid = [];
420 $object->fulldayevent = ($fulldayevent ? 1 : 0);
424 if (
GETPOST(
"elementtype",
'alpha')) {
425 $elProp = getElementProperties(
GETPOST(
"elementtype",
'alpha'));
426 $modulecodetouseforpermissioncheck = $elProp[
'module'];
428 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
430 switch ($modulecodetouseforpermissioncheck) {
432 $modulecodetouseforpermissioncheck =
'produit';
434 case 'eventorganization':
436 $modulecodetouseforpermissioncheck =
'projet';
437 $submodulecodetouseforpermissioncheck =
'';
444 $hasPermissionOnLinkedObject = 0;
445 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
446 $hasPermissionOnLinkedObject = 1;
447 } elseif ($user->hasRight($modulecodetouseforpermissioncheck, $submodulecodetouseforpermissioncheck,
'read')) {
448 $hasPermissionOnLinkedObject = 1;
451 if ($hasPermissionOnLinkedObject) {
459 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
460 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
462 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
463 $object->label = $langs->transnoentitiesnoconv(
"Action".
$object->type_code).
"\n";
465 $cactioncomm->fetch(
$object->type_code);
466 $object->label = $cactioncomm->label;
473 if (!empty($taskid)) {
475 if ($taskProject->fetch($taskid) > 0) {
476 $object->fk_project = $taskProject->fk_project;
481 $object->elementtype =
'project_task';
486 $object->percentage = $percentage;
489 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
492 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
493 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
496 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
497 $listofresourceid = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
501 foreach ($listofuserid as $key => $value) {
503 if ($value[
'id'] > 0) {
504 $object->userownerid = $value[
'id'];
506 $object->transparency = $transparency;
509 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
517 if (GETPOSTISSET(
"contactid")) {
528 if (empty(
$object->userownerid) && empty($_SESSION[$sessionkeyassignedtouser])) {
530 $donotclearsession = 1;
532 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
534 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
536 $donotclearsession = 1;
538 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
543 $donotclearsession = 1;
545 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
548 foreach ($socpeopleassigned as $cid) {
549 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
551 if (!empty(
$object->socpeopleassigned)) {
552 reset(
$object->socpeopleassigned);
557 $ret = $extrafields->setOptionalsFromPost(
null, $object);
560 $donotclearsession = 1;
572 $selectedrecurrulefreq =
'no';
573 $selectedrecurrulebyyearmonthday =
'';
574 $selectedrecurrulebymonthday =
'';
575 $selectedrecurrulebyday =
'';
576 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
577 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'YEARLY') ?
"_BYYEARMONTHDAY".((
int) $dayinyear) :
"";
578 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY') ?
"_BYMONTHDAY".((
int) $dayinmonth) :
"";
579 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY') ?
"_BYDAY".((
int) $dayinweek) :
"";
585 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
586 $selectedrecurrulefreq = $reg1[1];
588 if (
$object->recurrule && preg_match(
'/FREQ=YEARLY.*BYYEARMONTHDAY(\d+)/i',
$object->recurrule, $reg4)) {
589 $selectedrecurrulebyyearmonthday = (int) $reg4[1];
591 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
592 $selectedrecurrulebymonthday = (int) $reg2[1];
594 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
595 $selectedrecurrulebyday = (int) $reg3[1];
599 $eventisrecurring = 0;
600 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
601 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
602 $eventisrecurring = 1;
612 $idaction =
$object->create($user);
617 if (is_array($listofresourceid) && count($listofresourceid)) {
618 foreach ($listofresourceid as $resource_id => $val) {
619 $resource_type =
'dolresource';
624 $eventDateStart =
$object->datep;
625 $eventDateEnd =
$object->datef;
626 $isFullDayEvent =
$object->fulldayevent;
627 if (empty($eventDateEnd)) {
628 if ($isFullDayEvent) {
630 $eventDateStart =
dol_mktime(0, 0, 0, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
631 $eventDateEnd =
dol_mktime(23, 59, 59, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
635 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
636 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_resources as er";
637 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"resource as r ON r.rowid = er.resource_id AND er.resource_type = '" .
$db->escape($resource_type) .
"'";
638 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" .
$db->escape(
$object->element) .
"'";
639 $sql .=
" WHERE er.resource_id = " . ((int) $resource_id);
640 $sql .=
" AND er.busy = 1";
644 $sql .=
" (ac.datep <= '" .
$db->idate($eventDateStart) .
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '" .
$db->idate($eventDateStart) .
"'))";
646 if (!empty($eventDateEnd)) {
647 $sql .=
" OR (ac.datep <= '" .
$db->idate($eventDateEnd) .
"' AND (ac.datep2 >= '" .
$db->idate($eventDateEnd) .
"'))";
651 $sql .=
"ac.datep >= '" .
$db->idate($eventDateStart) .
"'";
652 if (!empty($eventDateEnd)) {
653 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" .
$db->idate($eventDateEnd) .
"')";
658 $resql =
$db->query($sql);
664 if (
$db->num_rows($resql) > 0) {
667 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse') .
' : ';
668 while ($obj =
$db->fetch_object($resql)) {
669 $object->error .=
'<br> - ' . $langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label .
' [' . $obj->ac_id .
']');
680 $res =
$object->add_element_resource($resource_id, $resource_type, $busy, $val[
'mandatory']);
685 unset($_SESSION[$sessionkeyassignedtoresource]);
690 $categories =
GETPOST(
'categories',
'array');
691 $object->setCategories($categories);
694 unset($_SESSION[$sessionkeyassignedtouser]);
696 if ($user->id !=
$object->userownerid) {
697 $moreparam =
"filtert=-1";
701 if (!$error && $addreminder ==
'on') {
706 $actionCommReminder->dateremind = $dateremind;
707 $actionCommReminder->typeremind = $remindertype;
708 $actionCommReminder->offsetunit = $offsetunit;
709 $actionCommReminder->offsetvalue = $offsetvalue;
710 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
711 $actionCommReminder->fk_actioncomm =
$object->id;
712 if ($remindertype ==
'email') {
713 $actionCommReminder->fk_email_template = $modelmail;
717 foreach (
$object->userassigned as $userassigned) {
718 $actionCommReminder->fk_user = $userassigned[
'id'];
719 $res = $actionCommReminder->create($user);
723 $langs->load(
"errors");
725 setEventMessages($langs->trans(
'ErrorReminderActionCommCreation'),
null,
'errors');
727 $donotclearsession = 1;
738 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
751 $langs->load(
"errors");
755 $donotclearsession = 1;
761 $donotclearsession = 1;
765 if (!$error && $eventisrecurring) {
770 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
772 $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');
777 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
778 $firstday = $selectedrecurrulebymonthday;
785 } elseif ($selectedrecurrulefreq ==
'YEARLY' && !empty($selectedrecurrulebyyearmonthday)) {
800 while ($datep <= $repeateventlimitdate && !$error) {
804 $finalobject->datep = $datep;
805 $finalobject->datef = $datef;
807 $idaction = $finalobject->create($user);
810 if (!$finalobject->error) {
812 $categories =
GETPOST(
'categories',
'array');
813 $finalobject->setCategories($categories);
815 unset($_SESSION[$sessionkeyassignedtouser]);
818 if ($user->id != $finalobject->userownerid) {
819 $moreparam =
"filtert=-1";
823 if ($addreminder ==
'on') {
828 $actionCommReminder->dateremind = $dateremind;
829 $actionCommReminder->typeremind = $remindertype;
830 $actionCommReminder->offsetunit = $offsetunit;
831 $actionCommReminder->offsetvalue = $offsetvalue;
832 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
833 $actionCommReminder->fk_actioncomm = $finalobject->id;
834 if ($remindertype ==
'email') {
835 $actionCommReminder->fk_email_template = $modelmail;
839 foreach ($finalobject->userassigned as $userassigned) {
840 $actionCommReminder->fk_user = $userassigned[
'id'];
841 $res = $actionCommReminder->create($user);
846 $langs->load(
"errors");
847 setEventMessages($langs->trans(
'ErrorReminderActionCommCreation'),
null,
'errors');
849 $donotclearsession = 1;
860 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
864 $langs->load(
"errors");
865 $error = $langs->trans($finalobject->error);
868 $donotclearsession = 1;
874 $donotclearsession = 1;
878 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
898 if (!empty($backtopage) && !$error) {
899 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
900 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
901 } elseif ($idaction) {
902 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
904 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
911if (empty($reshook) && $action ==
'update' && $usercancreate) {
912 if (empty($cancel)) {
913 $fulldayevent =
GETPOST(
'fullday');
918 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
946 if (!GETPOSTISSET(
'ap') && !GETPOSTISSET(
'aphour') && !GETPOSTISSET(
'apmin')) {
951 if (!GETPOSTISSET(
'p2') && !GETPOSTISSET(
'p2hour') && !GETPOSTISSET(
'p2min')) {
959 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
961 if (
$object->elementtype ==
'ticket') {
963 if (
$object->code ==
'TICKET_MSG') {
964 $object->code =
'TICKET_MSG_PRIVATE';
966 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
967 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
970 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
973 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
974 $object->code =
'TICKET_MSG_SENTBYMAIL';
986 $object->percentage = $percentage;
991 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
992 $object->socpeopleassigned = [];
993 foreach ($socpeopleassigned as $cid) {
994 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
997 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
998 reset(
$object->socpeopleassigned);
1003 if (!empty($taskid)) {
1005 if ($taskProject->fetch($taskid) > 0) {
1006 $object->fk_project = $taskProject->fk_project;
1009 $object->fk_element = $taskid;
1011 $object->elementtype =
'project_task';
1016 if (
GETPOST(
"elementtype",
'alpha')) {
1017 $elProp = getElementProperties(
GETPOST(
"elementtype",
'alpha'));
1018 $modulecodetouseforpermissioncheck = $elProp[
'module'];
1020 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
1022 switch ($modulecodetouseforpermissioncheck) {
1023 case 'productbatch':
1024 $modulecodetouseforpermissioncheck =
'produit';
1026 case 'eventorganization':
1028 $modulecodetouseforpermissioncheck =
'projet';
1029 $submodulecodetouseforpermissioncheck =
'';
1036 $hasPermissionOnLinkedObject = 0;
1037 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
1038 $hasPermissionOnLinkedObject = 1;
1040 if ($hasPermissionOnLinkedObject) {
1048 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
1052 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
1054 $tmplist1 = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
1055 foreach ($tmplist1 as $key => $val) {
1056 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
1057 $listofuserid[$val[
'id']] = $val;
1061 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
1062 if ($assignedtouser) {
1063 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
1069 foreach ($listofuserid as $key => $val) {
1071 $object->userownerid = $val[
'id'];
1073 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
1077 $object->transparency = $transparency;
1081 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
1083 $donotclearsession = 1;
1085 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1087 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
1089 if (empty(
$object->userownerid)) {
1091 $donotclearsession = 1;
1093 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
1097 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
1105 $eventDateStart =
$object->datep;
1106 $eventDateEnd =
$object->datef;
1108 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1109 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1110 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1111 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".
$db->escape(
$object->element).
"'";
1112 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1113 $sql .=
" AND er.resource_id IN (";
1114 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1115 $sql .=
" WHERE element_id = ".((int)
$object->id);
1116 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1117 $sql .=
" AND busy = 1";
1119 $sql .=
" AND er.busy = 1";
1123 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".
$db->idate($eventDateStart).
"'))";
1125 if (!empty($eventDateEnd)) {
1126 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".
$db->idate($eventDateEnd).
"'))";
1130 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1131 if (!empty($eventDateEnd)) {
1132 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1137 $resql =
$db->query($sql);
1143 if (
$db->num_rows($resql) > 0) {
1146 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1147 while ($obj =
$db->fetch_object($resql)) {
1148 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1164 $result =
$object->update($user);
1168 $categories =
GETPOST(
'categories',
'array');
1169 $object->setCategories($categories);
1171 $object->loadReminders($remindertype, 0,
false);
1174 if (!empty(
$object->reminders)) {
1175 foreach (
$object->reminders as $reminder) {
1176 if ($reminder->status < 1) {
1177 $reminder->delete($user);
1184 if ($addreminder ==
'on') {
1189 $actionCommReminder->dateremind = $dateremind;
1190 $actionCommReminder->typeremind = $remindertype;
1191 $actionCommReminder->offsetunit = $offsetunit;
1192 $actionCommReminder->offsetvalue = $offsetvalue;
1193 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
1194 $actionCommReminder->fk_actioncomm =
$object->id;
1195 if ($remindertype ==
'email') {
1196 $actionCommReminder->fk_email_template = $modelmail;
1200 foreach (
$object->userassigned as $userassigned) {
1201 $actionCommReminder->fk_user = $userassigned[
'id'];
1205 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1206 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".
$db->escape($remindertype).
"'";
1207 $resqldelete =
$db->query($sqldelete);
1209 $res = $actionCommReminder->create($user);
1213 $langs->load(
"errors");
1214 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1217 $donotclearsession = 1;
1224 unset($_SESSION[$sessionkeyassignedtouser]);
1225 unset($_SESSION[$sessionkeyassignedtoresource]);
1240 if (!empty($backtopage)) {
1241 unset($_SESSION[$sessionkeyassignedtouser]);
1242 header(
"Location: ".$backtopage);
1249if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes' && $usercandelete) {
1252 $object->fetch_userassigned();
1255 $result =
$object->delete($user);
1258 header(
"Location: index.php");
1269if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate' && $usercancreate) {
1275 $newdate =
GETPOST(
'newdate',
'alpha');
1276 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1277 header(
"Location: ".$backtopage,
true, 307);
1281 $datep =
dol_mktime($shour, $smin, 0, (
int) substr($newdate, 13, 2), (
int) substr($newdate, 15, 2), (
int) substr($newdate, 9, 4),
'tzuserrel');
1284 if ($datep !=
$object->datep) {
1293 $eventDateStart =
$object->datep;
1294 $eventDateEnd =
$object->datef;
1296 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1297 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1298 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1299 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".
$db->escape(
$object->element).
"'";
1300 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1301 $sql .=
" AND er.resource_id IN (";
1302 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1303 $sql .=
" WHERE element_id = ".((int)
$object->id);
1304 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1305 $sql .=
" AND busy = 1";
1307 $sql .=
" AND er.busy = 1";
1311 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".
$db->idate($eventDateStart).
"'))";
1313 if (!empty($eventDateEnd)) {
1314 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".
$db->idate($eventDateEnd).
"'))";
1318 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1319 if (!empty($eventDateEnd)) {
1320 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1325 $resql =
$db->query($sql);
1331 if (
$db->num_rows($resql) > 0) {
1334 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1335 while ($obj =
$db->fetch_object($resql)) {
1336 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1351 $result =
$object->update($user);
1361 if (!empty($backtopage)) {
1362 header(
"Location: ".$backtopage,
true, 307);
1371$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1372if (empty($reshook)) {
1373 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1384$arrayrecurrulefreq = array(
1385 'no' => $langs->trans(
"OnceOnly"),
1386 'YEARLY' => $langs->trans(
"EveryYear"),
1387 'MONTHLY' => $langs->trans(
"EveryMonth"),
1388 'WEEKLY' => $langs->trans(
"EveryWeek")
1393$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1394llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1396if ($action ==
'create') {
1399 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1400 if (!empty($socpeopleassigned[0])) {
1401 $result = $contact->fetch($socpeopleassigned[0]);
1409 if (!empty(
$conf->use_javascript_ajax)) {
1410 print
"\n".
'<script type="text/javascript">';
1411 print
'$(document).ready(function () {
1412 function setdatefields()
1414 if ($("#fullday:checked").val() == null) {
1415 $(".fulldaystarthour").removeAttr("disabled");
1416 $(".fulldaystartmin").removeAttr("disabled");
1417 $(".fulldayendhour").removeAttr("disabled");
1418 $(".fulldayendmin").removeAttr("disabled");
1419 $("#p2").removeAttr("disabled");
1421 $(".fulldaystarthour").prop("disabled", true).val("00");
1422 $(".fulldaystartmin").prop("disabled", true).val("00");
1423 $(".fulldayendhour").prop("disabled", true).val("23");
1424 $(".fulldayendmin").prop("disabled", true).val("59");
1425 $("#p2").removeAttr("disabled");
1428 $("#fullday").change(function() {
1429 console.log("setdatefields");
1432 var old_startdate = null;
1433 $("#ap").focus(function() {
1434 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1436 $("#ap").next(".ui-datepicker-trigger").click(function() {
1437 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1439 $("#ap").change(function() {
1440 setTimeout(function() {
1441 if ($("#p2").val() !== "") {
1442 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1443 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1444 if (new_startdate > old_enddate) {
1445 var timeDiff = old_enddate - old_startdate;
1446 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1447 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1448 $("#p2day").val(new_enddate.getDate());
1449 $("#p2month").val(new_enddate.getMonth() + 1);
1450 $("#p2year").val(new_enddate.getFullYear());
1455 $("#actioncode").change(function() {
1456 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1457 else $("#dateend").removeClass("fieldrequired");
1459 $("#aphour,#apmin").change(function() {
1460 if ($("#actioncode").val() == \'AC_RDV\') {
1461 var oldhour = parseInt($("#aphour").val());
1462 var oldmin = parseInt($("#apmin").val());
1463 var oldday = parseInt($("#apday").val());
1464 var oldmonth = $("#apmonth").val();
1465 var oldyear = $("#apyear").val();
1467 var newhour = oldhour + 1;
1468 var newday = oldday;
1469 var newmonth = oldmonth;
1470 var newyear = oldyear;
1471 if (newhour >= 24) {
1473 newday = oldday + 1;
1475 console.log("Start date was changed, we modify end date "+oldhour+" "+oldmin+" -> "+newhour+" "+oldmin);
1476 $("#p2hour").val(("00" + newhour).substr(-2,2));
1477 $("#p2min").val(("00" + oldmin).substr(-2,2));
1478 $("#p2day").val(newday);
1479 $("#p2month").val(newmonth);
1480 $("#p2year").val(newyear);
1481 $("#p2").val($("#ap").val());
1484 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1485 else $("#dateend").removeClass("fieldrequired");
1488 print
'</script>'.
"\n";
1491 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1492 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1493 print
'<input type="hidden" name="action" value="add">';
1494 print
'<input type="hidden" name="donotclearsession" value="1">';
1495 print
'<input type="hidden" name="page_y" value="">';
1497 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1500 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode(
$db,
'AC_OTH',
'c_actioncomm').
'">';
1507 print
'<div class="divcreate">';
1508 print
'<table class="border centpercent nobottom">';
1511 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>';
1515 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1517 if (empty($default)) {
1518 $default =
'AC_OTH';
1520 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1521 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1522 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1527 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1528 print
'<td class="valignmiddle height30">';
1530 print
'<input class="valignmiddle" type="checkbox" id="fullday" name="fullday" '.(GETPOST(
'fullday') ?
' checked' :
'').
'><label for="fullday" class="valignmiddle small">'.$langs->trans(
"EventOnFullDay").
'</label>';
1534 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1535 if (
GETPOST(
'datep',
'alpha', 1)) {
1538 $datef = ($datef ? $datef :
$object->datef);
1539 if (
GETPOST(
'datef',
'alpha', 1)) {
1542 if (empty($datef) && !empty($datep)) {
1549 print
'<tr><td class="nowrap">';
1551 print
'<div class="inline-block">';
1553 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1555 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1557 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1558 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1564 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
1565 if ($userepeatevent) {
1567 print
'<div class="clearbothonsmartphone hideonsmartphone inline-block"> </div>';
1570 print
'<div class="inline-block small" data-html="repeat">';
1571 print
'<span class="opacitymedium">';
1572 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 3px" class="paddingright"');
1573 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1575 $selectedrecurrulefreq =
'no';
1576 $selectedrecurrulebyyearmonthday =
'';
1577 $selectedrecurrulebymonthday =
'';
1578 $selectedrecurrulebyday =
'';
1579 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1580 $object->recurrule .= GETPOSTISSET(
'BYYEARMONTHDAY') ?
"_BYYEARMONTHDAY".GETPOST(
'BYYEARMONTHDAY',
'alpha') :
"";
1581 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1582 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1586 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1587 $selectedrecurrulefreq = $reg[1];
1589 if (
$object->recurrule && preg_match(
'/FREQ=YEARLY.*BYYEARMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1590 $selectedrecurrulebyyearmonthday = (int) $reg[1];
1592 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1593 $selectedrecurrulebymonthday = (int) $reg[1];
1595 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1596 $selectedrecurrulebyday = (int) $reg[1];
1599 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly minwidth125 maxwidth150');
1617 $repeateventlimitdate = empty($repeateventlimitdate) ? (
dol_now() + ((24 * 3600 * 365) + 1)) : $repeateventlimitdate;
1619 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1620 print $langs->trans(
"Until").
" ";
1621 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1624 <script
type=
"text/javascript">
1625 jQuery(document).ready(
function() {
1626 function init_repeat() {
1627 console.log(
"recurrule: " +
"<?php echo $object->recurrule; ?>");
1628 console.log(
"reg1: " +
"<?php echo $selectedrecurrulefreq; ?>");
1629 console.log(
"reg2: " +
"<?php echo $selectedrecurrulebymonthday; ?>");
1630 console.log(
"reg3: " +
"<?php echo $selectedrecurrulebyday; ?>");
1631 console.log(
"reg4: " +
"<?php echo $selectedrecurrulebyyearmonthday; ?>");
1632 console.log(
"selectedrulefreq: " +
"<?php echo $selectedrecurrulefreq; ?>");
1633 if (jQuery(
"#recurrulefreq").val() ==
'YEARLY') {
1635 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1636 jQuery(
".repeateventBYMONTHDAY").hide();
1637 jQuery(
".repeateventBYDAY").hide();
1638 }
else if (jQuery(
"#recurrulefreq").val() ==
'MONTHLY') {
1640 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1641 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1642 jQuery(
".repeateventBYDAY").hide();
1643 }
else if (jQuery(
"#recurrulefreq").val() ==
'WEEKLY') {
1644 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1645 jQuery(
".repeateventBYMONTHDAY").hide();
1647 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1649 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1650 jQuery(
".repeateventBYMONTHDAY").hide();
1651 jQuery(
".repeateventBYDAY").hide();
1652 jQuery(
".repeateventlimitdate").hide();
1656 jQuery(
"#recurrulefreq").change(
function() {
1671 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Location").
'</td><td>';
1672 print
img_picto(
'',
'map-marker-alt',
'class="pictofixedwidth"');
1673 print
'<input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.(GETPOST(
'location') ?
GETPOST(
'location') :
$object->location).
'"></td></tr>';
1681 print
'<div class="divcreate">';
1682 print
'<table class="border centpercent nobottom">';
1685 print
'<tr><td class="nowrap titlefieldcreate"><span>';
1686 print $langs->trans(
"AssignedTo");
1687 print
'</span></td><td>';
1689 $listofcontactid = [];
1690 $listofotherid = [];
1692 if (empty($donotclearsession)) {
1694 if ($assignedtouser) {
1695 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1698 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1699 $_SESSION[$sessionkeyassignedtouser] = json_encode($listofuserid);
1701 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
1702 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
1704 if (!is_array($listofuserid)) {
1707 $firstelem = reset($listofuserid);
1708 if (isset($listofuserid[$firstelem[
'id']])) {
1709 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1712 print
'<!-- list of user to assign -->'.
"\n";
1713 print
'<div class="assignedtouser">';
1714 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, [], 0,
'', [],
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid);
1720 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1722 $listofresourceid = [];
1723 if (empty($donotclearsession)) {
1724 $assignedtoresource =
GETPOST(
"assignedtoresource");
1725 if ($assignedtoresource) {
1726 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1728 $_SESSION[$sessionkeyassignedtoresource] = json_encode($listofresourceid);
1730 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
1731 $listofresourceid = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
1733 if (!is_array($listofresourceid)) {
1734 $listofresourceid = [];
1736 $firstelem = reset($listofresourceid);
1737 if ($firstelem && isset($listofresourceid[$firstelem[
'id']])) {
1738 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1741 print
'<div class="assignedtoresource">';
1742 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1, [], 0,
'', [],
'0', 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1749 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1750 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories', $object);
1760 print
'<div class="divcreate">';
1761 print
'<table class="border centpercent nobottom">';
1764 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td>';
1766 $percent = $complete !==
'' ? $complete : -1;
1767 if (GETPOSTISSET(
'status')) {
1769 } elseif (GETPOSTISSET(
'percentage')) {
1772 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1774 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1778 print $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'minwidth150 maxwidth300', 1);
1783 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1787 print $societe->getNomUrl(1);
1788 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1791 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1793 if (!empty($user->socid)) {
1794 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1796 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid',
'', $langs->trans(
'SelectThirdParty'), 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1802 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1803 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1807 if ($origin ==
'contact') {
1813 $select_contact_default = 0;
1815 $select_contact_default = -1;
1817 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
1826 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1827 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, [],
'multiple',
'contactid');
1828 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1830 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, [],
'multiple',
'contactid');
1838 $langs->load(
"projects");
1842 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1843 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1844 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');
1846 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1847 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1848 $urloption =
'?action=create&donotclearsession=1';
1853 <script
type=
"text/javascript">
1854 $(document).ready(
function () {
1855 $(
"#projectid").change(
function () {
1856 var url =
"<?php echo DOL_URL_ROOT; ?>/projet/ajax/projects.php?mode=gettasks&socid="+$(
"#search_socid").val()+
"&projectid="+$(
"#projectid").val();
1857 console.log(
"Call url to get the new list of tasks: "+url);
1858 $.get(url,
function(data) {
1860 if (data) $(
"#taskid").html(data).select2();
1870 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1871 print
img_picto(
'',
'projecttask',
'class="pictofixedwidth"');
1872 $projectsListId =
'';
1873 if (!empty($projectid)) {
1874 $projectsListId = $projectid;
1877 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1879 if (empty($projectsListId)) {
1880 print
'<select class="valignmiddle flat maxwidth500 widthcentpercentminusxx minwidth150imp" id="taskid" name="taskid">';
1881 print
'<option class="opacitymedium"> </option>';
1882 print
'<option class="opacitymedium" disabled data-html="'.dolPrintHTMLForAttribute($langs->trans(
"SelectAProjectFirst")).
'">'.$langs->trans(
"SelectAProjectFirst").
'</option>';
1886 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 64, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (
string) $projectsListId,
'all', null, 1);
1892 if (!empty($origin) && !empty($originid)) {
1893 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1895 $hasPermissionOnLinkedObject = 0;
1897 $elProp = getElementProperties($origin);
1898 $modulecodetouseforpermissioncheck = $elProp[
'module'];
1900 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
1902 switch ($modulecodetouseforpermissioncheck) {
1903 case 'productbatch':
1904 $modulecodetouseforpermissioncheck =
'produit';
1906 case 'eventorganization':
1908 $modulecodetouseforpermissioncheck =
'projet';
1909 $submodulecodetouseforpermissioncheck =
'';
1916 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read') || $user->hasRight($modulecodetouseforpermissioncheck, $elProp[
'element'],
'read')) {
1917 $hasPermissionOnLinkedObject = 1;
1921 if (! in_array($origin, array(
'societe',
'project',
'project_task',
'user'))) {
1923 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1924 print
'<td colspan="3">';
1925 if ($hasPermissionOnLinkedObject) {
1927 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1928 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1929 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1930 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1932 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1940 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1941 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1946 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1947 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1948 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 200,
'dolibarr_notes',
'In', true, true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1949 $doleditor->Create();
1954 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1955 print $hookmanager->resPrint;
1956 if (empty($reshook)) {
1957 print
$object->showOptionals($extrafields,
'create', $parameters);
1963 if ($enablereminders) {
1967 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>';
1969 print
'<div class="reminderparameters" '.(empty(
GETPOST(
'addreminder')) ?
'style="display: none;' :
'').
' ">';
1972 print
'<table class="border centpercent">';
1975 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1976 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1978 print $form->selectTypeDuration(
'offsetunit', (empty($offsetunit) ?
'i' : $offsetunit), $TDurationTypesExcluded);
1982 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1983 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1988 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1989 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (empty($modelmail) ? 0 : $modelmail));
1996 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
1997 $reminderDefaultOffset =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_OFFSET', 30);
1999 $reminderDefaultEmailModel =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
2001 print
"\n".
'<script type="text/javascript">';
2002 print
'$(document).ready(function () {
2003 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
2004 $(
"#actioncode").change(
function(){
2005 var selected_event_type = $(
"#actioncode option:selected").val();
2007 if (reminderDefaultEventTypes.includes(selected_event_type)) {
2008 $(
".reminderparameters").show();
2009 $(
"#addreminder").prop(
"checked",
true);
2012 $(
"[name=\"offsetvalue\"]").val(\
'' .
dol_escape_js((
string) $reminderDefaultOffset) .
'\');
2013 $(
"#select_offsetunittype_duration").select2(
"destroy");
2014 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
2015 $(
"#select_offsetunittype_duration").select2();
2017 $(
"#selectremindertype").select2(
"destroy");
2018 $(
"#selectremindertype").val(
"email");
2019 $(
"#selectremindertype").select2();
2022 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2023 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
2024 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js((
string) $reminderDefaultEmailModel).
'\');
2025 $(
"#select_actioncommsendmodel_mail").select2();
2029 print '</script>
'."\n";
2031 print "\n".'<script
type=
"text/javascript">
';
2032 print '$(document).ready(
function () {
2033 function toggle_reminder_part(evt) {
2034 console.log(
"Toggle reminder part");
2035 if ($(
"#addreminder").is(
":checked")) {
2036 $(
".reminderparameters").show();
2038 $(
".reminderparameters").hide();
2040 $(
"#selectremindertype").select2(
"destroy");
2041 $(
"#selectremindertype").select2();
2042 $(
"#select_offsetunittype_duration").select2(
"destroy");
2043 $(
"#select_offsetunittype_duration").select2();
2044 selectremindertype();
2047 toggle_reminder_part();
2048 $(
"#addreminder").click(toggle_reminder_part);
2050 $(
"#selectremindertype").change(
function(){
2051 selectremindertype();
2054 function selectremindertype() {
2055 console.log(
"Call selectremindertype");
2056 var selected_option = $(
"#selectremindertype option:selected").val();
2057 if(selected_option ==
"email") {
2058 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2060 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
2065 print '</script>
'."\n";
2068 print dol_get_fiche_end();
2070 print $form->buttonsSaveCancel("Create");
2076if ($id > 0 && $action != 'create
') {
2077 $result1 = $object->fetch($id);
2078 if ($result1 <= 0) {
2079 recordNotFound('', 0);
2082 $result2 = $object->fetch_thirdparty();
2083 $result2 = $object->fetchProject();
2084 $result3 = $object->fetch_contact();
2085 $result4 = $object->fetch_userassigned();
2086 $result5 = $object->fetch_optionals();
2088 if ($listUserAssignedUpdated || $donotclearsession) {
2089 $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
2091 $datep = dol_mktime($fulldayevent ? 0 : $aphour, $fulldayevent ? 0 : $apmin, 0, GETPOSTINT("apmonth"), GETPOSTINT("apday"), GETPOSTINT("apyear"), 'tzuserrel
');
2092 $datef = dol_mktime($fulldayevent ? 23 : $p2hour, $fulldayevent ? 59 : $p2min, $fulldayevent ? 59 : 0, GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), 'tzuserrel
');
2094 $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09
'), 'c_actioncomm
');
2095 $object->label = GETPOST("label", "alphanohtml");
2096 $object->datep = $datep;
2097 $object->datef = $datef;
2098 $object->percentage = $percentage;
2099 $object->priority = GETPOSTINT("priority");
2100 $object->fulldayevent = GETPOST("fullday") ? 1 : 0;
2101 $object->location = GETPOST('location
', "alphanohtml");
2102 $object->socid = GETPOSTINT("socid");
2103 $socpeopleassigned = GETPOST("socpeopleassigned", 'array
');
2104 foreach ($socpeopleassigned as $tmpid) {
2105 $object->socpeopleassigned[$id] = array('id' => $tmpid);
2107 $object->contact_id = GETPOSTINT("contactid");
2108 $object->fk_project = GETPOSTINT("projectid");
2110 $object->note_private = GETPOST("note", 'restricthtml
');
2113 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
2114 dol_print_error($db, $object->error);
2123 $head = actions_prepare_head($object);
2126 $delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO
') * 24 * 60 * 60;
2129 // Deletion confirmation action
2130 if ($action == 'delete') {
2131 print $form->formconfirm("card.php?id=".urlencode((string) ($id)), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1);
2134 if ($action == 'edit
') {
2135 $caneditdateorowner = ($object->type != 'systemauto
');
2137 if (!empty($conf->use_javascript_ajax)) {
2138 print "\n".'<script
type=
"text/javascript">
';
2139 print '$(document).ready(
function () {
2140 function setdatefields()
2142 if ($(
"#fullday:checked").val() ==
null) {
2143 $(
".fulldaystarthour").removeAttr(
"disabled");
2144 $(
".fulldaystartmin").removeAttr(
"disabled");
2145 $(
".fulldayendhour").removeAttr(
"disabled");
2146 $(
".fulldayendmin").removeAttr(
"disabled");
2148 $(
".fulldaystarthour").prop(
"disabled",
true).val(
"00");
2149 $(
".fulldaystartmin").prop(
"disabled",
true).val(
"00");
2150 $(
".fulldayendhour").prop(
"disabled",
true).val(
"23");
2151 $(
".fulldayendmin").prop(
"disabled",
true).val(
"59");
2155 '.($caneditdateorowner ? ' setdatefields();
' : '').'
2157 $(
"#fullday").change(
function() {
2160 var old_startdate =
null;
2161 $(
"#ap").focus(
function() {
2162 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2164 $(
"#ap").next(
".ui-datepicker-trigger").click(
function() {
2165 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2167 $(
"#ap").change(
function() {
2168 setTimeout(
function() {
2169 if ($(
"#p2").val() !==
"") {
2170 var new_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2171 var old_enddate =
new Date($(
"#p2year").val(), $(
"#p2month").val() - 1, $(
"#p2day").val());
2172 if (new_startdate > old_enddate) {
2173 var timeDiff = old_enddate - old_startdate;
2174 var new_enddate =
new Date(new_startdate.getTime() + timeDiff);
2175 $(
"#p2").val(formatDate(new_enddate,
"' . $langs->trans('FormatDateShortJavaInput') . '"));
2176 $(
"#p2day").val(new_enddate.getDate());
2177 $(
"#p2month").val(new_enddate.getMonth() + 1);
2178 $(
"#p2year").val(new_enddate.getFullYear());
2183 $(
"#actioncode").change(
function() {
2184 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
2185 else $("#dateend").removeClass("fieldrequired");
2188 print
'</script>'.
"\n";
2191 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
2192 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2193 print
'<input type="hidden" name="action" value="update">';
2194 print
'<input type="hidden" name="id" value="'.$id.
'">';
2195 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
2196 print
'<input type="hidden" name="page_y" value="">';
2198 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
2201 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2206 print
'<table class="border tableforfield centpercent">';
2209 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>'.
$object->id.
'</td></tr>';
2212 print
'<tr><td class="fieldrequired'.(!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ?
' titlefieldcreate' :
'').
'">'.$langs->trans(
"Title").
'</td><td><input type="text" name="label" class="soixantepercent" value="'.
$object->label.
'"></td></tr>';
2216 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
2217 if (
$object->type_code !=
'AC_OTH_AUTO') {
2218 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
2219 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
2221 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2222 print
$object->getTypePicto();
2223 print $langs->trans(
"Action".
$object->type_code);
2229 if (
$object->elementtype ==
'ticket') {
2230 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
2231 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
2232 print
'</td><td><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
2236 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td class="valignmiddle height30 small">';
2237 print
'<input '.($caneditdateorowner ?
'' :
' disabled').
' type="checkbox" id="fullday" name="fullday" '.(
$object->fulldayevent ?
' checked' :
'').
'>';
2238 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
2301 print
'<tr><td class="nowrap">';
2304 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');
2305 print
' <span class="hideonsmartphone"> - </span> ';
2306 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');
2311 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>';
2312 print
img_picto(
'',
'map-marker-alt',
'class="pictofixedwidth"');
2313 print
'<input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.$object->location.
'"></td></tr>';
2316 print
'<tr class="tdsmallheight"><td class="tdsmallheight"> </td><td class="tdsmallheight"></td></tr>';
2320 if (empty($donotclearsession)) {
2321 if (
$object->userownerid > 0) {
2322 $listofuserid[
$object->userownerid] = array(
2326 'transparency' =>
$object->transparency,
2327 'answer_status' => (isset(
$object->userassigned[
$object->userownerid][
'answer_status']) ?
$object->userassigned[
$object->userownerid][
'answer_status'] : null),
2328 'mandatory' => (isset(
$object->userassigned[
$object->userownerid][
'mandatory']) ?
$object->userassigned[
$object->userownerid][
'mandatory'] : null)
2331 if (!empty(
$object->userassigned)) {
2333 $tmplist1 =
$object->userassigned;
2334 foreach ($tmplist1 as $key => $val) {
2335 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2336 $listofuserid[$val[
'id']] = $val;
2340 $_SESSION[$sessionkeyassignedtouser] = json_encode($listofuserid);
2342 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
2343 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
2347 $listofcontactid =
$object->socpeopleassigned;
2348 $listofotherid =
$object->otherassigned;
2350 print
'<tr><td class="nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2351 print
'<div class="assignedtouser">';
2352 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, [], 0,
'', [],
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid, (int) $caneditdateorowner);
2364 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2365 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories', $object);
2375 print
'<table class="border tableforfield centpercent">';
2378 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td><td colspan="3">';
2379 $percent = GETPOSTISSET(
"percentage") ?
GETPOSTINT(
"percentage") :
$object->percentage;
2380 $formactions->form_select_status_action(
'formaction', (
string) $percent, 1,
'complete', 0, 0,
'minwidth150 maxwidth300');
2385 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2389 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2392 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2397 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2398 print
'<div class="maxwidth200onsmartphone">';
2400 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2408 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2409 print $form->selectcontacts(
getDolGlobalString(
'MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT') ? 0 : (
$object->socid > 0 ?
$object->socid : -1), array_keys(
$object->socpeopleassigned),
'socpeopleassigned[]', 1,
'',
'', 1,
'minwidth300 widthcentpercentminusx', 0, 0, 0, [],
'multiple',
'contactid');
2410 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2413 print $form->selectcontacts(
getDolGlobalString(
'MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT') ? 0 :
$object->socid, array_keys(
$object->socpeopleassigned),
'socpeopleassigned[]', 1,
'',
'', 1,
'minwidth300 widthcentpercentminusx', 0, 0, 0, [],
'multiple',
'contactid');
2422 $langs->load(
"projects");
2424 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2425 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2426 $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');
2427 if ($numprojet == 0) {
2428 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>';
2435 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2436 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2442 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2444 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2447 print
'<td id="project-task-input-container" >';
2449 $urloption =
'?action=create&donotclearsession=1';
2450 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2454 <script
type=
"text/javascript" >
2455 $(document).ready(
function () {
2456 $(
"#projectid").change(
function () {
2457 var url =
"<?php echo $url; ?>&projectid="+$(
"#projectid").val();
2458 $.get(url,
function(data) {
2459 console.log($( data ).find(
"#fk_element").html());
2460 if (data) $(
"#fk_element").html( $( data ).find(
"#taskid").html() ).select2();
2467 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);
2468 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2475 print
'<td id="project-task-input-container" >';
2479 <script
type=
"text/javascript">
2480 $(document).ready(
function () {
2481 $(
"#projectid").change(
function () {
2482 var url =
"<?php echo DOL_URL_ROOT; ?>/projet/ajax/projects.php?mode=gettasks&socid="+$(
"#search_socid").val()+
"&projectid="+$(
"#projectid").val();
2483 console.log(
"Call url to get new list of tasks: "+url);
2484 $.get(url,
function(data) {
2486 if (data) $(
"#taskid").html(data).select2();
2494 if (GETPOSTISSET(
"projecttaskid") &&
GETPOSTINT(
"projecttaskid") > 0) {
2496 } elseif (GETPOSTISSET(
"taskid") &&
GETPOSTINT(
"taskid") > 0) {
2500 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 64, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (
string) $projectsListId,
'all', null, 1);
2506 print
'<input type="hidden" name="fk_element" value="'.$object->elementid.
'">';
2507 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2516 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2518 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2519 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 200,
'dolibarr_notes',
'In',
true,
true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2520 $doleditor->Create();
2525 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2526 print $hookmanager->resPrint;
2527 if (empty($reshook)) {
2528 print
$object->showOptionals($extrafields,
'edit', $parameters);
2534 if ($enablereminders) {
2535 $filteruserid = $user->id;
2536 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2539 $object->loadReminders(
'', $filteruserid,
false);
2543 if (count(
$object->reminders) > 0) {
2544 $checked =
'checked';
2545 $keys = array_keys(
$object->reminders);
2546 $firstreminderId = array_shift($keys);
2548 $actionCommReminder =
$object->reminders[$firstreminderId];
2552 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2553 $actionCommReminder->offsetunit =
'i';
2554 $actionCommReminder->typeremind =
'email';
2563 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>';
2565 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2569 print
'<table class="border centpercent">';
2572 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2573 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2574 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, $TDurationTypesExcluded);
2578 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2579 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2583 if ($actionCommReminder->typeremind ==
'browser') {
2584 $hide =
'style="display:none;"';
2589 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2590 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (
string) $actionCommReminder->fk_email_template);
2596 <script
type=
"text/javascript">
2597 $(document).ready(
function () {
2598 $(
"#addreminder").click(
function(){
2600 $(
".reminderparameters").show();
2602 $(
".reminderparameters").hide();
2605 $(
"#selectremindertype").change(
function(){
2606 var selected_option = $(
"#selectremindertype option:selected").val();
2607 if(selected_option ==
"email") {
2608 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2610 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
2617 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
2620 $reminderDefaultEmailModel =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
2622 print
"\n".
'<script type="text/javascript">';
2623 print
'$(document).ready(function () {
2624 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
2625 $(
"#actioncode").change(
function(){
2626 var selected_event_type = $(
"#actioncode option:selected").val();
2628 if (reminderDefaultEventTypes.includes(selected_event_type)) {
2629 $(
".reminderparameters").show();
2630 $(
"#addreminder").prop(
"checked",
true);
2633 $(
"#offsetvalue").val(\
''.
dol_escape_js($reminderDefaultOffset).
'\');
2634 $(
"#select_offsetunittype_duration").select2(
"destroy");
2635 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
2636 $(
"#select_offsetunittype_duration").select2();
2638 $(
"#selectremindertype").select2(
"destroy");
2639 $(
"#selectremindertype").val(
"email");
2640 $(
"#selectremindertype").select2();
2643 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2644 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
2645 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js($reminderDefaultEmailModel).
'\');
2646 $(
"#select_actioncommsendmodel_mail").select2();
2650 print '</script>
'."\n";
2651 print '</div>
'; // End of div for reminderparameters
2654 print dol_get_fiche_end();
2656 print $form->buttonsSaveCancel();
2660 print dol_get_fiche_head($head, 'card
', $langs->trans("Action"), -1, 'action
');
2665 if ($action == 'clone
') {
2666 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?
id=
'.GETPOST('id'), $langs->trans('ToClone
'), $langs->trans('ConfirmCloneEvent
', $object->label), 'confirm_clone
', [], 'yes
', 1);
2669 // Call Hook formConfirm
2671 $reshook = $hookmanager->executeHooks('formConfirm
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2672 if (empty($reshook)) {
2673 $formconfirm .= $hookmanager->resPrint;
2674 } elseif ($reshook > 0) {
2675 $formconfirm = $hookmanager->resPrint;
2678 // Print form confirm
2682 // Link to other agenda views
2683 $linkback .= '<a href=
"'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">
';
2684 $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist
', 'class=
"pictoactionview pictofixedwidth"');
2685 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("BackToList").'</span>
';
2686 $linkback .= '</a>
';
2687 $linkback .= '</li>
';
2688 $linkback .= '<li
class=
"noborder litext">
';
2689 $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').'">
';
2690 $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar
', 'class=
"pictoactionview pictofixedwidth"');
2691 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewCal").'</span>
';
2692 $linkback .= '</a>
';
2693 $linkback .= '</li>
';
2694 $linkback .= '<li
class=
"noborder litext">
';
2695 $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').'">
';
2696 $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek
', 'class=
"pictoactionview pictofixedwidth"');
2697 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewWeek").'</span>
';
2698 $linkback .= '</a>
';
2699 $linkback .= '</li>
';
2700 $linkback .= '<li
class=
"noborder litext">
';
2701 $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').'">
';
2702 $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday
', 'class=
"pictoactionview pictofixedwidth"');
2703 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewDay").'</span>
';
2704 $linkback .= '</a>
';
2705 $linkback .= '</li>
';
2706 $linkback .= '<li
class=
"noborder litext">
';
2707 $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').'">
';
2708 $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser
', 'class=
"pictoactionview pictofixedwidth"');
2709 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewPerUser").'</span>
';
2710 $linkback .= '</a>
';
2712 // Add more views from hooks
2714 $reshook = $hookmanager->executeHooks('addCalendarView
', $parameters, $object, $action);
2715 if (empty($reshook)) {
2716 $linkback .= $hookmanager->resPrint;
2717 } elseif ($reshook > 1) {
2718 $linkback = $hookmanager->resPrint;
2723 $morehtmlref = '<div
class=
"refidno">
';
2725 //$morehtmlref.='<br>
'.$langs->trans('ThirdParty
') . ' :
' . $object->thirdparty->getNomUrl(1);
2727 if (isModEnabled('project
')) {
2728 $langs->load("projects");
2729 //$morehtmlref .= '<br>
';
2730 if ($usercancreate) {
2731 $morehtmlref .= img_picto($langs->trans("Project"), 'project
', 'class=
"pictofixedwidth"');
2732 if ($action != 'classify
') {
2733 $morehtmlref .= '<a class=
"editfielda" href=
"'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">
'.img_edit($langs->transnoentitiesnoconv('SetProject
')).'</a>
';
2735 $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
');
2737 if (!empty($object->fk_project)) {
2738 $proj = new Project($db);
2739 $proj->fetch($object->fk_project);
2740 $morehtmlref .= $proj->getNomUrl(1);
2742 $morehtmlref .= '<span class=
"opacitymedium"> -
'.dol_escape_htmltag($proj->title).'</span>
';
2747 $morehtmlref .= '</div>
';
2750 dol_banner_tab($object, 'id
', $linkback, ($user->socid ? 0 : 1), 'id
', 'ref', $morehtmlref);
2752 print '<div class=
"fichecenter">
';
2753 print '<div class=
"fichehalfleft">
';
2755 print '<div class=
"underbanner clearboth"></div>
';
2757 // Show event in view mode
2758 print '<
table class=
"border tableforfield centpercent">
';
2761 if (getDolGlobalString('AGENDA_USE_EVENT_TYPE
')) {
2762 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("Type").'</td><td>
';
2763 $labeltype = ($langs->transnoentities("Action".$object->type_code) != "Action".$object->type_code) ? $langs->transnoentities("Action".$object->type_code) : $object->type_label;
2764 $labeltoshow = $labeltype;
2765 if ($object->code) {
2766 $labeltoshow .= ' (
'.$object->code.')
';
2768 print $object->getTypePicto('pictofixedwidth paddingright
', $labeltoshow);
2774 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("EventOnFullDay").'</td><td>
'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>
';
2777 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2782 print '<tr><td>
'.$langs->trans("DateActionStart").'</td><td title=
"'.dol_print_date($object->datep, 'dayhoursec', 'tzuserrel').'">
';
2783 // Test a date before the 27 march and one after
2784 //print dol_print_date($object->datep, 'dayhour
', 'gmt
');
2785 //print dol_print_date($object->datep, 'dayhour
', 'tzuser
');
2786 //print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2787 if (empty($object->fulldayevent)) {
2788 print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2790 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2791 print dol_print_date($object->datep, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2793 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2794 print img_warning($langs->trans("Late"));
2800 print '<tr><td>
'.$langs->trans("DateActionEnd").'</td><td title=
"'.dol_print_date($object->datef, 'dayhoursec', 'tzuserrel').'">
';
2801 if (empty($object->fulldayevent)) {
2802 print dol_print_date($object->datef, 'dayhour
', 'tzuserrel
');
2804 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2805 print dol_print_date($object->datef, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2807 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2808 print img_warning($langs->trans("Late"));
2812 // Recurring event (into a series)
2813 if ($object->recurid) {
2814 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("RecurringEvent").'</td><td>
';
2815 print img_picto($langs->trans("EventPartOfARecurringSerie", $object->recurid), 'recurring
', 'class=
"pictofixedwidth"');
2817 if (preg_match('/FREQ=MONTHLY_BYMONTHDAY(\d+)/
', $object->recurrule, $reg)) {
2818 print $langs->trans("EveryMonth").' <span class=
"opacitymedium small">(
'.$langs->trans("DayOfMonth").' '.$reg[1].' -
'.$langs->trans("Until").' '.dol_print_date($object->recurdateend, 'day
').')</span>
';
2820 if (preg_match('/FREQ=YEARLY_BYYEARMONTHDAY(\d+)/
', $object->recurrule, $reg)) {
2821 print $langs->trans("EveryYear").' <span class=
"opacitymedium small">(
'.$langs->trans("DayOfYear").' '.$reg[1].' -
'.$langs->trans("Until").' '.dol_print_date($object->recurdateend, 'day
').')</span>
';
2827 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2828 print '<tr><td>
'.$langs->trans("Location").'</td><td>
'.$object->location.'</td></tr>
';
2832 print '<tr><td class=
"nowrap">
'.$langs->trans("ActionAssignedTo").'</td><td>
';
2834 if (empty($donotclearsession)) {
2835 if ($object->userownerid > 0) {
2836 $listofuserid[$object->userownerid] = array(
2837 'id
' => $object->userownerid,
2838 'transparency
' => $object->transparency, // Force transparency on owner from property of event
2839 'answer_status
' => $object->userassigned[$object->userownerid]['answer_status
'],
2840 'mandatory
' => $object->userassigned[$object->userownerid]['mandatory
']
2843 if (!empty($object->userassigned)) { // Now concat assigned users
2844 // Restore array with key with same value than param 'id
'
2845 $tmplist1 = $object->userassigned;
2846 foreach ($tmplist1 as $key => $val) {
2847 if ($val['id
'] && $val['id
'] != $object->userownerid) {
2848 $listofuserid[$val['id
']] = $val;
2852 $_SESSION[$sessionkeyassignedtouser] = json_encode($listofuserid);
2854 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
2855 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser], true);
2859 $listofcontactid = []; // not used yet
2860 $listofotherid = []; // not used yet
2861 print '<div class=
"assignedtouser">
';
2862 print $form->select_dolusers_forevent('view
', 'assignedtouser
', 1, [], 0, '', [], '0
', 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2865 if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
2867 print '<div class=
"myavailability">
';
2868 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
2872 print ' </td></tr>
';
2875 if (isModEnabled('category
')) {
2876 print '<tr><td class=
"valignmiddle">
'.$langs->trans("Categories").'</td><td>
';
2877 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2885 print '<div class=
"fichehalfright">
';
2887 print '<div class=
"underbanner clearboth"></div>
';
2888 print '<
table class=
"border tableforfield centpercent">
';
2890 if (isModEnabled("societe")) {
2892 print '<tr><td class=
"titlefield">
'.$langs->trans("ActionOnCompany").'</td>
';
2893 print '<td>
'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : ('<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
'));
2894 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL
') {
2895 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2896 print "<br>".dol_print_phone($object->thirdparty->phone);
2902 print '<tr><td>
'.$langs->trans("ActionOnContact").'</td>
';
2905 if (!empty($object->socpeopleassigned)) {
2906 foreach ($object->socpeopleassigned as $cid => $Tab) {
2907 $contact = new Contact($db);
2908 $result = $contact->fetch($cid);
2911 dol_print_error($db, $contact->error);
2915 print $contact->getNomUrl(1);
2916 if ($object->type_code == 'AC_TEL
') {
2917 if (!empty($contact->phone_pro)) {
2918 print '(
'.dol_print_phone($contact->phone_pro).')
';
2921 print '<div class=
"paddingright"></div>
';
2925 print '<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
';
2931 if (getDolGlobalString('AGENDA_SUPPORT_PRIORITY_IN_EVENTS
')) {
2932 print '<tr><td class=
"nowrap" class=
"titlefield">
' . $langs->trans("Priority") . '</td><td>
';
2933 print($object->priority ? $object->priority : '');
2937 // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
2938 // for such objects because there is already a dedicated field into table llx_actioncomm.
2939 if (!empty($object->elementid) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe
', 'contact
', 'project
'))) {
2940 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
2941 print '<tr><td>
'.$langs->trans("LinkedObject").'</td>
';
2942 $link = dolGetElementUrl($object->elementid, $object->elementtype, ($object->elementtype == 'user' ? -1 : 1));
2945 print '<span class=
"opacitymedium">
'.$langs->trans("ObjectDeleted").'</span>
';
2953 if (!empty($object->email_msgid)) {
2954 print '<tr><td>
'.$langs->trans('MailTopic
').'</td>
';
2955 print '<td>
'.dol_escape_htmltag($object->email_subject).'</td></tr>
';
2956 print '<tr><td>
'.$langs->trans('MailFrom
').'</td>
';
2957 print '<td>
'.dol_escape_htmltag($object->email_from).'</td></tr>
';
2958 print '<tr><td>
'.$langs->trans('MailTo
').'</td>
';
2959 print '<td>
'.dol_escape_htmltag($object->email_to).'</td></tr>
';
2960 if (!empty($object->email_tocc)) {
2961 print '<tr><td>
'.$langs->trans('MailCC
').'</td>
';
2962 print '<td>
'.dol_escape_htmltag($object->email_tocc).'</td></tr>
';
2967 print '<tr><td class=
"tdtop">
'.$langs->trans("Description").'</td><td class=
"wordbreak sensiblehtmlcontent">
';
2968 print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
2972 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php
';
2975 if ($enablereminders) {
2976 $filteruserid = $user->id;
2977 if ($user->hasRight('agenda
', 'allactions
', 'read
')) {
2980 $object->loadReminders('', $filteruserid, false);
2982 print '<tr><td class=
"titlefieldcreate nowrap">
'.$langs->trans("Reminders").'</td><td>
';
2984 if (count($object->reminders) > 0) {
2985 $tmpuserstatic = new User($db);
2987 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2988 print $TRemindTypes[$actioncommreminder->typeremind]['label
'];
2989 if ($actioncommreminder->fk_user > 0) {
2990 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2991 print ' (
'.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')
';
2993 print ' -
'.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit];
2995 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2996 print ' - <span class=
"opacitymedium">
';
2997 print $langs->trans("NotSent");
2999 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
3000 print ' - <span class=
"opacitymedium">
';
3001 print $langs->trans("Done");
3003 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
3004 print ' - <span class=
"opacitymedium">
';
3005 print $form->textwithpicto($langs->trans("Error"), $actioncommreminder->lasterror);
3019 print '<div class=
"clearboth"></div>
';
3021 print dol_get_fiche_end();
3028 print '<div class=
"tabsAction">
';
3031 $reshook = $hookmanager->executeHooks('addMoreActionsButtons
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
3032 if (empty($reshook)) {
3033 if ($action != 'edit
') {
3034 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
3035 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
3036 print '<div class=
"inline-block divButAction"><a class=
"butAction" href=
"card.php?action=edit&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Modify").'</a></div>
';
3038 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Modify").'</a></div>
';
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 butActionClone" href=
"card.php?action=clone&object='.$object->element.'&id='.$object->id.'">
'.$langs->trans("ToClone").'</a></div>
';
3045 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("ToClone").'</a></div>
';
3048 if ($usercandelete) {
3049 print '<div class=
"inline-block divButAction"><a class=
"butActionDelete" href=
"card.php?action=delete&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Delete").'</a></div>
';
3051 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Delete").'</a></div>
';
3058 if ($action != 'edit
') {
3059 if (!getDolGlobalString('AGENDA_DISABLE_BUILDDOC
')) {
3060 print '<div class=
"clearboth"></div><div class=
"fichecenter"><div class=
"fichehalfleft">
';
3061 print '<a
name=
"builddoc"></a>
'; // ancre
3063 // Generated documents
3064 $filedir = $conf->agenda->multidir_output[$conf->entity].'/
'.$object->id;
3065 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
3067 $genallowed = $user->hasRight('agenda
', 'myactions
', 'read
');
3068 $delallowed = $user->hasRight('agenda
', 'myactions
', 'create
');
3070 print $formfile->showdocuments('actions
', (string) $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang());
3072 if (getDolGlobalString('AGENDA_ENABLE_LINKED_ELEMENTS
')) {
3073 // Show links to link elements
3074 $tmparray = $form->showLinkToObjectBlock($object, [], array('myobject
'), 1);
3075 if (is_array($tmparray)) {
3076 $linktoelem = $tmparray['linktoelem
'];
3077 $htmltoenteralink = $tmparray['htmltoenteralink
'];
3078 print $htmltoenteralink;
3079 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
3081 // backward compatibility
3082 $somethingshown = $form->showLinkedObjectBlock($object, $tmparray);
3085 print '</div><div class=
"fichehalfright">
';
3087 print '</div></div>
';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
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.
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)
Add a delay to a date.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.
treeview li table
No Email.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
$conf db user
Active Directory does not allow anonymous connections.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
$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, $mode=0)
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.