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';
54$langs->loadLangs(array(
"companies",
"other",
"commercial",
"bills",
"orders",
"agenda",
"mails"));
57$action =
GETPOST(
'action',
'aZ09');
58$cancel =
GETPOST(
'cancel',
'alpha');
59$backtopage =
GETPOST(
'backtopage',
'alpha');
60$socpeopleassigned =
GETPOST(
'socpeopleassigned',
'array');
61$origin =
GETPOST(
'origin',
'alpha');
63$confirm =
GETPOST(
'confirm',
'alpha');
65$fulldayevent =
GETPOST(
'fullday',
'alpha');
72$addreminder =
GETPOST(
'addreminder',
'alpha');
74$offsetunit =
GETPOST(
'offsetunittype_duration',
'aZ09');
75$remindertype =
GETPOST(
'selectremindertype',
'aZ09');
76$modelmail =
GETPOSTINT(
'actioncommsendmodel_mail');
77$complete =
GETPOST(
'complete',
'alpha');
78$private =
GETPOST(
'private',
'alphanohtml');
79if ($complete ==
'na' || $complete == -2) {
96 if (
GETPOST(
'datep') ==
'now') {
98 } elseif (preg_match(
'/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',
GETPOST(
"datep"), $reg)) {
99 $datep =
dol_mktime(0, 0, 0, (
int) $reg[2], (
int) $reg[3], (
int) $reg[1],
'tzuserrel');
106if ($user->socid && ($socid != $user->socid)) {
111$donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
120$form =
new Form($db);
125if ($id > 0 && $action !=
'add') {
129 $ret =
$object->fetch_optionals();
130 $ret1 =
$object->fetch_userassigned();
132 if ($ret < 0 || $ret1 < 0) {
138$extrafields->fetch_name_optionals_label(
$object->table_element);
141$hookmanager->initHooks(array(
'actioncard',
'globalcard'));
143$parameters = array(
'socid' => $socid);
144$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
149$TRemindTypes = array();
151 $TRemindTypes[
'browser'] = array(
'label' => $langs->trans(
'BrowserPush'),
'disabled' => (
getDolGlobalString(
'AGENDA_REMINDER_BROWSER') ? 0 : 1));
154 $TRemindTypes[
'email'] = array(
'label' => $langs->trans(
'EMail'),
'disabled' => (
getDolGlobalString(
'AGENDA_REMINDER_EMAIL') ? 0 : 1));
157$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'));
159$result =
restrictedArea($user,
'agenda',
$object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
161$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || ((empty(
$object->id) ||
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
168$listUserAssignedUpdated =
false;
169$listResourceAssignedUpdated =
false;
170$assignedtouser = array();
173if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
174 $idtoremove =
GETPOST(
'removedassigned');
176 if (!empty($_SESSION[
'assignedtouser'])) {
177 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'],
true);
179 $tmpassigneduserids = array();
182 foreach ($tmpassigneduserids as $key => $val) {
183 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
184 unset($tmpassigneduserids[$key]);
188 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
189 $donotclearsession = 1;
190 if ($action ==
'add') {
193 if ($action ==
'update') {
197 $listUserAssignedUpdated =
true;
200if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
201 $idtoremove =
GETPOST(
'removedassignedresource');
203 if (!empty($_SESSION[
'assignedtoresource'])) {
204 $tmpassignedresourceids = json_decode($_SESSION[
'assignedtoresource'],
true);
206 $tmpassignedresourceids = array();
209 foreach ($tmpassignedresourceids as $key => $val) {
210 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
211 unset($tmpassignedresourceids[$key]);
215 $_SESSION[
'assignedtoresource'] = json_encode($tmpassignedresourceids);
216 $donotclearsessionresource = 1;
217 if ($action ==
'add' && $usercancreate) {
220 if ($action ==
'update' && $usercancreate) {
224 $listResourceAssignedUpdated =
true;
228if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
230 if (
GETPOST(
'assignedtouser') > 0) {
231 $assignedtouser = array();
232 if (!empty($_SESSION[
'assignedtouser'])) {
233 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
235 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id' =>
GETPOSTINT(
'assignedtouser'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
236 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
238 $donotclearsession = 1;
239 if ($action ==
'add' && $usercancreate) {
242 if ($action ==
'update' && $usercancreate) {
246 $listUserAssignedUpdated =
true;
250if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
252 if (
GETPOST(
'assignedtoresource') > 0) {
253 $assignedtoresource = array();
254 if (!empty($_SESSION[
'assignedtoresource'])) {
255 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
257 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id' =>
GETPOSTINT(
'assignedtoresource'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
258 $_SESSION[
'assignedtoresource'] = json_encode($assignedtoresource);
260 $donotclearsession = 1;
261 if ($action ==
'add' && $usercancreate) {
264 if ($action ==
'update' && $usercancreate) {
268 $listResourceAssignedUpdated =
true;
272if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
273 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
279if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
280 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
285 if (!empty(
$object->socpeopleassigned)) {
286 reset(
$object->socpeopleassigned);
291 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
302if (empty($reshook) && $action ==
'add' && $usercancreate) {
305 if (empty($backtopage)) {
307 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
309 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
313 if (!empty($socpeopleassigned[0])) {
314 $result = $contact->fetch($socpeopleassigned[0]);
318 header(
"Location: ".$backtopage);
322 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
335 $datef = (!$datef && $percentage == 100)?
dol_now():$datef;
338 if (!$datef && $percentage == 100) {
340 $donotclearsession = 1;
342 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
347 $donotclearsession = 1;
349 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
353 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
355 $donotclearsession = 1;
357 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
365 $object->fulldayevent = ($fulldayevent ? 1 : 0);
369 if (
GETPOST(
"elementtype",
'alpha')) {
371 $modulecodetouseforpermissioncheck = $elProp[
'module'];
373 $hasPermissionOnLinkedObject = 0;
374 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
375 $hasPermissionOnLinkedObject = 1;
377 if ($hasPermissionOnLinkedObject) {
385 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
386 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
388 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
389 $object->label = $langs->transnoentitiesnoconv(
"Action".
$object->type_code).
"\n";
391 $cactioncomm->fetch(
$object->type_code);
392 $object->label = $cactioncomm->label;
399 if (!empty($taskid)) {
400 $taskProject =
new Task($db);
401 if ($taskProject->fetch($taskid) > 0) {
402 $object->fk_project = $taskProject->fk_project;
412 $object->percentage = $percentage;
415 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
417 $listofuserid = array();
418 if (!empty($_SESSION[
'assignedtouser'])) {
419 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
422 foreach ($listofuserid as $key => $value) {
424 if ($value[
'id'] > 0) {
425 $object->userownerid = $value[
'id'];
427 $object->transparency = $transparency;
430 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
438 if (GETPOSTISSET(
"contactid")) {
450 if (empty(
$object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
452 $donotclearsession = 1;
454 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
456 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
458 $donotclearsession = 1;
460 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
465 $donotclearsession = 1;
467 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
470 foreach ($socpeopleassigned as $cid) {
471 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
473 if (!empty(
$object->socpeopleassigned)) {
474 reset(
$object->socpeopleassigned);
479 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
482 $donotclearsession = 1;
491 $selectedrecurrulefreq =
'no';
492 $selectedrecurrulebymonthday =
'';
493 $selectedrecurrulebyday =
'';
494 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
495 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY' && GETPOSTISSET(
'BYMONTHDAY')) ?
"_BYMONTHDAY".
GETPOST(
'BYMONTHDAY',
'alpha') :
"";
496 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY' && GETPOSTISSET(
'BYDAY')) ?
"_BYDAY".
GETPOST(
'BYDAY',
'alpha') :
"";
501 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
502 $selectedrecurrulefreq = $reg1[1];
504 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
505 $selectedrecurrulebymonthday = (int) $reg2[1];
507 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
508 $selectedrecurrulebyday = (int) $reg3[1];
512 $eventisrecurring = 0;
513 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 2 ? 1 : 0);
514 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
515 $eventisrecurring = 1;
525 $idaction =
$object->create($user);
531 $categories =
GETPOST(
'categories',
'array');
532 $object->setCategories($categories);
534 unset($_SESSION[
'assignedtouser']);
536 if ($user->id !=
$object->userownerid) {
537 $moreparam =
"filtert=-1";
541 if ($addreminder ==
'on') {
546 $actionCommReminder->dateremind = $dateremind;
547 $actionCommReminder->typeremind = $remindertype;
548 $actionCommReminder->offsetunit = $offsetunit;
549 $actionCommReminder->offsetvalue = $offsetvalue;
550 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
551 $actionCommReminder->fk_actioncomm =
$object->id;
552 if ($remindertype ==
'email') {
553 $actionCommReminder->fk_email_template = $modelmail;
557 foreach (
$object->userassigned as $userassigned) {
558 $actionCommReminder->fk_user = $userassigned[
'id'];
559 $res = $actionCommReminder->create($user);
564 $langs->load(
"errors");
565 $error = $langs->trans(
'ErrorReminderActionCommCreation');
568 $donotclearsession = 1;
579 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
599 $langs->load(
"errors");
600 $error = $langs->trans(
$object->error);
603 $donotclearsession = 1;
609 $donotclearsession = 1;
612 if ($eventisrecurring) {
616 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
618 $datep =
dol_mktime($fulldayevent ?
'00' :
GETPOSTINT(
"aphour"), $fulldayevent ?
'00' :
GETPOSTINT(
"apmin"), $fulldayevent ?
'00' :
GETPOSTINT(
"apsec"), $firstdatearray[
'month'], $firstdatearray[
'first_day'], $firstdatearray[
'year'], $tzforfullday ? $tzforfullday :
'tzuserrel');
622 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
623 $firstday = $selectedrecurrulebymonthday;
632 $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');
638 while ($datep <= $repeateventlimitdate && !$error) {
642 $finalobject->datep = $datep;
643 $finalobject->datef = $datef;
645 $idaction = $finalobject->create($user);
648 if (!$finalobject->error) {
650 $categories =
GETPOST(
'categories',
'array');
651 $finalobject->setCategories($categories);
653 unset($_SESSION[
'assignedtouser']);
656 if ($user->id != $finalobject->userownerid) {
657 $moreparam =
"filtert=-1";
661 if ($addreminder ==
'on') {
666 $actionCommReminder->dateremind = $dateremind;
667 $actionCommReminder->typeremind = $remindertype;
668 $actionCommReminder->offsetunit = $offsetunit;
669 $actionCommReminder->offsetvalue = $offsetvalue;
670 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
671 $actionCommReminder->fk_actioncomm = $finalobject->id;
672 if ($remindertype ==
'email') {
673 $actionCommReminder->fk_email_template = $modelmail;
677 foreach ($finalobject->userassigned as $userassigned) {
678 $actionCommReminder->fk_user = $userassigned[
'id'];
679 $res = $actionCommReminder->create($user);
684 $langs->load(
"errors");
685 $error = $langs->trans(
'ErrorReminderActionCommCreation');
688 $donotclearsession = 1;
699 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
709 $langs->load(
"errors");
710 $error = $langs->trans($finalobject->error);
713 $donotclearsession = 1;
719 $donotclearsession = 1;
723 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
734 if (!empty($backtopage) && !$error) {
735 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
736 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
737 } elseif ($idaction) {
738 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
740 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
747if (empty($reshook) && $action ==
'update' && $usercancreate) {
748 if (empty($cancel)) {
749 $fulldayevent =
GETPOST(
'fullday');
754 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
779 $datep =
dol_mktime(0, 0, 0,
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
780 $datef =
dol_mktime(23, 59, 59,
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
782 $datep =
dol_mktime(
GETPOST(
"aphour",
'int'),
GETPOST(
"apmin",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuserrel');
783 $datef =
dol_mktime(
GETPOST(
"p2hour",
'int'),
GETPOST(
"p2min",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuserrel');
786 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
788 if (
$object->elementtype ==
'ticket') {
790 if (
$object->code ==
'TICKET_MSG') {
791 $object->code =
'TICKET_MSG_PRIVATE';
793 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
794 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
797 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
800 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
801 $object->code =
'TICKET_MSG_SENTBYMAIL';
813 $object->percentage = $percentage;
818 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
819 $object->socpeopleassigned = array();
820 foreach ($socpeopleassigned as $cid) {
821 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
824 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
825 reset(
$object->socpeopleassigned);
831 if (
GETPOST(
"elementtype",
'alpha')) {
833 $modulecodetouseforpermissioncheck = $elProp[
'module'];
835 $hasPermissionOnLinkedObject = 0;
836 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
837 $hasPermissionOnLinkedObject = 1;
839 if ($hasPermissionOnLinkedObject) {
847 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
850 $listofuserid = array();
851 if (!empty($_SESSION[
'assignedtouser'])) {
853 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
854 foreach ($tmplist1 as $key => $val) {
855 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
856 $listofuserid[$val[
'id']] = $val;
860 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
861 if ($assignedtouser) {
862 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
865 $object->userassigned = array();
868 foreach ($listofuserid as $key => $val) {
870 $object->userownerid = $val[
'id'];
872 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
876 $object->transparency = $transparency;
880 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
882 $donotclearsession = 1;
884 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
886 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
888 if (empty(
$object->userownerid)) {
890 $donotclearsession = 1;
892 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
896 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
904 $eventDateStart =
$object->datep;
905 $eventDateEnd =
$object->datef;
907 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
908 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
909 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
910 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
911 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
912 $sql .=
" AND er.resource_id IN (";
913 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
914 $sql .=
" WHERE element_id = ".((int)
$object->id);
915 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
916 $sql .=
" AND busy = 1";
918 $sql .=
" AND er.busy = 1";
922 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
924 if (!empty($eventDateEnd)) {
925 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
929 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
930 if (!empty($eventDateEnd)) {
931 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
936 $resql = $db->query($sql);
939 $object->error = $db->lasterror();
942 if ($db->num_rows($resql) > 0) {
945 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
946 while ($obj = $db->fetch_object($resql)) {
947 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
963 $result =
$object->update($user);
967 $categories =
GETPOST(
'categories',
'array');
968 $object->setCategories($categories);
970 $object->loadReminders($remindertype, 0,
false);
973 if (!empty(
$object->reminders)) {
974 foreach (
$object->reminders as $reminder) {
975 if ($reminder->status < 1) {
976 $reminder->delete($user);
983 if ($addreminder ==
'on') {
988 $actionCommReminder->dateremind = $dateremind;
989 $actionCommReminder->typeremind = $remindertype;
990 $actionCommReminder->offsetunit = $offsetunit;
991 $actionCommReminder->offsetvalue = $offsetvalue;
992 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
993 $actionCommReminder->fk_actioncomm =
$object->id;
994 if ($remindertype ==
'email') {
995 $actionCommReminder->fk_email_template = $modelmail;
999 foreach (
$object->userassigned as $userassigned) {
1000 $actionCommReminder->fk_user = $userassigned[
'id'];
1004 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1005 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".$db->escape($remindertype).
"'";
1006 $resqldelete = $db->query($sqldelete);
1008 $res = $actionCommReminder->create($user);
1012 $langs->load(
"errors");
1013 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1016 $donotclearsession = 1;
1023 unset($_SESSION[
'assignedtouser']);
1024 unset($_SESSION[
'assignedtoresource']);
1039 if (!empty($backtopage)) {
1040 unset($_SESSION[
'assignedtouser']);
1041 header(
"Location: ".$backtopage);
1048if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
1051 $object->fetch_userassigned();
1054 if ($user->hasRight(
'agenda',
'myactions',
'delete')
1055 || $user->hasRight(
'agenda',
'allactions',
'delete')) {
1056 $result =
$object->delete($user);
1059 header(
"Location: index.php");
1071if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
1077 $newdate =
GETPOST(
'newdate',
'alpha');
1078 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1079 header(
"Location: ".$backtopage,
true, 307);
1083 $datep =
dol_mktime($shour, $smin, 0, (
int) substr($newdate, 13, 2), (
int) substr($newdate, 15, 2), (
int) substr($newdate, 9, 4),
'tzuserrel');
1086 if ($datep !=
$object->datep) {
1095 $eventDateStart =
$object->datep;
1096 $eventDateEnd =
$object->datef;
1098 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1099 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1100 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1101 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1102 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1103 $sql .=
" AND er.resource_id IN (";
1104 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1105 $sql .=
" WHERE element_id = ".((int)
$object->id);
1106 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1107 $sql .=
" AND busy = 1";
1109 $sql .=
" AND er.busy = 1";
1113 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1115 if (!empty($eventDateEnd)) {
1116 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1120 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1121 if (!empty($eventDateEnd)) {
1122 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1127 $resql = $db->query($sql);
1130 $object->error = $db->lasterror();
1133 if ($db->num_rows($resql) > 0) {
1136 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1137 while ($obj = $db->fetch_object($resql)) {
1138 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1153 $result =
$object->update($user);
1163 if (!empty($backtopage)) {
1164 header(
"Location: ".$backtopage,
true, 307);
1173$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1174if (empty($reshook)) {
1175 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1183$form =
new Form($db);
1186$arrayrecurrulefreq = array(
1187 'no' => $langs->trans(
"OnceOnly"),
1188 'MONTHLY' => $langs->trans(
"EveryMonth"),
1189 'WEEKLY' => $langs->trans(
"EveryWeek")
1194$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1195llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1197if ($action ==
'create') {
1200 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1201 if (!empty($socpeopleassigned[0])) {
1202 $result = $contact->fetch($socpeopleassigned[0]);
1210 if (!empty($conf->use_javascript_ajax)) {
1211 print
"\n".
'<script type="text/javascript">';
1212 print
'$(document).ready(function () {
1213 function setdatefields()
1215 if ($("#fullday:checked").val() == null) {
1216 $(".fulldaystarthour").removeAttr("disabled");
1217 $(".fulldaystartmin").removeAttr("disabled");
1218 $(".fulldayendhour").removeAttr("disabled");
1219 $(".fulldayendmin").removeAttr("disabled");
1220 $("#p2").removeAttr("disabled");
1222 $(".fulldaystarthour").prop("disabled", true).val("00");
1223 $(".fulldaystartmin").prop("disabled", true).val("00");
1224 $(".fulldayendhour").prop("disabled", true).val("23");
1225 $(".fulldayendmin").prop("disabled", true).val("59");
1226 $("#p2").removeAttr("disabled");
1229 $("#fullday").change(function() {
1230 console.log("setdatefields");
1233 var old_startdate = null;
1234 $("#ap").focus(function() {
1235 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1237 $("#ap").next(".ui-datepicker-trigger").click(function() {
1238 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1240 $("#ap").change(function() {
1241 setTimeout(function() {
1242 if ($("#p2").val() !== "") {
1243 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1244 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1245 if (new_startdate > old_enddate) {
1246 var timeDiff = old_enddate - old_startdate;
1247 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1248 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1249 $("#p2day").val(new_enddate.getDate());
1250 $("#p2month").val(new_enddate.getMonth() + 1);
1251 $("#p2year").val(new_enddate.getFullYear());
1256 $("#actioncode").change(function() {
1257 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1258 else $("#dateend").removeClass("fieldrequired");
1260 $("#aphour,#apmin").change(function() {
1261 if ($("#actioncode").val() == \'AC_RDV\') {
1262 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1263 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1264 $("#p2min").val($("#apmin").val());
1265 $("#p2day").val($("#apday").val());
1266 $("#p2month").val($("#apmonth").val());
1267 $("#p2year").val($("#apyear").val());
1268 $("#p2").val($("#ap").val());
1271 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1272 else $("#dateend").removeClass("fieldrequired");
1275 print
'</script>'.
"\n";
1278 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1279 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1280 print
'<input type="hidden" name="action" value="add">';
1281 print
'<input type="hidden" name="donotclearsession" value="1">';
1282 print
'<input type="hidden" name="page_y" value="">';
1284 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1287 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1290 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1291 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1298 print
'<table class="border centpercent nobottom">';
1302 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1304 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1305 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1306 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1311 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>';
1314 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1315 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>';
1318 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1319 if (
GETPOST(
'datep',
'alpha', 1)) {
1322 $datef = ($datef ? $datef :
$object->datef);
1323 if (
GETPOST(
'datef',
'alpha', 1)) {
1326 if (empty($datef) && !empty($datep)) {
1333 print
'<tr><td class="nowrap">';
1336 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1338 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1340 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1341 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1344 print
'<tr><td></td><td>';
1346 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0);
1347 if ($userepeatevent) {
1350 print
'<div class="opacitymedium inline-block small">';
1351 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 6px" class="paddingright2"');
1352 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1354 $selectedrecurrulefreq =
'no';
1355 $selectedrecurrulebymonthday =
'';
1356 $selectedrecurrulebyday =
'';
1357 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1358 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1359 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1363 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1364 $selectedrecurrulefreq = $reg[1];
1366 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1367 $selectedrecurrulebymonthday = (int) $reg[1];
1369 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1370 $selectedrecurrulebyday = (int) $reg[1];
1373 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1379 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1380 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1383 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1384 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1387 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1388 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1389 print $langs->trans(
"Until").
" ";
1390 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1393 print
'<script type="text/javascript">
1394 jQuery(document).ready(function() {
1395 function init_repeat()
1397 console.log("recurrule: " + "'.$object->recurrule.
'");
1398 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1399 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1400 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1401 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1402 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1404 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1405 jQuery(".repeateventlimitdate").css("display", "inline-block");
1406 jQuery(".repeateventBYDAY").hide();
1408 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1410 jQuery(".repeateventBYMONTHDAY").hide();
1411 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1412 jQuery(".repeateventlimitdate").css("display", "inline-block");
1416 jQuery(".repeateventBYMONTHDAY").hide();
1417 jQuery(".repeateventBYDAY").hide();
1418 jQuery(".repeateventlimitdate").hide();
1422 jQuery("#recurrulefreq").change(function() {
1432 print
'<tr><td class=""> </td><td></td></tr>';
1435 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1436 $listofuserid = array();
1437 $listofcontactid = array();
1438 $listofotherid = array();
1440 if (empty($donotclearsession)) {
1442 if ($assignedtouser) {
1443 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1446 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1447 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1449 if (!empty($_SESSION[
'assignedtouser'])) {
1450 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1452 $firstelem = reset($listofuserid);
1453 if (isset($listofuserid[$firstelem[
'id']])) {
1454 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1457 print
'<div class="assignedtouser">';
1458 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1464 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>';
1467 if (isModEnabled(
'category')) {
1469 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1470 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
1471 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1475 if (isModEnabled(
'resource')) {
1477 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1479 $listofresourceid = array();
1480 if (empty($donotclearsession)) {
1481 $assignedtoresource =
GETPOST(
"assignedtoresource");
1482 if ($assignedtoresource) {
1483 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1485 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1487 if (!empty($_SESSION[
'assignedtoresource'])) {
1488 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1490 $firstelem = reset($listofresourceid);
1491 if (isset($listofresourceid[$firstelem[
'id']])) {
1492 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1495 print
'<div class="assignedtoresource">';
1496 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1502 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1504 $percent = $complete !==
'' ? $complete : -1;
1505 if (GETPOSTISSET(
'status')) {
1507 } elseif (GETPOSTISSET(
'percentage')) {
1510 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1512 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1516 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1522 print
'<br><hr><br>';
1525 print
'<table class="border centpercent nobottom">';
1527 if (isModEnabled(
"societe")) {
1529 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1533 print $societe->getNomUrl(1);
1534 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1537 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1539 if (!empty($user->socid)) {
1540 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1542 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'', $langs->trans(
'SelectThirdParty'), 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1548 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1549 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1553 if ($origin ==
'contact') {
1559 $select_contact_default = 0;
1561 $select_contact_default = -1;
1563 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1565 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
1572 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1573 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, array(), false,
'multiple',
'contactid');
1574 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1576 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, array(), false,
'multiple',
'contactid');
1583 if (isModEnabled(
'project')) {
1584 $langs->load(
"projects");
1588 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1589 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1590 print $formproject->select_projects((
$object->socid > 0 ?
$object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx maxwidth500');
1592 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1593 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1594 $urloption =
'?action=create&donotclearsession=1';
1598 print
"\n".
'<script type="text/javascript">';
1599 print
'$(document).ready(function () {
1600 $("#projectid").change(function () {
1601 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1602 console.log("Call url to get new list of tasks: "+url);
1603 $.get(url, function(data) {
1605 if (data) $("#taskid").html(data).select2();
1609 print
'</script>'.
"\n";
1614 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1615 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1616 $projectsListId =
false;
1617 if (!empty($projectid)) {
1618 $projectsListId = $projectid;
1621 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1623 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', $projectsListId);
1628 if (!empty($origin) && !empty($originid)) {
1629 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1631 $hasPermissionOnLinkedObject = 0;
1634 if ($user->hasRight($elProp[
'module'],
'read') || $user->hasRight($elProp[
'module'], $elProp[
'element'],
'read')) {
1635 $hasPermissionOnLinkedObject = 1;
1639 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1641 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1642 print
'<td colspan="3">';
1643 if ($hasPermissionOnLinkedObject) {
1645 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1646 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1647 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1648 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1650 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1658 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1659 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1664 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1665 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1666 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 120,
'dolibarr_notes',
'In', true, true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1667 $doleditor->Create();
1671 $parameters = array();
1672 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1673 print $hookmanager->resPrint;
1674 if (empty($reshook)) {
1675 print
$object->showOptionals($extrafields,
'create', $parameters);
1685 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1687 print
'<div class="reminderparameters" style="display: none;">';
1689 print
'<table class="border centpercent">';
1692 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1693 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1694 print $form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1698 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1699 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1704 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1705 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1712 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
1713 $reminderDefaultOffset =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_OFFSET', 30);
1715 $reminderDefaultEmailModel =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
1717 print
"\n".
'<script type="text/javascript">';
1718 print
'$(document).ready(function () {
1719 const reminderDefaultEventTypes = '.$reminderDefaultEventTypes.
';
1720 $("#actioncode").change(function(){
1721 var selected_event_type = $("#actioncode option:selected").val();
1723 if (reminderDefaultEventTypes.includes(selected_event_type)) {
1724 $(".reminderparameters").show();
1725 $("#addreminder").prop("checked", true);
1727 // Set period with default reminder period
1728 $("[name=\"offsetvalue\"]").val("' . $reminderDefaultOffset .
'");
1729 $("#select_offsetunittype_duration").select2("destroy");
1730 $("#select_offsetunittype_duration").val("'.$reminderDefaultUnit.
'");
1731 $("#select_offsetunittype_duration").select2();
1733 $("#selectremindertype").select2("destroy");
1734 $("#selectremindertype").val("email");
1735 $("#selectremindertype").select2();
1737 // Set default reminder mail model
1738 $("#select_actioncommsendmodel_mail").closest("tr").show();
1739 $("#select_actioncommsendmodel_mail").select2("destroy");
1740 $("#select_actioncommsendmodel_mail").val("'.$reminderDefaultEmailModel.
'");
1741 $("#select_actioncommsendmodel_mail").select2();
1745 print
'</script>'.
"\n";
1747 print
"\n".
'<script type="text/javascript">';
1748 print
'$(document).ready(function () {
1749 $("#addreminder").click(function(){
1750 console.log("Click on addreminder");
1752 $(".reminderparameters").show();
1754 $(".reminderparameters").hide();
1756 $("#selectremindertype").select2("destroy");
1757 $("#selectremindertype").select2();
1758 $("#select_offsetunittype_duration").select2("destroy");
1759 $("#select_offsetunittype_duration").select2();
1760 selectremindertype();
1763 $("#selectremindertype").change(function(){
1764 selectremindertype();
1767 function selectremindertype() {
1768 console.log("Call selectremindertype");
1769 var selected_option = $("#selectremindertype option:selected").val();
1770 if(selected_option == "email") {
1771 $("#select_actioncommsendmodel_mail").closest("tr").show();
1773 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1778 print
'</script>'.
"\n";
1783 print $form->buttonsSaveCancel(
"Add");
1790 $result1 =
$object->fetch($id);
1791 if ($result1 <= 0) {
1792 $langs->load(
"errors");
1793 print $langs->trans(
"ErrorRecordNotFound");
1799 $result2 =
$object->fetch_thirdparty();
1800 $result2 =
$object->fetchProject();
1801 $result3 =
$object->fetch_contact();
1802 $result4 =
$object->fetch_userassigned();
1803 $result5 =
$object->fetch_optionals();
1805 if ($listUserAssignedUpdated || $donotclearsession) {
1806 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
1815 $object->percentage = $percentage;
1820 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1821 foreach ($socpeopleassigned as $tmpid) {
1822 $object->socpeopleassigned[
$id] = array(
'id' => $tmpid);
1830 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1836 $tmpuser =
new User($db);
1837 $res = $tmpuser->fetch(
$object->authorid);
1841 $tmpuser =
new User($db);
1842 $res = $tmpuser->fetch(
$object->usermodid);
1854 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
1858 if ($action ==
'delete') {
1859 print $form->formconfirm(
"card.php?id=".urlencode((
string) ($id)), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1862 if ($action ==
'edit') {
1863 if (!empty($conf->use_javascript_ajax)) {
1864 print
"\n".
'<script type="text/javascript">';
1865 print
'$(document).ready(function () {
1866 function setdatefields()
1868 if ($("#fullday:checked").val() == null) {
1869 $(".fulldaystarthour").removeAttr("disabled");
1870 $(".fulldaystartmin").removeAttr("disabled");
1871 $(".fulldayendhour").removeAttr("disabled");
1872 $(".fulldayendmin").removeAttr("disabled");
1874 $(".fulldaystarthour").prop("disabled", true).val("00");
1875 $(".fulldaystartmin").prop("disabled", true).val("00");
1876 $(".fulldayendhour").prop("disabled", true).val("23");
1877 $(".fulldayendmin").prop("disabled", true).val("59");
1881 $("#fullday").change(function() {
1884 var old_startdate = null;
1885 $("#ap").focus(function() {
1886 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1888 $("#ap").next(".ui-datepicker-trigger").click(function() {
1889 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1891 $("#ap").change(function() {
1892 setTimeout(function() {
1893 if ($("#p2").val() !== "") {
1894 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1895 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1896 if (new_startdate > old_enddate) {
1897 var timeDiff = old_enddate - old_startdate;
1898 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1899 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1900 $("#p2day").val(new_enddate.getDate());
1901 $("#p2month").val(new_enddate.getMonth() + 1);
1902 $("#p2year").val(new_enddate.getFullYear());
1907 $("#actioncode").change(function() {
1908 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1909 else $("#dateend").removeClass("fieldrequired");
1912 print
'</script>'.
"\n";
1915 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1916 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1917 print
'<input type="hidden" name="action" value="update">';
1918 print
'<input type="hidden" name="id" value="'.$id.
'">';
1919 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
1920 print
'<input type="hidden" name="page_y" value="">';
1922 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1925 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1930 print
'<table class="border tableforfield" width="100%">';
1933 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.
$object->id.
'</td></tr>';
1937 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
1938 if (
$object->type_code !=
'AC_OTH_AUTO') {
1939 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1940 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
1942 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1943 print
$object->getTypePicto();
1944 print $langs->trans(
"Action".
$object->type_code);
1950 if (
$object->elementtype ==
'ticket') {
1951 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
1952 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1953 print
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
1957 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>';
1960 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td><td colspan="3" class="valignmiddle height30 small"><input type="checkbox" id="fullday" name="fullday" '.(
$object->fulldayevent ?
' checked' :
'').
'>';
1961 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
2024 print
'<tr><td class="nowrap">';
2029 print
'</td><td td colspan="3">';
2031 print $form->selectDate($datep ? $datep :
$object->datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
$object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2032 print
' <span class="hideonsmartphone"> - </span> ';
2033 print $form->selectDate($datef ? $datef :
$object->datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
$object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2036 print
'<tr><td class=""> </td><td></td></tr>';
2039 $listofuserid = array();
2040 if (empty($donotclearsession)) {
2041 if (
$object->userownerid > 0) {
2042 $listofuserid[
$object->userownerid] = array(
2046 'transparency' =>
$object->transparency,
2047 'answer_status' =>
$object->userassigned[
$object->userownerid][
'answer_status'],
2048 'mandatory' =>
$object->userassigned[
$object->userownerid][
'mandatory']
2051 if (!empty(
$object->userassigned)) {
2053 $tmplist1 =
$object->userassigned;
2054 foreach ($tmplist1 as $key => $val) {
2055 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2056 $listofuserid[$val[
'id']] = $val;
2060 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2062 if (!empty($_SESSION[
'assignedtouser'])) {
2063 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2067 $listofcontactid =
$object->socpeopleassigned;
2068 $listofotherid =
$object->otherassigned;
2070 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
2071 print
'<div class="assignedtouser">';
2072 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
2084 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.
$object->location.
'"></td></tr>';
2088 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
2089 $percent = GETPOSTISSET(
"percentage") ?
GETPOSTINT(
"percentage") :
$object->percentage;
2090 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
2094 if (isModEnabled(
'category')) {
2095 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2096 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
2098 $cats = $c->containing(
$object->id, Categorie::TYPE_ACTIONCOMM);
2099 $arrayselected = array();
2100 foreach ($cats as $cat) {
2101 $arrayselected[] = $cat->id;
2103 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2110 print
'<br><hr><br>';
2113 print
'<table class="border tableforfield centpercent">';
2115 if (isModEnabled(
"societe")) {
2117 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2121 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2124 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2129 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2130 print
'<div class="maxwidth200onsmartphone">';
2131 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2132 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
2139 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2140 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');
2141 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2144 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');
2152 if (isModEnabled(
'project')) {
2153 $langs->load(
"projects");
2155 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2156 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2157 $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');
2158 if ($numprojet == 0) {
2159 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>';
2166 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2167 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2172 if (!empty(
$object->fk_element) && !empty(
$object->elementtype)) {
2173 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2175 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2177 if (
$object->elementtype ==
'task' && isModEnabled(
'project')) {
2178 print
'<td id="project-task-input-container" >';
2180 $urloption =
'?action=create&donotclearsession=1';
2181 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2184 print
"\n".
'<script type="text/javascript" >';
2185 print
'$(document).ready(function () {
2186 $("#projectid").change(function () {
2187 var url = "'.$url.
'&projectid="+$("#projectid").val();
2188 $.get(url, function(data) {
2189 console.log($( data ).find("#fk_element").html());
2190 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2194 print
'</script>'.
"\n";
2196 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1),
$object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500',
$object->fk_project);
2197 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2203 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2204 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2212 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2214 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2215 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2216 $doleditor->Create();
2220 $parameters = array();
2221 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2222 print $hookmanager->resPrint;
2223 if (empty($reshook)) {
2224 print
$object->showOptionals($extrafields,
'edit', $parameters);
2231 $filteruserid = $user->id;
2232 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2235 $object->loadReminders(
'', $filteruserid,
false);
2239 if (count(
$object->reminders) > 0) {
2240 $checked =
'checked';
2241 $keys = array_keys(
$object->reminders);
2242 $firstreminderId = array_shift($keys);
2244 $actionCommReminder =
$object->reminders[$firstreminderId];
2248 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2249 $actionCommReminder->offsetunit =
'i';
2250 $actionCommReminder->typeremind =
'email';
2257 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>';
2259 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2263 print
'<table class="border centpercent">';
2266 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2267 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2268 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2272 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2273 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2277 if ($actionCommReminder->typeremind ==
'browser') {
2278 $hide =
'style="display:none;"';
2283 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2284 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, $actionCommReminder->fk_email_template);
2290 print
"\n".
'<script type="text/javascript">';
2291 print
'$(document).ready(function () {
2292 $("#addreminder").click(function(){
2294 $(".reminderparameters").show();
2296 $(".reminderparameters").hide();
2300 $("#selectremindertype").change(function(){
2301 var selected_option = $("#selectremindertype option:selected").val();
2302 if(selected_option == "email") {
2303 $("#select_actioncommsendmodel_mail").closest("tr").show();
2305 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2310 print
'</script>'.
"\n";
2312 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
2315 $reminderDefaultEmailModel =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
2317 print
"\n".
'<script type="text/javascript">';
2318 print
'$(document).ready(function () {
2319 const reminderDefaultEventTypes = '.$reminderDefaultEventTypes.
';
2320 $("#actioncode").change(function(){
2321 var selected_event_type = $("#actioncode option:selected").val();
2323 if (reminderDefaultEventTypes.includes(selected_event_type)) {
2324 $(".reminderparameters").show();
2325 $("#addreminder").prop("checked", true);
2327 // Set period with default reminder period
2328 $("#offsetvalue").val('.$reminderDefaultOffset.
');
2329 $("#select_offsetunittype_duration").select2("destroy");
2330 $("#select_offsetunittype_duration").val("'.$reminderDefaultUnit.
'");
2331 $("#select_offsetunittype_duration").select2();
2333 $("#selectremindertype").select2("destroy");
2334 $("#selectremindertype").val("email");
2335 $("#selectremindertype").select2();
2337 // Set default reminder mail model
2338 $("#select_actioncommsendmodel_mail").closest("tr").show();
2339 $("#select_actioncommsendmodel_mail").select2("destroy");
2340 $("#select_actioncommsendmodel_mail").val("'.$reminderDefaultEmailModel.
'");
2341 $("#select_actioncommsendmodel_mail").select2();
2345 print
'</script>'.
"\n";
2351 print $form->buttonsSaveCancel();
2360 if ($action ==
'clone') {
2361 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent',
$object->label),
'confirm_clone', array(),
'yes', 1);
2365 $parameters = array();
2366 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2367 if (empty($reshook)) {
2368 $formconfirm .= $hookmanager->resPrint;
2369 } elseif ($reshook > 0) {
2370 $formconfirm = $hookmanager->resPrint;
2378 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
2379 $linkback .=
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="pictoactionview pictofixedwidth"');
2380 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"BackToList").
'</span>';
2381 $linkback .=
'</a>';
2382 $linkback .=
'</li>';
2383 $linkback .=
'<li class="noborder litext">';
2385 $linkback .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview pictofixedwidth"');
2386 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span>';
2387 $linkback .=
'</a>';
2388 $linkback .=
'</li>';
2389 $linkback .=
'<li class="noborder litext">';
2391 $linkback .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview pictofixedwidth"');
2392 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span>';
2393 $linkback .=
'</a>';
2394 $linkback .=
'</li>';
2395 $linkback .=
'<li class="noborder litext">';
2397 $linkback .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview pictofixedwidth"');
2398 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span>';
2399 $linkback .=
'</a>';
2400 $linkback .=
'</li>';
2401 $linkback .=
'<li class="noborder litext">';
2403 $linkback .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview pictofixedwidth"');
2404 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span>';
2405 $linkback .=
'</a>';
2408 $parameters = array();
2409 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters,
$object, $action);
2410 if (empty($reshook)) {
2411 $linkback .= $hookmanager->resPrint;
2412 } elseif ($reshook > 1) {
2413 $linkback = $hookmanager->resPrint;
2418 $morehtmlref =
'<div class="refidno">';
2422 if (isModEnabled(
'project')) {
2423 $langs->load(
"projects");
2425 if ($usercancreate) {
2426 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2427 if ($action !=
'classify') {
2428 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2430 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2432 if (!empty(
$object->fk_project)) {
2434 $proj->fetch(
$object->fk_project);
2435 $morehtmlref .= $proj->getNomUrl(1);
2437 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2442 $morehtmlref .=
'</div>';
2445 dol_banner_tab(
$object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
2447 print
'<div class="fichecenter">';
2448 print
'<div class="fichehalfleft">';
2450 print
'<div class="underbanner clearboth"></div>';
2453 print
'<table class="border tableforfield centpercent">';
2457 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2458 $labeltype = ($langs->transnoentities(
"Action".
$object->type_code) !=
"Action".$object->type_code) ? $langs->transnoentities(
"Action".$object->type_code) :
$object->type_label;
2459 $labeltoshow = $labeltype;
2461 $labeltoshow .=
' ('.$object->code.
')';
2463 print
$object->getTypePicto(
'pictofixedwidth paddingright', $labeltoshow);
2469 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn(
$object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2473 print
'<tr><td class="titlefield">'.$langs->trans(
"EventIntoASerie").
'</td><td>'.
dol_escape_htmltag(
$object->recurid).
'</td></tr>';
2482 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2487 if (empty(
$object->fulldayevent)) {
2500 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2501 if (empty(
$object->fulldayevent)) {
2514 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.
$object->location.
'</td></tr>';
2518 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2519 $listofuserid = array();
2520 if (empty($donotclearsession)) {
2521 if (
$object->userownerid > 0) {
2522 $listofuserid[
$object->userownerid] = array(
2524 'transparency' =>
$object->transparency,
2525 'answer_status' =>
$object->userassigned[
$object->userownerid][
'answer_status'],
2526 'mandatory' =>
$object->userassigned[
$object->userownerid][
'mandatory']
2529 if (!empty(
$object->userassigned)) {
2531 $tmplist1 =
$object->userassigned;
2532 foreach ($tmplist1 as $key => $val) {
2533 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2534 $listofuserid[$val[
'id']] = $val;
2538 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2540 if (!empty($_SESSION[
'assignedtouser'])) {
2541 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2545 $listofcontactid = array();
2546 $listofotherid = array();
2547 print
'<div class="assignedtouser">';
2548 print $form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', (
$object->datep !=
$object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2558 print
' </td></tr>';
2561 if (isModEnabled(
'category')) {
2562 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2563 print $form->showCategories(
$object->id, Categorie::TYPE_ACTIONCOMM, 1);
2571 print
'<div class="fichehalfright">';
2573 print
'<div class="underbanner clearboth"></div>';
2574 print
'<table class="border tableforfield centpercent">';
2576 if (isModEnabled(
"societe")) {
2578 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td>';
2579 print
'<td>'.(is_object(
$object->thirdparty) &&
$object->thirdparty->id ?
$object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2580 if (is_object(
$object->thirdparty) &&
$object->thirdparty->id > 0 &&
$object->type_code ==
'AC_TEL') {
2582 print
"<br>".dol_print_phone(
$object->thirdparty->phone);
2588 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2591 if (!empty(
$object->socpeopleassigned)) {
2592 foreach (
$object->socpeopleassigned as $cid => $Tab) {
2594 $result = $contact->fetch($cid);
2601 print $contact->getNomUrl(1);
2602 if (
$object->type_code ==
'AC_TEL') {
2603 if (!empty($contact->phone_pro)) {
2604 print
'('.dol_print_phone($contact->phone_pro).
')';
2607 print
'<div class="paddingright"></div>';
2611 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2618 print
'<tr><td class="nowrap" class="titlefield">' . $langs->trans(
"Priority") .
'</td><td>';
2625 if (!empty(
$object->fk_element) && !empty(
$object->elementtype) && !in_array(
$object->elementtype, array(
'societe',
'contact',
'project'))) {
2626 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2627 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2631 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2639 if (!empty(
$object->email_msgid)) {
2640 print
'<tr><td>'.$langs->trans(
'MailTopic').
'</td>';
2641 print
'<td>'.dol_escape_htmltag(
$object->email_subject).
'</td></tr>';
2642 print
'<tr><td>'.$langs->trans(
'MailFrom').
'</td>';
2643 print
'<td>'.dol_escape_htmltag(
$object->email_from).
'</td></tr>';
2644 print
'<tr><td>'.$langs->trans(
'MailTo').
'</td>';
2645 print
'<td>'.dol_escape_htmltag(
$object->email_to).
'</td></tr>';
2646 if (!empty(
$object->email_tocc)) {
2647 print
'<tr><td>'.$langs->trans(
'MailCC').
'</td>';
2648 print
'<td>'.dol_escape_htmltag(
$object->email_tocc).
'</td></tr>';
2653 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak sensiblehtmlcontent">';
2658 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2662 $filteruserid = $user->id;
2663 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2666 $object->loadReminders(
'', $filteruserid,
false);
2668 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2670 if (count(
$object->reminders) > 0) {
2671 $tmpuserstatic =
new User($db);
2673 foreach (
$object->reminders as $actioncommreminderid => $actioncommreminder) {
2674 print $TRemindTypes[$actioncommreminder->typeremind][
'label'];
2675 if ($actioncommreminder->fk_user > 0) {
2676 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2677 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2679 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2681 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2682 print
' - <span class="opacitymedium">';
2683 print $langs->trans(
"NotSent");
2685 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2686 print
' - <span class="opacitymedium">';
2687 print $langs->trans(
"Done");
2689 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2690 print
' - <span class="opacitymedium">';
2691 print $form->textwithpicto($langs->trans(
"Error"), $actioncommreminder->lasterror);
2705 print
'<div class="clearboth"></div>';
2714 print
'<div class="tabsAction">';
2716 $parameters = array();
2717 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
2718 if (empty($reshook)) {
2719 if ($action !=
'edit') {
2720 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2721 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2722 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2724 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2727 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2728 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2729 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>';
2731 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2734 if ($user->hasRight(
'agenda',
'allactions',
'delete') ||
2735 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'))) {
2736 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2738 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2745 if ($action !=
'edit') {
2747 print
'<div class="clearboth"></div><div class="fichecenter"><div class="fichehalfleft">';
2748 print
'<a name="builddoc"></a>';
2754 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.
$object->id;
2755 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2757 $genallowed = $user->hasRight(
'agenda',
'myactions',
'read');
2758 $delallowed = $user->hasRight(
'agenda',
'myactions',
'create');
2761 print $formfile->showdocuments(
'actions',
$object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2763 print
'</div><div class="fichehalfright">';
2766 print
'</div></div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
actions_prepare_head($object)
Prepare array with list of tabs.
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 projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
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...
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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
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_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0, $allowscript=0, $allowstyle=0)
Clean a string to keep only desirable HTML tags.
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_get_fiche_end($notab=0)
Return tab footer of a card.
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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
yn($yesno, $format=1, $color=0)
Return yes or no in current language.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.