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) {
95 if (
GETPOST(
'datep') ==
'now') {
97 } elseif (preg_match(
'/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/',
GETPOST(
"datep"), $reg)) {
98 $datep =
dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1],
'tzuserrel');
105if ($user->socid && ($socid != $user->socid)) {
110$donotclearsession =
GETPOST(
'donotclearsession') ?
GETPOST(
'donotclearsession') : 0;
119$form =
new Form($db);
124if ($id > 0 && $action !=
'add') {
128 $ret =
$object->fetch_optionals();
129 $ret1 =
$object->fetch_userassigned();
131 if ($ret < 0 || $ret1 < 0) {
137$extrafields->fetch_name_optionals_label(
$object->table_element);
140$hookmanager->initHooks(array(
'actioncard',
'globalcard'));
142$parameters = array(
'socid' => $socid);
143$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
148$TRemindTypes = array();
150 $TRemindTypes[
'browser'] = array(
'label' => $langs->trans(
'BrowserPush'),
'disabled' => (!
getDolGlobalString(
'AGENDA_REMINDER_BROWSER') ? 1 : 0));
153 $TRemindTypes[
'email'] = array(
'label' => $langs->trans(
'EMail'),
'disabled' => (!
getDolGlobalString(
'AGENDA_REMINDER_EMAIL') ? 1 : 0));
156$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'));
158$result =
restrictedArea($user,
'agenda',
$object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
160$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || ((empty(
$object->id) ||
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
167$listUserAssignedUpdated =
false;
168$listResourceAssignedUpdated =
false;
169$assignedtouser = array();
172if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
173 $idtoremove =
GETPOST(
'removedassigned');
175 if (!empty($_SESSION[
'assignedtouser'])) {
176 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'],
true);
178 $tmpassigneduserids = array();
181 foreach ($tmpassigneduserids as $key => $val) {
182 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
183 unset($tmpassigneduserids[$key]);
187 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
188 $donotclearsession = 1;
189 if ($action ==
'add') {
192 if ($action ==
'update') {
196 $listUserAssignedUpdated =
true;
199if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
200 $idtoremove =
GETPOST(
'removedassignedresource');
202 if (!empty($_SESSION[
'assignedtoresource'])) {
203 $tmpassignedresourceids = json_decode($_SESSION[
'assignedtoresource'],
true);
205 $tmpassignedresourceids = array();
208 foreach ($tmpassignedresourceids as $key => $val) {
209 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
210 unset($tmpassignedresourceids[$key]);
214 $_SESSION[
'assignedtoresource'] = json_encode($tmpassignedresourceids);
215 $donotclearsessionresource = 1;
216 if ($action ==
'add' && $usercancreate) {
219 if ($action ==
'update' && $usercancreate) {
223 $listResourceAssignedUpdated =
true;
227if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
229 if (
GETPOST(
'assignedtouser') > 0) {
230 $assignedtouser = array();
231 if (!empty($_SESSION[
'assignedtouser'])) {
232 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
234 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id' =>
GETPOSTINT(
'assignedtouser'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
235 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
237 $donotclearsession = 1;
238 if ($action ==
'add' && $usercancreate) {
241 if ($action ==
'update' && $usercancreate) {
245 $listUserAssignedUpdated =
true;
249if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
251 if (
GETPOST(
'assignedtoresource') > 0) {
252 $assignedtoresource = array();
253 if (!empty($_SESSION[
'assignedtoresource'])) {
254 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
256 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id' =>
GETPOSTINT(
'assignedtoresource'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
257 $_SESSION[
'assignedtoresource'] = json_encode($assignedtoresource);
259 $donotclearsession = 1;
260 if ($action ==
'add' && $usercancreate) {
263 if ($action ==
'update' && $usercancreate) {
267 $listResourceAssignedUpdated =
true;
271if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
272 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
278if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
279 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
284 if (!empty(
$object->socpeopleassigned)) {
285 reset(
$object->socpeopleassigned);
290 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
301if (empty($reshook) && $action ==
'add' && $usercancreate) {
304 if (empty($backtopage)) {
306 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
308 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
312 if (!empty($socpeopleassigned[0])) {
313 $result = $contact->fetch($socpeopleassigned[0]);
317 header(
"Location: ".$backtopage);
321 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
335 if (!$datef && $percentage == 100) {
337 $donotclearsession = 1;
339 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
344 $donotclearsession = 1;
346 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
350 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
352 $donotclearsession = 1;
354 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
362 $object->fulldayevent = ($fulldayevent ? 1 : 0);
366 if (
GETPOST(
"elementtype",
'alpha')) {
368 $modulecodetouseforpermissioncheck = $elProp[
'module'];
369 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
371 $hasPermissionOnLinkedObject = 0;
372 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
373 $hasPermissionOnLinkedObject = 1;
374 } elseif ($user->hasRight($modulecodetouseforpermissioncheck, $submodulecodetouseforpermissioncheck,
'read')) {
375 $hasPermissionOnLinkedObject = 1;
378 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;
411 $object->percentage = $percentage;
414 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
416 $listofuserid = array();
417 if (!empty($_SESSION[
'assignedtouser'])) {
418 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
421 if (!empty($_SESSION[
'assignedtoresource'])) {
422 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
426 foreach ($listofuserid as $key => $value) {
428 if ($value[
'id'] > 0) {
429 $object->userownerid = $value[
'id'];
431 $object->transparency = $transparency;
434 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
442 if (GETPOSTISSET(
"contactid")) {
456 if (empty(
$object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
458 $donotclearsession = 1;
460 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
462 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
464 $donotclearsession = 1;
466 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
471 $donotclearsession = 1;
473 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
476 foreach ($socpeopleassigned as $cid) {
477 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
479 if (!empty(
$object->socpeopleassigned)) {
480 reset(
$object->socpeopleassigned);
485 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
488 $donotclearsession = 1;
497 $selectedrecurrulefreq =
'no';
498 $selectedrecurrulebymonthday =
'';
499 $selectedrecurrulebyday =
'';
500 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
501 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY' && GETPOSTISSET(
'BYMONTHDAY')) ?
"_BYMONTHDAY".
GETPOST(
'BYMONTHDAY',
'alpha') :
"";
502 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY' && GETPOSTISSET(
'BYDAY')) ?
"_BYDAY".
GETPOST(
'BYDAY',
'alpha') :
"";
507 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
508 $selectedrecurrulefreq = $reg1[1];
510 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
511 $selectedrecurrulebymonthday = (int) $reg2[1];
513 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
514 $selectedrecurrulebyday = (int) $reg3[1];
518 $eventisrecurring = 0;
519 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 2 ? 1 : 0);
520 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
521 $eventisrecurring = 1;
531 $idaction =
$object->create($user);
536 if (is_array($listofresourceid) && count($listofresourceid)) {
537 foreach ($listofresourceid as $resource_id => $val) {
538 $resource_type =
'dolresource';
543 $eventDateStart =
$object->datep;
544 $eventDateEnd =
$object->datef;
545 $isFullDayEvent =
$object->fulldayevent;
546 if (empty($eventDateEnd)) {
547 if ($isFullDayEvent) {
549 $eventDateStart =
dol_mktime(0, 0, 0, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
550 $eventDateEnd =
dol_mktime(23, 59, 59, $eventDateStartArr[
'mon'], $eventDateStartArr[
'mday'], $eventDateStartArr[
'year']);
554 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
555 $sql .=
" FROM " . MAIN_DB_PREFIX .
"element_resources as er";
556 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"resource as r ON r.rowid = er.resource_id AND er.resource_type = '" . $db->escape($resource_type) .
"'";
557 $sql .=
" INNER JOIN " . MAIN_DB_PREFIX .
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '" . $db->escape(
$object->element) .
"'";
558 $sql .=
" WHERE er.resource_id = " . ((int) $resource_id);
559 $sql .=
" AND er.busy = 1";
563 $sql .=
" (ac.datep <= '" . $db->idate($eventDateStart) .
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '" . $db->idate($eventDateStart) .
"'))";
565 if (!empty($eventDateEnd)) {
566 $sql .=
" OR (ac.datep <= '" . $db->idate($eventDateEnd) .
"' AND (ac.datep2 >= '" . $db->idate($eventDateEnd) .
"'))";
570 $sql .=
"ac.datep >= '" . $db->idate($eventDateStart) .
"'";
571 if (!empty($eventDateEnd)) {
572 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '" . $db->idate($eventDateEnd) .
"')";
577 $resql = $db->query($sql);
580 $object->error = $db->lasterror();
583 if ($db->num_rows($resql) > 0) {
586 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse') .
' : ';
587 while ($obj = $db->fetch_object($resql)) {
588 $object->error .=
'<br> - ' . $langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label .
' [' . $obj->ac_id .
']');
599 $res =
$object->add_element_resource($resource_id, $resource_type, $busy, $val[
'mandatory']);
604 unset($_SESSION[
'assignedtoresource']);
609 $categories =
GETPOST(
'categories',
'array');
610 $object->setCategories($categories);
613 unset($_SESSION[
'assignedtouser']);
615 if ($user->id !=
$object->userownerid) {
616 $moreparam =
"filtert=-1";
620 if (!$error && $addreminder ==
'on') {
625 $actionCommReminder->dateremind = $dateremind;
626 $actionCommReminder->typeremind = $remindertype;
627 $actionCommReminder->offsetunit = $offsetunit;
628 $actionCommReminder->offsetvalue = $offsetvalue;
629 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
630 $actionCommReminder->fk_actioncomm =
$object->id;
631 if ($remindertype ==
'email') {
632 $actionCommReminder->fk_email_template = $modelmail;
636 foreach (
$object->userassigned as $userassigned) {
637 $actionCommReminder->fk_user = $userassigned[
'id'];
638 $res = $actionCommReminder->create($user);
643 $langs->load(
"errors");
644 $error = $langs->trans(
'ErrorReminderActionCommCreation');
647 $donotclearsession = 1;
658 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
678 $langs->load(
"errors");
679 $error = $langs->trans(
$object->error);
682 $donotclearsession = 1;
688 $donotclearsession = 1;
691 if (!$error && $eventisrecurring) {
695 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
697 $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');
701 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
702 $firstday = $selectedrecurrulebymonthday;
711 $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');
717 while ($datep <= $repeateventlimitdate && !$error) {
721 $finalobject->datep = $datep;
722 $finalobject->datef = $datef;
724 $idaction = $finalobject->create($user);
727 if (!$finalobject->error) {
729 $categories =
GETPOST(
'categories',
'array');
730 $finalobject->setCategories($categories);
732 unset($_SESSION[
'assignedtouser']);
735 if ($user->id != $finalobject->userownerid) {
736 $moreparam =
"filtert=-1";
740 if ($addreminder ==
'on') {
745 $actionCommReminder->dateremind = $dateremind;
746 $actionCommReminder->typeremind = $remindertype;
747 $actionCommReminder->offsetunit = $offsetunit;
748 $actionCommReminder->offsetvalue = $offsetvalue;
749 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
750 $actionCommReminder->fk_actioncomm = $finalobject->id;
751 if ($remindertype ==
'email') {
752 $actionCommReminder->fk_email_template = $modelmail;
756 foreach ($finalobject->userassigned as $userassigned) {
757 $actionCommReminder->fk_user = $userassigned[
'id'];
758 $res = $actionCommReminder->create($user);
763 $langs->load(
"errors");
764 $error = $langs->trans(
'ErrorReminderActionCommCreation');
767 $donotclearsession = 1;
778 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
788 $langs->load(
"errors");
789 $error = $langs->trans($finalobject->error);
792 $donotclearsession = 1;
798 $donotclearsession = 1;
802 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
813 if (!empty($backtopage) && !$error) {
814 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
815 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
816 } elseif ($idaction) {
817 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
819 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
826if (empty($reshook) && $action ==
'update' && $usercancreate) {
827 if (empty($cancel)) {
828 $fulldayevent =
GETPOST(
'fullday');
833 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
858 $datep =
dol_mktime(
'00',
'00',
'00',
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
859 $datef =
dol_mktime(
'23',
'59',
'59',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
861 $datep =
dol_mktime(
GETPOST(
"aphour",
'int'),
GETPOST(
"apmin",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuserrel');
862 $datef =
dol_mktime(
GETPOST(
"p2hour",
'int'),
GETPOST(
"p2min",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuserrel');
865 if (
$object->elementtype ==
'ticket') {
867 if (
$object->code ==
'TICKET_MSG') {
868 $object->code =
'TICKET_MSG_PRIVATE';
870 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
871 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
874 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
877 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
878 $object->code =
'TICKET_MSG_SENTBYMAIL';
890 $object->percentage = $percentage;
895 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
896 $object->socpeopleassigned = array();
897 foreach ($socpeopleassigned as $cid) {
898 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
901 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
902 reset(
$object->socpeopleassigned);
908 if (
GETPOST(
"elementtype",
'alpha')) {
910 $modulecodetouseforpermissioncheck = $elProp[
'module'];
912 $hasPermissionOnLinkedObject = 0;
913 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
914 $hasPermissionOnLinkedObject = 1;
916 if ($hasPermissionOnLinkedObject) {
922 if (!$datef && $percentage == 100) {
924 $donotclearsession = 1;
925 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
$object->errors,
'errors');
929 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
932 $listofuserid = array();
933 if (!empty($_SESSION[
'assignedtouser'])) {
935 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
936 foreach ($tmplist1 as $key => $val) {
937 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
938 $listofuserid[$val[
'id']] = $val;
942 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
943 if ($assignedtouser) {
944 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
947 $object->userassigned = array();
950 foreach ($listofuserid as $key => $val) {
952 $object->userownerid = $val[
'id'];
954 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
958 $object->transparency = $transparency;
962 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
964 $donotclearsession = 1;
966 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
968 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
970 if (empty(
$object->userownerid)) {
972 $donotclearsession = 1;
974 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
978 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
986 $eventDateStart =
$object->datep;
987 $eventDateEnd =
$object->datef;
989 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
990 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
991 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
992 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
993 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
994 $sql .=
" AND er.resource_id IN (";
995 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
996 $sql .=
" WHERE element_id = ".((int)
$object->id);
997 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
998 $sql .=
" AND busy = 1";
1000 $sql .=
" AND er.busy = 1";
1004 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1006 if (!empty($eventDateEnd)) {
1007 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1011 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1012 if (!empty($eventDateEnd)) {
1013 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1018 $resql = $db->query($sql);
1021 $object->error = $db->lasterror();
1024 if ($db->num_rows($resql) > 0) {
1027 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1028 while ($obj = $db->fetch_object($resql)) {
1029 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1045 $result =
$object->update($user);
1049 $categories =
GETPOST(
'categories',
'array');
1050 $object->setCategories($categories);
1052 $object->loadReminders($remindertype, 0,
false);
1055 if (!empty(
$object->reminders)) {
1056 foreach (
$object->reminders as $reminder) {
1057 if ($reminder->status < 1) {
1058 $reminder->delete($user);
1065 if ($addreminder ==
'on') {
1070 $actionCommReminder->dateremind = $dateremind;
1071 $actionCommReminder->typeremind = $remindertype;
1072 $actionCommReminder->offsetunit = $offsetunit;
1073 $actionCommReminder->offsetvalue = $offsetvalue;
1074 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
1075 $actionCommReminder->fk_actioncomm =
$object->id;
1076 if ($remindertype ==
'email') {
1077 $actionCommReminder->fk_email_template = $modelmail;
1081 foreach (
$object->userassigned as $userassigned) {
1082 $actionCommReminder->fk_user = $userassigned[
'id'];
1086 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1087 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".$db->escape($remindertype).
"'";
1088 $resqldelete = $db->query($sqldelete);
1090 $res = $actionCommReminder->create($user);
1094 $langs->load(
"errors");
1095 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1098 $donotclearsession = 1;
1105 unset($_SESSION[
'assignedtouser']);
1106 unset($_SESSION[
'assignedtoresource']);
1121 if (!empty($backtopage)) {
1122 unset($_SESSION[
'assignedtouser']);
1123 header(
"Location: ".$backtopage);
1130if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
1133 $object->fetch_userassigned();
1136 if ($user->hasRight(
'agenda',
'myactions',
'delete')
1137 || $user->hasRight(
'agenda',
'allactions',
'delete')) {
1138 $result =
$object->delete($user);
1141 header(
"Location: index.php");
1153if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
1159 $newdate =
GETPOST(
'newdate',
'alpha');
1160 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1161 header(
"Location: ".$backtopage,
true, 307);
1165 $datep =
dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4),
'tzuserrel');
1168 if ($datep !=
$object->datep) {
1177 $eventDateStart =
$object->datep;
1178 $eventDateEnd =
$object->datef;
1180 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1181 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1182 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1183 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1184 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1185 $sql .=
" AND er.resource_id IN (";
1186 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1187 $sql .=
" WHERE element_id = ".((int)
$object->id);
1188 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1189 $sql .=
" AND busy = 1";
1191 $sql .=
" AND er.busy = 1";
1195 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1197 if (!empty($eventDateEnd)) {
1198 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1202 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1203 if (!empty($eventDateEnd)) {
1204 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1209 $resql = $db->query($sql);
1212 $object->error = $db->lasterror();
1215 if ($db->num_rows($resql) > 0) {
1218 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1219 while ($obj = $db->fetch_object($resql)) {
1220 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1235 $result =
$object->update($user);
1245 if (!empty($backtopage)) {
1246 header(
"Location: ".$backtopage,
true, 307);
1255$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1256if (empty($reshook)) {
1257 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1265$form =
new Form($db);
1268$arrayrecurrulefreq = array(
1269 'no' => $langs->trans(
"OnceOnly"),
1270 'MONTHLY' => $langs->trans(
"EveryMonth"),
1271 'WEEKLY' => $langs->trans(
"EveryWeek")
1276$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1277llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1279if ($action ==
'create') {
1282 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1283 if (!empty($socpeopleassigned[0])) {
1284 $result = $contact->fetch($socpeopleassigned[0]);
1292 if (!empty($conf->use_javascript_ajax)) {
1293 print
"\n".
'<script type="text/javascript">';
1294 print
'$(document).ready(function () {
1295 function setdatefields()
1297 if ($("#fullday:checked").val() == null) {
1298 $(".fulldaystarthour").removeAttr("disabled");
1299 $(".fulldaystartmin").removeAttr("disabled");
1300 $(".fulldayendhour").removeAttr("disabled");
1301 $(".fulldayendmin").removeAttr("disabled");
1302 $("#p2").removeAttr("disabled");
1304 $(".fulldaystarthour").prop("disabled", true).val("00");
1305 $(".fulldaystartmin").prop("disabled", true).val("00");
1306 $(".fulldayendhour").prop("disabled", true).val("23");
1307 $(".fulldayendmin").prop("disabled", true).val("59");
1308 $("#p2").removeAttr("disabled");
1311 $("#fullday").change(function() {
1312 console.log("setdatefields");
1316 $("#actioncode").change(function() {
1317 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1318 else $("#dateend").removeClass("fieldrequired");
1320 $("#aphour,#apmin").change(function() {
1321 if ($("#actioncode").val() == \'AC_RDV\') {
1322 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1323 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1324 $("#p2min").val($("#apmin").val());
1325 $("#p2day").val($("#apday").val());
1326 $("#p2month").val($("#apmonth").val());
1327 $("#p2year").val($("#apyear").val());
1328 $("#p2").val($("#ap").val());
1331 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1332 else $("#dateend").removeClass("fieldrequired");
1335 print
'</script>'.
"\n";
1338 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1339 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1340 print
'<input type="hidden" name="action" value="add">';
1341 print
'<input type="hidden" name="donotclearsession" value="1">';
1342 print
'<input type="hidden" name="page_y" value="">';
1344 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1347 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1350 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1351 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1358 print
'<table class="border centpercent">';
1362 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1364 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1365 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1366 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1371 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>';
1374 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1375 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>';
1378 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0);
1379 if ($userepeatevent) {
1381 print
' <div class="opacitymedium inline-block small">';
1382 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 6px" class="paddingright2"');
1383 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1385 $selectedrecurrulefreq =
'no';
1386 $selectedrecurrulebymonthday =
'';
1387 $selectedrecurrulebyday =
'';
1388 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1389 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1390 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1394 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1395 $selectedrecurrulefreq = $reg[1];
1397 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1398 $selectedrecurrulebymonthday = (int) $reg[1];
1400 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1401 $selectedrecurrulebyday = (int) $reg[1];
1404 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1410 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1411 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1414 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1415 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1418 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1419 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1420 print $langs->trans(
"Until").
" ";
1421 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1424 print
'<script type="text/javascript">
1425 jQuery(document).ready(function() {
1426 function init_repeat()
1428 console.log("recurrule: " + "'.$object->recurrule.
'");
1429 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1430 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1431 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1432 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1433 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1435 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1436 jQuery(".repeateventlimitdate").css("display", "inline-block");
1437 jQuery(".repeateventBYDAY").hide();
1439 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1441 jQuery(".repeateventBYMONTHDAY").hide();
1442 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1443 jQuery(".repeateventlimitdate").css("display", "inline-block");
1447 jQuery(".repeateventBYMONTHDAY").hide();
1448 jQuery(".repeateventBYDAY").hide();
1449 jQuery(".repeateventlimitdate").hide();
1453 jQuery("#recurrulefreq").change(function() {
1464 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1468 $datef = ($datef ? $datef :
$object->datef);
1472 if (empty($datef) && !empty($datep)) {
1479 print
'<tr><td class="nowrap">';
1482 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1484 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1486 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1487 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1490 print
'<tr><td class=""> </td><td></td></tr>';
1493 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1494 $listofuserid = array();
1495 $listofcontactid = array();
1496 $listofotherid = array();
1498 if (empty($donotclearsession)) {
1500 if ($assignedtouser) {
1501 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1504 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1505 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1507 if (!empty($_SESSION[
'assignedtouser'])) {
1508 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1510 $firstelem = reset($listofuserid);
1511 if (isset($listofuserid[$firstelem[
'id']])) {
1512 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1515 print
'<div class="assignedtouser">';
1516 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1522 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>';
1525 if (isModEnabled(
'category')) {
1527 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1528 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
1529 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1533 if (isModEnabled(
'resource')) {
1535 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1537 $listofresourceid = array();
1538 if (empty($donotclearsession)) {
1539 $assignedtoresource =
GETPOST(
"assignedtoresource");
1540 if ($assignedtoresource) {
1541 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1543 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1545 if (!empty($_SESSION[
'assignedtoresource'])) {
1546 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1548 $firstelem = reset($listofresourceid);
1549 if (isset($listofresourceid[$firstelem[
'id']])) {
1550 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1553 print
'<div class="assignedtoresource">';
1554 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1560 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1562 $percent = $complete !==
'' ? $complete : -1;
1563 if (GETPOSTISSET(
'status')) {
1565 } elseif (GETPOSTISSET(
'percentage')) {
1568 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1570 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1574 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1580 print
'<br><hr><br>';
1583 print
'<table class="border centpercent">';
1585 if (isModEnabled(
"societe")) {
1587 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1591 print $societe->getNomUrl(1);
1592 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1595 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1597 if (!empty($user->socid)) {
1598 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1600 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1606 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1607 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1611 if ($origin ==
'contact') {
1617 $select_contact_default = 0;
1619 $select_contact_default = -1;
1621 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1623 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
1630 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1631 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, array(), false,
'multiple',
'contactid');
1632 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1634 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, array(), false,
'multiple',
'contactid');
1641 if (isModEnabled(
'project')) {
1642 $langs->load(
"projects");
1646 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1647 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1648 print $formproject->select_projects((
$object->socid > 0 ?
$object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx maxwidth500');
1650 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1651 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1652 $urloption =
'?action=create&donotclearsession=1';
1656 print
"\n".
'<script type="text/javascript">';
1657 print
'$(document).ready(function () {
1658 $("#projectid").change(function () {
1659 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1660 console.log("Call url to get new list of tasks: "+url);
1661 $.get(url, function(data) {
1663 if (data) $("#taskid").html(data).select2();
1667 print
'</script>'.
"\n";
1672 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1673 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1674 $projectsListId =
false;
1675 if (!empty($projectid)) {
1676 $projectsListId = $projectid;
1679 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1681 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', $projectsListId);
1686 if (!empty($origin) && !empty($originid)) {
1687 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1689 $hasPermissionOnLinkedObject = 0;
1692 if ($user->hasRight($elProp[
'module'],
'read') || $user->hasRight($elProp[
'module'], $elProp[
'element'],
'read')) {
1693 $hasPermissionOnLinkedObject = 1;
1697 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1699 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1700 print
'<td colspan="3">';
1701 if ($hasPermissionOnLinkedObject) {
1703 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1704 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1705 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1706 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1708 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1716 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1717 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1722 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1723 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1724 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 120,
'dolibarr_notes',
'In', true, true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1725 $doleditor->Create();
1729 $parameters = array();
1730 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1731 print $hookmanager->resPrint;
1732 if (empty($reshook)) {
1733 print
$object->showOptionals($extrafields,
'create', $parameters);
1743 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1745 print
'<div class="reminderparameters" style="display: none;">';
1747 print
'<table class="border centpercent">';
1750 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1751 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1752 print $form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1756 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1757 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1762 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1763 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1770 print
"\n".
'<script type="text/javascript">';
1771 print
'$(document).ready(function () {
1772 $("#addreminder").click(function(){
1773 console.log("Click on addreminder");
1775 $(".reminderparameters").show();
1777 $(".reminderparameters").hide();
1779 $("#selectremindertype").select2("destroy");
1780 $("#selectremindertype").select2();
1781 $("#select_offsetunittype_duration").select2("destroy");
1782 $("#select_offsetunittype_duration").select2();
1783 selectremindertype();
1786 $("#selectremindertype").change(function(){
1787 selectremindertype();
1790 function selectremindertype() {
1791 console.log("Call selectremindertype");
1792 var selected_option = $("#selectremindertype option:selected").val();
1793 if(selected_option == "email") {
1794 $("#select_actioncommsendmodel_mail").closest("tr").show();
1796 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1801 print
'</script>'.
"\n";
1806 print $form->buttonsSaveCancel(
"Add");
1813 $result1 =
$object->fetch($id);
1814 if ($result1 <= 0) {
1815 $langs->load(
"errors");
1816 print $langs->trans(
"ErrorRecordNotFound");
1822 $result2 =
$object->fetch_thirdparty();
1823 $result2 =
$object->fetch_projet();
1824 $result3 =
$object->fetch_contact();
1825 $result4 =
$object->fetch_userassigned();
1826 $result5 =
$object->fetch_optionals();
1828 if ($listUserAssignedUpdated || $donotclearsession) {
1829 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
1838 $object->percentage = $percentage;
1843 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1844 foreach ($socpeopleassigned as $tmpid) {
1845 $object->socpeopleassigned[$id] = array(
'id' => $tmpid);
1853 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1859 $tmpuser =
new User($db);
1860 $res = $tmpuser->fetch(
$object->authorid);
1864 $tmpuser =
new User($db);
1865 $res = $tmpuser->fetch(
$object->usermodid);
1877 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
1881 if ($action ==
'delete') {
1882 print $form->formconfirm(
"card.php?id=".urlencode((
string) ($id)), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1885 if ($action ==
'edit') {
1886 if (!empty($conf->use_javascript_ajax)) {
1887 print
"\n".
'<script type="text/javascript">';
1888 print
'$(document).ready(function () {
1889 function setdatefields()
1891 if ($("#fullday:checked").val() == null) {
1892 $(".fulldaystarthour").removeAttr("disabled");
1893 $(".fulldaystartmin").removeAttr("disabled");
1894 $(".fulldayendhour").removeAttr("disabled");
1895 $(".fulldayendmin").removeAttr("disabled");
1897 $(".fulldaystarthour").prop("disabled", true).val("00");
1898 $(".fulldaystartmin").prop("disabled", true).val("00");
1899 $(".fulldayendhour").prop("disabled", true).val("23");
1900 $(".fulldayendmin").prop("disabled", true).val("59");
1904 $("#fullday").change(function() {
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' => (isset(
$object->userassigned[
$object->userownerid][
'answer_status']) ?
$object->userassigned[
$object->userownerid][
'answer_status']: null),
2048 'mandatory' => (isset(
$object->userassigned[
$object->userownerid][
'mandatory']) ?
$object->userassigned[
$object->userownerid][
'mandatory']:null)
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">';
2132 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2133 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
2140 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2141 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');
2142 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2145 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');
2153 if (isModEnabled(
'project')) {
2154 $langs->load(
"projects");
2156 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2157 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2158 $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');
2159 if ($numprojet == 0) {
2160 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>';
2167 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2168 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2173 if (!empty(
$object->fk_element) && !empty(
$object->elementtype)) {
2174 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2176 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2178 if (
$object->elementtype ==
'task' && isModEnabled(
'project')) {
2179 print
'<td id="project-task-input-container" >';
2181 $urloption =
'?action=create&donotclearsession=1';
2182 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2185 print
"\n".
'<script type="text/javascript" >';
2186 print
'$(document).ready(function () {
2187 $("#projectid").change(function () {
2188 var url = "'.$url.
'&projectid="+$("#projectid").val();
2189 $.get(url, function(data) {
2190 console.log($( data ).find("#fk_element").html());
2191 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2195 print
'</script>'.
"\n";
2197 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1),
$object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500',
$object->fk_project);
2198 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2204 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2205 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2213 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2215 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2216 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2217 $doleditor->Create();
2221 $parameters = array();
2222 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2223 print $hookmanager->resPrint;
2224 if (empty($reshook)) {
2225 print
$object->showOptionals($extrafields,
'edit', $parameters);
2232 $filteruserid = $user->id;
2233 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2236 $object->loadReminders(
'', $filteruserid,
false);
2240 if (count(
$object->reminders) > 0) {
2241 $checked =
'checked';
2242 $keys = array_keys(
$object->reminders);
2243 $firstreminderId = array_shift($keys);
2245 $actionCommReminder =
$object->reminders[$firstreminderId];
2249 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2250 $actionCommReminder->offsetunit =
'i';
2251 $actionCommReminder->typeremind =
'email';
2258 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>';
2260 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2264 print
'<table class="border centpercent">';
2267 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2268 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2269 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2273 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2274 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2278 if ($actionCommReminder->typeremind ==
'browser') {
2279 $hide =
'style="display:none;"';
2284 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2285 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
2291 print
"\n".
'<script type="text/javascript">';
2292 print
'$(document).ready(function () {
2293 $("#addreminder").click(function(){
2295 $(".reminderparameters").show();
2297 $(".reminderparameters").hide();
2301 $("#selectremindertype").change(function(){
2302 var selected_option = $("#selectremindertype option:selected").val();
2303 if(selected_option == "email") {
2304 $("#select_actioncommsendmodel_mail").closest("tr").show();
2306 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2311 print
'</script>'.
"\n";
2318 print $form->buttonsSaveCancel();
2327 if ($action ==
'clone') {
2328 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent',
$object->label),
'confirm_clone', array(),
'yes', 1);
2332 $parameters = array();
2333 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2334 if (empty($reshook)) {
2335 $formconfirm .= $hookmanager->resPrint;
2336 } elseif ($reshook > 0) {
2337 $formconfirm = $hookmanager->resPrint;
2345 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
2346 $linkback .=
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="pictoactionview pictofixedwidth"');
2347 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"BackToList").
'</span>';
2348 $linkback .=
'</a>';
2349 $linkback .=
'</li>';
2350 $linkback .=
'<li class="noborder litext">';
2352 $linkback .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview pictofixedwidth"');
2353 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span>';
2354 $linkback .=
'</a>';
2355 $linkback .=
'</li>';
2356 $linkback .=
'<li class="noborder litext">';
2358 $linkback .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview pictofixedwidth"');
2359 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span>';
2360 $linkback .=
'</a>';
2361 $linkback .=
'</li>';
2362 $linkback .=
'<li class="noborder litext">';
2364 $linkback .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview pictofixedwidth"');
2365 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span>';
2366 $linkback .=
'</a>';
2367 $linkback .=
'</li>';
2368 $linkback .=
'<li class="noborder litext">';
2370 $linkback .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview pictofixedwidth"');
2371 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span>';
2372 $linkback .=
'</a>';
2375 $parameters = array();
2376 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters,
$object, $action);
2377 if (empty($reshook)) {
2378 $linkback .= $hookmanager->resPrint;
2379 } elseif ($reshook > 1) {
2380 $linkback = $hookmanager->resPrint;
2385 $morehtmlref =
'<div class="refidno">';
2389 if (isModEnabled(
'project')) {
2390 $langs->load(
"projects");
2392 if ($usercancreate) {
2393 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2394 if ($action !=
'classify') {
2395 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2397 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2399 if (!empty(
$object->fk_project)) {
2401 $proj->fetch(
$object->fk_project);
2402 $morehtmlref .= $proj->getNomUrl(1);
2404 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2409 $morehtmlref .=
'</div>';
2412 dol_banner_tab(
$object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
2414 print
'<div class="fichecenter">';
2415 print
'<div class="fichehalfleft">';
2417 print
'<div class="underbanner clearboth"></div>';
2420 print
'<table class="border tableforfield centpercent">';
2424 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2425 $labeltoshow = $langs->trans(
"Action".
$object->type_code);
2427 $labeltoshow .=
' ('.$object->code.
')';
2429 print
$object->getTypePicto(
'pictofixedwidth paddingright', $labeltoshow);
2430 print $langs->trans(
"Action".
$object->type_code);
2435 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn(
$object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2439 print
'<tr><td class="titlefield">'.$langs->trans(
"EventIntoASerie").
'</td><td>'.
dol_escape_htmltag(
$object->recurid).
'</td></tr>';
2448 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2453 if (empty(
$object->fulldayevent)) {
2466 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2467 if (empty(
$object->fulldayevent)) {
2480 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.
$object->location.
'</td></tr>';
2484 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2485 $listofuserid = array();
2486 if (empty($donotclearsession)) {
2487 if (
$object->userownerid > 0) {
2488 $listofuserid[
$object->userownerid] = array(
2490 'transparency' =>
$object->transparency,
2491 'answer_status' =>
$object->userassigned[
$object->userownerid][
'answer_status'],
2492 'mandatory' =>
$object->userassigned[
$object->userownerid][
'mandatory']
2495 if (!empty(
$object->userassigned)) {
2497 $tmplist1 =
$object->userassigned;
2498 foreach ($tmplist1 as $key => $val) {
2499 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2500 $listofuserid[$val[
'id']] = $val;
2504 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2506 if (!empty($_SESSION[
'assignedtouser'])) {
2507 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2511 $listofcontactid = array();
2512 $listofotherid = array();
2513 print
'<div class="assignedtouser">';
2514 print $form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', (
$object->datep !=
$object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2524 print
' </td></tr>';
2527 if (isModEnabled(
'category')) {
2528 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2529 print $form->showCategories(
$object->id, Categorie::TYPE_ACTIONCOMM, 1);
2537 print
'<div class="fichehalfright">';
2539 print
'<div class="underbanner clearboth"></div>';
2540 print
'<table class="border tableforfield centpercent">';
2542 if (isModEnabled(
"societe")) {
2544 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td>';
2545 print
'<td>'.(is_object(
$object->thirdparty) &&
$object->thirdparty->id ?
$object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2546 if (is_object(
$object->thirdparty) &&
$object->thirdparty->id > 0 &&
$object->type_code ==
'AC_TEL') {
2548 print
"<br>".dol_print_phone(
$object->thirdparty->phone);
2554 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2557 if (!empty(
$object->socpeopleassigned)) {
2558 foreach (
$object->socpeopleassigned as $cid => $Tab) {
2560 $result = $contact->fetch($cid);
2567 print $contact->getNomUrl(1);
2568 if (
$object->type_code ==
'AC_TEL') {
2569 if (!empty($contact->phone_pro)) {
2570 print
'('.dol_print_phone($contact->phone_pro).
')';
2573 print
'<div class="paddingright"></div>';
2577 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2584 print
'<tr><td class="nowrap" class="titlefield">' . $langs->trans(
"Priority") .
'</td><td>';
2591 if (!empty(
$object->fk_element) && !empty(
$object->elementtype) && !in_array(
$object->elementtype, array(
'societe',
'contact',
'project'))) {
2592 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2593 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2597 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2605 if (!empty(
$object->email_msgid)) {
2606 print
'<tr><td>'.$langs->trans(
'MailTopic').
'</td>';
2607 print
'<td>'.dol_escape_htmltag(
$object->email_subject).
'</td></tr>';
2608 print
'<tr><td>'.$langs->trans(
'MailFrom').
'</td>';
2609 print
'<td>'.dol_escape_htmltag(
$object->email_from).
'</td></tr>';
2610 print
'<tr><td>'.$langs->trans(
'MailTo').
'</td>';
2611 print
'<td>'.dol_escape_htmltag(
$object->email_to).
'</td></tr>';
2612 if (!empty(
$object->email_tocc)) {
2613 print
'<tr><td>'.$langs->trans(
'MailCC').
'</td>';
2614 print
'<td>'.dol_escape_htmltag(
$object->email_tocc).
'</td></tr>';
2619 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak sensiblehtmlcontent">';
2624 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2628 $filteruserid = $user->id;
2629 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2632 $object->loadReminders(
'', $filteruserid,
false);
2634 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2636 if (count(
$object->reminders) > 0) {
2637 $tmpuserstatic =
new User($db);
2639 foreach (
$object->reminders as $actioncommreminderid => $actioncommreminder) {
2640 print $TRemindTypes[$actioncommreminder->typeremind][
'label'];
2641 if ($actioncommreminder->fk_user > 0) {
2642 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2643 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2645 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2647 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2648 print
' - <span class="opacitymedium">';
2649 print $langs->trans(
"NotSent");
2651 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2652 print
' - <span class="opacitymedium">';
2653 print $langs->trans(
"Done");
2655 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2656 print
' - <span class="opacitymedium">';
2657 print $form->textwithpicto($langs->trans(
"Error"), $actioncommreminder->lasterror);
2671 print
'<div class="clearboth"></div>';
2680 print
'<div class="tabsAction">';
2682 $parameters = array();
2683 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
2684 if (empty($reshook)) {
2685 if ($action !=
'edit') {
2686 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2687 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2688 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2690 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2693 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2694 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2695 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>';
2697 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2700 if ($user->hasRight(
'agenda',
'allactions',
'delete') ||
2701 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'))) {
2702 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2704 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2711 if ($action !=
'edit') {
2713 print
'<div class="clearboth"></div><div class="fichecenter"><div class="fichehalfleft">';
2714 print
'<a name="builddoc"></a>';
2720 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.
$object->id;
2721 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2723 $genallowed = $user->hasRight(
'agenda',
'myactions',
'read');
2724 $delallowed = $user->hasRight(
'agenda',
'myactions',
'create');
2727 print $formfile->showdocuments(
'actions',
$object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2729 print
'</div><div class="fichehalfright">';
2732 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()
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...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles=1, $removeclassattribute=1, $cleanalsojavascript=0, $allowiframe=0, $allowed_tags=array(), $allowlink=0)
Clean a string to keep only desirable HTML tags.
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 =...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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...
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.