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') || ((empty(
$object->id) ||
$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' && $usercancreate) {
218 if ($action ==
'update' && $usercancreate) {
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' && $usercancreate) {
240 if ($action ==
'update' && $usercancreate) {
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' && $usercancreate) {
262 if ($action ==
'update' && $usercancreate) {
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' && $usercancreate) {
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' && $usercancreate) {
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'];
368 $submodulecodetouseforpermissioncheck = $elProp[
'subelement'];
370 $hasPermissionOnLinkedObject = 0;
371 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
372 $hasPermissionOnLinkedObject = 1;
373 } elseif ($user->hasRight($modulecodetouseforpermissioncheck, $submodulecodetouseforpermissioncheck,
'read')) {
374 $hasPermissionOnLinkedObject = 1;
377 if ($hasPermissionOnLinkedObject) {
384 if (
GETPOST(
'actioncode',
'aZ09') ==
'AC_RDV' && $contact->getFullName($langs)) {
385 $object->label = $langs->transnoentitiesnoconv(
"TaskRDVWith", $contact->getFullName($langs));
387 if ($langs->trans(
"Action".$object->type_code) !=
"Action".$object->type_code) {
388 $object->label = $langs->transnoentitiesnoconv(
"Action".
$object->type_code).
"\n";
390 $cactioncomm->fetch(
$object->type_code);
391 $object->label = $cactioncomm->label;
398 if (!empty($taskid)) {
399 $taskProject =
new Task($db);
400 if ($taskProject->fetch($taskid) > 0) {
401 $object->fk_project = $taskProject->fk_project;
410 $object->percentage = $percentage;
413 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
415 $listofuserid = array();
416 if (!empty($_SESSION[
'assignedtouser'])) {
417 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
420 foreach ($listofuserid as $key => $value) {
422 if ($value[
'id'] > 0) {
423 $object->userownerid = $value[
'id'];
425 $object->transparency = $transparency;
428 $object->userassigned[$value[
'id']] = array(
'id' => $value[
'id'],
'transparency' => $transparency);
436 if (GETPOSTISSET(
"contactid")) {
450 if (empty(
$object->userownerid) && empty($_SESSION[
'assignedtouser'])) {
452 $donotclearsession = 1;
454 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
456 if (
$object->type_code ==
'AC_RDV' && ($datep ==
'' || ($datef ==
'' && empty($fulldayevent)))) {
458 $donotclearsession = 1;
460 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
null,
'errors');
465 $donotclearsession = 1;
467 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Date")),
null,
'errors');
470 foreach ($socpeopleassigned as $cid) {
471 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
473 if (!empty(
$object->socpeopleassigned)) {
474 reset(
$object->socpeopleassigned);
479 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
482 $donotclearsession = 1;
491 $selectedrecurrulefreq =
'no';
492 $selectedrecurrulebymonthday =
'';
493 $selectedrecurrulebyday =
'';
494 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
495 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'MONTHLY' && GETPOSTISSET(
'BYMONTHDAY')) ?
"_BYMONTHDAY".
GETPOST(
'BYMONTHDAY',
'alpha') :
"";
496 $object->recurrule .= (
GETPOST(
'recurrulefreq',
'alpha') ==
'WEEKLY' && GETPOSTISSET(
'BYDAY')) ?
"_BYDAY".
GETPOST(
'BYDAY',
'alpha') :
"";
501 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg1)) {
502 $selectedrecurrulefreq = $reg1[1];
504 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg2)) {
505 $selectedrecurrulebymonthday = (int) $reg2[1];
507 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg3)) {
508 $selectedrecurrulebyday = (int) $reg3[1];
512 $eventisrecurring = 0;
513 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 2 ? 1 : 0);
514 if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq !=
'no') {
515 $eventisrecurring = 1;
525 $idaction =
$object->create($user);
530 $categories =
GETPOST(
'categories',
'array');
531 $object->setCategories($categories);
533 unset($_SESSION[
'assignedtouser']);
536 if ($user->id !=
$object->userownerid) {
537 $moreparam =
"filtert=-1";
541 if ($addreminder ==
'on') {
546 $actionCommReminder->dateremind = $dateremind;
547 $actionCommReminder->typeremind = $remindertype;
548 $actionCommReminder->offsetunit = $offsetunit;
549 $actionCommReminder->offsetvalue = $offsetvalue;
550 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
551 $actionCommReminder->fk_actioncomm =
$object->id;
552 if ($remindertype ==
'email') {
553 $actionCommReminder->fk_email_template = $modelmail;
557 foreach (
$object->userassigned as $userassigned) {
558 $actionCommReminder->fk_user = $userassigned[
'id'];
559 $res = $actionCommReminder->create($user);
564 $langs->load(
"errors");
565 $error = $langs->trans(
'ErrorReminderActionCommCreation');
568 $donotclearsession = 1;
579 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
599 $langs->load(
"errors");
600 $error = $langs->trans(
$object->error);
603 $donotclearsession = 1;
609 $donotclearsession = 1;
612 if ($eventisrecurring) {
614 if ($selectedrecurrulefreq ==
'WEEKLY' && !empty($selectedrecurrulebyday)) {
616 $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');
620 } elseif ($selectedrecurrulefreq ==
'MONTHLY' && !empty($selectedrecurrulebymonthday)) {
621 $firstday = $selectedrecurrulebymonthday;
630 $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');
636 while ($datep <= $repeateventlimitdate && !$error) {
640 $finalobject->datep = $datep;
641 $finalobject->datef = $datef;
643 $idaction = $finalobject->create($user);
646 if (!$finalobject->error) {
648 $categories =
GETPOST(
'categories',
'array');
649 $finalobject->setCategories($categories);
651 unset($_SESSION[
'assignedtouser']);
654 if ($user->id != $finalobject->userownerid) {
655 $moreparam =
"filtert=-1";
659 if ($addreminder ==
'on') {
664 $actionCommReminder->dateremind = $dateremind;
665 $actionCommReminder->typeremind = $remindertype;
666 $actionCommReminder->offsetunit = $offsetunit;
667 $actionCommReminder->offsetvalue = $offsetvalue;
668 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
669 $actionCommReminder->fk_actioncomm = $finalobject->id;
670 if ($remindertype ==
'email') {
671 $actionCommReminder->fk_email_template = $modelmail;
675 foreach ($finalobject->userassigned as $userassigned) {
676 $actionCommReminder->fk_user = $userassigned[
'id'];
677 $res = $actionCommReminder->create($user);
682 $langs->load(
"errors");
683 $error = $langs->trans(
'ErrorReminderActionCommCreation');
686 $donotclearsession = 1;
697 $moreparam .= ($moreparam ?
'&' :
'').
'disabledefaultvalues=1';
707 $langs->load(
"errors");
708 $error = $langs->trans($finalobject->error);
711 $donotclearsession = 1;
717 $donotclearsession = 1;
721 if (!($userepeatevent && GETPOSTISSET(
'recurrulefreq') &&
GETPOST(
'recurrulefreq') !=
'no' && GETPOSTISSET(
"limityear") && GETPOSTISSET(
"limitmonth") && GETPOSTISSET(
"limitday"))) {
732 if (!empty($backtopage) && !$error) {
733 dol_syslog(
"Back to ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
734 header(
"Location: ".$backtopage.($moreparam ? (preg_match(
'/\?/', $backtopage) ?
'&'.$moreparam :
'?'.$moreparam) :
''));
735 } elseif ($idaction) {
736 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/card.php?id='.$idaction.($moreparam ?
'&'.$moreparam :
''));
738 header(
"Location: ".DOL_URL_ROOT.
'/comm/action/index.php'.($moreparam ?
'?'.$moreparam :
''));
745if (empty($reshook) && $action ==
'update' && $usercancreate) {
746 if (empty($cancel)) {
747 $fulldayevent =
GETPOST(
'fullday');
752 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
777 $datep =
dol_mktime(
'00',
'00',
'00',
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
778 $datef =
dol_mktime(
'23',
'59',
'59',
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'), $tzforfullday ? $tzforfullday :
'tzuserrel');
780 $datep =
dol_mktime(
GETPOST(
"aphour",
'int'),
GETPOST(
"apmin",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"apmonth",
'int'),
GETPOST(
"apday",
'int'),
GETPOST(
"apyear",
'int'),
'tzuserrel');
781 $datef =
dol_mktime(
GETPOST(
"p2hour",
'int'),
GETPOST(
"p2min",
'int'),
GETPOST(
"apsec",
'int'),
GETPOST(
"p2month",
'int'),
GETPOST(
"p2day",
'int'),
GETPOST(
"p2year",
'int'),
'tzuserrel');
784 if (
$object->elementtype ==
'ticket') {
786 if (
$object->code ==
'TICKET_MSG') {
787 $object->code =
'TICKET_MSG_PRIVATE';
789 if (
$object->code ==
'TICKET_MSG_SENTBYMAIL') {
790 $object->code =
'TICKET_MSG_PRIVATE_SENTBYMAIL';
793 if (
$object->code ==
'TICKET_MSG_PRIVATE') {
796 if (
$object->code ==
'TICKET_MSG_PRIVATE_SENTBYMAIL') {
797 $object->code =
'TICKET_MSG_SENTBYMAIL';
809 $object->percentage = $percentage;
814 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
815 $object->socpeopleassigned = array();
816 foreach ($socpeopleassigned as $cid) {
817 $object->socpeopleassigned[$cid] = array(
'id' => $cid);
820 if (empty(
$object->contact_id) && !empty(
$object->socpeopleassigned)) {
821 reset(
$object->socpeopleassigned);
827 if (
GETPOST(
"elementtype",
'alpha')) {
829 $modulecodetouseforpermissioncheck = $elProp[
'module'];
831 $hasPermissionOnLinkedObject = 0;
832 if ($user->hasRight($modulecodetouseforpermissioncheck,
'read')) {
833 $hasPermissionOnLinkedObject = 1;
835 if ($hasPermissionOnLinkedObject) {
841 if (!$datef && $percentage == 100) {
843 $donotclearsession = 1;
844 setEventMessages($langs->transnoentitiesnoconv(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"DateEnd")),
$object->errors,
'errors');
848 $transparency = (
GETPOST(
"transparency") ==
'on' ? 1 : 0);
851 $listofuserid = array();
852 if (!empty($_SESSION[
'assignedtouser'])) {
854 $tmplist1 = json_decode($_SESSION[
'assignedtouser'],
true);
855 foreach ($tmplist1 as $key => $val) {
856 if ($val[
'id'] > 0 && $val[
'id'] != $assignedtouser) {
857 $listofuserid[$val[
'id']] = $val;
861 $assignedtouser = (!empty(
$object->userownerid) &&
$object->userownerid > 0 ?
$object->userownerid : 0);
862 if ($assignedtouser) {
863 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0,
'transparency' => ($user->id == $assignedtouser ? $transparency :
''));
866 $object->userassigned = array();
869 foreach ($listofuserid as $key => $val) {
871 $object->userownerid = $val[
'id'];
873 $object->userassigned[$val[
'id']] = array(
'id' => $val[
'id'],
'mandatory' => 0,
'transparency' => ($user->id == $val[
'id'] ? $transparency :
''));
877 $object->transparency = $transparency;
881 if (GETPOSTISSET(
'actioncode') && !
GETPOST(
'actioncode',
'aZ09')) {
883 $donotclearsession = 1;
885 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type")),
null,
'errors');
887 $result = $cactioncomm->fetch(
GETPOST(
'actioncode',
'aZ09'));
889 if (empty(
$object->userownerid)) {
891 $donotclearsession = 1;
893 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"ActionsOwnedBy")),
null,
'errors');
897 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
905 $eventDateStart =
$object->datep;
906 $eventDateEnd =
$object->datef;
908 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
909 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
910 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
911 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
912 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
913 $sql .=
" AND er.resource_id IN (";
914 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
915 $sql .=
" WHERE element_id = ".((int)
$object->id);
916 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
917 $sql .=
" AND busy = 1";
919 $sql .=
" AND er.busy = 1";
923 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
925 if (!empty($eventDateEnd)) {
926 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
930 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
931 if (!empty($eventDateEnd)) {
932 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
937 $resql = $db->query($sql);
940 $object->error = $db->lasterror();
943 if ($db->num_rows($resql) > 0) {
946 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
947 while ($obj = $db->fetch_object($resql)) {
948 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
964 $result =
$object->update($user);
968 $categories =
GETPOST(
'categories',
'array');
969 $object->setCategories($categories);
971 $object->loadReminders($remindertype, 0,
false);
974 if (!empty(
$object->reminders)) {
975 foreach (
$object->reminders as $reminder) {
976 if ($reminder->status < 1) {
977 $reminder->delete($user);
984 if ($addreminder ==
'on') {
989 $actionCommReminder->dateremind = $dateremind;
990 $actionCommReminder->typeremind = $remindertype;
991 $actionCommReminder->offsetunit = $offsetunit;
992 $actionCommReminder->offsetvalue = $offsetvalue;
993 $actionCommReminder->status = $actionCommReminder::STATUS_TODO;
994 $actionCommReminder->fk_actioncomm =
$object->id;
995 if ($remindertype ==
'email') {
996 $actionCommReminder->fk_email_template = $modelmail;
1000 foreach (
$object->userassigned as $userassigned) {
1001 $actionCommReminder->fk_user = $userassigned[
'id'];
1005 $sqldelete =
"DELETE FROM ".MAIN_DB_PREFIX.
"actioncomm_reminder";
1006 $sqldelete .=
" WHERE fk_user = ".((int) $actionCommReminder->fk_user).
" AND fk_actioncomm = ".((int)
$object->id).
" AND typeremind = '".$db->escape($remindertype).
"'";
1007 $resqldelete = $db->query($sqldelete);
1009 $res = $actionCommReminder->create($user);
1013 $langs->load(
"errors");
1014 $error = $langs->trans(
'ErrorReminderActionCommCreation');
1017 $donotclearsession = 1;
1024 unset($_SESSION[
'assignedtouser']);
1025 unset($_SESSION[
'assignedtoresource']);
1040 if (!empty($backtopage)) {
1041 unset($_SESSION[
'assignedtouser']);
1042 header(
"Location: ".$backtopage);
1049if (empty($reshook) && $action ==
'confirm_delete' &&
GETPOST(
"confirm") ==
'yes') {
1052 $object->fetch_userassigned();
1055 if ($user->hasRight(
'agenda',
'myactions',
'delete')
1056 || $user->hasRight(
'agenda',
'allactions',
'delete')) {
1057 $result =
$object->delete($user);
1060 header(
"Location: index.php");
1072if (empty($reshook) &&
GETPOST(
'actionmove',
'alpha') ==
'mupdate') {
1078 $newdate =
GETPOST(
'newdate',
'alpha');
1079 if (empty($newdate) || strpos($newdate,
'dayevent_') != 0) {
1080 header(
"Location: ".$backtopage,
true, 307);
1084 $datep =
dol_mktime($shour, $smin, 0, substr($newdate, 13, 2), substr($newdate, 15, 2), substr($newdate, 9, 4),
'tzuserrel');
1087 if ($datep !=
$object->datep) {
1096 $eventDateStart =
$object->datep;
1097 $eventDateEnd =
$object->datef;
1099 $sql =
"SELECT er.rowid, r.ref as r_ref, ac.id as ac_id, ac.label as ac_label";
1100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_resources as er";
1101 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"resource as r ON r.rowid = er.resource_id AND er.resource_type = 'dolresource'";
1102 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"actioncomm as ac ON ac.id = er.element_id AND er.element_type = '".$db->escape(
$object->element).
"'";
1103 $sql .=
" WHERE ac.id <> ".((int)
$object->id);
1104 $sql .=
" AND er.resource_id IN (";
1105 $sql .=
" SELECT resource_id FROM ".MAIN_DB_PREFIX.
"element_resources";
1106 $sql .=
" WHERE element_id = ".((int)
$object->id);
1107 $sql .=
" AND element_type = '".$db->escape(
$object->element).
"'";
1108 $sql .=
" AND busy = 1";
1110 $sql .=
" AND er.busy = 1";
1114 $sql .=
" (ac.datep <= '".$db->idate($eventDateStart).
"' AND (ac.datep2 IS NULL OR ac.datep2 >= '".$db->idate($eventDateStart).
"'))";
1116 if (!empty($eventDateEnd)) {
1117 $sql .=
" OR (ac.datep <= '".$db->idate($eventDateEnd).
"' AND (ac.datep2 >= '".$db->idate($eventDateEnd).
"'))";
1121 $sql .=
"ac.datep >= '".$db->idate($eventDateStart).
"'";
1122 if (!empty($eventDateEnd)) {
1123 $sql .=
" AND (ac.datep2 IS NOT NULL AND ac.datep2 <= '".$db->idate($eventDateEnd).
"')";
1128 $resql = $db->query($sql);
1131 $object->error = $db->lasterror();
1134 if ($db->num_rows($resql) > 0) {
1137 $object->error = $langs->trans(
'ErrorResourcesAlreadyInUse').
' : ';
1138 while ($obj = $db->fetch_object($resql)) {
1139 $object->error .=
'<br> - '.$langs->trans(
'ErrorResourceUseInEvent', $obj->r_ref, $obj->ac_label.
' ['.$obj->ac_id.
']');
1154 $result =
$object->update($user);
1164 if (!empty($backtopage)) {
1165 header(
"Location: ".$backtopage,
true, 307);
1174$permissiontoadd = ($user->hasRight(
'agenda',
'allactions',
'create') || ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'read')));
1175if (empty($reshook)) {
1176 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
1184$form =
new Form($db);
1187$arrayrecurrulefreq = array(
1188 'no' => $langs->trans(
"OnceOnly"),
1189 'MONTHLY' => $langs->trans(
"EveryMonth"),
1190 'WEEKLY' => $langs->trans(
"EveryWeek")
1195$help_url =
'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda|DE:Modul_Terminplanung';
1196llxHeader(
'', $langs->trans(
"Agenda"), $help_url);
1198if ($action ==
'create') {
1201 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1202 if (!empty($socpeopleassigned[0])) {
1203 $result = $contact->fetch($socpeopleassigned[0]);
1211 if (!empty($conf->use_javascript_ajax)) {
1212 print
"\n".
'<script type="text/javascript">';
1213 print
'$(document).ready(function () {
1214 function setdatefields()
1216 if ($("#fullday:checked").val() == null) {
1217 $(".fulldaystarthour").removeAttr("disabled");
1218 $(".fulldaystartmin").removeAttr("disabled");
1219 $(".fulldayendhour").removeAttr("disabled");
1220 $(".fulldayendmin").removeAttr("disabled");
1221 $("#p2").removeAttr("disabled");
1223 $(".fulldaystarthour").prop("disabled", true).val("00");
1224 $(".fulldaystartmin").prop("disabled", true).val("00");
1225 $(".fulldayendhour").prop("disabled", true).val("23");
1226 $(".fulldayendmin").prop("disabled", true).val("59");
1227 $("#p2").removeAttr("disabled");
1230 $("#fullday").change(function() {
1231 console.log("setdatefields");
1235 $("#actioncode").change(function() {
1236 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1237 else $("#dateend").removeClass("fieldrequired");
1239 $("#aphour,#apmin").change(function() {
1240 if ($("#actioncode").val() == \'AC_RDV\') {
1241 console.log("Start date was changed, we modify end date "+(parseInt($("#aphour").val()))+" "+$("#apmin").val()+" -> "+("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1242 $("#p2hour").val(("00" + (parseInt($("#aphour").val()) + 1)).substr(-2,2));
1243 $("#p2min").val($("#apmin").val());
1244 $("#p2day").val($("#apday").val());
1245 $("#p2month").val($("#apmonth").val());
1246 $("#p2year").val($("#apyear").val());
1247 $("#p2").val($("#ap").val());
1250 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1251 else $("#dateend").removeClass("fieldrequired");
1254 print
'</script>'.
"\n";
1257 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1258 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1259 print
'<input type="hidden" name="action" value="add">';
1260 print
'<input type="hidden" name="donotclearsession" value="1">';
1261 print
'<input type="hidden" name="page_y" value="">';
1263 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1266 print
'<input type="hidden" name="actioncode" value="'.dol_getIdFromCode($db,
'AC_OTH',
'c_actioncomm').
'">';
1269 if (
GETPOST(
"actioncode",
'aZ09') ==
'AC_RDV') {
1270 print
load_fiche_titre($langs->trans(
"AddActionRendezVous"),
'',
'title_agenda');
1277 print
'<table class="border centpercent">';
1281 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
"Type").
'</span></b></td><td>';
1283 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1284 $selectedvalue = GETPOSTISSET(
"actioncode") ?
GETPOST(
"actioncode",
'aZ09') : (
$object->type_code ?
$object->type_code : $default);
1285 print $formactions->select_type_actions($selectedvalue,
"actioncode",
"systemauto", 0, -1, 0, 1);
1290 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>';
1293 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
"Date").
'</span></td>';
1294 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>';
1297 $userepeatevent = (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0);
1298 if ($userepeatevent) {
1300 print
' <div class="opacitymedium inline-block small">';
1301 print
img_picto($langs->trans(
"Recurrence"),
'recurring',
'style="margin-left: 6px" class="paddingright2"');
1302 print
'<input type="hidden" name="recurid" value="'.(empty(
$object->recurid) ?
'' :
$object->recurid).
'">';
1304 $selectedrecurrulefreq =
'no';
1305 $selectedrecurrulebymonthday =
'';
1306 $selectedrecurrulebyday =
'';
1307 $object->recurrule = GETPOSTISSET(
'recurrulefreq') ?
"FREQ=".GETPOST(
'recurrulefreq',
'alpha') :
"";
1308 $object->recurrule .= GETPOSTISSET(
'BYMONTHDAY') ?
"_BYMONTHDAY".GETPOST(
'BYMONTHDAY',
'alpha') :
"";
1309 $object->recurrule .= GETPOSTISSET(
'BYDAY') ?
"_BYDAY".GETPOST(
'BYDAY',
'alpha') :
"";
1313 if (
$object->recurrule && preg_match(
'/FREQ=([A-Z]+)/i',
$object->recurrule, $reg)) {
1314 $selectedrecurrulefreq = $reg[1];
1316 if (
$object->recurrule && preg_match(
'/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i',
$object->recurrule, $reg)) {
1317 $selectedrecurrulebymonthday = (int) $reg[1];
1319 if (
$object->recurrule && preg_match(
'/FREQ=WEEKLY.*BYDAY(\d+)/i',
$object->recurrule, $reg)) {
1320 $selectedrecurrulebyday = (int) $reg[1];
1323 print $form->selectarray(
'recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0,
'', 0, 0, 0,
'',
'marginrightonly');
1329 print
'<div class="hidden marginrightonly inline-block repeateventBYMONTHDAY">';
1330 print $langs->trans(
"DayOfMonth").
': <input type="input" size="2" name="BYMONTHDAY" value="'.$selectedrecurrulebymonthday.
'">';
1333 print
'<div class="hidden marginrightonly inline-block repeateventBYDAY">';
1334 print $langs->trans(
"DayOfWeek").
': <input type="input" size="4" name="BYDAY" value="'.$selectedrecurrulebyday.
'">';
1337 $repeateventlimitdate = !empty($repeateventlimitdate) ? $repeateventlimitdate :
'';
1338 print
'<div class="hidden marginrightonly inline-block repeateventlimitdate">';
1339 print $langs->trans(
"Until").
" ";
1340 print $form->selectDate($repeateventlimitdate,
'limit', 0, 0, 0,
"action", 1, 0, 0,
'',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1343 print
'<script type="text/javascript">
1344 jQuery(document).ready(function() {
1345 function init_repeat()
1347 console.log("recurrule: " + "'.$object->recurrule.
'");
1348 console.log("reg1: " + "'.$selectedrecurrulefreq.
'");
1349 console.log("reg2: " + "'.$selectedrecurrulebymonthday.
'");
1350 console.log("reg3: " + "'.$selectedrecurrulebyday.
'");
1351 console.log("selectedrulefreq: " + "'.$selectedrecurrulefreq.
'");
1352 if (jQuery("#recurrulefreq").val() == \'MONTHLY\')
1354 jQuery(".repeateventBYMONTHDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1355 jQuery(".repeateventlimitdate").css("display", "inline-block");
1356 jQuery(".repeateventBYDAY").hide();
1358 else if (jQuery("#recurrulefreq").val() == \'WEEKLY\')
1360 jQuery(".repeateventBYMONTHDAY").hide();
1361 jQuery(".repeateventBYDAY").css("display", "inline-block"); /* use this instead of show because we want inline-block and not block */
1362 jQuery(".repeateventlimitdate").css("display", "inline-block");
1366 jQuery(".repeateventBYMONTHDAY").hide();
1367 jQuery(".repeateventBYDAY").hide();
1368 jQuery(".repeateventlimitdate").hide();
1372 jQuery("#recurrulefreq").change(function() {
1383 $datep = ($datep ? $datep : (is_null(
$object->datep) ?
'' :
$object->datep));
1387 $datef = ($datef ? $datef :
$object->datef);
1391 if (empty($datef) && !empty($datep)) {
1398 print
'<tr><td class="nowrap">';
1401 print $form->selectDate($datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1403 print $form->selectDate($datep,
'ap', 1, 1, 1,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1405 print
' <span class="hideonsmartphone"> - </span><br class="showonsmartphone"> ';
1406 print $form->selectDate($datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
'tzuserrel');
1409 print
'<tr><td class=""> </td><td></td></tr>';
1412 print
'<tr><td class="tdtop nowrap"><span class="fieldrequired">'.$langs->trans(
"ActionAffectedTo").
'</span></td><td>';
1413 $listofuserid = array();
1414 $listofcontactid = array();
1415 $listofotherid = array();
1417 if (empty($donotclearsession)) {
1419 if ($assignedtouser) {
1420 $listofuserid[$assignedtouser] = array(
'id' => $assignedtouser,
'mandatory' => 0);
1423 $listofuserid[$assignedtouser][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 1);
1424 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1426 if (!empty($_SESSION[
'assignedtouser'])) {
1427 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1429 $firstelem = reset($listofuserid);
1430 if (isset($listofuserid[$firstelem[
'id']])) {
1431 $listofuserid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1434 print
'<div class="assignedtouser">';
1435 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
1441 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>';
1444 if (isModEnabled(
'category')) {
1446 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1447 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
1448 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'minwidth300 quatrevingtpercent widthcentpercentminusx', 0, 0);
1452 if (isModEnabled(
'resource')) {
1454 print
'<tr><td class="tdtop nowrap">'.$langs->trans(
"Resource").
'</td><td>';
1456 $listofresourceid = array();
1457 if (empty($donotclearsession)) {
1458 $assignedtoresource =
GETPOST(
"assignedtoresource");
1459 if ($assignedtoresource) {
1460 $listofresourceid[$assignedtoresource] = array(
'id' => $assignedtoresource,
'mandatory' => 0);
1462 $_SESSION[
'assignedtoresource'] = json_encode($listofresourceid);
1464 if (!empty($_SESSION[
'assignedtoresource'])) {
1465 $listofresourceid = json_decode($_SESSION[
'assignedtoresource'],
true);
1467 $firstelem = reset($listofresourceid);
1468 if (isset($listofresourceid[$firstelem[
'id']])) {
1469 $listofresourceid[$firstelem[
'id']][
'transparency'] = (GETPOSTISSET(
'transparency') ?
GETPOST(
'transparency',
'alpha') : 0);
1472 print
'<div class="assignedtoresource">';
1473 print $form->select_dolresources_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtoresource', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofresourceid);
1479 print
'<tr><td>'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td>';
1481 $percent = $complete !==
'' ? $complete : -1;
1482 if (GETPOSTISSET(
'status')) {
1484 } elseif (GETPOSTISSET(
'percentage')) {
1487 if ($complete ==
'0' ||
GETPOST(
"afaire") == 1) {
1489 } elseif ($complete == 100 ||
GETPOST(
"afaire") == 2) {
1493 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
1499 print
'<br><hr><br>';
1502 print
'<table class="border centpercent">';
1504 if (isModEnabled(
"societe")) {
1506 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ActionOnCompany").
'</td><td>';
1510 print $societe->getNomUrl(1);
1511 print
'<input type="hidden" id="socid" name="socid" value="'.GETPOSTINT(
'socid').
'">';
1514 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
1516 if (!empty($user->socid)) {
1517 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company($user->socid,
'socid',
'', 1, 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1519 print
img_picto(
'',
'company',
'class="paddingrightonly"').$form->select_company(
'',
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300 widthcentpercentminusxx maxwidth500');
1525 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionOnContact").
'</td><td>';
1526 $preselectedids =
GETPOST(
'socpeopleassigned',
'array:int');
1530 if ($origin ==
'contact') {
1536 $select_contact_default = 0;
1538 $select_contact_default = -1;
1540 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
1542 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
1549 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
1550 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, array(), false,
'multiple',
'contactid');
1551 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
1553 print $form->selectcontacts(GETPOSTISSET(
'socid') ?
GETPOSTINT(
'socid') : $select_contact_default, $preselectedids,
'socpeopleassigned[]', 1,
'',
'', 0,
'minwidth300 widthcentpercentminusxx maxwidth500', 0, 0, array(), false,
'multiple',
'contactid');
1560 if (isModEnabled(
'project')) {
1561 $langs->load(
"projects");
1565 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td id="project-input-container">';
1566 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
1567 print $formproject->select_projects((
$object->socid > 0 ?
$object->socid : -1), $projectid,
'projectid', 0, 0, 1, 1, 0, 0, 0,
'', 1, 0,
'maxwidth500 widthcentpercentminusxx maxwidth500');
1569 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.(empty($societe->id) ?
'' : $societe->id).
'&action=create&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?action=create').
'">';
1570 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddProject").
'"></span></a>';
1571 $urloption =
'?action=create&donotclearsession=1';
1575 print
"\n".
'<script type="text/javascript">';
1576 print
'$(document).ready(function () {
1577 $("#projectid").change(function () {
1578 var url = "'.DOL_URL_ROOT.
'/projet/ajax/projects.php?mode=gettasks&socid="+$("#search_socid").val()+"&projectid="+$("#projectid").val();
1579 console.log("Call url to get new list of tasks: "+url);
1580 $.get(url, function(data) {
1582 if (data) $("#taskid").html(data).select2();
1586 print
'</script>'.
"\n";
1591 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Task").
'</td><td id="project-task-input-container" >';
1592 print
img_picto(
'',
'projecttask',
'class="paddingrightonly"');
1593 $projectsListId =
false;
1594 if (!empty($projectid)) {
1595 $projectsListId = $projectid;
1598 $tid = GETPOSTISSET(
"projecttaskid") ?
GETPOSTINT(
"projecttaskid") : (GETPOSTISSET(
"taskid") ?
GETPOSTINT(
"taskid") :
'');
1600 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1), $tid,
'taskid', 24, 0,
'1', 1, 0, 0,
'maxwidth500 widthcentpercentminusxx', $projectsListId);
1605 if (!empty($origin) && !empty($originid)) {
1606 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
1608 $hasPermissionOnLinkedObject = 0;
1611 if ($user->hasRight($elProp[
'module'],
'read') || $user->hasRight($elProp[
'module'], $elProp[
'element'],
'read')) {
1612 $hasPermissionOnLinkedObject = 1;
1616 if (! in_array($origin, array(
'societe',
'project',
'task',
'user'))) {
1618 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"LinkedObject").
'</td>';
1619 print
'<td colspan="3">';
1620 if ($hasPermissionOnLinkedObject) {
1622 print
'<input type="hidden" name="fk_element" value="'.$originid.
'">';
1623 print
'<input type="hidden" name="elementtype" value="'.$origin.
'">';
1624 print
'<input type="hidden" name="originid" value="'.$originid.
'">';
1625 print
'<input type="hidden" name="origin" value="'.$origin.
'">';
1627 print
'<!-- no permission on object to link '.$origin.
' id '.$originid.
' -->';
1635 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td colspan="3">';
1636 print
'<input type="text" name="priority" value="'.(GETPOSTISSET(
'priority') ?
GETPOSTINT(
'priority') : (
$object->priority ?
$object->priority :
'')).
'" size="5">';
1641 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1642 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1643 $doleditor =
new DolEditor(
'note', (GETPOSTISSET(
'note') ?
GETPOST(
'note',
'restricthtml') :
$object->note_private),
'', 120,
'dolibarr_notes',
'In', true, true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
1644 $doleditor->Create();
1648 $parameters = array();
1649 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1650 print $hookmanager->resPrint;
1651 if (empty($reshook)) {
1652 print
$object->showOptionals($extrafields,
'create', $parameters);
1662 print
'<label for="addreminder">'.img_picto(
'',
'bell',
'class="pictofixedwidth"').$langs->trans(
"AddReminder").
'</label> <input type="checkbox" id="addreminder" name="addreminder"><br><br>';
1664 print
'<div class="reminderparameters" style="display: none;">';
1666 print
'<table class="border centpercent">';
1669 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
1670 print
'<input class="width50" type="number" name="offsetvalue" value="'.(GETPOSTISSET(
'offsetvalue') ?
GETPOSTINT(
'offsetvalue') :
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30)).
'"> ';
1671 print $form->selectTypeDuration(
'offsetunit',
'i', array(
'y',
'm'));
1675 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
1676 print $form->selectarray(
'selectremindertype', $TRemindTypes,
'', 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200 maxwidth500', 1);
1681 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
1682 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
1689 print
"\n".
'<script type="text/javascript">';
1690 print
'$(document).ready(function () {
1691 $("#addreminder").click(function(){
1692 console.log("Click on addreminder");
1694 $(".reminderparameters").show();
1696 $(".reminderparameters").hide();
1698 $("#selectremindertype").select2("destroy");
1699 $("#selectremindertype").select2();
1700 $("#select_offsetunittype_duration").select2("destroy");
1701 $("#select_offsetunittype_duration").select2();
1702 selectremindertype();
1705 $("#selectremindertype").change(function(){
1706 selectremindertype();
1709 function selectremindertype() {
1710 console.log("Call selectremindertype");
1711 var selected_option = $("#selectremindertype option:selected").val();
1712 if(selected_option == "email") {
1713 $("#select_actioncommsendmodel_mail").closest("tr").show();
1715 $("#select_actioncommsendmodel_mail").closest("tr").hide();
1720 print
'</script>'.
"\n";
1725 print $form->buttonsSaveCancel(
"Add");
1732 $result1 =
$object->fetch($id);
1733 if ($result1 <= 0) {
1734 $langs->load(
"errors");
1735 print $langs->trans(
"ErrorRecordNotFound");
1741 $result2 =
$object->fetch_thirdparty();
1742 $result2 =
$object->fetch_projet();
1743 $result3 =
$object->fetch_contact();
1744 $result4 =
$object->fetch_userassigned();
1745 $result5 =
$object->fetch_optionals();
1747 if ($listUserAssignedUpdated || $donotclearsession) {
1748 $percentage = in_array(
GETPOST(
'status'), array(-1, 100)) ?
GETPOST(
'status') : (in_array($complete, array(-1, 100)) ? $complete :
GETPOSTINT(
"percentage"));
1757 $object->percentage = $percentage;
1762 $socpeopleassigned =
GETPOST(
"socpeopleassigned",
'array');
1763 foreach ($socpeopleassigned as $tmpid) {
1764 $object->socpeopleassigned[$id] = array(
'id' => $tmpid);
1772 if ($result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) {
1778 $tmpuser =
new User($db);
1779 $res = $tmpuser->fetch(
$object->authorid);
1783 $tmpuser =
new User($db);
1784 $res = $tmpuser->fetch(
$object->usermodid);
1796 $delay_warning =
getDolGlobalInt(
'MAIN_DELAY_ACTIONS_TODO') * 24 * 60 * 60;
1800 if ($action ==
'delete') {
1801 print $form->formconfirm(
"card.php?id=".urlencode((
string) ($id)), $langs->trans(
"DeleteAction"), $langs->trans(
"ConfirmDeleteAction"),
"confirm_delete",
'',
'', 1);
1804 if ($action ==
'edit') {
1805 if (!empty($conf->use_javascript_ajax)) {
1806 print
"\n".
'<script type="text/javascript">';
1807 print
'$(document).ready(function () {
1808 function setdatefields()
1810 if ($("#fullday:checked").val() == null) {
1811 $(".fulldaystarthour").removeAttr("disabled");
1812 $(".fulldaystartmin").removeAttr("disabled");
1813 $(".fulldayendhour").removeAttr("disabled");
1814 $(".fulldayendmin").removeAttr("disabled");
1816 $(".fulldaystarthour").prop("disabled", true).val("00");
1817 $(".fulldaystartmin").prop("disabled", true).val("00");
1818 $(".fulldayendhour").prop("disabled", true).val("23");
1819 $(".fulldayendmin").prop("disabled", true).val("59");
1823 $("#fullday").change(function() {
1826 $("#actioncode").change(function() {
1827 if ($("#actioncode").val() == \'AC_RDV\') $("#dateend").addClass("fieldrequired");
1828 else $("#dateend").removeClass("fieldrequired");
1831 print
'</script>'.
"\n";
1834 print
'<form name="formaction" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
1835 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1836 print
'<input type="hidden" name="action" value="update">';
1837 print
'<input type="hidden" name="id" value="'.$id.
'">';
1838 print
'<input type="hidden" name="ref_ext" value="'.$object->ref_ext.
'">';
1839 print
'<input type="hidden" name="page_y" value="">';
1841 print
'<input type="hidden" name="backtopage" value="'.($backtopage !=
'1' ? $backtopage :
'').
'">';
1844 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1849 print
'<table class="border tableforfield" width="100%">';
1852 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Ref").
'</td><td colspan="3">'.
$object->id.
'</td></tr>';
1856 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Type").
'</td><td colspan="3">';
1857 if (
$object->type_code !=
'AC_OTH_AUTO') {
1858 print
img_picto($langs->trans(
"ActionType"),
'square',
'class="fawidth30 inline-block" style="color: #ddd;"');
1859 print $formactions->select_type_actions(
GETPOST(
"actioncode",
'aZ09') ?
GETPOST(
"actioncode",
'aZ09') :
$object->type_code,
"actioncode",
"systemauto", 0, 0, 0, 1);
1861 print
'<input type="hidden" name="actioncode" value="'.$object->type_code.
'">';
1862 print
$object->getTypePicto();
1863 print $langs->trans(
"Action".
$object->type_code);
1869 if (
$object->elementtype ==
'ticket') {
1870 print
'<tr><td>'.$langs->trans(
"MarkMessageAsPrivate");
1871 print
' '.$form->textwithpicto(
'', $langs->trans(
"TicketMessagePrivateHelp"), 1,
'help');
1872 print
'</td><td colspan="3"><input type="checkbox" id="private" name="private" '.(preg_match(
'/^TICKET_MSG_PRIVATE/',
$object->code) ?
' checked' :
'').
'></td></tr>';
1876 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>';
1879 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' :
'').
'>';
1880 print
'<label for="fullday">'.$langs->trans(
"EventOnFullDay").
'</label>';
1943 print
'<tr><td class="nowrap">';
1948 print
'</td><td td colspan="3">';
1950 print $form->selectDate($datep ? $datep :
$object->datep,
'ap', 1, 1, 0,
"action", 1, 2, 0,
'fulldaystart',
'',
'',
'', 1,
'',
'',
$object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1951 print
' <span class="hideonsmartphone"> - </span> ';
1952 print $form->selectDate($datef ? $datef :
$object->datef,
'p2', 1, 1, 1,
"action", 1, 2, 0,
'fulldayend',
'',
'',
'', 1,
'',
'',
$object->fulldayevent ? ($tzforfullday ? $tzforfullday :
'tzuserrel') :
'tzuserrel');
1955 print
'<tr><td class=""> </td><td></td></tr>';
1958 $listofuserid = array();
1959 if (empty($donotclearsession)) {
1960 if (
$object->userownerid > 0) {
1961 $listofuserid[
$object->userownerid] = array(
1965 'transparency' =>
$object->transparency,
1966 'answer_status' => (isset(
$object->userassigned[
$object->userownerid][
'answer_status']) ?
$object->userassigned[
$object->userownerid][
'answer_status']: null),
1967 'mandatory' => (isset(
$object->userassigned[
$object->userownerid][
'mandatory']) ?
$object->userassigned[
$object->userownerid][
'mandatory']:null)
1970 if (!empty(
$object->userassigned)) {
1972 $tmplist1 =
$object->userassigned;
1973 foreach ($tmplist1 as $key => $val) {
1974 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
1975 $listofuserid[$val[
'id']] = $val;
1979 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
1981 if (!empty($_SESSION[
'assignedtouser'])) {
1982 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
1986 $listofcontactid =
$object->socpeopleassigned;
1987 $listofotherid =
$object->otherassigned;
1989 print
'<tr><td class="tdtop nowrap fieldrequired">'.$langs->trans(
"ActionAssignedTo").
'</td><td colspan="3">';
1990 print
'<div class="assignedtouser">';
1991 print $form->select_dolusers_forevent(($action ==
'create' ?
'add' :
'update'),
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'AND u.statut != 0', 1, $listofuserid, $listofcontactid, $listofotherid);
2003 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td colspan="3"><input type="text" name="location" class="minwidth300 maxwidth150onsmartphone" value="'.
$object->location.
'"></td></tr>';
2007 print
'<tr><td class="nowrap">'.$langs->trans(
"Status").
' / '.$langs->trans(
"Percentage").
'</td><td colspan="3">';
2008 $percent = GETPOSTISSET(
"percentage") ?
GETPOSTINT(
"percentage") :
$object->percentage;
2009 $formactions->form_select_status_action(
'formaction', $percent, 1,
'complete', 0, 0,
'maxwidth200');
2013 if (isModEnabled(
'category')) {
2014 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2015 $cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM,
'',
'parent', 64, 0, 3);
2017 $cats = $c->containing(
$object->id, Categorie::TYPE_ACTIONCOMM);
2018 $arrayselected = array();
2019 foreach ($cats as $cat) {
2020 $arrayselected[] = $cat->id;
2022 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2029 print
'<br><hr><br>';
2032 print
'<table class="border tableforfield centpercent">';
2034 if (isModEnabled(
"societe")) {
2036 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ActionOnCompany").
'</td>';
2040 $events[] = array(
'method' =>
'getContacts',
'url' =>
dol_buildpath(
'/core/ajax/contacts.php?showempty=1&token='.
currentToken(), 1),
'htmlname' =>
'contactid',
'params' => array(
'add-customer-contact' =>
'disabled'));
2043 print
img_picto(
'',
'company',
'class="pictofixedwidth"').$form->select_company(
$object->socid,
'socid',
'',
'SelectThirdParty', 1, 0, $events, 0,
'minwidth300');
2048 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td><td>';
2049 print
'<div class="maxwidth200onsmartphone">';
2051 print
img_picto(
'',
'contact',
'class="paddingrightonly"');
2052 if (
getDolGlobalString(
'CONTACT_USE_SEARCH_TO_SELECT') && $conf->use_javascript_ajax) {
2059 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = 0;
2060 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');
2061 $conf->global->CONTACT_USE_SEARCH_TO_SELECT = $sav;
2064 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');
2072 if (isModEnabled(
'project')) {
2073 $langs->load(
"projects");
2075 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"Project").
'</td><td>';
2076 print
img_picto(
'',
'project',
'class="pictofixedwidth"');
2077 $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');
2078 if ($numprojet == 0) {
2079 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>';
2086 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Priority").
'</td><td>';
2087 print
'<input type="text" name="priority" value="'.($object->priority ?
$object->priority :
'').
'" size="5">';
2092 if (!empty(
$object->fk_element) && !empty(
$object->elementtype)) {
2093 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2095 print
'<td>'.$langs->trans(
"LinkedObject").
'</td>';
2097 if (
$object->elementtype ==
'task' && isModEnabled(
'project')) {
2098 print
'<td id="project-task-input-container" >';
2100 $urloption =
'?action=create&donotclearsession=1';
2101 $url = DOL_URL_ROOT.
'/comm/action/card.php'.$urloption;
2104 print
"\n".
'<script type="text/javascript" >';
2105 print
'$(document).ready(function () {
2106 $("#projectid").change(function () {
2107 var url = "'.$url.
'&projectid="+$("#projectid").val();
2108 $.get(url, function(data) {
2109 console.log($( data ).find("#fk_element").html());
2110 if (data) $("#fk_element").html( $( data ).find("#taskid").html() ).select2();
2114 print
'</script>'.
"\n";
2116 $formproject->selectTasks((!empty($societe->id) ? $societe->id : -1),
$object->fk_element,
'fk_element', 24, 0, 0, 1, 0, 0,
'maxwidth500',
$object->fk_project);
2117 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2123 print
'<input type="hidden" name="fk_element" value="'.$object->fk_element.
'">';
2124 print
'<input type="hidden" name="elementtype" value="'.$object->elementtype.
'">';
2132 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2134 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2135 $doleditor =
new DolEditor(
'note',
$object->note_private,
'', 120,
'dolibarr_notes',
'In',
true,
true, isModEnabled(
'fckeditor'), ROWS_4,
'90%');
2136 $doleditor->Create();
2140 $parameters = array();
2141 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2142 print $hookmanager->resPrint;
2143 if (empty($reshook)) {
2144 print
$object->showOptionals($extrafields,
'edit', $parameters);
2151 $filteruserid = $user->id;
2152 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2155 $object->loadReminders(
'', $filteruserid,
false);
2159 if (count(
$object->reminders) > 0) {
2160 $checked =
'checked';
2161 $keys = array_keys(
$object->reminders);
2162 $firstreminderId = array_shift($keys);
2164 $actionCommReminder =
$object->reminders[$firstreminderId];
2168 $actionCommReminder->offsetvalue =
getDolGlobalInt(
'AGENDA_REMINDER_DEFAULT_OFFSET', 30);
2169 $actionCommReminder->offsetunit =
'i';
2170 $actionCommReminder->typeremind =
'email';
2177 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>';
2179 print
'<div class="reminderparameters" '.(empty($checked) ?
'style="display: none;"' :
'').
'>';
2183 print
'<table class="border centpercent">';
2186 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderTime").
'</td><td colspan="3">';
2187 print
'<input type="number" name="offsetvalue" class="width50" value="'.$actionCommReminder->offsetvalue.
'"> ';
2188 print $form->selectTypeDuration(
'offsetunit', $actionCommReminder->offsetunit, array(
'y',
'm'));
2192 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"ReminderType").
'</td><td colspan="3">';
2193 print $form->selectarray(
'selectremindertype', $TRemindTypes, $actionCommReminder->typeremind, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth200', 1);
2197 if ($actionCommReminder->typeremind ==
'browser') {
2198 $hide =
'style="display:none;"';
2203 print
'<tr '.$hide.
'><td class="titlefieldcreate nowrap">'.$langs->trans(
"EMailTemplates").
'</td><td colspan="3">';
2204 print $form->selectModelMail(
'actioncommsend',
'actioncomm_send', 1, 1);
2210 print
"\n".
'<script type="text/javascript">';
2211 print
'$(document).ready(function () {
2212 $("#addreminder").click(function(){
2214 $(".reminderparameters").show();
2216 $(".reminderparameters").hide();
2220 $("#selectremindertype").change(function(){
2221 var selected_option = $("#selectremindertype option:selected").val();
2222 if(selected_option == "email") {
2223 $("#select_actioncommsendmodel_mail").closest("tr").show();
2225 $("#select_actioncommsendmodel_mail").closest("tr").hide();
2230 print
'</script>'.
"\n";
2237 print $form->buttonsSaveCancel();
2246 if ($action ==
'clone') {
2247 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
GETPOST(
'id'), $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneEvent',
$object->label),
'confirm_clone', array(),
'yes', 1);
2251 $parameters = array();
2252 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2253 if (empty($reshook)) {
2254 $formconfirm .= $hookmanager->resPrint;
2255 } elseif ($reshook > 0) {
2256 $formconfirm = $hookmanager->resPrint;
2264 $linkback .=
'<a href="'.DOL_URL_ROOT.
'/comm/action/list.php?mode=show_list&restore_lastsearch_values=1">';
2265 $linkback .=
img_picto($langs->trans(
"BackToList"),
'object_calendarlist',
'class="pictoactionview pictofixedwidth"');
2266 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"BackToList").
'</span>';
2267 $linkback .=
'</a>';
2268 $linkback .=
'</li>';
2269 $linkback .=
'<li class="noborder litext">';
2271 $linkback .=
img_picto($langs->trans(
"ViewCal"),
'object_calendar',
'class="pictoactionview pictofixedwidth"');
2272 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewCal").
'</span>';
2273 $linkback .=
'</a>';
2274 $linkback .=
'</li>';
2275 $linkback .=
'<li class="noborder litext">';
2277 $linkback .=
img_picto($langs->trans(
"ViewWeek"),
'object_calendarweek',
'class="pictoactionview pictofixedwidth"');
2278 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewWeek").
'</span>';
2279 $linkback .=
'</a>';
2280 $linkback .=
'</li>';
2281 $linkback .=
'<li class="noborder litext">';
2283 $linkback .=
img_picto($langs->trans(
"ViewDay"),
'object_calendarday',
'class="pictoactionview pictofixedwidth"');
2284 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewDay").
'</span>';
2285 $linkback .=
'</a>';
2286 $linkback .=
'</li>';
2287 $linkback .=
'<li class="noborder litext">';
2289 $linkback .=
img_picto($langs->trans(
"ViewPerUser"),
'object_calendarperuser',
'class="pictoactionview pictofixedwidth"');
2290 $linkback .=
'<span class="hideonsmartphone">'.$langs->trans(
"ViewPerUser").
'</span>';
2291 $linkback .=
'</a>';
2294 $parameters = array();
2295 $reshook = $hookmanager->executeHooks(
'addCalendarView', $parameters,
$object, $action);
2296 if (empty($reshook)) {
2297 $linkback .= $hookmanager->resPrint;
2298 } elseif ($reshook > 1) {
2299 $linkback = $hookmanager->resPrint;
2304 $morehtmlref =
'<div class="refidno">';
2308 if (isModEnabled(
'project')) {
2309 $langs->load(
"projects");
2311 if ($usercancreate) {
2312 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
2313 if ($action !=
'classify') {
2314 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
2316 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
2318 if (!empty(
$object->fk_project)) {
2320 $proj->fetch(
$object->fk_project);
2321 $morehtmlref .= $proj->getNomUrl(1);
2323 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
2328 $morehtmlref .=
'</div>';
2331 dol_banner_tab(
$object,
'id', $linkback, ($user->socid ? 0 : 1),
'id',
'ref', $morehtmlref);
2333 print
'<div class="fichecenter">';
2334 print
'<div class="fichehalfleft">';
2336 print
'<div class="underbanner clearboth"></div>';
2339 print
'<table class="border tableforfield centpercent">';
2343 print
'<tr><td class="titlefield">'.$langs->trans(
"Type").
'</td><td>';
2344 $labeltoshow = $langs->trans(
"Action".
$object->type_code);
2346 $labeltoshow .=
' ('.$object->code.
')';
2348 print
$object->getTypePicto(
'pictofixedwidth paddingright', $labeltoshow);
2349 print $langs->trans(
"Action".
$object->type_code);
2354 print
'<tr><td class="titlefield">'.$langs->trans(
"EventOnFullDay").
'</td><td>'.
yn(
$object->fulldayevent ? 1 : 0, 3).
'</td></tr>';
2358 print
'<tr><td class="titlefield">'.$langs->trans(
"EventIntoASerie").
'</td><td>'.
dol_escape_htmltag(
$object->recurid).
'</td></tr>';
2367 print
'<tr><td>'.$langs->trans(
"DateActionStart").
'</td><td>';
2372 if (empty(
$object->fulldayevent)) {
2385 print
'<tr><td>'.$langs->trans(
"DateActionEnd").
'</td><td>';
2386 if (empty(
$object->fulldayevent)) {
2399 print
'<tr><td>'.$langs->trans(
"Location").
'</td><td>'.
$object->location.
'</td></tr>';
2403 print
'<tr><td class="nowrap">'.$langs->trans(
"ActionAssignedTo").
'</td><td>';
2404 $listofuserid = array();
2405 if (empty($donotclearsession)) {
2406 if (
$object->userownerid > 0) {
2407 $listofuserid[
$object->userownerid] = array(
2409 'transparency' =>
$object->transparency,
2410 'answer_status' =>
$object->userassigned[
$object->userownerid][
'answer_status'],
2411 'mandatory' =>
$object->userassigned[
$object->userownerid][
'mandatory']
2414 if (!empty(
$object->userassigned)) {
2416 $tmplist1 =
$object->userassigned;
2417 foreach ($tmplist1 as $key => $val) {
2418 if ($val[
'id'] && $val[
'id'] !=
$object->userownerid) {
2419 $listofuserid[$val[
'id']] = $val;
2423 $_SESSION[
'assignedtouser'] = json_encode($listofuserid);
2425 if (!empty($_SESSION[
'assignedtouser'])) {
2426 $listofuserid = json_decode($_SESSION[
'assignedtouser'],
true);
2430 $listofcontactid = array();
2431 $listofotherid = array();
2432 print
'<div class="assignedtouser">';
2433 print $form->select_dolusers_forevent(
'view',
'assignedtouser', 1,
'', 0,
'',
'', 0, 0, 0,
'', (
$object->datep !=
$object->datef) ? 1 : 0, $listofuserid, $listofcontactid, $listofotherid);
2443 print
' </td></tr>';
2446 if (isModEnabled(
'category')) {
2447 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2448 print $form->showCategories(
$object->id, Categorie::TYPE_ACTIONCOMM, 1);
2456 print
'<div class="fichehalfright">';
2458 print
'<div class="underbanner clearboth"></div>';
2459 print
'<table class="border tableforfield centpercent">';
2461 if (isModEnabled(
"societe")) {
2463 print
'<tr><td class="titlefield">'.$langs->trans(
"ActionOnCompany").
'</td>';
2464 print
'<td>'.(is_object(
$object->thirdparty) &&
$object->thirdparty->id ?
$object->thirdparty->getNomUrl(1) : (
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>'));
2465 if (is_object(
$object->thirdparty) &&
$object->thirdparty->id > 0 &&
$object->type_code ==
'AC_TEL') {
2467 print
"<br>".dol_print_phone(
$object->thirdparty->phone);
2473 print
'<tr><td>'.$langs->trans(
"ActionOnContact").
'</td>';
2476 if (!empty(
$object->socpeopleassigned)) {
2477 foreach (
$object->socpeopleassigned as $cid => $Tab) {
2479 $result = $contact->fetch($cid);
2486 print $contact->getNomUrl(1);
2487 if (
$object->type_code ==
'AC_TEL') {
2488 if (!empty($contact->phone_pro)) {
2489 print
'('.dol_print_phone($contact->phone_pro).
')';
2492 print
'<div class="paddingright"></div>';
2496 print
'<span class="opacitymedium">'.$langs->trans(
"None").
'</span>';
2503 print
'<tr><td class="nowrap" class="titlefield">' . $langs->trans(
"Priority") .
'</td><td>';
2510 if (!empty(
$object->fk_element) && !empty(
$object->elementtype) && !in_array(
$object->elementtype, array(
'societe',
'contact',
'project'))) {
2511 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
2512 print
'<tr><td>'.$langs->trans(
"LinkedObject").
'</td>';
2516 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectDeleted").
'</span>';
2524 if (!empty(
$object->email_msgid)) {
2525 print
'<tr><td>'.$langs->trans(
'MailTopic').
'</td>';
2526 print
'<td>'.dol_escape_htmltag(
$object->email_subject).
'</td></tr>';
2527 print
'<tr><td>'.$langs->trans(
'MailFrom').
'</td>';
2528 print
'<td>'.dol_escape_htmltag(
$object->email_from).
'</td></tr>';
2529 print
'<tr><td>'.$langs->trans(
'MailTo').
'</td>';
2530 print
'<td>'.dol_escape_htmltag(
$object->email_to).
'</td></tr>';
2531 if (!empty(
$object->email_tocc)) {
2532 print
'<tr><td>'.$langs->trans(
'MailCC').
'</td>';
2533 print
'<td>'.dol_escape_htmltag(
$object->email_tocc).
'</td></tr>';
2538 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td class="wordbreak sensiblehtmlcontent">';
2543 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2547 $filteruserid = $user->id;
2548 if ($user->hasRight(
'agenda',
'allactions',
'read')) {
2551 $object->loadReminders(
'', $filteruserid,
false);
2553 print
'<tr><td class="titlefieldcreate nowrap">'.$langs->trans(
"Reminders").
'</td><td>';
2555 if (count(
$object->reminders) > 0) {
2556 $tmpuserstatic =
new User($db);
2558 foreach (
$object->reminders as $actioncommreminderid => $actioncommreminder) {
2559 print $TRemindTypes[$actioncommreminder->typeremind][
'label'];
2560 if ($actioncommreminder->fk_user > 0) {
2561 $tmpuserstatic->fetch($actioncommreminder->fk_user);
2562 print
' ('.$tmpuserstatic->getNomUrl(0,
'', 0, 0, 16).
')';
2564 print
' - '.$actioncommreminder->offsetvalue.
' '.$TDurationTypes[$actioncommreminder->offsetunit];
2566 if ($actioncommreminder->status == $actioncommreminder::STATUS_TODO) {
2567 print
' - <span class="opacitymedium">';
2568 print $langs->trans(
"NotSent");
2570 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_DONE) {
2571 print
' - <span class="opacitymedium">';
2572 print $langs->trans(
"Done");
2574 } elseif ($actioncommreminder->status == $actioncommreminder::STATUS_ERROR) {
2575 print
' - <span class="opacitymedium">';
2576 print $form->textwithpicto($langs->trans(
"Error"), $actioncommreminder->lasterror);
2590 print
'<div class="clearboth"></div>';
2599 print
'<div class="tabsAction">';
2601 $parameters = array();
2602 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
2603 if (empty($reshook)) {
2604 if ($action !=
'edit') {
2605 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2606 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2607 print
'<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Modify").
'</a></div>';
2609 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Modify").
'</a></div>';
2612 if ($user->hasRight(
'agenda',
'allactions',
'create') ||
2613 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'create'))) {
2614 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>';
2616 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"ToClone").
'</a></div>';
2619 if ($user->hasRight(
'agenda',
'allactions',
'delete') ||
2620 ((
$object->authorid == $user->id ||
$object->userownerid == $user->id) && $user->hasRight(
'agenda',
'myactions',
'delete'))) {
2621 print
'<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?action=delete&token='.newToken().
'&id='.
$object->id.
'">'.$langs->trans(
"Delete").
'</a></div>';
2623 print
'<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotAllowed").
'">'.$langs->trans(
"Delete").
'</a></div>';
2630 if ($action !=
'edit') {
2632 print
'<div class="clearboth"></div><div class="fichecenter"><div class="fichehalfleft">';
2633 print
'<a name="builddoc"></a>';
2639 $filedir = $conf->agenda->multidir_output[$conf->entity].
'/'.
$object->id;
2640 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
2642 $genallowed = $user->hasRight(
'agenda',
'myactions',
'read');
2643 $delallowed = $user->hasRight(
'agenda',
'myactions',
'create');
2646 print $formfile->showdocuments(
'actions',
$object->id, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 0, 0,
'',
'',
'', $langs->getDefaultLang());
2648 print
'</div><div class="fichehalfright">';
2651 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...
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_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)
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_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.