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') {
127 $ret =
$object->fetch_optionals();
128 $ret1 =
$object->fetch_userassigned();
130 if ($ret < 0 || $ret1 < 0) {
136$extrafields->fetch_name_optionals_label(
$object->table_element);
139$hookmanager->initHooks(array(
'actioncard',
'globalcard'));
141$parameters = array(
'socid' => $socid);
142$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
147$TRemindTypes = array();
149 $TRemindTypes[
'browser'] = array(
'label' => $langs->trans(
'BrowserPush'),
'disabled' => (!
getDolGlobalString(
'AGENDA_REMINDER_BROWSER') ? 1 : 0));
152 $TRemindTypes[
'email'] = array(
'label' => $langs->trans(
'EMail'),
'disabled' => (!
getDolGlobalString(
'AGENDA_REMINDER_EMAIL') ? 1 : 0));
155$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'));
157$result =
restrictedArea($user,
'agenda',
$object,
'actioncomm&societe',
'myactions|allactions',
'fk_soc',
'id');
159$usercancreate = $user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'));
166$listUserAssignedUpdated =
false;
167$listResourceAssignedUpdated =
false;
168$assignedtouser = array();
171if (empty($reshook) && (
GETPOST(
'removedassigned') ||
GETPOST(
'removedassigned') ==
'0')) {
172 $idtoremove =
GETPOST(
'removedassigned');
174 if (!empty($_SESSION[
'assignedtouser'])) {
175 $tmpassigneduserids = json_decode($_SESSION[
'assignedtouser'],
true);
177 $tmpassigneduserids = array();
180 foreach ($tmpassigneduserids as $key => $val) {
181 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
182 unset($tmpassigneduserids[$key]);
186 $_SESSION[
'assignedtouser'] = json_encode($tmpassigneduserids);
187 $donotclearsession = 1;
188 if ($action ==
'add') {
191 if ($action ==
'update') {
195 $listUserAssignedUpdated =
true;
198if (empty($reshook) && (
GETPOST(
'removedassignedresource') ||
GETPOST(
'removedassignedresource') ==
'0')) {
199 $idtoremove =
GETPOST(
'removedassignedresource');
201 if (!empty($_SESSION[
'assignedtoresource'])) {
202 $tmpassignedresourceids = json_decode($_SESSION[
'assignedtoresource'],
true);
204 $tmpassignedresourceids = array();
207 foreach ($tmpassignedresourceids as $key => $val) {
208 if ($val[
'id'] == $idtoremove || $val[
'id'] == -1) {
209 unset($tmpassignedresourceids[$key]);
213 $_SESSION[
'assignedtoresource'] = json_encode($tmpassignedresourceids);
214 $donotclearsessionresource = 1;
215 if ($action ==
'add') {
218 if ($action ==
'update') {
222 $listResourceAssignedUpdated =
true;
226if (empty($reshook) && (
GETPOST(
'addassignedtouser') ||
GETPOST(
'updateassignedtouser'))) {
228 if (
GETPOST(
'assignedtouser') > 0) {
229 $assignedtouser = array();
230 if (!empty($_SESSION[
'assignedtouser'])) {
231 $assignedtouser = json_decode($_SESSION[
'assignedtouser'],
true);
233 $assignedtouser[
GETPOST(
'assignedtouser')] = array(
'id' =>
GETPOSTINT(
'assignedtouser'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
234 $_SESSION[
'assignedtouser'] = json_encode($assignedtouser);
236 $donotclearsession = 1;
237 if ($action ==
'add') {
240 if ($action ==
'update') {
244 $listUserAssignedUpdated =
true;
248if (empty($reshook) && (
GETPOST(
'addassignedtoresource') ||
GETPOST(
'updateassignedtoresource'))) {
250 if (
GETPOST(
'assignedtoresource') > 0) {
251 $assignedtoresource = array();
252 if (!empty($_SESSION[
'assignedtoresource'])) {
253 $assignedtoresource = json_decode($_SESSION[
'assignedtoresource'],
true);
255 $assignedtoresource[
GETPOST(
'assignedtoresource')] = array(
'id' =>
GETPOSTINT(
'assignedtoresource'),
'transparency' =>
GETPOST(
'transparency'),
'mandatory' => 1);
256 $_SESSION[
'assignedtoresource'] = json_encode($assignedtoresource);
258 $donotclearsession = 1;
259 if ($action ==
'add') {
262 if ($action ==
'update') {
266 $listResourceAssignedUpdated =
true;
270if (empty($reshook) && $action ==
'classin' && ($user->hasRight(
'agenda',
'allactions',
'create') ||
271 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create')))) {
277if (empty($reshook) && $action ==
'confirm_clone' && $confirm ==
'yes') {
278 if (1 == 0 && !
GETPOST(
'clone_content') && !
GETPOST(
'clone_receivers')) {
283 if (!empty(
$object->socpeopleassigned)) {
284 reset(
$object->socpeopleassigned);
289 header(
"Location: ".$_SERVER[
'PHP_SELF'].
'?id='.$result);
300if (empty($reshook) && $action ==
'add') {
303 if (empty($backtopage)) {
305 $backtopage = DOL_URL_ROOT.
'/societe/agenda.php?socid='.$socid;
307 $backtopage = DOL_URL_ROOT.
'/comm/action/index.php';
311 if (!empty($socpeopleassigned[0])) {
312 $result = $contact->fetch($socpeopleassigned[0]);
316 header(
"Location: ".$backtopage);
320 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
334 if (!$datef && $percentage == 100) {
336 $donotclearsession = 1;
338 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
343 $donotclearsession = 1;
345 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Title")),
null,
'errors');
349 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
351 $donotclearsession = 1;
353 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
361 $object->fulldayevent = ($fulldayevent ? 1 : 0);
365 if (
GETPOST(
"elementtype",
'alpha')) {
367 $modulecodetouseforpermissioncheck = $elProp[
'module'];
369 $hasPermissionOnLinkedObject = 0;
370 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
371 $hasPermissionOnLinkedObject = 1;
373 if ($hasPermissionOnLinkedObject) {
380 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
381 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
383 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
384 $object->label = $langs->transnoentitiesnoconv(
"Action".
$object->type_code).
"\n";
386 $cactioncomm->fetch(
$object->type_code);
387 $object->label = $cactioncomm->label;
394 if (!empty($taskid)) {
395 $taskProject =
new Task($db);
396 if ($taskProject->fetch($taskid) > 0) {
397 $object->fk_project = $taskProject->fk_project;
406 $object->percentage = $percentage;
409 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
411 $listofuserid = array();
412 if (!empty($_SESSION[
'assignedtouser'])) {
413 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
416 foreach ($listofuserid as $key => $value) {
418 if ($value[
'id'] > 0) {
419 $object->userownerid = $value[
'id'];
421 $object->transparency = $transparency;
424 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
432 if (GETPOSTISSET(
"contactid")) {
444 if (empty(
$object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
446 $donotclearsession = 1;
448 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
450 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
452 $donotclearsession = 1;
454 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
459 $donotclearsession = 1;
461 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
464 foreach ($socpeopleassigned as $cid) {
465 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
467 if (!empty(
$object->socpeopleassigned)) {
468 reset(
$object->socpeopleassigned);
473 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
476 $donotclearsession = 1;
485 $selectedrecurrulefreq =
'no';
486 $selectedrecurrulebymonthday =
'';
487 $selectedrecurrulebyday =
'';
488 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
489 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY' && GETPOSTISSET(
'BYMONTHDAY')) ?
"_BYMONTHDAY".
GETPOST(
'BYMONTHDAY',
'alpha') :
"";
490 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY' && GETPOSTISSET(
'BYDAY')) ?
"_BYDAY".
GETPOST(
'BYDAY',
'alpha') :
"";
495 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
496 $selectedrecurrulefreq = $reg1[1];
498 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
499 $selectedrecurrulebymonthday = (int) $reg2[1];
501 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
502 $selectedrecurrulebyday = (int) $reg3[1];
506 $eventisrecurring = 0;
507 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 2 ? 1 : 0);
508 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
509 $eventisrecurring = 1;
519 $idaction =
$object->create($user);
524 $categories =
GETPOST(
'categories',
'array');
525 $object->setCategories($categories);
527 unset($_SESSION[
'assignedtouser']);
530 if ($user->id !=
$object->userownerid) {
531 $moreparam =
"filtert=-1";
535 if ($addreminder ==
'on') {
540 $actionCommReminder->dateremind = $dateremind;
541 $actionCommReminder->typeremind = $remindertype;
542 $actionCommReminder->offsetunit = $offsetunit;
543 $actionCommReminder->offsetvalue = $offsetvalue;
544 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
545 $actionCommReminder->fk_actioncomm =
$object->id;
546 if ($remindertype ==
'email') {
547 $actionCommReminder->fk_email_template = $modelmail;
551 foreach (
$object->userassigned as $userassigned) {
552 $actionCommReminder->fk_user = $userassigned[
'id'];
553 $res = $actionCommReminder->create($user);
558 $langs->load(
"errors");
559 $error = $langs->trans(
'ErrorReminderActionCommCreation');
562 $donotclearsession = 1;
573 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
593 $langs->load(
"errors");
594 $error = $langs->trans(
$object->error);
597 $donotclearsession = 1;
603 $donotclearsession = 1;
606 if ($eventisrecurring) {
608 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
610 $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');
614 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
615 $firstday = $selectedrecurrulebymonthday;
624 $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');
630 while ($datep <= $repeateventlimitdate && !$error) {
634 $finalobject->datep = $datep;
635 $finalobject->datef = $datef;
637 $idaction = $finalobject->create($user);
640 if (!$finalobject->error) {
642 $categories =
GETPOST(
'categories',
'array');
643 $finalobject->setCategories($categories);
645 unset($_SESSION[
'assignedtouser']);
648 if ($user->id != $finalobject->userownerid) {
649 $moreparam =
"filtert=-1";
653 if ($addreminder ==
'on') {
658 $actionCommReminder->dateremind = $dateremind;
659 $actionCommReminder->typeremind = $remindertype;
660 $actionCommReminder->offsetunit = $offsetunit;
661 $actionCommReminder->offsetvalue = $offsetvalue;
662 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
663 $actionCommReminder->fk_actioncomm = $finalobject->id;
664 if ($remindertype ==
'email') {
665 $actionCommReminder->fk_email_template = $modelmail;
669 foreach ($finalobject->userassigned as $userassigned) {
670 $actionCommReminder->fk_user = $userassigned[
'id'];
671 $res = $actionCommReminder->create($user);
676 $langs->load(
"errors");
677 $error = $langs->trans(
'ErrorReminderActionCommCreation');
680 $donotclearsession = 1;
691 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
701 $langs->load(
"errors");
702 $error = $langs->trans($finalobject->error);
705 $donotclearsession = 1;
711 $donotclearsession = 1;
715 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
726 if (!empty($backtopage) && !$error) {
727 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
728 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
729 } elseif ($idaction) {
730 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
732 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
741if (empty($reshook) && $action ==
'update') {
742 if (empty($cancel)) {
743 $fulldayevent =
GETPOST(
'fullday');
748 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
773 $datep =
dol_mktime(
'00',
'00',
'00',
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
774 $datef =
dol_mktime(
'23',
'59',
'59',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
776 $datep =
dol_mktime(
GETPOST(
"aphour",
'int'),
GETPOST(
"apmin",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuserrel');
777 $datef =
dol_mktime(
GETPOST(
"p2hour",
'int'),
GETPOST(
"p2min",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuserrel');
780 $datef = (!$datef && $percentage == 100)?
dol_now():$datef;
782 if (
$object->elementtype ==
'ticket') {
784 if (
$object->code ==
'TICKET_MSG') {
785 $object->code =
'TICKET_MSG_PRIVATE';
787 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
788 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
791 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
794 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
795 $object->code =
'TICKET_MSG_SENTBYMAIL';
807 $object->percentage = $percentage;
812 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
813 $object->socpeopleassigned = array();
814 foreach ($socpeopleassigned as $cid) {
815 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
818 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
819 reset(
$object->socpeopleassigned);
825 if (
GETPOST(
"elementtype",
'alpha')) {
827 $modulecodetouseforpermissioncheck = $elProp[
'module'];
829 $hasPermissionOnLinkedObject = 0;
830 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
831 $hasPermissionOnLinkedObject = 1;
833 if ($hasPermissionOnLinkedObject) {
840 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
843 $listofuserid = array();
844 if (!empty($_SESSION[
'assignedtouser'])) {
846 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
847 foreach ($tmplist1 as $key => $val) {
848 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
849 $listofuserid[$val[
'id']] = $val;
853 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
854 if ($assignedtouser) {
855 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
858 $object->userassigned = array();
861 foreach ($listofuserid as $key => $val) {
863 $object->userownerid = $val[
'id'];
865 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
869 $object->transparency = $transparency;
873 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
875 $donotclearsession = 1;
877 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
879 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
881 if (empty(
$object->userownerid)) {
883 $donotclearsession = 1;
885 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
889 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
897 $eventDateStart =
$object->datep;
898 $eventDateEnd =
$object->datef;
900 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
901 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
902 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
903 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
904 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
905 $sql .=
" AND er.resource_id IN (";
906 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
907 $sql .=
" WHERE element_id = ".((int)
$object->id);
908 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
909 $sql .=
" AND busy = 1";
911 $sql .=
" AND er.busy = 1";
915 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
917 if (!empty($eventDateEnd)) {
918 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
922 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
923 if (!empty($eventDateEnd)) {
924 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
929 $resql = $db->query($sql);
932 $object->error = $db->lasterror();
935 if ($db->num_rows($resql) > 0) {
938 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
939 while ($obj = $db->fetch_object($resql)) {
940 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
956 $result =
$object->update($user);
960 $categories =
GETPOST(
'categories',
'array');
961 $object->setCategories($categories);
963 $object->loadReminders($remindertype, 0,
false);
966 if (!empty(
$object->reminders)) {
967 foreach (
$object->reminders as $reminder) {
968 if ($reminder->status < 1) {
969 $reminder->delete($user);
976 if ($addreminder ==
'on') {
981 $actionCommReminder->dateremind = $dateremind;
982 $actionCommReminder->typeremind = $remindertype;
983 $actionCommReminder->offsetunit = $offsetunit;
984 $actionCommReminder->offsetvalue = $offsetvalue;
985 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
986 $actionCommReminder->fk_actioncomm =
$object->id;
987 if ($remindertype ==
'email') {
988 $actionCommReminder->fk_email_template = $modelmail;
992 foreach (
$object->userassigned as $userassigned) {
993 $actionCommReminder->fk_user = $userassigned[
'id'];
994 $res = $actionCommReminder->create($user);
998 $langs->load(
"errors");
999 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1002 $donotclearsession = 1;
1008 unset($_SESSION[
'assignedtouser']);
1009 unset($_SESSION[
'assignedtoresource']);
1024 if (!empty($backtopage)) {
1025 unset($_SESSION[
'assignedtouser']);
1026 header(
"Location: ".$backtopage);
1033if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
1036 $object->fetch_userassigned();
1039 if ($user->hasRight(
'agenda',
'myactions',
'delete')
1040 || $user->hasRight(
'agenda',
'allactions',
'delete')) {
1041 $result =
$object->delete($user);
1044 header(
"Location: index.php");
1056if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
1062 $newdate =
GETPOST(
'newdate',
'alpha');
1063 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1064 header(
"Location: ".$backtopage,
true, 307);
1068 $datep =
dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4),
'tzuserrel');
1071 if ($datep !=
$object->datep) {
1080 $eventDateStart =
$object->datep;
1081 $eventDateEnd =
$object->datef;
1083 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1084 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1085 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1086 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1087 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1088 $sql .=
" AND er.resource_id IN (";
1089 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1090 $sql .=
" WHERE element_id = ".((int)
$object->id);
1091 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1092 $sql .=
" AND busy = 1";
1094 $sql .=
" AND er.busy = 1";
1098 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1100 if (!empty($eventDateEnd)) {
1101 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1105 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1106 if (!empty($eventDateEnd)) {
1107 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1112 $resql = $db->query($sql);
1115 $object->error = $db->lasterror();
1118 if ($db->num_rows($resql) > 0) {
1121 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1122 while ($obj = $db->fetch_object($resql)) {
1123 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1138 $result =
$object->update($user);
1148 if (!empty($backtopage)) {
1149 header(
"Location: ".$backtopage,
true, 307);
1158$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1159if (empty($reshook)) {
1160 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1168$form =
new Form($db);
1171$arrayrecurrulefreq = array(
1172 'no' => $langs->trans(
"OnceOnly"),
1173 'MONTHLY' => $langs->trans(
"EveryMonth"),
1174 'WEEKLY' => $langs->trans(
"EveryWeek")
1179$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1180llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1182if ($action ==
'create') {
1185 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1186 if (!empty($socpeopleassigned[0])) {
1187 $result = $contact->fetch($socpeopleassigned[0]);
1195 if (!empty($conf->use_javascript_ajax)) {
1196 print
"\n".
'<script type="text/javascript">';
1197 print
'$(document).ready(function () {
1198 function setdatefields()
1200 if ($("#fullday:checked").val() == null) {
1201 $(".fulldaystarthour").removeAttr("disabled");
1202 $(".fulldaystartmin").removeAttr("disabled");
1203 $(".fulldayendhour").removeAttr("disabled");
1204 $(".fulldayendmin").removeAttr("disabled");
1205 $("#p2").removeAttr("disabled");
1207 $(".fulldaystarthour").prop("disabled", true).val("00");
1208 $(".fulldaystartmin").prop("disabled", true).val("00");
1209 $(".fulldayendhour").prop("disabled", true).val("23");
1210 $(".fulldayendmin").prop("disabled", true).val("59");
1211 $("#p2").removeAttr("disabled");
1214 $("#fullday").change(function() {
1215 console.log("setdatefields");
1219 $("#actioncode").change(function() {
1220 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1221 else $("#dateend").removeClass("fieldrequired");
1223 $("#aphour,#apmin").change(function() {
1224 if ($("#actioncode").val() == \'AC_RDV\') {
1225 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1226 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1227 $("#p2min").val($("#apmin").val());
1228 $("#p2day").val($("#apday").val());
1229 $("#p2month").val($("#apmonth").val());
1230 $("#p2year").val($("#apyear").val());
1231 $("#p2").val($("#ap").val());
1234 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1235 else $("#dateend").removeClass("fieldrequired");
1238 print
'</script>'.
"\n";
1241 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1242 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1243 print
'<input type="hidden" name="action" value="add">';
1244 print
'<input type="hidden" name="donotclearsession" value="1">';
1245 print
'<input type="hidden" name="page_y" value="">';
1247 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1250 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1253 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1254 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1261 print
'<table class="border centpercent">';
1265 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1267 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1268 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1269 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1274 print
'<tr><td'.(!
getDolGlobalString(
'AGENDA_USE_EVENT_TYPE') ?
' class="fieldrequired titlefieldcreate"' :
'').
'>'.$langs->trans(
"Label").
'</td><td><input type="text" id="label" name="label" class="soixantepercent" value="'.
GETPOST(
'label').
'"></td></tr>';
1277 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1278 print
'<td class="valignmiddle height30 small"><input class="valignmiddle" type="checkbox" id="fullday" name="fullday" '.(GETPOST(
'fullday') ?
' checked' :
'').
'><label for="fullday" class="valignmiddle">'.$langs->trans(
"EventOnFullDay").
'</label>';
1281 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0);
1282 if ($userepeatevent) {
1285 print
' <div class="opacitymedium inline-block">';
1286 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 6px" class="paddingright2"');
1287 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1289 $selectedrecurrulefreq =
'no';
1290 $selectedrecurrulebymonthday =
'';
1291 $selectedrecurrulebyday =
'';
1292 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1293 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1294 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1298 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1299 $selectedrecurrulefreq = $reg[1];
1301 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1302 $selectedrecurrulebymonthday = (int) $reg[1];
1304 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1305 $selectedrecurrulebyday = (int) $reg[1];
1308 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1314 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1315 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1318 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1319 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1322 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1323 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1324 print $langs->trans(
"Until").
" ";
1325 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1328 print
'<script type="text/javascript">
1329 jQuery(document).ready(function() {
1330 function init_repeat()
1332 console.log("recurrule: " + "'.$object->recurrule.
'");
1333 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1334 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1335 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1336 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1337 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1339 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1340 jQuery(".repeateventlimitdate").css("display", "inline-block");
1341 jQuery(".repeateventBYDAY").hide();
1343 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1345 jQuery(".repeateventBYMONTHDAY").hide();
1346 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1347 jQuery(".repeateventlimitdate").css("display", "inline-block");
1351 jQuery(".repeateventBYMONTHDAY").hide();
1352 jQuery(".repeateventBYDAY").hide();
1353 jQuery(".repeateventlimitdate").hide();
1357 jQuery("#recurrulefreq").change(function() {
1368 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1372 $datef = ($datef ? $datef :
$object->datef);
1376 if (empty($datef) && !empty($datep)) {
1383 print
'<tr><td class="nowrap">';
1386 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1388 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1390 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1391 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1394 print
'<tr><td class=""> </td><td></td></tr>';
1397 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1398 $listofuserid = array();
1399 $listofcontactid = array();
1400 $listofotherid = array();
1402 if (empty($donotclearsession)) {
1404 if ($assignedtouser) {
1405 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1408 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1409 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1411 if (!empty($_SESSION[
'assignedtouser'])) {
1412 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1414 $firstelem = reset($listofuserid);
1415 if (isset($listofuserid[$firstelem[
'id']])) {
1416 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1419 print
'<div class="assignedtouser">';
1420 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1426 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>';
1429 if (isModEnabled(
'category')) {
1431 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1432 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
1433 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1437 if (isModEnabled(
'resource')) {
1439 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1441 $listofresourceid = array();
1442 if (empty($donotclearsession)) {
1443 $assignedtoresource =
GETPOST(
"assignedtoresource");
1444 if ($assignedtoresource) {
1445 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1447 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1449 if (!empty($_SESSION[
'assignedtoresource'])) {
1450 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1452 $firstelem = reset($listofresourceid);
1453 if (isset($listofresourceid[$firstelem[
'id']])) {
1454 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1457 print
'<div class="assignedtoresource">';
1458 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1464 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1466 $percent = $complete !==
'' ? $complete : -1;
1467 if (GETPOSTISSET(
'status')) {
1469 } elseif (GETPOSTISSET(
'percentage')) {
1472 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1474 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1478 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1484 print
'<br><hr><br>';
1487 print
'<table class="border centpercent">';
1489 if (isModEnabled(
"societe")) {
1491 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1495 print $societe->getNomUrl(1);
1496 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1499 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1501 if (!empty($user->socid)) {
1502 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1504 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1510 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1511 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1515 if ($origin ==
'contact') {
1521 $select_contact_default = 0;
1523 $select_contact_default = -1;
1525 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1527 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
1534 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1535 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, array(), false,
'multiple',
'contactid');
1536 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1538 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, array(), false,
'multiple',
'contactid');
1545 if (isModEnabled(
'project')) {
1546 $langs->load(
"projects");
1550 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1551 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1552 print $formproject->select_projects((
$object->socid > 0 ?
$object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx maxwidth500');
1554 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1555 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1556 $urloption =
'?action=create&donotclearsession=1';
1560 print
"\n".
'<script type="text/javascript">';
1561 print
'$(document).ready(function () {
1562 $("#projectid").change(function () {
1563 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1564 console.log("Call url to get new list of tasks: "+url);
1565 $.get(url, function(data) {
1567 if (data) $("#taskid").html(data).select2();
1571 print
'</script>'.
"\n";
1576 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1577 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1578 $projectsListId =
false;
1579 if (!empty($projectid)) {
1580 $projectsListId = $projectid;
1583 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1585 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', $projectsListId);
1590 if (!empty($origin) && !empty($originid)) {
1591 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1593 $hasPermissionOnLinkedObject = 0;
1596 if ($user->hasRight($elProp[
'module'],
'read') || $user->hasRight($elProp[
'module'], $elProp[
'element'],
'read')) {
1597 $hasPermissionOnLinkedObject = 1;
1601 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1603 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1604 print
'<td colspan="3">';
1605 if ($hasPermissionOnLinkedObject) {
1607 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1608 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1609 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1610 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1612 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1620 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1621 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1626 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1627 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1628 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 120,
'dolibarr_notes',
'In', true, true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1629 $doleditor->Create();
1633 $parameters = array();
1634 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1635 print $hookmanager->resPrint;
1636 if (empty($reshook)) {
1637 print
$object->showOptionals($extrafields,
'create', $parameters);
1647 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1649 print
'<div class="reminderparameters" style="display: none;">';
1651 print
'<table class="border centpercent">';
1654 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1655 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1656 print $form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1660 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1661 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1666 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1667 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1674 print
"\n".
'<script type="text/javascript">';
1675 print
'$(document).ready(function () {
1676 $("#addreminder").click(function(){
1677 console.log("Click on addreminder");
1679 $(".reminderparameters").show();
1681 $(".reminderparameters").hide();
1683 $("#selectremindertype").select2("destroy");
1684 $("#selectremindertype").select2();
1685 $("#select_offsetunittype_duration").select2("destroy");
1686 $("#select_offsetunittype_duration").select2();
1687 selectremindertype();
1690 $("#selectremindertype").change(function(){
1691 selectremindertype();
1694 function selectremindertype() {
1695 console.log("Call selectremindertype");
1696 var selected_option = $("#selectremindertype option:selected").val();
1697 if(selected_option == "email") {
1698 $("#select_actioncommsendmodel_mail").closest("tr").show();
1700 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1705 print
'</script>'.
"\n";
1710 print $form->buttonsSaveCancel(
"Add");
1717 $result1 =
$object->fetch($id);
1718 if ($result1 <= 0) {
1719 $langs->load(
"errors");
1720 print $langs->trans(
"ErrorRecordNotFound");
1726 $result2 =
$object->fetch_thirdparty();
1727 $result2 =
$object->fetch_projet();
1728 $result3 =
$object->fetch_contact();
1729 $result4 =
$object->fetch_userassigned();
1730 $result5 =
$object->fetch_optionals();
1732 if ($listUserAssignedUpdated || $donotclearsession) {
1733 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
1742 $object->percentage = $percentage;
1747 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1748 foreach ($socpeopleassigned as $tmpid) {
1749 $object->socpeopleassigned[$id] = array(
'id' => $tmpid);
1757 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1763 $tmpuser =
new User($db);
1764 $res = $tmpuser->fetch(
$object->authorid);
1768 $tmpuser =
new User($db);
1769 $res = $tmpuser->fetch(
$object->usermodid);
1781 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
1785 if ($action ==
'delete') {
1786 print $form->formconfirm(
"card.php?id=".urlencode((
string) ($id)), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1789 if ($action ==
'edit') {
1790 if (!empty($conf->use_javascript_ajax)) {
1791 print
"\n".
'<script type="text/javascript">';
1792 print
'$(document).ready(function () {
1793 function setdatefields()
1795 if ($("#fullday:checked").val() == null) {
1796 $(".fulldaystarthour").removeAttr("disabled");
1797 $(".fulldaystartmin").removeAttr("disabled");
1798 $(".fulldayendhour").removeAttr("disabled");
1799 $(".fulldayendmin").removeAttr("disabled");
1801 $(".fulldaystarthour").prop("disabled", true).val("00");
1802 $(".fulldaystartmin").prop("disabled", true).val("00");
1803 $(".fulldayendhour").prop("disabled", true).val("23");
1804 $(".fulldayendmin").prop("disabled", true).val("59");
1808 $("#fullday").change(function() {
1811 $("#actioncode").change(function() {
1812 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1813 else $("#dateend").removeClass("fieldrequired");
1816 print
'</script>'.
"\n";
1819 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1820 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1821 print
'<input type="hidden" name="action" value="update">';
1822 print
'<input type="hidden" name="id" value="'.$id.
'">';
1823 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
1824 print
'<input type="hidden" name="page_y" value="">';
1826 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1829 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1834 print
'<table class="border tableforfield" width="100%">';
1837 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.
$object->id.
'</td></tr>';
1841 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
1842 if (
$object->type_code !=
'AC_OTH_AUTO') {
1843 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1844 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
1846 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1847 print
$object->getTypePicto();
1848 print $langs->trans(
"Action".
$object->type_code);
1854 if (
$object->elementtype ==
'ticket') {
1855 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
1856 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1857 print
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
1861 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>';
1864 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' :
'').
'>';
1865 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
1928 print
'<tr><td class="nowrap">';
1933 print
'</td><td td colspan="3">';
1935 print $form->selectDate($datep ? $datep :
$object->datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
$object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1936 print
' <span class="hideonsmartphone"> - </span> ';
1937 print $form->selectDate($datef ? $datef :
$object->datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
$object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1940 print
'<tr><td class=""> </td><td></td></tr>';
1943 $listofuserid = array();
1944 if (empty($donotclearsession)) {
1945 if (
$object->userownerid > 0) {
1946 $listofuserid[
$object->userownerid] = array(
1950 'transparency' =>
$object->transparency,
1951 'answer_status' =>
$object->userassigned[
$object->userownerid][
'answer_status'],
1952 'mandatory' =>
$object->userassigned[
$object->userownerid][
'mandatory']
1955 if (!empty(
$object->userassigned)) {
1957 $tmplist1 =
$object->userassigned;
1958 foreach ($tmplist1 as $key => $val) {
1959 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
1960 $listofuserid[$val[
'id']] = $val;
1964 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1966 if (!empty($_SESSION[
'assignedtouser'])) {
1967 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1970 $listofcontactid =
$object->socpeopleassigned;
1971 $listofotherid =
$object->otherassigned;
1973 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
1974 print
'<div class="assignedtouser">';
1975 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1987 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.
$object->location.
'"></td></tr>';
1991 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
1992 $percent = GETPOSTISSET(
"percentage") ?
GETPOSTINT(
"percentage") :
$object->percentage;
1993 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1997 if (isModEnabled(
'category')) {
1998 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1999 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
2001 $cats = $c->containing(
$object->id, Categorie::TYPE_ACTIONCOMM);
2002 $arrayselected = array();
2003 foreach ($cats as $cat) {
2004 $arrayselected[] = $cat->id;
2006 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2013 print
'<br><hr><br>';
2016 print
'<table class="border tableforfield centpercent">';
2018 if (isModEnabled(
"societe")) {
2020 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2024 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1', 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2027 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2032 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2033 print
'<div class="maxwidth200onsmartphone">';
2034 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2035 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
2042 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2043 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');
2044 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2047 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');
2055 if (isModEnabled(
'project')) {
2056 $langs->load(
"projects");
2058 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2059 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2060 $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');
2061 if ($numprojet == 0) {
2062 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>';
2069 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2070 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2075 if (!empty(
$object->fk_element) && !empty(
$object->elementtype)) {
2076 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2078 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2080 if (
$object->elementtype ==
'task' && isModEnabled(
'project')) {
2081 print
'<td id="project-task-input-container" >';
2083 $urloption =
'?action=create&donotclearsession=1';
2084 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2087 print
"\n".
'<script type="text/javascript" >';
2088 print
'$(document).ready(function () {
2089 $("#projectid").change(function () {
2090 var url = "'.$url.
'&projectid="+$("#projectid").val();
2091 $.get(url, function(data) {
2092 console.log($( data ).find("#fk_element").html());
2093 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2097 print
'</script>'.
"\n";
2099 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1),
$object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500',
$object->fk_project);
2100 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2106 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2107 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2115 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2117 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2118 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2119 $doleditor->Create();
2123 $parameters = array();
2124 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2125 print $hookmanager->resPrint;
2126 if (empty($reshook)) {
2127 print
$object->showOptionals($extrafields,
'edit', $parameters);
2134 $filteruserid = $user->id;
2135 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2138 $object->loadReminders(
'', $filteruserid,
false);
2142 if (count(
$object->reminders) > 0) {
2143 $checked =
'checked';
2144 $keys = array_keys(
$object->reminders);
2145 $firstreminderId = array_shift($keys);
2147 $actionCommReminder =
$object->reminders[$firstreminderId];
2151 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2152 $actionCommReminder->offsetunit =
'i';
2153 $actionCommReminder->typeremind =
'email';
2160 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>';
2162 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2166 print
'<table class="border centpercent">';
2169 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2170 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2171 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2175 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2176 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2180 if ($actionCommReminder->typeremind ==
'browser') {
2181 $hide =
'style="display:none;"';
2186 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2187 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
2193 print
"\n".
'<script type="text/javascript">';
2194 print
'$(document).ready(function () {
2195 $("#addreminder").click(function(){
2197 $(".reminderparameters").show();
2199 $(".reminderparameters").hide();
2203 $("#selectremindertype").change(function(){
2204 var selected_option = $("#selectremindertype option:selected").val();
2205 if(selected_option == "email") {
2206 $("#select_actioncommsendmodel_mail").closest("tr").show();
2208 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2213 print
'</script>'.
"\n";
2220 print $form->buttonsSaveCancel();
2229 if ($action ==
'clone') {
2230 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent',
$object->label),
'confirm_clone', array(),
'yes', 1);
2234 $parameters = array();
2235 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2236 if (empty($reshook)) {
2237 $formconfirm .= $hookmanager->resPrint;
2238 } elseif ($reshook > 0) {
2239 $formconfirm = $hookmanager->resPrint;
2247 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
2248 $linkback .=
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="pictoactionview pictofixedwidth"');
2249 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"BackToList").
'</span>';
2250 $linkback .=
'</a>';
2251 $linkback .=
'</li>';
2252 $linkback .=
'<li class="noborder litext">';
2254 $linkback .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview pictofixedwidth"');
2255 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span>';
2256 $linkback .=
'</a>';
2257 $linkback .=
'</li>';
2258 $linkback .=
'<li class="noborder litext">';
2260 $linkback .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview pictofixedwidth"');
2261 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span>';
2262 $linkback .=
'</a>';
2263 $linkback .=
'</li>';
2264 $linkback .=
'<li class="noborder litext">';
2266 $linkback .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview pictofixedwidth"');
2267 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span>';
2268 $linkback .=
'</a>';
2269 $linkback .=
'</li>';
2270 $linkback .=
'<li class="noborder litext">';
2272 $linkback .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview pictofixedwidth"');
2273 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span>';
2274 $linkback .=
'</a>';
2277 $parameters = array();
2278 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters,
$object, $action);
2279 if (empty($reshook)) {
2280 $linkback .= $hookmanager->resPrint;
2281 } elseif ($reshook > 1) {
2282 $linkback = $hookmanager->resPrint;
2287 $morehtmlref =
'<div class="refidno">';
2291 if (isModEnabled(
'project')) {
2292 $langs->load(
"projects");
2294 if ($usercancreate) {
2295 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2296 if ($action !=
'classify') {
2297 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2299 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2301 if (!empty(
$object->fk_project)) {
2303 $proj->fetch(
$object->fk_project);
2304 $morehtmlref .= $proj->getNomUrl(1);
2306 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2311 $morehtmlref .=
'</div>';
2314 dol_banner_tab(
$object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
2316 print
'<div class="fichecenter">';
2317 print
'<div class="fichehalfleft">';
2319 print
'<div class="underbanner clearboth"></div>';
2322 print
'<table class="border tableforfield centpercent">';
2326 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2327 $labeltoshow = $langs->trans(
"Action".
$object->type_code);
2329 $labeltoshow .=
' ('.$object->code.
')';
2331 print
$object->getTypePicto(
'pictofixedwidth paddingright', $labeltoshow);
2332 print $langs->trans(
"Action".
$object->type_code);
2337 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn(
$object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2341 print
'<tr><td class="titlefield">'.$langs->trans(
"EventIntoASerie").
'</td><td>'.
dol_escape_htmltag(
$object->recurid).
'</td></tr>';
2350 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2355 if (empty(
$object->fulldayevent)) {
2368 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2369 if (empty(
$object->fulldayevent)) {
2382 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.
$object->location.
'</td></tr>';
2386 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2387 $listofuserid = array();
2388 if (empty($donotclearsession)) {
2389 if (
$object->userownerid > 0) {
2390 $listofuserid[
$object->userownerid] = array(
2392 'transparency' =>
$object->transparency,
2393 'answer_status' =>
$object->userassigned[
$object->userownerid][
'answer_status'],
2394 'mandatory' =>
$object->userassigned[
$object->userownerid][
'mandatory']
2397 if (!empty(
$object->userassigned)) {
2399 $tmplist1 =
$object->userassigned;
2400 foreach ($tmplist1 as $key => $val) {
2401 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2402 $listofuserid[$val[
'id']] = $val;
2406 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2408 if (!empty($_SESSION[
'assignedtouser'])) {
2409 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2413 $listofcontactid = array();
2414 $listofotherid = array();
2415 print
'<div class="assignedtouser">';
2416 print $form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', (
$object->datep !=
$object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2426 print
' </td></tr>';
2429 if (isModEnabled(
'category')) {
2430 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2431 print $form->showCategories(
$object->id, Categorie::TYPE_ACTIONCOMM, 1);
2439 print
'<div class="fichehalfright">';
2441 print
'<div class="underbanner clearboth"></div>';
2442 print
'<table class="border tableforfield centpercent">';
2444 if (isModEnabled(
"societe")) {
2446 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td>';
2447 print
'<td>'.(is_object(
$object->thirdparty) &&
$object->thirdparty->id ?
$object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2448 if (is_object(
$object->thirdparty) &&
$object->thirdparty->id > 0 &&
$object->type_code ==
'AC_TEL') {
2450 print
"<br>".dol_print_phone(
$object->thirdparty->phone);
2456 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2459 if (!empty(
$object->socpeopleassigned)) {
2460 foreach (
$object->socpeopleassigned as $cid => $Tab) {
2462 $result = $contact->fetch($cid);
2469 print $contact->getNomUrl(1);
2470 if (
$object->type_code ==
'AC_TEL') {
2471 if (!empty($contact->phone_pro)) {
2472 print
'('.dol_print_phone($contact->phone_pro).
')';
2475 print
'<div class="paddingright"></div>';
2479 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2485 print
'<tr><td class="nowrap" class="titlefield">'.$langs->trans(
"Priority").
'</td><td>';
2491 if (!empty(
$object->fk_element) && !empty(
$object->elementtype) && !in_array(
$object->elementtype, array(
'societe',
'contact',
'project'))) {
2492 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2493 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2497 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2505 if (!empty(
$object->email_msgid)) {
2506 print
'<tr><td>'.$langs->trans(
'MailTopic').
'</td>';
2507 print
'<td>'.dol_escape_htmltag(
$object->email_subject).
'</td></tr>';
2508 print
'<tr><td>'.$langs->trans(
'MailFrom').
'</td>';
2509 print
'<td>'.dol_escape_htmltag(
$object->email_from).
'</td></tr>';
2510 print
'<tr><td>'.$langs->trans(
'MailTo').
'</td>';
2511 print
'<td>'.dol_escape_htmltag(
$object->email_to).
'</td></tr>';
2512 if (!empty(
$object->email_tocc)) {
2513 print
'<tr><td>'.$langs->trans(
'MailCC').
'</td>';
2514 print
'<td>'.dol_escape_htmltag(
$object->email_tocc).
'</td></tr>';
2519 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak sensiblehtmlcontent">';
2524 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2528 $filteruserid = $user->id;
2529 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2532 $object->loadReminders(
'', $filteruserid,
false);
2534 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2536 if (count(
$object->reminders) > 0) {
2537 $tmpuserstatic =
new User($db);
2539 foreach (
$object->reminders as $actioncommreminderid => $actioncommreminder) {
2540 print $TRemindTypes[$actioncommreminder->typeremind][
'label'];
2541 if ($actioncommreminder->fk_user > 0) {
2542 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2543 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2545 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2547 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2548 print
' - <span class="opacitymedium">';
2549 print $langs->trans(
"NotSent");
2551 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2552 print
' - <span class="opacitymedium">';
2553 print $langs->trans(
"Done");
2555 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2556 print
' - <span class="opacitymedium">';
2557 print $form->textwithpicto($langs->trans(
"Error"), $actioncommreminder->lasterror);
2571 print
'<div class="clearboth"></div>';
2580 print
'<div class="tabsAction">';
2582 $parameters = array();
2583 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
2584 if (empty($reshook)) {
2585 if ($action !=
'edit') {
2586 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2587 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2588 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2590 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2593 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2594 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2595 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>';
2597 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2600 if ($user->hasRight(
'agenda',
'allactions',
'delete') ||
2601 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'))) {
2602 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2604 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2611 if ($action !=
'edit') {
2613 print
'<div class="clearboth"></div><div class="fichecenter"><div class="fichehalfleft">';
2614 print
'<a name="builddoc"></a>';
2620 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.
$object->id;
2621 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2623 $genallowed = $user->hasRight(
'agenda',
'myactions',
'read');
2624 $delallowed = $user->hasRight(
'agenda',
'myactions',
'create');
2627 print $formfile->showdocuments(
'actions',
$object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2629 print
'</div><div class="fichehalfright">';
2632 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.
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.
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_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)
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_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.