35require
'../../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.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;
137$form =
new Form($db);
142if ($id > 0 && $action !=
'add') {
146 $ret =
$object->fetch_optionals();
147 $ret1 =
$object->fetch_userassigned();
149 if ($ret < 0 || $ret1 < 0) {
155$extrafields->fetch_name_optionals_label(
$object->table_element);
157if (empty($action) && empty(
$object->id)) {
162$hookmanager->initHooks([
'actioncard',
'globalcard']);
166 $TRemindTypes[
'browser'] = [
167 'label' => $langs->trans(
'BrowserPush'),
169 'type' => ActionCommReminder::TYPE_USER,
170 'data-html' =>
img_picto(
'',
'globe',
'class="pictofixedwidth"') . $langs->trans(
'BrowserPush'),
174 $TRemindTypes[
'email'] = [
175 'label' => $langs->trans(
'EMail'),
177 'type' => ActionCommReminder::TYPE_USER,
178 'data-html' =>
img_picto(
'',
'email',
'class="pictofixedwidth"') . $langs->trans(
'EMail'),
183 $TRemindTypes[
'sms'] = [
184 'label' => $langs->trans(
'Sms'),
186 'type' => ActionCommReminder::TYPE_USER,
187 'data-html' =>
img_picto(
'',
'phoning_mobile',
'class="pictofixedwidth"') . $langs->trans(
'Sms'),
190$TDurationTypes = $form->getDurationTypes($langs);
191$TDurationTypesExcluded = [
'y',
'm',
's'];
195 'TRemindTypes' => &$TRemindTypes,
196 'enablereminders' => &$enablereminders,
197 'TDurationTypes' => &$TDurationTypes,
198 'TDurationTypesExcluded' => &$TDurationTypesExcluded,
200$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
205$result =
restrictedArea($user,
'agenda', $object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
207$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || ((empty(
$object->id) ||
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
208$usercandelete = $user->hasRight(
'agenda',
'allactions',
'delete') || ((
$object->authorid === $user->id ||
$object->userownerid === $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'));
215$listUserAssignedUpdated =
false;
216$listResourceAssignedUpdated =
false;
220if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
221 $idtoremove =
GETPOST(
'removedassigned');
223 if (!empty($_SESSION[
'assignedtouser'])) {
224 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'],
true);
226 $tmpassigneduserids = [];
229 foreach ($tmpassigneduserids as $key => $val) {
230 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
231 unset($tmpassigneduserids[$key]);
235 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
236 $donotclearsession = 1;
237 if ($action ==
'add') {
240 if ($action ==
'update') {
244 $listUserAssignedUpdated =
true;
247if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
248 $idtoremove =
GETPOST(
'removedassignedresource');
250 if (!empty($_SESSION[
'assignedtoresource'])) {
251 $tmpassignedresourceids = json_decode($_SESSION[
'assignedtoresource'],
true);
253 $tmpassignedresourceids = [];
256 foreach ($tmpassignedresourceids as $key => $val) {
257 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
258 unset($tmpassignedresourceids[$key]);
262 $_SESSION[
'assignedtoresource'] = json_encode($tmpassignedresourceids);
264 if ($action ==
'add' && $usercancreate) {
267 if ($action ==
'update' && $usercancreate) {
271 $listResourceAssignedUpdated =
true;
275if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
277 if (
GETPOST(
'assignedtouser') > 0) {
278 $assignedtouser = [];
279 if (!empty($_SESSION[
'assignedtouser'])) {
280 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
282 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id' =>
GETPOSTINT(
'assignedtouser'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
283 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
285 $donotclearsession = 1;
286 if ($action ==
'add' && $usercancreate) {
289 if ($action ==
'update' && $usercancreate) {
293 $listUserAssignedUpdated =
true;
297if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
299 if (
GETPOST(
'assignedtoresource') > 0) {
300 $assignedtoresource = [];
301 if (!empty($_SESSION[
'assignedtoresource'])) {
302 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
304 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id' =>
GETPOSTINT(
'assignedtoresource'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
305 $_SESSION[
'assignedtoresource'] = json_encode($assignedtoresource);
307 $donotclearsession = 1;
308 if ($action ==
'add' && $usercancreate) {
311 if ($action ==
'update' && $usercancreate) {
315 $listResourceAssignedUpdated =
true;
319if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
320 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
326if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
328 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
333 if (!empty(
$object->socpeopleassigned)) {
334 reset(
$object->socpeopleassigned);
339 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
350if (empty($reshook) && $action ==
'add' && $usercancreate) {
353 if (empty($backtopage)) {
355 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
357 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
361 if (!empty($socpeopleassigned[0])) {
362 $result = $contact->fetch($socpeopleassigned[0]);
366 header(
"Location: ".$backtopage);
370 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
383 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
386 if (!$datef && $percentage == 100) {
388 $donotclearsession = 1;
390 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
395 $donotclearsession = 1;
397 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
401 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
403 $donotclearsession = 1;
405 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
410 $listofresourceid = [];
415 $object->fulldayevent = ($fulldayevent ? 1 : 0);
419 if (
GETPOST(
"elementtype",
'alpha')) {
421 $modulecodetouseforpermissioncheck = $elProp[
'module'];
423 if ($modulecodetouseforpermissioncheck ==
'productbatch') {
424 $modulecodetouseforpermissioncheck =
'produit';
426 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
428 $hasPermissionOnLinkedObject = 0;
429 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
430 $hasPermissionOnLinkedObject = 1;
431 } elseif ($user->hasRight($modulecodetouseforpermissioncheck, $submodulecodetouseforpermissioncheck,
'read')) {
432 $hasPermissionOnLinkedObject = 1;
435 if ($hasPermissionOnLinkedObject) {
443 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
444 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
446 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
447 $object->label = $langs->transnoentitiesnoconv(
"Action".
$object->type_code).
"\n";
449 $cactioncomm->fetch(
$object->type_code);
450 $object->label = $cactioncomm->label;
457 if (!empty($taskid)) {
458 $taskProject =
new Task($db);
459 if ($taskProject->fetch($taskid) > 0) {
460 $object->fk_project = $taskProject->fk_project;
465 $object->elementtype =
'project_task';
470 $object->percentage = $percentage;
473 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
476 if (!empty($_SESSION[
'assignedtouser'])) {
477 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
480 if (!empty($_SESSION[
'assignedtoresource'])) {
481 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
485 foreach ($listofuserid as $key => $value) {
487 if ($value[
'id'] > 0) {
488 $object->userownerid = $value[
'id'];
490 $object->transparency = $transparency;
493 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
501 if (GETPOSTISSET(
"contactid")) {
512 if (empty(
$object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
514 $donotclearsession = 1;
516 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
518 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
520 $donotclearsession = 1;
522 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
527 $donotclearsession = 1;
529 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
532 foreach ($socpeopleassigned as $cid) {
533 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
535 if (!empty(
$object->socpeopleassigned)) {
536 reset(
$object->socpeopleassigned);
541 $ret = $extrafields->setOptionalsFromPost(
null, $object);
544 $donotclearsession = 1;
556 $selectedrecurrulefreq =
'no';
557 $selectedrecurrulebyyearmonthday =
'';
558 $selectedrecurrulebymonthday =
'';
559 $selectedrecurrulebyday =
'';
560 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
561 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'YEARLY') ?
"_BYYEARMONTHDAY".((
int) $dayinyear) :
"";
562 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY') ?
"_BYMONTHDAY".((
int) $dayinmonth) :
"";
563 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY') ?
"_BYDAY".((
int) $dayinweek) :
"";
569 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
570 $selectedrecurrulefreq = $reg1[1];
572 if (
$object->recurrule && preg_match(
'/FREQ=YEARLY.*BYYEARMONTHDAY(\d+)/i',
$object->recurrule, $reg4)) {
573 $selectedrecurrulebyyearmonthday = (int) $reg4[1];
575 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
576 $selectedrecurrulebymonthday = (int) $reg2[1];
578 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
579 $selectedrecurrulebyday = (int) $reg3[1];
583 $eventisrecurring = 0;
584 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
585 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
586 $eventisrecurring = 1;
596 $idaction =
$object->create($user);
601 if (is_array($listofresourceid) && count($listofresourceid)) {
602 foreach ($listofresourceid as $resource_id => $val) {
603 $resource_type =
'dolresource';
608 $eventDateStart =
$object->datep;
609 $eventDateEnd =
$object->datef;
610 $isFullDayEvent =
$object->fulldayevent;
611 if (empty($eventDateEnd)) {
612 if ($isFullDayEvent) {
614 $eventDateStart =
dol_mktime(0, 0, 0, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
615 $eventDateEnd =
dol_mktime(23, 59, 59, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
619 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
620 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_resources as er";
621 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) .
"'";
622 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape(
$object->element) .
"'";
623 $sql .=
" WHERE er.resource_id = " . ((int) $resource_id);
624 $sql .=
" AND er.busy = 1";
628 $sql .=
" (ac.datep <= '" . $db->idate($eventDateStart) .
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) .
"'))";
630 if (!empty($eventDateEnd)) {
631 $sql .=
" OR (ac.datep <= '" . $db->idate($eventDateEnd) .
"' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) .
"'))";
635 $sql .=
"ac.datep >= '" . $db->idate($eventDateStart) .
"'";
636 if (!empty($eventDateEnd)) {
637 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) .
"')";
642 $resql = $db->query($sql);
645 $object->error = $db->lasterror();
648 if ($db->num_rows($resql) > 0) {
651 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse') .
' : ';
652 while ($obj = $db->fetch_object($resql)) {
653 $object->error .=
'<br> - ' . $langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label .
' [' . $obj->ac_id .
']');
664 $res =
$object->add_element_resource($resource_id, $resource_type, $busy, $val[
'mandatory']);
669 unset($_SESSION[
'assignedtoresource']);
674 $categories =
GETPOST(
'categories',
'array');
675 $object->setCategories($categories);
678 unset($_SESSION[
'assignedtouser']);
680 if ($user->id !=
$object->userownerid) {
681 $moreparam =
"filtert=-1";
685 if (!$error && $addreminder ==
'on') {
690 $actionCommReminder->dateremind = $dateremind;
691 $actionCommReminder->typeremind = $remindertype;
692 $actionCommReminder->offsetunit = $offsetunit;
693 $actionCommReminder->offsetvalue = $offsetvalue;
694 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
695 $actionCommReminder->fk_actioncomm =
$object->id;
696 if ($remindertype ==
'email') {
697 $actionCommReminder->fk_email_template = $modelmail;
701 foreach (
$object->userassigned as $userassigned) {
702 $actionCommReminder->fk_user = $userassigned[
'id'];
703 $res = $actionCommReminder->create($user);
707 $langs->load(
"errors");
709 setEventMessages($langs->trans(
'ErrorReminderActionCommCreation'),
null,
'errors');
711 $donotclearsession = 1;
722 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
735 $langs->load(
"errors");
739 $donotclearsession = 1;
745 $donotclearsession = 1;
749 if (!$error && $eventisrecurring) {
754 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
756 $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');
761 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
762 $firstday = $selectedrecurrulebymonthday;
769 } elseif ($selectedrecurrulefreq ==
'YEARLY' && !empty($selectedrecurrulebyyearmonthday)) {
784 while ($datep <= $repeateventlimitdate && !$error) {
788 $finalobject->datep = $datep;
789 $finalobject->datef = $datef;
791 $idaction = $finalobject->create($user);
794 if (!$finalobject->error) {
796 $categories =
GETPOST(
'categories',
'array');
797 $finalobject->setCategories($categories);
799 unset($_SESSION[
'assignedtouser']);
802 if ($user->id != $finalobject->userownerid) {
803 $moreparam =
"filtert=-1";
807 if ($addreminder ==
'on') {
812 $actionCommReminder->dateremind = $dateremind;
813 $actionCommReminder->typeremind = $remindertype;
814 $actionCommReminder->offsetunit = $offsetunit;
815 $actionCommReminder->offsetvalue = $offsetvalue;
816 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
817 $actionCommReminder->fk_actioncomm = $finalobject->id;
818 if ($remindertype ==
'email') {
819 $actionCommReminder->fk_email_template = $modelmail;
823 foreach ($finalobject->userassigned as $userassigned) {
824 $actionCommReminder->fk_user = $userassigned[
'id'];
825 $res = $actionCommReminder->create($user);
830 $langs->load(
"errors");
831 setEventMessages($langs->trans(
'ErrorReminderActionCommCreation'),
null,
'errors');
833 $donotclearsession = 1;
844 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
848 $langs->load(
"errors");
849 $error = $langs->trans($finalobject->error);
852 $donotclearsession = 1;
858 $donotclearsession = 1;
862 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
882 if (!empty($backtopage) && !$error) {
883 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
884 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
885 } elseif ($idaction) {
886 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
888 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
895if (empty($reshook) && $action ==
'update' && $usercancreate) {
896 if (empty($cancel)) {
897 $fulldayevent =
GETPOST(
'fullday');
902 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
930 if (!GETPOSTISSET(
'ap') && !GETPOSTISSET(
'aphour') && !GETPOSTISSET(
'apmin')) {
935 if (!GETPOSTISSET(
'p2') && !GETPOSTISSET(
'p2hour') && !GETPOSTISSET(
'p2min')) {
943 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
945 if (
$object->elementtype ==
'ticket') {
947 if (
$object->code ==
'TICKET_MSG') {
948 $object->code =
'TICKET_MSG_PRIVATE';
950 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
951 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
954 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
957 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
958 $object->code =
'TICKET_MSG_SENTBYMAIL';
970 $object->percentage = $percentage;
975 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
976 $object->socpeopleassigned = [];
977 foreach ($socpeopleassigned as $cid) {
978 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
981 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
982 reset(
$object->socpeopleassigned);
987 if (!empty($taskid)) {
988 $taskProject =
new Task($db);
989 if ($taskProject->fetch($taskid) > 0) {
990 $object->fk_project = $taskProject->fk_project;
995 $object->elementtype =
'project_task';
1000 if (
GETPOST(
"elementtype",
'alpha')) {
1002 $modulecodetouseforpermissioncheck = $elProp[
'module'];
1004 if ($modulecodetouseforpermissioncheck ==
'productbatch') {
1005 $modulecodetouseforpermissioncheck =
'produit';
1008 $hasPermissionOnLinkedObject = 0;
1009 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
1010 $hasPermissionOnLinkedObject = 1;
1012 if ($hasPermissionOnLinkedObject) {
1020 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
1024 if (!empty($_SESSION[
'assignedtouser'])) {
1026 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
1027 foreach ($tmplist1 as $key => $val) {
1028 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
1029 $listofuserid[$val[
'id']] = $val;
1033 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
1034 if ($assignedtouser) {
1035 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
1041 foreach ($listofuserid as $key => $val) {
1043 $object->userownerid = $val[
'id'];
1045 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
1049 $object->transparency = $transparency;
1053 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
1055 $donotclearsession = 1;
1057 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1059 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
1061 if (empty(
$object->userownerid)) {
1063 $donotclearsession = 1;
1065 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
1069 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
1077 $eventDateStart =
$object->datep;
1078 $eventDateEnd =
$object->datef;
1080 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1081 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1082 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1083 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1084 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1085 $sql .=
" AND er.resource_id IN (";
1086 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1087 $sql .=
" WHERE element_id = ".((int)
$object->id);
1088 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1089 $sql .=
" AND busy = 1";
1091 $sql .=
" AND er.busy = 1";
1095 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1097 if (!empty($eventDateEnd)) {
1098 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1102 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1103 if (!empty($eventDateEnd)) {
1104 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1109 $resql = $db->query($sql);
1112 $object->error = $db->lasterror();
1115 if ($db->num_rows($resql) > 0) {
1118 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1119 while ($obj = $db->fetch_object($resql)) {
1120 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1136 $result =
$object->update($user);
1140 $categories =
GETPOST(
'categories',
'array');
1141 $object->setCategories($categories);
1143 $object->loadReminders($remindertype, 0,
false);
1146 if (!empty(
$object->reminders)) {
1147 foreach (
$object->reminders as $reminder) {
1148 if ($reminder->status < 1) {
1149 $reminder->delete($user);
1156 if ($addreminder ==
'on') {
1161 $actionCommReminder->dateremind = $dateremind;
1162 $actionCommReminder->typeremind = $remindertype;
1163 $actionCommReminder->offsetunit = $offsetunit;
1164 $actionCommReminder->offsetvalue = $offsetvalue;
1165 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
1166 $actionCommReminder->fk_actioncomm =
$object->id;
1167 if ($remindertype ==
'email') {
1168 $actionCommReminder->fk_email_template = $modelmail;
1172 foreach (
$object->userassigned as $userassigned) {
1173 $actionCommReminder->fk_user = $userassigned[
'id'];
1177 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1178 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".$db->escape($remindertype).
"'";
1179 $resqldelete = $db->query($sqldelete);
1181 $res = $actionCommReminder->create($user);
1185 $langs->load(
"errors");
1186 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1189 $donotclearsession = 1;
1196 unset($_SESSION[
'assignedtouser']);
1197 unset($_SESSION[
'assignedtoresource']);
1212 if (!empty($backtopage)) {
1213 unset($_SESSION[
'assignedtouser']);
1214 header(
"Location: ".$backtopage);
1221if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes' && $usercandelete) {
1224 $object->fetch_userassigned();
1227 $result =
$object->delete($user);
1230 header(
"Location: index.php");
1241if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate' && $usercancreate) {
1247 $newdate =
GETPOST(
'newdate',
'alpha');
1248 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1249 header(
"Location: ".$backtopage,
true, 307);
1253 $datep =
dol_mktime($shour, $smin, 0, (
int) substr($newdate, 13, 2), (
int) substr($newdate, 15, 2), (
int) substr($newdate, 9, 4),
'tzuserrel');
1256 if ($datep !=
$object->datep) {
1265 $eventDateStart =
$object->datep;
1266 $eventDateEnd =
$object->datef;
1268 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1269 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1270 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1271 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1272 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1273 $sql .=
" AND er.resource_id IN (";
1274 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1275 $sql .=
" WHERE element_id = ".((int)
$object->id);
1276 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1277 $sql .=
" AND busy = 1";
1279 $sql .=
" AND er.busy = 1";
1283 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1285 if (!empty($eventDateEnd)) {
1286 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1290 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1291 if (!empty($eventDateEnd)) {
1292 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1297 $resql = $db->query($sql);
1300 $object->error = $db->lasterror();
1303 if ($db->num_rows($resql) > 0) {
1306 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1307 while ($obj = $db->fetch_object($resql)) {
1308 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1323 $result =
$object->update($user);
1333 if (!empty($backtopage)) {
1334 header(
"Location: ".$backtopage,
true, 307);
1343$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1344if (empty($reshook)) {
1345 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1353$form =
new Form($db);
1356$arrayrecurrulefreq = array(
1357 'no' => $langs->trans(
"OnceOnly"),
1358 'YEARLY' => $langs->trans(
"EveryYear"),
1359 'MONTHLY' => $langs->trans(
"EveryMonth"),
1360 'WEEKLY' => $langs->trans(
"EveryWeek")
1365$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1366llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1368if ($action ==
'create') {
1371 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1372 if (!empty($socpeopleassigned[0])) {
1373 $result = $contact->fetch($socpeopleassigned[0]);
1381 if (!empty($conf->use_javascript_ajax)) {
1382 print
"\n".
'<script type="text/javascript">';
1383 print
'$(document).ready(function () {
1384 function setdatefields()
1386 if ($("#fullday:checked").val() == null) {
1387 $(".fulldaystarthour").removeAttr("disabled");
1388 $(".fulldaystartmin").removeAttr("disabled");
1389 $(".fulldayendhour").removeAttr("disabled");
1390 $(".fulldayendmin").removeAttr("disabled");
1391 $("#p2").removeAttr("disabled");
1393 $(".fulldaystarthour").prop("disabled", true).val("00");
1394 $(".fulldaystartmin").prop("disabled", true).val("00");
1395 $(".fulldayendhour").prop("disabled", true).val("23");
1396 $(".fulldayendmin").prop("disabled", true).val("59");
1397 $("#p2").removeAttr("disabled");
1400 $("#fullday").change(function() {
1401 console.log("setdatefields");
1404 var old_startdate = null;
1405 $("#ap").focus(function() {
1406 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1408 $("#ap").next(".ui-datepicker-trigger").click(function() {
1409 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1411 $("#ap").change(function() {
1412 setTimeout(function() {
1413 if ($("#p2").val() !== "") {
1414 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1415 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1416 if (new_startdate > old_enddate) {
1417 var timeDiff = old_enddate - old_startdate;
1418 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1419 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1420 $("#p2day").val(new_enddate.getDate());
1421 $("#p2month").val(new_enddate.getMonth() + 1);
1422 $("#p2year").val(new_enddate.getFullYear());
1427 $("#actioncode").change(function() {
1428 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1429 else $("#dateend").removeClass("fieldrequired");
1431 $("#aphour,#apmin").change(function() {
1432 if ($("#actioncode").val() == \'AC_RDV\') {
1433 var oldhour = parseInt($("#aphour").val());
1434 var oldmin = parseInt($("#apmin").val());
1435 var oldday = parseInt($("#apday").val());
1436 var oldmonth = $("#apmonth").val();
1437 var oldyear = $("#apyear").val();
1439 var newhour = oldhour + 1;
1440 var newday = oldday;
1441 var newmonth = oldmonth;
1442 var newyear = oldyear;
1443 if (newhour >= 24) {
1445 newday = oldday + 1;
1447 console.log("Start date was changed, we modify end date "+oldhour+" "+oldmin+" -> "+newhour+" "+oldmin);
1448 $("#p2hour").val(("00" + newhour).substr(-2,2));
1449 $("#p2min").val(("00" + oldmin).substr(-2,2));
1450 $("#p2day").val(newday);
1451 $("#p2month").val(newmonth);
1452 $("#p2year").val(newyear);
1453 $("#p2").val($("#ap").val());
1456 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1457 else $("#dateend").removeClass("fieldrequired");
1460 print
'</script>'.
"\n";
1463 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1464 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1465 print
'<input type="hidden" name="action" value="add">';
1466 print
'<input type="hidden" name="donotclearsession" value="1">';
1467 print
'<input type="hidden" name="page_y" value="">';
1469 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1472 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1479 print
'<div class="divcreate">';
1480 print
'<table class="border centpercent nobottom">';
1483 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>';
1487 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1489 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1490 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1491 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1496 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1497 print
'<td class="valignmiddle height30">';
1499 print
'<input class="valignmiddle" type="checkbox" id="fullday" name="fullday" '.(GETPOST(
'fullday') ?
' checked' :
'').
'><label for="fullday" class="valignmiddle small">'.$langs->trans(
"EventOnFullDay").
'</label>';
1503 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1504 if (
GETPOST(
'datep',
'alpha', 1)) {
1507 $datef = ($datef ? $datef :
$object->datef);
1508 if (
GETPOST(
'datef',
'alpha', 1)) {
1511 if (empty($datef) && !empty($datep)) {
1518 print
'<tr><td class="nowrap">';
1520 print
'<div class="inline-block">';
1522 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1524 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1526 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1527 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1533 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
1534 if ($userepeatevent) {
1536 print
'<div class="clearbothonsmartphone hideonsmartphone inline-block"> </div>';
1539 print
'<div class="inline-block small" data-html="repeat">';
1540 print
'<span class="opacitymedium">';
1541 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 3px" class="paddingright"');
1542 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1544 $selectedrecurrulefreq =
'no';
1545 $selectedrecurrulebyyearmonthday =
'';
1546 $selectedrecurrulebymonthday =
'';
1547 $selectedrecurrulebyday =
'';
1548 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1549 $object->recurrule .= GETPOSTISSET(
'BYYEARMONTHDAY') ?
"_BYYEARMONTHDAY".GETPOST(
'BYYEARMONTHDAY',
'alpha') :
"";
1550 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1551 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1555 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1556 $selectedrecurrulefreq = $reg[1];
1558 if (
$object->recurrule && preg_match(
'/FREQ=YEARLY.*BYYEARMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1559 $selectedrecurrulebyyearmonthday = (int) $reg[1];
1561 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1562 $selectedrecurrulebymonthday = (int) $reg[1];
1564 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1565 $selectedrecurrulebyday = (int) $reg[1];
1568 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly minwidth125 maxwidth150');
1586 $repeateventlimitdate = empty($repeateventlimitdate) ? (
dol_now() + ((24 * 3600 * 365) + 1)) : $repeateventlimitdate;
1588 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1589 print $langs->trans(
"Until").
" ";
1590 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1593 <script
type=
"text/javascript">
1594 jQuery(document).ready(
function() {
1595 function init_repeat() {
1596 console.log(
"recurrule: " +
"<?php echo $object->recurrule; ?>");
1597 console.log(
"reg1: " +
"<?php echo $selectedrecurrulefreq; ?>");
1598 console.log(
"reg2: " +
"<?php echo $selectedrecurrulebymonthday; ?>");
1599 console.log(
"reg3: " +
"<?php echo $selectedrecurrulebyday; ?>");
1600 console.log(
"reg4: " +
"<?php echo $selectedrecurrulebyyearmonthday; ?>");
1601 console.log(
"selectedrulefreq: " +
"<?php echo $selectedrecurrulefreq; ?>");
1602 if (jQuery(
"#recurrulefreq").val() ==
'YEARLY') {
1604 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1605 jQuery(
".repeateventBYMONTHDAY").hide();
1606 jQuery(
".repeateventBYDAY").hide();
1607 }
else if (jQuery(
"#recurrulefreq").val() ==
'MONTHLY') {
1609 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1610 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1611 jQuery(
".repeateventBYDAY").hide();
1612 }
else if (jQuery(
"#recurrulefreq").val() ==
'WEEKLY') {
1613 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1614 jQuery(
".repeateventBYMONTHDAY").hide();
1616 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1618 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1619 jQuery(
".repeateventBYMONTHDAY").hide();
1620 jQuery(
".repeateventBYDAY").hide();
1621 jQuery(
".repeateventlimitdate").hide();
1625 jQuery(
"#recurrulefreq").change(
function() {
1640 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Location").
'</td><td>';
1641 print
img_picto(
'',
'map-marker-alt',
'class="pictofixedwidth"');
1642 print
'<input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.(GETPOST(
'location') ?
GETPOST(
'location') :
$object->location).
'"></td></tr>';
1650 print
'<div class="divcreate">';
1651 print
'<table class="border centpercent nobottom">';
1654 print
'<tr><td class="nowrap titlefieldcreate"><span>';
1655 print $langs->trans(
"AssignedTo");
1656 print
'</span></td><td>';
1658 $listofcontactid = [];
1659 $listofotherid = [];
1661 if (empty($donotclearsession)) {
1663 if ($assignedtouser) {
1664 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1667 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1668 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1670 if (!empty($_SESSION[
'assignedtouser'])) {
1671 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1673 if (!is_array($listofuserid)) {
1676 $firstelem = reset($listofuserid);
1677 if (isset($listofuserid[$firstelem[
'id']])) {
1678 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1681 print
'<!-- list of user to assign -->'.
"\n";
1682 print
'<div class="assignedtouser">';
1683 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, [], 0,
'', [],
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid);
1689 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1691 $listofresourceid = [];
1692 if (empty($donotclearsession)) {
1693 $assignedtoresource =
GETPOST(
"assignedtoresource");
1694 if ($assignedtoresource) {
1695 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1697 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1699 if (!empty($_SESSION[
'assignedtoresource'])) {
1700 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1702 if (!is_array($listofresourceid)) {
1703 $listofresourceid = [];
1705 $firstelem = reset($listofresourceid);
1706 if ($firstelem && isset($listofresourceid[$firstelem[
'id']])) {
1707 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1710 print
'<div class="assignedtoresource">';
1711 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1, [], 0,
'', [],
'0', 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1718 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1719 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories', $object);
1729 print
'<div class="divcreate">';
1730 print
'<table class="border centpercent nobottom">';
1733 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td>';
1735 $percent = $complete !==
'' ? $complete : -1;
1736 if (GETPOSTISSET(
'status')) {
1738 } elseif (GETPOSTISSET(
'percentage')) {
1741 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1743 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1747 print $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'minwidth150 maxwidth300', 1);
1752 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1756 print $societe->getNomUrl(1);
1757 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1760 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1762 if (!empty($user->socid)) {
1763 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1765 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid',
'', $langs->trans(
'SelectThirdParty'), 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1771 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1772 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1776 if ($origin ==
'contact') {
1782 $select_contact_default = 0;
1784 $select_contact_default = -1;
1786 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
1788 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
1795 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1796 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, [],
'multiple',
'contactid');
1797 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1799 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, [],
'multiple',
'contactid');
1807 $langs->load(
"projects");
1811 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1812 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1813 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');
1815 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1816 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1817 $urloption =
'?action=create&donotclearsession=1';
1822 <script
type=
"text/javascript">
1823 $(document).ready(
function () {
1824 $(
"#projectid").change(
function () {
1825 var url =
"<?php echo DOL_URL_ROOT; ?>/projet/ajax/projects.php?mode=gettasks&socid="+$(
"#search_socid").val()+
"&projectid="+$(
"#projectid").val();
1826 console.log(
"Call url to get the new list of tasks: "+url);
1827 $.get(url,
function(data) {
1829 if (data) $(
"#taskid").html(data).select2();
1839 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1840 print
img_picto(
'',
'projecttask',
'class="pictofixedwidth"');
1841 $projectsListId =
'';
1842 if (!empty($projectid)) {
1843 $projectsListId = $projectid;
1846 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1848 if (empty($projectsListId)) {
1849 print
'<select class="valignmiddle flat maxwidth500 widthcentpercentminusxx minwidth150imp" id="taskid" name="taskid">';
1850 print
'<option class="opacitymedium"> </option>';
1851 print
'<option class="opacitymedium" disabled data-html="'.dolPrintHTMLForAttribute($langs->trans(
"SelectAProjectFirst")).
'">'.$langs->trans(
"SelectAProjectFirst").
'</option>';
1855 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 64, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (string) $projectsListId,
'all', null, 1);
1861 if (!empty($origin) && !empty($originid)) {
1862 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1864 $hasPermissionOnLinkedObject = 0;
1867 $modulecodetouseforpermissioncheck = $elProp[
'module'];
1869 if ($modulecodetouseforpermissioncheck ==
'productbatch') {
1870 $modulecodetouseforpermissioncheck =
'produit';
1872 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read') || $user->hasRight($modulecodetouseforpermissioncheck, $elProp[
'element'],
'read')) {
1873 $hasPermissionOnLinkedObject = 1;
1877 if (! in_array($origin, array(
'societe',
'project',
'project_task',
'user'))) {
1879 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1880 print
'<td colspan="3">';
1881 if ($hasPermissionOnLinkedObject) {
1883 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1884 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1885 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1886 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1888 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1896 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1897 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1902 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1903 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1904 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 100,
'dolibarr_notes',
'In', true, true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1905 $doleditor->Create();
1910 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1911 print $hookmanager->resPrint;
1912 if (empty($reshook)) {
1913 print
$object->showOptionals($extrafields,
'create', $parameters);
1919 if ($enablereminders) {
1923 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>';
1925 print
'<div class="reminderparameters" '.(empty(
GETPOST(
'addreminder')) ?
'style="display: none;' :
'').
' ">';
1928 print
'<table class="border centpercent">';
1931 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1932 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1934 print $form->selectTypeDuration(
'offsetunit', (empty($offsetunit) ?
'i' : $offsetunit), $TDurationTypesExcluded);
1938 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1939 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1944 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1945 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (empty($modelmail) ? 0 : $modelmail));
1952 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
1953 $reminderDefaultOffset =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_OFFSET', 30);
1955 $reminderDefaultEmailModel =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
1957 print
"\n".
'<script type="text/javascript">';
1958 print
'$(document).ready(function () {
1959 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
1960 $(
"#actioncode").change(
function(){
1961 var selected_event_type = $(
"#actioncode option:selected").val();
1963 if (reminderDefaultEventTypes.includes(selected_event_type)) {
1964 $(
".reminderparameters").show();
1965 $(
"#addreminder").prop(
"checked",
true);
1968 $(
"[name=\"offsetvalue\"]").val(\
'' .
dol_escape_js((
string) $reminderDefaultOffset) .
'\');
1969 $(
"#select_offsetunittype_duration").select2(
"destroy");
1970 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
1971 $(
"#select_offsetunittype_duration").select2();
1973 $(
"#selectremindertype").select2(
"destroy");
1974 $(
"#selectremindertype").val(
"email");
1975 $(
"#selectremindertype").select2();
1978 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
1979 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
1980 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js((
string) $reminderDefaultEmailModel).
'\');
1981 $(
"#select_actioncommsendmodel_mail").select2();
1985 print '</script>
'."\n";
1987 print "\n".'<script
type=
"text/javascript">
';
1988 print '$(document).ready(
function () {
1989 function toggle_reminder_part(evt) {
1990 console.log(
"Toggle reminder part");
1991 if ($(
"#addreminder").is(
":checked")) {
1992 $(
".reminderparameters").show();
1994 $(
".reminderparameters").hide();
1996 $(
"#selectremindertype").select2(
"destroy");
1997 $(
"#selectremindertype").select2();
1998 $(
"#select_offsetunittype_duration").select2(
"destroy");
1999 $(
"#select_offsetunittype_duration").select2();
2000 selectremindertype();
2003 toggle_reminder_part();
2004 $(
"#addreminder").click(toggle_reminder_part);
2006 $(
"#selectremindertype").change(
function(){
2007 selectremindertype();
2010 function selectremindertype() {
2011 console.log(
"Call selectremindertype");
2012 var selected_option = $(
"#selectremindertype option:selected").val();
2013 if(selected_option ==
"email") {
2014 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2016 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
2021 print '</script>
'."\n";
2024 print dol_get_fiche_end();
2026 print $form->buttonsSaveCancel("Create");
2032if ($id > 0 && $action != 'create
') {
2033 $result1 = $object->fetch($id);
2034 if ($result1 <= 0) {
2035 recordNotFound('', 0);
2038 $result2 = $object->fetch_thirdparty();
2039 $result2 = $object->fetchProject();
2040 $result3 = $object->fetch_contact();
2041 $result4 = $object->fetch_userassigned();
2042 $result5 = $object->fetch_optionals();
2044 if ($listUserAssignedUpdated || $donotclearsession) {
2045 $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
2047 $datep = dol_mktime($fulldayevent ? 0 : $aphour, $fulldayevent ? 0 : $apmin, 0, GETPOSTINT("apmonth"), GETPOSTINT("apday"), GETPOSTINT("apyear"), 'tzuserrel
');
2048 $datef = dol_mktime($fulldayevent ? 23 : $p2hour, $fulldayevent ? 59 : $p2min, $fulldayevent ? 59 : 0, GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), 'tzuserrel
');
2050 $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09
'), 'c_actioncomm
');
2051 $object->label = GETPOST("label", "alphanohtml");
2052 $object->datep = $datep;
2053 $object->datef = $datef;
2054 $object->percentage = $percentage;
2055 $object->priority = GETPOSTINT("priority");
2056 $object->fulldayevent = GETPOST("fullday") ? 1 : 0;
2057 $object->location = GETPOST('location
', "alphanohtml");
2058 $object->socid = GETPOSTINT("socid");
2059 $socpeopleassigned = GETPOST("socpeopleassigned", 'array
');
2060 foreach ($socpeopleassigned as $tmpid) {
2061 $object->socpeopleassigned[$id] = array('id' => $tmpid);
2063 $object->contact_id = GETPOSTINT("contactid");
2064 $object->fk_project = GETPOSTINT("projectid");
2066 $object->note_private = GETPOST("note", 'restricthtml
');
2069 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
2070 dol_print_error($db, $object->error);
2079 $head = actions_prepare_head($object);
2082 $delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO
') * 24 * 60 * 60;
2085 // Confirmation suppression action
2086 if ($action == 'delete') {
2087 print $form->formconfirm("card.php?id=".urlencode((string) ($id)), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1);
2090 if ($action == 'edit
') {
2091 $caneditdateorowner = ($object->type != 'systemauto
');
2093 if (!empty($conf->use_javascript_ajax)) {
2094 print "\n".'<script
type=
"text/javascript">
';
2095 print '$(document).ready(
function () {
2096 function setdatefields()
2098 if ($(
"#fullday:checked").val() ==
null) {
2099 $(
".fulldaystarthour").removeAttr(
"disabled");
2100 $(
".fulldaystartmin").removeAttr(
"disabled");
2101 $(
".fulldayendhour").removeAttr(
"disabled");
2102 $(
".fulldayendmin").removeAttr(
"disabled");
2104 $(
".fulldaystarthour").prop(
"disabled",
true).val(
"00");
2105 $(
".fulldaystartmin").prop(
"disabled",
true).val(
"00");
2106 $(
".fulldayendhour").prop(
"disabled",
true).val(
"23");
2107 $(
".fulldayendmin").prop(
"disabled",
true).val(
"59");
2111 '.($caneditdateorowner ? ' setdatefields();
' : '').'
2113 $(
"#fullday").change(
function() {
2116 var old_startdate =
null;
2117 $(
"#ap").focus(
function() {
2118 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2120 $(
"#ap").next(
".ui-datepicker-trigger").click(
function() {
2121 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2123 $(
"#ap").change(
function() {
2124 setTimeout(
function() {
2125 if ($(
"#p2").val() !==
"") {
2126 var new_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2127 var old_enddate =
new Date($(
"#p2year").val(), $(
"#p2month").val() - 1, $(
"#p2day").val());
2128 if (new_startdate > old_enddate) {
2129 var timeDiff = old_enddate - old_startdate;
2130 var new_enddate =
new Date(new_startdate.getTime() + timeDiff);
2131 $(
"#p2").val(formatDate(new_enddate,
"' . $langs->trans('FormatDateShortJavaInput') . '"));
2132 $(
"#p2day").val(new_enddate.getDate());
2133 $(
"#p2month").val(new_enddate.getMonth() + 1);
2134 $(
"#p2year").val(new_enddate.getFullYear());
2139 $(
"#actioncode").change(
function() {
2140 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
2141 else $("#dateend").removeClass("fieldrequired");
2144 print
'</script>'.
"\n";
2147 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
2148 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2149 print
'<input type="hidden" name="action" value="update">';
2150 print
'<input type="hidden" name="id" value="'.$id.
'">';
2151 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
2152 print
'<input type="hidden" name="page_y" value="">';
2154 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
2157 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2162 print
'<table class="border tableforfield centpercent">';
2165 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>'.
$object->id.
'</td></tr>';
2168 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>';
2172 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
2173 if (
$object->type_code !=
'AC_OTH_AUTO') {
2174 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
2175 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
2177 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2178 print
$object->getTypePicto();
2179 print $langs->trans(
"Action".
$object->type_code);
2185 if (
$object->elementtype ==
'ticket') {
2186 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
2187 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
2188 print
'</td><td><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
2192 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td class="valignmiddle height30 small">';
2193 print
'<input '.($caneditdateorowner ?
'' :
' disabled').
' type="checkbox" id="fullday" name="fullday" '.(
$object->fulldayevent ?
' checked' :
'').
'>';
2194 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
2257 print
'<tr><td class="nowrap">';
2260 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');
2261 print
' <span class="hideonsmartphone"> - </span> ';
2262 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');
2267 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>';
2268 print
img_picto(
'',
'map-marker-alt',
'class="pictofixedwidth"');
2269 print
'<input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.$object->location.
'"></td></tr>';
2272 print
'<tr class="tdsmallheight"><td class="tdsmallheight"> </td><td class="tdsmallheight"></td></tr>';
2276 if (empty($donotclearsession)) {
2277 if (
$object->userownerid > 0) {
2278 $listofuserid[
$object->userownerid] = array(
2282 'transparency' =>
$object->transparency,
2283 'answer_status' => (isset(
$object->userassigned[
$object->userownerid][
'answer_status']) ?
$object->userassigned[
$object->userownerid][
'answer_status'] : null),
2284 'mandatory' => (isset(
$object->userassigned[
$object->userownerid][
'mandatory']) ?
$object->userassigned[
$object->userownerid][
'mandatory'] : null)
2287 if (!empty(
$object->userassigned)) {
2289 $tmplist1 =
$object->userassigned;
2290 foreach ($tmplist1 as $key => $val) {
2291 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2292 $listofuserid[$val[
'id']] = $val;
2296 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2298 if (!empty($_SESSION[
'assignedtouser'])) {
2299 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2303 $listofcontactid =
$object->socpeopleassigned;
2304 $listofotherid =
$object->otherassigned;
2306 print
'<tr><td class="nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2307 print
'<div class="assignedtouser">';
2308 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, [], 0,
'', [],
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid, (int) $caneditdateorowner);
2320 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2321 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories', $object);
2331 print
'<table class="border tableforfield centpercent">';
2334 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td><td colspan="3">';
2335 $percent = GETPOSTISSET(
"percentage") ?
GETPOSTINT(
"percentage") :
$object->percentage;
2336 $formactions->form_select_status_action(
'formaction', (
string) $percent, 1,
'complete', 0, 0,
'minwidth150 maxwidth300');
2341 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2345 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2348 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2353 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2354 print
'<div class="maxwidth200onsmartphone">';
2356 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2357 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
2364 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2365 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');
2366 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2369 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');
2378 $langs->load(
"projects");
2380 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2381 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2382 $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');
2383 if ($numprojet == 0) {
2384 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>';
2391 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2392 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2398 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2400 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2403 print
'<td id="project-task-input-container" >';
2405 $urloption =
'?action=create&donotclearsession=1';
2406 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2410 <script
type=
"text/javascript" >
2411 $(document).ready(
function () {
2412 $(
"#projectid").change(
function () {
2413 var url =
"<?php echo $url; ?>&projectid="+$(
"#projectid").val();
2414 $.get(url,
function(data) {
2415 console.log($( data ).find(
"#fk_element").html());
2416 if (data) $(
"#fk_element").html( $( data ).find(
"#taskid").html() ).select2();
2423 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);
2424 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2431 print
'<td id="project-task-input-container" >';
2435 <script
type=
"text/javascript">
2436 $(document).ready(
function () {
2437 $(
"#projectid").change(
function () {
2438 var url =
"<?php echo DOL_URL_ROOT; ?>/projet/ajax/projects.php?mode=gettasks&socid="+$(
"#search_socid").val()+
"&projectid="+$(
"#projectid").val();
2439 console.log(
"Call url to get new list of tasks: "+url);
2440 $.get(url,
function(data) {
2442 if (data) $(
"#taskid").html(data).select2();
2450 if (GETPOSTISSET(
"projecttaskid") &&
GETPOSTINT(
"projecttaskid") > 0) {
2452 } elseif (GETPOSTISSET(
"taskid") &&
GETPOSTINT(
"taskid") > 0) {
2456 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 64, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (string) $projectsListId,
'all', null, 1);
2462 print
'<input type="hidden" name="fk_element" value="'.$object->elementid.
'">';
2463 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2472 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2474 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2475 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2476 $doleditor->Create();
2481 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2482 print $hookmanager->resPrint;
2483 if (empty($reshook)) {
2484 print
$object->showOptionals($extrafields,
'edit', $parameters);
2490 if ($enablereminders) {
2491 $filteruserid = $user->id;
2492 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2495 $object->loadReminders(
'', $filteruserid,
false);
2499 if (count(
$object->reminders) > 0) {
2500 $checked =
'checked';
2501 $keys = array_keys(
$object->reminders);
2502 $firstreminderId = array_shift($keys);
2504 $actionCommReminder =
$object->reminders[$firstreminderId];
2508 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2509 $actionCommReminder->offsetunit =
'i';
2510 $actionCommReminder->typeremind =
'email';
2519 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>';
2521 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2525 print
'<table class="border centpercent">';
2528 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2529 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2530 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, $TDurationTypesExcluded);
2534 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2535 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2539 if ($actionCommReminder->typeremind ==
'browser') {
2540 $hide =
'style="display:none;"';
2545 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2546 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (
string) $actionCommReminder->fk_email_template);
2552 <script
type=
"text/javascript">
2553 $(document).ready(
function () {
2554 $(
"#addreminder").click(
function(){
2556 $(
".reminderparameters").show();
2558 $(
".reminderparameters").hide();
2561 $(
"#selectremindertype").change(
function(){
2562 var selected_option = $(
"#selectremindertype option:selected").val();
2563 if(selected_option ==
"email") {
2564 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2566 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
2573 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
2576 $reminderDefaultEmailModel =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
2578 print
"\n".
'<script type="text/javascript">';
2579 print
'$(document).ready(function () {
2580 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
2581 $(
"#actioncode").change(
function(){
2582 var selected_event_type = $(
"#actioncode option:selected").val();
2584 if (reminderDefaultEventTypes.includes(selected_event_type)) {
2585 $(
".reminderparameters").show();
2586 $(
"#addreminder").prop(
"checked",
true);
2589 $(
"#offsetvalue").val(\
''.
dol_escape_js($reminderDefaultOffset).
'\');
2590 $(
"#select_offsetunittype_duration").select2(
"destroy");
2591 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
2592 $(
"#select_offsetunittype_duration").select2();
2594 $(
"#selectremindertype").select2(
"destroy");
2595 $(
"#selectremindertype").val(
"email");
2596 $(
"#selectremindertype").select2();
2599 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2600 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
2601 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js($reminderDefaultEmailModel).
'\');
2602 $(
"#select_actioncommsendmodel_mail").select2();
2606 print '</script>
'."\n";
2607 print '</div>
'; // End of div for reminderparameters
2610 print dol_get_fiche_end();
2612 print $form->buttonsSaveCancel();
2616 print dol_get_fiche_head($head, 'card
', $langs->trans("Action"), -1, 'action
');
2621 if ($action == 'clone
') {
2622 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?
id=
'.GETPOST('id'), $langs->trans('ToClone
'), $langs->trans('ConfirmCloneEvent
', $object->label), 'confirm_clone
', [], 'yes
', 1);
2625 // Call Hook formConfirm
2627 $reshook = $hookmanager->executeHooks('formConfirm
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2628 if (empty($reshook)) {
2629 $formconfirm .= $hookmanager->resPrint;
2630 } elseif ($reshook > 0) {
2631 $formconfirm = $hookmanager->resPrint;
2634 // Print form confirm
2638 // Link to other agenda views
2639 $linkback .= '<a href=
"'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">
';
2640 $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist
', 'class=
"pictoactionview pictofixedwidth"');
2641 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("BackToList").'</span>
';
2642 $linkback .= '</a>
';
2643 $linkback .= '</li>
';
2644 $linkback .= '<li
class=
"noborder litext">
';
2645 $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').'">
';
2646 $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar
', 'class=
"pictoactionview pictofixedwidth"');
2647 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewCal").'</span>
';
2648 $linkback .= '</a>
';
2649 $linkback .= '</li>
';
2650 $linkback .= '<li
class=
"noborder litext">
';
2651 $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').'">
';
2652 $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek
', 'class=
"pictoactionview pictofixedwidth"');
2653 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewWeek").'</span>
';
2654 $linkback .= '</a>
';
2655 $linkback .= '</li>
';
2656 $linkback .= '<li
class=
"noborder litext">
';
2657 $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').'">
';
2658 $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday
', 'class=
"pictoactionview pictofixedwidth"');
2659 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewDay").'</span>
';
2660 $linkback .= '</a>
';
2661 $linkback .= '</li>
';
2662 $linkback .= '<li
class=
"noborder litext">
';
2663 $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').'">
';
2664 $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser
', 'class=
"pictoactionview pictofixedwidth"');
2665 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewPerUser").'</span>
';
2666 $linkback .= '</a>
';
2668 // Add more views from hooks
2670 $reshook = $hookmanager->executeHooks('addCalendarView
', $parameters, $object, $action);
2671 if (empty($reshook)) {
2672 $linkback .= $hookmanager->resPrint;
2673 } elseif ($reshook > 1) {
2674 $linkback = $hookmanager->resPrint;
2679 $morehtmlref = '<div
class=
"refidno">
';
2681 //$morehtmlref.='<br>
'.$langs->trans('ThirdParty
') . ' :
' . $object->thirdparty->getNomUrl(1);
2683 if (isModEnabled('project
')) {
2684 $langs->load("projects");
2685 //$morehtmlref .= '<br>
';
2686 if ($usercancreate) {
2687 $morehtmlref .= img_picto($langs->trans("Project"), 'project
', 'class=
"pictofixedwidth"');
2688 if ($action != 'classify
') {
2689 $morehtmlref .= '<a class=
"editfielda" href=
"'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">
'.img_edit($langs->transnoentitiesnoconv('SetProject
')).'</a>
';
2691 $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
');
2693 if (!empty($object->fk_project)) {
2694 $proj = new Project($db);
2695 $proj->fetch($object->fk_project);
2696 $morehtmlref .= $proj->getNomUrl(1);
2698 $morehtmlref .= '<span class=
"opacitymedium"> -
'.dol_escape_htmltag($proj->title).'</span>
';
2703 $morehtmlref .= '</div>
';
2706 dol_banner_tab($object, 'id
', $linkback, ($user->socid ? 0 : 1), 'id
', 'ref', $morehtmlref);
2708 print '<div class=
"fichecenter">
';
2709 print '<div class=
"fichehalfleft">
';
2711 print '<div class=
"underbanner clearboth"></div>
';
2713 // Show event in view mode
2714 print '<
table class=
"border tableforfield centpercent">
';
2717 if (getDolGlobalString('AGENDA_USE_EVENT_TYPE
')) {
2718 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("Type").'</td><td>
';
2719 $labeltype = ($langs->transnoentities("Action".$object->type_code) != "Action".$object->type_code) ? $langs->transnoentities("Action".$object->type_code) : $object->type_label;
2720 $labeltoshow = $labeltype;
2721 if ($object->code) {
2722 $labeltoshow .= ' (
'.$object->code.')
';
2724 print $object->getTypePicto('pictofixedwidth paddingright
', $labeltoshow);
2730 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("EventOnFullDay").'</td><td>
'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>
';
2733 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2738 print '<tr><td>
'.$langs->trans("DateActionStart").'</td><td title=
"'.dol_print_date($object->datep, 'dayhoursec', 'tzuserrel').'">
';
2739 // Test a date before the 27 march and one after
2740 //print dol_print_date($object->datep, 'dayhour
', 'gmt
');
2741 //print dol_print_date($object->datep, 'dayhour
', 'tzuser
');
2742 //print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2743 if (empty($object->fulldayevent)) {
2744 print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2746 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2747 print dol_print_date($object->datep, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2749 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2750 print img_warning($langs->trans("Late"));
2756 print '<tr><td>
'.$langs->trans("DateActionEnd").'</td><td title=
"'.dol_print_date($object->datef, 'dayhoursec', 'tzuserrel').'">
';
2757 if (empty($object->fulldayevent)) {
2758 print dol_print_date($object->datef, 'dayhour
', 'tzuserrel
');
2760 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2761 print dol_print_date($object->datef, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2763 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2764 print img_warning($langs->trans("Late"));
2768 // Recurring event (into a series)
2769 if ($object->recurid) {
2770 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("RecurringEvent").'</td><td>
';
2771 print img_picto($langs->trans("EventPartOfARecurringSerie", $object->recurid), 'recurring
', 'class=
"pictofixedwidth"');
2773 if (preg_match('/FREQ=MONTHLY_BYMONTHDAY(\d+)/
', $object->recurrule, $reg)) {
2774 print $langs->trans("EveryMonth").' <span class=
"opacitymedium small">(
'.$langs->trans("DayOfMonth").' '.$reg[1].' -
'.$langs->trans("Until").' '.dol_print_date($object->recurdateend, 'day
').')</span>
';
2776 if (preg_match('/FREQ=YEARLY_BYYEARMONTHDAY(\d+)/
', $object->recurrule, $reg)) {
2777 print $langs->trans("EveryYear").' <span class=
"opacitymedium small">(
'.$langs->trans("DayOfYear").' '.$reg[1].' -
'.$langs->trans("Until").' '.dol_print_date($object->recurdateend, 'day
').')</span>
';
2783 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2784 print '<tr><td>
'.$langs->trans("Location").'</td><td>
'.$object->location.'</td></tr>
';
2788 print '<tr><td class=
"nowrap">
'.$langs->trans("ActionAssignedTo").'</td><td>
';
2790 if (empty($donotclearsession)) {
2791 if ($object->userownerid > 0) {
2792 $listofuserid[$object->userownerid] = array(
2793 'id
' => $object->userownerid,
2794 'transparency
' => $object->transparency, // Force transparency on owner from property of event
2795 'answer_status
' => $object->userassigned[$object->userownerid]['answer_status
'],
2796 'mandatory
' => $object->userassigned[$object->userownerid]['mandatory
']
2799 if (!empty($object->userassigned)) { // Now concat assigned users
2800 // Restore array with key with same value than param 'id
'
2801 $tmplist1 = $object->userassigned;
2802 foreach ($tmplist1 as $key => $val) {
2803 if ($val['id
'] && $val['id
'] != $object->userownerid) {
2804 $listofuserid[$val['id
']] = $val;
2808 $_SESSION['assignedtouser
'] = json_encode($listofuserid);
2810 if (!empty($_SESSION['assignedtouser
'])) {
2811 $listofuserid = json_decode($_SESSION['assignedtouser
'], true);
2815 $listofcontactid = []; // not used yet
2816 $listofotherid = []; // not used yet
2817 print '<div class=
"assignedtouser">
';
2818 print $form->select_dolusers_forevent('view
', 'assignedtouser
', 1, [], 0, '', [], '0
', 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2821 if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
2823 print '<div class=
"myavailability">
';
2824 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
2828 print ' </td></tr>
';
2831 if (isModEnabled('category
')) {
2832 print '<tr><td class=
"valignmiddle">
'.$langs->trans("Categories").'</td><td>
';
2833 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2841 print '<div class=
"fichehalfright">
';
2843 print '<div class=
"underbanner clearboth"></div>
';
2844 print '<
table class=
"border tableforfield centpercent">
';
2846 if (isModEnabled("societe")) {
2848 print '<tr><td class=
"titlefield">
'.$langs->trans("ActionOnCompany").'</td>
';
2849 print '<td>
'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : ('<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
'));
2850 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL
') {
2851 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2852 print "<br>".dol_print_phone($object->thirdparty->phone);
2858 print '<tr><td>
'.$langs->trans("ActionOnContact").'</td>
';
2861 if (!empty($object->socpeopleassigned)) {
2862 foreach ($object->socpeopleassigned as $cid => $Tab) {
2863 $contact = new Contact($db);
2864 $result = $contact->fetch($cid);
2867 dol_print_error($db, $contact->error);
2871 print $contact->getNomUrl(1);
2872 if ($object->type_code == 'AC_TEL
') {
2873 if (!empty($contact->phone_pro)) {
2874 print '(
'.dol_print_phone($contact->phone_pro).')
';
2877 print '<div class=
"paddingright"></div>
';
2881 print '<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
';
2887 if (getDolGlobalString('AGENDA_SUPPORT_PRIORITY_IN_EVENTS
')) {
2888 print '<tr><td class=
"nowrap" class=
"titlefield">
' . $langs->trans("Priority") . '</td><td>
';
2889 print($object->priority ? $object->priority : '');
2893 // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
2894 // for such objects because there is already a dedicated field into table llx_actioncomm.
2895 if (!empty($object->elementid) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe
', 'contact
', 'project
'))) {
2896 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
2897 print '<tr><td>
'.$langs->trans("LinkedObject").'</td>
';
2898 $link = dolGetElementUrl($object->elementid, $object->elementtype, ($object->elementtype == 'user' ? -1 : 1));
2901 print '<span class=
"opacitymedium">
'.$langs->trans("ObjectDeleted").'</span>
';
2909 if (!empty($object->email_msgid)) {
2910 print '<tr><td>
'.$langs->trans('MailTopic
').'</td>
';
2911 print '<td>
'.dol_escape_htmltag($object->email_subject).'</td></tr>
';
2912 print '<tr><td>
'.$langs->trans('MailFrom
').'</td>
';
2913 print '<td>
'.dol_escape_htmltag($object->email_from).'</td></tr>
';
2914 print '<tr><td>
'.$langs->trans('MailTo
').'</td>
';
2915 print '<td>
'.dol_escape_htmltag($object->email_to).'</td></tr>
';
2916 if (!empty($object->email_tocc)) {
2917 print '<tr><td>
'.$langs->trans('MailCC
').'</td>
';
2918 print '<td>
'.dol_escape_htmltag($object->email_tocc).'</td></tr>
';
2923 print '<tr><td class=
"tdtop">
'.$langs->trans("Description").'</td><td class=
"wordbreak sensiblehtmlcontent">
';
2924 print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
2928 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php
';
2931 if ($enablereminders) {
2932 $filteruserid = $user->id;
2933 if ($user->hasRight('agenda
', 'allactions
', 'read
')) {
2936 $object->loadReminders('', $filteruserid, false);
2938 print '<tr><td class=
"titlefieldcreate nowrap">
'.$langs->trans("Reminders").'</td><td>
';
2940 if (count($object->reminders) > 0) {
2941 $tmpuserstatic = new User($db);
2943 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2944 print $TRemindTypes[$actioncommreminder->typeremind]['label
'];
2945 if ($actioncommreminder->fk_user > 0) {
2946 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2947 print ' (
'.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')
';
2949 print ' -
'.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit];
2951 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2952 print ' - <span class=
"opacitymedium">
';
2953 print $langs->trans("NotSent");
2955 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2956 print ' - <span class=
"opacitymedium">
';
2957 print $langs->trans("Done");
2959 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2960 print ' - <span class=
"opacitymedium">
';
2961 print $form->textwithpicto($langs->trans("Error"), $actioncommreminder->lasterror);
2975 print '<div class=
"clearboth"></div>
';
2977 print dol_get_fiche_end();
2984 print '<div class=
"tabsAction">
';
2987 $reshook = $hookmanager->executeHooks('addMoreActionsButtons
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2988 if (empty($reshook)) {
2989 if ($action != 'edit
') {
2990 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
2991 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
2992 print '<div class=
"inline-block divButAction"><a class=
"butAction" href=
"card.php?action=edit&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Modify").'</a></div>
';
2994 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Modify").'</a></div>
';
2997 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
2998 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
2999 print '<div class=
"inline-block divButAction"><a class=
"butAction" href=
"card.php?action=clone&object='.$object->element.'&id='.$object->id.'">
'.$langs->trans("ToClone").'</a></div>
';
3001 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("ToClone").'</a></div>
';
3004 if ($usercandelete) {
3005 print '<div class=
"inline-block divButAction"><a class=
"butActionDelete" href=
"card.php?action=delete&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Delete").'</a></div>
';
3007 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Delete").'</a></div>
';
3014 if ($action != 'edit
') {
3015 if (!getDolGlobalString('AGENDA_DISABLE_BUILDDOC
')) {
3016 print '<div class=
"clearboth"></div><div class=
"fichecenter"><div class=
"fichehalfleft">
';
3017 print '<a
name=
"builddoc"></a>
'; // ancre
3019 // Generated documents
3020 $filedir = $conf->agenda->multidir_output[$conf->entity].'/
'.$object->id;
3021 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
3023 $genallowed = $user->hasRight('agenda
', 'myactions
', 'read
');
3024 $delallowed = $user->hasRight('agenda
', 'myactions
', 'create
');
3026 print $formfile->showdocuments('actions
', (string) $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang());
3028 if (getDolGlobalString('AGENDA_ENABLE_LINKED_ELEMENTS
')) {
3029 // Show links to link elements
3030 $tmparray = $form->showLinkToObjectBlock($object, [], array('myobject
'), 1);
3031 if (is_array($tmparray)) {
3032 $linktoelem = $tmparray['linktoelem
'];
3033 $htmltoenteralink = $tmparray['htmltoenteralink
'];
3034 print $htmltoenteralink;
3035 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
3037 // backward compatibility
3038 $somethingshown = $form->showLinkedObjectBlock($object, $tmparray);
3041 print '</div><div class=
"fichehalfright">
';
3043 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.
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getElementProperties($elementType)
Get an array with properties of an element.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
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.
$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.