35require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncommreminder.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
62$langs->loadLangs(array(
"companies",
"other",
"commercial",
"bills",
"orders",
"agenda",
"mails"));
65$action =
GETPOST(
'action',
'aZ09');
66$cancel =
GETPOST(
'cancel',
'alpha');
67$backtopage =
GETPOST(
'backtopage',
'alpha');
68$socpeopleassigned =
GETPOST(
'socpeopleassigned',
'array');
69$origin =
GETPOST(
'origin',
'alpha');
71$confirm =
GETPOST(
'confirm',
'alpha');
73$fulldayevent =
GETPOST(
'fullday',
'alpha');
80$addreminder =
GETPOST(
'addreminder',
'alpha');
82$offsetunit =
GETPOST(
'offsetunittype_duration',
'aZ09');
83$remindertype =
GETPOST(
'selectremindertype',
'aZ09');
84$modelmail =
GETPOSTINT(
'actioncommsendmodel_mail');
85$complete =
GETPOST(
'complete',
'alpha');
86$private =
GETPOST(
'private',
'alphanohtml');
87if ($complete ==
'na' || $complete == -2) {
104 if (
GETPOST(
'datep') ==
'now') {
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');
122if ($user->socid && ($socid != $user->socid)) {
127$donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
136$form =
new Form($db);
141if ($id > 0 && $action !=
'add') {
145 $ret =
$object->fetch_optionals();
146 $ret1 =
$object->fetch_userassigned();
148 if ($ret < 0 || $ret1 < 0) {
154$extrafields->fetch_name_optionals_label(
$object->table_element);
156if (empty($action) && empty(
$object->id)) {
161$hookmanager->initHooks(array(
'actioncard',
'globalcard'));
163$parameters = array(
'socid' => $socid);
164$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
169$TRemindTypes = array();
171 $TRemindTypes[
'browser'] = array(
'label' => $langs->trans(
'BrowserPush'),
'disabled' => (
getDolGlobalString(
'AGENDA_REMINDER_BROWSER') ? 0 : 1));
174 $TRemindTypes[
'email'] = array(
'label' => $langs->trans(
'EMail'),
'disabled' => (
getDolGlobalString(
'AGENDA_REMINDER_EMAIL') ? 0 : 1));
177$TDurationTypes = array(
'y' => $langs->trans(
'Years'),
'm' => $langs->trans(
'Month'),
'w' => $langs->trans(
'Weeks'),
'd' => $langs->trans(
'Days'),
'h' => $langs->trans(
'Hours'),
'i' => $langs->trans(
'Minutes'));
179$result =
restrictedArea($user,
'agenda',
$object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
181$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || ((empty(
$object->id) ||
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
188$listUserAssignedUpdated =
false;
189$listResourceAssignedUpdated =
false;
190$assignedtouser = array();
193if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
194 $idtoremove =
GETPOST(
'removedassigned');
196 if (!empty($_SESSION[
'assignedtouser'])) {
197 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'],
true);
199 $tmpassigneduserids = array();
202 foreach ($tmpassigneduserids as $key => $val) {
203 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
204 unset($tmpassigneduserids[$key]);
208 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
209 $donotclearsession = 1;
210 if ($action ==
'add') {
213 if ($action ==
'update') {
217 $listUserAssignedUpdated =
true;
220if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
221 $idtoremove =
GETPOST(
'removedassignedresource');
223 if (!empty($_SESSION[
'assignedtoresource'])) {
224 $tmpassignedresourceids = json_decode($_SESSION[
'assignedtoresource'],
true);
226 $tmpassignedresourceids = array();
229 foreach ($tmpassignedresourceids as $key => $val) {
230 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
231 unset($tmpassignedresourceids[$key]);
235 $_SESSION[
'assignedtoresource'] = json_encode($tmpassignedresourceids);
236 $donotclearsessionresource = 1;
237 if ($action ==
'add' && $usercancreate) {
240 if ($action ==
'update' && $usercancreate) {
244 $listResourceAssignedUpdated =
true;
248if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
250 if (
GETPOST(
'assignedtouser') > 0) {
251 $assignedtouser = array();
252 if (!empty($_SESSION[
'assignedtouser'])) {
253 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
255 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id' =>
GETPOSTINT(
'assignedtouser'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
256 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
258 $donotclearsession = 1;
259 if ($action ==
'add' && $usercancreate) {
262 if ($action ==
'update' && $usercancreate) {
266 $listUserAssignedUpdated =
true;
270if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
272 if (
GETPOST(
'assignedtoresource') > 0) {
273 $assignedtoresource = array();
274 if (!empty($_SESSION[
'assignedtoresource'])) {
275 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
277 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id' =>
GETPOSTINT(
'assignedtoresource'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
278 $_SESSION[
'assignedtoresource'] = json_encode($assignedtoresource);
280 $donotclearsession = 1;
281 if ($action ==
'add' && $usercancreate) {
284 if ($action ==
'update' && $usercancreate) {
288 $listResourceAssignedUpdated =
true;
292if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
293 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
299if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
301 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
306 if (!empty(
$object->socpeopleassigned)) {
307 reset(
$object->socpeopleassigned);
312 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
323if (empty($reshook) && $action ==
'add' && $usercancreate) {
326 if (empty($backtopage)) {
328 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
330 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
334 if (!empty($socpeopleassigned[0])) {
335 $result = $contact->fetch($socpeopleassigned[0]);
339 header(
"Location: ".$backtopage);
343 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
356 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
359 if (!$datef && $percentage == 100) {
361 $donotclearsession = 1;
363 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
368 $donotclearsession = 1;
370 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
374 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
376 $donotclearsession = 1;
378 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
383 $listofresourceid = array();
388 $object->fulldayevent = ($fulldayevent ? 1 : 0);
392 if (
GETPOST(
"elementtype",
'alpha')) {
394 $modulecodetouseforpermissioncheck = $elProp[
'module'];
396 if ($modulecodetouseforpermissioncheck ==
'productbatch') {
397 $modulecodetouseforpermissioncheck =
'produit';
399 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
401 $hasPermissionOnLinkedObject = 0;
402 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
403 $hasPermissionOnLinkedObject = 1;
404 } elseif ($user->hasRight($modulecodetouseforpermissioncheck, $submodulecodetouseforpermissioncheck,
'read')) {
405 $hasPermissionOnLinkedObject = 1;
408 if ($hasPermissionOnLinkedObject) {
416 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
417 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
419 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
420 $object->label = $langs->transnoentitiesnoconv(
"Action".
$object->type_code).
"\n";
422 $cactioncomm->fetch(
$object->type_code);
423 $object->label = $cactioncomm->label;
430 if (!empty($taskid)) {
431 $taskProject =
new Task($db);
432 if ($taskProject->fetch($taskid) > 0) {
433 $object->fk_project = $taskProject->fk_project;
443 $object->percentage = $percentage;
446 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
448 $listofuserid = array();
449 if (!empty($_SESSION[
'assignedtouser'])) {
450 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
453 if (!empty($_SESSION[
'assignedtoresource'])) {
454 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
458 foreach ($listofuserid as $key => $value) {
460 if ($value[
'id'] > 0) {
461 $object->userownerid = $value[
'id'];
463 $object->transparency = $transparency;
466 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
474 if (GETPOSTISSET(
"contactid")) {
485 if (empty(
$object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
487 $donotclearsession = 1;
489 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
491 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
493 $donotclearsession = 1;
495 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
500 $donotclearsession = 1;
502 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
505 foreach ($socpeopleassigned as $cid) {
506 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
508 if (!empty(
$object->socpeopleassigned)) {
509 reset(
$object->socpeopleassigned);
514 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
517 $donotclearsession = 1;
528 $selectedrecurrulefreq =
'no';
529 $selectedrecurrulebymonthday =
'';
530 $selectedrecurrulebyday =
'';
531 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
532 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY') ?
"_BYMONTHDAY".((
int) $dayinmonth) :
"";
533 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY') ?
"_BYDAY".((
int) $dayinweek) :
"";
538 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
539 $selectedrecurrulefreq = $reg1[1];
541 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
542 $selectedrecurrulebymonthday = (int) $reg2[1];
544 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
545 $selectedrecurrulebyday = (int) $reg3[1];
549 $eventisrecurring = 0;
550 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
551 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
552 $eventisrecurring = 1;
562 $idaction =
$object->create($user);
567 if (is_array($listofresourceid) && count($listofresourceid)) {
568 foreach ($listofresourceid as $resource_id => $val) {
569 $resource_type =
'dolresource';
574 $eventDateStart =
$object->datep;
575 $eventDateEnd =
$object->datef;
576 $isFullDayEvent =
$object->fulldayevent;
577 if (empty($eventDateEnd)) {
578 if ($isFullDayEvent) {
580 $eventDateStart =
dol_mktime(0, 0, 0, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
581 $eventDateEnd =
dol_mktime(23, 59, 59, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
585 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
586 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_resources as er";
587 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) .
"'";
588 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape(
$object->element) .
"'";
589 $sql .=
" WHERE er.resource_id = " . ((int) $resource_id);
590 $sql .=
" AND er.busy = 1";
594 $sql .=
" (ac.datep <= '" . $db->idate($eventDateStart) .
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) .
"'))";
596 if (!empty($eventDateEnd)) {
597 $sql .=
" OR (ac.datep <= '" . $db->idate($eventDateEnd) .
"' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) .
"'))";
601 $sql .=
"ac.datep >= '" . $db->idate($eventDateStart) .
"'";
602 if (!empty($eventDateEnd)) {
603 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) .
"')";
608 $resql = $db->query($sql);
611 $object->error = $db->lasterror();
614 if ($db->num_rows($resql) > 0) {
617 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse') .
' : ';
618 while ($obj = $db->fetch_object($resql)) {
619 $object->error .=
'<br> - ' . $langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label .
' [' . $obj->ac_id .
']');
630 $res =
$object->add_element_resource($resource_id, $resource_type, $busy, $val[
'mandatory']);
635 unset($_SESSION[
'assignedtoresource']);
640 $categories =
GETPOST(
'categories',
'array');
641 $object->setCategories($categories);
644 unset($_SESSION[
'assignedtouser']);
646 if ($user->id !=
$object->userownerid) {
647 $moreparam =
"filtert=-1";
651 if (!$error && $addreminder ==
'on') {
656 $actionCommReminder->dateremind = $dateremind;
657 $actionCommReminder->typeremind = $remindertype;
658 $actionCommReminder->offsetunit = $offsetunit;
659 $actionCommReminder->offsetvalue = $offsetvalue;
660 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
661 $actionCommReminder->fk_actioncomm =
$object->id;
662 if ($remindertype ==
'email') {
663 $actionCommReminder->fk_email_template = $modelmail;
667 foreach (
$object->userassigned as $userassigned) {
668 $actionCommReminder->fk_user = $userassigned[
'id'];
669 $res = $actionCommReminder->create($user);
674 $langs->load(
"errors");
675 $error = $langs->trans(
'ErrorReminderActionCommCreation');
678 $donotclearsession = 1;
689 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
710 $langs->load(
"errors");
711 $error = $langs->trans(
$object->error);
714 $donotclearsession = 1;
720 $donotclearsession = 1;
723 if (!$error && $eventisrecurring) {
727 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
729 $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');
733 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
734 $firstday = $selectedrecurrulebymonthday;
748 while ($datep <= $repeateventlimitdate && !$error) {
752 $finalobject->datep = $datep;
753 $finalobject->datef = $datef;
755 $idaction = $finalobject->create($user);
758 if (!$finalobject->error) {
760 $categories =
GETPOST(
'categories',
'array');
761 $finalobject->setCategories($categories);
763 unset($_SESSION[
'assignedtouser']);
766 if ($user->id != $finalobject->userownerid) {
767 $moreparam =
"filtert=-1";
771 if ($addreminder ==
'on') {
776 $actionCommReminder->dateremind = $dateremind;
777 $actionCommReminder->typeremind = $remindertype;
778 $actionCommReminder->offsetunit = $offsetunit;
779 $actionCommReminder->offsetvalue = $offsetvalue;
780 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
781 $actionCommReminder->fk_actioncomm = $finalobject->id;
782 if ($remindertype ==
'email') {
783 $actionCommReminder->fk_email_template = $modelmail;
787 foreach ($finalobject->userassigned as $userassigned) {
788 $actionCommReminder->fk_user = $userassigned[
'id'];
789 $res = $actionCommReminder->create($user);
794 $langs->load(
"errors");
795 $error = $langs->trans(
'ErrorReminderActionCommCreation');
798 $donotclearsession = 1;
809 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
819 $langs->load(
"errors");
820 $error = $langs->trans($finalobject->error);
823 $donotclearsession = 1;
829 $donotclearsession = 1;
833 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
844 if (!empty($backtopage) && !$error) {
845 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
846 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
847 } elseif ($idaction) {
848 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
850 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
857if (empty($reshook) && $action ==
'update' && $usercancreate) {
858 if (empty($cancel)) {
859 $fulldayevent =
GETPOST(
'fullday');
864 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
892 if (!GETPOSTISSET(
'ap') && !GETPOSTISSET(
'aphour') && !GETPOSTISSET(
'apmin')) {
897 if (!GETPOSTISSET(
'p2') && !GETPOSTISSET(
'p2hour') && !GETPOSTISSET(
'p2min')) {
905 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
907 if (
$object->elementtype ==
'ticket') {
909 if (
$object->code ==
'TICKET_MSG') {
910 $object->code =
'TICKET_MSG_PRIVATE';
912 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
913 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
916 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
919 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
920 $object->code =
'TICKET_MSG_SENTBYMAIL';
932 $object->percentage = $percentage;
937 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
938 $object->socpeopleassigned = array();
939 foreach ($socpeopleassigned as $cid) {
940 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
943 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
944 reset(
$object->socpeopleassigned);
949 if (!empty($taskid)) {
950 $taskProject =
new Task($db);
951 if ($taskProject->fetch($taskid) > 0) {
952 $object->fk_project = $taskProject->fk_project;
962 if (
GETPOST(
"elementtype",
'alpha')) {
964 $modulecodetouseforpermissioncheck = $elProp[
'module'];
966 if ($modulecodetouseforpermissioncheck ==
'productbatch') {
967 $modulecodetouseforpermissioncheck =
'produit';
970 $hasPermissionOnLinkedObject = 0;
971 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
972 $hasPermissionOnLinkedObject = 1;
974 if ($hasPermissionOnLinkedObject) {
982 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
985 $listofuserid = array();
986 if (!empty($_SESSION[
'assignedtouser'])) {
988 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
989 foreach ($tmplist1 as $key => $val) {
990 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
991 $listofuserid[$val[
'id']] = $val;
995 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
996 if ($assignedtouser) {
997 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
1000 $object->userassigned = array();
1003 foreach ($listofuserid as $key => $val) {
1005 $object->userownerid = $val[
'id'];
1007 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
1011 $object->transparency = $transparency;
1015 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
1017 $donotclearsession = 1;
1019 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
1021 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
1023 if (empty(
$object->userownerid)) {
1025 $donotclearsession = 1;
1027 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
1031 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
1039 $eventDateStart =
$object->datep;
1040 $eventDateEnd =
$object->datef;
1042 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1043 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1044 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1045 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1046 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1047 $sql .=
" AND er.resource_id IN (";
1048 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1049 $sql .=
" WHERE element_id = ".((int)
$object->id);
1050 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1051 $sql .=
" AND busy = 1";
1053 $sql .=
" AND er.busy = 1";
1057 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1059 if (!empty($eventDateEnd)) {
1060 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1064 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1065 if (!empty($eventDateEnd)) {
1066 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1071 $resql = $db->query($sql);
1074 $object->error = $db->lasterror();
1077 if ($db->num_rows($resql) > 0) {
1080 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1081 while ($obj = $db->fetch_object($resql)) {
1082 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1098 $result =
$object->update($user);
1102 $categories =
GETPOST(
'categories',
'array');
1103 $object->setCategories($categories);
1105 $object->loadReminders($remindertype, 0,
false);
1108 if (!empty(
$object->reminders)) {
1109 foreach (
$object->reminders as $reminder) {
1110 if ($reminder->status < 1) {
1111 $reminder->delete($user);
1118 if ($addreminder ==
'on') {
1123 $actionCommReminder->dateremind = $dateremind;
1124 $actionCommReminder->typeremind = $remindertype;
1125 $actionCommReminder->offsetunit = $offsetunit;
1126 $actionCommReminder->offsetvalue = $offsetvalue;
1127 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
1128 $actionCommReminder->fk_actioncomm =
$object->id;
1129 if ($remindertype ==
'email') {
1130 $actionCommReminder->fk_email_template = $modelmail;
1134 foreach (
$object->userassigned as $userassigned) {
1135 $actionCommReminder->fk_user = $userassigned[
'id'];
1139 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1140 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".$db->escape($remindertype).
"'";
1141 $resqldelete = $db->query($sqldelete);
1143 $res = $actionCommReminder->create($user);
1147 $langs->load(
"errors");
1148 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1151 $donotclearsession = 1;
1158 unset($_SESSION[
'assignedtouser']);
1159 unset($_SESSION[
'assignedtoresource']);
1174 if (!empty($backtopage)) {
1175 unset($_SESSION[
'assignedtouser']);
1176 header(
"Location: ".$backtopage);
1183if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes' && $usercancreate) {
1186 $object->fetch_userassigned();
1189 if ($user->hasRight(
'agenda',
'myactions',
'delete')
1190 || $user->hasRight(
'agenda',
'allactions',
'delete')) {
1191 $result =
$object->delete($user);
1194 header(
"Location: index.php");
1206if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate' && $usercancreate) {
1212 $newdate =
GETPOST(
'newdate',
'alpha');
1213 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1214 header(
"Location: ".$backtopage,
true, 307);
1218 $datep =
dol_mktime($shour, $smin, 0, (
int) substr($newdate, 13, 2), (
int) substr($newdate, 15, 2), (
int) substr($newdate, 9, 4),
'tzuserrel');
1221 if ($datep !=
$object->datep) {
1230 $eventDateStart =
$object->datep;
1231 $eventDateEnd =
$object->datef;
1233 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1234 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1235 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1236 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1237 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1238 $sql .=
" AND er.resource_id IN (";
1239 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1240 $sql .=
" WHERE element_id = ".((int)
$object->id);
1241 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1242 $sql .=
" AND busy = 1";
1244 $sql .=
" AND er.busy = 1";
1248 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1250 if (!empty($eventDateEnd)) {
1251 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1255 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1256 if (!empty($eventDateEnd)) {
1257 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1262 $resql = $db->query($sql);
1265 $object->error = $db->lasterror();
1268 if ($db->num_rows($resql) > 0) {
1271 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1272 while ($obj = $db->fetch_object($resql)) {
1273 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1288 $result =
$object->update($user);
1298 if (!empty($backtopage)) {
1299 header(
"Location: ".$backtopage,
true, 307);
1308$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1309if (empty($reshook)) {
1310 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1318$form =
new Form($db);
1321$arrayrecurrulefreq = array(
1322 'no' => $langs->trans(
"OnceOnly"),
1323 'MONTHLY' => $langs->trans(
"EveryMonth"),
1324 'WEEKLY' => $langs->trans(
"EveryWeek")
1329$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1330llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1332if ($action ==
'create') {
1335 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1336 if (!empty($socpeopleassigned[0])) {
1337 $result = $contact->fetch($socpeopleassigned[0]);
1345 if (!empty(
$conf->use_javascript_ajax)) {
1346 print
"\n".
'<script type="text/javascript">';
1347 print
'$(document).ready(function () {
1348 function setdatefields()
1350 if ($("#fullday:checked").val() == null) {
1351 $(".fulldaystarthour").removeAttr("disabled");
1352 $(".fulldaystartmin").removeAttr("disabled");
1353 $(".fulldayendhour").removeAttr("disabled");
1354 $(".fulldayendmin").removeAttr("disabled");
1355 $("#p2").removeAttr("disabled");
1357 $(".fulldaystarthour").prop("disabled", true).val("00");
1358 $(".fulldaystartmin").prop("disabled", true).val("00");
1359 $(".fulldayendhour").prop("disabled", true).val("23");
1360 $(".fulldayendmin").prop("disabled", true).val("59");
1361 $("#p2").removeAttr("disabled");
1364 $("#fullday").change(function() {
1365 console.log("setdatefields");
1368 var old_startdate = null;
1369 $("#ap").focus(function() {
1370 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1372 $("#ap").next(".ui-datepicker-trigger").click(function() {
1373 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1375 $("#ap").change(function() {
1376 setTimeout(function() {
1377 if ($("#p2").val() !== "") {
1378 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1379 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1380 if (new_startdate > old_enddate) {
1381 var timeDiff = old_enddate - old_startdate;
1382 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1383 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1384 $("#p2day").val(new_enddate.getDate());
1385 $("#p2month").val(new_enddate.getMonth() + 1);
1386 $("#p2year").val(new_enddate.getFullYear());
1391 $("#actioncode").change(function() {
1392 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1393 else $("#dateend").removeClass("fieldrequired");
1395 $("#aphour,#apmin").change(function() {
1396 if ($("#actioncode").val() == \'AC_RDV\') {
1397 var oldhour = parseInt($("#aphour").val());
1398 var oldmin = parseInt($("#apmin").val());
1399 var oldday = parseInt($("#apday").val());
1400 var oldmonth = $("#apmonth").val();
1401 var oldyear = $("#apyear").val();
1403 var newhour = oldhour + 1;
1404 var newday = oldday;
1405 var newmonth = oldmonth;
1406 var newyear = oldyear;
1407 if (newhour >= 24) {
1409 newday = oldday + 1;
1411 console.log("Start date was changed, we modify end date "+oldhour+" "+oldmin+" -> "+newhour+" "+oldmin);
1412 $("#p2hour").val(("00" + newhour).substr(-2,2));
1413 $("#p2min").val(("00" + oldmin).substr(-2,2));
1414 $("#p2day").val(newday);
1415 $("#p2month").val(newmonth);
1416 $("#p2year").val(newyear);
1417 $("#p2").val($("#ap").val());
1420 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1421 else $("#dateend").removeClass("fieldrequired");
1424 print
'</script>'.
"\n";
1427 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1428 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1429 print
'<input type="hidden" name="action" value="add">';
1430 print
'<input type="hidden" name="donotclearsession" value="1">';
1431 print
'<input type="hidden" name="page_y" value="">';
1433 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1436 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1443 print
'<table class="border centpercent nobottom">';
1447 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1449 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1450 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1451 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1456 print
'<tr><td'.(getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ?
'' :
' class="fieldrequired titlefieldcreate"').
'>'.$langs->trans(
"Title").
'</td><td><input type="text" id="label" name="label" class="soixantepercent" value="'.
GETPOST(
'label').
'"></td></tr>';
1459 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1460 print
'<td class="valignmiddle height30"><input class="valignmiddle" type="checkbox" id="fullday" name="fullday" '.(GETPOST(
'fullday') ?
' checked' :
'').
'><label for="fullday" class="valignmiddle small">'.$langs->trans(
"EventOnFullDay").
'</label>';
1463 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1464 if (
GETPOST(
'datep',
'alpha', 1)) {
1467 $datef = ($datef ? $datef :
$object->datef);
1468 if (
GETPOST(
'datef',
'alpha', 1)) {
1471 if (empty($datef) && !empty($datep)) {
1478 print
'<tr><td class="nowrap">';
1481 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1483 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1485 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1486 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1490 $userepeatevent = (
getDolGlobalInt(
'MAIN_DISABLE_RECURRING_EVENTS') ? 0 : 1);
1491 if ($userepeatevent) {
1492 print
'<tr><td></td><td>';
1496 print
'<div class="opacitymedium inline-block small">';
1497 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 6px" class="paddingright2"');
1498 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1500 $selectedrecurrulefreq =
'no';
1501 $selectedrecurrulebymonthday =
'';
1502 $selectedrecurrulebyday =
'';
1503 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1504 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1505 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1509 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1510 $selectedrecurrulefreq = $reg[1];
1512 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1513 $selectedrecurrulebymonthday = (int) $reg[1];
1515 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1516 $selectedrecurrulebyday = (int) $reg[1];
1519 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly minwidth100');
1536 $repeateventlimitdate = empty($repeateventlimitdate) ? (
dol_now() + ((24 * 3600 * 365) + 1)) : $repeateventlimitdate;
1538 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1539 print $langs->trans(
"Until").
" ";
1540 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1543 print
'<script type="text/javascript">
1544 jQuery(document).ready(function() {
1545 function init_repeat()
1547 console.log("recurrule: " + "'.$object->recurrule.
'");
1548 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1549 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1550 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1551 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1552 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1554 /* jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); */ /* use this instead of show because we want inline-block and not block */
1555 jQuery(".repeateventlimitdate").css("display", "inline-block");
1556 jQuery(".repeateventBYDAY").hide();
1558 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1560 jQuery(".repeateventBYMONTHDAY").hide();
1561 /* jQuery(".repeateventBYDAY").css("display", "inline-block"); */ /* use this instead of show because we want inline-block and not block */
1562 jQuery(".repeateventlimitdate").css("display", "inline-block");
1566 jQuery(".repeateventBYMONTHDAY").hide();
1567 jQuery(".repeateventBYDAY").hide();
1568 jQuery(".repeateventlimitdate").hide();
1572 jQuery("#recurrulefreq").change(function() {
1581 print
'<tr><td class=""> </td><td></td></tr>';
1584 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1585 $listofuserid = array();
1586 $listofcontactid = array();
1587 $listofotherid = array();
1589 if (empty($donotclearsession)) {
1591 if ($assignedtouser) {
1592 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1595 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1596 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1598 if (!empty($_SESSION[
'assignedtouser'])) {
1599 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1601 if (!is_array($listofuserid)) {
1602 $listofuserid = array();
1604 $firstelem = reset($listofuserid);
1605 if (isset($listofuserid[$firstelem[
'id']])) {
1606 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1609 print
'<!-- list of user to assign --><div class="assignedtouser">';
1610 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, array(), 0,
'', array(),
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid);
1616 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.(
GETPOST(
'location') ?
GETPOST(
'location') :
$object->location).
'"></td></tr>';
1619 if (isModEnabled(
'category')) {
1621 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1622 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories',
$object);
1626 if (isModEnabled(
'resource')) {
1628 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1630 $listofresourceid = array();
1631 if (empty($donotclearsession)) {
1632 $assignedtoresource =
GETPOST(
"assignedtoresource");
1633 if ($assignedtoresource) {
1634 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1636 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1638 if (!empty($_SESSION[
'assignedtoresource'])) {
1639 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1641 if (!is_array($listofresourceid)) {
1642 $listofresourceid = array();
1644 $firstelem = reset($listofresourceid);
1645 if (isset($listofresourceid[$firstelem[
'id']])) {
1646 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1649 print
'<div class="assignedtoresource">';
1650 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1, array(), 0,
'', array(),
'0', 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1656 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td>';
1658 $percent = $complete !==
'' ? $complete : -1;
1659 if (GETPOSTISSET(
'status')) {
1661 } elseif (GETPOSTISSET(
'percentage')) {
1664 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1666 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1670 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1676 print
'<br><hr><br>';
1679 print
'<table class="border centpercent nobottom">';
1681 if (isModEnabled(
"societe")) {
1683 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1687 print $societe->getNomUrl(1);
1688 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1691 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1693 if (!empty($user->socid)) {
1694 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1696 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'', $langs->trans(
'SelectThirdParty'), 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1702 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1703 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1707 if ($origin ==
'contact') {
1713 $select_contact_default = 0;
1715 $select_contact_default = -1;
1717 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1726 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1727 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, array(),
'multiple',
'contactid');
1728 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1730 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, array(),
'multiple',
'contactid');
1737 if (isModEnabled(
'project')) {
1738 $langs->load(
"projects");
1742 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1743 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1744 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');
1746 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1747 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1748 $urloption =
'?action=create&donotclearsession=1';
1752 print
"\n".
'<script type="text/javascript">';
1753 print
'$(document).ready(function () {
1754 $("#projectid").change(function () {
1755 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1756 console.log("Call url to get the new list of tasks: "+url);
1757 $.get(url, function(data) {
1759 if (data) $("#taskid").html(data).select2();
1763 print
'</script>'.
"\n";
1768 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1769 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1770 $projectsListId =
'';
1771 if (!empty($projectid)) {
1772 $projectsListId = $projectid;
1775 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1777 if (empty($projectsListId)) {
1778 print
'<select class="valignmiddle flat maxwidth500 widthcentpercentminusxx minwidth150imp" id="taskid" name="taskid">';
1779 print
'<option class="opacitymedium"> </option>';
1780 print
'<option class="opacitymedium" disabled data-html="'.dolPrintHTMLForAttribute($langs->trans(
"SelectAProjectFirst")).
'">'.$langs->trans(
"SelectAProjectFirst").
'</option>';
1784 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 32, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (string) $projectsListId,
'all', null, 1);
1790 if (!empty($origin) && !empty($originid)) {
1791 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1793 $hasPermissionOnLinkedObject = 0;
1796 $modulecodetouseforpermissioncheck = $elProp[
'module'];
1798 if ($modulecodetouseforpermissioncheck ==
'productbatch') {
1799 $modulecodetouseforpermissioncheck =
'produit';
1801 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read') || $user->hasRight($modulecodetouseforpermissioncheck, $elProp[
'element'],
'read')) {
1802 $hasPermissionOnLinkedObject = 1;
1806 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1808 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1809 print
'<td colspan="3">';
1810 if ($hasPermissionOnLinkedObject) {
1812 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1813 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1814 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1815 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1817 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1825 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1826 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1831 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1832 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1833 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 120,
'dolibarr_notes',
'In', true, true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1834 $doleditor->Create();
1838 $parameters = array();
1839 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1840 print $hookmanager->resPrint;
1841 if (empty($reshook)) {
1842 print
$object->showOptionals($extrafields,
'create', $parameters);
1852 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><br>';
1854 print
'<div class="reminderparameters" '.(empty(
GETPOST(
'addreminder')) ?
'style="display: none;' :
'').
' ">';
1856 print
'<table class="border centpercent">';
1859 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1860 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1861 print $form->selectTypeDuration(
'offsetunit', (empty($offsetunit) ?
'i' : $offsetunit), array(
'y',
'm'));
1865 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1866 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1871 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1872 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (empty($modelmail) ? 0 : $modelmail));
1879 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
1880 $reminderDefaultOffset =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_OFFSET', 30);
1882 $reminderDefaultEmailModel =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
1884 print
"\n".
'<script type="text/javascript">';
1885 print
'$(document).ready(function () {
1886 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
1887 $(
"#actioncode").change(
function(){
1888 var selected_event_type = $(
"#actioncode option:selected").val();
1890 if (reminderDefaultEventTypes.includes(selected_event_type)) {
1891 $(
".reminderparameters").show();
1892 $(
"#addreminder").prop(
"checked",
true);
1895 $(
"[name=\"offsetvalue\"]").val(\
'' .
dol_escape_js((
string) $reminderDefaultOffset) .
'\');
1896 $(
"#select_offsetunittype_duration").select2(
"destroy");
1897 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
1898 $(
"#select_offsetunittype_duration").select2();
1900 $(
"#selectremindertype").select2(
"destroy");
1901 $(
"#selectremindertype").val(
"email");
1902 $(
"#selectremindertype").select2();
1905 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
1906 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
1907 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js((
string) $reminderDefaultEmailModel).
'\');
1908 $(
"#select_actioncommsendmodel_mail").select2();
1912 print '</script>
'."\n";
1914 print "\n".'<script
type=
"text/javascript">
';
1915 print '$(document).ready(
function () {
1916 function toggle_reminder_part(evt) {
1917 console.log(
"Toggle reminder part");
1918 if ($(
"#addreminder").is(
":checked")) {
1919 $(
".reminderparameters").show();
1921 $(
".reminderparameters").hide();
1923 $(
"#selectremindertype").select2(
"destroy");
1924 $(
"#selectremindertype").select2();
1925 $(
"#select_offsetunittype_duration").select2(
"destroy");
1926 $(
"#select_offsetunittype_duration").select2();
1927 selectremindertype();
1930 toggle_reminder_part();
1931 $(
"#addreminder").click(toggle_reminder_part);
1933 $(
"#selectremindertype").change(
function(){
1934 selectremindertype();
1937 function selectremindertype() {
1938 console.log(
"Call selectremindertype");
1939 var selected_option = $(
"#selectremindertype option:selected").val();
1940 if(selected_option ==
"email") {
1941 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
1943 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
1948 print '</script>
'."\n";
1951 print dol_get_fiche_end();
1953 print $form->buttonsSaveCancel("Add");
1959if ($id > 0 && $action != 'create
') {
1960 $result1 = $object->fetch($id);
1961 if ($result1 <= 0) {
1962 recordNotFound('', 0);
1965 $result2 = $object->fetch_thirdparty();
1966 $result2 = $object->fetchProject();
1967 $result3 = $object->fetch_contact();
1968 $result4 = $object->fetch_userassigned();
1969 $result5 = $object->fetch_optionals();
1971 if ($listUserAssignedUpdated || $donotclearsession) {
1972 $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
1974 $datep = dol_mktime($fulldayevent ? 0 : $aphour, $fulldayevent ? 0 : $apmin, 0, GETPOSTINT("apmonth"), GETPOSTINT("apday"), GETPOSTINT("apyear"), 'tzuserrel
');
1975 $datef = dol_mktime($fulldayevent ? 23 : $p2hour, $fulldayevent ? 59 : $p2min, $fulldayevent ? 59 : 0, GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), 'tzuserrel
');
1977 $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09
'), 'c_actioncomm
');
1978 $object->label = GETPOST("label", "alphanohtml");
1979 $object->datep = $datep;
1980 $object->datef = $datef;
1981 $object->percentage = $percentage;
1982 $object->priority = GETPOST("priority", "alphanohtml");
1983 $object->fulldayevent = GETPOST("fullday") ? 1 : 0;
1984 $object->location = GETPOST('location
', "alphanohtml");
1985 $object->socid = GETPOSTINT("socid");
1986 $socpeopleassigned = GETPOST("socpeopleassigned", 'array
');
1987 foreach ($socpeopleassigned as $tmpid) {
1988 $object->socpeopleassigned[$id] = array('id' => $tmpid);
1990 $object->contact_id = GETPOSTINT("contactid");
1991 $object->fk_project = GETPOSTINT("projectid");
1993 $object->note_private = GETPOST("note", 'restricthtml
');
1996 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1997 dol_print_error($db, $object->error);
2006 $head = actions_prepare_head($object);
2009 $delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO
') * 24 * 60 * 60;
2012 // Confirmation suppression action
2013 if ($action == 'delete') {
2014 print $form->formconfirm("card.php?id=".urlencode((string) ($id)), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1);
2017 if ($action == 'edit
') {
2018 $caneditdateorowner = ($object->type != 'systemauto
');
2020 if (!empty($conf->use_javascript_ajax)) {
2021 print "\n".'<script
type=
"text/javascript">
';
2022 print '$(document).ready(
function () {
2023 function setdatefields()
2025 if ($(
"#fullday:checked").val() ==
null) {
2026 $(
".fulldaystarthour").removeAttr(
"disabled");
2027 $(
".fulldaystartmin").removeAttr(
"disabled");
2028 $(
".fulldayendhour").removeAttr(
"disabled");
2029 $(
".fulldayendmin").removeAttr(
"disabled");
2031 $(
".fulldaystarthour").prop(
"disabled",
true).val(
"00");
2032 $(
".fulldaystartmin").prop(
"disabled",
true).val(
"00");
2033 $(
".fulldayendhour").prop(
"disabled",
true).val(
"23");
2034 $(
".fulldayendmin").prop(
"disabled",
true).val(
"59");
2038 '.($caneditdateorowner ? ' setdatefields();
' : '').'
2040 $(
"#fullday").change(
function() {
2043 var old_startdate =
null;
2044 $(
"#ap").focus(
function() {
2045 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2047 $(
"#ap").next(
".ui-datepicker-trigger").click(
function() {
2048 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2050 $(
"#ap").change(
function() {
2051 setTimeout(
function() {
2052 if ($(
"#p2").val() !==
"") {
2053 var new_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
2054 var old_enddate =
new Date($(
"#p2year").val(), $(
"#p2month").val() - 1, $(
"#p2day").val());
2055 if (new_startdate > old_enddate) {
2056 var timeDiff = old_enddate - old_startdate;
2057 var new_enddate =
new Date(new_startdate.getTime() + timeDiff);
2058 $(
"#p2").val(formatDate(new_enddate,
"' . $langs->trans('FormatDateShortJavaInput') . '"));
2059 $(
"#p2day").val(new_enddate.getDate());
2060 $(
"#p2month").val(new_enddate.getMonth() + 1);
2061 $(
"#p2year").val(new_enddate.getFullYear());
2066 $(
"#actioncode").change(
function() {
2067 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
2068 else $("#dateend").removeClass("fieldrequired");
2071 print
'</script>'.
"\n";
2074 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
2075 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2076 print
'<input type="hidden" name="action" value="update">';
2077 print
'<input type="hidden" name="id" value="'.$id.
'">';
2078 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
2079 print
'<input type="hidden" name="page_y" value="">';
2081 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
2084 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2089 print
'<table class="border tableforfield centpercent">';
2092 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td>'.
$object->id.
'</td></tr>';
2096 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td>';
2097 if (
$object->type_code !=
'AC_OTH_AUTO') {
2098 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
2099 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
2101 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2102 print
$object->getTypePicto();
2103 print $langs->trans(
"Action".
$object->type_code);
2109 if (
$object->elementtype ==
'ticket') {
2110 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
2111 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
2112 print
'</td><td><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
2116 print
'<tr><td'.(!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ?
' class="fieldrequired titlefieldcreate"' :
'').
'>'.$langs->trans(
"Title").
'</td><td><input type="text" name="label" class="soixantepercent" value="'.
$object->label.
'"></td></tr>';
2119 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td class="valignmiddle height30 small">';
2120 print
'<input '.($caneditdateorowner ?
'' :
' disabled').
' type="checkbox" id="fullday" name="fullday" '.(
$object->fulldayevent ?
' checked' :
'').
'>';
2121 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
2184 print
'<tr><td class="nowrap">';
2187 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');
2188 print
' <span class="hideonsmartphone"> - </span> ';
2189 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');
2192 print
'<tr><td class=""> </td><td></td></tr>';
2195 $listofuserid = array();
2196 if (empty($donotclearsession)) {
2197 if (
$object->userownerid > 0) {
2198 $listofuserid[
$object->userownerid] = array(
2202 'transparency' =>
$object->transparency,
2203 'answer_status' => (isset(
$object->userassigned[
$object->userownerid][
'answer_status']) ?
$object->userassigned[
$object->userownerid][
'answer_status'] : null),
2204 'mandatory' => (isset(
$object->userassigned[
$object->userownerid][
'mandatory']) ?
$object->userassigned[
$object->userownerid][
'mandatory'] : null)
2207 if (!empty(
$object->userassigned)) {
2209 $tmplist1 =
$object->userassigned;
2210 foreach ($tmplist1 as $key => $val) {
2211 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2212 $listofuserid[$val[
'id']] = $val;
2216 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2218 if (!empty($_SESSION[
'assignedtouser'])) {
2219 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2223 $listofcontactid =
$object->socpeopleassigned;
2224 $listofotherid =
$object->otherassigned;
2226 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2227 print
'<div class="assignedtouser">';
2228 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, array(), 0,
'', array(),
'0', 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid, (int) $caneditdateorowner);
2240 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.
$object->location.
'"></td></tr>';
2244 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Progression").
'</td><td colspan="3">';
2245 $percent = GETPOSTISSET(
"percentage") ?
GETPOSTINT(
"percentage") :
$object->percentage;
2246 $formactions->form_select_status_action(
'formaction', (
string) $percent, 1,
'complete', 0, 0,
'maxwidth200');
2250 if (isModEnabled(
'category')) {
2251 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2252 print $form->selectCategories(Categorie::TYPE_ACTIONCOMM,
'categories',
$object);
2259 print
'<br><hr><br>';
2262 print
'<table class="border tableforfield centpercent">';
2264 if (isModEnabled(
"societe")) {
2266 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2270 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2273 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2278 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2279 print
'<div class="maxwidth200onsmartphone">';
2281 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2289 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2290 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, array(),
'multiple',
'contactid');
2291 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2294 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, array(),
'multiple',
'contactid');
2302 if (isModEnabled(
'project')) {
2303 $langs->load(
"projects");
2305 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2306 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2307 $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');
2308 if ($numprojet == 0) {
2309 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>';
2316 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2317 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2323 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2325 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2327 if (
$object->elementtype ==
'task' && isModEnabled(
'project')) {
2328 print
'<td id="project-task-input-container" >';
2330 $urloption =
'?action=create&donotclearsession=1';
2331 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2334 print
"\n".
'<script type="text/javascript" >';
2335 print
'$(document).ready(function () {
2336 $("#projectid").change(function () {
2337 var url = "'.$url.
'&projectid="+$("#projectid").val();
2338 $.get(url, function(data) {
2339 console.log($( data ).find("#fk_element").html());
2340 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2344 print
'</script>'.
"\n";
2346 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1),
$object->fk_element,
'fk_element', 24, 0,
'', 1, 0, 0,
'maxwidth500', (string)
$object->fk_project,
'all', null, 1);
2347 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2354 print
'<td id="project-task-input-container" >';
2357 print
"\n".
'<script type="text/javascript">';
2358 print
'$(document).ready(function () {
2359 $("#projectid").change(function () {
2360 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
2361 console.log("Call url to get new list of tasks: "+url);
2362 $.get(url, function(data) {
2364 if (data) $("#taskid").html(data).select2();
2368 print
'</script>'.
"\n";
2371 if (GETPOSTISSET(
"projecttaskid") &&
GETPOSTINT(
"projecttaskid") > 0) {
2373 } elseif (GETPOSTISSET(
"taskid") &&
GETPOSTINT(
"taskid") > 0) {
2377 print $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', (string) $projectsListId,
'all', null, 1);
2383 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2384 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2393 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2395 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2396 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2397 $doleditor->Create();
2401 $parameters = array();
2402 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2403 print $hookmanager->resPrint;
2404 if (empty($reshook)) {
2405 print
$object->showOptionals($extrafields,
'edit', $parameters);
2412 $filteruserid = $user->id;
2413 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2416 $object->loadReminders(
'', $filteruserid,
false);
2420 if (count(
$object->reminders) > 0) {
2421 $checked =
'checked';
2422 $keys = array_keys(
$object->reminders);
2423 $firstreminderId = array_shift($keys);
2425 $actionCommReminder =
$object->reminders[$firstreminderId];
2429 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2430 $actionCommReminder->offsetunit =
'i';
2431 $actionCommReminder->typeremind =
'email';
2440 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>';
2442 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2446 print
'<table class="border centpercent">';
2449 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2450 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2451 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2455 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2456 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2460 if ($actionCommReminder->typeremind ==
'browser') {
2461 $hide =
'style="display:none;"';
2466 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2467 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, (
string) $actionCommReminder->fk_email_template);
2473 print
"\n".
'<script type="text/javascript">';
2474 print
'$(document).ready(function () {
2475 $("#addreminder").click(function(){
2477 $(".reminderparameters").show();
2479 $(".reminderparameters").hide();
2483 $("#selectremindertype").change(function(){
2484 var selected_option = $("#selectremindertype option:selected").val();
2485 if(selected_option == "email") {
2486 $("#select_actioncommsendmodel_mail").closest("tr").show();
2488 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2493 print
'</script>'.
"\n";
2495 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
2498 $reminderDefaultEmailModel =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
2500 print
"\n".
'<script type="text/javascript">';
2501 print
'$(document).ready(function () {
2502 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
2503 $(
"#actioncode").change(
function(){
2504 var selected_event_type = $(
"#actioncode option:selected").val();
2506 if (reminderDefaultEventTypes.includes(selected_event_type)) {
2507 $(
".reminderparameters").show();
2508 $(
"#addreminder").prop(
"checked",
true);
2511 $(
"#offsetvalue").val(\
''.
dol_escape_js($reminderDefaultOffset).
'\');
2512 $(
"#select_offsetunittype_duration").select2(
"destroy");
2513 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
2514 $(
"#select_offsetunittype_duration").select2();
2516 $(
"#selectremindertype").select2(
"destroy");
2517 $(
"#selectremindertype").val(
"email");
2518 $(
"#selectremindertype").select2();
2521 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2522 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
2523 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js($reminderDefaultEmailModel).
'\');
2524 $(
"#select_actioncommsendmodel_mail").select2();
2528 print '</script>
'."\n";
2529 print '</div>
'; // End of div for reminderparameters
2532 print dol_get_fiche_end();
2534 print $form->buttonsSaveCancel();
2538 print dol_get_fiche_head($head, 'card
', $langs->trans("Action"), -1, 'action
');
2543 if ($action == 'clone
') {
2544 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?
id=
'.GETPOST('id'), $langs->trans('ToClone
'), $langs->trans('ConfirmCloneEvent
', $object->label), 'confirm_clone
', array(), 'yes
', 1);
2547 // Call Hook formConfirm
2548 $parameters = array();
2549 $reshook = $hookmanager->executeHooks('formConfirm
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2550 if (empty($reshook)) {
2551 $formconfirm .= $hookmanager->resPrint;
2552 } elseif ($reshook > 0) {
2553 $formconfirm = $hookmanager->resPrint;
2556 // Print form confirm
2560 // Link to other agenda views
2561 $linkback .= '<a href=
"'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">
';
2562 $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist
', 'class=
"pictoactionview pictofixedwidth"');
2563 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("BackToList").'</span>
';
2564 $linkback .= '</a>
';
2565 $linkback .= '</li>
';
2566 $linkback .= '<li
class=
"noborder litext">
';
2567 $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').'">
';
2568 $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar
', 'class=
"pictoactionview pictofixedwidth"');
2569 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewCal").'</span>
';
2570 $linkback .= '</a>
';
2571 $linkback .= '</li>
';
2572 $linkback .= '<li
class=
"noborder litext">
';
2573 $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').'">
';
2574 $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek
', 'class=
"pictoactionview pictofixedwidth"');
2575 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewWeek").'</span>
';
2576 $linkback .= '</a>
';
2577 $linkback .= '</li>
';
2578 $linkback .= '<li
class=
"noborder litext">
';
2579 $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').'">
';
2580 $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday
', 'class=
"pictoactionview pictofixedwidth"');
2581 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewDay").'</span>
';
2582 $linkback .= '</a>
';
2583 $linkback .= '</li>
';
2584 $linkback .= '<li
class=
"noborder litext">
';
2585 $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').'">
';
2586 $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser
', 'class=
"pictoactionview pictofixedwidth"');
2587 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewPerUser").'</span>
';
2588 $linkback .= '</a>
';
2590 // Add more views from hooks
2591 $parameters = array();
2592 $reshook = $hookmanager->executeHooks('addCalendarView
', $parameters, $object, $action);
2593 if (empty($reshook)) {
2594 $linkback .= $hookmanager->resPrint;
2595 } elseif ($reshook > 1) {
2596 $linkback = $hookmanager->resPrint;
2601 $morehtmlref = '<div
class=
"refidno">
';
2603 //$morehtmlref.='<br>
'.$langs->trans('ThirdParty
') . ' :
' . $object->thirdparty->getNomUrl(1);
2605 if (isModEnabled('project
')) {
2606 $langs->load("projects");
2607 //$morehtmlref .= '<br>
';
2608 if ($usercancreate) {
2609 $morehtmlref .= img_picto($langs->trans("Project"), 'project
', 'class=
"pictofixedwidth"');
2610 if ($action != 'classify
') {
2611 $morehtmlref .= '<a class=
"editfielda" href=
"'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">
'.img_edit($langs->transnoentitiesnoconv('SetProject
')).'</a>
';
2613 $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
');
2615 if (!empty($object->fk_project)) {
2616 $proj = new Project($db);
2617 $proj->fetch($object->fk_project);
2618 $morehtmlref .= $proj->getNomUrl(1);
2620 $morehtmlref .= '<span class=
"opacitymedium"> -
'.dol_escape_htmltag($proj->title).'</span>
';
2625 $morehtmlref .= '</div>
';
2628 dol_banner_tab($object, 'id
', $linkback, ($user->socid ? 0 : 1), 'id
', 'ref', $morehtmlref);
2630 print '<div class=
"fichecenter">
';
2631 print '<div class=
"fichehalfleft">
';
2633 print '<div class=
"underbanner clearboth"></div>
';
2635 // Show event in view mode
2636 print '<
table class=
"border tableforfield centpercent">
';
2639 if (getDolGlobalString('AGENDA_USE_EVENT_TYPE
')) {
2640 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("Type").'</td><td>
';
2641 $labeltype = ($langs->transnoentities("Action".$object->type_code) != "Action".$object->type_code) ? $langs->transnoentities("Action".$object->type_code) : $object->type_label;
2642 $labeltoshow = $labeltype;
2643 if ($object->code) {
2644 $labeltoshow .= ' (
'.$object->code.')
';
2646 print $object->getTypePicto('pictofixedwidth paddingright
', $labeltoshow);
2652 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("EventOnFullDay").'</td><td>
'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>
';
2655 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2660 print '<tr><td>
'.$langs->trans("DateActionStart").'</td><td>
';
2661 // Test a date before the 27 march and one after
2662 //print dol_print_date($object->datep, 'dayhour
', 'gmt
');
2663 //print dol_print_date($object->datep, 'dayhour
', 'tzuser
');
2664 //print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2665 if (empty($object->fulldayevent)) {
2666 print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2668 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2669 print dol_print_date($object->datep, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2671 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2672 print img_warning($langs->trans("Late"));
2678 print '<tr><td>
'.$langs->trans("DateActionEnd").'</td><td>
';
2679 if (empty($object->fulldayevent)) {
2680 print dol_print_date($object->datef, 'dayhour
', 'tzuserrel
');
2682 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2683 print dol_print_date($object->datef, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2685 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2686 print img_warning($langs->trans("Late"));
2690 // Recurring event (into a series)
2691 if ($object->recurid) {
2692 print '<tr><td class=
"titlefieldmiddle">
'.$langs->trans("RecurringEvent").'</td><td>
';
2693 print img_picto($langs->trans("EventPartOfARecurringSerie", $object->recurid), 'recurring
', 'class=
"pictofixedwidth"');
2695 if (preg_match('/FREQ=MONTHLY_BYMONTHDAY(\d+)/
', $object->recurrule, $reg)) {
2696 print $langs->trans("EveryMonth").' <span class=
"opacitymedium small">(
'.$langs->trans("DayOfMonth").' '.$reg[1].' -
'.$langs->trans("Until").' '.dol_print_date($object->recurdateend, 'day
').')</span>
';
2702 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2703 print '<tr><td>
'.$langs->trans("Location").'</td><td>
'.$object->location.'</td></tr>
';
2707 print '<tr><td class=
"nowrap">
'.$langs->trans("ActionAssignedTo").'</td><td>
';
2708 $listofuserid = array();
2709 if (empty($donotclearsession)) {
2710 if ($object->userownerid > 0) {
2711 $listofuserid[$object->userownerid] = array(
2712 'id
' => $object->userownerid,
2713 'transparency
' => $object->transparency, // Force transparency on owner from property of event
2714 'answer_status
' => $object->userassigned[$object->userownerid]['answer_status
'],
2715 'mandatory
' => $object->userassigned[$object->userownerid]['mandatory
']
2718 if (!empty($object->userassigned)) { // Now concat assigned users
2719 // Restore array with key with same value than param 'id
'
2720 $tmplist1 = $object->userassigned;
2721 foreach ($tmplist1 as $key => $val) {
2722 if ($val['id
'] && $val['id
'] != $object->userownerid) {
2723 $listofuserid[$val['id
']] = $val;
2727 $_SESSION['assignedtouser
'] = json_encode($listofuserid);
2729 if (!empty($_SESSION['assignedtouser
'])) {
2730 $listofuserid = json_decode($_SESSION['assignedtouser
'], true);
2734 $listofcontactid = array(); // not used yet
2735 $listofotherid = array(); // not used yet
2736 print '<div class=
"assignedtouser">
';
2737 print $form->select_dolusers_forevent('view
', 'assignedtouser
', 1, array(), 0, '', array(), '0
', 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2740 if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
2742 print '<div class=
"myavailability">
';
2743 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
2747 print ' </td></tr>
';
2750 if (isModEnabled('category
')) {
2751 print '<tr><td class=
"valignmiddle">
'.$langs->trans("Categories").'</td><td>
';
2752 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2760 print '<div class=
"fichehalfright">
';
2762 print '<div class=
"underbanner clearboth"></div>
';
2763 print '<
table class=
"border tableforfield centpercent">
';
2765 if (isModEnabled("societe")) {
2767 print '<tr><td class=
"titlefield">
'.$langs->trans("ActionOnCompany").'</td>
';
2768 print '<td>
'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : ('<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
'));
2769 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL
') {
2770 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2771 print "<br>".dol_print_phone($object->thirdparty->phone);
2777 print '<tr><td>
'.$langs->trans("ActionOnContact").'</td>
';
2780 if (!empty($object->socpeopleassigned)) {
2781 foreach ($object->socpeopleassigned as $cid => $Tab) {
2782 $contact = new Contact($db);
2783 $result = $contact->fetch($cid);
2786 dol_print_error($db, $contact->error);
2790 print $contact->getNomUrl(1);
2791 if ($object->type_code == 'AC_TEL
') {
2792 if (!empty($contact->phone_pro)) {
2793 print '(
'.dol_print_phone($contact->phone_pro).')
';
2796 print '<div class=
"paddingright"></div>
';
2800 print '<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
';
2806 if (getDolGlobalString('AGENDA_SUPPORT_PRIORITY_IN_EVENTS
')) {
2807 print '<tr><td class=
"nowrap" class=
"titlefield">
' . $langs->trans("Priority") . '</td><td>
';
2808 print($object->priority ? $object->priority : '');
2812 // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
2813 // for such objects because there is already a dedicated field into table llx_actioncomm.
2814 if (!empty($object->elementid) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe
', 'contact
', 'project
'))) {
2815 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
2816 print '<tr><td>
'.$langs->trans("LinkedObject").'</td>
';
2817 $link = dolGetElementUrl($object->elementid, $object->elementtype, ($object->elementtype == 'user' ? -1 : 1));
2820 print '<span class=
"opacitymedium">
'.$langs->trans("ObjectDeleted").'</span>
';
2828 if (!empty($object->email_msgid)) {
2829 print '<tr><td>
'.$langs->trans('MailTopic
').'</td>
';
2830 print '<td>
'.dol_escape_htmltag($object->email_subject).'</td></tr>
';
2831 print '<tr><td>
'.$langs->trans('MailFrom
').'</td>
';
2832 print '<td>
'.dol_escape_htmltag($object->email_from).'</td></tr>
';
2833 print '<tr><td>
'.$langs->trans('MailTo
').'</td>
';
2834 print '<td>
'.dol_escape_htmltag($object->email_to).'</td></tr>
';
2835 if (!empty($object->email_tocc)) {
2836 print '<tr><td>
'.$langs->trans('MailCC
').'</td>
';
2837 print '<td>
'.dol_escape_htmltag($object->email_tocc).'</td></tr>
';
2842 print '<tr><td class=
"tdtop">
'.$langs->trans("Description").'</td><td class=
"wordbreak sensiblehtmlcontent">
';
2843 print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
2847 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php
';
2850 if (getDolGlobalString('AGENDA_REMINDER_EMAIL
') || getDolGlobalString('AGENDA_REMINDER_BROWSER
')) {
2851 $filteruserid = $user->id;
2852 if ($user->hasRight('agenda
', 'allactions
', 'read
')) {
2855 $object->loadReminders('', $filteruserid, false);
2857 print '<tr><td class=
"titlefieldcreate nowrap">
'.$langs->trans("Reminders").'</td><td>
';
2859 if (count($object->reminders) > 0) {
2860 $tmpuserstatic = new User($db);
2862 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2863 print $TRemindTypes[$actioncommreminder->typeremind]['label
'];
2864 if ($actioncommreminder->fk_user > 0) {
2865 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2866 print ' (
'.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')
';
2868 print ' -
'.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit];
2870 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2871 print ' - <span class=
"opacitymedium">
';
2872 print $langs->trans("NotSent");
2874 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2875 print ' - <span class=
"opacitymedium">
';
2876 print $langs->trans("Done");
2878 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2879 print ' - <span class=
"opacitymedium">
';
2880 print $form->textwithpicto($langs->trans("Error"), $actioncommreminder->lasterror);
2894 print '<div class=
"clearboth"></div>
';
2896 print dol_get_fiche_end();
2903 print '<div class=
"tabsAction">
';
2905 $parameters = array();
2906 $reshook = $hookmanager->executeHooks('addMoreActionsButtons
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2907 if (empty($reshook)) {
2908 if ($action != 'edit
') {
2909 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
2910 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
2911 print '<div class=
"inline-block divButAction"><a class=
"butAction" href=
"card.php?action=edit&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Modify").'</a></div>
';
2913 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Modify").'</a></div>
';
2916 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
2917 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
2918 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>
';
2920 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("ToClone").'</a></div>
';
2923 if ($user->hasRight('agenda
', 'allactions
', 'delete
') ||
2924 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'delete
'))) {
2925 print '<div class=
"inline-block divButAction"><a class=
"butActionDelete" href=
"card.php?action=delete&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Delete").'</a></div>
';
2927 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Delete").'</a></div>
';
2934 if ($action != 'edit
') {
2935 if (!getDolGlobalString('AGENDA_DISABLE_BUILDDOC
')) {
2936 print '<div class=
"clearboth"></div><div class=
"fichecenter"><div class=
"fichehalfleft">
';
2937 print '<a
name=
"builddoc"></a>
'; // ancre
2940 * Generated documents
2943 $filedir = $conf->agenda->multidir_output[$conf->entity].'/
'.$object->id;
2944 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
2946 $genallowed = $user->hasRight('agenda
', 'myactions
', 'read
');
2947 $delallowed = $user->hasRight('agenda
', 'myactions
', 'create
');
2950 print $formfile->showdocuments('actions
', (string) $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang());
2952 print '</div><div class=
"fichehalfright">
';
2955 print '</div></div>
';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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_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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_now($mode='auto')
Return date for now.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
$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
$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.