35require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/agenda.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncommreminder.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/cactioncomm.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
62$langs->loadLangs(array(
"companies",
"other",
"commercial",
"bills",
"orders",
"agenda",
"mails"));
65$action =
GETPOST(
'action',
'aZ09');
66$cancel =
GETPOST(
'cancel',
'alpha');
67$backtopage =
GETPOST(
'backtopage',
'alpha');
68$socpeopleassigned =
GETPOST(
'socpeopleassigned',
'array');
69$origin =
GETPOST(
'origin',
'alpha');
71$confirm =
GETPOST(
'confirm',
'alpha');
73$fulldayevent =
GETPOST(
'fullday',
'alpha');
80$addreminder =
GETPOST(
'addreminder',
'alpha');
82$offsetunit =
GETPOST(
'offsetunittype_duration',
'aZ09');
83$remindertype =
GETPOST(
'selectremindertype',
'aZ09');
84$modelmail =
GETPOSTINT(
'actioncommsendmodel_mail');
85$complete =
GETPOST(
'complete',
'alpha');
86$private =
GETPOST(
'private',
'alphanohtml');
87if ($complete ==
'na' || $complete == -2) {
104 if (
GETPOST(
'datep') ==
'now') {
106 } elseif (preg_match(
'/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',
GETPOST(
"datep"), $reg)) {
107 $datep =
dol_mktime(0, 0, 0, (
int) $reg[2], (
int) $reg[3], (
int) $reg[1],
'tzuserrel');
114if ($user->socid && ($socid != $user->socid)) {
119$donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
128$form =
new Form($db);
133if ($id > 0 && $action !=
'add') {
137 $ret =
$object->fetch_optionals();
138 $ret1 =
$object->fetch_userassigned();
140 if ($ret < 0 || $ret1 < 0) {
146$extrafields->fetch_name_optionals_label(
$object->table_element);
149$hookmanager->initHooks(array(
'actioncard',
'globalcard'));
151$parameters = array(
'socid' => $socid);
152$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
157$TRemindTypes = array();
159 $TRemindTypes[
'browser'] = array(
'label' => $langs->trans(
'BrowserPush'),
'disabled' => (
getDolGlobalString(
'AGENDA_REMINDER_BROWSER') ? 0 : 1));
162 $TRemindTypes[
'email'] = array(
'label' => $langs->trans(
'EMail'),
'disabled' => (
getDolGlobalString(
'AGENDA_REMINDER_EMAIL') ? 0 : 1));
165$TDurationTypes = array(
'y' => $langs->trans(
'Years'),
'm' => $langs->trans(
'Month'),
'w' => $langs->trans(
'Weeks'),
'd' => $langs->trans(
'Days'),
'h' => $langs->trans(
'Hours'),
'i' => $langs->trans(
'Minutes'));
167$result =
restrictedArea($user,
'agenda',
$object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
169$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || ((empty(
$object->id) ||
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
176$listUserAssignedUpdated =
false;
177$listResourceAssignedUpdated =
false;
178$assignedtouser = array();
181if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
182 $idtoremove =
GETPOST(
'removedassigned');
184 if (!empty($_SESSION[
'assignedtouser'])) {
185 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'],
true);
187 $tmpassigneduserids = array();
190 foreach ($tmpassigneduserids as $key => $val) {
191 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
192 unset($tmpassigneduserids[$key]);
196 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
197 $donotclearsession = 1;
198 if ($action ==
'add') {
201 if ($action ==
'update') {
205 $listUserAssignedUpdated =
true;
208if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
209 $idtoremove =
GETPOST(
'removedassignedresource');
211 if (!empty($_SESSION[
'assignedtoresource'])) {
212 $tmpassignedresourceids = json_decode($_SESSION[
'assignedtoresource'],
true);
214 $tmpassignedresourceids = array();
217 foreach ($tmpassignedresourceids as $key => $val) {
218 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
219 unset($tmpassignedresourceids[$key]);
223 $_SESSION[
'assignedtoresource'] = json_encode($tmpassignedresourceids);
224 $donotclearsessionresource = 1;
225 if ($action ==
'add' && $usercancreate) {
228 if ($action ==
'update' && $usercancreate) {
232 $listResourceAssignedUpdated =
true;
236if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
238 if (
GETPOST(
'assignedtouser') > 0) {
239 $assignedtouser = array();
240 if (!empty($_SESSION[
'assignedtouser'])) {
241 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
243 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id' =>
GETPOSTINT(
'assignedtouser'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
244 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
246 $donotclearsession = 1;
247 if ($action ==
'add' && $usercancreate) {
250 if ($action ==
'update' && $usercancreate) {
254 $listUserAssignedUpdated =
true;
258if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
260 if (
GETPOST(
'assignedtoresource') > 0) {
261 $assignedtoresource = array();
262 if (!empty($_SESSION[
'assignedtoresource'])) {
263 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
265 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id' =>
GETPOSTINT(
'assignedtoresource'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
266 $_SESSION[
'assignedtoresource'] = json_encode($assignedtoresource);
268 $donotclearsession = 1;
269 if ($action ==
'add' && $usercancreate) {
272 if ($action ==
'update' && $usercancreate) {
276 $listResourceAssignedUpdated =
true;
280if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
281 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
287if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
288 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
293 if (!empty(
$object->socpeopleassigned)) {
294 reset(
$object->socpeopleassigned);
299 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
310if (empty($reshook) && $action ==
'add' && $usercancreate) {
313 if (empty($backtopage)) {
315 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
317 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
321 if (!empty($socpeopleassigned[0])) {
322 $result = $contact->fetch($socpeopleassigned[0]);
326 header(
"Location: ".$backtopage);
330 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
343 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
346 if (!$datef && $percentage == 100) {
348 $donotclearsession = 1;
350 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
355 $donotclearsession = 1;
357 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
361 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
363 $donotclearsession = 1;
365 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
370 $listofresourceid = array();
375 $object->fulldayevent = ($fulldayevent ? 1 : 0);
379 if (
GETPOST(
"elementtype",
'alpha')) {
381 $modulecodetouseforpermissioncheck = $elProp[
'module'];
382 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
384 $hasPermissionOnLinkedObject = 0;
385 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
386 $hasPermissionOnLinkedObject = 1;
387 } elseif ($user->hasRight($modulecodetouseforpermissioncheck, $submodulecodetouseforpermissioncheck,
'read')) {
388 $hasPermissionOnLinkedObject = 1;
391 if ($hasPermissionOnLinkedObject) {
399 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
400 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
402 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
403 $object->label = $langs->transnoentitiesnoconv(
"Action".
$object->type_code).
"\n";
405 $cactioncomm->fetch(
$object->type_code);
406 $object->label = $cactioncomm->label;
413 if (!empty($taskid)) {
414 $taskProject =
new Task($db);
415 if ($taskProject->fetch($taskid) > 0) {
416 $object->fk_project = $taskProject->fk_project;
426 $object->percentage = $percentage;
429 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
431 $listofuserid = array();
432 if (!empty($_SESSION[
'assignedtouser'])) {
433 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
436 if (!empty($_SESSION[
'assignedtoresource'])) {
437 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
441 foreach ($listofuserid as $key => $value) {
443 if ($value[
'id'] > 0) {
444 $object->userownerid = $value[
'id'];
446 $object->transparency = $transparency;
449 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
457 if (GETPOSTISSET(
"contactid")) {
471 if (empty(
$object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
473 $donotclearsession = 1;
475 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
477 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
479 $donotclearsession = 1;
481 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
486 $donotclearsession = 1;
488 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
491 foreach ($socpeopleassigned as $cid) {
492 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
494 if (!empty(
$object->socpeopleassigned)) {
495 reset(
$object->socpeopleassigned);
500 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
503 $donotclearsession = 1;
512 $selectedrecurrulefreq =
'no';
513 $selectedrecurrulebymonthday =
'';
514 $selectedrecurrulebyday =
'';
515 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
516 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY' && GETPOSTISSET(
'BYMONTHDAY')) ?
"_BYMONTHDAY".
GETPOST(
'BYMONTHDAY',
'alpha') :
"";
517 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY' && GETPOSTISSET(
'BYDAY')) ?
"_BYDAY".
GETPOST(
'BYDAY',
'alpha') :
"";
522 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
523 $selectedrecurrulefreq = $reg1[1];
525 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
526 $selectedrecurrulebymonthday = (int) $reg2[1];
528 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
529 $selectedrecurrulebyday = (int) $reg3[1];
533 $eventisrecurring = 0;
534 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 2 ? 1 : 0);
535 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
536 $eventisrecurring = 1;
546 $idaction =
$object->create($user);
551 if (is_array($listofresourceid) && count($listofresourceid)) {
552 foreach ($listofresourceid as $resource_id => $val) {
553 $resource_type =
'dolresource';
558 $eventDateStart =
$object->datep;
559 $eventDateEnd =
$object->datef;
560 $isFullDayEvent =
$object->fulldayevent;
561 if (empty($eventDateEnd)) {
562 if ($isFullDayEvent) {
564 $eventDateStart =
dol_mktime(0, 0, 0, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
565 $eventDateEnd =
dol_mktime(23, 59, 59, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
569 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
570 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_resources as er";
571 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) .
"'";
572 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape(
$object->element) .
"'";
573 $sql .=
" WHERE er.resource_id = " . ((int) $resource_id);
574 $sql .=
" AND er.busy = 1";
578 $sql .=
" (ac.datep <= '" . $db->idate($eventDateStart) .
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) .
"'))";
580 if (!empty($eventDateEnd)) {
581 $sql .=
" OR (ac.datep <= '" . $db->idate($eventDateEnd) .
"' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) .
"'))";
585 $sql .=
"ac.datep >= '" . $db->idate($eventDateStart) .
"'";
586 if (!empty($eventDateEnd)) {
587 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) .
"')";
592 $resql = $db->query($sql);
595 $object->error = $db->lasterror();
598 if ($db->num_rows($resql) > 0) {
601 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse') .
' : ';
602 while ($obj = $db->fetch_object($resql)) {
603 $object->error .=
'<br> - ' . $langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label .
' [' . $obj->ac_id .
']');
612 $res =
$object->add_element_resource($resource_id, $resource_type, $busy, $val[
'mandatory']);
617 unset($_SESSION[
'assignedtoresource']);
620 $categories =
GETPOST(
'categories',
'array');
621 $object->setCategories($categories);
623 unset($_SESSION[
'assignedtouser']);
625 if ($user->id !=
$object->userownerid) {
626 $moreparam =
"filtert=-1";
630 if ($addreminder ==
'on') {
635 $actionCommReminder->dateremind = $dateremind;
636 $actionCommReminder->typeremind = $remindertype;
637 $actionCommReminder->offsetunit = $offsetunit;
638 $actionCommReminder->offsetvalue = $offsetvalue;
639 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
640 $actionCommReminder->fk_actioncomm =
$object->id;
641 if ($remindertype ==
'email') {
642 $actionCommReminder->fk_email_template = $modelmail;
646 foreach (
$object->userassigned as $userassigned) {
647 $actionCommReminder->fk_user = $userassigned[
'id'];
648 $res = $actionCommReminder->create($user);
653 $langs->load(
"errors");
654 $error = $langs->trans(
'ErrorReminderActionCommCreation');
657 $donotclearsession = 1;
668 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
688 $langs->load(
"errors");
689 $error = $langs->trans(
$object->error);
692 $donotclearsession = 1;
698 $donotclearsession = 1;
701 if ($eventisrecurring) {
705 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
707 $datep =
dol_mktime($fulldayevent ? 0 :
GETPOSTINT(
"aphour"), $fulldayevent ? 0 :
GETPOSTINT(
"apmin"), $fulldayevent ? 0 :
GETPOSTINT(
"apsec"), $firstdatearray[
'month'], $firstdatearray[
'first_day'], $firstdatearray[
'year'], $tzforfullday ? $tzforfullday :
'tzuserrel');
711 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
712 $firstday = $selectedrecurrulebymonthday;
721 $repeateventlimitdate =
dol_mktime(23, 59, 59, GETPOSTISSET(
"limitmonth") ?
GETPOSTINT(
"limitmonth") : 1, GETPOSTISSET(
"limitday") ?
GETPOSTINT(
"limitday") : 1, GETPOSTISSET(
"limityear") &&
GETPOSTINT(
"limityear") < 2100 ?
GETPOSTINT(
"limityear") : 2100, $tzforfullday ? $tzforfullday :
'tzuserrel');
727 while ($datep <= $repeateventlimitdate && !$error) {
731 $finalobject->datep = $datep;
732 $finalobject->datef = $datef;
734 $idaction = $finalobject->create($user);
737 if (!$finalobject->error) {
739 $categories =
GETPOST(
'categories',
'array');
740 $finalobject->setCategories($categories);
742 unset($_SESSION[
'assignedtouser']);
745 if ($user->id != $finalobject->userownerid) {
746 $moreparam =
"filtert=-1";
750 if ($addreminder ==
'on') {
755 $actionCommReminder->dateremind = $dateremind;
756 $actionCommReminder->typeremind = $remindertype;
757 $actionCommReminder->offsetunit = $offsetunit;
758 $actionCommReminder->offsetvalue = $offsetvalue;
759 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
760 $actionCommReminder->fk_actioncomm = $finalobject->id;
761 if ($remindertype ==
'email') {
762 $actionCommReminder->fk_email_template = $modelmail;
766 foreach ($finalobject->userassigned as $userassigned) {
767 $actionCommReminder->fk_user = $userassigned[
'id'];
768 $res = $actionCommReminder->create($user);
773 $langs->load(
"errors");
774 $error = $langs->trans(
'ErrorReminderActionCommCreation');
777 $donotclearsession = 1;
788 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
798 $langs->load(
"errors");
799 $error = $langs->trans($finalobject->error);
802 $donotclearsession = 1;
808 $donotclearsession = 1;
812 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
823 if (!empty($backtopage) && !$error) {
824 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
825 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
826 } elseif ($idaction) {
827 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
829 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
836if (empty($reshook) && $action ==
'update' && $usercancreate) {
837 if (empty($cancel)) {
838 $fulldayevent =
GETPOST(
'fullday');
843 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
875 $datef = (!$datef && $percentage == 100) ?
dol_now() : $datef;
877 if (
$object->elementtype ==
'ticket') {
879 if (
$object->code ==
'TICKET_MSG') {
880 $object->code =
'TICKET_MSG_PRIVATE';
882 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
883 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
886 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
889 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
890 $object->code =
'TICKET_MSG_SENTBYMAIL';
902 $object->percentage = $percentage;
907 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
908 $object->socpeopleassigned = array();
909 foreach ($socpeopleassigned as $cid) {
910 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
913 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
914 reset(
$object->socpeopleassigned);
920 if (
GETPOST(
"elementtype",
'alpha')) {
922 $modulecodetouseforpermissioncheck = $elProp[
'module'];
924 $hasPermissionOnLinkedObject = 0;
925 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
926 $hasPermissionOnLinkedObject = 1;
928 if ($hasPermissionOnLinkedObject) {
936 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
939 $listofuserid = array();
940 if (!empty($_SESSION[
'assignedtouser'])) {
942 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
943 foreach ($tmplist1 as $key => $val) {
944 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
945 $listofuserid[$val[
'id']] = $val;
949 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
950 if ($assignedtouser) {
951 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
954 $object->userassigned = array();
957 foreach ($listofuserid as $key => $val) {
959 $object->userownerid = $val[
'id'];
961 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
965 $object->transparency = $transparency;
969 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
971 $donotclearsession = 1;
973 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
975 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
977 if (empty(
$object->userownerid)) {
979 $donotclearsession = 1;
981 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
985 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
993 $eventDateStart =
$object->datep;
994 $eventDateEnd =
$object->datef;
996 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
997 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
998 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
999 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1000 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1001 $sql .=
" AND er.resource_id IN (";
1002 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1003 $sql .=
" WHERE element_id = ".((int)
$object->id);
1004 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1005 $sql .=
" AND busy = 1";
1007 $sql .=
" AND er.busy = 1";
1011 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1013 if (!empty($eventDateEnd)) {
1014 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1018 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1019 if (!empty($eventDateEnd)) {
1020 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1025 $resql = $db->query($sql);
1028 $object->error = $db->lasterror();
1031 if ($db->num_rows($resql) > 0) {
1034 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1035 while ($obj = $db->fetch_object($resql)) {
1036 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1052 $result =
$object->update($user);
1056 $categories =
GETPOST(
'categories',
'array');
1057 $object->setCategories($categories);
1059 $object->loadReminders($remindertype, 0,
false);
1062 if (!empty(
$object->reminders)) {
1063 foreach (
$object->reminders as $reminder) {
1064 if ($reminder->status < 1) {
1065 $reminder->delete($user);
1072 if ($addreminder ==
'on') {
1077 $actionCommReminder->dateremind = $dateremind;
1078 $actionCommReminder->typeremind = $remindertype;
1079 $actionCommReminder->offsetunit = $offsetunit;
1080 $actionCommReminder->offsetvalue = $offsetvalue;
1081 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
1082 $actionCommReminder->fk_actioncomm =
$object->id;
1083 if ($remindertype ==
'email') {
1084 $actionCommReminder->fk_email_template = $modelmail;
1088 foreach (
$object->userassigned as $userassigned) {
1089 $actionCommReminder->fk_user = $userassigned[
'id'];
1093 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1094 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".$db->escape($remindertype).
"'";
1095 $resqldelete = $db->query($sqldelete);
1097 $res = $actionCommReminder->create($user);
1101 $langs->load(
"errors");
1102 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1105 $donotclearsession = 1;
1112 unset($_SESSION[
'assignedtouser']);
1113 unset($_SESSION[
'assignedtoresource']);
1128 if (!empty($backtopage)) {
1129 unset($_SESSION[
'assignedtouser']);
1130 header(
"Location: ".$backtopage);
1137if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
1140 $object->fetch_userassigned();
1143 if ($user->hasRight(
'agenda',
'myactions',
'delete')
1144 || $user->hasRight(
'agenda',
'allactions',
'delete')) {
1145 $result =
$object->delete($user);
1148 header(
"Location: index.php");
1160if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
1166 $newdate =
GETPOST(
'newdate',
'alpha');
1167 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1168 header(
"Location: ".$backtopage,
true, 307);
1172 $datep =
dol_mktime($shour, $smin, 0, (
int) substr($newdate, 13, 2), (
int) substr($newdate, 15, 2), (
int) substr($newdate, 9, 4),
'tzuserrel');
1175 if ($datep !=
$object->datep) {
1184 $eventDateStart =
$object->datep;
1185 $eventDateEnd =
$object->datef;
1187 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1188 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1189 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1190 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1191 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1192 $sql .=
" AND er.resource_id IN (";
1193 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1194 $sql .=
" WHERE element_id = ".((int)
$object->id);
1195 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1196 $sql .=
" AND busy = 1";
1198 $sql .=
" AND er.busy = 1";
1202 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1204 if (!empty($eventDateEnd)) {
1205 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1209 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1210 if (!empty($eventDateEnd)) {
1211 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1216 $resql = $db->query($sql);
1219 $object->error = $db->lasterror();
1222 if ($db->num_rows($resql) > 0) {
1225 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1226 while ($obj = $db->fetch_object($resql)) {
1227 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1242 $result =
$object->update($user);
1252 if (!empty($backtopage)) {
1253 header(
"Location: ".$backtopage,
true, 307);
1262$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1263if (empty($reshook)) {
1264 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1272$form =
new Form($db);
1275$arrayrecurrulefreq = array(
1276 'no' => $langs->trans(
"OnceOnly"),
1277 'MONTHLY' => $langs->trans(
"EveryMonth"),
1278 'WEEKLY' => $langs->trans(
"EveryWeek")
1283$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1284llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1286if ($action ==
'create') {
1289 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1290 if (!empty($socpeopleassigned[0])) {
1291 $result = $contact->fetch($socpeopleassigned[0]);
1299 if (!empty(
$conf->use_javascript_ajax)) {
1300 print
"\n".
'<script type="text/javascript">';
1301 print
'$(document).ready(function () {
1302 function setdatefields()
1304 if ($("#fullday:checked").val() == null) {
1305 $(".fulldaystarthour").removeAttr("disabled");
1306 $(".fulldaystartmin").removeAttr("disabled");
1307 $(".fulldayendhour").removeAttr("disabled");
1308 $(".fulldayendmin").removeAttr("disabled");
1309 $("#p2").removeAttr("disabled");
1311 $(".fulldaystarthour").prop("disabled", true).val("00");
1312 $(".fulldaystartmin").prop("disabled", true).val("00");
1313 $(".fulldayendhour").prop("disabled", true).val("23");
1314 $(".fulldayendmin").prop("disabled", true).val("59");
1315 $("#p2").removeAttr("disabled");
1318 $("#fullday").change(function() {
1319 console.log("setdatefields");
1322 var old_startdate = null;
1323 $("#ap").focus(function() {
1324 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1326 $("#ap").next(".ui-datepicker-trigger").click(function() {
1327 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1329 $("#ap").change(function() {
1330 setTimeout(function() {
1331 if ($("#p2").val() !== "") {
1332 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1333 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1334 if (new_startdate > old_enddate) {
1335 var timeDiff = old_enddate - old_startdate;
1336 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1337 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1338 $("#p2day").val(new_enddate.getDate());
1339 $("#p2month").val(new_enddate.getMonth() + 1);
1340 $("#p2year").val(new_enddate.getFullYear());
1345 $("#actioncode").change(function() {
1346 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1347 else $("#dateend").removeClass("fieldrequired");
1349 $("#aphour,#apmin").change(function() {
1350 if ($("#actioncode").val() == \'AC_RDV\') {
1351 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1352 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1353 $("#p2min").val($("#apmin").val());
1354 $("#p2day").val($("#apday").val());
1355 $("#p2month").val($("#apmonth").val());
1356 $("#p2year").val($("#apyear").val());
1357 $("#p2").val($("#ap").val());
1360 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1361 else $("#dateend").removeClass("fieldrequired");
1364 print
'</script>'.
"\n";
1367 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1368 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1369 print
'<input type="hidden" name="action" value="add">';
1370 print
'<input type="hidden" name="donotclearsession" value="1">';
1371 print
'<input type="hidden" name="page_y" value="">';
1373 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1376 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1379 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1380 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1387 print
'<table class="border centpercent nobottom">';
1391 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1393 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1394 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1395 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1400 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>';
1403 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1404 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>';
1407 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1408 if (
GETPOST(
'datep',
'alpha', 1)) {
1411 $datef = ($datef ? $datef :
$object->datef);
1412 if (
GETPOST(
'datef',
'alpha', 1)) {
1415 if (empty($datef) && !empty($datep)) {
1422 print
'<tr><td class="nowrap">';
1425 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1427 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1429 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1430 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1433 print
'<tr><td></td><td>';
1435 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0);
1436 if ($userepeatevent) {
1439 print
'<div class="opacitymedium inline-block small">';
1440 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 6px" class="paddingright2"');
1441 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1443 $selectedrecurrulefreq =
'no';
1444 $selectedrecurrulebymonthday =
'';
1445 $selectedrecurrulebyday =
'';
1446 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1447 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1448 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1452 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1453 $selectedrecurrulefreq = $reg[1];
1455 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1456 $selectedrecurrulebymonthday = (int) $reg[1];
1458 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1459 $selectedrecurrulebyday = (int) $reg[1];
1462 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1468 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1469 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1472 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1473 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1476 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1477 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1478 print $langs->trans(
"Until").
" ";
1479 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1482 print
'<script type="text/javascript">
1483 jQuery(document).ready(function() {
1484 function init_repeat()
1486 console.log("recurrule: " + "'.$object->recurrule.
'");
1487 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1488 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1489 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1490 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1491 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1493 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1494 jQuery(".repeateventlimitdate").css("display", "inline-block");
1495 jQuery(".repeateventBYDAY").hide();
1497 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1499 jQuery(".repeateventBYMONTHDAY").hide();
1500 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1501 jQuery(".repeateventlimitdate").css("display", "inline-block");
1505 jQuery(".repeateventBYMONTHDAY").hide();
1506 jQuery(".repeateventBYDAY").hide();
1507 jQuery(".repeateventlimitdate").hide();
1511 jQuery("#recurrulefreq").change(function() {
1521 print
'<tr><td class=""> </td><td></td></tr>';
1524 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1525 $listofuserid = array();
1526 $listofcontactid = array();
1527 $listofotherid = array();
1529 if (empty($donotclearsession)) {
1531 if ($assignedtouser) {
1532 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1535 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1536 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1538 if (!empty($_SESSION[
'assignedtouser'])) {
1539 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1541 if (!is_array($listofuserid)) {
1542 $listofuserid = array();
1544 $firstelem = reset($listofuserid);
1545 if (isset($listofuserid[$firstelem[
'id']])) {
1546 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1549 print
'<div class="assignedtouser">';
1550 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, array(), 0,
'', array(), 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1556 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>';
1559 if (isModEnabled(
'category')) {
1561 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1562 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
1563 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'), 0, 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1567 if (isModEnabled(
'resource')) {
1569 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1571 $listofresourceid = array();
1572 if (empty($donotclearsession)) {
1573 $assignedtoresource =
GETPOST(
"assignedtoresource");
1574 if ($assignedtoresource) {
1575 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1577 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1579 if (!empty($_SESSION[
'assignedtoresource'])) {
1580 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1582 if (!is_array($listofresourceid)) {
1583 $listofresourceid = array();
1585 $firstelem = reset($listofresourceid);
1586 if (isset($listofresourceid[$firstelem[
'id']])) {
1587 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1590 print
'<div class="assignedtoresource">';
1591 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1, array(), 0,
'', array(), 0, 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1597 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1599 $percent = $complete !==
'' ? $complete : -1;
1600 if (GETPOSTISSET(
'status')) {
1602 } elseif (GETPOSTISSET(
'percentage')) {
1605 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1607 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1611 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1617 print
'<br><hr><br>';
1620 print
'<table class="border centpercent nobottom">';
1622 if (isModEnabled(
"societe")) {
1624 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1628 print $societe->getNomUrl(1);
1629 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1632 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1634 if (!empty($user->socid)) {
1635 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1637 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'', $langs->trans(
'SelectThirdParty'), 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1643 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1644 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1648 if ($origin ==
'contact') {
1654 $select_contact_default = 0;
1656 $select_contact_default = -1;
1658 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1667 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1668 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, array(),
'multiple',
'contactid');
1669 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1671 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, 0, array(),
'multiple',
'contactid');
1678 if (isModEnabled(
'project')) {
1679 $langs->load(
"projects");
1683 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1684 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1685 print $formproject->select_projects((
$object->socid > 0 ?
$object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx maxwidth500');
1687 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1688 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1689 $urloption =
'?action=create&donotclearsession=1';
1693 print
"\n".
'<script type="text/javascript">';
1694 print
'$(document).ready(function () {
1695 $("#projectid").change(function () {
1696 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1697 console.log("Call url to get new list of tasks: "+url);
1698 $.get(url, function(data) {
1700 if (data) $("#taskid").html(data).select2();
1704 print
'</script>'.
"\n";
1709 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1710 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1711 $projectsListId =
false;
1712 if (!empty($projectid)) {
1713 $projectsListId = $projectid;
1716 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1718 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', $projectsListId);
1723 if (!empty($origin) && !empty($originid)) {
1724 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1726 $hasPermissionOnLinkedObject = 0;
1729 if ($user->hasRight($elProp[
'module'],
'read') || $user->hasRight($elProp[
'module'], $elProp[
'element'],
'read')) {
1730 $hasPermissionOnLinkedObject = 1;
1734 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1736 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1737 print
'<td colspan="3">';
1738 if ($hasPermissionOnLinkedObject) {
1740 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1741 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1742 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1743 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1745 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1753 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1754 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1759 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1760 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1761 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 120,
'dolibarr_notes',
'In', true, true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1762 $doleditor->Create();
1766 $parameters = array();
1767 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1768 print $hookmanager->resPrint;
1769 if (empty($reshook)) {
1770 print
$object->showOptionals($extrafields,
'create', $parameters);
1780 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1782 print
'<div class="reminderparameters" style="display: none;">';
1784 print
'<table class="border centpercent">';
1787 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1788 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1789 print $form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1793 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1794 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1799 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1800 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1807 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
1808 $reminderDefaultOffset =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_OFFSET', 30);
1810 $reminderDefaultEmailModel =
getDolGlobalInt(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
1812 print
"\n".
'<script type="text/javascript">';
1813 print
'$(document).ready(function () {
1814 const reminderDefaultEventTypes = '.$reminderDefaultEventTypes.
';
1815 $("#actioncode").change(function(){
1816 var selected_event_type = $("#actioncode option:selected").val();
1818 if (reminderDefaultEventTypes.includes(selected_event_type)) {
1819 $(".reminderparameters").show();
1820 $("#addreminder").prop("checked", true);
1822 // Set period with default reminder period
1823 $("[name=\"offsetvalue\"]").val("' . $reminderDefaultOffset .
'");
1824 $("#select_offsetunittype_duration").select2("destroy");
1825 $("#select_offsetunittype_duration").val("'.$reminderDefaultUnit.
'");
1826 $("#select_offsetunittype_duration").select2();
1828 $("#selectremindertype").select2("destroy");
1829 $("#selectremindertype").val("email");
1830 $("#selectremindertype").select2();
1832 // Set default reminder mail model
1833 $("#select_actioncommsendmodel_mail").closest("tr").show();
1834 $("#select_actioncommsendmodel_mail").select2("destroy");
1835 $("#select_actioncommsendmodel_mail").val("'.$reminderDefaultEmailModel.
'");
1836 $("#select_actioncommsendmodel_mail").select2();
1840 print
'</script>'.
"\n";
1842 print
"\n".
'<script type="text/javascript">';
1843 print
'$(document).ready(function () {
1844 $("#addreminder").click(function(){
1845 console.log("Click on addreminder");
1847 $(".reminderparameters").show();
1849 $(".reminderparameters").hide();
1851 $("#selectremindertype").select2("destroy");
1852 $("#selectremindertype").select2();
1853 $("#select_offsetunittype_duration").select2("destroy");
1854 $("#select_offsetunittype_duration").select2();
1855 selectremindertype();
1858 $("#selectremindertype").change(function(){
1859 selectremindertype();
1862 function selectremindertype() {
1863 console.log("Call selectremindertype");
1864 var selected_option = $("#selectremindertype option:selected").val();
1865 if(selected_option == "email") {
1866 $("#select_actioncommsendmodel_mail").closest("tr").show();
1868 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1873 print
'</script>'.
"\n";
1878 print $form->buttonsSaveCancel(
"Add");
1885 $result1 =
$object->fetch($id);
1886 if ($result1 <= 0) {
1887 $langs->load(
"errors");
1888 print $langs->trans(
"ErrorRecordNotFound");
1894 $result2 =
$object->fetch_thirdparty();
1895 $result2 =
$object->fetchProject();
1896 $result3 =
$object->fetch_contact();
1897 $result4 =
$object->fetch_userassigned();
1898 $result5 =
$object->fetch_optionals();
1900 if ($listUserAssignedUpdated || $donotclearsession) {
1901 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
1910 $object->percentage = $percentage;
1915 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1916 foreach ($socpeopleassigned as $tmpid) {
1917 $object->socpeopleassigned[
$id] = array(
'id' => $tmpid);
1925 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1931 $tmpuser =
new User($db);
1932 $res = $tmpuser->fetch(
$object->authorid);
1936 $tmpuser =
new User($db);
1937 $res = $tmpuser->fetch(
$object->usermodid);
1949 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
1953 if ($action ==
'delete') {
1954 print $form->formconfirm(
"card.php?id=".urlencode((
string) ($id)), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1957 if ($action ==
'edit') {
1958 if (!empty(
$conf->use_javascript_ajax)) {
1959 print
"\n".
'<script type="text/javascript">';
1960 print
'$(document).ready(function () {
1961 function setdatefields()
1963 if ($("#fullday:checked").val() == null) {
1964 $(".fulldaystarthour").removeAttr("disabled");
1965 $(".fulldaystartmin").removeAttr("disabled");
1966 $(".fulldayendhour").removeAttr("disabled");
1967 $(".fulldayendmin").removeAttr("disabled");
1969 $(".fulldaystarthour").prop("disabled", true).val("00");
1970 $(".fulldaystartmin").prop("disabled", true).val("00");
1971 $(".fulldayendhour").prop("disabled", true).val("23");
1972 $(".fulldayendmin").prop("disabled", true).val("59");
1976 $("#fullday").change(function() {
1979 var old_startdate = null;
1980 $("#ap").focus(function() {
1981 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1983 $("#ap").next(".ui-datepicker-trigger").click(function() {
1984 old_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1986 $("#ap").change(function() {
1987 setTimeout(function() {
1988 if ($("#p2").val() !== "") {
1989 var new_startdate = new Date($("#apyear").val(), $("#apmonth").val() - 1, $("#apday").val());
1990 var old_enddate = new Date($("#p2year").val(), $("#p2month").val() - 1, $("#p2day").val());
1991 if (new_startdate > old_enddate) {
1992 var timeDiff = old_enddate - old_startdate;
1993 var new_enddate = new Date(new_startdate.getTime() + timeDiff);
1994 $("#p2").val(formatDate(new_enddate, "' . $langs->trans(
'FormatDateShortJavaInput') .
'"));
1995 $("#p2day").val(new_enddate.getDate());
1996 $("#p2month").val(new_enddate.getMonth() + 1);
1997 $("#p2year").val(new_enddate.getFullYear());
2002 $("#actioncode").change(function() {
2003 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
2004 else $("#dateend").removeClass("fieldrequired");
2007 print
'</script>'.
"\n";
2010 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
2011 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2012 print
'<input type="hidden" name="action" value="update">';
2013 print
'<input type="hidden" name="id" value="'.$id.
'">';
2014 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
2015 print
'<input type="hidden" name="page_y" value="">';
2017 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
2020 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2025 print
'<table class="border tableforfield" width="100%">';
2028 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.
$object->id.
'</td></tr>';
2032 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
2033 if (
$object->type_code !=
'AC_OTH_AUTO') {
2034 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
2035 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
2037 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
2038 print
$object->getTypePicto();
2039 print $langs->trans(
"Action".
$object->type_code);
2045 if (
$object->elementtype ==
'ticket') {
2046 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
2047 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
2048 print
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
2052 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>';
2055 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' :
'').
'>';
2056 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
2119 print
'<tr><td class="nowrap">';
2124 print
'</td><td td colspan="3">';
2126 print $form->selectDate($datep ? $datep :
$object->datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
$object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2127 print
' <span class="hideonsmartphone"> - </span> ';
2128 print $form->selectDate($datef ? $datef :
$object->datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
$object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
2131 print
'<tr><td class=""> </td><td></td></tr>';
2134 $listofuserid = array();
2135 if (empty($donotclearsession)) {
2136 if (
$object->userownerid > 0) {
2137 $listofuserid[
$object->userownerid] = array(
2141 'transparency' =>
$object->transparency,
2142 'answer_status' => (isset(
$object->userassigned[
$object->userownerid][
'answer_status']) ?
$object->userassigned[
$object->userownerid][
'answer_status']: null),
2143 'mandatory' => (isset(
$object->userassigned[
$object->userownerid][
'mandatory']) ?
$object->userassigned[
$object->userownerid][
'mandatory']:null)
2146 if (!empty(
$object->userassigned)) {
2148 $tmplist1 =
$object->userassigned;
2149 foreach ($tmplist1 as $key => $val) {
2150 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2151 $listofuserid[$val[
'id']] = $val;
2155 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2157 if (!empty($_SESSION[
'assignedtouser'])) {
2158 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2162 $listofcontactid =
$object->socpeopleassigned;
2163 $listofotherid =
$object->otherassigned;
2165 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
2166 print
'<div class="assignedtouser">';
2167 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1, array(), 0,
'', array(), 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
2179 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.
$object->location.
'"></td></tr>';
2183 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
2184 $percent = GETPOSTISSET(
"percentage") ?
GETPOSTINT(
"percentage") :
$object->percentage;
2185 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
2189 if (isModEnabled(
'category')) {
2190 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2191 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
2193 $cats = $c->containing(
$object->id, Categorie::TYPE_ACTIONCOMM);
2194 $arrayselected = array();
2195 foreach ($cats as $cat) {
2196 $arrayselected[] = $cat->id;
2198 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2205 print
'<br><hr><br>';
2208 print
'<table class="border tableforfield centpercent">';
2210 if (isModEnabled(
"societe")) {
2212 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2216 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2219 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2224 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2225 print
'<div class="maxwidth200onsmartphone">';
2227 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2235 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2236 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');
2237 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2240 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');
2248 if (isModEnabled(
'project')) {
2249 $langs->load(
"projects");
2251 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2252 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2253 $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');
2254 if ($numprojet == 0) {
2255 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>';
2262 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2263 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2268 if (!empty(
$object->fk_element) && !empty(
$object->elementtype)) {
2269 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2271 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2273 if (
$object->elementtype ==
'task' && isModEnabled(
'project')) {
2274 print
'<td id="project-task-input-container" >';
2276 $urloption =
'?action=create&donotclearsession=1';
2277 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2280 print
"\n".
'<script type="text/javascript" >';
2281 print
'$(document).ready(function () {
2282 $("#projectid").change(function () {
2283 var url = "'.$url.
'&projectid="+$("#projectid").val();
2284 $.get(url, function(data) {
2285 console.log($( data ).find("#fk_element").html());
2286 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2290 print
'</script>'.
"\n";
2292 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1),
$object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500',
$object->fk_project);
2293 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2299 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2300 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2308 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2310 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2311 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2312 $doleditor->Create();
2316 $parameters = array();
2317 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2318 print $hookmanager->resPrint;
2319 if (empty($reshook)) {
2320 print
$object->showOptionals($extrafields,
'edit', $parameters);
2327 $filteruserid = $user->id;
2328 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2331 $object->loadReminders(
'', $filteruserid,
false);
2335 if (count(
$object->reminders) > 0) {
2336 $checked =
'checked';
2337 $keys = array_keys(
$object->reminders);
2338 $firstreminderId = array_shift($keys);
2340 $actionCommReminder =
$object->reminders[$firstreminderId];
2344 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2345 $actionCommReminder->offsetunit =
'i';
2346 $actionCommReminder->typeremind =
'email';
2355 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>';
2357 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2361 print
'<table class="border centpercent">';
2364 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2365 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2366 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2370 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2371 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2375 if ($actionCommReminder->typeremind ==
'browser') {
2376 $hide =
'style="display:none;"';
2381 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2382 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1, $actionCommReminder->fk_email_template);
2388 print
"\n".
'<script type="text/javascript">';
2389 print
'$(document).ready(function () {
2390 $("#addreminder").click(function(){
2392 $(".reminderparameters").show();
2394 $(".reminderparameters").hide();
2398 $("#selectremindertype").change(function(){
2399 var selected_option = $("#selectremindertype option:selected").val();
2400 if(selected_option == "email") {
2401 $("#select_actioncommsendmodel_mail").closest("tr").show();
2403 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2408 print
'</script>'.
"\n";
2410 $reminderDefaultEventTypes =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EVENT_TYPES',
'');
2413 $reminderDefaultEmailModel =
getDolGlobalString(
'AGENDA_DEFAULT_REMINDER_EMAIL_MODEL');
2415 print
"\n".
'<script type="text/javascript">';
2416 print
'$(document).ready(function () {
2417 const reminderDefaultEventTypes = '.$reminderDefaultEventTypes.
';
2418 $("#actioncode").change(function(){
2419 var selected_event_type = $("#actioncode option:selected").val();
2421 if (reminderDefaultEventTypes.includes(selected_event_type)) {
2422 $(".reminderparameters").show();
2423 $("#addreminder").prop("checked", true);
2425 // Set period with default reminder period
2426 $("#offsetvalue").val('.$reminderDefaultOffset.
');
2427 $("#select_offsetunittype_duration").select2("destroy");
2428 $("#select_offsetunittype_duration").val("'.$reminderDefaultUnit.
'");
2429 $("#select_offsetunittype_duration").select2();
2431 $("#selectremindertype").select2("destroy");
2432 $("#selectremindertype").val("email");
2433 $("#selectremindertype").select2();
2435 // Set default reminder mail model
2436 $("#select_actioncommsendmodel_mail").closest("tr").show();
2437 $("#select_actioncommsendmodel_mail").select2("destroy");
2438 $("#select_actioncommsendmodel_mail").val("'.$reminderDefaultEmailModel.
'");
2439 $("#select_actioncommsendmodel_mail").select2();
2443 print
'</script>'.
"\n";
2449 print $form->buttonsSaveCancel();
2458 if ($action ==
'clone') {
2459 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent',
$object->label),
'confirm_clone', array(),
'yes', 1);
2463 $parameters = array();
2464 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2465 if (empty($reshook)) {
2466 $formconfirm .= $hookmanager->resPrint;
2467 } elseif ($reshook > 0) {
2468 $formconfirm = $hookmanager->resPrint;
2476 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
2477 $linkback .=
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="pictoactionview pictofixedwidth"');
2478 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"BackToList").
'</span>';
2479 $linkback .=
'</a>';
2480 $linkback .=
'</li>';
2481 $linkback .=
'<li class="noborder litext">';
2483 $linkback .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview pictofixedwidth"');
2484 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span>';
2485 $linkback .=
'</a>';
2486 $linkback .=
'</li>';
2487 $linkback .=
'<li class="noborder litext">';
2489 $linkback .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview pictofixedwidth"');
2490 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span>';
2491 $linkback .=
'</a>';
2492 $linkback .=
'</li>';
2493 $linkback .=
'<li class="noborder litext">';
2495 $linkback .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview pictofixedwidth"');
2496 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span>';
2497 $linkback .=
'</a>';
2498 $linkback .=
'</li>';
2499 $linkback .=
'<li class="noborder litext">';
2501 $linkback .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview pictofixedwidth"');
2502 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span>';
2503 $linkback .=
'</a>';
2506 $parameters = array();
2507 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters,
$object, $action);
2508 if (empty($reshook)) {
2509 $linkback .= $hookmanager->resPrint;
2510 } elseif ($reshook > 1) {
2511 $linkback = $hookmanager->resPrint;
2516 $morehtmlref =
'<div class="refidno">';
2520 if (isModEnabled(
'project')) {
2521 $langs->load(
"projects");
2523 if ($usercancreate) {
2524 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2525 if ($action !=
'classify') {
2526 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2528 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2530 if (!empty(
$object->fk_project)) {
2532 $proj->fetch(
$object->fk_project);
2533 $morehtmlref .= $proj->getNomUrl(1);
2535 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2540 $morehtmlref .=
'</div>';
2543 dol_banner_tab(
$object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
2545 print
'<div class="fichecenter">';
2546 print
'<div class="fichehalfleft">';
2548 print
'<div class="underbanner clearboth"></div>';
2551 print
'<table class="border tableforfield centpercent">';
2555 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2556 $labeltype = ($langs->transnoentities(
"Action".
$object->type_code) !=
"Action".$object->type_code) ? $langs->transnoentities(
"Action".$object->type_code) :
$object->type_label;
2557 $labeltoshow = $labeltype;
2559 $labeltoshow .=
' ('.$object->code.
')';
2561 print
$object->getTypePicto(
'pictofixedwidth paddingright', $labeltoshow);
2567 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn(
$object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2571 print
'<tr><td class="titlefield">'.$langs->trans(
"EventIntoASerie").
'</td><td>'.
dol_escape_htmltag(
$object->recurid).
'</td></tr>';
2580 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2585 if (empty(
$object->fulldayevent)) {
2598 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2599 if (empty(
$object->fulldayevent)) {
2612 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.
$object->location.
'</td></tr>';
2616 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2617 $listofuserid = array();
2618 if (empty($donotclearsession)) {
2619 if (
$object->userownerid > 0) {
2620 $listofuserid[
$object->userownerid] = array(
2622 'transparency' =>
$object->transparency,
2623 'answer_status' =>
$object->userassigned[
$object->userownerid][
'answer_status'],
2624 'mandatory' =>
$object->userassigned[
$object->userownerid][
'mandatory']
2627 if (!empty(
$object->userassigned)) {
2629 $tmplist1 =
$object->userassigned;
2630 foreach ($tmplist1 as $key => $val) {
2631 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2632 $listofuserid[$val[
'id']] = $val;
2636 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2638 if (!empty($_SESSION[
'assignedtouser'])) {
2639 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2643 $listofcontactid = array();
2644 $listofotherid = array();
2645 print
'<div class="assignedtouser">';
2646 print $form->select_dolusers_forevent(
'view',
'assignedtouser', 1, array(), 0,
'', array(), 0, 0, 0,
'', (
$object->datep !=
$object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2656 print
' </td></tr>';
2659 if (isModEnabled(
'category')) {
2660 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2661 print $form->showCategories(
$object->id, Categorie::TYPE_ACTIONCOMM, 1);
2669 print
'<div class="fichehalfright">';
2671 print
'<div class="underbanner clearboth"></div>';
2672 print
'<table class="border tableforfield centpercent">';
2674 if (isModEnabled(
"societe")) {
2676 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td>';
2677 print
'<td>'.(is_object(
$object->thirdparty) &&
$object->thirdparty->id ?
$object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2678 if (is_object(
$object->thirdparty) &&
$object->thirdparty->id > 0 &&
$object->type_code ==
'AC_TEL') {
2680 print
"<br>".dol_print_phone(
$object->thirdparty->phone);
2686 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2689 if (!empty(
$object->socpeopleassigned)) {
2690 foreach (
$object->socpeopleassigned as $cid => $Tab) {
2692 $result = $contact->fetch($cid);
2699 print $contact->getNomUrl(1);
2700 if (
$object->type_code ==
'AC_TEL') {
2701 if (!empty($contact->phone_pro)) {
2702 print
'('.dol_print_phone($contact->phone_pro).
')';
2705 print
'<div class="paddingright"></div>';
2709 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2716 print
'<tr><td class="nowrap" class="titlefield">' . $langs->trans(
"Priority") .
'</td><td>';
2723 if (!empty(
$object->fk_element) && !empty(
$object->elementtype) && !in_array(
$object->elementtype, array(
'societe',
'contact',
'project'))) {
2724 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2725 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2729 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2737 if (!empty(
$object->email_msgid)) {
2738 print
'<tr><td>'.$langs->trans(
'MailTopic').
'</td>';
2739 print
'<td>'.dol_escape_htmltag(
$object->email_subject).
'</td></tr>';
2740 print
'<tr><td>'.$langs->trans(
'MailFrom').
'</td>';
2741 print
'<td>'.dol_escape_htmltag(
$object->email_from).
'</td></tr>';
2742 print
'<tr><td>'.$langs->trans(
'MailTo').
'</td>';
2743 print
'<td>'.dol_escape_htmltag(
$object->email_to).
'</td></tr>';
2744 if (!empty(
$object->email_tocc)) {
2745 print
'<tr><td>'.$langs->trans(
'MailCC').
'</td>';
2746 print
'<td>'.dol_escape_htmltag(
$object->email_tocc).
'</td></tr>';
2751 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak sensiblehtmlcontent">';
2756 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2760 $filteruserid = $user->id;
2761 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2764 $object->loadReminders(
'', $filteruserid,
false);
2766 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2768 if (count(
$object->reminders) > 0) {
2769 $tmpuserstatic =
new User($db);
2771 foreach (
$object->reminders as $actioncommreminderid => $actioncommreminder) {
2772 print $TRemindTypes[$actioncommreminder->typeremind][
'label'];
2773 if ($actioncommreminder->fk_user > 0) {
2774 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2775 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2777 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2779 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2780 print
' - <span class="opacitymedium">';
2781 print $langs->trans(
"NotSent");
2783 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2784 print
' - <span class="opacitymedium">';
2785 print $langs->trans(
"Done");
2787 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2788 print
' - <span class="opacitymedium">';
2789 print $form->textwithpicto($langs->trans(
"Error"), $actioncommreminder->lasterror);
2803 print
'<div class="clearboth"></div>';
2812 print
'<div class="tabsAction">';
2814 $parameters = array();
2815 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
2816 if (empty($reshook)) {
2817 if ($action !=
'edit') {
2818 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2819 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2820 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2822 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2825 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2826 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2827 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>';
2829 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2832 if ($user->hasRight(
'agenda',
'allactions',
'delete') ||
2833 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'))) {
2834 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2836 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2843 if ($action !=
'edit') {
2845 print
'<div class="clearboth"></div><div class="fichecenter"><div class="fichehalfleft">';
2846 print
'<a name="builddoc"></a>';
2853 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2855 $genallowed = $user->hasRight(
'agenda',
'myactions',
'read');
2856 $delallowed = $user->hasRight(
'agenda',
'myactions',
'create');
2859 print $formfile->showdocuments(
'actions',
$object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2861 print
'</div><div class="fichehalfright">';
2864 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'.
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_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
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_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.