35require
'../../main.inc.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncommreminder.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
60$langs->loadLangs([
"companies",
"other",
"commercial",
"bills",
"orders",
"agenda",
"mails"]);
63$action =
GETPOST(
'action',
'aZ09');
64$cancel =
GETPOST(
'cancel',
'alpha');
65$backtopage =
GETPOST(
'backtopage',
'alpha');
66$socpeopleassigned =
GETPOST(
'socpeopleassigned',
'array');
67$origin =
GETPOST(
'origin',
'alpha');
69$confirm =
GETPOST(
'confirm',
'alpha');
71$fulldayevent =
GETPOST(
'fullday',
'alpha');
78$addreminder =
GETPOST(
'addreminder',
'alpha');
80$offsetunit =
GETPOST(
'offsetunittype_duration',
'aZ09');
81$remindertype =
GETPOST(
'selectremindertype',
'aZ09');
82$modelmail =
GETPOSTINT(
'actioncommsendmodel_mail');
83$complete =
GETPOST(
'complete',
'alpha');
84$private =
GETPOST(
'private',
'alphanohtml');
85if ($complete ==
'na' || $complete == -2) {
102 if (
GETPOST(
'datep') ==
'now') {
104 } elseif (preg_match(
'/^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$/',
GETPOST(
"datep"), $reg)) {
105 $datep =
dol_mktime((
int) $reg[4], (
int) $reg[5], (
int) $reg[6], (
int) $reg[2], (
int) $reg[3], (
int) $reg[1],
'tzuserrel');
106 } elseif (preg_match(
'/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',
GETPOST(
"datep"), $reg)) {
107 $datep =
dol_mktime(0, 0, 0, (
int) $reg[2], (
int) $reg[3], (
int) $reg[1],
'tzuserrel');
113if (GETPOSTISSET(
"limityear") &&
GETPOSTINT(
"limityear") < 2100) {
114 $repeateventlimitdate =
dol_mktime(23, 59, 59, GETPOSTISSET(
"limitmonth") ?
GETPOSTINT(
"limitmonth") : 1, GETPOSTISSET(
"limitday") ?
GETPOSTINT(
"limitday") : 1,
GETPOSTINT(
"limityear"), $tzforfullday ? $tzforfullday :
'tzuserrel');
116 $repeateventlimitdate =
dol_mktime(23, 59, 59, 12, 31, $currentyear, $tzforfullday ? $tzforfullday :
'tzuserrel');
122 $socid = $user->socid;
125if ($user->socid && ($socid != $user->socid)) {
130$donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
135$sessionkeyassignedtouser =
'assignedtouser_'.($id > 0 ?
$id :
'new');
136$sessionkeyassignedtoresource =
'assignedtoresource_'.($id > 0 ?
$id :
'new');
149if ($id > 0 && $action !=
'add') {
153 $ret =
$object->fetch_optionals();
154 $ret1 =
$object->fetch_userassigned();
156 if ($ret < 0 || $ret1 < 0) {
162$extrafields->fetch_name_optionals_label(
$object->table_element);
164if (empty($action) && empty(
$object->id)) {
169$hookmanager->initHooks([
'actioncard',
'globalcard']);
173 $TRemindTypes[
'browser'] = [
174 'label' => $langs->trans(
'BrowserPush'),
176 'type' => ActionCommReminder::TYPE_USER,
177 'data-html' =>
img_picto(
'',
'globe',
'class="pictofixedwidth"') . $langs->trans(
'BrowserPush'),
181 $TRemindTypes[
'email'] = [
182 'label' => $langs->trans(
'EMail'),
184 'type' => ActionCommReminder::TYPE_USER,
185 'data-html' =>
img_picto(
'',
'email',
'class="pictofixedwidth"') . $langs->trans(
'EMail'),
190 $TRemindTypes[
'sms'] = [
191 'label' => $langs->trans(
'Sms'),
193 'type' => ActionCommReminder::TYPE_USER,
194 'data-html' =>
img_picto(
'',
'phoning_mobile',
'class="pictofixedwidth"') . $langs->trans(
'Sms'),
197$TDurationTypes = $form->getDurationTypes($langs);
198$TDurationTypesExcluded = [
'y',
'm',
's'];
202 'TRemindTypes' => &$TRemindTypes,
203 'enablereminders' => &$enablereminders,
204 'TDurationTypes' => &$TDurationTypes,
205 'TDurationTypesExcluded' => &$TDurationTypesExcluded,
207$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
212$result =
restrictedArea($user,
'agenda', $object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
214$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || ((empty(
$object->id) ||
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
215$usercandelete = $user->hasRight(
'agenda',
'allactions',
'delete') || ((
$object->authorid === $user->id ||
$object->userownerid === $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'));
222$listUserAssignedUpdated =
false;
223$listResourceAssignedUpdated =
false;
227if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
228 $idtoremove =
GETPOST(
'removedassigned');
230 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
231 $tmpassigneduserids = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
233 $tmpassigneduserids = [];
236 foreach ($tmpassigneduserids as $key => $val) {
237 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
238 unset($tmpassigneduserids[$key]);
242 $_SESSION[$sessionkeyassignedtouser] = json_encode($tmpassigneduserids);
243 $donotclearsession = 1;
244 if ($action ==
'add') {
247 if ($action ==
'update') {
251 $listUserAssignedUpdated =
true;
254if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
255 $idtoremove =
GETPOST(
'removedassignedresource');
257 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
258 $tmpassignedresourceids = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
260 $tmpassignedresourceids = [];
263 foreach ($tmpassignedresourceids as $key => $val) {
264 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
265 unset($tmpassignedresourceids[$key]);
269 $_SESSION[$sessionkeyassignedtoresource] = json_encode($tmpassignedresourceids);
271 if ($action ==
'add' && $usercancreate) {
274 if ($action ==
'update' && $usercancreate) {
278 $listResourceAssignedUpdated =
true;
282if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
284 if (
GETPOST(
'assignedtouser') > 0) {
285 $assignedtouser = [];
286 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
287 $assignedtouser = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
289 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id' =>
GETPOSTINT(
'assignedtouser'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
290 $_SESSION[$sessionkeyassignedtouser] = json_encode($assignedtouser);
292 $donotclearsession = 1;
293 if ($action ==
'add' && $usercancreate) {
296 if ($action ==
'update' && $usercancreate) {
300 $listUserAssignedUpdated =
true;
304if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
306 if (
GETPOST(
'assignedtoresource') > 0) {
307 $assignedtoresource = [];
308 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
309 $assignedtoresource = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
311 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id' =>
GETPOSTINT(
'assignedtoresource'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
312 $_SESSION[$sessionkeyassignedtoresource] = json_encode($assignedtoresource);
314 $donotclearsession = 1;
315 if ($action ==
'add' && $usercancreate) {
318 if ($action ==
'update' && $usercancreate) {
322 $listResourceAssignedUpdated =
true;
326if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
327 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
333if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
335 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
340 if (!empty(
$object->socpeopleassigned)) {
341 reset(
$object->socpeopleassigned);
346 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
357if (empty($reshook) && $action ==
'add' && $usercancreate) {
360 if (empty($backtopage)) {
362 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
364 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
368 if (!empty($socpeopleassigned[0])) {
369 $result = $contact->fetch($socpeopleassigned[0]);
373 header(
"Location: ".$backtopage);
377 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
390 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
393 if (!$datef && $percentage == 100) {
395 $donotclearsession = 1;
397 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
402 $donotclearsession = 1;
404 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
408 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
410 $donotclearsession = 1;
412 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
417 $listofresourceid = [];
422 $object->fulldayevent = ($fulldayevent ? 1 : 0);
426 if (
GETPOST(
"elementtype",
'alpha')) {
428 $modulecodetouseforpermissioncheck = $elProp[
'module'];
430 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
432 switch ($modulecodetouseforpermissioncheck) {
434 $modulecodetouseforpermissioncheck =
'produit';
436 case 'eventorganization':
438 $modulecodetouseforpermissioncheck =
'projet';
439 $submodulecodetouseforpermissioncheck =
'';
446 $hasPermissionOnLinkedObject = 0;
447 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
448 $hasPermissionOnLinkedObject = 1;
449 } elseif ($user->hasRight($modulecodetouseforpermissioncheck, $submodulecodetouseforpermissioncheck,
'read')) {
450 $hasPermissionOnLinkedObject = 1;
453 if ($hasPermissionOnLinkedObject) {
461 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
462 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
464 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
465 $object->label = $langs->transnoentitiesnoconv(
"Action".
$object->type_code).
"\n";
467 $cactioncomm->fetch(
$object->type_code);
468 $object->label = $cactioncomm->label;
475 if (!empty($taskid)) {
477 if ($taskProject->fetch($taskid) > 0) {
478 $object->fk_project = $taskProject->fk_project;
483 $object->elementtype =
'project_task';
488 $object->percentage = $percentage;
491 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
494 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
495 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
498 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
499 $listofresourceid = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
503 foreach ($listofuserid as $key => $value) {
505 if ($value[
'id'] > 0) {
506 $object->userownerid = $value[
'id'];
508 $object->transparency = $transparency;
511 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
519 if (GETPOSTISSET(
"contactid")) {
530 if (empty(
$object->userownerid) && empty($_SESSION[$sessionkeyassignedtouser])) {
532 $donotclearsession = 1;
534 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
536 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
538 $donotclearsession = 1;
540 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
545 $donotclearsession = 1;
547 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
550 foreach ($socpeopleassigned as $cid) {
551 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
553 if (!empty(
$object->socpeopleassigned)) {
554 reset(
$object->socpeopleassigned);
559 $ret = $extrafields->setOptionalsFromPost(
null, $object);
562 $donotclearsession = 1;
574 $selectedrecurrulefreq =
'no';
575 $selectedrecurrulebyyearmonthday =
'';
576 $selectedrecurrulebymonthday =
'';
577 $selectedrecurrulebyday =
'';
578 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
579 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'YEARLY') ?
"_BYYEARMONTHDAY".((
int) $dayinyear) :
"";
580 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY') ?
"_BYMONTHDAY".((
int) $dayinmonth) :
"";
581 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY') ?
"_BYDAY".((
int) $dayinweek) :
"";
587 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
588 $selectedrecurrulefreq = $reg1[1];
590 if (
$object->recurrule && preg_match(
'/FREQ=YEARLY.*BYYEARMONTHDAY(\d+)/i',
$object->recurrule, $reg4)) {
591 $selectedrecurrulebyyearmonthday = (int) $reg4[1];
593 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
594 $selectedrecurrulebymonthday = (int) $reg2[1];
596 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
597 $selectedrecurrulebyday = (int) $reg3[1];
601 $eventisrecurring = 0;
602 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
603 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
604 $eventisrecurring = 1;
614 $idaction =
$object->create($user);
619 if (is_array($listofresourceid) && count($listofresourceid)) {
620 foreach ($listofresourceid as $resource_id => $val) {
621 $resource_type =
'dolresource';
626 $eventDateStart =
$object->datep;
627 $eventDateEnd =
$object->datef;
628 $isFullDayEvent =
$object->fulldayevent;
629 if (empty($eventDateEnd)) {
630 if ($isFullDayEvent) {
632 $eventDateStart =
dol_mktime(0, 0, 0, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
633 $eventDateEnd =
dol_mktime(23, 59, 59, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
637 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
638 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_resources as er";
639 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"resource as r ON r.rowid = er.resource_id AND er.resource_type = '" .
$db->escape($resource_type) .
"'";
640 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" .
$db->escape(
$object->element) .
"'";
641 $sql .=
" WHERE er.resource_id = " . ((int) $resource_id);
642 $sql .=
" AND er.busy = 1";
646 $sql .=
" (ac.datep <= '" .
$db->idate($eventDateStart) .
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '" .
$db->idate($eventDateStart) .
"'))";
648 if (!empty($eventDateEnd)) {
649 $sql .=
" OR (ac.datep <= '" .
$db->idate($eventDateEnd) .
"' AND (ac.datep2 >= '" .
$db->idate($eventDateEnd) .
"'))";
653 $sql .=
"ac.datep >= '" .
$db->idate($eventDateStart) .
"'";
654 if (!empty($eventDateEnd)) {
655 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" .
$db->idate($eventDateEnd) .
"')";
660 $resql =
$db->query($sql);
666 if (
$db->num_rows($resql) > 0) {
669 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse') .
' : ';
670 while ($obj =
$db->fetch_object($resql)) {
671 $object->error .=
'<br> - ' . $langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label .
' [' . $obj->ac_id .
']');
682 $res =
$object->add_element_resource($resource_id, $resource_type, $busy, $val[
'mandatory']);
687 unset($_SESSION[$sessionkeyassignedtoresource]);
692 $categories =
GETPOST(
'categories',
'array');
693 $object->setCategories($categories);
696 unset($_SESSION[$sessionkeyassignedtouser]);
698 if ($user->id !=
$object->userownerid) {
699 $moreparam =
"filtert=-1";
703 if (!$error && $addreminder ==
'on') {
708 $actionCommReminder->dateremind = $dateremind;
709 $actionCommReminder->typeremind = $remindertype;
710 $actionCommReminder->offsetunit = $offsetunit;
711 $actionCommReminder->offsetvalue = $offsetvalue;
712 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
713 $actionCommReminder->fk_actioncomm =
$object->id;
714 if ($remindertype ==
'email') {
715 $actionCommReminder->fk_email_template = $modelmail;
719 foreach (
$object->userassigned as $userassigned) {
720 $actionCommReminder->fk_user = $userassigned[
'id'];
721 $res = $actionCommReminder->create($user);
725 $langs->load(
"errors");
727 setEventMessages($langs->trans(
'ErrorReminderActionCommCreation'),
null,
'errors');
729 $donotclearsession = 1;
740 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
753 $langs->load(
"errors");
757 $donotclearsession = 1;
763 $donotclearsession = 1;
767 if (!$error && $eventisrecurring) {
772 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
774 $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');
779 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
780 $firstday = $selectedrecurrulebymonthday;
787 } elseif ($selectedrecurrulefreq ==
'YEARLY' && !empty($selectedrecurrulebyyearmonthday)) {
802 while ($datep <= $repeateventlimitdate && !$error) {
806 $finalobject->datep = $datep;
807 $finalobject->datef = $datef;
809 $idaction = $finalobject->create($user);
812 if (!$finalobject->error) {
814 $categories =
GETPOST(
'categories',
'array');
815 $finalobject->setCategories($categories);
817 unset($_SESSION[$sessionkeyassignedtouser]);
820 if ($user->id != $finalobject->userownerid) {
821 $moreparam =
"filtert=-1";
825 if ($addreminder ==
'on') {
830 $actionCommReminder->dateremind = $dateremind;
831 $actionCommReminder->typeremind = $remindertype;
832 $actionCommReminder->offsetunit = $offsetunit;
833 $actionCommReminder->offsetvalue = $offsetvalue;
834 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
835 $actionCommReminder->fk_actioncomm = $finalobject->id;
836 if ($remindertype ==
'email') {
837 $actionCommReminder->fk_email_template = $modelmail;
841 foreach ($finalobject->userassigned as $userassigned) {
842 $actionCommReminder->fk_user = $userassigned[
'id'];
843 $res = $actionCommReminder->create($user);
848 $langs->load(
"errors");
849 setEventMessages($langs->trans(
'ErrorReminderActionCommCreation'),
null,
'errors');
851 $donotclearsession = 1;
862 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
866 $langs->load(
"errors");
867 $error = $langs->trans($finalobject->error);
870 $donotclearsession = 1;
876 $donotclearsession = 1;
880 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
900 if (!empty($backtopage) && !$error) {
901 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
902 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
903 } elseif ($idaction) {
904 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
906 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
913if (empty($reshook) && $action ==
'update' && $usercancreate) {
914 if (empty($cancel)) {
915 $fulldayevent =
GETPOST(
'fullday');
920 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
948 if (!GETPOSTISSET(
'ap') && !GETPOSTISSET(
'aphour') && !GETPOSTISSET(
'apmin')) {
953 if (!GETPOSTISSET(
'p2') && !GETPOSTISSET(
'p2hour') && !GETPOSTISSET(
'p2min')) {
961 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
963 if (
$object->elementtype ==
'ticket') {
965 if (
$object->code ==
'TICKET_MSG') {
966 $object->code =
'TICKET_MSG_PRIVATE';
968 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
969 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
972 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
975 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
976 $object->code =
'TICKET_MSG_SENTBYMAIL';
988 $object->percentage = $percentage;
993 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
994 $object->socpeopleassigned = [];
995 foreach ($socpeopleassigned as $cid) {
996 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
999 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
1000 reset(
$object->socpeopleassigned);
1005 if (!empty($taskid)) {
1007 if ($taskProject->fetch($taskid) > 0) {
1008 $object->fk_project = $taskProject->fk_project;
1011 $object->fk_element = $taskid;
1013 $object->elementtype =
'project_task';
1018 if (
GETPOST(
"elementtype",
'alpha')) {
1020 $modulecodetouseforpermissioncheck = $elProp[
'module'];
1022 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
1024 switch ($modulecodetouseforpermissioncheck) {
1025 case 'productbatch':
1026 $modulecodetouseforpermissioncheck =
'produit';
1028 case 'eventorganization':
1030 $modulecodetouseforpermissioncheck =
'projet';
1031 $submodulecodetouseforpermissioncheck =
'';
1038 $hasPermissionOnLinkedObject = 0;
1039 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
1040 $hasPermissionOnLinkedObject = 1;
1042 if ($hasPermissionOnLinkedObject) {
1050 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
1054 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
1056 $tmplist1 = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
1057 foreach ($tmplist1 as $key => $val) {
1058 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
1059 $listofuserid[$val[
'id']] = $val;
1063 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
1064 if ($assignedtouser) {
1065 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
1071 foreach ($listofuserid as $key => $val) {
1073 $object->userownerid = $val[
'id'];
1075 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
1079 $object->transparency = $transparency;
1083 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
1085 $donotclearsession = 1;
1087 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1089 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
1091 if (empty(
$object->userownerid)) {
1093 $donotclearsession = 1;
1095 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
1099 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
1107 if ($conflicts === -1) {
1111 } elseif (!empty($conflicts)) {
1113 $object->error =
$object->formatResourceConflicts($conflicts, $langs);
1122 $result =
$object->update($user);
1126 $categories =
GETPOST(
'categories',
'array');
1127 $object->setCategories($categories);
1129 $object->loadReminders($remindertype, 0,
false);
1132 if (!empty(
$object->reminders)) {
1133 foreach (
$object->reminders as $reminder) {
1134 if ($reminder->status < 1) {
1135 $reminder->delete($user);
1142 if ($addreminder ==
'on') {
1147 $actionCommReminder->dateremind = $dateremind;
1148 $actionCommReminder->typeremind = $remindertype;
1149 $actionCommReminder->offsetunit = $offsetunit;
1150 $actionCommReminder->offsetvalue = $offsetvalue;
1151 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
1152 $actionCommReminder->fk_actioncomm =
$object->id;
1153 if ($remindertype ==
'email') {
1154 $actionCommReminder->fk_email_template = $modelmail;
1158 foreach (
$object->userassigned as $userassigned) {
1159 $actionCommReminder->fk_user = $userassigned[
'id'];
1163 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1164 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".
$db->escape($remindertype).
"'";
1165 $resqldelete =
$db->query($sqldelete);
1167 $res = $actionCommReminder->create($user);
1171 $langs->load(
"errors");
1172 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1175 $donotclearsession = 1;
1182 unset($_SESSION[$sessionkeyassignedtouser]);
1183 unset($_SESSION[$sessionkeyassignedtoresource]);
1198 if (!empty($backtopage)) {
1199 unset($_SESSION[$sessionkeyassignedtouser]);
1200 header(
"Location: ".$backtopage);
1207if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes' && $usercandelete) {
1210 $object->fetch_userassigned();
1213 $result =
$object->delete($user);
1216 header(
"Location: index.php");
1228if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate' && $usercancreate) {
1234 $newdate =
GETPOST(
'newdate',
'alpha');
1235 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1236 header(
"Location: ".$backtopage,
true, 307);
1240 $datep =
dol_mktime($shour, $smin, 0, (
int) substr($newdate, 13, 2), (
int) substr($newdate, 15, 2), (
int) substr($newdate, 9, 4),
'tzuserrel');
1243 if ($datep !=
$object->datep) {
1251 if ($conflicts === -1) {
1255 } elseif (!empty($conflicts)) {
1257 $object->error =
$object->formatResourceConflicts($conflicts, $langs);
1265 $result =
$object->update($user);
1275 if (!empty($backtopage)) {
1276 header(
"Location: ".$backtopage,
true, 307);
1285$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1286if (empty($reshook)) {
1287 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1298$arrayrecurrulefreq = array(
1299 'no' => $langs->trans(
"OnceOnly"),
1300 'YEARLY' => $langs->trans(
"EveryYear"),
1301 'MONTHLY' => $langs->trans(
"EveryMonth"),
1302 'WEEKLY' => $langs->trans(
"EveryWeek")
1307$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1308llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1310if ($action ==
'create') {
1313 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1314 if (!empty($socpeopleassigned[0])) {
1315 $result = $contact->fetch($socpeopleassigned[0]);
1323 if (!empty(
$conf->use_javascript_ajax)) {
1324 print
"\n".
'<script type="text/javascript">';
1325 print
'$(document).ready(function () {
1326 function setdatefields()
1328 if ($("#fullday:checked").val() == null) {
1329 $(".fulldaystarthour").removeAttr("disabled");
1330 $(".fulldaystartmin").removeAttr("disabled");
1331 $(".fulldayendhour").removeAttr("disabled");
1332 $(".fulldayendmin").removeAttr("disabled");
1333 $("#p2").removeAttr("disabled");
1335 $(".fulldaystarthour").prop("disabled", true).val("00");
1336 $(".fulldaystartmin").prop("disabled", true).val("00");
1337 $(".fulldayendhour").prop("disabled", true).val("23");
1338 $(".fulldayendmin").prop("disabled", true).val("59");
1339 $("#p2").removeAttr("disabled");
1342 $("#fullday").change(function() {
1343 console.log("setdatefields");
1346 var old_startdate = null;
1347 $("#ap").focus(function() {
1348 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1350 $("#ap").next(".ui-datepicker-trigger").click(function() {
1351 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1353 $("#ap").change(function() {
1354 setTimeout(function() {
1355 if ($("#p2").val() !== "") {
1356 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1357 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1358 if (new_startdate > old_enddate) {
1359 var timeDiff = old_enddate - old_startdate;
1360 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1361 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1362 $("#p2day").val(new_enddate.getDate());
1363 $("#p2month").val(new_enddate.getMonth() + 1);
1364 $("#p2year").val(new_enddate.getFullYear());
1369 $("#actioncode").change(function() {
1370 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1371 else $("#dateend").removeClass("fieldrequired");
1373 $("#aphour,#apmin").change(function() {
1374 if ($("#actioncode").val() == \'AC_RDV\') {
1375 var oldhour = parseInt($("#aphour").val());
1376 var oldmin = parseInt($("#apmin").val());
1377 var oldday = parseInt($("#apday").val());
1378 var oldmonth = $("#apmonth").val();
1379 var oldyear = $("#apyear").val();
1381 var newhour = oldhour + 1;
1382 var newday = oldday;
1383 var newmonth = oldmonth;
1384 var newyear = oldyear;
1385 if (newhour >= 24) {
1387 newday = oldday + 1;
1389 console.log("Start date was changed, we modify end date "+oldhour+" "+oldmin+" -> "+newhour+" "+oldmin);
1390 $("#p2hour").val(("00" + newhour).substr(-2,2));
1391 $("#p2min").val(("00" + oldmin).substr(-2,2));
1392 $("#p2day").val(newday);
1393 $("#p2month").val(newmonth);
1394 $("#p2year").val(newyear);
1395 $("#p2").val($("#ap").val());
1398 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1399 else $("#dateend").removeClass("fieldrequired");
1402 print
'</script>'.
"\n";
1405 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1406 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1407 print
'<input type="hidden" name="action" value="add">';
1408 print
'<input type="hidden" name="donotclearsession" value="1">';
1409 print
'<input type="hidden" name="page_y" value="">';
1411 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1414 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode(
$db,
'AC_OTH',
'c_actioncomm').
'">';
1421 print
'<div class="divcreate">';
1422 print
'<table class="border centpercent nobottom">';
1425 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>';
1429 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1431 if (empty($default)) {
1432 $default =
'AC_OTH';
1434 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1435 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1436 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1441 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1442 print
'<td class="valignmiddle height30">';
1444 print
'<input class="valignmiddle" type="checkbox" id="fullday" name="fullday" '.(GETPOST(
'fullday') ?
' checked' :
'').
'><label for="fullday" class="valignmiddle small">'.$langs->trans(
"EventOnFullDay").
'</label>';
1448 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1449 if (
GETPOST(
'datep',
'alpha', 1)) {
1452 $datef = ($datef ? $datef :
$object->datef);
1453 if (
GETPOST(
'datef',
'alpha', 1)) {
1456 if (empty($datef) && !empty($datep)) {
1463 print
'<tr><td class="nowrap">';
1465 print
'<div class="inline-block">';
1467 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1469 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1471 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1472 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1478 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
1479 if ($userepeatevent) {
1481 print
'<div class="clearbothonsmartphone hideonsmartphone inline-block"> </div>';
1484 print
'<div class="inline-block small" data-html="repeat">';
1485 print
'<span class="opacitymedium">';
1486 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 3px" class="paddingright"');
1487 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1489 $selectedrecurrulefreq =
'no';
1490 $selectedrecurrulebyyearmonthday =
'';
1491 $selectedrecurrulebymonthday =
'';
1492 $selectedrecurrulebyday =
'';
1493 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1494 $object->recurrule .= GETPOSTISSET(
'BYYEARMONTHDAY') ?
"_BYYEARMONTHDAY".GETPOST(
'BYYEARMONTHDAY',
'alpha') :
"";
1495 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1496 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1500 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1501 $selectedrecurrulefreq = $reg[1];
1503 if (
$object->recurrule && preg_match(
'/FREQ=YEARLY.*BYYEARMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1504 $selectedrecurrulebyyearmonthday = (int) $reg[1];
1506 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1507 $selectedrecurrulebymonthday = (int) $reg[1];
1509 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1510 $selectedrecurrulebyday = (int) $reg[1];
1513 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly minwidth125 maxwidth150');
1531 $repeateventlimitdate = empty($repeateventlimitdate) ? (
dol_now() + ((24 * 3600 * 365) + 1)) : $repeateventlimitdate;
1533 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1534 print $langs->trans(
"Until").
" ";
1535 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1538 <script
type=
"text/javascript">
1539 jQuery(document).ready(
function() {
1540 function init_repeat() {
1541 console.log(
"recurrule: " +
"<?php echo $object->recurrule; ?>");
1542 console.log(
"reg1: " +
"<?php echo $selectedrecurrulefreq; ?>");
1543 console.log(
"reg2: " +
"<?php echo $selectedrecurrulebymonthday; ?>");
1544 console.log(
"reg3: " +
"<?php echo $selectedrecurrulebyday; ?>");
1545 console.log(
"reg4: " +
"<?php echo $selectedrecurrulebyyearmonthday; ?>");
1546 console.log(
"selectedrulefreq: " +
"<?php echo $selectedrecurrulefreq; ?>");
1547 if (jQuery(
"#recurrulefreq").val() ==
'YEARLY') {
1549 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1550 jQuery(
".repeateventBYMONTHDAY").hide();
1551 jQuery(
".repeateventBYDAY").hide();
1552 }
else if (jQuery(
"#recurrulefreq").val() ==
'MONTHLY') {
1554 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1555 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1556 jQuery(
".repeateventBYDAY").hide();
1557 }
else if (jQuery(
"#recurrulefreq").val() ==
'WEEKLY') {
1558 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1559 jQuery(
".repeateventBYMONTHDAY").hide();
1561 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1563 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1564 jQuery(
".repeateventBYMONTHDAY").hide();
1565 jQuery(
".repeateventBYDAY").hide();
1566 jQuery(
".repeateventlimitdate").hide();
1570 jQuery(
"#recurrulefreq").change(
function() {
1585 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Location").
'</td><td>';
1586 print
img_picto(
'',
'map-marker-alt',
'class="pictofixedwidth"');
1587 print
'<input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.(GETPOST(
'location') ?
GETPOST(
'location') :
$object->location).
'"></td></tr>';
1595 print
'<div class="divcreate">';
1596 print
'<table class="border centpercent nobottom">';
1599 print
'<tr><td class="nowrap titlefieldcreate"><span>';
1600 print $langs->trans(
"AssignedTo");
1601 print
'</span></td><td>';
1603 $listofcontactid = [];
1604 $listofotherid = [];
1606 if (empty($donotclearsession)) {
1608 if ($assignedtouser) {
1609 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1612 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1613 $_SESSION[$sessionkeyassignedtouser] = json_encode($listofuserid);
1615 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
1616 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
1618 if (!is_array($listofuserid)) {
1621 $firstelem = reset($listofuserid);
1622 if (isset($listofuserid[$firstelem[
'id']])) {
1623 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1626 print
'<!-- list of user to assign -->'.
"\n";
1627 print
'<div class="assignedtouser">';
1628 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, [], 0,
'', [],
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid);
1634 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1636 $listofresourceid = [];
1637 if (empty($donotclearsession)) {
1638 $assignedtoresource =
GETPOST(
"assignedtoresource");
1639 if ($assignedtoresource) {
1640 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1642 $_SESSION[$sessionkeyassignedtoresource] = json_encode($listofresourceid);
1644 if (!empty($_SESSION[$sessionkeyassignedtoresource])) {
1645 $listofresourceid = json_decode($_SESSION[$sessionkeyassignedtoresource],
true);
1647 if (!is_array($listofresourceid)) {
1648 $listofresourceid = [];
1650 $firstelem = reset($listofresourceid);
1651 if ($firstelem && isset($listofresourceid[$firstelem[
'id']])) {
1652 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1655 print
'<div class="assignedtoresource">';
1656 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1, [], 0,
'', [],
'0', 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1663 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1664 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories', $object);
1674 print
'<div class="divcreate">';
1675 print
'<table class="border centpercent nobottom">';
1678 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td>';
1680 $percent = $complete !==
'' ? $complete : -1;
1681 if (GETPOSTISSET(
'status')) {
1683 } elseif (GETPOSTISSET(
'percentage')) {
1686 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1688 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1692 print $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'minwidth150 maxwidth300', 1);
1697 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1701 print $societe->getNomUrl(1);
1702 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1705 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1707 if (!empty($user->socid)) {
1708 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1710 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid',
'', $langs->trans(
'SelectThirdParty'), 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1716 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1717 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1721 if ($origin ==
'contact') {
1727 $select_contact_default = 0;
1729 $select_contact_default = -1;
1731 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
1740 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1741 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, [],
'multiple',
'contactid');
1742 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1744 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, [],
'multiple',
'contactid');
1752 $langs->load(
"projects");
1756 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1757 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1758 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');
1760 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1761 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1762 $urloption =
'?action=create&donotclearsession=1';
1767 <script
type=
"text/javascript">
1768 $(document).ready(
function () {
1769 $(
"#projectid").change(
function () {
1770 var url =
"<?php echo DOL_URL_ROOT; ?>/projet/ajax/projects.php?mode=gettasks&socid="+$(
"#search_socid").val()+
"&projectid="+$(
"#projectid").val();
1771 console.log(
"Call url to get the new list of tasks: "+url);
1772 $.get(url,
function(data) {
1774 if (data) $(
"#taskid").html(data).select2();
1784 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1785 print
img_picto(
'',
'projecttask',
'class="pictofixedwidth"');
1786 $projectsListId =
'';
1787 if (!empty($projectid)) {
1788 $projectsListId = $projectid;
1791 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1793 if (empty($projectsListId)) {
1794 print
'<select class="valignmiddle flat maxwidth500 widthcentpercentminusxx minwidth150imp" id="taskid" name="taskid">';
1795 print
'<option class="opacitymedium"> </option>';
1796 print
'<option class="opacitymedium" disabled data-html="'.dolPrintHTMLForAttribute($langs->trans(
"SelectAProjectFirst")).
'">'.$langs->trans(
"SelectAProjectFirst").
'</option>';
1800 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 64, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (
string) $projectsListId,
'all', null, 1);
1806 if (!empty($origin) && !empty($originid)) {
1807 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1809 $hasPermissionOnLinkedObject = 0;
1812 $modulecodetouseforpermissioncheck = $elProp[
'module'];
1814 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
1816 switch ($modulecodetouseforpermissioncheck) {
1817 case 'productbatch':
1818 $modulecodetouseforpermissioncheck =
'produit';
1820 case 'eventorganization':
1822 $modulecodetouseforpermissioncheck =
'projet';
1823 $submodulecodetouseforpermissioncheck =
'';
1830 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read') || $user->hasRight($modulecodetouseforpermissioncheck, $elProp[
'element'],
'read')) {
1831 $hasPermissionOnLinkedObject = 1;
1835 if (! in_array($origin, array(
'societe',
'project',
'project_task',
'user'))) {
1837 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1838 print
'<td colspan="3">';
1839 if ($hasPermissionOnLinkedObject) {
1841 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1842 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1843 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1844 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1846 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1854 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1855 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1860 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1861 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1862 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 200,
'dolibarr_notes',
'In', true, true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1863 $doleditor->Create();
1868 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1869 print $hookmanager->resPrint;
1870 if (empty($reshook)) {
1871 print
$object->showOptionals($extrafields,
'create', $parameters);
1877 if ($enablereminders) {
1881 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>';
1883 print
'<div class="reminderparameters" '.(empty(
GETPOST(
'addreminder')) ?
'style="display: none;' :
'').
' ">';
1886 print
'<table class="border centpercent">';
1889 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1890 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1892 print $form->selectTypeDuration(
'offsetunit', (empty($offsetunit) ?
'i' : $offsetunit), $TDurationTypesExcluded);
1896 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1897 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1902 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1903 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (empty($modelmail) ? 0 : $modelmail));
1910 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
1911 $reminderDefaultOffset =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_OFFSET', 30);
1913 $reminderDefaultEmailModel =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
1915 print
"\n".
'<script type="text/javascript">';
1916 print
'$(document).ready(function () {
1917 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
1918 $(
"#actioncode").change(
function(){
1919 var selected_event_type = $(
"#actioncode option:selected").val();
1921 if (reminderDefaultEventTypes.includes(selected_event_type)) {
1922 $(
".reminderparameters").show();
1923 $(
"#addreminder").prop(
"checked",
true);
1926 $(
"[name=\"offsetvalue\"]").val(\
'' .
dol_escape_js((
string) $reminderDefaultOffset) .
'\');
1927 $(
"#select_offsetunittype_duration").select2(
"destroy");
1928 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
1929 $(
"#select_offsetunittype_duration").select2();
1931 $(
"#selectremindertype").select2(
"destroy");
1932 $(
"#selectremindertype").val(
"email");
1933 $(
"#selectremindertype").select2();
1936 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
1937 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
1938 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js((
string) $reminderDefaultEmailModel).
'\');
1939 $(
"#select_actioncommsendmodel_mail").select2();
1943 print '</script>
'."\n";
1945 print "\n".'<script
type=
"text/javascript">
';
1946 print '$(document).ready(
function () {
1947 function toggle_reminder_part(evt) {
1948 console.log(
"Toggle reminder part");
1949 if ($(
"#addreminder").is(
":checked")) {
1950 $(
".reminderparameters").show();
1952 $(
".reminderparameters").hide();
1954 $(
"#selectremindertype").select2(
"destroy");
1955 $(
"#selectremindertype").select2();
1956 $(
"#select_offsetunittype_duration").select2(
"destroy");
1957 $(
"#select_offsetunittype_duration").select2();
1958 selectremindertype();
1961 toggle_reminder_part();
1962 $(
"#addreminder").click(toggle_reminder_part);
1964 $(
"#selectremindertype").change(
function(){
1965 selectremindertype();
1968 function selectremindertype() {
1969 console.log(
"Call selectremindertype");
1970 var selected_option = $(
"#selectremindertype option:selected").val();
1971 if(selected_option ==
"email") {
1972 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
1974 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
1979 print '</script>
'."\n";
1982 print dol_get_fiche_end();
1984 print $form->buttonsSaveCancel("Create");
1990if ($id > 0 && $action != 'create
') {
1991 $result1 = $object->fetch($id);
1992 if ($result1 <= 0) {
1993 recordNotFound('', 0);
1996 $result2 = $object->fetch_thirdparty();
1997 $result2 = $object->fetchProject();
1998 $result3 = $object->fetch_contact();
1999 $result4 = $object->fetch_userassigned();
2000 $result5 = $object->fetch_optionals();
2002 if ($listUserAssignedUpdated || $donotclearsession) {
2003 $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
2005 $datep = dol_mktime($fulldayevent ? 0 : $aphour, $fulldayevent ? 0 : $apmin, 0, GETPOSTINT("apmonth"), GETPOSTINT("apday"), GETPOSTINT("apyear"), 'tzuserrel
');
2006 $datef = dol_mktime($fulldayevent ? 23 : $p2hour, $fulldayevent ? 59 : $p2min, $fulldayevent ? 59 : 0, GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), 'tzuserrel
');
2008 $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09
'), 'c_actioncomm
');
2009 $object->label = GETPOST("label", "alphanohtml");
2010 $object->datep = $datep;
2011 $object->datef = $datef;
2012 $object->percentage = $percentage;
2013 $object->priority = GETPOSTINT("priority");
2014 $object->fulldayevent = GETPOST("fullday") ? 1 : 0;
2015 $object->location = GETPOST('location
', "alphanohtml");
2016 $object->socid = GETPOSTINT("socid");
2017 $socpeopleassigned = GETPOST("socpeopleassigned", 'array
');
2018 foreach ($socpeopleassigned as $tmpid) {
2019 $object->socpeopleassigned[$id] = array('id' => $tmpid);
2021 $object->contact_id = GETPOSTINT("contactid");
2022 $object->fk_project = GETPOSTINT("projectid");
2024 $object->note_private = GETPOST("note", 'restricthtml
');
2027 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
2028 dol_print_error($db, $object->error);
2037 $head = actions_prepare_head($object);
2040 $delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO
') * 24 * 60 * 60;
2043 // Deletion confirmation action
2044 if ($action == 'delete') {
2045 print $form->formconfirm("card.php?id=".urlencode((string) ($id)), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1);
2048 if ($action == 'edit
') {
2049 $caneditdateorowner = ($object->type != 'systemauto
');
2051 if (!empty($conf->use_javascript_ajax)) {
2052 print "\n".'<script
type=
"text/javascript">
';
2053 print '$(document).ready(
function () {
2054 function setdatefields()
2056 if ($(
"#fullday:checked").val() ==
null) {
2057 $(
".fulldaystarthour").removeAttr(
"disabled");
2058 $(
".fulldaystartmin").removeAttr(
"disabled");
2059 $(
".fulldayendhour").removeAttr(
"disabled");
2060 $(
".fulldayendmin").removeAttr(
"disabled");
2062 $(
".fulldaystarthour").prop(
"disabled",
true).val(
"00");
2063 $(
".fulldaystartmin").prop(
"disabled",
true).val(
"00");
2064 $(
".fulldayendhour").prop(
"disabled",
true).val(
"23");
2065 $(
".fulldayendmin").prop(
"disabled",
true).val(
"59");
2069 '.($caneditdateorowner ? ' setdatefields();
' : '').'
2071 $(
"#fullday").change(
function() {
2074 var old_startdate =
null;
2075 $(
"#ap").focus(
function() {
2076 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2078 $(
"#ap").next(
".ui-datepicker-trigger").click(
function() {
2079 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2081 $(
"#ap").change(
function() {
2082 setTimeout(
function() {
2083 if ($(
"#p2").val() !==
"") {
2084 var new_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2085 var old_enddate =
new Date($(
"#p2year").val(), $(
"#p2month").val() - 1, $(
"#p2day").val());
2086 if (new_startdate > old_enddate) {
2087 var timeDiff = old_enddate - old_startdate;
2088 var new_enddate =
new Date(new_startdate.getTime() + timeDiff);
2089 $(
"#p2").val(formatDate(new_enddate,
"' . $langs->trans('FormatDateShortJavaInput') . '"));
2090 $(
"#p2day").val(new_enddate.getDate());
2091 $(
"#p2month").val(new_enddate.getMonth() + 1);
2092 $(
"#p2year").val(new_enddate.getFullYear());
2097 $(
"#actioncode").change(
function() {
2098 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
2099 else $("#dateend").removeClass("fieldrequired");
2102 print
'</script>'.
"\n";
2105 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
2106 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2107 print
'<input type="hidden" name="action" value="update">';
2108 print
'<input type="hidden" name="id" value="'.$id.
'">';
2109 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
2110 print
'<input type="hidden" name="page_y" value="">';
2112 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
2115 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2120 print
'<table class="border tableforfield centpercent">';
2123 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>'.
$object->id.
'</td></tr>';
2126 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>';
2130 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
2131 if (
$object->type_code !=
'AC_OTH_AUTO') {
2132 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
2133 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
2135 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2136 print
$object->getTypePicto();
2137 print $langs->trans(
"Action".
$object->type_code);
2143 if (
$object->elementtype ==
'ticket') {
2144 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
2145 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
2146 print
'</td><td><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
2150 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td class="valignmiddle height30 small">';
2151 print
'<input '.($caneditdateorowner ?
'' :
' disabled').
' type="checkbox" id="fullday" name="fullday" '.(
$object->fulldayevent ?
' checked' :
'').
'>';
2152 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
2215 print
'<tr><td class="nowrap">';
2218 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');
2219 print
' <span class="hideonsmartphone"> - </span> ';
2220 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');
2225 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>';
2226 print
img_picto(
'',
'map-marker-alt',
'class="pictofixedwidth"');
2227 print
'<input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.$object->location.
'"></td></tr>';
2230 print
'<tr class="tdsmallheight"><td class="tdsmallheight"> </td><td class="tdsmallheight"></td></tr>';
2234 if (empty($donotclearsession)) {
2235 if (
$object->userownerid > 0) {
2236 $listofuserid[
$object->userownerid] = array(
2240 'transparency' =>
$object->transparency,
2241 'answer_status' => (isset(
$object->userassigned[
$object->userownerid][
'answer_status']) ?
$object->userassigned[
$object->userownerid][
'answer_status'] : null),
2242 'mandatory' => (isset(
$object->userassigned[
$object->userownerid][
'mandatory']) ?
$object->userassigned[
$object->userownerid][
'mandatory'] : null)
2245 if (!empty(
$object->userassigned)) {
2247 $tmplist1 =
$object->userassigned;
2248 foreach ($tmplist1 as $key => $val) {
2249 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2250 $listofuserid[$val[
'id']] = $val;
2254 $_SESSION[$sessionkeyassignedtouser] = json_encode($listofuserid);
2256 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
2257 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser],
true);
2261 $listofcontactid =
$object->socpeopleassigned;
2262 $listofotherid =
$object->otherassigned;
2264 print
'<tr><td class="nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2265 print
'<div class="assignedtouser">';
2266 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, [], 0,
'', [],
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid, (int) $caneditdateorowner);
2278 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2279 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories', $object);
2289 print
'<table class="border tableforfield centpercent">';
2292 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td><td colspan="3">';
2293 $percent = GETPOSTISSET(
"percentage") ?
GETPOSTINT(
"percentage") :
$object->percentage;
2294 $formactions->form_select_status_action(
'formaction', (
string) $percent, 1,
'complete', 0, 0,
'minwidth150 maxwidth300');
2299 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2303 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2306 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2311 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2312 print
'<div class="maxwidth200onsmartphone">';
2314 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2322 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2323 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');
2324 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2327 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');
2336 $langs->load(
"projects");
2338 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2339 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2340 $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');
2341 if ($numprojet == 0) {
2342 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>';
2349 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2350 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2356 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2358 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2361 print
'<td id="project-task-input-container" >';
2363 $urloption =
'?action=create&donotclearsession=1';
2364 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2368 <script
type=
"text/javascript" >
2369 $(document).ready(
function () {
2370 $(
"#projectid").change(
function () {
2371 var url =
"<?php echo $url; ?>&projectid="+$(
"#projectid").val();
2372 $.get(url,
function(data) {
2373 console.log($( data ).find(
"#fk_element").html());
2374 if (data) $(
"#fk_element").html( $( data ).find(
"#taskid").html() ).select2();
2381 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);
2382 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2389 print
'<td id="project-task-input-container" >';
2393 <script
type=
"text/javascript">
2394 $(document).ready(
function () {
2395 $(
"#projectid").change(
function () {
2396 var url =
"<?php echo DOL_URL_ROOT; ?>/projet/ajax/projects.php?mode=gettasks&socid="+$(
"#search_socid").val()+
"&projectid="+$(
"#projectid").val();
2397 console.log(
"Call url to get new list of tasks: "+url);
2398 $.get(url,
function(data) {
2400 if (data) $(
"#taskid").html(data).select2();
2408 if (GETPOSTISSET(
"projecttaskid") &&
GETPOSTINT(
"projecttaskid") > 0) {
2410 } elseif (GETPOSTISSET(
"taskid") &&
GETPOSTINT(
"taskid") > 0) {
2414 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 64, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (
string) $projectsListId,
'all', null, 1);
2420 print
'<input type="hidden" name="fk_element" value="'.$object->elementid.
'">';
2421 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2430 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2432 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2433 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 200,
'dolibarr_notes',
'In',
true,
true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2434 $doleditor->Create();
2439 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2440 print $hookmanager->resPrint;
2441 if (empty($reshook)) {
2442 print
$object->showOptionals($extrafields,
'edit', $parameters);
2448 if ($enablereminders) {
2449 $filteruserid = $user->id;
2450 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2453 $object->loadReminders(
'', $filteruserid,
false);
2457 if (count(
$object->reminders) > 0) {
2458 $checked =
'checked';
2459 $keys = array_keys(
$object->reminders);
2460 $firstreminderId = array_shift($keys);
2462 $actionCommReminder =
$object->reminders[$firstreminderId];
2466 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2467 $actionCommReminder->offsetunit =
'i';
2468 $actionCommReminder->typeremind =
'email';
2477 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>';
2479 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2483 print
'<table class="border centpercent">';
2486 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2487 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2488 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, $TDurationTypesExcluded);
2492 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2493 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2497 if ($actionCommReminder->typeremind ==
'browser') {
2498 $hide =
'style="display:none;"';
2503 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2504 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (
string) $actionCommReminder->fk_email_template);
2510 <script
type=
"text/javascript">
2511 $(document).ready(
function () {
2512 $(
"#addreminder").click(
function(){
2514 $(
".reminderparameters").show();
2516 $(
".reminderparameters").hide();
2519 $(
"#selectremindertype").change(
function(){
2520 var selected_option = $(
"#selectremindertype option:selected").val();
2521 if(selected_option ==
"email") {
2522 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2524 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
2531 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
2534 $reminderDefaultEmailModel =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
2536 print
"\n".
'<script type="text/javascript">';
2537 print
'$(document).ready(function () {
2538 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
2539 $(
"#actioncode").change(
function(){
2540 var selected_event_type = $(
"#actioncode option:selected").val();
2542 if (reminderDefaultEventTypes.includes(selected_event_type)) {
2543 $(
".reminderparameters").show();
2544 $(
"#addreminder").prop(
"checked",
true);
2547 $(
"#offsetvalue").val(\
''.
dol_escape_js($reminderDefaultOffset).
'\');
2548 $(
"#select_offsetunittype_duration").select2(
"destroy");
2549 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
2550 $(
"#select_offsetunittype_duration").select2();
2552 $(
"#selectremindertype").select2(
"destroy");
2553 $(
"#selectremindertype").val(
"email");
2554 $(
"#selectremindertype").select2();
2557 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2558 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
2559 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js($reminderDefaultEmailModel).
'\');
2560 $(
"#select_actioncommsendmodel_mail").select2();
2564 print '</script>
'."\n";
2565 print '</div>
'; // End of div for reminderparameters
2568 print dol_get_fiche_end();
2570 print $form->buttonsSaveCancel();
2574 print dol_get_fiche_head($head, 'card
', $langs->trans("Action"), -1, 'action
', 0, '', '', 0, '', 1);
2579 if ($action == 'clone
') {
2580 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?
id=
'.GETPOST('id'), $langs->trans('ToClone
'), $langs->trans('ConfirmCloneEvent
', $object->label), 'confirm_clone
', [], 'yes
', 1);
2583 // Call Hook formConfirm
2585 $reshook = $hookmanager->executeHooks('formConfirm
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2586 if (empty($reshook)) {
2587 $formconfirm .= $hookmanager->resPrint;
2588 } elseif ($reshook > 0) {
2589 $formconfirm = $hookmanager->resPrint;
2592 // Print form confirm
2596 // Link to other agenda views
2597 $linkback .= '<a href=
"'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">
';
2598 $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist
', 'class=
"pictoactionview pictofixedwidth"');
2599 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("BackToList").'</span>
';
2600 $linkback .= '</a>
';
2601 $linkback .= '</li>
';
2602 $linkback .= '<li
class=
"noborder litext">
';
2603 $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').'">
';
2604 $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar
', 'class=
"pictoactionview pictofixedwidth"');
2605 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewCal").'</span>
';
2606 $linkback .= '</a>
';
2607 $linkback .= '</li>
';
2608 $linkback .= '<li
class=
"noborder litext">
';
2609 $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').'">
';
2610 $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek
', 'class=
"pictoactionview pictofixedwidth"');
2611 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewWeek").'</span>
';
2612 $linkback .= '</a>
';
2613 $linkback .= '</li>
';
2614 $linkback .= '<li
class=
"noborder litext">
';
2615 $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').'">
';
2616 $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday
', 'class=
"pictoactionview pictofixedwidth"');
2617 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewDay").'</span>
';
2618 $linkback .= '</a>
';
2619 $linkback .= '</li>
';
2620 $linkback .= '<li
class=
"noborder litext">
';
2621 $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').'">
';
2622 $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser
', 'class=
"pictoactionview pictofixedwidth"');
2623 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewPerUser").'</span>
';
2624 $linkback .= '</a>
';
2626 // Add more views from hooks
2628 $reshook = $hookmanager->executeHooks('addCalendarView
', $parameters, $object, $action);
2629 if (empty($reshook)) {
2630 $linkback .= $hookmanager->resPrint;
2631 } elseif ($reshook > 1) {
2632 $linkback = $hookmanager->resPrint;
2637 $morehtmlref = '<div
class=
"refidno">
';
2639 //$morehtmlref.='<br>
'.$langs->trans('ThirdParty
') . ' :
' . $object->thirdparty->getNomUrl(1);
2641 if (isModEnabled('project
')) {
2642 $langs->load("projects");
2643 //$morehtmlref .= '<br>
';
2644 if ($usercancreate) {
2645 $morehtmlref .= img_picto($langs->trans("Project"), 'project
', 'class=
"pictofixedwidth"');
2646 if ($action != 'classify
') {
2647 $morehtmlref .= '<a class=
"editfielda" href=
"'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">
'.img_edit($langs->transnoentitiesnoconv('SetProject
')).'</a>
';
2649 $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
');
2651 if (!empty($object->fk_project)) {
2652 $proj = new Project($db);
2653 $proj->fetch($object->fk_project);
2654 $morehtmlref .= $proj->getNomUrl(1);
2656 $morehtmlref .= '<span class=
"opacitymedium"> -
'.dol_escape_htmltag($proj->title).'</span>
';
2661 $morehtmlref .= '</div>
';
2664 dol_banner_tab($object, 'id
', $linkback, ($user->socid ? 0 : 1), 'id
', 'ref', $morehtmlref);
2666 print '<div class=
"fichecenter">
';
2667 print '<div class=
"fichehalfleft">
';
2669 print '<div class=
"underbanner clearboth"></div>
';
2671 // Show event in view mode
2672 print '<
table class=
"border tableforfield centpercent">
';
2675 if (getDolGlobalString('AGENDA_USE_EVENT_TYPE
')) {
2676 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("Type").'</td><td>
';
2677 $labeltype = ($langs->transnoentities("Action".$object->type_code) != "Action".$object->type_code) ? $langs->transnoentities("Action".$object->type_code) : $object->type_label;
2678 $labeltoshow = $labeltype;
2679 if ($object->code) {
2680 $labeltoshow .= ' (
'.$object->code.')
';
2682 print $object->getTypePicto('pictofixedwidth paddingright
', $labeltoshow);
2688 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("EventOnFullDay").'</td><td>
'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>
';
2691 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2696 print '<tr><td>
'.$langs->trans("DateActionStart").'</td><td title=
"'.dol_print_date($object->datep, 'dayhoursec', 'tzuserrel').'">
';
2697 // Test a date before the 27 march and one after
2698 //print dol_print_date($object->datep, 'dayhour
', 'gmt
');
2699 //print dol_print_date($object->datep, 'dayhour
', 'tzuser
');
2700 //print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2701 if (empty($object->fulldayevent)) {
2702 print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2704 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2705 print dol_print_date($object->datep, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2707 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2708 print img_warning($langs->trans("Late"));
2714 print '<tr><td>
'.$langs->trans("DateActionEnd").'</td><td title=
"'.dol_print_date($object->datef, 'dayhoursec', 'tzuserrel').'">
';
2715 if (empty($object->fulldayevent)) {
2716 print dol_print_date($object->datef, 'dayhour
', 'tzuserrel
');
2718 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2719 print dol_print_date($object->datef, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2721 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2722 print img_warning($langs->trans("Late"));
2726 // Recurring event (into a series)
2727 if ($object->recurid) {
2728 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("RecurringEvent").'</td><td>
';
2729 print img_picto($langs->trans("EventPartOfARecurringSerie", $object->recurid), 'recurring
', 'class=
"pictofixedwidth"');
2731 if (preg_match('/FREQ=MONTHLY_BYMONTHDAY(\d+)/
', $object->recurrule, $reg)) {
2732 print $langs->trans("EveryMonth").' <span class=
"opacitymedium small">(
'.$langs->trans("DayOfMonth").' '.$reg[1].' -
'.$langs->trans("Until").' '.dol_print_date($object->recurdateend, 'day
').')</span>
';
2734 if (preg_match('/FREQ=YEARLY_BYYEARMONTHDAY(\d+)/
', $object->recurrule, $reg)) {
2735 print $langs->trans("EveryYear").' <span class=
"opacitymedium small">(
'.$langs->trans("DayOfYear").' '.$reg[1].' -
'.$langs->trans("Until").' '.dol_print_date($object->recurdateend, 'day
').')</span>
';
2741 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2742 print '<tr><td>
'.$langs->trans("Location").'</td><td>
'.$object->location.'</td></tr>
';
2746 print '<tr><td class=
"nowrap">
'.$langs->trans("ActionAssignedTo").'</td><td>
';
2748 if (empty($donotclearsession)) {
2749 if ($object->userownerid > 0) {
2750 $listofuserid[$object->userownerid] = array(
2751 'id
' => $object->userownerid,
2752 'transparency
' => $object->transparency, // Force transparency on owner from property of event
2753 'answer_status
' => $object->userassigned[$object->userownerid]['answer_status
'],
2754 'mandatory
' => $object->userassigned[$object->userownerid]['mandatory
']
2757 if (!empty($object->userassigned)) { // Now concat assigned users
2758 // Restore array with key with same value than param 'id
'
2759 $tmplist1 = $object->userassigned;
2760 foreach ($tmplist1 as $key => $val) {
2761 if ($val['id
'] && $val['id
'] != $object->userownerid) {
2762 $listofuserid[$val['id
']] = $val;
2766 $_SESSION[$sessionkeyassignedtouser] = json_encode($listofuserid);
2768 if (!empty($_SESSION[$sessionkeyassignedtouser])) {
2769 $listofuserid = json_decode($_SESSION[$sessionkeyassignedtouser], true);
2773 $listofcontactid = []; // not used yet
2774 $listofotherid = []; // not used yet
2775 print '<div class=
"assignedtouser">
';
2776 print $form->select_dolusers_forevent('view
', 'assignedtouser
', 1, [], 0, '', [], '0
', 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2779 if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
2781 print '<div class=
"myavailability">
';
2782 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
2786 print ' </td></tr>
';
2789 if (isModEnabled('category
')) {
2790 print '<tr><td class=
"valignmiddle">
'.$langs->trans("Categories").'</td><td>
';
2791 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2799 print '<div class=
"fichehalfright">
';
2801 print '<div class=
"underbanner clearboth"></div>
';
2802 print '<
table class=
"border tableforfield centpercent">
';
2804 if (isModEnabled("societe")) {
2806 print '<tr><td class=
"titlefield">
'.$langs->trans("ActionOnCompany").'</td>
';
2807 print '<td>
'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : ('<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
'));
2808 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL
') {
2809 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2810 print "<br>".dol_print_phone($object->thirdparty->phone);
2816 print '<tr><td>
'.$langs->trans("ActionOnContact").'</td>
';
2819 if (!empty($object->socpeopleassigned)) {
2820 foreach ($object->socpeopleassigned as $cid => $Tab) {
2821 $contact = new Contact($db);
2822 $result = $contact->fetch($cid);
2825 dol_print_error($db, $contact->error);
2829 print $contact->getNomUrl(1);
2830 if ($object->type_code == 'AC_TEL
') {
2831 if (!empty($contact->phone_pro)) {
2832 print '(
'.dol_print_phone($contact->phone_pro).')
';
2835 print '<div class=
"paddingright"></div>
';
2839 print '<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
';
2845 if (getDolGlobalString('AGENDA_SUPPORT_PRIORITY_IN_EVENTS
')) {
2846 print '<tr><td class=
"nowrap" class=
"titlefield">
' . $langs->trans("Priority") . '</td><td>
';
2847 print($object->priority ? $object->priority : '');
2851 // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
2852 // for such objects because there is already a dedicated field into table llx_actioncomm.
2853 if (!empty($object->elementid) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe
', 'contact
', 'project
'))) {
2854 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
2855 print '<tr><td>
'.$langs->trans("LinkedObject").'</td>
';
2856 $link = dolGetElementUrl($object->elementid, $object->elementtype, ($object->elementtype == 'user' ? -1 : 1));
2859 print '<span class=
"opacitymedium">
'.$langs->trans("ObjectDeleted").'</span>
';
2867 if (!empty($object->email_msgid)) {
2868 print '<tr><td>
'.$langs->trans('MailTopic
').'</td>
';
2869 print '<td>
'.dol_escape_htmltag($object->email_subject).'</td></tr>
';
2870 print '<tr><td>
'.$langs->trans('MailFrom
').'</td>
';
2871 print '<td>
'.dol_escape_htmltag($object->email_from).'</td></tr>
';
2872 print '<tr><td>
'.$langs->trans('MailTo
').'</td>
';
2873 print '<td>
'.dol_escape_htmltag($object->email_to).'</td></tr>
';
2874 if (!empty($object->email_tocc)) {
2875 print '<tr><td>
'.$langs->trans('MailCC
').'</td>
';
2876 print '<td>
'.dol_escape_htmltag($object->email_tocc).'</td></tr>
';
2881 print '<tr><td class=
"tdtop">
'.$langs->trans("Description").'</td><td class=
"wordbreak sensiblehtmlcontent">
';
2882 print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
2886 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php
';
2889 if ($enablereminders) {
2890 $filteruserid = $user->id;
2891 if ($user->hasRight('agenda
', 'allactions
', 'read
')) {
2894 $object->loadReminders('', $filteruserid, false);
2896 print '<tr><td class=
"titlefieldcreate nowrap">
'.$langs->trans("Reminders").'</td><td>
';
2898 if (count($object->reminders) > 0) {
2899 $tmpuserstatic = new User($db);
2901 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2902 print $TRemindTypes[$actioncommreminder->typeremind]['label
'];
2903 if ($actioncommreminder->fk_user > 0) {
2904 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2905 print ' (
'.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')
';
2907 print ' -
'.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit];
2909 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2910 print ' - <span class=
"opacitymedium">
';
2911 print $langs->trans("NotSent");
2913 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2914 print ' - <span class=
"opacitymedium">
';
2915 print $langs->trans("Done");
2917 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2918 print ' - <span class=
"opacitymedium">
';
2919 print $form->textwithpicto($langs->trans("Error"), $actioncommreminder->lasterror);
2933 print '<div class=
"clearboth"></div>
';
2935 print dol_get_fiche_end();
2942 print '<div class=
"tabsAction">
';
2945 $reshook = $hookmanager->executeHooks('addMoreActionsButtons
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2946 if (empty($reshook)) {
2947 if ($action != 'edit
') {
2948 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
2949 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
2950 print '<div class=
"inline-block divButAction"><a class=
"butAction" href=
"card.php?action=edit&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Modify").'</a></div>
';
2952 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Modify").'</a></div>
';
2955 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
2956 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
2957 print '<div class=
"inline-block divButAction"><a class=
"butAction butActionClone" href=
"card.php?action=clone&token='.newToken().'&object='.$object->element.'&id='.$object->id.'">
'.$langs->trans("ToClone").'</a></div>
';
2959 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("ToClone").'</a></div>
';
2962 if ($usercandelete) {
2963 print '<div class=
"inline-block divButAction"><a class=
"butActionDelete" href=
"card.php?action=delete&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Delete").'</a></div>
';
2965 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Delete").'</a></div>
';
2972 if ($action != 'edit
') {
2973 if (!getDolGlobalString('AGENDA_DISABLE_BUILDDOC
')) {
2974 print '<div class=
"clearboth"></div><div class=
"fichecenter"><div class=
"fichehalfleft">
';
2975 print '<a
name=
"builddoc"></a>
'; // ancre
2977 // Generated documents
2978 $filedir = $conf->agenda->multidir_output[$conf->entity].'/
'.$object->id;
2979 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
2981 $genallowed = $user->hasRight('agenda
', 'myactions
', 'read
');
2982 $delallowed = $user->hasRight('agenda
', 'myactions
', 'create
');
2984 print $formfile->showdocuments('actions
', (string) $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang());
2986 if (getDolGlobalString('AGENDA_ENABLE_LINKED_ELEMENTS
')) {
2987 // Show links to link elements
2988 $tmparray = $form->showLinkToObjectBlock($object, [], array('myobject
'), 1);
2989 if (is_array($tmparray)) {
2990 $linktoelem = $tmparray['linktoelem
'];
2991 $htmltoenteralink = $tmparray['htmltoenteralink
'];
2992 print $htmltoenteralink;
2993 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
2995 // backward compatibility
2996 $somethingshown = $form->showLinkedObjectBlock($object, $tmparray);
2999 print '</div><div class=
"fichehalfright">
';
3001 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.
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getElementProperties($elementType)
Get an array with properties of an element.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
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)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
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.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
$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.