35require
'../../main.inc.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncommreminder.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
60$langs->loadLangs([
"companies",
"other",
"commercial",
"bills",
"orders",
"agenda",
"mails"]);
63$action =
GETPOST(
'action',
'aZ09');
64$cancel =
GETPOST(
'cancel',
'alpha');
65$backtopage =
GETPOST(
'backtopage',
'alpha');
66$socpeopleassigned =
GETPOST(
'socpeopleassigned',
'array');
67$origin =
GETPOST(
'origin',
'alpha');
69$confirm =
GETPOST(
'confirm',
'alpha');
71$fulldayevent =
GETPOST(
'fullday',
'alpha');
78$addreminder =
GETPOST(
'addreminder',
'alpha');
80$offsetunit =
GETPOST(
'offsetunittype_duration',
'aZ09');
81$remindertype =
GETPOST(
'selectremindertype',
'aZ09');
82$modelmail =
GETPOSTINT(
'actioncommsendmodel_mail');
83$complete =
GETPOST(
'complete',
'alpha');
84$private =
GETPOST(
'private',
'alphanohtml');
85if ($complete ==
'na' || $complete == -2) {
102 if (
GETPOST(
'datep') ==
'now') {
104 } elseif (preg_match(
'/^([0-9]{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;
139$form =
new Form($db);
144if ($id > 0 && $action !=
'add') {
148 $ret =
$object->fetch_optionals();
149 $ret1 =
$object->fetch_userassigned();
151 if ($ret < 0 || $ret1 < 0) {
157$extrafields->fetch_name_optionals_label(
$object->table_element);
159if (empty($action) && empty(
$object->id)) {
164$hookmanager->initHooks([
'actioncard',
'globalcard']);
168 $TRemindTypes[
'browser'] = [
169 'label' => $langs->trans(
'BrowserPush'),
171 'type' => ActionCommReminder::TYPE_USER,
172 'data-html' =>
img_picto(
'',
'globe',
'class="pictofixedwidth"') . $langs->trans(
'BrowserPush'),
176 $TRemindTypes[
'email'] = [
177 'label' => $langs->trans(
'EMail'),
179 'type' => ActionCommReminder::TYPE_USER,
180 'data-html' =>
img_picto(
'',
'email',
'class="pictofixedwidth"') . $langs->trans(
'EMail'),
185 $TRemindTypes[
'sms'] = [
186 'label' => $langs->trans(
'Sms'),
188 'type' => ActionCommReminder::TYPE_USER,
189 'data-html' =>
img_picto(
'',
'phoning_mobile',
'class="pictofixedwidth"') . $langs->trans(
'Sms'),
192$TDurationTypes = $form->getDurationTypes($langs);
193$TDurationTypesExcluded = [
'y',
'm',
's'];
197 'TRemindTypes' => &$TRemindTypes,
198 'enablereminders' => &$enablereminders,
199 'TDurationTypes' => &$TDurationTypes,
200 'TDurationTypesExcluded' => &$TDurationTypesExcluded,
202$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
207$result =
restrictedArea($user,
'agenda', $object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
209$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || ((empty(
$object->id) ||
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
210$usercandelete = $user->hasRight(
'agenda',
'allactions',
'delete') || ((
$object->authorid === $user->id ||
$object->userownerid === $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'));
217$listUserAssignedUpdated =
false;
218$listResourceAssignedUpdated =
false;
222if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
223 $idtoremove =
GETPOST(
'removedassigned');
225 if (!empty($_SESSION[
'assignedtouser'])) {
226 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'],
true);
228 $tmpassigneduserids = [];
231 foreach ($tmpassigneduserids as $key => $val) {
232 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
233 unset($tmpassigneduserids[$key]);
237 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
238 $donotclearsession = 1;
239 if ($action ==
'add') {
242 if ($action ==
'update') {
246 $listUserAssignedUpdated =
true;
249if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
250 $idtoremove =
GETPOST(
'removedassignedresource');
252 if (!empty($_SESSION[
'assignedtoresource'])) {
253 $tmpassignedresourceids = json_decode($_SESSION[
'assignedtoresource'],
true);
255 $tmpassignedresourceids = [];
258 foreach ($tmpassignedresourceids as $key => $val) {
259 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
260 unset($tmpassignedresourceids[$key]);
264 $_SESSION[
'assignedtoresource'] = json_encode($tmpassignedresourceids);
266 if ($action ==
'add' && $usercancreate) {
269 if ($action ==
'update' && $usercancreate) {
273 $listResourceAssignedUpdated =
true;
277if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
279 if (
GETPOST(
'assignedtouser') > 0) {
280 $assignedtouser = [];
281 if (!empty($_SESSION[
'assignedtouser'])) {
282 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
284 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id' =>
GETPOSTINT(
'assignedtouser'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
285 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
287 $donotclearsession = 1;
288 if ($action ==
'add' && $usercancreate) {
291 if ($action ==
'update' && $usercancreate) {
295 $listUserAssignedUpdated =
true;
299if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
301 if (
GETPOST(
'assignedtoresource') > 0) {
302 $assignedtoresource = [];
303 if (!empty($_SESSION[
'assignedtoresource'])) {
304 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
306 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id' =>
GETPOSTINT(
'assignedtoresource'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
307 $_SESSION[
'assignedtoresource'] = json_encode($assignedtoresource);
309 $donotclearsession = 1;
310 if ($action ==
'add' && $usercancreate) {
313 if ($action ==
'update' && $usercancreate) {
317 $listResourceAssignedUpdated =
true;
321if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
322 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
328if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
330 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
335 if (!empty(
$object->socpeopleassigned)) {
336 reset(
$object->socpeopleassigned);
341 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
352if (empty($reshook) && $action ==
'add' && $usercancreate) {
355 if (empty($backtopage)) {
357 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
359 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
363 if (!empty($socpeopleassigned[0])) {
364 $result = $contact->fetch($socpeopleassigned[0]);
368 header(
"Location: ".$backtopage);
372 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
385 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
388 if (!$datef && $percentage == 100) {
390 $donotclearsession = 1;
392 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
397 $donotclearsession = 1;
399 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
403 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
405 $donotclearsession = 1;
407 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
412 $listofresourceid = [];
417 $object->fulldayevent = ($fulldayevent ? 1 : 0);
421 if (
GETPOST(
"elementtype",
'alpha')) {
423 $modulecodetouseforpermissioncheck = $elProp[
'module'];
425 if ($modulecodetouseforpermissioncheck ==
'productbatch') {
426 $modulecodetouseforpermissioncheck =
'produit';
428 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
430 $hasPermissionOnLinkedObject = 0;
431 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
432 $hasPermissionOnLinkedObject = 1;
433 } elseif ($user->hasRight($modulecodetouseforpermissioncheck, $submodulecodetouseforpermissioncheck,
'read')) {
434 $hasPermissionOnLinkedObject = 1;
437 if ($hasPermissionOnLinkedObject) {
445 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
446 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
448 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
449 $object->label = $langs->transnoentitiesnoconv(
"Action".
$object->type_code).
"\n";
451 $cactioncomm->fetch(
$object->type_code);
452 $object->label = $cactioncomm->label;
459 if (!empty($taskid)) {
460 $taskProject =
new Task($db);
461 if ($taskProject->fetch($taskid) > 0) {
462 $object->fk_project = $taskProject->fk_project;
467 $object->elementtype =
'project_task';
472 $object->percentage = $percentage;
475 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
478 if (!empty($_SESSION[
'assignedtouser'])) {
479 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
482 if (!empty($_SESSION[
'assignedtoresource'])) {
483 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
487 foreach ($listofuserid as $key => $value) {
489 if ($value[
'id'] > 0) {
490 $object->userownerid = $value[
'id'];
492 $object->transparency = $transparency;
495 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
503 if (GETPOSTISSET(
"contactid")) {
514 if (empty(
$object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
516 $donotclearsession = 1;
518 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
520 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
522 $donotclearsession = 1;
524 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
529 $donotclearsession = 1;
531 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
534 foreach ($socpeopleassigned as $cid) {
535 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
537 if (!empty(
$object->socpeopleassigned)) {
538 reset(
$object->socpeopleassigned);
543 $ret = $extrafields->setOptionalsFromPost(
null, $object);
546 $donotclearsession = 1;
558 $selectedrecurrulefreq =
'no';
559 $selectedrecurrulebyyearmonthday =
'';
560 $selectedrecurrulebymonthday =
'';
561 $selectedrecurrulebyday =
'';
562 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
563 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'YEARLY') ?
"_BYYEARMONTHDAY".((
int) $dayinyear) :
"";
564 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY') ?
"_BYMONTHDAY".((
int) $dayinmonth) :
"";
565 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY') ?
"_BYDAY".((
int) $dayinweek) :
"";
571 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
572 $selectedrecurrulefreq = $reg1[1];
574 if (
$object->recurrule && preg_match(
'/FREQ=YEARLY.*BYYEARMONTHDAY(\d+)/i',
$object->recurrule, $reg4)) {
575 $selectedrecurrulebyyearmonthday = (int) $reg4[1];
577 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
578 $selectedrecurrulebymonthday = (int) $reg2[1];
580 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
581 $selectedrecurrulebyday = (int) $reg3[1];
585 $eventisrecurring = 0;
586 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
587 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
588 $eventisrecurring = 1;
598 $idaction =
$object->create($user);
603 if (is_array($listofresourceid) && count($listofresourceid)) {
604 foreach ($listofresourceid as $resource_id => $val) {
605 $resource_type =
'dolresource';
610 $eventDateStart =
$object->datep;
611 $eventDateEnd =
$object->datef;
612 $isFullDayEvent =
$object->fulldayevent;
613 if (empty($eventDateEnd)) {
614 if ($isFullDayEvent) {
616 $eventDateStart =
dol_mktime(0, 0, 0, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
617 $eventDateEnd =
dol_mktime(23, 59, 59, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
621 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
622 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_resources as er";
623 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) .
"'";
624 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape(
$object->element) .
"'";
625 $sql .=
" WHERE er.resource_id = " . ((int) $resource_id);
626 $sql .=
" AND er.busy = 1";
630 $sql .=
" (ac.datep <= '" . $db->idate($eventDateStart) .
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) .
"'))";
632 if (!empty($eventDateEnd)) {
633 $sql .=
" OR (ac.datep <= '" . $db->idate($eventDateEnd) .
"' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) .
"'))";
637 $sql .=
"ac.datep >= '" . $db->idate($eventDateStart) .
"'";
638 if (!empty($eventDateEnd)) {
639 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) .
"')";
644 $resql = $db->query($sql);
647 $object->error = $db->lasterror();
650 if ($db->num_rows($resql) > 0) {
653 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse') .
' : ';
654 while ($obj = $db->fetch_object($resql)) {
655 $object->error .=
'<br> - ' . $langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label .
' [' . $obj->ac_id .
']');
666 $res =
$object->add_element_resource($resource_id, $resource_type, $busy, $val[
'mandatory']);
671 unset($_SESSION[
'assignedtoresource']);
676 $categories =
GETPOST(
'categories',
'array');
677 $object->setCategories($categories);
680 unset($_SESSION[
'assignedtouser']);
682 if ($user->id !=
$object->userownerid) {
683 $moreparam =
"filtert=-1";
687 if (!$error && $addreminder ==
'on') {
692 $actionCommReminder->dateremind = $dateremind;
693 $actionCommReminder->typeremind = $remindertype;
694 $actionCommReminder->offsetunit = $offsetunit;
695 $actionCommReminder->offsetvalue = $offsetvalue;
696 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
697 $actionCommReminder->fk_actioncomm =
$object->id;
698 if ($remindertype ==
'email') {
699 $actionCommReminder->fk_email_template = $modelmail;
703 foreach (
$object->userassigned as $userassigned) {
704 $actionCommReminder->fk_user = $userassigned[
'id'];
705 $res = $actionCommReminder->create($user);
709 $langs->load(
"errors");
711 setEventMessages($langs->trans(
'ErrorReminderActionCommCreation'),
null,
'errors');
713 $donotclearsession = 1;
724 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
737 $langs->load(
"errors");
741 $donotclearsession = 1;
747 $donotclearsession = 1;
751 if (!$error && $eventisrecurring) {
756 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
758 $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');
763 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
764 $firstday = $selectedrecurrulebymonthday;
771 } elseif ($selectedrecurrulefreq ==
'YEARLY' && !empty($selectedrecurrulebyyearmonthday)) {
786 while ($datep <= $repeateventlimitdate && !$error) {
790 $finalobject->datep = $datep;
791 $finalobject->datef = $datef;
793 $idaction = $finalobject->create($user);
796 if (!$finalobject->error) {
798 $categories =
GETPOST(
'categories',
'array');
799 $finalobject->setCategories($categories);
801 unset($_SESSION[
'assignedtouser']);
804 if ($user->id != $finalobject->userownerid) {
805 $moreparam =
"filtert=-1";
809 if ($addreminder ==
'on') {
814 $actionCommReminder->dateremind = $dateremind;
815 $actionCommReminder->typeremind = $remindertype;
816 $actionCommReminder->offsetunit = $offsetunit;
817 $actionCommReminder->offsetvalue = $offsetvalue;
818 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
819 $actionCommReminder->fk_actioncomm = $finalobject->id;
820 if ($remindertype ==
'email') {
821 $actionCommReminder->fk_email_template = $modelmail;
825 foreach ($finalobject->userassigned as $userassigned) {
826 $actionCommReminder->fk_user = $userassigned[
'id'];
827 $res = $actionCommReminder->create($user);
832 $langs->load(
"errors");
833 setEventMessages($langs->trans(
'ErrorReminderActionCommCreation'),
null,
'errors');
835 $donotclearsession = 1;
846 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
850 $langs->load(
"errors");
851 $error = $langs->trans($finalobject->error);
854 $donotclearsession = 1;
860 $donotclearsession = 1;
864 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
884 if (!empty($backtopage) && !$error) {
885 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
886 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
887 } elseif ($idaction) {
888 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
890 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
897if (empty($reshook) && $action ==
'update' && $usercancreate) {
898 if (empty($cancel)) {
899 $fulldayevent =
GETPOST(
'fullday');
904 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
932 if (!GETPOSTISSET(
'ap') && !GETPOSTISSET(
'aphour') && !GETPOSTISSET(
'apmin')) {
937 if (!GETPOSTISSET(
'p2') && !GETPOSTISSET(
'p2hour') && !GETPOSTISSET(
'p2min')) {
945 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
947 if (
$object->elementtype ==
'ticket') {
949 if (
$object->code ==
'TICKET_MSG') {
950 $object->code =
'TICKET_MSG_PRIVATE';
952 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
953 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
956 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
959 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
960 $object->code =
'TICKET_MSG_SENTBYMAIL';
972 $object->percentage = $percentage;
977 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
978 $object->socpeopleassigned = [];
979 foreach ($socpeopleassigned as $cid) {
980 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
983 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
984 reset(
$object->socpeopleassigned);
989 if (!empty($taskid)) {
990 $taskProject =
new Task($db);
991 if ($taskProject->fetch($taskid) > 0) {
992 $object->fk_project = $taskProject->fk_project;
997 $object->elementtype =
'project_task';
1002 if (
GETPOST(
"elementtype",
'alpha')) {
1004 $modulecodetouseforpermissioncheck = $elProp[
'module'];
1006 if ($modulecodetouseforpermissioncheck ==
'productbatch') {
1007 $modulecodetouseforpermissioncheck =
'produit';
1010 $hasPermissionOnLinkedObject = 0;
1011 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
1012 $hasPermissionOnLinkedObject = 1;
1014 if ($hasPermissionOnLinkedObject) {
1022 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
1026 if (!empty($_SESSION[
'assignedtouser'])) {
1028 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
1029 foreach ($tmplist1 as $key => $val) {
1030 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
1031 $listofuserid[$val[
'id']] = $val;
1035 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
1036 if ($assignedtouser) {
1037 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
1043 foreach ($listofuserid as $key => $val) {
1045 $object->userownerid = $val[
'id'];
1047 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
1051 $object->transparency = $transparency;
1055 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
1057 $donotclearsession = 1;
1059 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1061 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
1063 if (empty(
$object->userownerid)) {
1065 $donotclearsession = 1;
1067 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
1071 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
1079 $eventDateStart =
$object->datep;
1080 $eventDateEnd =
$object->datef;
1082 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1083 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1084 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1085 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1086 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1087 $sql .=
" AND er.resource_id IN (";
1088 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1089 $sql .=
" WHERE element_id = ".((int)
$object->id);
1090 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1091 $sql .=
" AND busy = 1";
1093 $sql .=
" AND er.busy = 1";
1097 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1099 if (!empty($eventDateEnd)) {
1100 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1104 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1105 if (!empty($eventDateEnd)) {
1106 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1111 $resql = $db->query($sql);
1114 $object->error = $db->lasterror();
1117 if ($db->num_rows($resql) > 0) {
1120 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1121 while ($obj = $db->fetch_object($resql)) {
1122 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1138 $result =
$object->update($user);
1142 $categories =
GETPOST(
'categories',
'array');
1143 $object->setCategories($categories);
1145 $object->loadReminders($remindertype, 0,
false);
1148 if (!empty(
$object->reminders)) {
1149 foreach (
$object->reminders as $reminder) {
1150 if ($reminder->status < 1) {
1151 $reminder->delete($user);
1158 if ($addreminder ==
'on') {
1163 $actionCommReminder->dateremind = $dateremind;
1164 $actionCommReminder->typeremind = $remindertype;
1165 $actionCommReminder->offsetunit = $offsetunit;
1166 $actionCommReminder->offsetvalue = $offsetvalue;
1167 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
1168 $actionCommReminder->fk_actioncomm =
$object->id;
1169 if ($remindertype ==
'email') {
1170 $actionCommReminder->fk_email_template = $modelmail;
1174 foreach (
$object->userassigned as $userassigned) {
1175 $actionCommReminder->fk_user = $userassigned[
'id'];
1179 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1180 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".$db->escape($remindertype).
"'";
1181 $resqldelete = $db->query($sqldelete);
1183 $res = $actionCommReminder->create($user);
1187 $langs->load(
"errors");
1188 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1191 $donotclearsession = 1;
1198 unset($_SESSION[
'assignedtouser']);
1199 unset($_SESSION[
'assignedtoresource']);
1214 if (!empty($backtopage)) {
1215 unset($_SESSION[
'assignedtouser']);
1216 header(
"Location: ".$backtopage);
1223if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes' && $usercandelete) {
1226 $object->fetch_userassigned();
1229 $result =
$object->delete($user);
1232 header(
"Location: index.php");
1243if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate' && $usercancreate) {
1249 $newdate =
GETPOST(
'newdate',
'alpha');
1250 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1251 header(
"Location: ".$backtopage,
true, 307);
1255 $datep =
dol_mktime($shour, $smin, 0, (
int) substr($newdate, 13, 2), (
int) substr($newdate, 15, 2), (
int) substr($newdate, 9, 4),
'tzuserrel');
1258 if ($datep !=
$object->datep) {
1267 $eventDateStart =
$object->datep;
1268 $eventDateEnd =
$object->datef;
1270 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1271 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1272 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1273 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1274 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1275 $sql .=
" AND er.resource_id IN (";
1276 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1277 $sql .=
" WHERE element_id = ".((int)
$object->id);
1278 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1279 $sql .=
" AND busy = 1";
1281 $sql .=
" AND er.busy = 1";
1285 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1287 if (!empty($eventDateEnd)) {
1288 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1292 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1293 if (!empty($eventDateEnd)) {
1294 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1299 $resql = $db->query($sql);
1302 $object->error = $db->lasterror();
1305 if ($db->num_rows($resql) > 0) {
1308 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1309 while ($obj = $db->fetch_object($resql)) {
1310 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1325 $result =
$object->update($user);
1335 if (!empty($backtopage)) {
1336 header(
"Location: ".$backtopage,
true, 307);
1345$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1346if (empty($reshook)) {
1347 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1355$form =
new Form($db);
1358$arrayrecurrulefreq = array(
1359 'no' => $langs->trans(
"OnceOnly"),
1360 'YEARLY' => $langs->trans(
"EveryYear"),
1361 'MONTHLY' => $langs->trans(
"EveryMonth"),
1362 'WEEKLY' => $langs->trans(
"EveryWeek")
1367$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1368llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1370if ($action ==
'create') {
1373 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1374 if (!empty($socpeopleassigned[0])) {
1375 $result = $contact->fetch($socpeopleassigned[0]);
1383 if (!empty($conf->use_javascript_ajax)) {
1384 print
"\n".
'<script type="text/javascript">';
1385 print
'$(document).ready(function () {
1386 function setdatefields()
1388 if ($("#fullday:checked").val() == null) {
1389 $(".fulldaystarthour").removeAttr("disabled");
1390 $(".fulldaystartmin").removeAttr("disabled");
1391 $(".fulldayendhour").removeAttr("disabled");
1392 $(".fulldayendmin").removeAttr("disabled");
1393 $("#p2").removeAttr("disabled");
1395 $(".fulldaystarthour").prop("disabled", true).val("00");
1396 $(".fulldaystartmin").prop("disabled", true).val("00");
1397 $(".fulldayendhour").prop("disabled", true).val("23");
1398 $(".fulldayendmin").prop("disabled", true).val("59");
1399 $("#p2").removeAttr("disabled");
1402 $("#fullday").change(function() {
1403 console.log("setdatefields");
1406 var old_startdate = null;
1407 $("#ap").focus(function() {
1408 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1410 $("#ap").next(".ui-datepicker-trigger").click(function() {
1411 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1413 $("#ap").change(function() {
1414 setTimeout(function() {
1415 if ($("#p2").val() !== "") {
1416 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1417 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1418 if (new_startdate > old_enddate) {
1419 var timeDiff = old_enddate - old_startdate;
1420 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1421 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1422 $("#p2day").val(new_enddate.getDate());
1423 $("#p2month").val(new_enddate.getMonth() + 1);
1424 $("#p2year").val(new_enddate.getFullYear());
1429 $("#actioncode").change(function() {
1430 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1431 else $("#dateend").removeClass("fieldrequired");
1433 $("#aphour,#apmin").change(function() {
1434 if ($("#actioncode").val() == \'AC_RDV\') {
1435 var oldhour = parseInt($("#aphour").val());
1436 var oldmin = parseInt($("#apmin").val());
1437 var oldday = parseInt($("#apday").val());
1438 var oldmonth = $("#apmonth").val();
1439 var oldyear = $("#apyear").val();
1441 var newhour = oldhour + 1;
1442 var newday = oldday;
1443 var newmonth = oldmonth;
1444 var newyear = oldyear;
1445 if (newhour >= 24) {
1447 newday = oldday + 1;
1449 console.log("Start date was changed, we modify end date "+oldhour+" "+oldmin+" -> "+newhour+" "+oldmin);
1450 $("#p2hour").val(("00" + newhour).substr(-2,2));
1451 $("#p2min").val(("00" + oldmin).substr(-2,2));
1452 $("#p2day").val(newday);
1453 $("#p2month").val(newmonth);
1454 $("#p2year").val(newyear);
1455 $("#p2").val($("#ap").val());
1458 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1459 else $("#dateend").removeClass("fieldrequired");
1462 print
'</script>'.
"\n";
1465 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1466 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1467 print
'<input type="hidden" name="action" value="add">';
1468 print
'<input type="hidden" name="donotclearsession" value="1">';
1469 print
'<input type="hidden" name="page_y" value="">';
1471 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1474 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1481 print
'<div class="divcreate">';
1482 print
'<table class="border centpercent nobottom">';
1485 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>';
1489 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1491 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1492 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1493 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1498 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1499 print
'<td class="valignmiddle height30">';
1501 print
'<input class="valignmiddle" type="checkbox" id="fullday" name="fullday" '.(GETPOST(
'fullday') ?
' checked' :
'').
'><label for="fullday" class="valignmiddle small">'.$langs->trans(
"EventOnFullDay").
'</label>';
1505 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1506 if (
GETPOST(
'datep',
'alpha', 1)) {
1509 $datef = ($datef ? $datef :
$object->datef);
1510 if (
GETPOST(
'datef',
'alpha', 1)) {
1513 if (empty($datef) && !empty($datep)) {
1520 print
'<tr><td class="nowrap">';
1522 print
'<div class="inline-block">';
1524 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1526 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1528 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1529 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 0, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1535 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
1536 if ($userepeatevent) {
1538 print
'<div class="clearbothonsmartphone hideonsmartphone inline-block"> </div>';
1541 print
'<div class="inline-block small" data-html="repeat">';
1542 print
'<span class="opacitymedium">';
1543 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 3px" class="paddingright"');
1544 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1546 $selectedrecurrulefreq =
'no';
1547 $selectedrecurrulebyyearmonthday =
'';
1548 $selectedrecurrulebymonthday =
'';
1549 $selectedrecurrulebyday =
'';
1550 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1551 $object->recurrule .= GETPOSTISSET(
'BYYEARMONTHDAY') ?
"_BYYEARMONTHDAY".GETPOST(
'BYYEARMONTHDAY',
'alpha') :
"";
1552 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1553 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1557 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1558 $selectedrecurrulefreq = $reg[1];
1560 if (
$object->recurrule && preg_match(
'/FREQ=YEARLY.*BYYEARMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1561 $selectedrecurrulebyyearmonthday = (int) $reg[1];
1563 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1564 $selectedrecurrulebymonthday = (int) $reg[1];
1566 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1567 $selectedrecurrulebyday = (int) $reg[1];
1570 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly minwidth125 maxwidth150');
1588 $repeateventlimitdate = empty($repeateventlimitdate) ? (
dol_now() + ((24 * 3600 * 365) + 1)) : $repeateventlimitdate;
1590 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1591 print $langs->trans(
"Until").
" ";
1592 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1595 <script
type=
"text/javascript">
1596 jQuery(document).ready(
function() {
1597 function init_repeat() {
1598 console.log(
"recurrule: " +
"<?php echo $object->recurrule; ?>");
1599 console.log(
"reg1: " +
"<?php echo $selectedrecurrulefreq; ?>");
1600 console.log(
"reg2: " +
"<?php echo $selectedrecurrulebymonthday; ?>");
1601 console.log(
"reg3: " +
"<?php echo $selectedrecurrulebyday; ?>");
1602 console.log(
"reg4: " +
"<?php echo $selectedrecurrulebyyearmonthday; ?>");
1603 console.log(
"selectedrulefreq: " +
"<?php echo $selectedrecurrulefreq; ?>");
1604 if (jQuery(
"#recurrulefreq").val() ==
'YEARLY') {
1606 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1607 jQuery(
".repeateventBYMONTHDAY").hide();
1608 jQuery(
".repeateventBYDAY").hide();
1609 }
else if (jQuery(
"#recurrulefreq").val() ==
'MONTHLY') {
1611 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1612 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1613 jQuery(
".repeateventBYDAY").hide();
1614 }
else if (jQuery(
"#recurrulefreq").val() ==
'WEEKLY') {
1615 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1616 jQuery(
".repeateventBYMONTHDAY").hide();
1618 jQuery(
".repeateventlimitdate").css(
"display",
"inline-block");
1620 jQuery(
".repeateventBYYEARMONTHDAY").hide();
1621 jQuery(
".repeateventBYMONTHDAY").hide();
1622 jQuery(
".repeateventBYDAY").hide();
1623 jQuery(
".repeateventlimitdate").hide();
1627 jQuery(
"#recurrulefreq").change(
function() {
1642 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Location").
'</td><td>';
1643 print
img_picto(
'',
'map-marker-alt',
'class="pictofixedwidth"');
1644 print
'<input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.(GETPOST(
'location') ?
GETPOST(
'location') :
$object->location).
'"></td></tr>';
1652 print
'<div class="divcreate">';
1653 print
'<table class="border centpercent nobottom">';
1656 print
'<tr><td class="nowrap titlefieldcreate"><span>';
1657 print $langs->trans(
"AssignedTo");
1658 print
'</span></td><td>';
1660 $listofcontactid = [];
1661 $listofotherid = [];
1663 if (empty($donotclearsession)) {
1665 if ($assignedtouser) {
1666 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1669 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1670 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1672 if (!empty($_SESSION[
'assignedtouser'])) {
1673 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1675 if (!is_array($listofuserid)) {
1678 $firstelem = reset($listofuserid);
1679 if (isset($listofuserid[$firstelem[
'id']])) {
1680 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1683 print
'<!-- list of user to assign -->'.
"\n";
1684 print
'<div class="assignedtouser">';
1685 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, [], 0,
'', [],
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid);
1691 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1693 $listofresourceid = [];
1694 if (empty($donotclearsession)) {
1695 $assignedtoresource =
GETPOST(
"assignedtoresource");
1696 if ($assignedtoresource) {
1697 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1699 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1701 if (!empty($_SESSION[
'assignedtoresource'])) {
1702 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1704 if (!is_array($listofresourceid)) {
1705 $listofresourceid = [];
1707 $firstelem = reset($listofresourceid);
1708 if ($firstelem && isset($listofresourceid[$firstelem[
'id']])) {
1709 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1712 print
'<div class="assignedtoresource">';
1713 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1, [], 0,
'', [],
'0', 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1720 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1721 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories', $object);
1731 print
'<div class="divcreate">';
1732 print
'<table class="border centpercent nobottom">';
1735 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td>';
1737 $percent = $complete !==
'' ? $complete : -1;
1738 if (GETPOSTISSET(
'status')) {
1740 } elseif (GETPOSTISSET(
'percentage')) {
1743 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1745 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1749 print $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'minwidth150 maxwidth300', 1);
1754 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1758 print $societe->getNomUrl(1);
1759 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1762 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1764 if (!empty($user->socid)) {
1765 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1767 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
'',
'socid',
'', $langs->trans(
'SelectThirdParty'), 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1773 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1774 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1778 if ($origin ==
'contact') {
1784 $select_contact_default = 0;
1786 $select_contact_default = -1;
1788 print
img_picto(
'',
'contact',
'class="pictofixedwidth"');
1790 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
1797 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1798 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, [],
'multiple',
'contactid');
1799 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1801 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, [],
'multiple',
'contactid');
1809 $langs->load(
"projects");
1813 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1814 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1815 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');
1817 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1818 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1819 $urloption =
'?action=create&donotclearsession=1';
1824 <script
type=
"text/javascript">
1825 $(document).ready(
function () {
1826 $(
"#projectid").change(
function () {
1827 var url =
"<?php echo DOL_URL_ROOT; ?>/projet/ajax/projects.php?mode=gettasks&socid="+$(
"#search_socid").val()+
"&projectid="+$(
"#projectid").val();
1828 console.log(
"Call url to get the new list of tasks: "+url);
1829 $.get(url,
function(data) {
1831 if (data) $(
"#taskid").html(data).select2();
1841 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1842 print
img_picto(
'',
'projecttask',
'class="pictofixedwidth"');
1843 $projectsListId =
'';
1844 if (!empty($projectid)) {
1845 $projectsListId = $projectid;
1848 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1850 if (empty($projectsListId)) {
1851 print
'<select class="valignmiddle flat maxwidth500 widthcentpercentminusxx minwidth150imp" id="taskid" name="taskid">';
1852 print
'<option class="opacitymedium"> </option>';
1853 print
'<option class="opacitymedium" disabled data-html="'.dolPrintHTMLForAttribute($langs->trans(
"SelectAProjectFirst")).
'">'.$langs->trans(
"SelectAProjectFirst").
'</option>';
1857 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 64, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (string) $projectsListId,
'all', null, 1);
1863 if (!empty($origin) && !empty($originid)) {
1864 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1866 $hasPermissionOnLinkedObject = 0;
1869 $modulecodetouseforpermissioncheck = $elProp[
'module'];
1871 if ($modulecodetouseforpermissioncheck ==
'productbatch') {
1872 $modulecodetouseforpermissioncheck =
'produit';
1874 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read') || $user->hasRight($modulecodetouseforpermissioncheck, $elProp[
'element'],
'read')) {
1875 $hasPermissionOnLinkedObject = 1;
1879 if (! in_array($origin, array(
'societe',
'project',
'project_task',
'user'))) {
1881 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1882 print
'<td colspan="3">';
1883 if ($hasPermissionOnLinkedObject) {
1885 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1886 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1887 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1888 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1890 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1898 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1899 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1904 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1905 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1906 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 100,
'dolibarr_notes',
'In', true, true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1907 $doleditor->Create();
1912 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1913 print $hookmanager->resPrint;
1914 if (empty($reshook)) {
1915 print
$object->showOptionals($extrafields,
'create', $parameters);
1921 if ($enablereminders) {
1925 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>';
1927 print
'<div class="reminderparameters" '.(empty(
GETPOST(
'addreminder')) ?
'style="display: none;' :
'').
' ">';
1930 print
'<table class="border centpercent">';
1933 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1934 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1936 print $form->selectTypeDuration(
'offsetunit', (empty($offsetunit) ?
'i' : $offsetunit), $TDurationTypesExcluded);
1940 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1941 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1946 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1947 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (empty($modelmail) ? 0 : $modelmail));
1954 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
1955 $reminderDefaultOffset =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_OFFSET', 30);
1957 $reminderDefaultEmailModel =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
1959 print
"\n".
'<script type="text/javascript">';
1960 print
'$(document).ready(function () {
1961 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
1962 $(
"#actioncode").change(
function(){
1963 var selected_event_type = $(
"#actioncode option:selected").val();
1965 if (reminderDefaultEventTypes.includes(selected_event_type)) {
1966 $(
".reminderparameters").show();
1967 $(
"#addreminder").prop(
"checked",
true);
1970 $(
"[name=\"offsetvalue\"]").val(\
'' .
dol_escape_js((
string) $reminderDefaultOffset) .
'\');
1971 $(
"#select_offsetunittype_duration").select2(
"destroy");
1972 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
1973 $(
"#select_offsetunittype_duration").select2();
1975 $(
"#selectremindertype").select2(
"destroy");
1976 $(
"#selectremindertype").val(
"email");
1977 $(
"#selectremindertype").select2();
1980 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
1981 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
1982 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js((
string) $reminderDefaultEmailModel).
'\');
1983 $(
"#select_actioncommsendmodel_mail").select2();
1987 print '</script>
'."\n";
1989 print "\n".'<script
type=
"text/javascript">
';
1990 print '$(document).ready(
function () {
1991 function toggle_reminder_part(evt) {
1992 console.log(
"Toggle reminder part");
1993 if ($(
"#addreminder").is(
":checked")) {
1994 $(
".reminderparameters").show();
1996 $(
".reminderparameters").hide();
1998 $(
"#selectremindertype").select2(
"destroy");
1999 $(
"#selectremindertype").select2();
2000 $(
"#select_offsetunittype_duration").select2(
"destroy");
2001 $(
"#select_offsetunittype_duration").select2();
2002 selectremindertype();
2005 toggle_reminder_part();
2006 $(
"#addreminder").click(toggle_reminder_part);
2008 $(
"#selectremindertype").change(
function(){
2009 selectremindertype();
2012 function selectremindertype() {
2013 console.log(
"Call selectremindertype");
2014 var selected_option = $(
"#selectremindertype option:selected").val();
2015 if(selected_option ==
"email") {
2016 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2018 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
2023 print '</script>
'."\n";
2026 print dol_get_fiche_end();
2028 print $form->buttonsSaveCancel("Create");
2034if ($id > 0 && $action != 'create
') {
2035 $result1 = $object->fetch($id);
2036 if ($result1 <= 0) {
2037 recordNotFound('', 0);
2040 $result2 = $object->fetch_thirdparty();
2041 $result2 = $object->fetchProject();
2042 $result3 = $object->fetch_contact();
2043 $result4 = $object->fetch_userassigned();
2044 $result5 = $object->fetch_optionals();
2046 if ($listUserAssignedUpdated || $donotclearsession) {
2047 $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
2049 $datep = dol_mktime($fulldayevent ? 0 : $aphour, $fulldayevent ? 0 : $apmin, 0, GETPOSTINT("apmonth"), GETPOSTINT("apday"), GETPOSTINT("apyear"), 'tzuserrel
');
2050 $datef = dol_mktime($fulldayevent ? 23 : $p2hour, $fulldayevent ? 59 : $p2min, $fulldayevent ? 59 : 0, GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), 'tzuserrel
');
2052 $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09
'), 'c_actioncomm
');
2053 $object->label = GETPOST("label", "alphanohtml");
2054 $object->datep = $datep;
2055 $object->datef = $datef;
2056 $object->percentage = $percentage;
2057 $object->priority = GETPOSTINT("priority");
2058 $object->fulldayevent = GETPOST("fullday") ? 1 : 0;
2059 $object->location = GETPOST('location
', "alphanohtml");
2060 $object->socid = GETPOSTINT("socid");
2061 $socpeopleassigned = GETPOST("socpeopleassigned", 'array
');
2062 foreach ($socpeopleassigned as $tmpid) {
2063 $object->socpeopleassigned[$id] = array('id' => $tmpid);
2065 $object->contact_id = GETPOSTINT("contactid");
2066 $object->fk_project = GETPOSTINT("projectid");
2068 $object->note_private = GETPOST("note", 'restricthtml
');
2071 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
2072 dol_print_error($db, $object->error);
2081 $head = actions_prepare_head($object);
2084 $delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO
') * 24 * 60 * 60;
2087 // Confirmation suppression action
2088 if ($action == 'delete') {
2089 print $form->formconfirm("card.php?id=".urlencode((string) ($id)), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1);
2092 if ($action == 'edit
') {
2093 $caneditdateorowner = ($object->type != 'systemauto
');
2095 if (!empty($conf->use_javascript_ajax)) {
2096 print "\n".'<script
type=
"text/javascript">
';
2097 print '$(document).ready(
function () {
2098 function setdatefields()
2100 if ($(
"#fullday:checked").val() ==
null) {
2101 $(
".fulldaystarthour").removeAttr(
"disabled");
2102 $(
".fulldaystartmin").removeAttr(
"disabled");
2103 $(
".fulldayendhour").removeAttr(
"disabled");
2104 $(
".fulldayendmin").removeAttr(
"disabled");
2106 $(
".fulldaystarthour").prop(
"disabled",
true).val(
"00");
2107 $(
".fulldaystartmin").prop(
"disabled",
true).val(
"00");
2108 $(
".fulldayendhour").prop(
"disabled",
true).val(
"23");
2109 $(
".fulldayendmin").prop(
"disabled",
true).val(
"59");
2113 '.($caneditdateorowner ? ' setdatefields();
' : '').'
2115 $(
"#fullday").change(
function() {
2118 var old_startdate =
null;
2119 $(
"#ap").focus(
function() {
2120 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2122 $(
"#ap").next(
".ui-datepicker-trigger").click(
function() {
2123 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2125 $(
"#ap").change(
function() {
2126 setTimeout(
function() {
2127 if ($(
"#p2").val() !==
"") {
2128 var new_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2129 var old_enddate =
new Date($(
"#p2year").val(), $(
"#p2month").val() - 1, $(
"#p2day").val());
2130 if (new_startdate > old_enddate) {
2131 var timeDiff = old_enddate - old_startdate;
2132 var new_enddate =
new Date(new_startdate.getTime() + timeDiff);
2133 $(
"#p2").val(formatDate(new_enddate,
"' . $langs->trans('FormatDateShortJavaInput') . '"));
2134 $(
"#p2day").val(new_enddate.getDate());
2135 $(
"#p2month").val(new_enddate.getMonth() + 1);
2136 $(
"#p2year").val(new_enddate.getFullYear());
2141 $(
"#actioncode").change(
function() {
2142 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
2143 else $("#dateend").removeClass("fieldrequired");
2146 print
'</script>'.
"\n";
2149 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
2150 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2151 print
'<input type="hidden" name="action" value="update">';
2152 print
'<input type="hidden" name="id" value="'.$id.
'">';
2153 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
2154 print
'<input type="hidden" name="page_y" value="">';
2156 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
2159 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2164 print
'<table class="border tableforfield centpercent">';
2167 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>'.
$object->id.
'</td></tr>';
2170 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>';
2174 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
2175 if (
$object->type_code !=
'AC_OTH_AUTO') {
2176 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
2177 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
2179 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2180 print
$object->getTypePicto();
2181 print $langs->trans(
"Action".
$object->type_code);
2187 if (
$object->elementtype ==
'ticket') {
2188 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
2189 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
2190 print
'</td><td><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
2194 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td class="valignmiddle height30 small">';
2195 print
'<input '.($caneditdateorowner ?
'' :
' disabled').
' type="checkbox" id="fullday" name="fullday" '.(
$object->fulldayevent ?
' checked' :
'').
'>';
2196 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
2259 print
'<tr><td class="nowrap">';
2262 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');
2263 print
' <span class="hideonsmartphone"> - </span> ';
2264 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');
2269 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>';
2270 print
img_picto(
'',
'map-marker-alt',
'class="pictofixedwidth"');
2271 print
'<input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.$object->location.
'"></td></tr>';
2274 print
'<tr class="tdsmallheight"><td class="tdsmallheight"> </td><td class="tdsmallheight"></td></tr>';
2278 if (empty($donotclearsession)) {
2279 if (
$object->userownerid > 0) {
2280 $listofuserid[
$object->userownerid] = array(
2284 'transparency' =>
$object->transparency,
2285 'answer_status' => (isset(
$object->userassigned[
$object->userownerid][
'answer_status']) ?
$object->userassigned[
$object->userownerid][
'answer_status'] : null),
2286 'mandatory' => (isset(
$object->userassigned[
$object->userownerid][
'mandatory']) ?
$object->userassigned[
$object->userownerid][
'mandatory'] : null)
2289 if (!empty(
$object->userassigned)) {
2291 $tmplist1 =
$object->userassigned;
2292 foreach ($tmplist1 as $key => $val) {
2293 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2294 $listofuserid[$val[
'id']] = $val;
2298 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2300 if (!empty($_SESSION[
'assignedtouser'])) {
2301 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2305 $listofcontactid =
$object->socpeopleassigned;
2306 $listofotherid =
$object->otherassigned;
2308 print
'<tr><td class="nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2309 print
'<div class="assignedtouser">';
2310 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, [], 0,
'', [],
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid, (int) $caneditdateorowner);
2322 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2323 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories', $object);
2333 print
'<table class="border tableforfield centpercent">';
2336 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td><td colspan="3">';
2337 $percent = GETPOSTISSET(
"percentage") ?
GETPOSTINT(
"percentage") :
$object->percentage;
2338 $formactions->form_select_status_action(
'formaction', (
string) $percent, 1,
'complete', 0, 0,
'minwidth150 maxwidth300');
2343 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2347 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2350 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2355 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2356 print
'<div class="maxwidth200onsmartphone">';
2358 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2359 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
2366 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2367 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');
2368 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2371 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');
2380 $langs->load(
"projects");
2382 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2383 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2384 $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');
2385 if ($numprojet == 0) {
2386 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>';
2393 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2394 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2400 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2402 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2405 print
'<td id="project-task-input-container" >';
2407 $urloption =
'?action=create&donotclearsession=1';
2408 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2412 <script
type=
"text/javascript" >
2413 $(document).ready(
function () {
2414 $(
"#projectid").change(
function () {
2415 var url =
"<?php echo $url; ?>&projectid="+$(
"#projectid").val();
2416 $.get(url,
function(data) {
2417 console.log($( data ).find(
"#fk_element").html());
2418 if (data) $(
"#fk_element").html( $( data ).find(
"#taskid").html() ).select2();
2425 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);
2426 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2433 print
'<td id="project-task-input-container" >';
2437 <script
type=
"text/javascript">
2438 $(document).ready(
function () {
2439 $(
"#projectid").change(
function () {
2440 var url =
"<?php echo DOL_URL_ROOT; ?>/projet/ajax/projects.php?mode=gettasks&socid="+$(
"#search_socid").val()+
"&projectid="+$(
"#projectid").val();
2441 console.log(
"Call url to get new list of tasks: "+url);
2442 $.get(url,
function(data) {
2444 if (data) $(
"#taskid").html(data).select2();
2452 if (GETPOSTISSET(
"projecttaskid") &&
GETPOSTINT(
"projecttaskid") > 0) {
2454 } elseif (GETPOSTISSET(
"taskid") &&
GETPOSTINT(
"taskid") > 0) {
2458 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 64, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (string) $projectsListId,
'all', null, 1);
2464 print
'<input type="hidden" name="fk_element" value="'.$object->elementid.
'">';
2465 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2474 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2476 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2477 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true,
isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2478 $doleditor->Create();
2483 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2484 print $hookmanager->resPrint;
2485 if (empty($reshook)) {
2486 print
$object->showOptionals($extrafields,
'edit', $parameters);
2492 if ($enablereminders) {
2493 $filteruserid = $user->id;
2494 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2497 $object->loadReminders(
'', $filteruserid,
false);
2501 if (count(
$object->reminders) > 0) {
2502 $checked =
'checked';
2503 $keys = array_keys(
$object->reminders);
2504 $firstreminderId = array_shift($keys);
2506 $actionCommReminder =
$object->reminders[$firstreminderId];
2510 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2511 $actionCommReminder->offsetunit =
'i';
2512 $actionCommReminder->typeremind =
'email';
2521 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>';
2523 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2527 print
'<table class="border centpercent">';
2530 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2531 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2532 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, $TDurationTypesExcluded);
2536 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2537 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2541 if ($actionCommReminder->typeremind ==
'browser') {
2542 $hide =
'style="display:none;"';
2547 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2548 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (
string) $actionCommReminder->fk_email_template);
2554 <script
type=
"text/javascript">
2555 $(document).ready(
function () {
2556 $(
"#addreminder").click(
function(){
2558 $(
".reminderparameters").show();
2560 $(
".reminderparameters").hide();
2563 $(
"#selectremindertype").change(
function(){
2564 var selected_option = $(
"#selectremindertype option:selected").val();
2565 if(selected_option ==
"email") {
2566 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2568 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
2575 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
2578 $reminderDefaultEmailModel =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
2580 print
"\n".
'<script type="text/javascript">';
2581 print
'$(document).ready(function () {
2582 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
2583 $(
"#actioncode").change(
function(){
2584 var selected_event_type = $(
"#actioncode option:selected").val();
2586 if (reminderDefaultEventTypes.includes(selected_event_type)) {
2587 $(
".reminderparameters").show();
2588 $(
"#addreminder").prop(
"checked",
true);
2591 $(
"#offsetvalue").val(\
''.
dol_escape_js($reminderDefaultOffset).
'\');
2592 $(
"#select_offsetunittype_duration").select2(
"destroy");
2593 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
2594 $(
"#select_offsetunittype_duration").select2();
2596 $(
"#selectremindertype").select2(
"destroy");
2597 $(
"#selectremindertype").val(
"email");
2598 $(
"#selectremindertype").select2();
2601 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2602 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
2603 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js($reminderDefaultEmailModel).
'\');
2604 $(
"#select_actioncommsendmodel_mail").select2();
2608 print '</script>
'."\n";
2609 print '</div>
'; // End of div for reminderparameters
2612 print dol_get_fiche_end();
2614 print $form->buttonsSaveCancel();
2618 print dol_get_fiche_head($head, 'card
', $langs->trans("Action"), -1, 'action
');
2623 if ($action == 'clone
') {
2624 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?
id=
'.GETPOST('id'), $langs->trans('ToClone
'), $langs->trans('ConfirmCloneEvent
', $object->label), 'confirm_clone
', [], 'yes
', 1);
2627 // Call Hook formConfirm
2629 $reshook = $hookmanager->executeHooks('formConfirm
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2630 if (empty($reshook)) {
2631 $formconfirm .= $hookmanager->resPrint;
2632 } elseif ($reshook > 0) {
2633 $formconfirm = $hookmanager->resPrint;
2636 // Print form confirm
2640 // Link to other agenda views
2641 $linkback .= '<a href=
"'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">
';
2642 $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist
', 'class=
"pictoactionview pictofixedwidth"');
2643 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("BackToList").'</span>
';
2644 $linkback .= '</a>
';
2645 $linkback .= '</li>
';
2646 $linkback .= '<li
class=
"noborder litext">
';
2647 $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').'">
';
2648 $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar
', 'class=
"pictoactionview pictofixedwidth"');
2649 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewCal").'</span>
';
2650 $linkback .= '</a>
';
2651 $linkback .= '</li>
';
2652 $linkback .= '<li
class=
"noborder litext">
';
2653 $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').'">
';
2654 $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek
', 'class=
"pictoactionview pictofixedwidth"');
2655 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewWeek").'</span>
';
2656 $linkback .= '</a>
';
2657 $linkback .= '</li>
';
2658 $linkback .= '<li
class=
"noborder litext">
';
2659 $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').'">
';
2660 $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday
', 'class=
"pictoactionview pictofixedwidth"');
2661 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewDay").'</span>
';
2662 $linkback .= '</a>
';
2663 $linkback .= '</li>
';
2664 $linkback .= '<li
class=
"noborder litext">
';
2665 $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').'">
';
2666 $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser
', 'class=
"pictoactionview pictofixedwidth"');
2667 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewPerUser").'</span>
';
2668 $linkback .= '</a>
';
2670 // Add more views from hooks
2672 $reshook = $hookmanager->executeHooks('addCalendarView
', $parameters, $object, $action);
2673 if (empty($reshook)) {
2674 $linkback .= $hookmanager->resPrint;
2675 } elseif ($reshook > 1) {
2676 $linkback = $hookmanager->resPrint;
2681 $morehtmlref = '<div
class=
"refidno">
';
2683 //$morehtmlref.='<br>
'.$langs->trans('ThirdParty
') . ' :
' . $object->thirdparty->getNomUrl(1);
2685 if (isModEnabled('project
')) {
2686 $langs->load("projects");
2687 //$morehtmlref .= '<br>
';
2688 if ($usercancreate) {
2689 $morehtmlref .= img_picto($langs->trans("Project"), 'project
', 'class=
"pictofixedwidth"');
2690 if ($action != 'classify
') {
2691 $morehtmlref .= '<a class=
"editfielda" href=
"'.dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">
'.img_edit($langs->transnoentitiesnoconv('SetProject
')).'</a>
';
2693 $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
');
2695 if (!empty($object->fk_project)) {
2696 $proj = new Project($db);
2697 $proj->fetch($object->fk_project);
2698 $morehtmlref .= $proj->getNomUrl(1);
2700 $morehtmlref .= '<span class=
"opacitymedium"> -
'.dol_escape_htmltag($proj->title).'</span>
';
2705 $morehtmlref .= '</div>
';
2708 dol_banner_tab($object, 'id
', $linkback, ($user->socid ? 0 : 1), 'id
', 'ref', $morehtmlref);
2710 print '<div class=
"fichecenter">
';
2711 print '<div class=
"fichehalfleft">
';
2713 print '<div class=
"underbanner clearboth"></div>
';
2715 // Show event in view mode
2716 print '<
table class=
"border tableforfield centpercent">
';
2719 if (getDolGlobalString('AGENDA_USE_EVENT_TYPE
')) {
2720 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("Type").'</td><td>
';
2721 $labeltype = ($langs->transnoentities("Action".$object->type_code) != "Action".$object->type_code) ? $langs->transnoentities("Action".$object->type_code) : $object->type_label;
2722 $labeltoshow = $labeltype;
2723 if ($object->code) {
2724 $labeltoshow .= ' (
'.$object->code.')
';
2726 print $object->getTypePicto('pictofixedwidth paddingright
', $labeltoshow);
2732 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("EventOnFullDay").'</td><td>
'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>
';
2735 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2740 print '<tr><td>
'.$langs->trans("DateActionStart").'</td><td title=
"'.dol_print_date($object->datep, 'dayhoursec', 'tzuserrel').'">
';
2741 // Test a date before the 27 march and one after
2742 //print dol_print_date($object->datep, 'dayhour
', 'gmt
');
2743 //print dol_print_date($object->datep, 'dayhour
', 'tzuser
');
2744 //print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2745 if (empty($object->fulldayevent)) {
2746 print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2748 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2749 print dol_print_date($object->datep, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2751 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2752 print img_warning($langs->trans("Late"));
2758 print '<tr><td>
'.$langs->trans("DateActionEnd").'</td><td title=
"'.dol_print_date($object->datef, 'dayhoursec', 'tzuserrel').'">
';
2759 if (empty($object->fulldayevent)) {
2760 print dol_print_date($object->datef, 'dayhour
', 'tzuserrel
');
2762 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2763 print dol_print_date($object->datef, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2765 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2766 print img_warning($langs->trans("Late"));
2770 // Recurring event (into a series)
2771 if ($object->recurid) {
2772 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("RecurringEvent").'</td><td>
';
2773 print img_picto($langs->trans("EventPartOfARecurringSerie", $object->recurid), 'recurring
', 'class=
"pictofixedwidth"');
2775 if (preg_match('/FREQ=MONTHLY_BYMONTHDAY(\d+)/
', $object->recurrule, $reg)) {
2776 print $langs->trans("EveryMonth").' <span class=
"opacitymedium small">(
'.$langs->trans("DayOfMonth").' '.$reg[1].' -
'.$langs->trans("Until").' '.dol_print_date($object->recurdateend, 'day
').')</span>
';
2778 if (preg_match('/FREQ=YEARLY_BYYEARMONTHDAY(\d+)/
', $object->recurrule, $reg)) {
2779 print $langs->trans("EveryYear").' <span class=
"opacitymedium small">(
'.$langs->trans("DayOfYear").' '.$reg[1].' -
'.$langs->trans("Until").' '.dol_print_date($object->recurdateend, 'day
').')</span>
';
2785 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2786 print '<tr><td>
'.$langs->trans("Location").'</td><td>
'.$object->location.'</td></tr>
';
2790 print '<tr><td class=
"nowrap">
'.$langs->trans("ActionAssignedTo").'</td><td>
';
2792 if (empty($donotclearsession)) {
2793 if ($object->userownerid > 0) {
2794 $listofuserid[$object->userownerid] = array(
2795 'id
' => $object->userownerid,
2796 'transparency
' => $object->transparency, // Force transparency on owner from property of event
2797 'answer_status
' => $object->userassigned[$object->userownerid]['answer_status
'],
2798 'mandatory
' => $object->userassigned[$object->userownerid]['mandatory
']
2801 if (!empty($object->userassigned)) { // Now concat assigned users
2802 // Restore array with key with same value than param 'id
'
2803 $tmplist1 = $object->userassigned;
2804 foreach ($tmplist1 as $key => $val) {
2805 if ($val['id
'] && $val['id
'] != $object->userownerid) {
2806 $listofuserid[$val['id
']] = $val;
2810 $_SESSION['assignedtouser
'] = json_encode($listofuserid);
2812 if (!empty($_SESSION['assignedtouser
'])) {
2813 $listofuserid = json_decode($_SESSION['assignedtouser
'], true);
2817 $listofcontactid = []; // not used yet
2818 $listofotherid = []; // not used yet
2819 print '<div class=
"assignedtouser">
';
2820 print $form->select_dolusers_forevent('view
', 'assignedtouser
', 1, [], 0, '', [], '0
', 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2823 if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
2825 print '<div class=
"myavailability">
';
2826 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
2830 print ' </td></tr>
';
2833 if (isModEnabled('category
')) {
2834 print '<tr><td class=
"valignmiddle">
'.$langs->trans("Categories").'</td><td>
';
2835 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2843 print '<div class=
"fichehalfright">
';
2845 print '<div class=
"underbanner clearboth"></div>
';
2846 print '<
table class=
"border tableforfield centpercent">
';
2848 if (isModEnabled("societe")) {
2850 print '<tr><td class=
"titlefield">
'.$langs->trans("ActionOnCompany").'</td>
';
2851 print '<td>
'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : ('<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
'));
2852 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL
') {
2853 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2854 print "<br>".dol_print_phone($object->thirdparty->phone);
2860 print '<tr><td>
'.$langs->trans("ActionOnContact").'</td>
';
2863 if (!empty($object->socpeopleassigned)) {
2864 foreach ($object->socpeopleassigned as $cid => $Tab) {
2865 $contact = new Contact($db);
2866 $result = $contact->fetch($cid);
2869 dol_print_error($db, $contact->error);
2873 print $contact->getNomUrl(1);
2874 if ($object->type_code == 'AC_TEL
') {
2875 if (!empty($contact->phone_pro)) {
2876 print '(
'.dol_print_phone($contact->phone_pro).')
';
2879 print '<div class=
"paddingright"></div>
';
2883 print '<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
';
2889 if (getDolGlobalString('AGENDA_SUPPORT_PRIORITY_IN_EVENTS
')) {
2890 print '<tr><td class=
"nowrap" class=
"titlefield">
' . $langs->trans("Priority") . '</td><td>
';
2891 print($object->priority ? $object->priority : '');
2895 // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
2896 // for such objects because there is already a dedicated field into table llx_actioncomm.
2897 if (!empty($object->elementid) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe
', 'contact
', 'project
'))) {
2898 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
2899 print '<tr><td>
'.$langs->trans("LinkedObject").'</td>
';
2900 $link = dolGetElementUrl($object->elementid, $object->elementtype, ($object->elementtype == 'user' ? -1 : 1));
2903 print '<span class=
"opacitymedium">
'.$langs->trans("ObjectDeleted").'</span>
';
2911 if (!empty($object->email_msgid)) {
2912 print '<tr><td>
'.$langs->trans('MailTopic
').'</td>
';
2913 print '<td>
'.dol_escape_htmltag($object->email_subject).'</td></tr>
';
2914 print '<tr><td>
'.$langs->trans('MailFrom
').'</td>
';
2915 print '<td>
'.dol_escape_htmltag($object->email_from).'</td></tr>
';
2916 print '<tr><td>
'.$langs->trans('MailTo
').'</td>
';
2917 print '<td>
'.dol_escape_htmltag($object->email_to).'</td></tr>
';
2918 if (!empty($object->email_tocc)) {
2919 print '<tr><td>
'.$langs->trans('MailCC
').'</td>
';
2920 print '<td>
'.dol_escape_htmltag($object->email_tocc).'</td></tr>
';
2925 print '<tr><td class=
"tdtop">
'.$langs->trans("Description").'</td><td class=
"wordbreak sensiblehtmlcontent">
';
2926 print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
2930 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php
';
2933 if ($enablereminders) {
2934 $filteruserid = $user->id;
2935 if ($user->hasRight('agenda
', 'allactions
', 'read
')) {
2938 $object->loadReminders('', $filteruserid, false);
2940 print '<tr><td class=
"titlefieldcreate nowrap">
'.$langs->trans("Reminders").'</td><td>
';
2942 if (count($object->reminders) > 0) {
2943 $tmpuserstatic = new User($db);
2945 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2946 print $TRemindTypes[$actioncommreminder->typeremind]['label
'];
2947 if ($actioncommreminder->fk_user > 0) {
2948 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2949 print ' (
'.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')
';
2951 print ' -
'.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit];
2953 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2954 print ' - <span class=
"opacitymedium">
';
2955 print $langs->trans("NotSent");
2957 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2958 print ' - <span class=
"opacitymedium">
';
2959 print $langs->trans("Done");
2961 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2962 print ' - <span class=
"opacitymedium">
';
2963 print $form->textwithpicto($langs->trans("Error"), $actioncommreminder->lasterror);
2977 print '<div class=
"clearboth"></div>
';
2979 print dol_get_fiche_end();
2986 print '<div class=
"tabsAction">
';
2989 $reshook = $hookmanager->executeHooks('addMoreActionsButtons
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2990 if (empty($reshook)) {
2991 if ($action != 'edit
') {
2992 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
2993 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
2994 print '<div class=
"inline-block divButAction"><a class=
"butAction" href=
"card.php?action=edit&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Modify").'</a></div>
';
2996 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Modify").'</a></div>
';
2999 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
3000 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
3001 print '<div class=
"inline-block divButAction"><a class=
"butAction" href=
"card.php?action=clone&object='.$object->element.'&id='.$object->id.'">
'.$langs->trans("ToClone").'</a></div>
';
3003 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("ToClone").'</a></div>
';
3006 if ($usercandelete) {
3007 print '<div class=
"inline-block divButAction"><a class=
"butActionDelete" href=
"card.php?action=delete&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Delete").'</a></div>
';
3009 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Delete").'</a></div>
';
3016 if ($action != 'edit
') {
3017 if (!getDolGlobalString('AGENDA_DISABLE_BUILDDOC
')) {
3018 print '<div class=
"clearboth"></div><div class=
"fichecenter"><div class=
"fichehalfleft">
';
3019 print '<a
name=
"builddoc"></a>
'; // ancre
3021 // Generated documents
3022 $filedir = $conf->agenda->multidir_output[$conf->entity].'/
'.$object->id;
3023 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
3025 $genallowed = $user->hasRight('agenda
', 'myactions
', 'read
');
3026 $delallowed = $user->hasRight('agenda
', 'myactions
', 'create
');
3028 print $formfile->showdocuments('actions
', (string) $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang());
3030 if (getDolGlobalString('AGENDA_ENABLE_LINKED_ELEMENTS
')) {
3031 // Show links to link elements
3032 $tmparray = $form->showLinkToObjectBlock($object, [], array('myobject
'), 1);
3033 if (is_array($tmparray)) {
3034 $linktoelem = $tmparray['linktoelem
'];
3035 $htmltoenteralink = $tmparray['htmltoenteralink
'];
3036 print $htmltoenteralink;
3037 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
3039 // backward compatibility
3040 $somethingshown = $form->showLinkedObjectBlock($object, $tmparray);
3043 print '</div><div class=
"fichehalfright">
';
3045 print '</div></div>
';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage agenda events (actions)
Class for ActionCommReminder.
Class to manage different types of events.
Class to manage a WYSIWYG editor.
Class to manage third parties objects (customers, suppliers, prospects...)
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dol_get_first_day_week($day, $month, $year, $gm=false)
Return first day of week for a date.
num_between_day($timestampStart, $timestampEnd, $lastday=0)
Function to return number of days between two dates (date must be UTC date !) Example: 2012-01-01 201...
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_stringtotime($string, $gm=1)
Convert a string date into a GM Timestamps date Warning: YYYY-MM-DDTHH:MM:SS+02:00 (RFC3339) is not s...
dolGetElementUrl($objectid, $objecttype, $withpicto=0, $option='')
Return link url to an object.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getElementProperties($elementType)
Get an array with properties of an element.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
treeview li table
No Email.
$conf db user
Active Directory does not allow anonymous connections.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
$conf db name
Only used if Module[ID]Name translation string is not found.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.