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 .
']');
614 $res =
$object->add_element_resource($resource_id, $resource_type, $busy, $val[
'mandatory']);
619 unset($_SESSION[
'assignedtoresource']);
623 $categories =
GETPOST(
'categories',
'array');
624 $object->setCategories($categories);
627 unset($_SESSION[
'assignedtouser']);
629 if ($user->id !=
$object->userownerid) {
630 $moreparam =
"filtert=-1";
634 if (!$error && $addreminder ==
'on') {
639 $actionCommReminder->dateremind = $dateremind;
640 $actionCommReminder->typeremind = $remindertype;
641 $actionCommReminder->offsetunit = $offsetunit;
642 $actionCommReminder->offsetvalue = $offsetvalue;
643 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
644 $actionCommReminder->fk_actioncomm =
$object->id;
645 if ($remindertype ==
'email') {
646 $actionCommReminder->fk_email_template = $modelmail;
650 foreach (
$object->userassigned as $userassigned) {
651 $actionCommReminder->fk_user = $userassigned[
'id'];
652 $res = $actionCommReminder->create($user);
657 $langs->load(
"errors");
658 $error = $langs->trans(
'ErrorReminderActionCommCreation');
661 $donotclearsession = 1;
672 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
692 $langs->load(
"errors");
693 $error = $langs->trans(
$object->error);
696 $donotclearsession = 1;
702 $donotclearsession = 1;
705 if (!$error && $eventisrecurring) {
709 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
711 $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');
715 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
716 $firstday = $selectedrecurrulebymonthday;
725 $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');
731 while ($datep <= $repeateventlimitdate && !$error) {
735 $finalobject->datep = $datep;
736 $finalobject->datef = $datef;
738 $idaction = $finalobject->create($user);
741 if (!$finalobject->error) {
743 $categories =
GETPOST(
'categories',
'array');
744 $finalobject->setCategories($categories);
746 unset($_SESSION[
'assignedtouser']);
749 if ($user->id != $finalobject->userownerid) {
750 $moreparam =
"filtert=-1";
754 if ($addreminder ==
'on') {
759 $actionCommReminder->dateremind = $dateremind;
760 $actionCommReminder->typeremind = $remindertype;
761 $actionCommReminder->offsetunit = $offsetunit;
762 $actionCommReminder->offsetvalue = $offsetvalue;
763 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
764 $actionCommReminder->fk_actioncomm = $finalobject->id;
765 if ($remindertype ==
'email') {
766 $actionCommReminder->fk_email_template = $modelmail;
770 foreach ($finalobject->userassigned as $userassigned) {
771 $actionCommReminder->fk_user = $userassigned[
'id'];
772 $res = $actionCommReminder->create($user);
777 $langs->load(
"errors");
778 $error = $langs->trans(
'ErrorReminderActionCommCreation');
781 $donotclearsession = 1;
792 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
802 $langs->load(
"errors");
803 $error = $langs->trans($finalobject->error);
806 $donotclearsession = 1;
812 $donotclearsession = 1;
816 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
827 if (!empty($backtopage) && !$error) {
828 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
829 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
830 } elseif ($idaction) {
831 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
833 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
840if (empty($reshook) && $action ==
'update' && $usercancreate) {
841 if (empty($cancel)) {
842 $fulldayevent =
GETPOST(
'fullday');
847 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
880 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
882 if (
$object->elementtype ==
'ticket') {
884 if (
$object->code ==
'TICKET_MSG') {
885 $object->code =
'TICKET_MSG_PRIVATE';
887 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
888 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
891 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
894 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
895 $object->code =
'TICKET_MSG_SENTBYMAIL';
907 $object->percentage = $percentage;
912 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
913 $object->socpeopleassigned = array();
914 foreach ($socpeopleassigned as $cid) {
915 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
918 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
919 reset(
$object->socpeopleassigned);
925 if (
GETPOST(
"elementtype",
'alpha')) {
927 $modulecodetouseforpermissioncheck = $elProp[
'module'];
929 $hasPermissionOnLinkedObject = 0;
930 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
931 $hasPermissionOnLinkedObject = 1;
933 if ($hasPermissionOnLinkedObject) {
941 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
944 $listofuserid = array();
945 if (!empty($_SESSION[
'assignedtouser'])) {
947 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
948 foreach ($tmplist1 as $key => $val) {
949 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
950 $listofuserid[$val[
'id']] = $val;
954 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
955 if ($assignedtouser) {
956 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
959 $object->userassigned = array();
962 foreach ($listofuserid as $key => $val) {
964 $object->userownerid = $val[
'id'];
966 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
970 $object->transparency = $transparency;
974 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
976 $donotclearsession = 1;
978 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
980 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
982 if (empty(
$object->userownerid)) {
984 $donotclearsession = 1;
986 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
990 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
998 $eventDateStart =
$object->datep;
999 $eventDateEnd =
$object->datef;
1001 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1002 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1003 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1004 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1005 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1006 $sql .=
" AND er.resource_id IN (";
1007 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1008 $sql .=
" WHERE element_id = ".((int)
$object->id);
1009 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1010 $sql .=
" AND busy = 1";
1012 $sql .=
" AND er.busy = 1";
1016 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1018 if (!empty($eventDateEnd)) {
1019 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1023 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1024 if (!empty($eventDateEnd)) {
1025 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1030 $resql = $db->query($sql);
1033 $object->error = $db->lasterror();
1036 if ($db->num_rows($resql) > 0) {
1039 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1040 while ($obj = $db->fetch_object($resql)) {
1041 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1057 $result =
$object->update($user);
1061 $categories =
GETPOST(
'categories',
'array');
1062 $object->setCategories($categories);
1064 $object->loadReminders($remindertype, 0,
false);
1067 if (!empty(
$object->reminders)) {
1068 foreach (
$object->reminders as $reminder) {
1069 if ($reminder->status < 1) {
1070 $reminder->delete($user);
1077 if ($addreminder ==
'on') {
1082 $actionCommReminder->dateremind = $dateremind;
1083 $actionCommReminder->typeremind = $remindertype;
1084 $actionCommReminder->offsetunit = $offsetunit;
1085 $actionCommReminder->offsetvalue = $offsetvalue;
1086 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
1087 $actionCommReminder->fk_actioncomm =
$object->id;
1088 if ($remindertype ==
'email') {
1089 $actionCommReminder->fk_email_template = $modelmail;
1093 foreach (
$object->userassigned as $userassigned) {
1094 $actionCommReminder->fk_user = $userassigned[
'id'];
1098 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1099 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".$db->escape($remindertype).
"'";
1100 $resqldelete = $db->query($sqldelete);
1102 $res = $actionCommReminder->create($user);
1106 $langs->load(
"errors");
1107 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1110 $donotclearsession = 1;
1117 unset($_SESSION[
'assignedtouser']);
1118 unset($_SESSION[
'assignedtoresource']);
1133 if (!empty($backtopage)) {
1134 unset($_SESSION[
'assignedtouser']);
1135 header(
"Location: ".$backtopage);
1142if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
1145 $object->fetch_userassigned();
1148 if ($user->hasRight(
'agenda',
'myactions',
'delete')
1149 || $user->hasRight(
'agenda',
'allactions',
'delete')) {
1150 $result =
$object->delete($user);
1153 header(
"Location: index.php");
1165if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
1171 $newdate =
GETPOST(
'newdate',
'alpha');
1172 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1173 header(
"Location: ".$backtopage,
true, 307);
1177 $datep =
dol_mktime($shour, $smin, 0, (
int) substr($newdate, 13, 2), (
int) substr($newdate, 15, 2), (
int) substr($newdate, 9, 4),
'tzuserrel');
1180 if ($datep !=
$object->datep) {
1189 $eventDateStart =
$object->datep;
1190 $eventDateEnd =
$object->datef;
1192 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1193 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1194 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1195 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1196 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1197 $sql .=
" AND er.resource_id IN (";
1198 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1199 $sql .=
" WHERE element_id = ".((int)
$object->id);
1200 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1201 $sql .=
" AND busy = 1";
1203 $sql .=
" AND er.busy = 1";
1207 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1209 if (!empty($eventDateEnd)) {
1210 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1214 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1215 if (!empty($eventDateEnd)) {
1216 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1221 $resql = $db->query($sql);
1224 $object->error = $db->lasterror();
1227 if ($db->num_rows($resql) > 0) {
1230 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1231 while ($obj = $db->fetch_object($resql)) {
1232 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1247 $result =
$object->update($user);
1257 if (!empty($backtopage)) {
1258 header(
"Location: ".$backtopage,
true, 307);
1267$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1268if (empty($reshook)) {
1269 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1277$form =
new Form($db);
1280$arrayrecurrulefreq = array(
1281 'no' => $langs->trans(
"OnceOnly"),
1282 'MONTHLY' => $langs->trans(
"EveryMonth"),
1283 'WEEKLY' => $langs->trans(
"EveryWeek")
1288$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1289llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1291if ($action ==
'create') {
1294 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1295 if (!empty($socpeopleassigned[0])) {
1296 $result = $contact->fetch($socpeopleassigned[0]);
1304 if (!empty(
$conf->use_javascript_ajax)) {
1305 print
"\n".
'<script type="text/javascript">';
1306 print
'$(document).ready(function () {
1307 function setdatefields()
1309 if ($("#fullday:checked").val() == null) {
1310 $(".fulldaystarthour").removeAttr("disabled");
1311 $(".fulldaystartmin").removeAttr("disabled");
1312 $(".fulldayendhour").removeAttr("disabled");
1313 $(".fulldayendmin").removeAttr("disabled");
1314 $("#p2").removeAttr("disabled");
1316 $(".fulldaystarthour").prop("disabled", true).val("00");
1317 $(".fulldaystartmin").prop("disabled", true).val("00");
1318 $(".fulldayendhour").prop("disabled", true).val("23");
1319 $(".fulldayendmin").prop("disabled", true).val("59");
1320 $("#p2").removeAttr("disabled");
1323 $("#fullday").change(function() {
1324 console.log("setdatefields");
1327 var old_startdate = null;
1328 $("#ap").focus(function() {
1329 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1331 $("#ap").next(".ui-datepicker-trigger").click(function() {
1332 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1334 $("#ap").change(function() {
1335 setTimeout(function() {
1336 if ($("#p2").val() !== "") {
1337 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1338 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1339 if (new_startdate > old_enddate) {
1340 var timeDiff = old_enddate - old_startdate;
1341 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1342 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1343 $("#p2day").val(new_enddate.getDate());
1344 $("#p2month").val(new_enddate.getMonth() + 1);
1345 $("#p2year").val(new_enddate.getFullYear());
1350 $("#actioncode").change(function() {
1351 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1352 else $("#dateend").removeClass("fieldrequired");
1354 $("#aphour,#apmin").change(function() {
1355 if ($("#actioncode").val() == \'AC_RDV\') {
1356 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1357 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1358 $("#p2min").val($("#apmin").val());
1359 $("#p2day").val($("#apday").val());
1360 $("#p2month").val($("#apmonth").val());
1361 $("#p2year").val($("#apyear").val());
1362 $("#p2").val($("#ap").val());
1365 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1366 else $("#dateend").removeClass("fieldrequired");
1369 print
'</script>'.
"\n";
1372 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1373 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1374 print
'<input type="hidden" name="action" value="add">';
1375 print
'<input type="hidden" name="donotclearsession" value="1">';
1376 print
'<input type="hidden" name="page_y" value="">';
1378 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1381 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1384 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1385 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1392 print
'<table class="border centpercent nobottom">';
1396 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1398 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1399 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1400 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1405 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>';
1408 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1409 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>';
1412 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1413 if (
GETPOST(
'datep',
'alpha', 1)) {
1416 $datef = ($datef ? $datef :
$object->datef);
1417 if (
GETPOST(
'datef',
'alpha', 1)) {
1420 if (empty($datef) && !empty($datep)) {
1427 print
'<tr><td class="nowrap">';
1430 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1432 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1434 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1435 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1439 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0);
1440 if ($userepeatevent) {
1441 print
'<tr><td></td><td>';
1445 print
'<div class="opacitymedium inline-block small">';
1446 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 6px" class="paddingright2"');
1447 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1449 $selectedrecurrulefreq =
'no';
1450 $selectedrecurrulebymonthday =
'';
1451 $selectedrecurrulebyday =
'';
1452 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1453 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1454 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1458 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1459 $selectedrecurrulefreq = $reg[1];
1461 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1462 $selectedrecurrulebymonthday = (int) $reg[1];
1464 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1465 $selectedrecurrulebyday = (int) $reg[1];
1468 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1474 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1475 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1478 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1479 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1482 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1483 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1484 print $langs->trans(
"Until").
" ";
1485 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1488 print
'<script type="text/javascript">
1489 jQuery(document).ready(function() {
1490 function init_repeat()
1492 console.log("recurrule: " + "'.$object->recurrule.
'");
1493 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1494 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1495 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1496 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1497 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1499 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1500 jQuery(".repeateventlimitdate").css("display", "inline-block");
1501 jQuery(".repeateventBYDAY").hide();
1503 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1505 jQuery(".repeateventBYMONTHDAY").hide();
1506 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1507 jQuery(".repeateventlimitdate").css("display", "inline-block");
1511 jQuery(".repeateventBYMONTHDAY").hide();
1512 jQuery(".repeateventBYDAY").hide();
1513 jQuery(".repeateventlimitdate").hide();
1517 jQuery("#recurrulefreq").change(function() {
1526 print
'<tr><td class=""> </td><td></td></tr>';
1529 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1530 $listofuserid = array();
1531 $listofcontactid = array();
1532 $listofotherid = array();
1534 if (empty($donotclearsession)) {
1536 if ($assignedtouser) {
1537 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1540 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1541 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1543 if (!empty($_SESSION[
'assignedtouser'])) {
1544 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1546 if (!is_array($listofuserid)) {
1547 $listofuserid = array();
1549 $firstelem = reset($listofuserid);
1550 if (isset($listofuserid[$firstelem[
'id']])) {
1551 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1554 print
'<!-- list of user to assign --><div class="assignedtouser">';
1555 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, array(), 0,
'', array(), 0, 0, 0,
'u.statut:<>:0', 1, $listofuserid, $listofcontactid, $listofotherid);
1561 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>';
1564 if (isModEnabled(
'category')) {
1566 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1567 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
1568 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'), 0, 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1572 if (isModEnabled(
'resource')) {
1574 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1576 $listofresourceid = array();
1577 if (empty($donotclearsession)) {
1578 $assignedtoresource =
GETPOST(
"assignedtoresource");
1579 if ($assignedtoresource) {
1580 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1582 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1584 if (!empty($_SESSION[
'assignedtoresource'])) {
1585 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1587 if (!is_array($listofresourceid)) {
1588 $listofresourceid = array();
1590 $firstelem = reset($listofresourceid);
1591 if (isset($listofresourceid[$firstelem[
'id']])) {
1592 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1595 print
'<div class="assignedtoresource">';
1596 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1, array(), 0,
'', array(), 0, 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1602 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1604 $percent = $complete !==
'' ? $complete : -1;
1605 if (GETPOSTISSET(
'status')) {
1607 } elseif (GETPOSTISSET(
'percentage')) {
1610 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1612 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1616 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1622 print
'<br><hr><br>';
1625 print
'<table class="border centpercent nobottom">';
1627 if (isModEnabled(
"societe")) {
1629 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1633 print $societe->getNomUrl(1);
1634 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1637 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1639 if (!empty($user->socid)) {
1640 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1642 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'', $langs->trans(
'SelectThirdParty'), 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1648 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1649 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1653 if ($origin ==
'contact') {
1659 $select_contact_default = 0;
1661 $select_contact_default = -1;
1663 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1672 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1673 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, array(),
'multiple',
'contactid');
1674 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1676 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, array(),
'multiple',
'contactid');
1683 if (isModEnabled(
'project')) {
1684 $langs->load(
"projects");
1688 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1689 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1690 print $formproject->select_projects((
$object->socid > 0 ?
$object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx maxwidth500');
1692 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1693 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1694 $urloption =
'?action=create&donotclearsession=1';
1698 print
"\n".
'<script type="text/javascript">';
1699 print
'$(document).ready(function () {
1700 $("#projectid").change(function () {
1701 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1702 console.log("Call url to get new list of tasks: "+url);
1703 $.get(url, function(data) {
1705 if (data) $("#taskid").html(data).select2();
1709 print
'</script>'.
"\n";
1714 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1715 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1716 $projectsListId =
false;
1717 if (!empty($projectid)) {
1718 $projectsListId = $projectid;
1721 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1723 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', $projectsListId);
1728 if (!empty($origin) && !empty($originid)) {
1729 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1731 $hasPermissionOnLinkedObject = 0;
1734 if ($user->hasRight($elProp[
'module'],
'read') || $user->hasRight($elProp[
'module'], $elProp[
'element'],
'read')) {
1735 $hasPermissionOnLinkedObject = 1;
1739 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1741 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1742 print
'<td colspan="3">';
1743 if ($hasPermissionOnLinkedObject) {
1745 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1746 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1747 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1748 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1750 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1758 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1759 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1764 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1765 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1766 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 120,
'dolibarr_notes',
'In', true, true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1767 $doleditor->Create();
1771 $parameters = array();
1772 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1773 print $hookmanager->resPrint;
1774 if (empty($reshook)) {
1775 print
$object->showOptionals($extrafields,
'create', $parameters);
1785 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1787 print
'<div class="reminderparameters" style="display: none;">';
1789 print
'<table class="border centpercent">';
1792 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1793 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1794 print $form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1798 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1799 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1804 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1805 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1812 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
1813 $reminderDefaultOffset =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_OFFSET', 30);
1815 $reminderDefaultEmailModel =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
1817 print
"\n".
'<script type="text/javascript">';
1818 print
'$(document).ready(function () {
1819 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
1820 $(
"#actioncode").change(
function(){
1821 var selected_event_type = $(
"#actioncode option:selected").val();
1823 if (reminderDefaultEventTypes.includes(selected_event_type)) {
1824 $(
".reminderparameters").show();
1825 $(
"#addreminder").prop(
"checked",
true);
1828 $(
"[name=\"offsetvalue\"]").val(\
'' .
dol_escape_js((
string) $reminderDefaultOffset) .
'\');
1829 $(
"#select_offsetunittype_duration").select2(
"destroy");
1830 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
1831 $(
"#select_offsetunittype_duration").select2();
1833 $(
"#selectremindertype").select2(
"destroy");
1834 $(
"#selectremindertype").val(
"email");
1835 $(
"#selectremindertype").select2();
1838 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
1839 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
1840 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js((
string) $reminderDefaultEmailModel).
'\');
1841 $(
"#select_actioncommsendmodel_mail").select2();
1845 print '</script>
'."\n";
1847 print "\n".'<script
type=
"text/javascript">
';
1848 print '$(document).ready(
function () {
1849 $(
"#addreminder").click(
function(){
1850 console.log(
"Click on addreminder");
1852 $(
".reminderparameters").show();
1854 $(
".reminderparameters").hide();
1856 $(
"#selectremindertype").select2(
"destroy");
1857 $(
"#selectremindertype").select2();
1858 $(
"#select_offsetunittype_duration").select2(
"destroy");
1859 $(
"#select_offsetunittype_duration").select2();
1860 selectremindertype();
1863 $(
"#selectremindertype").change(
function(){
1864 selectremindertype();
1867 function selectremindertype() {
1868 console.log(
"Call selectremindertype");
1869 var selected_option = $(
"#selectremindertype option:selected").val();
1870 if(selected_option ==
"email") {
1871 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
1873 $(
"#select_actioncommsendmodel_mail").closest(
"tr").hide();
1878 print '</script>
'."\n";
1881 print dol_get_fiche_end();
1883 print $form->buttonsSaveCancel("Add");
1890 $result1 = $object->fetch($id);
1891 if ($result1 <= 0) {
1892 $langs->load("errors");
1893 print $langs->trans("ErrorRecordNotFound");
1899 $result2 = $object->fetch_thirdparty();
1900 $result2 = $object->fetchProject();
1901 $result3 = $object->fetch_contact();
1902 $result4 = $object->fetch_userassigned();
1903 $result5 = $object->fetch_optionals();
1905 if ($listUserAssignedUpdated || $donotclearsession) {
1906 $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
1908 $datep = dol_mktime($fulldayevent ? 0 : $aphour, $fulldayevent ? 0 : $apmin, 0, GETPOSTINT("apmonth"), GETPOSTINT("apday"), GETPOSTINT("apyear"), 'tzuserrel
');
1909 $datef = dol_mktime($fulldayevent ? 23 : $p2hour, $fulldayevent ? 59 : $p2min, $fulldayevent ? 59 : 0, GETPOSTINT("p2month"), GETPOSTINT("p2day"), GETPOSTINT("p2year"), 'tzuserrel
');
1911 $object->type_id = dol_getIdFromCode($db, GETPOST("actioncode", 'aZ09
'), 'c_actioncomm
');
1912 $object->label = GETPOST("label", "alphanohtml");
1913 $object->datep = $datep;
1914 $object->datef = $datef;
1915 $object->percentage = $percentage;
1916 $object->priority = GETPOST("priority", "alphanohtml");
1917 $object->fulldayevent = GETPOST("fullday") ? 1 : 0;
1918 $object->location = GETPOST('location
', "alphanohtml");
1919 $object->socid = GETPOSTINT("socid");
1920 $socpeopleassigned = GETPOST("socpeopleassigned", 'array
');
1921 foreach ($socpeopleassigned as $tmpid) {
1922 $object->socpeopleassigned[$id] = array('id' => $tmpid);
1924 $object->contact_id = GETPOSTINT("contactid");
1925 $object->fk_project = GETPOSTINT("projectid");
1927 $object->note_private = GETPOST("note", 'restricthtml
');
1930 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1931 dol_print_error($db, $object->error);
1935 if ($object->authorid > 0) {
1936 $tmpuser = new User($db);
1937 $res = $tmpuser->fetch($object->authorid);
1938 $object->author = $tmpuser;
1940 if ($object->usermodid > 0) {
1941 $tmpuser = new User($db);
1942 $res = $tmpuser->fetch($object->usermodid);
1943 $object->usermod = $tmpuser;
1951 $head = actions_prepare_head($object);
1954 $delay_warning = getDolGlobalInt('MAIN_DELAY_ACTIONS_TODO
') * 24 * 60 * 60;
1957 // Confirmation suppression action
1958 if ($action == 'delete') {
1959 print $form->formconfirm("card.php?id=".urlencode((string) ($id)), $langs->trans("DeleteAction"), $langs->trans("ConfirmDeleteAction"), "confirm_delete", '', '', 1);
1962 if ($action == 'edit
') {
1963 $caneditdateorowner = ($object->type != 'systemauto
');
1965 if (!empty($conf->use_javascript_ajax)) {
1966 print "\n".'<script
type=
"text/javascript">
';
1967 print '$(document).ready(
function () {
1968 function setdatefields()
1970 if ($(
"#fullday:checked").val() ==
null) {
1971 $(
".fulldaystarthour").removeAttr(
"disabled");
1972 $(
".fulldaystartmin").removeAttr(
"disabled");
1973 $(
".fulldayendhour").removeAttr(
"disabled");
1974 $(
".fulldayendmin").removeAttr(
"disabled");
1976 $(
".fulldaystarthour").prop(
"disabled",
true).val(
"00");
1977 $(
".fulldaystartmin").prop(
"disabled",
true).val(
"00");
1978 $(
".fulldayendhour").prop(
"disabled",
true).val(
"23");
1979 $(
".fulldayendmin").prop(
"disabled",
true).val(
"59");
1983 '.($caneditdateorowner ? ' setdatefields();
' : '').'
1985 $(
"#fullday").change(
function() {
1988 var old_startdate =
null;
1989 $(
"#ap").focus(
function() {
1990 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
1992 $(
"#ap").next(
".ui-datepicker-trigger").click(
function() {
1993 old_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
1995 $(
"#ap").change(
function() {
1996 setTimeout(
function() {
1997 if ($(
"#p2").val() !==
"") {
1998 var new_startdate =
new Date($(
"#apyear").val(), $(
"#apmonth").val() - 1, $(
"#apday").val());
1999 var old_enddate =
new Date($(
"#p2year").val(), $(
"#p2month").val() - 1, $(
"#p2day").val());
2000 if (new_startdate > old_enddate) {
2001 var timeDiff = old_enddate - old_startdate;
2002 var new_enddate =
new Date(new_startdate.getTime() + timeDiff);
2003 $(
"#p2").val(formatDate(new_enddate,
"' . $langs->trans('FormatDateShortJavaInput') . '"));
2004 $(
"#p2day").val(new_enddate.getDate());
2005 $(
"#p2month").val(new_enddate.getMonth() + 1);
2006 $(
"#p2year").val(new_enddate.getFullYear());
2011 $(
"#actioncode").change(
function() {
2012 if ($(
"#actioncode").val() == \
'AC_RDV\') $("#dateend").addClass("fieldrequired");
2013 else $("#dateend").removeClass("fieldrequired");
2016 print
'</script>'.
"\n";
2019 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
2020 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2021 print
'<input type="hidden" name="action" value="update">';
2022 print
'<input type="hidden" name="id" value="'.$id.
'">';
2023 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
2024 print
'<input type="hidden" name="page_y" value="">';
2026 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
2029 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2034 print
'<table class="border tableforfield" width="100%">';
2037 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.
$object->id.
'</td></tr>';
2041 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
2042 if (
$object->type_code !=
'AC_OTH_AUTO') {
2043 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
2044 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
2046 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2047 print
$object->getTypePicto();
2048 print $langs->trans(
"Action".
$object->type_code);
2054 if (
$object->elementtype ==
'ticket') {
2055 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
2056 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
2057 print
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
2061 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>';
2064 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td colspan="3" class="valignmiddle height30 small">';
2065 print
'<input '.($caneditdateorowner ?
'' :
' disabled').
' type="checkbox" id="fullday" name="fullday" '.(
$object->fulldayevent ?
' checked' :
'').
'>';
2066 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
2129 print
'<tr><td class="nowrap">';
2134 print
'</td><td td colspan="3">';
2136 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');
2137 print
' <span class="hideonsmartphone"> - </span> ';
2138 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');
2141 print
'<tr><td class=""> </td><td></td></tr>';
2144 $listofuserid = array();
2145 if (empty($donotclearsession)) {
2146 if (
$object->userownerid > 0) {
2147 $listofuserid[
$object->userownerid] = array(
2151 'transparency' =>
$object->transparency,
2152 'answer_status' => (isset(
$object->userassigned[
$object->userownerid][
'answer_status']) ?
$object->userassigned[
$object->userownerid][
'answer_status']: null),
2153 'mandatory' => (isset(
$object->userassigned[
$object->userownerid][
'mandatory']) ?
$object->userassigned[
$object->userownerid][
'mandatory']:null)
2156 if (!empty(
$object->userassigned)) {
2158 $tmplist1 =
$object->userassigned;
2159 foreach ($tmplist1 as $key => $val) {
2160 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2161 $listofuserid[$val[
'id']] = $val;
2165 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2167 if (!empty($_SESSION[
'assignedtouser'])) {
2168 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2172 $listofcontactid =
$object->socpeopleassigned;
2173 $listofotherid =
$object->otherassigned;
2175 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
2176 print
'<div class="assignedtouser">';
2177 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);
2189 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.
$object->location.
'"></td></tr>';
2193 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
2194 $percent = GETPOSTISSET(
"percentage") ?
GETPOSTINT(
"percentage") :
$object->percentage;
2195 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
2199 if (isModEnabled(
'category')) {
2200 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2201 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
2203 $cats =
$c->containing(
$object->id, Categorie::TYPE_ACTIONCOMM);
2204 $arrayselected = array();
2205 foreach ($cats as $cat) {
2206 $arrayselected[] = $cat->id;
2208 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2215 print
'<br><hr><br>';
2218 print
'<table class="border tableforfield centpercent">';
2220 if (isModEnabled(
"societe")) {
2222 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2226 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2229 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2234 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2235 print
'<div class="maxwidth200onsmartphone">';
2237 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2245 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2246 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');
2247 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2250 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');
2258 if (isModEnabled(
'project')) {
2259 $langs->load(
"projects");
2261 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2262 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2263 $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');
2264 if ($numprojet == 0) {
2265 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>';
2272 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2273 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2278 if (!empty(
$object->fk_element) && !empty(
$object->elementtype)) {
2279 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2281 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2283 if (
$object->elementtype ==
'task' && isModEnabled(
'project')) {
2284 print
'<td id="project-task-input-container" >';
2286 $urloption =
'?action=create&donotclearsession=1';
2287 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2290 print
"\n".
'<script type="text/javascript" >';
2291 print
'$(document).ready(function () {
2292 $("#projectid").change(function () {
2293 var url = "'.$url.
'&projectid="+$("#projectid").val();
2294 $.get(url, function(data) {
2295 console.log($( data ).find("#fk_element").html());
2296 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2300 print
'</script>'.
"\n";
2302 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1),
$object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500',
$object->fk_project);
2303 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2309 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2310 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2318 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2320 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2321 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2322 $doleditor->Create();
2326 $parameters = array();
2327 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2328 print $hookmanager->resPrint;
2329 if (empty($reshook)) {
2330 print
$object->showOptionals($extrafields,
'edit', $parameters);
2337 $filteruserid = $user->id;
2338 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2341 $object->loadReminders(
'', $filteruserid,
false);
2345 if (count(
$object->reminders) > 0) {
2346 $checked =
'checked';
2347 $keys = array_keys(
$object->reminders);
2348 $firstreminderId = array_shift($keys);
2350 $actionCommReminder =
$object->reminders[$firstreminderId];
2354 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2355 $actionCommReminder->offsetunit =
'i';
2356 $actionCommReminder->typeremind =
'email';
2365 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>';
2367 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2371 print
'<table class="border centpercent">';
2374 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2375 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2376 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2380 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2381 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2385 if ($actionCommReminder->typeremind ==
'browser') {
2386 $hide =
'style="display:none;"';
2391 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2392 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, $actionCommReminder->fk_email_template);
2398 print
"\n".
'<script type="text/javascript">';
2399 print
'$(document).ready(function () {
2400 $("#addreminder").click(function(){
2402 $(".reminderparameters").show();
2404 $(".reminderparameters").hide();
2408 $("#selectremindertype").change(function(){
2409 var selected_option = $("#selectremindertype option:selected").val();
2410 if(selected_option == "email") {
2411 $("#select_actioncommsendmodel_mail").closest("tr").show();
2413 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2418 print
'</script>'.
"\n";
2420 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
2423 $reminderDefaultEmailModel =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
2425 print
"\n".
'<script type="text/javascript">';
2426 print
'$(document).ready(function () {
2427 const reminderDefaultEventTypes = \''.dol_escape_js($reminderDefaultEventTypes).
'\';
2428 $(
"#actioncode").change(
function(){
2429 var selected_event_type = $(
"#actioncode option:selected").val();
2431 if (reminderDefaultEventTypes.includes(selected_event_type)) {
2432 $(
".reminderparameters").show();
2433 $(
"#addreminder").prop(
"checked",
true);
2436 $(
"#offsetvalue").val(\
''.
dol_escape_js($reminderDefaultOffset).
'\');
2437 $(
"#select_offsetunittype_duration").select2(
"destroy");
2438 $(
"#select_offsetunittype_duration").val(\
''.
dol_escape_js($reminderDefaultUnit).
'\');
2439 $(
"#select_offsetunittype_duration").select2();
2441 $(
"#selectremindertype").select2(
"destroy");
2442 $(
"#selectremindertype").val(
"email");
2443 $(
"#selectremindertype").select2();
2446 $(
"#select_actioncommsendmodel_mail").closest(
"tr").show();
2447 $(
"#select_actioncommsendmodel_mail").select2(
"destroy");
2448 $(
"#select_actioncommsendmodel_mail").val(\
''.
dol_escape_js($reminderDefaultEmailModel).
'\');
2449 $(
"#select_actioncommsendmodel_mail").select2();
2453 print '</script>
'."\n";
2454 print '</div>
'; // End of div for reminderparameters
2457 print dol_get_fiche_end();
2459 print $form->buttonsSaveCancel();
2463 print dol_get_fiche_head($head, 'card
', $langs->trans("Action"), -1, 'action
');
2468 if ($action == 'clone
') {
2469 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?
id=
'.GETPOST('id'), $langs->trans('ToClone
'), $langs->trans('ConfirmCloneEvent
', $object->label), 'confirm_clone
', array(), 'yes
', 1);
2472 // Call Hook formConfirm
2473 $parameters = array();
2474 $reshook = $hookmanager->executeHooks('formConfirm
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2475 if (empty($reshook)) {
2476 $formconfirm .= $hookmanager->resPrint;
2477 } elseif ($reshook > 0) {
2478 $formconfirm = $hookmanager->resPrint;
2481 // Print form confirm
2485 // Link to other agenda views
2486 $linkback .= '<a href=
"'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">
';
2487 $linkback .= img_picto($langs->trans("BackToList"), 'object_calendarlist
', 'class=
"pictoactionview pictofixedwidth"');
2488 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("BackToList").'</span>
';
2489 $linkback .= '</a>
';
2490 $linkback .= '</li>
';
2491 $linkback .= '<li
class=
"noborder litext">
';
2492 $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').'">
';
2493 $linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar
', 'class=
"pictoactionview pictofixedwidth"');
2494 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewCal").'</span>
';
2495 $linkback .= '</a>
';
2496 $linkback .= '</li>
';
2497 $linkback .= '<li
class=
"noborder litext">
';
2498 $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').'">
';
2499 $linkback .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek
', 'class=
"pictoactionview pictofixedwidth"');
2500 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewWeek").'</span>
';
2501 $linkback .= '</a>
';
2502 $linkback .= '</li>
';
2503 $linkback .= '<li
class=
"noborder litext">
';
2504 $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').'">
';
2505 $linkback .= img_picto($langs->trans("ViewDay"), 'object_calendarday
', 'class=
"pictoactionview pictofixedwidth"');
2506 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewDay").'</span>
';
2507 $linkback .= '</a>
';
2508 $linkback .= '</li>
';
2509 $linkback .= '<li
class=
"noborder litext">
';
2510 $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').'">
';
2511 $linkback .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser
', 'class=
"pictoactionview pictofixedwidth"');
2512 $linkback .= '<span
class=
"hideonsmartphone">
'.$langs->trans("ViewPerUser").'</span>
';
2513 $linkback .= '</a>
';
2515 // Add more views from hooks
2516 $parameters = array();
2517 $reshook = $hookmanager->executeHooks('addCalendarView
', $parameters, $object, $action);
2518 if (empty($reshook)) {
2519 $linkback .= $hookmanager->resPrint;
2520 } elseif ($reshook > 1) {
2521 $linkback = $hookmanager->resPrint;
2526 $morehtmlref = '<div
class=
"refidno">
';
2528 //$morehtmlref.='<br>
'.$langs->trans('ThirdParty
') . ' :
' . $object->thirdparty->getNomUrl(1);
2530 if (isModEnabled('project
')) {
2531 $langs->load("projects");
2532 //$morehtmlref .= '<br>
';
2533 if ($usercancreate) {
2534 $morehtmlref .= img_picto($langs->trans("Project"), 'project
', 'class=
"pictofixedwidth"');
2535 if ($action != 'classify
') {
2536 $morehtmlref .= '<a class=
"editfielda" href=
"'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">
'.img_edit($langs->transnoentitiesnoconv('SetProject
')).'</a>
';
2538 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF
'].'?id=
'.$object->id, $object->socid, $object->fk_project, ($action == 'classify
' ? 'projectid
' : 'none
'), 0, 0, 0, 1, '', 'maxwidth300
');
2540 if (!empty($object->fk_project)) {
2541 $proj = new Project($db);
2542 $proj->fetch($object->fk_project);
2543 $morehtmlref .= $proj->getNomUrl(1);
2545 $morehtmlref .= '<span class=
"opacitymedium"> -
'.dol_escape_htmltag($proj->title).'</span>
';
2550 $morehtmlref .= '</div>
';
2553 dol_banner_tab($object, 'id
', $linkback, ($user->socid ? 0 : 1), 'id
', 'ref', $morehtmlref);
2555 print '<div class=
"fichecenter">
';
2556 print '<div class=
"fichehalfleft">
';
2558 print '<div class=
"underbanner clearboth"></div>
';
2560 // Show event in view mode
2561 print '<
table class=
"border tableforfield centpercent">
';
2564 if (getDolGlobalString('AGENDA_USE_EVENT_TYPE
')) {
2565 print '<tr><td class=
"titlefield">
'.$langs->trans("Type").'</td><td>
';
2566 $labeltype = ($langs->transnoentities("Action".$object->type_code) != "Action".$object->type_code) ? $langs->transnoentities("Action".$object->type_code) : $object->type_label;
2567 $labeltoshow = $labeltype;
2568 if ($object->code) {
2569 $labeltoshow .= ' (
'.$object->code.')
';
2571 print $object->getTypePicto('pictofixedwidth paddingright
', $labeltoshow);
2577 print '<tr><td class=
"titlefield">
'.$langs->trans("EventOnFullDay").'</td><td>
'.yn($object->fulldayevent ? 1 : 0, 3).'</td></tr>
';
2579 // Event into a series
2580 if ($object->recurid) {
2581 print '<tr><td class=
"titlefield">
'.$langs->trans("EventIntoASerie").'</td><td>
'.dol_escape_htmltag($object->recurid).'</td></tr>
';
2585 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2590 print '<tr><td>
'.$langs->trans("DateActionStart").'</td><td>
';
2591 // Test a date before the 27 march and one after
2592 //print dol_print_date($object->datep, 'dayhour
', 'gmt
');
2593 //print dol_print_date($object->datep, 'dayhour
', 'tzuser
');
2594 //print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2595 if (empty($object->fulldayevent)) {
2596 print dol_print_date($object->datep, 'dayhour
', 'tzuserrel
');
2598 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2599 print dol_print_date($object->datep, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2601 if ($object->percentage == 0 && $object->datep && $object->datep < ($now - $delay_warning)) {
2602 print img_warning($langs->trans("Late"));
2608 print '<tr><td>
'.$langs->trans("DateActionEnd").'</td><td>
';
2609 if (empty($object->fulldayevent)) {
2610 print dol_print_date($object->datef, 'dayhour
', 'tzuserrel
');
2612 $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT
');
2613 print dol_print_date($object->datef, 'day
', ($tzforfullday ? $tzforfullday : 'tzuserrel
'));
2615 if ($object->percentage > 0 && $object->percentage < 100 && $object->datef && $object->datef < ($now - $delay_warning)) {
2616 print img_warning($langs->trans("Late"));
2621 if (!getDolGlobalString('AGENDA_DISABLE_LOCATION
')) {
2622 print '<tr><td>
'.$langs->trans("Location").'</td><td>
'.$object->location.'</td></tr>
';
2626 print '<tr><td class=
"nowrap">
'.$langs->trans("ActionAssignedTo").'</td><td>
';
2627 $listofuserid = array();
2628 if (empty($donotclearsession)) {
2629 if ($object->userownerid > 0) {
2630 $listofuserid[$object->userownerid] = array(
2631 'id
' => $object->userownerid,
2632 'transparency
' => $object->transparency, // Force transparency on owner from property of event
2633 'answer_status
' => $object->userassigned[$object->userownerid]['answer_status
'],
2634 'mandatory
' => $object->userassigned[$object->userownerid]['mandatory
']
2637 if (!empty($object->userassigned)) { // Now concat assigned users
2638 // Restore array with key with same value than param 'id
'
2639 $tmplist1 = $object->userassigned;
2640 foreach ($tmplist1 as $key => $val) {
2641 if ($val['id
'] && $val['id
'] != $object->userownerid) {
2642 $listofuserid[$val['id
']] = $val;
2646 $_SESSION['assignedtouser
'] = json_encode($listofuserid);
2648 if (!empty($_SESSION['assignedtouser
'])) {
2649 $listofuserid = json_decode($_SESSION['assignedtouser
'], true);
2653 $listofcontactid = array(); // not used yet
2654 $listofotherid = array(); // not used yet
2655 print '<div class=
"assignedtouser">
';
2656 print $form->select_dolusers_forevent('view
', 'assignedtouser
', 1, array(), 0, '', array(), 0, 0, 0, '', ($object->datep != $object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2659 if ($object->datep != $object->datef && in_array($user->id,array_keys($listofuserid)))
2661 print '<div class=
"myavailability">
';
2662 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
2666 print ' </td></tr>
';
2669 if (isModEnabled('category
')) {
2670 print '<tr><td class=
"valignmiddle">
'.$langs->trans("Categories").'</td><td>
';
2671 print $form->showCategories($object->id, Categorie::TYPE_ACTIONCOMM, 1);
2679 print '<div class=
"fichehalfright">
';
2681 print '<div class=
"underbanner clearboth"></div>
';
2682 print '<
table class=
"border tableforfield centpercent">
';
2684 if (isModEnabled("societe")) {
2686 print '<tr><td class=
"titlefield">
'.$langs->trans("ActionOnCompany").'</td>
';
2687 print '<td>
'.(is_object($object->thirdparty) && $object->thirdparty->id ? $object->thirdparty->getNomUrl(1) : ('<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
'));
2688 if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL
') {
2689 if ($object->thirdparty->fetch($object->thirdparty->id)) {
2690 print "<br>".dol_print_phone($object->thirdparty->phone);
2696 print '<tr><td>
'.$langs->trans("ActionOnContact").'</td>
';
2699 if (!empty($object->socpeopleassigned)) {
2700 foreach ($object->socpeopleassigned as $cid => $Tab) {
2701 $contact = new Contact($db);
2702 $result = $contact->fetch($cid);
2705 dol_print_error($db, $contact->error);
2709 print $contact->getNomUrl(1);
2710 if ($object->type_code == 'AC_TEL
') {
2711 if (!empty($contact->phone_pro)) {
2712 print '(
'.dol_print_phone($contact->phone_pro).')
';
2715 print '<div class=
"paddingright"></div>
';
2719 print '<span class=
"opacitymedium">
'.$langs->trans("None").'</span>
';
2725 if (getDolGlobalString('AGENDA_SUPPORT_PRIORITY_IN_EVENTS
')) {
2726 print '<tr><td class=
"nowrap" class=
"titlefield">
' . $langs->trans("Priority") . '</td><td>
';
2727 print($object->priority ? $object->priority : '');
2731 // Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
2732 // for such objects because there is already a dedicated field into table llx_actioncomm.
2733 if (!empty($object->fk_element) && !empty($object->elementtype) && !in_array($object->elementtype, array('societe
', 'contact
', 'project
'))) {
2734 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php
';
2735 print '<tr><td>
'.$langs->trans("LinkedObject").'</td>
';
2736 $link = dolGetElementUrl($object->fk_element, $object->elementtype, 1);
2739 print '<span class=
"opacitymedium">
'.$langs->trans("ObjectDeleted").'</span>
';
2747 if (!empty($object->email_msgid)) {
2748 print '<tr><td>
'.$langs->trans('MailTopic
').'</td>
';
2749 print '<td>
'.dol_escape_htmltag($object->email_subject).'</td></tr>
';
2750 print '<tr><td>
'.$langs->trans('MailFrom
').'</td>
';
2751 print '<td>
'.dol_escape_htmltag($object->email_from).'</td></tr>
';
2752 print '<tr><td>
'.$langs->trans('MailTo
').'</td>
';
2753 print '<td>
'.dol_escape_htmltag($object->email_to).'</td></tr>
';
2754 if (!empty($object->email_tocc)) {
2755 print '<tr><td>
'.$langs->trans('MailCC
').'</td>
';
2756 print '<td>
'.dol_escape_htmltag($object->email_tocc).'</td></tr>
';
2761 print '<tr><td class=
"tdtop">
'.$langs->trans("Description").'</td><td class=
"wordbreak sensiblehtmlcontent">
';
2762 print dol_string_onlythesehtmltags(dol_htmlentitiesbr($object->note_private));
2766 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php
';
2769 if (getDolGlobalString('AGENDA_REMINDER_EMAIL
') || getDolGlobalString('AGENDA_REMINDER_BROWSER
')) {
2770 $filteruserid = $user->id;
2771 if ($user->hasRight('agenda
', 'allactions
', 'read
')) {
2774 $object->loadReminders('', $filteruserid, false);
2776 print '<tr><td class=
"titlefieldcreate nowrap">
'.$langs->trans("Reminders").'</td><td>
';
2778 if (count($object->reminders) > 0) {
2779 $tmpuserstatic = new User($db);
2781 foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) {
2782 print $TRemindTypes[$actioncommreminder->typeremind]['label
'];
2783 if ($actioncommreminder->fk_user > 0) {
2784 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2785 print ' (
'.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')
';
2787 print ' -
'.$actioncommreminder->offsetvalue.' '.$TDurationTypes[$actioncommreminder->offsetunit];
2789 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2790 print ' - <span class=
"opacitymedium">
';
2791 print $langs->trans("NotSent");
2793 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2794 print ' - <span class=
"opacitymedium">
';
2795 print $langs->trans("Done");
2797 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2798 print ' - <span class=
"opacitymedium">
';
2799 print $form->textwithpicto($langs->trans("Error"), $actioncommreminder->lasterror);
2813 print '<div class=
"clearboth"></div>
';
2815 print dol_get_fiche_end();
2822 print '<div class=
"tabsAction">
';
2824 $parameters = array();
2825 $reshook = $hookmanager->executeHooks('addMoreActionsButtons
', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2826 if (empty($reshook)) {
2827 if ($action != 'edit
') {
2828 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
2829 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
2830 print '<div class=
"inline-block divButAction"><a class=
"butAction" href=
"card.php?action=edit&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Modify").'</a></div>
';
2832 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Modify").'</a></div>
';
2835 if ($user->hasRight('agenda
', 'allactions
', 'create
') ||
2836 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'create
'))) {
2837 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>
';
2839 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("ToClone").'</a></div>
';
2842 if ($user->hasRight('agenda
', 'allactions
', 'delete
') ||
2843 (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->hasRight('agenda
', 'myactions
', 'delete
'))) {
2844 print '<div class=
"inline-block divButAction"><a class=
"butActionDelete" href=
"card.php?action=delete&token='.newToken().'&id='.$object->id.'">
'.$langs->trans("Delete").'</a></div>
';
2846 print '<div class=
"inline-block divButAction"><a class=
"butActionRefused classfortooltip" href=
"#" title=
"'.$langs->trans("NotAllowed
").'">
'.$langs->trans("Delete").'</a></div>
';
2853 if ($action != 'edit
') {
2854 if (!getDolGlobalString('AGENDA_DISABLE_BUILDDOC
')) {
2855 print '<div class=
"clearboth"></div><div class=
"fichecenter"><div class=
"fichehalfleft">
';
2856 print '<a
name=
"builddoc"></a>
'; // ancre
2859 * Generated documents
2862 $filedir = $conf->agenda->multidir_output[$conf->entity].'/
'.$object->id;
2863 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
2865 $genallowed = $user->hasRight('agenda
', 'myactions
', 'read
');
2866 $delallowed = $user->hasRight('agenda
', 'myactions
', 'create
');
2869 print $formfile->showdocuments('actions
', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang());
2871 print '</div><div class=
"fichehalfright">
';
2874 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.