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');
114if ($user->socid && ($socid != $user->socid)) {
119$donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
128$form =
new Form($db);
133if ($id > 0 && $action !=
'add') {
137 $ret =
$object->fetch_optionals();
138 $ret1 =
$object->fetch_userassigned();
140 if ($ret < 0 || $ret1 < 0) {
146$extrafields->fetch_name_optionals_label(
$object->table_element);
149$hookmanager->initHooks(array(
'actioncard',
'globalcard'));
151$parameters = array(
'socid' => $socid);
152$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
157$TRemindTypes = array();
159 $TRemindTypes[
'browser'] = array(
'label' => $langs->trans(
'BrowserPush'),
'disabled' => (
getDolGlobalString(
'AGENDA_REMINDER_BROWSER') ? 0 : 1));
162 $TRemindTypes[
'email'] = array(
'label' => $langs->trans(
'EMail'),
'disabled' => (
getDolGlobalString(
'AGENDA_REMINDER_EMAIL') ? 0 : 1));
165$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'));
167$result =
restrictedArea($user,
'agenda',
$object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
169$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || ((empty(
$object->id) ||
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
176$listUserAssignedUpdated =
false;
177$listResourceAssignedUpdated =
false;
178$assignedtouser = array();
181if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
182 $idtoremove =
GETPOST(
'removedassigned');
184 if (!empty($_SESSION[
'assignedtouser'])) {
185 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'],
true);
187 $tmpassigneduserids = array();
190 foreach ($tmpassigneduserids as $key => $val) {
191 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
192 unset($tmpassigneduserids[$key]);
196 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
197 $donotclearsession = 1;
198 if ($action ==
'add') {
201 if ($action ==
'update') {
205 $listUserAssignedUpdated =
true;
208if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
209 $idtoremove =
GETPOST(
'removedassignedresource');
211 if (!empty($_SESSION[
'assignedtoresource'])) {
212 $tmpassignedresourceids = json_decode($_SESSION[
'assignedtoresource'],
true);
214 $tmpassignedresourceids = array();
217 foreach ($tmpassignedresourceids as $key => $val) {
218 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
219 unset($tmpassignedresourceids[$key]);
223 $_SESSION[
'assignedtoresource'] = json_encode($tmpassignedresourceids);
224 $donotclearsessionresource = 1;
225 if ($action ==
'add' && $usercancreate) {
228 if ($action ==
'update' && $usercancreate) {
232 $listResourceAssignedUpdated =
true;
236if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
238 if (
GETPOST(
'assignedtouser') > 0) {
239 $assignedtouser = array();
240 if (!empty($_SESSION[
'assignedtouser'])) {
241 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
243 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id' =>
GETPOSTINT(
'assignedtouser'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
244 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
246 $donotclearsession = 1;
247 if ($action ==
'add' && $usercancreate) {
250 if ($action ==
'update' && $usercancreate) {
254 $listUserAssignedUpdated =
true;
258if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
260 if (
GETPOST(
'assignedtoresource') > 0) {
261 $assignedtoresource = array();
262 if (!empty($_SESSION[
'assignedtoresource'])) {
263 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
265 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id' =>
GETPOSTINT(
'assignedtoresource'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
266 $_SESSION[
'assignedtoresource'] = json_encode($assignedtoresource);
268 $donotclearsession = 1;
269 if ($action ==
'add' && $usercancreate) {
272 if ($action ==
'update' && $usercancreate) {
276 $listResourceAssignedUpdated =
true;
280if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
281 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
287if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
288 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
293 if (!empty(
$object->socpeopleassigned)) {
294 reset(
$object->socpeopleassigned);
299 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
310if (empty($reshook) && $action ==
'add' && $usercancreate) {
313 if (empty($backtopage)) {
315 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
317 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
321 if (!empty($socpeopleassigned[0])) {
322 $result = $contact->fetch($socpeopleassigned[0]);
326 header(
"Location: ".$backtopage);
330 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
343 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
346 if (!$datef && $percentage == 100) {
348 $donotclearsession = 1;
350 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
355 $donotclearsession = 1;
357 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
361 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
363 $donotclearsession = 1;
365 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
370 $listofresourceid = array();
375 $object->fulldayevent = ($fulldayevent ? 1 : 0);
379 if (
GETPOST(
"elementtype",
'alpha')) {
381 $modulecodetouseforpermissioncheck = $elProp[
'module'];
382 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
384 $hasPermissionOnLinkedObject = 0;
385 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
386 $hasPermissionOnLinkedObject = 1;
387 } elseif ($user->hasRight($modulecodetouseforpermissioncheck, $submodulecodetouseforpermissioncheck,
'read')) {
388 $hasPermissionOnLinkedObject = 1;
391 if ($hasPermissionOnLinkedObject) {
399 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
400 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
402 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
403 $object->label = $langs->transnoentitiesnoconv(
"Action".
$object->type_code).
"\n";
405 $cactioncomm->fetch(
$object->type_code);
406 $object->label = $cactioncomm->label;
413 if (!empty($taskid)) {
414 $taskProject =
new Task($db);
415 if ($taskProject->fetch($taskid) > 0) {
416 $object->fk_project = $taskProject->fk_project;
426 $object->percentage = $percentage;
429 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
431 $listofuserid = array();
432 if (!empty($_SESSION[
'assignedtouser'])) {
433 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
436 if (!empty($_SESSION[
'assignedtoresource'])) {
437 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
441 foreach ($listofuserid as $key => $value) {
443 if ($value[
'id'] > 0) {
444 $object->userownerid = $value[
'id'];
446 $object->transparency = $transparency;
449 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
457 if (GETPOSTISSET(
"contactid")) {
471 if (empty(
$object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
473 $donotclearsession = 1;
475 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
477 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
479 $donotclearsession = 1;
481 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
486 $donotclearsession = 1;
488 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
491 foreach ($socpeopleassigned as $cid) {
492 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
494 if (!empty(
$object->socpeopleassigned)) {
495 reset(
$object->socpeopleassigned);
500 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
503 $donotclearsession = 1;
512 $selectedrecurrulefreq =
'no';
513 $selectedrecurrulebymonthday =
'';
514 $selectedrecurrulebyday =
'';
515 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
516 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY' && GETPOSTISSET(
'BYMONTHDAY')) ?
"_BYMONTHDAY".
GETPOST(
'BYMONTHDAY',
'alpha') :
"";
517 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY' && GETPOSTISSET(
'BYDAY')) ?
"_BYDAY".
GETPOST(
'BYDAY',
'alpha') :
"";
522 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
523 $selectedrecurrulefreq = $reg1[1];
525 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
526 $selectedrecurrulebymonthday = (int) $reg2[1];
528 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
529 $selectedrecurrulebyday = (int) $reg3[1];
533 $eventisrecurring = 0;
534 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 2 ? 1 : 0);
535 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
536 $eventisrecurring = 1;
546 $idaction =
$object->create($user);
551 if (is_array($listofresourceid) && count($listofresourceid)) {
552 foreach ($listofresourceid as $resource_id => $val) {
553 $resource_type =
'dolresource';
558 $eventDateStart =
$object->datep;
559 $eventDateEnd =
$object->datef;
560 $isFullDayEvent =
$object->fulldayevent;
561 if (empty($eventDateEnd)) {
562 if ($isFullDayEvent) {
564 $eventDateStart =
dol_mktime(0, 0, 0, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
565 $eventDateEnd =
dol_mktime(23, 59, 59, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
569 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
570 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_resources as er";
571 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) .
"'";
572 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape(
$object->element) .
"'";
573 $sql .=
" WHERE er.resource_id = " . ((int) $resource_id);
574 $sql .=
" AND er.busy = 1";
578 $sql .=
" (ac.datep <= '" . $db->idate($eventDateStart) .
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) .
"'))";
580 if (!empty($eventDateEnd)) {
581 $sql .=
" OR (ac.datep <= '" . $db->idate($eventDateEnd) .
"' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) .
"'))";
585 $sql .=
"ac.datep >= '" . $db->idate($eventDateStart) .
"'";
586 if (!empty($eventDateEnd)) {
587 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) .
"')";
592 $resql = $db->query($sql);
595 $object->error = $db->lasterror();
598 if ($db->num_rows($resql) > 0) {
601 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse') .
' : ';
602 while ($obj = $db->fetch_object($resql)) {
603 $object->error .=
'<br> - ' . $langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label .
' [' . $obj->ac_id .
']');
612 $res =
$object->add_element_resource($resource_id, $resource_type, $busy, $val[
'mandatory']);
617 unset($_SESSION[
'assignedtoresource']);
620 $categories =
GETPOST(
'categories',
'array');
621 $object->setCategories($categories);
623 unset($_SESSION[
'assignedtouser']);
625 if ($user->id !=
$object->userownerid) {
626 $moreparam =
"filtert=-1";
630 if ($addreminder ==
'on') {
635 $actionCommReminder->dateremind = $dateremind;
636 $actionCommReminder->typeremind = $remindertype;
637 $actionCommReminder->offsetunit = $offsetunit;
638 $actionCommReminder->offsetvalue = $offsetvalue;
639 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
640 $actionCommReminder->fk_actioncomm =
$object->id;
641 if ($remindertype ==
'email') {
642 $actionCommReminder->fk_email_template = $modelmail;
646 foreach (
$object->userassigned as $userassigned) {
647 $actionCommReminder->fk_user = $userassigned[
'id'];
648 $res = $actionCommReminder->create($user);
653 $langs->load(
"errors");
654 $error = $langs->trans(
'ErrorReminderActionCommCreation');
657 $donotclearsession = 1;
668 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
688 $langs->load(
"errors");
689 $error = $langs->trans(
$object->error);
692 $donotclearsession = 1;
698 $donotclearsession = 1;
701 if ($eventisrecurring) {
705 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
707 $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');
711 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
712 $firstday = $selectedrecurrulebymonthday;
721 $repeateventlimitdate =
dol_mktime(23, 59, 59, GETPOSTISSET(
"limitmonth") ?
GETPOSTINT(
"limitmonth") : 1, GETPOSTISSET(
"limitday") ?
GETPOSTINT(
"limitday") : 1, GETPOSTISSET(
"limityear") &&
GETPOSTINT(
"limityear") < 2100 ?
GETPOSTINT(
"limityear") : 2100, $tzforfullday ? $tzforfullday :
'tzuserrel');
727 while ($datep <= $repeateventlimitdate && !$error) {
731 $finalobject->datep = $datep;
732 $finalobject->datef = $datef;
734 $idaction = $finalobject->create($user);
737 if (!$finalobject->error) {
739 $categories =
GETPOST(
'categories',
'array');
740 $finalobject->setCategories($categories);
742 unset($_SESSION[
'assignedtouser']);
745 if ($user->id != $finalobject->userownerid) {
746 $moreparam =
"filtert=-1";
750 if ($addreminder ==
'on') {
755 $actionCommReminder->dateremind = $dateremind;
756 $actionCommReminder->typeremind = $remindertype;
757 $actionCommReminder->offsetunit = $offsetunit;
758 $actionCommReminder->offsetvalue = $offsetvalue;
759 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
760 $actionCommReminder->fk_actioncomm = $finalobject->id;
761 if ($remindertype ==
'email') {
762 $actionCommReminder->fk_email_template = $modelmail;
766 foreach ($finalobject->userassigned as $userassigned) {
767 $actionCommReminder->fk_user = $userassigned[
'id'];
768 $res = $actionCommReminder->create($user);
773 $langs->load(
"errors");
774 $error = $langs->trans(
'ErrorReminderActionCommCreation');
777 $donotclearsession = 1;
788 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
798 $langs->load(
"errors");
799 $error = $langs->trans($finalobject->error);
802 $donotclearsession = 1;
808 $donotclearsession = 1;
812 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
823 if (!empty($backtopage) && !$error) {
824 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
825 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
826 } elseif ($idaction) {
827 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
829 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
836if (empty($reshook) && $action ==
'update' && $usercancreate) {
837 if (empty($cancel)) {
838 $fulldayevent =
GETPOST(
'fullday');
843 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
876 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
878 if (
$object->elementtype ==
'ticket') {
880 if (
$object->code ==
'TICKET_MSG') {
881 $object->code =
'TICKET_MSG_PRIVATE';
883 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
884 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
887 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
890 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
891 $object->code =
'TICKET_MSG_SENTBYMAIL';
903 $object->percentage = $percentage;
908 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
909 $object->socpeopleassigned = array();
910 foreach ($socpeopleassigned as $cid) {
911 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
914 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
915 reset(
$object->socpeopleassigned);
921 if (
GETPOST(
"elementtype",
'alpha')) {
923 $modulecodetouseforpermissioncheck = $elProp[
'module'];
925 $hasPermissionOnLinkedObject = 0;
926 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
927 $hasPermissionOnLinkedObject = 1;
929 if ($hasPermissionOnLinkedObject) {
937 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
940 $listofuserid = array();
941 if (!empty($_SESSION[
'assignedtouser'])) {
943 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
944 foreach ($tmplist1 as $key => $val) {
945 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
946 $listofuserid[$val[
'id']] = $val;
950 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
951 if ($assignedtouser) {
952 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
955 $object->userassigned = array();
958 foreach ($listofuserid as $key => $val) {
960 $object->userownerid = $val[
'id'];
962 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
966 $object->transparency = $transparency;
970 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
972 $donotclearsession = 1;
974 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
976 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
978 if (empty(
$object->userownerid)) {
980 $donotclearsession = 1;
982 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
986 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
994 $eventDateStart =
$object->datep;
995 $eventDateEnd =
$object->datef;
997 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
998 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
999 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1000 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1001 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1002 $sql .=
" AND er.resource_id IN (";
1003 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1004 $sql .=
" WHERE element_id = ".((int)
$object->id);
1005 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1006 $sql .=
" AND busy = 1";
1008 $sql .=
" AND er.busy = 1";
1012 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1014 if (!empty($eventDateEnd)) {
1015 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1019 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1020 if (!empty($eventDateEnd)) {
1021 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1026 $resql = $db->query($sql);
1029 $object->error = $db->lasterror();
1032 if ($db->num_rows($resql) > 0) {
1035 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1036 while ($obj = $db->fetch_object($resql)) {
1037 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1053 $result =
$object->update($user);
1057 $categories =
GETPOST(
'categories',
'array');
1058 $object->setCategories($categories);
1060 $object->loadReminders($remindertype, 0,
false);
1063 if (!empty(
$object->reminders)) {
1064 foreach (
$object->reminders as $reminder) {
1065 if ($reminder->status < 1) {
1066 $reminder->delete($user);
1073 if ($addreminder ==
'on') {
1078 $actionCommReminder->dateremind = $dateremind;
1079 $actionCommReminder->typeremind = $remindertype;
1080 $actionCommReminder->offsetunit = $offsetunit;
1081 $actionCommReminder->offsetvalue = $offsetvalue;
1082 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
1083 $actionCommReminder->fk_actioncomm =
$object->id;
1084 if ($remindertype ==
'email') {
1085 $actionCommReminder->fk_email_template = $modelmail;
1089 foreach (
$object->userassigned as $userassigned) {
1090 $actionCommReminder->fk_user = $userassigned[
'id'];
1094 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1095 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".$db->escape($remindertype).
"'";
1096 $resqldelete = $db->query($sqldelete);
1098 $res = $actionCommReminder->create($user);
1102 $langs->load(
"errors");
1103 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1106 $donotclearsession = 1;
1113 unset($_SESSION[
'assignedtouser']);
1114 unset($_SESSION[
'assignedtoresource']);
1129 if (!empty($backtopage)) {
1130 unset($_SESSION[
'assignedtouser']);
1131 header(
"Location: ".$backtopage);
1138if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
1141 $object->fetch_userassigned();
1144 if ($user->hasRight(
'agenda',
'myactions',
'delete')
1145 || $user->hasRight(
'agenda',
'allactions',
'delete')) {
1146 $result =
$object->delete($user);
1149 header(
"Location: index.php");
1161if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
1167 $newdate =
GETPOST(
'newdate',
'alpha');
1168 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1169 header(
"Location: ".$backtopage,
true, 307);
1173 $datep =
dol_mktime($shour, $smin, 0, (
int) substr($newdate, 13, 2), (
int) substr($newdate, 15, 2), (
int) substr($newdate, 9, 4),
'tzuserrel');
1176 if ($datep !=
$object->datep) {
1185 $eventDateStart =
$object->datep;
1186 $eventDateEnd =
$object->datef;
1188 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1189 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1190 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1191 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1192 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1193 $sql .=
" AND er.resource_id IN (";
1194 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1195 $sql .=
" WHERE element_id = ".((int)
$object->id);
1196 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1197 $sql .=
" AND busy = 1";
1199 $sql .=
" AND er.busy = 1";
1203 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1205 if (!empty($eventDateEnd)) {
1206 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1210 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1211 if (!empty($eventDateEnd)) {
1212 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1217 $resql = $db->query($sql);
1220 $object->error = $db->lasterror();
1223 if ($db->num_rows($resql) > 0) {
1226 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1227 while ($obj = $db->fetch_object($resql)) {
1228 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1243 $result =
$object->update($user);
1253 if (!empty($backtopage)) {
1254 header(
"Location: ".$backtopage,
true, 307);
1263$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1264if (empty($reshook)) {
1265 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1273$form =
new Form($db);
1276$arrayrecurrulefreq = array(
1277 'no' => $langs->trans(
"OnceOnly"),
1278 'MONTHLY' => $langs->trans(
"EveryMonth"),
1279 'WEEKLY' => $langs->trans(
"EveryWeek")
1284$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1285llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1287if ($action ==
'create') {
1290 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1291 if (!empty($socpeopleassigned[0])) {
1292 $result = $contact->fetch($socpeopleassigned[0]);
1300 if (!empty(
$conf->use_javascript_ajax)) {
1301 print
"\n".
'<script type="text/javascript">';
1302 print
'$(document).ready(function () {
1303 function setdatefields()
1305 if ($("#fullday:checked").val() == null) {
1306 $(".fulldaystarthour").removeAttr("disabled");
1307 $(".fulldaystartmin").removeAttr("disabled");
1308 $(".fulldayendhour").removeAttr("disabled");
1309 $(".fulldayendmin").removeAttr("disabled");
1310 $("#p2").removeAttr("disabled");
1312 $(".fulldaystarthour").prop("disabled", true).val("00");
1313 $(".fulldaystartmin").prop("disabled", true).val("00");
1314 $(".fulldayendhour").prop("disabled", true).val("23");
1315 $(".fulldayendmin").prop("disabled", true).val("59");
1316 $("#p2").removeAttr("disabled");
1319 $("#fullday").change(function() {
1320 console.log("setdatefields");
1323 var old_startdate = null;
1324 $("#ap").focus(function() {
1325 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1327 $("#ap").next(".ui-datepicker-trigger").click(function() {
1328 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1330 $("#ap").change(function() {
1331 setTimeout(function() {
1332 if ($("#p2").val() !== "") {
1333 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1334 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1335 if (new_startdate > old_enddate) {
1336 var timeDiff = old_enddate - old_startdate;
1337 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1338 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1339 $("#p2day").val(new_enddate.getDate());
1340 $("#p2month").val(new_enddate.getMonth() + 1);
1341 $("#p2year").val(new_enddate.getFullYear());
1346 $("#actioncode").change(function() {
1347 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1348 else $("#dateend").removeClass("fieldrequired");
1350 $("#aphour,#apmin").change(function() {
1351 if ($("#actioncode").val() == \'AC_RDV\') {
1352 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1353 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1354 $("#p2min").val($("#apmin").val());
1355 $("#p2day").val($("#apday").val());
1356 $("#p2month").val($("#apmonth").val());
1357 $("#p2year").val($("#apyear").val());
1358 $("#p2").val($("#ap").val());
1361 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1362 else $("#dateend").removeClass("fieldrequired");
1365 print
'</script>'.
"\n";
1368 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1369 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1370 print
'<input type="hidden" name="action" value="add">';
1371 print
'<input type="hidden" name="donotclearsession" value="1">';
1372 print
'<input type="hidden" name="page_y" value="">';
1374 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1377 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1380 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1381 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1388 print
'<table class="border centpercent nobottom">';
1392 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1394 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1395 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1396 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1401 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>';
1404 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1405 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>';
1408 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1409 if (
GETPOST(
'datep',
'alpha', 1)) {
1412 $datef = ($datef ? $datef :
$object->datef);
1413 if (
GETPOST(
'datef',
'alpha', 1)) {
1416 if (empty($datef) && !empty($datep)) {
1423 print
'<tr><td class="nowrap">';
1426 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1428 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1430 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1431 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1435 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0);
1436 if ($userepeatevent) {
1437 print
'<tr><td></td><td>';
1441 print
'<div class="opacitymedium inline-block small">';
1442 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 6px" class="paddingright2"');
1443 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1445 $selectedrecurrulefreq =
'no';
1446 $selectedrecurrulebymonthday =
'';
1447 $selectedrecurrulebyday =
'';
1448 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1449 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1450 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1454 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1455 $selectedrecurrulefreq = $reg[1];
1457 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1458 $selectedrecurrulebymonthday = (int) $reg[1];
1460 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1461 $selectedrecurrulebyday = (int) $reg[1];
1464 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1470 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1471 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1474 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1475 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1478 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1479 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1480 print $langs->trans(
"Until").
" ";
1481 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1484 print
'<script type="text/javascript">
1485 jQuery(document).ready(function() {
1486 function init_repeat()
1488 console.log("recurrule: " + "'.$object->recurrule.
'");
1489 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1490 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1491 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1492 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1493 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1495 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1496 jQuery(".repeateventlimitdate").css("display", "inline-block");
1497 jQuery(".repeateventBYDAY").hide();
1499 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1501 jQuery(".repeateventBYMONTHDAY").hide();
1502 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1503 jQuery(".repeateventlimitdate").css("display", "inline-block");
1507 jQuery(".repeateventBYMONTHDAY").hide();
1508 jQuery(".repeateventBYDAY").hide();
1509 jQuery(".repeateventlimitdate").hide();
1513 jQuery("#recurrulefreq").change(function() {
1522 print
'<tr><td class=""> </td><td></td></tr>';
1525 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1526 $listofuserid = array();
1527 $listofcontactid = array();
1528 $listofotherid = array();
1530 if (empty($donotclearsession)) {
1532 if ($assignedtouser) {
1533 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1536 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1537 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1539 if (!empty($_SESSION[
'assignedtouser'])) {
1540 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1542 if (!is_array($listofuserid)) {
1543 $listofuserid = array();
1545 $firstelem = reset($listofuserid);
1546 if (isset($listofuserid[$firstelem[
'id']])) {
1547 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1550 print
'<!-- list of user to assign --><div class="assignedtouser">';
1551 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, array(), 0,
'', array(), 0, 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid);
1557 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>';
1560 if (isModEnabled(
'category')) {
1562 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1563 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
1564 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'), 0, 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1568 if (isModEnabled(
'resource')) {
1570 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1572 $listofresourceid = array();
1573 if (empty($donotclearsession)) {
1574 $assignedtoresource =
GETPOST(
"assignedtoresource");
1575 if ($assignedtoresource) {
1576 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1578 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1580 if (!empty($_SESSION[
'assignedtoresource'])) {
1581 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1583 if (!is_array($listofresourceid)) {
1584 $listofresourceid = array();
1586 $firstelem = reset($listofresourceid);
1587 if (isset($listofresourceid[$firstelem[
'id']])) {
1588 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1591 print
'<div class="assignedtoresource">';
1592 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1, array(), 0,
'', array(), 0, 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1598 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1600 $percent = $complete !==
'' ? $complete : -1;
1601 if (GETPOSTISSET(
'status')) {
1603 } elseif (GETPOSTISSET(
'percentage')) {
1606 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1608 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1612 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1618 print
'<br><hr><br>';
1621 print
'<table class="border centpercent nobottom">';
1623 if (isModEnabled(
"societe")) {
1625 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1629 print $societe->getNomUrl(1);
1630 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1633 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1635 if (!empty($user->socid)) {
1636 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1638 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'', $langs->trans(
'SelectThirdParty'), 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1644 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1645 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1649 if ($origin ==
'contact') {
1655 $select_contact_default = 0;
1657 $select_contact_default = -1;
1659 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1668 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1669 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, array(),
'multiple',
'contactid');
1670 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1672 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, array(),
'multiple',
'contactid');
1679 if (isModEnabled(
'project')) {
1680 $langs->load(
"projects");
1684 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1685 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1686 print $formproject->select_projects((
$object->socid > 0 ?
$object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx maxwidth500');
1688 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1689 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1690 $urloption =
'?action=create&donotclearsession=1';
1694 print
"\n".
'<script type="text/javascript">';
1695 print
'$(document).ready(function () {
1696 $("#projectid").change(function () {
1697 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1698 console.log("Call url to get new list of tasks: "+url);
1699 $.get(url, function(data) {
1701 if (data) $("#taskid").html(data).select2();
1705 print
'</script>'.
"\n";
1710 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1711 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1712 $projectsListId =
false;
1713 if (!empty($projectid)) {
1714 $projectsListId = $projectid;
1717 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1719 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', $projectsListId);
1724 if (!empty($origin) && !empty($originid)) {
1725 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1727 $hasPermissionOnLinkedObject = 0;
1730 if ($user->hasRight($elProp[
'module'],
'read') || $user->hasRight($elProp[
'module'], $elProp[
'element'],
'read')) {
1731 $hasPermissionOnLinkedObject = 1;
1735 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1737 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1738 print
'<td colspan="3">';
1739 if ($hasPermissionOnLinkedObject) {
1741 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1742 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1743 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1744 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1746 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1754 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1755 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1760 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1761 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1762 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 120,
'dolibarr_notes',
'In', true, true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1763 $doleditor->Create();
1767 $parameters = array();
1768 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1769 print $hookmanager->resPrint;
1770 if (empty($reshook)) {
1771 print
$object->showOptionals($extrafields,
'create', $parameters);
1781 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1783 print
'<div class="reminderparameters" style="display: none;">';
1785 print
'<table class="border centpercent">';
1788 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1789 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1790 print $form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1794 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1795 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1800 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1801 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1808 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
1809 $reminderDefaultOffset =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_OFFSET', 30);
1811 $reminderDefaultEmailModel =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
1813 print
"\n".
'<script type="text/javascript">';
1814 print
'$(document).ready(function () {
1815 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
1816 $(
"#actioncode").change(
function(){
1817 var selected_event_type = $(
"#actioncode option:selected").val();
1819 if (reminderDefaultEventTypes.includes(selected_event_type)) {
1820 $(
".reminderparameters").show();
1821 $(
"#addreminder").prop(
"checked",
true);
1824 $(
"[name=\"offsetvalue\"]").val(\
'' .
dol_escape_js((
string) $reminderDefaultOffset) .
'\');
1825 $(
"#select_offsetunittype_duration").select2(
"destroy");
1826 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
1827 $(
"#select_offsetunittype_duration").select2();
1829 $(
"#selectremindertype").select2(
"destroy");
1830 $(
"#selectremindertype").val(
"email");
1831 $(
"#selectremindertype").select2();
1834 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
1835 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
1836 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js((
string) $reminderDefaultEmailModel).
'\');
1837 $(
"#select_actioncommsendmodel_mail").select2();
1841 print '</script>
'."\n";
1843 print "\n".'<script
type=
"text/javascript">
';
1844 print '$(document).ready(
function () {
1845 $(
"#addreminder").click(
function(){
1846 console.log(
"Click on addreminder");
1848 $(
".reminderparameters").show();
1850 $(
".reminderparameters").hide();
1852 $(
"#selectremindertype").select2(
"destroy");
1853 $(
"#selectremindertype").select2();
1854 $(
"#select_offsetunittype_duration").select2(
"destroy");
1855 $(
"#select_offsetunittype_duration").select2();
1856 selectremindertype();
1859 $(
"#selectremindertype").change(
function(){
1860 selectremindertype();
1863 function selectremindertype() {
1864 console.log(
"Call selectremindertype");
1865 var selected_option = $(
"#selectremindertype option:selected").val();
1866 if(selected_option ==
"email") {
1867 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
1869 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
1874 print '</script>
'."\n";
1877 print dol_get_fiche_end();
1879 print $form->buttonsSaveCancel("Add");
1886 $result1 = $object->fetch($id);
1887 if ($result1 <= 0) {
1888 $langs->load("errors");
1889 print $langs->trans("ErrorRecordNotFound");
1895 $result2 = $object->fetch_thirdparty();
1896 $result2 = $object->fetchProject();
1897 $result3 = $object->fetch_contact();
1898 $result4 = $object->fetch_userassigned();
1899 $result5 = $object->fetch_optionals();
1901 if ($listUserAssignedUpdated || $donotclearsession) {
1902 $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
1904 $datep = dol_mktime($fulldayevent ? 0 : $aphour, $fulldayevent ? 0 : $apmin, 0, GETPOSTINT("apmonth"), GETPOSTINT("apday"), GETPOSTINT("apyear"), 'tzuserrel
');
1905 $datef = dol_mktime($fulldayevent ? 23 : $p2hour, $fulldayevent ? 59 : $p2min, $fulldayevent ? 59 : 0, GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), 'tzuserrel
');
1907 $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09
'), 'c_actioncomm
');
1908 $object->label = GETPOST("label", "alphanohtml");
1909 $object->datep = $datep;
1910 $object->datef = $datef;
1911 $object->percentage = $percentage;
1912 $object->priority = GETPOST("priority", "alphanohtml");
1913 $object->fulldayevent = GETPOST("fullday") ? 1 : 0;
1914 $object->location = GETPOST('location
', "alphanohtml");
1915 $object->socid = GETPOSTINT("socid");
1916 $socpeopleassigned = GETPOST("socpeopleassigned", 'array
');
1917 foreach ($socpeopleassigned as $tmpid) {
1918 $object->socpeopleassigned[$id] = array('id' => $tmpid);
1920 $object->contact_id = GETPOSTINT("contactid");
1921 $object->fk_project = GETPOSTINT("projectid");
1923 $object->note_private = GETPOST("note", 'restricthtml
');
1926 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1927 dol_print_error($db, $object->error);
1931 if ($object->authorid > 0) {
1932 $tmpuser = new User($db);
1933 $res = $tmpuser->fetch($object->authorid);
1934 $object->author = $tmpuser;
1936 if ($object->usermodid > 0) {
1937 $tmpuser = new User($db);
1938 $res = $tmpuser->fetch($object->usermodid);
1939 $object->usermod = $tmpuser;
1947 $head = actions_prepare_head($object);
1950 $delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO
') * 24 * 60 * 60;
1953 // Confirmation suppression action
1954 if ($action == 'delete') {
1955 print $form->formconfirm("card.php?id=".urlencode((string) ($id)), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1);
1958 if ($action == 'edit
') {
1959 $caneditdateorowner = ($object->type != 'systemauto
');
1961 if (!empty($conf->use_javascript_ajax)) {
1962 print "\n".'<script
type=
"text/javascript">
';
1963 print '$(document).ready(
function () {
1964 function setdatefields()
1966 if ($(
"#fullday:checked").val() ==
null) {
1967 $(
".fulldaystarthour").removeAttr(
"disabled");
1968 $(
".fulldaystartmin").removeAttr(
"disabled");
1969 $(
".fulldayendhour").removeAttr(
"disabled");
1970 $(
".fulldayendmin").removeAttr(
"disabled");
1972 $(
".fulldaystarthour").prop(
"disabled",
true).val(
"00");
1973 $(
".fulldaystartmin").prop(
"disabled",
true).val(
"00");
1974 $(
".fulldayendhour").prop(
"disabled",
true).val(
"23");
1975 $(
".fulldayendmin").prop(
"disabled",
true).val(
"59");
1979 '.($caneditdateorowner ? ' setdatefields();
' : '').'
1981 $(
"#fullday").change(
function() {
1984 var old_startdate =
null;
1985 $(
"#ap").focus(
function() {
1986 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
1988 $(
"#ap").next(
".ui-datepicker-trigger").click(
function() {
1989 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
1991 $(
"#ap").change(
function() {
1992 setTimeout(
function() {
1993 if ($(
"#p2").val() !==
"") {
1994 var new_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
1995 var old_enddate =
new Date($(
"#p2year").val(), $(
"#p2month").val() - 1, $(
"#p2day").val());
1996 if (new_startdate > old_enddate) {
1997 var timeDiff = old_enddate - old_startdate;
1998 var new_enddate =
new Date(new_startdate.getTime() + timeDiff);
1999 $(
"#p2").val(formatDate(new_enddate,
"' . $langs->trans('FormatDateShortJavaInput') . '"));
2000 $(
"#p2day").val(new_enddate.getDate());
2001 $(
"#p2month").val(new_enddate.getMonth() + 1);
2002 $(
"#p2year").val(new_enddate.getFullYear());
2007 $(
"#actioncode").change(
function() {
2008 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
2009 else $("#dateend").removeClass("fieldrequired");
2012 print
'</script>'.
"\n";
2015 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
2016 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2017 print
'<input type="hidden" name="action" value="update">';
2018 print
'<input type="hidden" name="id" value="'.$id.
'">';
2019 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
2020 print
'<input type="hidden" name="page_y" value="">';
2022 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
2025 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2030 print
'<table class="border tableforfield" width="100%">';
2033 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.
$object->id.
'</td></tr>';
2037 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
2038 if (
$object->type_code !=
'AC_OTH_AUTO') {
2039 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
2040 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
2042 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2043 print
$object->getTypePicto();
2044 print $langs->trans(
"Action".
$object->type_code);
2050 if (
$object->elementtype ==
'ticket') {
2051 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
2052 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
2053 print
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
2057 print
'<tr><td'.(!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ?
' class="fieldrequired titlefieldcreate"' :
'').
'>'.$langs->trans(
"Title").
'</td><td colspan="3"><input type="text" name="label" class="soixantepercent" value="'.
$object->label.
'"></td></tr>';
2060 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td colspan="3" class="valignmiddle height30 small">';
2061 print
'<input '.($caneditdateorowner ?
'' :
' disabled').
' type="checkbox" id="fullday" name="fullday" '.(
$object->fulldayevent ?
' checked' :
'').
'>';
2062 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
2125 print
'<tr><td class="nowrap">';
2130 print
'</td><td td colspan="3">';
2132 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');
2133 print
' <span class="hideonsmartphone"> - </span> ';
2134 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');
2137 print
'<tr><td class=""> </td><td></td></tr>';
2140 $listofuserid = array();
2141 if (empty($donotclearsession)) {
2142 if (
$object->userownerid > 0) {
2143 $listofuserid[
$object->userownerid] = array(
2147 'transparency' =>
$object->transparency,
2148 'answer_status' => (isset(
$object->userassigned[
$object->userownerid][
'answer_status']) ?
$object->userassigned[
$object->userownerid][
'answer_status']: null),
2149 'mandatory' => (isset(
$object->userassigned[
$object->userownerid][
'mandatory']) ?
$object->userassigned[
$object->userownerid][
'mandatory']:null)
2152 if (!empty(
$object->userassigned)) {
2154 $tmplist1 =
$object->userassigned;
2155 foreach ($tmplist1 as $key => $val) {
2156 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2157 $listofuserid[$val[
'id']] = $val;
2161 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2163 if (!empty($_SESSION[
'assignedtouser'])) {
2164 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2168 $listofcontactid =
$object->socpeopleassigned;
2169 $listofotherid =
$object->otherassigned;
2171 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
2172 print
'<div class="assignedtouser">';
2173 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, array(), 0,
'', array(), 0, 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid, $caneditdateorowner);
2185 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.
$object->location.
'"></td></tr>';
2189 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
2190 $percent = GETPOSTISSET(
"percentage") ?
GETPOSTINT(
"percentage") :
$object->percentage;
2191 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
2195 if (isModEnabled(
'category')) {
2196 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2197 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
2199 $cats =
$c->containing(
$object->id, Categorie::TYPE_ACTIONCOMM);
2200 $arrayselected = array();
2201 foreach ($cats as $cat) {
2202 $arrayselected[] = $cat->id;
2204 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2211 print
'<br><hr><br>';
2214 print
'<table class="border tableforfield centpercent">';
2216 if (isModEnabled(
"societe")) {
2218 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2222 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2225 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2230 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2231 print
'<div class="maxwidth200onsmartphone">';
2233 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2241 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2242 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');
2243 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2246 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');
2254 if (isModEnabled(
'project')) {
2255 $langs->load(
"projects");
2257 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2258 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2259 $numprojet = $formproject->select_projects((
$object->socid > 0 ?
$object->socid : -1),
$object->fk_project,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'maxwidth500 widthcentpercentminusxx');
2260 if ($numprojet == 0) {
2261 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>';
2268 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2269 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2274 if (!empty(
$object->fk_element) && !empty(
$object->elementtype)) {
2275 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2277 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2279 if (
$object->elementtype ==
'task' && isModEnabled(
'project')) {
2280 print
'<td id="project-task-input-container" >';
2282 $urloption =
'?action=create&donotclearsession=1';
2283 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2286 print
"\n".
'<script type="text/javascript" >';
2287 print
'$(document).ready(function () {
2288 $("#projectid").change(function () {
2289 var url = "'.$url.
'&projectid="+$("#projectid").val();
2290 $.get(url, function(data) {
2291 console.log($( data ).find("#fk_element").html());
2292 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2296 print
'</script>'.
"\n";
2298 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1),
$object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500',
$object->fk_project);
2299 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2305 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2306 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2314 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2316 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2317 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2318 $doleditor->Create();
2322 $parameters = array();
2323 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2324 print $hookmanager->resPrint;
2325 if (empty($reshook)) {
2326 print
$object->showOptionals($extrafields,
'edit', $parameters);
2333 $filteruserid = $user->id;
2334 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2337 $object->loadReminders(
'', $filteruserid,
false);
2341 if (count(
$object->reminders) > 0) {
2342 $checked =
'checked';
2343 $keys = array_keys(
$object->reminders);
2344 $firstreminderId = array_shift($keys);
2346 $actionCommReminder =
$object->reminders[$firstreminderId];
2350 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2351 $actionCommReminder->offsetunit =
'i';
2352 $actionCommReminder->typeremind =
'email';
2361 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>';
2363 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2367 print
'<table class="border centpercent">';
2370 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2371 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2372 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2376 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2377 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2381 if ($actionCommReminder->typeremind ==
'browser') {
2382 $hide =
'style="display:none;"';
2387 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2388 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, $actionCommReminder->fk_email_template);
2394 print
"\n".
'<script type="text/javascript">';
2395 print
'$(document).ready(function () {
2396 $("#addreminder").click(function(){
2398 $(".reminderparameters").show();
2400 $(".reminderparameters").hide();
2404 $("#selectremindertype").change(function(){
2405 var selected_option = $("#selectremindertype option:selected").val();
2406 if(selected_option == "email") {
2407 $("#select_actioncommsendmodel_mail").closest("tr").show();
2409 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2414 print
'</script>'.
"\n";
2416 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
2419 $reminderDefaultEmailModel =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
2421 print
"\n".
'<script type="text/javascript">';
2422 print
'$(document).ready(function () {
2423 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
2424 $(
"#actioncode").change(
function(){
2425 var selected_event_type = $(
"#actioncode option:selected").val();
2427 if (reminderDefaultEventTypes.includes(selected_event_type)) {
2428 $(
".reminderparameters").show();
2429 $(
"#addreminder").prop(
"checked",
true);
2432 $(
"#offsetvalue").val(\
''.
dol_escape_js($reminderDefaultOffset).
'\');
2433 $(
"#select_offsetunittype_duration").select2(
"destroy");
2434 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
2435 $(
"#select_offsetunittype_duration").select2();
2437 $(
"#selectremindertype").select2(
"destroy");
2438 $(
"#selectremindertype").val(
"email");
2439 $(
"#selectremindertype").select2();
2442 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2443 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
2444 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js($reminderDefaultEmailModel).
'\');
2445 $(
"#select_actioncommsendmodel_mail").select2();
2449 print '</script>
'."\n";
2450 print '</div>
'; // End of div for reminderparameters
2453 print dol_get_fiche_end();
2455 print $form->buttonsSaveCancel();
2459 print dol_get_fiche_head($head, 'card
', $langs->trans("Action"), -1, 'action
');
2464 if ($action == 'clone
') {
2465 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?
id=
'.GETPOST('id'), $langs->trans('ToClone
'), $langs->trans('ConfirmCloneEvent
', $object->label), 'confirm_clone
', array(), 'yes
', 1);
2468 // Call Hook formConfirm
2469 $parameters = array();
2470 $reshook = $hookmanager->executeHooks('formConfirm
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2471 if (empty($reshook)) {
2472 $formconfirm .= $hookmanager->resPrint;
2473 } elseif ($reshook > 0) {
2474 $formconfirm = $hookmanager->resPrint;
2477 // Print form confirm
2481 // Link to other agenda views
2482 $linkback .= '<a href=
"'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">
';
2483 $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist
', 'class=
"pictoactionview pictofixedwidth"');
2484 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("BackToList").'</span>
';
2485 $linkback .= '</a>
';
2486 $linkback .= '</li>
';
2487 $linkback .= '<li
class=
"noborder litext">
';
2488 $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').'">
';
2489 $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar
', 'class=
"pictoactionview pictofixedwidth"');
2490 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewCal").'</span>
';
2491 $linkback .= '</a>
';
2492 $linkback .= '</li>
';
2493 $linkback .= '<li
class=
"noborder litext">
';
2494 $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').'">
';
2495 $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek
', 'class=
"pictoactionview pictofixedwidth"');
2496 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewWeek").'</span>
';
2497 $linkback .= '</a>
';
2498 $linkback .= '</li>
';
2499 $linkback .= '<li
class=
"noborder litext">
';
2500 $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').'">
';
2501 $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday
', 'class=
"pictoactionview pictofixedwidth"');
2502 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewDay").'</span>
';
2503 $linkback .= '</a>
';
2504 $linkback .= '</li>
';
2505 $linkback .= '<li
class=
"noborder litext">
';
2506 $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').'">
';
2507 $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser
', 'class=
"pictoactionview pictofixedwidth"');
2508 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewPerUser").'</span>
';
2509 $linkback .= '</a>
';
2511 // Add more views from hooks
2512 $parameters = array();
2513 $reshook = $hookmanager->executeHooks('addCalendarView
', $parameters, $object, $action);
2514 if (empty($reshook)) {
2515 $linkback .= $hookmanager->resPrint;
2516 } elseif ($reshook > 1) {
2517 $linkback = $hookmanager->resPrint;
2522 $morehtmlref = '<div
class=
"refidno">
';
2524 //$morehtmlref.='<br>
'.$langs->trans('ThirdParty
') . ' :
' . $object->thirdparty->getNomUrl(1);
2526 if (isModEnabled('project
')) {
2527 $langs->load("projects");
2528 //$morehtmlref .= '<br>
';
2529 if ($usercancreate) {
2530 $morehtmlref .= img_picto($langs->trans("Project"), 'project
', 'class=
"pictofixedwidth"');
2531 if ($action != 'classify
') {
2532 $morehtmlref .= '<a class=
"editfielda" href=
"'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">
'.img_edit($langs->transnoentitiesnoconv('SetProject
')).'</a>
';
2534 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF
'].'?id=
'.$object->id, $object->socid, $object->fk_project, ($action == 'classify
' ? 'projectid
' : 'none
'), 0, 0, 0, 1, '', 'maxwidth300
');
2536 if (!empty($object->fk_project)) {
2537 $proj = new Project($db);
2538 $proj->fetch($object->fk_project);
2539 $morehtmlref .= $proj->getNomUrl(1);
2541 $morehtmlref .= '<span class=
"opacitymedium"> -
'.dol_escape_htmltag($proj->title).'</span>
';
2546 $morehtmlref .= '</div>
';
2549 dol_banner_tab($object, 'id
', $linkback, ($user->socid ? 0 : 1), 'id
', 'ref', $morehtmlref);
2551 print '<div class=
"fichecenter">
';
2552 print '<div class=
"fichehalfleft">
';
2554 print '<div class=
"underbanner clearboth"></div>
';
2556 // Show event in view mode
2557 print '<
table class=
"border tableforfield centpercent">
';
2560 if (getDolGlobalString('AGENDA_USE_EVENT_TYPE
')) {
2561 print '<tr><td class=
"titlefield">
'.$langs->trans("Type").'</td><td>
';
2562 $labeltype = ($langs->transnoentities("Action".$object->type_code) != "Action".$object->type_code) ? $langs->transnoentities("Action".$object->type_code) : $object->type_label;
2563 $labeltoshow = $labeltype;
2564 if ($object->code) {
2565 $labeltoshow .= ' (
'.$object->code.')
';
2567 print $object->getTypePicto('pictofixedwidth paddingright
', $labeltoshow);
2573 print '<tr><td class=
"titlefield">
'.$langs->trans("EventOnFullDay").'</td><td>
'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>
';
2575 // Event into a series
2576 if ($object->recurid) {
2577 print '<tr><td class=
"titlefield">
'.$langs->trans("EventIntoASerie").'</td><td>
'.dol_escape_htmltag($object->recurid).'</td></tr>
';
2581 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2586 print '<tr><td>
'.$langs->trans("DateActionStart").'</td><td>
';
2587 // Test a date before the 27 march and one after
2588 //print dol_print_date($object->datep, 'dayhour
', 'gmt
');
2589 //print dol_print_date($object->datep, 'dayhour
', 'tzuser
');
2590 //print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2591 if (empty($object->fulldayevent)) {
2592 print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2594 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2595 print dol_print_date($object->datep, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2597 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2598 print img_warning($langs->trans("Late"));
2604 print '<tr><td>
'.$langs->trans("DateActionEnd").'</td><td>
';
2605 if (empty($object->fulldayevent)) {
2606 print dol_print_date($object->datef, 'dayhour
', 'tzuserrel
');
2608 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2609 print dol_print_date($object->datef, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2611 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2612 print img_warning($langs->trans("Late"));
2617 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2618 print '<tr><td>
'.$langs->trans("Location").'</td><td>
'.$object->location.'</td></tr>
';
2622 print '<tr><td class=
"nowrap">
'.$langs->trans("ActionAssignedTo").'</td><td>
';
2623 $listofuserid = array();
2624 if (empty($donotclearsession)) {
2625 if ($object->userownerid > 0) {
2626 $listofuserid[$object->userownerid] = array(
2627 'id
' => $object->userownerid,
2628 'transparency
' => $object->transparency, // Force transparency on owner from property of event
2629 'answer_status
' => $object->userassigned[$object->userownerid]['answer_status
'],
2630 'mandatory
' => $object->userassigned[$object->userownerid]['mandatory
']
2633 if (!empty($object->userassigned)) { // Now concat assigned users
2634 // Restore array with key with same value than param 'id
'
2635 $tmplist1 = $object->userassigned;
2636 foreach ($tmplist1 as $key => $val) {
2637 if ($val['id
'] && $val['id
'] != $object->userownerid) {
2638 $listofuserid[$val['id
']] = $val;
2642 $_SESSION['assignedtouser
'] = json_encode($listofuserid);
2644 if (!empty($_SESSION['assignedtouser
'])) {
2645 $listofuserid = json_decode($_SESSION['assignedtouser
'], true);
2649 $listofcontactid = array(); // not used yet
2650 $listofotherid = array(); // not used yet
2651 print '<div class=
"assignedtouser">
';
2652 print $form->select_dolusers_forevent('view
', 'assignedtouser
', 1, array(), 0, '', array(), 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2655 if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
2657 print '<div class=
"myavailability">
';
2658 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
2662 print ' </td></tr>
';
2665 if (isModEnabled('category
')) {
2666 print '<tr><td class=
"valignmiddle">
'.$langs->trans("Categories").'</td><td>
';
2667 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2675 print '<div class=
"fichehalfright">
';
2677 print '<div class=
"underbanner clearboth"></div>
';
2678 print '<
table class=
"border tableforfield centpercent">
';
2680 if (isModEnabled("societe")) {
2682 print '<tr><td class=
"titlefield">
'.$langs->trans("ActionOnCompany").'</td>
';
2683 print '<td>
'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : ('<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
'));
2684 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL
') {
2685 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2686 print "<br>".dol_print_phone($object->thirdparty->phone);
2692 print '<tr><td>
'.$langs->trans("ActionOnContact").'</td>
';
2695 if (!empty($object->socpeopleassigned)) {
2696 foreach ($object->socpeopleassigned as $cid => $Tab) {
2697 $contact = new Contact($db);
2698 $result = $contact->fetch($cid);
2701 dol_print_error($db, $contact->error);
2705 print $contact->getNomUrl(1);
2706 if ($object->type_code == 'AC_TEL
') {
2707 if (!empty($contact->phone_pro)) {
2708 print '(
'.dol_print_phone($contact->phone_pro).')
';
2711 print '<div class=
"paddingright"></div>
';
2715 print '<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
';
2721 if (getDolGlobalString('AGENDA_SUPPORT_PRIORITY_IN_EVENTS
')) {
2722 print '<tr><td class=
"nowrap" class=
"titlefield">
' . $langs->trans("Priority") . '</td><td>
';
2723 print($object->priority ? $object->priority : '');
2727 // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
2728 // for such objects because there is already a dedicated field into table llx_actioncomm.
2729 if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe
', 'contact
', 'project
'))) {
2730 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
2731 print '<tr><td>
'.$langs->trans("LinkedObject").'</td>
';
2732 $link = dolGetElementUrl($object->fk_element, $object->elementtype, 1);
2735 print '<span class=
"opacitymedium">
'.$langs->trans("ObjectDeleted").'</span>
';
2743 if (!empty($object->email_msgid)) {
2744 print '<tr><td>
'.$langs->trans('MailTopic
').'</td>
';
2745 print '<td>
'.dol_escape_htmltag($object->email_subject).'</td></tr>
';
2746 print '<tr><td>
'.$langs->trans('MailFrom
').'</td>
';
2747 print '<td>
'.dol_escape_htmltag($object->email_from).'</td></tr>
';
2748 print '<tr><td>
'.$langs->trans('MailTo
').'</td>
';
2749 print '<td>
'.dol_escape_htmltag($object->email_to).'</td></tr>
';
2750 if (!empty($object->email_tocc)) {
2751 print '<tr><td>
'.$langs->trans('MailCC
').'</td>
';
2752 print '<td>
'.dol_escape_htmltag($object->email_tocc).'</td></tr>
';
2757 print '<tr><td class=
"tdtop">
'.$langs->trans("Description").'</td><td class=
"wordbreak sensiblehtmlcontent">
';
2758 print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
2762 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php
';
2765 if (getDolGlobalString('AGENDA_REMINDER_EMAIL
') || getDolGlobalString('AGENDA_REMINDER_BROWSER
')) {
2766 $filteruserid = $user->id;
2767 if ($user->hasRight('agenda
', 'allactions
', 'read
')) {
2770 $object->loadReminders('', $filteruserid, false);
2772 print '<tr><td class=
"titlefieldcreate nowrap">
'.$langs->trans("Reminders").'</td><td>
';
2774 if (count($object->reminders) > 0) {
2775 $tmpuserstatic = new User($db);
2777 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2778 print $TRemindTypes[$actioncommreminder->typeremind]['label
'];
2779 if ($actioncommreminder->fk_user > 0) {
2780 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2781 print ' (
'.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')
';
2783 print ' -
'.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit];
2785 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2786 print ' - <span class=
"opacitymedium">
';
2787 print $langs->trans("NotSent");
2789 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2790 print ' - <span class=
"opacitymedium">
';
2791 print $langs->trans("Done");
2793 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2794 print ' - <span class=
"opacitymedium">
';
2795 print $form->textwithpicto($langs->trans("Error"), $actioncommreminder->lasterror);
2809 print '<div class=
"clearboth"></div>
';
2811 print dol_get_fiche_end();
2818 print '<div class=
"tabsAction">
';
2820 $parameters = array();
2821 $reshook = $hookmanager->executeHooks('addMoreActionsButtons
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2822 if (empty($reshook)) {
2823 if ($action != 'edit
') {
2824 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
2825 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
2826 print '<div class=
"inline-block divButAction"><a class=
"butAction" href=
"card.php?action=edit&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Modify").'</a></div>
';
2828 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Modify").'</a></div>
';
2831 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
2832 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
2833 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>
';
2835 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("ToClone").'</a></div>
';
2838 if ($user->hasRight('agenda
', 'allactions
', 'delete
') ||
2839 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'delete
'))) {
2840 print '<div class=
"inline-block divButAction"><a class=
"butActionDelete" href=
"card.php?action=delete&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Delete").'</a></div>
';
2842 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Delete").'</a></div>
';
2849 if ($action != 'edit
') {
2850 if (!getDolGlobalString('AGENDA_DISABLE_BUILDDOC
')) {
2851 print '<div class=
"clearboth"></div><div class=
"fichecenter"><div class=
"fichehalfleft">
';
2852 print '<a
name=
"builddoc"></a>
'; // ancre
2855 * Generated documents
2858 $filedir = $conf->agenda->multidir_output[$conf->entity].'/
'.$object->id;
2859 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
2861 $genallowed = $user->hasRight('agenda
', 'myactions
', 'read
');
2862 $delallowed = $user->hasRight('agenda
', 'myactions
', 'create
');
2865 print $formfile->showdocuments('actions
', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang());
2867 print '</div><div class=
"fichehalfright">
';
2870 print '</div></div>
';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 categories.
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)
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...
if(preg_match('/crypted:/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.